# data[].attributes.attachment_link.readable_text
program bai1;
uses crt;
var f:text;
a,b,c,tam,max,i,j:integer;
begin
clrscr;
assign(f,'D:\SBD11\COINS.INP');reset(f);
read(f,a,b,c);
close(f);
assign(f,'D:\SBD11\COINS.OUT');rewrite(f);
if a>b then
 begin
  tam:=a;
  a:=b;
  b:=tam;
 end;
max:=0;
for i:=c div a downto 0 do
 for j:=0 to c div b do
if a*i+b*j=c then
if i+j>max then max:=i+j;
   if max<>0 then write(f,max)
   else write(f,-1);
close(f);
end.
///////////------------------------
program bai2;
uses crt;
var f:text;
    Q,B:array[1..100] of longint;
    i,j,s,n,m,dem,z,d:integer;
begin
clrscr;
assign(f,'D:\SBD11\PT.INP');reset(f);
read(f,n);
for i:=1 to n do
read(f,Q[i]);
close(f);
assign(f,'D:\SBD11\PT.OUT');rewrite(f);
d:=0;
for i:=1 to n do
 if Q[i]>0 then d:=d+1;
if (n>=2) and (n<=100) and (d=n) then
 begin
 m:=0;
 for i:=1 to n do
  for j:=1 to Q[i] do
   if Q[i] mod j=0 then
     begin
      m:=m+1;
      B[m]:=j;
     end;
 s:=0;dem:=0;
 for i:=1 to m do
  for j:=1 to n do
   if (q[i] mod b[i]=0) and (b[i]<>1) then
     begin
      dem:=dem+1;
      if dem=n then s:=b[i];
    end;
 end;
write(f,s);
close(f);
end.
//-------------------
program bai3;
uses crt;
var f:text;
    A,B,C:array[1..100] of integer;
    i,j,n,t,dem,s,z,m,max,d:integer;
begin
clrscr;
assign(f,'D:\SBD11\NTCN.Inp');reset(f);
read(f,n);
for i:=1 to n do
readln(f,A[i]);
close(f);
assign(f,'D:\SBD11\NTCN.Out');rewrite(f);
m:=A[1];
for i:=1 to n do
if A[i]>m then m:=A[i];
for i:=1 to m do B[i]:=i;
d:=0;
for i:=1 to n do
 for j:=1 to m do
   if A[i]=B[j]-1 then
    begin
     d:=d+1;
     C[d]:=B[j];
    end;
max:=C[1];
for i:=1 to d do
 if c[i]>max then max:=c[i];
write(f,max);
close(f);
end.
//--------------
program bai4;
uses crt;
var f:text;
    A:array[1..100,1..100] of integer;
    B:array[1..100] of integer;
    m,n,i,j,dem,s,max,g,cot,dong:integer;
begin
clrscr;
assign(f,'D:\SBD11\HAIQUA.INP');reset(f);
read(f,n,m);
for i:=1 to n do
 for j:=1 to m do read(f,A[i,j]);
close(f);
assign(f,'D:\SBD11\HAIQUA.OUT');rewrite(f);
B[1]:=A[1,1];
max:=A[1,1];
for i:=1 to n do
 for j:=1 to m do
  if A[i,j]>max then
   begin
   max:=A[i,j];
   cot:=i;dong:=j;
   end;

for i:=1 to n do
 begin
  for j:=1 to m do
  write(A[i,j],' ');
  writeln;
 end;
m:=1;
 for i:=2 to 2 do
 for j:=1 to n do
    begin
     m:=m+1;
     B[m]:=A[i,j];
    end;
B[m+1]:=B[m-1]+B[m];
g:=m+1;
for i:=1 to 1 do
for j:=A[cot-1,dong] to n do
 begin
 g:=g+1;
 B[g]:=A[i,j]
 end;
for i:=1 to g do
write(f,B[i]);
close(f);
end.



# data[].attributes.attachment_link.readable_text
program tienxu;

uses crt;

var fi, fo: text;
    a, b: integer;
    c: longint;

procedure Nhap;
begin
  assign(fi, 'D:\SBD05\coins.inp');
  assign(fo, 'D:\SBD05\coins.out');
  reset(fi);
  rewrite(fo);

  readln(fi, a, b, c);
end;

procedure XuLy;
var tong, i, m: longint;
begin
  tong:=-1;
  if (a < 1) or (b < 1) or (a > 5000) or (b > 5000)
  or (c < 1) or (c > 1000000) then
  begin
    writeln(fo, -1);
    close(fi);
    close(fo);
    exit;
  end;
  if a > b then m:=c mod a else m:=c mod b;
  for i:=0 to m do
    if (c-b*i) mod a = 0 then
    begin
      tong:=(c-b*i) div a + i;
      break;
    end
    else if (c-a*i) mod b = 0 then
    begin
      tong:=(c-a*i) div b + i;
      break;
    end;

  writeln(fo, tong);
  close(fi);
  close(fo);
