program analysis;
{
	This program determines the average temperature of all the
	temperature stations in GYA.txt for each year in a range of years.
	It prints the year, the number of stations available, and the
	average temperature to the console for each year.
}
const
	max_num_measurements=1000000;
	period_start=1960;
	period_end=2000;
	first_year=1800;
	last_year=2007;

type
	measurement_type=record
		id:longint;{station identifier}
		year:integer;{year of the measurement}
		temperature:real;{year-long average}
		derivative_valid:boolean;{valid if last year's measurement exists}
		derivative:real;{change from last year}
		include:boolean;
	end;
	
var
	data:text;{the data file}
	measurements:array [1..max_num_measurements] of measurement_type;
	m,mm,num_measurements,y,counter:integer;
	t,sum:real;
	sorted,include:boolean;
	first_available_year,last_available_year:integer;
	id:longint;
	num:integer;

begin
	writeln('Read GYA.txt...');
	reset(data,'GYA.txt');
	num_measurements:=0;
	while not eof(data) do begin
		inc(num_measurements);
		with measurements[num_measurements] do begin
			readln(data,id,year,temperature);
		end;
	end;
	close(data);

	writeln('Calculating averages...');
	for y:=1800 to 2010 do begin
		sum:=0;
		counter:=0;

		for m:=1 to num_measurements do begin
			if measurements[m].year=y then begin
				sum:=sum+measurements[m].temperature;
				inc(counter);
			end;
		end;
		
		if counter>0 then 
			writeln(y:1,' ',counter:1,' ',sum/counter:7:2)
		else 
			writeln(y:1,' ',counter:1,' 0');
	end;
end.