Program AreaMisteryPart3(input,output); { Program for Higher Maths investigation '93  }
                                        { Identifies if when a square is devided into }
                                        { two sets of congruent shapes, when the loss }
                                        { or gain of area is as given. Does 160000    }
                                        { calculations.                               }
VAR
	NumX, NumY, 
	NumResult, SearchNum : integer;
	TextFile             : text;
	SFilePath             : string;
	
Begin
	write('Search number : ');
	readln(SearchNum);
	write('Save File Path : ');
	readln(SFilePath);
	rewrite(Textfile,SFilePath);
	for NumX := 1 to 400 do
	begin
		for NumY := 1 to 400 do
		begin
			NumResult := (sqr(NumX) - sqr(NumY)) - NumX*NumY;
			if (NumResult = SearchNum) or (NumResult = -SearchNum) then begin
				writeln('X  ',NumX:5,' Y ',NumY:5,' ',NumResult:2);
				writeln(Textfile,'X  ',NumX:5,' Y ',NumY:5,' ',NumResult:2);
			end;
		end;
	end;
	Writeln('Finished!');
	close(TextFile);
end.
			 