end;

BEGIN
Nhap;
XuLy;
END.

program pt;

uses crt;

type mang = array[1..100] of longint;
var fi, fo: text;
    n: integer;
    a: mang;
    dk: boolean;
procedure Nhap;
var i: integer;
begin
  assign(fi, 'D:\SBD05\pt.inp');
  assign(fo, 'D:\SBD05\pt.out');
  reset(fi);
  rewrite(fo);

  readln(fi, n);
  if (n < 2) or (n > 100) then dk:=false;
  for i:=1 to n do
  begin
    read(fi, a[i]);
    if (a[i] <= 0) or (a[i] > 2000000000) then dk:=false;
  end;
end;

function min(a: mang; n: integer): longint;
var i: integer;
    m: longint;
begin
  m:=a[1];
  for i:=2 to n do
    if a[i] < m then m:=a[i];
  min:=m;
end;

function ktuoc(a: mang; n: integer; k: longint): boolean;
var i: integer;
begin
  for i:=1 to n do
    if a[i] mod k <> 0 then exit(false);
  exit(true);
end;

function UCLN(a: mang; n: integer): longint;
var i, m: longint;
begin
  m:=min(a, n);
  for i:=m downto 1 do
    if ktuoc(a, n, i) = true then exit(i);
  exit(1);
end;

procedure XuLy;
begin
  if dk = true then writeln(fo, UCLN(a, n));
  close(fi);
  close(fo);
end;

BEGIN
dk:=true;
Nhap;
Xuly;
END.



program ntcn;

uses crt;

type mang = array[1..100] of integer;
var fi, fo: text;
    n: integer;
    a: mang;
    dk: boolean;
procedure Nhap;
var i: integer;
begin
  assign(fi, 'D:\SBD05\ntcn.inp');
  assign(fo, 'D:\SBD05\ntcn.out');
  reset(fi);
  rewrite(fo);

  readln(fi, n);
  if (n < 0) or (n > 100) then dk:=false;
  for i:=1 to n do
  begin
    read(fi, a[i]);
    if (a[i] > 1000) then dk:=false;
  end;
end;

function max(a: mang; n: integer): integer;
var i: integer;
    m: integer;
begin
  m:=a[1];
  for i:=2 to n do
    if a[i] > m then m:=a[i];
  max:=m;
end;

function ktntcn(a, b: integer): boolean;
var i, c: integer;
begin
  if a < b then c:=a else c:=b;
  for i:=c downto 2 do
    if (a mod i = 0) and (b mod i = 0) then exit(false);
  exit(true);
end;

function ktuoc(a: mang; n, k: integer): boolean;
var i: integer;
begin
  for i:=1 to n do
    if ktntcn(a[i], k) = false then exit(false);
  exit(true);
end;

procedure XuLy;
var m, i: integer;
begin
  if dk = false then
  begin
    close(fi);
    close(fo);
    exit;
  end;
  m:=max(a, n);
  for i:=m downto 1 do
    if ktuoc(a, n, i) = true then
    begin
      writeln(fo, i);
      break;
    end;
  close(fi);
  close(fo);
end;

BEGIN
dk:=true;
Nhap;
XuLy;
END.



program haiqua;

uses crt;

type mang2chieu = array[1..100, 1..100] of integer;
     mang = array[1..10000] of integer;
var fi, fo: text;
    m, n: integer;
    a: mang2chieu;
    b: mang;
    dk: boolean;

procedure Nhap;
var i, j: integer;
begin
  assign(fi, 'D:\SBD05\haiqua.inp');
  assign(fo, 'D:\SBD05\haiqua.out');
  reset(fi);
  rewrite(fo);

  readln(fi, m, n);
  if (m <= 0) or (n <= 0) or (m >= 100) or (n >= 100) then
  begin
    dk:=false;
    exit;
  end;
  for i:=1 to m do
  begin
    for j:=1 to n do
      read(fi, a[i, j]);
    readln(fi);
  end;
end;

procedure XuLy;
var x, y, c, next, i: integer;
    tong: longint;
begin
  if dk = false then
  begin
    close(fi);
    close(fo);
    exit;
  end;
  x:=1; y:=1;
  c:=1;
  b[1]:=a[1, 1];
  tong:=b[1];
  while (x < n) or (y < m) do
  begin
    if (y = m) or (a[y, x+1] >= a[y+1, x]) then
    begin
      next:=a[y, x+1];
      inc(x);
    end
    else if (x = n) or (a[y, x+1] < a[y+1, x]) then
    begin
      next:=a[y+1, x];
      inc(y);
    end;
    inc(c);
    b[c]:=next;
    tong:=tong+next;
  end;
  writeln(fo, tong);
  for i:=1 to c do write(fo, b[i], ' ');
  close(fi);
  close(fo);
end;

BEGIN
dk:=true;
Nhap;
XuLy;
END.




