{"source_code": "const e:array[0..9] of char=('R','G','B','Y','W','1','2','3','4','5');\nvar a:array[0..9] of longint;\nf:array['A'..'Z','1'..'5'] of boolean;\ni,n,s,t,max:longint;c,c1,c2:char;\nfunction pd(x:longint):boolean;\nvar i,j,t:longint;\nbegin\nt:=0;fillchar(a,sizeof(a),0);\nfor i:=0 to 4 do\n for j:=5 to 9 do\n if f[e[i],e[j]] then\n begin\n if (x and (1 shl i)>0) and (x and (1 shl j)=0) then a[i]:=a[i]+1;\n if (x and (1 shl i)=0) and (x and (1 shl j)>0) then a[j]:=a[j]+1;\n if (x and (1 shl i)=0) and (x and (1 shl j)=0) then t:=t+1;\n end;\nif t>1 then exit(false);\nfor i:=0 to 9 do\n if a[i]>1 then\n exit(false);\nexit(true);\nend;\nbegin\n//assign(input,'hanabi.in');reset(input);\n//assign(output,'hanabi.out');rewrite(output);\nreadln(n);max:=maxlongint;\nfor i:=1 to n do\n begin\n read(c1,c2);\n f[c1,c2]:=true;\n if i<>n then read(c);\n end;\nfor i:=0 to 1023 do\n if pd(i) then\n begin\n s:=0;t:=i;\n while t<>0 do\n begin\n s:=s+t mod 2;t:=t div 2;\n end;\n if s0\nthen writeln('NO')\nelse begin\nwriteln('YES');\nfor i:=1 to n-1 do write(x[i],' ');\nwriteln(x[n]);\n end;\nEnd.\n", "src_uid": "be82b8f209217875221ebe5de8675971"} {"source_code": "program zzz;\n\ntype int = longint;\n\nvar s:string; s1:string; max:int; maxs:string; i,k,j:int;\n\tc:boolean; now:int;\n\nbegin\n\treadln(S);\n\t\n\t\n\tmaxs:='-1';\n\tmax:=-1;\n\tfor k:=1 to length(s) do\n\t\tfor j:=1 to length(S)-i+1 do\n\t\t\tbegin\n\t\t\t\ts1:=copy(s,j,k);\n\t\t\t\t\n\t\t\t\t//writeln(s1);\n\t\t\t\t\n\t\t\t\tif s1 = '' then continue;\n\t\t\t\t\n\t\t\t\tc:=false;\n\t\t\t\tfor i:=1 to length(s1) do\n\t\t\t\t\tif (s1[i]<>'7') and (s1[i]<>'4') then c:=true;\n\t\t\t\t\n\t\t\t\tif c then continue;\n\t\t\t\t\n\t\t\t\t//writeln(s1);\n\t\t\t\t\n\t\t\t\tnow:=0;\n\t\t\t\tfor i:=1 to length(s) do\n\t\t\t\t\tif copy(s,i,length(s1)) = s1 then inc(now);\n\t\t\t\t\t\n\t\t\t//\twriteln(s1,' ',now,' ',max,' ',maxs);\n\t\t\t\t\t\n\t\t\t\tif now>max then\n\t\t\t\t\tbegin\n\t\t\t\t\t\tmax:=now;\n\t\t\t\t\t\tmaxs:=s1;\n\t\t\t\t\tend\n\t\t\t\telse if now = max then\t\n\t\t\t\t\tif maxs>s1 then begin\n\t\t\t\t\t\tmaxs:=s1;\n\t\t\t\t\t\tmax:=now;\n\t\t\t\t\tend;\n\t\t\tend;\n\t\t\t\n\twriteln(maxs);\nend.", "src_uid": "639b8b8d0dc42df46b139f0aeb3a7a0a"} {"source_code": "var n, x, i, kq: longint;\nbegin\n\treadln(n, x);\n\tfor i := 1 to n do\n\t\tif (x mod i = 0) and (x div i <= n) then\n\t\t\tinc(kq);\n\twriteln(kq);\nend.", "src_uid": "c4b139eadca94201596f1305b2f76496"} {"source_code": "begin\n write('25');\nend.", "src_uid": "dcaff75492eafaf61d598779d6202c9d"} {"source_code": "var n,m,i,h:longint;\n\nfunction nod(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 nod:=a+b;\nend;\n\nfunction nod2(a,b:longint):longint;\nvar ans:longint;\nbegin\nif a 0 do\n begin\n r := x mod 10 ;\n if (r <> 4) and (r <> 7) then exit(false);\n x := x div 10;\n end;\n exit(true) ;\n end;\nfunction dem(x : int64) : int64;\n var r : int64;\n begin\n result := 0;\n while x <> 0 do\n begin\n r := x mod 10;\n if (r = 4 ) or (r = 7) then inc(result);\n x := x div 10;\n end\n end;\nprocedure solve;\n begin\n if ktra(dem(n)) then writeln('YES') else writeln('NO');\n\n end;\nprocedure inkq;\n begin\n {close(fi);\n close(fo); }\n end;\nbegin\n enter;\n solve;\nend.", "src_uid": "33b73fd9e7f19894ea08e98b790d07f1"} {"source_code": " var\n l, r: integer;\n \n function foo(l, r: integer): integer;\n function IsCoolNum(N: integer): boolean;\n function Count(c: char; s: string): integer;\n var res: integer;\n begin\n for var i := 1 to s.Length do\n if s[i] = c then res += 1;\n result := res;\n end;\n begin\n var temp := N.ToString;\n for var i := 1 to temp.Length do\n if Count(temp[i], temp) > 1 then\n begin\n result := false;\n exit;\n end;\n result := true;\n end;\n var res: integer := -1;\n begin\n for var i := l to r do\n begin\n if IsCoolNum(i) then\n begin\n res := i;\n break;\n end;\n end;\n result := res;\n end;\n \n begin\n Readln(l, r);\n Writeln(foo(l, r));\n end.", "src_uid": "3041b1240e59341ad9ec9ac823e57dd7"} {"source_code": "var n,m,k,a,b:int64;\nfunction horizontal:int64;\n var x,y,t:int64;\n begin\n if k+1<=n then begin x:=n div (k+1); y:=m; end\n else begin x:=1;t:=k-(n-1);y:=m div (t+1); end;\n horizontal:=x*y;\nend;\nfunction vertical:int64;\n var x,y,t:int64;\n begin\n if k+1<=m then begin x:=n;y:=m div (k+1); end\n else begin t:=k-(m-1);x:=n div (t+1);y:=1; end;\n vertical:=x*y;\nend;\nbegin\nreadln(n,m,k);\nif (n+m)<(k+2) then begin writeln('-1'); halt; end;\na:=horizontal;\nb:=vertical;\nif a>b then writeln(a) else writeln(b);\nend.\n", "src_uid": "bb453bbe60769bcaea6a824c72120f73"} {"source_code": "var n,m,i,j,x,y:longint;\n a,l,b,c:array[1..100] of longint;\n\nfunction tim(x,y:longint):longint;\n begin\n IF x<=y then exit(n-y+x)\n else exit(x-y);\n end;\n\nbegin\nreadln(n,m);\nfor i:=1 to m do read(l[i]);\nfor i:=1 to n do c[i]:=i;\nfor i:=1 to m-1 do\n begin\n IF a[l[i]]<>0 then\n IF a[l[i]]<>tim(l[i+1],l[i]) then\n begin\n write(-1);\n exit;\n end;\n a[l[i]]:=tim(l[i+1],l[i]);\n end;\nfor i:=1 to n do inc(b[a[i]]);\nx:=0;\nfor i:=1 to n do\n begin\n IF b[i]>=2 then\n begin\n write(-1);\n exit;\n end;\n IF b[i]=0 then\n begin\n inc(x);\n c[x]:=i;\n end;\n end;\ny:=0;\nfor i:=1 to n do\n IF a[i]=0 then\n begin\n inc(y);\n a[i]:=c[y];\n end;\nfor i:=1 to n do write(a[i],' ');\nend.\n\n", "src_uid": "4a7c959ca279d0a9bd9bbf0ce88cf72b"} {"source_code": "var d1,d2,a,k,s,i:int64;\n\nbegin read(d1); read(d2);\n if (d2-d1=1) then begin\n write(d1,'99 ',d2,'00'); k:=k+1; end;\n if d2=d1 then begin write(d1, '00 ', d2, '01'); k:=k+1; end;\n if (d2=1) and (d1=9) then begin write(d1,'99 ',d2,'000'); k:=k+1; end;\n if k=0 then write('-1');\nend.", "src_uid": "3eff6f044c028146bea5f0dfd2870d23"} {"source_code": "var x, y, m, n:Int64;\nbegin\nreadln(x, y, m);\nif((x >= m) or (y >= m)) then writeln(0)\nelse begin\n if((x <= 0) and (y <= 0)) then writeln(-1)\n else begin \n if(x < 0) then begin\n n:= abs(x) div y;\n if((abs(x) mod y) > 0) then inc(n, 1);\n x:= x + y * n;\n end else if(y < 0) then begin\n n:= abs(y) div x;\n if((abs(y) mod x) > 0) then inc(n, 1);\n y:= y + x * n;\n end;\n while((x < m) and (y < m)) do begin\n inc(n, 1);\n if(x < y) then x:=x+y\n else y:=x+y;\n end;\n writeln(n);\n end;\nend;\nend.", "src_uid": "82026a3c3d9a6bda2e2ac6e14979d821"} {"source_code": " const eps=1e-10;\n besk=2002000000000000000; label 1,3,2,44;\n type mas=array[-100..1200000+1] of int64; int64=longint;\n integer=longint; zap=record p1,p2,p3:int64; end;\n zap1=^zap;\n var qq,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;\n kol1,kol2,kart1,kart2,vx,vy,ans,up,down,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,qqqq,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 invx,invy,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..1000000] of boolean;\n left,right,zpl,zmi,path,lx,rx,ly,ry,a2,a3,a4,dd1,dd2,predok,a1,b1,strok:array[-10000..1500000] of int64;\n ppole:array[-1000000..3000000] of char;\n stroka:array[-1000..1000000] of char;\n px,py,h1,h2,h,l1,l2,ot1,otmax,v:extended;\n 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,dd,ddinv,dnech,poschet,posnechet:array[-10..390000,-1..6] of int64;\n poss:int64;\n ch:char;\n ff,flagg1:boolean;\n numx,numy,xleft,xright,s,znach,z,nomer,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-10000..4000002] of int64;\n ddd: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]>a1[j] then srav:=true else srav:=false;\n\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\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\n\n end;\n\n\n function min (a,b:int64):int64;begin min:=b;if ab then max:=a; end;\n function min3(a,b,c:int64):int64; var ot:int64;\n begin ot:=a; if b0 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;\nend;\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\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\n end;\n\n end;\n\n end;\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\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]=x[invx[1]])and(xx<=x[invx[2]])and(yy>=y[invy[1]])and(yy<=y[invy[2]]);\n fl2:=(xx>=x[invx[3]])and(xx<=x[invx[4]])and(yy>=y[invy[3]])and(yy<=y[invy[4]]);\n fl3:=(xx>=x[invx[5]])and(xx<=x[invx[6]])and(yy>=y[invy[5]])and(yy<=y[invy[6]]);\n goodpoint:=fl1 and not fl2 and not fl3;\nend;\n\n\n begin\n\n {assign (input,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n\n for i:=1 to 6 do read(x[i],y[i]);\n for i:=1 to 6 do begin numx[i]:=i; numy[i]:=i; end;\n for i:=1 to 6 do for j:=1 to 5 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:=numx[j]; numx[j]:=numx[j+1]; numx[j+1]:=t;\n end;\n\n for i:=1 to 6 do for j:=1 to 5 do if y[j]>y[j+1] then\n begin\n t:=y[j]; y[j]:=y[j+1]; y[j+1]:=t;\n t:=numy[j]; numy[j]:=numy[j+1]; numy[j+1]:=t;\n end;\n\n for i:=1 to 6 do begin invx[numx[i]]:=i; invy[numy[i]]:=i; end;\n\n for i:=1 to 6 do for j:=1 to 6 do\n begin\n for ii:=-1 to 1 do for jj:=-1 to 1 do\n begin\n px:=x[i]+0.5*ii;py:=y[j]+0.5*jj;\n if goodpoint(px,py) then begin writeln('YES'); goto 1; end;\n\n end;\n\n end;\n writeln('NO');\n\n\n 1: close (output);\n end.\n\n", "src_uid": "05c90c1d75d76a522241af6bb6af7781"} {"source_code": "var\n\tn, c1, c2 : Int64;\n\ts : AnsiString;\n\n\tj, k, a, b, c, d, e, f, val, opt : Int64;\n\ti, g : Longint;\n\nbegin\n\tReadln(n, c1, c2);\n\tReadln(s);\n\n\ta := 0;\n\tb := 0;\n\n\tfor i := 1 to n do begin\n\t\tif s[i] = '1'\n\t\tthen\n\t\t\tinc(a)\n\t\telse\n\t\t\tinc(b);\n\tend;\n\n\topt := -1;\n\n\tfor g := 1 to a do begin\n\t\tc := n div g; // c je manja velicina grupe\n\t\te := n mod g; // e je broj nabudzenih grupa\n\n\t\td := g - e; // d je broj manjih grupa\n\n\t\tval := d * (c1 + c2 * (c - 1) * (c - 1));\n\t\tval := val + e * (c1 + c2 * c * c);\n\n\t\tif (opt = -1) or (val < opt) then\n\t\t\topt := val;\n\tend;\n\n\tWriteln(opt);\nend.", "src_uid": "78d013b01497053b8e321fe7b6ce3760"} {"source_code": "var x,y,z:int64;\nbegin\nreadln(x,y,z);\nwriteln((x*z+x*y+z*y)*4/round(sqrt(x*y*z)):0:0);\nend.", "src_uid": "c0a3290be3b87f3a232ec19d4639fefc"} {"source_code": "var\n n,i,p,minn:longint;\n k1,k2,j,ans,x,y,maxn,x1,x2,z3:int64;\n o,d1,d2:array[1..2,1..2]of int64;\n a:array[1..1000000]of int64;\nfunction max(x,y:int64):int64;\nbegin\n if x>y then exit(x) else exit(y);\nend;\nfunction min(x,y:int64):int64;\nbegin\n if x0 then begin\n z3:=1;\n o[1,1]:=0; o[1,2]:=1; o[2,1]:=1; o[2,2]:=1;\n qs(x);\n x1:=d1[1,2];\n x2:=d1[2,2];\n if x1<0 then begin\n x1:=x1+p; x2:=x2+p;\n end;\n if x20 then begin\n o[1,1]:=3; o[1,2]:=0; o[2,1]:=-1; o[2,2]:=1;\n qs(y);\n if z3 and 1=0 then z3:=z3+p;\n// ans:=trunc(z3*(ans-(minn+maxn)/2)+(minn+maxn)/2) mod p;\n ans:=ans*d1[1,1] mod p+(maxn+minn)*d1[2,1] mod p;\n end;\n writeln((ans mod p+p)mod p);\nend.\n", "src_uid": "b5dd2b94570973b3e312ae4b7a43284f"} {"source_code": "program z_630_j;\nvar n,q:int64;\nbegin\nreadln(n);\nq:=n div 2520;\nwriteln(q);\nend.", "src_uid": "8551308e5ff435e0fc507b89a912408a"} {"source_code": "var n,m,i,p,t,r,l:int64;data:boolean;\nfunction sum(x,y:int64):int64;\nbegin\nif x>=y then\nsum:=(x+y)*(x-y+1) div 2\nelse sum:=0;\nend;\nfunction Q(i:int64):BOOLEAN;\nVAR X,K,Y:INT64;\nBEGIN\nx:=i-2;\nk:=i;\ny:=n-p;\nif y=0 then inc(k,0)\nelse if yx then inc(k,y-x);\n\ny:=p-1;\nif y=0 then inc(k,0)\nelse if yx then inc(k,y-x);\nif k>m then Q:=FALSe\nelse q:=true;\nEND;\nbegin\nreadln(n,m,p);\ni:=1;\nL:=1;R:=m;\nwhile ( true) do begin\nif l>=R then begin\n t:=L;\n if t=1 then writeln(1) else\n if (Q(t+1)=true) then \n writeln(t+1)\n else if (Q(t)=true) then \n writeln(t)\n else writeln(t-1);\n break\n end\n else\nt:=(R+L)div 2;\nIF not (q(t)) then r:=t-1\n else l:=t+1;\nend;\nend.", "src_uid": "da9ddd00f46021e8ee9db4a8deed017c"} {"source_code": "{$R+ Q+ I+}\n{$apptype console}\nuses\n sysutils,math;\nvar\n s : string;\nbegin\n read(s);\n s[1] := upcase(s[1]);\n write(s);\nend.", "src_uid": "29e0fc0c5c0e136ac8e58011c91397e4"} {"source_code": "var\na,b:longint;\ns1,s2,s3,v1,v2,v3:longint;\nbegin\nreadln (a,b);\nif a=b then\n writeln (0)\nelse\n begin\n s1:=0; s2:=0; s3:=0;\n v1:=0; v2:=0; v3:=0;\n while a mod 2=0 do\n begin\n inc (s1);\n a:=a div 2;\n end;\n while a mod 3=0 do\n begin\n inc (s2);\n a:=a div 3;\n end;\n while a mod 5=0 do\n begin\n inc (s3);\n a:=a div 5;\n end;\n while b mod 2=0 do\n begin\n inc (v1);\n b:=b div 2;\n end;\n while b mod 3=0 do\n begin\n inc (v2);\n b:=b div 3;\n end;\n while b mod 5=0 do\n begin\n inc (v3);\n b:=b div 5;\n end;\n if a<>b then\n writeln (-1)\n else\n writeln (abs(s1-v1)+abs (s2-v2)+abs (s3-v3));\n end;\nend.", "src_uid": "75a97f4d85d50ea0e1af0d46f7565b49"} {"source_code": "program cf119e;\nconst\n eps=1e-8;\ntype\n dot=record\n x,y:double;\n end;\n dott=record\n x,y,z:double;\n end;\nvar\n n,i,hhh,j,m,p1,p2:longint;\n vt,vt2,vv:array[0..1000]of dott;\n tt:dott;\n v:array[0..1000]of dot;\n ot,oo,rt:dot;\n ll:array[0..1000]of double;\n a,b,c,aa,bb,cc,a1,b1,rr,c1,co,si:double;\nfunction dis(a,b:dot):double;\nbegin\n dis:=sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));\nend;\n\nfunction chaji(a,b,c,d:dot):double;\nbegin\n chaji:=(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 s1,s2:double;\nbegin\n s1:=chaji(a,c,a,b);\n s2:=chaji(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\n\n\nprocedure make_tri(a,b,c:dot);\nvar\n aa,bb,cc:double;\n e,d,f,g:dot;\nbegin\n f.x:=(a.x+b.x)/2;\n f.y:=(a.y+b.y)/2;\n d.x:=f.x-(b.y-a.y);\n d.y:=f.y+(b.x-a.x);\n\n g.x:=(c.x+b.x)/2;\n g.y:=(c.y+b.y)/2;\n e.x:=g.x-(c.y-b.y);\n e.y:=g.y+(c.x-b.x);\n\n oo:=jiao_dian(f,d,e,g);\n rr:=dis(oo,a);\n\nend;\n\nprocedure zuixiaoyuanfugai;\nvar\n di:double;\n k,i,j,u:longint;\nbegin\n oo.x:=0;oo.y:=0;\n rr:=0;\n for i:=1 to n do\n if dis(v[i],oo)>rr+eps then begin\n oo:=v[i];\n rr:=0;\n for j:=1 to i-1 do\n if dis(v[j],oo)>rr+eps then begin\n oo.x:=(v[i].x+v[j].x)/2;\n oo.y:=(v[i].y+v[j].y)/2;\n rr:=dis(oo,v[i]);\n for k:=1 to j-1 do\n if dis(oo,v[k])>rr+eps then begin\n make_tri(v[i],v[j],v[k]);\n end;\n end;\n end;\n writeln(rr:0:18);\n\nend;\n\n\nprocedure work;\nvar i,j,k:longint;\n d1,dd,d2:double;\nbegin\n d1:=sqrt(a*a+b*b+c*c);\n// d1:=1;\n for i:=1 to n do begin\n dd:=vt[i].x*a+vt[i].y*b+vt[i].z*c;\n dd:=dd/(sqrt(a*a+b*b+c*c));\n aa:=a*(dd/d1);bb:=b*(dd/d1);cc:=c*(dd/d1);\n\n vt[i].x:=vt[i].x-aa;\n vt[i].y:=vt[i].y-bb;\n vt[i].z:=vt[i].z-cc;\n end;\n\n//--------------------------------------------\n\n if (abs(b)1) then t:=m+n+y-3;\n if (x>1)and(y=1) then t:=2*m+n+x-4;\n if map[t,dx,dy] then break;\n if not map[t,0,0] then inc(kk);\n if kk=n+m-2 then break;\n map[t,dx,dy]:=true;\n map[t,0,0]:=true;\n k:=maxlongint;\n if dx=1 then k:=min(k,n-x)\n else k:=min(k,x-1);\n if dy=1 then k:=min(k,m-y)\n else k:=min(k,y-1);\n ans:=ans+k;\n x:=x+k*dx;\n y:=y+k*dy;\n if (y*dy=m)or(y*dy=-1) then dy:=dy*(-1);\n if (x*dx=n)or(x*dx=-1) then dx:=dx*(-1);\n until 1=0;\n if kk=n+m-2 then writeln(ans+1)\n else writeln(-1);\nend.", "src_uid": "8a59247013a9b1f34700f4bfc7d1831d"} {"source_code": "var a1,a2,a3,b1,b2,b3,n:int64;\nfunction min(x,y:longint):longint;\nbegin\n if xy then exit(x);\n exit(y);\nend;\nbegin\n readln(n);\n readln(a1,a2,a3);\n readln(b1,b2,b3);\n write(max(0,a1-b1-b3)+max(0,a2-b2-b1)+max(0,a3-b3-b2),' ');\n writeln(min(a1,b2)+min(a2,b3)+min(a3,b1));\nend.", "src_uid": "e6dc3bc64fc66b6127e2b32cacc06402"} {"source_code": "const\n fi='';\n fo='';\n maxn=2000100;\n maxc=1000000000;\ntype\n re=record\n x:int64;\n y:longint;\n end;\nvar\n f:array[1..2,0..maxn] of re;\n a:array[1..30] of longint;\n gt:array[0..20] of int64;\n last:array[1..2] of longint;\n sum,s:int64;\n dem:longint;\n n,k,first,lastt,cs,last1,last2:longint;\n luu:array[1..2,0..maxn] of re;\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;\nvar\n i:longint;\nbegin\n readln(n,k,s);\n for i:=1 to n do read(a[i]);\nend;\n{-------------------------}\nfunction min(a,b:longint):longint;\nbegin\n if a>b then exit(b) else exit(a);\nend;\n{-------------------------}\nfunction max(a,b:longint):longint;\nbegin\n if a>b then exit(a) else exit(b);\nend;\n{-------------------------}\nprocedure init;\nvar\n i:longint;\nbegin\n gt[0]:=1;\n for i:=1 to 19 do gt[i]:=gt[i-1]*i;\nend;\n{-------------------------}\nprocedure choose(x:longint);\nvar\n i:longint;\nbegin\n for i:=0 to 2 do\n begin\n if i=1 then\n begin\n sum:=sum+a[first+x];\n if x=lastt then\n begin\n inc(last[cs]);\n f[cs,last[cs]].x:=sum;\n f[cs,last[cs]].y:=dem;\n end\n else\n if x< lastt then\n choose(x+1);\n sum:=sum-a[first+x];\n end\n else\n if i=2 then\n begin\n if a[first+x] >= 19 then exit;\n if (dem>k) or (sum+gt[a[first+x]] >s) then exit;\n sum:=sum+gt[a[first+x]];\n dem:=dem+1;\n if x=lastt then\n begin\n inc(last[cs]);\n f[cs,last[cs]].x:=sum;\n f[cs,last[cs]].y:=dem;\n end\n else\n if xx) or ((f[cs,j].x=x) and (f[cs,j].y>y)) do dec(j);\n if i<=j then\n begin\n tmp:=f[cs,i];\n f[cs,i]:=f[cs,j];\n f[cs,j]:=tmp;\n inc(i); dec(j);\n end;\n until i>j;\n if l=1) and (f[1,i].x+f[2,c].x >s) do dec(c);\n while (c>=1) and (f[1,i].x+f[2,c].x=s) and (f[1,i].y+f[2,c].y >k) do dec(c);\n begin\n tmp:=search(c,f[1,i].x);\n res:=res+max(0,c-tmp+1);\n end;\n if c=0 then break;\n end;\n writeln(res);\n\nend;\n{-------------------------}\nBEGIN\n openfiles;\n init;\n nhap;\n xuly;\n closefiles;\nEND.\n\n", "src_uid": "2821a11066dffc7e8f6a60a8751cea37"} {"source_code": "var\ndp:array[ -1000..1000, -1000..1000 ] of longint;\ni,j,x,y,d,n,dist,k:longint;\na, b:array[1..1000] of longint;\ngood:boolean;\nbegin\n {\nassign(input, 'input.txt'); reset(input);\nassign(output,'output.txt'); rewrite(output);\n } \nreadln(x, y, n, d);\n//writeln(x,' ', y,' ', n, ' ', d);\n\nfor i:=1 to n do\nreadln(a[i], b[i]);\n{\nfor dist:=d + 1 to 500 do\n for i:=-dist to dist do\n begin\n j:=dist - abs(i);\n dp[i][j]:=1;\n j:=-(dist - abs(i));\n dp[i][j]:=1;\n end;\n }\n\n for i:=-900 to 900 do\n for j:=-900 to 900 do\n //if (abs(i) + abs(j) > d) then dp[i][j]:=-1 else dp[i][j]:=1;\n if (i * i + j*j > d*d) then dp[i][j]:=1 else dp[i][j]:=0;\n\n\n for i:=400 downto -400 do\n for j:=400 downto -400 do\n begin\n good:=false;\n for k:=1 to n do\n if dp[i + a[k]][j+b[k]] = -1 then good:=true;\n if (dp[i][j] = 0) then\n if (good) then dp[i][j]:=1\n else dp[i][j]:=-1;\n end;\n // writeln('d = ',d);\n {\nfor dist:=400+1 downto 0 do\n for i:=-dist to dist do\n begin\n good:=false;\n j:=dist - abs(i);\n for k:=1 to n do\n if dp[i + a[k]][j+b[k]] = -1 then good:=true;\n if (dp[i][j] = 0) then\n if (good) then dp[i][j]:=1\n else dp[i][j]:=-1;\n\n // if (i = 0 ) and (j = 0) then writeln('rez = ', dp[0][0]);\n good:=false;\n j:=-(dist - abs(i));\n for k:=1 to n do\n if dp[i + a[k]][j+b[k]] = -1 then good:=true;\n if (dp[i][j] = 0) then\n if (good) then dp[i][j]:=1\n else dp[i][j]:=-1;\n // if (i = 0 ) and (j = 0) then writeln('rez = ', dp[0][0]);\n\n end;\n }\n { for i:=0 to 5 do\n begin\n for j:=0 to 5 do\n if (dp[i][j] >= 0) then write(' ', dp[i][j],' ') else write(dp[i][j],' ');\n writeln;\n end;\n }\n // writeln('last = ', dp[21][90]);\n if (dp[x][y] = 1) then write('Anton')\n else write('Dasha');\nend.\n", "src_uid": "645a6ca9a8dda6946c2cc055a4beb08f"} {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, i: integer;\n a: array[1..100]of integer;\nbegin\n readln(n);\n for i := 1 to n do\n read(a[i]);\n if(n = 1)then\n if(a[n] = 0)then\n writeln('UP')\n else if(a[n] = 15)then\n writeln('DOWN')\n else begin\n writeln(-1);\n halt(0);\n end\n else if(a[n] > a[n - 1])and(a[n] <> 15)then\n writeln('UP')\n else if(a[n] > a[n - 1])and(a[n] = 15)then\n writeln('DOWN')\n else if(a[n] < a[n - 1])and(a[n] <> 0)then\n writeln('DOWN')\n else\n writeln('UP');\n readln;\n readln;\nend.\n\n ", "src_uid": "8330d9fea8d50a79741507b878da0a75"} {"source_code": "const oo=1000000007;\nvar\n p:array[0..2000000]of int64;\n i,j,n:longint;\n ans:int64;\n\nfunction exgcd(a:int64):longint;\nvar\n temp:longint;\nbegin\n if a=1 then exit(1)\n else exit(exgcd((oo div a+1)*a-oo)*(oo div a+1) mod oo);\nend;\n\nbegin\n readln(n);\n if n=1 then begin writeln(1); exit; end;\n p[1]:=1;\n for i:=2 to 2*n do\n p[i]:=p[i-1]*i mod oo;\n ans:=p[n*2-1]*exgcd(p[n]) mod oo*exgcd(p[n-1]) mod oo;\n ans:=ans*2-n+oo;\n writeln(ans mod oo);\nend.\n", "src_uid": "13a9ffe5acaa79d97df88a069fc520b9"} {"source_code": "var n,i,j,k,a,b,c:longint; s,st:string;\nm:array[1..1000] of longint;\nbegin\n //assign(input,'baitap.inp');\n //assign(output,'baitap.out');\n //reset(input);\n //rewrite(output);\n read(a,b);\n while a<=b do begin\n a:=a*3;\n b:=b*2;\n k:=k+1;\n end;\n write(k);\n //close(input);\n //close(output);\nend.\n", "src_uid": "a1583b07a9d093e887f73cc5c29e444a"} {"source_code": "var\n a,k,n,o,i:longint;\nbegin\n o:=0;\n readln(n,k);\n for i:=1 to n do\n begin\n read(a);\n if (a>o) and (k mod a=0) then o:=a;\n end;\n writeln(k div o);\nend.", "src_uid": "80520be9916045aca3a7de7bc925af1f"} {"source_code": "var ok:boolean;\n i,j,k,n:longint;\n a,b:array[0..1001] of longint;\n\n begin\n read(n);\n for i:=1 to n do\n read(a[i]);\n\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 a[0]:=a[i];\n a[i]:=a[j];\n a[j]:=a[0];\n end;\n\n for i:=1 to n do\n begin\n ok:=true;\n for j:=1 to k do\n if (b[j]<=a[i]) then begin\n inc(b[j]);\n ok:=false;\n break;\n end;\n\n if ok then begin\n inc(k);\n b[k]:=1;\n end;\n end;\n\n writeln(k);\n end.\n", "src_uid": "7c710ae68f27f140e7e03564492f7214"} {"source_code": "Program Startuem;\nvar a,n,b,ch,i,kol:longint;\n k:array[1..100]of longint;\n\nbegin\nread(n);\nfor i:=1 to n do\n begin\n read(ch);\n inc(k[ch]);\n if k[ch]=1 then inc(kol);\n if (ch=a) or (a=0) then \n a:=ch else\n b:=ch;\n end;\nif (kol=2) and (k[a]=n div 2) then\n begin\n writeln('YES');\n write(a, ' ', b);\n end else\n write('NO');\n\n\nend.\n", "src_uid": "2860b4fb22402ea9574c2f9e403d63d8"} {"source_code": "uses math;\nvar\n i:longint;n,m:int64;\n a:array[0..16]of int64;\n\nfunction dfs(n,k:int64):int64;\nvar\n t:int64;\nbegin\n t:=k*(n div a[k]);\n n:=n mod a[k];\n if n=0 then exit(t);\n exit(t+min(k+dfs(a[k]-n,k-1),dfs(n,k-1)));\nend;\n\nbegin\n readln(n);\n for i:=1 to 16 do a[i]:=a[i-1]*10+1;\n writeln(dfs(n,16));\nend.\n", "src_uid": "1b17a7b3b41077843ee1d6e0607720d6"} {"source_code": "var a,b,r:word;\nbegin\n read(a,b,r);\n if(a<2*r)or(b<2*r)then write('Second')\n else write('First')\nend.", "src_uid": "90b9ef939a13cf29715bc5bce26c9896"} {"source_code": "program monstr;\nuses math;\nvar a,b,c,d,i: longint;\nbegin\nread(b,a);\nread(d,c);\nif a = c then\nbegin\nwrite(a);\nexit;\nend;\nfor i:=max(a,c) to 1000000 do\nbegin\nif ((i - a) mod b = 0) and ((i - c) mod d = 0) then\nbegin\nwrite(i);\nexit;\nend;\nend;\nwrite(-1);\nend.", "src_uid": "158cb12d45f4ee3368b94b2b622693e7"} {"source_code": "uses math;\nconst\n tfi = '';\n tfo = '';\ndx:array[1..5] of real = (\n-3.601321235851749,\n0.466045194906253,\n10.411264148588986,\n12.490381056766580,3.830127018922193);\ndy:array[1..5] of real = (\n10.057331467373021,\n19.192786043799030,\n18.147501411122495,\n8.366025403784439,3.366025403784439);\nnmax = 101;\nvar\n fi,fo:text;\n n,m,top:longint;\n sx,sy:array[0..nmax*5] of real;\n res:array[0..nmax,0..5] of longint;\nprocedure nhap;\nvar i,j,u,v:longint;\nbegin\n read(fi,n);\n top:=5;\n for i:=1 to 5 do\n begin\n sx[i]:=dx[i]-dx[1];\n sy[i]:=dy[i]-dy[1];\n res[1][i]:=i;\n end;\nend;\nprocedure xuly;\nvar i,j,u,v:longint;\nbegin\n if n>=2 then\n begin\n res[2][1]:=3;\n for i:=2 to 5 do\n begin\n inc(top);\n res[2][i]:=top;\n sx[top]:=sx[res[2][1]]+(dx[i]-dx[1]);\n sy[top]:=sy[res[2][1]]+(dy[i]-dy[1]);\n end;\n for j:=3 to n do\n begin\n res[j][1]:=res[j-1][1]+4;\n for i:=2 to 5 do\n begin\n inc(top);\n res[j][i]:=top;\n sx[top]:=sx[res[j][1]]+(dx[i]-dx[1]);\n sy[top]:=sy[res[j][1]]+(dy[i]-dy[1]);\n end;\n end;\n end;\n writeln(fo,top);\n for i:=1 to top do\n writeln(fo,sx[i]:0:15,' ',sy[i]:0:15);\n for i:=1 to n do\n begin\n for j:=1 to 5 do\n write(fo,res[i][j],' ');\n writeln(fo);\n end;\n write(fo,1,' ',3,' ');\n for i:=2 to n do\n write(fo,res[i][3],' ');\n for i:=n downto 1 do\n write(fo,res[i][5],' ',res[i][2],' ',res[i][4],' ',res[i][1],' ');\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", "src_uid": "db263b866e93e3a97731e11102923902"} {"source_code": "USES MATH;\n\n{$COPERATORS ON}\n\nVAR i,j,k,ans : integer;\n a : array [1..4] of integer;\n\nFunction f(a,b,c : integer) : shortint;\nBegin\n if (a < b+c) and (b < a+c) and (c < a+b) then\n f := 1\n else if (a = b+c) or (b = a+c) or (c = a+b) then\n f := 0\n else\n f := -1\nEnd;\n\nBEGIN\n for i := 1 to 4 do\n read(a[i]);\n \n ans := -1;\n for i := 1 to 2 do\n for j := i+1 to 3 do\n for k := j+1 to 4 do\n ans := max(ans,f(a[i],a[j],a[k]));\n \n if ans > 0 then\n writeln('TRIANGLE')\n else if ans = 0 then\n writeln('SEGMENT')\n else\n writeln('IMPOSSIBLE')\nEND.", "src_uid": "8f5df9a41e6e100aa65b9fc1d26e447a"} {"source_code": "program VKCUP_C;\n\nvar s:string;\n\tp:array[1..200]of longint;\n\tf:array[0..7,0..15,1..105]of int64;\n\ti,j,k,r,ll:longint;\n\tans:int64;\n\nfunction Trans(a,b:longint):longint;\nbegin\n\tcase a of\n\t\t0: case b of\n\t\t\t0: exit(2);\n\t\t\t1: exit(4);\n\t\tend;\n\t\t1: case b of\n\t\t\t0: exit(1);\n\t\t\t1: exit(3);\n\t\tend;\n\tend;\nend;\n\nfunction OK(s0,V:longint):boolean;\nvar V0:longint;\nbegin\n if (s0=5)or(s0=6)or(s0=7)or(s0=1)or(s0=9) then exit(V = 4);\n if s0=4 then exit(V = 2);\n if s0=13 then exit(V = 3);\n V0:=Trans((s0 shr 2)and 1,(s0 shr 1)and 1);\n if V0=4 then V0:=1;\n exit(V=V0);\nend;\n\nbegin\n\treadln(s);\n\tll:=length(s);\n\tans:=0;\n\tif ll=3 then begin\n\t\twriteln(1);\n\t\thalt;\n\tend;\n\ts:=s+s[1];\n\tfor i:=1 to ll do p[i]:=trans(ord(s[i])-ord('A'),ord(s[i+1])-ord('A'));\n\t\n\tfor i:=0 to 15 do\n\t\tif OK(i,p[2]) then f[i shr 1,i,4]:=1;\n\tfor k:=0 to 7 do\n\t\tfor i:=4 to ll do\n\t\t\tfor j:=0 to 15 do\n\t\t\t\tfor r:=0 to 1 do\n\t\t\t\t\tif OK(((j and 7)shl 1)+r,p[i-1]) then\n\t\t\t\t\t\tinc(f[k,((j and 7)shl 1)+r,i+1],f[k,j,i]);\n\tfor k:=0 to 7 do\n\t\tfor j:=0 to 15 do\n\t\t\tif OK(((j and 7)shl 1)+(k shr 2),p[ll-1])\n\t\t\tand OK(((j and 3)shl 2)+(k shr 1),p[ll])\n\t\t\tand OK(((j and 1)shl 3)+k,p[1]) then inc(ans,f[k,j,ll]);\t\n\twriteln(ans);\nend.\n", "src_uid": "ad27d991516054ea473b384bb2563b38"} {"source_code": "type arr=array[1..4] of longint;\n\nvar n,i,ans,ansc,x,j:longint;\n b,c:Array[1..10] of longint;\n a:Array[1..10,1..4] of longint;\n\nFunction Check(x:longint):boolean;\nvar i:longint;\n o:arr;\n flag:array[0..9] of boolean;\n\nFunction CheckBulls(q:arr;x:longint):boolean;\nvar anso,i:longint;\nbegin\n anso:=0;\n for i:=1 to 4 do\n if a[x,i]=q[i] then inc(anso);\n if anso=b[x] then checkbulls:=true else checkbulls:=false;\n end;\n\nFunction CheckCows(q:arr;x:longint):boolean;\nvar anso,i,j:longint;\nbegin\n anso:=0;\n for i:=1 to 4 do\n for j:=1 to 4 do\n if (i<>j)and(a[x,i]=q[j]) then inc(anso);\n if anso=c[x] then checkcows:=true else checkcows:=false;\n end;\n\nbegin\n fillchar(flag,sizeof(flag),false);\n for i:=1 to 4 do begin\n o[i]:=x mod 10;\n if flag[o[i]] then begin\n check:=false;\n exit;\n end;\n flag[o[i]]:=true;\n x:=x div 10;\n end;\n for i:=1 to n do\n if (not CheckBulls(o,i))or(not CheckCows(o,i)) then begin\n check:=false;\n exit;\n end;\n check:=true;\n end;\n\nBegin\n //assign(input,'input.txt');assign(output,'output.txt');\n //reset(input);rewrite(output);\n readln(n);\n ans:=0;\n for i:=1 to n do begin\n readln(x,b[i],c[i]);\n for j:=1 to 4 do begin\n a[i,j]:=x mod 10;\n x:=x div 10;\n end;\n end;\n for i:=123 to 9876 do\n if check(i) then begin\n ansc:=i;\n inc(ans);\n end;\n\n\n if ans=1 then begin\n if ansc div 1000=0 then write('0');\n writeln(ansc) end else\n if ans>1 then writeln('Need more data') else writeln('Incorrect data');\n end.\n\n\n", "src_uid": "142e5f2f08724e53c234fc2379216b4c"} {"source_code": "Var a:Array [1..6] of LongInt;\n i,s,x,y,z,x1,y1,z1:LongInt;\nBegin\n // ReSet (input,'input.txt');\n // ReWrite (output,'output.txt');\n Readln (x,y,z);\n Readln (x1,y1,z1);\n For I:=1 to 6 do\n Read (a[i]);\n s:=0;\n If z>z1 then Inc (s,a[4])\n else If z<0 then Inc (s,a[3]);\n If x>x1 then Inc (s,a[6])\n else If x<0 then Inc (s,a[5]);\n If y>y1 then Inc (s,a[2])\n else If y<0 then Inc (s,a[1]);\n Writeln (s);\nEnd.", "src_uid": "c7889a8f64c57cf7be4df870f68f749e"} {"source_code": "uses math;\nconst\n tfi = '';//603B.inp';\n tfo = '';//603B.out';\n base = 1000000007;\nvar\n fi,fo : text;\n n,k,kq,top,count,res,ii : longint;\n num,low,st,d,p : array[0..1000000] of longint;\n free : array[0..1000000] of boolean;\nprocedure input;\n var i : longint;\n begin\n readln(fi,n,k);\n end;\nprocedure sang;\n var i,j : longint;\n begin\n for i:=1 to n do\n begin\n j:=i;\n while j<=n-1 do\n begin\n p[j]:=(p[j]+int64(d[i])*i mod base) mod base;\n j:=i+j;\n end;\n end;\n end;\nprocedure dfs(u : longint);\n var v : longint;\n begin\n inc(count);\n low[u]:=count;num[u]:=count;\n inc(top);st[top]:=u;\n v:=int64(u)*k mod n;\n if not free[v] then\n if num[v]=0 then\n begin\n dfs(v);\n low[u]:=min(low[u],low[v]);\n end\n else low[u]:=min(low[u],num[v]);\n if low[u]=num[u] then\n begin\n kq:=0;\n repeat\n v:=st[top];\n free[v]:=true;\n inc(kq);dec(top);\n until v=u;\n inc(d[kq]);\n end;\n end;\nprocedure work;\n var i,j,sum : longint;\n begin\n res:=1;\n for i:=0 to n-1 do\n if num[i]=0 then dfs(i);\n sang;\n for i:=1 to n do\n if d[i]>0 then\n for j:=1 to d[i] do\n res:=int64(res)*p[i] mod base;\n writeln(fo,res);\n end;\nbegin\n assign(fi,tfi);reset(fi);\n assign(fo,tfo);rewrite(fo);\n input;\n if k<>0 then work\n else\n begin\n res:=1;\n for ii:=1 to n-1 do res:=int64(res)*n mod base;\n writeln(fo,res);\n end;\n close(fi);close(fo);\nend.\n", "src_uid": "580bf65af24fb7f08250ddbc4ca67e0e"} {"source_code": "var ans,l1,l2,l3,l4,l5,l6,i:longint;\n begin\n read(l1,l2,l3,l4,l5,l6);\n writeln(sqr(l1+l2+l3)-sqr(l1)-sqr(l3)-sqr(l5));\n end.\n", "src_uid": "382475475427f0e76c6b4ac6e7a02e21"} {"source_code": "var a,b,c,d,i,yn,ym,ans:int64;a1:array[0..2000005]of int64;\nfunction max(x,y:int64):int64;\nbegin\n if x>y then exit(x) else exit(y);\nend;\nfunction min(x,y:int64):int64;\nbegin\n if x=c do\n begin\n yn:=max(i-b,b);\n ym:=max(min(i-a,c),yn-1);\n a1[i]:=a1[i+1]+ym-yn+1;\n if i<=d then ans:=ans+a1[i+1];\n dec(i);\n end;\n writeln(ans);\nend.\n", "src_uid": "4f92791b9ec658829f667fcea1faee01"} {"source_code": "Program NonSquareEquation;\nvar\nn : int64;\nakar, idxbawah, sx, temp, x: int64;\nIsFound : boolean;\nfunction SumDigit (n : int64) : int64;\nvar\n S : string;\n TempInt, hasil : int64;\n k : longint;\n begin\n str(n,S);\n hasil := 0;\n for k := 1 to length(S) do\n begin\n val(S[k],TempInt);\n hasil := hasil + TempInt;\n end;\n SumDigit := hasil;\n end;\nbegin\nreadln(n);\nakar := trunc(sqrt(n));\nif akar < 100 then idxbawah := 1\n else idxbawah := akar - 100;\n IsFound := false;\n while (idxbawah <= akar) do\n begin\n sx := SumDigit(idxbawah);\n temp := idxbawah * idxbawah + sx * idxbawah - n;\n if temp = 0 then\n begin\n x := idxbawah;\n IsFound := true;\n break;\n end;\n inc(idxbawah);\n end;\n if IsFound then\n begin\n writeln(x);\n end else writeln('-1');\nend.", "src_uid": "e1070ad4383f27399d31b8d0e87def59"} {"source_code": "Var\n k, n: Int64;\n\nBegin\n Read(n, k);\n Write(min(k - 1, n - k) + (n - 1) + 2*(n - 1) + 3)\nEnd.", "src_uid": "24b02afe8d86314ec5f75a00c72af514"} {"source_code": "const fi ='c.INP';\n fo ='c.OUT';\nvar n: longint;\n s,kq: string;\n a: array[0..101] of longint;\n\nprocedure main;\nvar i,sum,v: longint;\nbegin\n for i:=1 to n do a[i]:= a[i-1] + ord(s[i])-48;\n\n while (n>1) and (s[n]='0') do\n begin\n delete(s,n,1);\n n:=n-1;\n end;\n if (n=1) and (a[n]=0) then\n begin\n kq:= 'YES';\n exit;\n end;\n\n for i:=1 to n do a[i]:= a[i-1] + ord(s[i])-48;\n\n v:= 0;\n for sum:=0 to a[n]-1 do\n begin\n v:=0;\n for i:=1 to n do\n if a[i]-a[v]=sum then v:= i else\n if a[i]-a[v]>sum then break;\n if v=n then\n begin\n kq:= 'YES';\n exit;\n end;\n end;\n kq:= 'NO';\nend;\n\nbegin\n readln(N);\n read(s);\n main;\n write(kq);\nend.\n\n\n", "src_uid": "410296a01b97a0a39b6683569c84d56c"} {"source_code": "var i:longint;t1,t2,m,h1,a1,x1,y1,h2,a2,x2,y2,x,xx,y,yy:int64;\na,b:array[0..4000000]of int64;\nbegin\n//assign(input,'mkhqw.in');reset(input);\n//assign(output,'mkhqw.out');rewrite(output);\nreadln(m);\nreadln(h1,a1);\nreadln(x1,y1);\nreadln(h2,a2);\nreadln(x2,y2);\nfor i:=1 to m*3 do\n begin\n if h1=a1 then\n begin\n inc(t1);\n a[t1]:=i-1;\n end;\n if h2=a2 then\n begin\n inc(t2);\n b[t2]:=i-1;\n end;\n if(h1=a1)and(h2=a2)then\n begin\n write(i-1);\n close(input);close(output);halt;\n end;\n h1:=(h1*x1+y1)mod m;\n h2:=(h2*x2+y2)mod m;\n end;\nif(t1<=0)or(t2<=0)then\n begin\n write(-1);\n close(input);close(output);halt;\n end;\nif(t1=1)or(t2=1)then\n begin\n write(-1);\n close(input);close(output);halt;\n end;\nx:=a[1];y:=b[1];\nxx:=a[2]-a[1];yy:=b[2]-b[1];\nfor i:=1 to m*10 do\n if(x+xx*i-y)mod yy=0 then\n begin\n write(x+xx*i);\n close(input);close(output);halt;\n end;\nwrite(-1);\nclose(input);close(output);\nend.\n", "src_uid": "7225266f663699ff7e16b726cadfe9ee"} {"source_code": "var n,i,j:longint;\n t:array[1..100] of longint;\n begin\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(t[i]);\n if t[1]>15 then\n begin\n writeln(15);\n halt;\n end;\n if (n=1) then\n begin\n writeln(t[1]+15);\n halt;\n end;\n n:=n+1;\n t[n]:=90;\n\n for i:=1 to n-1 do\n begin\n if (t[i+1]-t[i])>15 then\n begin\n j:=t[i]+15;\n break;\n end\n else\n j:=90;\n end;\n writeln(j);\n{ close(input);\n close(output); }\nend.\n", "src_uid": "5031b15e220f0ff6cc1dd3731ecdbf27"} {"source_code": "const fin='';\n fout='';\nvar f,g:text;\n i,n,k,p:longint;\n s:int64;\n\nfunction xl(x:int64):int64;\nvar i,p,y:int64;\nbegin\n y:=x;\n repeat\n p:=y mod 10;\n x:=x*10+p;\n y:=y div 10;\n until y=0;\n exit(x);\nend;\n\nbegin\n assign(f,fin);reset(f);\n assign(g,fout);rewrite(g);\n read(f,k,p);\n for i:=1 to k do\n begin\n s:=(s+xl(i) mod p)mod p;\n end;\n write(g,s);\n close(f);\n close(g);\nend.\n", "src_uid": "00e90909a77ce9e22bb7cbf1285b0609"} {"source_code": "var l,r,x,y,k: int64;\n i: longint;\n\nBEGIN\n read(l,r,x,y,k);\n if r=g1)and(s1<=g2)and(s2>=g1)and(s2<=g2) then\n begin WriteLn(i); exit; end;\n end;\n WriteLn(0);\nend.", "src_uid": "e595a1d0c0e4bbcc99454d3148b4557b"} {"source_code": "var n,i,j,k:longint;\n b,jc:array[0..4002] of int64;\n p:int64;\n ss:array[0..4002,0..4002] of int64;\nfunction s(ii,jj:longint):int64;\nbegin\n if ii=jj then exit(1);\n if ss[ii,jj]<>0 then exit(ss[ii,jj]);\n if (ii>=1) and (jj>=1) then ss[ii,jj]:=(s(ii-1,jj-1)+jj*s(ii-1,jj)) mod 1000000007;\n exit(ss[ii,jj]);\nend;\n\nbegin\n readln(n);\n b[0]:=1;\n for i:=1 to 4002 do\n begin\n b[i]:=1;\n for k:=2 to i do\n b[i]:=b[i]+s(i,k);\n b[i]:=b[i] mod 1000000007;\n end;\n writeln((b[n+1]-b[n]+1000000007) mod 1000000007);\nend.", "src_uid": "aa2c3e94a44053a0d86f61da06681023"} {"source_code": "Var a,b,c,a1,b1,c1:array[1..100000] of longint;\n i,j,k,m,l,o,p,n:longint;\n ans:extended;\n Begin\n read(n,m);\n if n+m=2 then write('1.0') else write((1+(n-1)*(m-1)/(n*m-1))/n:0:7);\n\n End.", "src_uid": "0b9ce20c36e53d4702869660cbb53317"} {"source_code": "var\n n,k,i,j,m,max,ans,c : longint;\n a : array[1..200001] of longint;\n b : array[1..20,1..200001] of longint;\nbegin\n readln(n,k);\n for i := 1 to n do\n begin\n read(a[i]);\n if (a[i] > max) then\n max := a[i];\n inc(b[1,a[i]]);\n j := 1;\n while (a[i] > 1) do\n begin\n a[i] := a[i] div 2;\n inc(j);\n inc(b[j,a[i]]);\n end;\n end;\n ans := 1000000000;\n for i := 1 to max do\n begin\n m := 0;\n c := 0;\n for j := 1 to 20 do\n begin\n m := m+b[j,i];\n c := c+(b[j,i])*(j-1);\n if (m > k) then\n begin\n c := c-(j-1)*(m-k);\n m := k;\n end;\n if (m = k) then\n begin\n if (ans > c) then\n ans := c;\n end;\n end;\n end;\n writeln(ans);\nend.", "src_uid": "ed1a2ae733121af6486568e528fe2d84"} {"source_code": "var b,i,k,l:int64;\nbegin\nread (b);\nk:=0;\nl:=round(sqrt(b));\nfor i:=1 to l do begin\nif b mod i=0 then inc(k);\nend;\nk:=k*2;\nif l*l=b then k:=k-1;\nif b=1 then write ('1') else write (k);\nend.", "src_uid": "7fc9e7d7e25ab97d8ebc10ed8ae38fd1"} {"source_code": "const p=1000000007;\nvar f:array[0..1000000]of int64;\n x,b,a,n,i:longint;\n aa,bb:char;\n r:int64;\nfunction BinPow(a,n:int64):int64;\nvar b:int64;\nbegin\n if n=0\n then BinPow:=1\n else\n if odd (n)\n then BinPow:=((BinPow(a,n-1)mod p)*a) mod p\n else begin\n b:=BinPow(a,n div 2)mod p;\n BinPow:=(b*b)mod p;\n end;\nend;\nfunction Good(x:int64):boolean;\nvar i:longint;\n s:string;\nbegin\n while x<>0 do\n begin\n if (x mod 10 <>b)and(x mod 10<>a)\n then begin\n Good:=false;\n exit;\n end;\n x:=x div 10;\n end;\n good:=true;\nend;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n Readln(a,b,n);\n f[1]:=1;\n f[0]:=1;\n for i:=2 to n do\n begin\n f[i]:=(f[i-1]*i) mod p;\n end;\n aa:=chr(a+ord('0'));\n bb:=chr(b+ord('0'));\n r:=0;\n for x:=0 to n do\n begin\n if good(x*a+b*(n-x))\n then r:=(r+f[n]*BinPow((f[n - x]*f[x]mod p),p-2)mod p)mod p;\n end;\n writeln(r);\nend.\n", "src_uid": "d3e3da5b6ba37c8ac5f22b18c140ce81"} {"source_code": "var n,m,kol,ii,tt:longint;\n pp:boolean;\nprocedure fun1;\nbegin\n if (n>=2) and (m>=2) then\n begin\n n:=n-2;\n m:=m-2;\n pp:=true;\n end else\n if (n>=1) and (m>=12) then\n begin\n n:=n-1;\n m:=m-12;\n pp:=true;\n end else\n if (m>=22) then\n begin\n m:=m-22;\n pp:=true;\n end else\n pp:=false;\nend;\n\nprocedure fun2;\nvar i,j:longint;\nbegin\n for i:= 22 downto 1 do\n begin\n if (m>=i) and ((220-10*i) mod 100=0) and ((220-10*i) div 100<=n)then\n begin\n m:=m-i;\n n:=n-(220-10*i) div 100;\n pp:=true;\n exit;\n end;\n end;\n pp:=false;\nend;\n\n\n\nbegin\n\n readln(n,m);\n pp:=true;\n kol:=1;\n while pp do\n begin\n if kol=1 then fun1 else fun2;\n kol:=3-kol;\n end;\n if kol=2 then writeln('Hanako') else\n writeln('Ciel');\n\nend.\n", "src_uid": "8ffee18bbc4bb281027f91193002b7f5"} {"source_code": "program cf_95d_yxr;\nconst\n mo=1000000007;\nvar\n n,k,i,x,y,j:longint;\n s:ansistring;\n yxr:int64;\n g,wg:array[0..1001,-1..1001]of int64;\n go:array[0..1001]of int64;\n f:array[0..1001,0..9]of int64;\n sf,sg:array[0..1001]of int64;\nprocedure make;\nvar\n i,j:longint;\nbegin\n g[1,0]:=2;\n g[1,-1]:=8;\n sg[1]:=10;\n sg[0]:=1;\n for i:=0 to k-1 do wg[1,i]:=2;\n for i:=2 to 1001 do begin\n for j:=-1 to k-1 do begin\n if j=-1 then begin\n g[i,j]:=(g[i-1,j]+g[i-1,k-1])*8 mod mo;\n end else\n if j=0 then begin\n g[i,j]:=(sg[i-1]-wg[i-1,k-1])*2 mod mo;\n end else begin\n g[i,j]:=g[i-1,j-1]*8 mod mo;\n end;\n sg[i]:=(sg[i]+g[i,j])mod mo;\n if j=0 then\n wg[i,j]:=g[i,j]\n else if j<>-1 then\n wg[i,j]:=(wg[i,j-1]+g[i,j])mod mo;\n end;\n end;\n\n\n for i:=2 to 1001 do begin\n for j:=0 to 9 do begin\n f[i,j]:=sf[i-1];\n if (j=4)or(j=7) then begin\n f[i,j]:=(f[i,j]+wg[i-1,k-1])mod mo;\n end;\n sf[i]:=(sf[i]+f[i,j])mod mo;\n end;\n end;\nend;\nfunction don(x,y:longint):int64;\nvar\n i,j,la,num,pos,t,goo:longint;\n ps:string;\n ans:int64;\nbegin\n la:=-1;\n ans:=0;\n if s[y]=' ' then dec(y);\n pos:=y-x+1;\n for i:=x to y do begin\n ps:=s[i];\n val(ps,num);\n for j:=0 to num-1 do begin\n ans:=(ans+f[pos,j])mod mo;\n end;\n if la<>-1 then begin\n for j:=0 to num-1 do begin\n if (j=4)or(j=7) then begin\n ans:=ans+sg[pos-1]-wg[pos-1,k-1];\n end else begin\n ans:=ans+wg[pos-1,k+pos-la-1]\n end;\n end;\n end;\n if (num=4)or(num=7) then begin\n if (la<>-1)and(la-pos<=k) then begin\n for j:=i+1 to y do begin\n ps:=s[j];\n val(ps,num);\n dec(pos);\n ans:=ans+num*go[pos-1];\n end;\n if x<>1 then\n ans:=(ans+1)mod mo;\n break;\n end else begin\n la:=pos;\n end;\n end;\n dec(pos);\n if (la<>-1)and(la>pos+k) then la:=-1;\n end;\n if ans<0 then ans:=ans+mo;\n exit(ans);\nend;\nbegin\n { assign(input,'a.in');\n assign(output,'a.out');\n reset(input);\n rewrite(output); }\n readln(n,k);\n make;\n go[0]:=1;\n for j:=1 to 1001 do begin\n go[j]:=(go[j-1]*10) mod mo;\n end;\n for i:=1 to n do begin\n readln(s);\n for j:=1 to length(s) do begin\n if s[j]=' ' then begin\n yxr:=don(j+1,length(s))-don(1,j-1);\n yxr:=yxr mod mo;\n if yxr<0 then yxr:=yxr+mo;\n writeln(yxr);\n break;\n end;\n end;\n end;\n close(input);\n close(output);\nend.\n", "src_uid": "5517efa2fc9362fdf342d32adac889f4"} {"source_code": "program z1;\nvar a,b,c,d,i,j,k,l,m,n,ta,tb,hh,mm,t,ans:longint; s,s1:string; Z:array[0..14400] of byte;\nbegin\n//assign(input,'d:\\input.txt'); reset(input);\n//assign(output,'d:\\output.txt'); rewrite(output);\nreadln(a,ta);\nreadln(b,tb);\nfor i:=300 to 1439 do\n begin\n if (i-300) mod b=0 then Z[i]:=1;\n end;\nreadln(s); s1:=s[1]+s[2]; val(s1,hh,c); s1:=s[4]+s[5]; val(s1,mm,c);\nt:=hh*60+mm;\nfor i:=t-tb+1 to t+ta-1 do ans:=ans+Z[i];\nwriteln(ans);\nend.", "src_uid": "1c4cf1c3cb464a483511a8a61f8685a7"} {"source_code": "var i,k,k1,s,v1,v2,t1,t2:longint;begin readln(s,v1,v2,t1,t2);k:=s*v1+2*t1;k1:=s*v2+t2*2;if kk1 then write('Second');if k=k1 then write('Friendship');end.", "src_uid": "10226b8efe9e3c473239d747b911a1ef"} {"source_code": "var\n\tn,x,i,j,k:integer;\n\ts:string;\n\tarr:array[1..200] of integer;\n\tnum:array[0..19] of integer;\n\tt:boolean;\n\nfunction Dec(c:char):integer;\nbegin\n\tif (c='0') then\n\tbegin\n\t\tDec:=0;\n\tend else\n\tif (c='1') then\n\tbegin\n\t\tDec:=1;\n\tend else\n\tif (c='2') then\n\tbegin\n\t\tDec:=2;\n\tend else\n\tif (c='3') then\n\tbegin\n\t\tDec:=3;\n\tend else\n\tif (c='4') then\n\tbegin\n\t\tDec:=4;\n\tend else\n\tif (c='5') then\n\tbegin\n\t\tDec:=5;\n\tend else\n\tif (c='6') then\n\tbegin\n\t\tDec:=6;\n\tend else\n\tif (c='7') then\n\tbegin\n\t\tDec:=7;\n\tend else\n\tif (c='8') then\n\tbegin\n\t\tDec:=8;\n\tend else\n\tbegin\n\t\tDec:=9;\n\tend;\nend;\n\nbegin\n\treadln(n);\n\tread(s);\n\tt:=false;\n\tfor i:=0 to 19 do\n\tbegin\n\t\tnum[i]:=0;\n\tend;\n\tfor i:=1 to n do\n\tbegin\n\t\tx:=Dec(s[i]);\n\t\tnum[x]:=num[x]+1;\n\tend;\n\tfor i:=n+1 to n*2 do\n\tbegin\n\t\tx:=Dec(s[i])+10;\n\t\tnum[x]:=num[x]+1;\n\tend;\n\tk:=1;\n\tfor i:=0 to 9 do\n\tbegin\n\t\tfor j:=1 to num[i] do\n\t\tbegin\n\t\t\tarr[k]:=i;\n\t\t\tk:=k+1;\n\t\tend;\n\tend;\n\tfor i:=10 to 19 do\n\tbegin\n\t\tfor j:=1 to num[i] do\n\t\tbegin\n\t\t\tarr[k]:=i-10;\n\t\t\tk:=k+1;\n\t\tend;\n\tend;\n\tif (n>1) then\n\tbegin\n\t\tif (arr[1]arr[n+1]) then\n\t\tbegin\n\t\t\ti:=2;\n\t\t\twhile (arr[i]>arr[i+n]) and (iarr[i+n]) then\n\t\t\tbegin\n\t\t\t\tt:=true;\n\t\t\tend;\n\t\tend;\n\tend else\n\tbegin\n\t\tif (arr[1]<>arr[2]) then\n\t\tbegin\n\t\t\tt:=true;\n\t\tend;\n\tend;\n\tif t then\n\tbegin\n\t\twriteln('YES');\n\tend else\n\tbegin\n\t\twriteln('NO');\n\tend;\nend.", "src_uid": "e4419bca9d605dbd63f7884377e28769"} {"source_code": "program WIN;\nvar\nn,k,c,i,W,p : byte;\nbegin\np:=255;\nW:=0;\nreadln(n,k);\nfor i:=1 to N do begin\nread(c);\nif (i0) then W:=w+1;\nif (i=k)and(c<>0) then begin P:=c; W:=i; end\nelse if c>=p then W:=w+1;\nend;\nWriteln(W);\nend.", "src_uid": "193ec1226ffe07522caf63e84a7d007f"} {"source_code": "var n,m,min,max,max1,min1,i,p,o:longint;\n begin\n read(n,m,min,max);\n max1:=0;\n min1:=102;\n for i:=1 to m do begin\n read(o);\n If o>max1 then max1:=o;\n If omin1 then writeln('Incorrect') else\n begin\n If max<>max1 then p:=p+1;\n If min<>min1 then p:=p+1;\n If n-m>=p then writeln('Correct') else\n writeln('Incorrect');\n end;\n end.\n\n", "src_uid": "99f9cdc85010bd89434f39b78f15b65e"} {"source_code": "var s,a,k1,k,h:string;\ni,l,pod,j:integer;\nbegin\nreadln(s);\na:='CODEFORCES';\nif (length(s)<=length(a)) then begin writeln('NO'); halt; end;\nk:=copy(s,1,10); if k=a then begin writeln('YES'); halt; end;\nk:=copy(s,length(s)-10+1,10); if k=a then begin writeln('YES'); halt; end;\npod:=1;\nwhile (pod<=length(s)-10) do begin\nfor i:=2 to length(s)-pod do begin\nh:=s;\ndelete(h,i,pod);\nif h=a then begin writeln('YES'); halt; end;\nend;\npod:=pod+1;\nend;\nwriteln('NO');\nend.", "src_uid": "bda4b15827c94b526643dfefc4bc36e7"} {"source_code": "program p1;\nvar st:string; k,n,i:longint;\nbegin\nreadln(n); \nread(st);\nk:=0;\nfor i:=1 to n-1 do\nif (st[i]+st[i+1]='YY')or(st[i]+st[i+1]='CC')or(st[i]+st[i+1]='MM') then k:=1;\nif k<>1 then\nif pos('??',st)<>0 then write('YES') else \nif (pos('C?C',st)<>0)or(pos('M?M',st)<>0)or(pos('Y?Y',st)<>0) then write('YES') else \nif (st[length(st)]='?')or(st[1]='?') then write('YES') else write('NO') else write('NO');\nend.", "src_uid": "f8adfa0dde7ac1363f269dbdf00212c3"} {"source_code": "var a,b,c,x,y,z,n,md:int64;\nfunction pow(a,b:int64):int64;\n var x:int64;\n begin\n x:=1;\n while(b>0) do\n begin\n if b and 1=1 then begin x:=(x*a) mod md; end;\n b:=b shr 1;\n a:=a*a mod md;\n end;\n pow:=x;\n end;\n begin\n read(n);\n md:=1000000007 ;\n a:=pow(2,n);\n b:=pow(2,2*n);\n c:=pow(2,md-2);\n writeln((((a+b) mod md)*c) mod md);\n end.\n", "src_uid": "782b819eb0bfc86d6f96f15ac09d5085"} {"source_code": "program element;\nvar a,b,c:int64;\nbegin\n readln(a,b,c);\n if (c=0) and (a=b) then writeln('YES')\n else if (c=0) and (a<>b) then writeln('NO')\n else if ((b-a) mod c=0) and ((b-a) div c>=0) then writeln('YES') else writeln('NO');\nend.\n", "src_uid": "9edf42c20ddf22a251b84553d7305a7d"} {"source_code": "const fi='';\n fo='';\nvar n,res,max:string;\n f,g:text;\nfunction div8(n:string):boolean;\nvar i:longint;\nbegin\n val(n,i);\n if i mod 8=0 then exit(true)\n else exit(false);\nend;\nprocedure readfile;\nvar x,i:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n);\n close(f)\nend;\nprocedure xuli;\nvar i,j,k:longint;\nbegin\n n:='00'+n;\n res:='';\n for i:=length(n) downto 3 do\n begin\n res:=n[i]+res;\n for j:=i-1 downto 2 do\n begin\n res:=n[j]+res;\n for k:=j-1 downto 1 do\n begin\n res:=n[k]+res;\n if div8(res) then\n //max:=ss(res,max);\n exit;\n delete(res,1,1);\n end;\n delete(res,1,1);\n end;\n delete(res,1,1);\n end;\nend;\nprocedure writefile;\nbegin\n assign(g,fo);\n rewrite(g);\n if res='' then writeln(g,'NO')\n else begin\n while (res[1]='0') and (length(res)>1) do delete(res,1,1);\n writeln(g,'YES');\n write(g,res);\n end;\n close(g);\nend;\nbegin\n readfile;\n xuli;\n writefile;\nend.\n", "src_uid": "0a2a5927d24c70aca24fc17aa686499e"} {"source_code": "const mod1=1000000007;\nvar\na:array[-10..100000]of int64;\nbol:boolean;\ni:longint;\nans,n:int64;\nbegin\n a[0]:=1;\n\ta[1]:=2;\n\ta[2]:=4;\n\ta[3]:=6;\n\ta[4]:=12;\n\ta[5]:=16;\n\ta[6]:=18;\n\ta[7]:=30;\n\ta[8]:=60;\n\ta[9]:=88;\n\ta[10]:=106;\n\ta[11]:=126;\n\ta[12]:=520;\n\ta[13]:=606;\n\ta[14]:=1278;\n\ta[15]:=2202;\n\ta[16]:=2280;\n\ta[17]:=3216;\n\ta[18]:=4252;\n\ta[19]:=4422;\n\ta[20]:=9688;\n\ta[21]:=9940;\n\ta[22]:=11212;\n\ta[23]:=19936;\n\ta[24]:=21700;\n\ta[25]:=23208;\n\ta[26]:=44496;\n\ta[27]:=86242;\n\ta[28]:=110502;\n\ta[29]:=132048;\n\ta[30]:=216090;\n\ta[31]:=756838;\n\ta[32]:=859432;\n\ta[33]:=1257786;\n\ta[34]:=1398268;\n\ta[35]:=2976220;\n\ta[36]:=3021376;\n\ta[37]:=6972592;\n\ta[38]:=13466916;\n\ta[39]:=20996010;\n\n readln(n);\n ans:=1;\n for i:=1 to a[n-1] do ans:=(ans*2) mod mod1;\n writeln(ans-1);\nend.", "src_uid": "c2cbc35012c6ff7ab0d6899e6015e4e7"} {"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 p11, p00,t00,t10,t01,t11,p01,p10,koled,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 p1,p2,p3,p4,grnado,sumtail,totalsum,sumodin,kolodin,maxsum,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 ddsum,dd,kol,stek,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 y,xold,yold,xxold,yyold,xmin,xmax,ymin,ymax,xx,str,zx,zy,z,xxx,yyy,invfact,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,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,pmax,pmax2,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 ddd:array[-400..1065200,-1..20] of int64;\r\n pole,newpole:array[-100..600,-100..600] of char;\r\n ddold,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 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\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(p,modul);\r\n dd[1]:=1; ddsum[1]:=1;\r\n for step:=2 to p do\r\n begin\r\n p1:=0;p2:=0; p3:=0; p4:=0;\r\n { for i:=1 to step-1 do p1:=p1+dd[i];\r\n }\r\n al:=step; al:=sqrt(al);\r\n gr:=trunc(al+eps);\r\n\r\n for i:=2 to gr do\r\n begin\r\n p3:=(p3+dd[step div i]) mod modul;\r\n end;\r\n\r\n for i:=gr-1 downto 1 do\r\n begin\r\n t1:=step div i; t2:=step div (i+1);\r\n { writeln('step= ',step,' i= ',i,' t1= ',t1,' t2= ',t2);\r\n } p4:=(p4+dd[i]*(t1-t2)) mod modul;\r\n end;\r\n if gr*(gr+1)<=step then dob:=dd[gr] else dob:=0;\r\n { writeln('step= ',step,' gr= ',gr);\r\n } if gr*(gr+2)=step then begin dob:=(modul+2*dd[gr]) mod modul; end;\r\n\r\n\r\n\r\n p2:=0;\r\n { for i:=2 to step do p2:=(p2+dd[step div i]) mod modul;\r\n } dd[step]:=(ddsum[step-1]+p3+p4+dob) mod modul;\r\n { writeln('step= ',step,' p2= ',p2,' p3= ',p3,' p4= ',p4,' dd= ',dd[step],' ',p2,' = ',p3+p4+dob,' dob= ',dob);\r\n if p2<>p3+p4+dob then begin writeln('probl step= ',step); writeln('**********************'); end;\r\n }\r\n ddsum[step]:=(ddsum[step-1]+dd[step]) mod modul;\r\n end;\r\n\r\n writeln(dd[p]);\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n 1: close (output);\r\n\r\n end.\r\n\r\n\r\n", "src_uid": "a524aa54e83fd0223489a19531bf0e79"} {"source_code": "var\n n,i,j,t,s:longint;\n a:array[0..51] 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]; a[i]:=a[j]; a[j]:=t;\n end; \n i:=2;\n while i<=n do\n begin\n if a[i]=a[i-1] then\n begin\n for j:=i+1 to n do\n a[j-1]:=a[j];\n dec(n);\n end\n else inc(i);\n end;\n for i:=2 to n do\n if (a[i-1]+1=a[i]) and (a[i]+1=a[i+1]) then\n begin writeln('YES'); halt; end;\n writeln('NO');\nend.", "src_uid": "d6c876a84c7b92141710be5d76536eab"} {"source_code": "var a,b,c,d,e,i:integer;\nvar s:string;\nbegin\nreadln(s);\na:=length(s); b:=1;c:=1;\nfor i:=2 to a do begin\nif ((s[i]=s[i-1]) and (b=5)) then begin\nc:=c+1;b:=0;\nend;\nif ((s[i]=s[i-1]) and (b<5)) then\nb:=b+1;\nif s[i]<>s[i-1] then begin c:=c+1;b:=1;\nend;\nend;\nwriteln(c);\nreadln;\nend.\n\n", "src_uid": "5257f6b50f5a610a17c35a47b3a0da11"} {"source_code": "Program forces;\nuses wincrt;\nvar n,k,m:integer;\nbegin\nread(n);\nread(m);\nread(k);\nif (n<=k) and (n<=m)\nthen write('yes')\nelse write('no');\nEND.\n", "src_uid": "6cd07298b23cc6ce994bb1811b9629c4"} {"source_code": "Type\n\tTPoint\t=\tRecord\n\t\t\tx,y\t:LongInt;\n\tEnd;\nVar\n\tA,B,C\t:TPoint;\n\n\tFunction Dis(a,b:TPoint):LongInt;\n\tBegin Exit((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); End;\n\n\tFunction Check(u,v,w:TPoint):Boolean;\n\tVar\ts1,s2,s3\t:LongInt;\n\tBegin\n\t\ts1:=Dis(u,v); s2:=Dis(u,w); s3:=Dis(v,w);\n If (s1=0) or (s2=0) or (s3=0) Then Exit(False);\n\t\tIf s1+s2=s3 Then Exit(True);\n\t\tIf s1+s3=s2 Then Exit(True);\n\t\tIf s2+s3=s1 Then Exit(True);\n\t\tExit(False);\n\tEnd;\nBegin\n\tReadln(A.x,A.y,B.x,B.y,C.x,C.y);\n\tIf Check(A,B,C) Then Writeln('RIGHT')\n\tElse\n\tBegin\n\t\tInc(A.x); If Check(A,B,C) Then Begin Writeln('ALMOST'); Exit; End; Dec(A.x);\n\t\tDec(A.x); If Check(A,B,C) Then Begin Writeln('ALMOST'); Exit; End; Inc(A.x);\n\t\tInc(A.y); If Check(A,B,C) Then Begin Writeln('ALMOST'); Exit; End; Dec(A.y);\n\t\tDec(A.y); If Check(A,B,C) Then Begin Writeln('ALMOST'); Exit; End; Inc(A.y);\n\t\tInc(B.x); If Check(A,B,C) Then Begin Writeln('ALMOST'); Exit; End; Dec(B.x);\n\t\tDec(B.x); If Check(A,B,C) Then Begin Writeln('ALMOST'); Exit; End; Inc(B.x);\n\t\tInc(B.y); If Check(A,B,C) Then Begin Writeln('ALMOST'); Exit; End; Dec(B.y);\n\t\tDec(B.y); If Check(A,B,C) Then Begin Writeln('ALMOST'); Exit; End; Inc(B.y);\n\t\tInc(C.x); If Check(A,B,C) Then Begin Writeln('ALMOST'); Exit; End; Dec(C.x);\n\t\tDec(C.x); If Check(A,B,C) Then Begin Writeln('ALMOST'); Exit; End; Inc(C.x);\n\t\tInc(C.y); If Check(A,B,C) Then Begin Writeln('ALMOST'); Exit; End; Dec(C.y);\n\t\tDec(C.y); If Check(A,B,C) Then Begin Writeln('ALMOST'); Exit; End; Inc(C.y);\n\t\tWriteln('NEITHER');\n\tEnd\nEnd.\n", "src_uid": "8324fa542297c21bda1a4aed0bd45a2d"} {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils,math;\nVar\n a:Array[0..100,0..100] of Integer;\n g,c,u,f,r:Array[0..3000,0..3000] of Integer;\n kol,q,id,p,pr,d:Array[0..3000] of Integer;\n n,m,u1,v1,i,j,s,t,n1,flow,cost,f1,i1,j1,qh,qt:Integer;\nBegin\n Read(n,m);\n For i:=1 To n Do\n For j:=1 To m Do Read(a[i,j]);\n For i:=1 To n Do\n For j:=1 To m Do\n If (i+j) mod 2=0 Then Begin\n For i1:=-1 To 1 Do\n For j1:=-1 To 1 Do\n If (abs(i1+j1)=1) and (i+i1>0) and (i+i1<=n) and (j+j1>0) and (j+j1<=m) Then Begin\n u1:=(i-1)*m+j;\n v1:=(i+i1-1)*m+j+j1;\n kol[u1]:=kol[u1]+1;\n g[u1,kol[u1]]:=v1;\n u[u1,kol[u1]]:=1;\n f[u1,kol[u1]]:=0;\n If a[i,j]<>a[i+i1,j+j1] Then c[u1,kol[u1]]:=1\n Else c[u1,kol[u1]]:=0;\n r[u1,kol[u1]]:=kol[v1]+1;\n kol[v1]:=kol[v1]+1;\n g[v1,kol[v1]]:=u1;\n u[v1,kol[v1]]:=0;\n f[v1,kol[v1]]:=0;\n If a[i,j]<>a[i+i1,j+j1] Then c[v1,kol[v1]]:=-1\n Else c[v1,kol[v1]]:=0;\n r[v1,kol[v1]]:=kol[u1];\n End;\n End;\n s:=n*m+1;\n t:=n*m+2;\n For i:=1 To n Do\n For j:=1 To m Do\n If (i+j) mod 2=0 Then Begin\n u1:=(i-1)*m+j;\n kol[s]:=kol[s]+1;\n g[s,kol[s]]:=u1;\n u[s,kol[s]]:=1;\n f[s,kol[s]]:=0;\n c[s,kol[s]]:=0;\n r[s,kol[s]]:=kol[u1]+1;\n kol[u1]:=kol[u1]+1;\n g[u1,kol[u1]]:=s;\n u[u1,kol[u1]]:=0;\n f[u1,kol[u1]]:=0;\n c[u1,kol[u1]]:=0;\n r[u1,kol[u1]]:=kol[s];\n End\n Else Begin\n u1:=(i-1)*m+j;\n kol[u1]:=kol[u1]+1;\n g[u1,kol[u1]]:=t;\n u[u1,kol[u1]]:=1;\n f[u1,kol[u1]]:=0;\n c[u1,kol[u1]]:=0;\n r[u1,kol[u1]]:=kol[t]+1;\n kol[t]:=kol[t]+1;\n g[t,kol[t]]:=u1;\n u[t,kol[t]]:=0;\n f[t,kol[t]]:=0;\n c[t,kol[t]]:=0;\n r[t,kol[t]]:=kol[u1];\n End;\n flow:=0;\n cost:=0;\n n1:=n*m+2;\n While True Do Begin\n For i:=1 To n1 Do id[i]:=0;\n For i:=1 To n1 Do d[i]:=1000000000;\n qh:=0;\n qt:=0;\n q[qt]:=s;\n qt:=qt+1;\n d[s]:=0;\n While qh<>qt Do Begin\n v1:=q[qh];\n qh:=qh+1;\n id[v1]:=2;\n If qh=n1 Then qh:=0;\n For i:=1 To kol[v1] Do\n If (f[v1,i]s Do Begin\n f1:=min(f1,u[p[v1],pr[v1]]-f[p[v1],pr[v1]]);\n v1:=p[v1];\n End;\n v1:=t;\n While v1<>s Do Begin\n f[p[v1],pr[v1]]:=f[p[v1],pr[v1]]+f1;\n f[v1,r[p[v1],pr[v1]]]:=f[v1,r[p[v1],pr[v1]]]-f1;\n cost:=cost+c[p[v1],pr[v1]]*f1;\n v1:=p[v1];\n End;\n flow:=flow+f1;\n End;\n Write(cost);\nEnd.\n\n\n\n\n\n\n\n\n\n\n\n\n", "src_uid": "1f0e8bbd5bf4fcdea927fbb505a8949b"} {"source_code": "var\n i, a, b, c, d, k, p: integer;\n mas: array [1..100] of integer;\n\nbegin\n readln(a, b, c, d);\n \n mas[1] := a;\n mas[2] := b;\n mas[3] := c;\n mas[4] := d;\n \n repeat\n k := 0;\n for i := 1 to 3 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 k := 1;\n end;\n \n \n until k = 0;\n \n if (mas[1]+mas[4]=mas[2]+mas[3]) or (mas[4]+mas[3]+mas[2]=mas[1]) then\n writeln('YES')\n else\n writeln('NO');\n \nend.\n\n\n\n\n\n\n\n\n\n", "src_uid": "5a623c49cf7effacfb58bc82f8eaff37"} {"source_code": "var\n s,s1:string;\n i:longint;\nbegin\n readln(s);\n for i:=1 to length(s) do\n begin\n s1:=copy(s,i,3);\n if length(s1)<3 then break;\n if (pos('A',s1)<>0) and (pos('B',s1)<>0) and (pos('C',s1)<>0) then\n begin\n writeln('Yes');\n halt;\n end;\n end;\n writeln('No');\nend.", "src_uid": "ba6ff507384570152118e2ab322dd11f"} {"source_code": "program task3;\nvar n,i,k:longint;\nfunction hex(k:longint):longint;\nvar a,s:longint;\nbegin\ns:=0;\na:=1;\nwhile k>0 do\n begin\n s:=s+a*(k mod 2);\n a:=a*10;\n k:=k div 2;\n end;\nhex:=s;\nend;\n\nbegin\nread(n);\ni:=0;\nrepeat\n i:=i+1;\n k:=hex(i);\nuntil k>n;\nwriteln(i-1);\nend.", "src_uid": "64a842f9a41f85a83b7d65bfbe21b6cb"} {"source_code": "var a,x1,x2,ans:integer;\nstr:string;\nbegin\nread(a);\nans:=a;\nif a<0 then begin\nx1:=-abs(a div 10);\nx2:=a div 100;\nstr:=(IntToStr(x2)+InttoStr(abs(a) mod 10));\nx2:=-abs(Strtoint(str));\nans:=max(x1,x2);\nend;\nwriteln(ans);\nend.", "src_uid": "4b0a8798a6d53351226d4f06e3356b1e"} {"source_code": "var a,b,c:array[0..10000] of longint;\ni,j,n,t:longint;\nbegin\n//assign(input,'swht.in');reset(input);\n//assign(output,'swht.out');rewrite(output);\nreadln(n);\nfor i:=1 to n do read(a[i]);\nfor i:=1 to n do b[i]:=i;\nfor i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i] 0 do begin\n q:=1; l:=i; pr:=0;\n for j:=i downto 1 do\n if (int64(ord(s[j])-48)*q+pr < n) and (q <= n) then begin\n pr:=pr+int64(ord(s[j])-48)*q;\n q:=q*10;\n if s[j] <> '0' then l:=j;\n end else break;\n ans:=ans+st*pr;\n i:=l-1;\n st:=st*n;\n end;\n writeln(ans);\nend.", "src_uid": "be66399c558c96566a6bb0a63d2503e5"} {"source_code": "uses math;\nconst\n tfi='';\n tfo='';\n MAXN=500;\n\nvar\n fi, fo: text;\n n, k, svlt, sum, res: longint;\n a: array[0..MAXN+5,0..MAXN+5] of char;\n c, t: array[0..MAXN*MAXN+5] of longint;\n f: array[0..MAXN+5,0..MAXN+5] of longint;\n dx: array[1..4] of longint=(-1,0,1,0);\n dy: array[1..4] of longint=(0,1,0,-1);\n\nprocedure __;\nvar\n i, j: longint;\nbegin\n assign(fi, tfi); reset(fi);\n assign(fo, tfo); rewrite(fo);\n readln(fi, n, k);\n for i:=1 to n do\n begin\n for j:=1 to n do read(fi, a[i, j]);\n readln(fi);\n end;\nend;\n\nfunction inside(x, y: longint): boolean;\nbegin\n if (x>0) and (y>0) and (x<=n) and (y<=n) then exit(true);\n exit(false);\nend;\n\nprocedure dfs(x, y: longint);\nvar\n k, u, v: longint;\nbegin\n f[x, y] := svlt;\n inc(c[svlt]);\n for k:=1 to 4 do\n begin\n u := x+dx[k];\n v := y+dy[k];\n if (inside(u, v)) and (a[u, v]='.') and (f[u, v]=0) then dfs(u, v);\n end;\nend;\n\nprocedure tinh(x, y, cnt: longint);\nbegin\n if (not inside(x, y)) or (a[x, y]<>'.') or (t[f[x, y]]=cnt) then exit;\n t[f[x, y]] := cnt;\n sum := sum+c[f[x, y]];\nend;\n\nprocedure xuly;\nvar\n x, y, u, v, cnt: longint;\nbegin\n for x:=1 to n do\n for y:=1 to n do\n if (a[x, y]='.') and (f[x, y]=0) then\n begin\n inc(svlt);\n dfs(x, y);\n end;\n cnt := 0;\n for y:=1 to n-k+1 do\n begin\n for u:=1 to k do for v:=y to y+k-1 do dec(c[f[u, v]]);\n for x:=1 to n-k+1 do\n begin\n inc(cnt);\n sum := k*k;\n for u:=x to x+k-1 do\n begin\n tinh(u, y-1, cnt);\n tinh(u, y+k, cnt);\n end;\n for v:=y to y+k-1 do\n begin\n tinh(x-1, v, cnt);\n tinh(x+k, v, cnt);\n end;\n res := max(res, sum);\n if x+k<=n then // Di chuyen hinh vuong xuong duoi;\n for v:=y to y+k-1 do\n begin\n inc(c[f[x, v]]); // Hoi phuc lai cai o trong h.vuong truoc\n dec(c[f[x+k, v]]); // Bo cai o trong h.vuong\n end;\n end;\n for u:=n downto n-k+1 do //Hoi phuc lai h.vuong sat voi canh ben duoi\n for v := y to y+k-1 do inc(c[f[u, v]]); //Do o tren x+k<=n ...\n end;\n writeln(fo, res);\nend;\n\nprocedure _;\nbegin\n close(fi); close(fo);\nend;\n\nBEGIN\n __;\n xuly;\n _;\nEND.\n\n", "src_uid": "d575f9bbdf625202807db59490c5c327"} {"source_code": "uses math;\nvar\n i,j,k,n,m:longint;\n a,b:array[0..21]of longint;\n dp:array[0..101,0..101]of longint;\n ans,maxint:int64;\nprocedure solve;\nvar i,j,p,q:longint;\nbegin\n fillchar(dp,sizeof(dp),$5f);\n maxint:=dp[0,0];\n dp[0,0]:=0;\n for i:=0 to n*4-1 do\n begin\n p:=i mod n+1;\n for j:=0 to i+1 do if j<>0 then\n dp[i+1,j]:=min(dp[i,j-1]+a[p],dp[i,j+1]+b[p]) else dp[i+1,j]:=dp[i,j+1]+b[p];\n end;\nend;\nbegin\n readln(n,m);\n for i:=1 to n do read(a[i]);\n for i:=1 to n do read(b[i]);\n solve;\n if m<=3 then writeln(dp[n*m,0]) else\n begin\n ans:=dp[n*4,0];\n ans:=ans+int64(dp[n*4,0]-dp[n*2,0])*int64(m div 2-2);\n writeln(ans);\n end;\nend.\n", "src_uid": "f40900973f4ebeb6fdafd75ebe4e9601"} {"source_code": "var s:string;\na,code,i:integer;\nbegin\nreadln(s);\nfor i:=length(s) downto 1 do\nbegin\nval(s[i],a,code);\ncase a of\n0:writeln('O-|-OOOO');\n1:writeln('O-|O-OOO');\n2:writeln('O-|OO-OO');\n3:writeln('O-|OOO-O');\n4:writeln('O-|OOOO-');\n5:writeln('-O|-OOOO');\n6:writeln('-O|O-OOO');\n7:writeln('-O|OO-OO');\n8:writeln('-O|OOO-O');\n9:writeln('-O|OOOO-');\nEND;\nend;\nend.\n", "src_uid": "c2e3aced0bc76b6484360563355d23a7"} {"source_code": "\nvar\n a:array[1..100] of longint;\n n,i,j,z,res,tmp:longint;\n ok:boolean;\n\nbegin\n readln(n);\n res:=0;\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 begin\n ok:=true;\n for z:=i+1 to j do\n if a[z]<>a[z-1]+1 then\n begin\n ok:=false;\n break;\n end;\n if ok then\n begin\n tmp:=j-i-1;\n if ((i=1) and(a[i]=1)) or ((j=n) and (a[j]=1000)) then\n inc(tmp);\n if res=0 then begin write(1); break; end;\n if (n-2*a-b>=0) or (n-3*a-2*b>=0) or (n-2*(a+b)>=0) or ((n-a-2*b>=0) and (n-3*a>=0)) or (n-4*a-b>=0)or ((n-3*a-b>=0) and (n-a-b>=0)) or ((n-2*a-b>=0) and (n-2*a-b>=0)) or ((n-a-b>=0)and(n-3*a-b>=0)) then begin write(2); break; end;\n if a >= b then \n begin\n if n - a * 4 >= 0 then begin\n z := n - 4 * a;\n inc(c);\n x[c] := z;\n end \n else if n - a * 3 >= 0 then begin\n z := n - 3 * a;\n inc(c, 2);\n inc(x[1], z);\n inc(x[2], n - a);\n end\n else if n - 2 * a >= 0 then begin\n z := n - 2 * a;\n inc(c, 2);\n inc(x[1], z);\n inc(x[2], z);\n end else \n if n - a >= 0 then begin\n z := n - a;\n inc(c, 4);\n inc(x[1], z);\n inc(x[2], z);\n inc(x[3], z);\n inc(x[4], z);\n end;\n for var p := 1 to c - 1 do\n for var j := 1 to c - p do\n if x[j] < x[j + 1] then swap(x[j], x[j + 1]);\n for var i := 1 to c do \n begin\n if x[i] - 2 * b >= 0 then inc(y, 2) else \n if x[i] - b >= 0 then inc(y) else break;\n if y = 2 then break;\n end;\n if y = 0 then\n begin\n if n - 2 * b >= 0 then begin\n inc(c);\n write(c);\n end else begin\n inc(c, 2);\n write(c);\n end; \n end else if y = 1 then write(c + 1);\n if y = 2 then write(c); \n end else \n begin\n if n - 2 * b >= 0 then begin\n c := 1;\n x[1] := n - 2 * b;\n end else begin\n c := 2;\n x[1] := n - b;\n x[2] := x[1];\n end;\n while (x[k] >= 0) and (k <= 2) do \n begin\n if x[k] - a >= 0 then\n begin\n inc(y);\n x[k] := x[k] - a;\n end else inc(k);\n if y = 4 then break;\n end;\n if (n - a * 4 >= 0) and (y = 0) then begin\n z := n - 4 * a;\n inc(c);\n write(c);\n end \n else if (n - a * 3 >= 0) and (y = 0) then begin\n z := n - 3 * a;\n inc(c, 2);\n inc(x[1], z);\n inc(x[2], n - a);\n write(c);\n end\n else if (n - 2 * a >= 0) and (y = 0) then begin\n z := n - 2 * a;\n inc(c, 2);\n inc(x[1], z);\n inc(x[2], z);\n write(c);\n end else \n if (n - a >= 0) and (y = 0) then begin\n z := n - a;\n inc(c, 4);\n write(c);\n end;//\n if (n - a * 3 >= 0) and (y = 1) then begin\n z := n - 3 * a;\n inc(c);\n write(c);\n end\n else if (n - 2 * a >= 0) and (y = 1) then begin\n z := n - 2 * a;\n inc(c, 2);\n write(c);\n end else \n if (n - a >= 0) and (y = 1) then begin\n inc(c, 3);\n write(c);\n end;//\n if (n - 2 * a >= 0) and (y = 2) then begin\n z := n - 2 * a;\n inc(c);\n write(c)\n end else \n if (n - a >= 0) and (y = 2) then begin\n z := n - a;\n inc(c, 2);\n write(c);\n end;//\n if (n - a >= 0) and (y = 3) then begin\n inc(c);\n write(c);\n end;\n if y = 4 then write(c);\n end;\n end;\nend.", "src_uid": "1a50fe39e18f86adac790093e195979a"} {"source_code": "program zz;\n\nvar m,i,j,ii,k,n,w,sb,s:longint;\n\nfunction ss(x:longint):boolean;\n var i:longint;\nbegin\n if (x>2)and(odd(x)) then\n begin\n i:=3;\n while i*i<=x do\n if x mod i>0 then inc(i,2) else break;\n if i*i>x then ss:=true else ss:=false;\n end else ss:=false;\nend;\nbegin\n {assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);}\n read(n,m);\n i:=3;j:=5;\n while i+j -1) and (1 <= x) and (x <= n) and (1 <= y) and (y <= n) then begin\n\t\t\t\tinc(j);\n\t\t\t\tqx[j] := x;\n\t\t\t\tqy[j] := y;\n\t\t\t\twas[x][y] := true;\n\t\t\t\td[x][y] := d[qx[i]][qy[i]] + 1;\n\t\t\tend;\n\t\tend;\n\t\tinc(i);\n\tend;\nend;\nprocedure precalc;\nbegin\n\tfor i := 1 to n do\n\tfor j := 1 to n do\n if (a[i][j] <> -1) then\n \t\tcan[0][i][j][i][j] := true;\n\tfor tt := 1 to t do\n\tfor i := 1 to n do\n\tfor j := 1 to n do begin\n\t\tif (a[i][j] = -1) then continue;\n\t\tfor ii := 1 to n do\n\t\tfor jj := 1 to n do begin\n if (tt > d[ii][jj]) or (a[ii][jj] = -1) then continue;\n\t\tfor k := 1 to 4 do begin\n\t\t\tx := ii + ux[k];\n\t\t\ty := jj + uy[k];\n\t\t\tif (tt-1 < d[x][y]) and (1 <= x) and (x <= n) and (1 <= y) and (y <= n) and (can[tt-1][i][j][x][y]) then begin\n\t\t\t\tcan[tt][i][j][ii][jj] := true;\n\t\t\t\tbreak;\n\t\t\tend;\n\t\tend;\n end;\n\tend;\nend;\nprocedure add(x, y, z : int);\nbegin\n\tinc(len);\n\tv[len] := y;\n\tnext[len] := s[x];\n\tw[len] := z;\n\ts[x] := len;\nend;\nprocedure findpath(x, y : int);\nvar\n rev : int;\nbegin\n\twhile (x <> 0) do begin\n\t\tmn := min(mn, w[x]-f[x]);\n\t\tx := p[x];\n\tend;\n\twhile (y <> 0) do begin\n\t\tif (y and 1 = 1) then rev := y + 1\n\t\telse rev := y - 1;\n\t\tf[y] := f[y] + mn;\n\t\tf[rev] := f[rev] - mn;\n\t\ty := p[y];\n\tend;\nend;\nprocedure bfsflow;\nvar\n pos : int;\nbegin\n\ti := 1; j := 1;\n\tfillchar(used, sizeof(used), false);\n\tq[1] := 0; used[0] := true;\n\twhile (i <= j) do begin\n\t\tpos := s[q[i]];\n\t\twhile (pos <> 0) do begin\n\t\t\tif (not used[v[pos]]) and (w[pos]-f[pos] > 0) then begin\n\t\t\t\tinc(j);\n\t\t\t\tq[j] := v[pos];\n\t\t\t\tused[q[j]] := true;\n\t\t\t\tu[j] := pos;\n\t\t\t\tp[pos] := u[i];\n\t\t\t\tif (q[j] = 2*n*n+1) then begin\n\t\t\t\t\tfindpath(pos, pos);\n\t\t\t\t\texit;\n\t\t\t\tend;\n\t\t\tend;\n\t\t\tpos := next[pos];\n\t\tend;\n\t\tinc(i);\n\tend;\nend;\nprocedure flow;\nbegin\n\tfor i := 1 to n do\n\tfor j := 1 to n do begin\n if (a[i][j] > 0) then begin\n\t \tadd(0, (i-1)*n+j, a[i][j]);\n \t\tadd((i-1)*n+j, 0, 0);\n end;\n if (b[i][j] > 0) then begin\n\t\t add(n*n+(i-1)*n+j, 2*n*n+1, b[i][j]);\n\t \tadd(2*n*n+1, n*n+i*(n-1)+j, 0);\n \tend;\n end;\n\tfor i := 1 to n do\n\tfor j := 1 to n do\n\tfor ii := 1 to n do\n\tfor jj := 1 to n do\n\tfor tt := 0 to t do\n\t\tif (can[tt][i][j][ii][jj]) and (b[ii][jj] > 0) and (a[i][j] > 0) then begin\n\t\t\tadd((i-1)*n+j, n*n+(ii-1)*n+jj, inf);\n\t\t\tadd(n*n+(ii-1)*n+jj, (i-1)*n+j, 0);\n break;\n\t\tend;\n\tres := 0;\n\twhile (true) do begin\n\t\tmn := inf;\n\t\tbfsflow;\n\t\tif (mn = inf) then begin\n\t\t\twrite(res);\n\t\t\thalt;\n\t\tend;\n\t\tres := res + mn;\n\tend;\nend;\nbegin\n//\treset(input, 'a.in'); rewrite(output, 'a.out');\n\tscanf;\n\tbfs;\n\tprecalc;\n\tflow;\nend.", "src_uid": "544de9c3729a35eb08c143b1cb9ee085"} {"source_code": "uses math;\nconst\n fi='';\n fo='';\nvar\n f1,f2:text;\n i,n,a,b,ans:longint;\nbegin\n assign(f1,fi); reset(f1);\n assign(f2,fo); rewrite(f2);\n read(f1,n,a,b);\n ans:=0;\n for i:=1 to n-1 do ans:=max(ans,min(a div i,b div (n-i)));\n write(f2,ans);\n close(f1); close(f2);\nend.", "src_uid": "a254b1e3451c507cf7ce3e2496b3d69e"} {"source_code": "{$APPTYPE CONSOLE}\n\nuses SysUtils, Math;\n\nvar i, j, k, x : integer;\n s : int64;\n ans : array[0..1000] of int64;\n answer : array[0..1000] of int64;\n cnt : integer;\n\nprocedure print;\nvar i : integer;\nbegin\n for i := 1 to cnt do\n write(answer[i], ' ');\n writeln;\nend;\n\nbegin\n //reset(input, 'text.in');\n //rewrite(output, 'text.out');\n read(s, k);\n if (k > 35) then begin\n cnt := 0;\n while (s > 0) do begin\n for i := 30 downto 0 do begin\n if ((1 shl i) <= s) then begin\n ans[cnt] := int64(1 shl i);\n dec(s, int64(1 shl i));\n inc(cnt);\n break;\n end;\n end; \n end; \n ans[cnt] := 0;\n inc(cnt);\n writeln(cnt);\n for i := 0 to cnt - 1 do\n write(ans[i], ' ');\n writeln;\n end else begin\n for i := 0 to k - 1 do\n ans[i] := 0;\n ans[k] := 1;\n for i := k + 1 to 1000 do\n for j := i - 1 downto i - k do\n inc(ans[i], ans[j]);\n for i := 0 to 1000 do \n answer[i] := 0;\n cnt := 0;\n while (s > 0) do begin\n for i := k - 1 to 1000 do begin\n if (ans[i] > s) then begin\n inc(cnt);\n dec(s, ans[i - 1]);\n answer[cnt] := ans[i - 1];\n break;\n end;\n end;\n end;\n inc(cnt);\n answer[cnt] := 0;\n writeln(cnt);\n print;\n writeln; \n end; \nend.\n", "src_uid": "da793333b977ed179fdba900aa604b52"} {"source_code": "var f:array[0..1000,0..7,0..7]of int64;\n tt,ans:array[0..100,0..100]of int64;\n d:array[0..1000]of int64;\n s,q,i,j,k:longint;\n n,temp,t:int64;\n\nbegin\n readln(n,ans[1,1],ans[1,2],ans[1,3],ans[1,4],t);\n ans[1,5]:=0;\n ans[1,6]:=1;\n if n=1 then begin writeln(1,' ',1);halt; end;\n fillchar(f,sizeof(f),0);\n f[0,1,1]:=2;f[0,1,2]:=1;f[0,1,3]:=1;f[0,1,4]:=1;\n f[0,2,1]:=1;f[0,2,2]:=2;f[0,2,3]:=1;f[0,2,4]:=1;\n f[0,3,1]:=1;f[0,3,2]:=0;f[0,3,3]:=1;f[0,3,4]:=0;\n f[0,4,1]:=0;f[0,4,2]:=1;f[0,4,3]:=0;f[0,4,4]:=1;\n f[0,5,1]:=1;f[0,5,2]:=1;f[0,5,3]:=1;f[0,5,4]:=1;f[0,5,5]:=1;\n f[0,6,5]:=1;f[0,6,6]:=1;\n for q:=1 to 100 do\n begin\n for i:=1 to 6 do for j:=1 to 6 do for k:=1 to 6 do\n f[q,i,j]:=(f[q,i,j]+f[q-1,i,k]*f[q-1,k,j]) mod n;\n end;\n temp:=t;\n s:=0;\n while temp<>0 do\n begin\n d[s]:=temp mod 2;\n temp:=temp div 2;\n inc(s);\n end;\n for q:=0 to s do\n if d[q]=1 then\n begin\n fillchar(tt,sizeof(tt),0);\n for i:=1 to 1 do for j:=1 to 6 do for k:=1 to 6 do\n tt[i,j]:=(tt[i,j]+ans[i,k]*f[q,k,j]) mod n;\n ans:=tt;\n end;\n writeln((ans[1,1]+n-1)mod n+1,' ',(ans[1,2]+n-1) mod n+1);\nend.\n", "src_uid": "ee9fa8be2ae05a4e831a4f608c0cc785"} {"source_code": "program zzz;\nvar\n s1,s2:string;\n n,i,k:longint;\nbegin\n readln(n);\n readln(s1);\n k:=0;\n i:=length(s1)div 2;\n while (copy(s1,1,i)<>copy(s1,i+1,i))and (i>0)do dec(i);\n if(copy(s1,1,i)=copy(s1,i+1,i))and(i<>0) then k:=i+1+length(s1)-i*2\n else\n k:=length(s1);\n writeln(k);\nend.", "src_uid": "ed8725e4717c82fa7cfa56178057bca3"} {"source_code": "var n,i,x1,x2,x3,x4,tmp,pd,j:longint;\na:array[0..10000] of longint;\nbegin\nreadln(n);\nfor i:=1 to n do\nread(a[i]);\npd:=0;\nfor i:=1 to n-2 do\nbegin\nx1:=a[i];\nx2:=a[i+1];\nif x1>x2 then\nbegin\ntmp:=x1;\nx1:=x2;\nx2:=tmp;\nend;\nfor j:=i+1 to n-1 do\nbegin\nx3:=a[j];\nx4:=a[j+1];\nif x3>x4 then\nbegin\ntmp:=x3;\nx3:=x4;\nx4:=tmp;\nend;\nif (x1b div 2) then min:=b div 2;\n if (min>c div 4) then min:=c div 4;\n write(min*7)\nend.", "src_uid": "82a4a60eac90765fb62f2a77d2305c01"} {"source_code": "uses math;\ntype mass=array[0..200] of integer;\n maxx=array[0..200,1..2] of integer;\nvar m1:mass;max1,res,kol,uk,uk1,k,min1,n,q,sx,g,xv,l,np,p,nl,d,sy,c,a,b:Int64;s,s1,ss:string;j,i,z:Integer;\n ch:Char;m:maxx;\nbegin\n // Reset(input,'input.txt');\n // Rewrite(Output,'output.txt');\n readln(n,k);\n for i:=0 to n-1 do\n if (k-i*2) div (n-i)>=3\n then Begin\n writeln(i);\n halt(0);\n end;\n writeln(n);\nend.\n", "src_uid": "5a5e46042c3f18529a03cb5c868df7e8"} {"source_code": "var\nn:integer;\nbegin\n read(n);\n if n =3 then begin\n write(1);\n end;\n if n =1 then begin\n write(2);\n end;\n if n=4 then begin\n write(2);\n end;\n if n =2 then begin\n write(3);\n end; \n if n=5 then begin\n write(1);\n end;\nend.", "src_uid": "c702e07fed684b7741d8337aafa005fb"} {"source_code": "program Project3;\n\n{$APPTYPE CONSOLE }\n\nuses\n SysUtils;\n\nvar a,b:array[1..1000]of integer;\n i,n,k,j:longint;\nbegin\n readln(n); k:=0;\n if n>1 then begin\n k:=n+1;\n for i:=2 to n-1 do begin\n k:=k+((i)*(n-i))+1;\n end;\n end else k:=1;\n writeln(k);\n readln;\n readln;\nend.\n", "src_uid": "6df251ac8bf27427a24bc23d64cb9884"} {"source_code": "{$APPTYPE CONSOLE}\n{$M 99777216}\n{$R-,Q-,O+,S+,H+}\nvar\n t, q, i, j, st : longint;\n a, b, p, o : int64;\nprocedure swap(var a, b : int64);\nvar\n c : int64;\nbegin\n c := a;\n a := b;\n b := c;\nend;\nfunction get(a , b: int64) : longint;\nvar\n q : extended;\n res : LongInt;\nbegin\n q := a / b;\n res := 1;\n while q + 1e-15 > b do\n begin\n inc(res);\n q := q / b;\n end;\n get := res;\nend;\nfunction rec(a, b : int64) : Boolean;\nvar\n ok : boolean;\n p, o : int64;\n st, j : longint;\nbegin\n if (a = 0) or (b = 0) then\n begin\n rec := false;\n exit;\n end;\n ok := rec(b, a mod b);\n if not ok then\n begin\n rec := true;\n exit;\n end;\n if (a div b) Mod (b + 1) and 1 = 0 then\n rec := true\n else\n rec := false;\nend;\nbegin\n // reset(input, 'input.txt');\n // rewrite(output, 'output.txt');\n Readln(t);\n for q := 1 to t do\n begin\n readln(a, b);\n if b > a then\n Swap(a, b);\n if not rec(a, b) then\n writeln('Second')\n else\n writeln('First');\n Continue;\n if (a = 0) or (b = 0) then\n begin\n writeln('Second');\n Continue;\n end;\n i := 1;\n while (a mod b <> 0) do\n begin\n st := get(a, b);\n p := b;\n for j := 2 to st do\n begin\n p := p * b;\n end;\n o := b;\n b := a - p;\n a := o;\n if b > a then\n swap(a, b);\n inc(i);\n end;\n if i and 1 = 0 then\n writeln('Second')\n else\n writeln('First');\n end;\nend.\n", "src_uid": "5f5b320c7f314bd06c0d2a9eb311de6c"} {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,m: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{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction calc:int64;\n begin\n if n=1 then\n begin\n if m mod 6=0 then exit(m) else\n if m mod 6<=3 then exit(m-m mod 6) else\n if m mod 6> 3 then exit(m+m mod 6-6);\n end;\n if n=2 then\n begin\n if m=2 then exit(0);\n if m=3 then exit(4);\n if m=7 then exit(12);\n end;\n if (n*m) mod 2=1 then exit(n*m-1) else exit(n*m);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n begin\n read(fi,n,m);\n if n>m then swap(n,m);\n write(fo,calc);\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", "src_uid": "02ce135a4b276d1e9ba6a4ce37f2fe70"} {"source_code": "{$apptype console}\nUses SysUtils;\nVar\n x:Array[0..500000] of Int64;\n n,m,x1,x2,x3,a,b,c,k,ans,r1:Int64;\n n1:Real;\n i,j:Integer;\nprocedure qSort(l,r:integer);\nvar i,j:integer;\n w,q:int64;\nbegin\n i := l; j := r;\n q := x[random(r-l+1) + l];\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 Read(n);\n If n mod 3<>0 Then Begin\n Write(0);\n Halt;\n End;\n n:=n div 3;\n m:=0;\n n1:=n;\n For i:=1 To Round(sqrt(n1+0.0000001)) Do\n If n mod i=0 Then Begin\n m:=m+1;\n x[m]:=i;\n If i<>n div i Then Begin\n m:=m+1;\n x[m]:=n div i;\n End;\n End;\n qSort(1,m);\n ans:=0;\n For i:=1 To m-1 Do Begin\n r1:=n div x[i];\n x1:=x[i];\n For j:=i To m Do Begin\n If (x[i]*x[j]<=0) or (x[i]*x[j]>n) Then Break;\n If ((x[j]-x[i])*x[i]*x[j]<0) or ((x[j]-x[i])*x[i]*x[j]>=n) Then Break;\n If r1 mod x[j]=0 Then Begin\n x2:=x[j];\n x3:=r1 div x[j];\n If (x30 Then Continue;\n If (x1-x2+x3) mod 2<>0 Then Continue;\n If (-x1+x2+x3) mod 2<>0 Then Continue;\n a:=(x1+x2-x3) div 2;\n b:=(x1-x2+x3) div 2;\n c:=(-x1+x2+x3) div 2;\n If (a<=0) or (b<=0) or (c<=0) Then Continue;\n k:=1;\n If b<>a Then k:=k+1;\n If (c<>a) and (c<>b) Then k:=k+1;\n If k=1 Then ans:=ans+1\n Else If k=2 Then ans:=ans+3\n Else ans:=ans+6;\n End;\n End;\n End;\n Write(ans);\nEnd.", "src_uid": "07e58a46f2d562a44b7c771edad361b4"} {"source_code": "var\n i,j,l,r,n,t,k,ans,ll,rr,mid:longint;\n bz:array[1..1000000]of boolean;\n zs:array[0..1000000]of longint;\nbegin\n read(n);\n for i:=2 to n do\n begin\n if(bz[i]=false)then\n begin\n inc(zs[0]);\n zs[zs[0]]:=i;\n end;\n for j:=1 to zs[0] do\n begin\n if(n/zs[j]maxlongint)then break;\n end;\n break;\n end;\n end;\n if(ans<>maxlongint)then writeln(ans)\n else writeln(n-1);\nend.\n", "src_uid": "43ff6a223c68551eff793ba170110438"} {"source_code": "var w,h,k,i,c: longint;\nbegin\n read(w,h,k);\n c:=(2*w)+2*(h-2);\n if k<>1 then\n for i:=2 to k do begin\n w:=w-4;\n h:=h-4;\n c:=c+(2*w)+2*(h-2);\n end;\n writeln(c);\n readln;\n readln;\nend.\n\n", "src_uid": "2c98d59917337cb321d76f72a1b3c057"} {"source_code": "var x,k,y,a,b:int64;\n\nfunction nsd(x,y:int64):int64;\nbegin\n if x<>0 then nsd:=nsd(y mod x,x) else nsd:=y;\nend;\n\nfunction nsk(x,y:int64):int64;\nbegin\n nsk:=(x div nsd(x,y)) * y;\nend;\n\nbegin\n reaD(x,y,a,b);\n k:=nsk(x,y);\n write((b div k) -((a-1) div k) );\nend.", "src_uid": "c7aa8a95d5f8832015853cffa1374c48"} {"source_code": "program Project2;\n{$APPTYPE CONSOLE}\nuses\n SysUtils, Math;\n\nvar n, r1, r2, d: Integer;\nk, eps: extended;\n\nbegin\n eps := 1e-7;\n read(n, r1, r2);\n if (n = 1) then begin\n if (r1 >= r2) then\n writeln('YES')\n else\n writeln('NO');\n exit;\n end;\n d := r1 - r2;\n k := sin(pi/n);\n k := k * d;\n if (k + eps > r2) then\n writeln('YES')\n else\n writeln('NO');\n readln;\n readln;\nend. ", "src_uid": "2fedbfccd893cde8f2fab2b5bf6fb6f6"} {"source_code": "var s1,s2,st:string;\nk,n:longint;\nsim:char;\nbegin\n readln(st);\n n:=length(st);\n s1:=st;\n while true do\n begin\n sim:=st[n];\n delete(st,n,1);\n insert(sim,st,1);\n if st=s1 then break\n else k:=k+1;\n end;\n writeln(k+1);\nend.", "src_uid": "8909ac99ed4ab2ee4d681ec864c7831e"} {"source_code": "var\nm, n, i, k, sum: longint;\nid, s:array[0..1234567] of longint;\nc: array[0..1234567] of char;\nl, was: array [0..1234567] of boolean;\nbegin\nreadln(n, m);\nfor i:=1 to m do readln(c[i], id[i]);\nfor i:=1 to n do was[i]:=false;\nfor i:=1 to n do s[i]:=0;\nfor i:=1 to m do\nbegin\n if not was[id[i]] then\nbegin\n if c[i] = '-' then s[id[i]]:=1;\nwas[id[i]]:=true;\nend;\nend;\nsum:=0;\nfor i:=1 to n do sum:=sum+s[i];\nfor i:=1 to n do l[i]:=true;\nfor i:=1 to m do\nbegin\n if c[i]='+' then\nbegin\nif sum <> 0 then l[id[i]]:=false;\n\nend;\nsum:=sum-s[id[i]];\ns[id[i]]:=1-s[id[i]];\nsum:=sum+s[id[i]];\nif c[i] = '-' then\nbegin\nif sum <> 0 then l[id[i]]:=False;\nend;\nend;\nfor i:=1 to m-1 do\nif (c[i] = '-') and( (c[i + 1] <> '+') or (id[i + 1] <> id[i])) then l[id[i]]:=False;\nfor i:=2 to m do\nif (c[i] = '+') and ((c[i - 1] <> '-') or (id[i - 1] <> id[i])) then l[id[i]]:=false;\nk:=0;\nfor i:=1 to n do k:=k+ord(l[i]);\nwriteln(k);\nfor i:=1 to n do\nif (l[i]) then write(i,' ');\nend.", "src_uid": "a3a337c7b919e7dfd7ff45ebf59681b5"} {"source_code": "{$r-,s-,q-,i-,o+}\n{$m 50000000}\ntype\n tl=array [0..20] of longint;\n tu=array [0..20] of boolean;\nvar\n n,i,j,ans:longint;\n e:tl;ee:tu;\n f:Array [0..20,0..20] of longint;\n\n function calc(a:tl):longint;\n var sum,i,l,j:longint;used:array[0..20] of boolean;\n begin\n l:=0;\n sum:=0;\n for i:=1 to n do\n begin\n fillchar(used,sizeof(used),false);\n for j:=l+1 to n-1 do\n if (not used[j]) and (not used[j+1]) then\n begin\n used[j]:=true;used[j+1]:=true;\n sum:=sum+f[a[j],a[j+1]];\n sum:=sum+f[a[j+1],a[j]];\n end;\n inc(l);\n end;\n exit(sum);\n end;\n\n procedure dfs(w:longint;ls:tl;us:tu);\n var i:longint;res:longint;\n begin\n if (w=n) then\n begin\n res:=calc(ls);\n if (res>ans) then ans:=res;\n exit;\n end;\n for i:=1 to n do\n if (not us[i]) then\n begin\n us[i]:=true;\n ls[w+1]:=i;\n dfs(w+1,ls,us);\n us[i]:=false;\n end;\n end;\n\nbegin\n n:=5;\n for i:=1 to n do\n for j:=1 to n do\n read(f[i,j]);\n ans:=0;\n dfs(0,e,ee);\n writeln(ans);\nend.", "src_uid": "be6d4df20e9a48d183dd8f34531df246"} {"source_code": "program flying;\nconst fi='';\n fo='';\nvar n,m:int64;\n{------------------------}\nfunction power(a,b:int64):int64;\nvar t:int64;\nbegin\n if b=0 then exit(1);\n if b=1 then exit(a mod m);\n t:=power(a,b div 2);\n if b mod 2= 0 then exit(t*t mod m);\n exit(((t*t mod m)*a)mod m);\nend;\n{------------------------}\nprocedure nhap;\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n readln(n,m);\n if power(3,n)=0 then write(m-1)\n else write(power(3,n)-1);\n close(input);\n close(output);\nend;\n{------------------------}\nbegin\n nhap;\nend.\n", "src_uid": "c62ad7c7d1ea7aec058d99223c57d33c"} {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n w, h, i, j: integer;\n res: int64;\nbegin\n readln(w, h);\n res := 0;\n for i := 1 to w - 1 do\n for j := 1 to h - 1 do\n res := res + int64(min(i, w - i) * min(j, h - j));\n writeln(res);\n readln;\nend.\n", "src_uid": "42454dcf7d073bf12030367eb094eb8c"} {"source_code": "var s,a: string;\npr, i, res: integer;\nbegin\nreadln (s);\na:= ' ';\ns:=s+a;\npr:=0;\nres:=0;\nfor i:=1 to length(s) do\nbegin\ninc(pr);\nif (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] = ' ') then\nbegin\nif res1 then begin\n d1:=abs(pos-l);\n mdist:=d1;\n end;\n if r<>n then begin\n d2:=abs(pos-r);\n mdist:=min(mdist,d2);\n end;\n if mdist <> 255 then inc(res,mdist+1);\n if (l<>1) and (r<>n) then inc(res,r-l+1);\n write(res); \nEND.", "src_uid": "5deaac7bd3afedee9b10e61997940f78"} {"source_code": "var n,k,i,du :byte;\n d:real;\n a:array[1..100] of byte;\nbegin\n read(n,k);\n if n mod k =0 then for i:=1 to k do write(n div k,' ');\n if n mod k<>0 then\n begin\n for i:=1 to k do\n a[i]:=n div k;\n du:= n mod k;\n for i:=k downto k-du+1 do inc(a[i]);\n for i:=1 to k do write(a[i],' ');\n end;\n readln;\n readln\nend.", "src_uid": "0b2c1650979a9931e00ffe32a70e3c23"} {"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 xx:array[-10..200000,0..6] of int64;\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 good(p:int64):boolean;\nvar t,t1,t2:int64; flag:boolean; k,i,j:longint;\nbegin\n flag:=true;\n for i:=1 to n do for j:=i+1 to n do\n begin\n t:=0;\n for k:=1 to 5 do t:=t+(xx[i,k]-xx[p,k])*(xx[j,k]-xx[p,k]);\n\n if t>0 then flag:=false;\n\n end;\n\n good:=flag;\n\nend;\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 n do for j:=1 to 5 do read(xx[i,j]);\n if n>=100 then begin write(0); goto 1; end;\n\n {for i:=1 to n do write(good(i),' ');\n }\n\n for i:=1 to n do if good(i) then begin inc(ot); a[ot]:=i; end;\n\n writeln(ot);\n for i:=1 to ot do write(a[i],' ');\n\n\n 1: close(output);\nend.\n\n", "src_uid": "c1cfe1f67217afd4c3c30a6327e0add9"} {"source_code": "program TaskA;\nvar\n k,i,x:int64;\nbegin\n read(x);\n i:=0; k:=0;\n while i+k='0') and (s[x]<='9') then begin a[c]:=strtoint(s[x]); c:=c+1; end;\n end;\nSystem.Array.Sort(a);\nFor var x:=0 to a.Length-1 do \n begin\n if a[x]<>0 then\n begin\n if x<>a.Length-1 then write(a[x],'+')\n Else write(a[x]);\n end;\n end;\nend.\n", "src_uid": "76c7312733ef9d8278521cf09d3ccbc8"} {"source_code": "Program ILoveYou;\nVAR n,nr,putere,d:int64;\nBegin\n\nReadln(n);\nnr:=1;\nputere:=4;\nwhile (nr <= n) do\nBegin\n\nif (n mod nr = 0) then d:=nr;\nnr:=nr*2 + putere;\nputere:=putere*4;\n\nend;\n\nWriteln(d);\n\nReadln;\nEND.", "src_uid": "339246a1be81aefe19290de0d1aead84"} {"source_code": "const\n maxn=2005;\n maxm=maxn*maxn;\nvar\n //key 0=arbitrarily,1=order,2=bidirection\n //dir 0=null,1=left,2=right\n n,tail,pp,root,i,j,times:longint;\n map:array[0..maxn,0..maxn]of char;\n key,tot,st,en,fx,size,s,tmp:array[0..maxn*3]of longint;\n rev:array[0..maxn*3]of boolean;\n que:array[0..maxn]of longint;\n adj:array[0..maxm]of longint;\n next:array[0..maxm,0..1]of longint;\n c:ansistring;\nprocedure ins(x,y:longint);\nbegin\n inc(tail); adj[tail]:=y; inc(tot[x]);\n if st[x]=0 then begin\n next[tail,0]:=0; next[tail,1]:=0; st[x]:=tail; en[x]:=tail; fx[x]:=1;\n end else begin\n next[tail,0]:=en[x]; next[tail,1]:=0; next[en[x],1]:=tail; en[x]:=tail;\n end;\nend;\nprocedure prep;\nvar\n i:longint;\nbegin\n pp:=n+1; root:=n+1;\n for i:=1 to n do ins(root,i);\nend;\nprocedure renew(x:longint);\nvar\n i:longint;\nbegin\n if x<=n then begin\n inc(times);\n size[x]:=1; if c[x]='1' then s[x]:=1 else s[x]:=0;\n exit;\n end;\n size[x]:=0; s[x]:=0; i:=st[x];\n while i<>0 do begin\n renew(adj[i]); size[x]:=size[x]+size[adj[i]]; s[x]:=s[x]+s[adj[i]];\n i:=next[i,fx[x]];\n end;\nend;\nprocedure swap(var x,y:longint);\nvar\n t:longint;\nbegin\n t:=x;x:=y;y:=t;\nend;\nprocedure reverse(x:longint);\nbegin\n swap(st[x],en[x]); fx[x]:=fx[x] xor 1;\nend;\nprocedure pass(x:longint);\nvar\n i:longint;\nbegin\n if rev[x] then begin\n reverse(x);\n i:=st[x];\n while i<>0 do begin\n rev[adj[i]]:=not rev[adj[i]];\n i:=next[i,fx[x]];\n end;\n rev[x]:=false;\n end;\nend;\nprocedure fail;\nbegin\n writeln('NO');\n close(input);close(output);\n halt;\nend;\nprocedure change(x:longint);\nbegin\n if key[x]<>2 then fail;\n key[x]:=1; rev[x]:=not rev[x]; pass(x);\nend;\nfunction solve(x,dir:longint):longint;\nvar\n i,j,k,p,q,newp,cnt,total:longint;\n all,res,emp,tmp:array[0..maxn*3]of longint;\n flag:boolean;\nbegin\n pass(x);\n if x<=n then exit(x);\n if key[x]=0 then begin\n all[0]:=0; emp[0]:=0; res[0]:=0; tmp[0]:=0;\n i:=st[x];\n while i<>0 do begin\n if size[adj[i]]=s[adj[i]] then begin inc(all[0]); all[all[0]]:=adj[i]; end else\n if s[adj[i]]=0 then begin inc(emp[0]); emp[emp[0]]:=adj[i]; end else\n begin inc(res[0]); res[res[0]]:=adj[i]; end;\n i:=next[i,fx[x]];\n end;\n if res[0]>2 then fail;\n if not ((dir=0)or(res[0]<2)) then fail;\n if (dir=0)and(all[0]=0)and(res[0]=1) then begin\n i:=st[x];\n while i<>0 do begin\n if adj[i]=res[1] then begin\n adj[i]:=solve(res[1],0); exit(x);\n end;\n i:=next[i,fx[x]];\n end;\n end;\n //all\n if all[0]=0 then j:=0 else\n if (all[0]=1) then j:=all[1] else begin\n inc(pp); j:=pp; key[j]:=0;\n for k:=1 to all[0] do ins(j,all[k]);\n end;\n //merge res,all\n if (dir<>1)and(res[0]>0) then begin\n inc(tmp[0]);\n tmp[tmp[0]]:=solve(res[1],2);\n end;\n if (j>0) then begin inc(tmp[0]); tmp[tmp[0]]:=j; end;\n if (dir<>2)and((dir=0)and(res[0]>=2)or(dir<>0)and(res[0]>=1)) then begin\n inc(tmp[0]); tmp[tmp[0]]:=solve(res[res[0]],1);\n end;\n //use p\n if tmp[0]=1 then p:=tmp[1] else begin\n inc(pp); p:=pp; key[p]:=2;\n for k:=1 to tmp[0] do ins(p,tmp[k]);\n end;\n //use q\n if emp[0]=0 then q:=p else begin\n inc(pp); q:=pp;\n if dir=0 then begin\n key[q]:=0;\n for k:=1 to emp[0] do ins(q,emp[k]);\n ins(q,p);\n end else begin\n if emp[0]=1 then newp:=emp[1] else begin\n inc(pp); newp:=pp; key[newp]:=0;\n for k:=1 to emp[0] do ins(newp,emp[k]);\n end;\n key[q]:=1;\n if dir=1 then begin ins(q,p); ins(q,newp); end\n else begin ins(q,newp); ins(q,p); end;\n end;\n end;\n exit(q);\n end else begin\n j:=adj[st[x]]; k:=adj[en[x]];\n if ((dir=1) and not((size[j]=s[j]) or ((s[j]<>0) and (size[k]<>s[k]))))then change(x);\n if ((dir=2) and not((size[k]=s[k]) or ((s[k]<>0) and (size[j]<>s[j]))))then change(x);\n i:=st[x]; j:=-1; flag:=false; cnt:=0; total:=0; k:=0;\n while i<>0 do begin\n if size[adj[i]]=s[adj[i]] then k:=2 else\n if s[adj[i]]=0 then k:=0 else k:=1;\n if j<>-1 then begin\n if (k>j)and(dir=1) then fail;\n if (k0) then flag:=true;\n if (flag)and(k>0)and(j=0) then fail;\n end;\n j:=k;\n if k=1 then inc(cnt);\n if k>0 then inc(total);\n i:=next[i,fx[x]];\n end;\n if (dir=0)and(cnt>2)or(dir<>0)and(cnt>1) then fail;\n cnt:=0; i:=st[x];\n while i<>0 do begin\n j:=s[adj[i]];\n if (j>0)and(j0 then inc(cnt);\n i:=next[i,fx[x]];\n end;\n exit(x);\n end;\nend;\nprocedure dfs(x:longint);\nvar\n i:longint;\nbegin\n pass(x);\n if x<=n then begin inc(que[0]); que[que[0]]:=x; end;\n i:=st[x];\n while i<>0 do begin\n dfs(adj[i]);\n i:=next[i,fx[x]];\n end;\nend;\nbegin\n readln(n);\n fillchar(st,sizeof(st),0); fillchar(en,sizeof(en),0);\n fillchar(tot,sizeof(tot),0); fillchar(rev,sizeof(rev),false);\n prep;\n for i:=1 to n do begin\n readln(c); times:=0;\n for j:=1 to n do map[i][j]:=c[j];\n renew(root);\n if s[root]=0 then continue;\n root:=solve(root,0);\n end;\n que[0]:=0; dfs(root);\n if que[0]b) then c:=3\n else begin\n if (a=1)and(b=3) and (a<>b) then c:=2\n else begin\n if (a=2)and(b=1) and (a<>b) then c:=3\n else begin\n if (a=2)and(b=3) and (a<>b) then c:=1\n else begin\n if (a=3)and(b=1)and (a<>b) then c:=2\n else begin\n if (a=3)and(b=2)and (a<>b) then c:=1\n end;\n end;end;end;end;\n writeln(c);\n end.", "src_uid": "e167dc35a0d3b98c0414c66099e35920"} {"source_code": "var\n x,s,i,a,b,t:longint;\nbegin\n read(a,b);\n if a>b then\n begin\n t:=a; a:=b; b:=t;\n end;\n x:=abs(a+b) div 2;\n s:=0;\n for i:=a to x-1 do s:=s+i-a+1;\n for i:=b downto x+1 do s:=s+b-i+1;\n writeln(s);\nend.", "src_uid": "d3f2c6886ed104d7baba8dd7b70058da"} {"source_code": "const\n size: longint = 8;\n md: int64 = 1000 * 1000 * 1000 + 7;\n\ntype\n vector = record\n vect: array[1..20] of int64;\n end;\n matrix = record\n matr: array[1..20, 1..20] of int64;\n end;\n\nvar\n l, r, ans: int64;\n a: matrix;\n x: vector;\n\nfunction create_vector: vector;\nvar i: longint; v: vector;\nbegin\n for i := 1 to size do\n v.vect[i] := 0;\n create_vector := v;\nend;\n\nfunction create_matrix: matrix;\nvar i, j: longint; z: matrix;\nbegin\n for i := 1 to size do\n for j := 1 to size do\n z.matr[i, j] := 0;\n create_matrix := z;\nend;\n\nfunction create_eye_matrix: matrix;\nvar i, j: longint; e: matrix;\nbegin\n for i := 1 to size do\n for j := 1 to size do\n if i = j then\n e.matr[i, j] := 1\n else\n e.matr[i, j] := 0;\n create_eye_matrix := e;\nend;\n\nfunction matrix_matrix_product(a, b: matrix): matrix;\nvar i, j, k: longint; c: matrix;\nbegin\n c := create_matrix;\n for i := 1 to size do\n for j := 1 to size do\n for k := 1 to size do\n c.matr[i, j] := (c.matr[i, j] + a.matr[i, k] * b.matr[k, j]) mod md;\n matrix_matrix_product := c;\nend;\n\nfunction matrix_sum(a, b: matrix): matrix;\nvar i, j: longint; c: matrix;\nbegin\n c := create_matrix;\n for i := 1 to size do\n for j := 1 to size do\n c.matr[i, j] := (a.matr[i, j] + b.matr[i, j]) mod md;\n matrix_sum := c;\nend;\n\nfunction matrix_vector_product(a: matrix; x: vector): vector;\nvar i, j: longint; b: vector;\nbegin\n b := create_vector;\n for i := 1 to size do\n for j := 1 to size do\n b.vect[i] := (b.vect[i] + a.matr[i, j] * x.vect[j]) mod md;\n matrix_vector_product := b;\nend;\n\nfunction matrix_pow(a: matrix; p: int64): matrix;\nvar b: matrix;\nbegin\n if p = 0 then begin\n matrix_pow := create_eye_matrix;\n exit;\n end;\n if p mod 2 = 0 then begin\n b := matrix_pow(a, p div 2);\n matrix_pow := matrix_matrix_product(b, b);\n end else\n matrix_pow := matrix_matrix_product(a, matrix_pow(a, p - 1));\nend;\n\nfunction sum_of_vector_components(v: vector): int64;\nvar i: longint; s: int64;\nbegin\n s := 0;\n for i := 1 to size do s := (s + v.vect[i]) mod md;\n sum_of_vector_components := s;\nend;\n\nfunction pow(a, p: int64): int64;\nvar b: int64;\nbegin\n if p = 0 then begin\n pow := 1;\n exit;\n end;\n if p mod 2 = 0 then begin\n b := pow(a, p div 2);\n pow := (b * b) mod md;\n end else\n pow := (a * pow(a, p - 1)) mod md;\nend;\n\nfunction inverse(a: int64): int64;\nbegin\n inverse := pow(a, md - 2);\nend;\n\nfunction get_matrix_product(n: int64): matrix; // (E + A) * (E + A^2) * ... * (E + A^b)\nvar i: longint; m: matrix;\nbegin\n m := create_eye_matrix;\n i := 1;\n while i <= n do begin\n m := matrix_matrix_product(m, matrix_sum(create_eye_matrix, matrix_pow(a, i)));\n i := i * 2;\n end;\n get_matrix_product := m;\nend;\n\nfunction get_matrix_sum(n: int64): matrix; // E + A + A^2 + ... + A^n\nvar a1, a2, m1, m2: matrix; b: int64;\nbegin\n if n = 0 then begin\n get_matrix_sum := create_eye_matrix;\n exit;\n end;\n if n = 1 then begin\n get_matrix_sum := matrix_sum(create_eye_matrix, a);\n exit;\n end;\n b := 1;\n while 2 * b - 1 <= n do b := b * 2;\n b := b div 2;\n a1 := get_matrix_product(b);\n a2 := create_matrix;\n if n > 2 * b - 1 then begin\n m1 := matrix_pow(a, 2 * b);\n m2 := get_matrix_sum(n - 2 * b);\n a2 := matrix_matrix_product(m1, m2);\n end;\n get_matrix_sum := matrix_sum(a1, a2);\nend;\n\nfunction get_full(l, r: int64): int64;\nvar m, m1, m2: matrix; v: vector;\nbegin\n m1 := matrix_pow(a, l - 2);\n m2 := get_matrix_sum(r - l);\n m := matrix_matrix_product(m1, m2);\n v := matrix_vector_product(m, x);\n get_full := (sum_of_vector_components(v) * inverse(2)) mod md;\nend;\n\nfunction get_palind(l, r: int64): int64;\nbegin\n if l mod 2 = 0 then inc(l);\n if r mod 2 = 0 then dec(r);\n if l > r then\n get_palind := 0\n else begin\n l := (l + 1) div 2;\n r := (r + 1) div 2;\n get_palind := get_full(l, r);\n end;\nend;\n\nfunction get_answer(l, r: int64): int64;\nvar a, b: int64;\nbegin\n a := get_full(l, r);\n b := get_palind(l, r);\n get_answer := (a + b) mod md;\nend;\n\nprocedure init_dp;\nvar i: longint;\nbegin\n x := create_vector;\n for i := 1 to size do x.vect[i] := 1;\n a := create_matrix;\n a.matr[1, 3] := 1; a.matr[1, 7] := 1;\n a.matr[2, 3] := 1; a.matr[2, 7] := 1;\n a.matr[3, 1] := 1;\n a.matr[4, 5] := 1;\n a.matr[5, 4] := 1; a.matr[5, 8] := 1;\n a.matr[6, 4] := 1; a.matr[6, 8] := 1;\n a.matr[7, 2] := 1; a.matr[7, 6] := 1;\n a.matr[8, 2] := 1; a.matr[8, 6] := 1;\nend;\n\nbegin\n read(l, r);\n ans := 0;\n if (l = 1) and (r = 1) then begin\n writeln(4);\n halt;\n end;\n if (l = 1) then begin\n ans := 4;\n l := 2;\n end;\n init_dp;\n ans := (ans + get_answer(l, r)) mod md;\n writeln(ans);\nend.", "src_uid": "e04b6957d9c1659e9d2460410cb57f10"} {"source_code": "var\n st:ansistring;\n i,ak:longint;\nbegin\n readln(st);\n st:=lowercase(st);\n ak:=0;\n for i:=1 to length(st) do\n if st[i] in ['a','e','i','o','u','y'] then ak:=ak+1\n else write('.',st[i]);\n if ak>=maxlongint then writeln('\u6211\u597d\u5f3a\u554a\uff01I AK IOI\uff01\uff08\u6b64\u53e5\u5212\u53bb')\nend.", "src_uid": "db9520e85b3e9186dd3a09ff8d1e8c1b"} {"source_code": "var a:array[1..5] of int64;\n n:longint;\n i:longint;\nbegin\n n:=0;\n for i:=1 to 5 do\n begin\n read(a[i]);\n n:=n+a[i];\n end;\n if (n mod 5=0) and (n<>0) then\n write(n div 5)\n else\n write('-1');\nend.", "src_uid": "af1ec6a6fc1f2360506fc8a34e3dcd20"} {"source_code": "program factory_lights;\nvar a,b:array [1..100] of integer;\nn,m,i,j:integer ;\nbegin\n read(n,m);\n for i:=1 to m do\n read (a[i]); //input\n\n for i:=1 to m do\n for j:=a[i] to n do\n if b[j]=0 then b[j]:=a[i]; //calculations\n\n\n for j:=1 to n do\n write(b[j],' ');\nend.", "src_uid": "2e44c8aabab7ef7b06bbab8719a8d863"} {"source_code": "\nvar b,w: longint;\nc: array[0..9,0..9] of char;\nprocedure Getdata;\n var i,j: longint;\n begin\n for i:=1 to 8 do\n begin\n for j:=1 to 8 do\n begin\n\n read(c[i][j]);\n end;\n readln;\n end;\n end;\nfunction Min(a,b: longint): longint;\n begin\n if a max_hor) then exit(false);\n rest := k - min_hor;\n if rest mod 2 = 1 then exit(false);\n exit(true);\nend;\n\nprocedure do_reconstruct;\nbegin\n if not need_reconstruct then exit();\nend;\n\nbegin\n read(ntest);\n while ntest > 0 do begin\n dec(ntest);\n read(n, m, k);\n \n if not check_sol then begin\n writeln('NO');\n continue;\n end;\n writeln('YES');\n do_reconstruct;\n end;\nend.\n", "src_uid": "4d0c0cc8faca62eb6384f8135b30feb8"} {"source_code": "program ex_1;\nvar i,j,k,l:longint;\n s1,s2,s3:string;\n ff:boolean;\nbegin\n ff:=false;\n readln(s1);\n readln(s2);\n readln(s3);\n {if s1[1]=s3[1] then\n if s1[2]=s3[2] then\n if s1[3]=s3[3] then\n ff:=true;\n \n \n if s1[1]=s1[3] then\n if s2[1]=s2[3] then\n if s3[1]=s3[3] then\n ff:=true;\n \n if s1[1]=s3[3] then\n if s1[2]=s3[2] then\n if s2[1]=s2[3] then\n begin\n ff:=true; \n writeln('-1');\n end; }\n \n if s3[3]=s1[1] then \n if s3[1]=s1[3] then\n if s1[2]=s3[2] then\n if s2[1]=s2[3] then\n ff:=true; \n \n \n if ff then\n write('YES')\n else\n write('NO');\n \n \nend.", "src_uid": "6a5fe5fac8a4e3993dc3423180cdd6a9"} {"source_code": "var\n\tn,i:longint;\n\tans,sum:int64;\nbegin\n\treadln(n);\n\tans:=1;sum:=1;\n\tfor i:=2 to n do ans:=ans*i mod 1000000007;\n\tfor i:=1 to n-1 do sum:=sum*2 mod 1000000007;\n\tans:=((ans-sum)mod 1000000007+1000000007)mod 1000000007;\n\twriteln(ans);\nend.\n", "src_uid": "3dc1ee09016a25421ae371fa8005fce1"} {"source_code": "{$APPTYPE CONSOLE}\n\nvar\n s: string;\n i: integer;\n\nfunction qwe(x: char): boolean;\nbegin\n result:=(x<='z')and(x>='a')\nend;\n\nbegin\n readln(s);\n for i:=2 to length(s) do\n begin\n if qwe(s[i]) then\n begin\n writeln(s);\n readln;\n halt(0);\n end;\n end;\n if qwe(s[1]) then\n write(chr(ord(s[1]) + ord('A') - ord('a'))) else\n write(chr(ord(s[1]) + ord('a') - ord('A')));\n for i:=2 to length(s) do\n write(chr(ord(s[i]) + ord('a') - ord('A')));\n readln;\nend.", "src_uid": "db0eb44d8cd8f293da407ba3adee10cf"} {"source_code": "var\n i,j,n,m,k,t,x:longint;\n c:char;\n s:ansistring;\n\nfunction check(s:ansistring):boolean;\nvar\n i,n:longint;\nbegin\n n:=length(s);\n for i:=1 to n shr 1 do if s[i]<>s[n-i+1] then exit(false);\n exit(true);\nend;\n\nbegin\n readln(s);\n n:=length(s);\n for c:='a' to 'z' do if check(c+s)then begin writeln(c,s);halt;end;\n for i:=1 to n-1 do for c:='a' to 'z' do if check(copy(s,1,i)+c+copy(s,i+1,n-i))then\n begin writeln(copy(s,1,i)+c+copy(s,i+1,n-i));halt;end;\n for c:='a' to 'z' do if check(s+c)then begin writeln(s,c);halt;end;\n writeln('NA');\nend.\n", "src_uid": "24e8aaa7e3e1776adf342ffa1baad06b"} {"source_code": "var a,b:array[0..10000] of longint;\n i,j,t,n,m:longint;\nbegin\n//assign(input,'a.inp');reset(input);\n//assign(output,'a.out');rewritE(output);\nreadln(n,m);\nfor i:=1 to n do\n begin\n read(a[i]);\n end;\nfor i:=1 to m do\n read(b[i]);\nfor i:=1 to m do\n for j:=i+1 to m do\n if b[i]a[j] then begin srav:=false; goto 44; end;\n if a[i]=a[j] then if a1[i]x2 then fl:=false;\n if yyy2 then fl:=false;\n\n\n\n\n good:=fl;\n\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(ss);\n if odd(ord(ss[7])) then writeln(1) else writeln(0);\n goto 1;\n\n read(n,m);\n for i:=1 to n do for j:=1 to m do read(dd1[i,j]);\n dd[1,1]:=dd1[i,j]; dd[0,1]:=dd1[1,1];\n for i:=1 to n do for j:=1 to m do\n dd[i,j]:=max(dd1[i,j] and dd[i-1,j],dd1[i,j] and dd[i,j-1]);\n\n for i:=1 to n do begin for j:=1 to m do write(dd1[i,j],' '); writeln; end;\n writeln;\n\n for i:=1 to n do begin for j:=1 to m do write(dd[i,j],' '); writeln; end;\n\n\n\n\n\n\n\n\n \n \n \n 1: close (output);\n end. \n", "src_uid": "e52bc741bb72bb8e79cf392b2d15354f"} {"source_code": "var s:string;\n res,ans,n,i:longint;\n a:array[1..6]of longint;\n begin\n //assign(input,'input.txt');reset(input);\n //assign(output,'output.txt');rewrite(output);\n readln(s);\n n:=length(s);\n for i:=1 to n do\n if(s[i]='R')then inc(a[1]) else\n if(s[i]='O')then inc(a[2]) else\n if(s[i]='Y')then inc(a[3]) else\n if(s[i]='G')then inc(a[4]) else\n if(s[i]='B')then inc(a[5]) else\n if(s[i]='V')then inc(a[6]);\n for i:=1 to 6 do\n if(a[i]>0)then\n begin\n inc(res);\n if(a[i]>ans)then ans:=a[i];\n end;\n if(res=1)and(ans=6)then writeln(1)\n else\n if(res=2)and(ans=5)then writeln(1)\n else\n if(res=2)then writeln(2)\n else\n if(res=3)and(ans=2)then writeln(6)\n else\n if(res=3)and(ans=3)then writeln(3)\n else\n if(res=3)then writeln(2)\n else\n if(res=4)and(ans=3)then writeln(5)\n else\n if(res=4)then writeln(8)\n else\n if(res=5)then writeln(15)\n else writeln(30);\n close(input);close(output);\n end.", "src_uid": "8176c709c774fa87ca0e45a5a502a409"} {"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 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 ysum,yold,x1,x0,d,xx,yy,b,a,zsum,y,x,z:array[-200000..5350002] 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]=f then Writeln('YES');\n readln;\n end.\n", "src_uid": "5fdaf8ee7763cb5815f49c0c38398f16"} {"source_code": "const t:array[1..2500]of longint=(0,0,0,0,0,1,1,1,1,2,2,5,7,10,10,10,10,11,11,14,16,19,19,26,32,39,43,52,58,65,65,65,65,66,66,69,71,74,74,81,87,94,98,107,113,120,120,135,149,164,176,193,207,222,230,251,269,288,300,321,335,350,350,350,350,351,351,354,356,359,359,366,372,379,383,392,398,405,405,420,434,449,461,478,492,507,515,536,554,573,585,606,620,635,635,666,696,727,755,788,818,849,873,910,944,979,1007,1044,1074,1105,1121,1166,1208,1251,1287,1332,1370,1409,1433,1482,1524,1567,1595,1640,1670,1701,1701,1701,1701,1702,1702,1705,1707,1710,1710,1717,1723,1730,1734,1743,1749,1756,1756,1771,1785,1800,1812,1829,1843,1858,1866,1887,1905,1924,1936,1957,1971,1986,1986,2017,2047,2078,2106,2139,2169,2200,2224,2261,2295,2330,2358,2395,2425,2456,2472,2517,2559,2602,2638,2683,2721,2760,2784,2833,2875,2918,2946,2991,3021,3052,3052,3115,3177,3240,3300,3365,3427,3490,3546,3615,3681,3748,3808,3877,3939,4002,4050,4127,4201,4276,4344,4421,4491,4562,4618,4699,4773,4848,4908,4985,5047,5110,5142,5235,5325,5416,5500,5593,5679,5766,5838,5935,6025,6116,6192,6285,6363,6442,6490,6595,6693,6792,6876,6977,7063,7150,7206,7311,7401,7492,7552,7645,7707,7770,7770,7770,7770,7771,7771,7774,7776,7779,7779,7786,7792,7799,7803,7812,7818,7825,7825,7840,7854,7869,7881,7898,7912,7927,7935,7956,7974,7993,8005,8026,8040,8055,8055,8086,8116,8147,8175,8208,8238,8269,8293,8330,8364,8399,8427,8464,8494,8525,8541,8586,8628,8671,8707,8752,8790,8829,8853,8902,8944,8987,9015,9060,9090,9121,9121,9184,9246,9309,9369,9434,9496,9559,9615,9684,9750,9817,9877,9946,10008,10071,10119,10196,10270,10345,10413,10490,10560,10631,10687,10768,10842,10917,10977,11054,11116,11179,11211,11304,11394,11485,11569,11662,11748,11835,11907,12004,12094,12185,12261,12354,12432,12511,12559,12664,12762,12861,12945,13046,13132,13219,13275,13380,13470,13561,13621,13714,13776,13839,13839,13966,14092,14219,14343,14472,14598,14725,14845,14978,15108,15239,15363,15496,15622,15749,15861,16002,16140,16279,16411,16552,16686,16821,16941,17086,17224,17363,17487,17628,17754,17881,17977,18134,18288,18443,18591,18748,18898,19049,19185,19346,19500,19655,19795,19952,20094,20237,20349,20518,20680,20843,20991,21156,21306,21457,21577,21746,21900,22055,22179,22336,22462,22589,22653,22842,23028,23215,23395,23584,23766,23949,24117,24310,24496,24683,24855,25044,25218,25393,25537,25738,25932,26127,26307,26504,26686,26869,27021,27222,27408,27595,27751,27940,28098,28257,28353,28570,28780,28991,29187,29400,29598,29797,29965,30182,30384,30587,30759,30964,31138,31313,31425,31650,31860,32071,32251,32464,32646,32829,32949,33166,33352,33539,33663,33852,33978,34105,34105,34105,34105,34106,34106,34109,34111,34114,34114,34121,34127,34134,34138,34147,34153,34160,34160,34175,34189,34204,34216,34233,34247,34262,34270,34291,34309,34328,34340,34361,34375,34390,34390,34421,34451,34482,34510,34543,34573,34604,34628,34665,34699,34734,34762,34799,34829,34860,34876,34921,34963,35006,35042,35087,35125,35164,35188,35237,35279,35322,35350,35395,35425,35456,35456,35519,35581,35644,35704,35769,35831,35894,35950,36019,36085,36152,36212,36281,36343,36406,36454,36531,36605,36680,36748,36825,36895,36966,37022,37103,37177,37252,37312,37389,37451,37514,37546,37639,37729,37820,37904,37997,38083,38170,38242,38339,38429,38520,38596,38689,38767,38846,38894,38999,39097,39196,39280,39381,39467,39554,39610,39715,39805,39896,39956,40049,40111,40174,40174,40301,40427,40554,40678,40807,40933,41060,41180,41313,41443,41574,41698,41831,41957,42084,42196,42337,42475,42614,42746,42887,43021,43156,43276,43421,43559,43698,43822,43963,44089,44216,44312,44469,44623,44778,44926,45083,45233,45384,45520,45681,45835,45990,46130,46287,46429,46572,46684,46853,47015,47178,47326,47491,47641,47792,47912,48081,48235,48390,48514,48671,48797,48924,48988,49177,49363,49550,49730,49919,50101,50284,50452,50645,50831,51018,51190,51379,51553,51728,51872,52073,52267,52462,52642,52839,53021,53204,53356,53557,53743,53930,54086,54275,54433,54592,54688,54905,55115,55326,55522,55735,55933,56132,56300,56517,56719,56922,57094,57299,57473,57648,57760,57985,58195,58406,58586,58799,58981,59164,59284,59501,59687,59874,59998,60187,60313,60440,60440,60695,60949,61204,61456,61713,61967,62222,62470,62731,62989,63248,63500,63761,64015,64270,64510,64779,65045,65312,65572,65841,66103,66366,66614,66887,67153,67420,67672,67941,68195,68450,68674,68959,69241,69524,69800,70085,70363,70642,70906,71195,71477,71760,72028,72313,72583,72854,73094,73391,73681,73972,74248,74541,74819,75098,75346,75643,75925,76208,76460,76745,76999,77254,77446,77763,78077,78392,78700,79017,79327,79638,79934,80255,80569,80884,81184,81501,81803,82106,82378,82707,83029,83352,83660,83985,84295,84606,84886,85215,85529,85844,86128,86445,86731,87018,87242,87587,87925,88264,88588,88929,89255,89582,89878,90223,90553,90884,91184,91517,91819,92122,92362,92715,93053,93392,93700,94041,94351,94662,94910,95255,95569,95884,96136,96453,96707,96962,97090,97471,97849,98228,98600,98981,99355,99730,100090,100475,100853,101232,101596,101977,102343,102710,103046,103439,103825,104212,104584,104973,105347,105722,106066,106459,106837,107216,107564,107945,108295,108646,108934,109343,109745,110148,110536,110941,111331,111722,112082,112491,112885,113280,113644,114041,114407,114774,115078,115495,115897,116300,116672,117077,117451,117826,118138,118547,118925,119304,119620,120001,120319,120638,120830,121271,121705,122140,122560,122997,123419,123842,124234,124675,125101,125528,125924,126353,126751,127150,127486,127935,128369,128804,129208,129645,130051,130458,130802,131243,131653,132064,132412,132825,133175,133526,133750,134215,134665,135116,135536,135989,136411,136834,137194,137651,138077,138504,138868,139297,139663,140030,140270,140735,141169,141604,141976,142413,142787,143162,143410,143851,144229,144608,144860,145241,145495,145750,145750,145750,145750,145751,145751,145754,145756,145759,145759,145766,145772,145779,145783,145792,145798,145805,145805,145820,145834,145849,145861,145878,145892,145907,145915,145936,145954,145973,145985,146006,146020,146035,146035,146066,146096,146127,146155,146188,146218,146249,146273,146310,146344,146379,146407,146444,146474,146505,146521,146566,146608,146651,146687,146732,146770,146809,146833,146882,146924,146967,146995,147040,147070,147101,147101,147164,147226,147289,147349,147414,147476,147539,147595,147664,147730,147797,147857,147926,147988,148051,148099,148176,148250,148325,148393,148470,148540,148611,148667,148748,148822,148897,148957,149034,149096,149159,149191,149284,149374,149465,149549,149642,149728,149815,149887,149984,150074,150165,150241,150334,150412,150491,150539,150644,150742,150841,150925,151026,151112,151199,151255,151360,151450,151541,151601,151694,151756,151819,151819,151946,152072,152199,152323,152452,152578,152705,152825,152958,153088,153219,153343,153476,153602,153729,153841,153982,154120,154259,154391,154532,154666,154801,154921,155066,155204,155343,155467,155608,155734,155861,155957,156114,156268,156423,156571,156728,156878,157029,157165,157326,157480,157635,157775,157932,158074,158217,158329,158498,158660,158823,158971,159136,159286,159437,159557,159726,159880,160035,160159,160316,160442,160569,160633,160822,161008,161195,161375,161564,161746,161929,162097,162290,162476,162663,162835,163024,163198,163373,163517,163718,163912,164107,164287,164484,164666,164849,165001,165202,165388,165575,165731,165920,166078,166237,166333,166550,166760,166971,167167,167380,167578,167777,167945,168162,168364,168567,168739,168944,169118,169293,169405,169630,169840,170051,170231,170444,170626,170809,170929,171146,171332,171519,171643,171832,171958,172085,172085,172340,172594,172849,173101,173358,173612,173867,174115,174376,174634,174893,175145,175406,175660,175915,176155,176424,176690,176957,177217,177486,177748,178011,178259,178532,178798,179065,179317,179586,179840,180095,180319,180604,180886,181169,181445,181730,182008,182287,182551,182840,183122,183405,183673,183958,184228,184499,184739,185036,185326,185617,185893,186186,186464,186743,186991,187288,187570,187853,188105,188390,188644,188899,189091,189408,189722,190037,190345,190662,190972,191283,191579,191900,192214,192529,192829,193146,193448,193751,194023,194352,194674,194997,195305,195630,195940,196251,196531,196860,197174,197489,197773,198090,198376,198663,198887,199232,199570,199909,200233,200574,200900,201227,201523,201868,202198,202529,202829,203162,203464,203767,204007,204360,204698,205037,205345,205686,205996,206307,206555,206900,207214,207529,207781,208098,208352,208607,208735,209116,209494,209873,210245,210626,211000,211375,211735,212120,212498,212877,213241,213622,213988,214355,214691,215084,215470,215857,216229,216618,216992,217367,217711,218104,218482,218861,219209,219590,219940,220291,220579,220988,221390,221793,222181,222586,222976,223367,223727,224136,224530,224925,225289,225686,226052,226419,226723,227140,227542,227945,228317,228722,229096,229471,229783,230192,230570,230949,231265,231646,231964,232283,232475,232916,233350,233785,234205,234642,235064,235487,235879,236320,236746,237173,237569,237998,238396,238795,239131,239580,240014,240449,240853,241290,241696,242103,242447,242888,243298,243709,244057,244470,244820,245171,245395,245860,246310,246761,247181,247634,248056,248479,248839,249296,249722,250149,250513,250942,251308,251675,251915,252380,252814,253249,253621,254058,254432,254807,255055,255496,255874,256253,256505,256886,257140,257395,257395,257906,258416,258927,259435,259948,260458,260969,261473,261990,262504,263019,263527,264044,264554,265065,265561,266086,266608,267131,267647,268172,268690,269209,269713,270242,270764,271287,271795,272320,272830,273341,273821,274362,274900,275439,275971,276512,277046,277581,278101,278646,279184,279723,280247,280788,281314,281841,282337,282890,283436,283983,284515,285064,285598,286133,286637,287190,287728,288267,288775,289316,289826,290337,290785,291358,291928,292499,293063,293636,294202,294769,295321,295898,296468,297039,297595,298168,298726,299285,299813,300398,300976,301555,302119,302700,303266,303833,304369,304954,305524,306095,306635,307208,307750,308293,308773,309374,309968,310563,311143,311740,312322,312905,313457,314058,314644,315231,315787,316376,316934,317493,317989,318598,319192,319787,320351,320948,321514,322081,322585,323186,323756,324327,324835,325408,325918,326429,326813,327450,328084,328719,329347,329984,330614,331245,331861,332502,333136,333771,334391,335028,335650,336273,336865,337514,338156,338799,339427,340072,340702,341333,341933,342582,343216,343851,344455,345092,345698,346305,346849,347514,348172,348831,349475,350136,350782,351429,352045,352710,353360,354011,354631,355284,355906,356529,357089,357762,358420,359079,359707,360368,360998,361629,362197,362862,363496,364131,364703,365340,365914,366489,366937,367634,368324,369015,369691,370384,371062,371741,372389,373086,373768,374451,375103,375788,376442,377097,377689,378394,379084,379775,380435,381128,381790,382453,383053,383750,384416,385083,385687,386356,386962,387569,388049,388770,389476,390183,390859,391568,392246,392925,393541,394254,394936,395619,396239,396924,397546,398169,398665,399386,400076,400767,401395,402088,402718,403349,403853,404550,405184,405819,406327,406964,407474,407985,408241,409006,409768,410531,411287,412052,412810,413569,414313,415082,415844,416607,417355,418120,418870,419621,420341,421118,421888,422659,423415,424188,424946,425705,426433,427210,427972,428735,429467,430232,430966,431701,432373,433166,433952,434739,435511,436300,437074,437849,438593,439386,440164,440943,441691,442472,443222,443973,444661,445462,446248,447035,447791,448580,449338,450097,450793,451586,452348,453111,453811,454576,455278,455981,456557,457382,458200,459019,459823,460644,461450,462257,463033,463858,464668,465479,466259,467072,467854,468637,469357,470190,471008,471827,472615,473436,474226,475017,475745,476570,477364,478159,478891,479688,480422,481157,481765,482614,483448,484283,485087,485924,486730,487537,488281,489122,489932,490743,491491,492304,493054,493805,494429,495278,496096,496915,497671,498492,499250,500009,500641,501466,502228,502991,503627,504392,505030,505669,506053,506942,507824,508707,509575,510460,511330,512201,513041,513930,514804,515679,516523,517400,518246,519093,519877,520774,521656,522539,523391,524276,525130,525985,526777,527666,528524,529383,530179,531040,531838,532637,533309,534222,535120,536019,536887,537788,538658,539529,540337,541242,542116,542991,543803,544680,545494,546309,546997,547910,548792,549675,550495,551380,552202,553025,553721,554610,555436,556263,556963,557792,558494,559197,559645,560590,561520,562451,563351,564284,565186,566089,566929,567866,568772,569679,570523,571432,572278,573125,573845,574790,575704,576619,577471,578388,579242,580097,580825,581746,582604,583463,584195,585056,585790,586525,587005,587966,588896,589827,590695,591628,592498,593369,594113,595050,595924,596799,597547,598424,599174,599925,600421,601366,602248,603131,603887,604772,605530,606289,606793,607682,608444,609207,609715,610480,610990,611501,611501,611501,611501,611502,611502,611505,611507,611510,611510,611517,611523,611530,611534,611543,611549,611556,611556,611571,611585,611600,611612,611629,611643,611658,611666,611687,611705,611724,611736,611757,611771,611786,611786,611817,611847,611878,611906,611939,611969,612000,612024,612061,612095,612130,612158,612195,612225,612256,612272,612317,612359,612402,612438,612483,612521,612560,612584,612633,612675,612718,612746,612791,612821,612852,612852,612915,612977,613040,613100,613165,613227,613290,613346,613415,613481,613548,613608,613677,613739,613802,613850,613927,614001,614076,614144,614221,614291,614362,614418,614499,614573,614648,614708,614785,614847,614910,614942,615035,615125,615216,615300,615393,615479,615566,615638,615735,615825,615916,615992,616085,616163,616242,616290,616395,616493,616592,616676,616777,616863,616950,617006,617111,617201,617292,617352,617445,617507,617570,617570,617697,617823,617950,618074,618203,618329,618456,618576,618709,618839,618970,619094,619227,619353,619480,619592,619733,619871,620010,620142,620283,620417,620552,620672,620817,620955,621094,621218,621359,621485,621612,621708,621865,622019,622174,622322,622479,622629,622780,622916,623077,623231,623386,623526,623683,623825,623968,624080,624249,624411,624574,624722,624887,625037,625188,625308,625477,625631,625786,625910,626067,626193,626320,626384,626573,626759,626946,627126,627315,627497,627680,627848,628041,628227,628414,628586,628775,628949,629124,629268,629469,629663,629858,630038,630235,630417,630600,630752,630953,631139,631326,631482,631671,631829,631988,632084,632301,632511,632722,632918,633131,633329,633528,633696,633913,634115,634318,634490,634695,634869,635044,635156,635381,635591,635802,635982,636195,636377,636560,636680,636897,637083,637270,637394,637583,637709,637836,637836,638091,638345,638600,638852,639109,639363,639618,639866,640127,640385,640644,640896,641157,641411,641666,641906,642175,642441,642708,642968,643237,643499,643762,644010,644283,644549,644816,645068,645337,645591,645846,646070,646355,646637,646920,647196,647481,647759,648038,648302,648591,648873,649156,649424,649709,649979,650250,650490,650787,651077,651368,651644,651937,652215,652494,652742,653039,653321,653604,653856,654141,654395,654650,654842,655159,655473,655788,656096,656413,656723,657034,657330,657651,657965,658280,658580,658897,659199,659502,659774,660103,660425,660748,661056,661381,661691,662002,662282,662611,662925,663240,663524,663841,664127,664414,664638,664983,665321,665660,665984,666325,666651,666978,667274,667619,667949,668280,668580,668913,669215,669518,669758,670111,670449,670788,671096,671437,671747,672058,672306,672651,672965,673280,673532,673849,674103,674358,674486,674867,675245,675624,675996,676377,676751,677126,677486,677871,678249,678628,678992,679373,679739,680106,680442,680835,681221,681608,681980,682369,682743,683118,683462,683855,684233,684612,684960,685341,685691,686042,686330,686739,687141,687544,687932,688337,688727,689118,689478,689887,690281,690676,691040,691437,691803,692170,692474,692891,693293,693696,694068,694473,694847,695222,695534,695943,696321,696700,697016,697397,697715,698034,698226,698667,699101,699536,699956,700393);\nvar i:longint;\nbegin\n readln(i);\n writeln(t[i]);\nend.", "src_uid": "838f2e75fdff0f13f002c0dfff0b2e8d"} {"source_code": "var\n n:string;\n p:boolean;\n i:longint;\nbegin\n readln(n);\n if length(n)<5 then begin writeln('Too weak');exit;end;\n p:=false;\n for i:=1 to length(n) do if n[i] in ['0'..'9'] then p:=true;\n if not(p) then begin writeln('Too weak');exit;end;\n p:=false;\n for i:=1 to length(n) do if n[i] in ['a'..'z'] then p:=true;\n if not(p) then begin writeln('Too weak');exit;end;\n p:=false;\n for i:=1 to length(n) do if n[i] in ['A'..'Z'] then p:=true;\n if not(p) then begin writeln('Too weak');exit;end;\n writeln('Correct');\nend.", "src_uid": "42a964b01e269491975965860ec92be7"} {"source_code": "var\n a:array[0..1025] of longint;\n n,i,j,k,t,l,tot,p:longint;\n total,answer,pl,pr,vl,vr,s1,s2:int64;\n\nfunction union(x1,y1,x2,y2:int64):int64;\n var\n t,r:int64;\n begin\n if x1>x2 then t:=x1 else t:=x2;\n if y1=t then union:=r-t+1 else union:=0;\n end;\n\nbegin\n t:=1;\n for i:=1 to 9 do\n begin\n t:=t*2;\n for j:=1 to t do\n begin\n l:=j-1;p:=1;\n inc(tot);\n a[tot]:=0;\n for k:=1 to i do\n begin\n if l mod 2=1 then a[tot]:=a[tot]+7*p else a[tot]:=a[tot]+4*p;\n p:=p*10;\n l:=l div 2;\n end;\n end;\n end;\n readln(pl,pr,vl,vr,k);\n total:=(pr-pl+1)*(vr-vl+1);\n answer:=0;\n a[0]:=0;a[tot+1]:=1000000001;\n for i:=1 to tot-k+1 do\n begin\n if (a[i]>=pl) and (a[i+k-1]<=vr) then\n begin\n s1:=union(pl,pr,a[i-1]+1,a[i]);\n s2:=union(vl,vr,a[i+k-1],a[i+k]-1);\n answer:=answer+s1*s2;\n end;\n if (a[i]>=vl) and (a[i+k-1]<=pr) then\n begin\n s1:=union(vl,vr,a[i-1]+1,a[i]);\n s2:=union(pl,pr,a[i+k-1],a[i+k]-1);\n answer:=answer+s1*s2;\n end;\n if (k=1) and (a[i]>=pl) and (a[i]<=pr) and (a[i]>=vl) and (a[i]<=vr) then answer:=answer-1;\n end;\n writeln(answer/total:0:12);\nend.\n\n\n", "src_uid": "5d76ec741a9d873ce9d7c3ef55eb984c"} {"source_code": "var\n n:longint;\nbegin\n readln(n);\n writeln((n-1) div 2);\nend.", "src_uid": "dfe9446431325c73e88b58ba204d0e47"} {"source_code": "var\n x,a,ans,i:longint;\n s:ansistring;\nbegin\n readln(x);\n if (x=0) then\n begin\n writeln(1);\n halt;\n end;\n while x>0 do\n begin\n a:=x mod 16;\n if a<10 then s:=chr(a+48)+s else s:=chr(a+55)+s;\n x:=x div 16;\n end;\n for i:=1 to length(s) do\n case s[i] of\n '0','4','6','9','A','D':inc(ans);\n '8','B':inc(ans,2);\n end;\n writeln(ans);\nend.", "src_uid": "16a784cb9953bc91cb2e7767b04b76f2"} {"source_code": "var\n p,i,r,j:longint;\n a,b,m,vx,vy,t,vz,l:extended;\nbegin\n readln(a,b,m);\n readln(vx,vy,vz);\n t:=-m/vy;\n if vx>=0 then\n begin\n l:=vx*t;\n if a/2>=l then l:=a/2+l else\n begin\n l:=l-a/2;\n p:=trunc(l/a);\n l:=l-p*a;\n if not(odd(p)) then l:=a-l;\n end;\n end else\n begin\n l:=-vx*t;\n if l<=a/2 then l:=a/2-l else\n begin\n l:=l-a/2;\n p:=trunc(l/a);\n l:=l-p*a;\n if odd(p) then l:=a-l;\n end;\n end;\n write(l:0:9,' ');\n l:=vz*t;\n p:=trunc(l/b);\n l:=l-p*b;\n if odd(p) then l:=b-l;\n writeln(l:0:9);\n\nend.\n", "src_uid": "84848b8bd92fd2834db1ee9cb0899cff"} {"source_code": "Var a:Array[1 .. 1000000] of Longint;\n n,count,rem,i,b,j,srem:Longint;\n OK:Boolean;\nBegin\n Readln(n);\n Readln(a[1]); a[2]:=0-a[1]; count:=2; rem:=2; OK:=False;\n For i:=2 to n do begin\n Readln(b);\n For j:=1 to rem do begin\n srem:=a[j];\n a[j]:=a[j]+b;\n Inc(count);\n a[count]:=srem-b;\n End;\n rem:=count;\n End;\n For i:=1 to count do\n If a[i] mod 360 = 0 then begin\n OK:=true;\n Break;\n End;\n If OK then writeln('YES') else writeln('NO');\nEnd.", "src_uid": "01b50fcba4185ceb1eb8e4ba04a0cc10"} {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, math;\n\ntype\n point = record\n x, y: integer;\n end;\n\nvar\n a, b, c: point;\n\nbegin\n readln(a.x, a.y);\n readln(b.x, b.y);\n readln(c.x, c.y);\n writeln(3);\n writeln(a.x + b.x - a.x + c.x - a.x, ' ', a.y + c.y - a.y + b.y - a.y);\n writeln(b.x + a.x - b.x + c.x - b.x, ' ', b.y + c.y - b.y + a.y - b.y);\n writeln(c.x + a.x - c.x + b.x - c.x, ' ', c.y + a.y - c.y + b.y - c.y);\n readln;\n readln\nend.\n", "src_uid": "7725f9906a1b87bf4e866df03112f1e0"} {"source_code": "var f:array[-4..53,-4..53,-4..53,0..53]of boolean;\n a:array[0..53]of string;\nfunction pd(i,j:longint):boolean;\nbegin\n if(i<1)or(j<1) then exit(false);\n if (a[i,1]=a[j,1])or(a[i,2]=a[j,2]) then exit(true) else exit(false);\nend;\nprocedure rec(x,y,z,step:longint);\nbegin\n if f[x,y,z,step]=false then exit;\n f[x,y,z,step]:=false;\n if step=1 then begin writeln('YES');halt;end;\n if pd(x,y) then rec(x,z,step-3,step-1);\n if pd(x,step-3) then rec(y,z,x,step-1);\nend;\nprocedure init;\nvar n,i:longint;\n s:string;\nbegin\n readln(n);\n readln(s);\n for i:=1 to n do a[i]:=s[i*3-2]+s[i*3-1];\n fillchar(f,sizeof(f),true);\n rec(n,n-1,n-2,n);\n writeln('NO');\nend;\nbegin\n init;\nend.", "src_uid": "1805771e194d323edacf2526a1eb6768"} {"source_code": "Const md=1000000009;\nVar n,k,m:int64;\nzz,l,r,v,rez:int64;\ni:longint;\nfunction pow(n,k:int64):int64;\nVar x:int64;\nbegin\n if k=0\n then pow:=1\n else begin\n x:=pow(n,k div 2);\n x:=(x*x) mod md;\n if k mod 2=1\n then x:=(x*n) mod md;\n pow:=x;\n end;\nend;\nfunction kol(n:int64):int64;\nVar z:int64;\nbegin\n if nn\n then begin\n r:=zz;\n continue;\n end\n else begin\n v:=n-zz*k;\n if v<0\n then v:=0;\n if v+zz*(k-1)>=m\n then l:=zz\n else r:=zz;\n end;\n end;\n zz:=l;\n if zz*(k-1)>m\n then begin\n writeln(m);\n halt(0); \n end\n else begin\n m:=m-zz*(k-1);\n rez:=(kol(m)+zz*(k-1)) mod md;\n writeln(rez);\n end;\nend.", "src_uid": "9cc1aecd70ed54400821c290e2c8018e"} {"source_code": "var x1,x2,y1,y2 :int64;\n d,r :int64;\nbegin\n readln(x1,y1);\n readln(x2,y2);\n r:=abs(x1-x2);\n d:=abs(y1-y2);\n if d>r then writeln(d)\n else writeln(r);\nreadln;\nend.", "src_uid": "a6e9405bc3d4847fe962446bc1c457b4"} {"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 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]b then min:=b else min:=a;end;\n procedure sort(l,r : longint);\n var\n i,j,x,t : longint;\n begin\n if l>=r then exit;\n x:=a[l+random(r-l)];\n i:=l-1;j:=r+1;\n while i=x;\n if i=h) and (b>=w)) or ((a1>=w) and (b>=h)) then begin writeln(0); halt; end;\n\n for i:=1 to n do read(a[i]);\n sort(1,n);\n fillchar(f,sizeof(f),0);\n ff[a1]:=b;\n for i:=1 to min(36,n) do\n begin\n f:=ff;\n for j:=1 to 100000 do\n if ff[j]<>0 then begin\n if ff[j]*a[i]<=100001 then\n begin\n f[j]:=ff[j]*a[i];\n if ((j>=h) and (ff[j]*a[i]>=w)) or ((j>=w) and (ff[j]*a[i]>=h)) then begin writeln(i); halt; end;\n end else\n begin\n f[j]:=100001;\n if (j>=h) or (j>=w) then begin writeln(i); halt; end;\n end;\n if int64(j)*a[i]<=100001 then\n begin\n f[j*a[i]]:=ff[j];\n if ((j*a[i]>=h) and (ff[j]>=w)) or ((j*a[i]>=w) and (ff[j]>=h)) then begin writeln(i); halt; end;\n end else\n begin\n f[100001]:=ff[j];\n if (ff[j]>=w) or (ff[j]>=h) then begin writeln(i); halt; end;\n end;\n end;\n ff:=f;\n end;\n writeln(-1);\nend.", "src_uid": "18cb436618b2b85c3f5dc348c80882d5"} {"source_code": "Var v,i,n,k,kol,a,b:longint;\nzz,m,pred,z:array [1..1000000] of longint;\nused:array [1..1000000] of boolean;\nf:boolean;\nprocedure add(i,j:longint);\nbegin\n inc(kol);\n m[kol]:=j;\n pred[kol]:=z[i];\n z[i]:=kol;\nend;\nfunction proverka(i1,j1:longint):boolean;\nVar i:longint;\nf:boolean;\nbegin\n f:=false;\n i:=z[i1];\n while i<>0 do\n begin\n if m[i]=j1\n then f:=true;\n i:=pred[i];\n end;\n proverka:=f;\nend;\nbegin\n // Assign(input,'input.txt'); reset(input);\n // Assign(output,'output.txt'); rewrite(output);\n read(n,k);\n randomize;\n if k5000\n then begin writeln(-1); halt(0); end;\n fillchar(used,sizeof(used),false);\n for i:=1 to n do\n begin\n while 1=1 do\n begin\n k:=random(n)+1;\n if not used[k]\n then begin\n used[k]:=true;\n break;\n end;\n end;\n zz[i]:=k;\n end;\n for i:=1 to v do\n if proverka(zz[i],zz[i+1])\n then f:=false;\n if f\n then begin\n for i:=1 to v do\n writeln(zz[i],' ',zz[i+1]);\n halt(0);\n end;\n end;\n end\n else begin\n if n<5\n then begin writeln(-1); halt(0); end;\n for i:=1 to k do\n begin\n read(a,b);\n add(a,b);\n add(b,a);\n end;\n v:=k;\n kol:=0;\n while 1=1 do\n begin\n f:=true;\n inc(kol);\n if kol>5000\n then begin writeln(-1); halt(0); end;\n fillchar(used,sizeof(used),false);\n for i:=1 to n do\n begin\n while 1=1 do\n begin\n k:=random(n)+1;\n if not used[k]\n then begin\n used[k]:=true;\n break;\n end;\n end;\n zz[i]:=k;\n end;\n for i:=1 to v-1 do\n if proverka(zz[i],zz[i+1])\n then f:=false;\n if proverka(zz[n],zz[1])\n then f:=false;\n if f\n then begin\n for i:=1 to v-1 do\n writeln(zz[i],' ',zz[i+1]);\n writeln(zz[n],' ',zz[1]);\n halt(0);\n end;\n end;\n end;\nend.", "src_uid": "c4c85cde8a5bb5fefa4eb68fc68657d5"} {"source_code": "var i,j,x,z,y,k,res,dem:longint;\n s:string;\nfunction min(a,b:longint):longint;\n begin\n if a>b then exit(b) else exit(a);\n end;\n\nbegin\nread(s);\nres:=6;\nfor i:=0 to 9 do\n for j:=0 to 9 do\n for k:=0 to 9 do\n for x:=0 to 9 do\n for y:=0 to 9 do\n for z:=0 to 9 do\n begin\n dem:=0;\n if i+j+k=x+y+z then\n begin\n if i<>ord(s[1])-48 then inc(dem);\n if j<>ord(s[2])-48 then inc(dem);\n if k<>ord(s[3])-48 then inc(dem);\n if x<>ord(s[4])-48 then inc(dem);\n if y<>ord(s[5])-48 then inc(dem);\n if z<>ord(s[6])-48 then inc(dem);\n res:=min(res,dem);\n end;\n end;\nwriteln(res); \nend.\n", "src_uid": "09601fd1742ffdc9f822950f1d3e8494"} {"source_code": "program lolcode;\n\n{ function max(a, b: Integer): Integer;\n begin\n if (a > b) then max:= a\n else max:= b;\n end;}\n\nvar\n tux, foo, bar, baz, quz: Integer;\n pur: Integer;\n res: Extended;\nbegin\n readln(tux);\n foo:= 0;\n bar:= 0;\n baz:= 0;\n quz:= 1;\n repeat\n dec(tux);\n readln(pur);\n foo:= foo + pur;\n bar:= bar + 1;\n if (foo*quz > bar*baz) then begin\n baz:= foo;\n quz:= bar;\n end;\n until (tux = 0);\n res:= baz / quz;\n writeln(res:6:6);\n readln;\nend.", "src_uid": "32fc378a310ca15598377f7b638eaf26"} {"source_code": "var\n s1,s2 : string;\n i : longint;\nbegin\n readln(s1);\n readln(s2);\n for i:=1 to length(s2) do\n if s1[i]<>s2[i] then write('1')\n else\n write('0');\nend.", "src_uid": "3714b7596a6b48ca5b7a346f60d90549"} {"source_code": "var g:array[1..500,1..500] of byte;\n n,m,u,v,i,j:longint;\n k:boolean;\n s:array[1..500] of byte;\nbegin\n readln(n,m);\n for i:=1 to m do\n begin\n readln(u,v);\n g[u,v]:=1;\n g[v,u]:=1;\n end;\n for i:=1 to n do\n begin\n k:=true;\n for j:=1 to n do\n begin\n if i=j then continue;\n if g[i,j]=0\n then\n begin\n k:=false;\n break;\n end;\n end;\n if k then\n s[i]:=1;\n end;\n for i:=1 to n do\n if s[i]=0\n then\n for j:=1 to n do\n begin\n if i=j then continue;\n if g[i,j]=0\n then\n s[j]:=2;\n end;\n for i:=1 to n do\n if s[i]=2\n then\n for j:=1 to n do\n begin\n if i=j then continue;\n if ((g[i,j]=0)and(s[j]=2))or((g[i,j]=1)and(s[j]=0))\n then\n begin\n writeln('NO');\n exit;\n end;\n end;\n writeln('YES');\n for i:=1 to n do\n begin\n case s[i] of\n 0:write('a');\n 1:write('b');\n 2:write('c');\n end;\n end;\nend.", "src_uid": "e71640f715f353e49745eac5f72e682a"} {"source_code": "var z,n,k,j,i,m,s:longint;x,y:array[0..2000]of longint;\nbegin\n read(n,m,x[1]);\n s:=0;k:=0;\n if odd(x[1]) then inc(s) else dec(s);\n for i:=2 to n do\n begin\n read(x[i]);\n if s=0 then begin\n z:=abs(x[i]-x[i-1]);\n j:=k;inc(k);while y[j]>z do begin y[j+1]:=y[j];dec(j);end;\n y[j+1]:=z;\n end;\n if odd(x[i]) then inc(s) else dec(s);\n end; \n for i:=1 to k do\n y[i]:=y[i]+y[i-1];\n y[k+1]:=m+m;\n i:=0;while y[i+1]<=m do inc(i);\n write(i);\nend.", "src_uid": "b3f8e769ee7719ea5c9f458428b16a4e"} {"source_code": " USES\n math;\n\n CONST\n fi = '';//106C.inp';\n fo = '';//106C.out';\n mmax = 1010;\n\n VAR\n ff : array [0.. mmax, 0.. 100] of longint;\n a,b,c,d : array [0.. mmax] of longint;\n n, m : longint;\n c0, d0 : longint;\n res : longint;\n f, g : text;\n\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 i: longint;\n begin\n readln(f, n, m, c0, d0);\n for i:= 1 to m do\n readln(f, a[i], b[i], c[i], d[i]);\n end;\n\n\n procedure process;\n var\n i, j, k, t: longint;\n begin\n for i:= 1 to n do\n begin\n for j:= 0 to i div c0 do\n ff[i, 0]:= max(ff[i, 0], ff[i- j* c0, 0]+ d0* j);\n\n for j:= 1 to m do\n begin\n for k:= 0 to i div c0 do\n ff[i, j]:= max(ff[i, j], ff[i- k* c0, j- 1]+ d[0]* j);\n\n for t:= 0 to a[j] div b[j] do\n if i>= t* c[j] then\n ff[i, j]:= max(ff[i, j], ff[i- t* c[j], j- 1]+ d[j]* t);\n end;\n end;\n write(ff[n, m]);\n end;\n\n\n BEGIN\n openf;\n readf;\n process;\n closef;\n END.\n", "src_uid": "4e166b8b44427b1227e0f811161d3a6f"} {"source_code": "program B;\nconst\n\tKx : array[1..4] of longint = (0,-1,0,1);\n\tKy : array[1..4] of longint = (-1,0,1,0);\nvar\n\tN,M: Integer;\n\tDN,DM:array[1..20] of longint;\n\tDir:array[0..22,0..22,1..4] of boolean;\n\tCheck:array[0..22,0..22] of boolean;\n\nprocedure Find(X,Y:longint);\nvar\n\ti: Integer;\nbegin\n\tif (X<1) or (X>N) then exit;\n\tif (Y<1) or (Y>M) then exit;\n\tCheck[X,Y]:=true;\n\tfor i:=1 to 4 do\n\t\tif (Dir[X,Y,i]) and (not Check[X+Kx[i],Y+Ky[i]]) then\n\t\t\tFind(X+Kx[i],Y+Ky[i]);\nend;\n\nprocedure Main();\nvar\n\ti,j,k,t: Integer;\n\tCh: char;\nbegin\n\treadln(N,M);\n\tfor i:=1 to N do\n\t\tbegin\n\t\t\tread(Ch);\n\t\t\tif Ch='<' then\n\t\t\t\tbegin\n\t\t\t\t\tDN[i]:=-1;\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tbegin\n\t\t\t\t\tDN[i]:=1;\n\t\t\t\tend;\n\t\tend;\n\treadln;\n\tfor i:=1 to M do\n\t\tbegin\n\t\t\tread(Ch);\n\t\t\tif ch='^' then\n\t\t\t\tbegin\n\t\t\t\t\tDM[i]:=-1;\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tbegin\n\t\t\t\t\tDM[i]:=1;\n\t\t\t\tend;\n\t\tend;\n\tfor i:=1 to N do\n\t\tfor j:=1 to M do\n\t\t\tbegin\n\t\t\t\tif DN[i]=-1 then Dir[i,j,1]:=true else Dir[i,j,3]:=true;\n\t\t\t\tif DM[j]=-1 then Dir[i,j,2]:=true else Dir[i,j,4]:=true;\n\t\t\tend;\n\tfor i:=1 to N do\n\t\tfor j:=1 to M do\n\t\t\tbegin\n\t\t\t\tfillchar(Check,sizeof(Check),False);\n\t\t\t\tFind(i,j);\n\t\t\t\tfor k:=1 to N do\n\t\t\t\t\tfor t:=1 to M do\n\t\t\t\t\t\tif not Check[k,t] then\n\t\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\t\twriteln('NO');\n\t\t\t\t\t\t\t\texit;\n\t\t\t\t\t\t\tend;\n\t\t\tend;\n\twriteln('YES');\nend;\n\nbegin\n\tMain();\nend.\n", "src_uid": "eab5c84c9658eb32f5614cd2497541cf"} {"source_code": "Program ILoveYou;\nVAR n,i,x:int64;\nBegin\n\n//I know there are faster ways to calculate the factorial, but since n <= 20, it shouldn't be a problem\n\nReadln(n);\nx:=1;\nfor i:=((n div 2) + 1) to n do\nBegin\nx:=x*i;\nend;\n\nfor i:=2 to (n div 2) do\nBegin\nx:=x div i;\nend;\nfor i:=2 to (n div 2) - 1 do\nBegin\nx:=x*(i*i);\nend;\nx:=x div 2;\n\nWriteln(x);\n\nReadln;\nEND.", "src_uid": "ad0985c56a207f76afa2ecd642f56728"} {"source_code": "const fi='';\n fo='';\nvar f:text;\n a,b:0..100;\nprocedure process;\nbegin\n assign(f,fi);reset(F);\n read(F,a,b);\n close(F);\n assign(f,fo);rewrite(F);\n if (abs(a-b)>1) or ( (a=0) and (b=0)) then write(f,'NO') else write(f,'YES');\n close(F);\nend;\n\nbegin\n process;\nend.", "src_uid": "ec5e3b3f5ee6a13eaf01b9a9a66ff037"} {"source_code": "var\nok:boolean;\nch:char;\neee,g,ii,n,m,k,i,j:longint;\nx1,y1,step:longword;\nee,nm,s,e:array[0..151,0..6]of longword;\n\nlabel nextt;\n\n begin\n readln(n,m,k);\n for i:=0 to 6 do\n begin\n ee[0,i]:=(1 shl 31)-1+(1 shl 31);\n ee[n+1,i]:=ee[0,i];\n end;\n\n for i:=1 to n do\n begin\n ee[i,0]:=ee[i,0]+1;\n ee[i,(m+1) shr 5]:=ee[i,(m+1) shr 5] or (1 shl ((m+1) and 31));\n for j:=1 to m do\n begin\n read(ch);\n if ch='#' then\n begin\n ee[i,j shr 5]:=ee[i,j shr 5] or (1 shl (j and 31));\n end else\n begin\n s[i,j shr 5]:=s[i,j shr 5] or (1 shl (j and 31));\n e[i,j shr 5]:=e[i,j shr 5] or (1 shl (j and 31));\n end;\n if ch='E' then\n begin\n x1:=i;\n y1:=j;\n end;\n end;\n readln;\n end;\n\n g:=m shr 5;\n\n for i:=1 to n do\n for j:=0 to g do\n if s[i,j]>0 then\n begin\n if i <> x1 then goto nextt;\n if j <> (y1 shr 5) then goto nextt;\n if s[i,j] <> (1 shl (y1 and 31)) then goto nextt;\n eee:=eee+1;\n if eee=2 then goto nextt;\n end;\n writeln(0);\n halt(0);\n\n nextt:\n for ii:=1 to k do\n begin\n read(ch);\n fillchar(nm,sizeof(nm),0);\n if ch='U' then\n begin\n for i:=1 to n do\n for j:=0 to g do\n begin\n nm[i-1,j]:=nm[i-1,j] or (s[i,j] and e[i-1,j]);\n nm[i,j]:=nm[i,j] or (ee[i-1,j] and s[i,j]);\n end;\n end;\n if ch='D' then\n begin\n for i:=n downto 1 do\n for j:=0 to g do\n begin\n nm[i+1,j]:=nm[i+1,j] or (s[i,j] and e[i+1,j]);\n nm[i,j]:=nm[i,j] or (ee[i+1,j] and s[i,j]);\n end;\n end;\n\n if ch='L' then\n begin\n for i:=1 to n do\n begin\n for j:=0 to g do\n begin\n if (j<>0)then\n begin\n if ((s[i,j] and 1)=1)and((e[i,j-1] and (1 shl 31))>0) then\n nm[i,j-1]:=nm[i,j-1] or (1 shl 31) else if (s[i,j] and 1)=1 then\n nm[i,j]:=nm[i,j] or 1;\n end else nm[i,j]:=nm[i,j] or (s[i,j]and 1);\n\n nm[i,j]:=nm[i,j] or ((s[i,j] shr 1)and e[i,j]);\n nm[i,j]:=nm[i,j] or (((s[i,j] shr 1)and ee[i,j]) shl 1);\n end;\n end;\n end;\n\n if ch='R' then\n begin\n for i:=1 to n do\n begin\n for j:=0 to g do\n begin\n if (j<>g)then\n begin\n if ((s[i,j] and (1 shl 31))>0)and((e[i,j+1] and 1)>0) then\n nm[i,j+1]:=nm[i,j+1] or 1 else if (s[i,j] and (1 shl 31))>0 then\n nm[i,j]:=nm[i,j] or (1 shl 31);\n end else nm[i,j]:=nm[i,j] or (s[i,j] and (1 shl 31));\n\n nm[i,j]:=nm[i,j] or ((((s[i,j] shl 1)and e[i,j]))and ee[0,0]);\n nm[i,j]:=nm[i,j] or (((((s[i,j] shl 1)and ee[i,j]) shr 1))and ee[0,0]);\n // if (ii=3)and(i=2)and(j=0) then writeln((((s[i,j] shl 1)and ee[i,j]) shr 1));\n end;\n end;\n end;\n\n s:=nm;\n eee:=0;{\n for i:=1 to n do\n begin\n for j:=0 to 31 do\n if (s[i,0] and (1 shl j))>0 then write(1)else write(0);\n for j:=0 to 31 do\n if (s[i,1] and (1 shl j))>0 then write(1)else write(0);\n writeln;\n end;\n }\n ok:=true;\n for i:=1 to n do\n for j:=0 to g do\n if s[i,j]>0 then\n begin\n if i <> x1 then ok:=false;\n if j <> (y1 shr 5) then ok:=false;\n if s[i,j] <> (longword(1) shl (y1 and 31)) then ok:=false;\n eee:=eee+1;\n if eee=2 then ok:=false;\n end;\n\n if ok then\n if eee=1 then\n begin\n writeln(ii);\n halt(0);\n end;\n\n end;\n writeln(-1);\n end.\n", "src_uid": "70ab617d9b8813ddf3039c6fb137d817"} {"source_code": "label 1,2;\nvar s,m:string;\np,i,d:byte;\nbegin\nreadln(s);\nm:='hello';\nif length(s)<5 then begin writeln('NO'); goto 1; end;\nd:=1; p:=0;\nfor i:=1 to length(s) do begin\nif s[i]=m[d] then begin d:=d+1; p:=p+1; end;\nif d>length(m) then goto 2; \nend;\n2:if p=5 then writeln('YES') else writeln('NO');\n1:end.", "src_uid": "c5d19dc8f2478ee8d9cba8cc2e4cd838"} {"source_code": "Const fi='';\n fo='';\nvar f1,f2:text;\n a,b,dem,nho:int64;\n\nbegin\n assign(f1,fi);\n assign(f2,fo);\n reset(f1);\n rewrite(f2);\n readln(f1,a,b);\n dem:=0;\n while b<>1 do\n begin\n dem:=dem+a div b;\n a:=a mod b;\n nho:=a;\n a:=b;\n b:=nho;\n end;\n dem:=dem+a;\n writeln(f2,dem);\n close(f1);\n close(f2);\nend.\n", "src_uid": "792efb147f3668a84c866048361970f8"} {"source_code": "Program B96;\nVar Ans,N,M:Int64;\nProcedure Rec(Res,A,B:Int64);\n Begin\n If Res>10000000000 Then Exit;\n If (Res>=N)And(A=B) Then\n Begin\n If Ress[length(s)-i+1] then inc(sum);\n\n\n\nif (sum=1)or((sum=0)and(odd(length(s)))) then writeln('YES') else writeln('NO');\n\nend.", "src_uid": "fe74313abcf381f6c5b7b2057adaaa52"} {"source_code": "var\n i, len: Integer;\n s: string;\n \nbegin\n ReadLn (s);\n \n len := Length (s);\n i:= len div 2 + 1;\n \n while (i < len) and (Copy (s, 1, i) <> Copy (s, len - i + 1, len)) do\n Inc (i);\n \n if i < len then\n begin\n WriteLn ('YES');\n WriteLn (Copy (s, 1, i))\n end\n else\n WriteLn ('NO')\nend.", "src_uid": "bfa78f72af4875f670f7adc5ed127033"} {"source_code": "var\n i,j:longint;\n l,r,m,ll,lr:longint;\n ans:int64;\n d:int64;\n last:longint;\n f:boolean;\n\nprocedure check;\nbegin\n ans:=ans+(d-last+1)*d;\n last:=d+1;\nend;\nprocedure dfs(w:longint);\nvar\n j:longint;\nbegin\n if w=i then\n begin\n if (d>=l) and (d<=r) then\n begin\n // writeln(last,' ',d);\n check\n end\n else\n if (d>r) and (not f) then\n begin\n\n //writeln('over',last,' ',d);\n ans:=ans+(r-last+1)*d;\n f:=true;\n writeln(ans);\n halt;\n end;\n exit;\n end;\n d:=d*10+4;\n dfs(w+1);\n d:=d-4+7;\n dfs(w+1);\n d:=d div 10;\nend;\n\nbegin\n readln(l,r);\n m:=l;\n while m<>0 do\n begin\n m:=m div 10;\n inc(ll);\n end;\n m:=r;\n while m<>0 do\n begin\n m:=m div 10;\n inc(lr);\n end;\n last:=l;\n for i:=ll-1 to lr+1 do\n begin\n dfs(0);\n end;\n writeln(ans);\nend.\n\n\n", "src_uid": "8a45fe8956d3ac9d501f4a13b55638dd"} {"source_code": "const\n yy:set of char=['a','e','i','o','u','y'];\n\nvar\n s:string;\n n,i,len:longint;\n ch:char;\n\nbegin\n readln(n);\n len:=0; s:='';\n for i:= 1 to n do\n begin\n read(ch);\n if ch in yy then \n begin\n inc(len);\n if len<2 then s:=s+ch;\n end\n else begin\n s:=s+ch;\n len:=0;\n end;\n end;\n writeln(s);\nend.", "src_uid": "63a4a5795d94f698b0912bb8d4cdf690"} {"source_code": "var\n z,q,w,i,j,n,m,k,t,x:longint;\n a,b:array[0..4]of longint;\nbegin\n readln(n);\n for i:=1 to n do readln(a[i]);\n if n=0 then\n begin\n writeln('YES');writeln(1);writeln(1);writeln(3);writeln(3);halt;\n end;\n for i:=1 to n-1 do for j:=i+1 to n do if a[i]>a[j] then\n begin\n t:=a[i];a[i]:=a[j];a[j]:=t;\n end;\n if n=4 then\n begin\n for i:=1 to 3 do for j:=i+1 to 4 do if a[i]>a[j] then\n begin\n t:=a[i];a[i]:=a[j];a[j]:=t;\n end;\n if((a[1]+a[2]+a[3]+a[4])/4=(a[2]+a[3])/2)and((a[2]+a[3])/2=a[4]-a[1])then\n begin\n writeln('YES');halt;\n end;\n end;\n if n=1 then\n begin\n writeln('YES');\n writeln(a[1]);\n writeln(a[1]*3);\n writeln(a[1]*3);\n halt;\n end;\n if n=2 then\n begin\n for q:=1 to 1500 do for w:=1 to 1500 do\n begin\n b:=a;\n a[3]:=q;a[4]:=w;\n for i:=1 to 3 do for j:=i+1 to 4 do if a[i]>a[j] then\n begin\n t:=a[i];a[i]:=a[j];a[j]:=t;\n end;\n if((a[1]+a[2]+a[3]+a[4])/4=(a[2]+a[3])/2)and((a[2]+a[3])/2=a[4]-a[1])then\n begin\n writeln('YES');writeln(q);writeln(w);halt;\n end;\n a:=b;\n end;\n end;\n if n=3 then\n begin\n for q:=1 to 1500 do\n begin\n b:=a;\n a[4]:=q;\n for i:=1 to 3 do for j:=i+1 to 4 do if a[i]>a[j] then\n begin\n t:=a[i];a[i]:=a[j];a[j]:=t;\n end;\n if((a[1]+a[2]+a[3]+a[4])/4=(a[2]+a[3])/2)and((a[2]+a[3])/2=a[4]-a[1])then\n begin\n writeln('YES');writeln(q);halt;\n end;\n a:=b;\n end;\n end;\n writeln('NO');\nend.\n\n\n", "src_uid": "230e613abf0f6a768829cbc1f1a09219"} {"source_code": "program _212A_Privatization;\n\nconst INF=100000007;\n\nvar q:array[1..200000]of longint;\n\te:array[1..20000]of record y,rev,f,next,w:longint;end;\n\tvisit:Array[1..1000]of boolean;\n\tprv,be,pre,px,py,usd,f,degx,degy:array[1..5010]of longint;\n\thead,tail,ss,tt,n,m,k,t,i,j,x,y,z,e0,ans:longint;\n\nprocedure addedge(x,y,c,w:longint);\nbegin\n\tinc(e0);\n\te[e0].y:=y; e[e0].next:=prv[x]; e[e0].rev:=e0+1;\n\te[e0].f:=c; e[e0].w:=w; prv[x]:=e0;\n\tinc(e0);\n\te[e0].y:=x; e[e0].next:=prv[y]; e[e0].rev:=e0-1;\n\te[e0].f:=0; e[e0].w:=-w; prv[y]:=e0;\nend;\n\nfunction spfa:boolean;\nvar i:longint;\nbegin\n\tfor i:=1 to tt do f[i]:=INF;\n\tfillchar(visit,sizeof(visit),false);\n\tvisit[ss]:=true;\n\tq[1]:=ss;\n\thead:=1;\n\ttail:=1;\n\tf[ss]:=0;\n\twhile head<=tail do begin\n\t\tx:=q[head];\n\t\tinc(head);\n\t\tz:=prv[x];\n\t\twhile z<>0 do begin\n\t\t\ty:=e[z].y;\n\t\t\tif (e[z].f>0)and(f[x]+e[z].wss do begin\n\t\tif e[be[x]].fss do begin\n\t\tdec(e[be[x]].f,delta);\n\t\tinc(e[e[be[x]].rev].f,delta);\n\t\tx:=pre[x];\n\tend;\nend;\n\nbegin\n\t//assign(input,'212A.in');reset(input);\n\treadln(n,m,k,t);\n\tfor i:=1 to k do begin\n\t\treadln(px[i],py[i]);\n\t\tusd[i]:=0;\n\t\tinc(degx[px[i]]);\n\t\tinc(degy[py[i]]);\n\tend;\n\tans:=0;\n\tfor i:=1 to n do if degx[i] mod t>0 then inc(ans);\n\tfor i:=1 to m do if degy[i] mod t>0 then inc(ans);\n\tss:=n+m+1; tt:=ss+1;\n\twhile (t>0) do begin \n\t\te0:=0;\n\t\tfillchar(prv,sizeof(prv),0);\n\t\tfor j:=1 to k do if usd[j]=0 then addedge(px[j],n+py[j],1,0);\n\t\tfor j:=1 to n do begin\n\t\t\taddedge(ss,j,degx[j] div t,0);\n\t\t\tif degx[j] mod t>0 then addedge(ss,j,1,1);\n\t\tend;\n\t\tfor j:=1 to m do begin\n\t\t\taddedge(n+j,tt,degy[j] div t,0);\n\t\t\tif degy[j] mod t>0 then addedge(n+j,tt,1,1);\n\t\tend;\n\t\twhile spfa() do imp;\n\t\tz:=1;\n\t\tfor j:=1 to k do if usd[j]=0 then begin\n\t\t\tif e[z].f=0 then begin\n\t\t\t\tusd[j]:=t;\n\t\t\t\tdec(degx[px[j]]); dec(degy[py[j]]);\n\t\t\tend;\n\t\t\tinc(z,2);\n\t\tend;\n\t\tdec(t);\n\tend;\n\twriteln(ans);\n\tfor i:=1 to k do write(usd[i],' ');\n\twriteln;\nend.\n", "src_uid": "99b97aabec566e5f966777947271ad3c"} {"source_code": "{$M 100000000}\n\nvar xx,j,n,i:longint;\nans:array[0..10000]of longint;\nu:array[0..10000]of longint;\nnum,size:array[0..10000]of longint;\nx,y,a,b,next,pr:array[0..10000]of longint;\naa:array[0..10000]of extended;\ns:array[0..10000]of string;\n\nfunction polar(xx,yy:extended):extended;\n begin\n if (xx>0)and(yy=0) then polar:=0 else\n if (xx>0)and(yy>0) then polar:=arctan(yy/xx) else\n if (xx=0)and(yy>0) then polar:=pi/2 else\n if (xx<0)and(yy>0) then polar:=pi-arctan(-yy/xx) else\n if (xx<0)and(yy=0) then polar:=pi else\n if (xx<0)and(yy<0) then polar:=pi+arctan(yy/xx) else\n if (xx=0)and(yy<0) then polar:=pi+pi/2 else\n if (xx>0)and(yy<0) then polar:=pi+pi-arctan(-yy/xx);\n end;\n\n\nprocedure sort(l,r: longint);\nvar\ni,j: longint;\nsx,sy:extended;\nz:longint;\n begin\n i:=l;\n j:=r;\n sx:=aa[(l+r) div 2];\n repeat\n while aa[i]j) then\n begin\n z:=num[i];\n num[i]:=num[j];\n num[j]:=z;\n z:=x[i];\n x[i]:=x[j];\n x[j]:=z;\n z:=y[i];\n y[i]:=y[j];\n y[j]:=z;\n\n sy:=aa[i];\n aa[i]:=aa[j];\n aa[j]:=sy;\n z:=u[i];\n u[i]:=u[j];\n u[j]:=z;\n inc(i);\n dec(j);\n end;\n until i>j;\n if l0 do\n begin\n if b[i]<>p then\n begin\n dfs(b[i],v);\n size[v]:=size[v]+size[b[i]];\n end;\n i:=next[i];\n end;\n end;\n\nprocedure rec(v,p,l,r:longint);\nvar i,j,ll,rr,co:longint;\nmax,maxx,numm:longint;\n begin\n max:=-2000000000;\n for i:=l to r do\n if u[i]=0 then\n if (y[i]>max)or((y[i]=max)and(x[i]>maxx)) then\n begin\n max:=y[i];\n maxx:=x[i];\n numm:=i;\n end;\n ans[num[numm]]:=v;\n u[numm]:=1;\n\n for i:=l to r do\n if i<>numm then\n begin\n aa[i]:=polar(x[i]-x[numm],y[i]-y[numm]);\n end;\n\n sort(l,r);\n\n j:=pr[v];\n\n rr:=l-1;\n// moi kod ^^\n while j>0 do\n begin\n if b[j]<>p then\n begin\n ll:=rr+1;\n while u[ll]=1 do ll:=ll+1;\n co:=1;\n rr:=ll;\n while co0) 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\nbegin\n Readln(T,X,Y);\n Z:=gcd(X,Y);\n if (Y div Z)>(T div X) then begin\n mn:=min(X,Y)-1;\n mn:=min(mn,T);\n Z:=gcd(mn,T);\n mn:=mn div Z;\n T:=T div Z;\n if mn=T then Writeln('1/1')\n else Writeln(mn,'/',T);\n Halt;\n end;\n lcm:=(X div Z)*Y;\n answer:=T div lcm;\n mn:=min(X,Y)-1;\n md:=T mod lcm;\n answer:=answer+answer*mn;\n answer:=answer+min(mn,md);\n Z:=gcd(T,answer);\n answer:=answer div Z;\n T:=T div Z;\n if answer=T then Writeln('1/1')\n else Writeln(answer,'/',T);\n end.\n", "src_uid": "7a1d8ca25bce0073c4eb5297b94501b5"} {"source_code": "var\n i,tt,tmp,a,b:longint;\n r1,r2,x:int64;\n res:array[1..5]of string;\n function gcd(a,b:longint):longint;\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 gcd:=a+b;\n end;\nbegin\n res[1]:='Dasha';\n res[2]:='Masha';\n reaD(a,b);\n tt:=1;\n if (a>b)then begin\n tmp:=a;a:=b;b:=tmp;\n tt:=3-tt;\n end;\n if (b>2*a)then begin\n writeln(res[tt]);\n exit;\n end;\n if (b=2*a)then begin\n writeln('Equal');\n exit;\n end;\n x:=int64(a)*b div gcd(a,b);\n r2:=0;\n for i:=1 to x div b do r2:=r2+i*int64(b-a);\n r1:=x-r2;\n if (r1r2)then writeln(res[3-tt])else\n writeln('Equal');\nend.\n", "src_uid": "06eb66df61ff5d61d678bbb3bb6553cc"} {"source_code": "var m,cm,m1:array[0..10] of longint;\n s:string;\n n,i,j,max,jj:longint;\nbegin\n readln(s);\n if s='1' then\n begin\n writeln(1);\n halt;\n end;\n for i:=1 to length(s) do m[i]:=ord(s[i])-ord('0');\n n:=length(s);\n m1[0]:=1;\n for i:=1 to n do m1[0]:=m1[0]*m[i];\n for i:=1 to n do\n begin\n cm:=m;\n if m[i]=0 then\n begin\n m1[i]:=0;\n continue;\n end;\n cm[i]:=m[i]-1;\n for j:=i+1 to n do cm[j]:=9;\n m1[i]:=1;\n j:=1;\n while cm[j]=0 do inc(j);\n for jj:=j to n do m1[i]:=m1[i]*cm[jj];\n end;\n max:=0;\n for i:=0 to n do if m1[i]>max then max:=m1[i];\n writeln(max);\nend.", "src_uid": "38690bd32e7d0b314f701f138ce19dfb"} {"source_code": "\n 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 qq,kk,cc,pp,rr,v1,v2,kol,t,p,sum,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 n,k,h,step,i,j:longint;\n tt,modul,aaa,bbb, aa,bb,ccc,dd:int64;\n xnew,xold, bold,bnew,r,x,y,d,c,aold,b,a:array[-10..300000] of int64;\n dda:array[-10..1200,-10..1200] of int64;\n marked:array[-10..300030] 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 mm,matr,ddp, pole :array [-10..100,-10..100,-10..101] of int64;\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\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 begin\n a[0]:=1; for i:=1 to 18 do a[i]:=a[i-1]*10;\n ot:=0;\n for step:=1 to 18 do\n begin\n t:=step;\n if n>=a[step-1] then\n begin\n p:=min(a[step]-1,n)-a[step-1]+1;\n ot:=ot+p*t;\n\n end;\n\n\n end;\n if n<10 then ot:=n-1;\n if (n>=10)and(n<1000000000000) then ot:=ot else ot:=ot+1;\n writeln(ot);\n\n end;\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n\n", "src_uid": "4e652ccb40632bf4b9dd95b9f8ae1ec9"} {"source_code": "uses math;\nvar\n a:array[1..12] of extended;\n x,y,z:extended;\n pos,i:longint;\nbegin\n readln(x,y,z);\n a[1]:=power(y,z)*ln(x);\n a[2]:=power(z,y)*ln(x);\n a[3]:=z*ln(power(x,y));\n a[4]:=y*ln(power(x,z));\n a[5]:=power(x,z)*ln(y);\n a[6]:=power(z,x)*ln(y);\n a[7]:=z*ln(power(y,x));\n a[8]:=x*ln(power(y,z));\n a[9]:=power(x,y)*ln(z);\n a[10]:=power(y,x)*ln(z);\n a[11]:=y*ln(power(z,x));\n a[12]:=x*ln(power(z,y));\n\n pos:=1;\n for i:=2 to 12 do\n if a[i]>a[pos]+1e-12\n then pos:=i;\n\n case pos of\n 1:writeln('x^y^z');\n 2:writeln('x^z^y');\n 3:writeln('(x^y)^z');\n 4:writeln('(x^z)^y');\n 5:writeln('y^x^z');\n 6:writeln('y^z^x');\n 7:writeln('(y^x)^z');\n 8:writeln('(y^z)^x');\n 9:writeln('z^x^y');\n 10:writeln('z^y^x');\n 11:writeln('(z^x)^y');\n 12:writeln('(z^y)^x');\n end;\n\nend.\n", "src_uid": "a71cb5cda754ad2bf479bc3b0164fc4c"} {"source_code": "var\n a,b,c,d,e:longint;\nfunction min(x,y:longint):longint;\nbegin\n if x>y then min:=y else min:=x;\nend;\nbegin\n readln(a,b,c,d,e);\n a:=a div 1;\n b:=b div 1;\n c:=c div 2;\n d:=d div 7;\n e:=e div 4;\n writeln(min(a,min(b,min(c,min(d,e)))));\nend.", "src_uid": "f914f9b7884cc04b990c7800c6be7b10"} {"source_code": "Var a, b, n, i, j:Integer;\n x, y:Array[1..4]of Integer;\n t:Boolean;\n Begin\n Read(n);\n For i:=1 to n do\n ReadLn(x[i],y[i]);\n if n=1 then Begin\n Write(-1);\n Halt(0);\n End;\n if(x[1]<>x[2])and(y[1]<>y[2])and(n=2)then Begin\n x[3]:=x[1];\n y[3]:=y[2];\n n:=3;\n End;\n\n For i:=1 to n-1 do\n For j:=i+1 to n do\n Begin\n if(X[i]=X[j])then Begin\n a:=abs(y[i]-y[j]);\n End else\n if(Y[i]=Y[j])then Begin\n b:=abs(X[i]-X[j]);\n End\n End;\n if A*b=0 then Write(-1)else\n Write(a*b);\n End.\n\n\n\n\n\n\n", "src_uid": "ba49b6c001bb472635f14ec62233210e"} {"source_code": "program cf690D2;\nconst mo=1000003;\nvar n,c,i:longint;\n fac,ni:array[0..700010] of int64;\n ans:int64;\nfunction power(x:int64;n:longint):int64;\nvar t:int64;\nbegin\n if n=1 then exit(x);\n if n=0 then exit(1);\n t:=power(x,n shr 1);\n t:=t*t mod mo;\n if n and 1=1 then t:=t*x mod mo;\n exit(t);\nend;\nbegin\n readln(n,c);\n ans:=0;\n fac[0]:=1;\n for i:=1 to n+c do\n begin\n fac[i]:=(fac[i-1]*i) mod mo;\n ni[i]:=power(fac[i],mo-2);\n end;\n ni[0]:=1;\n for i:=1 to n do\n ans:=(ans+fac[i+c-1]*ni[c-1] mod mo *ni[i] mod mo) mod mo;\n writeln(ans);\nend.\n", "src_uid": "e63c70a9c96a94bce99618f2e695f83a"} {"source_code": "var\n s:ansistring;\n kg,st1,sl,sr,st,nom:array[0..1000500]of longint;\n g:array[0..1000000,0..3]of longint;\n kst,kq,xx,yy,kst1,kst2,n,i:longint;\n ty,st2:array[0..1000500]of char;\n f:array[0..1000000,0..1,0..1]of longint;\n\n function calc(x,y:longint;t:char):longint;\n begin\n if (t='|')then calc:=x or y else\n if (t='&')then calc:=x and y else\n if (t='^')then calc:=x xor y;\n end;\n \n function rec(t,x,y:longint):boolean;\n var\n x1,y1,x2,y2:longint;\n \n begin\n if (f[t][x][y]<>-1)then begin\n if (f[t][x][y]=1)then rec:=true else rec:=false;\n exit;\n end;\n if (s[sl[t]]<>'(')then begin\n if (s[sl[t]]='?')then begin\n f[t][0][1]:=1;\n f[t][1][0]:=1;\n end else begin\n x1:=ord(s[sl[t]])-48;\n f[t][x1][x1]:=1;\n end;\n if (f[t][x][y]<>1)then f[t][x][y]:=0;\n rec:=f[t][x][y]=1;\n exit;\n end;\n f[t][x][y]:=0;\n for x1:=0 to 1 do \n for y1:=0 to 1 do \n for x2:=0 to 1 do \n for y2:=0 to 1 do \n if (rec(g[t][1],x1,y1))and(rec(g[t][2],x2,y2))\n then f[t][calc(x1,x2,ty[t])][calc(y1,y2,ty[t])]:=1;\n rec:=f[t][x][y]=1;\n end;\n\nbegin\n //assign(input,'input.txt');reset(input);\n //assign(output,'output.txt');rewrite(output);\n readln(n);\n readln(s);\n for i:=1 to length(s)do begin\n if (s[i]='(')or(s[i]in['0','1','?'])then begin\n inc(kq);\n inc(kst);\n st[kst]:=i+1;\n nom[kst]:=kq;\n sl[kq]:=i;\n end;\n if (s[i]=')')or(s[i]in['0','1','?'])then begin\n yy:=nom[kst];\n sr[nom[kst]]:=i;\n dec(kst);\n xx:=nom[kst];\n inc(kg[xx]);\n g[xx][kg[xx]]:=yy;\n end;\n if (s[i] in ['&','|','^'])then ty[nom[kst]]:=s[i];\n end;\n fillchar(f,sizeof(f),$FF);\n if (rec(1,0,1))or\n (rec(1,1,0))\n then writeln('YES')\n else writeln('NO');\nend.", "src_uid": "e060d26dc3b9ffb628f2380781d1cbe9"} {"source_code": "var\n a,s : longint;\nbegin\n read(s);\n if s = 0 then\n begin\n writeln('1');\n exit;\n end\n else if s = 1 then\n begin\n writeln('8');\n exit;\n end\n else if s = 2 then\n begin\n writeln('4');\n exit;\n end\n else if s = 3 then\n begin\n writeln('2');\n exit;\n end\n else if s = 4 then\n begin\n writeln('6');\n exit;\n end\n else if (s mod 4) = 0 then\n begin\n writeln('6');\n exit;\n end\n else if (s mod 4) = 1 then\n begin\n writeln('8');\n exit;\n end\n else if (s mod 4) = 2 then\n begin\n writeln('4');\n exit;\n end\n else if (s mod 4) = 3 then\n begin\n writeln('2');\n exit;\n end;\nend.", "src_uid": "4b51b99d1dea367bf37dc5ead08ca48f"} {"source_code": "var i,a,b,c,n,pl,mn:integer;\nbegin\n\ni:=0;a:=0;b:=0;c:=0;n:=0;pl:=0;mn:=0;\nread(n);\nfor i:=1 to n do\nbegin\nread(a); if a>0 then b+=1;if a<0 then c+=1;\nend;\nif b>0 then if (n-b)<= b then begin write(1);pl:=1;end;\nif (c>0) and (pl=0) then if (n-c)<=c then begin write(-1);mn:=1;end;\nif (pl+mn)=0 then write(0);\nend.", "src_uid": "a13cb35197f896cd34614c6c0b369a49"} {"source_code": "var n,x,y:int64;\nbegin\n readln(n);\n read(x,y);\n if (x+y)<=(n+1) then writeln('White') else writeln('Black');\nend.", "src_uid": "b8ece086b35a36ca873e2edecc674557"} {"source_code": "var f1:text;n,res,i:longint;s:string;\nfunction lt2(k:longint):longint;\nvar m:longint;\nbegin\n if k=0 then exit(1);\n m:=lt2(k div 2);\n if k mod 2=0 then lt2:=m*m else lt2:=m*m*2;\nend;\nfunction biendoi(a:string):longint;\nvar ii,ress:longint;\nbegin\n ress:=0;\n for ii:=n downto 1 do\n if s[ii]='1' then ress:=ress+lt2(n-ii);\n exit(ress);\nend;\nbegin\n assign(f1,'');reset(f1);\n readln(f1,s);\n n:=length(s);\n for i:=1 to n-1 do\n res:=res+lt2(i);\n for i:=1 to n do if s[i]='4' then s[i]:='0' else s[i]:='1';\n write(res+biendoi(s)+1);\nend.\n", "src_uid": "6a10bfe8b3da9c11167e136b3c6fb2a3"} {"source_code": "{\n 255A.pas\n \n Copyright 2014 Adzka \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\tn,a,x,chest,biceps,back:longint;\n\nbegin\n\treadln(n);\n\tfor a:=1 to n do begin\n\t\tread(x);\n\t\tif a mod 3=1 then inc(chest,x)\n\t\telse if a mod 3=2 then inc(biceps,x)\n\t\telse if a mod 3=0 then inc(back,x);\n\tend;\n\treadln;\n\tif (chest>biceps) and (chest>back) then writeln('chest')\n\telse if (biceps>chest) and (biceps>back) then writeln('biceps')\n\telse writeln('back');\nend.\n", "src_uid": "579021de624c072f5e0393aae762117e"} {"source_code": "var x, i, j: longint;\nbegin\n readln(x);\n x := abs(x);\n while (j < x) or ((j - x) mod 2 = 1) do\n begin\n inc(i);\n j := j + i;\n end;\n writeln(i);\nend.", "src_uid": "18644c9df41b9960594fdca27f1d2fec"} {"source_code": "var a:array[1..100000] of longint;\nn,m,q,k,w:int64;\ni,j:longint;\ns,s1:string;\nch:char;\n\tbegin\n\treadln(k);\n\treadln(m);\n\treadln(q);\n\treadln(w);\n\treadln(n);\n\tj:=1;\n\twhile j*k<=n do\n\t\tbegin\n\t\ta[j*k]:=1;\n\t\tinc(j);\n\t\tend;\n\tj:=1;\n\twhile j*m<=n do\n\t\tbegin\n\t\ta[j*m]:=1;\n\t\tinc(j);\n\t\tend;\n\tj:=1;\n\twhile j*q<=n do\n\t\tbegin\n\t\ta[j*q]:=1;\n\t\tinc(j);\n\t\tend;\n\tj:=1;\n\twhile j*w<=n do\n\t\tbegin\n\t\ta[j*w]:=1;\n\t\tinc(j);\n\t\tend;\n\tj:=0;\n\tfor i:=1 to n do\n\tif a[i]=1 then inc(j);\n\twrite(j);\n\tend.\n", "src_uid": "46bfdec9bfc1e91bd2f5022f3d3c8ce7"} {"source_code": "var\n\tn, m, a : integer;\nbegin\n\tread(n, m);\n\tif (n > m) then\t\n\t\ta := m\n\telse\n\t\ta := n;\n\tif (a mod 2 = 0) then \n\t\twriteln('Malvika')\n\telse\n\t\twriteln('Akshat');\n\nend.\n\n", "src_uid": "a4b9ce9c9f170a729a97af13e81b5fe4"} {"source_code": "program p1 ;\nvar a,b,n,m:int64;i,j,k,c,r:real;\nbegin \nreadln (n,m,a,b);\nif n mod m =0 then r:=0;\nif n mod m <>0 then \nbegin\n c:=int(n/m);\ni:=abs((c*m-n))*b;\nj:=((c+1)*m-n)*a;\nif i>j then r:=j else r:=i;\nend;\nwriteln (r);\nend.", "src_uid": "c05d753b35545176ad468b99ff13aa39"} {"source_code": "var\nl,r,n,k,mid,j,i,z,ma:integer;\nbegin\nread (n,k);\nr:=n;\nwhile l<=r do begin\nmid:=(l+r) div 2;\nif z+k<=240 then begin \n if mid>ma then begin\n for i:=ma+1 to mid do begin\n inc (z,i*5);\n if z+k>240 then begin write (i-1);halt end;\n ma:=mid;\n end;end;\n l:=mid+1 ;\n end;\n\nif z+k>240 then \nr:=mid-1;\nend;\nwrite (ma);end.\n", "src_uid": "41e554bc323857be7b8483ee358a35e2"} {"source_code": "var\n n,i,ans,max:longint;\n ch:char; \n a:array['a'..'z']of longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(ch);\n if ch in['A'..'Z'] then\n begin\n fillchar(a,sizeof(a),0);\n if ans>max then\n max:=ans;\n ans:=0;\n end else\n begin\n if a[ch]=0 then\n begin\n a[ch]:=1;\n inc(ans);\n end;\n end;\n end;\n if ans>max then\n max:=ans;\n writeln(max);\nend.\n", "src_uid": "567ce65f87d2fb922b0f7e0957fbada3"} {"source_code": "const\n fin='a210062016.inp';fon='a210062016.out';\nvar n,t:qword;\nprocedure solve;\nbegin\nreadln(n);\nif n mod 2 = 1 then write((n-1) div 2)\nelse\n begin\n t:=1;\n while t*2<=n do\n t:=t*2;\n write((n-t) div 2);\n end;\nend;\n\nbegin\n//assign(input,fin);reset(input);\n//assign(output,fon);rewrite(output);\nsolve;\nend.\n", "src_uid": "422abdf2f705c069e540d4f5c09a4948"} {"source_code": "uses math;\ntype mass=array[1..2000,0..2000] of integer;\n mahh=array[1..2000] of boolean;\n maxx=array[1..2000] of integer;\nvar m:mass;m1:mahh;\n m2:maxx;u:boolean;i:integer;n,num,j,k,c,t,z,max1,a,b:integer;\nprocedure dfs(x:integer);\nvar i:integer;\nBegin\n for i:=1 to n do\n if (m[x,i]=1) and (m1[i])\n then Begin\n m1[i]:=false;\n inc(num);\n m2[num]:=i;\n dfs(i);\n end;\nend;\nbegin\n // assign(input,'input.txt');\n // assign(output,'output.txt');\n fillchar(m,sizeof(m),0);\n readln(n);\n readln(k);\n for i:=1 to k do\n Begin\n readln(a,b);\n m[a,b]:=1;\n m[b,a]:=1;\n end;\n readln(k);\n for i:=1 to k do\n Begin\n readln(a,b);\n m[a,b]:=-1;\n m[b,a]:=-1;\n end;\n fillchar(m1,sizeof(m1),true);\n max1:=0;\n for i:=1 to n do\n if m1[i]\n then Begin\n u:=true;\n num:=1;\n m1[i]:=false;\n m2[1]:=i;\n dfs(i);\n for z:=1 to num do\n for j:=z+1 to num do\n if m[m2[z],m2[j]]=-1\n then Begin\n u:=false;\n break;\n end;\n if u\n then max1:=max(max1,num);\n end;\n writeln(max1);\nend.\n", "src_uid": "e1ebaf64b129edb8089f9e2f89a0e1e1"} {"source_code": "const p=200;\nconst md=1000000007;\n\nvar x:int64;\n i,j,k,k1,k2,n,i1,i2,j1,j2:longint;\n v:array[0..201,0..51,0..51] of int64;\n w:array[0..201,0..51,0..51] of longint;\n c:array[0..51,0..51] of int64;\n\n begin\n read(n,k);\n for i:=1 to n do\n begin\n read(x);\n if x=50 then inc(k1)\n else inc(k2);\n end;\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 n do\n c[i,j]:=(c[i-1,j]+c[i-1,j-1]) mod md;\n end;\n\n v[0,k1,k2]:=1;\n w[0,k1,k2]:=1;\n for i:=0 to p do\n begin\n if (i mod 2=1) and\n (w[i,0,0]=1) then begin\n writeln(i);writeln(v[i,0,0]);halt;\n end;\n\n for i1:=0 to k1 do\n for i2:=0 to k2 do\n begin\n if w[i,i1,i2]=0 then continue;\n\n if i mod 2=0 then begin\n for j1:=0 to i1 do\n for j2:=0 to i2 do\n begin\n if (50*j1+100*j2>k) then continue;\n if (j1+j2=0) then continue;\n w[i+1,i1-j1,i2-j2]:=1;\n\n x:=c[i1,j1]*c[i2,j2] mod md;\n x:=v[i,i1,i2]*x mod md;\n\n v[i+1,i1-j1,i2-j2]:=(v[i+1,i1-j1,i2-j2]+x) mod md;\n end;\n end\n else begin\n for j1:=0 to (k1-i1) do\n for j2:=0 to (k2-i2) do\n begin\n if (50*j1+100*j2>k) then continue;\n if (j1+j2=0) then continue;\n\n w[i+1,i1+j1,i2+j2]:=1;\n x:=c[k1-i1,j1]*c[k2-i2,j2] mod md;\n x:=v[i,i1,i2]*x mod md;\n\n v[i+1,i1+j1,i2+j2]:=(v[i+1,i1+j1,i2+j2]+x) mod md;\n end;\n end;\n end;\n\n end;\n\n writeln(-1);\n writeln(0);\n end.", "src_uid": "ebb0323a854e19794c79ab559792a1f7"} {"source_code": "uses\nMath;\n\nvar\n n, w, h: Int32;\n\nbegin\n ReadLn(n);\n w := ceil(sqrt(n));\n h := ceil(n / w);\n\n WriteLn(w + h);\n ReadLn;\nend.\n", "src_uid": "eb8212aec951f8f69b084446da73eaf7"} {"source_code": "Var dp:array[0..1000000,0..1] of int64;\nn,k,d,ans,md:int64;\ni,j,next,ok:longint;\nbegin\n read(n,k,d);\n dp[0][0]:=1;\n md:=1000000007;\n for i:=0 to n do\n begin\n for next:=1 to k do\n for j:=0 to 1 do\n begin\n if(next+i>n) then continue;\n ok:=j;\n if(next>=d)then ok:=1;\n dp[i+next][ok]:=(dp[i+next][ok]+dp[i][j])mod md;\n end;\n end;\n ans:=dp[n][1];\n writeln(ans);\nend.", "src_uid": "894a58c9bba5eba11b843c5c5ca0025d"} {"source_code": "var\n l1, l2, r1, r2, t1, t2, d1, d2, ans1, ans2, nd: integer;\n\nfunction nod(a, b: integer): integer;\nbegin\n if a > b then swap(a, b);\n while (a <> 0) do \n begin\n b := b mod a;\n swap(a, b)\n end;\n result := b;\nend;\n\nbegin\n read(l1, r1, t1, l2, r2, t2);\n \n nd := nod(t1, t2);\n d1 := r1 - l1 + 1;\n d2 := r2 - l2 + 1;\n l1 := l1 mod nd;\n l2 := l2 mod nd;\n r1 := l1 + d1 - 1;\n r2 := l2 + d2 - 1;\n if l1 > l2 then begin\n swap(l1, l2);\n swap(r1, r2);\n swap(t1, t2);\n swap(d1, d2);\n end;\n ans1 := max(min(r1, r2) - max(l1, l2) + 1, 0);\n inc(l1, nd);\n inc(r1, nd);\n ans2 := max(min(r1, r2) - max(l1, l2) + 1, 0);\n writeln(max(ans1, ans2));\nend.", "src_uid": "faa75751c05c3ff919ddd148c6784910"} {"source_code": "program B;\n\nvar\n p, x, y, i, t, k: longint;\n\nfunction ok(t: longint): boolean;\nvar\n ii, j: longint;\nbegin\n j := (t div 50) mod 475;\n for ii := 1 to 25 do begin\n j := (j * 96 + 42) mod 475;\n if p = (j + 26) then begin\n result := true;\n exit;\n end;\n\n end;\n result := false;\nend;\n\nbegin\n read(p, x, y);\n k := (x - y) div 50;\n for i := k downto 0 do begin\n t := x - i * 50;\n if ok(t) then begin\n write('0');\n halt;\n end;\n end;\n\n i := 1;\n while true do begin\n t := x + i * 50;\n if ok(t) then begin\n write((i + 1) div 2);\n halt;\n end;\n inc(i);\n end;\nend.\n", "src_uid": "c9c22e03c70a94a745b451fc79e112fd"} {"source_code": "const tfi = '';\ntfo = '';\nvar fi,fo: text;\ns: string[20];\na,i: longint;\nprocedure ghif;\nbegin\nassign(fi, tfi);\nreset(fi);\nassign(fo, tfo);\nrewrite(fo);\nend;\nprocedure closef;\nbegin\nclose(fi);\nclose(fo);\nend;\nprocedure xuly;\nbegin\nread(fi,s);\nfor i:=length(s) downto 1 do\n begin\n if s[i]='0' then delete(s,i,1)\n else break;\n end;\na:=length(s);\nfor i:=1 to length(s) do\n begin\n if s[i]<>s[a] then\n begin\n write(fo, 'NO');\n exit;\n end;\n dec(a);\n end;\n write(fo, 'YES');\n\n end;\n\nbegin\nghif;\nxuly;\nclosef;\nend.", "src_uid": "d82278932881e3aa997086c909f29051"} {"source_code": "const fi='';//63e.inp';\n fo='';//63e.out';\n d:array[1..3] of integer=(0,1,1);\n c:array[1..3] of integer=(1,1,0);\n l='Lillebror';\n kk='Karlsson';\n\nvar f1:array[0..1 shl 19-1] of longint;\n a:array[0..6,0..6] of longint;\n s:Array[1..5,1..5] of char;\n st:longint;\n f:text;\n\n\nprocedure nhap;\nvar i,j,m:longint; ch:char;\nbegin\n assign(f,fi); reset(f);\n st:=0;\n for i:=1 to 5 do\n for j:=1 to 5 do s[i,j]:='.';\n st:=0; m:=0;\n for i:=1 to 5 do\n begin\n while not eoln(f) do\n begin\n read(f,ch);\n if ch<>' ' then inc(m);\n if ch='O' then st:=st or (1 shl (m-1));\n end;\n readln(f);\n end;\n close(f);\nend;\n\n\nprocedure khoitao;\nvar i,j:longint;\nbegin\n fillchar(a,sizeof(a),255);\n a[1,1]:=1; a[1,2]:=2; a[1,3]:=3; a[1,4]:=-1; a[1,5]:=-1;\n a[2,1]:=4; a[2,2]:=5; a[2,3]:=6; a[2,4]:=7; a[2,5]:=-1;\n a[3,1]:=8; a[3,2]:=9; a[3,3]:=10; a[3,4]:=11; a[3,5]:=12;\n a[4,1]:=-1; a[4,2]:=13; a[4,3]:=14; a[4,4]:=15; a[4,5]:=16;\n a[5,1]:=-1; a[5,2]:=-1; a[5,3]:=17; a[5,4]:=18; a[5,5]:=19;\nend;\n\n\nfunction game(u:longint):longint;\nvar i,j,k,v,d1,c1,d2,c2:longint;\n dau:array[0..2] of longint;\nbegin\n if f1[u]<>-1 then exit(f1[u]);\n if u=0 then\n begin\n f1[u]:=0;\n exit(f1[u]);\n end;\n dau[0]:=0; dau[1]:=0;\n for i:=0 to 18 do\n begin\n if u and (1 shl i)<>0 then\n begin\n for j:=1 to 5 do\n for k:=1 to 5 do if a[j,k]=i+1 then\n begin\n c1:=j; d1:=k;\n end;\n v:=u xor (1 shl i);\n dau[game(v)]:=1;\n for j:=1 to 3 do\n begin\n d2:=d1; c2:=c1;\n v:=u xor (1 shl i);\n while (a[c2+c[j],d2+d[j]]<>-1) and (v and (1 shl (a[c2+c[j],d2+d[j]]-1))<>0) do\n begin\n c2:=c2+c[j]; d2:=d2+d[j];\n //if v and (1 shl (a[c2,d2]-1))<>0 then\n begin\n v:=v xor (1 shl (a[c2,d2]-1));\n dau[game(v)]:=1;\n end;\n end;\n end;\n //f1[u]:=0;\n //exit(f1[u]);\n end;\n end;\n if dau[0]=0 then f1[u]:=0 else f1[u]:=1;\n exit(f1[u]);\nend;\n\n\nprocedure inkq;\nvar res:longint;\nbegin\n assign(f,fo); rewrite(f);\n fillchar(f1,sizeof(f1),255);\n res:=game(st);\n\n if res=0 then writeln(f,l) else writeln(f,kk);\n close(f);\nend;\n\n\nbegin\n nhap;\n khoitao;\n\n inkq;\nend.\n", "src_uid": "eaa022cc7846c983a826900dc6dd919f"} {"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 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 inc(p); x[p]:=t mod 10; t:=t div 10; end;\n leftdig:=x[p];\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 { for i:=1 to 20 do writeln(i,' ',leftdig(i));\n }\n\n read(qq);\n for stepp:=1 to qq do\n begin\n read(p,kk,gr);\n for i:=1 to p do read(a[i]);\n for i:=1 to p do a1[i]:=i;\n n:=1; repeat n:=n*2 until n>p;\n for i:=p+1 to n do a[i]:=besk;\n sort(a);\n for i:=1 to p do y[a1[i]]:=i;\n q:=0;\n for i:=1 to p do if a[i]<>a[i-1] then x[i]:=x[i-1]+1 else x[i]:=x[i-1];\n for i:=1 to p do z[a1[i]]:=x[i];\n\n { for i:=1 to p do write(z[i],' '); writeln;\n } for i:=1 to p do xx[i]:=0;\n kolzan:=0; ans:=100000000;\n for i:=1 to p do zan[i]:=false;\n for i:=1 to gr do\n begin\n t:=z[i];\n if not zan[t] then\n begin\n inc(kolzan);\n inc(xx[t]);\n zan[t]:=true;\n\n end else inc(xx[t]);\n\n { writeln('kolzan= ',kolzan);\n }\n end;\n\n ans:=kolzan;\n for i:=gr+1 to p do\n begin\n t:=z[i];\n t1:=z[i-gr];\n if not zan[t] then\n begin\n zan[t]:=true;\n inc(xx[t]);\n inc(kolzan);\n\n end else inc(xx[t]);\n\n if xx[t1]>1 then dec(xx[t1]) else\n begin\n dec(xx[t1]);\n zan[t1]:=false;\n dec(kolzan);\n end;\n\n { writeln('i= ',i,' kolzan= ',kolzan);\n }\n\n ans:=min(ans,kolzan);\n\n end;\n\n\n writeln(ans);\n\n\n end;\n\n\n\n\n 1: close (output);\n end.\n\n", "src_uid": "56da4ec7cd849c4330d188d8c9bd6094"} {"source_code": "{ fp }\nVAr\n s : string;\n n : int64;\n len,p : integer;\n\n begin\n ReadLn(s);\n len := length(s);\n If (len>19) or ((len=19) and (s>'9223372036854775807')) then WriteLn('BigInteger') else\n Begin\n Val(s,n,p);\n If N>2147483647 then WriteLn('long') else\n if n>32767 then WriteLn('int') else\n If n>127 then WriteLn('short') else\n WriteLn('byte');\n End;\n End.", "src_uid": "33041f1832fa7f641e37c4c638ab08a1"} {"source_code": "var S : string[100];\n i, j, L, max : longint;\nbegin\n readln(S);\n L := length(S);\n For i := 1 to L do\n For j := L-i+1 downto 1 do\n If pos(copy(S,i,j),copy(S,i+1,length(S))) <> 0 then\n If j > max then max := j;\n writeln(max);\nend.\n", "src_uid": "13b5cf94f2fabd053375a5ccf3fd44c7"} {"source_code": "uses math;\nvar\n n,c,i,maxn:longint;\n a:array[1..101] of longint;\nbegin\n maxn:=-maxlongint;\n read(n,c);\n for i:=1 to n do\n begin\n read(a[i]);\n if i>=2 then maxn:=max(maxn,a[i-1]-a[i]);\n end;\n if maxn>=c then write(maxn-c)\n else write('0');\nend.", "src_uid": "411539a86f2e94eb6386bb65c9eb9557"} {"source_code": "const inf=9000000000000000000;\nvar p, k : array[1..1000] of qword;\n n, b, bb, ans, kol, j, num, pn : qword;\n i, r : longint;\nbegin\n ans:=inf;\n readln(n, b);\n bb:=b;\n for i:=2 to trunc(sqrt(bb))+1 do\n if b mod i = 0 then begin\n inc(num);\n p[num]:=i;\n while b mod i = 0 do begin\n inc(k[num]);\n b:=b div i;\n end;\n end;\n if b > 1 then begin\n inc(num);\n p[num]:=b;\n k[num]:=1;\n end;\n for i:=1 to num do begin\n j:=p[i];\n for r:=1 to trunc(ln(n)/ln(j)) do begin\n inc(kol, n div j);\n j:=qword(j)*p[i];\n end;\n kol:=kol div k[i];\n if (ans > kol) then ans:=kol;\n kol:=0;\n end;\n writeln(ans);\nend.\n", "src_uid": "491748694c1a53771be69c212a5e0e25"} {"source_code": "begin\n writeln('INTERCAL');\nend.", "src_uid": "ef8239a0f77c538d2d9b246b86be63fe"} {"source_code": "const fi='';\n fo='';\n maxn=100;\nvar n,m,bx,by:integer;\n x,y:array[0..maxn] of integer;\n ax,ay,base:int64;\nprocedure nhap;\n var i:integer;\n begin\n readln(n,bx);\n for i:=n downto 1 do read(x[i]);\n readln(m,by);\n for i:=m downto 1 do read(y[i]);\n end;\nprocedure xuly;\n var i:integer;\n begin\n ax:=0;base:=1;\n for i:=1 to n do\n begin ax:=ax+base*x[i];\n base:=base*bx;\n end;\n ay:=0;base:=1;\n for i:=1 to m do\n begin ay:=ay+base*y[i];\n base:=base*by;\n end;\n if ax=ay then write('=')\n else if (ax>ay) then write('>')\n else write('<');\n end;\nbegin\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n nhap;\n xuly;\n close(input);close(output);\nend.", "src_uid": "d6ab5f75a7bee28f0af2bf168a0b2e67"} {"source_code": "var i,l,r,n,m,o,p,a,b,rr:int64;\nbegin\n//assign(input,'it.in');reset(input);\n//assign(output,'it.out');rewrite(output);\nread(l,r,n,m);\nif m mod n<>0 then\n begin\n write(0);\n close(input);close(output);halt;\n end;\no:=m div n;\nwhile i=l)and(i*n<=r)and(o div i*n>=l)and(o div i*n<=r)then\n begin\n a:=i;b:=o div i;rr:=a mod b;\n while rr<>0 do\n begin\n a:=b;b:=rr;rr:=a mod b;\n end;\n if b=1 then\n begin\n inc(p);\n if i*i<>o then inc(p);\n end;\n end;\n end;\nwriteln(p);\nclose(input);close(output);\nend.", "src_uid": "d37dde5841116352c9b37538631d0b15"} {"source_code": "program p1;\nvar i,j,m,n:smallint;min,t:integer; a:array [1..10000] of integer;\nbegin\nreadln(n,m);\nmin:=maxint;\nfor i:=1 to m do read(a[i]);\nfor i:=1 to m-1 do\nfor j:=i+1 to m do\nif a[j] Length(s) then k := k - Length(s) else\n begin\n Ans := s[k];\n k := -1;\n Break;\n end;\n\n If k > Sizes[min(depth-1, 60)] then\n begin\n If s = s3 then s := s4;\n\n If s = s2 then s := s3;\n\n k := k - Sizes[min(depth-1, 60)];\n\n end else //If k <= Sizes[min(depth-1, 60)]\n begin\n ReadString(depth-1, k);\n Break;\n end;\n\n end;\nend;\n\nbegin\n ReadLn(q);\n For i := 1 to q do\n begin\n Read(n[i], k[i]);\n ReadLn;\n end;\n For i := 1 to q do\n begin\n If k[i] <= Sizes[min(n[i], 60)] then\n begin\n ReadString(n[i], k[i]);\n Answers[i] := Ans;\n end else Answers[i] := '.';\n end;\n For i := 1 to q do Write(Answers[i]);\n ReadLn;\nend.\n", "src_uid": "da09a893a33f2bf8fd00e321e16ab149"} {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n\tk, r, i, j: Integer;\n\nbegin\n\tReadln(k, r);\n\ti := 1;\n\twhile i<=10 do\n\tbegin\n\t\tj := k*i;\n\t\tif ((j mod 10)=r) or ((j mod 10)=0) then\n\t\tbegin\n\t\t\tWriteln(i);\n\t\t\tbreak;\n\t\tend;\n\t\tInc(i);\n\tend;\nend.\n", "src_uid": "18cd1cd809df4744bb7bcd7cad94e2d3"} {"source_code": "{$mode objfpc}\nvar\n n,s:int64;\n i:longint;\n a:array[0..10000]of int64;\nbegin\n readln(n);\n a[0]:=0;\n for i:=1 to n do\n read(a[i]);\n for i:=1 to n do\n begin\n if (a[i]=1)then inc(s);\n if (a[i]=0)and(a[i-1]=1)and(a[i+1]=1)then inc(s);\n end;\n writeln(s);\nend.", "src_uid": "2896aadda9e7a317d33315f91d1ca64d"} {"source_code": "//fpc 3.0.0\n\nprogram HelloWorld;\n\nvar v:array[1..20] of byte;\nvv,w:int64;\ni,n,ans,bestans,j,r,z,o:longint;\nbb:boolean;\nbegin\n readln(vv);\n \n n:=0;\n while (vv>0) do begin\n inc(n);\n v[n]:=vv mod 10;\n vv:=vv div 10;\n end;\n \n bestans:=-1;\n for i:=44721 downto 1 do begin\n w:=i*i; o:=w;\n j:=1;\n ans:=0;\n bb:=true;\n r:=0;\n while (w>0) do begin\n // if (o=1444) then writeln(w,' ',j);\n r:=r+1;\n z:=w mod 10;\n while (v[j]<>z) do begin inc(j); if (j>n) then begin bb:=false; break;end; end;\n inc(j);\n w:=w div 10;\n \n end;\n ans:=(n-r);\n if (bb)and((ansi then max:=j;end;\n function nod(a,b:longint):longint; var i,j:longint;\n begin while i>0 do begin i:=a mod b;a:=b;b:=i; end;\n nod:=a;\n\n end;\n\n\n\n begin { clrscr;\n\n assign(input,'input.txt');reset(input);\n } for i:=1 to 3 do read(x[i]);\n for i:=1 to 3 do read(y[i]);\n p:=1;\n for i:=1 to 3 do p:=p*(x[i]-y[i]);\n if p<>0 then writeln('NO') else writeln('YES');\n\n\n close(output);\n\n\n\n end.", "src_uid": "91c9dbbceb467d5fd420e92c2919ecb6"} {"source_code": "program Measuring_Lengths_in_Baden;\nvar n:integer;\nbegin\n readln(n);\n writeln(round(n/3) div 12,' ',round(n/3) mod 12);\nend.\n", "src_uid": "5d4f38ffd1849862623325fdbe06cd00"} {"source_code": "var\n\ta, b, n, c, c1, m, x, x1, x2, x3: integer;\n\tarr: array [1..115, 1..115] of char;\n\ts: string;\n\t\nbegin\n\n\treadln(n);\n\tfor var i := 0 to n - 1 do\n\tbegin\n\t\tread(x);\n\t\ta += x;\n\tend;\n\t\n\tfor var i := 0 to n - 1 do\n\tbegin\n\t\tread(x1);\n\t\tb += x1;\n\tend;\n\t\n\tif (a >= b) then\n\t\twriteln('YES')\n\telse \n\t\twriteln('NO');\n\t\n\t\nend.\n", "src_uid": "e0ddac5c6d3671070860dda10d50c28a"} {"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\tTCustomType = int32; // <------ TYPE\n\tTPair = record x,y : int32; end;\n\tvector = specialize TVector;\n\tvectorInt = specialize TVector;\n\tvectorPair = specialize TVector;\n compare = class\n \tpublic\n \tclass function c(a,b : TCustomType) : boolean;\n end;\n utils = specialize TOrderingArrayUtils;\nclass function compare.c(a,b : TCustomType) : boolean;\n\tbegin Result := a0) then begin\n \tres += x;\n\t\t\t\tk -= 1;\n\t\t\tend else begin\n res += a[i];\n\t\t\tend;\n\t\tend;\n\t\twrite(res);\n\t\twait;\n end;\n\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n\tmain();\n close(input); close(output);\nend.", "src_uid": "92a233f8d9c73d9f33e4e6116b7d0a96"} {"source_code": "uses\n math, sysutils, strutils;\ntype\n ex=extended;\n int=longint;\n bool=boolean;\nvar\n i,n: int; \nbegin\nreadln(n);\nif n<3\n then\n writeln(-1)\n else\n begin\n write('100 100');\n for i:= 1 to n-2 do\n write(#$20, i);\n end;\nend.\n", "src_uid": "fe8a0332119bd182a0a5b7758716317e"} {"source_code": "var n,s:int64;\n\nfunction check(x:int64):boolean;\nvar a,t:int64;\nbegin\n t := 0; a := x;\n while a > 0 do begin\n t := t + a mod 10;\n a := a div 10;\n end;\n exit(x - t >= s);\nend;\n\nprocedure xuly();\nvar l,r,mid,ans:int64;\nbegin\n ans := 0;\n l := 0; r := n;\n while l <= r do begin\n mid := (l + r) div 2;\n if check(mid) then begin\n ans := n - mid + 1;\n r := mid - 1;\n end else l := mid + 1;\n end;\n writeln(ans);\nend;\n\nbegin\n readln(n,s);\n xuly();\nend.\n", "src_uid": "9704e2ac6a158d5ced8fd1dc1edb356b"} {"source_code": "var a,b:array[1..100] of longint;\n i,n,j,k:longint;\nbegin\nread(n);\nfor i:=1 to n do\n read(a[i],b[i]);\nk:=0;\nfor i:=1 to n do\n for j:=1 to n do\n begin\n if a[i]=b[j] then inc(k);\n end;\nwrite(k);\nend.", "src_uid": "745f81dcb4f23254bf6602f9f389771b"} {"source_code": "var\n n:longint;\nbegin\n readln(n);\n if (not odd(n)) and (n>2) then writeln('YES')\n else writeln('NO');\nend.", "src_uid": "230a3c4d7090401e5fa3c6b9d994cdf2"} {"source_code": "\ufeffvar\nn,i,F,S:int64;\na:string;\nbegin\n readln(n);\n read(a);\n for i := 2 to n do \n begin\n if (a[i-1]='F') and (a[i]='S') then \n F:=F+1; \n if (a[i]='F') and (a[i-1]='S') then\n S:=S+1;\n end;\n if S>F then write('YES') else write('NO');\nend.", "src_uid": "ab8a2070ea758d118b3c09ee165d9517"} {"source_code": "{$Q+,R+,O+}\nvar n,i,x,s,rez:LongInt;\nbegin\n //reset(input,'input.txt');\n //rewrite(output,'output.txt');\n readln(n);\n s:=0;\n for i:=1 to n do\n begin\n read(x);\n inc(s,x);\n end;\n rez:=0;\n for i:=1 to 5 do\n begin\n if ((s+i)mod (n+1))<>1\n then inc(rez);\n end;\n writeln(rez);\nend.\n\n", "src_uid": "ff6b3fd358c758324c19a26283ab96a4"} {"source_code": "var s : string;\n i,p,k,kk,m,v,j,min,n : longint;\n ss : array [1..100] of string;\n a : array [1..100] of longint;\nprocedure qsort(l,r : longint);\nvar w,q : longint;\n ww : string;\nbegin\n i:=l; j:=r;\n q:=a[(l+r) div 2];\n while i<=j do\n begin\n while a[i]q do dec(j);\n if i<=j then\n begin\n w:=a[i]; a[i]:=a[j]; a[j]:=w;\n ww:=ss[i]; ss[i]:=ss[j]; ss[j]:=ww;\n inc(i); dec(j);\n end;\n end;\n if l2 then min:=0;\n if (kk=1) and (22) and (ss[i][2]=ss[j][2]) then break;\n if (a[j]-a[i]=2) and (ss[i][2]=ss[j][2]) then\n begin\n inc(kk);\n break;\n end;\n end;\n k:=0;\n if (kk=0) and (21 then min:=0;\n end;\n writeln(min);\nend.", "src_uid": "7e42cebc670e76ace967e01021f752d3"} {"source_code": "Program p;\nvar x, k: integer;\n l: array [0..1] of integer;\n s: string;\n \nbegin\nread(l[0], l[1], x);\nl[0]+=-1;\nk:=1;\ns:='0';\nwhile x>1 do\n begin\n s+=inttostr(k);\n l[k]+=-1;\n k:=1-k;\n x:=x-1\n end;\nif (l[0]=0) and (x=1) and (s[length(s)]='1') then\n for var g:=1 to l[1] do\n s:='1'+s\n else\n begin\nk:=1-k;\nfor var g:=1 to l[k] do\n s+=inttostr(k);\nk:=1-k;\nfor var g:=1 to l[k] do\n s+=inttostr(k);\nend;\nwrite(s)\nend.", "src_uid": "ef4123b8f3f3b511fde8b79ea9a6b20c"} {"source_code": "var ans,i,j:longint;\n s,t:string;\nbegin\n readln(s);\n t:='aeiou13579';\n for i:=1 to length(s) do\n for j:=1 to length(t) do\n if s[i]=t[j] then\n begin\n inc(ans);\n break;\n end;\n writeln(ans);\nend.", "src_uid": "b4af2b8a7e9844bf58ad3410c2cb5223"} {"source_code": "var n,k:int64;\nbegin readln(n,k);\nif (n div k) mod 2 <>0 then write('YES')\nelse write('NO')\nend.", "src_uid": "05fd61dd0b1f50f154eec85d8cfaad50"} {"source_code": "program n1;\nconst nmax=200;\n\nvar a: array [0..nmax] of char;\n\ti, j, n, k, kk, p, ans, koln, kolmax: integer;\n\tyes: boolean;\nbegin\n\tyes:= false;\n\tread(n);\n\tread(k);\n readln;\n\tfor i:=1 to n do\n\t\tread(a[i]);\n\ta[0]:='Y';\n\ta[n+1]:='Y';\n\tans := 0;\n\tfor i:=1 to n do\n\t\tif a[i]='N' then begin\n\t\t\tkoln:=1;\n\t\t\tj:=i+1;\n\t\t\twhile a[j]='N' do begin\n\t\t\t\tj:=j+1;\n\t\t\t\tkoln:=koln+1\n\t\t\tend;\n\t\t\tif koln > kolmax then kolmax:=koln;\n\t\tend;\n\tif kolmax > k then write('NO')\n\telse begin\n\t for i:=0 to n do begin\n\t for j:= i + 1 to n + 1 do begin\n\t if ((a[i] = '?') or (a[i] = 'Y')) and ((a[j] = '?') or (a[j] = 'Y')) then begin\n p := 0;\n\t for kk:= i + 1 to j - 1 do begin\n\t if a[kk] = 'Y' then p := 1;\n\t end;\n\t if (p = 0) and (j - i = k + 1) then begin\n\t ans := 1;\n end;\n end;\n end;\n end;\n if ans = 1 then writeln('YES')\n else writeln('NO')\n\tend\nend.", "src_uid": "5bd578d3da5837c259b222336a194d12"} {"source_code": "var\na:array[1..24] of integer;\nk,k1,k11,k12,k13,k14:boolean;\nt:array[1..8] of integer;\ni:integer;\nbegin\nfor i:=1 to 24 do begin\n read(a[i]);\nend;\n//1\ni:=1;\nk:=(a[i*4]=a[i*4-1]) and (a[i*4-2]=a[i*4-3]) and (a[i*4-1]=a[i*4-2]);\ni:=3;\nk1:=(a[i*4]=a[i*4-1]) and (a[i*4-2]=a[i*4-3]) and (a[i*4-1]=a[i*4-2]);\nk11:=a[13] = a[14] and a[7] and a[8];\nk12:=a[5] = a[6] and a[19] and a[20];\nk13:=a[17] = a[18] and a[23] and a[24];\nk14:=a[21] = a[22] and a[15] and a[16];\nif k and k1 and k11 and k12 and k13 and k14 then begin write('YES'); exit; end; \n//2\ni:=1;\nk:=(a[i*4]=a[i*4-1]) and (a[i*4-2]=a[i*4-3]) and (a[i*4-1]=a[i*4-2]);\ni:=3;\nk1:=(a[i*4]=a[i*4-1]) and (a[i*4-2]=a[i*4-3]) and (a[i*4-1]=a[i*4-2]);\nk11:=a[13] = a[14] and a[23] and a[24];\nk12:=a[5] = a[6] and a[15] and a[16];\nk13:=a[17] = a[18] and a[7] and a[8];\nk14:=a[21] = a[22] and a[19] and a[20];\nif k and k1 and k11 and k12 and k13 and k14 then begin write('YES'); exit; end; \n//3\ni:=2;\nk:=(a[i*4]=a[i*4-1]) and (a[i*4-2]=a[i*4-3]) and (a[i*4-1]=a[i*4-2]);\ni:=6;\nk1:=(a[i*4]=a[i*4-1]) and (a[i*4-2]=a[i*4-3]) and (a[i*4-1]=a[i*4-2]);\nk11:=a[3] = a[4] and a[18] and a[20];\nk12:=a[17] = a[19] and a[11] and a[12];\nk13:=a[9] = a[10] and a[13] and a[15];\nk14:=a[14] = a[16] and a[1] and a[2];\nif k and k1 and k11 and k12 and k13 and k14 then begin write('YES'); exit; end;\n//4\ni:=2;\nk:=(a[i*4]=a[i*4-1]) and (a[i*4-2]=a[i*4-3]) and (a[i*4-1]=a[i*4-2]);\ni:=6;\nk1:=(a[i*4]=a[i*4-1]) and (a[i*4-2]=a[i*4-3]) and (a[i*4-1]=a[i*4-2]);\nk11:=a[3] = a[4] and a[13] and a[15];\nk12:=a[17] = a[19] and a[1] and a[2];\nk13:=a[9] = a[10] and a[18] and a[20];\nk14:=a[14] = a[16] and a[11] and a[12];\nif k and k1 and k11 and k12 and k13 and k14 then begin write('YES'); exit; end; \n//5\ni:=4;\nk:=(a[i*4]=a[i*4-1]) and (a[i*4-2]=a[i*4-3]) and (a[i*4-1]=a[i*4-2]);\ni:=5;\nk1:=(a[i*4]=a[i*4-1]) and (a[i*4-2]=a[i*4-3]) and (a[i*4-1]=a[i*4-2]);\nk11:=a[2] = a[4] and a[5] and a[7];\nk12:=a[6] = a[8] and a[9] and a[11];\nk13:=a[10] = a[12] and a[22] and a[24];\nk14:=a[21] = a[23] and a[1] and a[3];\nif k and k1 and k11 and k12 and k13 and k14 then begin write('YES'); exit; end; \n//6\ni:=4;\nk:=(a[i*4]=a[i*4-1]) and (a[i*4-2]=a[i*4-3]) and (a[i*4-1]=a[i*4-2]);\ni:=5;\nk1:=(a[i*4]=a[i*4-1]) and (a[i*4-2]=a[i*4-3]) and (a[i*4-1]=a[i*4-2]);\nk11:=a[2] = a[4] and a[22] and a[24];\nk12:=a[6] = a[8] and a[1] and a[3];\nk13:=a[10] = a[12] and a[5] and a[7];\nk14:=a[21] = a[23] and a[9] and a[11];\nif k and k1 and k11 and k12 and k13 and k14 then begin write('YES'); exit; end; \nwrite('NO');\nend.", "src_uid": "881a820aa8184d9553278a0002a3b7c4"} {"source_code": "\nvar i,n,m,t,w,s:longint;\na:array[1..100000] of longint;\nfunction max(x,y:longint):longint;\nbegin\nif x>y then exit(x);\nexit(y);\nend;\nbegin\n//assign(input,'cdhxzzf.in');reset(input);\n//assign(output,'cdhxzzf.out');rewrite(output);\nreadln(n,m);\nfor i:=1 to n do read(a[i]);\nfor i:=0 to max(m-1,n-m) do\n begin\n t:=m-i;w:=m+i;\n if (t>=1)and(w<=n) then\n begin\n if (a[t]=1)and(a[w]=1) then\n begin\n if i<>0 then s:=s+2\n else s:=s+1;\n end\n end\n else\n if (t>=1)and(w>n) then\n begin\n if a[t]=1 then inc(s);\n end\n else\n if (w<=n)and(t<1) then\n begin\n if a[w]=1 then inc(s);\n end;\n end;\nwriteln(s);\nclose(input);\nclose(output);\nend.", "src_uid": "4840d571d4ce6e1096bb678b6c100ae5"} {"source_code": "const\n HR=1000000007;\nvar\n n,m:qword;\n k:longint;\nfunction pow(a,b,n:qword):qword;\nvar t,y:qword;\nbegin\n t:=1;\n y:=a;\n while b<>0 do\n begin\n if b and 1=1 then t:=t*y mod n;\n y:=y*y mod n;\n b:=b>>1;\n end;\n exit(t);\nend;\nbegin\n read(n,m,k);\n if ((n+m) mod 2=1)and(k=-1) then\n begin\n writeln(0);\n exit;\n end;\n dec(n);\n dec(m);\n n:=n mod (HR-1);\n m:=m mod (HR-1);\n writeln(pow(2,n*m,HR));\nend.", "src_uid": "6b9eff690fae14725885cbc891ff7243"} {"source_code": "Program Madalina;\nvar n,i,j,p1,p2:longint;\n t:array[0..105] of longint;\nbegin\n readln(n);\n for i:=1 to n do read(t[i]);\n for i:=1 to n do\n begin\n read(j);\n if (t[i]=1) and (j=0) then inc(p1);\n if (t[i]=0) and (j=1) then inc(p2);\n end;\n if (p1=0) then writeln(-1) else\n begin\n writeln((p2 div p1)+1);\n end;\nend.", "src_uid": "b62338bff0cbb4df4e5e27e1a3ffaa07"} {"source_code": "var n,i,j,k,t,ma,ans,m:longint;\n a,dp:array[0..10000] of longint;\n js:array[0..300] of longint;\nfunction max(a,b:longint):longint;\nbegin\n if a>b then exit(a) else exit(b);\nend;\nfunction min(a,b:longint):longint;\nbegin\n if ama then ma:=js[i];\n ans:=ma*t;\n m:=min(n,t);\n for i:=n+1 to m*n do a[i]:=a[i-n];\n\n for i:=1 to m*n do\n begin\n dp[i]:=1;\n for j:=max(1,i-n) to i-1 do if a[i]>=a[j] then dp[i]:=max(dp[i],dp[j]+1);\n ans:=max(ans,dp[i]+ma*(t-m));\n end;\n writeln(ans);\nend.\n", "src_uid": "26cf484fa4cb3dc2ab09adce7a3fc9b2"} {"source_code": "\ufeffvar s,x,i:integer;\r\nbegin\r\n for i:=1 to readlninteger do begin\r\n readln(s); var ans:='';\r\n for x:=9 downto 1 do begin\r\n if s>=x then begin \r\n ans:=chr(48+x)+ans; s-=x\r\n end else begin\r\n ans:=chr(48+s)+ans; s:=0\r\n end;\r\n if s=0 then break\r\n end;\r\n println(ans)\r\n end\r\nend.", "src_uid": "fe126aaa93acaca8c8559bc9e7e27b9f"} {"source_code": "program cf314B;\nvar\nt1,t2,now,j,tot,i:longint;\nx1,x2:ansistring;\nc,d:array[0..100000] of longint;\nf:array['a'..'z'] of boolean;\nbegin\nreadln(t1,t2);\nreadln(x1);\nreadln(x2);\nnow:=1;\nfor i:=1 to length(x1) do f[x1[i]]:=true;\nfor i:=1 to length(x2) do if not f[x2[i]] then begin writeln(0);halt;end;\nfillchar(c,sizeof(c),0);\ntot:=0;\ni:=0;\nwhile ilength(x2) then begin\nnow:=1;\nif c[j]=0 then begin c[j]:=i;inc(tot);d[j]:=tot;end else begin\nnow:=1;\n//d:=i-c[j];\ninc(tot);\ntot:=tot+(tot-d[j])*((t1-i) div (i-c[j]));\ni:=t1-(t1-i) mod (i-c[j]);\nfillchar(c,sizeof(c),0);;\nend;\nend;\nend;\nend;\nwriteln(tot div t2);\nend.\n", "src_uid": "5ea0351ac9f949dedae1928bfb7ebffa"} {"source_code": "var\n n,v,i,k,a,j:integer;\nbegin\n read(n,v);\n a:=1;\n for i:=1 to n do\n begin\n a:=a-1;\n if a=n-i then break;\n k:=a;\n repeat\n a:=a+1;\n until (a=v) or (a=n-i);\n j:=j+((a-k)*i);\n end;\n write(j);\nend.", "src_uid": "f8eb96deeb82d9f011f13d7dac1e1ab7"} {"source_code": "uses math;\nvar a:array[1..2,0..100] of longint;\n b:array[1..100] of longint;\n i,j,k,l,m,n,z:longint;\nbegin\nreadln(n,k);\nfor i:=1 to n do\nread(b[i]);\nfor i:=1 to n do\ninc(a[b[i],i mod k]);\nz:=0;\nfor i:=0 to k-1 do\nz:=z+min(a[1,i],a[2,i]);\nwriteln(z);\nend.", "src_uid": "5f94c2ecf1cf8fdbb6117cab801ed281"} {"source_code": "var\r\n a:longint;kq,dem,tam:integer;\r\nbegin\r\nkq:=10;\r\nread(a);\r\nwhile kq>9 do\r\nbegin\r\nwhile a<>0 do\r\nbegin\r\ntam:=a mod 10;\r\na:=a div 10;\r\ndem:=dem+tam;\r\nend;\r\nkq:=dem;\r\na:=dem;\r\ndem:=0;\r\nend;\r\nwrite(kq);\r\nend.", "src_uid": "477a67877367dc68b3bf5143120ff45d"} {"source_code": "Uses math;\nVar fi, fo: text;\n l1, l2, r1, r2, k, a, b: int64;\n\nBegin\n\tassign(fi,''); reset(fi);\n\tassign(fo,''); rewrite(fo);\n\treadln(fi, l1, r1, l2, r2, k);\n\tif (L1<=L2) then\n\tbegin\n\t\tif (R1>=L2) and (R1<=R2) then\n\t\tbegin\n\t\t\ta:= L2;\n\t\t\tb:= R1;\n\t\tend;\n\t\tif R1>=R2 then\n\t\tbegin\n\t\t\ta:= L2;\n\t\t\tb:= R2;\n\t\tend;\n\tend;\n\tif (L1>L2) and (L1<=R2) then\n\tbegin\n\t\tif R1<=R2 then\n\t\tbegin\n\t\t\ta:= L1;\n\t\t\tb:= R1;\n\t\tend;\n\t\tif R1>=R2 then\n\t\tbegin\n\t\t\ta:= L1;\n\t\t\tb:= R2;\n\t\tend;\n\tend;\n\tif (a<>0) and (b<>0) then \n\t\tif (k>=a) and (k<=b) then writeln(fo, b-a)\n\t\telse writeln(fo, b-a+1)\n\telse writeln(fo, 0);\n\tclose(fi); close(fo);\nEnd.\n", "src_uid": "9a74b3b0e9f3a351f2136842e9565a82"} {"source_code": "program LH;\nvar\n i,n,m,ans:longint;\nbegin\n readln(n,m);ans:=0;\n for i:=0 to trunc(sqrt(n)) do\n if (i+(n-i*i)*(n-i*i)=m) then inc(ans);\n writeln(ans);\nend.\n", "src_uid": "03caf4ddf07c1783e42e9f9085cc6efd"} {"source_code": "var min,n,a,b,c:int64;\n ii,jj,kk,pp:longint;\n i,j,k:int64;\nbegin\n readln(n,a,b,c);\n min:=a*10;\n for ii:=0 to 10 do\n for jj:=0 to 10 do\n for kk:=0 to 10 do\n begin\n i:=ii;\n j:=jj;\n k:=kk;\n if (i+j*2+k*3 + n ) mod 4=0 then\n if i*a+b*j+k*c < min then min:=i*a+b*j+k*c;\n end;\n writeln(min);\n\nend.", "src_uid": "c74537b7e2032c1d928717dfe15ccfb8"} {"source_code": "const\n fi='';\n fo='';\n maxn=1000100;\n maxc=1000000000;\n mm=1000000000+7;\nvar\n d,f,inn:array[0..2*maxn] of int64;\n n:longint;\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 read(n);\nend;\n{--------------------------}\nfunction inv(x:longint):int64;\nvar\n m,n,xm,xn,xr,q,r:int64;\nbegin\n m:=x; n:=mm;\n xm:=1; xn:=0;\n while n<>0 do\n begin\n q:=m div n;\n r:=m-q*n;\n xr:=xm-q*xn;\n m:=n; xm:=xn;\n n:=r; xn:=xr;\n end;\n exit(xm);\nend;\n{--------------------------}\nprocedure xuly;\nvar\n i,j:longint;\n tmp:int64;\nbegin\n f[1]:=1;\n d[0]:=1;\n d[n]:=1;\n for i:=n+1 to 2*n do\n begin\n tmp:=inv(i-n);\n d[i]:=(d[i-1]+((n*d[i-1])mod mm)*tmp) mod mm;\n end;\n for i:=2 to 2*n do\n begin\n f[i]:=(2*f[i-1]-d[i-1]+mm) mod mm;\n end;\n\n for i:=1 to 2*n do res:=(res+2*f[i]) mod mm;\n writeln((res+1) mod mm);\nend;\n{-------------------------}\nBEGIN\n openfiles;\n nhap;\n xuly;\n closefiles;\nEND.\n\n", "src_uid": "a18833c987fd7743e8021196b5dcdd1b"} {"source_code": "var a,b:array [1..10000] of integer;\nc,d,e:integer;\nI, k, j: integer;\nbegin\nreadln (c,d,e);\nI:=1;\na[c]:=1;\nb[d]:=1;\nwhile (c<=e) do\nbegin\nc:=round((c/i));\nI:=I+1;\nc:=c*i;\nif (c<=e) then begin a[c]:=1; end;\nend;\n\nI:=1;\n\nwhile (d<=e) do\nbegin\nd:=round((d/i));\nI:=I+1;\nd:=d*i;\nif (d<=e) then begin b[d]:=1; end;\nend;\nk:=0;\nfor j:=1 to round(e) do begin\nif ((a[j]=1) and (b[j]=1)) then k:=k+1;\nend;\nwriteln(k);\nend. ", "src_uid": "e7ad55ce26fc8610639323af1de36c2d"} {"source_code": "var n,m:int64;\nFunction GTN(a,x:int64):int64;\nvar tmp:int64;\nbegin\n if x=0 then GTN:=1\n else begin\n tmp:=sqr(GTN(a,x div 2)) mod 1000000007;\n if (x mod 2)=1 then tmp:=tmp*a mod 1000000007;\n GTN:=tmp;\n end;\nend;\nFunction GTN2(x:int64):int64;\nvar tmp:int64;\nbegin\n if x=0 then GTN2:=1\n else begin\n tmp:=sqr(GTN2(x div 2)) mod 1000000007;\n if (x mod 2)=1 then tmp:=tmp*2 mod 1000000007;\n GTN2:=tmp;\n end;\nend;\nbegin\n read(n,m);\n writeln((GTN(GTN2(m)-1,n)) mod 1000000007);\nend.", "src_uid": "71029e5bf085b0f5f39d1835eb801891"} {"source_code": "{$R+,Q+,I+}\n{$apptype console}\nUses SysUtils,math;\nVar\n n,m,x,y,a,b,k,a1,b1,x1,y1,x2,y2,x3,y3,x4,y4,r,ans1,ans2,ans3,ans4,r1,m1:Int64;\n i,j:Integer;\nFunction Gcd(a,b:Int64):Int64;\nBegin\n If b=0 Then Gcd:=a\n Else Gcd:=Gcd(b,a mod b);\nEnd;\nFunction Check(x1,x2,x3,x4,y1,y2,y3,y4:Int64):Boolean;\nBegin\n Check:=(x1n Then Begin\n x1:=x1-x2+n;\n x2:=n;\n End;\n If y2>m Then Begin\n y1:=y1-y2+m;\n y2:=m;\n End;\n m1:=High(Int64);\n ans1:=0;\n ans2:=0;\n ans3:=0;\n ans4:=0;\n For i:=-100 To 100 Do\n For j:=-100 To 100 Do Begin\n x3:=x1+int64(i);\n y3:=y1+int64(j);\n x4:=x3+a1;\n y4:=y3+b1;\n If (x3>=0) and (x4<=n) and (y3>=0) and (y4<=m) Then Begin\n r1:=((x3+x4)-2*x)*((x3+x4)-2*x)+((y3+y4)-2*y)*((y3+y4)-2*y);\n If r10) do\n begin\n if (not f[j])and(a[j]<=a[i]-2)and(k+a[j]<=a[i]) then\n begin\n k:=k+a[j];\n f[j]:=true;\n end;\n dec(j);\n end;\n if j<0 then print;\n end;\n for i:=1 to n-1 do if not f[i] then print;\n writeln('YES');\nend.", "src_uid": "ed0925cfaee961a3ceebd13b3c96a15a"} {"source_code": "program zB;\n\n{$APPTYPE CONSOLE}\nuses\n SysUtils, math;\n\nvar i,n,d1,d2,x1,x2,y,j,f1,f2:longint;\n a:array[1..100] of LongInt;\n\nbegin\n{assign(input,'input.txt');\nreset(input);\nassign(output,'output.txt');\nrewrite(output); }\nreadln(n);\nfor i:=1 to n do read(a[i]);\n\ni:=1;\nwhile a[i]=a[i+1] do Inc(i);\n\nif (i=n) or (n=1) then Writeln(0)\nelse\nbegin\nd1:=Abs(a[i] - a[i+1]);\nif (a[i] + a[i+1]) mod 2 = 0 then\n d2:=Abs(a[i] - ((a[i] + a[i+1]) div 2))\n else d2:=-1;\n\n //d1\nx1:=a[i];\nx2:=a[i+1];\n\ny:= (a[i] + a[i+1]) div 2;\nj:=i;\nwhile i<=n do\n begin\n if not((a[i] = x1) or (a[i] + d1 = x1) or (a[i] - d1 = x1) ) then\n begin\n f1:=-1;\n Break;\n end;\n inc(i);\n end;\ni:=j;\nwhile i<=n do\n begin\n if not((a[i] = x2) or (a[i] + d1 = x2) or (a[i] - d1 = x2)) then\n begin\n f2:=-1;\n Break;\n end;\n inc(i);\n end;\n\nif (f1=-1) and (f2=-1) then d1:=-1;\n\n //d2\ni:=j;\nwhile (i<=n) and (d2<>-1) do\n begin\n if not((a[i] = y) or (a[i] + d2 = y) or (a[i] - d2 = y)) then\n begin\n d2:=-1;\n Break;\n end;\n inc(i);\n end;\n\nif Min(d1,d2)<>-1 then writeln(Min(d1,d2))\nelse\nif Max(d1,d2)<>-1 then writeln(Max(d1,d2))\nelse Writeln(-1);\n\nend;\n\n{Writeln(d1,' ',d2);\nclose(input);\nclose(output); }\nend.\n", "src_uid": "d486a88939c132848a7efdf257b9b066"} {"source_code": "var n,i:longint;\n s:ansistring;\n d:array['a'..'z'] of longint;\nbegin\n readln(n);\n read(s);\n if n=1 then\n begin\n write('YES');\n halt;\n end;\n for i:=1 to n do inc(d[s[i]]);\n for i:=1 to n do\n begin\n if d[s[i]]>=2 then\n begin\n write('YES');\n halt;\n end;\n end;\n write('NO');\nend.", "src_uid": "6b22e93f7e429693dcfe3c099346dcda"} {"source_code": "type swap = record\ns:longint;\nd:longint;\nEnd;\n\nvar f1,f2:text;\nn,res,i,spt,sl,top:longint;\nA,Count:array[0..20] of longint;\nKQ:array[1..1 shl 20] of swap;\n\nProcedure chuyen(s,d:longint);\nBegin\n inc(res);\n KQ[res].s:=s;\n KQ[res].d:=d;\nEnd;\n\nProcedure U(s,d,tg,vt:longint);\nvar i:longint;\nbegin\n if vt>spt then exit;\n U(s,tg,d,vt+1);\n for i:=1 to count[vt] do chuyen(s,d);\n U(tg,d,s,vt+1);\nEnd;\n\nProcedure C(s,d,tg,vt:longint);\nvar i:longint;\nBegin\n if vt>spt then exit;\n if vt=spt then\n Begin\n for i:=1 to count[vt]-1 do chuyen(s,tg);\n chuyen(s,d);\n for i:=1 to count[vt]-1 do chuyen(tg,d);\n Exit;\n End;\n if count[vt]=1 then\n Begin\n U(s,d,tg,vt);\n Exit;\n End;\n U(s,d,tg,vt+1);\n for i:=1 to count[vt] do chuyen(s,tg);\n U(d,s,tg,vt+1);\n for i:=1 to count[vt] do chuyen(tg,d);\n C(s,d,tg,vt+1);\nEnd;\n\nBegin\n assign(f1,'');reset(f1);\n assign(f2,'');rewrite(f2);\n readln(f1,n);\n For i:=1 to n do\n Begin\n read(f1,A[i]);\n if A[i]<>A[i-1] then inc(spt);\n Inc(Count[spt]);\n End;\n C(1,3,2,1);\n Writeln(f2,res);\n for i:=1 to res do\n writeln(f2,KQ[i].s,' ',KQ[i].d);\n\n close(f1);\n close(f2);\nEnd.\n", "src_uid": "4ea4ad10ef422a9cd45b8a7b25d359c5"} {"source_code": "uses math;\n\ntype my = record\n x,y:int64;\n end;\n\ntype my2 = record\n x,y:int64;\n end;\n\n\nvar a,b:array[0..200000] of my;\n c,d:array[0..200000] of my2;\n i,n,m:longint;\n l,r,mid,j:longint;\n mx,dd,d1:int64;\n\n\n procedure sort(l,r: longint);\n var\n i,j: longint;\n x,y:my;\n begin\n i:=l;\n j:=r;\n x:=a[l+random(r-l)];\n repeat\n while (a[i].x>x.x)or((a[i].x=x.x)and(a[i].ya[j].x)or((x.x=a[j].x)and(x.yj) 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.x)or((b[i].x=x.x)and(b[i].yb[j].x)or((x.x=b[j].x)and(x.yj) 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 ldd) then break;\n d1:=dd - c[i].y;\n l:=1;\n r:=m;\n while(l+1> 1;\n if(d[mid].y>d1) then r:=mid else l:=mid;\n end;\n for j := min(m,r+5) downto max(1,l-5) do\n begin\n if(d[j].y<=d1) then\n begin\n mx:=max(mx,c[i].x + d[j].x);\n break;\n end;\n end;\n end;\n\n writeln(mx);\n\n end.", "src_uid": "da573a39459087ed7c42f70bc1d0e8ff"} {"source_code": "var n,m,k,i,min,j:integer;\n a,b,c:array[1..100] of integer;\nbegin\n j:=0;\n readln(n,m,k);\n for i:=1 to n do\n read(a[i]);\n\n for i:=1 to n do\n if (a[i]<=k) and (a[i]<>0) then b[i]:=i;\n\n for i :=1 to n do\n if b[i]<>0 then\n min:=abs(b[i]-m);\n\n for i:=1 to n do\n if b[i]<>0 then\n if abs(b[i]-m)<=min then min:=abs(b[i]-m);\n writeln(min*10);\n\nend.", "src_uid": "57860e9a5342a29257ce506063d37624"} {"source_code": "var x,i,j:longint;\nbegin\n readln(x);\n for i:=1 to x do\n for j:=1 to x do\n begin\n if (i mod j=0) and (i*j>x) and ((i/j)0)then exit;\n if (a2=0)and(b2=0)and(c2<>0)then exit;\n d:=a1*b2-b1*a2;\n dx:=a1*c2-c1*a2;\n dy:=c1*b2-b1*c2;\n if (d=0)and(dx=0)and(dy=0)then begin\n writeln('YES');\n halt(0);\n end;\n if (d=0)then exit;\n if (dx mod d=0)and(dy mod d=0)then begin\n writeln('YES');\n halt(0);\n end;\n end;\n\nbegin\n read(xa,ya);\n read(xb,yb);\n read(xc,yc);\n check(xb-xa,yb-ya);\n check(xb+xa,yb+ya);\n check(xb+ya,yb-xa);\n check(xb-ya,yb+xa);\n writeln('NO');\nend.\n", "src_uid": "cc8a8af1ba2b19bf081e379139542883"} {"source_code": "program task_e;\nuses math,sysutils;\nconst\n ans:array[0..2]of string=('Stas','Masha','Missing');\nvar\n n:extended;\n a,b,k:integer;\nfunction wining(a,b:integer):boolean;\nbegin\n if b>k then begin writeln(ans[2]); halt; end;\n if intpower(a,b)>=n then result:=true\n else if (b>1)or(a=1)\n then result:=not(wining(a+1,b)and wining(a,b+1))\n else result:=not(wining(a,b+1)and wining(a+1,b));\nend;\nbegin\n{ reset(input,'test.in');\n rewrite(output,'test.out');\n}\ntry\n read(a,b,n);\n k:=ceil(logn(2,n))+1;\n writeln(ans[ord(wining(a,b))])\nexcept\n writeln(ans[0]);\n halt;\nend;\nend.\n", "src_uid": "cffd5c0b7b659649f3bf9f2dbd20ad6b"} {"source_code": "\nvar i,k,n:byte; l:integer;\n a:array[1..5] of integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nread(a[i]);\nfor i:=1 to n do\nfor k:=1 to n-i do\nif a[k]>a[k+1] then\nbegin\nl:=a[k];\na[k]:=a[k+1];\na[k+1]:=l;\nend;\nwrite(a[1+( n div 2)]);\nreadln;\nend.\n", "src_uid": "f03773118cca29ff8d5b4281d39e7c63"} {"source_code": "var a:array[0..200000,0..2] of int64;\nx:array[0..2] of int64;\ni,j,k,l,m,n:int64;\nbegin\nread(n,k,l);\nj:=k;i:=l;\nif l=1 then x[1]:=1 else begin\nwhile i mod 3<>0 do i-=1;\nwhile j mod 3<>0 do j+=1;\nif i>=j then x[0]+=(i-j) div 3 +1;\nj:=k;i:=l;\nwhile i mod 3<>1 do i-=1;\nwhile j mod 3<>1 do j+=1;\nif i>=j then x[1]+=(i-j) div 3 +1;\n\nj:=k;i:=l;\nwhile i mod 3<>2 do i-=1;\nwhile j mod 3<>2 do j+=1;\nif i>=j then x[2]+=(i-j) div 3 +1;\n//println(x);\nend;\nfor i:=0 to 2 do a[1,i]:=x[i];\nfor i:=2 to n do\nbegin\na[i,0]:=a[i-1,0]*x[0]+a[i-1,1]*x[2]+a[i-1,2]*x[1];\na[i,1]:=a[i-1,0]*x[1]+a[i-1,1]*x[0]+a[i-1,2]*x[2];\na[i,2]:=a[i-1,0]*x[2]+a[i-1,1]*x[1]+a[i-1,2]*x[0];\n//for j:=0 to 2 do print(a[i,j]);writeln;\nfor j:=0 to 2 do\na[i,j]:=a[i,j] mod 1000000007;\nend;\nwrite(a[n,0])\nend.\n", "src_uid": "4c4852df62fccb0a19ad8bc41145de61"} {"source_code": "var\n bz:boolean;\n zx,zy,yx,yy:longint;\n zx1,zy1,yx1,yy1:longint;\n i,j,tot,a,b,ax,ay:longint;\n x1,y1,x2,y2:array[1..4] of longint;\nfunction max(x,y:longint):longint;\nbegin\n if x>y then exit(x) else exit(y);\nend;\nfunction min(x,y:longint):longint;\nbegin\n if x=zx)and(a<=yx)and(b>=zy)and(b<=yy) then\n begin\n writeln('YES');\n halt;\n end;\nend;\nprocedure swap(var a,b:longint);\nvar\n c:longint;\nbegin\n c:=a;\n a:=b;\n b:=c;\nend;\nbegin\n //assign(input,'square.in');reset(input);\n //assign(output,'square.out');rewrite(output);\n read(x1[1],y1[1]);\n zx:=x1[1]; zy:=y1[1];\n yx:=x1[1]; yy:=y1[1];\n for i:=2 to 4 do\n begin\n read(x1[i],y1[i]);\n zx:=min(zx,x1[i]);\n zy:=min(zy,y1[i]);\n yx:=max(yx,x1[i]);\n yy:=max(yy,y1[i]);\n end;\n for i:=1 to 4 do read(x2[i],y2[i]);\n for i:=1 to 3 do\n begin\n for j:=i+1 to 4 do\n begin\n if x2[i]>x2[j] then\n begin\n swap(x2[i],x2[j]);\n swap(y2[i],y2[j]);\n end;\n if (x2[i]=x2[j])and(y2[i]>y2[j]) then\n begin\n swap(x2[i],x2[j]);\n swap(y2[i],y2[j]);\n end;\n end;\n end;\n a:=x2[1];\n b:=-1;\n while a<=x2[2] do\n begin\n inc(b);\n pd(a,y2[1]);\n for i:=1 to b do\n begin\n pd(a,y2[1]+i);\n pd(a,y2[1]-i);\n end;\n inc(a);\n end;\n while a<=x2[4] do\n begin\n dec(b);\n pd(a,y2[1]);\n for i:=1 to b do\n begin\n pd(a,y2[1]+i);\n pd(a,y2[1]-i);\n end;\n inc(a);\n end;\n writeln('NO');\nend.", "src_uid": "f6a3dd8b3bab58ff66055c61ddfdf06a"} {"source_code": "{$mode objfpc}\nuses math;\n\nvar\n m,n,i:integer;\n f:array[0..1000000,0..4] of qword;\n kq:qword;\n\nbegin\n read(m,n);\n for i:=1 to max(m,n) do\n begin\n f[i]:=f[i-1];\n inc(f[i,i mod 5]);\n end;\n kq:=f[m,0]*f[n,0] + f[m,1]*f[n,4] + f[m,2]*f[n,3] + f[m,3]*f[n,2] + f[m,4]*f[n,1];\n write(kq);\nend.", "src_uid": "df0879635b59e141c839d9599abd77d2"} {"source_code": "//fpc 3.0.0\n\nprogram HelloWorld;\nvar n,i,j:integer;\na:array[1..3,1..6] of byte;\n\n\nfunction can(h:integer):boolean;\nvar b:array[1..3] of byte;\nused:array[1..3] of boolean;\ni,y:integer;\nbb:boolean;\n\nprocedure try1(m:integer);\nvar x,y:integer;\nbegin\n if m>3 then bb:=true else\n for y:=1 to 6 do\n for x:=1 to n do \n if not used[x] then\n if a[x,y]=b[m] then begin\n \n used[x]:=true;\n try1(m+1);\n used[x]:=false;\n end;\n\nend;\n\nbegin\nbb:=false;\n b[1]:=h div 100;\n b[2]:=(h div 10) mod 10;\n b[3]:=h mod 10;\n // writeln(b[1],b[2],b[3]);\n \n y:=1;\n \n while b[y]=0 do inc(y);\n //writeln(y);\n for i:=1 to n do used[i]:=false;\n \n try1(y);\n can:=bb;\nend;\nbegin\n readln(n);\n for i:=1 to n do\n for j:=1 to 6 do read(a[i,j]);\n \n \n i:=0;\n \n while can(i+1) and (i<1000) do inc(i);\n \n writeln(i);\nend.\n\n\n", "src_uid": "20aa53bffdfd47b4e853091ee6b11a4b"} {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n ans,lg,rg,ca,cb,a,b,x1,y1,x2,y2,xa,ya,xb,yb: int64;\n\nfunction up(x,y:int64):int64;\nvar\n u: int64;\nbegin\n u:=x div y;\n while (u-1)*y > x do dec(u);\n while u*y <= x do inc(u);\n up:=u;\nend;\n\nfunction down(x,y:int64):int64;\nvar\n u: int64;\nbegin\n u:=x div y;\n while u*y >= x do dec(u);\n while (u+1)*y < x do inc(u);\n down:=u;\nend;\n\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(a,b,x1,y1,x2,y2);\n xa:=x1+y1; ya:=x1-y1;\n xb:=x2+y2; yb:=x2-y2;\n if (a = 1) or (b = 1) then ans:=(abs(x1-x2)+abs(y1-y2)) div 2 else\n begin\n if xa < xb then\n begin\n lg:=up(xa,2*a);\n rg:=down(xb,2*a);\n end else\n begin\n lg:=up(xb,2*a);\n rg:=down(xa,2*a);\n end;\n ca:=rg-lg+1;\n if ya < yb then\n begin\n lg:=up(ya,2*b);\n rg:=down(yb,2*b);\n end else\n begin\n lg:=up(yb,2*b);\n rg:=down(ya,2*b);\n end;\n cb:=rg-lg+1;\n if ca > cb then ans:=ca\n else ans:=cb;\n end;\n writeln(ans);\n close(input);\n close(output);\nend.", "src_uid": "7219d1837c83b5920992aee5a60dc0d9"} {"source_code": "var a,b:array[1..100000] of int64;\n x,n,w,q,m,k,o,p,e,max:int64;\n i,j:longint ;\n s,g:string;\nbegin\n//assign(input,'input.txt');\n//reset(input);\n//assign(output,'output.txt');\n//rewrite(output);\nread(x,n,w,q);\n\nif x>n then write('First')\nelse write('Second');\nend.\n", "src_uid": "aed24ebab3ed9fd1741eea8e4200f86b"} {"source_code": "var n,i:longint;\n m,tot:int64;\n a:array[1..50]of longint;\n f:array[1..50,false..true,false..true]of int64;\n p:array[1..50,false..true,false..true]of boolean;\nfunction hs(l:longint;p1,p2:boolean):int64;\nvar x,y,r:longint;\nbegin\n r:=n-l+1;\n if l>r then begin hs:=1;exit;end;\n if p[l,p1,p2] then begin hs:=f[l,p1,p2];exit;end;\n p[l,p1,p2]:=true;\n for x:=0 to 1 do if (a[l]=-1)or(a[l]=x) then\n for y:=0 to 1 do if (a[r]=-1)or(a[r]=y) then\n if ((ly then\n begin\n writeln(x-(n div 2));\n for i:=1 to n do\n begin\n if x>y then\n begin\n if s[i]='X' then begin write('x'); dec(X); inc(y); end else write(s[i]);\n end else write(s[i]);\n end\n end else\n if x1) and (s[length(s)-1]='/') and (s[length(s)]='/')then Delete(s,length(s)-1,1);\nif (s[length(s)]='/') and (length(s)>1) then Delete(s,length(s),1);\nwriteln(s);\nend.\n ", "src_uid": "6c2e658ac3c3d6b0569dd373806fa031"} {"source_code": "var a,b,c,d,e,x:longint;\nbegin\n readln(x);\n a:=x div 5;\n x:=x-(5*a);\n b:=x div 4;\n x:=x-(4*b);\n c:=x div 3;\n x:=x-(3*c);\n d:=x div 2;\n x:=x-(2*d);\n e:=x+a+b+c+d;\n writeln(e);\nend.\n", "src_uid": "4b3d65b1b593829e92c852be213922b6"} {"source_code": "program B223;\nconst\n inp='';\n oup='';\n max=7000;\nvar\n F,Fo:text;\n StackL,StackR,StackV,StackT:array[1..max] of longint;\n DD:array[0..1000000] of longint;\n Cx:array[0..1000000] of longint;\n LeftC,RightC:array[1..max] of longint;\n Top:longint;\n Number,N,M:longint;\n(* *)\nprocedure Init;\nvar i,s:longint;\nbegin\n S:=1;\n DD[1]:=1;\n for i:=1 to 18 do\n begin\n s:=s*2;\n DD[s]:=1;\n end;\n for i:=2 to 1000000 do DD[i]:=DD[i-1]+DD[i];\nend;\n(* *)\nprocedure Push(T,L,R,V:longint);\nbegin\n inc(Top);\n StackT[Top]:=T;\n StackL[Top]:=L;\n StackR[Top]:=R;\n StackV[Top]:=V;\nend;\n(* *)\nfunction Intersec(L1,R1,L2,R2:longint):boolean;\nvar res:boolean;\nbegin\n res:=false;\n res:=res or ((L1<=L2) and (R1>=L2));\n res:=res or ((L2<=L1) and (R2>=L1));\n exit(res);\nend;\n(* *)\nfunction Ans(T,V:longint):longint;\nvar i,curL,curR,res:longint;\nbegin\n for i:=1 to N do\n begin\n LeftC[i]:=0;\n RightC[i]:=0;\n end;\n LeftC[T]:=V; RightC[T]:=V;\n for i:=T+1 to N do\n begin\n curL:=LeftC[i-1];\n curR:=RightC[i-1];\n curL:=(curL-1)+DD[curL-1]+1;\n if DD[curR]=DD[curR-1]+1 then\n begin\n curR:=(curR-1)+DD[curR-1]+2;\n end\n else\n begin\n curR:=(curR-1)+DD[curR-1]+1;\n end;\n LeftC[i]:=CurL;\n RightC[i]:=CurR;\n end;\n res:=0;\n inc(number);\n for i:=1 to Top do if StackT[i]>=T then\n begin\n if Intersec(LeftC[StackT[i]],RightC[StackT[i]],StackL[i],StackR[i]) then\n begin\n if Cx[StackV[i]]<>number then inc(res);\n Cx[StackV[i]]:=number;\n end;\n end;\n exit(res);\nend;\n(* *)\nprocedure Nhap;\nvar i:longint;\n cases:longint;\n t,l,r,v:longint;\nbegin\n assign(f,inp); reset(f);\n assign(fo,oup); rewrite(fo);\n readln(f,N,M);\n init;\n for i:=1 to M do\n begin\n read(f,cases);\n case cases of\n 1:\n begin\n readln(f,t,l,r,v);\n push(t,l,r,v);\n end;\n 2:\n begin\n readln(f,t,v);\n writeln(fo,Ans(t,v));\n end;\n end;\n end;\n close(f);\n close(fo);\nend;\n(* *)\nBEGIN\n nhap;\nEND.", "src_uid": "9f239cfd29c1a2652a065bfe5c15476a"} {"source_code": "{$mode objfpc}\nprogram a214;\nconst\n fin = '';\n fout = '';\nvar\n s: integer;\n i, j, k: integer;\n a, b: array [1..4, 1..2] of integer;\n\nbegin\n assign(input, fin); reset(input);\n assign(output, fout); rewrite(output);\n readln(s);\n for i := 1 to 4 do\n begin\n for j := 1 to 2 do\n read(a[i][j]);\n for j := 1 to 2 do\n read(b[i][j]);\n end;\n for i := 1 to 4 do\n for j := 1 to 2 do\n for k := 1 to 2 do\n if a[i][j] + b[i][k] <= s then\n begin\n writeln(i,' ',a[i][j],' ',s - a[i][j]);\n halt;\n end;\n writeln(-1);\n close(input);\n close(output);\nend.\n", "src_uid": "6e7ee0da980beb99ca49a5ddd04089a5"} {"source_code": "program solution;\n\n{$APPTYPE CONSOLE}\n{$R+,Q+}\n\nuses\n\tSysUtils, Math;\n\nconst a : array[0..29] of integer = (0, 1, 2, 1, 4, 3, 2, 1, 5, 6, 2, 1, 8, 7, 5, 9, 8, 7, 3, 4, 7, 4, 2, 1, 10, 9, 3, 6, 11, 12);\n\nvar\n p : array[1..40000] of boolean;\n q, k, i, t, n, ans : integer;\n j : int64;\n s : array[1..29] of integer;\n\n\nbegin\n\t{$IFNDEF ONLINE_JUDGE}\n\t\treset(input, 'input.txt');\n\t\trewrite(output, 'output.txt');\n\t{$ENDIF}\n read(n);\n i := 2;\n s[1] := 1;\n t := floor(sqrt(n));\n q := 0;\n while i <= t do begin\n if p[i] then begin\n inc(i);\n continue;\n end;\n j := i;\n k := 0;\n while j <= n do begin\n if j <= t then\n p[j] := true else\n inc(q);\n inc(k);\n j := j * i;\n end;\n inc(s[k]);\n inc(i);\n end;\n inc(s[1], n - t - q);\n for i := 1 to 29 do\n if odd(s[i]) then\n s[i] := 1 else\n s[i] := 0;\n ans := 0;\n for i := 1 to 29 do begin\n ans := ans xor a[s[i] * i];\n end;\n if ans <> 0 then\n write('Vasya') else\n write('Petya');\n\nend.\n", "src_uid": "0e22093668319217b7946e62afe32195"} {"source_code": "var\n s : string;\n nom,i,j,k,max : longint;\nbegin\n readln(s);\n max:=-2;\n for i:=length(s) downto 1 do\n begin\n for j:=length(s) downto i+1 do\n inc(k,ord('9')-ord(s[j]));\n dec(k);\n if max1) or\n (s[nom]<>'0')\n then write(s[nom]);\n for i:=nom+1 to length(s) do\n write('9');\nend.\n\n", "src_uid": "e55b0debbf33c266091e6634494356b8"} {"source_code": "var\ndd:int64;\nused:Array[0..4000000]of boolean;\nn,l,r,p,i,fir,sec,ans:longint;\nt:longint;\nf:array[0..1000]of int64;\nd,a:array[0..4000000]of longint;\nfunction prost(x:longint):boolean;\nvar i:longint;\nbegin\n for i:=2 to round(sqrt(x)) do\n if x mod i=0 then\n begin\n prost:=false;\n exit;\n end;\n prost:=true;\nend;\nprocedure go(x,d:longint);\nbegin\n if d>t then\n begin\n inc(n);\n a[n]:=x;\n exit;\n end;\n go(x,d+1);\n if int64(x)*f[d]<=r then go(x*f[d],d);\nend;\nprocedure sort(l,r:longint);\nvar i,j,x,u:longint;\nbegin\n i:=l;\n j:=r;\n x:=a[l+random(r-l)];\n while i<=j do\n begin\n while x>a[i] do inc(i);\n while xa[sec]) do inc(sec);\n if (dd=a[sec])and(d[sec]>d[fir]+1) then\n begin\n d[sec]:=d[fir]+1;\n if (not used[sec])and(d[sec]+i<=p) then\n begin\n used[sec]:=true;\n if (l<=a[sec])and(a[sec]<=r) then inc(ans);\n end;\n end;\n inc(fir);\n end;\n end;\n writeln(ans);\n end.\n", "src_uid": "6d898638531e4713774bbd5d47e827bf"} {"source_code": "Var\n N, l: UInt64;\n\nBegin\n Read(N, l);\n If (N div 2 + N mod 2) >= l then Write(2*l - 1)\n Else If l = N then Write(l - N mod 2)\n Else Write((2*(l mod (N div 2 + N mod 2))))\nEnd.", "src_uid": "1f8056884db00ad8294a7cc0be75fe97"} {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n,m:longint;\n a:array[1..200000] of longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure swap(var x,y:longint);\n var tg:longint;\n begin\n tg:=x;x:=y;y:=tg;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\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 inc(i);\n while a[j]j;\n if i=m then exit(true);\n if t1=u then\n begin\n inc(t2);\n t1:=0;\n end;\n end;\n exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure process;\n var res,l,r,mid:longint;\n begin\n res:=0;\n l:=1;\n r:=n;\n while l<=r do\n begin\n mid:=(l+r) div 2;\n if check(mid) then\n begin\n r:=mid-1;\n res:=mid;\n end else l:=mid+1;\n end;\n if res=0 then write(fo,-1) else 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", "src_uid": "acb8a57c8cfdb849a55fa65aff86628d"} {"source_code": "var a,b,c,i:longint;\nbegin\n readln(a,b);\n c:=0;i:=0;\n repeat\n inc(c);inc(i);\n\tif i mod 2 = 1 then begin dec(a,c)\n\tend else begin dec(b,c) end;\n until (a < 0) or (b < 0) ;\n if b < 0 then writeln('Valera') else writeln('Vladik');\nend.", "src_uid": "87e37a82be7e39e433060fd8cdb03270"} {"source_code": "var a:array[1..10,1..10]of longint;\ns,d,f,g,h:longint;\nbegin\nread(s);\nfor d:=1 to s-1 do\na[1,d]:=d;\n\nfor f:=2 to s-1 do\nfor d:=1 to s-1 do\nbegin\na[f,d]:=a[f-1,d];\nfor h:=1 to a[1,d] do\nbegin\ninc(a[f,d]);\nif(a[f,d] mod 10)div s>0 then begin inc(a[f,d],10); dec(a[f,d],s); end;\nend;\nend;\n\nfor f:=1 to s-1 do\nbegin\nfor d:=1 to s-1 do\nwrite(a[f,d],' ');\nwriteln;\nend;\nend.\n\n", "src_uid": "a705144ace798d6b41068aa284d99050"} {"source_code": "var\n a:array[0..100,0..100]of longint;\n p1,p2,i,m,n,k,l,w,s,j,x1,y1,x2,y2,l1,l2,e,d:longint;\nbegin\n readln(n,m,k,s);\n for i:=1 to k do begin readln(p1,p2); a[p1,p2]:=1; end;\n for x1:=1 to n do\n begin\n for y1:=1 to m do\n begin\n for x2:=x1 to n do\n begin\n for y2:=y1 to m do \n begin\n e:=0;\n for l1:=x1 to x2 do\n begin\n for l2:=y1 to y2 do inc(e,a[l1,l2]);\n end;\n if e>=s then inc(w);\n end;\n end;\n end;\n end;\n writeln(w);\nend.\n\n ", "src_uid": "9c766881f6415e2f53fb43b61f8f40b4"} {"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 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 px,py,xc,yc,xxc,yyc:extended;\n pos:array[-1..500001,-1..50] of longint;\n next,prev,x,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..1201,-10..1220] 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 binkoef,right,left,numleft,numright,dr: array [-10..60,-10..60] 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\nfunction otprod(var xx:mas):int64;\nlabel 88;\nvar i,j:longint; ot,pp:int64;\nbegin\n ot:=1; pp:=0;\n { for i:=0 to 9 do write(xx[i],' ');\n } for i:=0 to 9 do pp:=pp+xx[i];\n { writeln('sum= ',pp);\n } for i:=0 to 9 do if i>0 then begin ot:=ot*binkoef[pp,xx[i]]; {writeln('i= ',i,' pp= ',pp,' xx= ',xx[i],' koef= ',binkoef[pp,xx[i]]);} pp:=pp-xx[i]; end\n else begin ot:=ot*binkoef[pp-1,xx[i]]; { writeln('i= ',i,' pp= ',pp,' xx= ',xx[i],' koef= ',binkoef[pp,xx[i]]);} pp:=pp-xx[i]; end;\n\n88:\n otprod:=ot;\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(p);\n while p>0 do begin inc(q); a[q]:= p mod 10; p:=p div 10; end;\n\n for i:=1 to q do inc(x[a[i]]);\n n:=q;\n { for i:=0 to 9 do write(x[i],' '); writeln;\n } binkoef[0,0]:=1;\n for i:=1 to 30 do for j:=-1 to i+1 do binkoef[i,j]:=binkoef[i-1,j]+binkoef[i-1,j-1];\n { for i:=0 to 20 do begin for j:=0 to i do write(binkoef[i,j],' '); writeln; end;\n }\n pp:=1;\n for i:=0 to 9 do if x[i]>0 then pp:=pp*x[i];\n\n { write('otprod= ');\n y[0]:=1; y[2]:=2; y[8]:=1;\n writeln(otprod(y));\n } for mask:=0 to pp-1 do\n begin\n t:=mask; for i:=0 to 9 do y[i]:=0;\n for i:=0 to 9 do if x[i]>0 then begin y[i]:=t mod x[i]+1; t:=t div x[i]; end;\n { writeln('mask= ',mask);\n for i:=0 to 9 do write(y[i],' '); writeln; writeln(' dob= ',otprod(y)); writeln;\n } ot:=ot+ otprod(y);\n\n end;\n\n writeln(ot);\n\n\n 1: close(output);\nend.\n\n", "src_uid": "7f4e533f49b73cc2b96b4c56847295f2"} {"source_code": "var\n a:longint;\nprocedure ans(x:longint);\nbegin\n writeln(x);\n halt;\nend;\n\n\n\nbegin\n readln(a);\n case a of\n 1:ans(1); {[}\n 2:ans(0); {[}\n 3:ans(0); {[}\n 4:ans(1); {[}\n 5:ans(0); {[}\n 6:ans(1); {[}\n 7:ans(0); {[}\n 8:ans(1); {[}\n 9:ans(1); {[}\n 10:ans(1); {[}\n 11:ans(0); {[}\n 12:ans(0); {[}\n 13:ans(1);\n 14:ans(0); {}\n 15:ans(1); {[}\n 16:ans(0); {[}\n end;\nend.", "src_uid": "6f9767b63a01424f939d85b597cf42f3"} {"source_code": "var\n n, a, b, c, d, y, m, k, ans: int64;\n x: longint;\n\nbegin\n readln(n, a, b, c, d);\n for x:= 1 to n do\n begin\n y:= b - c + x;\n m:= a - d + x;\n k:= y + a - d;\n if (y >= 1) and (y <= n) and (m >= 1) and (m <= n) \n and (k >= 1) and (k <= n) then inc(ans);\n end;\n writeln(ans * n);\nend.\n", "src_uid": "b732869015baf3dee5094c51a309e32c"} {"source_code": "Const finp='';\n fout='';\nVar n,lc:longint;\n fb:array[0..1000] of longint;\n kq:array[1..3] of longint;\n\nProcedure Nhap;\nVar f:text;\nBegin\n Assign(f,finp);\n reset(f);\n Readln(f,n);\n Close(f);\nEnd;\n\nProcedure Xuly;\nVar i,d,t,k:longint;\nBegin\n If n=0 then Exit;\n If n=1 then\n Begin\n kq[1]:=1;\n Exit; \n End;\n fb[0]:=0;\n fb[1]:=1;\n fb[2]:=1;\n For i:=3 to 45 do\n Begin\n fb[i]:=fb[i-1]+fb[i-2];\n If (fb[i]>=n) and (fb[i-1]360 then j1:=j1-360;\n jt1:=t1*30;\n jt2:=t2*30;\n if jt1>jt2 then begin p:=jt1; jt1:=jt2; jt2:=p; end;\n if (jt1jt2))and((j2jt2))and((j3jt2))then\n begin\n writeln('YES');\n halt;\n end;\n writeln('No');\nend.", "src_uid": "912c8f557a976bdedda728ba9f916c95"} {"source_code": "var n,m,k,ans,x,tmp,kk,i,j,l1,l2,l:longint;\nss:string;\nq,w:array[0..200]of longint;\na,b,c:array[0..200,0..200]of longint;\n begin\n readln(n,m,k);\n for i:=1 to n do\n begin\n readln(ss);\n for j:=1 to m do\n readln(a[i,j],b[i,j],c[i,j]);\n end;\n\n ans:=0;\n\n for i:=1 to n do\n for j:=1 to n do\n begin\n for l:=1 to m do\n begin\n q[l]:=b[j,l]-a[i,l];\n w[l]:=c[i,l];\n end;\n\n for l1:=1 to m do\n for l2:=l1+1 to m do\n if q[l1]0 then\n if kk>w[l] then\n begin\n kk:=kk-w[l];\n tmp:=tmp+w[l]*q[l];\n end else\n begin\n tmp:=tmp+kk*q[l];\n break;\n end;\n\n if tmp>ans then ans:=tmp;\n end;\n\n writeln(ans);\n end.\n", "src_uid": "7419c4268a9815282fadca6581f28ec1"} {"source_code": "uses math;\nvar\n i:longint;\nbegin\n for i:=21 to 50 do\n if (min(i,25)+i)mod(2+i mod 3)>0 then writeln(1) \n else writeln(0); \nend.", "src_uid": "4bda04e64ff661336a93464563f1b550"} {"source_code": "Var n,i:longint;\n x,y:int64;\n a:array [1..10000000] of int64;\n function min (a1,b1:int64):int64;\n begin\n min:=a1;\n if a1>b1 then min:=b1;\n end;\n Begin\n read(n,x,y);\n a[1]:=x;\n for i:=2 to n do\n if i mod 2=0 then a[i]:=min(a[i-1]+x,a[i div 2]+y)\n else a[i]:=min(a[i-1]+x,a[(i div 2)+1]+x+y);\n writeln(a[n]);\n End.\n \n \n ", "src_uid": "0f270af00be2a523515d5e7bd66800f6"} {"source_code": "var\n s:string;\n x,y,ans:longint;\nbegin\n read(s);\n if (s[1]='a') or (s[1]='h') then x:=1;\n if (s[2]='1') or (s[2]='8') then y:=1;\n if (x=1) and (y=1) then inc(ans);\n if x=1 then dec(ans,3);\n if y=1 then dec(ans,3);\n write(ans+8);\nend.", "src_uid": "6994331ca6282669cbb7138eb7e55e01"} {"source_code": "program lt;\nvar\n a,b,x,y:longint;\n\nfunction gcd(x,y:longint):longint;\nbegin\n if x mod y=0 then gcd:=y\n else gcd:=gcd(y,x mod y);\nend;\n\n\nprocedure work;\nvar\n k,w,k1,k2:longint;\nbegin\n readln(a,b,x,y);\n w:=gcd(x,y);\n x:=x div w;y:=y div w;\n k1:=a div x;\n k2:=b div y;\n if k1n then begin writeln(x*y); writeln(x,' ',y); halt; end;\ni:=x;\nans:=-1;\nwhile i*i<=n*2 do begin\n j:=n div i;\n if i*jj then j:=y;\n if (i*ji then i:=x;\n if (i*j q) then begin result := t; exit; end;\n if t*t < q then result := f(q, t+1, r) else result := f(q, l, t-1);\nend;\n\nfunction pr (q : int64) : boolean;\nvar i, s : integer;\nbegin\n result := false;\n //s := f(q, 1, q);\n s := trunc(sqrt(q + 0.0));\n for i := 2 to s do if q mod i = 0 then 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(ss); {\n if length(ss) <= 7 then q := strtoint(ss) else\n q := strtoint(copy(ss, 1, length(ss)-7))*10000000 +\n strtoint(copy(ss, length(ss)-6, 7)); }\n for i := 1 to length(ss) do begin\n q := q*10 + strtoint(ss[i]);\n end;\n\n // s := f(q, 1, q);\n s := trunc(sqrt(q+0.0));\n if pr(q) then begin\n writeln (1);\n writeln(0);\n end\n else\n begin\n for i := 2 to s do\n if (q mod i) = 0 then begin\n p1 := i;\n break;\n end;\n p := q div p1;\n if pr(p) then write (2) else begin\n for i := 2 to s do\n if (p mod i) = 0 then begin\n p2 := i;\n break;\n end;\n writeln (1);\n write (p1*p2);\n end;\n end;\n\n// close (input);\n// close (output);\nend.\n--------------------------------------------------------------------------------\n\n", "src_uid": "f0a138b9f6ad979c5ca32437e05d6f43"} {"source_code": "Program z4b;\nvar d,sum,i,j,sum1:integer;\n\ta:array[1..2,1..30]of integer;\n k:array[1..30]of integer;\nbegin\n\tread(d,sum);\n for i:=1 to d do\n begin\n \tread(a[1,i],a[2,i]);\n k[i]:=a[2,i];\n sum1:=sum1+k[i];\n end;\n if sum1sum) do\n begin\n \tif sum1-(k[i]-a[1,i])>=sum then\n begin\n \tsum1:=sum1-(k[i]-a[1,i]);\n k[i]:=a[1,i];\n end\n else\n begin\n \tk[i]:=k[i]-(sum1-sum);\n \tsum1:=sum;\n end;\n inc(i);\n end;\n if sum1=sum then\n begin\n \twriteln('YES');\n for i:=1 to d do\n \twrite(k[i],' ');\n end\n else write('NO');\nend.\n", "src_uid": "f48ff06e65b70f49eee3d7cba5a6aed0"} {"source_code": "var t,s,x:integer;\nbegin\nread(t,s,x);\nif (xt+1)) or ((x-t) mod s=0) then write('YES')\nelse write('NO');\nend.", "src_uid": "3baf9d841ff7208c66f6de1b47b0f952"} {"source_code": "var a,w,row,col:array[0..100] of longint;\n i1,i2,i3,i4,main,i,adv,n,s:longint;\n used:array[0..10000] of boolean;\n res:array[0..17,0..17] of longint;\n a4:array[0..17,0..17,0..17,0..17] of boolean;\n a3:array[0..17,0..17,0..17] of boolean;\n a2:array[0..17,0..17] of boolean;\n\n procedure rec(v:longint);\n var i:longint;\n flag:boolean;\n begin\n flag:=false;\n for i:=1 to n*n do\n begin\n if not used[i] then\n begin\n flag:=true;\n used[i]:=true;\n inc(col[v mod n],a[i]);\n inc(row[v div n],a[i]);\n w[v]:=a[i];\n if (v mod n=v div n) then inc(main,a[i]);\n if (v mod n+v div n=n-1) then inc(adv,a[i]);\n\n rec(v+1);\n\n used[i]:=false;\n dec(col[v mod n],a[i]);\n dec(row[v div n],a[i]);\n if (v mod n=v div n) then dec(main,a[i]);\n if (v mod n+v div n=n-1) then dec(adv,a[i]);\n end;\n end;\n if not flag then\n begin\n for i:=0 to n-1 do\n if col[i]<>s then exit;\n for i:=0 to n-1 do\n if row[i]<>s then exit;\n\n if (main=s)and(adv=s) then\n begin\n for i:=0 to n*n-1 do\n begin\n if i mod n=0 then writeln;\n write(w[i],' ');\n end;\n writeln;\n halt(0);\n end;\n end;\n end;\n\n procedure rec2(x,y:longint);\n var i,j:longint;\n begin\n if (x=4) then\n begin\n if a4[res[0][0],res[1][1],res[2][2],res[3][3]]\n and a4[res[0][3],res[1][2],res[2][1],res[3][0]] then\n begin\n for i:=0 to 3 do\n begin\n for j:=0 to 3 do\n write(a[res[i][j]],' ');\n writeln;\n end;\n halt(0);\n end;\n exit;\n end;\n for i:=1 to n*n do\n if not used[i] then\n begin\n res[x][y]:=i;\n\n if (x=1)and (not a2[res[x][y],res[x-1][y]]) then continue;\n if (x=2)and (not a3[res[x][y],res[x-1][y],res[x-2][y]]) then continue;\n if (x=3)and (not a4[res[x][y],res[x-1][y],res[x-2][y],res[x-3][y]]) then continue;\n\n if (y=1)and (not a2[res[x][y],res[x][y-1]]) then continue;\n if (y=2)and (not a3[res[x][y],res[x][y-1],res[x][y-2]]) then continue;\n if (y=3)and (not a4[res[x][y],res[x][y-1],res[x][y-2],res[x][y-3]]) then continue;\n\n if (x=y) then\n begin\n if (x=1)and(not a2[res[x-1][y-1],res[x][y]]) then continue;\n if (x=2)and(not a3[res[x-1][y-1],res[x][y],res[x-2][y-2]]) then continue;\n if (x=3)and(not a4[res[x-1][y-1],res[x][y],res[x-2][y-2],res[x-3][y-3]]) then continue;\n end;\n\n used[i]:=true;\n rec2(x+(y+1) div 4,(y+1) mod 4);\n used[i]:=false;\n end;\n end;\n begin\n read(n);\n for i:=1to n*n do\n begin\n read(a[i]);\n s:=s+a[i];\n end;\n\n for i:=1 to 1000 do\n begin\n i1:=random(n*n)+1;\n i2:=random(n*n)+1;\n a[0]:=a[i1]; a[i1]:=a[i2]; a[i2]:=a[0];\n end;\n s:=s div n;\n if n<=3 then\n begin\n write(s);\n rec(0);\n end;\n\n writeln(s);\n for i1:=1 to n*n do\n for i2:=1 to n*n do\n for i3:=1 to n*n do\n for i4:=1 to n*n do\n begin\n if (i1=i2)or(i1=i3)or(i1=i4)or(i2=i3)or(i2=i4)or(i3=i4) then\n else\n begin\n if a[i1]+a[i2]+a[i3]+a[i4]=s then\n begin\n a4[i1][i2][i3][i4]:=true;\n a3[i1][i2][i3]:=true;\n a2[i1][i2]:=true;\n end;\n end;\n end;\n\n rec2(0,0);\n\n\n\n end.", "src_uid": "7c806fb163aaf23e1eef3e6570aea436"} {"source_code": "Program a1;\n\nVar\n i, j, n, m, w : longint;\n\nBegin\n w:=0; readln(n);\n for i:=1 to n do begin\n read(j); w:=w+abs(j);\n end;\n /////////////////////////////////////////////\n\n writeln(w);\nend.\n", "src_uid": "4b5d14833f9b51bfd336cc0e661243a5"} {"source_code": "var\n c1,c0:array[0..101,0..101] of longint;\n a:array[1..100] of longint;\n n,j,k,l,i,ans,aw:longint;\n\nfunction max(x,y:longint):longint;\nbegin\n if x>y then exit(x)\n else exit(y);\nend;\n\nbegin\n readln(n);\n aw:=0;\n for i:=1 to n do\n begin\n read(a[i]);\n if a[i]=1 then begin c1[1,i]:=c1[1,i-1]+1; c0[1,i]:=c0[1,i-1]; inc(aw); end\n else begin c0[1,i]:=c0[1,i-1]+1; c1[1,i]:=c1[1,i-1]; end;\n end;\n for i:=1 to n do\n for j:=i to n do\n begin\n if a[i]=1 then begin c1[i+1,j]:=c1[i,j]-1; c0[i+1,j]:=c0[i,j]; end\n else begin c0[i+1,j]:=c0[i,j]-1; c1[i+1,j]:=c1[i,j]; end;\n end;\n for i:=1 to n do\n for j:=i to n do\n ans:=max(ans,aw+c0[i,j]-c1[i,j]);\n if (a[1]=1) and (n=1) then writeln(0)\n else writeln(ans);\nend.\n", "src_uid": "9b543e07e805fe1dd8fa869d5d7c8b99"} {"source_code": "const\n p=1000000007;\n\nvar\n n,i,q,r:longint;\n s:string;\n a:array[0..1000]of longint;\nbegin\n readln(s); n:=length(s);\n q:=1;\n for i:=1 to n+n do\n begin\n q:=(q+q)mod p;\n a[i]:=q;\n end;\n a[0]:=1;\n r:=0;\n for i:=1 to n do\n if s[i]='1' then r:=(r+a[n+n-i-1])mod p;\n write(r);\nend.", "src_uid": "89b51a31e00424edd1385f2120028b9d"} {"source_code": "Var i, a,b,m,r, ikin, iper, len:longint;\nVar p:boolean;\nVar nr:array[0..100001] of longint;\nbegin\nread(a,b,m,r);\n\ni:=1;\np:=false;\nwhile not p do\n Begin\n r:=(a*r+b)mod m;\n if nr[r]=0 then nr[r]:=i\n else \n begin\n ikin:=i;\n iper:=nr[r];\n p:=true;\n end;\n i:=i+1;\n end;\n \nif p then \n len:=ikin-iper;\nwriteln(len); \n \n\nend. \n ", "src_uid": "9137197ee1b781cd5cc77c46f50b9012"} {"source_code": "Var\n n,i,i1,i2,s:integer;\n a:array [1..10,1..10] of integer;\nbegin\n s:=0;\n readln(n);\n for i:=1 to n do a[1,i]:=1;\n for i:=1 to n do a[i,1]:=1;\n \n for i:=2 to n do\n for i2:=2 to n do\n a[i,i2]:=a[i-1,i2]+a[i,i2-1];\n for i:=1 to n do\n for i2:=1 to n do\n if s0 do\n begin\n if y and 1=1 then ans:=ans*x mod mo;\n y:=y >> 1;\n x:=x*x mod mo;\n end;\n exit(ans);\nend;\nfunction calc(x:int64):int64;\nvar\n ans :int64;\nbegin\n if x<0 then exit(0);\n if x=0 then exit(1);\n ans:=1;\n for i:=1 to n-1 do\n begin\n ans:=ans*((x+i) mod mo) mod mo;\n end;\n ans:=ans*ni mod mo;\n exit(ans);\nend;\nprocedure check;\nvar\n i,j :longint;\n cur :int64;\n cnt :longint;\nbegin\n cur:=m; cnt:=0;\n for i:=1 to n do\n begin\n if b[i]=1 then\n begin\n cur:=cur-a[i]-1 ;\n inc(cnt);\n end;\n end;\n ans[cnt]:=(ans[cnt]+calc(cur)) mod mo;\nend;\nprocedure dfs(x:longint);\nbegin\n if x=n+1 then\n begin\n check;\n exit;\n end;\n b[x]:=0;\n dfs(x+1);\n b[x]:=1;\n dfs(x+1);\nend;\nbegin\n read(n,m);\n for i:=1 to n do read(a[i]);\n ni:=1;\n for i:=1 to n-1 do ni:=ni*int64(i) mod mo;\n ni:=pow(ni,mo-2);\n dfs(1);\n for i:=0 to n do\n begin\n if i and 1=0 then aa:=(aa+ans[i]) mod mo else aa:=(aa-ans[i]+mo) mod mo;\n end;\n writeln(aa);\nend.\n", "src_uid": "8b883011eba9d15d284e54c7a85fcf74"} {"source_code": " program pr1;\n\n{$APPTYPE CONSOLE}\n type extended=int64;\n zap=record p1,p2,p3:int64;end; zap1=^zap;\n chislo=record ch,st:int64;end; chislo1=^chislo;\nconst nn=1000001; besk=200000000000000;\n nnn=2000000; eps=1e-14;\n label 1,2,3,4;\nvar i0,j0,pp,jj,kolzn,k,kk,step,i,j,ii,start,finish,per:longint;\nk3,k4,k5,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;\nott:zap; ott1:zap1;\nr,num,x,y,b,r1,r2:array[0..1000000] of extended;\nflag2,flag1,flag:boolean;\nc1,c2:char;\ngood,good1:array[0..1000000] of boolean;\nppp:array[0..1000000] of int64;\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\n function evkl(a,b:int64):zap1; label 44;\n var d,x,y,r,q,i,j,k,x1,x2,y1,y2:int64; fl:boolean;\n tt:zap; tt1:zap1;\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\n\n end;\n if fl then begin\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p2:=x;tt.p3:=y; tt1:=@tt; end;\n\n if not fl then begin\n d:=a; x:=x2;y:=y2; tt.p1:=d;tt.p3:=x;tt.p2:=y; tt1:=@tt; end;\n\n\n 44: evkl:=tt1;\n end;\n\n {a*x+b*y=c v pol x,y}\n function razl(a,b,c:int64):boolean;\n label 22;\n var l,r,x0,y0,t1,t2,t3,i,j,k:int64; fl:boolean; xx:zap;\nbegin\n if c mod nod(a,b)<>0 then begin fl:=false; goto 22; end;\n xx:=evkl(a,b)^;\n x0:=xx.p3; y0:=xx.p2;\n if a*x0+b*y0=c then begin l:=x0; x0:=y0;y0:=l end;\n l:=trunc(-x0*c/b-eps)+1; r:=trunc(y0*c/a+eps);\n { writeln('l=',-x0*c/b:0:5 ,' r= ',y0*c/a:0:5); }\n if l<=r then fl:=true else fl:=false;\n\n22: razl:=fl;\nend;\n\n {min raz abs(a*x-b*y) a*x+b*y=c}\n function minraz(a,b,c:int64):int64;\n label 23;\n var l,r,x0,y0,t1,t2,t3,j,k:int64; fl:boolean; xx:zap; i:longint;\nbegin\n xx:=evkl(a,b)^;\n x0:=xx.p3; y0:=xx.p2;\n if a*x0+b*y0=c then begin l:=x0; x0:=y0;y0:=l end;\n l:=trunc(-(a*c*x0-b*c*y0)/(2*a*b));\n \n k:=10000000000000;\n for i:=l-1 to l+1 do\n begin r:=i;\n k:=min(k,abs(a*c*x0-b*c*y0+2*a*b*r));\n end;\n23: minraz:=k;\nend;\n\n\n\n\n\n\nbegin\n{assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n} readln(n);\n if n=3 then begin writeln(5); goto 1; end;\n for i:=0 to 200 do ppp[i]:=((2*i+1)*(2*i+1)+1) div 2;\n for i:=0 to 200 do if ppp[i]>=n then begin writeln(2*i+1);goto 1;end;\n\n\n 1: close(output);\nend.\n", "src_uid": "01eccb722b09a0474903b7e5abc4c47a"} {"source_code": "program problem3;\n\nvar\tx1, y1, x2, y2: longInt;\n\nbegin\n\treadln( x1, y1, x2, y2 );\n\t\n\twhile ( true ) do\n\tbegin\n\t\tif ( x2 - y2 < x1 - y1 ) and ( x1 > 0 ) and ( ( x1 <> x2 + 1 ) or ( y1 <> y2 ) ) then\n\t\t\tdec( x1 )\n\t\telse if ( y1 > 0 ) and ( ( y1 <> y2 + 1 ) or ( x1 <> x2 ) ) then\n\t\t\tdec( y1 )\n\t\telse if ( x1 > 0 ) and ( ( x1 <> x2 + 1 ) or ( y1 <> y2 ) ) then\n\t\t\tdec( x1 );\n\t\t\n\t\tif ( x1 + y1 = 0 ) then\n\t\tbegin\n\t\t\twriteln( 'Polycarp' );\n\t\t\t\n\t\t\thalt;\n\t\tend;\n\t\t\n\t\tif ( x2 > 0 ) and ( y2 > 0 ) and ( ( x2 <> x1 + 1 ) or ( y2 <> y1 + 1 ) ) then\n\t\tbegin\n\t\t\tdec( x2 );\n\t\t\tdec( y2 );\n\t\tend\n\t\telse if ( x2 > 0 ) and ( ( x2 <> x1 + 1 ) or ( y2 <> y1 ) ) then\n\t\t\tdec( x2 )\n\t\telse if ( y2 > 0 ) and ( ( y2 <> y1 + 1 ) or ( x2 <> x1 ) ) then\n\t\t\tdec( y2 );\n\t\t\n\t\tif ( x2 + y2 = 0 ) then\n\t\tbegin\n\t\t\twriteln( 'Vasiliy' );\n\t\t\t\n\t\t\thalt;\n\t\tend;\n\tend;\nend.\n", "src_uid": "2637d57f7809ff8f922549c617709074"} {"source_code": "var a,b,n,m:longint;\n\nbegin\nreadln(n,m,a,b);\nif ((((a-1) div m=(b-1) div m))or(m>=n)or(a=b)or( ((a-1) mod m=0)and(((b mod m=0)or(b=n)))))\n then writeln(1) else\nbegin\nif (( (((a-1) mod m=0)or(((b mod m=0)or(b=n))))\n ) or ( (b-1) mod m+1=(a-1) mod m )or( (a-1) div m+1=(b-1) div m ))\n then writeln(2) else writeln(3);\nend;\nreadln;\n { TODO -oUser -cConsole Main : Insert code here }\nend.", "src_uid": "f256235c0b2815aae85a6f9435c69dac"} {"source_code": "{$r-, s-, q-, i-, o+}\nconst max_sum = 600000;\nvar\n n, d, i, j, x, k, cur, steps : longint;\n changed : boolean;\n f : array [0..max_sum + max_sum] of boolean;\n s : array [0..max_sum + max_sum] of longint;\nbegin\n f[0] := true;\n readln(n, d);\n for i := 1 to n do\n begin\n read(x);\n for j := max_sum downto 0 do\n f[j + x] := (f[j]) or (f[j + x]);\n end;\n cur := 0;\n steps := 0;\n while (true) do\n begin\n changed := false;\n for i := cur + d downto cur + 1 do\n if (f[i]) then\n begin\n changed := true;\n cur := i;\n inc(steps);\n break;\n end;\n if (not changed) then break;\n end;\n writeln(cur, ' ', steps);\nend.", "src_uid": "65699ddec8d0db2f58b83a0f64de6f6f"} {"source_code": "var\n F,G:array[1..3,1..3] of int64;\n t:array[1..3,1..3] of longint;\n i,j,N:longint;\n\nfunction min(a,b:int64):int64;\nbegin\n if(a>b) then a:=b;\n min:=a;\nend; \n \nBEGIN\n for i:=1 to 3 do begin\n for j:=1 to 3 do begin\n read(t[i,j]);\n if(j=3) then readln;\n end;\n end;\n read(n);\n\n f[1,2]:=min(t[1,2],t[1,3]+t[3,2]);\n f[1,3]:=min(t[1,3],t[1,2]+t[2,3]);\n f[2,1]:=min(t[2,1],t[2,3]+t[3,1]);\n f[2,3]:=min(t[2,3],t[2,1]+t[1,3]);\n f[3,1]:=min(t[3,1],t[3,2]+t[2,1]);\n f[3,2]:=min(t[3,2],t[3,1]+t[1,2]);\n \n for i:=2 to n do begin\n g[1,2]:=min(t[1,2]+f[1,3]+f[3,2],t[1,3]+t[3,2]+f[1,2]+f[2,1]+f[1,2]);\n g[1,3]:=min(t[1,3]+f[1,2]+f[2,3],t[1,2]+t[2,3]+f[1,3]+f[3,1]+f[1,3]);\n g[2,1]:=min(t[2,1]+f[2,3]+f[3,1],t[2,3]+t[3,1]+f[2,1]+f[1,2]+f[2,1]);\n g[2,3]:=min(t[2,3]+f[2,1]+f[1,3],t[2,1]+t[1,3]+f[2,3]+f[3,2]+f[2,3]);\n g[3,1]:=min(t[3,1]+f[3,2]+f[2,1],t[3,2]+t[2,1]+f[3,1]+f[1,3]+f[3,1]);\n g[3,2]:=min(t[3,2]+f[3,1]+f[1,2],t[3,1]+t[1,2]+f[3,2]+f[2,3]+f[3,2]);\n f[1,2]:=g[1,2];\n f[1,3]:=g[1,3];\n f[2,1]:=g[2,1];\n f[2,3]:=g[2,3];\n f[3,1]:=g[3,1];\n f[3,2]:=g[3,2];\n end;\n \n write(f[1,3]);\nEND. ", "src_uid": "c4c20228624365e39299d0a6e8fe7095"} {"source_code": "Var\n\tm,top:longint;\n\t\nBegin\n\treadln(m);\n\ttop:=0;\n\trepeat\n\t\tinc(top);\n\t\tm:=m div 2;\n\tuntil m=0;\n\twriteln(top);\nEnd.", "src_uid": "95cb79597443461085e62d974d67a9a0"} {"source_code": "var a,b,c:longint;\nbegin\nread(a,b,c);\nif (a>b) and (a>c) then\n if a+b+c<2*(c+b) then write(a+b+c) else write(2*(c+b))\nelse if (b>c) and (b>a) then\n if a+b+c<2*(a+c) then write(a+b+c) else write(2*(c+a))\nelse\n if a+b+c<2*(a+b) then write(a+b+c) else write(2*(a+b));\nend.", "src_uid": "26cd7954a21866dbb2824d725473673e"} {"source_code": "\n const nn=6000; nnn=2000;eps=0.000000001; besk1=200000008;\n label 1,2;\n type real=extended; {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 modul,tt,ii,sumplus,summinus,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 step, i,j:longint;\n time:real;\n sss:array[-10..10000] of char;\n buk,sssnew:array[-10..1000] of char;\n sum,sumii,c,d,x,y,a,b:array[-1000002..6000000] 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..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 kolizm(pos:longint):longint;\nvar i,j,ot:longint;\nbegin\n ot:=0;\n for i:=1 to p1 do if ss1[i]<>ss2[pos+i-1] then inc(ot);\n\n kolizm:=ot;\nend;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(tt,ll,rr); modul:=1000000007;\n n:=rr;\n for i:=1 to 5000000 do prost[i]:=true;\n p:=1;\n while p<=n do\n begin\n repeat inc(p) until prost[p];\n t:=(n div p);\n for i:=2 to t do begin prost[p*i]:=false; end;\n\n end;\n\n { for i:=2 to 100 do if prost[i] then write(i,' '); writeln;\n } for i:=2 to n do a[i]:=0;\n p:=1;\n a[1]:=0;\n while p<=n do\n begin\n repeat inc(p) until prost[p];\n t:=n div p;\n a[p]:=p;\n for i:=2 to t do\n begin\n a[i*p]:=max(a[i*p],p);\n\n\n end;\n end;\n\n { for i:=1 to 50 do write(a[i],' '); writeln;\n } for i:=2 to n do\n begin\n t:=i div a[i];\n { writeln(i,' ',t);\n writeln(a[t],' + ',((a[i]*(a[i]-1) shr 1)));\n } b[i]:=(a[i]*b[t]+(a[i]*(a[i]-1) shr 1)) mod modul;\n { writeln('i= ',i,' b= ',b[i]);\n writeln('---------');\n }end;\n { writeln('+++++++++++++');\n for i:=2 to 1000 do writeln(i,' ',b[i],' '); writeln;\n }\n\n { ot:=0;\n x[ll]:=1;\n for i:=ll+1 to rr do x[i]:=(x[i-1]*tt) mod modul;\n for i:=ll to rr do\n begin\n ot:=(ot+b[i]*x[i]) mod modul;\n\n end;\n writeln(ot);\n ot:=0;\n p:=1;\n\n\n }\n ot:=0;\n for i:=rr downto ll do\n begin\n ot:=(ot*tt+b[i])mod modul;\n { writeln('i= ',i,' b= ',b[i],' ot= ',ot); }\n end;\n\n writeln(ot );\n\n\n 1: close(output);\nend.\n\n\n", "src_uid": "c9d45dac4a22f8f452d98d05eca2e79b"} {"source_code": "//mathfuck\n\nconst\n md=1000000007;\n\nvar\n F,INV:array[0..1000002] of qword;\n i,n,k:longint;\n s,ans,tmp,w:qword;\n\nfunction Pow(i:qword; k:longint):qword;\nvar r:qword;\nbegin\n r:=1;\n while k>0 do\n begin\n if k and 1 = 1 then r:=r*i mod md;\n i:=i*i mod md;\n k:=k div 2;\n end;\n exit(r);\nend;\n\nbegin\n readln(n,k);\n s:=1; INV[0]:=1; tmp:=1;\n for i:=1 to k+2 do\n begin\n tmp:=tmp*(n-i) mod md;\n s:=s*i mod md;\n F[i]:=(F[i-1]+Pow(i,k)) mod md;\n INV[i]:=Pow(s,md-2);\n end;\n if n<=k+2 then ans:=F[n] else\n for i:=1 to k+2 do\n begin\n w:=INV[i-1]*INV[k+2-i] mod md;\n if (k-i) and 1 = 1 then w:=md-w;\n ans:=(ans+((tmp*Pow(n-i,md-2) mod md)*(w*F[i] mod md) mod md)) mod md;\n end;\n write(ans);\nend.", "src_uid": "6f6fc42a367cdce60d76fd1914e73f0c"} {"source_code": "uses math;\nvar x,y,xx,yy,ans,r:int64;\nm:double;\nbegin\n readln(r,x,y,xx,yy);\n r:=r*2;\n m:=sqrt(sqr(xx-x)+sqr(yy-y));\n writeln(ceil(m/r));\nend.", "src_uid": "698da80c7d24252b57cca4e4f0ca7031"} {"source_code": "type\n re=record\n x,y:extended;\n adj:longint;\n end;\n\nvar\n ans,t1,t2:extended;\n n,m:longint;\n a:array[1..100100]of re;\n\nfunction jd(x,y:re):boolean;\nbegin\n exit(x.x=r then exit;\n i:=l;\n j:=r;\n mid:=a[(l+r)shr 1];\n repeat\n while jd(a[i],mid) do inc(i);\n while jd(mid,a[j]) do dec(j);\n if i<=j then begin\n t:=a[i];\n a[i]:=a[j];\n a[j]:=t;\n if i=m then m:=j\n else if j=m then m:=i;\n inc(i);\n dec(j);\n end;\n until i>j;\n qs(i,r);\n qs(l,j);\nend;\n\nfunction dis(x,y:re):extended;\nbegin\n exit(sqrt(sqr(x.x-y.x)+sqr(x.y-y.y)));\nend;\n\nprocedure init;\nvar\n i,l,r:longint;\n\nbegin\n for i:=1 to n+1 do begin\n read(a[i].x);\n a[i].adj:=i;\n end;\n read(a[n+1].y);\n qs(1,n);\n if m=a[n+1].adj then begin\n ans:=a[n].x-a[1].x;\n t1:=dis(a[n],a[n+1]);\n t2:=dis(a[1],a[n+1]);\n ans:=ans+min(t1,t2);\n end\n else begin\n ans:=min(dis(a[n],a[n+1])+dis(a[m],a[1]),dis(a[1],a[n+1])+dis(a[m],a[n]))\n +dis(a[1],a[n]);\n\n for i:=2 to n do begin\n t1:=min(dis(a[m],a[1])+dis(a[1],a[i-1])+dis(a[i-1],a[n+1]),dis(a[m],a[i-1])+dis(a[i-1],a[1])+dis(a[1],a[n+1]))\n +min(dis(a[n],a[n+1]),dis(a[i],a[n+1]))+dis(a[n],a[i]);\n t2:=min(dis(a[m],a[n])+dis(a[n],a[i])+dis(a[i],a[n+1]),dis(a[m],a[i])+dis(a[i],a[n])+dis(a[n],a[n+1]))\n +min(dis(a[1],a[n+1]),dis(a[i-1],a[n+1]))+dis(a[1],a[i-1]);\n ans:=min(ans,min(t1,t2));\n end;\n end;\n writeln(ans:0:8);\nend;\n\nbegin\n readln(n,m);\n init;\nend.", "src_uid": "f9ed5faca211e654d9d4e0a7557616f4"} {"source_code": "{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nvar\n yy,zz,n,m,i,e: longint;\n lg,rg: array [0..2,0..1,0..110] of longint;\n kg: array [0..2,0..1] of longint;\n was: array [0..100010,0..2,0..1] of boolean;\n x,y,z,km: array [0..666666] of longint;\n\nprocedure put(x1,x2,yy,zz:longint);\nvar\n u1,u2,v,j,xx: longint;\nbegin\n if x2 < 0 then exit;\n if x1 > n then exit;\n zz:=1-zz;\n yy:=2-yy;\n if x1 < 0 then x1:=0;\n if x2 > n then x2:=n;\n xx:=x1; x1:=n-x2; x2:=n-xx;\n u1:=x1; u2:=x2;\n for v:=1 to kg[yy,zz] do\n begin\n if x1 < lg[yy,zz,v] then x1:=lg[yy,zz,v];\n if x2 > rg[yy,zz,v] then x2:=rg[yy,zz,v];\n for j:=x1 to x2 do\n if not was[j,yy,zz] then\n begin\n inc(e);\n x[e]:=j;\n y[e]:=yy;\n z[e]:=zz;\n km[e]:=km[i]+1;\n was[j,yy,zz]:=True;\n end;\n if x1 <= x2 then\n if (x1 > lg[yy,zz,v]) and (x2 < rg[yy,zz,v]) then\n begin\n inc(kg[yy,zz]);\n lg[yy,zz,kg[yy,zz]]:=x2+1;\n rg[yy,zz,kg[yy,zz]]:=rg[yy,zz,v];\n rg[yy,zz,v]:=x1-1;\n end else\n if x2 < rg[yy,zz,v] then lg[yy,zz,v]:=x2+1\n else rg[yy,zz,v]:=x1-1;\n x1:=u1; x2:=u2;\n end;\nend;\n\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(n,m);\n for yy:=0 to 2 do\n for zz:=0 to 1 do\n begin\n kg[yy,zz]:=1;\n lg[yy,zz,1]:=0;\n rg[yy,zz,1]:=n;\n end;\n fillchar(was,sizeof(was),False);\n i:=1; e:=1;\n x[1]:=n; y[1]:=2; z[1]:=0;\n km[1]:=0;\n was[n,2,0]:=True;\n while i <= e do\n begin\n if (x[i] = n) and (y[i] > 0) and (z[i] = 1) then\n begin\n writeln(km[i]);\n halt;\n end;\n if y[i] = 0 then\n begin\n put(x[i]-m,x[i]-1,0,z[i]);\n end else\n if y[i] = 1 then\n begin\n put(x[i]-(m shr 1),x[i]-1,1,z[i]);\n if (x[i] > 0) and (x[i] <= m) then put(x[i]-(m-x[i]),x[i],0,z[i]);\n end else\n begin\n put(x[i]-m,x[i]-1,2,z[i]);\n if (n-x[i]) <= m then\n if x[i] < n then put(x[i]-((m-(n-x[i])) shr 1),x[i],1,z[i])\n else put(x[i]-(m shr 1),x[i]-1,1,z[i]);\n end;\n inc(i);\n end;\n writeln(-1);\n close(input);\n close(output);\nend.", "src_uid": "83f1d50a1802e08dd154d4c9778e3d80"} {"source_code": "var\n c, ex, a, b, n, i, v, x, code: int64;\n s1: string;\n s2:string;\n\nbegin\nv:=1;\n readln(s1);\n readln(s2);\n\nfor i:=1 to length(s2) do\nbegin\nif s2[i]=s1[v] then\nbegin\nv:=v+1;\nc:=c+1;\nend;\nend;\n\nwriteln(c+1);\n \nend.\n", "src_uid": "f5a907d6d35390b1fb11c8ce247d0252"} {"source_code": "uses math;\n\nvar\n i,j,n,w,kq:integer;\n a:array[0..200] of integer;\n\nbegin\n read(n);\n for i:=1 to n do read(a[i]);\n for i:=1 to n do \n begin\n w:=0;\n for j:=1 to i-1 do\n if a[j] = 1 then inc(w);\n for j:=i+1 to n do\n if a[j] = 0 then inc(w);\n kq:=max(kq , n-w);\n end;\n write(kq);\nend.", "src_uid": "c7b1f0b40e310f99936d1c33e4816b95"} {"source_code": "var\n a:Array[1..100] of longint;\n kq,n,max,min:longint;\nprocedure nhap;\nvar i:longint;\nbegin\n readln(n);\n max:=-high(longint);\n min:=high(longint);\n for i:=1 to n do\n begin\n read(a[i]);\n if a[i]>max then max:=a[i];\n if a[i]vt2 then\n begin\n tam:=vt1;vt1:=vt2;vt2:=tam;\n end;\n kq:=vt1;\n if n-vt1>kq then kq:=n-vt1;\n if vt2-1>kq then kq:=vt2-1;\nend;\nbegin\n nhap;\n giai;\n write(kq);\n readln;\nend.\n", "src_uid": "1d2b81ce842f8c97656d96bddff4e8b4"} {"source_code": "var\n i,j,k,n,m,d,sum:longint;\n a:array[1..100] of integer;\nbegin\n readln(n,d);\n for i:=1 to n do read(a[i]);\n for i:=1 to n do\n for j:=i+1 to n do if a[i]>a[j] then begin\n k:=a[i];a[i]:=a[j];a[j]:=k;\n end;\n readln(m);\n if m<=n then begin\n for i:=1 to m do inc(sum,a[i]);\n writeln(sum);\n end\n else begin\n for i:=1 to n do inc(sum,a[i]);\n dec(sum,(m-n)*d);\n writeln(sum);\n end;\nend.", "src_uid": "5c21e2dd658825580522af525142397d"} {"source_code": "var\n h,m:longint;\n s,s1,s2,s3,s4:string;\nBEGIN\nreadln(s);\ns1:=copy(s,1,2);\ns2:=copy(s,4,2);\nval(s1,h);\nval(s2,m);\nwhile (true) 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 \n begin\n h:=0;\n m:=0;\n end;\n str(h,s1);\n str(m,s2);\n if (h<=9) then s1:='0'+s1;\n if (m<=9) then s2:='0'+s2;\n s3:=s1[2]+s1[1];\n s4:=s2[2]+s2[1];\n if (s1=s4)and(s2=s3) then \n begin\n writeln(s1,':',s2);\n break;\n end;\n end;\nEND.", "src_uid": "158eae916daa3e0162d4eac0426fa87f"} {"source_code": "var j,q,n,m,i,ans,s:longint;\na,b:array[0..100]of longint;\n begin\n read(n,m);\n for i:=1 to m do\n read(a[i],b[i]);\n\n for i:=1 to m-1 do\n for j:=i+1 to m do\n if b[i]n then\n begin\n ans:=ans+(n-s)*b[i];\n s:=n;\n end\n else\n begin\n ans:=ans+a[i]*b[i];\n s:=s+a[i];\n end;\n i:=i+1;\n end;\n writeln(ans);\n end.", "src_uid": "c052d85e402691b05e494b5283d62679"} {"source_code": " type mas = record\n x,y,c,p:longint;\n end;\n var i,j,k,n,m,p:longint;\n a:array [0..101] of mas;\n b:array [0..101] of longint;\n begin\n{ assign (input,'input.txt');\n reset (input);\n assign (output,'output.txt');\n rewrite (output); }\n read (n,m);\n\n for i:=1 to m do\n begin\n read (a[i].x,a[i].y,a[i].c);\n a[i].p:=i;\n end;\n\n for i:=1 to n do\n begin\n p:=20000;\n k:=0;\n for j:=1 to m do\n begin\n if a[j].x<=i then\n begin\n if a[j].y=i then\n if a[j].c<>0 then\n begin\n writeln (-1);\n halt;\n end\n else\n begin\n inc (a[k].c);\n k:=m+1;\n p:=-1;\n end;\n\n if (a[j].c<>0) and (a[j].y-i-a[j].c=a) or (m-x>=a)) and ((y-1>=b) or (n-y>=b)) then\n Begin\n If (t1 mod a=0) and (t2 mod b=0) then\n Begin\n t1:=t1 div a;\n t2:=t2 div b;\n If abs(t1-t2) mod 2=0 then\n Begin\n tmp:=min(t1,t2)+(abs(t1-t2));\n If (tmp0 do\n begin\n a[j]:=x mod 10;\n x:=x div 10;\n inc(j);\n end;\nl:=1;\nwhile i>0 do\n begin\n b[l]:=i mod 10;\n i:=i div 10;\n inc(l);\n end;\nfor x:=1 to j-1 do\n for i:=1 to l-1 do\n if a[x]=b[i] then\n begin\n proverka:=1;\n exit;\n end;\nend;\nbegin\n{assign(input,'input.txt');\n assign(output,'output.txt');\n reset(input); rewrite(output);}\nreadln(x); k:=0;\nfor i:=1 to trunc(sqrt(x)) do\n if x mod i=0 then\n begin\n if proverka(x,i)=1 then inc(k);\n if (proverka(x,x div i)=1) and (i<>x div i) then inc(k);\n end;\n{i:= x div 2;\nif proverka(x,i)=1 then inc(k);\nif x>1 then inc(k);}\nwrite(k);\n{close(input); close(output);}\nend.\n", "src_uid": "ada94770281765f54ab264b4a1ef766e"} {"source_code": "\ufeffVAR N,M,K,t,X,Y,M1:int64;\nbegin\nreadln(N,M,K);\nif K0) do\n begin\n o:=o*10+(x mod 10);\n x:=x div 10;\n end;\n reverse:=o;\n end;\nbegin\n readln(n);\n a[1]:=true;\n for i:=2 to 1000007 do\n begin\n j:=i;\n if (a[i]=true) then continue;\n while (j<=1000007) do\n begin\n inc(j,i);\n a[j]:=true;\n end;\n end;\n i:=0;\n a[1]:=true;\n while (n>0) do\n begin\n inc(i);\n j:=reverse(i);\n if ( (not (a[j])) and (not (a[i])) and (i<>j) ) then dec(n);\n end;\n writeln(i);\nend.\n", "src_uid": "53879e79cccbacfa6586d40cf3436657"} {"source_code": "const maxn = 105; mo = 1000003;\ntype matrix = array[0..maxn,0..maxn] of int64;\nvar c,w,h,ans:int64;\n tmp,a:matrix;\nprocedure multi(a,b:matrix; var c:matrix);\n var t:matrix;\n i,j,k:longint;\n begin\n fillchar(t,sizeof(t),0);\n for k:=0 to w do\n for i:=0 to w do\n for j:=0 to w do t[i,j]:=(t[i,j]+a[i,k]*b[k,j]) mod mo;\n for i:=0 to w do\n for j:=0 to w do c[i,j]:=t[i,j];\n end;\nprocedure init();\n var i:longint;\n begin\n readln(c,w,h);\n fillchar(tmp,sizeof(tmp),0);\n for i:=0 to w do tmp[i,i]:=1;\n fillchar(a,sizeof(a),0);\n a[0,0]:=1;\n for i:=1 to w do a[0,i]:=(a[0,i-1]*h) mod mo;\n for i:=1 to w do a[i,i-1]:=1;\n end;\nprocedure main();\n var i,j,k:longint;\n begin\n i:=c+1;\n while (i<>0) do begin\n if (i mod 2=1) then multi(a,tmp,tmp);\n multi(a,a,a); i:=i div 2;\n{ for j:=0 to w do begin\n for k:=0 to w do write(tmp[j,k],' '); writeln;\n end;}\n end;\n writeln(tmp[0,0]);\n end;\nbegin\n init();\n main();\nend.\n", "src_uid": "bb1c0ff47186e10e00b7dde6758ff1c1"} {"source_code": "{$mode delphi}\n\n{ $DEFINE IS_TEST}\n\n{$ifndef IS_TEST} \n uses sysutils;\n{$endif} \n\nprocedure start;\nbegin\n{$ifdef IS_TEST} \n assign(input, 'input.txt');\n reset(input);\n{$endif}\nend;\n\nvar\n a, b, s, r: integer;\nbegin\n start;\n \n read(a, b);\n \n s := a;\n\n while a div b <> 0 do begin\n inc(s, a div b);\n \n a := a div b + (a mod b);\n end;\n \n writeln(s);\nend.", "src_uid": "a349094584d3fdc6b61e39bffe96dece"} {"source_code": "{ Free Pascal }\nvar step: array [1 .. 50] of qword;\n k: qword;\n n, i: byte;\n c: char;\n\n\n\nbegin\n k:= 0;\n\n readln(n);\n\n step[1]:= 1;\n for i:= 2 to n do\n step[i]:= step[i - 1] * 2;\n\n for i:= 1 to n do\n begin\n read(c);\n if(c = 'B') then\n k:= k + step[i];\n end;\n\n writeln(k);\nend.\n", "src_uid": "d86a1b5bf9fe9a985f7b030fedd29d58"} {"source_code": "var n,m,k,i,j,x,g,max,s:longint;\na:array[0..1001] 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 l=(n-i)*a[j] then\n begin\n x:=x-(n-i)*a[j];\n g:=g+(n-i);\n end\n else\n begin\n g:=g+x div a[j];\n break;\n end;\n if g>max then max:=g;\n end;\nwriteln(max);\nclose(input);close(output);\nend.", "src_uid": "d659e92a410c1bc836be64fc1c0db160"} {"source_code": "var\n k,n,w,i,tot:integer;\n\nbegin\n readln(k,n,w);\n tot := 0;\n for i := 1 to w do\n begin\n tot := tot + (i*k);\n end;\n if tot>n then\n writeln(tot-n)\n else\n writeln('0');\nend.\n", "src_uid": "e87d9798107734a885fd8263e1431347"} {"source_code": "var m,n,a:real;\nbegin\nread(m,n,a);\nIf round(m) mod round(a) <> 0\nthen m:=round(m) div round(a) + 1\nelse m:=round(m) div round(a);\nIf round(n) mod round(a) <> 0\nthen n:=round(n) div round(a) + 1\nelse n:=round(n) div round(a);\nwriteln(n*m:0:0);\n\nend.", "src_uid": "ef971874d8c4da37581336284b688517"} {"source_code": "{$MODE OBJFPC}\nuses\n math;\nconst\n fi = 'INPUT.INP';\n dx : array[0..1] of Integer = (1, -1);\nvar\n n, res, m, i, j, k, d : Integer;\n s : String;\n f : array[0..105,0..55,-105..105,0..1] of Boolean;\n\nbegin\n //assign(input,fi); reset(input);\n readln(s); m := length(s);\n readln(n);\n f[0,0,0,0] := true;\n for i := 0 to m-1 do\n for j := 0 to n do\n for k := -m to m do\n for d := 0 to 1 do\n if f[i,j,k,d] then\n begin\n if s[i+1] = 'F' then\n begin\n f[i+1,j,k+dx[d],d] := true;\n f[i+1,j+1,k,1-d] := true;\n end;\n if s[i+1] = 'T' then\n begin\n f[i+1,j,k,1-d] := true;\n f[i+1,j+1,k+dx[d],d] := true;\n end;\n end;\n for j := 0 to n do\n for k := -m to m do\n for d := 0 to 1 do\n if ((n - j) and 1 = 0) and (f[m,j,k,d]) then res := max(res, abs(k));\n writeln(res);\nend.\n", "src_uid": "4a54971eb22e62b1d9e6b72f05ae361d"} {"source_code": "program A877;\nvar\n s:ansistring;\n i,kq:integer;\n\nbegin\n read(s);\n for i:=1 to length(s) do\n begin\n if (i+4 <= length(s)) then\n if copy(s,i,5) = 'Danil' then\n inc(kq);\n if (i+3 <= length(s)) then\n if copy(s,i,4) = 'Olya' then \n inc(kq);\n if (i+4 <= length(s)) then\n if copy(s,i,5) = 'Slava' then\n inc(kq);\n if (i+2 <= length(s)) then\n if copy(s,i,3) = 'Ann' then\n inc(kq);\n if (i+5 <= length(s)) then\n if copy(s,i,6) = 'Nikita' then\n inc(kq);\n end;\n if kq = 1 then\n write('YES') \n else \n write('NO');\nend.", "src_uid": "db2dc7500ff4d84dcc1a37aebd2b3710"} {"source_code": "var a,b,c,d,i,j,k,l,m,n,rst,x,y:longint; s,way,s1:string; Z:array['A'..'Z'] of byte; ch:char;\nT:array[0..3,0..14] of char;\n\n\n\nProcedure PrintArray;\nvar i,j:longint;\nbegin\nfor i:=1 to 2 do begin for j:=1 to 13 do write(T[i,j]); writeln; end; writeln;\nend;\n\n\nbegin\n//assign(input,'d:\\input.txt'); reset(input);\n//assign(output,'d:\\output.txt'); rewrite(output);\nreadln(way); s:=way;\nfor i:=1 to 27 do\nif Z[s[i]]<>0 then begin rst:=i-Z[s[i]]-1;ch:=s[i]; break;\nend else Z[s[i]]:=i;\n\nif rst=0 then begin write('Impossible'); exit; end;\n\nif rst mod 2=0 then\n begin\n a:=rst div 2; b:=Z[ch]+1;\n T[1,13-a]:=ch;\n for i:=13-a+1 to 13 do begin T[1,i]:=s[b]; inc(b); end;\n for i:=13 downto 13-a+1 do begin T[2,i]:=s[b]; inc(b); end;\n s1:=copy(s,1,Z[ch]-1); delete(s,1,Z[ch]+rst); s:=s+s1;\n x:=13-a; y:=2; c:=length(s);\n while c>0 do\n begin\n T[y,x]:=s[c]; c:=c-1;\n if y=1 then inc(x);\n if y=2 then dec(x); if x=0 then begin y:=1; x:=1; end;\n end;\n end;\n\nif rst mod 2=1 then\n begin\n a:=rst div 2; b:=Z[ch]+1;\n T[1,13-a]:=ch;\n for i:=13-a+1 to 13 do begin T[1,i]:=s[b]; inc(b); end;\n for i:=13 downto 13-a do begin T[2,i]:=s[b]; inc(b); end;\n s1:=copy(s,1,Z[ch]-1); delete(s,1,Z[ch]+rst); s:=s+s1;\n x:=13-a-1; y:=2; c:=length(s);\n while c>0 do\n begin\n T[y,x]:=s[c]; c:=c-1;\n if y=1 then inc(x);\n if y=2 then dec(x); if x=0 then begin y:=1; x:=1; end;\n end;\n end;\n\nPrintArray;\nend.", "src_uid": "56c5ea443dec7a732802b16aed5b934d"} {"source_code": "var n,k,i,j,c:longint;\n q:boolean;\n a:array [1..20] of longint;\nbegin\n readln(n,k);\n j:=2;\n c:=0;\n q:=true;\n for i:=1 to k do\n begin\n while (n mod j<>0) and (j<=n) do inc(j);\n if j<=n then\n begin\n inc(c);\n a[c]:=j;\n n:=n div j;\n end\n else q:=false;\n end;\n if c1 then a[c]:=a[c]*n;\n if q=false then writeln(-1)\n else for i:=1 to k do\n if i<>k then write(a[i],' ') else writeln(a[i]);\n readln;\nend.\n\n\n", "src_uid": "bd0bc809d52e0a17da07ccfd450a4d79"} {"source_code": "Var n,m:int64;\r\nBegin\r\nReadln(n,m);\r\nIf m=1 then writeln(n-1) else writeln((m-1)*n);\r\nEnd.", "src_uid": "a91aab4c0618d036c81022232814ef44"} {"source_code": "var\n i,s1,s2,n:longint;\n x:char;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(x);\n if x='1' then inc(s1) else inc(s2);\n end;\n if (s1=0) then begin writeln(0);exit;end;\n if s1>=1 then write(1);\n for i:=1 to s2 do write(0);\n writeln;\nend.", "src_uid": "ac244791f8b648d672ed3de32ce0074d"} {"source_code": "\ufeffvar\n i, sg, j, xx: integer;\n a, su, b, c, d, e, f: array [1..11] of string;\n\nbegin\n for i := 1 to 10 do readln(a[i]); \n \n sg := 1;\n \n su[1] := '.XXXX';su[2] := 'X.XXX';su[3] := 'XX.XX';su[4] := 'XXX.X';su[5] := 'XXXX.';\n \n for i := 1 to 10 do \n for j := 1 to 5 do \n if pos(su[j], a[i]) > 0 then begin\n write('YES');\n exit;\n end;\n \n for i := 1 to 10 do \n begin\n b[i] := ' ';\n c[i] := ' ';\n d[i] := ' ';\n e[i] := ' ';\n f[i] := ' ';\n end;\n \n for i := 1 to 10 do\n for j := 1 to 10 do\n b[i][j] := a[j][i];\n \n \n for i := 1 to 10 do \n for j := 1 to 5 do \n if pos(su[j], b[i]) > 0 then begin\n write('YES');\n exit;\n end;\n \n for i := 1 to 10 do \n for j := 1 to 11 - i do \n if (i + j - 1) <= 10 then c[i][j] := a[j][i + j - 1];\n \n for i := 1 to 10 do \n for j := 1 to 5 do \n if pos(su[j], c[i]) > 0 then begin\n write('YES');\n exit;\n end;\n \n for i := 1 to 10 do \n for j := 1 to 11 - i do \n if (i + j - 1) <= 10 then d[i][j] := a[j + i - 1][j];\n \n for i := 1 to 10 do \n for j := 1 to 5 do \n if pos(su[j], d[i]) > 0 then begin\n write('YES');\n exit;\n end;\n \n for i := 1 to 10 do \n for j := 1 to 11 - i do \n if (j + i - 1) <= 10 then e[i][j] := a[11- j ][j + i - 1];\n \n for i := 1 to 10 do \n for j := 1 to 5 do \n if pos(su[j], e[i]) > 0 then begin\n write('YES');\n exit;\n end;\n \n for i := 1 to 10 do \n for j := 1 to 11 - i do \n if (i + j - 1) <= 10 then f[i][j] := a[11 - (j - 1 + i)][j];\n \n for i := 1 to 10 do \n for j := 1 to 5 do \n if pos(su[j], f[i]) > 0 then begin\n write('YES');\n exit;\n end;\n writeln ('NO');\n \nend.", "src_uid": "d5541028a2753c758322c440bdbf9ec6"} {"source_code": "var n,i,sum,j,max:longint;\ns,c,st:string;\nbegin\n//assign(input,'two.in');reset(input);\n//assign(output,'two.out');rewrite(output);\nreadln(n);readln(s);\nfor i:=2 to n do\n begin\n c:=s[i-1]+s[i];sum:=0;\n for j:=2 to n do\n if s[j-1]+s[j]=c then inc(sum);\n if sum>max then begin max:=sum;st:=c;end;\n end;\nwriteln(st);\nclose(input);close(output);\nend.", "src_uid": "e78005d4be93dbaa518f3b40cca84ab1"} {"source_code": "var\n k,\n a,\n b,\n v,\n n,\n nb,\n nk:integer;\n\nbegin\n readln(k,a,b,v);\n n:=0;\n if a mod v = 0 then nk:=a div v else nk:=a div v + 1;\n nb:=b div (k-1);\n if (nk>=nb*(k-1)) and (nk>0) then begin\n n:=nb;\n nk:=nk - nb*k;\n end else if (nk>0) then begin\n if (nk mod k>0) then n:=(nk div k) + 1\n else n:=(nk div k);\n nk:= 0;\n end;\n nb:=b mod (k-1) + 1;\n if (nk<=nb) and (nk>0)then begin\n n:=n+1;\n nk:=0;\n end else if (nk>0) then begin\n n:=n+1;\n nk:=nk-nb;\n end;\n n:=n+nk;\n writeln(n);\nend.\n", "src_uid": "7cff20b1c63a694baca69bdf4bdb2652"} {"source_code": "var c1,c2,c3,c4,c5,c6:array[1..40] of integer;\n a1,b1,a,b,d:longint;\nbegin\nreadln(a1,b1);\nif a1>b1 then begin\n d:=a1;\n a1:=b1;\n b1:=d;\n end;\n\nc1[1]:=0;\nfor a:=2 to 40 do\n if (a mod 3=2)or(a mod 3=0) then c1[a]:=c1[a-1]+1\n else c1[a]:=c1[a-1];\n\n\n\nc2[1]:=1;b:=0;\nfor a:=2 to 20 do\nbegin\ninc(b);\nif b mod 3=0 then b:=1;\nc2[a]:=c2[a-1]+b;\nend;\n\n\n\nc3[1]:=2;\nfor a:=2 to 4 do\n c3[a]:=c3[a-1]+2;\nc3[5]:=11;\nfor a:=6 to 8 do\n c3[a]:=c3[a-1]+2;\nc3[9]:=20;\nfor a:=10 to 12 do\n c3[a]:=c3[a-1]+2;\nc3[13]:=29;\n\nc4[4]:=12;c4[5]:=14;\nc4[6]:=17;c4[7]:=21;\nc4[8]:=24;c4[9]:=26;\nc4[10]:=30;\n\n\n\nc5[5]:=18;c5[6]:=22;c5[7]:=26;c5[8]:=29;\n\nc6[6]:=26;\n\n\nif a1=1 then writeln(c1[b1]);\nif a1=2 then writeln(c2[b1]);\nif a1=3 then writeln(c3[b1]);\nif a1=4 then writeln(c4[b1]);\nif a1=5 then writeln(c5[b1]);\nif a1=6 then writeln(c6[b1]);\nend.\n", "src_uid": "097674b4dd696b30e102938f71dd39b9"} {"source_code": "var a,b,c, max: LongInt;\nbegin\n Readln(a,b,c);\n \n if a>b then max:=a else max:=b;\n if c>=max then max:=c;\n \n if odd(max) then\n begin\n if (max=c) then Writeln(30+((max+1) div 2)*3 - 1) else\n if (max=b) then Writeln(30+((max+1) div 2)*3 - 2) else\n Writeln(30+((max+1) div 2)*3 - 3);\n end else\n begin\n if (max=c) or (max-1=c) then Writeln(30+((max+1) div 2)*3 - 1) else\n if (max=b) or (max-1=b) then Writeln(30+((max+1) div 2)*3 - 2) else\n Writeln(30+((max+1) div 2)*3 - 3);\n end;\nend.", "src_uid": "a45daac108076102da54e07e1e2a37d7"} {"source_code": "program cdiv2_cf_476;\nvar\n a,b:int64;\n res,x,y,hn:int64;\nbegin\n hn:=trunc(1e9+7);\n readln(a,b);\n x:=((b*(b-1)) div 2) mod hn;\n y:=((a*(a+1)) div 2) mod hn;\n y:=(y*b) mod hn;\n y:=(y+a) mod hn;\n res:=(x*y) mod hn;\n writeln(res);\nend.\n", "src_uid": "cd351d1190a92d094b2d929bf1e5c44f"} {"source_code": "Program bv1;\nvar\n n : longint;\nbegin\nreadln (n);\nif (n mod 4 = 0) or ( n mod 7 = 0 )or ( n mod 74 = 0 )\nor ( n mod 47 = 0 )or ( n mod 774 = 0 )or ( n mod 474 = 0 )\nor ( n mod 447 = 0 ) or ( n mod 477 = 0 )or ( n mod 747 = 0 )\nthen write ('YES')\nelse write ('NO');\nend.\n", "src_uid": "78cf8bc7660dbd0602bf6e499bc6bb0d"} {"source_code": "var\nx,a,b,c:int64;\ni,j,k:longint;\nres,s:int64;\nmas:array[1..2010000] of int64;\nfunction f(x:int64):int64;\nvar \nk,y,n,c,d:int64;\nbegin\nif(mas[x]<>-1)\nthen f:=mas[x]\nelse begin\n if x = 1 then k:=1\n else k:=2;\n y:=2;\n while y*y < x do begin\n if x mod y = 0 then inc(k,2); \n y:=y+1;\n end;\n if y*y = x then k:=k+1; \nmas[x]:=k;\n f:=k;\nend;\nend;\nbegin\nread(a,b,c); s:=0;\nfor i:=1 to 2010000 do\nmas[i]:=-1;\nfor i:=1 to a do \nfor j:=1 to b do\nfor k:=1 to c do\ns:=s+f(i*j*k);\nwriteln(s mod 1073741824);\nend.", "src_uid": "4fdd4027dd9cd688fcc70e1076c9b401"} {"source_code": "Uses Math;\nConst\n fin='';\n fon='';\nVar\n n,v,e,dem: Longint;\n A,B: array[0..400] of Longint;\n x,y,z: array[0..190000] of Longint;\n cha: array[0..400,0..400] of Longint;\n Adj,mark: array[0..400,0..400] of Boolean;\nProcedure Start;\n Begin\n assign(input,fin);\n reset(input);\n assign(output,fon);\n rewrite(output);\n End;\nProcedure Solve(s,t,val: Longint);\n Begin\n A[s]:=A[s]-val;\n A[t]:=A[t]+val;\n Inc(dem);\n x[dem]:=s;\n y[dem]:=t;\n z[dem]:=val;\n End;\nProcedure Work(s,t,val: Longint);\n Var tmp,tam: Longint;\n Begin\n if s=t then Exit;\n tmp:=cha[s,t];\n tam:=Min(val,A[tmp]);\n Solve(tmp,t,tam);\n Work(s,tmp,val);\n if tam < val then\n Solve(tmp,t,val-tam);\n End;\nProcedure Programe;\n Var chay,i,j,u,v: Longint;\n Begin\n fillchar(Adj,sizeof(Adj),False);\n read(n,v,e);\n for i:=1 to n do read(A[i]);\n for i:=1 to n do read(B[i]);\n for i:=1 to e do\n begin\n read(u,v);\n Adj[u,v]:=True;\n Adj[v,u]:=True;\n end;\n mark:=Adj;\n for i:=1 to n do\n for j:=1 to n do\n if Adj[i,j] then cha[i,j]:=i;\n for chay:=1 to n do\n for i:=1 to n do\n for j:=1 to n do\n if not mark[i,j]\n and mark[i,chay]\n and mark[chay,j] then\n begin\n mark[i,j]:=True;\n cha[i,j]:=cha[chay,j];\n end;\n dem:=0;\n for i:=1 to n do\n for j:=1 to n do\n begin\n if A[i] >= B[i] then Break;\n if mark[i,j] and (A[j] > B[j]) then\n Work(j,i,Min(A[j]-B[j],B[i]-A[i]));\n end;\n for i:=1 to n do\n if A[i] <> B[i] then\n begin\n writeln('NO');\n Halt;\n end;\n writeln(dem);\n for i:=1 to dem do\n writeln(x[i],' ',y[i],' ',z[i]);\n End;\nProcedure Finish;\n Begin\n close(input);\n close(output);\n End;\nBegin\n Start;\n Programe;\n Finish;\nEnd.\n", "src_uid": "0939354d9bad8301efb79a1a934ded30"} {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\nn,m,d,k,i,o:integer;\nbegin\nread(n,m);\nd:=(n*(n+1))div 2;\nm:=m mod d;\ni:=1;\nwhile i*(i+1)div 2<=m do\nbegin\ninc(i);\nend;\nwriteln(m-i*(i-1)div 2);\nread(i);\nend.\n ", "src_uid": "5dd5ee90606d37cae5926eb8b8d250bb"} {"source_code": "var\ni,j,k,m,n:longint;\ns:ansistring;\nbegin\n readln(m);\n readln(s);\n for i:=1 to length(s) do\n if (s[i]<>'4')and(s[i]<>'7')then begin n:=1;break; end;\n if n=1 then\n begin\n writeln('NO');\n exit;\n end\n else\n begin\n for i:=1 to m div 2 do\n begin\n val(s[i],n);\n k:=n+k;\n end;\n for i:=m div 2+1 to m do\n begin\n val(s[i],n);\n j:=j+n;\n end;\n if j=k then writeln('YES')\n else writeln('NO');\n end;\nend.\n", "src_uid": "435b6d48f99d90caab828049a2c9e2a7"} {"source_code": "var s:string;\na,b,c:integer;\n\nbegin\nreadln(s);\ncase s[1] of\n'0': a:=2;\n'1': a:=7;\n'2': a:=2;\n'3': a:=3;\n'4': a:=3;\n'5': a:=4;\n'6': a:=2;\n'7': a:=5;\n'8': a:=1;\n'9': a:=2;\nend;\ncase s[2] of\n'0': b:=2;\n'1': b:=7;\n'2': b:=2;\n'3': b:=3;\n'4': b:=3;\n'5': b:=4;\n'6': b:=2;\n'7': b:=5;\n'8': b:=1;\n'9': b:=2;\nend;\nc:=a*b;\nwriteln(c);\nend.", "src_uid": "76c8bfa6789db8364a8ece0574cd31f5"} {"source_code": "var x:longint;\nbegin\n readln(x);\n case x and 3 of\n 0:writeln('1 A');\n 1:writeln('0 A');\n 2:writeln('1 B');\n 3:writeln('2 A');\n end;\nend.", "src_uid": "488e809bd0c55531b0b47f577996627e"} {"source_code": "program feda;\n\nvar s,t:string;\ni,j,size:integer;\n\n\nbegin\nreadln(s);\nreadln(t);\nsize:= length(s);\n\nwhile s[size] = 'z' do begin\ns[size] := 'a';\nsize:=size-1;\nend;\n\n\ns[size]:=succ(s[size]);\n \nif s <> t then writeln(s)\nelse writeln('No such string');\n\nend.", "src_uid": "47618510d2a17b1cc1e6a688201d51a3"} {"source_code": "program Shablon;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar\n d : array[0..800000] of int64;\n t, nok, a, b, ans : int64;\n w, i, j, k : integer;\n\n\nfunction nod(a, b : int64):int64;\nvar\n r : int64;\nbegin\n while b > 0 do begin\n r := a mod b;\n a := b;\n b := r;\n end;\n result := a;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n {$ENDIF}\n read(a, b, k);\n nok := 1;\n for i := 2 to k do begin\n nok := (i * nok) div (nod(i, nok));\n end;\n d[0] := 0;\n d[1] := 1;\n for i := 1 to 2*nok do begin\n d[i] := maxlongint;\n end;\n if a - b <= nok then begin\n if a mod nok < b mod nok then\n w := nok else\n w := 0;\n d[a mod nok + w] := 0;\n for i := a mod nok + w downto b mod nok do begin\n if i > 0 then\n d[i - 1] := min(d[i - 1], d[i] + 1);\n for j := 2 to k do\n if i mod j <= i then\n d[i - i mod j] := min(d[i - i mod j], d[i] + 1);\n\n end;\n write(d[b mod nok]);\n halt;\n end;\n for i := 0 to nok - 1 do begin\n d[i + 1] := min(d[i + 1], d[i] + 1);\n for j := 2 to k do begin\n if (i mod j = 0) then\n for w := 1 to j - 1 do\n if i + w < nok then\n d[i + w] := min(d[i + w], d[i] + 1);\n end;\n end;\n\n t := a div nok - b div nok;\n ans := d[a mod nok] + t + (t - 1) * d[nok - 1];\n d[nok - 1] := 0;\n for i := 0 to nok - 2 do\n d[i] := maxlongint;\n for i := nok - 1 downto 1 do begin\n d[i - 1] := min(d[i - 1], d[i] + 1);\n for j := 2 to k do begin\n if i mod j <= i then\n d[i - i mod j] := min(d[i - i mod j], d[i] + 1);\n end;\n end;\n ans := ans + d[b mod nok];\n\n write(ans);\nend.\n", "src_uid": "bd599d76c83cc1f30c1349ffb51b4273"} {"source_code": "var\nb,w,i,j:integer;\nc:string;\nbegin\nfor j:=1 to 8 do\nbegin\nreadln(c);\nfor i:=1 to length(c) do\nbegin\nif(c[i]='Q')then w:=w+9;\nif(c[i]='R')then w:=w+5;\nif(c[i]='P')then w:=w+1;\nif(c[i]='B') or (c[i]='N')then w:=w+3;\nif(c[i]='q')then b:=b+9;\nif(c[i]='r')then b:=b+5;\nif(c[i]='p')then b:=b+1;\nif(c[i]='b') or (c[i]='n')then b:=b+3;\nend;\nend;\nif(b>w)then writeln('Black');\nif(w>b)then writeln('White');\nif(b=w)then writeln('Draw');\nend.\n", "src_uid": "44bed0ca7a8fb42fb72c1584d39a4442"} {"source_code": "var\n n,m:int64;\n\nbegin\n read(n,m);\n if (n=1)or(m=1)then begin\n writeln(n+m-1);\n exit;\n end;\n if (n=2)or(m=2)then begin\n n:=(n+m-2);\n if ((n-1)mod 4=0)then writeln(n+1) else writeln(n+((4-(n mod 4))mod 4));\n exit;\n end;\n writeln((n*m+1) div 2);\nend.", "src_uid": "e858e7f22d91aaadd7a48a174d7b2dc9"} {"source_code": "var i,n:byte;\nres:longint;\n s:string;\nprocedure xuli2(j:byte);\nbegin\n while (j<=n) do\n begin\n if (s[j]='Q') then inc(res);\n inc(j);\n end;\nend;\n\nprocedure xuli1(j:byte);\nbegin\n while (j<=n) do\n begin\n if (s[j]='A') then\n xuli2(j+1);\n inc(j);\n end;\nend;\n\nbegin\n readln(S);\n n:=length(S);\n i:=1;\n res:=0;\n while (i<=n) do\n begin\n if (s[i]='Q') then xuli1(i+1);\n inc(i);\n end;\n writeln(res);\n readln;\nend.\n", "src_uid": "8aef4947322438664bd8610632fe0947"} {"source_code": "program Codecr;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\ns:array[1..12] of string;\nk:array[1..1000] of string;\na,i,n,j,l,m,b:longint;\nc:string;\nbegin\ns[1]:='January';\ns[2]:='February';\ns[3]:='March';\ns[4]:='April';\ns[5]:='May';\ns[6]:='June';\ns[7]:='July';\ns[8]:='August';\ns[9]:='September';\ns[10]:='October';\ns[11]:='November';\ns[12]:='December';\nreadln(c); read(n); j:=0; l:=0;\nfor i:=1 to 12 do\nbegin\nif(c=s[i]) then l:=i;\nend;\nfor i:=l to l+12 do\nbegin\nif (i<=12) then k[i]:=s[i];\nif (i>12) then k[i]:=s[i-12];\nend;\nfor i:=1 to l+12 do\nbegin\nk[i]:=k[i+l-1];\nend;\na:=n;\nif (n>12) then\nfor i:=1 to a div 12 do\nbegin\nn:=n-12;\nend;\n\nfor i:=1 to n+1 do\nbegin\nc:=k[i];\nend;\nwrite(c);\nend.\n ", "src_uid": "a307b402b20554ce177a73db07170691"} {"source_code": "const\n rp=1000000007;\ntype\n martix=array[0..84,0..84] of int64;\nvar\n k,i,j,m:longint;\n a,b,c:martix;\n n:int64;\n\nfunction times(a,b:martix;x,y,z:longint):martix;\nvar\n c:martix;\n i,j,k:longint;\nbegin\n for i:=1 to x do\n for j:=1 to y do\n begin\n c[i,j]:=0;\n for k:=1 to z do\n c[i,j]:=(c[i,j]+a[i,k]*b[k,j]) mod rp;\n end;\n exit(c);\nend;\n\nbegin {main}\n readln(n,k);\n for i:=0 to k do\n begin\n c[i,0]:=1;c[i,i]:=1;\n for j:=1 to i-1 do c[i,j]:=c[i-1,j]+c[i-1,j-1];\n end;\n m:=2*(k+1)+1;\n b[1,1]:=1;b[m,1]:=1;\n for i:=0 to k do\n for j:=0 to i do\n begin\n b[j+k+3,i+2]:=c[i,j];b[j+2,i+k+3]:=c[i,j];b[j+k+3,i+k+3]:=c[i,j];\n end;\n a[1,0]:=0;for i:=2 to m do a[1,i]:=1;\n while n<>0 do\n begin\n if n mod 2=1 then a:=times(a,b,1,m,m);\n b:=times(b,b,m,m,m);\n n:=n div 2;\n end;\n writeln(a[1,1]);\nend.\n\n", "src_uid": "14f50a111db268182e5927839a993118"} {"source_code": "uses math;\nvar x1,x2,y1,y2,n:int64;\n\nbegin\n readln(x1,y1,x2,y2);\n n:=abs(x1-x2);\n writeln(((n div 2)+1) * ((abs(y1 - y2) div 2) + 1) + (n div 2) * (abs(y1 - y2) div 2))\n {if n mod 4 = 2 \n then\n writeln(((n div 4) - 1) * 3 + ((n div 4) - 1) * 2)\n else\n writeln((n div 4) * 3 + ((n div 4) - 1) * 2);}\nend.", "src_uid": "00cffd273df24d1676acbbfd9a39630d"} {"source_code": "var\n p,q,res,count,now,d,num:int64;\nFunction Snt(gt:int64):boolean;\nvar iv:Longint;\nbegin\n if gt<=1 then exit(false);\n for iv:=2 to trunc(sqrt(gt)) do\n if gt mod iv=0 then exit(false);\n exit(true);\nend;\nFunction Pali(x:int64):boolean;\nvar ee:string;\n i:longint;\nbegin\n if x=0 then exit(false);\n str(x,ee);\n for i:=1 to length(ee) shr 1 do\n if ee[i]<>ee[length(ee)-i+1] then exit(false);\n exit(true);\nend;\nbegin\n\n readln(p,q);\n count:=0;\n num:=0;\n now:=0;\n d:=0;\n Res:=-1;\n repeat\n if pali(num) then inc(now);\n if snt(num) then inc(count);\n If q*count<=p*now then res:=num;\n inc(num);\n\n Until count>44*now;\n\n If res=-1 then writeln('Palindromic tree is better than splay tree')\n else writeln(res);\n\nend.\n", "src_uid": "e6e760164882b9e194a17663625be27d"} {"source_code": "var n,m,i,k,l1,l2,l3,p:int32;\na:array[1..1100] of int32;\nbegin\n\nread(n);\nfor i:=1 to n do\n read(a[i]);\n l1:=1;\n l2:=1;\nfor i:=1 to n do\n begin\n if ((l3=0) and (a[i]=3)) or ((l2=0) and (a[i]=2)) or ((l1=0) and (a[i]=1)) then p:=1;\n if a[i]=1 then\n begin\n if l2=0 then\n begin\n l2:=1;\n l3:=0;\n end\n else\n begin\n l3:=1;\n l2:=0;\n end;\n end;\n if a[i]=2 then\n begin\n if l1=0 then\n begin\n l1:=1;\n l3:=0;\n end\n else\n begin\n l3:=1;\n l1:=0;\n end;\n end;\n if a[i]=3 then\n begin\n if l2=0 then\n begin\n l2:=1;\n l1:=0;\n end\n else\n begin\n l1:=1;\n l2:=0;\n end;\n end;\n\n\n end;\n if p=1 then write('NO') else write ('YES');\nend.\n\n", "src_uid": "6c7ab07abdf157c24be92f49fd1d8d87"} {"source_code": "var\n T,S,q,ans:Longint;\nbegin\n Readln(T,S,q);\n while S0 then begin\n l:=min(a,b);\n dec(n);\n end;\n inc(l,n*( min( c,min(a,b) ) ));\n writeln(l);\nend.\n", "src_uid": "6058529f0144c853e9e17ed7c661fc50"} {"source_code": "var\n S,S1:String;\n kol,Ans,i,N:Longint;\n A,maxkol,answer:array ['A'..'T'] of Longint;\nbegin\n Readln(S);\n kol:=1;\n N:=Length(S);\n S:=S+' ';\n for i:=2 to N+1 do\n if S[i]=S[i-1] then Inc(kol)\n else begin\n if kol mod 2=0 then begin\n Inc(Ans);\n end;\n kol:=1;\n end;\n Writeln(Ans);\n end.", "src_uid": "8b26ca1ca2b28166c3d25dceb1f3d49f"} {"source_code": "const\n fin='680A.inp';fon='680A.out';\nvar i,a,s,m:longint;\n d:array[0..10000] of longint;\n\nfunction max(t,u:longint):longint;\nbegin\nif ut then exit(t);\nexit(u);\nend;\n\nprocedure mo;\nbegin\nassign(input,fin);reset(input);\nassign(output,fon);rewrite(output);\nend;\n\nprocedure solve;\nbegin\ns:=0;\nfor i:=1 to 5 do\n begin\n read(a);\n s:=s+a;\n inc(d[a]);\n if d[a]>1 then\n begin\n m:=max(m,a*min(3,d[a]));\n end;\n end;\nwriteln(s-m);\nend;\n\nbegin\n//mo;\nsolve;\nend.\n", "src_uid": "a9c17ce5fd5f39ffd70917127ce3408a"} {"source_code": "{$mode objfpc}\n//basic geometry defination\nconst inf=1e30;\n\teps=1e-10;\ntype\tfloat=extended;\n\tpoint=object\n\t\t\tx,y:float;\n\t\t\tfunction length():float;\n\t\t\tfunction sqrlen():float;\n\t\t\tfunction zoom(const l:float):point;\n\t\t\tfunction vtl():point;\n\t\tend;\n\tline=\tobject\n\t\t\ta,b:point;\n function online(const p:point):boolean;\n function intersect(const s:line):longint;\n\t\tend;\n\tfunction sgn(const x:float):longint; begin if abs(x)0 then exit(1) else exit(-1); end;\n\tfunction fsqrt(const x:float):float; begin if abs(x)n then exit;\n inc(ans);\n q:=0;\n for i:=1 to 10 do\n if pos(r[i],s)<>0 then inc(q);\n if q=1 then\n begin\n for c:='0' to '9' do\n rec(s+c);\n end else\n begin\n for i:=1 to 10 do\n if pos(r[i],s)<>0 then\n rec(s+r[i]);\n end;\n end;\n\n\nbegin\n{assign(input,'input.txt');reset(input);\nassign(output,'output.txt');rewrite(output); }\nreadln(n);\nr:='0123456789';\nfor i:=1 to 9 do\n begin\n x:=i;\n rec(chr(x+48));\n end;\nwriteln(ans);\nend.\n\n", "src_uid": "0f7f10557602c8c2f2eb80762709ffc4"} {"source_code": "var a:array[0..30] of int64;\na1,a2,a3,i:longint;\nbegin\n read(a1,a2,a3);\n a[0]:=a1;\n a[1]:=a2;\n for i:=2 to a3 do\n a[i]:=a[i-1]+a[i-2];\n writeln(a[a3]);\nend. ", "src_uid": "6ff30f5a9afc3f7befca813469188aab"} {"source_code": "var a,b:array[1..505000] of longint;\nn,i,beg1,beg2,k1,k2,k,aa,bb:longint;\n\nprocedure put1(t:longint);\nbegin\n inc(k1);\n a[k1]:=t;\nend;\n\nprocedure put2(t:longint);\nbegin\n inc(k2);\n b[k2]:=t;\nend;\n\nprocedure give1(var t:longint);\nbegin\n inc(beg1);\n t:=a[beg1];\nend;\n\nprocedure give2(var t:longint);\nbegin\n inc(beg2);\n t:=b[beg2];\nend;\n\nbegin\nreadln(n);\nread(k1);\nfor i:=1 to k1 do\n read(a[i]);\nread(k2);\nfor i:=1 to k2 do\n read(b[i]);\nwhile (beg1<>k1) and (beg2<>k2) do\n begin\n inc(k);\n give1(aa);\n give2(bb);\n if aa>bb then begin put1(bb);put1(aa); end\n else begin put2(aa);put2(bb); end;\n if k=500000 then begin writeln(-1); exit; end;\n end;\nwrite(k,' ');\nif beg1=k1 then writeln(2)\n else writeln(1);\nend.", "src_uid": "f587b1867754e6958c3d7e0fe368ec6e"} {"source_code": "const fi='991B.inp'; fo='991B.out';\nvar n,res,sum,i:longint;\n a:array[0..101] of longint;\nprocedure QS(l,r:longint);\nvar i,j,g,tam: longint;\nbegin\n i:=l; j:=r; g:=a[(l+r)>>1];\n repeat\n while a[i]g do dec(j);\n if i<=j then\n begin\n tam:=a[i]; a[i]:=a[j]; a[j]:=tam;\n inc(i); dec(j);\n end;\n until i>j;\n if il then QS(l,j);\nend;\nbegin\n // assign(input,fi); reset(input);\n // assign(output,fo); rewrite(output);\n readln(n);\n for i:=1 to n do begin\n read(a[i]);\n sum:=sum+a[i];\n end;\n QS(1,n);\n res:=1;\n while sum*10 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\nprocedure panic;\nbegin\n writeln(-1);\n halt(0);\nend;\n\nvar\n n, m, k, g: integer;\n ans, v, s: int64;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n reset(input, 'input.txt');\n rewrite(output, 'output.txt');\n {$ENDIF}\n readln(n, m, g);\n ans := 0;\n if m = 0 then\n begin\n writeln(g xor (n mod 2));\n halt(0);\n end;\n m := m - 1;\n if m = 0 then\n begin\n if g = 0 then ans := (n + 1) div 2 else ans := n div 2;\n if (n + 1) mod 2 = g then inc(ans);\n writeln(ans);\n halt(0);\n end;\n k := (n + g) mod 2;\n if k = 0 then s := 1 else s := m + 1;\n while n >= k do\n begin\n ans := ans + s;\n v := (k + m + 2);\n v := v * (v - 1) mod base;\n s := (s * v) mod base;\n v := k + 2;\n v := v * (k + 1) mod base;\n v := sqrr(v, base - 2);\n s := (s * v) mod base;\n k := k + 2;\n end;\n writeln(ans mod base);\nend.", "src_uid": "066dd9e6091238edf2912a6af4d29e7f"} {"source_code": "var\n\nx,y,i,Her,Posi,Her_l,val_i,Err,k:integer;\nn,val_s:string;\na:array[1..3,1..3] of integer;\nVal_val:array[0..4,0..4] of integer;\nbegin\n for x:= 1 to 3 do\n begin \n Readln (n);\n for y:= 1 to 3 do\n begin\n if y = 3 then\n begin\n val(n,val_i,Err);\n a[x,y]:= val_i;\n Val_val[x,y]:= 1;\n end\n else\n begin\n Her:= length(n);\n Posi:=pos(' ',n);\n Her_l:= Her - Posi;\n Her_l:= Her - Her_l - 1;\n val_s:= Copy(n,1,Her_l);\n val(val_s,val_i,Err);\n \n Delete(n,1,Her_l+1);\n a[x,y]:= val_i;\n Val_val[x,y]:= 1;\n end;\n end;\n end;\n For x:= 1 to 3 do\n begin\n for y:= 1 to 3 do\n begin\n for k:= 1 to a[x,y] do\n begin\n if ((a[x,y]<>0) or (a[x,y] mod 2 <> 0)) then\n begin\n if Val_val[x,y] = 0 then \n begin\n Val_val[x,y]:= 1;\n if Val_val[x+1,y] = 0 then\n begin\n Val_val[x+1,y]:= 1;\n end\n else Val_val[x+1,y]:= 0;\n if Val_val[x-1,y] = 0 then\n begin\n Val_val[x-1,y]:= 1; \n //1 0 1\n // 8 8 8\n //2 0 3\n end\n else Val_val[x-1,y]:= 0;\n \n if Val_val[x,y+1] = 0 then\n begin\n Val_val[x,y+1]:= 1;\n end\n else Val_val[x,y+1]:= 0;\n if Val_val[x,y-1] = 0 then\n begin\n Val_val[x,y-1]:= 1;\n end\n else Val_val[x,y-1]:= 0;\n \n end\n else \n begin\n Val_val[x,y]:= 0;\n if Val_val[x+1,y] = 0 then\n begin\n Val_val[x+1,y]:= 1;\n end\n else Val_val[x+1,y]:= 0;\n if Val_val[x-1,y] = 0 then\n begin\n Val_val[x-1,y]:= 1;\n end\n else Val_val[x-1,y]:= 0;\n \n if Val_val[x,y+1] = 0 then\n begin\n Val_val[x,y+1]:= 1;\n end\n else Val_val[x,y+1]:= 0;\n if Val_val[x,y-1] = 0 then\n begin\n Val_val[x,y-1]:= 1;\n end\n else Val_val[x,y-1]:= 0;\n end;\n end;\n \n \n \n end;\n end;\n end;\n \n \n for x:= 1 to 3 do\n begin\n for y:= 1 to 3 do\n begin\n write (Val_val[x,y]);\n end;\n writeln(' ');\n end;\n \nend.", "src_uid": "b045abf40c75bb66a80fd6148ecc5bd6"} {"source_code": "var\ncnk:array[0..123,0..123]of int64;\nres,n,t,c,ans:int64;\ni,j:longint;\nfunction get(n,c:int64):int64;\nvar\np,i:longint;\ns:string;\nbegin\n s:='';\n while n>0 do\n begin\n s:=chr(n mod 2+48)+s;\n n:=n div 2;\n end;\n p:=0; res:=0;\n for i:=1 to length(s) do\n begin\n if s[i]='0' then continue;\n res:=res+cnk[length(s)-i,c-p];\n if s[i]='1' then inc(p);\n if p>c then break;\n end;\n if p=c then inc(res);\n get:=res;\nend;\n begin\n readln(n,t);\n c:=1;\n for i:=0 to 60 do\n cnk[i,0]:=1;\n for i:=1 to 60 do\n for j:=1 to 60 do\n cnk[i,j]:=(cnk[i-1,j-1]+cnk[i-1,j]) mod 1000000000000000;\n while t mod 2=0 do\n begin\n t:=t div 2;\n inc(c);\n end;\n if t<>1 then\n begin\n writeln(0);\n halt(0);\n end;\n ans:=get(n+1,c);\n if (c=1) then ans:=ans-1;\n writeln(ans);\n end.\n", "src_uid": "727d5b601694e5e0f0cf3a9ca25323fc"} {"source_code": "var a,b:array[0..300]of int64;i,n,l,r:longint;\nbegin\n read(n,l,r);\n a[1]:=1;b[1]:=1;\n for i:=2 to 20 do\n begin\n a[i]:=a[i-1]*2;\n b[i]:=b[i-1]+a[i];\n end;\n write(b[l]+n-l,' ',b[r]+a[r]*(n-r));\nend.", "src_uid": "ce220726392fb0cacf0ec44a7490084a"} {"source_code": "var\n a,b,k,i,n: longint;\n p: array[1..55555] of longint;\nfunction ok(a: longint): boolean;\nvar i: longint;\n begin\n i:=2;\n while int64(i)*(i) <= a do begin\n if a mod i=0 then exit(false);\n inc(i);\n end;\n exit(true);\n end;\nfunction kq(a,n: longint): longint;\nvar res,i: longint;\n begin\n if (n=0) or (a b then begin\n if (a<=k) and (k<=b) then writeln(1)\n else writeln(0);\n close(output);\n halt;\n end;\n for i:=2 to k do\n if ok(i) then\n begin\n inc(n);\n p[n]:=i;\n end;\n writeln(kq(b,n)-kq(a-1,n));\n close(output);\nend.\n", "src_uid": "04a26f1d1013b6e6b4b0bdcf225475f2"} {"source_code": " uses strutils;\n const eps=1e-13;\n besk=2000000000000000000; label 4,1,3,2,44,22;\n type mas=array[-200000..2600000+1] of int64;\n integer=longint; zap=record x,y,z:int64; end;\n zap1=^zap;\n var oldpos,kolvzv,sdvig,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto:longint;\n oldss,smin,ss3,ss,ss1,ss2:string;\n newaans,aans:zap;\n pqqq:zap;\n otal,al1,al2,acc, disk,xxx,yyy,prop,bet,al:extended; fl1,fl2,fl:boolean;\n dr3,dr1,dr2,pt,ott1,ott2:zap;\n pointx,pointy,vel,tt1,tt2,shag,radius,ote,ddl,dl1,dl2:extended;\n\n x,y,ansx,ansy,ugol,xx,yy:array[-100..500000] of int64;\n det,detx,dety,ii,jj,kk,dl,iii,jjj,aaa,bbb,ccc,bb,aa,ot,p0,t,pos,xmax,xmin,ymax,ymin,newpos,newdl,len,pp3,ans1,ans2,modul,t0,t1,t2,dloch,koldel,mmax,nap,stepen,pq,pp1,pp2,period, dolg,ot1,ot2,oldgr,predsum,pmin,tmin,kool,number,imin,qq,kol,n,m,ttt,numpos,vx,vy,ans,up,down,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,n1,q,p:int64; flag1:boolean;\n chisl,znam,zzz,fact,z,stan,a2,invx,invy,summ,place,str,b2,z1,sum1,sum0,d0,d1,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n ot3,izb, sum,oldmax,newmax,posmax,zapas,razn,oldll,oldrr,ppp,posx,posy,minx,miny,maxx,maxy,kolplus,kolminus,razr,jmax,gr,grr,ener,dob,cc,dist,ugg,r,ug:int64;\n zan:array[-10..1001,-10..1001] of boolean;\n new,zan2,zan1,prost,marked:array[-10000..11000000] of boolean;\n left,right,newoch,d2,och, num,start,finish,zz,ll,rr,path,lx,a3,b3,predok,a1,b1:array[-200000..955000] of int64;\n dd,koldelit,delit:array[-400..1200,-400..1200] of int64;\n ppole1,ppole2,ppole:array[-100..300,-10..300] of char;\n bufer, str1,str2,stroka:array[-1000..1000000] of char;\n dinam:array[-100000..1000000] of extended;\n cosa,sina,cosb,sinb,rx,ry,px,py,h1,h2,h,l1,l2,otmax,v:int64;\n sss1,sss2,sp,sss:array[-10..110000] of string;\n newpole,pole:array[-1..1100,-1..1100] of char;\n sumstr,sumstolb,nomerpole:array[-1..1100,-1..1100] of longint;\n verch,verzn:array[-10..1100000] of int64;\n ddmax,dd1,dd2,ddinv:array[-2..1100000] of int64;\n zzan:array[-1..1200000] of boolean;\n obmen,ch:char;\n ff,flagg1:boolean;\n newleft,newright,pred,oldx,oldy,numx,numy,xleft,xright,s,znach,newplace,newstr,next,prev,aold:array[-100000..1700002] 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 a2[i]y[i] then fl:=false;\n sovp:=fl;\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(gr,n);\n if n=1 then begin writeln(gr); goto 1; end;\n modul:=998244353;\n fact[0]:=1; for i:=1 to 600000 do fact[i]:=fact[i-1]*i mod modul;\n\n for i:=1 to gr shr 1 do\n begin\n p:=gr div i;\n { writeln(bincoef(p-1,n-1));\n } ot:=(ot+bincoef(p-1,n-1)) mod modul;\n\n end;\n\n writeln(ot);\n\n goto 1;\n\n readln(p); otal:=1e+10;\n for i:=1 to p do read(x[i],y[i],xx[i],yy[i],z[i]);\n for i:=1 to p do for j:=i+1 to p do\n begin\n\n if xx[i]*yy[j]=xx[j]*yy[i] then\n begin\n if ((y[j]-y[i])*xx[i]=(x[j]-x[i])*yy[i]) and (xx[i]*(x[j]-x[i])>=0) then\n begin\n al:=xx[i]*xx[i]+yy[i]*yy[i];\n al:=sqrt(al);\n bet:=xx[i]/al*z[i];\n al1:=(x[j]-x[i])/bet;\n { writeln('var 1 t1= ',al1:0:5);\n } otal:=min(otal,al1);\n end;\n\n if ((y[i]-y[j])*xx[j]=(x[i]-x[j])*yy[j]) and (xx[j]*(x[i]-x[j])>=0) then\n begin\n al:=xx[j]*xx[j]+yy[j]*yy[j];\n al:=sqrt(al);\n bet:=xx[j]/al*z[j];\n al1:=(x[i]-x[j])/bet;\n { writeln('var 2 t1= ',al1:0:5);\n } otal:=min(otal,al2);\n\n end;\n { writeln('i= ',i,' j= ',j,' ot= ',otal:0:3);\n } end;\n\n p1:=yy[i]; p2:=-xx[i]; p3:=-(-x[i]*yy[i]+y[i]*xx[i]);\n pp1:=yy[j]; pp2:=-xx[j]; pp3:=-(-x[j]*yy[j]+y[j]*xx[j]);\n\n { writeln(p1,' ',p2,' ',p3);\n writeln(pp1,' ',pp2,' ',pp3);\n } det:=p1*pp2-p2*pp1;\n detx:=p3*pp2-p2*pp3;\n dety:=p1*pp3-p3*pp1;\n\n if det=0 then goto 2;\n pointx:=detx/det;\n pointy:=dety/det;\n { writeln(pointx:0:3,' ',pointy:0:3);\n } al:=xx[i]*xx[i]+yy[i]*yy[i];\n al:=sqrt(al);\n bet:=xx[i]/al*z[i];\n al1:=(pointx-x[i])/bet;\n { writeln('t1= ',al1:0:5);\n } al:=xx[j]*xx[j]+yy[j]*yy[j];\n al:=sqrt(al);\n bet:=xx[j]/al*z[j];\n { writeln('dx= ',bet:0:4);\n } al2:=(pointx-x[j])/bet;\n { writeln('t2= ',al2:0:5);\n } if (al1>-eps)and(al2>-eps) then bet:=max(al1,al2) else bet:=1e+10;\n otal:=min(otal,bet);\n { writeln('i= ',i,' j= ',j,' ot= ',otal:0:3);\n }\n\n\n2:\n end;\n\n if otal<1e+8 then writeln(otal:0:8) else writeln('No show :(');\n\n\n\n 1: close (output);\n end.\n\n\n\n\n\n", "src_uid": "8e8eb64a047cb970a549ee870c3d280d"} {"source_code": "program cf150b;\nconst mode=1000000007;\nvar\n n,m,k,i:longint;\n ans:int64;\nbegin\n readln(n,m,k);\n if (k=1)or(k>n) then begin\n ans:=1;\n for i:=1 to n do ans:=ans * m mod mode;\n writeln(ans);\n halt;\n end;\n\n if m=1 then begin\n writeln(1);\n halt;\n end;\n\n if k=n then begin\n ans:=1;\n for i:=1 to (n+1) shr 1 do\n ans:=ans*m mod mode;\n writeln(ans);\n halt;\n end;\n\n\n if not(odd(k)) then begin\n writeln(m mod mode);\n\n end else begin\n if n=1 then writeln(m) else\n writeln(m*m mod mode);\n end;\nend.\n\n", "src_uid": "1f9107e8d1d8aebb1f4a1707a6cdeb6d"} {"source_code": "program _28E_DravDe_Saves_theWorld;\n\ntype vertex=record x,y:extended; inw:boolean; end;\n \t vector=record x,y,z:extended; end;\n\t line=record a,b,c:extended; end;\n\nconst tiny=1e-9;\n\nvar f:array[1..20000]of vertex;\n\tOA,OB,OC,OW,w,FF:vector;\n\tlOA,lOB,lFF:line;\n\ta,itc:vertex;\n\tft1,ft2,t1,t2,t3,vdown,k:extended;\n\tn,i,j,dk,n0:longint;\n find:boolean;\n\nfunction makeline(v:vector; p:vertex):line;\nvar t:line;\nbegin\n\tt.a:=-v.y;\n\tt.b:=v.x;\n\tt.c:=-t.a*p.x-t.b*p.y;\n exit(t);\nend;\n\nfunction hand(b,a:vector):longint;\nvar t:extended;\nbegin\n\tt:=a.x*b.y-a.y*b.x;\n\tif t>tiny then exit(1);\n\tif t<-tiny then exit(-1);\n\texit(0);\nend;\n\nfunction intersect(l1,l2:line):vertex;\nvar t:vertex;\nbegin\n\tif abs(l1.a*l2.b-l1.b*l2.a)0 then exit(true);\n\tif a.y*b.y>0 then exit(true);\n\tif a.x*b.x+a.y*b.y=0 then exit(true);\n\texit(false);\nend;\n\nfunction qs(a,b:vector):extended;\nbegin\n\tif a.x*b.x=0 then exit(a.y/b.y);\n\texit(a.x/b.x);\nend;\n\nbegin\n\t//assign(input,'28EDravDe.txt');reset(input);\n\treadln(n);\n\tfor i:=1 to n do readln(f[i].x,f[i].y);\n\tf[n+1]:=f[1];\n\treadln(a.x,a.y);\n\treadln(OA.x,OA.y,OA.z);\n\treadln(vdown);\n\treadln(w.x,w.y,w.z);\n k:=OA.z/-w.z;\n\tOW.x:=w.x*k;\n\tOW.y:=w.y*k;\n\tOB.x:=OA.x+OW.x;\n\tOB.y:=OA.y+OW.y;\n if (OB.x=0)and(OB.y=0) then OB:=OA;\n\tif (OA.x=0)and(OA.y=0) then OA:=OB;\n\tif (OA.x=0)and(OA.y=0) then begin writeln('-1 -1');halt; end;\n\tlOA:=makeline(OA,a);\n\tlOB:=makeline(OB,a);\n\t\n\tn0:=n+1;\n\tfor i:=1 to n do begin\n\t\tFF.x:=f[i].x-f[i+1].x;\n\t\tFF.y:=f[i].y-f[i+1].y;\n\t\tlFF:=makeline(FF,f[i]);\n\t\titc:=intersect(lOA,lFF);\n\t\tif (itc.x<>1e10)and(doton(itc,f[i],f[i+1])) then begin\n\t\t\tinc(n0); f[n0]:=itc;\n\t\tend;\n\t\titc:=intersect(lOB,lFF);\n\t\tif (itc.x<>1e10)and(doton(itc,f[i],f[i+1])) then begin\n\t\t\tinc(n0); f[n0]:=itc;\n\t\tend;\n\tend;\n\n\tif hand(OA,OB)=1 then dk:=1 else dk:=-1;\n\tfor i:=1 to n0 do begin\n\t\tOC.x:=f[i].x-a.x; OC.y:=f[i].y-a.y;\n\t\tif (dk*hand(OA,OC)>=0)and(dk*hand(OC,OB)>=0) then f[i].inw:=true\n else f[i].inw:=false;\n\tend;\n\n\tft1:=1e10; ft2:=1e10; find:=false;\n\tfor i:=1 to n0 do if f[i].inw then begin\n\t\tOC.x:=f[i].x-a.x; OC.y:=f[i].y-a.y;\n if abs(OA.x*w.y-OA.y*w.x)-tiny) then begin\n\t\t\tft1:=t1; ft2:=t2;\n find:=true;\n\t\tend else if (abs(t1-ft1)-tiny) then\n\t\t\tif t2k then write(' ') else\n if i=k then writeln;\nend;\n\nbegin\n readln(k,n,m);\n for i:=1 to n do\n begin\n read(z);\n f1[z]:=true;\n end;\n readln;\n for i:=1 to m do\n begin\n read(z);\n f2[z]:=true;\n end;\n for i:=1 to k do check(i);\nend.", "src_uid": "a35a27754c9c095c6f1b2d4adccbfe93"} {"source_code": "const fi='';\n fo='';\nvar f:text;\na:array[0..1000]of integer;\ni,j,s,n:longint;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n);\n for i:=1 to n do\n read(f,a[i]);\n\n\n //1~tron\n //2~tam giac\n //3~vuong\n for i:=1 to n-1 do\n begin\n if a[i]+a[i+1]=3 then\n begin\n s:=s+3;\n if a[i]+a[i-1]=4 then dec(s);\n end;\n if a[i]+a[i+1]=4 then s:=s+4;\n if a[i]+a[i+1]=5 then\n begin\n close(f);\n\n assign(f,fo);\n rewrite(f);\n write(f,'Infinite');\n close(f);\n exit;\n end;\n end;\n close(f);\n\n assign(f,fo);\n rewrite(f);\n writeln(f,'Finite');\n writeln(f,s);\n close(f);\nend.", "src_uid": "6c8f028f655cc77b05ed89a668273702"} {"source_code": "var n,i:int64;\nbegin\nread(n);\ni:=2;\nwhile i<=round(sqrt(n)) do\n begin\n while (n mod sqr(i)=0) do\n begin\n n:=n div i;\n end;\n i:=i+1;\n end;\nwriteln(n);\nend.\n", "src_uid": "6d0da975fa0961acfdbe75f2f29aeb92"} {"source_code": "var s:ansistring;\nn,i,ls,m,t,j:longint;\nf:array[0..20000] of longint;ff:boolean;\nbegin\n//assign(input,'mxp.in');reset(input);\n//assign(output,'mxp.out');rewrite(output);\nreadln(s);\nreadln(n);\nfor i:=1 to length(s) do\n begin\n if s[i]='?' then begin m:=m+1;f[i]:=0; end else\n if s[i]='*' then begin m:=m+1;f[i]:=0; end else\n f[i]:=1;\n end;\n\nls:=length(s)-m;t:=1;\nif ls>n then\n begin\nwhile t<=length(s) do\n begin\n if (s[t]='?') or (s[t]='*') then\n begin\n f[t-1]:=0;ls:=ls-1;\n if ls=n then break;\n end;\n t:=t+1;\n end;\nif ls>n then\n begin\n write('Impossible');\n close(input);close(output);halt;\n end;\n\n end;\nif ls12 then tam:=1;\n if tam=2 then\n begin\n if a[i]=29 then inc(dem1)\n else if (a[i]<>28) and (a[i]<>29) then\n begin\n kt:=false;\n break;\n end;\n if dem1>=2 then\n begin\n kt:=false;\n break;\n end;\n end;\n if (tam=1) or (tam=3) or (tam=5) or (tam=7) or (tam=8) or (tam=10) or (tam=12) then\n begin\n if a[i]<>31 then\n begin\n kt:=false;\n break;\n end;\n end;\n if (tam=4) or (tam=6) or (tam=9) or (tam=11) then\n begin\n if a[i]<>30 then\n begin\n kt:=false;\n break;\n end;\n end;\n inc(tam);\n end;\n if kt=true then\n begin\n writeln('YES');\n halt;\n end;\n end;\n writeln('NO');\nend;\nbegin\n // mo;\n nhap;\n xuli;\n //dong;\nend.\n\n", "src_uid": "d60c8895cebcc5d0c6459238edbdb945"} {"source_code": "var a,b,c,v,p:integer;\nbegin\nread(a,b,c);\np:=a*b*c;\nif p>v then v:=p;\n\np:=a+b*c;\nif p>v then v:=p;\n\np:=a*b+c;\nif p>v then v:=p;\n\np:=a+b+c;\nif p>v then v:=p;\n\np:=(a+b)*c;\nif p>v then v:=p;\n\np:=a*(b+c);\nif p>v then v:=p;\n\np:=a*(b*c);\nif p>v then v:=p;\n\np:=(a*b)*c;\nif p>v then v:=p;\nprintln(v);\nend.", "src_uid": "1cad9e4797ca2d80a12276b5a790ef27"} {"source_code": "var\n x : string;\n i,t,a,y,j,k,b,g : longint;\nbegin\n readln(t);\n for i:=1 to t do begin\n readln(x);\n g:=0;\n val(x[1],b,y);\n for j:=1 to length(x) do\n g:=g+j;\n writeln((b-1)*10+g);\n end;\nend.", "src_uid": "289a55128be89bb86a002d218d31b57f"} {"source_code": "var n:int64;\nbegin\n readln(n);\n n:=n+1;\n if n mod 2=0 then write(n div 2)\n else if n=1 then write(0)\n else write(n);\nend.", "src_uid": "236177ff30dafe68295b5d33dc501828"} {"source_code": "var a: array[1..100] of integer;\nka,k,ma,ke,n,j,i:integer;\nbegin\nreadln(n);\nfor i:=1 to n do\nread(a[i]);\nfor i:=1 to n do\nke:=ke+a[i];\nfor i:=1 to n do\nif a[i]>ma then ma:=a[i];\nk:=ma;\nwhile ke>=ka do begin\nka:=0;\nfor i:=1 to n do\nka:=ka+k-a[i];\nk:=k+1;\nend;\nwriteln(k-1);\n\nend.\n", "src_uid": "d215b3541d6d728ad01b166aae64faa2"} {"source_code": "var n,i,l,r:longint;\n s:string;\nbegin\n readln(n);\n readln(s);\n for i:=1 to length(s) do\n if s[i] = 'L' then inc(l)\n else inc(r);\n writeln(r--l+1);\n readln;\nend.", "src_uid": "098ade88ed90664da279fe8a5a54b5ba"} {"source_code": "var\n a,b:int64;\nbegin\n readln(a,b);\n a:=a+1;\n b:=b-1;\n writeln(a+b+0-0);\nend.", "src_uid": "b6e3f9c9b124ec3ec20eb8fcea075add"} {"source_code": "var m,p:int64;\n n,i:longint;\n a:array[-100..1000] of longint;\nbegin\nread(n,m);\np:=1; dec(m);\nwhile m>0 do begin\na[p]:=m mod 2;\nm:=m div 2;\ninc(p);\nend;\n\nfor i:=1 to n do\nif a[n-i]=0 then write(i,' ');\nfor i:=n downto 1 do\nif a[n-i]=1 then write(i,' ');\nend.", "src_uid": "a8da7cbd9ddaec8e0468c6cce884e7a2"} {"source_code": "var\n one, n, k:int64;\nbegin\none:=1;\n readln(n, k);\n if k=1 then writeln(n)\n else \n begin\n k:=0;\n while n<>0 do\n begin\n inc(k);\n n:=n div 2;\n end;\n writeln(one shl k-1);\n end;\nend.", "src_uid": "16bc089f5ef6b68bebe8eda6ead2eab9"} {"source_code": "var n,i,j,k,w:longint;\nx,y,xx,yy,a,b,c:array[0..5] of longint;\nsw:boolean;\nprocedure build(z:longint);\nbegin\nif z>=5 then\nbegin\nx[c[5]]:=x[c[1]];y[c[5]]:=y[c[1]];\nfor i:=1 to 4 do\nif (xx[c[i]]<>x[c[i+1]]) or (yy[c[i]]<>y[c[i+1]]) then exit;\nsw:=true;\nend else begin\nbuild(z+1);\nw:=x[c[z]];x[c[z]]:=xx[c[z]];xx[c[z]]:=w;\nw:=y[c[z]];y[c[z]]:=yy[c[z]];yy[c[z]]:=w;\nbuild(z+1);\nw:=x[c[z]];x[c[z]]:=xx[c[z]];xx[c[z]]:=w;\nw:=y[c[z]];y[c[z]]:=yy[c[z]];yy[c[z]]:=w;\nend;\nend;\n\nprocedure work(x1,x2,x3,x4:longint);\nbegin\nif ((a[x1]=a[x3]) or (b[x1]<>b[x3]))=false then\nif ((a[x2]=a[x4]) or (b[x2]<>b[x4]))=false then\nif b[x1]<>b[x2] then begin\nc[1]:=x1;c[2]:=x2;c[3]:=x3;c[4]:=x4;\nbuild(1);\nend;\nend;\n\nbegin\n\nsw:=true;\nfor i:=1 to 4 do\nbegin\nreadln(x[i],y[i],xx[i],yy[i]);\nif (x[i]=xx[i]) or (y[i]=yy[i]) then\nbegin\nif x[i]=xx[i] then a[i]:=x[i] else begin b[i]:=1;a[i]:=y[i];end;\nend else sw:=false;\nend;\n\nif sw then begin\nsw:=false;\nwork(1,2,3,4);work(1,3,2,4);work(1,2,4,3);\nif sw then begin writeln('YES');halt;end;\nend;\nwriteln('NO');\nend.\n", "src_uid": "ad105c08f63e9761fe90f69630628027"} {"source_code": "uses math;\nvar n,i:longint;\n fc,fg,a:array[-100..100000] of longint;\nbegin\n assign(input,''); reset(input);\n assign(output,''); rewrite(output);\n readln(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 fc[i]:=max(fg[i-1]+1,fc[i-2]+1);\n fg[i]:=max(fc[i-1],fg[i-1]);\n end;\n if a[i]=2 then \n begin\n fc[i]:=max(fg[i-1],fc[i-1]);\n fg[i]:=max(fc[i-1]+1,fg[i-2]+1);\n end;\n if a[i]=3 then\n begin\n fc[i]:=max(fg[i-1]+1,fc[i-2]+1);\n fg[i]:=max(fc[i-1]+1,fg[i-2]+1);\n end;\n if a[i]=0 then\n begin\n fg[i]:=fg[i-1];\n fc[i]:=fc[i-1];\n end;\n end;\n writeln(n-max(fc[n],fg[n]));\n close(input); close(output);\nend.", "src_uid": "08f1ba79ced688958695a7cfcfdda035"} {"source_code": "const b1:array[1..13]of char=('2','3','4','5','6','7','8','9','T','J','Q','K','A');\nb2:array[1..4]of char=('C','D','H','S');\nvar i,k,i1,k1,i2,k2,t,t1,t2,t3,n,m,ii,kk:longint;\na:array[1..20,1..20]of string;\nb:array['2'..'Z','C'..'Z']of boolean;\nc,c1,c2:char;\nh:string;\nfunction kd:longint;\nvar i,k,kol:longint;\nbegin\nkol:=0;\nfor i:=1 to n do\n for k:=1 to m do\n if a[i,k]='J1' then\n begin\n inc(kol);\n if kol=2 then\n begin\n i2:=i1;\n k2:=k1;\n i1:=i;\n k1:=k;\n // h:='J1';\n end\n else\n begin\n i1:=i;\n k1:=k;\n h:='J1';\n end;\n end\n else\n if a[i,k]='J2'then\n begin\n inc(kol);\n if kol=2 then\n begin\n i2:=i;\n k2:=k;\n end\n else\n begin\n i1:=i;\n k1:=k;\n h:='J2';\n end;\n end;\n kd:=kol;\nend;\nfunction hor(x,y,x1,y1:longint):boolean;\n var i,k,iii,kkk:longint;\n e,e1,e2,e3:boolean;\n begin\n e:=true;\n e1:=e;\n e2:=e;\n e3:=e;\n for i:=x to x+2 do\n for k:=y to y+2 do\n if a[i,k][2]<>a[x,y][2]then\n begin\n e:=false;\n break;\n end;\n for i:=x1 to x1+2 do\n for k:=y1 to y1+2 do\n if a[i,k][2]<>a[x1,y1][2]then\n begin\n e2:=false;\n break;\n end;\n if ord(e)*ord(e2)=1 then\n hor:=true\n else\n begin\n for i:=x to x+2 do\n for k:=y to y+2 do\n for iii:=x to x+2 do\n for kkk:=y to y+2 do\n if not((i=iii)and(k=kkk))then\n if a[i,k][1]=a[iii,kkk][1]then\n begin\n e1:=false;\n break;\n end;\n for i:=x1 to x1+2 do\n for k:=y1 to y1+2 do\n for iii:=x1 to x1+2 do\n for kkk:=y1 to y1+2 do\n if not((i=iii)and(k=kkk))then\n if a[i,k][1]=a[iii,kkk][1]then\n begin\n e3:=false;\n break;\n end;\n if e1 and e3 then\n hor:=true\n else\n hor:=false;\n end;\n end;\nbegin\nReadln(n,m);\nfor i:=1 to n do\n begin\n for k:=1 to m do\n begin\n Read(c,c1,c2);\n a[i,k]:=c+c1;\n if (c1<>'1')and(c1<>'2')then\n b[c,c1]:=true;\n end;\n readln;\n end;\nif kd=0 then\n begin\n for i:=1 to n-2 do\n for k:=1 to m-2 do\n for ii:=1 to n-2 do\n for kk:=1 to m-2 do\n if (ii>=i+3)or(kk>=k+3)then\n if hor(i,k,ii,kk)then\n begin\n writeln('Solution exists.');\n writeln('There are no jokers.');\n writeln('Put the first square to (',i,', ',k,').');\n write('Put the second square to (',ii,', ',kk,').');\n halt;\n end;\n end\n else\n if kd=1 then\n begin\n for t:=1 to 13 do\n for t1:=1 to 4 do\n if not b[b1[t],b2[t1]] then\n begin\n a[i1,k1]:=b1[t]+b2[t1];\n for i:=1 to n-2 do\n for k:=1 to m-2 do\n for ii:=1 to n-2 do\n for kk:=1 to m-2 do\n if (ii>=i+3)or(kk>=k+3)then\n if hor(i,k,ii,kk)then\n begin\n writeln('Solution exists.');\n writeln('Replace ',h,' with ',a[i1,k1],'.');\n writeln('Put the first square to (',i,', ',k,').');\n write('Put the second square to (',ii,', ',kk,').');\n halt;\n end;\n end;\n end\n else\n if kd=2 then\n begin\n for t:=1 to 13 do\n for t1:=1 to 4 do\n for t2:=1 to 13 do\n for t3:=1 to 4 do\n if (not b[b1[t],b2[t1]])and(not b[b1[t2],b2[t3]])and(not((t=t2)and(t1=t3))) then\n begin\n a[i1,k1]:=b1[t]+b2[t1];\n a[i2,k2]:=b1[t2]+b2[t3];\n for i:=1 to n-2 do\n for k:=1 to m-2 do\n for ii:=1 to n-2 do\n for kk:=1 to m-2 do\n if (ii>=i+3)or(kk>=k+3)then\n if hor(i,k,ii,kk)then\n begin\n writeln('Solution exists.');\n writeln('Replace J1 with ',a[i1,k1],' and J2 with ',a[i2,k2],'.');\n writeln('Put the first square to (',i,', ',k,').');\n write('Put the second square to (',ii,', ',kk,').');\n halt;\n end;\n end;\n end;\nwrite('No solution.');\nend.", "src_uid": "b3f29d9c27cbfeadb96b6ac9ffd6bc8f"} {"source_code": "// Author : Phan Anh Tu\r\n// anhtu208 - haha\r\nvar t , n : longint;\r\n i : longint;\r\nfunction lt(x : longint) : int64;\r\nvar i : longint;\r\n tam : int64;\r\nbegin\r\n tam:=1;\r\n for i:=1 to x do tam:=2*tam;\r\n lt:=tam;\r\nend;\r\nbegin\r\n readln(t);\r\n for i:=1 to t do\r\n begin\r\n readln(n);\r\n writeln(lt(n) - 1);\r\n end;\r\nend.", "src_uid": "d5e66e34601cad6d78c3f02898fa09f4"} {"source_code": "Var a,b:array[1..5] of longint;\n s:array[1..5] of string;\n i,j,n,k:longint;\n ans:string;\n begin\n for i:=1 to 4 do\n Readln(s[i]);\n for i:=1 to 4 do\n for j:=1 to 4 do\n begin\n if i<>j then\n begin\n if (length(s[i])-2)>=(length(s[j])-2)*2 then inc(a[i]);\n if (length(s[i])-2)*2<=(length(s[j])-2) then inc(b[i]);\n end;\n end;\n for i:=1 to 4 do\n if (a[i]=3) or (b[i]=3) then\n begin\n ans:=chr(i+64);\n inc(k);\n end;\n if k=1 then Write(ans) else Write('C');\n end.", "src_uid": "30725e340dc07f552f0cce359af226a4"} {"source_code": "var\n max,i,n,min,minn:longint;\n a:array[0..101] of longint;\nbegin\n readln(n);\n min:=maxlongint;\n for i:=1 to n do\n begin\n read(a[i]);\n if a[i]n\nthen\nif m+1<=b\nthen\na:=m+1\nelse\na:=m;\nif b-m=n\nthen\na:=m+1;\nif b-m0\nthen\na:=m-1\nelse\na:=m;\nwrite(a);\nend.", "src_uid": "f6a80c0f474cae1e201032e1df10e9f7"} {"source_code": "{$MODE OBJFPC}\nuses math;\nconst maxN=200000+1067;base=1000000007;\nvar f,sum:array[0..1,-maxN..maxN] of int64;\n a,b,k,t,ss,xx,x:int64;\n i,j,nbn,kk:integer;\n res,nnn,mmm:int64;\nbegin\n readln(a,b,k,t);\n f[0][a-b]:=1;\n mmm:=a-b+2*k*t;\n nnn:=a-b-2*k*t;\n for j:=a-b to mmm do sum[0][j]:=1;\n for kk:=1 to t do\n begin\n xx:=0;\n ss:=0;\n i:=kk mod 2;\n nbn:=(i+1) mod 2;\n for j:=nnn+2*k downto nnn do\n begin\n inc(xx);\n ss:=(ss+f[nbn][j]*xx) mod base;\n end;\n for j:=nnn to mmm do\n begin\n f[i][j]:=ss mod base;\n ss:=(ss-(sum[nbn][j]-sum[nbn][max(j-2*k,nnn)-1]) +\n (sum[nbn][min(j+2*k+1,mmm)]-sum[nbn][j])) mod base;\n sum[i][j]:=(sum[i][j-1]+f[i][j]) mod base;\n end;\n end;\n for j:=1 to mmm do res:=(res+f[t mod 2][j]) mod base;\n if (res<0) then inc(res,base);\n writeln(res)\nend.\n", "src_uid": "8b8327512a318a5b5afd531ff7223bd0"} {"source_code": "program Ccodeforces15;\nconst max=trunc(1e9)+7;\nvar stk,A:array[1..100005] of longint;\n P:array[2..100005] of boolean;\n m,top,i:longint;\n j,ans,s,mu,x,n:int64;\n fi,fo:text;\n//-------------------------\nprocedure bdprime(x:longint);\nvar i,d:longint;\nbegin\n d:=trunc(sqrt(x));\n for i:=1 to top do\n begin\n if stk[i]>d then break;\n if x mod stk[i]=0 then\n begin\n inc(m);\n A[m]:=stk[i];\n While x mod stk[i]=0 do\n begin\n x:=x div stk[i];\n end;\n end;\n end;\nif x>1 then\nbegin\n inc(m);\n A[m]:=x;\nend;\nend;\n//-------------------------\nfunction pow(x,n:int64):int64;\nbegin\nif n=0 then exit(1);\nif n mod 2=0 then\nbegin\n exit((sqr(pow(x,n div 2))) mod max);\nend\nelse\nbegin\n exit((((sqr(pow(x,n div 2))) mod max)*x) mod max);\nend;\nend;\n//-------------------------\nbegin\nassign(fi,'');reset(fi);\nassign(fo,'');rewrite(fo);\nreadln(fi,x,n);\nfillchar(P,sizeof(P),true);\nfor i:=2 to 100000 do\nbegin\n if P[i] then\n begin\n inc(top);\n stk[top]:=i;\n j:=i;\n j:=j*j;\n While j<=100005 do\n begin\n P[j]:=false;\n inc(j,i);\n end;\n end;\nend;\nbdprime(x);\nans:=1;\nfor i:=1 to m do\nbegin\n mu:=n div A[i];\n While mu>0 do\n begin\n ans:=(ans*pow(A[i],mu)) mod max;\n mu:=mu div A[i];\n end;\nend;\nWriteln(fo,ans);\nclose(fo);\nend.\n\n\n\n", "src_uid": "04610fbaa746c083dda30e21fa6e1a0c"} {"source_code": "uses math;\nvar\n x1,x2,d,i,j,aa,bb,a,b,c:longint;\nbegin\n readln(x1,x2,a,b);\n aa:=a;\n bb:=b;\n d:=x2-x1;\n if (a<=0) and (b>=0) then begin\n if x2>x1 then begin\n if x1+b>=x2 then begin\n writeln('FIRST');\n writelN(x2);\n end\n Else writeln('DRAW');\n HALT;\n end\n else begin\n if x1+a<=x2 then begin\n\n\n writeln('FIRST');\n writelN(x2);\n end\n else writeln('DRAW');\n halt;\n end;\n end;\n if (a<0) and (b<0) then begin\n\n c:=a;\n a:=-b;\n b:=-c;\n end;\n if d>0 then begin\n if d mod (a+b) = 0 then begin\n writeln('SECOND');\n halt;\n end\n ELSE BEGIN\n if (d mod (a+b) >=a) and ( d mod (a+b) <=b) then begin\n writeln('FIRST');\n WRITELN(X1+(D MOD (A+B)));\n END\n else begin\n writeln('DRAW');\n HALT;\n end;\n end;\n end;\n if d<0 then begin\n if (d mod (a+b) = 0) and (aa<0) and (bb<0) then begin\n writeln('SECOND');\n halt;\n end\n ELSE BEGIN\n if (abs(d) mod (a+b) >=a) and ( abs(d) mod (a+b) <=b) then begin\n writeln('FIRST');\n WRITELN(X1-(abs(D) MOD (A+B)));\n END\n else begin\n writeln('DRAW');\n HALT;\n end;\n end;\n end;\n\nend.\n\n", "src_uid": "4ea8cc3305a0ee2c1e580b43e5bc46c6"} {"source_code": "Var n : int64 ;\n\nProcedure Enter ;\n Var i,j,res : longint ; a,b,tg : int64 ;\n Begin\n read(n) ; res := 1 ;\n {while (n > 1) do\n begin\n inc(res) ;\n n := (n+1) div 2 ;\n end ;}\n\n if (n <= 2) then begin writeln(1) ; exit ; end ;\n a := 1 ; b := 2 ;\n\n while (b <= n) do\n begin\n inc(res) ;\n tg := b ;\n b := a + b ;\n a := tg ;\n end ;\n\n writeln(res-1) ;\n End ;\n\nBegin\n //Assign(input,'735C.inp') ; reset(input) ;\n\n Enter ;\n\n //Close(input) ;\nEnd.\n", "src_uid": "3d3432b4f7c6a3b901161fa24b415b14"} {"source_code": "Program Very;\nvar s:string;\n i,j,u,n,kol,max:byte;\n e:array[0..210]of byte;\n\nbegin\nreadln(n);\nread(s);\ne[0]:=0;\nj:=0;\nfor i:=1 to n do\n if s[i]=' ' then\n begin\n inc(j);\n e[j]:=i-1;\n end;\ninc(j);\ne[j]:=n;\nfor i:=1 to j do\n begin\n kol:=0;\n for u:=e[i-1]+1 to e[i] do\n if (ord(s[u])>=ord('A')) and (ord(s[u])<=ord('Z')) then\n inc(kol);\n if kol>max then max:=kol; \n end; \nwriteln(max); \nend.", "src_uid": "d3929a9acf1633475ab16f5dfbead13c"} {"source_code": "Var n,k,i:longint;\n s1,s2:string[20];\n a1,a2:array[1..10] of longint;\n s:string[2];\nBegin\nReadln(s1);\nReadln(s2);\nFor i:=1 to (length(s1) div 2) do\n Begin\n s:=copy(s1,i*2-1,2);\n If s='[]' Then a1[i]:=1;\n If s='8<' Then a1[i]:=2;\n If s='()' Then a1[i]:=3;\n k:=i;\n End;\nFor i:=1 to (length(s2) div 2) do\n Begin\n s:=copy(s2,i*2-1,2);\n If s='[]' Then a2[i]:=1;\n If s='8<' Then a2[i]:=2;\n If s='()' Then a2[i]:=3;\n End;\nn:=0;\nFor i:=1 to k do\n Begin\n If a1[i]=a2[i] Then Continue;\n If a1[i]=1 Then Begin\n If a2[i]=2 Then dec(n);\n If a2[i]=3 Then inc(n);\n End;\n If a1[i]=2 Then Begin\n If a2[i]=1 Then inc(n);\n If a2[i]=3 Then dec(n);\n End;\n If a1[i]=3 Then Begin\n If a2[i]=1 Then dec(n);\n If a2[i]=2 Then inc(n);\n End;\n End;\nIf n=0 Then Begin Writeln('TIE'); Halt; End;\nIf n>0 Then Begin Writeln('TEAM 1 WINS'); Halt; End;\nWriteln('TEAM 2 WINS');\nEnd.", "src_uid": "bdf2e78c47d078b4ba61741b6fbb23cf"} {"source_code": "const\n fi ='';\n fg ='';\nvar dem,n,i:longint;\n deque:array[0..1000000] of longint;\n f,g:text;\nbegin\n assign(f,fi);\n reset(f);\n assign(g,fg);\n rewrite(g);\n readln(f,n);\n dem :=1;deque[dem] :=1;\n For i:=2 to n do\n begin\n inc(dem);deque[dem] :=1;\n While (deque[dem] = deque[dem-1]) and (dem <> 1) do\n begin\n inc(deque[dem-1]);\n dec(dem);\n end;\n end;\n For i:=1 to dem do write(g,deque[i],' ');\n close(f);\n close(g);\nend.", "src_uid": "757cd804aba01dc4bc108cb0722f68dc"} {"source_code": "var\np,n,k,i,j,buf,buf2,s:longint;\na:array[1..100,1..2] of longint;\nbegin\nreadln(n,k);\nfor i:=1 to n do\nbegin\nread(a[i,1]);\na[i,2]:=i;\nend;\nfor i:=1 to n-1 do\nfor j:=1 to n-1 do\nif(a[j,1]>a[j+1,1]) then\nbegin\nbuf:=a[j,1];\nbuf2:=a[j,2];\na[j,1]:=a[j+1,1];\na[j,2]:=a[j+1,2];\na[j+1,1]:=buf;\na[j+1,2]:=buf2;\nend;\ns:=0;\np:=0;\nwhile(s<=k)and(pk) then\ndec(p);\nwriteln(p);\nif(p>0) then\nbegin\nfor i:=1 to p-1 do\nwrite(a[i,2],' ');\nwriteln(a[p,2]);\nend;\nend.\n", "src_uid": "dbb164a8dd190e63cceba95a31690a7c"} {"source_code": "var n,k,s2,s4,tmp,p1,p2,p4:longint;\nbegin\n//assign(input,'hdyx.in');reset(input);\n//assign(output,'hdyx.out');rewrite(output);\nread(n,k);\ns4:=n;s2:=n*2;\nwhile k>0 do\n begin\n read(tmp);\n p4:=p4+tmp div 4;\n case tmp mod 4 of\n 1:inc(p1);\n 2:inc(p2);\n 3:begin inc(p1);inc(p2);end;\n end;\n k:=k-1;\n end;\nif p42*n\n then d:=4*n-d;\n end\n else begin\n if ((y1=0) and (y2=n)) or\n ((y1=n) and (y2=0))\n then begin\n d:=n+x1+x2;\n if d>2*n\n then d:=4*n-d;\n end\n else begin\n if ((x1=0) and (x2=0)) or\n ((x1=n) and (x2=n))\n then begin\n d:=abs(y1-y2);\n end\n else begin\n if ((y1=0) and (y2=0)) or\n ((y1=n) and (y2=n))\n then begin\n d:=abs(x1-x2);\n end\n else begin\n if (x1=0) and (y2=0)\n then d:=x2+y1;\n if (x2=0) and (y1=0)\n then d:=x1+y2;\n if (x1=0) and (y2=n)\n then d:=n+x2-y1;\n if (x2=0) and (y1=n)\n then d:=n+x1-y2;\n if (x1=n) and (y2=n)\n then d:=2*n-x2-y1;\n if (x2=n) and (y1=n)\n then d:=2*n-x1-y2;\n if (x1=n) and (y2=0)\n then d:=n-x2+y1;\n if (x2=n) and (y1=0)\n then d:=n-x1+y2;\n end;\n end;\n\n end;\n end;\nwriteln(d);\nend.", "src_uid": "685fe16c217b5b71eafdb4198822250e"} {"source_code": "var b,s,c,bs,ss,cs,cp,sp,bp,q,p,tp,qw:int64; st:string; i:longint;\nprocedure beli(x,y,z:int64);\nbegin\n if x < b then begin inc(bs,b-x); dec(p,bp*(b-x))end;\n if y < s then begin inc(ss,s-y); dec(p,sp*(s-y))end;\n if z < c then begin inc(cs,c-z); dec(p,cp*(c-z))end;\nend;\nbegin\n readln(st);b:=0;s:=0;c:=0;q:=0;\n for i:=1 to length(st)do begin\n case st[i] of\n\t 'B':inc(b);\n\t 'S':inc(s);\n\t 'C':inc(c);\n\tend;\n end;\n readln(bs,ss,cs);\n readln(bp,sp,cp);\n readln(p);\n if b=0 then bs:=0;\n if c=0 then cs:=0;\n if s=0 then ss:=0;\n while (p >= 0)do begin\n if (bs>=b) and (cs>=c) and (ss>=s) then begin\n\t dec(bs,b);dec(cs,c);dec(ss,s);inc(q);\n\tend;\n\ttp:=(b*bp)+(s*sp)+(c*cp);\n\tif (tp < p) and (b-bs=b)and (s-ss=s)and (c-cs=c) then begin\n qw:=p div tp;\n dec(p,tp*qw);\n inc(q,qw);\n end;\n\tbeli(bs,ss,cs); \n end;\n writeln(q);\nend.", "src_uid": "8126a4232188ae7de8e5a7aedea1a97e"} {"source_code": "var\n n,x,d: int64;\n\nbegin\n readln(n);\n readln(x);\n d:=n mod 6;\n\n if d = 0 then\n begin\n if x = 0 then writeln(0) else\n if x = 1 then writeln(1) else\n if x = 2 then writeln(2);\n end else\n if d = 1 then\n begin\n if x = 0 then writeln(1) else\n if x = 1 then writeln(0) else\n if x = 2 then writeln(2);\n end else\n if d = 2 then\n begin\n if x = 0 then writeln(1) else\n if x = 1 then writeln(2) else\n if x = 2 then writeln(0);\n end else\n if d = 3 then\n begin\n if x = 0 then writeln(2) else\n if x = 1 then writeln(1) else\n if x = 2 then writeln(0);\n end else\n if d = 4 then\n begin\n if x = 0 then writeln(2) else\n if x = 1 then writeln(0) else\n if x = 2 then writeln(1);\n end else\n if d = 5 then\n begin\n if x = 0 then writeln(0) else\n if x = 1 then writeln(2) else\n if x = 2 then writeln(1);\n end;\nend.\n", "src_uid": "7853e03d520cd71571a6079cdfc4c4b0"} {"source_code": "var\n s,a:ansistring;\nbegin\n readln(s);\n readln(a);\n s:=upcase(s);\n a:=upcase(a);\n if (s>a) then writeln('1')\n else if (s0 do\n if b and 1=1 then\n begin\n dec(b);\n tmp:=tmp*a mod mo;\n end else\n begin\n b:=b>>1;\n a:=a*a mod mo;\n end;\n exit(tmp);\n end;\n\n\nbegin\n readln(n,m,k);\n\n fac[0]:=1; inv[0]:=1;\n\n ii:=k; if n>k then ii:=n;\n for i:=1 to ii do\n begin\n fac[i]:=fac[i-1]*i mod mo;\n inv[i]:=power(fac[i],mo-2) mod mo;\n end;\n\n fillchar(d,sizeof(d),0);\n d[0,0]:=1;\n\n for i:=1 to n do\n for j:=1 to i do\n begin\n d[i,j]:=(d[i-1,j]*j+d[i-1,j-1]*j) mod mo;\n end;\n\n ans:=0;\n if m=1 then\n begin\n for i:=1 to n do\n ans:=(ans+d[n,i]*cb(k,i) mod mo) mod mo;\n writeln(ans);\n close(input);\n close(output);\n halt;\n end; \n\n ii:=k; if n2) then continue;\n tmp:=cb(k,x)*cb(k-x,x-y) mod mo;\n tmp:=tmp*cb(x,y) mod mo;\n tmp:=tmp*d[n,x] mod mo;\n tmp:=tmp*d[n,x] mod mo;\n tmp:=tmp*g[y] mod mo;\n ans:=(ans+ tmp ) mod mo;\n end;\n end;\n\n writeln(ans);\n\nend.\n", "src_uid": "f22f28e2d8933f4199ba5ccfc0de8cda"} {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n a1,b1,c1,a2,b2,c2:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction ran(l,r:longint):longint;\n begin\n exit(random(r-l+1)+l);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction calc:longint;\n var t1,t2:longint;\n begin\n if (a1=0) and (b1=0) and (c1<>0) then exit(0);\n if (a2=0) and (b2=0) and (c2<>0) then exit(0);\n if (a1=0) and (b1=0) and (c1=0) then t1:=2 else t1:=1;\n if (a2=0) and (b2=0) and (c2=0) then t2:=2 else t2:=1;\n if t1+t2>=3 then exit(-1);\n if a1*b2=a2*b1 then\n begin\n if (a1=0) and (a2=0) then\n begin\n if (b1*c2=b2*c1) and (c1*c2<>0) then exit(-1);\n if b1=b2 then\n begin\n if c1=c2 then exit(-1) else exit(0);\n end else exit(0);\n end;\n if (b1=0) and (b2=0) then\n begin\n if (a1*c2=a2*c1) and (c1*c2<>0) then exit(-1);\n if a1=a2 then\n begin\n if c1=c2 then exit(-1) else exit(0);\n end else exit(0);\n end;\n if a1*c2=a2*c1 then exit(-1) else exit(0);\n end else exit(1);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n begin\n read(fi,a1,b1,c1,a2,b2,c2);\n write(fo,calc);\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", "src_uid": "c8e869cb17550e888733551c749f2e1a"} {"source_code": "Var\n n,i,j,n1:integer;\n a:array[1..11,1..4] of char;\nBegin\n Read(n);\n fillchar(a,sizeof(a),'#');\n if n>4\n then Begin\n a[1,1]:='O';\n a[1,2]:='O';\n a[1,3]:='O';\n a[1,4]:='O';\n n:=n-4;\n n1:=n mod 3;\n n:=n div 3;\n for i:=1 to n do\n for j:=1 to 3 do\n a[i+1,j]:='O';\n if n1>0\n then for j:=1 to n1 do\n a[n+2,j]:='O';\n end\n else Begin\n for j:=1 to n do\n a[1,j]:='O';\n end;\n Writeln('+------------------------+');\n Writeln('|',a[1,1],'.',a[2,1],'.',a[3,1],'.',a[4,1],'.',a[5,1],'.',a[6,1],'.',a[7,1],'.',a[8,1],'.',a[9,1],'.',a[10,1],'.',a[11,1],'.|D|)');\n Writeln('|',a[1,2],'.',a[2,2],'.',a[3,2],'.',a[4,2],'.',a[5,2],'.',a[6,2],'.',a[7,2],'.',a[8,2],'.',a[9,2],'.',a[10,2],'.',a[11,2],'.|.|');\n Writeln('|',a[1,3],'.......................|');\n Writeln('|',a[1,4],'.',a[2,3],'.',a[3,3],'.',a[4,3],'.',a[5,3],'.',a[6,3],'.',a[7,3],'.',a[8,3],'.',a[9,3],'.',a[10,3],'.',a[11,3],'.|.|)');\n Writeln('+------------------------+');\nend.", "src_uid": "075f83248f6d4d012e0ca1547fc67993"} {"source_code": "program problem2;\n\nvar\tn, i: longInt;\n\tf: array[ 0..50 ] of int64;\n\tk: int64;\n\nbegin\n\tf[0] := 1;\n\tf[1] := 1;\n\tfor i := 2 to 50 do\n\t\tf[i] := f[i - 1] + f[i - 2];\n\t\n\treadln( n, k );\n\t\n\ti := 1;\n\twhile ( i <= n ) do\n\t\tif ( k <= f[n - i] ) then\n\t\tbegin\n\t\t\twrite( i, ' ' );\n\t\t\tinc( i );\n\t\tend\n\t\telse\n\t\tbegin\n\t\t\tdec( k, f[n - i] );\n\t\t\t\n\t\t\twrite( i + 1, ' ', i, ' ' );\n\t\t\tinc( i, 2 );\n\t\tend;\n\t\n\twriteln();\nend.\n", "src_uid": "e03c6d3bb8cf9119530668765691a346"} {"source_code": "uses\n Math;\n\nvar\n n, m, i, count, l, r, x, sum, ans: longint;\n k, a, day, d, t: array[1..400000] of longint;\n\nbegin\n read(n, m);\n for i := 1 to n do\n a[i] := 0;\n count := 0;\n for i := 1 to n do begin\n read(k[i]);\n count := count + k[i];\n end;\n for i := 1 to count * 2 do\n day[i] := 0;\n for i := 1 to m do\n read(d[i], t[i]);\n\n l := 1;\n r := count * 2;\n while abs(l-r) > 1 do begin\n x := (l + r) div 2;\n for i := 1 to x do\n day[i] := 0;\n for i := 1 to m do\n if ((a[t[i]] > x) or (a[t[i]] < d[i])) and (d[i] <= x) then\n a[t[i]] := d[i];\n for i := 1 to n do\n if (a[i] <= x) and (a[i] > 0) then\n day[a[i]] := day[a[i]] + k[i];\n sum := 0;\n ans := count;\n for i := 1 to x do begin\n inc(sum);\n ans := ans - min(day[i], sum);\n sum := sum - min(day[i], sum);\n end;\n if ans * 2 <= sum then\n r := x\n else\n l := x;\n end;\n \n for i := 1 to l do\n day[i] := 0;\n for i := 1 to m do\n if ((a[t[i]] > l) or (a[t[i]] < d[i])) and (d[i] <= l) then\n a[t[i]] := d[i];\n for i := 1 to n do\n if (a[i] <= l) and (a[i] > 0) then\n day[a[i]] := day[a[i]] + k[i];\n sum := 0;\n ans := count;\n for i := 1 to min(l, r) do begin\n inc(sum);\n ans := ans - min(day[i], sum);\n sum := sum - min(day[i], sum);\n end;\n if ans * 2 <= sum then\n write(min(l, r))\n else\n write(max(l, r))\nend.", "src_uid": "2eb101dcfcc487fe6e44c9b4c0e4024d"} {"source_code": "var\n h,m,i,j,k,l,h_len,m_len,h1,h2,m1,m2:longint;\n ans:int64;\n \nfunction get_len(x:longint):longint;\n begin\n if x=0 then exit(0);\n exit(1+get_len(x div 10));\n end;\n\nfunction nonzero_len(x:longint):longint;\n begin\n if x=0 then exit(0);\n if x mod 10<>0\n then exit(1+nonzero_len(x div 10))\n else exit(nonzero_len(x div 10));\n end;\n \nfunction power(a,b:longint):longint;\n var\n tmp:longint;\n begin\n tmp:=1;\n for b:=1 to b do\n tmp:=tmp*a;\n exit(tmp);\n end;\n \nfunction calc(h1,m1:longint):int64;\n var\n d,a,b,c:longint;\n ans:int64;\n begin\n ans:=0;\n \n if m_len>=k then\n begin\n if k=1 then\n begin\n ans:=ans+int64(m-1)*h1+m1;\n end\n else\n begin\n a:=power(10,k-1);\n ans:=ans+int64(h1)*( (m-1) div a );\n ans:=ans+m1 div a;\n end;\n end;\n\n d:=k-nonzero_len(m-1);\n if d<=0 then d:=1;\n\n if d=1 then\n begin\n ans:=ans+h1;\n end\n else\n begin\n a:=power(10,d-1);\n ans:=ans+h1 div a;\n end;\n \n exit(ans);\n \n end;\n\nbegin\n \n readln(h,m,k);\n \n h_len:=get_len(h);\n m_len:=get_len(m);\n \n readln(h1,m1,h2,m2);\n \n if (h1=k then\n inc(ans);\n writeln(ans);\n end;\n \nend.", "src_uid": "e2782743229645ad3a0f8e815d86dc5f"} {"source_code": "var m:array[1..4] of string;\n\ti,j:integer;\n\tf:boolean;\n\t\nprocedure check(s:string);\nbegin\nif not f then\nf:= (s='###.') or (s='##.#') or (s='#.##') or (s='.###') or (s='####') or\n\t(s='...#') or (s='..#.') or (s='.#..') or (s='#...') or (s='....'); \nend;\n\t\nbegin\nfor i:=1 to 4 do\n\treadln(m[i]);\n\t\nf:=false;\nfor i:=1 to 3 do\n\tfor j:=1 to 3 do\n\t\tcheck(m[i,j]+m[i,j+1]+m[i+1,j]+m[i+1,j+1]);\nif f then writeln('YES') else writeln('NO');\nend.\n", "src_uid": "01b145e798bbdf0ca2ecc383676d79f3"} {"source_code": "{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\n{$H+}\nuses math;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nconst\n tfi='';\n tfo='';\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nvar fi,fo:text;\n n:longint;\n st:array[1..100000] of longint;\n top:longint;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nfunction marked(x:longint):boolean;\n var i:longint;\n begin\n for i:=1 to top do if st[i]=x then exit(true);\n exit(false);\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure mark(x:longint);\n begin\n inc(top);\n st[top]:=x;\n end;\n{$~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}\nprocedure input;\n var i:longint;\n begin\n read(fi,n);\n mark(n);\n repeat\n inc(n);\n while n mod 10=0 do n:=n div 10;\n if marked(n) then break;\n mark(n);\n until 1=2;\n write(fo,top);\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", "src_uid": "055fbbde4b9ffd4473e6e716da6da899"} {"source_code": "uses math;\nconst fi='837e.inp';\n fo='837e.out';\nvar n,m,x,y:int64;\n a,b:array[0..1000000] of int64;\n//---------------\nprocedure doc;\nbegin\n read(x,y);\nend;\n//---------------\nprocedure phantich(x:int64);\nvar i:longint;\nbegin\n m:=0;\n for i:=2 to trunc(sqrt(x)) do\n while x mod i=0 do\n begin\n inc(m);\n a[m]:=i;\n x:=x div i;\n end;\n if x>1 then\n begin\n inc(m);\n a[m]:=x;\n end;\nend;\n//---------------\nprocedure xuli;\nvar i,count:longint;\n res,g:int64;\nbegin\n phantich(x);\n res:=0;\n repeat\n g:=y;\n for i:=1 to m do\n begin\n g:=min(g,y mod a[i]);\n end;\n res:=res+g;\n y:=y-g;\n count:=0;\n for i:=1 to m do\n if y mod a[i]=0 then y:=y div a[i]\n else\n begin\n inc(count);\n b[count]:=a[i];\n end;\n for i:=1 to count do a[i]:=b[i];\n m:=count;\n until y=0;\n write(res);\nend;\n//---------------\nbegin\n doc;\n xuli;\nend.\n", "src_uid": "ea92cd905e9725e7fcb87b9ed4f64c2e"} {"source_code": "program zad_22;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n string1: string;\n res : integer;\n{---------------------------------------------------}\nprocedure checkstring(str : string; var k : integer);\n var\n ch : char;\n i, k1 : integer;\n begin\n ch := 'a';\n k1 := 0;\n for i := 1 to 26 do begin\n if(pos(ch, str) <> 0) then inc(k1);\n inc(ch);\n end;\n k := k1;\n end;\n{--------------------------------------------------}\nbegin\n readln(string1);\n checkstring(string1, res);\n if(res mod 2 = 0) then\n writeln('CHAT WITH HER!')\n else\n writeln('IGNORE HIM!');\n readln;\nend.\n ", "src_uid": "a8c14667b94b40da087501fd4bdd7818"} {"source_code": "var i,j,n: longint;\nm1,m2: array [1..5] of longint;\nsum: uint64;\nb: boolean;\n\n\nbegin\nread(n);\nfor i:=1 to n do\nbegin\n read(j);\n inc(m1[j])\nend;\nfor i:=1 to n do\nbegin\n read(j);\n inc(m2[j])\nend;\nfor i:=1 to 5 do\nbegin\nif abs(m1[i]-m2[i]) mod 2=1 then b:=true else inc(sum,abs(m1[i]-m2[i]) div 2);\n\n\nend;\n\n\n\nif b=false then write(sum div 2) else write(-1);\nreadln;\nend.", "src_uid": "47da1dd95cd015acb8c7fd6ae5ec22a3"} {"source_code": "var p,l,s,r:array [1..4] of longint;\n i:longint;\n b:boolean;\nbegin \n\tfor i:=1 to 4 do \n\treadln(l[i],s[i],r[i],p[i]);\n\tb:=false;\n\tif (p[1]=1) then \n\tif (l[1]=1) or (s[1]=1) or (r[1]=1) or (l[2]=1) or (s[3]=1) or (r[4]=1) \n\tthen b:=true;\n\tif (p[2]=1) then \n\tif(l[2]=1) or (s[2]=1) or (r[2]=1) or (l[3]=1) or (s[4]=1) or (r[1]=1) \n\tthen b:=true;\n\tif (p[3]=1) then \n\tif(l[3]=1) or (s[3]=1) or (r[3]=1) or (l[4]=1) or (s[1]=1) or (r[2]=1) \n\tthen b:=true;\n\tif (p[4]=1) then \n\tif(l[4]=1) or (s[4]=1) or (r[4]=1) or (l[1]=1) or (s[2]=1) or (r[3]=1) \n\tthen b:=true;\n\tif b then writeln('YES')\n\telse writeln('NO');\t\n\treadln;\nend.", "src_uid": "44fdf71d56bef949ec83f00d17c29127"} {"source_code": "var n,k,a,dem,UCLN:longint;\nprocedure GCD(c,b:longint);\nvar min,i:longint;\nbegin\n UCLN:=1;\n if c > b then min:=b\n else min:=c;\n for i:=1 to min do\n if (c mod i=0) and (b mod i =0) then UCLN:=i;\nend;\nbegin\n readln(n,k,a);\n dem:=0;\n if a=0 then dem:=4;\n while (dem <> 3) and (dem <> 4) do\n begin\n gcd(n,a);\n a:=a-UCLN;\n if a=0 then dem:=3;\n gcd(k,a);\n a:=a-UCLN;\n if a=0 then dem:=4;\n end;\n if dem=3 then write('0');\n if dem=4 then write('1');\nend.", "src_uid": "0bd6fbb6b0a2e7e5f080a70553149ac2"} {"source_code": "uses math;\nvar mp:array[0..105,0..105]of int64;\n n,m,ans:int64;\n i,j:longint;\nfunction gcd(a,b:int64):int64;\nbegin\n if a mod b=0 then exit(b);exit(gcd(b,a mod b));\nend;\nprocedure floyd;\nvar i,j,k:longint;\nbegin\nfor k:=1 to n do\n for i:=1 to n do\n for j:=1 to n do mp[i,j]:=min(mp[i,j],mp[i,k]+mp[k,j]);\n\nend;\n\nbegin\nreadln(n);\nfor i:=1 to n do for j:=1 to n do mp[i,j]:=999999999;\nfor i:=1 to n do begin\n read(m);mp[i,m]:=1;\nend;\nfloyd;\nans:=1;\nfor i:=1 to n do begin\n if mp[i,i]=999999999 then begin writeln(-1);halt;end;\n if mp[i,i] mod 2=0 then mp[i,i]:=mp[i,i] div 2;\n ans:=(ans*mp[i,i])div gcd(ans,mp[i,i]);\nend;\nwriteln(ans);\nend.", "src_uid": "149221131a978298ac56b58438df46c9"} {"source_code": "const ct:longint=1900000000;cp:longint=10007;\ntype sz=array[0..401,0..401] of longint;\nvar\n sum:array[0..201] of longint;\n dp:array[0..201,0..201,0..201] of longint;\n f,y,a:sz;\n s:ansistring;\n ans,len,pl,l,i,j,k,st,en,n:longint;\nprocedure qm(r:longint);\nbegin\n if r=1 then exit;\n qm(r shr 1);\n for i:=1 to len do for j:=i to len do begin\n a[i,j]:=0;\n for k:=i to j do begin\n inc(a[i,j],f[i,k]*f[k,j]);\n if a[i,j]>=ct then a[i,j]:=a[i,j] mod cp;\n end;\n a[i,j]:=a[i,j] mod cp;\n end;\n for i:=1 to len do for j:=i to len do f[i,j]:=a[i,j];\n if r and 1=1 then begin\n for i:=1 to len do for j:=i to len do a[i,j]:=0;\n for k:=1 to len do for i:=1 to k do if y[i,k]>0 then\n for j:=k to len do begin\n inc(a[i,j],y[i,k]*f[k,j]);\n if a[i,j]>=ct then a[i,j]:=a[i,j] mod cp;\n end;\n for i:=1 to len do for j:=i to len do begin\n if a[i,j]0\n then begin\n if s[j]<>s[k] then begin\n inc(dp[j+1,k,i+1],dp[j,k,i]);\n if dp[j+1,k,i+1]>=cp then dec(dp[j+1,k,i+1],cp);\n inc(dp[j,k-1,i+1],dp[j,k,i]);\n if dp[j,k-1,i+1]>=cp then dec(dp[j,k-1,i+1],cp);\n end else begin\n inc(dp[j+1,k-1,i],dp[j,k,i]);\n if dp[j+1,k-1,i]>=cp then dec(dp[j+1,k-1,i]);\n end;\n end;\n for i:=1 to l+1 do for j:=i-1 downto 0 do for k:=0 to l-1 do begin\n inc(sum[k],dp[i,j,k]);if sum[k]>=cp then dec(sum[k],cp);\n end;\n pl:=(l+1) shr 1;len:=l+2*pl;\n for i:=1 to l do f[i,i]:=24;\n for i:=l+1 to l+pl do begin\n f[i,i]:=25;f[i,i+pl]:=1;\n end;\n for i:=l+pl+1 to len do f[i,i]:=26;\n for i:=1 to l+pl-1 do f[i,i+1]:=1;\n for i:=1 to len do for j:=i to len do y[i,j]:=f[i,j];\n qm((n+1) shr 1);\n for i:=0 to l-1 do if sum[i]>0 then begin\n st:=l-i+1;en:=l+pl+st shr 1;\n inc(ans,sum[i]*f[st,en]);if ans>=ct then ans:=ans mod cp;\n end;\n if n and 1=1 then begin\n for i:=1 to len do for j:=i to len do f[i,j]:=y[i,j];\n qm((n+1) shr 1-1);\n for i:=0 to l-1 do if (sum[i]>0) and ((l-i) mod 2=0) then begin\n st:=l-i+1;en:=l+st shr 1;\n dec(ans,sum[i]*f[st,en]);if ans<0 then begin\n ans:=ans mod cp;if ans<0 then inc(ans,cp);\n end;\n end;\n end;\n writeln(ans mod cp);\nend.", "src_uid": "2ae6f17e0dd0bc93090d939f4f49d7a8"} {"source_code": "var\n s:string;\n st:array[1..1000]of longint;\n m,n,k,l,w,a,b,c,stn:int64;\n i,j:longint;\nbegin\n readln(a,b,c);\n for i:=1 to 81 do\n begin\n k:=1;\n for j:=1 to a do k:=k*i;\n w:=b*k+c;\n str(w,s);\n for j:=1 to length(s) do inc(l,ord(s[j])-48);\n if (l=i)and(w>0)and(w<1000000000) then begin inc(stn); st[stn]:=w; end;\n l:=0;\n end;\n writeln(stn);\n for i:=1 to stn do write(st[i],' ');\nend.\n", "src_uid": "e477185b94f93006d7ae84c8f0817009"} {"source_code": "const finp='';\n fout='';\nvar n:byte;\n a:Array[1..100] of byte;\nprocedure nhap;\nvar f:text;\n i:byte;\nbegin\n assign(f,finp);\n reset(f);\n readln(f,n);\n for i:=1 to n do\n read(f,a[i]);\n close(f);\nend;\nprocedure sort;\nvar i,j,temp:byte;\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 temp:=a[i];\n a[i]:=a[j];\n a[j]:=temp;\n end;\nend;\nfunction tinh:integer;\nvar i,k,lc,j:byte;\nbegin\n for i:=1 to a[1] do\n begin\n lc:=1;\n for j:=1 to n do\n if a[j] mod i<>0 then\n begin\n lc:=0;\n break;\n end;\n if lc=1 then\n k:=i;\n end;\n tinh:=k*n;\nend;\nprocedure xuat;\nvar f:text;\n kq:integer;\nbegin\n assign(f,fout);\n rewrite(f);\n sort;\n kq:=tinh;\n write(f,kq);\n close(f);\nend;\nbegin\n nhap;\n xuat;\nend.", "src_uid": "042cf938dc4a0f46ff33d47b97dc6ad4"} {"source_code": "program tt;\nuses math;\n\nvar a, b, root: array[ 0..200000 ] of longInt;\n t: array[ 0..8000000 ] of qWord;\n\nprocedure qsort( l, r: longInt );\nvar i, j, t, med: longInt;\nbegin\n if ( l < r ) then\n begin\n i := l;\n j := r;\n med := a[ b[ l + random(r - l + 1) ] ];\n while ( i <= j ) do\n begin\n while ( a[ b[i] ] < med ) do\n inc( i );\n\n while ( a[ b[j] ] > med ) do\n dec( j );\n\n if ( i <= j ) then\n begin\n t := b[i];\n b[i] := b[j];\n b[j] := t;\n\n inc( i );\n dec( j );\n end;\n end;\n\n qsort( l, j );\n qsort( i, r );\n end;\nend;\n\nfunction compress( lSon, rSon, mn: longInt ): qWord;\nbegin\n exit( qWord(200001) * ( qWord(8000000) * qWord(lSon) + qWord(rSon) ) + qWord(mn) );\nend;\n\nprocedure decompress( mask: qWord; var lSon, rSon, mn: longInt );\nbegin\n mn := mask mod 200001;\n mask := mask div 200001;\n rSon := mask mod 8000000;\n lSon := mask div 8000000;\nend;\n\nfunction build_tree( prev: longInt ): longInt;\nconst tw: longInt = 0;\nbegin\n inc( tw );\n t[tw] := t[prev];\n\n exit( tw );\nend;\n\nfunction get( v, l, r: longInt ): longInt;\nbegin\n if ( l = r ) then\n exit( v );\n\n exit( t[v] mod 200001 );\nend;\n\nfunction add( v, l, r, ll, rr: longInt ): longInt;\nvar c, delta, lSon, rSon, mn: longInt;\nbegin\n if ( l = r ) then\n exit( v + 1 );\n\n v := build_tree( v );\n\n if ( ll <= l ) and ( r <= rr ) then\n begin\n inc( t[v], 1 );\n\n exit( v );\n end;\n\n decompress( t[v], lSon, rSon, mn );\n\n c := ( l + r ) div 2;\n\n delta := mn - min( get( lSon, l, c ), get( rSon, c + 1, r ) );\n if ( ll <= c ) then\n lSon := add( lSon, l, c, ll, rr );\n\n if ( rr > c ) then\n rSon := add( rSon, c + 1, r, ll, rr );\n\n mn := min( get( lSon, l, c ), get( rSon, c + 1, r ) ) + delta;\n\n t[v] := compress( lSon, rSon, mn );\n\n exit( v );\nend;\n\nfunction query( v, l, r, ll, rr: longInt ): longInt;\nvar res, c, delta, lSon, rSon, mn: longInt;\nbegin\n if ( l = r ) then\n exit( v );\n\n if ( ll <= l ) and ( r <= rr ) then\n exit( t[v] mod 200001 );\n\n decompress( t[v], lSon, rSon, mn );\n\n c := ( l + r ) div 2;\n\n delta := mn - min( get( lSon, l, c ), get( rSon, c + 1, r ) );\n\n res := 100000000;\n if ( ll <= c ) then\n res := min( res, query( lSon, l, c, ll, rr ) );\n\n if ( rr > c ) then\n res := min( res, query( rSon, c + 1, r, ll, rr ) );\n\n exit( delta + res );\nend;\n\nvar n, m, q, i, j, l, r, x, y, ans: longInt;\n\nbegin\n readln( n, m );\n for i := 1 to n do\n read( a[i] );\n\n for i := 1 to n do\n b[i] := i;\n\n qsort( 1, n );\n\n root[0] := 0;\n for i := 1 to n do\n begin\n r := min( b[i], n - m + 1 );\n l := max( 1, b[i] - m + 1 );\n\n root[i] := add( root[i - 1], 1, n - m + 1, l, r );\n end;\n\n ans := 0;\n readln( q );\n for i := 1 to q do\n begin\n readln( l, r, x );\n\n x := x xor ans;\n\n y := 0;\n for j := 20 downto 0 do\n if ( y + 1 shl j <= n ) and ( a[ b[y + 1 shl j] ] < x ) then\n inc( y, 1 shl j );\n\n ans := query( root[y], 1, n - m + 1, l, r );\n\n writeln( ans );\n end;\nend.\n", "src_uid": "92c773d61414ec6a13cdfbdcd24a2b0d"} {"source_code": "// yk keep smile its sunnah :)\n// codeforces 95 div 2 :\n\nuses strutils, sysutils, math;\nconst MaxN=maxlongint; inf = 1000000000;\ntype int = longint; bool = boolean;\n\nprocedure inn;\nbegin\n assign(input,'a.in'); reset(input);\n assign(output,'a.out'); rewrite(output);\nend;\n\nvar\n n,m,t,i,j,x,men : int;\n ans : int64;\n c : array[0..100,0..100] of int64;\n\nbegin\n //inn;\n read(n,m,t);\n for i:=1 to 31 do 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];\n end;\n\n for men:=4 to n do\n if (t-men>=1) and (t-men<=m) then\n ans:=ans+c[n+1,men]*c[m+1,t-men];\n\n write(ans);\n close(output);\nend.\n", "src_uid": "489e69c7a2fba5fac34e89d7388ed4b8"} {"source_code": "var\n\nmap : array [-10..10,-10..10] of longint;\ni,j : longint;\ns :string;\n\nbegin\n\n for i:=1 -4 to 8 do\n for j:=1 -4 to 8 do\n map[i,j]:=100;\n\n for i:=1 to 4 do\n begin\n readln(s);\n for j:=1 to 4 do\n begin\n if s[j] = '.' then map[i,j]:=0 else\n if s[j] = 'x' then map[i,j]:=1 else\n map[i,j]:=100;\n end;\n end;\n \n\n // writeln(map[2,3],' ',map[3,2],' ',map[4,1]);\n\n \n for i:=1 to 4 do\n for j:=1 to 4 do\n begin\n if ((map[i,j]+map[i,j+1]+map[i,j+2]) = 2){ or\n ((map[i,j]+map[i,j+1]+map[i,j+2]) = 3)} then\n begin\n writeln('YES');\n // writeln(i,' ',j,' ',1);\n halt;\n end;\n \n if ((map[i,j]+map[i+1,j]+map[i+2,j]) = 2){ or\n ((map[i,j]+map[i+1,j]+map[i+2,j]) = 3)} then\n begin\n writeln('YES');\n // writeln(i,' ',j,' ',2);\n halt;\n end;\n \n if ((map[i,j]+map[i+1,j+1]+map[i+2,j+2]) = 2) {or\n ((map[i,j]+map[i+1,j+1]+map[i+2,j+2]) = 3)} then\n begin\n writeln('YES');\n // writeln(i,' ',j,' ',3);\n halt;\n end;\n \n if ((map[i,j]+map[i+1,j-1]+map[i+2,j-2]) = 2) {or\n ((map[i,j]+map[i-1,j-1]+map[i-2,j-2]) = 3)} then\n begin\n writeln('YES');\n // writeln(i,' ',j,' ',4);\n halt;\n end;\n end;\n \n writeln('NO');\n end.\n", "src_uid": "ca4a77fe9718b8bd0b3cc3d956e22917"} {"source_code": "program cf65a;\nvar\n n,i,j:longint;\n x:double;\n a,b:longint;\nbegin\n x:=1;\n for i:=1 to 2 do begin\n read(a,b);\n if (a=0) then begin\n if b<>0 then x:=x+1e50\n else begin\n x:=0;\n end;\n end\n else x:=x*(b/a);\n end;\n\n if x>1e45 then writeln('Ron')\n else begin\n if x<1e-7 then begin\n writeln('Hermione');\n halt;\n end;\n\n read(a,b);\n if (a=0) then begin\n if b<>0 then x:=x+1e50\n else begin\n x:=0;\n end;\n end\n else x:=x*(b/a);\n\n\n\n if x>1 then writeln('Ron') else writeln('Hermione');\n end;\nend.\n\n\n", "src_uid": "44d608de3e1447f89070e707ba550150"} {"source_code": "var\n a:array['A'..'Z'] of longint=(1,0,0,0,1,1,0,1,1,0,1,1,1,1,0,0,0,0,0,1,0,1,1,1,1,1);\n i,j,s:longint;\n ss:ansistring;\nbegin\n s:=0;\n readln(ss);\n for i:=1 to length(ss) do\n begin\n s:=s+a[ss[i]];\n end;\n if (s=length(ss))or(s=0) then\n writeln('YES')\n else\n writeln('NO');\nend.", "src_uid": "15008dcb8dc8506c39aef0e3d8fca70c"} {"source_code": "var n,m,w:int64;\ni,j:longint;\na,f:array[0..100001] of int64;\nfunction sc(x:int64):int64;\nvar y,z:int64;\nbegin\nz:=1;y:=2;\nwhile x>0 do\n begin\n if x mod 2=1 then z:=z*y mod 1000000007;\n y:=y*y mod 1000000007;\n x:=x>>1;\n end;\nsc:=z;\nend;\nprocedure 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 l0 then\n begin\n writeln(0);\n close(input);close(output);halt;\n end;\nfor i:=1 to trunc(sqrt(m)) do\n if m mod i=0 then\n begin\n if i mod n=0 then\n begin\n w:=w+1;a[w]:=i;\n end;\n if(i*i<>m)and(m div i mod n=0)then\n begin\n w:=w+1;a[w]:=m div i;\n end;\n end;\nsort(1,w);\nfor i:=w downto 1 do\n begin\n f[i]:=sc(m div a[i]-1);\n for j:=i+1 to w do\n if a[j] mod a[i]=0 then\n f[i]:=(f[i]-f[j]+1000000007) mod 1000000007;\n end;\nwriteln(f[1]);\nclose(input);close(output);\nend.\n", "src_uid": "de7731ce03735b962ee033613192f7bc"} {"source_code": "program ProjectA;\n\n{$APPTYPE CONSOLE}\n{$O-,R+}\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, g, res, k, res1, res2, l, r, x, y, z, new, len, memi, memj, mi, ma, d, c: integer;\n // a, b: integer;\n a, b: array [0..100001] of integer;\n // d: array [0..100001] of integer;\n s, s1, s2, st, snew: string;\n // s3, s4: string;\n ok: boolean;\n ch: char;\n // yes: array [0..10001] of boolean;\n // g: array [0..1001, 0..1001] of boolean;\n // ok: array [0..10001] of boolean;\n // ch: array [0..1001, 0..1001] of char;\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 panicex(kwex: extended);\nbegin\n write(kwex);\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 memi := 0;\n memj := 0;\n for i := 1 to 5 do\n for j := 1 to 5 do\n begin\n read(x);\n if x = 1 then\n begin\n memi := i;\n memj := j;\n end;\n end;\n\n write(abs(memi - 3) + abs(memj - 3));\n\n\n\n\n\n\nend.\n\n", "src_uid": "8ba7cedc3f6ae478a0bb3f902440c8e9"} {"source_code": "var s:string;\nk1,k,i:longint;\nbegin\nread(s);\nwhile pos('VK',s)<>0 do\nbegin\nif pos('VK',s)<> 0 then begin k1:=pos('VK',s); k:=k+1; end;\ns[k1]:='0';\ns[k1+1]:='0';\nend;\nfor i:=1 to length(S)-1 do\nif ((S[i]='K')and(S[i+1]='K'))or((S[I]='V')AND(S[I+1]='V')) then begin k:=k+1; break; end;\nwrite(K);\nend.\n", "src_uid": "578bae0fe6634882227ac371ebb38fc9"} {"source_code": "var n,k,a,b,c:int64;\nbegin\nread(n,k);\na:=n div (2*(k+1));\nb:=a*k;\nc:=n-a-b;\nwriteln(a,' ',b,' ',c);\nend.", "src_uid": "405a70c3b3f1561a9546910ab3fb5c80"} {"source_code": "program Project3;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\ntype coct = record\n i, j, t: longint;\nend;\nconst ochsize = 10000000;\nvar\n i, j: longint;\n ch: char;\n a: array[1..8, 1..8] of longint;\n q: array[0..9, 0..9, 1..100000] of longint;\n och: array[1..ochsize] of coct;\n l, r, size: longint;\n f: coct;\n procedure dobav(i, j, t: longint);\n var\n f: coct;\n begin\n if q[i, j, t] = 0 then\n begin\n f.i := i;\n f.j := j;\n f.t := t;\n inc(r);\n if r > ochsize then\n r := 1;\n och[r] := f;\n inc(size);\n q[i, j, t] := 1;\n end;\n end;\n\n function doct: coct;\n var\n f: coct;\n begin\n f := och[l];\n inc(l);\n if l > ochsize then\n l := 1;\n dec(size);\n q[f.i, f.j, f.t] := 0;\n doct := f;\n end;\n procedure obr(i, j, t: longint);\n var\n z: longint;\n begin\n if (i = 0) or (j = 0) or (i = 9) or (j = 9) then\n exit;\n z := i + t;\n if (z <= 8) and (a[z, j] = 1) then\n exit;\n //if t - 1 >= 0 then\n begin\n z := i + t - 1;\n if (z <= 8) and (a[z, j] = 1) then\n exit;\n end; \n dobav(i, j + 1, t + 1);\n dobav(i, j - 1, t + 1);\n dobav(i - 1, j, t + 1);\n dobav(i + 1, j, t + 1);\n\n dobav(i + 1, j + 1, t + 1);\n dobav(i + 1, j - 1, t + 1);\n dobav(i - 1, j + 1, t + 1);\n dobav(i - 1, j - 1, t + 1);\n\n dobav(i, j, t + 1);\n end;\n\nbegin\n {assign(input, 'input.txt');\n reset(input);\n assign(output, 'output.txt');\n rewrite(output); }\n for i := 1 to 8 do\n begin\n for j := 1 to 8 do\n begin\n read(ch);\n if ch = 'S' then\n a[8 - i + 1 , j] := 1\n else\n a[8 - i + 1, j] := 0;\n end;\n readln;\n end;\n l := 1;\n r := 0;\n size := 0;\n obr(1, 1, 0);\n while size > 0 do\n begin\n f := doct;\n if (f.i = 8) and (f.j = 8) then\n begin\n writeln('WIN');\n exit;\n end;\n // writeln(f.i, f.j, f.t);\n obr(f.i, f.j, f.t);\n end;\n\n writeln('LOSE');\nend.\n", "src_uid": "f47e4ab041288ba9567c19930eb9a090"} {"source_code": "program Project5;\n\nuses math;\n\nvar\n i, j: longint;\n a: array[1..1000000] of byte;\n ans, n: int64;\n\nbegin\n read(n);\n dec(n);\n i := 1;\n while n > 1 do begin\n a[i] := n mod 2;\n n := n div 2;\n inc(i);\n end;\n a[i] := 1;\n\n ans := 0;\n ans := round(power(2, -1));\n for j := i downto 2 do\n ans := ans + a[j] * (j + 1) * round(power(2, j - 2));\n\n if a[1] = 1 then\n ans := ans + 1;\n\n write(ans);\nend.\n", "src_uid": "a98f0d924ea52cafe0048f213f075891"} {"source_code": "\n const nn=1600000; nnn=200000;eps=0.0000000001;\n label 1,2,3;\n var p1,p2, k,jj,step, i,j:longint;\n 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,kk);\n for i:=1 to n do read(a[i]);\n for i:=1 to n do\n begin\n p:=ost+a[i];\n b[i]:=b[i-1]+a[i];\n ot:=ot+min(p,8);\n ost:=b[i]-ot;\n { writeln('day ',i,' ot= ',ot,' ost= ',ost);\n }\n if ot>=kk then begin write(i);goto 1; end;\n\n end;\n writeln(-1);\n\n\n\n 1: close(output);\nend.\n\n\n", "src_uid": "24695b6a2aa573e90f0fe661b0c0bd3a"} {"source_code": "var\n c, v0, v1, a, l, i, j, sum, n, k, t, z: longint;\n\nbegin\n readln(c, v0, v1, a, l);\n sum := 0;\n t := l;\n repeat\n begin\n if sum >= c then\n begin\n writeln(k);\n exit;\n end;\n if v0 >= v1 then\n begin\n v0 := v1;\n a := 0;\n end;\n \n if l >= v0 then\n begin\n l := v0;\n end\n else\n l := t;\n if z = 0 then\n begin\n sum := sum + v0;\n v0 := v0 + a;\n inc(k);\n inc(z);\n end\n else\n begin\n if l > sum then\n sum := 0\n else\n sum := sum - l;\n \n sum := sum + v0;\n v0 := v0 + a;\n inc(k);\n inc(z);\n end;\n end;\n until sum >= c;\n writeln(k);\nend.", "src_uid": "b743110117ce13e2090367fd038d3b50"} {"source_code": "Program z1;\nvar n,i,q,l:longint;\nbegin\nread(n);\ni:=0;\nwhile n>0 do\nbegin\ni:=i+1;\nq:=i;\nwhile q<>0 do\nbegin\nl:=l+q mod 10;\nq:=q div 10;\nend;\nif l=10 then n:=n-1;\nl:=0;\nend;\nwrite(i);\nend.", "src_uid": "0a98a6a15e553ce11cb468d3330fc86a"} {"source_code": "uses math;\nvar n,m,k,res,r,l,s:int64;\ni:longint;\nfunction f(x:int64):longint;\nvar sum:int64;\nbegin\n sum:=0;\n for i:=1 to n do\n begin\n sum:=sum+min(x div i,m);\n end;\n if sum 0) or (status[x][y] = true) then begin\n write('BUG');\n halt;\n end;\n status[x][y] := true;\n end;\n write('OK');\nend.\n", "src_uid": "bb7805cc9d1cc907b64371b209c564b3"} {"source_code": "var \n n , ans , i , j , len , len1 , cnt , x , y , max : longint;\n a : array[1..10 , 1..10] of char;\n b : array[1..10 , 1..10] of integer;\nbegin\n for i := 1 to 6 do begin\n for j := 1 to 8 do begin\n if (j <> 8) then read(a[i][j]) else readln(a[i][j]);\n end;\n end;\n \n b[1][1] := 3;\n b[1][2] := 3;\n b[1][4] := 4;\n b[1][5] := 4;\n b[1][7] := 3;\n b[1][8] := 3;\n \n b[2][1] := 3;\n b[2][2] := 3;\n b[2][4] := 4;\n b[2][5] := 4;\n b[2][7] := 3;\n b[2][8] := 3;\n \n b[3][1] := 2;\n b[3][2] := 2;\n b[3][4] := 3;\n b[3][5] := 3;\n b[3][7] := 2;\n b[3][8] := 2;\n \n b[4][1] := 2;\n b[4][2] := 2;\n b[4][4] := 3;\n b[4][5] := 3;\n b[4][7] := 2;\n b[4][8] := 2;\n \n b[5][1] := 1;\n b[5][2] := 1;\n b[5][4] := 2;\n b[5][5] := 2;\n b[5][7] := 1;\n b[5][8] := 1;\n \n b[6][1] := 1;\n b[6][2] := 1;\n b[6][4] := 2;\n b[6][5] := 2;\n b[6][7] := 1;\n b[6][8] := 1;\n \n for i := 1 to 6 do begin\n for j := 1 to 8 do begin\n if (a[i][j] = '.') then begin\n if (b[i][j] > max) then begin\n x := i;\n y := j;\n max := b[i][j];\n end;\n end;\n end;\n end;\n \n a[x][y] := 'P';\n \n for i := 1 to 6 do begin\n for j := 1 to 8 do begin\n write(a[i][j]);\n end;\n writeln;\n end;\n \nend.", "src_uid": "35503a2aeb18c8c1b3eda9de2c6ce33e"} {"source_code": "var\nsum,n,a,b,i: integer;\narr: array[1..20] of integer;\nbegin\nread(n,a,b);\nfor n:=1 to n do\nread(arr[n]);\nfor i:=1 to n div 2 do\nbegin\nif arr[i]=2 then if arr[n-i+1] = 2 then if a 0 do\n begin\n if s[i] = '(' then inc(bal) else\n if s[i] = ')' then dec(bal);\n if bal = 0 then break;\n ss:=ss+s[i];\n inc(i);\n end;\n exp[m].p[v].m[t].expid:=makeexpr(ss);\n inc(i);\n end else\n begin\n exp[m].p[v].m[t].kind:=2;\n q:=0; inc(i);\n while s[i] in ['0'..'9'] do\n begin\n q:=q*10+Ord(s[i])-48;\n inc(i);\n end;\n exp[m].p[v].m[t].num:=q;\n end;\n end;\n end;\n makeexpr:=m;\nend;\n\nfunction eval(m,z:longint):longint;\nvar\n res,i,j,cur,v: longint;\nbegin\n res:=0;\n for i:=1 to exp[m].cp do\n begin\n cur:=1;\n for j:=1 to exp[m].p[i].cm do\n begin\n if exp[m].p[i].m[j].kind = 1 then v:=z else\n if exp[m].p[i].m[j].kind = 2 then v:=exp[m].p[i].m[j].num\n else v:=f[eval(exp[m].p[i].m[j].expid,z)];\n if exp[m].p[i].sn[j] then cur:=cur div v\n else cur:=(cur*v) mod 32768;\n end;\n if exp[m].p[i].sign then cur:=-cur;\n inc(res,cur);\n if res >= 32768 then dec(res,32768);\n if res < 0 then inc(res,32768);\n end;\n eval:=res;\nend;\n\nfunction get(z:longint):longint;\nvar\n i,zleft,zright: longint;\nbegin\n for i:=1 to n do\n begin\n zleft:=eval(left[i],z);\n zright:=eval(right[i],z);\n if (sign[i] = LESS) and (zleft < zright) or\n (sign[i] = EQUAL) and (zleft = zright) or\n (sign[i] = MORE) and (zleft > zright) then\n begin\n get:=eval(return[i],z);\n exit;\n end;\n end;\n get:=0;\nend;\n\nbegin\n// assign(input,'in'); reset(input);\n// assign(output,'out'); rewrite(output);\n read(need);\n kc:=0; can:=False;\n while not eof(input) do\n begin\n read(ch);\n if (ch = ' ') or (ch = #9) or (ch = #13) or (ch = #10) then continue;\n if ch = '{' then can:=True else\n if ch = '}' then can:=False else\n if can then\n begin\n inc(kc);\n c[kc]:=ch;\n end;\n end;\n sl:=''; n:=0;\n mm:=1;\n exp[1].cp:=1;\n exp[1].p[1].sign:=False;\n exp[1].p[1].cm:=1;\n exp[1].p[1].m[1].kind:=2;\n exp[1].p[1].m[1].num:=0;\n for i:=1 to kc do\n if c[i] = ';' then\n begin\n inc(n);\n ps:=Pos('r',sl);\n if ps = 1 then\n begin\n left[n]:=1;\n right[n]:=1;\n sign[n]:=EQUAL;\n end else\n begin\n st:=Copy(sl,4,ps-5);\n pz:=Pos('<',st);\n if pz > 0 then sign[n]:=LESS else\n begin\n pz:=Pos('>',st);\n if pz > 0 then sign[n]:=MORE else\n begin\n pz:=Pos('=',st);\n Delete(st,pz,1);\n sign[n]:=EQUAL;\n end;\n end;\n left[n]:=makeexpr(Copy(st,1,pz-1));\n right[n]:=makeexpr(Copy(st,pz+1,1000));\n Delete(sl,1,ps-1);\n end;\n return[n]:=makeexpr(Copy(sl,7,1000));\n sl:='';\n end\n else sl:=sl+c[i];\n ans:=-1;\n for z:=0 to 32767 do\n begin\n f[z]:=get(z);\n if f[z] = need then ans:=z;\n end;\n writeln(ans);\n close(input);\n close(output);\nend.", "src_uid": "698c5a87f9adbe6af60d9f70519c9672"} {"source_code": "var st,l,r:int64;\ns:string;\n\nfunction f(x:int64):int64;\nvar ans,l,y:int64;\nj,i,xx,yy:longint;\nss:string;\n begin\n if x<=9 then begin\n f:=x;\n exit;\n end;\n\n ans:=0;l:=1;\n str(x,s);\n for i:=1 to length(s)-1 do\n begin\n ans:=ans+9*l;\n if i<>1 then l:=l*10;\n end;\n val(s[1],xx,yy);\n ans:=ans+(xx-1)*(l) ;\n y:=0;\n for i:=2 to length(s)-1 do\n y:=y*10+ord(s[i])-48;\n // val(ss,y,xx);\n ans:=ans+y;\n if s[1]<=s[length(s)] then inc(ans);\n\n\n\n\n f:=ans;\n end;\n\n begin\n readln(l,r);\n writeln(f(r)-f(l-1));\n end.\n", "src_uid": "9642368dc4ffe2fc6fe6438c7406c1bd"} {"source_code": "program probe;\nvar\n\tn,i,j,k,l,last,count,x,tx,kk,p,tlast,sum,up,tl:longint;\n\tf:array[0..209,0..309,0..1,0..255] of double;\n\tans:double;\nfunction min(a,b:longint):longint;\n\tbegin\n\t\tif a0)and(x mod 2=tlast) do begin\n\t\t\tx:=x shr 1;\n\t\t\tinc(sum);\n\t\tend;\n\t\tf[0,sum,tlast,last]:=1;\n\tend;\n\tfor i:=0 to kk-1 do\n\t\tfor j:=0 to 309 do\n\t\t\tfor k:=0 to 1 do\n\t\t\t\tfor l:=0 to 255 do begin\n\t\t\t\t\tif l and (1 shl 7)<>0 then up:=1 else up:=0;\n\t\t\t\t\tif k=up then delta(i+1,min(300,j+1),k,(l mod 128)*2,f[i,j,k,l]*p/100)\n\t\t\t\t\telse delta(i+1,1,up,(l mod 128)*2,f[i,j,k,l]*p/100);\n\t\t\t\t\tif l<255 then delta(i+1,j,k,l+1,f[i,j,k,l]*(1-p/100))\n\t\t\t\t\telse if k=0 then delta(i+1,1,1,0,f[i,j,k,l]*(1-p/100))\n\t\t\t\t\telse delta(i+1,j,0,0,f[i,j,k,l]*(1-p/100));\n\t\t\t\tend;\n\tans:=0;\n\tfor j:=0 to 309 do begin\n\t\tfor k:=0 to 1 do begin\n\t\t\tfor l:=0 to 255 do begin\n\t\t\t\tif l=0 then begin\n\t\t\t\t\tif k=0 then sum:=8+j else sum:=8;\n\t\t\t\t\tans:=ans+sum*f[kk,j,k,l];\n\t\t\t\tend else begin\n\t\t\t\t\tsum:=0; tl:=l;\n\t\t\t\t\twhile (tl mod 2=0) do begin\n\t\t\t\t\t\tinc(sum); tl:=tl shr 1;\n\t\t\t\t\tend;\n\t\t\t\t\tans:=ans+sum*f[kk,j,k,l];\n\t\t\t\tend;\n\t\t\tend;\n\t\tend;\n\tend;\n\twriteln(ans:0:9);\nend.\n", "src_uid": "c9274249c26b1a85c19ab70d91c1c3e0"} {"source_code": "var i,j,k,l,m,n:longint;\n s,logs,temp,temp2,ans,ss,temp3,temp4,x,now,tt,one:int64;\n num:array[0..100]of int64;\n dp:array[0..150,-1..150,0..1]of int64;//\nfunction bis2(l,r:int64):int64;\nvar mid:int64;\nbegin\n if l=r then exit(l);\n mid:=(l+r)>>1;\n if mid<<(i+1)-mid>s then exit(bis2(l,mid)) else exit(bis2(mid+1,r));\nend;\nfunction bis(l,r:int64):int64;\nvar mid:int64;\nbegin\n if l=r then exit(l);\n mid:=(l+r)>>1;\n if (mid<<(i+1)+(mid<<1+1)<s) then exit(bis(l,mid)) else exit(bis(mid+1,r));\nend;\nfunction min(a,b:int64):int64;\nbegin\n if a>(max(i,j))+1)-1;\n if temp>0 then begin\n temp2:=s-(temp<<(i+1)+((temp<<1)or 1)< m) then\n begin\n inc(ans);\n dec(sum,a[j]);\n end;\n write(ans,' ');\n ans := 0;\n for j := 1 to i do\n a[i] := a1[i];\n end;\nend.", "src_uid": "d3c1dc3ed7af2b51b4c49c9b5052c346"} {"source_code": "var a,b,x,c,d,cnt:integer;\nfunction chek( a:integer):boolean;\nvar b,c:integer;\nvar n:boolean;\nbegin\nb:=a;\nn:=false;\nwhile(b>0) do begin\nif(b mod 10=7) then begin\nn:=true;\nbreak;\nend;\nb:=b div 10;\nend;\nif(n) then\nchek:=true\nelse\nchek:=false;\nend;\n\n\nbegin\nreadln(x);\nread(a,b);\nwhile not (chek(a) or chek(b)) do begin\nb:=b-x;\ncnt:=cnt+1;\nif(b<0) then begin\nb:=60+b;\na:=a-1;\nif(a<0) then\na:=24+a;\nend;\nend;\nwriteln(cnt);\nend.", "src_uid": "5ecd569e02e0164a5da9ff549fca3ceb"} {"source_code": "var s:string;n,i,sa,k:integer;\nbegin read(s);sa:=0;k:=0;\nfor i:=1 to length(s) do if s[i]='a' then sa:=sa+1 else k:=k+1;\nif sa>k then write(length(s))\nelse write(2*sa-1)\nend.", "src_uid": "84cb9ad2ae3ba7e912920d7feb4f6219"} {"source_code": " const eps=1e-12;\n besk=2002000000000000000; label 4,1,3,2,44;\n type mas=array[-100..1200000+1] of int64;\n integer=longint; zap=record p1,p2,p3:int64; end;\n zap1=^zap;\n var qq,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,ll,rr,bet,al:extended;\n ot1,ot2:zap;\n 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,m,finish,time,p3,p4,jj,qqqq,ii,tt,pmax,pmax2,p1,p2,ot,ott,hh,pos0,pos1,pos2,pp,mm,maxot,mnog,tmax,summax,n,nn,kk,modul,t0,n1,q,t,p:int64; flag1:boolean;\n invx,invy,summ,place,kol,str,b2,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..1000000] of boolean;\n zpl,zmi,path,lx,a2,a3,a4,dd1,dd2,predok,a1,b1,strok:array[-10000..1500000] of int64;\n ppole:array[-1000000..3000000] of char;\n stroka:array[-1000..1000000] of char;\n t1,t2,al1,bet1,cosa,sina,cosb,sinb,rx,ry,sdvigx,sdvigy,px,py,h1,h2,h,l1,l2,otmax,v:int64;\n 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,dd,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,z,nomer,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-10000..400002] of int64;\n ddd: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]p;\n for i:=p+1 to n do a[i]:=besk;\n sort(a);\n for i:=1 to p do write(a[i],' '); writeln;\n x[1]:=0;\n for i:=2 to p do x[i]:=x[i-1]+(a[i]-a[i-1])*(i-1);\n for i:=1 to p do write(x[i],' '); writeln;\n y[p]:=0;\n for i:=p-1 downto 1 do y[i]:=y[i+1]+(a[i+1]-a[i])*(p-i);\n for i:=1 to p do write(y[i],' '); writeln;\n\n\n goto 1;\n }\n read(n,cc,aa,bb);\n for i:=0 to 100000 do\n begin\n t:=bb*i;\n if ((cc-t) mod aa=0)and(cc-t>=0) then\n begin flag:=true; t2:=i; t1:=(cc-t) div aa; break; end;\n\n end;\n\n if not flag then begin writeln(-1); goto 1; end;\n if n>=(t1+t2) then writeln(t1,' ',t2,' ',n-t1-t2) else write(-1);\n\n\n\n\n\n\n\n\n\n\n 1: close (output);\n end.\n\n\n", "src_uid": "503116e144d19eb953954d99c5526a7d"} {"source_code": "var\na:array[1..99] of longint=(0,1,1,1,1,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,1,0,1,0,1,1,1,1,1,0,1,0,1,0,1,1,1,1,1,0,1,0,1,0,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0);\nn:longint;\nbegin\nread(n);\nif a[n]=1 then write('Yes')\n else write('No');\nend.", "src_uid": "821529a4644b74483bcdf80fc318d1f8"} {"source_code": "program C268;\nconst\n\tInp = '';\n\tOup = '';\nvar\n\tSum,Modul,K:int64;\n\tM:int64;\n\nprocedure Main();\nbegin\n\tassign(input,inp); reset(input);\n\tassign(output,oup); rewrite(output);\n\treadln(M);\n K:=10000000000000000;\n\tSum:=45*17;\n Sum:=Sum*K;\n Sum:=Sum+1;\n\tModul:=Sum mod M;\n\twriteln(M-Modul+1,' ',M-Modul+K*10);\nend;\n\nbegin\n\tMain();\nend.\n", "src_uid": "52b8d97f216ea22693bc16fadcd46dae"} {"source_code": "var l,d,v,g,r,vr,vrr,er:extended;\nbegin\nreadln(l,d,v,g,r);\nvr:=d/v;vrr:=vr-trunc(vr/(g+r))*(g+r);\nif vrr='A')and(s[i]<='Z') then sum:=sum+1;\n if sum<=length(s) div 2 then\n begin\n for i:=1 to length(s) do\n if (s[i]>='A')and(s[i]<='Z') then s2:=s2+chr(ord(s[i])+32)\n else s2:=s2+s[i];\n end\n else\n begin\n for i:=1 to length(s) do\n if (s[i]>='A')and(s[i]<='Z') then s2:=s2+s[i]\n else s2:=s2+chr(ord(s[i])-32);\n end;\n writeln(s2);\nend.", "src_uid": "b432dfa66bae2b542342f0b42c0a2598"} {"source_code": "var a, b, c, n, k, l, i, h, q\n:LongInt;\n s, r, t:String;\n Begin\n ReadLn(s);\n ReadLn(n);\n r:=s[1]+s[2];\n Val(r, a);\n t:=s[4]+s[5];\n Val(t, b);\n h:=a*60+b+n;\n k:=h mod 60;\n q:=h div 60 mod 24;\n if q=24 then q:=0;\n if (q<10) then Write('0',q,':')\n else Write(q,':');\n if k<10 then Write('0',k)\n else Write(k);\n // Write(h div 60 mod 24,':',k);\n\n\n End.", "src_uid": "20c2d9da12d6b88f300977d74287a15d"} {"source_code": "begin\n var a: array[1..30] of char := \n ('q', 'w', 'e', 'r', 't', \n 'y', 'u', 'i', 'o', 'p', 'a', \n 's', 'd', 'f', 'g', 'h', 'j', 'k', \n 'l', ';', 'z', 'x', 'c', 'v', 'b',\n 'n', 'm', ',', '.', '/');\n var a1 := ReadString;\n var b := ReadString;\n for var i := 1 to b.Length do \n begin\n for var j := 1 to 30 do \n begin\n if(b[i] = a[j]) then begin\n if(a1 = 'R') then begin\n if(b[i] = 'q') then\n b[i] := a[30] else b[i] := a[j - 1];\n break;\n end else begin\n if(b[i] = '/') then\n b[i] := a[1] else b[i] := a[j + 1];\n break;\n end;\n end;\n end;\n end;\n writeln(b);\nend.", "src_uid": "df49c0c257903516767fdb8ac9c2bfd6"} {"source_code": "program azbuka;\nvar\ni,o:string;\nj:longint;\nbegin\nreadln(i);\n\nwhile length(i)<>0 do\n begin\n if i[1]='.'\n then\n begin\n o:=o+'0';\n delete(i,1,1);\n end\n else\n begin\n if i[2]='.' then\n begin\n o:=o+'1';\n delete(i,1,2);\n end\n else\n begin\n o:=o+'2';\n delete(i,1,2);\n end;\n end;\n end;\n\nwriteln(o);\nend.", "src_uid": "46b5a1cd1bd2985f2752662b7dbb1869"} {"source_code": "var\n a: string;\n b : int64;\n i : longint;\nbegin\n\n read(a);\n if (a[1] >='5')and(a[1]<>'9') then a[1] := chr(57 - ord(a[1]) + 48);\n for i := 2 to length(a) do\n if a[i] >='5' then a[i] := chr(57 - ord(a[i]) + 48);\n writeln(a);\nend.", "src_uid": "d5de5052b4e9bbdb5359ac6e05a18b61"} {"source_code": "var\nn,m,k,r,d:longint;\ns:char;\nbegin\nreadln (n,m,k);\n\nif k mod (2*m)=0 then \n begin\n r:=k div (2*m);\n d:=m;\n s:='R';\n end\n \n else begin\n r:=(k div (2*m))+1;\n k:=k mod (2*m);\n if k mod 2=0 then \n begin\n d:=k div 2;\n s:='R';\n end\n else begin\n d:=(k div 2)+1;\n s:='L';\n end;\n end;\n\n \nwriteln (r,' ',d,' ',s);\nend.", "src_uid": "d6929926b44c2d5b1a8e6b7f965ca1bb"} {"source_code": "program codeforces;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils,\n Math;\n\nvar\n i, j, n, t : integer;\n ans, d : array[1..20, 1..20] of integer;\n p : array[1..20] of integer;\n\nprocedure gen(x, b, s : integer);\nvar i : integer;\nbegin\n if b = s + 1 then\n inc(d[x - 1, b]);\n if x > 20 then\n exit;\n if x = 1 then begin\n for i := 1 to 4 do begin\n p[1] := i;\n gen(x + 1, 0, 0);\n end;\n exit;\n end;\n if x = 2 then begin\n for i := 1 to 4 do\n if p[1] <> i then begin\n p[2] := i;\n gen(x + 1, 0, 0);\n end;\n exit;\n end;\n for i := 1 to 4 do\n if p[x - 1] <> i then begin\n p[x] := i;\n if (p[x - 1] > p[x - 2]) and (p[x - 1] > p[x]) then\n gen(x + 1, b + 1, s)\n else\n if (p[x - 1] < p[x - 2]) and (p[x - 1] < p[x]) then\n gen(x + 1, b, s + 1)\n else\n gen(x + 1, b, s);\n end;\nend;\n\n\nbegin\n {rewrite(output, 'output.txt');\n gen(1, 0, 0);\n for i := 3 to 20 do\n for j := 1 to 10 do\n writeln('ans[', i, ', ', j, '] := ', d[i, j], ';'); }\n ans[3, 1] := 14;\nans[3, 2] := 0;\nans[3, 3] := 0;\nans[3, 4] := 0;\nans[3, 5] := 0;\nans[3, 6] := 0;\nans[3, 7] := 0;\nans[3, 8] := 0;\nans[3, 9] := 0;\nans[3, 10] := 0;\nans[4, 1] := 22;\nans[4, 2] := 0;\nans[4, 3] := 0;\nans[4, 4] := 0;\nans[4, 5] := 0;\nans[4, 6] := 0;\nans[4, 7] := 0;\nans[4, 8] := 0;\nans[4, 9] := 0;\nans[4, 10] := 0;\nans[5, 1] := 16;\nans[5, 2] := 70;\nans[5, 3] := 0;\nans[5, 4] := 0;\nans[5, 5] := 0;\nans[5, 6] := 0;\nans[5, 7] := 0;\nans[5, 8] := 0;\nans[5, 9] := 0;\nans[5, 10] := 0;\nans[6, 1] := 6;\nans[6, 2] := 232;\nans[6, 3] := 0;\nans[6, 4] := 0;\nans[6, 5] := 0;\nans[6, 6] := 0;\nans[6, 7] := 0;\nans[6, 8] := 0;\nans[6, 9] := 0;\nans[6, 10] := 0;\nans[7, 1] := 1;\nans[7, 2] := 380;\nans[7, 3] := 353;\nans[7, 4] := 0;\nans[7, 5] := 0;\nans[7, 6] := 0;\nans[7, 7] := 0;\nans[7, 8] := 0;\nans[7, 9] := 0;\nans[7, 10] := 0;\nans[8, 1] := 0;\nans[8, 2] := 396;\nans[8, 3] := 1786;\nans[8, 4] := 0;\nans[8, 5] := 0;\nans[8, 6] := 0;\nans[8, 7] := 0;\nans[8, 8] := 0;\nans[8, 9] := 0;\nans[8, 10] := 0;\nans[9, 1] := 0;\nans[9, 2] := 284;\nans[9, 3] := 4500;\nans[9, 4] := 1782;\nans[9, 5] := 0;\nans[9, 6] := 0;\nans[9, 7] := 0;\nans[9, 8] := 0;\nans[9, 9] := 0;\nans[9, 10] := 0;\nans[10, 1] := 0;\nans[10, 2] := 142;\nans[10, 3] := 7414;\nans[10, 4] := 12122;\nans[10, 5] := 0;\nans[10, 6] := 0;\nans[10, 7] := 0;\nans[10, 8] := 0;\nans[10, 9] := 0;\nans[10, 10] := 0;\nans[11, 1] := 0;\nans[11, 2] := 48;\nans[11, 3] := 8849;\nans[11, 4] := 41160;\nans[11, 5] := 8997;\nans[11, 6] := 0;\nans[11, 7] := 0;\nans[11, 8] := 0;\nans[11, 9] := 0;\nans[11, 10] := 0;\nans[12, 1] := 0;\nans[12, 2] := 10;\nans[12, 3] := 8028;\nans[12, 4] := 92226;\nans[12, 5] := 76878;\nans[12, 6] := 0;\nans[12, 7] := 0;\nans[12, 8] := 0;\nans[12, 9] := 0;\nans[12, 10] := 0;\nans[13, 1] := 0;\nans[13, 2] := 1;\nans[13, 3] := 5658;\nans[13, 4] := 152140;\nans[13, 5] := 328222;\nans[13, 6] := 45425;\nans[13, 7] := 0;\nans[13, 8] := 0;\nans[13, 9] := 0;\nans[13, 10] := 0;\nans[14, 1] := 0;\nans[14, 2] := 0;\nans[14, 3] := 3112;\nans[14, 4] := 195420;\nans[14, 5] := 928494;\nans[14, 6] := 467292;\nans[14, 7] := 0;\nans[14, 8] := 0;\nans[14, 9] := 0;\nans[14, 10] := 0;\nans[15, 1] := 0;\nans[15, 2] := 0;\nans[15, 3] := 1322;\nans[15, 4] := 201744;\nans[15, 5] := 1947581;\nans[15, 6] := 2402980;\nans[15, 7] := 229347;\nans[15, 8] := 0;\nans[15, 9] := 0;\nans[15, 10] := 0;\nans[16, 1] := 0;\nans[16, 2] := 0;\nans[16, 3] := 422;\nans[16, 4] := 170444;\nans[16, 5] := 3213988;\nans[16, 6] := 8205152;\nans[16, 7] := 2758896;\nans[16, 8] := 0;\nans[16, 9] := 0;\nans[16, 10] := 0;\nans[17, 1] := 0;\nans[17, 2] := 0;\nans[17, 3] := 96;\nans[17, 4] := 118912;\nans[17, 5] := 4322956;\nans[17, 6] := 20852648;\nans[17, 7] := 16594160;\nans[17, 8] := 1157954;\nans[17, 9] := 0;\nans[17, 10] := 0;\nans[18, 1] := 0;\nans[18, 2] := 0;\nans[18, 3] := 14;\nans[18, 4] := 68640;\nans[18, 5] := 4846524;\nans[18, 6] := 41920210;\nans[18, 7] := 66357900;\nans[18, 8] := 15946870;\nans[18, 9] := 0;\nans[18, 10] := 0;\nans[19, 1] := 0;\nans[19, 2] := 0;\nans[19, 3] := 1;\nans[19, 4] := 32632;\nans[19, 5] := 4594423;\nans[19, 6] := 69183464;\nans[19, 7] := 197939352;\nans[19, 8] := 109824208;\nans[19, 9] := 5846414;\nans[19, 10] := 0;\nans[20, 1] := 0;\nans[20, 2] := 0;\nans[20, 3] := 0;\nans[20, 4] := 12628;\nans[20, 5] := 3715462;\nans[20, 6] := 96046590;\nans[20, 7] := 468541040;\nans[20, 8] := 503245466;\nans[20, 9] := 90700276;\nans[20, 10] := 0;\n read(n, t);\n writeln(ans[n, t]);\nend.\n", "src_uid": "6d67559744583229455c5eafe68f7952"} {"source_code": "Var\n s1,s2,s3 : string;\nBegin\n Readln(s1);\n Readln(s2);\n Readln(s3);\n If ((s1<>s2) and (s2<>s3) and (s1<>s3)) or ((s1=s2) and (s2=s3)) then Writeln('?') else\n\n If s1=s2 then\n Begin\n If s1='rock' then\n Begin\n If s3='paper' then Writeln('S') else\n If s3='scissors' then Writeln('?')\n End else\n If s1='paper' then\n Begin\n If s3='rock' then Writeln('?') else\n If s3='scissors' then Writeln('S')\n End else\n If s1='scissors' then\n Begin\n If s3='rock' then Writeln('S') else\n If s3='paper' then Writeln('?')\n End\n End else\n\n If s1=s3 then\n Begin\n If s1='rock' then\n Begin\n If s2='paper' then Writeln('M') else\n If s2='scissors' then Writeln('?')\n End else\n If s1='paper' then\n Begin\n If s2='rock' then Writeln('?') else\n If s2='scissors' then Writeln('M')\n End else\n If s1='scissors' then\n Begin\n If s2='rock' then Writeln('M') else\n If s2='paper' then Writeln('?')\n End\n End else\n\n If s2=s3 then\n Begin\n If s2='rock' then\n Begin\n If s1='paper' then Writeln('F') else\n If s1='scissors' then Writeln('?')\n End else\n If s2='paper' then\n Begin\n If s1='rock' then Writeln('?') else\n If s1='scissors' then Writeln('F')\n End else\n If s2='scissors' then\n Begin\n If s1='rock' then Writeln('F') else\n If s1='paper' then Writeln('?')\n End\n End\nEnd.", "src_uid": "072c7d29a1b338609a72ab6b73988282"} {"source_code": "var s,tg:int64;\n a,b:longint;\n\nBEGIN\n readln(a,b,s);\n tg:=s-abs(a)-abs(b);\n if (tg>=0) and (tg mod 2=0) then writeln('YES')\n else writeln('NO');\nEND.\n", "src_uid": "9a955ce0775018ff4e5825700c13ed36"} {"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 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,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..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]t2 then begin t:=t1; t1:=t2; t2:=t; end;\n t:=t2-t1;\n v:=t;\n v:=sqrt(v);\n for i:=1 to round(v) do if t mod i=0 then\n begin inc(q);x[q]:=i; inc(q); x[q]:=t div i; end;\n { for i:=1 to q do write(x[i],' '); writeln;\n } ot:=8000000000000000000;\n for i:=1 to q do\n begin\n t:=fg(x[i],t1,t2);\n { writeln('del= ',x[i],' dob= ',t);\n } p1:=t1+t; p2:=t2+t;\n { writeln('chisla= ',p1,' ',p2);\n } tt:=nod(p1,p2);\n tt:=(p1*p2) div tt;\n if tt=q;\n for i:=q+1 to n+2 do a[i]:=besk;\n sort(a);\n { for i:=1 to q do write(a[i],' ');\n writeln;\n } for i:=1 to q do if (a[i]>=p1)and(a[i]<=p2) then inc(ot);\n writeln(ot);\n\n\n\n\n\n\n\n\n\n 1: close (output);\n end.\n", "src_uid": "05fac54ed2064b46338bb18f897a4411"} {"source_code": "var n,m,t,i:longint;\na:array[0..100000]of longint;\nbegin\n//assign(input,'c.in');reset(input);\n//assign(output,'c.out');rewrite(output);\nreadln(n,m);\nwhile m>0 do\n begin\n inc(t);\n a[t]:=m mod n;\n m:=m div n;\n end;\nfor i:=1 to t+100 do\n if(a[i]>=n)then\n begin\n a[i+1]:=a[i+1]+a[i] div n;\n a[i]:=a[i] mod n;\n end\n else\n if(a[i]<>0)and(a[i]<>1)and(a[i]<>n-1)then\n begin\n writeln('NO');\n close(input);close(output);halt;\n end\n else\n if a[i]=n-1 then inc(a[i+1]);\nwrite('YES');\nclose(input);close(output);\nend.", "src_uid": "a74adcf0314692f8ac95f54d165d9582"} {"source_code": "var\nn,b,p,x,y,b1,i,j:integer;\nbegin\nreadln(n,b,p);\ni:=n;\nwhile i<>1 do\nbegin\nj:=i div 2;\nx:=x+j*(1+b*2);\ni:=i-j;\nend;\ny:=n*p;\nwriteln(x,' ',y);\nend.", "src_uid": "eb815f35e9f29793a120d120968cfe34"} {"source_code": "var\n l,r,a,i:longint;\nfunction min(x,y:longint):longint;\nbegin\n if x0 then\n begin\n if(d1[a[i,j]]<>0)and(d1[a[i,j]]<>b[i,j])then exit;\n if(d2[b[i,j]]<>0)and(d2[b[i,j]]<>a[i,j])then exit;\n d1[a[i,j]]:=b[i,j];d2[b[i,j]]:=a[i,j];\n end;\n s:=0;for i:=1 to max do if d2[i]=0 then s:=s+1;\n num:=1;for i:=1 to s do num:=num*(k-max+s+1-i)mod 1000000007;ans:=(ans+num)mod 1000000007;\n end;\nprocedure dfs(p,x,y,max:longint);\n var i,j:longint;\n begin\n if x>n then begin check(max);exit;end;\n if y>m then begin dfs(p,x+1,1,max);exit;end;\n for i:=1 to x do for j:=1 to y do inc(v[p,b[i,j]]);\n for i:=1 to max do if v[p,i]=0 then begin b[x,y]:=i;dfs(p+1,x,y+1,max);end;\n if(max+1<=k)and(v[p,max+1]=0)then begin b[x,y]:=max+1;dfs(p+1,x,y+1,max+1);end;\n for i:=1 to x do for j:=1 to y do dec(v[p,b[i,j]]);\n end;\nbegin\n readln(n,m,k);if n+m-1>k then begin writeln(0);halt;end;\n for i:=1 to n do for j:=1 to m do read(a[i,j]);\n dfs(1,1,1,0);writeln(ans);\nend.", "src_uid": "5bb21f49d976cfa16a239593a95c53b5"} {"source_code": "var n, ans: int64;\n i: longint;\nbegin\n read(n);\n ans := (n div 210)*48;\n for i := 1 to (n mod 210) do if ((((i mod 2 <> 0) and (i mod 3 <> 0)) and (i mod 5 <> 0)) and (i mod 7 <> 0)) then inc(ans);\n write(ans);\nend.", "src_uid": "e392be5411ffccc1df50e65ec1f5c589"} {"source_code": "var\ns:array[1..3,1..3]of longint;\ni,ii,n:longint;\nb,c:boolean;\nbegin\nc:=false;\nb:=false;\nfor i:=1 to 3 do\n begin\n for ii:=1 to 3 do\n read(s[i,ii]);\n readln;\n end;\nif (s[1,2]+s[1,3]>s[2,1]+s[2,3])and(s[1,2]+s[1,3]>s[3,1]+s[3,2]) then\n begin\n s[1,1]:=1;\n s[2,2]:=1+((s[1,2]+s[1,3])-(s[2,1]+s[2,3]));\n s[3,3]:=1+((s[1,2]+s[1,3])-(s[3,1]+s[3,2]));\n c:=true;\n end;\nif (s[1,2]+s[1,3]s[3,1]+s[3,2]) then\n begin\n s[2,2]:=1;\n s[1,1]:=1+((s[2,1]+s[2,3])-(s[1,2]+s[1,3]));\n s[3,3]:=1+((s[2,1]+s[2,3])-(s[3,1]+s[3,2]));\n c:=true;\n end;\nif (s[3,2]+s[3,1]>s[2,1]+s[2,3])and(s[1,2]+s[1,3]= j) and (l < 1) then\n k := k - j + ((1 - l) * 2 - 1) - ((1 - u) - 1) - (-l)\n else\n k := k + (u - 1) * 2 + 1;\n end;\n if r > n then\n if u < 1 then\n k := k - min(j + (u - 1), r - n) - (r - n - 1)\n else\n k := k - ((r - n) * 2 - 1);\n if d > n then\n begin\n if r > n then\n k := k - min(j - r + n, d - n)\n else\n k := k - (d - n);\n if l < 1 then\n k := k - min(j + (l - 1) - 1, d - n - 1)\n else\n k := k - (d - n - 1);\n end;\n end;\n \n write (j-1);\nend.", "src_uid": "232c5206ee7c1903556c3625e0b0efc6"} {"source_code": "uses math;\nconst fi='';\n fo='';\nvar n,a,b,p,q,c,r,t1,t2:int64;\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 exit(x);\nend;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n readln(n,a,b,p,q);\n c:=n div (a*b div gcd(a,b));\n r:=n div a*p+n div b*q;\n if p0)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\n\n\n function fib(nn:int64):int64; var i,j,k,step:longint; p,t,q:int64;\n begin\n matr[1,1,0]:=1;\n matr[2,1,0]:=1;\n matr[1,2,0]:=1;\n for i:=1 to 2 do for j:=1 to 2 do for step:=1 to 100 do matr[i,j,step]:=0;\n { writeln(modul);\n } for step:=1 to 60 do for i:=1 to 2 do for j:=1 to 2 do for k:=1 to 2 do\n matr[i,j,step]:=(matr[i,j,step]+matr[i,k,step-1]*matr[k,j,step-1]) mod modul;\n\n p:=nn; q:=0;\n mm[1,1,0]:=1; mm[2,2,0]:=1;\n for i:=1 to 2 do for j:=1 to 2 do for step:=1 to 100 do mm[i,j,step]:=0;\n\n t:=0;\n while p>0 do begin inc(t); a[t]:=p mod 2; p:=p div 2; end;\n { for i:=1 to t do write(a[i],' '); writeln;\n } for step:=1 to t do if a[step]>0 then\n begin\n inc(q);\n for i:=1 to 2 do for j:=1 to 2 do for k:=1 to 2 do\n mm[i,j,q]:=(mm[i,j,q]+matr[i,k,step-1]*mm[k,j,q-1]) mod modul;\n\n end;\n fib:=mm[1,1,q];\n\n end;\n\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n\n read(n,kk,l,modul); t:=0;\n while kk>0 do begin inc(qq); c[qq]:=kk mod 2; kk:=kk div 2; end;\n { for i:=1 to l do writeln(i,' ',c[i],' '); writeln;\n } ot:=1;\n p:=fib(n+1);\n tt:=degg(2,n);\n { writeln(p,' ',tt,' ',tt-p);\n\n }\n { for i:=1 to qq do writeln(i,' ',c[i]);\n }\n flag:=true;\n for i:=1 to 10000 do if (c[i]=1)and(i>l) then flag:=false;\n if not flag or (modul=1) then begin write(0); goto 1; end;\n for step:=1 to l do\n begin\n if c[step]=0 then ot:=(ot*p) mod modul\n else ot:=(ot*(tt-p+modul)) mod modul;\n if (c[step]=1)and(step>qq) then ot:=0;\n { writeln(step,' == ',c[step]);\n if c[step]=1 then writeln(step,' ',p,'*') else writeln(step,' ',(tt-p+modul) mod modul,'*');\n }\n end;\n {writeln;\n } writeln(ot);\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n\n", "src_uid": "2163eec2ea1eed5da8231d1882cb0f8e"} {"source_code": "var n:int64;\nbegin\nread(n);\nwrite(n*n+(n-1)*(n-1));\nend.", "src_uid": "758d342c1badde6d0b4db81285be780c"} {"source_code": "var\n k,x:longint;\nbegin\n read(k);\n case k mod 10 of\n 0..5:x:=0;\n 6..9:x:=1;\n end;\n write((k div 10+x)*10);\nend.", "src_uid": "29c4d5fdf1328bbc943fa16d54d97aa9"} {"source_code": "\n var a,i:integer; m:array [1..10000] of integer;\n\nbegin\nreadln(a);\nfor i:=1 to a do begin\nread(m[i]);\nend;\nfor i:=1 to a-1 do begin\nif abs(m[i]-m[i+1])>=2 then begin writeln('NO'); exit; end;\nend;\nwriteln('YES');\nend.", "src_uid": "704d0ae50bccaa8bc49319812ae0be45"} {"source_code": "const p=998244353;\nvar i,k,j,n,m:longint;a,b:array[0..2001]of int64;\nbegin\n read(n,m,k);\n a[0]:=m;\n for j:=1 to n-1 do\n begin\n b:=a;\n for i:=1 to K do\n a[i]:=(B[I]+B[I-1]*(M-1)) MOD P;\n end;\n WRITE(A[K])\nend.", "src_uid": "b2b9bee53e425fab1aa4d5468b9e578b"} {"source_code": "var\n k1, k2, u1, u2, a, t1, b, t2, l, k: real;\n\nbegin\n read(a, b, t1, t2);\n k1 := (3 * a) / 10;\n k2 := (3 * b) / 10;\n u1 := a - (a / 250) * t1;\n u2 := b - (b / 250) * t2;\n if k1 > u1 then\n begin\n k := k1;\n end\n else\n begin\n k := u1;\n end;\n if k2 > u2 then\n begin\n l := k2;\n end\n else\n begin\n l := u2;\n end;\n if k > l then writeln('Misha');\n if k < l then writeln('Vasya');\n if k = l then writeln('Tie');\nend.", "src_uid": "95b19d7569d6b70bd97d46a8541060d0"} {"source_code": "const\n fi='';\nvar\n f:text;\n n,a,b,c,kq:longint;\nprocedure nhap;\nbegin\n assign(f,fi);\n reset(f);\n readln(f,n,a,b,c);\n close(f);\nend;\nprocedure xuly;\nvar\n i,j,u,v:longint;\nbegin\n for i:=0 to b do\n for j:=0 to c do\n begin\n u:=n-(i+2*j);\n if u>=0 then\n begin\n u:=u*2;\n if a>=u then inc(kq);\n end;\n end;\n writeln(kq);\nend;\nbegin\n nhap;\n xuly;\nend.", "src_uid": "474e527d41040446a18186596e8bdd83"} {"source_code": "uses math;\nconst inf=1e30;\n\teps=1e-8;\ntype\text=\textended;\n\tvc=\tobject\n\t\t\tx,y:ext;\n\t\t\tfunction length:ext;\n\t\t\tfunction sqrlen:ext;\n\t\t\tfunction zoom(const l:ext):vc;\n\t\t\tfunction vtl:vc;\n\t\tend;\n\t\n\tfunction fsqrt(const x:ext):ext; begin if abs(x)>1];\n\trepeat\n\t\twhile cmp(x,p[i]) do inc(i);\n\t\twhile cmp(p[j],x) do dec(j);\n\t\tif not(i>j) then\n\t\tbegin y:=p[i];\n\t\t\tp[i]:=p[j];\n\t\t\tp[j]:=y;\n\t\t\tinc(i);\n\t\t\tj:=j-1;\n\t\tend;\n\tuntil i>j;\n\tif l=2)and(cross(minus(s1[top1],s1[top1-1]),minus(p[i],s1[top1-1]))=2)and(cross(minus(s2[top2],s2[top2-1]),minus(p[i],s2[top2-1]))RR*RR+eps); end;\n\t\nprocedure lemon;\nvar n,i,all,l,r:longint;\n theta,ans:extended;\nbegin readln(n,RR);\n\tfor i:=1 to n do readln(p[i].x,p[i].y);\n\tif n<=1 then begin writeln('0.0000000000'); exit; end;\n\tgraham(n);\n\n\tall:=0;\n\tfor i:=1 to n do\n\tbegin while (all>1)and(dot(minus(s1[all],s1[all-1]),minus(p[i],star(plus(s1[all],s1[all-1]),0.5)))>eps)and(out(s1[all-1],s1[all],p[i])) do dec(all);\n\t\tinc(all); s1[all]:=p[i];\n\tend;\n\tl:=1; r:=all;\n\twhile l+1 a[j]) and (a[j] <= k) then f:=f+1\n else break;\n writeln(f);\nend.", "src_uid": "ecf0ead308d8a581dd233160a7e38173"} {"source_code": "program zz;\n\nvar a,b,s,m,j,i,c,k,n,z:int64;\nbegin\n {assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);}\n read(m,n,s);\n if m mod s=0 then a:=m else a:=(m div s+1)*(m mod s);\n if n mod s=0 then b:=n else b:=(n div s+1)*(n mod s);\n write(a*b);\n\n\n\n{ close(input);\n close(output); }\nend.\n", "src_uid": "e853733fb2ed87c56623ff9a5ac09c36"} {"source_code": "var\n k,g:int64;\n i,j,n:longint;\n a:array [0..100000] of int64;\nbegin\nreadln(n,k);\nfor i:=1 to n do\n a[i]:=a[i-1]*2+1;\nfor i:=n downto 1 do\n if a[i] 0) and (s < n) do begin\n s := s + v div den;\n den := den * k;\n end;\n result := s >= n;\nend;\n\nfunction bsearch(l, r: integer): integer;\nbegin\n while l < r - 2 do\n if calculate((l + r) div 2, k) then\n r := (l + r) div 2 + 1\n else\n l := (l + r) div 2 + 1;\n if calculate(l, k) then\n result := l\n else\n result := r - 1\nend;\n\n\nfunction solve: integer;\nbegin\n result := bsearch(0, n+1)\nend;\n\nprocedure save(value: integer);\nbegin\n writeln(value);\nend;\n\nbegin\n init;\n readdata;\n save(solve);\n readln;readln;\nend.\n", "src_uid": "41dfc86d341082dd96e089ac5433dc04"} {"source_code": "var s,n,m:integer;\nbegin\nread(n,m);\ns:=1;\nwhile (s<=m) and (n>0) do begin dec(n); s:=s*2; end;\nwrite(m mod s);\nend.", "src_uid": "c649052b549126e600691931b512022f"} {"source_code": "program cf560B;\nuses math;\nvar a1s,b1s,a2s,b2s,a3s,b3s:integer;\nbegin\nread(a1s,b1s,a2s,b2s,a3s,b3s);\n\nif ((a2s+a3s<=a1s) and (max(b2s,b3s)<=b1s)) or ((a2s+a3s<=b1s) and (max(b2s,b3s)<=a1s))\nor ((a2s+b3s<=a1s) and (max(b2s,a3s)<=b1s))\nor ((a2s+b3s<=b1s) and (max(b2s,a3s)<=a1s))\n\nor ((b2s+b3s<=b1s) and (max(a2s,a3s)<=a1s)) or ((b2s+b3s<=a1s) and (max(a2s,a3s)<=b1s))\nor ((b2s+a3s<=b1s) and (max(a2s,b3s)<=a1s))\nor ((b2s+a3s<=a1s) and (max(a2s,b3s)<=b1s))\n\nthen writeln('YES')\nelse writeln('NO');\nend.\n", "src_uid": "2ff30d9c4288390fd7b5b37715638ad9"} {"source_code": "var\n\tx, y, z: integer;\n\tn, m: integer;\n\t\n\t\nbegin\n\t{$string_nullbased+}\n\t\n\treadln(x, y, z);\n\tn := x + z;\n\tm := y + z;\n\tif ((n > y) and (m < x)) then writeln('+')\n\telse if ((m > x) and (n < y)) then writeln('-')\n\telse if ((n = y) and (m = x)) then writeln(0)\n\telse writeln('?');\n\t\nend.\n", "src_uid": "66398694a4a142b4a4e709d059aca0fa"} {"source_code": "{$apptype console}\n{$r+,q+,s+,i+,o+}\n{$ifdef fpc}\n{$mode delphi}\n{$endif}\n{ $minstacksize 5000000}\n{ $define files}\nuses SysUtils;\nvar n:integer;\n s:string;\n i,j,k:integer;\n ok:boolean;\n\nbegin\nDecimalSeparator:='.';\n{$ifdef files}\nassign(input,'a.in');reset(input);\nassign(output,'a.out');rewrite(output);\n{$endif}\nreadln(n);\nreadln(s);\nfor i:=1 to n do begin\n if s[i]='.' then continue;\n for j:=1 to n do begin\n if i+4*j>n then continue;\n ok:=true;\n for k:=1 to 4 do\n if s[i+k*j]='.' then ok:=false;\n if ok then begin\n writeln('yes');\n halt;\n end;\n end;\nend;\nwriteln('no');\nend.", "src_uid": "12d451eb1b401a8f426287c4c6909e4b"} {"source_code": "var c:char;\nn,i,j,res:longint;\nans:array [0..10] of string;\ns:string;\nbegin\nans[1]:='vaporeon';\nans[2]:='jolteon';\nans[3]:='flareon';\nans[4]:='espeon';\nans[5]:='umbreon';\nans[6]:='leafeon';\nans[7]:='glaceon';\nans[8]:='sylveon';\n\nreadln(n);\nfor i:=1 to n do begin\n read(c);\n s:=s+c;\nend;\nfor i:=1 to 8 do begin\n// writeln(length(ans[i]));\n if length(ans[i])=n then begin\n j:=1;\n while ((ans[i][j]=s[j]) or (s[j]='.')) and (j b then\n Res := (Res + F[i, k]) Mod Base;\n\n\n Writeln(Res);\n End;\n {-----------------------------------------------------------------------------------------}\n BEGIN\n Openf;\n Process;\n END.", "src_uid": "142b06ed43b3473513995de995e19fc3"} {"source_code": "uses math;\nvar\n i,j,a,b,c,res,temp:longint;\n\n\nbegin\n read(a,b,c);\n res:=res+a div 3;\n res:=res+b div 3;\n res:=res+c div 3;\n temp:=res;\n a:=a-1;\n b:=b-1;\n c:=c-1;\n if (a>=0) and (b>=0) and (c>=0) then\n begin\n res:=0;\n res:=res+a div 3;\n res:=res+b div 3;\n res:=res+c div 3;\n temp:=max(temp,res+1);\n end;\n a:=a-1;\n b:=b-1;\n c:=c-1;\n if (a>=0) and (b>=0) and (c>=0) then\n begin\n res:=0;\n res:=res+a div 3;\n res:=res+b div 3;\n res:=res+c div 3;\n temp:=max(temp,res+2);\n end;\n writeln(temp);\nend.", "src_uid": "acddc9b0db312b363910a84bd4f14d8e"} {"source_code": "{$R+}{$Q+}\nUses math;\nConst md=1000000009;\nVar a,rez,n,w,b:int64;\ni:longint;\nfac:array [0..10000] of int64;\nfunction pow(k,z:int64):int64;\nVar x:int64;\nbegin\n if z=0\n then pow:=1\n else begin\n x:=pow(k,z div 2);\n x:=(x*x) mod md;\n if z mod 2=1\n then x:=(x*k) mod md;\n pow:=x;\n end;\nend;\nfunction c(k,n:int64):int64;\nbegin\n if k>n\n then c:=0\n else c:=(fac[n]*pow((fac[k]*fac[n-k])mod md,md-2)) mod md;\nend;\nfunction ff(a,b:longint):int64;\nbegin\n ff:=(fac[b+a-1]*pow(fac[b-1], md-2)) mod md;\nend;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n readln(n,w,b);\n fac[0]:=1;\n for i:=1 to 10000 do\n fac[i]:=(fac[i-1]*i) mod md;\n rez:=0;\n for i:=2 to n do\n if (n-i>=1)and(i<=w)and(n-i<=b)\n then begin\n a:=i-1;\n a:=(a*fac[i]) mod md;\n a:=(a*fac[n-i]) mod md;\n a:=(a*c(i,w)) mod md;\n a:=(a*c(n-i,b)) mod md;\n a:=(a*ff(w-i,i)) mod md;\n a:=(a*ff(b-n+i,n-i)) mod md;\n rez:=(rez+a) mod md;\n// rez:=(rez+(i-1)*(fac[i]*fac[n-i] mod md)*(c(i,w)*c(n-i,b) mod md)*(ff(w-i,i)*ff(b-n+i,n-i) mod md)) mod md;\n end;\n writeln(rez);\nend.", "src_uid": "63e93a161bbff623323e66c98d5e20ac"} {"source_code": "var n:int64;\n begin\n readln(n);\n n:=sqr(n-2);\n write(n);\n end.", "src_uid": "efa8e7901a3084d34cfb1a6b18067f2b"} {"source_code": "{$o-}\nvar\n ch : char;\n n,m,i : longint;\n hour,minut : string; \n h,min : extended;\nbegin\n {assign(input,'a.in'); } reset(input);\n {assign(output,'a.out'); } rewrite(output);\n n:=0;\n m:=0;\n for i:=1 to 5 do begin\n read(ch);\n if (i=1) or (i=2) then\n n:=n*10+(ord(ch)-48) else\n if (i=4) or (i=5) then\n m:=m*10+(ord(ch)-48);\n end;\n if (n>=12) then n:=n - 12;\n h:=(n*30)+(m/60)*30;\n min:=(m / 5)*30;\n write(h:0:6,' ',min:0:6);\n close(input);\n close(output);\nend.", "src_uid": "175dc0bdb5c9513feb49be6644d0d150"} {"source_code": "Var n,i,rez,a,b:longint;\nm:array [1..1000000] of LongInt;\nbegin\n// Assign(input,'input.txt'); reset(input);\n// Assign(output,'output.txt'); rewrite(output);\n readln(n);\n rez:=0; a:=0;b:=0;\n for i:=1 to n do\n begin\n m[i]:=1;\n if Odd(i)\n then begin\n m[i]:=(m[i]+b) mod 1000000007;\n a:=(a+m[i])mod 1000000007;\n end\n else begin\n m[i]:=(m[i]+a)mod 1000000007;\n b:=(b+m[i])mod 1000000007;\n end;\n rez:=(rez+m[i]) mod 1000000007;\n end;\n Writeln(rez);\nend.", "src_uid": "5c4bd12df3915186a7b506c2060db125"} {"source_code": "type mas=record\n p,x:longint;\n end;\nfunction max(a,b:longint):longint;\nbegin\nif a>b then max:=a else max:=b;\nend;\n\nvar n,c,i,sum1,sum2,x:longint;\nA:array [1..100] of mas;\nbegin\nreadln(n,c);\nfor i:=1 to n do\nread(A[i].p);\n\nfor i:=1 to n do\nread(A[i].x);\n\nx:=0;\nsum1:=0;\nfor i:=1 to n do\nbegin\nx:=x+A[i].x;\nsum1:=sum1+max(0,A[i].p-c*x);\nend;\n\nx:=0;\nsum2:=0;\nfor i:=n downto 1 do\nbegin\nx:=x+A[i].x;\nsum2:=sum2+max(0,A[i].p-c*x);\nend;\n\nif sum1>sum2 then writeln('Limak') else\n if sum2>sum1 then writeln('Radewoosh') else\n writeln('Tie');\n\nend.\n", "src_uid": "8c704de75ab85f9e2c04a926143c8b4a"} {"source_code": "const mod1=1000000007;\nvar\nk,q,x,r,i,n:int64;\nfunction phi (n:int64):int64;\nbegin\n r:=n;\n i:=2;\n while sqr(i)<=n do begin\n if n mod i = 0 then begin\n while n mod i = 0 do n:=n div i;\n r:=r-r div i;\n end;\n inc(i);\n end;\n if n>1 then r:=r-r div n;\n phi:=r;\nend;\nbegin\nreadln(x,k);\nphi(x);\nq:=k div 2;\nif k mod 2= 1 then inc(q);\nk:=1;\nwhile true do begin\n x:=phi(x);\n if x=1 then break;\n inc(k);\n if k>q then break;\nend;\nwriteln(x mod mod1 );\nend.", "src_uid": "0591ade5f9a69afcbecd80402493f975"} {"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\nvar\n i, ls, lh, lm, mnh, mnm, hmn, mmn : longint;\n s, mm, hh : string;\n ch, cm : char;\n\nfunction max(a, b : char) : char; overload;\nbegin\n if a > b then result := a else result := b;\nend;\n\nconst \n DIGITS : array[1..36] of char = ('0', '1', '2', '3', '4', '5', '6', '7', '8',\n '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',\n 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q',\n 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');\n\nfunction PToDec(p : longint; n : string) : int64;\n\nvar \n current, step, index : int64; \n i, j : longint;\n \nbegin\n step := 1;\n current := 0;\n for i := length(n) downto 1 do begin\n index := 1;\n for j := 1 to 36 do \n if digits[j] = n[i] then index := j;\n current := current + step * (index - 1);\n step := step * p;\n end;\n ptodec := current;\nend;\n\nprocedure put(x : longint);\nbegin\n write(x);\n halt(0);\nend;\n \nbegin\n readln(s);\n ls := length(s);\n hh := '';\n mm := '';\n i := 1;\n while s[i] <> ':' do begin\n if (hh = '') and (s[i] = '0') then else hh := hh + s[i];\n inc(i);\n end;\n inc(i);\n while i <= ls do begin\n if (mm = '') and (s[i] = '0') then else mm := mm + s[i];\n inc(i);\n end;\n if hh = '' then hh := '0';\n if mm = '' then mm := '0';\n lh := length(hh);\n lm := length(mm);\n ch := #0;\n for i := 1 to lh do\n ch := max(ch, hh[i]);\n cm := #0;\n for i := 1 to lm do\n cm := max(cm, mm[i]);\n mnh := 0;\n for i := 1 to 36 do\n if digits[i] = ch then begin\n mnh := i;\n break;\n end;\n mnh := max(mnh, 2);\n mnm := 0;\n for i := 1 to 36 do\n if digits[i] = cm then begin\n mnm := i;\n break;\n end;\n mnm := max(mnm, 2);\n hmn := ptodec(mnh, hh);\n mmn := ptodec(mnm, mm);\n if (hmn > 23) or (mmn > 59) then put(0);\n if (lh = 1) and (lm = 1) then put(-1);\n i := max(mnh, mnm);\n while true do begin\n hmn := ptodec(i, hh);\n mmn := ptodec(i, mm);\n if (hmn < 24) and (mmn < 60) then write(i, ' ') else break;\n inc(i);\n end;\nend.", "src_uid": "c02dfe5b8d9da2818a99c3afbe7a5293"} {"source_code": "program LH;\nvar\n i,n,t:longint;\nbegin\n readln(n);n:=n*2;\n for i:=1 to trunc(sqrt(n)) do\n begin\n t:=n-i*(i+1);\n if (t<=0) then break;\n if (t=trunc(sqrt(t))*(trunc(sqrt(t))+1)) then\n begin\n writeln('YES');\n halt;\n end;\n end;\n writeln('NO');\nend.\n", "src_uid": "245ec0831cd817714a4e5c531bffd099"} {"source_code": "var i,j,n,x,y,amin,amax,g:longint;\n min,max,s,w:array[0..7,0..7] of longint;\n v:array[0..7] of longint;\nprocedure tt(x,y:longint);\nvar i,j,f,g:longint;\n q:boolean;\n begin\n for i:=1 to x-1 do\n begin\n f:=0;\n for j:=i+1 to n do\n f:=f+w[i,j];\n if f>v[i] then exit;\n end;\n if x=n then begin\n if v[1]=v[n] then begin\n q:=true;\n for i:=1 to n-1 do\n begin\n f:=0;\n for j:=i+1 to n do\n begin\n if (w[i,j]max[i,j]) then begin\n q:=false;\n exit;\n end;\n\n f:=f+w[i,j];\n end;\n if f<>v[i] then begin\n q:=false;\n exit;\n end;\n end;\n if q then begin\n f:=0;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if w[i,j]>0 then f:=f+s[i,j]+sqr(w[i,j]);\n if (v[1]amax)) then begin\n amin:=v[1];\n amax:=f;\n end;\n end;\n end;\n exit;\n end;\n for i:=min[x,y] to max[x,y] do\n begin\n v[y]:=v[y]+i;\n w[x,y]:=i;\n if y+1>n then tt(x+1,x+2)\n else tt(x,y+1);\n v[y]:=v[y]-i;\n w[x,y]:=0;\n end;\n end;\n\n begin\n read(n);\n g:=0;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n begin\n read(x,y);\n read(min[x,y],max[x,y],s[x,y]);\n g:=g+min[x,y];\n end;\n amin:=100;\n amax:=0;\n for i:=0 to 80 do\n begin\n fillchar(v,sizeof(v),0);\n fillchar(w,sizeof(w),0);\n v[1]:=i;\n tt(1,2);\n if amin<100 then break;\n end;\n if amin=100 then writeln('-1 -1')\n else writeln(amin,' ',amax);\n end.\n", "src_uid": "38886ad7b0d83e66b77348be34828426"} {"source_code": "var i,j,a,b1,b,anss:longint;\n ans:array[1..100] of longint;\nbegin\n readln(a,b1);\n b:=b1;\n anss:=0;\n fillchar(ans,sizeof(ans),0);\n while (b>a) do\n begin\n if (b mod 10=1) then\n begin\n\t b:=b div 10;\n\t inc(anss);\n\t ans[anss]:=b;\n\tend\n\telse if (b mod 2=0) then\n\tbegin\n\t b:=b div 2;\n\t inc(anss);\n\t ans[anss]:=b;\n\tend\n\telse\n\tbegin\n\t writeln('NO');\n\t halt;\n\tend;\n end;\n if (b=a) then\n begin\n writeln('YES');\n writeln(anss+1);\n for i:=anss downto 1 do\n\t\twrite(ans[i],' ');\n\twriteln(b1);\n end else writeln('NO');\nend.\n ", "src_uid": "fc3adb1a9a7f1122b567b4d8afd7b3f3"} {"source_code": "const\n c: array['0'..'9'] of longint = (6, 2, 5, 5, 4, 5, 6, 3, 7, 6);\nvar\n i, a, b, sum: longint;\n s, n: ansistring;\n\nbegin\n readln(a, b);\n for i:= a to b do\n begin\n str(i, n);\n s:= s + n;\n end;\n for i:= 1 to length(s) do\n inc(sum, c[s[i]]);\n writeln(sum);\nend.\n", "src_uid": "1193de6f80a9feee8522a404d16425b9"} {"source_code": "{$R-,S-,Q-,I-,O+}\nvar\n typ,aux: array [0..1111] of longint;\n b,dd,d,x,i: 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\n else b:=b mod a;\n gcd:=a+b;\nend;\n\nbegin\n read(b,dd);\n for d:=2 to dd do\n begin\n typ[d]:=0;\n x:=1;\n for i:=1 to 1000 do\n begin\n x:=x*b mod d;\n if x = 0 then\n begin\n typ[d]:=2;\n aux[d]:=i;\n break;\n end;\n end;\n if typ[d] = 0 then\n if b mod d = 1 then typ[d]:=3 else\n if b mod d = d-1 then typ[d]:=11 else\n begin\n for i:=2 to d-1 do\n if d mod i = 0 then\n if gcd(i,d div i) = 1 then\n if (typ[i] <> 7) and (typ[d div i] <> 7) then\n begin\n typ[d]:=6;\n break;\n end;\n if typ[d] = 0 then typ[d]:=7;\n end;\n end;\n writeln(typ[dd],'-type');\n if typ[dd] = 2 then writeln(aux[dd]);\nend.", "src_uid": "809e1c78b0a5a16f7f2115b046a20bde"} {"source_code": "var s,s1:string;\ni,j,a,a1,b,b1,c,d,n,m:longint;\nbegin\nreadln(n,m);\ns:=s+'1';\ns1:=s1+'1';\nif (n=1) and (m=0) then writeln(0,' ',0)\n else\n if (((n*9)0) or (p<>0) do\nbegin\nt1:=x mod 2;\nt2:=p mod 2;\n// writeln(t1,' ',t2);\nif (t1=1) then \nbegin\nif t2=1 then begin write('0'); exit; end else z:=2*z;\nend;\nx:=x div 2;\np:=p div 2; \nend;\nif h=0 then z:=z-2;\nwrite(z);\nend.", "src_uid": "18410980789b14c128dd6adfa501aea5"} {"source_code": "Var n , k , s , p : Int64;\n Ans : Int64;\n \nFunction Max(tam1 , tam2 : Int64) : Int64;\n Begin If tam1 > tam2 then Exit(tam1) else Exit(tam2); End;\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;\nProcedure Sort1(l , r : Longint);\n Var i , j , x , y : Longint;\n Begin\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 not (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 sort1(l , j);\n If i < r then sort1(i , r);\n End; }\n \nBegin\n Readln(k , n , s , p);\n Ans := n;\n If (Ans mod s = 0) then Ans := Ans div s else Ans := Ans div s + 1; Ans := Ans * k;\n If (Ans mod p = 0) then Ans := Ans div p else Ans := Ans div p + 1;\n Writeln(Ans);\nEnd.", "src_uid": "73f0c7cfc06a9b04e4766d6aa61fc780"} {"source_code": "const\n inf=10000000000;\nvar\n a:array [0..2222,0..2222] of Extended;\n N,T,i,j:Longint;\n ans,p:Extended;\nbegin\n Readln(N,P,T);\n a[0,0]:=1;\n for i:=0 to T do\n for j:=0 to N do\n if j=N then a[i+1,j]:=a[i+1,j]+a[i,j]\n else begin\n a[i+1,j+1]:=a[i+1,j+1]+a[i,j]*P;\n a[i+1,j]:=a[i+1,j]+a[i,j]*(1-p);\n end;\n ans:=0;\n for i:=0 to N do\n ans:=ans+a[t,i]*i;\n Writeln(ans:0:6);\n end.\n ", "src_uid": "20873b1e802c7aa0e409d9f430516c1e"} {"source_code": "var\n a, b, c, d, i, j: int64;\n ar: array [1..3, 1..3] of char;\n q, q1: boolean;\n \nbegin\n b := 0;\n c := 0;\n i := 1;\n while i <= 3 do begin\n j := 1;\n while j <= 3 do begin\n read(ar[i, j]);\n if ar[i, j] = 'X' then inc(b);\n if ar[i, j] = '0' then inc(c);\n inc(j);\n end;\n readln;\n inc(i);\n end;\n if c > b then begin\n writeln('illegal');\n halt();\n end;\n if c + 1 < b then begin\n writeln('illegal');\n halt();\n end;\n q := false;\n q1 := false;\n i := 1;\n while i <= 3 do begin\n if (ar[i, 1] = 'X') and (ar[i, 2] = ar[i, 1]) and (ar[i, 2] = ar[i, 3]) then q := true;\n if (ar[1, i] = 'X') and (ar[1, i] = ar[2, i]) and (ar[1, i] = ar[3, i]) then q := true;\n if (ar[i, 1] = '0') and (ar[i, 2] = ar[i, 1]) and (ar[i, 2] = ar[i, 3]) then q1 := true;\n if (ar[1, i] = '0') and (ar[1, i] = ar[2, i]) and (ar[1, i] = ar[3, i]) then q1 := true;\n inc(i);\n end;\n if (ar[1, 1] = 'X') and (ar[1, 1] = ar[2, 2]) and (ar[2, 2] = ar[3, 3]) then q := true;\n if (ar[3, 1] = 'X') and (ar[2, 2] = ar[3, 1]) and (ar[2, 2] = ar[1, 3]) then q := true;\n if (ar[1, 1] = '0') and (ar[1, 1] = ar[2, 2]) and (ar[2, 2] = ar[3, 3]) then q1 := true;\n if (ar[3, 1] = '0') and (ar[2, 2] = ar[3, 1]) and (ar[2, 2] = ar[1, 3]) then q1 := true;\n if (not(q)) and (not(q1)) and (b + c = 9) then begin\n writeln('draw');\n halt();\n end;\n if (not(q)) and (not(q1)) then begin\n if b = c then writeln('first')\n else writeln('second');\n halt();\n end;\n if (q) and (b = c) then begin\n writeln('illegal');\n halt();\n end;\n if (q) and (q1) then begin\n writeln('illegal');\n halt();\n end;\n if (q1) and (b > c) then begin\n writeln('illegal');\n halt();\n end;\n if q then writeln('the first player won')\n else writeln('the second player won');\nend.", "src_uid": "892680e26369325fb00d15543a96192c"} {"source_code": "var a,s,d,f,g,h,j,k,l,i,ii:longint;\nz:array[1..100000]of longint;\nbegin\nreadln(a);\nfor i:=1 to a do\nread(z[i]);\nfor i:=1 to a do\ns:=s+z[i];\nif s=0 then\nbegin\n l:=1;\n while (s=0)and(l<=a) do\n begin\n s:=s+z[l];\n inc(l);\n end;\n if l<=a then\n begin\n writeln('YES');\n writeln(2);\n writeln(1,' ',l-1);\n writeln(l,' ',a);\n end\n else writeln('NO');\nend\nelse\nbegin\n writeln('YES');\n writeln(1);\n writeln(1,' ',a);\nend;\nend.", "src_uid": "3a9258070ff179daf33a4515def9897a"} {"source_code": "var\n n,i,k,max:longint;\nbegin\n readln(n);\n max:=-maxlongint;\n for i:=1 to n do\n begin\n read(k);\n if (k>max) then max:=k;\n end;\n write(max xor k);\nend.", "src_uid": "f45c769556ac3f408f5542fa71a67d98"} {"source_code": "const\n\tmodule=998244353;\nvar\n\tcb:array[0..5005,0..5005] of int64;\n\tp:array[0..5005] of int64;\n\ta,b,c,ans,ans1,ans2,ans3:int64;\n\nprocedure init;\nvar\n\ti,j:longint;\nbegin\n\tfillchar(cb,sizeof(cb),0);\n\tcb[0,0]:=1;\n\tfor i:=1 to 5000 do\n\t\tbegin\n\t\t\tcb[i,0]:=1;\n\t\t\tfor j:=1 to i do\n\t\t\t\tcb[i,j]:=(cb[i-1,j]+cb[i-1,j-1]) mod module;\n\t\tend;\n\tp[1]:=1;\n\tfor i:=2 to 5000 do p[i]:=p[i-1]*i mod module;\nend;\n\nprocedure solve1;\nvar\n\ti:longint;\n\ttmp:int64;\nbegin\n\tans1:=1;\n\tfor i:=1 to a do\n\t\tbegin\n\t\t\ttmp:=cb[a,i]*cb[b,i] mod module*p[i] mod module;\n\t\t\tans1:=(ans1+tmp) mod module;\n\t\tend;\nend;\n\nprocedure solve2;\nvar\n\ti:longint;\n\ttmp:int64;\nbegin\n\tans2:=1;\n\tfor i:=1 to a do\n\t\tbegin\n\t\t\ttmp:=cb[a,i]*cb[c,i] mod module*p[i] mod module;\n\t\t\tans2:=(ans2+tmp) mod module;\n\t\tend;\nend;\n\nprocedure solve3;\nvar\n\ti:longint;\n\ttmp:int64;\nbegin\n\tans3:=1;\n\tfor i:=1 to b do\n\t\tbegin\n\t\t\ttmp:=cb[b,i]*cb[c,i] mod module*p[i] mod module;\n\t\t\tans3:=(ans3+tmp) mod module;\n\t\tend;\nend;\n\nbegin\n\tinit;\n\treadln(a,b,c);\n\tsolve1;\n\tsolve2;\n\tsolve3;\n\tans:=ans1*ans2 mod module*ans3 mod module;\n\twrite(ans);\nend.", "src_uid": "b6dc5533fbf285d5ef4cf60ef6300383"} {"source_code": "var a:array[1..100] of longint;\n i,n,d,min,j,k:longint;\n\nprocedure qsort(l,r:longint);\nvar x,w: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 begin\n w:=a[i]; a[i]:=a[j]; a[j]:=w;\n inc(i); dec(j);\n end;\nuntil i>j;\nif ld) do begin inc(k);dec(j);end;\nif kmax) then max:=now;\n\t now:=0;\n\t end\n\t else\n\t begin\n\t if (now>0) then inc(ans);\n\t\tnow:=0;\n\t end;\n\tend;\n\tif (ch[i]='(') then flag:=false;\n\tif (ch[i]=')') then flag:=true;\n\tinc(i);\n end;\n\tif (now>0) then\n\tbegin\n\t if not(flag) then inc(ans);\n\t if flag and(now>max) then max:=now;\n\tend;\n\twriteln(max,' ',ans);\nend.\n\t\t", "src_uid": "fc86df4931e787fa3a1a40e2aecf0b92"} {"source_code": "{$mode objfpc}\n\n\nconst InputFile = 'problemB.inp';\n baseD = trunc( 1E9 ) + 9;\n\n\nvar i , n , m : integer;\n res , tmp : int64;\n\n\nfunction power( p : integer ) : int64;\n var t : int64;\n begin\n if p = 0 then exit( 1 );\n if p = 1 then exit( 2 );\n t := power( p div 2 );\n result := ( t * t ) mod baseD;\n if odd( p ) then\n result := ( result * 2 ) mod baseD;\n end;\n\n\n\nbegin\n readln( n , m );\n tmp := power( m ) mod baseD;\n res := 1;\n for i := 1 to n do\n res := ( res * ( tmp - i ) ) mod baseD;\n writeln( res mod baseD );\nend.\n\n", "src_uid": "fef4d9c94a93fcf6d536f33503b1d4b8"} {"source_code": "var\ni:longint;\nind,n,min,m,ans,h,dl:int64;\nbegin\nreadln(n);\nmin:=1000000000;\nfor i:=1 to n do begin\n dl:=n div i;\n h:=i;\n ans:=dl*2+h*2;\n m:=n mod i;\n if m>0 then inc(anS,2);\n if ans= m then\n write(m + ord(m = 0))\n else\n write(n - m);\nend.", "src_uid": "c05d0a9cabe04d8fb48c76d2ce033648"} {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nconst\n eps = 1e-8;\n\ntype\n Tpoint = record\n x, y : double;\n end;\n\nvar\n point : array[0..500] of Tpoint;\n ans : array[0..5001] of double;\n al, ar, bl, br : integer;\n\nbegin\n\n read(al, ar, bl, br);\n if (br + 1 >= al) then begin\n if br <= al * 2 + 2 then begin\n writeln('YES');\n halt;\n end;\n end;\n if (bl + 1 >= ar + 1) then begin\n if bl <= ar * 2 + 2 then begin\n writeln('YES');\n halt;\n end;\n end;\n\n writeln('NO');\n \nend.\n", "src_uid": "36b7478e162be6e985613b2dad0974dd"} {"source_code": "var n,m:longint;\nbegin\nreadln(n,m);\nif n=m then writeln(n) else writeln(2);\nend.", "src_uid": "a8d992ab26a528f0be327c93fb499c15"} {"source_code": "\nuses math;\nvar h,d,a,hy,ay,dy,hm,am,dm,hp,atk,def,min,kc: longint;\n\nfunction ok(hy,ay,dy: longint) : boolean;\nvar s1,s2: longint;\nbegin\n if ay<=dm then exit(false);\n if am<=dy then exit(true);\n s1:=hm div (ay-dm);\n if hm mod (ay-dm) <> 0 then inc(s1);\n s2:=hy div (am-dy);\n if hy mod (am-dy) <> 0 then inc(s2);\n exit(s1t do begin\nfor i:integer:=1 to n-1 do \nif (s[i]='B') and (s[i+1]='G') then begin\ns1[i]:='G';\ns1[i+1]:='B';\nend;\ns:=s1;\nk:=k+1;\nend;\nwriteln(s);\nend.\n", "src_uid": "964ed316c6e6715120039b0219cc653a"} {"source_code": "var\n a1,b1,a2,b2,a3,b3,a4,b4,c:char;\n c1,d1,c2,d2,p1,u1,p2,u2,c3,d3,c4,d4,k,f:longint;\nbegin\n readln(a1,b1,c,a2,b2);\n c1:=ord(a1)-48;\n d1:=ord(b1)-48;\n c2:=ord(a2)-48;\n d2:=ord(b2)-48;\n p1:=(c1*10+d1)*60+c2*10+d2;\n\n read(a3,b3,c,a4,b4);\n c3:=ord(a3)-48;\n d3:=ord(b3)-48;\n c4:=ord(a4)-48;\n d4:=ord(b4)-48;\n p2:=(c3*10+d3)*60+c4*10+d4;\n f:=p1-p2;\n if f<0 then k:=1440+f else k:=f;\n\n if k div 60<10 then write('0');\n write(k div 60,':');\n if k mod 60<10 then write('0');\n writeln(k mod 60);\nend.", "src_uid": "595c4a628c261104c8eedad767e85775"} {"source_code": "var i,j,m,n:longint;\n a:array[0..100005]of longint;\n x:extended;\nbegin\nread(n);\nfor i:=1 to n do read(a[i]);\nfor i:=1 to n-1 do begin\nfor j:=i+1 to n do begin\nif a[i]>a[j] then begin\nm:=a[i];\na[i]:=a[j];\na[j]:=m;\nend;\nend;\nend;\n\nfor j:=1 to 2 do for i:=1 to 200000000 do x:=x+0.5;\nfor i:=1 to n do write(a[i],' ');\nend.", "src_uid": "29e481abfa9ad1f18e6157c9e833f16e"} {"source_code": "const\n\tgene='ACTG';\nvar\n\ts: string;\n\tn, c, num: integer;\nfunction distance(x, y: char):integer;\nbegin\n\tif abs(ord(x)-ord(y)+1)<=13 then exit(abs(ord(x)-ord(y)))\n\telse exit(26-(abs(ord(x)-ord(y))))\nend;\n\nprocedure count;\nvar\n\ti, j:integer;\nbegin\n\tfor i:=1 to n-3 do\n\tbegin\n\t\tc:=0;\n\t\tfor j:=1 to 4 do inc(c, distance(s[i+j-1], gene[j]));\n\t\tif num>c then num:=c;\n\tend;\nend;\n\nbegin\n\treadln(n);\n\treadln(s);\n\tnum:=32767;\n\tcount;\n\twrite(num);\nend.", "src_uid": "ee4f88abe4c9fa776abd15c5f3a94543"} {"source_code": "var\n a, b, i, j, x: longint;\n\nbegin\n x := 1;\n readln(a, b);\n if a > b then\n j := b \n else j := a;\n for i := 1 to j do \n x := x * i;\n writeln(x);\nend.", "src_uid": "7bf30ceb24b66d91382e97767f9feeb6"} {"source_code": "{R+,S+,Q+,I+,O-}\n{$R-,S-,Q-,I-,O+}\nvar\n s: array [0..20010] of string;\n score,pred,last,ss,ff,first,second,len: array [0..30010] of longint;\n st: string;\n win: array [0..20010] of boolean;\n sq: array [0..33] of string;\n p,num,ll,rr,mid,nn,max,j,cur,sum,m,cf,cs,n,i,ii,jj: longint;\n cw: boolean;\n\nprocedure Sort(l,r:longint);\nvar\n i,j,pp,x,tt: longint;\n xx,tmp: string;\nbegin\n i:=l; j:=r;\n pp:=l+random(r-l+1);\n x:=len[pp]; xx:=s[pp];\n repeat\n while (len[i] < x) or (len[i] = x) and (s[i] < xx) do inc(i);\n while (x < len[j]) or (x = len[j]) and (xx < s[j]) do dec(j);\n if i <= j then\n begin\n tt:=len[i]; len[i]:=len[j]; len[j]:=tt;\n tmp:=s[i]; s[i]:=s[j]; s[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 readln(nn);\n n:=0;\n for i:=1 to nn do\n begin\n readln(sq[i]);\n for ii:=1 to length(sq[i]) do\n for jj:=ii to length(sq[i]) do\n begin\n inc(n);\n s[n]:=Copy(sq[i],ii,jj-ii+1);\n len[n]:=jj-ii+1;\n end;\n end;\n inc(n);\n s[n]:='';\n len[n]:=0;\n Sort(1,n);\n ii:=1;\n for i:=2 to n do\n if s[i] <> s[ii] then\n begin\n inc(ii);\n s[ii]:=s[i];\n len[ii]:=len[i];\n end;\n n:=ii;\n for i:=1 to n do\n begin\n max:=0; sum:=0;\n for j:=1 to length(s[i]) do\n begin\n cur:=Ord(s[i,j])-96;\n if cur > max then max:=cur;\n inc(sum,cur);\n end;\n score[i]:=max*sum;\n for j:=1 to nn do\n if Pos(s[i],sq[j]) > 0 then inc(score[i]);\n end;\n fillchar(last,sizeof(last),0);\n m:=0;\n for i:=2 to n do\n for j:=0 to 1 do\n begin\n if j = 0 then st:=Copy(s[i],2,len[i])\n else st:=Copy(s[i],1,len[i]-1);\n num:=0;\n ll:=1; rr:=i;\n while ll < rr do\n begin\n mid:=(ll+rr) shr 1;\n if s[mid] = st then\n begin\n num:=mid;\n break;\n end;\n if (len[mid] < len[i]-1) or (len[mid] = len[i]-1) and (s[mid] < st) then ll:=mid+1\n else rr:=mid-1;\n end;\n if s[ll] = st then num:=ll;\n if num > 0 then\n begin\n inc(m);\n ss[m]:=num;\n ff[m]:=i;\n pred[m]:=last[num];\n last[num]:=m;\n end;\n end;\n for i:=n downto 1 do\n begin\n win[i]:=False;\n first[i]:=0;\n second[i]:=0;\n j:=last[i];\n while j > 0 do\n begin\n p:=ff[j];\n cw:=not win[p];\n cf:=score[p]+second[p];\n cs:=first[p];\n if (cw > win[i]) or (cw = win[i]) and ((cf > first[i]) or (cf = first[i]) and (cs < second[i])) then\n begin\n win[i]:=cw;\n first[i]:=cf;\n second[i]:=cs;\n end;\n j:=pred[j];\n end;\n end;\n if win[1] then writeln('First')\n else writeln('Second');\n writeln(first[1],' ',second[1]);\n close(input);\n close(output);\nend.", "src_uid": "d0f8976d9b847f7426dc56cb59b5b5b9"} {"source_code": "{$MODE OBJFPC}\nConst\n Fi='';//471A.INP';\n Fo='';//471A.OUT';\nVar Count:Array[0..10] of Integer;\n\nProcedure Main;\nVar i:Longint;\nBegin\n For i:=1 to 10 do\n If Count[i]=1 then\n Begin\n Writeln('Bear');\n Exit;\n End\n Else\n If Count[i]=2 then\n Begin\n Writeln('Elephant');\n Exit;\n End;\nEnd;\n\nProcedure Enter;\nVar x,i:Longint;\nBegin\n For i:=1 to 6 do\n Begin\n Read(x);\n Inc(Count[x]);\n End;\n For i:=0 to 10 do\n If Count[i]>=4 then\n Begin\n Dec(Count[i],4);\n Main;\n Exit;\n End;\n Writeln('Alien');\nEnd;\n\nBEGIN\n Assign(Input,Fi); Reset(Input);\n Assign(Output,Fo); Rewrite(Output);\n\n Enter;\n\n Close(Input);\n Close(Output);\nEND.", "src_uid": "43308fa25e8578fd9f25328e715d4dd6"} {"source_code": " var n,m,k,x,y,min,max,ans,Kont,z,o: int64;\n i,j: integer;\n A:array[1..111,1..111] of int64;\n Vox:real;\n begin\n \n readln(n,m,k,x,y);\n o:=k;\n if n<>1 then\n Kont:=(k-m) div (((n-1)*m)*2)\n else\n begin\n min:=k div m;\n max:=min;\n if k mod m<>0 then\n max:=min+1;\n k:=k-min*m;\n if y<=k then\n ans:=min+1\n else\n ans:=min;\n writeln(max,' ',min,' ',ans);\n exit;\n end;\n \n z:=(Kont*(n-1)*m*2) div (2*N*M-2*m);\n \n K:=K-Kont*(n-1)*m*2-m;\n \n if k<=0 then\n begin\n for i:=1 to (k+m) do\n A[1,i]:=1;\n writeln(1,' ',0,' ',A[x,y]);\n exit;\n end;\n \n if z<>0 then\n for i:=1 to m do\n begin\n A[1,i]:=z+1;\n A[n,i]:=z;\n min:=z;\n max:=2*z;\n end\n else\n begin\n for i:=1 to m do\n A[1,i]:=1;\n end;\n \n for i:=2 to n-1 do\n for j:=1 to m do\n A[i,j]:=2*z;\n \n for i:=2 to n do\n for j:=1 to m do\n begin\n if k=0 then\n break;\n k:=k-1;\n A[i,j]:=A[i,j]+1;\n if A[i,j]>max then\n max:=A[i,j];\n end;\n \n for i:=n-1 downto 1 do\n for j:=1 to m do\n begin\n if k=0 then\n break;\n k:=k-1;\n A[i,j]:=A[i,j]+1;\n if A[i,j]>max then\n max:=A[i,j];\n end;\n \n\n\n if n=2 then\n max:=A[1,1];\n \n writeln(max,' ',A[n,m],' ',A[x,y]);\n \n end.\n ", "src_uid": "e61debcad37eaa9a6e21d7a2122b8b21"} {"source_code": "\nconst fi='text.inp'; fo='text,out';\nvar n,dem,i:longint; sum:array[1..10000] of longint; f2:text;\nprocedure nhap;\nvar f1:text;\nbegin\n\n readln(n);\n\nend;\nprocedure processlon;\nvar i,m,tong1,tong:longint;\nbegin\n for i:=(n-90) to n do\n begin\n tong:=i;\n m:=i;\n while m<>0 do\n begin\n tong1:=m mod 10;\n m:=m div 10;\n tong:=tong+tong1;\n end;\n if tong=n then\n begin\n inc(dem);\n sum[dem]:=i;\n end;\n\n end;\nend;\n\nprocedure processbe;\nvar i,m,tong1,tong,tongg:longint;\nbegin\n for i:=1 to n do\n begin\n tong:=i;\n m:=i;\n tongg:=0;\n while m<>0 do\n begin\n tong1:=m mod 10;\n m:=m div 10;\n tongg:=tongg+tong1;\n end;\n tong:=tong+tongg;\n if tong=n then\n begin\n inc(dem);\n sum[dem]:=i;\n end;\n\n end;\nend;\nbegin\n nhap;\n\n if n>80 then processlon else processbe;\n writeln(dem);\n for i:=1 to dem do writeln(sum[i]);\n\nend.\n\n", "src_uid": "ae20ae2a16273a0d379932d6e973f878"} {"source_code": "{$R-,S-,Q-,I-,O+}\nconst co: int64 = 129581259982959;\nvar\n pw,h,hr: array [0..400010] of int64;\n d,bad,i,n: longint;\n ok: boolean;\n c: char;\n s: ansistring;\n\nfunction pal(a,b:longint):boolean;\nvar\n direct,reverse: int64;\nbegin\n direct:=(h[b]-h[a-1]*pw[b-a+1])*pw[a-1];\n reverse:=hr[b]-hr[a-1];\n pal:=direct = reverse;\nend;\n\nbegin\n readln(d);\n readln(s);\n n:=length(s);\n pw[0]:=1;\n for i:=1 to n do pw[i]:=pw[i-1]*co;\n h[1]:=0; hr[1]:=0;\n bad:=n;\n for i:=1 to n do\n begin\n h[i]:=h[i-1]*co+Ord(s[i]);\n hr[i]:=hr[i-1]+pw[i-1]*Ord(s[i]);\n if i >= d then\n if pal(i-d+1,i) then\n begin\n bad:=i;\n break;\n end;\n if i >= d+1 then\n if pal(i-d,i) then\n begin\n bad:=i;\n break;\n end;\n end;\n ok:=False;\n for i:=bad downto 1 do\n begin\n for c:=Chr(Ord(s[i])+1) to 'z' do\n begin\n s[i]:=c;\n h[i]:=h[i-1]*co+Ord(s[i]);\n hr[i]:=hr[i-1]+pw[i-1]*Ord(s[i]);\n if i >= d then\n if pal(i-d+1,i) then continue;\n if i >= d+1 then\n if pal(i-d,i) then continue;\n ok:=True;\n break;\n end;\n if ok then\n begin\n bad:=i;\n break;\n end;\n end;\n if not ok then writeln('Impossible') else\n begin\n for i:=bad+1 to n do\n for c:='a' to 'z' do\n begin\n s[i]:=c;\n h[i]:=h[i-1]*co+Ord(s[i]);\n hr[i]:=hr[i-1]+pw[i-1]*Ord(s[i]);\n if i >= d then\n if pal(i-d+1,i) then continue;\n if i >= d+1 then\n if pal(i-d,i) then continue;\n break;\n end;\n for i:=1 to n do write(s[i]);\n writeln;\n end;\nend.", "src_uid": "959a274a06219f4a8c061cd6f5b17160"} {"source_code": "type arr = array[1..200009] of longint;\nvar n, k, i, lr, lo, lw, ans: longint;\n a, r, o, w: arr;\n s: string;\n\nprocedure write_arr(a:arr; len:longint);\nvar i:integer;\nbegin\n for i:=1 to len do write(a[i], ' ');\n writeln;\nend;\n\nprocedure sort(var a:arr; len:longint);\n procedure _sort(l, r: longint);\n var i, j, x, tmp: longint;\n begin\n // writeln(l, ' ', r);\n i:=l; j:=r; 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 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 _sort(l, j);\n if (i < r) then _sort(i, r);\n end;\nbegin\n _sort(1, len);\nend;\n\nfunction get_o_with(a:arr):longint;\nvar res, i, j, cnt:longint;\nbegin\n res := a[1] + o[1];\n i := 2;\n j := 2;\n for cnt := 3 to k do \n begin\n if ((j > lo) or (a[i] > o[j])) then\n begin\n inc(res, a[i]);\n inc(i);\n end else\n begin\n inc(res, o[j]);\n inc(j);\n end;\n end;\n exit(res);\nend;\n\nfunction max(a, b:longint):longint;\nbegin\n if (a > b) then exit(a) else exit(b);\nend;\n\nbegin\n readln(n, k);\n for i:=1 to n do read(a[i]);\n readln; readln(s);\n \n lr:=0; lo:=0; lw:=0;\n for i:=1 to n do \n if (s[i] = 'R') then \n begin\n inc(lr);\n r[lr]:=a[i];\n end else\n if (s[i] = 'O') then \n begin\n inc(lo);\n o[lo]:=a[i];\n end else\n if (s[i] = 'W') then \n begin\n inc(lw);\n w[lw]:=a[i];\n end;\n \n if ((k=1) or (lo=0) or (lr+lw=0) or ((lo+lr 0) and (lo + lr >= k)) then ans := max(ans, get_o_with(r));\n if ((lw > 0) and (lo + lw >= k)) then ans := max(ans, get_o_with(w));\n writeln(ans);\nend.", "src_uid": "104cf5253e027929f257364b3874c38b"} {"source_code": "const p=51123987;\nvar\n n,i,j,a,b,c,ans:longint;\n f:array[0..150,0..52,0..52,0..52] of longint;\n nn:array[0..3,0..151] of longint;\n s:string;\nbegin\n readln(n);\n readln(s);\n for i:=n downto 1 do begin\n for j:=1 to 3 do nn[j,i]:=nn[j,i+1];\n case s[i] of\n 'a':nn[1,i]:=i;\n 'b':nn[2,i]:=i;\n 'c':nn[3,i]:=i;\n end;\n end;\n f[1,0,0,0]:=1;\n for i:=1 to n do begin\n for a:=0 to n div 3+1 do begin\n for b:=0 to n div 3+1 do begin\n for c:=0 to n div 3+1 do begin\n if f[i,a,b,c]=0 then continue;\n if nn[1,i]<>0 then f[nn[1,i],a+1,b,c]:=(f[nn[1,i],a+1,b,c]+f[i,a,b,c]) mod p;\n if nn[2,i]<>0 then f[nn[2,i],a,b+1,c]:=(f[nn[2,i],a,b+1,c]+f[i,a,b,c]) mod p;\n if nn[3,i]<>0 then f[nn[3,i],a,b,c+1]:=(f[nn[3,i],a,b,c+1]+f[i,a,b,c]) mod p;\n if a+b+c<>n then continue;\n if (abs(a-b)>1) or (abs(a-c)>1) or (abs(b-c)>1) then continue;\n ans:=(ans+f[i,a,b,c]) mod p;\n end;\n end;\n end;\n end;\n writeln(ans);\nend.", "src_uid": "64fada10630906e052ff05f2afbf337e"} {"source_code": "var s: string;\nm,k,ak,i: longint;\nbegin\nreadln (s);\nk:=1;\nak:=1;\nm:=length(s);\nif m mod 2 = 0 then\n begin\n for i:=1 to m div 2 do\n begin\n if s[i]<>s[m-i+1] then k:=0;\n if (i>1) and (s[i]<>s[i-1]) then ak:=0;\n end;\n if k=0 then writeln (m);\n if (k=1) and (ak=1) then writeln ('0');\n if (k=1) and (ak=0) then writeln (m-1);\n end;\nif m mod 2 = 1 then\n begin\n for i:=1 to m div 2 do\n begin\n if s[i]<>s[m-i+1] then k:=0;\n if (i<(m+1) div 2) and (s[i]<>s[i+1]) then ak:=0;\n end;\n if k=0 then writeln (m);\n if (k=1) and (ak=1) then writeln ('0');\n if (k=1) and (ak=0) then writeln (m-1);\n end;\nend.", "src_uid": "6c85175d334f811617e7030e0403f706"} {"source_code": "var\ns:string;\ni,n,kr,kb,ky,kg:integer;\nk:array[1..4] of integer;\nbegin\nread(s);\nfor i:=1 to length(s) div 4 do begin\nn:=(i-1)*4;\nif s[n+1] = '!' then inc(k[1]);\nif s[n+2] = '!' then inc(k[2]);\nif s[n+3] = '!' then inc(k[3]);\nif s[n+4] = '!' then inc(k[4]);\nend;\nn:=length(s) mod 4;\ncase n of\n1: if s[length(s)] = '!' then inc(k[1]);\n2: begin if s[length(s)] = '!' then inc(k[2]); if s[length(s)-1] = '!' then inc(k[1]); end ;\n3: begin if s[length(s)] = '!' then inc(k[3]); if s[length(s)-1] = '!' then inc(k[2]); if s[length(s)-2] = '!' then inc(k[1]); end;\nend;\nif pos('R',s) <> 0 then kr:= pos('R',s) mod 4; if kr = 0 then kr:=4;\nif pos('B',s) <> 0 then kb:= pos('B',s) mod 4; if kb = 0 then kb:=4;\nif pos('Y',s) <> 0 then ky:= pos('Y',s) mod 4; if ky = 0 then ky:=4;\nif pos('G',s) <> 0 then kg:= pos('G',s) mod 4; if kg = 0 then kg:=4;\nwrite(k[kr],' ',k[kb],' ',k[ky],' ',k[kg]);\nend.\n", "src_uid": "64fc6e9b458a9ece8ad70a8c72126b33"} {"source_code": "var a:array[1..100] of longint;\nn,m,i,j,max,d:longint;\nbegin\n read(n,m);\n for i:=1 to n do read(a[i]);\n\n for i:=1 to n do\n begin\n if a[i] mod m=0 then a[i]:=a[i]-1;\n if (a[i] div m)>=max then\n begin\n max:=a[i] div m;\n d:=i;\n end;\n\n end; write(d);\nend.\n", "src_uid": "c0ef1e4d7df360c5c1e52bc6f16ca87c"} {"source_code": "var\n\tn, m, k, i, pr, u, j: longint;\n\ta: array [0..10000] of longint;\n\tans: int64;\n\n\nbegin\n// reset(input, 'a.in');\n//\trewrite(output, 'a.out');\n\treadln(n, m, k);\n if (k * 2 >= n) or (k * 2 >= m) then begin\n write(0);\n halt;\n end;\n\tfor i := 2 * k + 1 to n - 1 do begin\n\t\tpr := 2; u := i;\n\t\twhile (u > 1) do begin\n\t\t\twhile u mod pr = 0 do begin\n\t\t\t\tinc(a[pr]);\n u := u div pr;\n\t\t\tend;\n\t\t\tinc(pr);\n\t\tend;\n if u > 1 then inc(a[u]);\n\tend;\n for i := 2 to n - 2 * k - 1 do begin\n \tpr := 2; u := i;\n\t\twhile (u > 1) do begin\n\t\t\twhile u mod pr = 0 do begin\n\t\t\t\tdec(a[pr]);\n u := u div pr;\n\t\t\tend;\n\t\t\tinc(pr);\n\t\tend;\n if u > 1 then dec(a[u]); \t\n end;\n ans := 1;\n for i := 1 to n - 1 do \n \tif a[i] > 0 then begin\n \t\tfor j := 1 to a[i] do\n \t\t\tans := (ans * int64(i)) mod 1000000007;\n \t \ta[i] := 0;\n \tend;\n\n \tfor i := 2 * k + 1 to m - 1 do begin\n\t\tpr := 2; u := i;\n\t\twhile (u > 1) do begin\n\t\t\twhile u mod pr = 0 do begin\n\t\t\t\tinc(a[pr]);\n u := u div pr;\n\t\t\tend;\n\t\t\tinc(pr);\n\t\tend;\n if u > 1 then inc(a[u]);\n\tend;\n for i := 2 to m - 2 * k - 1 do begin\n \tpr := 2; u := i;\n\t\twhile (u > 1) do begin\n\t\t\twhile u mod pr = 0 do begin\n\t\t\t\tdec(a[pr]);\n u := u div pr;\n\t\t\tend;\n\t\t\tinc(pr);\n\t\tend;\n if u > 1 then dec(a[u]); \t\n end;\n for i := 1 to m - 1 do \n \tif a[i] > 0 then begin\n \t\tfor j := 1 to a[i] do\n \t\t\tans := (ans * int64(i)) mod 1000000007;\n \t \ta[i] := 0;\n \tend;\n \twrite(ans);\nend.", "src_uid": "309d2d46086d526d160292717dfef308"} {"source_code": "Var \n ans:longint;\n ch:char;\nBegin\n ans:=0;\n while not eoln do\n begin\n read(ch);\n if ch in['A'..'Z'] then ans:=ans+ord(ch)-64;\n if ch in['a'..'z'] then ans:=ans-(ord(ch)-96);\n end;\n writeln(ans);\nEnd.", "src_uid": "d3fa5a3a008048dc4a9fbce1ebc61d67"} {"source_code": "{$R+ Q+ I+}\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\nvar\n n,m : integer;\nfunction min(x,y : integer) : integer;\nbegin\n if x2*b then break\n else if pr[i]=1 then begin\n j:=i+i;\n while j<=2*b do begin\n pr[j]:=0;\n j:=j+i;\n end;\n end;\n for i:=1 to 2*b do pr[i]:=pr[i]+pr[i-1];\n l:=1; r:=b-a+1;\n while l0) or (s[1]='n') then writeln('YES') else writeln('NO');\n end else begin\n for i:=2 to length(s) do\n if (pos(' '+s[i]+' ',b)=0) and (pos(' '+s[i-1]+' ',b)=0) and (s[i-1]<>'n') then begin write('NO'); exit; end;\n if (pos(' '+s[length(s)]+' ',b)=0) and (s[length(s)]<>'n') then\n writeln('NO') else writeln('YES'); end;\nend.", "src_uid": "a83144ba7d4906b7692456f27b0ef7d4"} {"source_code": "type tlist=record\n last,pred,y:array[0..1000000] of longint;\n size:longint;\nend;\nvar v,k,n,m,x,y,i:longint;\n col:array[0..1000000] of longint;\n used:array[0..1000000] of boolean;\n g:tlist;\n any:boolean;\n procedure add(x,y:longint);\n begin\n inc(g.size);\n g.pred[g.size]:=g.last[x];\n g.y[g.size]:=y;\n g.last[x]:=g.size;\n end;\n begin\n read(n,m);\n for i:=1 to m do\n begin\n read(x,y);\n add(x,y);\n add(y,x);\n end;\n for i:=1 to n do\n begin\n col[i]:=1;\n end;\n while true do\n begin\n any:=false;\n for v:=1 to n do\n begin\n x:=g.last[v];\n k:=0;\n while x<>0 do\n begin\n if col[g.y[x]]=col[v] then k:=k+1;\n x:=g.pred[x];\n end;\n if k>1 then\n begin\n col[v]:=3-col[v];\n any:=true;\n end;\n end;\n if not any then break;\n end;\n for i:=1 to n do\n write(col[i]-1);\n writeln;\n end.", "src_uid": "7017f2c81d5aed716b90e46480f96582"} {"source_code": "var\n\nx,y:array[1..3] of longint;\ncheck:array[1..3] of integer;\nans,ravx,ravy,i:integer;\n\nbegin\n\nfor i:=1 to 3 do\n begin\n read(x[i],y[i]);\n readln;\n end;\n\nif (x[1]=x[2]) then inc(ravx);\nif (x[2]=x[3]) then inc(ravx);\nif (ravx<>2) and (x[1]=x[3]) then inc(ravx);\n\nif (y[1]=y[2]) then inc(ravy);\nif (y[2]=y[3]) then inc(ravy);\nif (ravy<>2) and (y[1]=y[3]) then inc(ravy);\n\nif (ravx=2) or (ravy=2) then ans:=1;\n\nif (ravx=1) and (ravy=1) then ans:=2;\n\nif (ravx=1) and (ravy=0) then\n begin\n if (x[1]=x[2]) then\n begin\n check[1]:=1;\n check[2]:=2;\n check[3]:=3;\n end;\n if (x[2]=x[3]) then\n begin\n check[1]:=2;\n check[2]:=3;\n check[3]:=1;\n end;\n if (x[1]=x[3]) then \n begin\n check[1]:=1;\n check[2]:=3;\n check[3]:=2;\n end;\n if (y[check[3]]y[check[1]]) then ans:=3;\n if (y[check[3]]>y[check[2]]) and (y[check[3]]x[check[1]]) then ans:=3;\n if (x[check[3]]>x[check[2]]) and (x[check[3]]lab[o]+1 then\n\t\t\t\t\tbegin\n\t\t\t\t\t\tlab[o+i]:=lab[o]+1;\n\t\t\t\t\t\tdi(o+i);\n\t\t\t\t\tend;\n\t\t\t\tend;\n\t\t\t\tinc(i);\n\t\t\tend;\n\t\tend;\nbegin\n\treadln(n,d);\n\treadln(s);\n\tfillchar(a,sizeof(a),0);\n\tif s[1]='0' then xuat;\n\tfor i:=1 to n do\n\tbegin\n\t\tj:=1;\n\t\twhile (j<=d) and (i+j<=n) do\n\t\tbegin\n\t\t\tif (s[i]='1') and (s[i+j]='1') then a[i,i+j]:=1 else a[i,i+j]:=0;\n\t\t\tinc(j);\n\t\tend;\n\tend;\n\tfillchar(lab,sizeof(lab),n+1);\n\tlab[1]:=0;\n\tdi(1);\n\tif lab[n]>n then xuat else writeln(lab[n]);\nend.", "src_uid": "c08d2ecdfc66cd07fbbd461b1f069c9e"} {"source_code": "uses math;\nvar\n a : array [0..11111] of longint;\n res0,res1,res2,x0,y0,x1,y1,x2,y2,res,n,i,j,k,m,h,c,x,z : longint;\n\nbegin\n readln(n);\n readln(x0, y0);\n readln(x1, y1);\n readln(x2, y2);\n\n res0:=min(n - (x1+x2), y0);\n res1:=min(n - res0 - x2, y1);\n\n writeln(res0, ' ', res1, ' ', n - (res1 + res0));\nend.", "src_uid": "3cd092b6507079518cf206deab21cf97"} {"source_code": "var a1,a2,k1,k2,n:integer;\n l1,l2,l3:integer;\nbegin\n read(a1, a2, k1, k2, n);\n l1:=n-(k1-1)*a1-(k2-1)*a2;\n if k1a1 then l2:=a1;\n n:=n-l2*k1;\n l3:=n div k2;\n if l3>a2 then l3:=a2;\n end\n else\n begin\n l2:=n div k2;\n if l2>a2 then l2:=a2;\n n:=n-l2*k2;\n l3:=n div k1;\n if l3>a1 then l3:=a1;\n end;\n if l1<0 then l1:=0;\n write(l1,' ',l2+l3);\nend.", "src_uid": "2be8e0b8ad4d3de2930576c0209e8b91"} {"source_code": "\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n var a:array[0 .. 10000]of integer;\n n,m,k,count,t ,j,z,i : integer;\nbegin\n readln(n,m,t);\n count := 0;\n for i:=1 to n do\n begin\n inc(count);\n read(a[count]);\n if a[count] = 1 then dec(count);\n end;\n for i:=1 to n-1 do\n for j:=i+1 to n do\n if a[i]= m then\n begin\n writeln(i);\n halt;\n end;\n inc(i);\n end;\n writeln(-1);\nend.", "src_uid": "b32ab27503ee3c4196d6f0d0f133d13c"} {"source_code": "var\n i,j,n,m,k,kol:longint;\n ans:int64;\n f:boolean;\nbegin\n// assign(input,'input.txt'); reset(input); assign(output,'output.txt'); rewrite(output);\n readln(n);\n ans:=n;\n while n>1 do\n begin\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 if not f then i:=n;\n inc(ans,n div i);\n n:=n div i;\n f:=false;\n end;\n writeln(ans);\nend.\n", "src_uid": "821c0e3b5fad197a47878bba5e520b6e"} {"source_code": "var\n c : array[1..100000] of char;\n n : 0..100000;\n\nprocedure print();\nvar\n i : 0..100000;\nbegin\n for i := 1 to n do\n write(c[i]);\n halt;\nend;\n \nvar\n i, k : 0..100000;\n x : 0..27;\nbegin\n n := 0;\n k := 0;\n x := 1;\n while not EOLN do\n begin\n\t inc(n);\n read(c[n]);\n\t \n\t if (ord(c[n]) <= 96 + x) and (x <> 27) then\n\t begin\n\t\t c[n] := chr(96 + x);\n\t\t inc(x);\n\t\tend;\n\tend;\n \n if (n < 26) or (x < 27) then\n begin\n writeln('-1');\n\t halt;\n\tend\n else print();\n \nend.", "src_uid": "f8ad543d499bcc0da0121a71a26db854"} {"source_code": "var\n i,a,b,c:longint;\n s:ansistring;\nbegin\n read(s);\n for i:=1 to length(s) do\n begin\n if ipos('+',s))and(ipos('=',s) then inc(c);\n end;\n if a+b=c then\n begin\n write(s);\n halt;\n end;\n if a+b>c then\n begin\n if a>1 then\n if a-1+b=c+1 then\n begin\n for i:=1 to a-1 do write('|');\n write('+');\n for i:=1 to b do write('|');\n write('=');\n for i:=1 to c+1 do write('|');\n halt;\n end;\n if b>1 then\n if a+b-1=c+1 then\n begin\n for i:=1 to a do write('|');\n write('+');\n for i:=1 to b-1 do write('|');\n write('=');\n for i:=1 to c+1 do write('|');\n halt;\n end;\n end;\n if (a+b1) then\n begin\n if a+1+b=c-1 then\n begin\n for i:=1 to a+1 do write('|');\n write('+');\n for i:=1 to b do write('|');\n write('=');\n for i:=1 to c-1 do write('|');\n halt;\n end;\n if a+b+1=c-1 then\n begin\n for i:=1 to a do write('|');\n write('+');\n for i:=1 to b+1 do write('|');\n write('=');\n for i:=1 to c-1 do write('|');\n halt;\n end;\n end;\n writeln('Impossible');\nend.", "src_uid": "ee0aaa7acf127e9f3a9edafc58f4e2d6"} {"source_code": " const eps=1e-10;\n besk=4000000000000000000; label 1,3,2,44;\n type mas=array[-1000000..1500000+1] of int64; integer=longint;\n var sdvig,start,dl,len,i1,j1,mask,stepp,h,n2,i,j,k,l,step,k1,mesto,num:longint;\n ss3,ss,ss1,ss2:string;\n 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,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 xa,summ,place,kol,str,b2,left,right,zz,z1,sum1,sum0,d0,d1,ccc,c,d,a,b:mas; flag2,flag:boolean; pl:longint;\n 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 prost,marked,zan:array[-10..4000000] of boolean;\n lx,rx,ly,ry,a2,a3,a4,dd1,dd2,predok,a1,b1,strok:array[-10..550000] of int64;\n ppole:array[-1000..1000000] of char;\n stroka:array[-1000..1000000] of char;\n ot1,otmax,v:extended;\n prof,profil,zzz:array[-10..100,-10..100] of int64;\n sp,sss:array[-10..2000000] of string;\n newpole,pole:array[-1..1100,-1..700] of int64;\n ddpos,dd,ddinv,dnech,poschet,posnechet:array[-10..1900000,0..2,0..2] of int64;\n poss:int64;\n ch:char;\n ff,flagg1:boolean;\n 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]=kk then goto 2;\n t:=length(sss[i]);\n { writeln('work with ',sss[i]); }\n for j:=0 to t do\n begin\n ss2:=copy(sss[i],1,j); ss3:=copy(sss[i],j+2,t-j-1);\n { writeln(ss2,' = ',ss3);\n } ss1:=ss2+ss3;\n { writeln(ss1);\n } flag:=false;\n for k:=1 to q do if ss1=sss[k] then flag:=true;\n if not flag then\n begin\n inc(q); sss[q]:=ss1; ff:=true;\n { writeln('**add**= ',ss1); }\n end;\n { writeln(ss1,' ',flag); }\n end;\n\n end;\n if not ff and(q 0 then\n begin\n flag := true;\n for i := 1 to kol do\n flag := flag and (pow(b, d[i]) <> 1);\n end;\n dec(b);\n until ((flag = true) or (b = 0));\n if flag then writeln(b + 1) else\n begin\n writeln(-1);\n halt;\n end;\nend.", "src_uid": "29dda6a3f057e5bccdc076d7e492ac9a"} {"source_code": "{$R+}\n{$APPTYPE CONSOLE}\nUSES SysUtils, Math;\n var a, b, k, l: int64;\n i, j: integer;\n s1, s2 : string;\n\nbegin\n{$IFNDEF ONLINE_JUDGE}\nReset(input, 'input.txt');\nRewrite(output, 'output.txt');\n{$ENDIF}\nread(a, b);\nk := a - b;\ns1 := IntToStr(a);\ns2 := IntToStr(k);\ni := length(s1);\nl := 0;\nwhile (s1[i] = '9') and (i > 1) do begin dec(i);inc(l);end;\nif s1[i] = '9' then inc(l);\n\nif l >= length(s1) - 1 then begin write(s1);exit;end;\n\n\n\nif length(s2) < length(s1) then begin\nif s1[1] > '1' then write(StrToInt(s1[1]) - 1);\nfor i := 1 to length(s1) - 1 do write('9');\n\nexit;\nend;\ni := 1;\nwhile (s1[i] = s2[i]) and (i < length(s1)) do inc(i);\nif (i = length(s1)) and (s1[i] = s2[i]) then begin write(s1);exit;end;\n if i = length(s1) then begin write(s1);exit;end;\n for j := 1 to i - 1 do write(s1[j]);\n l := 0;\n\n\n \n j := i;\n while (s1[j] = '9') and (j < length(s1)) do inc(j);\n if (j = length(s1)) and (s1[j] = '9') and (s1[i] = '9') then\n begin\n for j := i to length(s1) do write(9);\n exit;\n end;\n\n\nwrite(StrToInt(s1[i]) - 1);\n inc(i);\nfor j := i to length(s1) do write(9);\n\n\nend.\n", "src_uid": "c706cfcd4c37fbc1b1631aeeb2c02b6a"} {"source_code": "const fi='520B.inp'; fo='520B.out';\nvar n,m,s:integer;\n\nprocedure input;\nvar f:text;\n begin\n {assign(f,fi);\n reset(f);}\n readln(n,m);\n //close(f);\n end;\n\nprocedure run;\nvar a,t:integer;\n begin\n s:=0;\n while m>n do\n begin\n if odd(m) then\n begin\n inc(s);\n m:=m+1;\n end;\n m:=m shr 1;\n inc(s);\n end;\n s:=s+n-m;\n end;\n\nprocedure output;\nvar f:text;\n begin\n {assign(f,fo);\n rewrite(f);}\n writeln(s);\n //close(f);\n end;\n\nBEGIN\n input;\n run;\n output;\nEND.\n\n\n", "src_uid": "861f8edd2813d6d3a5ff7193a804486f"} {"source_code": "var\n a:array [1..111] of Longint;\n i,j,T,N,X,Ans:Longint;\nbegin\n Readln(N);\n for i:=1 to N do\n Read(a[i]);\n Readln(T);\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 Ans:=1;\n for i:=1 to N-1 do\n for j:=i+1 to N do\n if a[j]-a[i]<=T then\n if j-i+1>Ans then Ans:=j-i+1;\n Writeln(Ans);\n end.\n", "src_uid": "086d07bd6f9031df09bd6a6e8fe8f25c"} {"source_code": "const mas:array[1..65,1..3] of longint =\n((1,1,1),\n(1,0,1),\n(2,2,2),\n(2,1,2),\n(2,0,2),\n(3,3,4),\n(3,2,6),\n(3,1,6),\n(3,0,6),\n(4,4,10),\n(4,3,16),\n(4,2,24),\n(4,1,24),\n(4,0,24),\n(5,5,26),\n(5,4,50),\n(5,3,80),\n(5,2,120),\n(5,1,120),\n(5,0,120),\n(6,6,76),\n(6,5,156),\n(6,4,300),\n(6,3,480),\n(6,2,720),\n(6,1,720),\n(6,0,720),\n(7,7,232),\n(7,6,532),\n(7,5,1092),\n(7,4,2100),\n(7,3,3360),\n(7,2,5040),\n(7,1,5040),\n(7,0,5040),\n(8,8,764),\n(8,7,1856),\n(8,6,4256),\n(8,5,8736),\n(8,4,16800),\n(8,3,26880),\n(8,2,40320),\n(8,1,40320),\n(8,0,40320),\n(9,9,2620),\n(9,8,6876),\n(9,7,16704),\n(9,6,38304),\n(9,5,78624),\n(9,4,151200),\n(9,3,241920),\n(9,2,362880),\n(9,1,362880),\n(9,0,362880),\n(10,10,9496),\n(10,9,26200),\n(10,8,68760),\n(10,7,167040),\n(10,0,3628800),\n(10,1,3628800),\n(10,2,3628800),\n(10,3,2419200),\n(10,4,1512000),\n(10,5,786240),\n(10,6,383040));\n\nvar n,m,i,j,k,c1,c2:longint;\n\nbegin\n readln(n);\n c1:=0; c2:=0;\n for i:= 1 to n do\n begin\n read(k);\n if (k=1) then inc(c1) else inc(c2);\n end;\n for i:= 1 to 65 do\n if (mas[i][1]=n) and (c1=mas[i][2]) then\n begin\n writeln(mas[i][3]);\n halt;\n end;\nend.\n", "src_uid": "91e8dbe94273e255182aca0f94117bb9"} {"source_code": "var s:array[1..4]of longint;\n i,j,k:byte;\nbegin\n readln(s[1],s[2],s[3],s[4]);\n k:=0;\n for i:=1 to 3 do\n for j:=i+1 to 4 do\n if s[i]=s[j] then\n inc(k);\n case k of\n 0:writeln(0);\n 1:writeln(1);\n 2,3:writeln(2);\n 6:writeln(3);\n end;\n readln;\nend.", "src_uid": "38c4864937e57b35d3cce272f655e20f"} {"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 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,n,s1,s2,m,s,cen,t2,i1,besk:int64;\n newug,ugol,newdl,dloch,dugol,ist,jst,ifin,jfin,newnapx,newnapy,napx,napy,jj,step, k,ii,i,j:longint;\n pr,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:string;ch3,ch,ch1,ch2:char;\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\nread(aa,bb,n,xx);\nif aa=1 then pp:=n mod modul else\nbegin\n p1:=((degg(aa,n)-1+modul) mod modul );\n p2:=degg(aa-1,modul-2);\n pp:=p1*p2 mod modul;\n\n\nend;\n\n {writeln('pp= ',pp);\n} qq:=degg(aa,n);\n writeln(((qq*xx) mod modul+bb*pp) mod modul);\n\n\n\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n", "src_uid": "e22a1fc38c8b2a4cc30ce3b9f893028e"} {"source_code": "var g:array[-10..120] of longint;\n fd,ed:array[-10..120] of extended;\n f:array[-10..50,-10..50,-10..50] of extended;\n n:array[-10..50] of longint;\n d,range:array[-10..60] of extended;\n tower:array[-10..400] of longint;\n ans:extended;\n\nprocedure openfile;\n begin\n assign(input,'E.in'); reset(input);\n assign(output,'E.out'); rewrite(output);\n end;\n\nprocedure endfile;\n begin\n close(input); close(output);\n end;\n\nprocedure init;\n var i:longint;\n begin\n readln(n[1],n[2],n[3]);\n readln(range[1],range[2],range[3]);\n readln(d[1],d[2]);\n for i:=1 to 10 do g[i]:=2;\n for i:=1 to 3 do range[i]:=sqrt(range[i]*range[i]-1);\n end;\n\nprocedure check;\n var i,j,k:longint;\n l,r,ll,rr:extended;\n begin\n for i:=1 to 10 do begin\n l:=i-range[1]; r:=i+range[1];\n fd[i]:=r-l;\n for j:=1 to n[3] do begin\n ll:=tower[j]-range[3]; rr:=tower[j]+range[3];\n if (rrr) then continue;\n if (ll>l) then begin\n if (rrrr) then continue;\n if (ll>l) then begin\n if (rr=1 then begin\n if k>0 then\n if f[i+1,j,k-1]0 then\n if f[i+1,j-1,k]=2 then begin\n if k>1 then\n if f[i+1,j,k-2]1 then\n if f[i+1,j-2,k]0)and(j>0) then\n if f[i+1,j-1,k-1]ans then ans:=f[10,0,0];\n end;\n\nprocedure dfs(x,y:longint);\n begin\n if x=11 then begin\n if y=n[3] then check;\n exit;\n end;\n dfs(x+1,y);\n g[x]:=1;\n tower[y+1]:=x;\n dfs(x+1,y+1);\n g[x]:=0;\n tower[y+2]:=x;\n dfs(x+1,y+2);\n g[x]:=2;\n end;\n\nbegin\n //openfile;\n init;\n dfs(1,0);\n writeln(ans:0:8);\n //endfile;\nend.\n\n\n\n\n\n\n\n", "src_uid": "de5a42225714552cc5422d8a45734d58"} {"source_code": "var\na:longint;\nbegin\nreadln(a);\nwriteln(6*a*(a-1)+1);\nend.", "src_uid": "879ac20ae5d3e7f1002afe907d9887df"} {"source_code": "Var n,k,m,a,b,tmin,sm,pm,sd,pd,spusc:integer;\nProcedure Nps(var p,s,kv:integer);\n var i,j,sum:integer;\n b:boolean;\n begin\n sum:=0;\n b:=false;\n for i:=1 to n do\n begin\n if b then break;\n for j:=1 to m do\n begin\n sum:=sum+k;\n if kv-sum <= 0 then\n begin\n p:=i;\n s:=j;\n b:=true;\n break;\n end;\n end;\n end;\n end;\nBegin\n Readln(n,m,k);\n Readln(a,b);\n Nps(pm,sm,a);\n Nps(pd,sd,b);\n tmin:= abs((pd-pm)*15);\n if pd>pm then if (n-pd+pm)*15< tmin then tmin:=(n-pd+pm)*15\n else\n else if (n-pm+pd)*153 then spusc:=sm-1+10\n else spusc:=(sm-1)*5;\n tmin:=tmin+spusc;\n if sd>3 then spusc:=sd-1+10\n else spusc:=(sd-1)*5;\n tmin:=tmin+spusc;\n end;\n Writeln(tmin);\nEnd.", "src_uid": "c37b46851abcf7eb472869bd1ab9f793"} {"source_code": "var\n s : string;\n i : longint;\nbegin\n readln(s);\n for i:=1 to length(s) do\n begin\n if (s[i]='a') and (s[i+1]='t') and (i<>1) and (i+1<>2) and (i<>length(s)-1) and (i+1<>length(s)) then\n begin\n s[i]:='@';\n delete(s,i+1,1);\n break;\n end;\n end;\n for i:=1 to length(s) do\n begin\n if (s[i]='d') and (s[i+1]='o') and (s[i+2]='t') and (i<>1) and (i+1<>2) and (i+2<>3) and (i<>length(s)-2) and (i+1<>length(s)-1) and (i+2<>length(s)) then\n begin\n s[i]:='.';\n delete(s,i+1,2);\n end;\n end;\n write(s);\nend.\n", "src_uid": "a11c9679d8e2dca51be17d466202df6e"} {"source_code": " {$APPTYPE CONSOLE}\nconst besk=2000000000{000000000};\n label 1,2,3,4;\nvar k,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;\nnach,kon,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;\nmon1,mon2,day1,day2,god1,god2,kk,mnog,koef:int64;\nfl0,fl10,fl100,flag2,flag1,flag:boolean;\nott,pp1,pp2,dl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;\ndd,otdd,b,c:array[-10..200,-10..200] of int64;\ny,x:extended;\na,zz,xx,yy,z1,z: array[-10..500000] of int64;\ngr1,gr: array[-50..700,-50..700] of char;\nee,deg,marked:array[-100000..250000] of int64;\n{ss:array[0..2000000] of char; }\nsss1,sss:string;\nab:array[-100..200,-100..201,-100..201] of char;\nch11,ch12,ch1,ch:char;\nsl,sr :array[-10 ..200000] of int64;\nstolb,str:array[-10..500] of boolean;\nssot:array[-1000..1100000] of char;\np,stepen: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 ;\n readln(n,m);\n for i:=1 to n do begin for j:=1 to m do read(gr[i,j]); readln; end;\n\n for i:=1 to n do for j:=1 to m do if gr[i,j]='S' then str[i]:=true;\n for i:=1 to n do for j:=1 to m do if gr[i,j]='S' then stolb[j]:=true;\nfor i:=1 to n do if str[i] then inc(p1);\nfor i:=1 to m do if stolb[i] then inc(p2);\n{writeln(p1,' ',p2);\n}writeln(n*m-p1*p2);\n\n\n\n 1: close(output);\n\nend.\n", "src_uid": "ebaf7d89c623d006a6f1ffd025892102"} {"source_code": "var\n a,q:int64;\n\nbegin\n readln(a);\n if a mod 2 = 0 then q:=2\n else q:=1;\n writeln(q);\nend.", "src_uid": "816ec4cd9736f3113333ef05405b8e81"} {"source_code": "// https://codeforces.com/contest/1184/problem/A1\n//Heidi Leanrns Hashing A1\n\nfunction f(x:int64):int64;\nbegin\n f:=x*x+3*x;\nend;\n\nprocedure solve;\nvar x,y,r,res:int64;\nbegin\n readln(r);\n res:=-1;\n x:=1;\n While (f(x)0 then\n if y mod (2*x) = 0 then res:=y div (2*x);\n inc(x);\n end;\n if res=-1 then write('NO') else write(x-1,' ',res);\nend;\n\nbegin\n solve;\nreadln;\nend.\n\n\n", "src_uid": "3ff1c25a1026c90aeb14d148d7fb96ba"} {"source_code": "const md = 777777777;\nvar\nc,i,j,n,k,u:longint;\ncc,c1,c2:Array[0..256,0..256]of longint;\nans:int64;\nfunction mult(a,b:int64):longint;\nbegin\n a:=a*b;\n a:=a mod md;\n mult:=a;\nend;\nprocedure add(var a:longint; b:longint);\nbegin\n a:=a+b;\n if a>=md then a:=a-md;\nend;\n begin\n readln(n,k);\nif (n=128) and (k=1) then begin writeln(482164403); halt(0); end;\nif (n=128) and (k=2) then begin writeln(768209115); halt(0); end;\nif (n=128) and (k=3) then begin writeln(462063756); halt(0); end;\nif (n=128) and (k=4) then begin writeln(154906374); halt(0); end;\nif (n=128) and (k=5) then begin writeln(36099042); halt(0); end;\nif (n=128) and (k=6) then begin writeln(341766705); halt(0); end;\nif (n=128) and (k=7) then begin writeln(678182556); halt(0); end;\nif (n=128) and (k=8) then begin writeln(621882744); halt(0); end;\nif (n=128) and (k=9) then begin writeln(478771358); halt(0); end;\nif (n=128) and (k=10) then begin writeln(231881111); halt(0); end;\nif (n=128) and (k=11) then begin writeln(175889805); halt(0); end;\nif (n=128) and (k=12) then begin writeln(243630450); halt(0); end;\nif (n=128) and (k=13) then begin writeln(168908523); halt(0); end;\nif (n=128) and (k=14) then begin writeln(671961765); halt(0); end;\nif (n=128) and (k=15) then begin writeln(55761813); halt(0); end;\nif (n=128) and (k=16) then begin writeln(652682670); halt(0); end;\nif (n=128) and (k=17) then begin writeln(773939082); halt(0); end;\nif (n=128) and (k=18) then begin writeln(517628076); halt(0); end;\nif (n=128) and (k=19) then begin writeln(756201264); halt(0); end;\nif (n=128) and (k=20) then begin writeln(124604900); halt(0); end;\nif (n=128) and (k=21) then begin writeln(750976272); halt(0); end;\nif (n=128) and (k=22) then begin writeln(498253248); halt(0); end;\nif (n=128) and (k=23) then begin writeln(676047609); halt(0); end;\nif (n=128) and (k=24) then begin writeln(137170026); halt(0); end;\nif (n=128) and (k=25) then begin writeln(705610017); halt(0); end;\nif (n=128) and (k=26) then begin writeln(495032139); halt(0); end;\nif (n=128) and (k=27) then begin writeln(561797418); halt(0); end;\nif (n=128) and (k=28) then begin writeln(703097347); halt(0); end;\nif (n=128) and (k=29) then begin writeln(500815609); halt(0); end;\nif (n=128) and (k=30) then begin writeln(95984586); halt(0); end;\nif (n=128) and (k=31) then begin writeln(739707108); halt(0); end;\nif (n=128) and (k=32) then begin writeln(265613565); halt(0); end;\nif (n=128) and (k=33) then begin writeln(387099846); halt(0); end;\nif (n=128) and (k=34) then begin writeln(777331779); halt(0); end;\nif (n=128) and (k=35) then begin writeln(594676173); halt(0); end;\nif (n=128) and (k=36) then begin writeln(591219559); halt(0); end;\nif (n=128) and (k=37) then begin writeln(407997044); halt(0); end;\nif (n=128) and (k=38) then begin writeln(208947235); halt(0); end;\nif (n=128) and (k=39) then begin writeln(93337440); halt(0); end;\nif (n=128) and (k=40) then begin writeln(478908360); halt(0); end;\nif (n=128) and (k=41) then begin writeln(685013007); halt(0); end;\nif (n=128) and (k=42) then begin writeln(487033953); halt(0); end;\nif (n=128) and (k=43) then begin writeln(671903001); halt(0); end;\nif (n=128) and (k=44) then begin writeln(39521181); halt(0); end;\nif (n=128) and (k=45) then begin writeln(738490312); halt(0); end;\nif (n=128) and (k=46) then begin writeln(33785059); halt(0); end;\nif (n=128) and (k=47) then begin writeln(465470131); halt(0); end;\nif (n=128) and (k=48) then begin writeln(310453920); halt(0); end;\nif (n=128) and (k=49) then begin writeln(54648783); halt(0); end;\nif (n=128) and (k=50) then begin writeln(346831137); halt(0); end;\nif (n=128) and (k=51) then begin writeln(427694175); halt(0); end;\nif (n=128) and (k=52) then begin writeln(474743430); halt(0); end;\nif (n=128) and (k=53) then begin writeln(705296781); halt(0); end;\nif (n=128) and (k=54) then begin writeln(435828036); halt(0); end;\nif (n=128) and (k=55) then begin writeln(429824745); halt(0); end;\nif (n=128) and (k=56) then begin writeln(663532359); halt(0); end;\nif (n=128) and (k=57) then begin writeln(261388683); halt(0); end;\nif (n=128) and (k=58) then begin writeln(244690731); halt(0); end;\nif (n=128) and (k=59) then begin writeln(533997135); halt(0); end;\nif (n=128) and (k=60) then begin writeln(596108961); halt(0); end;\nif (n=128) and (k=61) then begin writeln(506813013); halt(0); end;\nif (n=128) and (k=62) then begin writeln(371892402); halt(0); end;\nif (n=128) and (k=63) then begin writeln(590145264); halt(0); end;\nif (n=128) and (k=64) then begin writeln(104733162); halt(0); end;\nif (n=128) and (k=65) then begin writeln(143420103); halt(0); end;\nif (n=128) and (k=66) then begin writeln(654339672); halt(0); end;\nif (n=128) and (k=67) then begin writeln(700348950); halt(0); end;\nif (n=128) and (k=68) then begin writeln(685038942); halt(0); end;\nif (n=128) and (k=69) then begin writeln(578826927); halt(0); end;\nif (n=128) and (k=70) then begin writeln(286484229); halt(0); end;\nif (n=128) and (k=71) then begin writeln(501639192); halt(0); end;\nif (n=128) and (k=72) then begin writeln(434962491); halt(0); end;\nif (n=128) and (k=73) then begin writeln(299270097); halt(0); end;\nif (n=128) and (k=74) then begin writeln(27702486); halt(0); end;\nif (n=128) and (k=75) then begin writeln(335375775); halt(0); end;\nif (n=128) and (k=76) then begin writeln(111746817); halt(0); end;\nif (n=128) and (k=77) then begin writeln(565603164); halt(0); end;\nif (n=128) and (k=78) then begin writeln(294926121); halt(0); end;\nif (n=128) and (k=79) then begin writeln(676063665); halt(0); end;\nif (n=128) and (k=80) then begin writeln(735862995); halt(0); end;\nif (n=128) and (k=81) then begin writeln(710035809); halt(0); end;\nif (n=128) and (k=82) then begin writeln(437011960); halt(0); end;\nif (n=128) and (k=83) then begin writeln(668528077); halt(0); end;\nif (n=128) and (k=84) then begin writeln(138765186); halt(0); end;\nif (n=128) and (k=85) then begin writeln(508213986); halt(0); end;\nif (n=128) and (k=86) then begin writeln(615036450); halt(0); end;\nif (n=128) and (k=87) then begin writeln(353784942); halt(0); end;\nif (n=128) and (k=88) then begin writeln(624827616); halt(0); end;\nif (n=128) and (k=89) then begin writeln(343900011); halt(0); end;\nif (n=128) and (k=90) then begin writeln(241289776); halt(0); end;\nif (n=128) and (k=91) then begin writeln(52410890); halt(0); end;\nif (n=128) and (k=92) then begin writeln(72018835); halt(0); end;\nif (n=128) and (k=93) then begin writeln(352406796); halt(0); end;\nif (n=128) and (k=94) then begin writeln(415705878); halt(0); end;\nif (n=128) and (k=95) then begin writeln(4802637); halt(0); end;\nif (n=128) and (k=96) then begin writeln(376367145); halt(0); end;\nif (n=128) and (k=97) then begin writeln(65589678); halt(0); end;\nif (n=128) and (k=98) then begin writeln(333633477); halt(0); end;\nif (n=128) and (k=99) then begin writeln(341834527); halt(0); end;\nif (n=128) and (k=100) then begin writeln(303717460); halt(0); end;\nif (n=128) and (k=101) then begin writeln(282387700); halt(0); end;\nif (n=128) and (k=102) then begin writeln(42951006); halt(0); end;\nif (n=128) and (k=103) then begin writeln(254706039); halt(0); end;\nif (n=128) and (k=104) then begin writeln(423048528); halt(0); end;\nif (n=128) and (k=105) then begin writeln(526429710); halt(0); end;\nif (n=128) and (k=106) then begin writeln(68131467); halt(0); end;\nif (n=128) and (k=107) then begin writeln(669954708); halt(0); end;\nif (n=128) and (k=108) then begin writeln(12787348); halt(0); end;\nif (n=128) and (k=109) then begin writeln(500636381); halt(0); end;\nif (n=128) and (k=110) then begin writeln(317959019); halt(0); end;\nif (n=128) and (k=111) then begin writeln(479433192); halt(0); end;\nif (n=128) and (k=112) then begin writeln(657133515); halt(0); end;\nif (n=128) and (k=113) then begin writeln(416259390); halt(0); end;\nif (n=128) and (k=114) then begin writeln(610216692); halt(0); end;\nif (n=128) and (k=115) then begin writeln(340129188); halt(0); end;\nif (n=128) and (k=116) then begin writeln(44594256); halt(0); end;\nif (n=128) and (k=117) then begin writeln(257373347); halt(0); end;\nif (n=128) and (k=118) then begin writeln(138718678); halt(0); end;\nif (n=128) and (k=119) then begin writeln(530767740); halt(0); end;\nif (n=128) and (k=120) then begin writeln(292922628); halt(0); end;\nif (n=128) and (k=121) then begin writeln(37220268); halt(0); end;\nif (n=128) and (k=122) then begin writeln(605295159); halt(0); end;\nif (n=128) and (k=123) then begin writeln(480722613); halt(0); end;\nif (n=128) and (k=124) then begin writeln(458170419); halt(0); end;\nif (n=128) and (k=125) then begin writeln(30540300); halt(0); end;\nif (n=128) and (k=126) then begin writeln(487159055); halt(0); end;\nif (n=128) and (k=127) then begin writeln(232966794); halt(0); end;\nif (n=128) and (k=128) then begin writeln(149150650); halt(0); end;\nif (n=256) and (k=1) then begin writeln(412133651); halt(0); end;\nif (n=256) and (k=2) then begin writeln(386543325); halt(0); end;\nif (n=256) and (k=3) then begin writeln(139952108); halt(0); end;\nif (n=256) and (k=4) then begin writeln(289303402); halt(0); end;\nif (n=256) and (k=5) then begin writeln(102404925); halt(0); end;\nif (n=256) and (k=6) then begin writeln(317067177); halt(0); end;\nif (n=256) and (k=7) then begin writeln(396414708); halt(0); end;\nif (n=256) and (k=8) then begin writeln(80515854); halt(0); end;\nif (n=256) and (k=9) then begin writeln(663739304); halt(0); end;\nif (n=256) and (k=10) then begin writeln(317300809); halt(0); end;\nif (n=256) and (k=11) then begin writeln(228877044); halt(0); end;\nif (n=256) and (k=12) then begin writeln(493725043); halt(0); end;\nif (n=256) and (k=13) then begin writeln(715317967); halt(0); end;\nif (n=256) and (k=14) then begin writeln(490300965); halt(0); end;\nif (n=256) and (k=15) then begin writeln(315527373); halt(0); end;\nif (n=256) and (k=16) then begin writeln(743539734); halt(0); end;\nif (n=256) and (k=17) then begin writeln(488329191); halt(0); end;\nif (n=256) and (k=18) then begin writeln(553627998); halt(0); end;\nif (n=256) and (k=19) then begin writeln(533025234); halt(0); end;\nif (n=256) and (k=20) then begin writeln(242583957); halt(0); end;\nif (n=256) and (k=21) then begin writeln(706116537); halt(0); end;\nif (n=256) and (k=22) then begin writeln(614109258); halt(0); end;\nif (n=256) and (k=23) then begin writeln(645447222); halt(0); end;\nif (n=256) and (k=24) then begin writeln(523195911); halt(0); end;\nif (n=256) and (k=25) then begin writeln(492109128); halt(0); end;\nif (n=256) and (k=26) then begin writeln(722623041); halt(0); end;\nif (n=256) and (k=27) then begin writeln(111085128); halt(0); end;\nif (n=256) and (k=28) then begin writeln(766395126); halt(0); end;\nif (n=256) and (k=29) then begin writeln(654378921); halt(0); end;\nif (n=256) and (k=30) then begin writeln(691964847); halt(0); end;\nif (n=256) and (k=31) then begin writeln(496688157); halt(0); end;\nif (n=256) and (k=32) then begin writeln(399056049); halt(0); end;\nif (n=256) and (k=33) then begin writeln(654363234); halt(0); end;\nif (n=256) and (k=34) then begin writeln(102052314); halt(0); end;\nif (n=256) and (k=35) then begin writeln(191720088); halt(0); end;\nif (n=256) and (k=36) then begin writeln(473910948); halt(0); end;\nif (n=256) and (k=37) then begin writeln(259736526); halt(0); end;\nif (n=256) and (k=38) then begin writeln(332840025); halt(0); end;\nif (n=256) and (k=39) then begin writeln(388047555); halt(0); end;\nif (n=256) and (k=40) then begin writeln(665791056); halt(0); end;\nif (n=256) and (k=41) then begin writeln(627111387); halt(0); end;\nif (n=256) and (k=42) then begin writeln(139696515); halt(0); end;\nif (n=256) and (k=43) then begin writeln(441456687); halt(0); end;\nif (n=256) and (k=44) then begin writeln(443032569); halt(0); end;\nif (n=256) and (k=45) then begin writeln(283264821); halt(0); end;\nif (n=256) and (k=46) then begin writeln(771641703); halt(0); end;\nif (n=256) and (k=47) then begin writeln(452641455); halt(0); end;\nif (n=256) and (k=48) then begin writeln(511306362); halt(0); end;\nif (n=256) and (k=49) then begin writeln(117572859); halt(0); end;\nif (n=256) and (k=50) then begin writeln(127701891); halt(0); end;\nif (n=256) and (k=51) then begin writeln(721298331); halt(0); end;\nif (n=256) and (k=52) then begin writeln(176520078); halt(0); end;\nif (n=256) and (k=53) then begin writeln(357242229); halt(0); end;\nif (n=256) and (k=54) then begin writeln(611296308); halt(0); end;\nif (n=256) and (k=55) then begin writeln(696994956); halt(0); end;\nif (n=256) and (k=56) then begin writeln(405628839); halt(0); end;\nif (n=256) and (k=57) then begin writeln(429224274); halt(0); end;\nif (n=256) and (k=58) then begin writeln(465336054); halt(0); end;\nif (n=256) and (k=59) then begin writeln(695091546); halt(0); end;\nif (n=256) and (k=60) then begin writeln(689828796); halt(0); end;\nif (n=256) and (k=61) then begin writeln(574648641); halt(0); end;\nif (n=256) and (k=62) then begin writeln(351220905); halt(0); end;\nif (n=256) and (k=63) then begin writeln(507964023); halt(0); end;\nif (n=256) and (k=64) then begin writeln(675326610); halt(0); end;\nif (n=256) and (k=65) then begin writeln(517248963); halt(0); end;\nif (n=256) and (k=66) then begin writeln(453528621); halt(0); end;\nif (n=256) and (k=67) then begin writeln(220301928); halt(0); end;\nif (n=256) and (k=68) then begin writeln(494463186); halt(0); end;\nif (n=256) and (k=69) then begin writeln(681789969); halt(0); end;\nif (n=256) and (k=70) then begin writeln(339589656); halt(0); end;\nif (n=256) and (k=71) then begin writeln(44524053); halt(0); end;\nif (n=256) and (k=72) then begin writeln(417125457); halt(0); end;\nif (n=256) and (k=73) then begin writeln(339589404); halt(0); end;\nif (n=256) and (k=74) then begin writeln(747135963); halt(0); end;\nif (n=256) and (k=75) then begin writeln(341780733); halt(0); end;\nif (n=256) and (k=76) then begin writeln(734158215); halt(0); end;\nif (n=256) and (k=77) then begin writeln(396817281); halt(0); end;\nif (n=256) and (k=78) then begin writeln(21997836); halt(0); end;\nif (n=256) and (k=79) then begin writeln(5728464); halt(0); end;\nif (n=256) and (k=80) then begin writeln(147611205); halt(0); end;\nif (n=256) and (k=81) then begin writeln(456248898); halt(0); end;\nif (n=256) and (k=82) then begin writeln(714128667); halt(0); end;\nif (n=256) and (k=83) then begin writeln(377654949); halt(0); end;\nif (n=256) and (k=84) then begin writeln(3862068); halt(0); end;\nif (n=256) and (k=85) then begin writeln(128418948); halt(0); end;\nif (n=256) and (k=86) then begin writeln(589390074); halt(0); end;\nif (n=256) and (k=87) then begin writeln(304947090); halt(0); end;\nif (n=256) and (k=88) then begin writeln(11703825); halt(0); end;\nif (n=256) and (k=89) then begin writeln(228266073); halt(0); end;\nif (n=256) and (k=90) then begin writeln(127304142); halt(0); end;\nif (n=256) and (k=91) then begin writeln(429215724); halt(0); end;\nif (n=256) and (k=92) then begin writeln(361541124); halt(0); end;\nif (n=256) and (k=93) then begin writeln(521572968); halt(0); end;\nif (n=256) and (k=94) then begin writeln(468358191); halt(0); end;\nif (n=256) and (k=95) then begin writeln(341231688); halt(0); end;\nif (n=256) and (k=96) then begin writeln(65323503); halt(0); end;\nif (n=256) and (k=97) then begin writeln(613778508); halt(0); end;\nif (n=256) and (k=98) then begin writeln(15985323); halt(0); end;\nif (n=256) and (k=99) then begin writeln(291661029); halt(0); end;\nif (n=256) and (k=100) then begin writeln(410970006); halt(0); end;\nif (n=256) and (k=101) then begin writeln(591638112); halt(0); end;\nif (n=256) and (k=102) then begin writeln(349541550); halt(0); end;\nif (n=256) and (k=103) then begin writeln(89967528); halt(0); end;\nif (n=256) and (k=104) then begin writeln(224922159); halt(0); end;\nif (n=256) and (k=105) then begin writeln(361094166); halt(0); end;\nif (n=256) and (k=106) then begin writeln(584206074); halt(0); end;\nif (n=256) and (k=107) then begin writeln(640051812); halt(0); end;\nif (n=256) and (k=108) then begin writeln(324264456); halt(0); end;\nif (n=256) and (k=109) then begin writeln(652625388); halt(0); end;\nif (n=256) and (k=110) then begin writeln(693768537); halt(0); end;\nif (n=256) and (k=111) then begin writeln(11740617); halt(0); end;\nif (n=256) and (k=112) then begin writeln(309238398); halt(0); end;\nif (n=256) and (k=113) then begin writeln(211085469); halt(0); end;\nif (n=256) and (k=114) then begin writeln(194905872); halt(0); end;\nif (n=256) and (k=115) then begin writeln(639416484); halt(0); end;\nif (n=256) and (k=116) then begin writeln(110110707); halt(0); end;\nif (n=256) and (k=117) then begin writeln(296645895); halt(0); end;\nif (n=256) and (k=118) then begin writeln(748118511); halt(0); end;\nif (n=256) and (k=119) then begin writeln(131177718); halt(0); end;\nif (n=256) and (k=120) then begin writeln(511142751); halt(0); end;\nif (n=256) and (k=121) then begin writeln(775975599); halt(0); end;\nif (n=256) and (k=122) then begin writeln(421403409); halt(0); end;\nif (n=256) and (k=123) then begin writeln(475528473); halt(0); end;\nif (n=256) and (k=124) then begin writeln(434685258); halt(0); end;\nif (n=256) and (k=125) then begin writeln(1768977); halt(0); end;\nif (n=256) and (k=126) then begin writeln(80301375); halt(0); end;\nif (n=256) and (k=127) then begin writeln(708023862); halt(0); end;\nif (n=256) and (k=128) then begin writeln(569195676); halt(0); end;\nif (n=256) and (k=129) then begin writeln(56238084); halt(0); end;\nif (n=256) and (k=130) then begin writeln(632887668); halt(0); end;\nif (n=256) and (k=131) then begin writeln(88089750); halt(0); end;\nif (n=256) and (k=132) then begin writeln(631539342); halt(0); end;\nif (n=256) and (k=133) then begin writeln(396695565); halt(0); end;\nif (n=256) and (k=134) then begin writeln(38780154); halt(0); end;\nif (n=256) and (k=135) then begin writeln(695798271); halt(0); end;\nif (n=256) and (k=136) then begin writeln(469819224); halt(0); end;\nif (n=256) and (k=137) then begin writeln(439587099); halt(0); end;\nif (n=256) and (k=138) then begin writeln(69045921); halt(0); end;\nif (n=256) and (k=139) then begin writeln(682966116); halt(0); end;\nif (n=256) and (k=140) then begin writeln(112310856); halt(0); end;\nif (n=256) and (k=141) then begin writeln(64943298); halt(0); end;\nif (n=256) and (k=142) then begin writeln(534475872); halt(0); end;\nif (n=256) and (k=143) then begin writeln(40215357); halt(0); end;\nif (n=256) and (k=144) then begin writeln(389728458); halt(0); end;\nif (n=256) and (k=145) then begin writeln(286368453); halt(0); end;\nif (n=256) and (k=146) then begin writeln(736006257); halt(0); end;\nif (n=256) and (k=147) then begin writeln(501181650); halt(0); end;\nif (n=256) and (k=148) then begin writeln(54829908); halt(0); end;\nif (n=256) and (k=149) then begin writeln(603489402); halt(0); end;\nif (n=256) and (k=150) then begin writeln(338032656); halt(0); end;\nif (n=256) and (k=151) then begin writeln(512182818); halt(0); end;\nif (n=256) and (k=152) then begin writeln(627500097); halt(0); end;\nif (n=256) and (k=153) then begin writeln(462674016); halt(0); end;\nif (n=256) and (k=154) then begin writeln(3103092); halt(0); end;\nif (n=256) and (k=155) then begin writeln(157324491); halt(0); end;\nif (n=256) and (k=156) then begin writeln(43978329); halt(0); end;\nif (n=256) and (k=157) then begin writeln(596818971); halt(0); end;\nif (n=256) and (k=158) then begin writeln(259025598); halt(0); end;\nif (n=256) and (k=159) then begin writeln(9088632); halt(0); end;\nif (n=256) and (k=160) then begin writeln(91991781); halt(0); end;\nif (n=256) and (k=161) then begin writeln(577291428); halt(0); end;\nif (n=256) and (k=162) then begin writeln(211245489); halt(0); end;\nif (n=256) and (k=163) then begin writeln(429471231); halt(0); end;\nif (n=256) and (k=164) then begin writeln(142626330); halt(0); end;\nif (n=256) and (k=165) then begin writeln(172560633); halt(0); end;\nif (n=256) and (k=166) then begin writeln(510907446); halt(0); end;\nif (n=256) and (k=167) then begin writeln(444609585); halt(0); end;\nif (n=256) and (k=168) then begin writeln(758102058); halt(0); end;\nif (n=256) and (k=169) then begin writeln(375112647); halt(0); end;\nif (n=256) and (k=170) then begin writeln(744786693); halt(0); end;\nif (n=256) and (k=171) then begin writeln(276174402); halt(0); end;\nif (n=256) and (k=172) then begin writeln(19259856); halt(0); end;\nif (n=256) and (k=173) then begin writeln(233672418); halt(0); end;\nif (n=256) and (k=174) then begin writeln(745389414); halt(0); end;\nif (n=256) and (k=175) then begin writeln(225772848); halt(0); end;\nif (n=256) and (k=176) then begin writeln(23385663); halt(0); end;\nif (n=256) and (k=177) then begin writeln(324290610); halt(0); end;\nif (n=256) and (k=178) then begin writeln(519804558); halt(0); end;\nif (n=256) and (k=179) then begin writeln(120337812); halt(0); end;\nif (n=256) and (k=180) then begin writeln(402578568); halt(0); end;\nif (n=256) and (k=181) then begin writeln(360676008); halt(0); end;\nif (n=256) and (k=182) then begin writeln(450089262); halt(0); end;\nif (n=256) and (k=183) then begin writeln(551043738); halt(0); end;\nif (n=256) and (k=184) then begin writeln(337388940); halt(0); end;\nif (n=256) and (k=185) then begin writeln(512108856); halt(0); end;\nif (n=256) and (k=186) then begin writeln(28879011); halt(0); end;\nif (n=256) and (k=187) then begin writeln(690040638); halt(0); end;\nif (n=256) and (k=188) then begin writeln(106017282); halt(0); end;\nif (n=256) and (k=189) then begin writeln(558262341); halt(0); end;\nif (n=256) and (k=190) then begin writeln(99972432); halt(0); end;\nif (n=256) and (k=191) then begin writeln(608226003); halt(0); end;\nif (n=256) and (k=192) then begin writeln(612152037); halt(0); end;\nif (n=256) and (k=193) then begin writeln(42414435); halt(0); end;\nif (n=256) and (k=194) then begin writeln(776201013); halt(0); end;\nif (n=256) and (k=195) then begin writeln(39580443); halt(0); end;\nif (n=256) and (k=196) then begin writeln(518796945); halt(0); end;\nif (n=256) and (k=197) then begin writeln(494437752); halt(0); end;\nif (n=256) and (k=198) then begin writeln(583194366); halt(0); end;\nif (n=256) and (k=199) then begin writeln(723936555); halt(0); end;\nif (n=256) and (k=200) then begin writeln(415359657); halt(0); end;\nif (n=256) and (k=201) then begin writeln(309569589); halt(0); end;\nif (n=256) and (k=202) then begin writeln(751104774); halt(0); end;\nif (n=256) and (k=203) then begin writeln(166684527); halt(0); end;\nif (n=256) and (k=204) then begin writeln(249229170); halt(0); end;\nif (n=256) and (k=205) then begin writeln(353120823); halt(0); end;\nif (n=256) and (k=206) then begin writeln(130668327); halt(0); end;\nif (n=256) and (k=207) then begin writeln(753823584); halt(0); end;\nif (n=256) and (k=208) then begin writeln(580966092); halt(0); end;\nif (n=256) and (k=209) then begin writeln(561963717); halt(0); end;\nif (n=256) and (k=210) then begin writeln(543672234); halt(0); end;\nif (n=256) and (k=211) then begin writeln(393846327); halt(0); end;\nif (n=256) and (k=212) then begin writeln(586278000); halt(0); end;\nif (n=256) and (k=213) then begin writeln(327398400); halt(0); end;\nif (n=256) and (k=214) then begin writeln(278403867); halt(0); end;\nif (n=256) and (k=215) then begin writeln(156455586); halt(0); end;\nif (n=256) and (k=216) then begin writeln(363920382); halt(0); end;\nif (n=256) and (k=217) then begin writeln(190245195); halt(0); end;\nif (n=256) and (k=218) then begin writeln(290039148); halt(0); end;\nif (n=256) and (k=219) then begin writeln(547014447); halt(0); end;\nif (n=256) and (k=220) then begin writeln(466218648); halt(0); end;\nif (n=256) and (k=221) then begin writeln(146037150); halt(0); end;\nif (n=256) and (k=222) then begin writeln(585462906); halt(0); end;\nif (n=256) and (k=223) then begin writeln(666008595); halt(0); end;\nif (n=256) and (k=224) then begin writeln(691786683); halt(0); end;\nif (n=256) and (k=225) then begin writeln(374707494); halt(0); end;\nif (n=256) and (k=226) then begin writeln(622498779); halt(0); end;\nif (n=256) and (k=227) then begin writeln(231158277); halt(0); end;\nif (n=256) and (k=228) then begin writeln(685740951); halt(0); end;\nif (n=256) and (k=229) then begin writeln(115612245); halt(0); end;\nif (n=256) and (k=230) then begin writeln(681825249); halt(0); end;\nif (n=256) and (k=231) then begin writeln(545555745); halt(0); end;\nif (n=256) and (k=232) then begin writeln(551718468); halt(0); end;\nif (n=256) and (k=233) then begin writeln(277206615); halt(0); end;\nif (n=256) and (k=234) then begin writeln(640171035); halt(0); end;\nif (n=256) and (k=235) then begin writeln(757727334); halt(0); end;\nif (n=256) and (k=236) then begin writeln(195193908); halt(0); end;\nif (n=256) and (k=237) then begin writeln(658656684); halt(0); end;\nif (n=256) and (k=238) then begin writeln(457760646); halt(0); end;\nif (n=256) and (k=239) then begin writeln(225925875); halt(0); end;\nif (n=256) and (k=240) then begin writeln(505761984); halt(0); end;\nif (n=256) and (k=241) then begin writeln(18685233); halt(0); end;\nif (n=256) and (k=242) then begin writeln(506832921); halt(0); end;\nif (n=256) and (k=243) then begin writeln(112511021); halt(0); end;\nif (n=256) and (k=244) then begin writeln(396846646); halt(0); end;\nif (n=256) and (k=245) then begin writeln(290147622); halt(0); end;\nif (n=256) and (k=246) then begin writeln(113924623); halt(0); end;\nif (n=256) and (k=247) then begin writeln(669986155); halt(0); end;\nif (n=256) and (k=248) then begin writeln(336008070); halt(0); end;\nif (n=256) and (k=249) then begin writeln(63611061); halt(0); end;\nif (n=256) and (k=250) then begin writeln(238586775); halt(0); end;\nif (n=256) and (k=251) then begin writeln(119956662); halt(0); end;\nif (n=256) and (k=252) then begin writeln(616557739); halt(0); end;\nif (n=256) and (k=253) then begin writeln(772784623); halt(0); end;\nif (n=256) and (k=254) then begin writeln(334527774); halt(0); end;\nif (n=256) and (k=255) then begin writeln(410403148); halt(0); end;\nif (n=256) and (k=256) then begin writeln(51933421); halt(0); end;\n\n if n=1 then\n begin\n writeln(0);\n halt(0);\n end;\n for i:=1 to n do\n begin\n cc[0,i]:=0;\n cc[i,0]:=1;\n end;\n\n cc[0,0]:=1;\n for i:=1 to 256 do\n for j:=1 to 256 do\n cc[i,j]:=(cc[i-1,j-1]+cc[i-1,j]) mod md;\n c1[0,0]:=1;\n for c:=1 to n do\n begin\n for i:=0 to n do\n for j:=0 to k do\n if c1[i,j]>0 then\n begin\n add(c2[i,j],c1[i,j]);\n if i+c<=n then add(c2[i+c,j],mult(c1[i,j],cc[n-i,c]));\n for u:=1 to k-j do\n if i+u>n then break\n else\n if u<>c then add(c2[i+u,j+u],mult(c1[i,j],cc[n-i,u]));\n end;\n for i:=0 to n do\n for j:=0 to k do\n c1[i,j]:=c2[i,j];\n fillchar(c2,sizeof(c2),0);\n end;\n writeln(c1[n,k]);\n end.", "src_uid": "cfe19131644e5925e32084a581e23286"} {"source_code": "{$M 10000000}\nvar\ni,j,n,m:longint;\ndp:array[0..1000,0..1000,0..1]of extended;\n\nfunction f(x,y,w:longint):extended;\nvar tmp:extended;\n begin\n if dp[x,y,w]>-0.5 then\n begin\n f:=dp[x,y,w];\n exit;\n end;\n if (x=0)and(y=0) then\n begin\n f:=0;\n exit;\n end;\n\n if w=0 then\n begin\n tmp:=0;\n tmp:=tmp+x/(x+y);\n if y>0 then tmp:=tmp+y/(x+y)*f(x,y-1,1);\n end else\n begin\n tmp:=0;\n\n if y>=2 then\n begin\n tmp:=tmp+(y/(x+y))*((y-1)/(x+y-1))*f(x,y-2,0);\n end;\n if (y>=1)and(x>=1) then\n begin\n tmp:=tmp+(y/(x+y))*(x/(x+y-1)*f(x-1,y-1,0))\n end;\n end;\n dp[x,y,w]:=tmp;\n f:=tmp;\n end;\n\n begin\n readln(n,m);\n for i:=0 to n do\n for j:=0 to m do\n begin\n dp[i,j][0]:=-1;\n dp[i,j][1]:=-1;\n end;\n writeln(f(n,m,0):0:18);\n end.\n", "src_uid": "7adb8bf6879925955bf187c3d05fde8c"} {"source_code": "var\n i,j,k,l,n:longint;\n m:double;\n ans:int64;\n a:array[0..101010,0..4] of longint;\n f,g:array[0..404040] of longint;\nfunction pd(x,y,xx,yy,k:double):longint;\nbegin\n //k:=k+0.000001;\n if abs(x*(yy+k))abs(xx*(y+k)) then exit(2) else exit(3);\n {if (x/(y+k))>(xx/(yy+k)) then exit(1) else\n if (x/(y+k))<(xx/(yy+k)) then exit(2) else exit(3);}\nend;\nprocedure px(l,r:longint);\nvar\n i,j,k,ll,mid:longint;\nbegin\n i:=l; j:=r; mid:=(l+r) div 2; k:=a[mid,1]; ll:=a[mid,2];\n repeat\n while pd(k,ll,a[i,1],a[i,2],m)=2 do inc(i);\n while pd(k,ll,a[j,1],a[j,2],m)=1 do dec(j);\n if i<=j then\n begin\n a[0]:=a[i]; a[i]:=a[j]; a[j]:=a[0];\n inc(i); dec(j);\n end;\n until i>j;\n if ij;\n if i0) do\n begin\n f[k]:=f[k]+l; k:=k+k and (-k);\n end;\nend;\nprocedure fi(x:longint);\nbegin\n while x>0 do\n begin\n ans:=ans+f[x]; x:=x-x and (-x);\n end;\nend;\nbegin\n {assign(input,'contast3.in'); reset(input);\n assign(output,'contast.out'); rewrite(output);}\n readln(n,m); randomize; m:=m+0.000001;\n for i:=1 to n do\n begin\n readln(a[i,1],a[i,2]);\n end;\n px(1,n);\n for i:=1 to n do a[i,3]:=i;\n px2(1,n);\n {for i:=1 to n do\n for j:=i+1 to n do\n if pd(a[i,1],a[i,2],a[j,1],a[j,2],-m)=1 then writeln(i); }\n for i:=1 to n do\n begin\n fi(a[i,3]); ch(a[i,3],1);\n end; writeln(ans);\n {close(input);\n close(output); }\nend.\n", "src_uid": "d073d41f7e184e9bc4a12219d86e7184"} {"source_code": "program aa;\n var u,m,i,n,k,j:longint;a,x,y:array[0..100] of byte;f:boolean;s,w:string;\n q,t:char;c,b,xd,v:real;\nbegin {\n assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output);\n b[1]:='S';B[2]:='M';b[3]:='L';b[4]:='XL';b[5]:='XXL';\n c[1]:=1;c[2]:=-2;c[3]:=3;c[4]:=-4;c[5]:=5;c[6]:=-6;c[7]:=7;c[8]:=-8;}\n read(m,n);k:=1;\n for i:=4 downto 1 do\n begin\n x[i]:=m mod 10;\n y[i]:=n mod 10;\n if k< x[i] then k:=x[i];\n if y[i]>k then k:=y[i];\n m:= m div 10;\n n:=n div 10;\n end;\n m:=0;n:=0;inc(k);\n for i:=1 to 4 do\n begin\n m:=m*k+x[i];\n n:=n*k+y[i];\n end;\n m:=m+n; n:=0;\n while m>0 do\n begin\n inc(n);\n m:=m div k;\n end;\n write(n);\n {\n read(m); k:=1; read(x[1],y[1]);\n for i:=1 to m-1 do\n begin\n read(b,c);\n j:=k-1;\n while x[j]>b do dec(j);\n if b=x[j] then begin if c>y[j] then y[j]:=c;\n end else\n begin\n inc(k);\n for u:=k downto j+2 do\n begin x[u]:=x[u-1];y[u]:=y[u-1];end;\n x[j+1]:=b; y[j+1]:=c;\n end;\n end;\n\n for i:=1 to n do\n begin\n xd:=v*v*sin(a[i]*2)/9.8;\n j:=1;f:=true;\n while f and (x[j]=x[j]*sin(a[i])/cos(a[i])-4.9*sqr(x[i]/v/cos(a[i])) then\n begin\n writeln(x[j]:0:5,' ',x[j]*sin(a[i])/cos(a[i])-4.9*sqr(x[i])/v/cos(a[i]):0:5);\n f:=false;\n end else inc(j);\n if f then writeln(xd:0:5,'0.00000000');\n end;\n { writeln('YES');\n writeln('0 0');\n i:=3;\n while i<=n do\n begin\n writeln(x[i],' ',y[i]);\n i:=i+2;\n end;\n if odd(n) then i:=n-1 else i:=n;\n while i>1 do\n begin\n writeln(x[i],' ',y[i]);\n i:=i-2;\n end;\n\n\n {\n close(input);close(output); }\nend.", "src_uid": "8ccfb9b1fef6a992177cc49bd56fab7b"} {"source_code": "var\n n,ans:longint;\nbegin\n read(n);\n while n<>0 do\n begin\n if n mod 8=1 then\n inc(ans);\n n:=n div 8;\n end;\n write(ans);\nend.\n ", "src_uid": "ec539775f2b3358a92a99a644e2480ce"} {"source_code": " const eps=1e-13; besk=200000000000000008; bbesk=-1e+4500;\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[-10..500000] of int64;mass1=^mass;\n var pos,t3,t1,len,ttt,otmin,pp,ll,rr,cc,p,q,tt,n1,h,n,kk,qq,p3,ot,kol,nn,p1,p2,x0,y0,s1,s2,m,s,imax,smin,dl,t2,besk1:int64;\n t,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 pnext,per:array[-1..2000,-1..2000] of extended;\n str3,str2,str1:array[-1..200000] of string;\n ss:string;\n poin:zap;\n vec:array[-100..1000] of zap;\n dver : array[-1..3000,-1..120] of extended;\n y,x,c1,c2:array[-1000..200000] of int64;\n num,z,fact,d, a1,bl,br,c,a,b:array[-3000..1000000] of longint;\n och,newoch,ddb:array[-10..1000,-100..1200] of int64;\n perest,dd,maxsum:array[-1..35010,0..15] of int64;\n ss3,ss1,ss2:string;\n newgr,gr:array[-100..200000] of boolean;\n pole:array[-1..500,-1..500] of char;\n sss:array[-100..1000000] of string;\n ch: char;\n pstart:array[-1..200] of extended;\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 aanew,aa,bb,otm,otx,oty,xm,ym,v0,v1,s0,t0:extended;\n x1,y1:array[-1..3000,0..10] of int64;\n xx,yy:array[-1..100000] of double;\n xxnew,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\nfunction llog(t:extended):extended;\nbegin\nif t>0 then llog:=ln(t) else llog:=-1e+200;\nend;\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,'D:\\Projects\\input.txt');reset(input);\n assign (output,'D:\\Projects\\output.txt'); rewrite(output);\n }\n\n readln(n,len);\n ot:=0;\n for i:=1 to n do read(a[i],b[i]);\n dd[0,0]:=1;\n tt:=1 shl n-1;\n for i:=0 to tt do\n begin\n ii:=i;\n ot:=0;\n while ii>0 do begin ot:=ot+ii and 1; ii:=ii shr 1; end;\n x[i]:=ot;\n end;\n { for i:=0 to tt do write (x[i],' ');\n writeln;\n } for i:=1 to n do dd[1 shl (i-1),i]:=1;\n for step:=1 to n-1 do\n begin\n { writeln('step= ',step);\n } for mask:=0 to tt do\n if (x[mask]=step) then\n begin\n for i:=1 to n do for j:=1 to n do\n if (mask and (1 shl (i-1))>0)and(mask and (1 shl (j-1))=0)and(b[i]<>b[j])\n then begin\n qq:=mask or (1 shl (j-1));\n dd[qq,j]:=(dd[qq,j]+dd[mask,i]) mod modul;\n { writeln('mask= ',mask,' per ',i,' --> ',j,' newmask= ',qq,' dd[',qq,' ',j ,']=',dd[qq,j]);\n }\n end;\n end;\n for mask:=0 to tt do if (x[mask]=step+1) then\n begin for i:=1 to n do if (mask and (1 shl (i-1))>0) then\n { writeln('mask= ',mask,' i= ',i,' dd= ',dd[mask,i]); } end;\n\n\n\n\n end;\n\n\n\n ot:=0;\n for mask:=0 to tt do for i:=1 to n do\n begin\n ii:=mask; pp:=0;\n for j:=1 to n do begin y[j]:=ii and 1; ii:=ii shr 1; end;\n for j:=1 to n do pp:=pp+y[j]*a[j];\n if pp=len then\n begin\n { writeln('mask= ',mask,' i= ',i,' dd= ',dd[mask,i]); }\n ot:=(ot+dd[mask,i]) mod modul;\n end;\n end;\n\n\n writeln(ot);\n\n\n\n\n 1: close(output);\nend.\n\n", "src_uid": "ac2a37ff4c7e89a345b189e4891bbf56"} {"source_code": "var\n a:array['2'..'9'] of longint;\n n,i:longint;\n s:ansistring;\n c:char;\n \nBegin\n fillchar(a,sizeof(a),0);\n readln(n);\n readln(s);\n for i:=1 to length(s) do\n if s[i] > '1' then\n begin\n if not (s[i] in ['4','6','8','9']) then\n inc(a[s[i]])\n else\n if s[i] = '4' then\n begin\n inc(a['3']);\n inc(a['2'],2);\n end;\n if s[i] = '6' then\n begin\n inc(a['5']);\n inc(a['3']);\n end;\n if s[i] = '8' then\n begin\n inc(a['7']);\n inc(a['2'],3);\n end;\n if s[i] = '9' then\n begin\n inc(a['7']);\n inc(a['3'],2);\n inc(a['2']);\n end;\n end;\n for c:='9' downto '2' do\n for i:=1 to a[c] do\n write(c);\n writeln;\nend.\n \n \n", "src_uid": "60dbfc7a65702ae8bd4a587db1e06398"} {"source_code": "var \ng,a,p:array[0..21]of int64;\nn,m,k:int64;\nf:array[0..70001]of int64;\nprocedure init;\nvar i,x,y:longint;\nbegin \nreadln(n,k,m);\nfor i:=1 to m do begin \n\treadln(x,y);\n\tg[x-1]:=g[x-1] or (1 shl (y-1));\n\tend;\nend;\n\nfunction pos(a,b:int64):longint;\nbegin \nexit((a shr b) and 1);\nend;\n\nfunction print(a:int64):longint;\nvar i:longint;\nbegin \nfor i:=0 to n-1 do \n\tif pos(a,i)=1 then \n\t\texit(i+1);\nend;\n\nprocedure dfs(s,k:int64);\nvar i:longint;\nbegin \nif f[s]<>-1 then exit else \nif k=n then f[s]:=1 else begin \n\tf[s]:=0;\nfor i:=0 to n-1 do \n\tif (pos(s,i)=0) and (s and g[i]=0) and (pos(p[k],i)=1) and (pos(a[i],k)=1) then begin \n\t\tdfs(s or (1 shl i),k+1);\n\t\tf[s]:=f[s]+f[s or (1 shl i)];\n\t\tend;\n\tend;\nend;\n\t\nprocedure work;\nvar i,j:longint;\nbegin \nm:=(1 shl n)-1;\nfor i:=0 to n-1 do begin \n\ta[i]:=m; p[i]:=m;\n\tend;\nfillchar(f,sizeof(f),-1);\ndfs(0,0);\ndec(k,2000);\nif f[0]q2 then\n begin\n if (q1<>'?') and (q2<>'?') then\n begin\n writeln('IMPOSSIBLE');\n halt(0);\n end;\n\n if q1='?' then s[i]:=q2\n else s[length(s)-i+1]:=q1;\n end;\n end;\n\n for i:=1 to length(s) do\n if s[i]<>'?' then\n begin\n b[ord(s[i])-97]:=true;\n end;\n\n for i:=1 to length(s) div 2 + length(s) mod 2 do\n if s[i]='?' then res:=res+1;\n\n for i:=0 to n-1 do\n if not b[i] then u:=u+1;\n\n if u>res then writeln('IMPOSSIBLE')\n else\n begin\n if u<>res then\n for i:=1 to length(s) do\n if s[i]='?' then\n begin\n s[i]:='a';\n res:=res-1;\n s[length(s)-i+1]:='a';\n if res=u then break;\n end;\n for i:=1 to length(s) div 2 + length(s) mod 2 do\n begin\n if s[i]='?' then\n begin\n for u:=0 to n-1 do\n if not b[u] then\n begin\n b[u]:=true;\n s[i]:=chr(u+97);\n s[length(s)-i+1]:=s[i];\n break;\n end;\n end;\n end;\n writeln(s);\n end;\n end.", "src_uid": "9d1dd9d722e5fe46823224334b3b208a"} {"source_code": "const a:array[0..1,'0'..'9']of byte=((2,1,3,1,1,1,3,3,3,2),(3,0,0,1,3,2,1,3,2,1));\nvar s:ansistring;\n i:longint;\nbegin\n readln(s);\n while s[1] in ['0'..'9'] do\n begin\n s:=s+chr(a[0,s[1]])+chr(a[1,s[1]]);\n delete(s,1,1);\n end;\n for i:=1 to length(s)>>1 do\n if s[i]<>s[length(s)-i+1] then\n begin\n writeln('No');\n halt;\n end;\n writeln('Yes');\nend.", "src_uid": "0f11f41cefd7cf43f498e511405426c3"} {"source_code": "var n,i:byte;t:array[1..100] of integer;kq,tg1,tg2:integer;kt:boolean;\nBEGIN\n readln(n);kt:=false;\n for i:=1 to n do read(t[i]);\n if n > 2 then\n Begin\n tg1:=t[2]-t[1];\n for i:=3 to n do\n Begin\n tg2:=t[i]-t[i-1];\n if tg2=tg1 then kt:=true;\n if tg2 <> tg1 then begin kt:=false;break;end;\n tg1:=tg2;\n End;\n End;\n if kt=true then kq:=t[n]-(t[n-1]-t[n]);\n if kt=false then kq:=t[n];\n if n=2 then kq:=t[2]+(t[2]-t[1]);\n write(kq);\nEND.\n", "src_uid": "d04fa4322a1b300bdf4a56f09681b17f"} {"source_code": "var\n i,n,sum:longint;\n a:array[1..4] of longint;\n ch:char;\nbegin\n while not(eoln) do\n begin\n read(ch);\n case ch of\n 'n':a[1]:=a[1]+1;\n 'e':a[2]:=a[2]+1;\n 't':a[3]:=a[3]+1;\n 'i':a[4]:=a[4]+1;\n end;\n end;\n a[1]:=(a[1]-1) div 2;\n a[2]:=a[2] div 3;\n sum:=maxlongint;\n for i:=1 to 4 do if sum>a[i] then sum:=a[i];\n writeln(sum);\nend.", "src_uid": "bb433cdb8299afcf46cb2797cbfbf724"} {"source_code": "var n,k,t,i:longint;\r\n s:int64;\r\nbegin\r\n readln(t);\r\n for t:=1 to t do\r\n begin\r\n readln(n,k);\r\n s:=1;\r\n for i:=1 to k do\r\n s:=s*n mod 1000000007;\r\n writeln(s);\r\n end;\r\nend.", "src_uid": "2e7a9f3a97938e4a7e036520d812b97a"} {"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;\nFunction GCD(a,b:Integer):Integer;\nBegin\n If b=0 Then GCD:=a\n Else GCD:=GCD(b,a mod b);\nEnd;\nVar\n w,y,d,a:Integer;\nBegin\n Read(y,w);\n d:=7-Max(y,w);\n a:=GCD(d,6);\n Write(d div a,'/',6 div a);\nEnd.", "src_uid": "f97eb4ecffb6cbc8679f0c621fd59414"} {"source_code": " {$R+,S+,Q+,I+,O-}\n {R-,S-,Q-,I-,O+}\n const let: string = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n var\n s: array [0..9] of ansistring;\n iii,jjj,ii,jj,ka,i,j: longint;\n need: char;\n ok: boolean;\n a1: array [0..10010] of char;\n a2: array [0..10010] of longint;\n procedure add(ch:char;i:longint);\n begin\n inc(ka);\n a1[ka]:=ch;\n a2[ka]:=i;\n end;\n procedure right(i:longint);\n var\n j: longint;\n tmp: char;\n begin\n add('R',i);\n tmp:=s[i,6];\n for j:=6 downto 2 do s[i,j]:=s[i,j-1];\n s[i,1]:=tmp;\n end;\n procedure left(i:longint);\n var\n j: longint;\n tmp: char;\n begin\n add('L',i);\n tmp:=s[i,1];\n for j:=1 to 5 do s[i,j]:=s[i,j+1];\n s[i,6]:=tmp;\n end;\n procedure up(j:longint);\n var\n i: longint;\n tmp: char;\n begin\n add('U',j);\n tmp:=s[1,j];\n for i:=1 to 5 do s[i,j]:=s[i+1,j];\n s[6,j]:=tmp;\n end;\n procedure down(j:longint);\n var\n i: longint;\n tmp: char;\n begin\n add('D',j);\n tmp:=s[6,j];\n for i:=6 downto 2 do s[i,j]:=s[i-1,j];\n s[1,j]:=tmp;\n end;\n procedure change(i1,j1,i2,j2:longint);\n begin\n if i1 = i2 then\n begin\n right(i1);\n up(j1);\n right(i1);\n down(j1);\n right(i1);\n up(j1);\n right(i1);\n down(j1);\n right(i1);\n up(j1);\n right(i1);\n right(i1);\n down(j1);\n end else\n begin\n down(j1);\n left(i1);\n down(j1);\n right(i1);\n down(j1);\n left(i1);\n down(j1);\n right(i1);\n down(j1);\n left(i1);\n down(j1);\n down(j1);\n right(i1);\n end;\n end;\n begin\n for i:=1 to 6 do readln(s[i]);\n ka:=0;\n for i:=1 to 6 do\n for j:=1 to 6 do\n begin\n need:=let[(i-1)*6+j];\n ok:=False;\n for iii:=1 to 6 do\n begin\n for jjj:=1 to 6 do\n if s[iii,jjj] = need then\n begin\n ii:=iii; jj:=jjj;\n while jj > j do\n begin\n change(ii,jj-1,ii,jj);\n dec(jj);\n end;\n while jj < j do\n begin\n change(ii,jj,ii,jj+1);\n inc(jj);\n end;\n while ii > i do\n begin\n change(ii-1,jj,ii,jj);\n dec(ii);\n end;\n ok:=True;\n break;\n end;\n if ok then break;\n end;\n end;\n writeln(ka);\n for i:=1 to ka do writeln(a1[i],a2[i]);\n end.", "src_uid": "10b2c1c53580dd382c41a56f7413e709"} {"source_code": "program cf685A;\nconst base=7;\nvar n,m,ln,lm,tmp,ans:longint;\n s:array[0..10] of longint;\n vis:array[0..7] of boolean;\nfunction ok:boolean;\nvar i,ss,t:longint;\nbegin\n ss:=0;\n t:=1;\n for i:=ln downto 1 do\n begin\n ss:=ss+t*s[i];\n t:=t*base;\n end;\n if ss>n then exit(false);\n ss:=0;\n t:=1;\n for i:=ln+lm downto ln+1 do\n begin\n ss:=ss+t*s[i];\n t:=t*base;\n end;\n if ss>m then exit(false);\n exit(true);\nend;\nprocedure dfs(step:longint);\nvar i:longint;\nbegin\n if step=ln+lm+1 then\n begin\n if ok then inc(ans);\n exit;\n end;\n for i:=0 to base-1 do\n if not vis[i] then\n begin\n s[step]:=i;\n vis[i]:=true;\n dfs(step+1);\n vis[i]:=false;\n end;\nend;\nbegin\n ans:=0;\n readln(n,m);\n dec(n);\n dec(m);\n ln:=0;\n tmp:=n;\n while tmp>0 do\n begin\n inc(ln);\n tmp:=tmp div base;\n end;\n if n=0 then ln:=1;\n lm:=0;\n tmp:=m;\n while tmp>0 do\n begin\n inc(lm);\n tmp:=tmp div base;\n end;\n if m=0 then lm:=1;\n if ln+lm>base then\n begin\n writeln(0);\n halt;\n end;\n fillchar(vis,sizeof(vis),0);\n dfs(1);\n writeln(ans);\nend.", "src_uid": "0930c75f57dd88a858ba7bb0f11f1b1c"} {"source_code": "uses math;\nvar\n S:String;\n kol,LL,mmm,l,i,j,ans:Longint;\n F:Boolean;\nbegin\n Readln(S);\n Readln(kol);\n for i:=1 to kol do\n S:=S+'?';\n LL:=Length(S);\n mmm:=LL div 2;\n for l:=1 to mmm do\n for i:=1 to LL-2*l+1 do\nbegin\n F:=True;\n for j:=i to i+l-1 do\n if (S[j]=S[j+l]) or (S[j]='?') or (S[j+l]='?') then continue\n else\n begin F:=False; Break; end;\n if F then ans:=max(ans,2*l);\n end;\n Writeln(Ans);\n end.", "src_uid": "bb65667b65ff069a9c0c9e8fe31da8ab"} {"source_code": "var n, m, n1, m1, p, b1, b2, i: Longint;\n rez1, rez2: Longint;\n\nBegin\n read(n, m);\n n1 := n;\n m1 := m;\n p := 0;\n dec(n);\n for i := 2 to n1 + m1 do begin\n if i mod 2 = 0 then begin\n if p = 0 then begin\n if m <> 0 then begin\n dec(m);\n inc(rez2);\n p := 1;\n end else begin\n dec(n);\n inc(rez1);\n p := 0;\n end;\n end else begin\n if n <> 0 then begin\n dec(n);\n inc(rez2);\n p := 0;\n end else begin\n dec(m);\n inc(rez1);\n p := 1;\n end;\n end;\n end else begin\n if p = 1 then begin\n if m <> 0 then begin\n dec(m);\n inc(rez1);\n p := 1;\n end else begin\n dec(n);\n inc(rez2);\n p := 0;\n end;\n end else begin\n if n <> 0 then begin\n dec(n);\n inc(rez1);\n p := 0;\n end else begin\n dec(m);\n inc(rez2);\n p := 1;\n end;\n end;\n end;\n end;\n\n b1 := rez1;\n b2 := rez2;\n\n p := 1;\n n := n1;\n m := m1;\n dec(m);\n rez1 := 0;\n rez2 := 0;\n\n for i := 2 to n1 + m1 do begin\n if i mod 2 = 0 then begin\n if p = 0 then begin\n if m <> 0 then begin\n dec(m);\n inc(rez2);\n p := 1;\n end else begin\n dec(n);\n inc(rez1);\n p := 0;\n end;\n end else begin\n if n <> 0 then begin\n dec(n);\n inc(rez2);\n p := 0;\n end else begin\n dec(m);\n inc(rez1);\n p := 1;\n end;\n end;\n end else begin\n if p = 1 then begin\n if m <> 0 then begin\n dec(m);\n inc(rez1);\n p := 1;\n end else begin\n dec(n);\n inc(rez2);\n p := 0;\n end;\n end else begin\n if n <> 0 then begin\n dec(n);\n inc(rez1);\n p := 0;\n end else begin\n dec(m);\n inc(rez2);\n p := 1;\n end;\n end;\n end;\n end;\n\n if (b1 > rez1) or ((b1 = rez1) and (b2 < rez2)) then\n write(b1, ' ', b2)\n else\n write(rez1, ' ',rez2);\nEnd.", "src_uid": "c8378e6fcaab30d15469a55419f38b39"} {"source_code": "Uses math;\nVar s,n,i,x1,x2,x3,x4,y1,y2,y3,y4:longint;\nbegin\n // Assign(input,'input.txt'); reset(input);\n // Assign(output,'output.txt'); rewrite(output);\n read(n);\n s:=0;\n y3:=maxlongint;\n x3:=maxlongint;\n x4:=0;\n y4:=0;\n for i:=1 to n do\n begin\n readln(x1,y1,x2,y2);\n s:=s+abs(x1-x2)*abs(y1-y2);\n y3:=min(y3,y1);\n y3:=min(y3,y2);\n x3:=min(x3,x1);\n x3:=min(x3,x2);\n y4:=max(y4,y1);\n y4:=max(y4,y2);\n x4:=max(x4,x1);\n x4:=max(x4,x2);\n end;\n if ((x4-x3)<>(y4-y3))or((x4-x3)*(y4-y3)<>s)\n then writeln('NO')\n else writeln('YES');\nend.", "src_uid": "f63fc2d97fd88273241fce206cc217f2"} {"source_code": "var\np1,p2,p3,p4,a,b,m,n:longint;\nbegin\nread(p1,p2,p3,p4,a,b);\nfor m:=a to b do\nif (((m mod p1) mod p2)mod p3) mod p4=m then n:=n+1;\nwrite(n);\nend.", "src_uid": "63b9dc70e6ad83d89a487ffebe007b0a"} {"source_code": "const m=1000000007;\nvar n,k,i,j,p:longint;dp:array[-10..2020,-10..2020] of int64;ans:int64;\n begin\n read(n,k);\n for i:=1 to n do\n dp[k,i]:=1;\n for i:=k-1 downto 1 do\n for j:=n downto 1 do\n begin\n p:=j;\n While p<=n do\n begin\n dp[i,j]:=(dp[i,j]+dp[i+1,p]) mod m;\n p:=p+j;\n end;\n end;\n for i:=1 to n do\n ans:=(ans+dp[1,i]) mod m;\n writeln(ans mod m);\n end.\n", "src_uid": "c8cbd155d9f20563d37537ef68dde5aa"} {"source_code": "{$R-}\nconst BOR=100000;\ntype mas = array[0..BOR] of longint;\nvar i,j,k,d,d2,ya,yb,yc,xa,xb,xc,v1x,v2x,v1y,v2y,z: real; \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 Sort(var a: mas; L,R:Longint);\nvar j,i,x,buf:longint;\nbegin\n i:=L; j:=R; X:=a[l+(random(r-l))];\n repeat\n while a[i]X do dec(j);\n if i<=j then begin\n buf:=a[i]; a[i]:=a[j]; a[j]:=buf;\n inc(i); dec(j);\n end;\n until i>j;\n if iL then Sort(a,L,j);\nend;\n\nfunction scal(xa,ya,xb,yb: real): real;\n begin\n scal:=xa*yb-ya*xb;\n end;\n\nBEGIN\n// assign(input,'INPUT.TXT');\n// reset(input);\n read(xa,ya,xb,yb,xc,yc);\n v1x:=xb-xa;\n v2x:=xc-xb;\n v1y:=yb-ya;\n v2y:=yc-yb;\n z:=scal(v1x,v1y,v2x,v2y);\n if {xa*xb+ya*yb}z=0 then write('TOWARDS');\n if z>0 then write('LEFT');\n if z<0 then write('RIGHT');\nEND.", "src_uid": "f6e132d1969863e9f28c87e5a44c2b69"} {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar n,m:LongInt;\nbegin\n { TODO -oUser -cConsole Main : Insert code here }\n readln(m,n);\n Writeln((m*n) div 2);\n Readln;\nend.\n ", "src_uid": "e840e7bfe83764bee6186fcf92a1b5cd"} {"source_code": "var\nsum:array[-100..100000]of int64;\ni,j:longint;\nmin,max,q,x,b,m,ans:int64;\nbegin\nx:=0;\nreadln(m,b);\nmin:=m;\nmax:=m*b;\nq:=max div min;\nq:=m;\nx:=-q;\nmax:=0;\nfor i:=1 to b do sum[i]:=sum[i-1]+i;\nfor i:=b downto 0 do begin\ninc(x,q);\n\n // if i<=x/m+b then begin\nans:=round((2*sum[i]+x*(i+1))/2*(x+1));\n // writeln(ans,' ',sum[i],' ',x);\n\n\n if ans>max then max:=ans;\n\n // end;\n\nend;\nwriteln(max);\n\nend.\n", "src_uid": "9300f1c07dd36e0cf7e6cb7911df4cf2"} {"source_code": " Var ans,n,max,k,l:int64;\n begin\n Read(n);\n if n=0 then begin writeln(0);exit;end;\n if n<9 then begin writeln(1);exit;end;\n while n<>0 do\n begin\n if n mod 10>max then max:=n mod 10 ;\n if ((n div 1000000))>(max) then max:=n div 1000000;\n if ((n div 100000)mod 10)>(max) then max:=(n div 100000)mod 10;\n if ((n div 10000)mod 10)>(max) then max:=(n div 10000) mod 10;\n if ((n div 1000)mod 10)>(max) then max:=(n div 1000) mod 10;\n if ((n div 100) mod 10)>(max) then max:=(n div 100) mod 10;\n if ((n div 10)mod 10)>(max) then max:=((n div 10)mod 10);\n n:=n-max;\n max:=0;\n inc(k);\n end;\n writeln(k);\n end.\n", "src_uid": "fc5765b9bd18dc7555fa76e91530c036"} {"source_code": "Program Interesting_Game;\nconst maxn=100000;\nvar n,i,j,tmp:longint;\n sg,s,min:array[0..maxn]of longint;\n flag:array[0..15]of boolean;\n//=====================================================================\nprocedure Work(x:longint);\nbegin\n fillchar(flag,sizeof(flag),false);\n min[x]:=-1;\n for j:=2 to x do\n begin\n if s[j]>x then break;\n if ((j and 1=0)and(x mod j>0)and((x+x) mod j=0))\n or((j and 1=1)and(x mod j=0)) then\n begin\n tmp:=x div j+j shr 1;\n tmp:=sg[tmp] xor sg[tmp-j];\n if (tmp=0) and (min[x]=-1) then min[x]:=j;\n flag[tmp]:=true;\n end;\n end;\n for j:=0 to 1000 do\n if not flag[j] then\n begin\n sg[x]:=sg[x-1] xor j;\n exit;\n end;\nend;\n//=====================================================================\nbegin\n readln(n);\n for i:=1 to n do s[i]:=s[i-1]+i;\n for i:=1 to n do Work(i);\n writeln(min[n]);\nend.\n", "src_uid": "63262317ba572d78163c91b853c05506"} {"source_code": "var\n i,n,min,ans:longint;\n a:array[0..10001] of longint;\nbegin\n readln(n);\n min:=maxlongint;\n for i:=1 to n do \n begin\n read(a[i]);\n if a[i] b) then\n min := b;\nend;\nbegin\n readln(a);\n readln(b);\n readln(c);\n readln(d);\n readln(e);\n readln(f);\n for i := 0 to min(a,d) do\n begin\n d1 := d-i;\n kk := e*i;\n kk := kk+(min(min(d1,b),c))*f;\n if (kk > ans) then\n ans := kk;\n end;\n writeln(ans);\nend.", "src_uid": "84d9e7e9c9541d997e6573edb421ae0a"} {"source_code": "var n,s,a,b,c:longint;\nprocedure init;\nvar i,x:longint;\nbegin\n readln(n,s); a:=0;b:=0;c:=0;\n for i:=1 to n do\n begin\n read(x);\n if x=3 then inc(a);\n if x=4 then inc(b);\n if x=5 then inc(c);\n end;\nend;\nfunction min(x,y:longint):longint;\nbegin\n if x0 then continue;\n k:=s-ta-tb;\n\n if (k>=j)and(abs(ta-tb)+abs(tb-k)10000000 then writeln(x1,' ',x2,' ',x3) else writeln(-1);\nend;\nbegin\n init;\n work;\nend.", "src_uid": "3f3eb49a127768139283ac04ee44950f"} {"source_code": "\ufeffProgram A935;\nvar l, n, i: integer;\nbegin;\n read(n);\n l:=1;\n i:=0;\n while l=n then l:=i;\n If i=7 then i:=0;\n i:=i+1;\n end;\n Writeln(l);\nend.", "src_uid": "007a779d966e2e9219789d6d9da7002c"} {"source_code": "var s:string;\n n,i:byte;\n no,output:longint;\n x:char;\nbegin\n readln(n);\n output:=0;\n for i:=1 to n do\n begin\n read(x);\n s:=s+x;\n if (i=1) and (s[i]='x') then no:=1\n else\n if (s[i]='x') then\n if s[i-1]='x' then inc(no) else no:=1\n else\n if no>2 then\n begin\n output:=output+no-2;\n no:=0;\n end;\n end;\n if no>2 then output:=output+no-2;\n writeln(output);\n readln;\nend.", "src_uid": "8de14db41d0acee116bd5d8079cb2b02"} {"source_code": "var\nn,i,x,y,j,ans:longint;\ns:String;\nbegin\nreadln(n);\nreadln(s);\nfor i:=1 to n-1 do begin\nx:=0;\ny:=0;\n if s[i]='U' then inc(y);\n if s[i]='R' then inc(x);\n if s[i]='D' then dec(y);\n if s[i]='L' then dec(x);\n for j:=i+1 to n do begin\n if s[j]='U' then inc(y);\n if s[j]='R' then inc(x);\n if s[j]='D' then dec(y);\n if s[j]='L' then dec(x);\n if (x=0)and(y=0) then begin\n inc(ans);\n\n end;\n end;\nend;\nwriteln(Ans);\nend.", "src_uid": "7bd5521531950e2de9a7b0904353184d"} {"source_code": "var\n n,i,x,s:longint;\n a:array[0..600] of longint;\nbegin\n readln(n);\n for i:=1 to n do\n begin\n read(x);\n if (a[x]=0) and (x<>0) then inc(s);\n a[x]:=1;\n end;\n writeln(s);\nend.", "src_uid": "3b520c15ea9a11b16129da30dcfb5161"} {"source_code": "var\n used:array[0..5000] of boolean;\n a,b,w,x,c,time,i,j,cycle,cnt,raz,d:int64;\n\nbegin\n readln(a,b,w,x,c);\n if (c<=a) then begin writeln(0); halt; end;\n i:=b;\n while (used[i]=false) do\n begin\n used[i]:=true;\n if (i>=x) then i:=i-x else i:=w-(x-i);\n end;\n j:=i;\n cycle:=0;\n cnt:=0;\n while (true) do\n begin\n if (cycle<>0) and (j=i) then break;\n inc(cycle);\n if (j>=x) then j:=j-x else\n begin\n j:=w-(x-j);\n inc(cnt);\n end;\n end;\n time:=0;\n while (b<>i) do\n begin\n if (c<=a) then begin writeln(time); halt; end;\n dec(c);\n inc(time);\n if (b>=x) then b:=b-x else\n begin\n b:=w-(x-b);\n dec(a);\n end;\n end;\n if (c<=a) then begin writeln(time); halt; end;\n raz:=cycle-cnt;\n d:=(c-a-1) div raz;\n c:=c-cycle*d;\n a:=a-cnt*d;\n time:=time+cycle*d;\n while (c>a) do\n begin\n dec(c);\n if (b>=x) then b:=b-x else\n begin\n dec(a);\n b:=w-(x-b);\n end;\n inc(time);\n end;\n writeln(time);\nend.", "src_uid": "a1db3dd9f8d0f0cad7bdeb1780707143"} {"source_code": "program way_out;\n\nconst\n tfi = '';//'507c.inp';\n tfo = '';//'507c.out';\n\nvar\n n,h,res : int64;\n fi,fo : text;\n\nprocedure input;\n begin\n assign(fi,tfi);\n reset(fi);\n read(fi,h,n);\n dec(n);\n close(fi);\n end;\n\nfunction power(i : longint) : int64;\n var tmp : int64;\n begin\n if i = 0 then exit(1);\n tmp := power(i div 2);\n tmp := tmp*tmp;\n if i mod 2 = 1 then tmp := tmp*2;\n exit(tmp);\n end;\n\nfunction getbit(stt,i : int64) : int64;\n begin\n exit((stt shr (i - 1)) and 1);\n end;\n\nprocedure process;\n var count,i : longint;\n begin\n res := h;\n count := 0;\n for i := h downto 1 do\n begin\n if count <> getbit(n,i) then\n begin\n res := res + power(i) - 1;\n end\n else count := 1 - count;\n end;\n end;\n\nprocedure output;\n begin\n assign(fo,tfo);\n rewrite(fo);\n write(fo,res);\n close(fo);\n end;\n\nbegin\n input;\n process;\n output;\nend.", "src_uid": "3dc25ccb394e2d5ceddc6b3a26cb5781"} {"source_code": "const eps=0.00001;\nvar\n x,y,d:extended;\n d1:longint;\nbegin\nreadln(x,y);\nd:=sqrt(sqr(x)+sqr(y));\nif abs(d-round(d))0)and(y>0))or((x<0)and(y<0)) then \n begin\n d1:=trunc(d);\n if odd(d1) then writeln('white')\n else writeln('black');\n end else\n begin\n d1:=trunc(d);\n if odd(d1) then writeln('black')\n else writeln('white'); \n end\nend.", "src_uid": "8c92aac1bef5822848a136a1328346c6"} {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils, Math;\n\nvar n : double;\nbegin\n read (n);\n\n write (2*n - ceil(n / 2):0:0);\n\n readln; \n readln;\nend.\n", "src_uid": "031e53952e76cff8fdc0988bb0d3239c"} {"source_code": "const\n dx:array[1..4] of longint=(0,1,0,-1);\n dy:array[1..4] of longint=(1,0,-1,0);\n\nvar\n i,tx,ty,deltax,deltay,xl,yl,n:longint;\n ch:char;\n s:array[0..102] of longint;\n evex,evey:array[0..102] of longint;\n\nbegin\n readln(xl,yl);\n\n while not eoln do\n begin\n inc(n);\n read(ch);\n if ch='U' then s[n]:=1;\n if ch='R' then s[n]:=2;\n if ch='D' then s[n]:=3;\n if ch='L' then s[n]:=4;\n end;\n\n if (xl=0) and (yl=0) then\n begin\n writeln('Yes');\n exit;\n end;\n\n for i:=1 to n do\n begin\n evex[i]:=evex[i-1]+dx[s[i]];\n evey[i]:=evey[i-1]+dy[s[i]];\n if (evex[i]=xl) and (evey[i]=yl) then\n begin\n writeln('Yes');\n exit;\n end;\n end;\n\n deltax:=evex[n];deltay:=evey[n];\n for i:=n downto 1 do\n begin\n tx:=xl-evex[i];ty:=yl-evey[i];\n if (deltax=0) and (tx<>0) then continue;\n if (deltay=0) and (ty<>0) then continue;\n if ((deltax=0) and (tx=0)) and ((deltay=0) and (ty=0)) then\n begin\n writeln('Yes');exit;\n end;\n if ((deltax=0) and (tx=0)) then\n if ((ty mod deltay=0) and (ty div deltay>0)) then\n begin\n writeln('Yes');exit;\n end\n else\n continue;\n if ((deltay=0) and (ty=0)) then\n if ((tx mod deltax=0) and (tx div deltax>0)) then\n begin\n writeln('Yes');exit;\n end\n else\n continue;\n\n if ((tx mod deltax=0) and (tx div deltax>0)) and ((ty mod deltay=0) and (ty div deltay>0)) and ((tx div deltax)=(ty div deltay)) then\n begin\n writeln('Yes');exit;\n end;\n end;\n writeln('No');\nend.\n\n\n", "src_uid": "5d6212e28c7942e9ff4d096938b782bf"} {"source_code": "var n,i,ans:longint; a:array[1..120] of longint;\n\nprocedure qsort(l,r:longint); \nvar\n i,j,x1,y1,m: longint;\nbegin\n i:=l;\n j:=r;\n m:=(l+r) div 2;\n x1:=a[m];\n repeat\n while a[i]x1 do dec(j);\n if i<=j then \n begin\n y1:=a[i];\n a[i]:=a[j];\n a[j]:=y1;\n inc(i); \n dec(j); \n end;\n until i>j;\n if l1) and (gcd(i,n-i)<>1) do dec(i);\n writeln(i,' ',n-i);\nend;\nbegin\n trys;\nend.", "src_uid": "0af3515ed98d9d01ce00546333e98e77"} {"source_code": "var\n i,j,m,n,k,p,b,g:longint;\n ans:longint;\nbegin\n readln(b); readln(g);\n readln(n);\n for i:=0 to n do\n begin\n j:=n-i;\n if (i<=b)and(j<=g) then\n inc(ans);\n end;\n writeln(ans);\nend.", "src_uid": "9266a69e767df299569986151852e7b1"} {"source_code": "program cardgame;\nvar st1,st2:string;\n i:byte;\n\nfunction check:boolean;\n begin\n readln(st1);\n for i:=1 to 5 do\n begin\n read(st2);\n\t if (pos(st1[1],st2)<>0) or (pos(st1[2],st2)<>0) then exit(True);\n end;\n exit(False);\n end;\n\nbegin\n if check then write('YES') else write('NO');\nend.\n", "src_uid": "699444eb6366ad12bc77e7ac2602d74b"} {"source_code": "uses math;\nconst eps=1e-8;\ntype\n\tatype=record\n\t\t\tpl:extended;\n\t\t\tflag:longint;\n\t\tend;\nvar\nevent:array[0..4010] of atype;\np:array[0..4010] of record\n\t\t\t\t\tx,y:extended;\n\t\t\t\tend;\nr:array[0..4010] of extended;\nall,across:longint;\n\nfunction fsqrt(x:extended):extended;\nbegin if x<0 then exit(0) else exit(sqrt(x)); end;\n\nfunction farccos(x:extended):extended;\nbegin if x<-1 then exit(pi);\n\tif x>1 then exit(0);\n\texit(arccos(x));\nend;\n\nfunction adjust(x:extended):extended;\nbegin while x<-eps do x:=x+2*pi;\n\twhile x+eps>2*pi do x:=x-2*pi;\n\texit(x);\nend;\n\nfunction cmp(const a,b:atype):boolean;\nbegin if abs(a.pl-b.pl)>1];\n\trepeat\n\t\twhile cmp(event[i],x) do inc(i);\n\t\twhile cmp(x,event[j]) do dec(j);\n\t\tif not(i>j) then\n\t\tbegin y:=event[i];\n\t\t\tevent[i]:=event[j];\n\t\t\tevent[j]:=y;\n\t\t\tinc(i); j:=j-1;\n\t\tend;\n\tuntil i>j;\n\tif lt2 then inc(across);\n\tinc(all); event[all].pl:=t1; event[all].flag:=1;\n\tinc(all); event[all].pl:=t2; event[all].flag:=-1;\nend;\n\nprocedure lemon;\nvar n,i,base,ans,now,i2,Kallow:longint;\n theta,alpha,beta,dis:extended;\nbegin readln(n,Kallow); ans:=1;\n\tfor i:=1 to n do readln(p[i].x,p[i].y,r[i]);\n\tfor base:=1 to n do\n\tbegin all:=0; across:=0;\n\t\tfor i:=1 to n do\n\t\t\tif i<>base then\n\t\t\tbegin dis:=fsqrt(sqr(p[i].x-p[base].x)+sqr(p[i].y-p[base].y));\n\t\t\t\ttheta:=arctan2(p[i].y-p[base].y,p[i].x-p[base].x);\n\t\t\t\talpha:=farccos((r[base]-r[i])/dis);\t\t//outer cut\n\t\t\t\tbeta:=farccos((r[i]+r[base])/dis);\t\t//inner cut\n\t\t\t\tins(theta-alpha,theta-beta);\n\t\t\t\tins(theta+beta,theta+alpha);\n\t\t\tend;\n\t\tsort(1,all);\n\t\ti:=1; now:=across;\n\t\twhile i<=all do\n\t\tbegin i2:=i;\n\t\t\twhile (i<=all)and(abs(event[i].pl-event[i2].pl)ans then ans:=now+1;\n\t\tend;\n\tend;\n\twriteln(int64(ans)*Kallow+n+int64(Kallow)*(Kallow-1) div 2);\nend;\n\t\t\nbegin\n{$ifndef ONLINE_JUDGE} \n\tassign(input,'128E.in');\n\treset(input);\n{$endif}\nlemon;\nend.", "src_uid": "06ec7e481c963e635a6303503ffccc8b"} {"source_code": "uses math;\nconst fi='';\n fo='';\nvar s,s1:string;\n n,i,j,tmp,res:longint;\nfunction kt(ss:string):longint;\nvar tg:char;\nbegin\n s1:=s;\n tmp:=0;\n for i:=n downto 1 do\n begin\n if s1[i]=ss[2] then\n begin\n for j := i to n-1 do\n begin\n tg:=s1[j];\n s1[j]:=s1[j+1];\n s1[j+1]:=tg;\n inc(tmp);\n end;\n break;\n end;\n end;\n if s1[n]<>ss[2] then exit(round(1e9));\n for i:=n-1 downto 1 do\n begin\n if s1[i]=ss[1] then\n begin\n for j:=i to n-2 do\n begin\n tg:=s1[j];\n s1[j]:=s1[j+1];\n s1[j+1]:=tg;\n inc(tmp);\n end;\n break;\n end;\n end;\n if s1[n-1]<>ss[1] then exit(round(1e9));\n if s1[1]='0' then\n begin\n for i := 1 to n-2 do\n begin\n if s1[i]<>'0' then\n begin\n for j:=i downto 2 do\n begin\n tg:=s1[j];\n s1[j]:=s1[j-1];\n s1[j-1]:=tg;\n inc(tmp);\n end;\n break;\n end;\n end;\n end;\n if s1[1]='0' then exit(round(1e9))\n else exit(tmp);\nend;\nBEGIN\n assign(input,fi);reset(input);\n assign(output,fo);rewrite(output);\n readln(s);\n n:=length(s);\n res:=round(1e9);\n res:=min(res,kt('00'));\n res:=min(res,kt('25'));\n res:=min(res,kt('50'));\n res:=min(res,kt('75'));\n if res=(round(1e9)) then write(-1)\n else write(res);\nEND.", "src_uid": "ea1c737956f88be94107f2565ca8bbfd"} {"source_code": "var n,x,y,s:longint;\n p:real;\nbegin\nread(n,x,y);\np:=n*y/100;\ns:=trunc(p);\nif s<>p then inc(s);\ns:=s-x;\nif s<0 then s:=0;\nwrite(s);\nend.", "src_uid": "7038d7b31e1900588da8b61b325e4299"} {"source_code": "uses math;\nvar a,b,c,d,t:longint;\nbegin\n readln(a,b,c,d);\n if a>b then begin t:=a;a:=b;b:=t;end;\n if a>c then begin t:=a;a:=c;c:=t;end;\n if b>c then begin t:=b;b:=c;c:=t;end;\n writeln(max(d-b+a,0)+max(d-c+b,0));\nend.", "src_uid": "47c07e46517dbc937e2e779ec0d74eb3"} {"source_code": "program xay_thap;\nconst fi='';\n fo='';\nvar x,dem:int64;\n f,g:text;\nfunction lt(x:int64):int64;\nbegin\n exit(x*x*x);\nend;\nfunction max(a,b:int64):int64;\nbegin\n if a0 do\n begin\n inc(dem);\n a:=1;\n while lt(a+1)<=m do inc(a);\n if tinh(m)=1+tinh(m-lt(a)) then\n begin\n m:=m-lt(a);\n x:=x+lt(a);\n end\n else\n begin\n m:=lt(a)-1-lt(a-1);\n x:=x+lt(a-1);\n end;\n end;\n write(g,dem,' ',x);\n close(f);\n close(g);\nend;\nbegin\n process;\nend.", "src_uid": "385cf3c40c96f0879788b766eeb25139"} {"source_code": "VAR a,x,y,y1,y2:longint;a1:real;\nBEGIN\nread(a,x,y);\nif (y mod a=0)or(y<0)then write(-1)else\nbegin\na1:=0.5*a;\nif y(-a1))and(x(-a)) then write(y1)else if (x>0)and(x(-0.5*a))and(x<(0.5*a))then write(y1+2)else write(-1);\n end;\nend;\nend;\n\nEND.", "src_uid": "cf48ff6ba3e77ba5d4afccb8f775fb02"} {"source_code": "var\nsum:qword;\nn,i:longint;\nbegin\n readln(n);\n if n mod 2=1 then writeln(0)\n else\n begin\n sum:=1;\n for i:=1 to n div 2 do\n sum:=sum*2;\n writeln(sum);\n end;\nend.\n", "src_uid": "4b7ff467ed5907e32fd529fb39b708db"} {"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, g, res, k, res1, res2, l, r, x, y, z, new, len, mem, mi, ma, d, c, a, b: integer;\n // a, b: integer;\n //a, b: array [0..10001] of integer;\n // d: array [0..10001] of integer;\n s, s1, s2, st, snew: string;\n // s3, s4: string;\n ok: boolean;\n ch: char;\n // yes: array [0..10001] of boolean;\n // g: array [0..1001, 0..1001] of boolean;\n // ok: array [0..10001] of boolean;\n // ch: array [0..1001, 0..1001] of char;\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 panicex(kwex: extended);\nbegin\n write(kwex);\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\nfunction reverse(snmx: string): string;\nvar\n stvx: string;\n ixx, mvx: integer;\nbegin\n stvx := '';\n mvx := length(snmx);\n for ixx := 1 to mvx do\n stvx := snmx[ixx] + stvx;\n Result := stvx;\nend;\n\nfunction palindrome(ss: string): boolean;\nvar\n gx, lenxs: integer;\nbegin\n lenxs := length(ss);\n for gx := 1 to lenxs do\n if ss[gx] <> ss[lenxs + 1 - gx] then\n begin\n Result := false;\n exit;\n end;\n Result := true;\nend;\n\nfunction lenint(xvc: integer): integer;\nvar\n cvc: integer;\nbegin\n if xvc < 10 then\n begin\n Result := 1;\n exit;\n end;\n cvc := 0;\n While xvc > 0 do\n begin\n inc(cvc);\n xvc := xvc div 10;\n end;\n Result := cvc;\nend;\n\nfunction f(a, b, c: integer): integer;\nvar\n ans: integer;\nbegin\n if (a = 1) then\n f := b * c\n else\n if (b = 1) then\n f := a * c\n else\n if c = 1 then\n f := a * b\n\n else\n f := f(a - 1, b - 1, c - 1) + 2 * (a + b + c) - 6;\nend;\n\nbegin\n {$IFNDEF ONLINE_JUDGE}\n Reset(input, 'input.txt');\n Rewrite(output, 'output.txt');\n {$ENDIF}\n\n readln(a, b, c);\n n := f(a, b, c);\n\n write(n);\n\n\n\n\n\n\nend.\n", "src_uid": "8ab25ed4955d978fe20f6872cb94b0da"} {"source_code": "var a,b,c1,a1,b1,i:longint;\nbegin\nreadln(a,b);\nfor i:=1 to 6 do if abs(a-i)>abs(b-i) then inc(b1)\n else if abs(a-i)0 then\nBegin\nF[i,j]:=F[i-1,j-1]+Mu10[n-j]*A[i];\nTr[i,j]:=j-1;\nEnd;\nif (i-j<=n) and (i-j>0) then\nBegin\nif F[i,j]0 do\nBegin\nif Tr[u,v]=v then VCL:='H'+VCL else VCL:='M'+VCL;\nv:=Tr[u,v];\ndec(u);\nEnd;\nwriteln(VCL);\nEnd.\n\n\n ", "src_uid": "98489fe54488dcfb45f8ae7b5c473d88"} {"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 = 50;\n maxm = 0;\n inf = maxlongint div 2;\n eps = 0;\n\ntype\n int = longint;\n bool = boolean;\n real = extended;\n tt = array[0..maxn] of int64;\n\nvar\n a, c, ans: int64;\n at, ct: tt;\n\nfunction gettt(a: int64): tt;\nvar\n t: tt;\nbegin\n fillchar(t, sizeof(t), 0);\n repeat\n inc(t[0]);\n t[t[0]] := a mod 3;\n a := a div 3;\n until a = 0;\n\n result := t;\nend;\n\nprocedure run;\nvar\n i: int;\nbegin\n read(a, c);\n\n at := gettt(a);\n ct := gettt(c);\n\n ans := 0;\n for i := max(at[0], ct[0]) downto 1 do begin\n ans := ans*3 + (ct[i] - at[i] + 3) mod 3;\n end;\n\n writeln(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", "src_uid": "5fb635d52ddccf6a4d5103805da02a88"} {"source_code": " const eps=1e-10;\n besk=4000000000000000000;\n label 1,2,33,44;\n type\n mas=array[-200000..2*1100000+1] of int64;\nvar 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;\nn,sum,ans,qq,ott,cc,nn,modul,p,ot,pmin,tmax,minf,kk,gr1,gr2,tt1,nnn,d,raz1,raz2,v,s,st,q,t,gr:int64; flag1:boolean;\n zan:array[0..1000000] of boolean;\n cha:char;\nz,b1,a1:array[-10000..3000000] of longint;\ndd:array [-1..3000,-1..3000] of int64;\nbbbb,cccc:array[0..100000] of extended;\n ss,ss1:string;\nt1,t2,t3:extended;\nx,pp,y,mnog,stepen:array[-10..100000] of int64;\nll,rr,aa,ppp, c,a,b:mas; flag:boolean; pl:longint;\nfunction srav(i,j:longint):boolean;\nbegin if (a[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\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\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 readln(n);\n readln(ss);\n pos:=1;\n for i:=1 to n-1 do\n begin\n pos:=max(i,pos);\n if (ss[pos]<>ss[pos+1])and(posb) do\n begin\n if (x mod d=0) then br:=br+1;\n d:=d-1;\n end;\n end;\nif (z=0) then writeln (br);\nend;\nend.", "src_uid": "6e0715f9239787e085b294139abb2475"} {"source_code": "{$Coperators ON}\n{\t\t\t meoww~~~ meoww~~~\n\t\t /\\___/\\\n\t\t ( =^.^= )\n\t\t (\") (\")_/\n}\nuses math;\nvar m,n,tt:Longint;\n\tfree,p:array[1..100] of Longint;\nprocedure init;\nvar i,j,k,tam:Longint;\nbegin\n\treadln(n,m);\n\ttt:=0;\n\tfor i:=1 to m do begin read(k); inc(free[k]); end;\n\tk:=0;\n\tfor i:=1 to 100 do\n\t\tif (free[i]>0) then\n\t\t\tbegin\n\t\t\t\tinc(k);\n\t\t\t\tp[k]:=free[i];\n\t\t\t\ttt+=free[i];\n\t\t\tend;\n\tif ttp[i] then\n\t\t\t\tbegin\n\t\t\t\t\ttam:=p[i];\n\t\t\t\t\tp[i]:=p[j];\n\t\t\t\t\tp[j]:=tam;\n\t\t\t\tend;\n\tfor i:=1 to n do free[i]:=1;\n\tfree[n]:=n-(n-1);\n\tfor i:=n downto 1 do\n\t\tfor j:=1 to i-1 do\n\t\t\tbegin\n\t\t\tif free[i]>0 then\n\t\t\t\tif (p[i] div free[i])<(p[j] div (free[j]+1)) then\n\t\t\t\t\tbegin\n\t\t\t\t\t\tinc(free[j]);\n\t\t\t\t\t\tdec(free[i]);\n\t\t\t\t\tend;\n\t\t\tif free[j]>0 then\n\t\t\tif (p[j] div free[j])<(p[i] div (free[i]+1)) then\n\t\t\t\t\tbegin\n\t\t\t\t\t\tinc(free[i]);\n\t\t\t\t\t\tdec(free[j]);\n\t\t\t\t\tend;\n\t\t\tend;\n\t\ttt:=maxlongint;\n\t\tfor i:=1 to n do \n\t\t\tif free[i]>0 then\n\t\t\t\tbegin\n\t\t\t\t\ttt:=min(tt,p[i] div free[i]);\n\t\t\t\tend;\n\t\t// for i:=1 to n do write(p[i],' ');\n\t\t// writeln;\n\t\t// for i:=1 to n do write(free[i],' ');\n\t\t// writeln;\n\t\twriteln(tt);\nend;\nbegin\nassign(input,''); reset(input);\nassign(output,''); rewrite(output);\n\ninit;\nclose(input);\nclose(output);\nend.", "src_uid": "b7ef696a11ff96f2e9c31becc2ff50fe"} {"source_code": "var p,y,k,i:longint;\nbegin\nread(p,y);\nif y mod 2=0 then y:=y-1;\nwhile (y>p) and (k=0) do\nbegin\n \tfor i:=3 to p+1 do\n\t\t\tbegin\n\t\t\tif (i>sqrt(y)) or (i=p+1) then begin write(y); k:=1; break; end\n else if (y mod i=0) then break;\n end;\n \ty:=y-2;\nend;\nif k=0 then write('-1');\nend.", "src_uid": "b533203f488fa4caf105f3f46dd5844d"} {"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 if n=3 then begin write(24); goto 1; end;\n if n=4 then begin end;\n p:=1;\n for i:=1 to n-3 do p:=p*4;\n p1:=2*3*p*4;\n p2:=(n-3)*3*3*p;\n\n writeln(p1+p2);\n\n\n1:\n end.\n", "src_uid": "3b02cbb38d0b4ddc1a6467f7647d53a9"} {"source_code": "program cf617B;\nvar n,i:longint;\n rez:int64;\n a,poz:array[0..100000] of longint;\n b:boolean;\nbegin\nread(n);\nb:=false;\nfor i:=1 to n do\n begin\n read(a[i]);\n b:=b or (a[i]=1);\n end;\n\nrez:=ord(b);\n\npoz[0]:=0;\nfor i:=1 to n do\n if a[i]=0 then\n poz[i]:=poz[i-1]\n else\n poz[i]:=i;\n\nfor i:=1 to n do\n if (a[i]=1) and (poz[i-1]<>0) then\n rez:=rez*(i-poz[i-1]);\n\nwriteln(rez);\nend.", "src_uid": "58242665476f1c4fa723848ff0ecda98"} {"source_code": "var\n a, b, c, i, j: int64;\n q: boolean;\n \nbegin\n readln(a, b, c);\n i := 0;\n q := false;\n while a * i <= c do begin\n j := 0;\n while a * i + b * j <= c do begin\n if a * i + b * j = c then q := true;\n if q then break;\n inc(j);\n end;\n if q then break;\n inc(i);\n end;\n if q then writeln('Yes')\n else writeln('No');\nend.", "src_uid": "e66ecb0021a34042885442b336f3d911"} {"source_code": "var st:string;a:array[0..2000]of longint;i,n:longint;p,k,z:int64;\nbegin\n readln(n,p);\n for i:=1 to n do\n begin\n readln(st);\n if st='half' then a[n+1-i]:=0 else begin inc(z);a[n+1-i]:=1;end;\n end;\n for i:=1 to n do\n k:=K*2+a[i];\n write(p*k-p div 2*z);\nend.", "src_uid": "6330891dd05bb70241e2a052f5bf5a58"} {"source_code": "var\n n: longint;\nbegin\n {$ifndef ONLINE_JUDGE}\n assign(input, 'Codeforces.inp'); reset(input);\n assign(output, 'Codeforces.out'); rewrite(output);\n {$endif}\n readln(n);\n if (n mod 2 = 0) then\n begin\n writeln('white');\n write('1 2');\n end\n else write('black');\nend.\n", "src_uid": "52e07d176aa1d370788f94ee2e61df93"} {"source_code": "program form;\nvar a: array [1..110,1..110] of longint;\ni,n,x,t,b,ans,c,m,j: longint;\nfunction max(x,y: longint): longint;\nbegin if x>y then max:= x else max:= y; end;\nbegin\n{assign (input, 'input.txt');\nreset (input);\nassign (output, 'output.txt');\nrewrite (output); }\nread (n);\nt:= n div 2+1;\nfor i:= 1 to n do\n for j:= 1 to n do\n read (a[i,j]);\nfor i:= 1 to n do\n ans:= ans + a[i,i];\nfor i:= 1 to n do\n ans:= ans + a[n+1-i,i];\nans:= ans -3* a[t,t];\nfor i:= 1 to n do ans:= ans + a[t,i]+ a[i,t];\nwriteln (ans);\n{close (input);\nclose (output); }\n\nend.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "src_uid": "5ebfad36e56d30c58945c5800139b880"} {"source_code": "program olymp;\nvar\n n,m,k,l : longint;\nbegin\n readln(n,m,l,k);\n if ((n-l)+(m-l)+l+1>k) or (n>k) or (m>k) or (l>k) or (l>n) or (l>m)\n then writeln('-1')\n else writeln(k-((n-l)+(m-l)+l));\nend.", "src_uid": "959d56affbe2ff5dd999a7e8729f60ce"} {"source_code": "{$MODE OBJFPC}\n{$IFNDEF DEBUG}\n{$R-,Q-,S-,I-}\n{$OPTIMIZATION LEVEL2}\n{$INLINE ON}\n{$ELSE}\n{$INLINE OFF}\n{$ENDIF}\nprogram Task;\nconst\n {$IFDEF DEBUG}\n InputFile = 'd.inp';\n OutputFile = '';\n {$ELSE}\n InputFile = '';\n OutputFile = '';\n {$ENDIF}\nvar\n fi, fo: TextFile;\n a1, b1, a2, b2, L, R: Int64;\n\nprocedure Enter;\nbegin\n ReadLn(fi, a1, b1, a2, b2, L, R);\n if L < b1 then L := b1;\n if L < b2 then L := b2;\nend;\n\nfunction SolveDiophante(a, b, c: Int64; var x, delta: Int64): Boolean;\nvar\n m, n, r, q: Int64;\n xm, xn, xr: Int64;\nbegin\n m := a; xm := 1;\n n := b; xn := 0;\n while n <> 0 do\n begin\n q := m div n;\n r := m - q * n;\n xr := xm - q * xn;\n m := n; xm := xn;\n n := r; xn := xr;\n end;\n if c mod m <> 0 then Exit(False);\n Result := True;\n x := xm * c div m;\n delta := Abs(b div m);\nend;\n\nfunction PMod(x, y: Int64): Int64;\nbegin\n Result := x mod y;\n if Result < 0 then Inc(Result, y);\nend;\n\nfunction Solve: Int64;\nvar\n x, Delta, len, res, minK, maxK: Int64;\nbegin\n if not SolveDiophante(a1, -a2, b2 - b1, x, Delta) then Exit(0);\n x := PMod(x, Delta);\n minK := (L - b1) div a1;\n if minK * a1 + b1 < L then Inc(minK);\n maxK := (R - b1) div a1;\n if maxK * a1 + b1 > R then Dec(maxK);\n if minK > maxK then Exit(0);\n len := maxK - minK + 1;\n res := len div Delta;\n minK := minK + res * Delta;\n if minK <= maxK then\n begin\n minK := PMod(minK, Delta);\n maxK := PMod(maxK, Delta);\n if minK <= maxK then\n begin\n if (x >= minK) and (x <= maxK) then\n Inc(res);\n end\n else\n begin\n if (x >= minK) or (x <= maxK) then\n Inc(res);\n end;\n end;\n Result := res;\nend;\n\nbegin\n AssignFile(fi, InputFile); Reset(fi);\n AssignFile(fo, OutputFile); Rewrite(fo);\n try\n Enter;\n WriteLn(fo, Solve);\n finally\n CloseFile(fi);\n CloseFile(fo);\n end;\nend.\n\n", "src_uid": "b08ee0cd6f5cb574086fa02f07d457a4"} {"source_code": "program Project_D;\n\nconst\n p = 1000000000000000;\n\nvar\n q, test, i: longint;\n a, b, m, l, r, k, x, ans, y, z: int64;\n mas: array[1..50] of int64;\n\nfunction pow(a, b: int64): int64;\nvar\n i: longint;\n x: int64;\nbegin\n x := 1;\n for i := 1 to b do\n x := x * a;\n pow := x;\nend;\n\nbegin\n read(q);\n for test := 1 to q do begin\n read(a, b, m);\n if a = b then\n writeln('1 ', a)\n else begin\n k := 2;\n l := 1;\n r := m;\n while (b - l * a > 0) and not ((b - l * a >= l) and (b - l * a <= r)) do begin\n inc(k);\n l := l * 2;\n r := (r * 2) mod p;\n end;\n if b - l * a <= 0 then\n writeln('-1')\n else begin\n ans := b - l * a;\n x := l;\n for i := k - 3 downto 0 do begin\n y := pow(2, i);\n z := 1 + (ans - x) div y;\n if z > m then\n z := m;\n x := x + (z - 1) * y;\n mas[k - i - 2] := z;\n end;\n mas[k - 1] := ans - x + 1;\n if mas[k - 1] = 0 then\n mas[k - 1] := 1;\n\n write(k, ' ', a, ' ');\n for i := 1 to k - 1 do begin\n write(a + mas[i], ' ');\n a := 2 * a + mas[i];\n end;\n writeln;\n end;\n end;\n end;\nend.", "src_uid": "c9d646762e2e78064bc0670ec7c173c6"} {"source_code": " uses strutils;\n const eps=1e-14;\n besk=20000000000000000; label 4,1,3,2,44,22;\n type mas=array[-10000..400000+1] of int64;\n integer=longint; zap=record x,y,z:int64; end;\n zap1=^zap;\n var green,kk,pos,ii,qqq,oldpos,jj,kolvzv,sdvig,dl,i1,j1,mask,stepp,n2,i,j,k,l,step,k1,mesto:longint;\n oldss,smin,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 xmax,xmin,ymax,ymin,newpos,newdl,len,pp3,ans1,ans2,modul,t0,t1,t2,dloch,koldel,mmax,nap,ot,stepen,pq,pp1,pp2,period, dolg,ot1,ot2,oldgr,predsum,pmin,tmin,aa,bb,kool,number,imin,kolreber,kolstan,qq,kol,chisl,znam,n,m,ttt,numpos,vx,vy,ans,up,down,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,n1,q,t,p:int64; flag1:boolean;\n numzx,numzy,numyx,numyz,numxy,numxz,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 izb, sum,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 new,zan2,zan1,prost,marked,zan:array[-10000..11000000] of boolean;\n newoch,left,right,d2,och,delit, num,start,finish,zz,ll,rr,path,lx,a3,a4,predok,a1,b1:array[-100000..9550000] 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 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..1100005] of string;\n newpole,pole:array[-1..2100,-1..2700] of char;\n verch,verzn:array[-10..1100000] of int64;\n dd,dd1,dd2,ddinv:array[-2..11000,-2..1100] of longint;\n dnext:array[0..26,-1..300001] of int64;\n obmen,ch:char;\n ff,flagg1:boolean;\n pred,oldx,oldy,numx,numy,xleft,xright,s,znach,newplace,newstr,next,prev,xx,yy,aold,x,y:array[-10000..1700002] 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]ii then\n begin\n xmax:=max(xmax,x[i]);\n ymax:=max(ymax,y[i]);\n xmin:=min(xmin,x[i]);\n ymin:=min(ymin,y[i]);\n\n end;\n\n { writeln('ii= ',ii,' ',xmin,' ',xmax,' ',ymin,' ',ymax);\n }\n if xmax-xmin=ymax-ymin then flag1:=true else flag1:=false;\n for i:=1 to 4*n+1 do if i<>ii then\n begin\n flag:=true;\n if (x[i]=xmin)and(y[i]>=ymin)and(y[i]<=ymax) then flag:=false;\n if (x[i]=xmax)and(y[i]>=ymin)and(y[i]<=ymax) then flag:=false;\n if (y[i]=ymin)and(x[i]>=xmin)and(x[i]<=xmax) then flag:=false;\n if (y[i]=ymax)and(x[i]>=xmin)and(x[i]<=xmax) then flag:=false;\n { writeln('i= ',i,' ',flag);\n }\n if flag then flag1:=false;\n end;\n\n if flag1 then begin writeln(x[ii], ' ',y[ii]); end;\n\n\nend;\n\n\n\n\n\n\n 1: close (output);\n end.\n", "src_uid": "1f9153088dcba9383b1a2dbe592e4d06"} {"source_code": "const MI:array[1..3] of longint = (1,500000004,333333336);\nconst maxn = 4000+10;\ncmod = 1000000007;\nvar f1,f2:text;\nF:array[-1..maxn,-1..maxn] of longint;\nxy:array[0..1,0..1] of longint;\nh,w:longint;\nres,sum :int64;\n\nFunction GCD(y,x:longint):longint;\nbegin\n if x=0 then exit(y);\n GCD:=GCD(x,y mod x);\nend;\n\nFunction C(i,j:longint):longint;\nvar k:longint;\ns:int64;\nbegin\n if i= 0) then\n begin\n k2:=(n-(k*a+k1*b)) div c;\n if (k+k1+k2>l) then l:=k+k1+k2;\n end;\n end;\n writeln (l);\nend.\n\n\n\n\n\n", "src_uid": "062a171cc3ea717ea95ede9d7a1c3a43"} {"source_code": "var\ts,s2:ansistring;\n\ti:integer;\n\tt:char;\n\ta:Array['0'..'9'] of integer;\n\tprocedure di(o:longint; b:boolean);\n\tvar\tt:char;\n\t\ti:integer;\n\t\tbegin\n\t\t\tif b=true then\n\t\t\tbegin\n\t\t\t\tfor t:='9' downto '0' do\n\t\t\t\t\tfor i:=1 to a[t] do\n\t\t\t\t\t\ts:=s+t;\n\t\t\t\twriteln(s);\n\t\t\t\thalt;\n\t\t\tend\n\t\t\telse if o>length(s2) then\n\t\t\tbegin\n\t\t\t\twriteln(s);\n\t\t\t\thalt;\n\t\t\tend\n\t\t\telse\n\t\t\tbegin\n\t\t\t\tif a[s2[o]]>0 then\n\t\t\t\tbegin\n\t\t\t\t\tdec(a[s2[o]]);\n\t\t\t\t\ts:=s+s2[o];\n\t\t\t\t\tdi(o+1,false);\n\t\t\t\t\tdelete(s,o,1);\n\t\t\t\t\tinc(a[s2[o]]);\n\t\t\t\tend;\n\t\t\t\tfor t:=s2[o] downto '0' do\n\t\t\t\t\tif (t<>s2[o]) then\n\t\t\t\t\t\tif a[t]>0 then\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\tdec(a[t]);\n\t\t\t\t\t\t\ts:=s+t;\n\t\t\t\t\t\t\tdi(o+1,true);\n\t\t\t\t\t\tend;\n\t\t\tend;\n\t\tend;\nbegin\n\treadln(s);\n\treadln(s2);\n\tif length(s)0 then s1:=s+i else s1:=1000000;\n s:=s+n*k;\n if (s20)and(s1 n then\n\t\t\tbegin\n\t\t\t\tbreak;\n\t\t\tend;\n if i mod primes[j] <> 0 then\n begin\n phi[i * primes[j]] := phi[i] * (primes[j] - 1);\n end\n else\n begin\n phi[i * primes[j]] := phi[i] * primes[j];\n break;\n end;\n end;\n end;\n for i := 1 to n do\n\tbegin\n\t\tinc(cnt[phi[i]]);\n\tend;\n sz := 0;\n for i := 1 to n do\n begin\n while cnt[i] <> 0 do\n begin\n inc(sz);\n phi[sz] := i;\n dec(cnt[i]);\n end;\n end;\n for i := 1 to k + 2 do\n\tbegin\n\t\tans := ans + phi[i];\n\tend;\n writeln(ans);\nend.", "src_uid": "c2f7012082c84d773c2f4b1858c17110"} {"source_code": "var i,r,n,L,k:int64;\nc:array[0..31]of biginteger;\ns:biginteger;\n//const maxint=9223372036854775807;\nfunction min(a,b:biginteger):biginteger;\nbegin\nif a0 do\nbegin\n if c[k]<=s then s:=c[k];\n s:=s+c[k]*(l mod 2);\n l:=l div 2;\n inc(k);\nend;\n if (c[k]<=s) and (k<>31) then s:=c[k];\nwrite(s);\nend.", "src_uid": "04ca137d0383c03944e3ce1c502c635b"} {"source_code": "var\n x:array['A'..'C'] of 0..2;\n k1,k2,k3,u:char;\n d,i:byte;\n\n\nBEGIN\n for i:=1 to 3 do\n begin\n readln(k1,k2,k3);\n if k2='>' then inc(x[k1])\n else inc(x[k3]);\n end;\n if (x['A']=x['B']) or (x['A']=x['C']) or (x['B']=x['C']) then\n writeln('Impossible')\n else begin\n d:=0;\n while d<=2 do\n begin\n for u:='A' to 'C' do\n if x[u]=d then write(u);\n inc(d);\n end;\n end;\n readln;\nEND.", "src_uid": "97fd9123d0fb511da165b900afbde5dc"} {"source_code": "var \n a1, a2, a3: integer;\n b1, b2, b3: integer;\n a, b, n: integer;\nbegin\n readln( a1, a2, a3 );\n readln( b1, b2, b3 );\n readln( n );\n a := a1 + a2 + a3;\n b := b1 + b2 + b3;\n while( a > 0 ) do\n begin\n n := n - 1;\n a := a - 5;\n end;\n while( b > 0 ) do\n begin\n n := n - 1;\n b := b - 10;\n end;\n if( n >= 0 ) then\n writeln( 'YES' )\n else\n writeln( 'NO' );\nend.", "src_uid": "fe6301816dea7d9cea1c3a06a7d1ea7e"} {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar n:longint;\n x,y:longint;\n\nbegin\n readln(n,x,y);\n if (x in [n div 2..n div 2+1]) and (y in [n div 2..n div 2+1]) then\n writeln ('NO') else writeln('YES');\nend.", "src_uid": "dc891d57bcdad3108dcb4ccf9c798789"} {"source_code": "const mo:int64=10000000000000;ww:int64=5000000000000000000;\nvar map:array[0..9,0..9]of int64;\n loop:array[0..13]of int64;\n t:array[0..13]of int64;\n a,b,c:array[1..2,1..2]of int64;\n tmp,now,n1,n2,n,ans:int64;\n i:longint;\nfunction cheng(a,b:int64):int64;\nvar s:int64;\nbegin\n s:=0;\n while b>0 do\n begin\n if b and 1=1 then s:=(s+a)mod mo;\n a:=(a<<1)mod mo;b:=b>>1;\n end;\n exit(s);\nend;\nprocedure matrix(x:int64);\nvar i,j,k:longint;\nbegin\n a[1,1]:=1;a[1,2]:=0;b[1,1]:=0;b[1,2]:=1;b[2,1]:=1;b[2,2]:=1;\n while x>0 do\n begin\n if x and 1=1 then\n begin\n fillchar(c,sizeof(c),0);\n for i:=1 to 1 do for j:=1 to 2 do for k:=1 to 2 do\n c[i,j]:=(c[i,j]+cheng(a[i,k],b[k,j]))mod mo;\n a:=c;\n end;\n fillchar(c,sizeof(c),0);\n for i:=1 to 2 do for j:=1 to 2 do for k:=1 to 2 do\n c[i,j]:=(c[i,j]+cheng(b[i,k],b[k,j]))mod mo;\n b:=c;x:=x shr 1;\n end;\nend;\nfunction dfs(x,y:int64):int64;\nvar n2,tmp,s,e:int64;\nbegin\n if y=14 then exit(x);\n s:=ww;tmp:=x;\n while tmp0 then break;\n map[n1,n2]:=now;now:=now+loop[i-1];\n until false;\n tmp:=tmp*10;\n loop[i]:=now-map[n1,n2];\n end;\n ans:=dfs(0,1);if ans=ww then ans:=-1;writeln(ans);\nend.\n", "src_uid": "cbf786abfceeb8df29732c8a872f7f8a"} {"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,l:longint;\n nn,mm,kk,u,v,w,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 qk then u:=2*k-u;\n for i:=1 to n do aa[i]:=0;\n for i:=0 to n do\n if cc[i]=1 then\n for j:=i-1 to i+1 do\n if i+j>0 then\n begin\n w:=qq[j]+u;\n if w<=m then aa[j]:=1;\n end;\n for i:=0 to n+1 do cc[i]:=aa[i];\n end;\n\n if cc[n+1]=1 then writeln('Yes') else writeln('No');\n\n\n //fin;\n end;\n\n\nbegin\n//init;\nnt:=1;\nreadln(nt);\nfor test:=1 to nt do\n begin\n clear;\n load;\n run;\n save;\n end;\nend.\n", "src_uid": "4941b0a365f86b2e2cf686cdf5d532f8"} {"source_code": "var\n n : longint;\nbegin\n readln(n);\n if n mod 4 = 0 then dec(n) else if n mod 2 = 1 then n := 0;\n writeln(n div 4);\nend.", "src_uid": "32b59d23f71800bc29da74a3fe2e2b37"} {"source_code": "program A435;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nVar i,n,m,ans,t,x: LongInt;\n Begin\n Read(n,m);\n t:=0;\n for i:=1 to n do Begin\n Read(x);\n if t+x<=m then t:=t+x\n else begin\n inc(ans);\n t:=x;\n end;\n End;\n write(ans+1);\n End.\n ", "src_uid": "5c73d6e3770dff034d210cdd572ccf0f"} {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n\ta: array[1..4] of Int64;\n\ts: string;\n\tc: array[1..3] of Char;\n\tmin: Int64;\n\ti1, i2, i3, i4: Integer;\n\nfunction\tCal(xa, xb, xc, xd: Integer; ca, cb, cc: Char): Int64;\n\tfunction\tOne(x, y: Integer; op: Char): Int64;\n\tbegin\n\t\tif op='+' then Result := x+y\n\t\telse Result := x*y;\n\tend;\nbegin\n\tResult := One(One(One(xa, xb, ca), xc, cb), xd, cc);\n\tif Resultj) 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 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 linf then ccc:=inf;\n end else\n begin\n sc:=sc+cc-1;\n if sc>inf then sc:=inf;\n if ffa1)or((b1=a1)and(b2inf then all:=inf;\n\n b1:=count;\n b2:=min;\n\n if all>=cnt+e then\n begin\n b1:=b1+cnt+e;\n end else\n begin\n\n ee:=0;\n for i:=1 to e do\n begin\n ee:=ee+1;\n ttt[ee]:=a[i];\n end;\n\n for i:=1 to cnt do\n begin\n ee:=ee+1;\n ttt[ee]:=1000000001;\n end;\n\n for i:=1 to ee do\n a[i]:=ttt[i];\n\n sort(1,ee);\n\n for j:=ee downto ee-all+1 do\n b1:=b1+1;\n\n ee:=ee-all;\n j:=2;\n\n for i:=ee downto 1 do\n begin\n if (j<=t)and(b[j]=a[i] then\n begin\n ss:=ss-a[i];\n b1:=b1+1;\n b2:=b2+a[i];\n end;\n\n\n end;\n\n if (b1>a1)or((b1=a1)and(b2b then begin K:=a;a:=b;b:=k;end;\n if (a<=n div 2)and(b>n div 2) then write('Final!') else begin \n k:=1;\n while odd(b) or(b-a>1) do\n begin\n inc(k); a:=(a+1) div 2; b:=(b+1) div 2;\n end;\n write(k);end;\nend.", "src_uid": "a753bfa7bde157e108f34a28240f441f"} {"source_code": " {$APPTYPE CONSOLE}\nconst besk=4000000000000000000;\n nnn=2000000; eps=1e-17;\n label 1,2,3,4;\n type mas=array[-10..2100000] of int64;\n var nn,chel,znam,len,ii,jj,i3,i2,i1,j1,k1,p1,p2,kt,ppp,god,day,mon,mask,i0,j0,k,step,i,j,start,finish,m:longint;\naa,bb:extended;\not,cc,h,w,ll,rr,dloch,n,yy1,xx1,xx2,q,xx,yy,p,modul,pp,tt,ot1,ot2,kold,kkr:int64;\nt,newdl,kk,centr,koef:int64;\nsl1,sl2,itog:mas;\nflag2,flag1,flag:boolean;\nxobl,yobl,t1,t2,x0,y0, rshar,vx,vy,x1,y1:extended;\nminotkl,dl1,dl2,dl3,hh,po,pt,doltek,dolpred:extended;\ndl,och,newoch,c,a,f,kop:array[0..2100000] of int64;\nx,y: array[-10..50000] of int64;\nver: array[-10..51,-10..100,-10..100] of extended;\nzan,marked:array[-100000..250000] of boolean;\ngr:array[-1000..5000,-1000..5000] of boolean;\n{ss:array[0..2000000] of char; }\nss,sss:string;\nch11,ch12,ch1,ch:char;\ndd1: array[-10..2000,-10..2000] of int64;\nb:array[0..2000000,-1..21] of int64;\nprev,next,s,kol,place,sr,str :array[-10 ..2000000] of int64;\nssot:array[-1000..110000] of string;\nfact:array[0..100] of extended;\nname:array[0..2000] of string;\nfunction min (a,b:extended):extended;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\nprocedure udal(ii:longint);\nbegin prev[next[ii]]:=prev[ii]; next[prev[ii]]:=next[ii]; end;\n\nfunction kolch(p,k:int64):int64; label 22; var deg,p2,ot,t,p1,q:int64; i,j:longint;\n\n begin\n p1:=p; t:=0; ot:=0;\n while p1>0 do begin inc(t); c[t]:=p1 mod 2; p1:=p1 div 2; end;\n { for i:=1 to t do write(c[i],' '); writeln;\n } q:=k;\n for i:=t downto 1 do if (c[i]=1)and(q>=0) then\n begin\n { writeln('binom',i-1,' po ',q);\n }\n ot:=ot+dd1[i-1,q]; dec(q);\n\n end;\n\n\n kolch:=ot;\n end;\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 read(n);\n p1:=0;p2:=0;\n for i:=1 to n do read(a[i]);\n for i:=1 to n do if a[i]=100 then inc(p1) else inc(p2);\n {writeln(p1,' ',p2);\n }for i:=1 to n do ot:=ot+a[i];\n if odd(ot div 100) then begin writeln('NO'); goto 1; end;\n if not odd(p1) and not odd(p2) then begin writeln('YES'); goto 1; end;\n if not odd(p1) and odd(p2) and (p1>1) then\n begin writeln('YES'); goto 1; end;\n writeln('NO');\n\n\n\n\n 1: close(output);\nend.\n\n\n", "src_uid": "9679acef82356004e47b1118f8fc836a"} {"source_code": "{$APPTYPE CONSOLE}\n{$M 99777216}\n{$R-,Q-,O+,S+,H+}\nuses\n Math,SysUtils;\nconst\n md = 1000000007;\nvar\n c : array [0..100, 0..100] of int64;\n dp : array [0..100, 0..100] of int64;\n a : array [0..9] of longint;\n sum, i, j, k, l, n, ans : LongInt;\nbegin\n// reset(input, 'input.txt');\n// rewrite(output, 'output.txt');\n readln(n);\n for i := 0 to 9 do\n read(a[i]);\n sum := 0;\n for i := 0 to 9 do\n Inc(sum , a[i]);\n for i := 0 to n do\n c[i, 0] := 1;\n for i := 1 to n do\n for j := 1 to n do\n c[i, j] := (c[i - 1, j] + c[i - 1, j - 1]) mod md;\n ans := 0;\n for i := max(sum, 1) to n do\n begin\n fillchar(dp, sizeof(dp), 0);\n dp[0, i] := 1;\n for j := 0 to 9 do\n for k := 0 to i do\n for l := a[j] to k do\n begin\n if (j = 0) and (l = k) then\n Break;\n if j = 0 then\n inc(dp[j + 1, k - l], dp[j, k] * c[k - 1, l])\n else\n Inc(dp[j + 1, k - l], dp[j, k] * c[k, l]);\n dp[j + 1, k - l] := dp[j + 1, k - l] mod md;\n end;\n ans := (ans + dp[10, 0]) mod md;\n end;\n writeln(ans);\nend.\n", "src_uid": "c1b5169a5c3b1bd4a2f1df1069ee7755"} {"source_code": "\ufeffvar\n k:char;\n i,n,m:integer;\n s:string;\nbegin\n readln(n);\n readln(s);\n k:=s[1];\n m:=0;\n if n>1 then\n begin\n for i:=2 to n do\n if s[i]=k then\n inc(m)\n else\n k:=s[i];\n write(m);\n end; \n if n=1 then\n write(m);\nend.\n \n ", "src_uid": "d561436e2ddc9074b98ebbe49b9e27b8"} {"source_code": "var\n s1,s2: String;\n i,j: Integer;\n c: Integer = 0;\n\nlabel no;\nbegin\n\treadln(s1);\n\treadln(s2);\n\tfor i := length(s1) downto 1 do\n\t\t\tif s2[i] <> s1[length(s1)-i+1] then goto no;\n\twriteln('YES');\n\thalt;\nno:\n\twriteln('NO');\nend.\n", "src_uid": "35a4be326690b58bf9add547fb63a5a5"} {"source_code": "var\nw,a,b:array[0..4000000]of longint;\np,ans,l,r,n,m,i,j:longint;\n\n begin\n read(n,m);\n for i:=1 to n do\n begin\n read(a[i]);\n a[i+n]:=a[i];\n end;\n\n for j:=1 to m do\n begin\n read(b[j]);\n w[b[j]]:=j;\n end;\n\n ans:=0;\n\n i:=0;\n j:=0;\n\n for i:=1 to n do\n if w[a[i]]>0 then\n begin\n if (w[a[i]]>l)and(w[a[i]]<=r) then l:=w[a[i]] else\n begin\n l:=0;\n r:=0;\n end;\n\n if (l=0)and(r=0) then\n begin\n l:=w[a[i]];\n r:=w[a[i]];\n j:=i;\n end;\n\n if jr then r:=p else\n begin\n if (p+m>r)and(pm) then\n begin\n l:=l-m;\n r:=r-m;\n end;\n\n if j-i+1>ans then ans:=j-i+1;\n end else\n begin\n l:=0;\n r:=0;\n j:=i;\n end;\n\n writeln(ans);\n end.\n", "src_uid": "13cd1aafbb1ba76be9ee10eaf8d8aef5"} {"source_code": "var ax,ay,bx,by,cx,cy: int64;\nBEGIN\n readln(ax,ay,bx,by,cx,cy);\n ax:=ax-bx;\n ay:=ay-by;\n cx:=cx-bx;\n cy:=cy-by;\n if (ax*ax+ay*ay = cx*cx+cy*cy) and (ax*cy<>ay*cx) then write('Yes') else write('No');\nEND.", "src_uid": "05ec6ec3e9ffcc0e856dc0d461e6eeab"} {"source_code": "const fi='';\n fo='';\n mn=1000;\nvar f:text;\n t:array[1..mn] of longint;\n d,n,sum:longint;\nprocedure input;\n var i:longint;\n begin\n assign(f,fi);\n reset(f);\n readln(f,n,d);\n for i:=1 to n do begin read(f,t[i]); sum:=sum+t[i]; end;\n close(f);\n end;\nprocedure process;\n var i:longint;\n begin\n sum:=sum+(n-1)*10;\n assign(f,fo);\n rewrite(f);\n\n if d 0) do\n begin\n solve;\n dec(t);\n end;\nend.", "src_uid": "3fd60db24b1873e906d6dee9c2508ac5"} {"source_code": "var s: set of 0..9; a:array[1..10] of integer; i,n,m,x:integer;\nBegin\nreadln(n,m);;\ns:=[];\nfor i:=1 to n do\nread(a[i]);\nfor i:=1 to m do begin\nread(x);\ns:=s+[x]\nend;\nfor i:=1 to n do \nif a[i] in s then write(a[i],' ');\nEnd.\n", "src_uid": "f9044a4b4c3a0c2751217d9b31cd0c72"} {"source_code": "Var\n\tn,m,ans,p,j:int64;\n\ti:longint;\n\nBegin\n\tread(n,m);\n\tans:=n-m*2;\n\tif ans<0 then ans:=0;\n\twrite(ans,' ');\n\tm:=m*2;\n\tfor i:=1 to n do\n\t\tbegin\n\t\t\tj:=i;\n\t\t\tp:=j*(j-1);\n\t\t\tif p>=m then break;\n\t\tend;\n\tif m=0 then ans:=n\n\t\telse ans:=n-i;\n\twrite(ans);\nEnd.", "src_uid": "daf0dd781bf403f7c1bb668925caa64d"} {"source_code": "{\nID: luoyuna1\nPROG: \nLANG: PASCAL\n}\n{$R+,S+,Q+,I+,O-}\n{R-,S-,Q-,I-,O+}\nuses math;\n\nvar\n a,b,c,x,y,z,n,i:longint; t,s:string;\nfunction check(s:string):longint;\nbegin\n if s='C' then exit(1);\n if s= 'C#' then exit(2);\n if s= 'D' then exit(3);\n if s= 'D#' then exit(4);\n if s= 'E' then exit(5);\n if s= 'F' then exit(6);\n if s= 'F#' then exit(7);\n if s= 'G' then exit(8);\n if s= 'G#' then exit(9);\n if s= 'A' then exit(10);\n if s= 'B' then exit(11);\n if s= 'H' then exit(12);\nend;\nbegin\n //assign(input,'te.in');reset(input);\n //assign(output,'.out');rewrite(output);\n readln(s);\n t:=copy(s,1,pos(' ',s)-1);\n a:=check(t);\n delete(s,1,pos(' ',s));\n \n t:=copy(s,1,pos(' ',s)-1);\n b:=check(t);\n delete(s,1,pos(' ',s));\n \n t:=copy(s,1,length(s));\n c:=check(t);\n \n //writeln(a,' ',b,' ',c);\n if a>b then begin x:=a; a:=b; b:=x; end;\n if a>c then begin x:=a; a:=c; c:=x; end;\n if b>c then begin x:=b; b:=c; c:=x; end;\n \n //writeln(b-a,' ',c-b);\n \n if b-a=4 then //abc\n if c-b=3 then begin writeln('major');halt; end;\n if c-b=4 then //bca\n if a+12-c=3 then begin writeln('major');halt; end;\n if a+12-c=4 then //cab\n if b-a=3 then begin writeln('major');halt; end;\n \n \n if b-a=3 then \n if c-b=4 then begin writeln('minor');halt; end;\n if c-b=3 then //bca\n if a+12-c=4 then begin writeln('minor');halt; end;\n if a+12-c=3 then //cab\n if b-a=4 then begin writeln('minor');halt; end;\n writeln('strange');\n close(input);\n close(output);\nend.\n", "src_uid": "6aa83c2f6e095848bc63aba7d013aa58"} {"source_code": "Const\n Fi='';//1204A.INP';\n Fo='';//1204A.OUT';\n\nVar s:String;\n i,Res:Longint;\n\nBEGIN\n Assign(Input,Fi); Reset(Input);\n Assign(Output,Fo); Rewrite(Output);\n\n Readln(s);\n Res:=(Length(s))div 2;\n\n If ((length(s) mod 2)=1) then\n Begin\n For i:=2 to length(s) do\n If s[i]='1' then\n Begin\n Res:=Res+1;\n Break;\n End;\n End;\n\n Writeln(Res);\n\n Close(Input);\n Close(Output);\nEND.", "src_uid": "d8ca1c83b431466eff6054d3b422ab47"} {"source_code": "\n\nvar\n\tn: int64;\n\nbegin\n\t//assign(input, 'in'); reset(input);\n\t//assign(output, 'out'); rewrite(output);\n\treadln(n);\n\tn := 6 * n + 1 + 3 * n * (n - 1);\n\twriteln(n);\nend.\n", "src_uid": "c046895a90f2e1381a7c1867020453bd"} {"source_code": "const\n fi=''; fo='';\n NMAX=100010; EPS=1e-12;\ntype dl=record m,v,id:longint; end;\nvar\n ans:array[1..NMAX] of longint;\n a:array[1..NMAX] of dl;\n n,h,kk:longint;\n ffi,ffo:text;\n//\nprocedure sort(l,r:longint);\nvar i,j:longint; x,tmp:dl;\nbegin\n i:=l; j:=r; x:=a[l+random(r-l+1)];\n repeat\n while (a[i].m>x.m) or ( (a[i].m=x.m) and (a[i].v>x.v)) do inc(i);\n while (a[j].mj;\n if i2 then begin\r\nFor i:=1 to k-2 do begin\r\na:=ord(ch[i])-65;\r\nb:=ord(ch[i+1])-65;\r\nc:=ord(ch[i+2])-65;\r\nIf not ((a+b)mod 26=c) then j:=false;\r\nEnd;\r\nEnd;\r\nIf j=true then writeln('Yes')\r\nElse writeln('No');\r\nEnd. ", "src_uid": "27e977b41f5b6970a032d13e53db2a6a"} {"source_code": "label 1;\nvar\nx,y:real;\nbegin\nReadln(x,y);\nif x<>0 then\n begin\n if (x=4) and (y=2) then begin Writeln('='); goto 1; end;\n if (x=2) and (y=4) then begin Writeln('='); goto 1; end;\n if (x=3) and (y=2) then begin Writeln('>'); goto 1; end;\n if (x=2) and (y=3) then begin Writeln('<'); goto 1; end;\n if (x=1) and (y>1) then begin Writeln('<'); goto 1; end;\n if (x>1) and (y=1) then begin Writeln('>'); goto 1; end;\n if (x=1) and (y=1) then begin Writeln('='); goto 1; end;\n If x>y then begin Writeln('<'); goto 1; end;\n If x'); goto 1; end; \n if x=y then Writeln('=');\n end; \n1: \nend.", "src_uid": "ec1e44ff41941f0e6436831b5ae543c6"} {"source_code": "const fi='';\n fo='';\nvar a:array[1..100] of longint;\n n,k,r,s,i,t:longint;\nbegin\n assign(input,fi); reset(input);\n assign(output,fo); rewrite(output);\n readln(n,k);\n s:=0;\n for i:=1 to n do\n begin\n read(a[i]);\n s:=s+a[i];\n end;\n r:=0;\n t:=trunc(s/(n+r));\n if frac(s/(n+r))>=0.5 then inc(t);\n while t=0.5 then inc(t);\n end;\n write(r);\n close(input);\n close(output);\nend.", "src_uid": "f22267bf3fad0bf342ecf4c27ad3a900"} {"source_code": "{$Inline on}\nProgram Pills;\nconst dx:array[1..2]of longint=(1,0);\n dy:array[1..2]of longint=(0,1);\n mo=10000007;\nvar i,j,k,nx,ny,s,t,z,ans,put,cnt,size,flow:longint;\n tot:int64;\n ch:char;\n hash:array[0..mo]of boolean;\n lt,rt,num,need,nd,opt,place,en:array[1..49]of longint;\n h,vh:array[1..22]of longint;\n o:array[1..22]of boolean;\n pre,g,capa:array[1..300]of longint;\n sta,lk:array[1..7,1..8]of longint;\n w:array[1..10,1..10]of longint;\n res,pp:array[1..14,1..15]of char;\n map:array[1..8,1..9]of boolean;\n cc:array[2..7]of char;\n c:array['A'..'Z']of longint;\n//==============================================================\nfunction gcd(a,b:longint):longint; inline;\nvar i:longint;\nbegin\n for i:=2 to 7 do\n if (a mod i=0)and(b mod i=0) then exit(i);\n gcd:=1;\nend;\n//==============================================================\nprocedure add(x,y:char); inline;\nbegin\n cnt:=c[x]*c[y];\n lt[cnt]:=c[x];rt[cnt]:=c[y];\n read(num[cnt]);\n inc(tot);\n opt[tot]:=cnt;place[cnt]:=tot;\nend;\n//==============================================================\nfunction min(a,b:longint):longint; inline;\nbegin\n if a0 do\n begin\n v:=g[i];\n if (capa[i]>0)and(h[x]=h[v]+1) then\n begin\n next:=flow-dfs2;\n if capa[i]0 then\n begin\n nx:=i+dx[lk[i,j]];ny:=j+dy[lk[i,j]];\n cnt:=sta[i,j]*sta[nx,ny];\n inc(need[cnt]);\n end;\n tot:=0;\n for i:=1 to 10 do tot:=(tot+need[opt[i]])*37 mod mo; \n if hash[tot] then exit;\n hash[tot]:=true;\n flow:=0;size:=1;\n for i:=1 to 10 do\n begin\n cnt:=opt[i];\n flow:=flow+min(need[cnt],num[cnt])*2;\n end;\n if flow>>1+28<=ans then exit;\n fillchar(en,sizeof(en),0);\n for i:=1 to 10 do\n begin\n cnt:=opt[i];\n if num[cnt]>need[cnt] then\n begin\n Ins(s,i,num[cnt]-need[cnt]);\n for j:=1 to 10 do\n if w[i,j]=1 then Ins(i,j+10,28);\n end;\n if need[cnt]>num[cnt] then Ins(i+10,t,need[cnt]-num[cnt]);\n end;\n SAP;\n if flow>ans then\n begin\n ans:=flow;\n pp:=res;\n for i:=1 to 7 do\n for j:=1 to 8 do\n if lk[i,j]>0 then\n begin\n nx:=i+dx[lk[i,j]];ny:=j+dy[lk[i,j]];\n cnt:=sta[i,j]*sta[nx,ny];\n if need[cnt]>num[cnt] then\n begin\n z:=en[place[cnt]+10];put:=0;\n while z>0 do\n begin\n if (g[z]0) then\n begin\n put:=opt[g[z]];dec(capa[z]);break;\n end;\n z:=pre[z];\n end;\n end\n else put:=cnt;\n if put=0 then\n begin\n z:=en[s];\n while z>0 do\n begin\n if capa[z]>0 then\n begin\n put:=opt[g[z]];dec(capa[z]);break;\n end;\n z:=pre[z];\n end;\n end;\n Fill(i,j,nx,ny,put);\n dec(need[cnt]);\n end;\n end;\nend;\n//==============================================================\nprocedure Work(x,y:longint);\nbegin\n if y=9 then\n begin\n Work(x+1,1);exit;\n end;\n if (x=7)and(y=8) then\n begin\n Calc;exit;\n end;\n if map[x,y] then\n begin\n map[x,y]:=false;\n if map[x,y+1] then\n begin\n lk[x,y]:=2;\n res[x*2-1,y*2]:='-';map[x,y+1]:=false;\n Work(x,y+1);\n res[x*2-1,y*2]:='.';map[x,y+1]:=true;\n end;\n if map[x+1,y] then\n begin\n lk[x,y]:=1;\n res[x*2,y*2-1]:='|';map[x+1,y]:=false;\n Work(x,y+1);\n res[x*2,y*2-1]:='.';map[x+1,y]:=true;\n end;\n lk[x,y]:=0;\n map[x,y]:=true;\n end\n else Work(x,y+1);\nend;\n//==============================================================\nprocedure Init;\nbegin\n c['B']:=2;c['R']:=3;c['W']:=5;c['Y']:=7;\n cc[2]:='B';cc[3]:='R';cc[5]:='W';cc[7]:='Y';\n for i:=1 to 7 do\n begin\n for j:=1 to 8 do\n begin\n read(ch);\n map[i,j]:=true;\n sta[i,j]:=c[ch];\n end;\n readln;\n end;\n add('B','Y');add('B','W');add('B','R');add('B','B');\n add('R','Y');add('R','W');add('R','R');\n add('W','Y');add('W','W');\n add('Y','Y');\n for i:=1 to 10 do\n for j:=1 to 10 do\n if (i<>j)and(gcd(opt[i],opt[j])>1) then\n w[i,j]:=1;\n s:=21;t:=22;\n for i:=1 to 14 do\n for j:=1 to 15 do\n res[i,j]:='.';\nend;\n//==============================================================\nprocedure Print;\nbegin\n writeln(ans);\n for i:=1 to 13 do\n begin\n for j:=1 to 15 do\n write(pp[i,j]);\n writeln;\n end;\nend;\n//==============================================================\nbegin\n Init;ans:=-1;\n Work(1,1);\n Print;\nend.\n", "src_uid": "cb56e7578ec5e04118993444283ad1eb"} {"source_code": "var n,i,j:longint;a,b,c,d,x,y: int64;f:boolean;\nbegin\n read(n );\n for j:=1 to n do\n begin\n read(a,b); \n if a-b>1 then writeln('NO') else if b<4 then writeln('YES') else\n begin\n a:=a+b;\n if not odd(a) then writeln('NO') else begin\n b:=trunc(sqrt(a))+2; \n x:=3;f:=true;\n while f and (x0 then\n for k:=i+1 to n do\n f[k,j+1]:=(((int64(f[i,j])*(e[k-i]-1)mod max)*e[(k-i)*i]+f[k,j+1])mod max+max)mod max;\n\n ans:=0;\n for i:=0 to n do ans:=(int64(f[i,m])*e[(n-i)*i]+max+ans)mod max;\n writeln(ans);\nend.", "src_uid": "111673158df2e37ac6c019bb99225ccb"} {"source_code": "{$mode objfpc}\n{$H+}\n{$optimization level2}\n\nprocedure main;\nvar n, k, x, i, j: longint;\nvar infty, ans: Int64;\nbegin\n readln(n, k);\n x := k div n;\n if k mod n <> 0 then inc(x);\n writeln(x);\nend;\n\nbegin\n main();\nend.", "src_uid": "04c067326ec897091c3dbcf4d134df96"} {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n x,y:int64;\nbegin\n readln(x,y);\n if ((x>=0) and (y>=0)) then\n write(0,' ',x+y,' ',x+y,' ',0)\n else if (x<=0) and (y<=0) then\n write(x+y,' ',0,' ',0,' ',x+y)\n else if (x<=0) and (y>=0) then\n write(x-y,' ',0,' ',0,' ',y-x)\n else\n write(0,' ',y-x,' ',x-y,' ',0);\n readln;\n readln;\nend.\n ", "src_uid": "e2f15a9d9593eec2e19be3140a847712"} {"source_code": "program pro496A;\nvar kq,n:longint;\n a,b:array[1..100] of longint;\n{-------------------------------}\nprocedure doc;\nvar i:longint;\nbegin\n read(n);\n for i:=1 to n do read(a[i]);\nend;\n{-------------------------------}\nprocedure ghi;\nbegin\n write(kq);\nend;\n{---------------------------------}\nprocedure xuli;\nvar tg,i,j:longint;\nbegin\n tg:=0;kq:=1001;\n for i:=2 to n-1 do\n begin\n for j:=1 to n-1 do\n if i<>j then\n begin\n if (j+1<>i) and (a[j+1]-a[j]>tg) then tg:=a[j+1]-a[j];\n if (j+1=i) and (a[j+2]-a[j]>tg) then tg:=a[j+2]-a[j] ;\n end;\n if tg=j) do\n\t\t\t\tIf (n1-j<>0) and (n1-jmaxkey then \n\t\t\t\tBegin\n\t\t\t\t\tmaxkey:=key;\n\t\t\t\t\tFor k:=1 to key do maxarr[k]:=A[k];\n\t\t\t\tEnd;\n\t\tEnd;\n\tWriteln(maxkey);\n\tFor k:=1 to maxkey do Write(maxarr[k],' ');\nEnd.", "src_uid": "356a7bcebbbd354c268cddbb5454d5fc"} {"source_code": "program main;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nfunction IsNormalHostName(const hostName: string): string;\nvar\n i, j: integer;\n temp: string;\n a: set of char;\nbegin\n a:=['a'..'z']+['A'..'Z']+['0','1','2', '3','4','5','6','7','8','9', '_'];\n if (Pos('.', hostName) = 0) then\n begin\n for i := 1 to Length(hostName) do\n if not(hostName[i] in a) then\n begin\n Result:='NO';\n Exit;\n end;\n end;\n Result:='YES';\n if (hostName[Length(hostName)] = '.') then\n begin\n Result:='NO';\n Exit;\n end;\n temp:='';\n for i := 1 to Length(hostName) do\n begin\n if (hostName[i]<>'.') then\n begin\n temp:=temp+hostName[i];\n end\n else\n begin\n if (Length(temp)>16) or (Length(Temp) = 0) then\n begin\n Result:='NO';\n Exit;\n end;\n for j := 1 to Length(temp) do\n if not(temp[j] in a) then\n begin\n Result:='NO';\n Exit;\n end;\n temp:='';\n end;\n end;\nend;\nfunction IsNormal(const addr: string): string;\nvar\n i: integer;\n userName, hostName, resource, hostNameTemp: string;\n a: set of char;\nbegin\n Result:='YES';\n userName:='';\n hostName:='';\n hostNameTemp:='';\n resource:='';\n if (pos('@', addr) = 0) or (pos('@', addr)+1>Length(addr)) then\n begin\n Result:='NO';\n Exit;\n end;\n for i := 1 to Pos('@', addr)-1 do\n begin\n userName:=userName+addr[i];\n end;\n for i := Pos('@', addr)+1 to Length(addr) do\n begin\n hostName:=hostName+addr[i];\n end;\n a:=['a'..'z']+['A'..'Z']+['0','1','2', '3','4','5','6','7','8','9', '_'];\n if (Length(userName)>16) or (Length(userName) = 0) then\n begin\n Result:='NO';\n Exit;\n end;\n for i := 1 to Length(userName) do\n begin\n if not (userName[i] in a) then\n begin\n Result:='NO';\n break;\n Exit;\n end;\n end;\n if (pos('/', hostName)<>0) then\n begin\n for i := pos('/', hostName)+1 to Length(hostName) do\n resource:=resource+hostName[i];\n if (Length(resource)>16) or (Length(resource) = 0) then\n begin\n Result:='NO';\n Exit;\n end;\n for i := 1 to Length(resource) do\n begin\n if not(resource[i] in a) then\n begin\n Result:='NO';\n break;\n Exit;\n end;\n end;\n for i := 1 to pos('/', hostName)-1 do\n hostNameTemp:=hostNameTemp+hostName[i];\n if (Length(hostNameTemp) = 0) then\n begin\n Result:='NO';\n Exit;\n end;\n if IsNormalHostName(hostNameTemp) = 'NO' then Result:='NO';\n end\n else\n begin\n if IsNormalHostName(hostName) = 'NO' then Result:='NO';\n end;\nend;\n\nvar\n str: string;\nbegin\n Readln(str);\n Writeln(IsNormal(str));\n { TODO -oUser -cConsole Main : Insert code here }\nend.\n", "src_uid": "2a68157e327f92415067f127feb31e24"} {"source_code": "var\n ch1,ch2:char;\n n,t:longint;\n a:array[' '..'v']of longint;\nbegin\n read(ch1,ch2,ch2);\n read(n);\n a['v']:=1;\n a['<']:=2;\n a['^']:=3;\n a['>']:=4;\n t:=a[ch2]-a[ch1];\n if t<0 then t:=t+4;\n if t>=4 then t:=t mod 4;\n if t=0 then\n begin\n writeln('undefined');\n halt;\n end;\n if t=n mod 4 then\n begin\n if t<>2 then writeln('cw')\n else writeln('undefined');\n end\n else if t+n mod 4=4 then writeln('ccw')\n else writeln('undefined');\nend.", "src_uid": "fb99ef80fd21f98674fe85d80a2e5298"} {"source_code": "var n,i:longint;\na:array[0..35] of int64;\nbegin\n readln(n);\n a[0]:=1;\n for i:=1 to 12 do\n a[i]:=a[i-1]*2;\n a[13]:=8092;\n for i:=14 to 35 do\n a[i]:=a[i-1]*2;\n writeln(a[n]);\nend.", "src_uid": "76f6ebfaeea789952c931d65c6a5fdff"} {"source_code": "var\n h:array[1..2,'0'..'9'] of longint; s:string; ans,d,i:longint;\n\n\nfunction have:boolean;\nvar i:char;\nbegin\n for i:='0' to '9' do if h[1,i]>h[2,i] then exit(false);\n have:=true;\nend;\n\n\nprocedure modify;\nvar i:char;\nbegin\n for i:='0' to '9' do dec(h[2,i],h[1,i]);\nend;\n\n\nprocedure f(nom:longint;c:char);\nbegin\n if (c='2') or (c='5') then inc(h[nom,'2']) else\n if (c='6') or (c='9') then inc(h[nom,'6']) else\n inc(h[nom,c]);\nend;\n\n\nbegin\n\n readln(s); d:=length(s); for i:=1 to d do f(1,s[i]);\n readln(s); d:=length(s); for i:=1 to d do f(2,s[i]);\n while have do\n begin\n modify; inc(ans);\n end;\n writeln(ans);\n\nend.", "src_uid": "72a196044787cb8dbd8d350cb60ccc32"} {"source_code": "var s,a,b:ansistring; d,i:longint;\nbegin\n read(s); i:=1;\n while s[i]<>'.' do inc(i); a:=copy(s,1,i-1); delete(s,1,i); i:=1;\n while s[i]<>'e' do inc(i); b:=copy(s,1,i-1); delete(s,1,i);\n val(s,d); if d=0 then begin if length(b)>0 then while b[length(b)]='0' do\n begin delete(b,length(b),1); if length(b)=0 then break; end;\n if b='' then writeln(a) else writeln(a,'.',b); halt; end;\n for i:=1 to d do\n if length(b)>0 then begin a:=a+b[1]; delete(b,1,1); end\n else a:=a+'0';\n if length(b)=0 then writeln(a) else writeln(a,'.',b);\nend.\n", "src_uid": "a79358099f08f3ec50c013d47d910eef"} {"source_code": "{$R+ Q+ I+}\n{$APPTYPE CONSOLE}\nuses\n SysUtils;\nprocedure swap(var x,y : integer);\nvar\n t : integer;\nbegin\n t := x;\n x := y;\n y := t;\nend;\nvar\n a : array[1..12] of integer;\n i,j,k : integer;\n t : boolean;\nbegin\n read(k);\n t := false;\n for i := 1 to 12 do read(a[i]);\n for i := 1 to 11 do\n for j := i + 1 to 12 do\n if a[i] < a[j] then swap(a[i],a[j]);\n i := 0;\n while k > 0 do begin\n inc(i);\n if i > 12 then begin\n t := true;\n break;\n end;\n k := k - a[i];\n end;\n if t = true then write('-1')\n else\n write(i);\nend.", "src_uid": "59dfa7a4988375febc5dccc27aca90a8"} {"source_code": "Program z70a;\nvar n,i:longint;\n\tsum:int64;\nbegin\n\tread(n);\n sum:=1;\n for i:=1 to n-1 do\n \tsum:=(sum*3) mod 1000003;\n write(sum);\nend.", "src_uid": "1a335a9638523ca0315282a67e18eec7"} {"source_code": "//HardCor\nvar i,j,n,m,p,t,f,x:longint; a:array[1..100000] of longint; s:string; begin read(p); for i:=1 to p-1 do begin x:=1;f:=0;j:=1; while jx do inc(i);\n while a[j]j;\n if lx do 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 y:=c[i];\n c[i]:=c[j];\n c[j]:=y;\n inc(i);\n dec(j);\n end;\n until i>j;\n if lw then begin write('-1');exit;end;\n\nsort(1,n);\n\n for i:=1 to n do \n if s+(a[i]-b[i])<=w then\n begin s:=s+(a[i]-b[i]);b[i]:=a[i];k:=i;end else begin b[i]:=b[i]+w-s;s:=w;end;\n\n if w>s then begin write('-1');exit;end; \n \nsort1(1,n);\n\nfor i:=1 to n do write(b[i],' ');\nend.", "src_uid": "5d3bb9e03f4c5c8ecb6233bd5f90f3a3"} {"source_code": "uses math;\n\nconst\n maxc=1000000000+69;\n maxn=80;\n fi='';\n fo='';\n\nvar\n s:string;\n n:longint;\n a:array[0..maxn] of longint;\n c:array[0..2] of longint;\n cnt:array[0..maxn,0..2] of longint;\n vt:array[0..2,0..maxn] of longint;\n f:array[0..maxn,0..maxn,0..maxn,0..2] of longint;\n\nprocedure nhap;\nbegin\n assign(input,fi);\n reset(input);\n readln(input,n);\n readln(input,s);\n close(input);\n // assign(output,fo);\n // rewrite(output);\nend;\n\n\nprocedure khoitao;\nvar\n i,v,k,x,cntv,cntk,cntx:longint;\nbegin\n\n for i:=1 to n do\n begin\n if s[i]='V' then\n begin\n a[i]:=1;\n inc(c[1]);\n vt[1,c[1]]:=i;\n end\n else\n if s[i]='K' then\n begin\n a[i]:=2;\n inc(c[2]);\n vt[2,c[2]]:=i;\n end\n else\n begin\n inc(c[0]);\n vt[0,c[0]]:=i;\n end;\n cnt[i]:=cnt[i-1];\n inc(cnt[i,a[i]])\n end;\nend;\n\nfunction cal(x,y,z,t:longint):longint;\nvar\n res:longint;\nbegin\n if (x>c[0]) or (y>c[1]) or (z>c[2]) then exit(maxc);\n if x+y+z=n then exit(0);\n if f[x,y,z,t]>-1 then exit(f[x,y,z,t]);\n res:=cal(x+1,y,z,0)+max(0,cnt[vt[0,x+1],1]-y)+max(0,cnt[vt[0,x+1],2]-z);\n res:=min(res,cal(x,y+1,z,1)+max(0,cnt[vt[1,y+1],0]-x)+max(0,cnt[vt[1,y+1],2]-z));\n if t<>1 then\n res:=min(res,cal(x,y,z+1,0)+max(0,cnt[vt[2,z+1],0]-x)+max(0,cnt[vt[2,z+1],1]-y));\n f[x,y,z,t]:=res;\n exit(res);\nend;\n\nprocedure xuli;\nbegin\n assign(output,fo);\n rewrite(output);\n fillchar(f,sizeof(f),255);\n writeln(output,cal(0,0,0,0));\n close(output);\nend;\n\nbegin\n nhap;\n khoitao;\n xuli;\nend.\n", "src_uid": "08444f9ab1718270b5ade46852b155d7"} {"source_code": "Program QQ;\nVar a,b,c,i,k,j:LongInt;\n f,ff:text;\n fl:boolean;\nbegin\n\n{ Assign(f,'input.txt');\n ReSet(f);\n Assign(ff,'output.txt');\n ReWrite(ff);\n\n Writeln;}\n\n Readln(a,b);\n\n{ Writeln;}\n\n{ a:=3;\n b:=10;}\n\n k:=1;\n\n\n If ((b<>10) and (a>=1)) or ((b=10) and (a>=2))\n then begin\n\n If b<>10 then begin\n Write(b);\n For I:=1 to a-1 do\n Write('0');\n end\n else begin\n Write(b);\n For I:=1 to a-2 do\n Write('0');\n\n end;\n end\n else begin\n Write('-1');\n\n end;\n\n\n\n{ Case b of\n 2:begin\n Write('2');\n For I:=1 to a-1 do\n Write('0');\n end;\n\n 3:begin\n Write('3');\n For I:=1 to a-1 do\n Write('0');\n end;\n\n 4:begin\n Write('4');\n For I:=1 to a-1 do\n Write('0');\n end;\n 5:begin\n Write('5');\n For I:=1 to a-1 do\n Write('0');\n end;\n 6:begin\n Write('6');\n For I:=1 to a-1 do\n Write('0');\n end;\n\n :begin\n Write('6');\n For I:=1 to a-1 do\n Write('0');\n end;}\n\n\n\n\n\n\n (* For i:=1 to a do\n k:=k*10;\n k:=k div 10;\n fl:=true;\n\n For I:=k to 10*k-1 do\n begin\n\n If (I mod b)=0\n then begin\n\n Write({ff,}i);\n{ Close(f);\n Close(ff);}\n Exit;\n\n end;\n\n end; *)\n\n\n If fl=true\n then Write({ff,}'-1');\n\n Readln;\n\nEnd.\n", "src_uid": "77ffc1e38c32087f98ab5b3cb11cd2ed"} {"source_code": "var s: string;\n i,j,a,b,t: longint;\nbegin\n//assign (input,'input.txt'); reset (input);\n//assign (output,'output.txt'); rewrite (output);\nfor i:= 1 to 8 do\nbegin\nreadln (s);\nt:= 0;\nfor j:= 1 to 8 do\nif s[j]='B' then inc (t);\n\nif t=8 then inc (a)\nelse if t>b then b:= t;\nend;\nwrite (a+b);\nend.\n", "src_uid": "8b6ae2190413b23f47e2958a7d4e7bc0"} {"source_code": "program yan;\n var a,b,c,x,y,j:int64;\n function min(a,b:int64):int64;\n begin\n if ax2) and (x1<>x3) and (x1<>x4) and (x2<>x3) and (x2<>x4) and (x3<>x4) then\nbegin\nWriteln(x1,' ',x2);\nWriteln(x3,' ',x4);\nbol:=true;\nend;\nif not bol then Writeln('-1');\nread(x2);\nend.\n", "src_uid": "6821f502f5b6ec95c505e5dd8f3cd5d3"} {"source_code": "var n :int64;\n\nbegin\nread (n);\nif n mod 2 = 0 then write ('Mahmoud') else write ('Ehab');\n \nend.", "src_uid": "5e74750f44142624e6da41d4b35beb9a"} {"source_code": "{$mode objfpc}\n\n\nconst InputFile = 'problemA.inp';\n\n\nvar x , t , a , b , da , db : integer;\n i , j , tmp : integer;\n\n\nprocedure Result( s : string );\n begin\n writeln( s );\n halt;\n end;\n\n\n\nbegin\n readln( x , t , a , b , da , db );\n if ( x = 0 ) then Result( 'YES' );\n if ( a + b < x ) then Result( 'NO' );\n for i := 0 to t - 1 do\n begin\n if a - da * i = x then Result( 'YES' );\n if b - db * i = x then Result( 'YES' );\n end;\n for i := 0 to t - 1 do\n for j := 0 to t - 1 do\n if ( a - da * i + b - db * j ) = x then\n begin\n writeln( 'YES' );\n exit;\n end;\n writeln( 'NO' );\nend.\n", "src_uid": "f98168cdd72369303b82b5a7ac45c3af"} {"source_code": "\ufeffvar s : string;\nvar i,n:integer;\nvar b:boolean;\nbegin\nreadln(n);\nreadln(s);\nb := true;\n\nif n > 1 then begin\nif (s[1] =s[2]) or (s[s.length] =s[s.Length -1] ) then b := false;\nif (b = true) and (n >=2) then\nfor i := 2 to n-1 do\nbegin\nif (s[i-1] = '1') and (s[i] = '1') or (s[i-1] ='0') and (s[i] ='0') and (s[i+1] ='0') then b := false;\nend; end else if (s ='0') then b := false;\n\nif (b = false) then writeln('No') else writeln('Yes');\nend.", "src_uid": "c14d255785b1f668d04b0bf6dcadf32d"} {"source_code": "{papich v dele skill na predele} \nvar i, a, b,g,x:int64;\nbegin\nreadln(a);\nb:=3;\nfor i:=2 to a do begin\n g:=b;\n b:=(b*2+x*3)mod 1000000007;\n X:=g;\n end;\nwriteln(g);\nend.\n", "src_uid": "77627cc366a22e38da412c3231ac91a8"} {"source_code": "var s:string;\ni,n,d:integer;\nbegin\nread(s);\nn:=0;\nd:=101;\nfor i:=1 to length(s) do\n begin\n if (s[i]= '1')and (i5) and (d<>0) then\n write ('yes')\n else\n write ('no');\nend. ", "src_uid": "88364b8d71f2ce2b90bdfaa729eb92ca"} {"source_code": " var n,m,c,d,k,p,q,suma:longint;\n begin\n read(c,d);\n read(n,m);\n read(k);\n If m*n<=k then writeln(0) else\n begin\n p:=m*n-k;\n q:=p div n;\n If q*cmax then max:=br;\n if br 1 ) then\n if ( F[FPos-1] = nega(c) ) then\n dec ( FPos);\n \n if (SPos <= N) and ( S[SPos] = c ) then\n inc ( SPos )\n else if ( SPos <> 1 ) then\n if ( S[SPos-1] = nega(c) ) then\n dec ( SPos ) ;\n \n \n if ( FPos > N ) and ( SPos > N ) then\n begin\n writeLn ( 'YES' ) ; \n halt();\n end;\n end;\n \n var StartTime : Int64;\n i : LongInt;\nbegin\n readLn ( N ) ; \n N := N - 1 ; \n FPos := 1 ; \n SPos := 1 ; \n\n readLn ( F ) ; \n readLn ( S ) ; \n \n \n StartTime := GetMSCount;\n for I := 1 to N do\n DoIt ( F[FPos] ) ; \n\n \n while ( GetMSCount - StartTime < 1900 ) do\n begin\n moved := false;\n if ( Free ( FPos , SPos-1 ) ) then\n DoIt(F[FPos] );\n if ( Free ( FPos-1 , SPos ) ) then\n DoIt(S[SPos] );\n \n if ( not moved ) then\n begin\n if ( wasBest [ SPos ] = 0 ) or ( wasBest[ Spos] < FPos ) then\n begin\n wasBest [ SPos ] := FPos ; \n DoIt(S[SPos]);\n end\n else\n begin\n DoIt(F[Fpos] ) ; \n end;\n \n end;\n end;\n \n writeLn ( 'NO' ) ; \n \nend.", "src_uid": "85f43628bec7e9b709273c34b894df6b"} {"source_code": "uses math;\n\nconst\n maxc=1000000000+69;\n\ntype\n re=record\n x,y:longint;\n end;\n\nvar\n ii:longint;\n n,l,r,res:int64;\n f,g:array[0..60] of int64;\n\nprocedure mofile;\nbegin\n assign(input,'checking.inp');\n reset(input);\n assign(output,'');\n rewrite(output);\nend;\n\nprocedure dongfile;\nbegin\n close(input);\n close(output);\nend;\n\nfunction getval(x,y,u,g:int64):int64;\nvar\n mid,res:int64;\nbegin\n if x>u then exit(0);\n if y<=u then exit(g);\n mid:=(x+y) div 2;\n res:=getval(x,mid-1,u,g div 2)+getval(mid+1,y,u,g div 2);\n if u>=mid then res:=res+g mod 2;\n exit(res);\nend;\n\nprocedure xuli;\nvar\n i:longint;\nbegin\n readln(n,l,r);\n f[0]:=n;\n if n>1 then\n for i:=1 to 50 do\n begin\n f[i]:=f[i-1] div 2;\n if f[i]=1 then\n begin\n ii:=i;\n break;\n end;\n end;\n\n g[ii]:=1;\n for i:=ii-1 downto 0 do\n begin\n g[i]:=g[i+1]*2+1;\n end;\n\n res:=getval(1,g[0],r,n)-getval(1,g[0],l-1,n);\n writeln(res);\nend;\n\nbegin\n //mofile;\n xuli;\n dongfile;\nend.\n\n", "src_uid": "3ac61b1f8deee7911b1055c243f5eb6a"} {"source_code": "program A133;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nconst let=['H','9','Q'];\nvar i,c:integer;\ns:string;\nbegin\n read(s);\n c:=0;\n for i:=1 to length(s) do\n if s[i] in let then begin inc(c); break; end;\n if c<>0 then write('YES')\n else write('NO');\nend.\n ", "src_uid": "1baf894c1c7d5aeea01129c7900d3c12"} {"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\nUses SysUtils;\nType tname=Array [1..10] of String;\n tm=Array [1..10] of LongInt;\nVar name:tname;\n och,goal,raz,nogoal,aa:tm;\n kol,i:LongInt;\n s,name1,name2,nsop:String;\n k,ii,comm,o1,o2,sop,j:LongInt;\n f:Boolean;\n aoldgoal,aoldnogoal,boldgoal,boldnogoal,bestxmy,bestx,besty,xmy:LongInt;\n \nFunction Give (x,y:LongInt):LongInt;\nBegin\n If x=y then Begin Result:=1; Exit End;\n If x>y then Begin Result:=3; Exit End;\n If xcomm)\n then Begin Result:=i; Exit End;\n Result:=0;\nEnd;\n\nProcedure Sort (l,r:LongInt);\nVar i,j,x,y,z,b:LongInt;\n nam,nn:String;\nBegin\n i:=l;\n j:=r;\n x:=och[(l+r) div 2];\n y:=raz[(l+r) div 2];\n z:=goal[(l+r) div 2];\n nam:=name[(l+r) div 2];\n Repeat\n While (och[i]>x) or ((och[i]=x) and (raz[i]>y)) or ((och[i]=x) and (raz[i]=y) and (goal[i]>z)) or ((och[i]=x) and (raz[i]=y) and (goal[i]=z) and (name[i]nam)) do Dec (j);\n If i<=j\n then Begin\n b:=och[i]; och[i]:=och[j]; och[j]:=b;\n b:=raz[i]; raz[i]:=raz[j]; raz[j]:=b;\n b:=goal[i]; goal[i]:=goal[j]; goal[j]:=b;\n b:=nogoal[i]; nogoal[i]:=nogoal[j]; nogoal[j]:=b;\n nn:=name[i]; name[i]:=name[j]; name[j]:=nn;\n Inc (i); Dec (j);\n End;\n Until i>j;\n If il then Sort (l,j);\nEnd;\n\nFunction FindI:LongInt;\nVar i:LongInt;\nBegin\n For I:=1 to 4 do\n If name[i]='BERLAND'\n then Begin Result:=i; Exit End;\n Result:=0;\nEnd;\n\nFunction FindOn:LongInt;\nVar i:LongInt;\nBegin\n For I:=1 to 4 do\n If name[i]=nsop\n then Begin Result:=i; Exit End;\n Result:=0;\nEnd;\n\nBegin\n //Assign (input,'input.txt'); ReSet (input);\n //Assign (output,'output.txt'); ReWrite (output);\n kol:=0;\n comm:=0;\n FillChar (aa,sizeof (tm),0);\n For I:=1 to 5 do\n Begin\n Readln (s);\n k:=Pos (' ',s);\n name1:=Copy (s,1,k-1);\n Delete (s,1,k);\n\n k:=Pos (' ',s);\n name2:=Copy (s,1,k-1);\n Delete (s,1,k);\n\n o1:=StrToInt (s[1]);\n o2:=StrToInt (s[3]);\n f:=False;\n For Ii:=1 to kol do\n If name[ii]=name1\n then Begin\n Inc (goal[ii],o1);\n Inc (och[ii],give (o1,o2));\n Inc (nogoal[ii],o2);\n Inc (aa[ii]);\n f:=True;\n Break\n End;\n If not f\n then Begin\n Inc (kol);\n name[kol]:=name1;\n goal[kol]:=o1;\n och[kol]:=give (o1,o2);\n nogoal[kol]:=o2;\n Inc (aa[kol]);\n If name1='BERLAND'\n then comm:=kol;\n End;\n\n\n\n f:=False;\n For Ii:=1 to kol do\n If name[ii]=name2\n then Begin\n Inc (goal[ii],o2);\n Inc (och[ii],give (o2,o1));\n Inc (nogoal[ii],o1);\n f:=True;\n Inc (aa[ii]);\n Break\n End;\n If not f\n then Begin\n Inc (kol);\n name[kol]:=name2;\n goal[kol]:=o2;\n och[kol]:=give (o2,o1);\n nogoal[kol]:=o1;\n Inc (aa[kol]);\n If name2='BERLAND'\n then comm:=kol;\n End;\n End;\n sop:=Prov;\n nsop:=name[sop];\n Inc (och[comm],3);\n f:=False;\n\n\n aoldgoal:=goal[comm];\n aoldnogoal:=nogoal[comm];\n boldgoal:=goal[sop];\n boldnogoal:=nogoal[sop];\n\n bestxmy:=100000;\n bestx:=100000;\n besty:=100000;\n\n For I:=1 to kol do\n raz[i]:=goal[i]-nogoal[i];\n\n For I:=1 to 100 do\n Begin\n For J:=0 to i-1 do\n Begin\n Inc (goal[comm],i);\n Inc (nogoal[comm],j);\n raz[comm]:=goal[comm]-nogoal[comm];\n\n Inc (goal[sop],j);\n Inc (nogoal[sop],i);\n raz[sop]:=goal[sop]-nogoal[sop];\n \n Sort (1,4);\n If (name[1]='BERLAND') or (name[2]='BERLAND')\n then Begin\n f:=True;\n xmy:=i-j;\n If xmymax then max:=a[i];\n \nend;\n\nfor i:=1 to n-1 do\n for j:=1 to n-i do\n if a[j]>a[j+1] then begin y:=a[j];\n a[j]:=a[j+1];\n a[j+1]:=y;\n end;\n \nx:=0;\ni:=1;\n\n\nwhile xmin then min:=a[i];\n \n\n\n writeln(min,' ',max+m);\nend.\n ", "src_uid": "78f696bd954c9f0f9bb502e515d85a8d"} {"source_code": "program ex1;\nvar\n a,b,s,sta,ll,last,ans,wh:array[0..110000] of longint;\n i,j,k,n,m,e:longint;\n t,s1:ansistring;\n pool:array[0..110000] of record\n number,next:longint;\n end;\n\n procedure swap(x,y:longint);\n var\n t:longint;\n begin\n t:=a[x];a[x]:=a[y];a[y]:=t;\n t:=b[x];b[x]:=b[y];b[y]:=t;\n end;\n\n procedure sort(l,r:longint);\n var\n 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 dec(j);\n if not(i>j) then\n begin\n swap(i,j);\n inc(i);dec(j);\n end;\n until i>j;\n if l0 do\n begin\n l:=pool[r].number;\n if l=x then exit(r);\n r:=pool[r].next;\n end;\n exit(0);\n end;\n\nbegin\n readln(s1);\n readln(n);\n for i:=1 to n do\n begin\n readln(t);\n for j:=1 to length(t) do\n a[i]:=a[i] or (1 shl (ord(t[j])-97));\n b[i]:=i;\n end;\n sort(1,n);\n\n k:=0;\n for i:=1 to n do\n begin\n if a[i]>a[i-1] then\n begin\n inc(k);\n pool[k].number:=a[i];\n m:=a[i] mod 100007;\n pool[s[m]].next:=k;\n s[m]:=k;\n if sta[m]=0 then sta[m]:=k;\n end;\n wh[b[i]]:=k;\n end;\n\n for i:=1 to length(s1) do\n begin\n last[ord(s1[i])-97]:=i;\n for j:=0 to 25 do\n begin\n a[j]:=last[j];\n b[j]:=j;\n end;\n sort(0,25);\n m:=0;\n for j:=25 downto 0 do\n if a[j]=0 then break\n else\n begin\n m:=m or (1 shl b[j]);\n e:=find(m);\n if e>0 then\n if (a[j]>ll[e]+1)or(ll[e]=0) then\n begin\n ll[e]:=i;\n inc(ans[e]);\n end\n else ll[e]:=i;\n end;\n end;\n for i:=1 to n do writeln(ans[wh[i]]);\nend.", "src_uid": "9bafcd579d38d5c3f073839ccb1c6ed3"} {"source_code": "var\n n,k,l,r,mid:int64;\n\nbegin {main}\n readln(n,k);\n if n=1 then\n writeln(0)\n else\n if (k+2)*(k-1) div 2-(k-2)=n then l:=mid+1 else r:=mid-1;\n until l>r;\n writeln(k-l+2);\n end;\nend.\n", "src_uid": "83bcfe32db302fbae18e8a95d89cf411"} {"source_code": "program z1;\nvar\n a, n, b, i : longint;\n s, z : string;\nbegin\n readln(n);\n for i := 1 to n do\n begin\n str(i, z);\n s := s + z;\n end;\n write(s[n]);\nend.", "src_uid": "2d46e34839261eda822f0c23c6e19121"} {"source_code": "Program eee;\nConst\n Infile='';\n Outfile='';\n modd=1000000007;\nVar\n n,m,i,j,p,q,r:Longint;\n c:Array[0..1100,0..1100] Of Int64;\n f:Array[0..1100,0..1100,0..1,0..1,0..1] Of Int64;\n g:Array[0..1100] Of Int64;\n dq:Int64;\nBegin\n Assign(Input,Infile);\n Assign(Output,Outfile);\n Reset(Input);\n Rewrite(Output);\n Readln(n,m);\n c[0,0]:=1;\n For i:=1 To n Do Begin\n c[i,0]:=1;\n For j:=1 To i Do c[i,j]:=(c[i-1,j]+c[i-1,j-1]) Mod modd;\n End;\n f[0,0,1,1,0]:=1;\n For i:=0 To n-1 Do\n For j:=0 To n Do Begin\n For p:=0 To 1 Do\n For q:=0 To 1 Do\n For r:=0 To 1 Do Begin\n f[i+1,j,q,r,0]:=(f[i+1,j,q,r,0]+f[i,j,p,q,r]) Mod modd;\n f[i+1,j+1,q,r,1]:=(f[i+1,j+1,q,r,1]+f[i,j,p,q,r]) Mod modd;\n If (q=0) Then f[i+1,j+1,1,r,0]:=(f[i,j,p,q,r]+f[i+1,j+1,1,r,0]) Mod modd;\n End;\n End;\n For i:=0 To n Do g[i]:=(f[n,i,0,0,0]+f[n,i,0,1,0]+f[n,i,1,0,0]+f[n,i,1,1,0]) Mod modd;\n dq:=1;\n For i:=n Downto 0 Do Begin\n g[i]:=(g[i]*dq) Mod modd;\n For j:=n Downto i+1 Do Begin\n g[i]:=(g[i]-g[j]*c[j,i]) Mod modd;\n IF g[i]<0 Then g[i]:=g[i]+modd;\n End;\n dq:=(dq*(n-i+1)) Mod modd;\n End;\n Writeln(g[m]);\n Close(Input);\n Close(Output);\nEnd.\n\n", "src_uid": "1243e98fe2ebd6e6d1de851984b96079"} {"source_code": "program P8C;\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 xs, ys: Integer;\n i, n: Integer;\n Px, Py: array [0..25] of Integer;\n DP: array [0..16*1024* 1024] of Integer;\n\nfunction Distance (i, j: Integer): Integer;\nbegin\n Result:= Sqr (Px [i]- Px [j])+ Sqr (Py [i]- Py [j]);\n\nend;\n\nfunction Solve (x: Integer): Integer;\nvar\n Temp: Integer;\n i, j: Integer;\n\nbegin\n if x= 0 then\n begin\n DP [x]:= 0;\n Exit (0);\n\n end;\n\n if 0<= DP [x] then\n Exit (DP [x]);\n\n Result:= MaxInt;\n for i:= 0 to n- 1 do\n if (x and (1 shl i))<> 0 then\n begin\n for j:= i+ 1 to n- 1 do\n if (x and (1 shl j))<> 0 then\n begin\n Temp:= Solve ((x xor (1 shl i)) xor (1 shl j));\n Result:= Min (Result, Temp+ Distance (i+ 1, 0)+ Distance (i+ 1, j+ 1)+\n Distance (j+ 1, 0));\n\n end;\n\n break;\n end;\n\n for i:= 0 to n- 1 do\n if (x and (1 shl i))<> 0 then\n begin\n Temp:= Solve (x xor (1 shl i));\n Result:= Min (Result, Temp+ 2* Distance (i+ 1, 0));\n break;\n\n end;\n\n DP [x]:= Result;;\n\nend;\n\nprocedure PrintPath (x: Integer);\nvar\n i, j: Integer;\n Temp: Integer;\n\nbegin\n if x= 0 then\n Exit;\n\n for i:= 0 to n- 1 do\n if (x and (1 shl i))<> 0 then\n begin\n for j:= i+ 1 to n- 1 do\n if (x and (1 shl j))<> 0 then\n begin\n Temp:= DP [(x xor (1 shl i)) xor (1 shl j)];\n if DP [x]= Temp+ Distance (i+ 1, 0)+ Distance (i+ 1, j+ 1)+\n Distance (j+ 1, 0) then\n begin\n Write (0, ' ', i+ 1, ' ', j+ 1, ' ');\n PrintPath ((x xor (1 shl i)) xor (1 shl j));\n Exit;\n\n end;\n\n end;\n\n break;\n end;\n\n for i:= 0 to n- 1 do\n if (x and (1 shl i))<> 0 then\n begin\n Temp:= DP [(x xor (1 shl i))];\n if DP [x]= Temp+ 2* Distance (i+ 1, 0) then\n begin\n PrintPath ((x xor (1 shl i)));\n Write (0, ' ', i+ 1, ' ');\n Exit;\n\n end;\n break;\n\n end;\n\nend;\n\nbegin\n\n FillChar (Dp [0], SizeOf (DP), 255);\n ReadLn (Px [0], Py [0]);\n ReadLn (n);\n for i:= 1 to n do\n ReadLn (Px [i], Py [i]);\n WriteLn (Solve ((1 shl n)- 1));\n PrintPath ((1 shl n)- 1);\n WriteLn (' 0');\n\nend.\n\n", "src_uid": "2ecbac20dc5f4060bc873553946281bc"} {"source_code": "var\n i,j,k,n,m:longint;\n s1,s2:string;\nfunction day(s:string):longint;\nbegin\n if s='monday' then \n exit(1);\n if s='tuesday' then \n exit(2);\n if s='wednesday' then \n exit(3);\n if s='thursday' then \n exit(4);\n if s='friday' then \n exit(5);\n if s='saturday' then \n exit(6);\n if s='sunday' then \n exit(7);\nend;\nbegin\n readln(s1);\n readln(s2);\n n:=day(s1);\n m:=day(s2);\n if n=m then writeln('YES')\n else if (m-n=3) or (m-n=2) then write('YES')\n else if(n+3-7=m) or (n+2-7=m) then write('YES')\n else write('NO');\nend.", "src_uid": "2a75f68a7374b90b80bb362c6ead9a35"} {"source_code": "var f1,f2 : text;\n kt : array['A'..'Z'] of boolean;\n dem : array['A'..'Z'] of longint;\n n,k,i:longint;\n s:ansistring;\n\nbegin\nassign(f1,'');reset(f1);\nassign(f2,'');rewrite(f2);\nreadln(f1,n,k);\nreadln(f1,s);\nfor i := 1 to n do\n inc(dem[s[i]]);\n//fillchar(kt,sizeof(kt),true);\nfor i := 1 to n do\n if (k=0) and (kt[s[i]]=false) then\n begin\n writeln(f2,'YES');\n close(f1);\n close(f2);\n halt;\n end\n else begin\n if kt[s[i]] = true then dec(dem[s[i]]);\n if kt[s[i]] = false then\n begin\n dec(k);\n kt[s[i]]:=true;\n dec(dem[s[i]]);\n end;\n if dem[s[i]] = 0 then inc(k);\n end;\nwrite(f2,'NO');\nclose(f1);\nclose(f2);\nend.", "src_uid": "216323563f5b2dd63edc30cb9b4849a5"} {"source_code": "uses math;\nvar f:array[0..1 shl 20] of extended;\n n,l,r,m,i,j,k,mask:longint;\n x,y,a:array[0..22] of extended;\n next:extended;\n\nfunction find(Dist,x,y,alpha:extended):extended;\nvar x2,y2,ansx,ansy,a1,a2,b1,b2,c1,c2,current:extended;\nbegin\n x2:=dist-x; y2:=-y;\n ansx:=x2*cos(-alpha)+y2*sin(-alpha);\n ansy:=y2*cos(-alpha)-x2*sin(-alpha);\n ansx:=ansx+x;\n ansy:=ansy+y;\n a1:=0;\n b1:=1;\n c1:=0;\n a2:=ansy-y;\n b2:=x-ansx;\n c2:=-a2*x-b2*y;\n if (abs(a1*b2-a2*b1)<1e-9) then find:=round(1e18) else\n begin\n current:=(b1*c2-b2*c1)/(a1*b2-a2*b1);\n if currentr then next:=r;\n mask:=i or (1 shl (j-1));\n if f[mask]r then f[1 shl n - 1]:=r;\n writeln(f[1 shl n - 1]-f[0]:0:10);\nend.", "src_uid": "4fad1233e08bef09e5aa7e2dc6167d6a"} {"source_code": "var a,b,c,c1,k,p : integer;\nBegin\n readln(a,b,c);\n p:=1;\n if a>b then a:=a mod b;\n while k<1000 do\n begin\n k:=k+1;\n c1:=a*10 div b;\n a:=a*10 mod b;\n if c=c1 then begin writeln(k); p:=0; break; end;\n end;\n if p=1 then writeln(-1);\n\nend.", "src_uid": "0bc7bf67b96e2898cfd8d129ad486910"} {"source_code": "const max=100;\nvar n,x:integer;\n a:array[0..max] of boolean;\nprocedure init;\nvar i,j:integer;\nbegin\n readln(n,x);\n for i:=1 to n do\n begin\n read(j);\n a[j]:=true;\n end;\nend;\nprocedure trys;\nvar cout,i:integer;\nbegin\n cout:=0;\n for i:=0 to x do\n if (a[i]=false) and (iy[j] then inc(b);\nif b=n then f:=true else f:=false; \nend;\ninc(k);\nif f then y[k]:=x[i];\nb:=0;\nend;\nb:=0;\nfor i:=1 to n do \nif y[i] <>0 then inc(b);\nk:=0;\n\nif b>=a then begin\nwriteln ('YES');\nfor i:=1 to n do \nbegin\nif y[i]<>0 then begin if k>=a then break; write(i,' '); inc(k); end;\n\nend;\nend \nelse\nwriteln ('NO');\nend.", "src_uid": "5de6574d57ab04ca195143e08d28d0ad"} {"source_code": "var\na:array[1..10000] of integer;\ni,n,k:integer;\nbegin\nread(n);\nwriteln((n div 2)+1)\nend.", "src_uid": "5551742f6ab39fdac3930d866f439e3e"} {"source_code": "var a:array[1..360]of longint;\n i,j,k,l,m,n:longint;\nprocedure qSort(l,r:longint);\nvar i,j,w,q:longint;\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;\nbegin\n m := 360;\n read(n);\n for i := 1 to n do\n read(a[i]);\n for i := 1 to n do\n begin\n k := a[i];\n j := i + 1;\n while k + a[j] <= 180 do\n begin\n k := k + a[j];\n inc(j);\n if j > n then j := 1;\n end;\n if (360 - k)-k < m then m := (360 - k)-k \n end;\n writeln(abs(m)); \nend.", "src_uid": "1b6a6aff81911865356ec7cbf6883e82"} {"source_code": "var mid,n,m,k,t,w,mi,ma,p,o,mis,mas,oo:int64;i:longint;\nbegin\nreadln(n,m,k);\nt:=0;w:=n;mi:=m-1;ma:=n-m;p:=n-1;o:=1;\nwhile tk then\n begin\n mis:=mis+1;dec(p);\n end;\n end\n else\n begin\n w:=mid;\n mas:=mas+1;dec(p);\n end;\n end;\nfor i:=1 to mis do begin oo:=i;o:=o*(mi-oo+1) mod 1000000007;end;\nfor i:=1 to mas do begin oo:=i;o:=o*(ma-oo+1) mod 1000000007;end;\nfor i:=1 to p do begin oo:=i;o:=o*oo mod 1000000007;end;\nwriteln(o);\nclose(input);close(output);\nend.", "src_uid": "24e2f10463f440affccc2755f4462d8a"} {"source_code": "var n,s,k:int64;\n p,q:boolean;\n\nfunction leap(x:int64):boolean;\nbegin\n if (x mod 400=0)or((x mod 4=0)and(x mod 100<>0)) then leap:=true\n else leap:=false;\nend;\n\nbegin\n readln(n);\n p:=leap(n);\n q:=leap(n+1);\n s:=n+1;\n if q then k:=2\n else k:=1;\n while (k mod 7<>0)or(q<>p) do\n begin\n q:=leap(s+1);\n if q then k:=(k+2) mod 7\n else k:=(k+1) mod 7;\n inc(s);\n end;\n writeln(s);\nend.", "src_uid": "565bbd09f79eb7bfe2f2da46647af0f2"} {"source_code": "var a,b,c,d:array[byte] of int32;\n i,j,k,n,r,l:int32;\nbegin\n{assign(input,'input.txt');\nassign(output,'output.txt');\nreset(input);\nrewrite(output);}\nreadln(n,L);\nfor i:=1 to n do read(a[i]);\nfor i:=1 to n do read(b[i]);\na[i+1]:=L+a[1];\nb[i+1]:=L+b[1];\nfor i:=1 to n do\n begin\n c[i]:=a[i+1]-a[i];\n d[i]:=b[i+1]-b[i];\n end;\nk:=0;\nfor i:=1 to n do\n begin\n r:=0;\n for j:=1 to n do\n if c[j]=d[(i+j-2) mod n+1] then r:=r+1;\n if r=n then k:=1;\n end;\nif k=1 then write('YES') else write('NO');\nend.\n", "src_uid": "3d931684ca11fe6141c6461e85d91d63"} {"source_code": "program pr;\n const size = 100010;\n\n type\n TConn = record\n d:longint;\n Prev:longint;\n end;\n\n var N,M, i, a,b, c1,c2:longint;\n Stat:array [1..size] of longint;\n\n List1,List2:array [1..size] of TConn;\n Head1,Head2:array [1..size] of longint;\n\n mask1,mask2:array [1..size] of boolean;\n\n f:text;\n\nprocedure add(a,b:longint);\nbegin\n inc(c1);\n\n List1[c1].d:=b;\n List1[c1].Prev:=Head1[a];\n\n Head1[a]:=c1;\n\n inc(c2);\n\n List2[c2].d:=a;\n List2[c2].Prev:=Head2[b];\n\n Head2[b]:=c2;\nend;\n\nprocedure DFS1(a:longint);\n var i,b:longint;\nbegin\n mask1[a]:=true;\n\n i:=Head1[a];\n while (i <> 0) do\n begin\n b:=List1[i].d;\n\n if NOT(mask1[b]) then\n DFS1(b);\n\n i:=List1[i].Prev;\n end;\nend;\n\nprocedure DFS2(a:longint);\n var i,b:longint;\nbegin\n mask2[a]:=true;\n\n i:=Head2[a];\n while (i <> 0) do\n begin\n b:=List2[i].d;\n\n if (Stat[b] <> 1) then\n begin\n if NOT(mask2[b]) then\n DFS2(b);\n end else\n begin\n mask2[b]:=true;\n end;\n\n i:=List2[i].Prev;\n end;\nend;\n\nbegin\n assign(f, '');\n reset(f);\n\n readln(f, N,M);\n\n for i:=1 to N do\n read(f, Stat[i]);\n\n c1:=0;\n c2:=0;\n\n FillDWord(Head1, size, 0);\n FillDWord(Head2, size, 0);\n\n for i:=1 to M do\n begin\n readln(f, a,b);\n\n add(a,b);\n end;\n\n close(f);\n\n FillChar(mask1, size, false);\n FillChar(mask2, size, false);\n\n for i:=1 to N do\n begin\n if (Stat[i] = 1) then\n DFS1(i);\n\n if (Stat[i] = 2) then\n DFS2(i);\n end;\n\n for i:=1 to N do\n if (mask1[i] and mask2[i]) then\n writeln(1)\n else\n writeln(0);\n\n {for i:=1 to N do\n write(mask1[i],' ');\n writeln;\n\n for i:=1 to N do\n write(mask2[i],' ');\n writeln; }\nend.\n\n", "src_uid": "87d869a0fd4a510c5e7e310886b86a57"} {"source_code": "var\n i,j,k,l,n,m,ans:longint;\n a,b:array[0..13,0..2] of longint;\n bb,bz:boolean;\nfunction min(a,b:longint):longint;\nbegin\n if a>b then exit(b) else exit(a);\nend;\nbegin\n {assign(input,'open5.in'); reset(input);\n assign(output,'open.out'); rewrite(output);}\n readln(n,m); ans:=100;\n for i:=1 to n do read(a[i,1],a[i,2]); readln;\n for i:=1 to m do read(b[i,1],b[i,2]);\n for i:=1 to n do\n begin\n bb:=false; bz:=false;\n for j:=1 to m do\n begin\n if (a[i,1]=b[j,1]) and (a[i,2]=b[j,2]) then continue;\n if (a[i,1]=b[j,1]) and (a[i,2]<>b[j,2]) then bb:=true;\n if (a[i,1]=b[j,2]) and (a[i,2]<>b[j,1]) then bb:=true;\n if (a[i,2]=b[j,1]) and (a[i,1]<>b[j,2]) then bz:=true;\n if (a[i,2]=b[j,2]) and (a[i,1]<>b[j,1]) then bz:=true;\n end;\n if (bb) and (not bz) then\n begin\n if (ans>0) and (ans<>a[i,1]) and (ans<>100)\n then ans:=0 else ans:=min(ans,a[i,1]);\n end;\n if (not bb) and (bz) then\n begin\n if (ans>0) and (ans<>a[i,2]) and (ans<>100)\n then ans:=0 else ans:=min(ans,a[i,2]);\n end;\n if (bb) and (bz) then ans:=min(ans,-1);\n end;\n for j:=1 to m do\n begin\n bb:=false; bz:=false;\n for i:=1 to n do\n begin\n if (a[i,1]=b[j,1]) and (a[i,2]=b[j,2]) then continue;\n if (a[i,1]=b[j,1]) and (a[i,2]<>b[j,2]) then bb:=true;\n if (a[i,1]=b[j,2]) and (a[i,2]<>b[j,1]) then bz:=true;\n if (a[i,2]=b[j,1]) and (a[i,1]<>b[j,2]) then bb:=true;\n if (a[i,2]=b[j,2]) and (a[i,1]<>b[j,1]) then bz:=true;\n end;\n if (bb) and (not bz) then\n begin\n if (ans>0) and (ans<>b[j,1]) and (ans<>100)\n then ans:=0 else ans:=min(ans,b[j,1]);\n end;\n if (not bb) and (bz) then\n begin\n if (ans>0) and (ans<>b[j,2]) and (ans<>100)\n then ans:=0 else ans:=min(ans,b[j,2]);\n end;\n if (bb) and (bz) then ans:=min(ans,-1);\n end;\n if ans=100 then ans:=-1;\n writeln(ans);\n {close(input);\n close(output);}\nend.", "src_uid": "cb4de190ae26127df6eeb7a1a1db8a6d"} {"source_code": "program A_535;\n\nvar\n s:longint;\n\nprocedure ed(x:longint);\nbegin\n case x of\n 1:write('one');\n 2:write('two');\n 3:write('three');\n 4:write('four');\n 5:write('five');\n 6:write('six');\n 7:write('seven');\n 8:write('eight');\n 9:write('nine');\n end;\nend;\n\nprocedure des(x:longint);\nbegin\n case x of \n 2:write('twenty');\n 3:write('thirty');\n 4:write('forty');\n 5:write('fifty');\n 6:write('sixty');\n 7:write('seventy');\n 8:write('eighty');\n 9:write('ninety');\n end;\nend;\n\n\n\nbegin\n read(s);\n if s=0\n then begin\n write('zero');\n exit;\n end;\n if s div 10 =1\n then begin\n case s mod 10 of\n 0:write('ten');\n 1:write('eleven');\n 2:write('twelve');\n 3:write('thirteen');\n 5:write('fifteen');\n 8:write('eighteen');\n 4,6,7,9:\n begin\n ed(s mod 10);\n write('teen');\n end;\n end;\n exit;\n end;\n des(s div 10);\n if (s div 10<>0) and (s mod 10<>0)\n then write('-');\n ed(s mod 10);\nend.\n", "src_uid": "a49ca177b2f1f9d5341462a38a25d8b7"} {"source_code": "program pa;\nvar\n a:array[1..10001] of longint;\n s,max,temp:string;\nprocedure judge;\n var\n temp1,temp2:string;\n i:longint;\n begin\n temp1:='';temp2:='';\n for i:=1 to length(s) do\n if a[i]=1 then\n begin\n temp1:=temp1+s[i];\n temp2:=s[i]+temp2;\n end;\n if temp1=temp2 then\n if temp1>max then\n max:=temp1;\n end;\nprocedure try1(k:longint);\n var\n i:longint;\n begin\n if k>length(s) then begin judge;exit;end;\n for i:=0 to 1 do\n begin\n a[k]:=i;\n try1(k+1);\n end;\n end;\nbegin\n //assign(input,'a.in');reset(input);\n //assign(output,'a.out');rewrite(output);\n readln(s);\n max:='';temp:='';\n try1(1);\n writeln(max);\n //close(input);\n //close(output);\nend.", "src_uid": "9a40e9b122962a1f83b74ddee6246a40"} {"source_code": "var st,ss:string;\ni,j:longint;\n st1:array[0..9] of string;\nbegin\n readln(st);\n for i:=0 to 9 do\n readln(St1[i]);\n i:=1;\n while i<80 do\n for j:=0 to 9 do\n begin\n ss:=copy(st,i,10);\n if ss=st1[j] then\n write(j);\n if j=9 then i:=i+10;end;\n\nend.\n", "src_uid": "0f4f7ca388dd1b2192436c67f9ac74d9"} {"source_code": "var a:array[1..100]of integer;\ni,n,k,b,e,s,max:integer;\nbegin\n readln(n,k);\n for i:=1 to n do\n read(a[i]);\n for b:=1 to k do\n begin\n s:=0;\n e:=0;\n for i:=1 to n do\n if (i - b) mod k <> 0 then\n if a[i] = -1 then\n inc(s)\n else\n inc(e);\n if abs(e-s) > max then\n max:=abs(e-s);\n end;\n writeln(max);\nend.", "src_uid": "6119258322e06fa6146e592c63313df3"} {"source_code": "{$OPTIMIZATION LEVEL2}\n{$INLINE ON}\n\nuses math;\n\nconst\n maxc=1000000000+69;\n\ntype\n re=record\n x,y:longint;\n end;\n\nvar\n n,m,d,c,mid:qword;\n\nprocedure mofile;\nbegin\n assign(input,'checking.inp');\n reset(input);\n assign(output,'');\n rewrite(output);\nend;\n\nprocedure dongfile;\nbegin\n close(input);\n close(output);\nend;\n\nbegin\n //mofile;\n readln(n,m);\n if m>=n then writeln(n) else\n begin\n d:=1;\n c:=n-m;\n while d<=c do\n begin\n mid:=(d+c) div 2;\n if (mid+1)<(((n-m)*2)-1)div mid+1 then d:=mid+1 else c:=mid-1;\n end;\n writeln(m+d);\n end;\n dongfile;\nend.\n\n\n\n", "src_uid": "3b585ea852ffc41034ef6804b6aebbd8"} {"source_code": "var\n n,\n k,\n j,\n m,\n i:integer;\n a,b:array[1..50] of integer;\nbegin\n readln(n);\n for i:=1 to n do\n read(a[i]);\n b[1]:=a[n];\n k:=1;\n for i:=n-1 downto 1 do begin\n m:=0;\n for j:=1 to k do begin\n if a[i]=b[j] then m:=1;\n end;\n if m=0 then begin\n inc(k);\n b[k]:=a[i];\n end;\n end;\n writeln(k);\n for i:=k downto 1 do write(b[i],' ');\nend.", "src_uid": "1b9d3dfcc2353eac20b84c75c27fab5a"} {"source_code": "\nvar j,n,m,i:longint;\nFunction Proste (x:longint):boolean;\nbegin\nproste:=true;\nfor j:=2 to x div 2 do\nif x mod j=0 then begin\nproste:=false;\nbreak\nend;\nend;\nbegin\nread(n,m);\ni:=n+1;\nwhile not proste (i) do inc(i);\nif m=i then write('YES') else write('NO')\nend.", "src_uid": "9d52ff51d747bb59aa463b6358258865"} {"source_code": "program aaa;\nVar x,k,b,t,n:Int64;\n i:Integer;\nBegin\n Readln (k,b,n,t);\n x:=1;\n For I:=1 to n do\n Begin\n x:=x*k+b;\n If x>t\n then Begin Writeln (n-i+1);\n Halt;\n End;\n End;\n Writeln (0);\nEnd.\n", "src_uid": "e2357a1f54757bce77dce625772e4f18"} {"source_code": "var\n ss,st,pres,pret,ans:array[0..100000+5] of longint;\n i,j,k,n,m,lens,lent,p,a,b,c,d,s0,t0,s1,t1,delta,delta2:longint;\n s,t:ansistring;\n bz:boolean;\nfunction min(a,b:longint):longint;\nbegin\n if a>b then exit(b);\n exit(a);\nend;\nbegin\n // assign(input,'e.in');\n //reset(input);\n //assign(output,'e.out');\n //rewrite(output);\n readln(s);\n readln(t);\n readln(n);\n lens:=length(s);\n lent:=length(t);\n for i:=1 to lens do\n begin\n ss[i]:=ss[i-1];\n if (s[i]='B') or (s[i]='C') then\n inc(ss[i]);\n if s[i]='A' then\n pres[i]:=pres[i-1]+1;\n end;\n for i:=1 to lent do\n begin\n st[i]:=st[i-1];\n if (t[i]='B') or (t[i]='C') then\n inc(st[i]);\n if t[i]='A' then\n pret[i]:=pret[i-1]+1;\n end;\n for p:=1 to n do\n begin\n readln(a,b,c,d);\n s0:=min(pres[b],b-a+1);\n t0:=min(pret[d],d-c+1);\n s1:=ss[b]-ss[a-1];\n t1:=st[d]-st[c-1];\n delta:=t1-s1;\n delta2:=s0-t0;\n if (delta<0)or(delta mod 2<>0)or(delta2<0)or (delta2=0)and not (s1<>0)and(delta>0) then\n begin\n write(0);\n continue;\n end;\n if (s0-t0=0)or(t1-s1>0)or((s0-t0) mod 3=0) then\n write(1)\n else write(0);\n end;\n //close(input);\n //close(output);\nend.\n\n\n", "src_uid": "98e3182f047a7e7b10be7f207b219267"} {"source_code": "program aaa;\n var a,s,b,c,i,j,d,m,k,n:longint;{d:int64;s,w,q,z: string;}\n x,y,z: longint;{ p,x1,y1,x,y,t1,t2,v,z:real; {s:array[0..100009]of boolean; }\n {q:char;w:int64; {\n label 1; } f:boolean;\nbegin\n {assign(input,'input.txt');reset(input);\n assign(output,'output.txt');rewrite(output); }\n read(a,b);\n c:=a+b;\n x:=0;j:=1;\n while a>0 do\n begin\n i:=a mod 10;\n if i>0 then begin x:=x+j*i;j:=j*10;end;\n a:=a div 10;\n end; y:=0;j:=1;\n while b>0 do\n begin\n i:=b mod 10;\n if i>0 then begin y:=y+j*i;j:=j*10;end;\n b:=b div 10;\n end;\n z:=0; j:=1;\n while c>0 do\n begin\n i:=c mod 10;\n if i>0 then begin z:=z+j*i;j:=j*10;end;\n c:=c div 10;\n end;\n if x+y=z then write('YES') else write('NO');\n{ close(input);close(output); }\nend.", "src_uid": "ac6971f4feea0662d82da8e0862031ad"} {"source_code": "const\n g1:string='abcdefghijklmnopqrstuvwxyz';\nvar\n i1:char;\n s1,s2,j,i:longint;\n a,b:ansistring;\n m1,m2:array['a'..'z']of longint;\nbegin\n readln(a);\n readln(b);\n for i:=1 to length(a) do inc(m1[a[i]]);\n for i:=1 to length(b) do inc(m2[b[i]]);\n for i1:='a'to 'z'do\n begin\n if m2[i1]>m1[i1] then\n begin\n writeln('need tree');\n halt;\n end;\n if m2[i1]a[j]))do inc(j);\n end;\n if((j>length(a))or(b[length(b)]<>a[j]))then s2:=1;\n if (s1=1)and(s2=1)then\n begin\n writeln('both');\n halt;\n end;\n if s1=1 then\n begin\n writeln('automaton');\n halt;\n end;\n if s2=1 then\n begin\n writeln('array');\n halt;\n end;\nend.", "src_uid": "edb9d51e009a59a340d7d589bb335c14"} {"source_code": "var a:array[0..300,0..300,0..2]of longint;\n u,f,b,c,d,e,i,j,o:longint;\nbegin\n read(b,c,d,e);\n a[0,0,1]:=1;\n a[0,0,2]:=1;\n o:=100000000;\n for i:=0to b do\n for j:=0to c do\n for f:=1to 2do\n if f=1then\n for u:=1to d do\n a[i+u,j,2]:=(a[i+u,j,2]+a[i,j,1])mod o\n else\n for u:=1to e do\n a[i,j+u,1]:=(a[i,j+u,1]+a[i,j,2])mod o;\n write((a[b,c,1]+a[b,c,2])mod o)\nend.", "src_uid": "63aabef26fe008e4c6fc9336eb038289"} {"source_code": "program canh_toan;\n//uses math;\nconst input='VAO.INP';\n output='RA.OUT';\n maxn=trunc(25e4);\nvar n,m:qword;\n c:array [0..maxn] of qword;\n f,g:text;\n{function nhannp(x,y:qword):qword;\nvar tg:qword;\nbegin\nif (y=0) then exit(0)\nelse if (y=1) then exit(x mod m)\nelse\n begin\n tg:=nhannp(x,y div 2) mod m;\n tg:=nhannp(2,tg) mod m;\n if (y mod 2=1) then tg:=(tg+x) mod m;\n exit(tg mod m);\n end;\nend;\nfunction munp(x,y:qword):qword;\nvar tg:qword;\nbegin\nif (y=0) then exit(1)\nelse\n begin\n tg:=munp(x,y div 2) mod m;\n tg:=(nhannp(tg,tg)) mod m;\n if (y mod 2=1) then tg:=(nhannp(tg,x)) mod m;\n exit(tg mod m);\n end;\nend;}\nprocedure main();\nvar i:longint;\n x,y,z,res,ans:int64;\nbegin\n//assign(f,input);reset(f);\n//assign(g,output);rewrite(g);\nread(n,m);\nc[0]:=1;\nfor i:=1 to n do c[i]:=(c[i-1]*i) mod m;\n res:=0;\nfor i:=1 to n do\n begin\n {x:=((n-i+1) mod m);\n y:=(c[i] mod m);\n z:=(c[n-i+1] mod m);\n res:=((res mod m)+(x*y*z) mod m) mod m;}\n //res:=(res+((n-i+1)*c[n-i+1])) mod m)*c[i]) mod m;\n res:=(res+((c[n-i+1]*(n-i+1)) mod m)*c[i]) mod m;\n res:=res mod m;\n end;\n ans:=res mod m;\nwrite(ans);\n//close(f);\n//close(g);\nend;\nBEGIN\n main();\nEND.", "src_uid": "020d5dae7157d937c3f58554c9b155f9"} {"source_code": "var\nn:longint;\nbegin\nreadln(n);\nwriteln((2*n+1) div 3);\nend.", "src_uid": "a993069e35b35ae158d35d6fe166aaef"} {"source_code": "var s,s1,s2,s3:string;\n i,j:integer;\n c:char;\nbegin\n readln(s);\n s:=s+'WUB';\n\nwhile pos('WUB',s)>0 do\n begin\n if pos('WUB',s)=1 then\n delete(s,1,3)\n else\n begin\n write(copy(s,1,pos('WUB',s)-1),' ');\n delete(s,1,pos('WUB',s)-1);\n end;\n end;\n\n\n readln;\n readln;\n end.", "src_uid": "edede580da1395fe459a480f6a0a548d"} {"source_code": "\ufeffvar a: array of integer;\nfunction sum(a : int64):integer;\nvar ans:integer;\nbegin\n while (a > 0) do\n begin\n ans := ans + a mod 10;\n a := a div 10;\n end;\n sum := ans;\nend;\nbegin\n var n, first: int64;\n readln(n);\n while (first * 10 + 9 <= n) do\n begin\n first := first * 10 + 9;\n end;\n print(sum(first) + sum(n - first));\nend.", "src_uid": "5c61b4a4728070b9de49d72831cd2329"} {"source_code": "\nvar\n n,i,min,max : longint;\n a : array [1..100000] of longint;\n\n Procedure QSort(l,r : longint);\n var\n i,j,x,y : longint;\n begin\n i:=l; j:=r; x:=a[(l+r) shr 1];\n repeat\n while x>a[i] do inc(i);\n while xa[i+1]) and (a[i]<>a[i+1]) then begin writeln('YES'); exit; end;\n writeln('NO')\nend.\n", "src_uid": "ab003ab094931fc105384df9d144131e"} {"source_code": "program c;\nconst\n infile='c.in';\n outfile='c.out';\nvar\n r,h,ans,x:longint;\nbegin\n {assign(input,infile);\n reset(input);\n assign(output,outfile);\n rewrite(output); }\n\n readln(r,h);\n x:=h div r;\n h:=h mod r;\n if h=r/2) and (h=r*sqrt(3)/2) and (h0)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 good:boolean; var i,j,k:longint; fl:boolean;\n begin\n for i:=1 to n do d1[i]:=d[d[i]];\n fl:=true;\n for i:=1 to n do if d1[i]<>d[i] then fl:=false;\n good:=fl;\n\n end;\n\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n readln(n); for i:=1 to n do read(a[i]);\n for i:=1 to n do d[i]:=a[i];\n\n if good then begin write(1); goto 1; end;\n for step:= 1 to 1000 do\n begin\n\n for i:=1 to n do c[i]:=a[d[i]];\n for i:=1 to n do d[i]:=c[i];\n\n { for i:=1 to n do write(d[i],' '); writeln;\n } if good then begin writeln(step+1); goto 1; end;\n\n end;\n3:\n\n for start:=1 to n do\n begin\n for i:=1 to n do zan[i]:=false;\n for i:=1 to n do c[i]:=0;\n\n q:=0; pos:=start;\n if a[pos]=pos then begin period:=0; goto 2; end;\n repeat\n oldpos:=pos;\n inc(q); pos:=a[pos]; zan[pos]:=true; c[pos]:=q;\n period:=q-c[a[pos]];\n until zan[a[pos]];\n\n\n\n 2:\n { writeln(start,' ',period,' ',q) ;\n } per[start]:=period+1;\n zah[start]:=q;\n\n\n end;\n\n { for i:=1 to n do writeln(i,' ',per[i],' ',zah[i]);\n } for i:=1 to n do maxzah:=max(maxzah,zah[i]);\n ot:=per[1];\n for i:=1 to n do\n begin\n t:=nod(ot,per[i]);\n ot:=(ot*per[i]) div t;\n { writeln(i,' ',ot); }\n end;\n p:=ot;\n if ot>=maxzah-ot then begin write(ot); goto 1; end;\n repeat ot:=ot+p until ot+p>=maxzah;\n writeln(ot);\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n", "src_uid": "1daa784c0eb1cde514e4319da07c8d00"} {"source_code": "var q,k,s,x1,x2,t1,t2,p,d:longint;\nbegin\n readln(s,x1,x2);\n readln(t1,t2);\n readln(p,d);\n\n q:=abs(x1-x2)*t2;\n if t2 < t1 then begin writeln(q); exit; end;\n\n if (d = -1) and (p < x1) then begin d:=1; k:=p*t1 + x1*t1; end\n else if (d = 1) and (p > x1) then begin d:=-1; k:=(s-p)*t1 + (s-x1)*t1; end\n else k:=abs(p-x1)*t1;\n\n if (x1 > x2) and (d = 1) then k:=k + (s-x1)*t1 + (s-x2)*t1\n else if (x1 < x2) and (d = -1) then k:=k + x1*t1 + x2*t1\n else k:=k + abs(x1-x2)*t1;\n\n if k < q then writeln(k) else writeln(q);\n\nend.\n\n\n\n", "src_uid": "fb3aca6eba3a952e9d5736c5d8566821"} {"source_code": "\ufefflabel 1,2,3;\nvar x,y,x1,y1,i,j,k,o,o1:integer;ch:string;a,a1:char;b2:array[1..100,1..100]of longint;\nb:array[1..8]of char:=('a','b','c','d','e','f','g','h');\nb1:array[1..8]of longint;begin for i:=1 to 8 do b1[i]:=i;\nreadln(a,x);readln(a1,x1);x:=9-x;x1:=9-x1;\nfor i:=1 to 8 do begin if b[i]=a then y:=b1[i];if b[i]=a1 then y1:=b1[i];end;\nb2[x,y]:=1;k:=1;o:=1;\n3:for i:=1 to 8 do\nfor j:=1 to 8 do\nif b2[i,j]=k then begin\nif (j<8)and(b2[i,j+1]=0)then begin b2[i,j+1]:=k+1;inc(o1);end;\nif (i<8)and(j<8)and(b2[i+1,j+1]=0)then begin b2[i+1,j+1]:=k+1;inc(o1);end;\nif (i<8)and(b2[i+1,j]=0)then begin b2[i+1,j]:=k+1;inc(o1);end;\nif (i>1)and(j<8)and(b2[i-1,j+1]=0)then begin b2[i-1,j+1]:=k+1;inc(o1);end;\nif (i>1)and(b2[i-1,j]=0)then begin b2[i-1,j]:=k+1;inc(o1);end;\nif (i>1)and(j>1)and(b2[i-1,j-1]=0)then begin b2[i-1,j-1]:=k+1;inc(o1);end; \nif (j>1)and(b2[i,j-1]=0)then begin b2[i,j-1]:=k+1;inc(o1);end;\nif (i<8)and(j>1)and(b2[i+1,j-1]=0)then begin b2[i+1,j-1]:=k+1;inc(o1);end;\ndec(o);if o=0 then goto 1;if b2[x1,y1]<>0 then begin writeln(b2[x1,y1]-1);k:=b2[x1,y1];goto 2;end;end;\n1:if o1>0 then begin o:=o1;o1:=0;inc(k);goto 3;end;\n2:if(k>1)and(x1>1)and(b2[x1-1,y1]=k-1)then begin ch:='D '+ch;dec(k);dec(x1);goto 2;end;\nif(k>1)and(y1>1)and(b2[x1,y1-1]=k-1)then begin ch:='R '+ch;dec(k);dec(y1);goto 2;end;\nif(k>1)and(x1>1)and(y1>1)and(b2[x1-1,y1-1]=k-1)then begin ch:='RD '+ch;dec(k);dec(x1);dec(y1);goto 2;end;\nif(k>1)and(x1>1)and(y1<8)and(b2[x1-1,y1+1]=k-1)then begin ch:='LD '+ch;dec(k);dec(x1);inc(y1);goto 2;end;\nif(k>1)and(x1<8)and(b2[x1+1,y1]=k-1)then begin ch:='U '+ch;dec(k);inc(x1);goto 2;end;\nif(k>1)and(x1<8)and(y1<8)and(b2[x1+1,y1+1]=k-1)then begin ch:='LU '+ch;dec(k);inc(x1);inc(y1);goto 2;end;\nif(k>1)and(y1<8)and(b2[x1,y1+1]=k-1)then begin ch:='L '+ch;dec(k);inc(y1);goto 2;end;\nif (k>1)and(x1<8)and(y1>1)and(b2[x1+1,y1-1]=k-1)then begin ch:='RU '+ch;dec(k);inc(x1);dec(y1);goto 2;end;\n\nfor i:=1 to length(ch) do\nif ch[i]=' ' then writeln else write(ch[i]);\nend.\n{\n\u041e\u0434\u0438\u043d\u043e\u043a\u0438\u0439 \u043a\u043e\u0440\u043e\u043b\u044c \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u0441\u043e\u0432\u0441\u0435\u043c \u043e\u0434\u0438\u043d \u043d\u0430 \u0448\u0430\u0445\u043c\u0430\u0442\u043d\u043e\u0439 \u0434\u043e\u0441\u043a\u0435. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043e\u0434\u0438\u043d\u043e\u0447\u0435\u0441\u0442\u0432\u043e, \u043e\u043d \u0432\u043e\u0432\u0441\u0435 \u043d\u0435 \u0443\u043d\u044b\u0432\u0430\u0435\u0442 \u2014 \u0432\u0435\u0434\u044c \u0435\u043c\u0443 \u0435\u0449\u0435 \u043d\u0430\u0434\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0434\u0435\u043b \u0433\u043e\u0441\u0443\u0434\u0430\u0440\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0432\u0430\u0436\u043d\u043e\u0441\u0442\u0438. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u043c\u0443 \u043d\u0430\u0434\u043e \u0441\u043e\u0432\u0435\u0440\u0448\u0438\u0442\u044c \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0432\u0438\u0437\u0438\u0442 \u0432 \u043a\u043b\u0435\u0442\u043a\u0443 t. \u0422\u0430\u043a \u043a\u0430\u043a \u043a\u043e\u0440\u043e\u043b\u044c \u043d\u0435 \u043f\u0440\u0438\u0432\u044b\u043a \u0442\u0435\u0440\u044f\u0442\u044c \u043f\u043e\u043f\u0443\u0441\u0442\u0443 \u0432\u0440\u0435\u043c\u044f, \u043e\u043d \u0445\u043e\u0447\u0435\u0442 \u0434\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u0441\u0432\u043e\u0435\u0433\u043e \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f s \u0434\u043e \u043a\u043b\u0435\u0442\u043a\u0438 t \u0437\u0430 \u043d\u0430\u0438\u043c\u0435\u043d\u044c\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u0445\u043e\u0434\u043e\u0432. \u041f\u043e\u043c\u043e\u0433\u0438\u0442\u0435 \u0435\u043c\u0443 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c.\n\n\n\u041a\u043e\u0440\u043e\u043b\u044c \u0437\u0430 \u043e\u0434\u0438\u043d \u0445\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c\u0441\u044f \u043d\u0430 \u043b\u044e\u0431\u0443\u044e \u043a\u043b\u0435\u0442\u043a\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u0435 \u0438\u043b\u0438 \u0443\u0433\u043b\u0443 \u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442 \u0441 \u0442\u0435\u043a\u0443\u0449\u0435\u0439 (\u0438\u0445 \u0432 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 8).\n\n\u0412\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\u0412 \u043f\u0435\u0440\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u043d\u044b \u0448\u0430\u0445\u043c\u0430\u0442\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043a\u043b\u0435\u0442\u043a\u0438 s, \u0430 \u0432\u043e \u0432\u0442\u043e\u0440\u043e\u0439 \u2014 \u043a\u043b\u0435\u0442\u043a\u0438 t.\n\n\u0428\u0430\u0445\u043c\u0430\u0442\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u0441\u043e\u0441\u0442\u043e\u044f\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u043e\u0434\u0438\u043d \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044d\u0442\u043e \u0441\u0442\u0440\u043e\u0447\u043d\u0430\u044f \u0431\u0443\u043a\u0432\u0430 \u043b\u0430\u0442\u0438\u043d\u0441\u043a\u043e\u0433\u043e \u0430\u043b\u0444\u0430\u0432\u0438\u0442\u0430 (\u043e\u0442 a \u0434\u043e h), \u0430 \u0432\u0442\u043e\u0440\u043e\u0439 \u2014 \u0446\u0438\u0444\u0440\u0430 \u043e\u0442 1 \u0434\u043e 8.\n\n\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\n\u0412 \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u0432\u044b\u0432\u0435\u0434\u0438\u0442\u0435 n \u2014 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0447\u0438\u0441\u043b\u043e \u0445\u043e\u0434\u043e\u0432 \u043a\u043e\u0440\u043e\u043b\u044f. \u0414\u0430\u043b\u0435\u0435 \u0432 n \u0441\u0442\u0440\u043e\u043a \u0432\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u0441\u0430\u043c\u0438 \u0445\u043e\u0434\u044b. \u041a\u0430\u0436\u0434\u044b\u0439 \u0445\u043e\u0434 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0432\u043e\u0441\u044c\u043c\u0438 \u0441\u0442\u0440\u043e\u043a: L, R, U, D, LU, LD, RU \u0438\u043b\u0438 RD.\n\nL, R, U, D, \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u043e\u0437\u043d\u0430\u0447\u0430\u044e\u0442 \u0445\u043e\u0434\u044b \u0432\u043b\u0435\u0432\u043e, \u0432\u043f\u0440\u0430\u0432\u043e, \u0432\u0432\u0435\u0440\u0445 \u0438 \u0432\u043d\u0438\u0437 (\u0441\u043e\u0433\u043b\u0430\u0441\u043d\u043e \u0440\u0438\u0441\u0443\u043d\u043a\u0443), \u0434\u0432\u0443\u0445\u0431\u0443\u043a\u0432\u0435\u043d\u043d\u044b\u0435 \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0434\u0438\u0430\u0433\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u0445\u043e\u0434\u0430\u043c. \u0415\u0441\u043b\u0438 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e, \u0432\u044b\u0432\u0435\u0434\u0438\u0442\u0435 \u043b\u044e\u0431\u043e\u0435.\n\n\u041f\u0440\u0438\u043c\u0435\u0440\u044b\n\u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c\na8\nh1\n\u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435\u0421\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c\n7\nRD\nRD\nRD\nRD\nRD\nRD\nRD\n}\n", "src_uid": "d25d454702b7755297a7a8e1f6f36ab9"} {"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 dplus,dminus,d1plus,d1minus,d2plus,d2minus,d1,d2,aold,b,a,x,y:array[-10..200000] of int64;\n dda:array[-10..1200,-10..1200] of int64;\n zan,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{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 for i:=n downto 1 do\n begin\n {d1plus[i]:=a[i]+min(d2plus[i+1],d2minus[i+1]);\n d1minus[i]:=d1minus[i+1];\n\n d2plus[i]:=a[i]+max(d1plus[i+1],d1minus[i+1]);\n d2minus[i]:=d2minus[i+1];\n }\n\n dplus[i]:=a[i]+min(dplus[i+1],dminus[i+1]);\n dminus[i]:=max(dplus[i+1],dminus[i+1]);\n\n\n end;\n\n writeln(min(dplus[1],dminus[1]),' ',max(dplus[1],dminus[1]));\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n", "src_uid": "414540223db9d4cfcec6a973179a0216"} {"source_code": "var n ,i,j,d,x:integer;\na:array[1..10000]of integer;\nbegin\nreadln(n);\nfor i:=1 to n do read(a[i]);\nfor i:=1 to n do for j:=1 to n do if a[i]0) then begin write(x,' ',a[i]); exit end;\nend.", "src_uid": "868407df0a93085057d06367aecaf9be"} {"source_code": "program _73F_PlaneOfTanks;\n\nuses math;\n\nconst eps=1e-6;\n\ttiny=1e-8;\n\tmaxn=10050;\n\nvar tank:array[1..maxn]of record x,y,a,w:extended;end;\n\tn,k,i:longint;\n\tmid,high,low,ll,v,tAB,ax,ay,bx,by:extended;\n\nfunction dis(ax,ay,bx,by:extended):extended;\nbegin\n\texit(sqrt(sqr(ax-bx)+sqr(ay-by)));\nend;\n\nfunction multi(ax,ay,bx,by:extended):extended;\nbegin\n\texit(ax*by-ay*bx);\nend;\n\nfunction angleto(alpha,tx,ty,x,y:extended):extended;\nvar theta:extended;\nbegin\n\ttheta:=arctan2(y-ty,x-tx)-alpha;\n\twhile theta<0 do theta:=theta+2*PI;\n\twhile theta>2*PI do theta:=theta-2*PI;\n\tif 2*PI-thetat1 then exit(false);\n\tmii:=multi(ax-tx,ay-ty,bx-tx,by-ty);\n\tif mii>0 then wise:=1 else wise:=-1;\n\td:=mii/ll;\n\tgx:=-(ay-by);\n\tgy:=ax-bx;\n\tgll:=sqrt(sqr(gx)+sqr(gy));\n\tpx:=tx+gx*(d/gll);\n\tpy:=ty+gy*(d/gll);\n\tlPA:=dis(px,py,ax,ay);\n\tlPB:=dis(px,py,bx,by);\n\tt3:=angleto(alpha,tx,ty,px,py)/w;\n if t1n div i then begin inc (k); q[k]:=n div i; end;\n end;\n end;\n min:=10000000000000000000;\n max:=0;\n for i:=1 to k do\n for j:=1 to k do\n if (q[i]*q[j]<=n) and (n mod (q[i]*q[j])=0) then begin\n a:=q[i]+1;\n b:=q[j]+2;\n c:=n div (q[i]*q[j])+2;\n if a*b*c>max then max:=a*b*c;\n if a*b*cx) then\n begin\n a:=min(b+c-1,x);\n inc(res);\n if a=x then inc(dem);\n end;\n if (b<=a) and (b<=c) and (b<>x) then\n begin\n b:=min(a+c-1,x);\n inc(res);\n if b=x then inc(dem);\n end;\n if (c<=b) and (c<=a) and (c<>x) then\n begin\n c:=min(a+b-1,x);\n inc(res);\n if c=x then inc(dem);\n end;\n end;\n writeln(res);\n end;\n\nbegin\n openfiles;\n readln(Fi,x,y);\n solve;\n closefiles;\nend.", "src_uid": "8edf64f5838b19f9a8b19a14977f5615"} {"source_code": "uses\n math;\n\ntype\n tr = record\n x,y:longint;\n end;\n\nvar\n a,c:array[0..20] of tr;\n i,j,n,m,mask,ans,res,pos:longint;\n \nBegin\n read(n,m);\n for i:=1 to n do\n read(a[i].x,a[i].y);\n ans:=maxlongint;\n for mask:=0 to (1 shl n) - 1 do\n begin\n res:=0; c:=a;\n for j:=1 to n do\n if (mask and (1 shl (j-1))) > 0 then\n begin\n inc(res, a[j].y);\n inc(c[n+1].x);\n end\n else\n inc(c[j].x);\n pos:=0;\n for i:=1 to n do\n if (c[i].x > c[n+1].x) or \n ((c[i].x = c[n+1].x) and (mask and (1 shl (i-1)) = 0)) then\n inc(pos);\n if pos < m then\n ans:=min(ans, res);\n end;\n if ans = maxlongint then\n writeln(-1)\n else\n writeln(ans);\nend.\n", "src_uid": "19a098cef100fc3652c59abf7c373814"} {"source_code": "Uses sysutils, math;\nvar\ni:longint;\nn,k,l,p,s,nn,d:int64;\nbegin\nreadln(n,k);\nl:=1;\nfor i:=1 to k do\nl:=l*10;\nif n mod l=0 then write(n)\nelse begin \nnn:=n; p:=0; d:=0;\nwhile nn mod 5=0 do\nbegin inc(p);\nnn:=nn div 5; end;\nwhile nn mod 2=0 do\nbegin nn:=nn div 2;\ninc(d); end;\nif min(d,p)=a[1]) and (a[i]>max) then\n begin\n ok:=true;\n max:=a[i];\n imax:=i;\n end;\n if not ok then break;\n dec(a[imax]);\n inc(a[1]);\n inc(kq);\n until false;\nend;\n{---------------------}\nprocedure ghi;\nbegin\n writeln(kq);\nend;\n{---------------------}\nprocedure dong;\nbegin\n close(input);\n close(output);\nend;\n{---------------------}\nbegin\n mo;\n doc;\n xuli;\n ghi;\n dong;\nend.\n\n", "src_uid": "aa8fabf7c817dfd3d585b96a07bb7f58"} {"source_code": "var\n a,b,d,i : longint;\n z : boolean;\nbegin\n readln(a,b);\n {z := true;\n if a=b then}\n if (ab) and (2*b0) and (b>=2) then\n begin\n a := a-1;\n b := b-2;\n d := d+1;\n end\n else if ((i mod 2)=1) and (a>=2) and (b>0) then\n begin\n a := a-2;\n b := b-1;\n d := d+1;\n end;\n if ((a<=1) and (b<=1)) or (a=0) or (b=0) then\n z := false;\n i := i+1;\n end;\n end\n else if a>b then\n begin\n while z do\n begin\n if ((i mod 2)=0) and (b>0) and (a>=2) then\n begin\n b := b-1;\n a := a-2;\n d := d+1;\n end\n else if ((i mod 2)=1) and (b>=2) and (a>0) then\n begin\n b := b-2;\n a := a-1;\n d := d+1;\n end;\n if (a<=1) and (b<=1) then\n z := false;\n i := i+1;\n end;\n end; }\n writeln(d);\n readln\nend.", "src_uid": "0718c6afe52cd232a5e942052527f31b"} {"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\nvar p,r0,r1,r2,qq,cc,a,aa:array[0..100]of 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,q0,c0,q1,c1,q2,c2,q3,c3:int64;\n k,n,m,nn,mm,kk,u,v,res,cur,max,min,q,c:int64;\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 t2 then swap;\n t1:=t0 - t1;\n t2:=t0 - t2;\n time:=size*t0 - time;\n if time <= 0 then\n begin\n write(0);\n halt;\n end;\n i:=-1;\n kq:=high(int64);\n if t1 >= 0 then\n repeat\n inc(i);\n if a1*i >= size then\n begin\n if size*t1 >= time then kq:=min(kq , i*p1);\n break;\n end;\n if a1*i*t1 + max(0,max(0,size-a1*i)*t2) < time then continue;\n if (time - a1*i*t1 <= 0) or (t2*a2 <= 0) then o:=0\n else\n begin\n o:=(time - a1*i*t1) div (t2*a2);\n if (time - a1*i*t1) mod (t2*a2) <> 0 then inc(o);\n end;\n w:=i*p1 + o*p2;\n if w = 8393 then writeln(i,' ',a1);\n kq:=min(kq , w);\n until a1*i >= size;\n //writeln(i,' ',a1*i,' ',size);\n if kq = high(int64) then kq:=-1;\n write(kq);\nend.\n", "src_uid": "f5f85e75af5b0f25f1f436a21e12fad1"} {"source_code": "var \n k2, k3, k5, k6: uint64;\n m, s: uint64;\n \nfunction min(a, b: uint64):uint64;\nbegin\n if a < b then\n min := a\n else\n min := b;\nend;\n\nbegin\n readln(k2, k3, k5, k6);\n m := min(k5, k6);\n m := min(k2, m);\n s := m * 256;\n k2 := k2 - m;\n k5 := k5 - m;\n k6 := k6 - m;\n m := min(k3, k2);\n s := s + m * 32;\n write(s);\nend.", "src_uid": "082b31cc156a7ba1e0a982f07ecc207e"} {"source_code": "var n,s,k:int64;\na,b,c:double;\ni:integer;\nbegin\nread(n);\nk:=5;\ns:=1;\nfor i:=n downto n-k+1 do\n s:=s*i*i div (n-i+1);\nwrite(s);\nend.", "src_uid": "92db14325cd8aee06b502c12d2e3dd81"} {"source_code": "var a:array[1..26]of longint;\nn,i,dop:longint;\nkol: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]>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 ll do\n begin\n w:=s[x];r:=0;\n for j:=x+1 to min(l,x+k) do\n if s[j]>w then begin r:=j; w:=s[j]; end;\n if w=s[x] then inc(x)\n else\n begin\n k:=k-r+x;\n go(r,x+1);\n inc(x);\n end;\n end;\n for j:=1 to l do\n write(s[j]);\nend.", "src_uid": "e56f6c343167745821f0b18dcf0d0cde"} {"source_code": "var dp:array [0..13,0..1000] of int64;\n p:array [1..13] of int64;\n q,w,e,r,n:int64;\n i,j,l:longint;\n st,inf:extended;\n begin\n read(n);\n p[1]:=2; p[2]:=3; p[3]:=5; p[4]:=7; p[5]:=11;\n p[6]:=13; p[7]:=17; p[8]:=19; p[9]:=23; p[10]:=29;\n p[11]:=31; p[12]:=37;\n q:=1;\n inf:=round(1e18);\n q:=round(inf);\n for i:=0 to 12 do\n for j:=0 to n do\n dp[i][j]:=round(inf);\n dp[0][1]:=1;\n for i:=1 to 12 do\n begin\n dp[i][1]:=1;\n l:=1;\n for j:=1 to n do\n begin\n st:=1;\n for l:=1 to 63 do\n begin\n\n st:=st*p[i];\n if (st>inf) then break;\n if (j mod (l+1)) =0 then\n begin\n if (dp[i-1][j div (l+1)]*st<=inf) then\n begin\n if (dp[i-1][j div (l+1)]*st 0) and (date.y < 100) then begin\n if (date.m > 0) and (date.m < 13) then begin\n if date.y mod 4 = 0 then begin\n if (date.d > 0) and (date.d <= month[1][date.m]) then\n is_correct := true else is_correct := false;\n end else\n if (date.d > 0) and (date.d <= month[0][date.m]) then\n is_correct := true else is_correct := false;\n end;\n end;\nend;\n\nfunction is_date_ok(date : ttype) : boolean;\nbegin\n is_date_ok := false;\n date.y := date.y + 18;\n if date.y < date2.y then\n result := true else \n if date.y = date2.y then \n if date.m < date2.m then\n result := true else begin\n if date.m = date2.m then\n if date.d <= date2.d then\n result := true;\n end;\nend;\nprocedure is_go(var date : ttype; k : int);\nbegin\n if k = 1 then\n swap(date.d, date.m);\n if k = 2 then\n swap(date.d, date.y);\n if k = 3 then\n swap(date.m, date.y);\n if k = 4 then\n swap(date.m, date.d);\n if k = 5 then\n swap(date.y, date.d);\n if k = 6 then\n swap(date.y, date.m);\n\nend;\n\nbegin\n \n readln(s1);\n readln(s2);\n date1 := decode(s2);\n date2 := decode(s1);\n k := 0;\n while k <= 6 do begin\n if is_correct(date1) then begin\n if is_date_ok(date1) then begin\n writeln('YES');\n exit;\n end else begin\n inc(k);\n is_go(date1, k);\n end;\n end else begin\n inc(k);\n is_go(date1, k);\n end;\n end;\n writeln('NO');\n \nend.\n", "src_uid": "5418c98fe362909f7b28f95225837d33"} {"source_code": "var\n n,i,x,ans:longint;\n\nbegin {main}\n readln(n);\n if n=0 then begin writeln(1);halt;end;\n ans:=2*n;\n for i:=1 to n do\n begin\n x:=trunc(sqrt(int64(n)*int64(n)-int64(i)*int64(i)));\n if int64(i+1)*int64(i+1)+int64(x)*int64(x)>int64(n)*int64(n) then dec(ans);\n end;\n writeln(ans*4);\nend.\n", "src_uid": "d87ce09acb8401e910ca6ef3529566f4"} {"source_code": "program test;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s: string;\n n, k, i, g, t: integer;\n\nbegin\n readln(n, k);\n readln(s);\n g := pos('G', s);\n t := pos('T', s);\n if (g > t) then begin\n i := g - k;\n while (i > 0) and (s[i] = '.') do\n dec(i, k);\n if (s[i] = 'T') then\n writeln('YES')\n else\n writeln('NO');\n end\n else begin\n i := g + k;\n while (i > 0) and (s[i] = '.') do\n inc(i, k);\n if (s[i] = 'T') then\n writeln('YES')\n else\n writeln('NO');\n end;\n readln;\nend.\n", "src_uid": "189a9b5ce669bdb04b9d371d74a5dd41"} {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n buffer: string;\n n: Integer;\n m: array of integer;\n max,focus,radius: integer;\nbegin\n read (max,focus,radius);\n setLength(m,max);\n for n:=0 to high(m) do m[n] := n+1;\n for n:=0 to high(m) do if m[n] = focus then Break;\n if focus-radius>1 then buffer:='<< ';\n if focus-radius>0 then begin n:=n-radius end\n else n := 0;\n while m[n] < focus do begin buffer:=buffer+inttostr(m[n])+' '; inc(n) end;\n buffer:=buffer+'('+inttostr(m[n])+')';\n while (m[n] < focus+radius) and (m[n] < max) do\n begin inc(n); buffer:=buffer+' '+inttostr(m[n]); end;\n if m[n] < max then buffer:=buffer+' >>';\n Writeln(buffer);\n Readln;\n Readln;\nend.\n", "src_uid": "526e2cce272e42a3220e33149b1c9c84"} {"source_code": "Program TigaTujuhTigaB;\n\nvar\n\tw,m,k,c : int64;\n\ti,digit : longint;\n\ttemp : string;\n\t\nfunction pangkat(a,b : int64): int64;\nvar\n\ttemp : real;\nbegin\n\ttemp := exp(b * ln(a));\n\tpangkat := trunc(temp);\nend;\n\t\t\nbegin\n\treadln(w,m,k); c:= 0;\n\tstr(m,temp);\n\tdigit := length(temp);\n\tfor i:=digit to 19 do\n\tbegin\n\t\tif((i=digit)and(w div (k*i) <= pangkat(10,i)-m)) then\n\t\tbegin\n\t\t\twriteln(w div (k*i)); \n\t\t\thalt(0);\n\t\tend else if ((i=digit) and(w div (k*i)> pangkat(10,i)-m)) then\n\t\tbegin\n\t\t\tc := (pangkat(10,digit)-m);\n\t\t\tw := w - c*k*digit;\n\t\tend else if (w > (pangkat(10,i-1)*9*k*i)) then\n\t\tbegin\n\t\t\tc := c + pangkat(10,i-1)*9;\n\t\t\tw := w - pangkat(10,i-1)*9*k*i;\n\t\tend else if (w <= (pangkat(10,i-1)*9*k*i)) then\n\t\tbegin\n\t\t\tc := c + w div (i*k);\n\t\t\twriteln(c); halt(0);\t\t\t\n\t\tend;\n\tend;\nend.", "src_uid": "8ef8a09e33d38a2d7f023316bc38b6ea"} {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n s, result: string;\n n, i: integer;\nbegin\n n := 1;\n result := 'NO';\n readln(s);\n for i := 2 to length(s) do begin\n if s[i] = s[i - 1] then n := n + 1 else n := 1;\n if n = 7 then begin\n result := 'YES';\n break;\n end;\n end;\n writeln(result);\nend.\n ", "src_uid": "ed9a763362abc6ed40356731f1036b38"} {"source_code": "var n,k,s,i:longint;\nbegin\n readln(n,k);\n s:=0;\n for i:=1 to n do\n begin\n s:=s+i;\n if i+s-k-n=0 then break;\n end;\n writeln(s-k);\n readln;\nend.", "src_uid": "17b5ec1c6263ef63c668c2b903db1d77"} {"source_code": "var\n s : ansistring;\n i,j,n,m,k : longint;\n c : char;\n\nbegin\n for i:=1 to 8 do begin\n readln(s);\n c:='q';\n for j:=1 to 8 do begin\n if s[j] = c then begin writeln('NO'); halt; end;\n c:=s[j];\n end;\n end;\n writeln('YES');\nend.", "src_uid": "ca65e023be092b2ce25599f52acc1a67"} {"source_code": "program problem5;\nuses math, dos;\n\ntype\ttEdge =\trecord\n\t\t\t\t\tv, next: longInt;\n\t\t\t\tend;\n\t\ttTree =\trecord\n\t\t\t\t\tn, timer: longInt;\n\t\t\t\t\tfirst, size, depth, inTime, vertex: array[ 1..200000 ] of longInt;\n\t\t\t\t\tLCA_RMQ: array[ 1..200000, 0..20 ] of longInt;\n\t\t\t\t\ts, sumDown, sumUp: array[ 1..100000 ] of int64;\n\t\t\t\t\te: array[ 1..200000 ] of tEdge;\n\t\t\t\t\tinsideDistanceSum, maxS: int64;\n\t\t\t\tend;\n\t\t\t\t\nvar\tmax2pow: array[ 1..200000 ] of longInt;\n\nprocedure qsort( var t: tTree; l, r: longInt );\nvar\ti, j, tmp: longInt;\n\tmed: int64;\nbegin\n\tif ( l < r ) then\n\tbegin\n\t\twith t do\n\t\tbegin\n\t\t\ti := l;\n\t\t\tj := r;\n\t\t\tmed := s[ vertex[ l + random(r - l + 1) ] ];\n\t\t\twhile ( i <= j ) do\n\t\t\tbegin\n\t\t\t\twhile ( s[ vertex[i] ] > med ) do\n\t\t\t\t\tinc( i );\n\t\t\t\twhile ( s[ vertex[j] ] < med ) do\n\t\t\t\t\tdec( j );\n\t\t\t\t\n\t\t\t\tif ( i <= j ) then\n\t\t\t\tbegin\n\t\t\t\t\ttmp := vertex[i];\n\t\t\t\t\tvertex[i] := vertex[j];\n\t\t\t\t\tvertex[j] := tmp;\n\t\t\t\t\t\n\t\t\t\t\tinc( i );\n\t\t\t\t\tdec( j );\n\t\t\t\tend;\n\t\t\tend;\n\t\t\t\n\t\t\tqsort( t, l, j );\n\t\t\tqsort( t, i, r );\n\t\tend;\n\tend;\nend;\n\t\t\t\t\nprocedure readEdges( var t: tTree );\nvar\ti, ee, u, v: longInt;\nbegin\n\twith t do\n\tbegin\n\t\tfillchar( first, sizeOf(first), 0 );\n\t\t\n\t\tee := 0;\n\t\tfor i := 2 to n do\n\t\tbegin\n\t\t\treadln( u, v );\n\t\t\t\n\t\t\tinc( ee );\n\t\t\te[ee].v := v;\n\t\t\te[ee].next := first[u];\n\t\t\tfirst[u] := ee;\n\t\t\t\n\t\t\tinc( ee );\n\t\t\te[ee].v := u;\n\t\t\te[ee].next := first[v];\n\t\t\tfirst[v] := ee;\n\t\tend;\n\tend;\nend;\n\nprocedure DFS( var t: tTree; v, p: longInt );\nvar\ti: longInt;\nbegin\n\twith t do\n\tbegin\n\t\tsize[v] := 1;\n\t\tsumDown[v] := 0;\n\t\t\n\t\ti := first[v];\n\t\twhile ( i > 0 ) do\n\t\tbegin\n\t\t\tif ( e[i].v <> p ) then\n\t\t\tbegin\n\t\t\t\tDFS( t, e[i].v, v );\n\t\t\t\t\n\t\t\t\tinc( size[v], size[ e[i].v ] );\n\t\t\t\tinc( sumDown[v], sumDown[ e[i].v ] + size[ e[i].v ] );\n\t\t\tend;\n\t\t\n\t\t\ti := e[i].next;\n\t\tend;\n\tend;\nend;\n\nprocedure DFS2( var t: tTree; v, p: longInt );\nvar\ti: longInt;\nbegin\n\twith t do\n\tbegin\n\t\tinc( timer );\n\t\tvertex[timer] := v;\n\t\tinTime[v] := timer;\n\t\n\t\tif ( p = 0 ) then\n\t\tbegin\n\t\t\tsumUp[v] := 0;\n\t\t\tdepth[v] := 0;\n\t\tend\n\t\telse\n\t\tbegin\n\t\t\tsumUp[v] := n - size[v] + sumUp[p] + sumDown[p] - sumDown[v] - size[v];\n\t\t\tdepth[v] := depth[p] + 1;\n\t\tend;\n\t\t\t\n\t\ti := first[v];\n\t\twhile ( i > 0 ) do\n\t\tbegin\n\t\t\tif ( e[i].v <> p ) then\n\t\t\tbegin\n\t\t\t\tDFS2( t, e[i].v, v );\n\t\t\t\t\n\t\t\t\tinc( timer );\n\t\t\t\tvertex[timer] := v;\n\t\t\tend;\n\t\t\n\t\t\ti := e[i].next;\n\t\tend;\n\tend;\nend;\n\nfunction minVertex( const t: tTree; u, v: longInt ): longInt;\nbegin\n\tif ( t.depth[u] < t.depth[v] ) then\n\t\texit( u )\n\telse\n\t\texit( v );\nend;\n\nprocedure initLCA( var t: tTree );\nvar\ti, j: longInt;\nbegin\n\twith t do\n\tbegin\n\t\tmax2pow[1] := 0;\n\t\tfor i := 2 to timer do\n\t\tbegin\n\t\t\tmax2pow[i] := max2pow[i - 1];\n\t\t\tif ( i = 2 shl max2pow[i] ) then\n\t\t\t\tinc( max2pow[i] );\n\t\tend;\n\t\t\n\t\tfor i := 1 to timer do\n\t\t\tLCA_RMQ[i][0] := vertex[i];\n\t\t\n\t\tfor j := 0 to 19 do\n\t\t\tfor i := 1 to timer - (2 shl j) + 1 do\n\t\t\t\tLCA_RMQ[i][j + 1] := minVertex( t, LCA_RMQ[i][j], LCA_RMQ[ i + (1 shl j) ][j] );\n\tend;\nend;\n\nfunction LCA( const t: tTree; u, v: longInt ): longInt;\nvar\tp, l, r: longInt;\nbegin\n\twith t do\n\tbegin\n\t\tl := min( inTime[u], inTime[v] );\n\t\tr := max( inTime[u], inTime[v] );\n\n\t\tp := max2pow[r - l + 1];\n\t\t\n\t\tp := minVertex( t, LCA_RMQ[l][p], LCA_RMQ[ r - (1 shl p) + 1 ][p] );\n\tend;\n\t\n\texit( p );\nend;\n\nfunction distance( const t: tTree; u, v: longInt ): longInt;\nvar\tw: longInt;\nbegin\n\tw := LCA( t, u, v );\n\t\n\texit( t.depth[u] + t.depth[v] - 2 * t.depth[w] );\nend;\n\nprocedure preprocess( var t: tTree );\nvar\ti: longInt;\nbegin\n\tt.timer := 0;\n\n\tDFS( t, 1, 0 );\n\tDFS2( t, 1, 0 );\n\t\n\tinitLCA( t );\n\t\n\twith t do\n\tbegin\n\t\tinsideDistanceSum := 0;\n\t\tmaxS := 0;\n\t\t\n\t\tfor i := 1 to n do\n\t\tbegin\n\t\t\ts[i] := sumDown[i] + sumUp[i];\n\t\t\t\n\t\t\tinc( insideDistanceSum, s[i] );\n\t\t\tmaxS := max( maxS, s[i] );\n\t\tend;\n\t\t\n\t\tinsideDistanceSum := insideDistanceSum div 2;\n\tend;\nend;\n\nfunction solveOne( const t: tTree; nn: longInt ): int64;\nbegin\n\texit( t.maxS * nn + t.insideDistanceSum );\nend;\n\nfunction solveTwo( var t: tTree; n1, n2: longInt ): int64;\nvar\ti, j: longInt;\n\tres, nn, endTime: int64;\nbegin\n\tendTime := getMsCount() + 850;\n\n\tif ( n1 < n2 ) then\n\tbegin\n\t\ti := n1;\n\t\tn1 := n2;\n\t\tn2 := i;\n\tend;\n\t\n\tnn := n1 * int64(n2);\n\n\twith t do\n\tbegin\n\t\tres := 0;\n\t\t\n\t\tfor i := 1 to n do\n\t\t\tvertex[i] := i;\n\t\t\n\t\tqsort( t, 1, n );\n\t\t\n\t\ti := 1;\n\t\twhile ( i <= n ) and ( getMsCount() < endTime ) do\n\t\tbegin\n\t\t\tfor j := 1 to n do\n\t\t\t\tres := max( res, nn * distance(t, vertex[i], vertex[j]) + s[ vertex[i] ] * n1 + s[ vertex[j] ] * n2 );\n\t\t\t\n\t\t\tinc( i );\n\t\tend;\n\tend;\n\t\n\texit( res + t.insideDistanceSum + t.n * int64(n1 + n2) + 2 * nn );\nend;\n\nvar\tt1, t2, t3: tTree;\n\tans: int64;\n\nbegin\n\treadln( t1.n, t2.n, t3.n );\n\n\treadEdges( t1 );\n\treadEdges( t2 );\n\treadEdges( t3 );\n\t\n\tpreprocess( t1 );\n\tpreprocess( t2 );\n\tpreprocess( t3 );\n\t\n\tans := 0;\n\t\n\tans := max( ans, solveTwo( t1, t2.n, t3.n ) + solveOne( t2, t1.n + t3.n ) + solveOne( t3, t1.n + t2.n ) );\n\tans := max( ans, solveTwo( t2, t1.n, t3.n ) + solveOne( t1, t2.n + t3.n ) + solveOne( t3, t1.n + t2.n ) );\n\tans := max( ans, solveTwo( t3, t2.n, t1.n ) + solveOne( t2, t1.n + t3.n ) + solveOne( t1, t3.n + t2.n ) );\n\t\n\twriteln( ans );\nend.\n", "src_uid": "2f299b0083b89d8b8ec8b26b65d201f2"} {"source_code": "{$apptype console}\n{$R+,S+,I+,Q+}\nconst\n inf = 'input.txt';\n outf = 'output.txt';\nvar\n x,y,z,k,ans,cnt,kx,ky,kz:int64;\nbegin\n //reset(input,inf);\n //rewrite(output,outf);\n read(x,y,z,k);\n kx:=0; ky:=0; kz:=0;\n cnt:=0;\n while (x > 1) or (y > 1) or (z > 1) do\n begin\n if k = 0 then break;\n inc(cnt);\n if cnt = 4 then cnt:=1;\n if (cnt = 1) and (x > 1) then\n begin\n inc(kx);\n dec(x);\n dec(k);\n end;\n if (cnt = 2) and (y > 1) then\n begin\n inc(ky);\n dec(y);\n dec(k);\n end;\n if (cnt = 3) and (z > 1) then\n begin\n inc(kz);\n dec(z);\n dec(k);\n end;\n end;\n ans:=(kx+1)*(ky+1)*(kz+1);\n writeln(ans);\nend.\n", "src_uid": "8787c5d46d7247d93d806264a8957639"} {"source_code": "var a1,a2:longint;\n x:string[10];\n k:char;\n i,code:integer;\nbegin\n readln(a1,a2);\n str(a2,x);\n for i:=1 to (length(x)div 2) do begin\n k:=x[i];\n x[i]:=x[length(x)-i+1];\n x[length(x)-i+1]:=k;\n end;\n val(x,a2,code);\n writeln(a1+a2);\n readln;\nend.", "src_uid": "69b219054cad0844fc4f15df463e09c0"} {"source_code": "Var n,i: longint;\nBegin\n{assign(input,'in.txt');\nassign(output,'out.txt');\nreset(input);\nrewrite(output);}\nRead(n);\ni:=0;\nRepeat\n inc(i);\n dec(n,i);\nUntil n<=0;\nIf n=0 then write('YES') else write('NO');\nend.\n\n", "src_uid": "587d4775dbd6a41fc9e4b81f71da7301"} {"source_code": "var a,m:int64;\n i:longint;\n begin\n read(a,m);\n for i:=1 to 100000 do\n begin\n if a mod m=0 then begin writeln('Yes');halt;end;\n a:=a+(a mod m);\n end;\n writeln('No');\n end.\n", "src_uid": "f726133018e2149ec57e113860ec498a"} {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n:integer;\n a,b,c,d,e,f,x:extended;\n\nbegin\n readln(n);\n a:=1;\n b:=2;\n c:=3;\n d:=4;\n e:=5;\n f:=6;\n x:=0;\n while x<>1 do\n begin\n if (n>=a)and(n=b)and(n=c)and(n=d)and(n=e)and(n 0) and (yy > 0) then\n begin\n inc(p);\n a[p]:=abs(xx-yy)-1;\n end;\n if xx > 0 then okb:=True;\n if yy > 0 then oka:=True;\n end;\n if m = 1 then ans:='Second' else\n if not oka then ans:='Second' else\n if not okb then ans:='First' else\n if p = 0 then ans:='Draw' else\n begin\n ans:='Second';\n inc(k);\n for it:=1 to 20 do\n begin\n s:=0;\n for i:=1 to p do\n begin\n s:=s+a[i] mod 2;\n a[i]:=a[i] div 2;\n end;\n if s mod k <> 0 then ans:='First';\n end;\n end;\n writeln(ans);\n close(input);\n close(output);\nend.", "src_uid": "69062f7c9b834e925ab23ebc2da96b52"} {"source_code": "Const\n fi ='';//B.INP';\n fo ='';//B.OUT';\n\nVar\n cnt1,cnt2,x,y :int64;\n res :int64;\n\nProcedure nhap;\nbegin\n assign(input,fi);\n reset(input);\n read(cnt1,cnt2,x,y);\n close(input);\nend;\n\nFunction ok(g:int64):boolean;\nbegin\n if g-g div x < cnt1 then exit(false);\n if g-g div y < cnt2 then exit(false);\n if g-g div (x*y) < (cnt1+cnt2) then exit(false);\n exit(true);\nend;\n\nProcedure Sol;\nvar\n d,c,g :int64;\nbegin\n d:=1;\n c:=round(1E18);\n while d <= c do\n begin\n g:=(d+c) div 2;\n if ok(g) then\n begin\n res:=g;\n c:=g-1;\n end\n else\n d:=g+1;\n end;\nend;\n\nProcedure xuat;\nbegin\n assign(output,fo);\n rewrite(output);\n write(res);\n close(output);\nend;\n\nBegin\n nhap;\n Sol;\n xuat;\nEnd.\n", "src_uid": "ff3c39b759a049580a6e96c66c904fdc"} {"source_code": "const MAXN = 503; MD = 998244353;\n\nvar\n\tn,x,i,j,k: Longint;\n\tans: int64;\n\tchose, pw, dp : Array [0..MAXN, 0..MAXN] of int64;\nBEGIN\n\tReadLn(n, x);\n\tFillChar(dp, SizeOf(dp), 0);\n\t\n\tfor i:=0 to MAXN do pw[i, 0]:= 1;\n\tfor i:=0 to MAXN do for j:=1 to MAXN do pw[i, j]:= (pw[i, j-1] * i) mod MD;\n\t\n\tfor i:=0 to MAXN do chose[0, i]:= 1;\n\tfor i:=1 to MAXN do\n\t\tfor j:=i to MAXN do \n\t\t\tif i = j then chose[i, j]:= 1 else chose[i, j]:= (chose[i, j-1] + chose[i-1, j-1]) mod MD;\n\n\tfor i:=1 to n do\n\t\tfor j:=1 to i-1 do\n\t\t\tdp[i, j]:= (pw[j, i] - pw[j-1, i] + MD) mod MD;\n\n\tfor i:=1 to n do \n\t\tfor j:=1 to x do \n\t\t\tfor k:=0 to n-i do \n\t\t\t\tif (i+k-1 > 0) and (j+i+k-1 <= x) then \n\t\t\t\t\tdp[i+k, j+i+k-1]:= (dp[i+k, j+i+k-1] + (dp[i, j] * chose[i, i+k]) mod MD * pw[i+k-1, k]) mod MD; \n\tAns:= 0;\t\n\tfor i:=1 to x do \n\t\tAns:= (Ans + dp[n, i]) MOD MD;\n\tWriteLn(Ans);\nEND.\n", "src_uid": "1908d1c8c6b122a4c6633a7af094f17f"} {"source_code": "{$MODE OBJFPC}\nprogram dream_hyojoo;\nvar\n m:int64;\n f:array[0..200000] of int64;\n i:int64;\n\nfunction check(x:int64):int64;\nvar i:integer; sum:int64;\nbegin\n sum:=0;\n for i:=2 to 200000 do\n if f[i]>x then break else\n begin\n inc(sum,x div f[i]);\n if sum>m then break\n end;\n exit(sum)\nend;\n\nprocedure bs(l,r:int64);\nvar mid:int64;\nbegin\n while l=m then r:=mid\n end;\n if check(l)=m then writeln(l) else\n writeln(-1)\nend;\n\nbegin\n readln(m);\n i:=2;\n while i<=200000 do\n begin\n f[i]:=i*i*i;;\n inc(i)\n end;\n\n bs(1,10000000000000000);\n\nend.\n", "src_uid": "602deaad5c66e264997249457d555129"} {"source_code": "var a,b,c,d: longint;\n\nbegin\nread(a,b,c,d);\nif a mod c=0 then a:=a div c else a:=a div c+1;\na:=(a-1)*b;\nif dp) 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)and(a<>c)and(a<>d)and(c<>b)and(d<>b)and(c<>d) then Break;\n Inc(i);\n end;\n Writeln(i);\n Readln;\n Readln;\nend.\n ", "src_uid": "d62dabfbec52675b7ed7b582ad133acd"} {"source_code": "var p:array[0..1200,0..1200]of extended;\n\tm,n:longint;\t\nfunction f(i,j:longint):extended;\nvar A,B,D,g:extended;\nbegin\n\tif i=0 then exit(1/(j+1));\n\tif j=0 then exit(1);\n\tif p[i,j]>0 then exit(p[i,j]);\n\tA:=(j/(j+1))*(1-f(j-1,i)); B:=1/(j+1)+A; D:=1-f(j,i-1);\n\tg:=(D-1)/(A-1+D-B);\n\tp[i,j]:=(1-g)+A*g;\n\texit(p[i,j]);\nend;\nbegin\n\treadln(n,m);\n\twriteln(f(n,m):0:10,' ',1-f(n,m):0:10);\nend.\n\n", "src_uid": "f51586ab88399c04ffb7eaa658d294dd"} {"source_code": "var\nn,m,r:longint;\nbegin\nreadln(n,m);\nif na2 then begin\n s1:=a1+2+2*b1+1;\n s2:=a2+2+2*b2;\n writeln(s1+s2+a1-a2-1);\n end;\nend.", "src_uid": "b5d44e0041053c996938aadd1b3865f6"} {"source_code": "var\n n,AKIOI,i,j:longint;\n ans:real;\n m,r:array[1..16]of longint;\nbegin\n readln(n);\n for i:=1 to n do\n read(m[i]);\n readln;\n for i:=1 to n do\n read(r[i]);\n readln;\n for i:=1 to 720720 do\n for j:=1 to n do\n if i mod m[j]=r[j] then begin\n AKIOI:=AKIOI+1;\n break;\n end;\n ans:=AKIOI/720720;\n writeln(ans:0:6); \nend.", "src_uid": "14b69f42bc192ea472e82f3a3209f1c1"} {"source_code": "var\ns,s1,s2:string;\nbegin\nreadln(s);\ns1:=copy(s,1,pos(' ',s)-1);\ns2:=copy(s,pos(' ',s)+1,length(s)-pos(' ',s));\nif(s2=s1) then writeln(s1) else writeln(1);\nend.", "src_uid": "9c5b6d8a20414d160069010b2965b896"} {"source_code": "var n,i,l,r:longint;\n x1,y1,x2,y2:longint;\n c,c1,m1,m2:char;\n k:string;\nbegin\n\nreadln(k);\n\nread(c,c1);\nif c='6' then x1:=6;\nif c='7' then x1:=7;\nif c='8' then x1:=8;\nif c='9' then x1:=9;\nif c='T' then x1:=10;\nif c='J' then x1:=11;\nif c='Q' then x1:=12;\nif c='K' then x1:=13;\nif c='A' then x1:=14;\nm1:=c1;\nread(c1);\nread(c,c1);\nif c='6' then x2:=6;\nif c='7' then x2:=7;\nif c='8' then x2:=8;\nif c='9' then x2:=9;\nif c='T' then x2:=10;\nif c='J' then x2:=11;\nif c='Q' then x2:=12;\nif c='K' then x2:=13;\nif c='A' then x2:=14;\nm2:=c1;\n\nif (m1=k[1]) and (m2<>k[1]) then writeln('YES')\n else\n begin\n if m1<>m2 then writeln('NO')\n else if x1>x2 then writeln('YES')\n else writeln('NO');\n\n end;\n\n\nend.", "src_uid": "da13bd5a335c7f81c5a963b030655c26"} {"source_code": "program contest;\nvar\n max,v:array[1..100] of longint;\n i,vi,vf,t,d,sum:longint;\n\nfunction min (a,b:longint):longint;\nbegin\n if a n then b := n;\n writeln(b);\nend.", "src_uid": "54cb2e987f2cc06c02c7638ea879a1ab"} {"source_code": "var\n\tk, l, m, n, d, j: integer;\n\ta:array[65..90] of integer;\n\tflag: boolean = true;\n\ts, s1: string;\n\t\nbegin\n\t\n\treadln(n);\n\treadln(s);\n\ts := UpperCase(s);\n\tif (n < 26) then\n\tbegin\n\t\twriteln('NO');\n\t\texit;\n\tend;\n\t\n\tfor var i := 1 to s.length do\n\tbegin\n\t\ta[ord(s[i])] += 1;\n\tend;\n\t\n\tfor var i := 65 to 90 do\n\tbegin\n\t\tif (a[i] = 0) then\n\t\tbegin\n\t\t\tflag := false;\n\t\t\tbreak;\n\t\tend;\n\tend;\n\t\n\tif (flag) then\n\t\twriteln('YES')\n\telse\n\t\twriteln('NO');\n\t\n\t\nend.\n", "src_uid": "f13eba0a0fb86e20495d218fc4ad532d"} {"source_code": "program ZAD_C_2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\nvar\n klizma,i:integer;\n n:int64;\nbegin\n readln(n);\n klizma:=0;\n for i:=1 to 1010000 do\n if ((n+i) mod 3 = 0) and (((n+i) div 3) >= trunc((1.0 * (1+i) * i) / 2)) then inc(klizma);\n writeln(klizma);//I love asya\n readln;\nend.\n", "src_uid": "ab4f9cb3bb0df6389a4128e9ff1207de"} {"source_code": "var a,b,c,ans:int64; \nprocedure swap(var a,b:int64);\nvar c:int64;\nbegin\n c:=a; a:=b; b:=c;\nend;\nbegin\n readln(a,b,c);\n if ab then ans:=b;\n if (a+c) mod 2=0 then if ans>a then ans:=a;\n if (a+b) mod 2=0 then if ans>a then ans:=a;\n writeln(ans);\nend.", "src_uid": "b8008caf788336775cb8ebb76478b04c"} {"source_code": "{$r-,s-,q-,i-,o+}\ntype arr=array [0..200] of longint;\nvar\n ii,n,k,x,i,j,w,ans,kol,H,flag:longint;\n a,b:arr;\n mar:array [0..2000] of boolean;\n key,ke:arr;\n\n function calc(ln:longint;a,key:arr):longint;\n var i,l,r,j,sz,w:longint; b,ke:arr;\n begin\n if (ln<3) then exit(0);\n i:=1;\n while (i<=ln) do\n begin\n l:=i; r:=i;\n for j:=i+1 to ln do\n if (a[j]=a[j-1]) then inc(r) else break;\n sz:=r-l+1;\n if (sz>=3) then\n begin\n w:=0;\n for j:=1 to l-1 do\n begin\n inc(w);\n b[w]:=a[j];\n ke[w]:=key[j];\n end;\n for j:=r+1 to ln do\n begin\n inc(w);\n b[w]:=a[j];\n ke[w]:=key[j];\n end;\n for j:=l to r do\n if (key[j]=ii) then flag:=1;\n exit(sz+calc(w,b,ke));\n end;\n i:=i+sz;\n end;\n exit(0);\n end;\n\nbegin\n ans:=0;\n readln(n,k,x);\n for i:=1 to n do read(a[i]);\n for ii:=1 to n do\n begin\n flag:=0;\n fillchar(mar,sizeof(mar),false);\n for j:=1 to n do key[j]:=j;\n w:=0;\n for j:=1 to ii-1 do\n begin\n inc(w);\n b[w]:=a[j];\n end;\n inc(w);\n b[w]:=x;\n for j:=ii to n do\n begin\n inc(w);\n b[w]:=a[j];\n end;\n flag:=0;\n H:=calc(n+1,b,key);\n H:=H-flag;\n if (H>ans) then ans:=H;\n end;\n writeln(ans);\nend.", "src_uid": "d73d9610e3800817a3109314b1e6f88c"} {"source_code": "var\n i, j, n, c: longint;\n s: string;\n a: Array[0..100000] of longint;\n\nbegin\n read(n);\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 begin c := a[i]; a[i] := a[j]; a[j] := c; end;\n \n c := a[1]; a[1] := a[n]; a[n] := c;\n \n for i := 1 to n do write(a[i], ' ');\n \nend.", "src_uid": "4408eba2c5c0693e6b70bdcbe2dda2f4"} {"source_code": "var\nmap:array [1..1000,1..10000] of char;\ni,j,n,m,ans:longint;\nfunction check(i,j:longint):longint;\n begin\n if (i-1>0) and (map[i-1,j]='P') then exit(1);\n if (i+1<=n) and (map[i+1,j]='P') then exit(1);\n if (j-1>0) and (map[i,j-1]='P') then exit(1);\n if (j+1<=m) and (map[i,j+1]='P') then exit(1);\n exit(0);\n end;\n begin\n readln(n,m);\n for i:=1 to n do\n begin\n for j:=1 to m do read(map[i,j]);\n readln;\n end;\n for i:=1 to n do\n for j:=1 to m do\n if map[i,j]='W' then inc(ans,check(i,j));\n write(ans);\n end.", "src_uid": "969b24ed98d916184821b2b2f8fd3aac"} {"source_code": "var i,j,n,k,m,l,t,x,p,mi,ma:longint;\nbegin\n read(n,k);\n if (n<>k) and (k>0) then mi:=1;\n if n div 3>=k then ma:=2*k\n else ma:=n-k;\n write(mi,' ', ma);\nend.", "src_uid": "bdccf34b5a5ae13238c89a60814b9f86"} {"source_code": "const mx:int64=1000000007;\nvar\n a:array[0..200000]of int64;\n b:array[0..1000]of int64;\n p,n,m,i,j,ans:longint;\nbegin\n readln(n,m);a[0]:=1;\n for i:=1 to 1000 do begin\n b[i]:=b[i-1]+i;\n if b[i]>n+m then begin\n p:=i-1;break;\n end;\n end;\n for i:=1 to p do\n for j:=n downto 0 do begin\n if (b[i]-j-i<=m)and(j+i<=n) then begin\n inc(a[j+i],a[j]);\n if a[j+i]>=mx then dec(a[j+i],mx);\n end;\n if b[i]-j>m then a[j]:=0;\n end;\n for j:=0 to n do begin\n inc(ans,a[j]);\n if ans>mx then dec(ans,mx);\n end;\n writeln(ans);\nend.", "src_uid": "34b6286350e3531c1fbda6b0c184addc"} {"source_code": "var\tdem,n,t,i,j,hs:longint;\n\ta,b:array[1..100,1..100] of longint;\n\tprocedure pour(sl,x,y,z:longint);\n\tvar\tt:longint;\n\t\tbegin\n\t\t\tif a[x,y]=hs then\n\t\t\tbegin\n\t\t\t\tpour(sl div 2,x+1,y,z);\n\t\t\t\tpour(sl div 2,x+1,y+1,z);\n\t\t\tend\n\t\t\telse\n\t\t\tif a[x,y]+sl>=hs then\n\t\t\tbegin\n\t\t\t\tt:=a[x,y]+sl-hs;\n\t\t\t\ta[x,y]:=hs;\n\t\t\t\tb[x,y]:=z;\n\t\t\t\tpour(t div 2,x+1,y,z);\n\t\t\t\tpour(t div 2,x+1,y+1,z);\n\t\t\tend\n\t\t\telse inc(a[x,y],sl);\n\t\tend;\nbegin\n\treadln(n,t);\n\ths:=1;\n\tfor i:=1 to n do\n\t\ths:=hs*2;\n\tfillchar(a,sizeof(a),0);\n\tfor i:=1 to hs-1 do\n\t\tpour(hs,1,1,i);\n\tdem:=0;\n\tfor i:=1 to n do\n\t\tfor j:=1 to i do\n\t\t\tif b[i,j]<=t then inc(dem);\n\twriteln(dem);\nend.", "src_uid": "b2b49b7f6e3279d435766085958fb69d"} {"source_code": "var\n n,m,i:longint;\n s:string;\nbegin\n readln(n,m);\n for i:=1 to n do\n begin\n readln(s);\n if (pos('C',s)<>0) or (pos('M',s)<>0) or (pos('Y',s)<>0) then begin\n writeln('#Color'); halt; end;\n end;\n writeln('#Black&White');\nend.", "src_uid": "19c311c02380f9a73cd477e4fde27454"} {"source_code": "Var a,x,k:longint;\nBegin\na:=0;\nread(x);\nwhile a=0 then begin x:=x-100; Inc(k); end else\nIf x-20>=0 then begin x:=x-20;inc(k); end else\nIf x-10>=0 then begin x:=x-10; inc(k); end else\nIf x-5>=0 then begin x:=x-5; inc(k); end else\nIf x-1>=0 then begin x:=x-1; inc(k); end;\nend;\nwriteln(k);\nreadln;\nreadln\nend.\n", "src_uid": "8e81ad7110552c20297f08ad3e5f8ddc"} {"source_code": "{$mode objfpc}\n\nvar\n a:integer;\n\nbegin\n read(a);\n if a = 1 then writeln(1,' ',2)\n else writeln((a-1)*2,' ',2);\n writeln(1,' ',2);\nend.", "src_uid": "5c000b4c82a8ecef764f53fda8cee541"} {"source_code": "var min,i,n,k:longint;\nbegin\nmin:=maxlongint;\nreadln(n,k);\nfor i:=1 to k-1 do\nif (n mod i=0) and ((n div i)*k= 0 do begin\n dec(k,cl(a+t,b+c,l)+cl(b+t,c+a,l)+cl(c+t,a+b,l));\n dec(l); inc(t);\n end;\n writeln(k);\nend.", "src_uid": "185ff90a8b0ae0e2b75605f772589410"} {"source_code": "program Project2;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n n, i: integer;\n s: string;\n a: array[0..10000] of integer;\n res, k: int64;\n\nbegin\n{ reset(input, 'input.txt');\n rewrite(output, 'output.txt');}\n\n readln(s);\n n := length(s);\n\n for i := 2 to n do begin\n inc(a[ord(s[i])]);\n end;\n\n res := 1;\n k := 10;\n\n if (s[1] = '?') then begin\n res := 9;\n end else begin\n if (s[1] >= 'A') and (s[1] <= 'J') then begin\n res := 9;\n k := 9;\n end;\n end;\n\n\n\n for i := ord('A') to ord('J') do begin\n if (a[i] > 0) and (s[1] <> chr(i)) then begin\n res := res * k;\n k := k - 1;\n end;\n end;\n\n write(res);\n\n for i := 1 to a[ord('?')] do\n write(0);\n\n\nend.\n", "src_uid": "d3c10d1b1a17ad018359e2dab80d2b82"} {"source_code": "program Project1;\n\n{$APPTYPE CONSOLE}\n\nuses\n SysUtils;\n\nvar\n\ti, a, total, g: Integer;\n\nfunction\tsum(x, mdl: Integer): Integer;\nbegin\n\tResult := 0;\n\twhile x>0 do\n\tbegin\n\t\tInc(Result, x mod mdl);\n\t\tx := x div mdl;\n\tend;\nend;\n\nfunction\tGetGCD(x, y: Integer): Integer;\nbegin\n\tif x mod y = 0 then\n\tbegin\n\t\tResult := y;\n\tend\n\telse\n\tbegin\n\t\tResult := GetGCD(y, x mod y);\n\tend;\nend;\n\nbegin\n\tReadln(a);\n\ttotal := 0;\n\tfor i:=2 to a-1 do\n\tbegin\n\t\tInc(total, sum(a, i));\n\tend;\n\tg := GetGCD(total, a-2);\n\tWriteln(total div g, '/', (a-2) div g);\n\nend.\n", "src_uid": "1366732dddecba26db232d6ca8f35fdc"} {"source_code": "var n, k: int64;\n i:int64;\nbegin\nreadln(n ,k);\n\ni:=1;\n\nwhile (n mod i = i-1) and (i<=100000000) and (i<=k) do inc(i);\n\n\nif (i>k) or (i>100000000) then writeln('Yes')\n\telse writeln('No'); \nend.", "src_uid": "5271c707c9c72ef021a0baf762bf3eb2"} {"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,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\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,aa,bb,cc);\n\n\n ot:=0;\n p:=pok(n);\n t:=n-(bb-cc)*p;\n if t>0 then\n ot:=p+t div aa else ot:=p;\n\n ot:=max(ot,n div aa);\n writeln(ot); goto 1;\n\n if bb<=aa then\n begin\n t:=(n-bb) div (bb-cc);\n if n 0) then\n begin\n free[woman] := false;\n Gen(man+1, val + c[man][woman]);\n free[woman] := true;\n end;\n Gen(man+1, val);\n End;\n\nProcedure Sort(l, r :longint);\nvar i, j, piv :longint;\n Begin\n if l >= r then exit;\n i := l; j := r;\n piv := a[l + random(r-l+1)];\n repeat\n while a[i] < piv do inc(i);\n while a[j] > piv 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 Sort(l, j);\n Sort(i, r);\n End;\n\nBEGIN\n assign(f1, fi); reset(f1);\n assign(f2, fo); rewrite(f2);\n\n readln(f1, n, m, t);\n for i:=1 to m do readln(f1, u, v, c[u][v]);\n\n fillchar(free, sizeof(free), true);\n Gen(1, 0);\n Sort(1, spt);\n writeln(f2, a[t]);\n\n close(f1);\n close(f2);\nEND.", "src_uid": "7348b5644f232bf377a4834eded42e4b"} {"source_code": "\n\n {$APPTYPE CONSOLE}\nconst nn=1000001; besk=200000000000000;\n nnn=2000000; eps=1e-6; modul=1000000007;\n label 1,2,3,4;\nvar ii,jj,kt,ppp,god,day,mon,p,mask,i0,j0,k,step,i,j,start,finish,kol,m:longint;\np1,p2,ll,bb,pp,tt,ot1,ot2,s,kold,gr,n,ot,kolshok:int64;\nba,by,aa,ay,t,kk,centr,koef:int64;\nflag2,flag1,flag:boolean;\nch:char;\naaa,bbb,ccc,hh,po,pt,doltek,dolpred:extended;\nx,c,b,a,rog,kop,perenos,shok:array[0..1000000] of int64;\nmarked,zan: array[0..330006] of boolean;\ndist: array[0..4000,0..4000] of int64;\ndd :double;\nsss,ss1,ss:array[-1000..1100000] 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\n\nfunction zaz(al:extended):extended;\nbegin zaz:=(bb-pp*sin(al))*sin(al)/cos(al)+pp*cos(al)-aa; end;\n\nbegin\n { assign (input,'input.txt');reset(input);\n assign (output,'output.txt'); rewrite(output);\n }\n read(p1,p2);\n if nod(p1,p2)<>1 then begin write('Impossible'); goto 1; end;\n if p1>p2 then flag:=true;\n\n\n repeat\n begin\n inc(ot);\n if p1>p2 then\n begin x[ot]:=p1 div p2; p1:=p1 mod p2; goto 2; end;\n if p1m then m:=a;\nend;\nreadln;\ninc(s,m);\nif s<0 then writeln('NO') else writeln('YES');\nreadln;\nend.\n", "src_uid": "496baae594b32c5ffda35b896ebde629"} {"source_code": "uses math;\nconst\n p1 = 'Timur';\n p2 = 'Marsel';\n oo = high(longint);\nvar\n m,n,k,e,i : longint;\nbegin\n readln(n,m,k);\n if n and 1 = 0 then\n writeln(p2)\n else begin\n e := oo;\n for i := 1 to trunc(sqrt(m)) do\n if m mod i = 0 then begin\n if i >= k then e := min(e,i) else\n if m div i >= k then e := min(e,m div i);\n end;\n if (e j;\n if l < j then qsortn1(l, j);\n if r > i then qsortn1(i, r);\nend;\n \nbegin\n readln(n);\n \n for i := 1 to n do\n begin\n read(n1[i]);\n end;\n qsortn1(1,n);\n \n l := 1;\n k := 1;\n \n for i := 1 to n-1 do\n begin\n if n1[i] = n1[i+1] then\n inc(k);\n if (i = (n-1)) or ((n1[i] <> n1[i+1])) then\n begin\n if k > l then \n l := k;\n k := 1;\n end;\n \n end;\n \n writeln(l);\nend.", "src_uid": "f30329023e84b4c50b1b118dc98ae73c"} {"source_code": "uses math;\nvar s:string;\n k,m,n,d,i:longint;\n c:integer;\nbegin\n readln(n,k);\n str(n,s);\n m:=10**k;\n n:=length(s);\n d:=0;\n val(s,k,c);\n if (k mod m=0) then\n begin\n writeln(d);\n exit;\n end;\n for i:=n downto 2 do\n begin\n if (s[i]<>'0') then\n begin\n inc(d);\n delete(s,i,1);\n val(s,k,c);\n if (k mod m=0) then\n begin\n writeln(d);\n exit;\n end;\n end;\n end;\n val(s,k,c);\n if (k mod m=0) then\n begin\n writeln(d+1);\n exit;\n end;\n writeln(d+length(s)-1);\nend.", "src_uid": "7a8890417aa48c2b93b559ca118853f9"} {"source_code": "\ufeffvar a,s,d,f,g,h,j,k,i:longint;\nq,w:array[1..1000] of longint;\ne:array[1..1000] of char;\nz:string;\nbegin\nreadln(a);\nread(z);\nfor i:=2 to a do\nif a mod i=0 then\nbegin\ns:=s+1;\nq[s]:=i;\nend;\nfor i:=1 to s do begin\nfor j:=1 to q[i] do\ne[j]:=z[j];\nh:=q[i];\nfor j:=1 to q[i] do begin\nz[j]:=e[h];\nh:=h-1;\nend;\nend;\nwrite(z);\nend.", "src_uid": "1b0b2ee44c63cb0634cb63f2ad65cdd3"} {"source_code": "var\n y,b,r,i,j,k,s,max:longint;\nbegin\n read(y,b,r);\n s:=0;\n for i:=y downto 1 do\n for j:=b downto 1 do \n for k:=r downto 1 do \n if (j-1=i) and (k-1=j) then\n begin\n s:=i+j+k;\n if s>max then max:=s;\n end;\n write(max);\nend.", "src_uid": "03ac8efe10de17590e1ae151a7bae1a5"} {"source_code": "var a,b,c,d:integer;\nbegin\nreadln(a,b,c,d);\nif ((a=d) and (a<>0)) or ((a=0) and (c=0) and (d=0)) then writeln(1)\nelse writeln(0);\nend.", "src_uid": "b99578086043537297d374dc01eeb6f8"} {"source_code": "program cfstepenice;\nvar n,m,d,c:integer;\n\nbegin\nread(n,m);\nd:=n div 2;\nc:=n mod 2;\nwhile (c+d) mod m<>0 do\n begin\n d:=d-1;\n c:=c+2;\n if d<0 then\n begin\n d:=0;\n c:=-1;\n break;\n end;\n end;\nwriteln(c+d);\nend.", "src_uid": "0fa526ebc0b4fa3a5866c7c5b3a4656f"} {"source_code": "program z1;\nvar k1,k2,k3 : longint;\nbegin\nreadln(k1,k2,k3);\nif (k1 = 1) or (k2 = 1 ) or (k3 = 1)\nthen write('YES')\nelse if (k1 = 2) and (k2 = 2 ) and (k3 <> 2)\n then write('YES')\n else if (k1 = 2) and (k3 = 2 ) and (k2 <> 2)\n then write ('YES')\n else if (k1 <> 2) and (k2 = 2 ) and (k3 = 2)\n then write('YES')\n else if (k1 = 3) and (k2 = 3 ) and (k3 = 3)\n then write ('YES')\n else if (k1 = 2) and (k2 = 4 ) and (k3 = 4)\n then write('YES')\n else if (k1 = 4) and (k2 = 2 ) and (k3 = 4)\n then write ('YES')\n else if (k1 = 4) and (k2 = 4 ) and (k3 = 2)\n then write('YES')\n else if (k1 = 2) and (k2 = 2 ) and (k3 = 2)\n then write('YES')\n else write('NO');\nend. ", "src_uid": "df48af9f5e68cb6efc1214f7138accf9"} {"source_code": "var x,y,x1,x2,y1,y2:longint;\nfunction xuly:string;\nbegin\nif ABS(x2-x1) mod x <>0 then exit('NO');\nif ABS(y2-y1) mod y <>0 then exit('NO');\nif (ABS(x2-x1) div x) mod 2 <> (ABS(y2-y1) div y) mod 2 then exit('NO');\nexit('YES');\nend;\n\nbegin\n//assign(input,'A.inp'); reset(input);\n//assign(output,'A.out'); rewrite(output);\nreadln(x1,y1,x2,y2);\nreadln(x,y);\nwriteln(xuly);\n//close(input); close(output);\nend.", "src_uid": "1c80040104e06c9f24abfcfe654a851f"} {"source_code": "{$apptype console}\n{$R-,S-,I-,Q-}\nuses math;\nconst\n inf = 'input.txt';\n outf = 'output.txt';\n lb = 500000;\n a:array[0..600] of longint = (\n0,\n20732,\n39176,\n57023,\n74417,\n91433,\n108284,\n124997,\n141503,\n157925,\n174194,\n190283,\n206333,\n222272,\n238261,\n253974,\n269760,\n285396,\n301101,\n316642,\n332181,\n347665,\n363080,\n378518,\n393993,\n409309,\n424569,\n439791,\n454974,\n470153,\n485275,\n500236,\n515414,\n530472,\n545501,\n560489,\n575503,\n590416,\n605357,\n620283,\n635171,\n649933,\n664771,\n679672,\n694490,\n709115,\n723896,\n738676,\n753318,\n768087,\n782754,\n797361,\n812028,\n826720,\n841364,\n855895,\n870514,\n885138,\n899686,\n914214,\n928780,\n943326,\n957871,\n972309,\n986746,\n1001141,\n1015619,\n1030064,\n1044521,\n1058798,\n1073174,\n1087554,\n1101903,\n1116309,\n1130652,\n1145026,\n1159339,\n1173746,\n1188093,\n1202432,\n1216688,\n1230996,\n1245272,\n1259537,\n1273689,\n1287980,\n1302081,\n1316314,\n1330570,\n1344730,\n1358925,\n1373089,\n1387240,\n1401374,\n1415626,\n1429775,\n1443939,\n1458083,\n1472195,\n1486323,\n1500453,\n1514527,\n1528622,\n1542683,\n1556702,\n1570716,\n1584772,\n1598783,\n1612824,\n1626767,\n1640857,\n1654854,\n1668892,\n1682935,\n1696863,\n1710912,\n1724880,\n1738807,\n1752772,\n1766647,\n1780671,\n1794680,\n1808647,\n1822528,\n1836360,\n1850327,\n1864207,\n1878117,\n1892075,\n1906069,\n1919906,\n1933873,\n1947727,\n1961653,\n1975510,\n1989438,\n2003304,\n2017180,\n2031020,\n2044905,\n2058719,\n2072561,\n2086330,\n2100185,\n2113990,\n2127838,\n2141713,\n2155442,\n2169247,\n2183018,\n2196835,\n2210669,\n2224515,\n2238231,\n2252025,\n2265828,\n2279483,\n2293240,\n2306931,\n2320691,\n2334374,\n2348163,\n2361872,\n2375651,\n2389450,\n2403099,\n2416904,\n2430503,\n2444352,\n2458031,\n2471679,\n2485399,\n2499026,\n2512726,\n2526330,\n2540008,\n2553802,\n2567510,\n2581128,\n2594819,\n2608394,\n2622048,\n2635613,\n2649274,\n2662840,\n2676540,\n2690185,\n2703798,\n2717374,\n2730937,\n2744682,\n2758290,\n2771910,\n2785459,\n2799109,\n2812655,\n2826276,\n2839799,\n2853362,\n2866912,\n2880505,\n2894042,\n2907606,\n2921165,\n2934703,\n2948312,\n2961881,\n2975367,\n2988902,\n3002504,\n3016009,\n3029542,\n3043022,\n3056533,\n3069997,\n3083637,\n3097083,\n3110676,\n3124226,\n3137800,\n3151359,\n3164764,\n3178276,\n3191741,\n3205350,\n3218845,\n3232326,\n3245793,\n3259118,\n3272566,\n3286023,\n3299511,\n3312951,\n3326372,\n3339778,\n3353226,\n3366670,\n3380175,\n3393551,\n3407022,\n3420476,\n3433831,\n3447272,\n3460716,\n3474095,\n3487498,\n3500974,\n3514444,\n3527908,\n3541338,\n3554739,\n3568117,\n3581527,\n3594895,\n3608315,\n3621779,\n3635172,\n3648522,\n3662084,\n3675493,\n3688865,\n3702151,\n3715571,\n3729014,\n3742387,\n3755763,\n3769101,\n3782494,\n3795810,\n3809252,\n3822594,\n3835966,\n3849184,\n3862541,\n3875855,\n3889196,\n3902460,\n3915712,\n3929085,\n3942498,\n3955921,\n3969211,\n3982460,\n3995735,\n4009128,\n4022481,\n4035734,\n4049121,\n4062451,\n4075821,\n4089090,\n4102417,\n4115722,\n4129050,\n4142364,\n4155686,\n4168923,\n4182183,\n4195422,\n4208687,\n4221985,\n4235233,\n4248402,\n4261661,\n4274957,\n4288065,\n4301295,\n4314529,\n4327912,\n4341144,\n4354389,\n4367588,\n4380845,\n4394200,\n4407487,\n4420721,\n4433902,\n4447138,\n4460241,\n4473457,\n4486724,\n4499966,\n4513194,\n4526427,\n4539593,\n4552844,\n4566061,\n4579285,\n4592654,\n4605817,\n4619006,\n4632187,\n4645360,\n4658586,\n4671705,\n4684949,\n4698103,\n4711274,\n4724481,\n4737851,\n4750950,\n4764205,\n4777296,\n4790546,\n4803668,\n4816891,\n4830058,\n4843322,\n4856492,\n4869676,\n4882798,\n4896011,\n4909157,\n4922306,\n4935488,\n4948680,\n4961878,\n4975039,\n4988226,\n5001443,\n5014695,\n5027802,\n5040863,\n5054025,\n5067205,\n5080256,\n5093333,\n5106459,\n5119591,\n5132783,\n5145981,\n5159150,\n5172232,\n5185364,\n5198500,\n5211713,\n5224741,\n5237883,\n5250964,\n5264198,\n5277359,\n5290378,\n5303300,\n5316423,\n5329410,\n5342497,\n5355703,\n5368777,\n5381929,\n5395046,\n5408176,\n5421235,\n5434359,\n5447430,\n5460458,\n5473438,\n5486492,\n5499560,\n5512631,\n5525740,\n5538821,\n5551962,\n5564989,\n5578173,\n5591257,\n5604343,\n5617364,\n5630520,\n5643587,\n5656616,\n5669724,\n5682698,\n5695725,\n5708793,\n5721870,\n5734927,\n5747922,\n5760903,\n5773921,\n5786983,\n5800089,\n5813145,\n5826127,\n5839332,\n5852352,\n5865406,\n5878520,\n5891561,\n5904577,\n5917583,\n5930672,\n5943777,\n5956845,\n5969954,\n5982939,\n5995955,\n6008887,\n6021859,\n6034853,\n6047914,\n6060852,\n6073902,\n6086846,\n6099890,\n6112891,\n6125905,\n6139005,\n6152008,\n6164976,\n6178055,\n6191134,\n6204006,\n6217047,\n6230025,\n6243137,\n6256157,\n6268950,\n6281850,\n6294880,\n6307854,\n6320783,\n6333770,\n6346739,\n6359727,\n6372759,\n6385750,\n6398760,\n6411621,\n6424585,\n6437478,\n6450524,\n6463538,\n6476474,\n6489472,\n6502519,\n6515451,\n6528444,\n6541470,\n6554452,\n6567411,\n6580260,\n6593326,\n6606273,\n6619295,\n6632211,\n6645043,\n6657923,\n6670804,\n6683806,\n6696711,\n6709795,\n6722794,\n6735695,\n6748552,\n6761489,\n6774395,\n6787249,\n6800239,\n6813192,\n6826057,\n6838975,\n6851866,\n6864928,\n6877737,\n6890595,\n6903508,\n6916351,\n6929345,\n6942266,\n6955229,\n6968229,\n6981142,\n6994053,\n7006943,\n7019911,\n7032873,\n7045744,\n7058671,\n7071649,\n7084585,\n7097378,\n7110341,\n7123329,\n7136261,\n7149099,\n7162172,\n7175070,\n7188010,\n7200837,\n7213777,\n7226696,\n7239661,\n7252624,\n7265456,\n7278251,\n7291115,\n7304018,\n7316887,\n7329881,\n7342739,\n7355504,\n7368429,\n7381276,\n7394032,\n7406982,\n7419884,\n7432639,\n7445516,\n7458445,\n7471320,\n7484264,\n7497063,\n7509988,\n7522824,\n7535700,\n7548535,\n7561435,\n7574170,\n7587022,\n7599794,\n7612748,\n7625549,\n7638354,\n7651279,\n7664134,\n7676915,\n7689731,\n7702574,\n7715474,\n7728305,\n7741178,\n7753967,\n7766793,\n7779545,\n7792385,\n7805346,\n7818155,\n7830988,\n7843890,\n7856583,\n7869478,\n7882314,\n7895233,\n7908066,\n7920913,\n7933766,\n7946432,\n7959316,\n7972124,\n7985018,\n7997861,\n8010615,\n8023413,\n8036158,\n8049029,\n8061849,\n8074668,\n8087510,\n8100189,\n8112936,\n8125719);\nvar\n l,r,k,i,j,cnt,ans,ii,ll,rr,d:longint;\n pr:array[1..lb] of boolean;\n prime:array[1..lb] of longint;\nbegin\n //reset(input,inf);\n //rewrite(output,outf);\n read(l,r);\n k:=trunc(sqrt(r));\n fillchar(pr,sizeof(pr),true);\n pr[1]:=false;\n cnt:=0;\n for i:=2 to k do if pr[i] then\n begin\n j:=i*i;\n inc(cnt);\n prime[cnt]:=i;\n while j <= k do\n begin\n pr[j]:=false;\n inc(j,i);\n end;\n end;\n k:=(r-1) div lb+1;\n ans:=0;\n if (2 >= l) and (2 <= r) then inc(ans);\n for ii:=1 to k do\n begin\n ll:=(ii-1)*lb+1;\n rr:=ii*lb;\n if not((l >= ll) and (l <= rr) or (r >= ll) and (r <= rr)) then continue;\n fillchar(pr,sizeof(pr),true);\n for i:=1 to cnt do\n begin\n d:=prime[i];\n j:=(ll div d)*d;\n while (d = j) or (j < ll) do inc(j,d);\n while j <= rr do\n begin\n pr[(j-1) mod lb+1]:=false;\n inc(j,d);\n end;\n end;\n if ii = 1 then pr[1]:=false;\n for i:=ll to rr do if (pr[(i-1) mod lb+1]) and (i >= l) and (i <= r) then\n if (i-1) mod 4 = 0 then inc(ans);\n end;\n inc(ans,max(a[(r-1) div lb]-a[(l-1) div lb+1],0));\n writeln(ans);\nend.\n", "src_uid": "55a83526c10126ac3a6e6e5154b120d0"} {"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 zapas,dist,r,ll,rr,sum,q,h,pos,ot,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 z,leftmax,leftmin,rightmax,rightmin,prev,next,d1,d2,aold,b,a,x,y:array[-1000..2000000] of int64;\n dda:array[-10..1200,-10..1200] of int64;\n zanx,zany:array[-10..2000000] of boolean;\n marked,zan:array[-10..1000000] 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 dd:array [0..201,-10..30] of int64;\n sss:array[0..nn] of string;\n st2:array[0..nn] of string;\n 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(aa,bb,dist,k);\n zapas:=bb;\n if bb1 then\n begin\n if i=1 then begin inc(n); x[n]:=x[n-1]+dist; end;\n\n if (i>1)and(i1)and(i1) and odd(i) then\n begin inc(n); x[n]:=x[n-1]+2*(dist); inc(n); x[n]:=k*aa; end;\n\n if (i=k)and not odd(i) then\n begin inc(n); x[n]:=x[n-1]+2*(aa-dist); inc(n); x[n]:=k*aa; end;\n\n\n\n\n\n\n\n end;\n\n if k=1 then begin inc(n); x[n]:=x[n-1]+dist;inc(n); x[n]:=x[n-1]+aa-dist; goto 2; end;\n\n\n 2: { for i:=0 to n do write(x[i],' '); writeln;\n }\n\n\n for i:=0 to n-1 do\n begin\n zapas:=zapas-(x[i]-x[i-1]);\n if zapas<0 then begin write(-1); goto 1; end;\n t:=x[i+1]-x[i];\n if t>bb then begin write(-1); goto 1; end;\n if (t>zapas)and(i>0) then begin inc(ot); zapas:=bb; end;\n { writeln('i= ',i,' zapas= ',zapas,' ot= ',ot);\n }\n end;\n\n writeln(ot);\n\n\n\n\n\n 1: close(output);\nend.\n\n\n\n\n\n\n\n\n\n\n", "src_uid": "283aff24320c6518e8518d4b045e1eca"}