The first one is giving NZEC because you need to declare your main function to return int i.e. int main and also need to add a return 0; at the end of main.
I dont know exactly about second one but i would suggest that you remove all the fread and stdin and replace it with simple printf and scanf or cout and cin.
Well i have submitted many solutions with void main and it worked…so i dont think that the return type of main has to be int necessarily…yes ommting return 0 gives NZEC but only when you declare the return type of main as int…
Please refer to this FAQ : http://www.codechef.com/wiki/faq . NZEC is caused by not returning zero from main in C or due to some exeptions. main has to be of type int.