# data[].attributes.body
nopbai

# data[].attributes.body
nopbai

# data[].attributes.body
nopbai

# data[].attributes.body
nopbai

# data[].attributes.attachment_link.readable_text
program b1;
uses crt;
var i,a,b,c:integer;
    f,g:text;
BEGIN
   assign(f,'d:/SBD14/COINS.INP');reset(f);
   assign(g,'d:/SBD14/COINS.OUT');rewrite(g);
   readln(f,a,b,c);
   if a > b then
    begin
     a:=a+b;
     b:=a-b;
     a:=a-b;
    end;
   for i:=0 to c div b do
    if (c-b*i) mod a = 0 then
      begin
       writeln(g,i+((c-b*i) div a));
       break;
      end;
   close(f);
   close(g);
END.

program b2;
uses crt;
type mang=array[1..100]of integer;
var f,g:text;
    i,n,s,ucln:integer;
    a:mang;
function uc(a,b:integer):integer;
begin
  while a <> b do
   if a > b  then
    a:=a-b
   else
    b:=b-a;
end;
BEGIN
 assign(f,'d:/SBD14/PT.INP');reset(f);
 assign(g,'d:/SBD14/PT.OUT');rewrite(g);
 readln(f,n);
 for i:=1 to n do
  read(f,a[i]);
 ucln:=uc(a[1],a[2]);
 if n > n then
  for i:=3 to n do
   ucln:=uc(ucln,a[i]);
 writeln(g,ucln);
 close(f);
 close(g);
END.

program b3;
uses crt;
type mang=array[1..1000]of integer;
var f,g:text;
    n,i,max:integer;
    a:mang;
function nt(x:integer):boolean;
begin
 if x < 2 then exit(false);
 for i:=2 to x-1  do
  if x mod i = 0 then exit(false);
 exit(true);
end;
BEGIN
  assign(f,'d:/SBD14/NTCN.INP');reset(f);
  assign(g,'d:/SBD14/NTCN.OUT');rewrite(g);
  readln(f,n);
  max:=a[1];
  for i:=1 to n do
   if max < a[i] then max:=a[i];
  for i:=1 to n do
   readln(f,a[i]);
  max:=a[1];
  for i:=1 to n do
   if max < a[i] then max:=a[i];
  max:=max-1;
  while nt(max) = false do
    max:=max-1;
  writeln(g,max);
  close(f);
  close(g);
END.

program b4;
uses crt;
type mang=array[1..100,1..100]of integer;
var f,g:text;
    i,n,s,j,m:integer;
    a:mang;
BEGIN
  assign(f,'d:/SBD14/HAIQUA.INP');reset(f);
  assign(g,'d:/SBD14/HAIQUA.OUT');rewrite(g);
  readln(f,n,m);
  for i:=1 to n do
   for j:=1 to m do
    read(f,a[i,j]);
  i:=1;j:=1;s:=a[1,1];
  while (i <> n) or (j <> m) do
   begin
     if a[i+1,j] > a[i,j+1] then
      inc(i)
     else
      inc(j);
     s:=s+a[i,j];
   end;
  writeln(g,s);
  i:=1;j:=1;
  write(g,a[1,1],' ');
  while (i <> n ) or (j <> m) do
   begin
    if a[i+1,j] > a[i,j+1] then
     inc(i)
    else
     inc(j);
    write(g,a[i,j],' ');
   end;
  close(f);
  close(g);
END.

# data[].attributes.attachment_link.readable_text
program B6;

uses crt;

type mang2chieu = array[1..50, 1..50] of integer;
     mang = array[1..50] of integer;
var fi, fo: text;
    n, demin: integer;
    mai, maj: integer;
    a: mang2chieu;
    dem: mang;

procedure Nhap;
var i, j: integer;
begin
  assign(fi, 'D:\FP_Tien\18.01\matrannt.inp');
  assign(fo, 'D:\FP_Tien\18.01\matrannt.out');
  reset(fi);
  rewrite(fo);

  readln(fi, n);
  for i:=1 to n do
  begin
    for j:=1 to n do
      read(fi, a[i,j]);
    readln(fi);
  end;
end;

function snt(n: integer): boolean;
var i: integer;
begin
  if n < 2 then exit(false);
  for i:=2 to round(sqrt(n)) do if n mod i = 0 then exit(false);
  exit(true);
end;

procedure kthangsnt(a: mang; n, k: integer);
var i, c: integer;
begin
  c:=0;
  for i:=1 to n do
    if snt(a[i]) = true then
    begin
      inc(demin);
      inc(dem[i]);
      inc(c);
      write(fo, a[i], ' ');
      if demin = 10 then
      begin
        writeln(fo);
        demin:=0;
      end;
    end;
  if c = n then mai:=k;
end;

