[an error occurred while processing this directive]
Listing SQUARES.PAS 
Program Squares; 
const MAX=1000; 
type punct=record 
x,y:Longint 
end; 
var nr_patrate,n_viz:Integer; 
P,Q:array[1..MAX] of punct; 
f:Text; 
procedure Citire; 
var i,x,y,lung:Integer; 
begin 
Assign(f,'SQUARES.IN'); Reset(f); 
Readln(f,nr_patrate); 
for i:=1 to nr_patrate do 
begin 
Readln(f,x,y,lung); 
P[i].x:=x; 
P[i].y:=y+lung; 
Q[i].x:=x+lung; 
Q[i].y:=y 
end; 
Close(f) 
end; 
procedure Schimba(a,b:Integer); 
var aux:punct; 
begin 
aux:=P[a]; P[a]:=P[b]; P[b]:=aux; 
aux:=Q[a]; Q[a]:=Q[b]; Q[b]:=aux 
end; 
procedure QSort(a,b:Integer); 
var i,j,ii,jj,aux:Integer; 
begin 
if a>=b then Exit; 
i:=a; j:=b; 
ii:=1; jj:=0; 
while i<j do 
begin 
if P[i].y*P[j].x<P[j].y*P[i].x 
then 
begin 
Schimba(i,j); 
aux:=ii; 
ii:=-jj; 
jj:=-aux 
end; 
i:=i+ii; 
j:=j+jj 
end; 
QSort(a,i-1); 
QSort(i+1,b) 
end; 
function Orientare(x1,y1,x2,y2:Longint):Integer; 
var res:Longint; 
begin 
res:=x1*y2-x2*y1; 
if res>0 
then Orientare:=1 
else 
if res<0 then Orientare:=-1 
else Orientare:=0 
end; 
procedure Solutie; 
var i,j:Integer; 
R:punct; 
begin 
QSort(1,nr_patrate); 
n_viz:=0; 
for i:=1 to nr_patrate do 
begin 
R:=P[i]; 
for j:=1 to nr_patrate do 
begin 
if P[j].x+P[j].y>=P[i].x+P[i].y 
then 
else 
if Orientare(Q[j].x,Q[j].y,R.x,R.y)<> 
Orientare(P[j].x,P[j].y,R.x,R.y) 
then R:=Q[j] 
end; 
if Orientare(Q[i].x,Q[i].y,R.x,R.y)>0 
then Inc(n_viz) 
end 
end; 
procedure Scriere; 
begin 
Assign(f,'SQUARES.OUT'); Rewrite(f); 
Writeln(f,n_viz); 
Close(f) 
end; 
Begin 
Citire; 
Solutie; 
Scriere 
End.