program solitario;
var N,M,soluzione,area, arearimanente:longint;
griglia:array[0..10,0..10] of longint;
function gioca(r, c: longint): boolean;
begin
(*tris orizzontale*)
if (c-2>=0) and (griglia[r][c-2]=1) and (griglia[r][c-1]=1) then gioca:=false
(*tris verticale*)
else if (r-2>=0) and (griglia[r-2][c]=1) and (griglia[r-1][c]=1) then gioca:=false
(* Tris diagonale in alto a sx*)
else if (r-2>=0 ) and (c-2>=0) and (griglia[r-2][c-2]=1) and (griglia[r-1][c-1]=1) then gioca:=false
(* Tris diagonale in alto a dx*)
else if (r-2>=0) and (c+2<=M) and (griglia[r-2][c+2]=1) and (griglia[r-1][c+1]=1) then gioca:=false
else gioca := true;
end;
Procedure riempi (riga:longint; colonna:longint; tot:longint);
begin
arearimanente:=N*M-(M*(riga)+colonna+1);
if tot+((2 div 3)*arearimanente)<soluzione then begin if tot>soluzione then soluzione:=tot; exit; end
else begin
if colonna=M then begin riga:=riga+1; colonna:=0; end;
if riga=N then begin if tot>soluzione then soluzione:=tot; exit end;
(*Se posso, metto la X*)
if gioca (riga,colonna)=true then
begin
griglia[riga][colonna]:=1;
Riempi(riga,colonna+1, tot+1);
(* Reset della griglia[riga][col]*)
griglia[riga][colonna]:=0;
end;
(* Non metto la X*)
Riempi(riga,colonna+1, tot); end;
end;
begin
readln(N,M);
area:=N*M;
soluzione:=0; riempi(0,0,0);
writeln(soluzione);
end.
cHJvZ3JhbSBzb2xpdGFyaW87Cgp2YXIgTixNLHNvbHV6aW9uZSxhcmVhLCBhcmVhcmltYW5lbnRlOmxvbmdpbnQ7CiAgICBncmlnbGlhOmFycmF5WzAuLjEwLDAuLjEwXSBvZiBsb25naW50OwogICAgCmZ1bmN0aW9uIGdpb2NhKHIsIGM6IGxvbmdpbnQpOiBib29sZWFuOwpiZWdpbgogICAgICAoKnRyaXMgb3JpenpvbnRhbGUqKQogICBpZiAoYy0yPj0wKSBhbmQgKGdyaWdsaWFbcl1bYy0yXT0xKSBhbmQgKGdyaWdsaWFbcl1b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b2x1emlvbmU6PXRvdDsgZXhpdCAgZW5kOwogICAgICAgICAgKCpTZSBwb3NzbywgbWV0dG8gbGEgWCopCiAgICBpZiBnaW9jYSAocmlnYSxjb2xvbm5hKT10cnVlIHRoZW4KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYmVnaW4gCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmlnbGlhW3JpZ2FdW2NvbG9ubmFdOj0xOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgUmllbXBpKHJpZ2EsY29sb25uYSsxLCB0b3QrMSk7CiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgqIFJlc2V0IGRlbGxhIGdyaWdsaWFbcmlnYV1bY29sXSopCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBncmlnbGlhW3JpZ2FdW2NvbG9ubmFdOj0wOwogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbmQ7CiAgICAgKCogTm9uIG1ldHRvIGxhIFgqKQogICAgUmllbXBpKHJpZ2EsY29sb25uYSsxLCB0b3QpOyBlbmQ7CmVuZDsgICAgICAgICAgICAgICAgICAgCmJlZ2luCglyZWFkbG4oTixNKTsKCWFyZWE6PU4qTTsKCXNvbHV6aW9uZTo9MDsgcmllbXBpKDAsMCwwKTsgCiAgICAgICB3cml0ZWxuKHNvbHV6aW9uZSk7CQplbmQu