procedure XuLy;
var i, j: integer;
begin
  demin:=0;
  for i:=1 to n do
    kthangsnt(a[i], n, i);
  for i:=1 to n do
    if dem[i] = n then
    begin
      maj:=i;
      break;
    end;
  writeln(fo);
  writeln(fo, '-----------------------------');
  for i:=1 to n do write(fo, a[i, maj], ' ');
  writeln(fo);
  for i:=1 to n do write(fo, a[mai, i], ' ');
  writeln(fo);
  writeln(fo, '-----------------------------');
  writeln(fo, 'A[',mai,',',maj,']-',a[mai, maj]);
  close(fi);
  close(fo);
end;

BEGIN
Nhap;
XuLy;
END.


# data[].attributes.body
program bt6;

uses crt;

var f1,f2:text;

i,j,m,x,y,k:integer;

a:array[1..50,1..50]of integer;

b:array[1..50,1..50]of boolean;

kt:boolean;

function nt(x:integer):boolean;

var ii:integer;

begin

if x<2 then

exit(false);

for ii:=2 to x div 2 do

if x mod ii=0 then

exit(false);

exit(true);

end;

begin

clrscr;

assign(f1,'D:\FP_LAM\18.1\inp\MATRANNT.INP');

reset(f1);

assign(f2,'D:\FP_LAM\18.1\out\MATRANNT.OUT');

rewrite(f2);

readln(f1,m);

for i:=1 to m do

for j:=1 to m do

read(f1,a[i,j]);

for i:=1 to m do

for j:=1 to m do

b[i,j]:=false;

for i:=1 to m do

for j:=1 to m do

if nt(a[i,j])then

begin

inc(k);

if k mod 10=0 then

writeln(f2,a[i,j])

else

write(f2,a[i,j],' ');

b[i,j]:=true;

end;

for i:=1 to m do

begin

kt:=true;

for j:=1 to m do

if b[i,j]=false then

begin

kt:=false;

break;

end;

if kt then

break;

end;

x:=i;

for i:=1 to m do

begin

kt:=true;

for j:=1 to m do

if b[j,i]=false then

begin

kt:=false;

break;

end;

if kt then

break;

end;

y:=i;

writeln(f2);

writeln(f2,'-------------------------------------------------------');

for i:=1 to m do

write(f2,a[i,y],' ');

writeln(f2);

for i:=1 to m do

write(f2,a[x,i],' ');

writeln(f2);

writeln(f2,'-----------------------------');

write(f2,'A[',x,',',y,']-',a[x,y]);

close(f2);

//readln;

end.

# data[].attributes.body
10

1000 1012 1019 1024 1035 1034 1034 1048 1050 1062

1063 1069 1087 1091 1094 1092 1102 1100 1117 1123

1129 1151 1153 1164 1171 1181 1180 1190 1200 1214

1217 1223 1229 1231 1237 1249 1259 1277 1279 1283

1289 1294 1297 1301 1304 1308 1320 1321 1328 1360

1368 1372 1381 1390 1402 1420 1428 1429 1434 1438

1444 1452 1453 1458 1470 1484 1480 1482 1488 1492

1498 1512 1523 1530 1544 1540 1554 1555 1562 1570

1578 1583 1597 1601 1607 1608 1613 1620 1622 1622

1637 1657 1663 1660 1668 1693 1697 1699 1700 1720

# data[].attributes.attachment_link.readable_text
PROGRAM CT;
USES CRT;
const mm=14; kk=7; nn=100000;
fi='D:\pas\xaucon.inp';
fo='D:\pas\xaucon.ou';
var 	f,f1:text;
st:string;
n,m,k,d,i,soxau:longint; dem:array[1..14] of integer;
function soluong(s:string):integer; var i,dem:integer;
begin dEM:=0;
for i:=1 to length(s) do
if s[i]='A' then dEM:=dEM+1;
soluong:=dEM;
end;
procedure xuly;
var i,j:integer;
c:char;
tam,s1: string;
begin
soxau:=0;
for i:=1 to 14 do dem[i]:=0;
st:='';
readln(f,n,m,k);
for i:=1 to m do
begin
read(f,c);
st:=st+c;
end;
for i:=k to m do
for j:=1 to m-i+1 do
begin
tam:=copy(st,j,i);
if soluong(tam)=k then
begin
write(f1, tam, ' ');
soxau:=soxau+1;
end;
end;
d:=m;
repeat read(f,c);
st:=st+c;
d:=d+1;
delete(st,1,1);
for i:=k to m do
begin
s1:=copy(st,m-i+1,i);
if soluong(s1)=k then
begin
soxau:=soxau+1;
write(f1, tam, ' ');
end;
end;
until d=n;
READLN(F);
end;
BEGIN
assign(f1,fo); rewrite(f1);
assign(f,fi); reset(f); while not eof(f) DO
begin
xuly;
READLN(F,ST);
d:=0;
writeln(f1,'tong so xau la: ', soxau);
end;
close(f);
close(f1);
readln;
end.

