#include <iostream>
using namespace std;

int main(void){
	int n;
	cout<<"Give temperature (-999 to stop) "<<endl;
	cin>>n;
	int i=0;
	int sum=0;
	int sumH=0;
	int sumL=0;
	int k=0;
	int max=-55;
	int min=60;
	int l=0;
	int m=0;
	int mean;
	int meanH;
	int meanL;
	while(n!=-999) {
		if(n<-50 || n>60) {
			cout<<"Temperature should be between -50 and 60 degrees, TRY AGAIN!"<<endl;
			if(i>=0){
				i--;
			}
			else if(i<-1){
				i=-1;
			}
		}
		else {
			sum+=n;
			if(n>17 && n<=28) {
				sumH+=n;
				l++;
				if(n==22) {
					k++;
				}
			}
			else if(n>1 && n<=17) {
				sumL+=n;
				m++;
			}
			if(max<=n) {
				max=n;
			}
			if(min>=n) {
				min=n;
			}
		}
		i++;
		cin>>n;
	}
	if(i!=0){
		mean=sum/i;
	}
	if(l!=0){
		meanH=sumH/l;
	}
	if(m!=0){
		meanL=sumL/m;
	}
	cout<<"The number of valid temperatures is: "<<i<<endl;
	if(i!=0){
		cout<<"The mean of valid temperatures is: "<<mean<<endl;
	}
	else{
		cout<<"The mean of valid temperatures is: 0"<<endl;
	}	
	cout<<"The number of temps between 18 and 28 is: "<<l<<endl;
	if(l!=0){
		cout<<"The mean of temps between 18 and 28 is: "<<meanH<<endl;
	}
	else{
		cout<<"The mean of temps between 18 and 28 is: 0"<<endl;
	}
	cout<<"The number of temps between 2 and 17 is: "<<m<<endl;
	if(m!=0){
		cout<<"The mean of temps between 2 and 17 is: "<<meanL<<endl;
	}
	else{
		cout<<"The mean of temps between 2 and 17 is: 0"<<endl;
	}
	cout<<"The number of temps=22 is: "<<k<<endl;
	cout<<"The temp of the hotest day is: "<<max<<endl;
	cout<<"The temp of the coldest day is: "<<min<<endl;
}