# data[].attributes.attachment_link.readable_text
program bai6;
uses crt;
var A:array[1..100] of integer;
    n,i,j,m:integer;
begin
clrscr;
write('nhap n: ');readln(n);
m:=0;
while (n<>0) do
 begin
  i:=n mod 2;
  m:=m+1;
  A[m]:=i;
  n:=n div 2;
 end;
 for i:=m downto 1 do write(A[i],' ');
readln;
end.

# data[].attributes.attachment_link.readable_text
program B7;

uses crt;

var fi, fo: text;
    n: longint;
    m, k: integer;
    s: string;

procedure Nhap;
begin
  readln(fi, n, m, k);
  readln(fi, s);
end;

function DemXH(s: string; c: char): integer;
var i, dem: integer;
begin
  dem:=0;
  for i:=1 to length(s) do
    if s[i] = c then inc(dem);
  DemXH:=dem;
end;

procedure XuLy;
var i, j, dem: integer;
    subs: string;
begin
  dem:=0;
  for i:=1 to n do
    for j:=i to i+m-1 do
    begin
      if j>n then break;
      subs:=copy(s, i, j-i+1);
      if DemXH(subs, 'A') = k then
      begin
        write(fo, subs, ' ');
        inc(dem);
      end;
    end;
  writeln(fo);
  writeln(fo, 'tong so xau la: ', dem);
end;

BEGIN
  assign(fi, 'D:\FP_Tien\14.01\xaucon.inp');
  assign(fo, 'D:\FP_Tien\14.01\xaucon.out');
  reset(fi);
  rewrite(fo);
  while not eof(fi) do
  begin
    Nhap;
    XuLy;
    if not eof(fi) then readln(fi);
  end;
  close(fi);
  close(fo);
END.


# data[].attributes.body
uses crt;

var n1,n2,i:integer;

function bt(m:integer):boolean;

var kt:boolean;

h:integer;

begin

kt:=true;

while (m>=10) do

begin

h:=m mod 10;

m:=m div 10;

if h< (m mod 10) then

begin

kt:=kt;

kt:=false;

end;

end;

bt:=kt;

end;

begin

clrscr;

write ('nhap n1:'); readln (n1);

write ('nhap n2:'); readln (n2);

for i:=n1 to n2 do

if bt(i)=true then

write (i,' ');

readln;

end.

# data[].attributes.attachment_link.readable_text
program bai4;
uses crt;
var st,s,sct:string;
    n,i,j,g,k:longint;
begin
clrscr;
repeat
write('nhap n,k: ');readln(n,k);
str(n,s);
if (k=0) or (k>length(s)) then writeln('khong tim duoc');
until (k>0) and (k<=length(s));
 for i:=1 to n do
  begin
   str(n,st);
   for j:=1 to length(st) do
     if j=k then sct:=st[j];
  end;
 write(sct);
readln;
end.

# data[].attributes.attachment_link.readable_text
program bai3;
uses crt;
var A:array[1..100] of integer;
    n,s,i,j,z,dem:integer;
begin
clrscr;
write('nhap n: ');readln(n);
dem:=0;dem:=0;
for i:=1 to n do A[i]:=i;
for i:=0 to n do
 for j:=0 to n do
  if i+j+z=n then dem:=dem+1;
for i:=1 to n do
 begin
 s:=s+1;
 if s=n then dem:=dem+1;
 end;
write(dem);
readln;
end.


# data[].attributes.attachment_link.readable_text
program bai2;
uses crt;
var
   i,hsd,hsc:longint;
begin
clrscr;
for i:=1000 to 9999 do
 begin
    hsd:= i div 100;
    hsc:= i mod 100;
    if i = sqr(hsd+hsc) then write(i:5);
 end;
readln;
end.




# data[].attributes.attachment_link.readable_text
program bai1;
uses crt;
var f:text;
    n,i,j:integer;
    s,s2:real;
begin
clrscr;
assign(f,'D:\FP_HUY\14.1\TONG.INP');reset(f);
read(f,n);
close(f);
assign(f,'D:\FP_HUY\14.1\TONG.OUT');rewrite(f);
s:=0;
for i:=1 to n do
begin
s2:=1/(i*i);
 s:=s+s2;
 end;
 write(f,s:1:7);
close(f);
end.

# data[].attributes.body
uses crt;

var i:integer;

begin

clrscr;

for i:=1000 to 9999 do

if sqr((i div 100) + (i mod 100))=i then

writeln (i);

readln;

end.

# data[].attributes.attachment_link.readable_text
program bai7;
uses crt;
var f:text;
    A,B:array[1..100] of string;
    st:string;
    n,i,j,m,dem,dem2:integer;
begin
clrscr;
assign(f,'D:\FP_HUY\11.1\CAU7.INP');reset(f);
readln(f,n);
for i:=1 to n do
 readln(f,A[i]);
close(f);
assign(f,'D:\FP_HUY\11.1\CAU7.OUT');rewrite(f);
st:='';m:=0;
for i:=1 to n do
 begin
 st:=A[i];
 dem:=0;dem2:=0;
 for j:=1 to length(st) do
  begin
   if st[j]='(' then dem:=dem+1;
   if st[j]=')' then dem2:=dem2+1;
  end;
  if dem=dem2 then B[i]:='YES'
  else if dem<>dem2 then B[i]:='NO';
 end;
for i:=1 to n do writeln(f,B[i]);
close(f);
end.



# data[].attributes.attachment_link.readable_text
program bai3;
uses crt;
var f:text;
    B,C:array[1..100] of string;
    st,s,x,g,p:string;
    k,i,j,dem,max,m,d,z:integer;
    ch,ch2:char;
begin
clrscr;
assign(f,'D:\FP_HUY\11.1\CAU3.INP');reset(f);
readln(f,st,k);
close(f);
assign(f,'D:\FP_HUY\11.1\CAU3.OUT');rewrite(f);
s:='';m:=0;
for i:=1 to length(st) do
if st[i]<>' ' then s:=s+st[i]
 else
  begin
   m:=m+1;
   B[m]:=s;
   s:='';
  end;
max:=0;
for i:=1 to m do
if length(B[i])>max then max:=length(B[i]);
d:=0;
for i:=1 to m do
 if length(B[i])=max then
  begin
   d:=d+1;
   C[d]:=B[i];
   x:=C[1];
  end;
writeln(d);
g:='';
for ch:='A' to 'Z' do g:=g+ch;
p:='';
for j:=1 to length(x) do
for i:=1 to length(g) do
 if x[j]=g[i] then p:=p+g[i-1];
write(f,p);
close(f);
end.

# data[].attributes.attachment_link.readable_text
program bai2;
uses crt;
var n,i,a,j,dem:integer;
    st:string;
begin
clrscr;
write('nhap n: ');readln(n);
for i:=1 to n do
  if i mod 9=0 then
   begin
    str(i,st);
    dem:=0;
    for j:=1 to length(st) do
     if (length(st)=2) and (st[j]=st[j+1]) then dem:=dem+1;
   end;
write(dem);
readln;
end.

# data[].attributes.attachment_link.readable_text
program bai1;
uses crt;
var A:array[1..100] of integer;
    n,i,j,tam:integer;
    s:longint;
begin
clrscr;
write('nhap n: ');readln(n);
for i:=1 to n do
 begin
  write('A[',i,']=');readln(A[i]);
 end;
for i:=1 to n do
 for j:=i+1 to n do
  if A[i]<A[j] then
  begin
   tam:=A[i];
   A[i]:=A[j];
   A[j]:=tam;
  end;
s:=A[1]*A[2]*A[3];
write(s);
readln;
end.

# data[].attributes.attachment_link.readable_text
program B5;

uses crt;

type mang = array[1..10000] of integer;
var a: mang;
    n: integer;

procedure Nhap;
var i: integer;
begin
  clrscr;
  readln(n);
  for i:=1 to n do
    read(a[i]);
  readln;
end;

function SoSanh(a, b: integer): boolean;
var i, av, bv: integer;
    as, bs: string;
begin
  str(a, as);
  str(b, bs);
  for i:=1 to length(as) do
  begin
    val(as[i], av);
    val(bs[i], bv);
    if av < bv then exit(true);
    if av > bv then exit(false);
  end;
  SoSanh:=length(as) < length(bs);
end;

procedure SXMang(var a: mang; n: integer);
var i, j: integer;
    tmp: integer;
begin
  for i:=1 to n-1 do
    for j:=i+1 to n do
      if SoSanh(a[i], a[j]) = true then
      begin
        tmp:=a[i];
        a[i]:=a[j];
        a[j]:=tmp;
      end;
end;

procedure XuLy;
var s, sv: string;
    i: integer;
begin
  SXMang(a, n);
  s:='';
  for i:=1 to n do
  begin
    str(a[i], sv);
    s:=s+sv;
  end;
  writeln(s);
  readln;
end;
BEGIN
Nhap;
XuLy;
END.


# data[].attributes.body
program bt1;

uses crt;

var i,j,k,n,max:int32;

a:array[1..10000]of string;

b:array[1..10000]of int32;

st:string;

begin

clrscr;

readln(n);

readln(st);

k:=1;

for i:=1 to length(st)do

if(st[i]=' ')then

inc(k)

else

a[k]:=a[k]+st[i];

for i:=1 to n do

val(a[i],b[i]);

for i:=1 to n-2 do

for j:=i+1 to n-1 do

for k:=j+1 to n do

if b[i]*b[j]*b[k]>max then

max:=b[i]*b[j]*b[k];

write(max);

readln;

end.

# data[].attributes.body
program sap_xep_danh_sach;

uses crt;

var f1,f2:text;

ho,ten,tlot:array[1..100]of string;

st:string;

j,i,d,n:integer;

tam:string;

procedure change;

begin

tam:=ten[i];

ten[i]:=ten[j];

ten[j]:=tam;

tam:=ho[i];

ho[i]:=ho[j];

ho[j]:=tam;

tam:=tlot[i];

tlot[i]:=tlot[j];

tlot[j]:=tam;

end;

begin

clrscr;

assign(f1,'D:\FP_LAM\7.1\inp\SAPXEP.INP');

reset(f1);

assign(f2,'D:\FP_LAM\7.1\out\SAPXEP.OUT');

rewrite(f2);

readln(f1,n);

for i:=1 to n do

begin

readln(f1,st);

for j:=1 to length(st)do

if st[j]=' 'then

begin

ho[i]:=copy(st,1,j-1);

d:=j+1;

break;

end;

for j:=length(st)downto 1 do

if st[j]=' 'then

begin

ten[i]:=copy(st,j+1,length(st)-j);

break;

end;

tlot[i]:=copy(st,d,j-d);

end;

for i:=1 to n do

for j:=n downto i+1 do

if ten[i]>ten[j]then

begin

change;

end

else

if ten[i]=ten[j]then

if tlot[i]>tlot[j]then

begin

change;

end

else

if tlot[i]=tlot[j]then

if ho[i]>ho[j]then

begin

change;

end;

for i:=1 to n do

if tlot[i]='' then

writeln(f2,ho[i],' ',ten[i])

else

writeln(f2,ho[i],' ',tlot[i],' ',ten[i]);

close(f2);

readln;

end.

# data[].attributes.body
program phong_kham;

uses crt;

var f1,f2:text;

a,b:array[1..100]of integer;

i,j,k,tam,n:integer;

begin

clrscr;

assign(f1,'D:\FP_LAM\7.1\inp\PHONGKHAM.INP');

reset(f1);

assign(f2,'D:\FP_LAM\7.1\out\PHONGKHAM.OUT');

rewrite(f2);

readln(f1,n);

for i:=1 to n do

read(f1,a[i],b[i]);

for i:=1 to n do

for j:=n downto i+1 do

if a[i]>a[j]then

begin

tam:=a[i];

a[i]:=a[j];

a[j]:=tam;

tam:=b[i];

b[i]:=b[j];

b[j]:=tam;

end;

k:=0;

for i:=1 to n do

if k>a[i]then

k:=k+b[i]

else

k:=a[i]+b[i];

write(f2,k);

close(f2);

end.

# data[].attributes.body
program taxi;

uses crt;

var f1,f2:text;

s,i,n:int32;

begin

clrscr;

assign(f1,'D:\FP_LAM\7.1\inp\TAXI.INP');

reset(f1);

assign(f2,'D:\FP_LAM\7.1\out\TAXI.OUT');

rewrite(f2);

read(f1,n);

for i:=1 to n do

case i of

1:s:=s+14000;

2..10:s:=s+13000;

else

s:=s+11000;

end;

write(f2,s);

close(f2);

end.

# data[].attributes.body
program tach_cum;

uses crt;

var f1,f2:text;

st:string;

dem,i,d:integer;

c:array[1..100]of string;

a:array[1..100]of integer;

begin

clrscr;

assign(f1,'D:\FP_LAM\7.1\inp\CUM.INP');

reset(f1);

assign(f2,'D:\FP_LAM\7.1\out\CUM.OUT');

rewrite(f2);

read(f1,st);

d:=0;

for i:=1 to length(st)do

if st[i]='('then

begin

inc(d);

a[d]:=i;

end

else

if st[i]=')'then

begin

inc(dem);

c[dem]:=copy(st,a[d],i-a[d]+1);

dec(d);

end;

if d<>0 then

write(f2,-1)

else

begin

writeln(f2,dem);

for i:=1 to dem do

writeln(f2,c[i]);

end;

close(f2);

end.

# data[].attributes.body
program mat_bang_lon_nhat;

uses crt;

var f1,f2:text;

i,tam,max,n:int32;

a:array[1..100000]of integer;

begin

clrscr;

assign(f1,'D:\FP_LAM\7.1\inp\MB.INP');

reset(f1);

assign(f2,'D:\FP_LAM\7.1\out\MB.OUT');

rewrite(f2);

readln(f1,n);

for i:=1 to n do

read(f1,a[i]);

i:=0;

while(i<=n)do

begin

inc(i);

tam:=i;

while(a[tam]=a[tam+1])and(tam<=n)do

inc(tam);

if max<tam-i+1 then

max:=tam-i+1;

i:=tam;

end;

write(f2,max);

close(f2);

end.

# data[].attributes.body
program xep_hang;

uses crt;

var f1,f2:text;

n,m,i,j:integer;

a:array[1..50,1..15]of integer;

b,c:array[1..50]of real;

tam:real;

begin

clrscr;

assign(f1,'D:\FP_LAM\7.1\inp\XH.INP');

reset(f1);

assign(f2,'D:\FP_LAM\7.1\out\XH.OUT');

rewrite(f2);

readln(f1,n,m);

for i:=1 to n do

for j:=1 to m do

read(f1,a[i,j]);

for i:=1 to n do

begin

for j:=1 to m do

b[i]:=b[i]+a[i,j];

b[i]:=b[i]/m;

end;

for i:=1 to n do

c[i]:=b[i];

for i:=1 to n do

for j:=n downto i+1 do

if c[i]<c[j]then

begin

tam:=c[i];

c[i]:=c[j];

c[j]:=tam;

end;

for i:=1 to n do

for j:=1 to n do

if b[i]=c[j] then

begin

writeln(f2,j);

break;

end;

close(f2);

readln;

end.

# data[].attributes.body
program bt1;

uses crt;

var n:int32;

s:extended;

begin

clrscr;

write('nhap so: ');

readln(n);

if n>=1000 then

begin

n:=n-1000;

s:=s+5550000;

end

else

begin

s:=s+n*5550;

n:=0;

end;

if n>=1000 then

begin

n:=n-1000;

s:=s+5450000;

end

else

begin

s:=s+n*5450;

n:=0;

end;

if n>=1000 then

begin

n:=n-1000;

s:=s+5250000;

end

else

begin

s:=s+n*5250;

n:=0;

end;

if n>1 then

s:=s+n*5550;

s:=s+(s*10/100);

write(s:0:0);

readln;

end.

# data[].attributes.body
program bt2;

uses crt;

var a,b,tam:longword;

function ucln(x,y:longword):longword;

begin

while(y<>0)do

begin

tam:=x mod y;

x:=y;

y:=tam;

end;

exit(x);

end;

begin

clrscr;

write('nhap a: ');

readln(a);

write('nhap b: ');

readln(b);

write(ucln(a,b));

readln;

end.

# data[].attributes.body
program bt3;

uses crt;

var i,n,dem,j:int32;

a,b:array[1..1000000]of int32;

function kt(x:int32):boolean;

begin

for j:=x+1 to n do

if a[x]<=a[j]then

exit(false);

exit(true);

end;

begin

clrscr;

write('nhap n: ');

readln(n);

for i:=1 to n do

begin

write('nhap a[',i,']= ');

readln(a[i]);

end;

for i:=1 to n do

if kt(i) then

begin

inc(dem);

b[dem]:=a[i];

end;

writeln(dem);

for i:=1 to dem do

write(b[i],' ');

readln;

end.

# data[].attributes.body
program B8;

uses crt;

var f1,f2:text;

i,a,b,n:int32;

kt:boolean;

begin

clrscr;

assign(f1,'D:\FP_LAM\30.11\inp\B8.inp');

reset(f1);

assign(f2,'D:\FP_LAM\30.11\out\B8.out');

rewrite(f2);

read(f1,n,a,b);

kt:=true;

for i:=n div b downto 0 do

if(n-b*i)mod a=0 then

begin

write(f2,(n-b*i)div a+i);

close(f2);

exit;

end;

write(f2,-1);

close(f2);

end.

# data[].attributes.body
program bt9;

uses crt;

var f1,f2:text;

a,b:array[1..100]of integer;

dem,i,j,k,n,m:integer;

begin

clrscr;

assign(f1,'D:\FP_LAM\4.1\inp\BOISO.INP');

reset(f1);

assign(f2,'D:\FP_LAM\4.1\out\BOISO.OUT');

rewrite(f2);

readln(f1,n,m);

for i:=1 to n do

read(f1,a[i]);

for i:=1 to n-2 do

for j:=i+1 to n-1 do

for k:=j+1 to n do

if a[i]+a[j]+a[k]=m then

begin

inc(dem);

b[dem]:=i*100+j*10+k;

end;

writeln(f2,dem);

for i:=1 to dem do

write(f2,b[i],' ');

close(f2);

end.

# data[].attributes.body
program bt7;

uses crt;

var f1,f2:text;

a:array['0'..'9']of integer;

stx,sty,st:string;

i:integer;

ch:char;

begin

clrscr;

assign(f1,'D:\FP_LAM\4.1\inp\SINHXAU.INP');

reset(f1);

assign(f2,'D:\FP_LAM\4.1\out\SINHXAU.OUT');

rewrite(f2);

readln(f1,stx);

read(f1,sty);

stx:=copy(stx,4,length(stx)-4);

sty:=copy(sty,4,length(sty)-4);

for i:=1 to length(stx)do

if a[stx[i]]=0 then

inc(a[stx[i]]);

for i:=1 to length(sty)do

if a[sty[i]]=1 then

inc(a[sty[i]]);

st:='';

for ch:='9'downto'0'do

if a[ch]=2 then

st:=st+ch;

if st<>''then

write(f2,st)

else

write(f2,'Khong co');

close(f2);

end.