Correct method for getting Input?

im using codechef for first time.
what is the correct method for getting input?

solution 1:

#include <stdio.h>

#include <inttypes.h>
int i,b,n;
int main (){


scanf("%d",&n);
unsigned long long int temp[n],j;

for(i=0; i<n;i++){
	scanf("%llu",&temp[i]);}

	for(i=0; i<n;i++){
		b= 0;
	for(j=2; j<=temp[i]/2; j++){
		if((temp[i]%j) == 0){
			b++;
		if(b==2){break;}
		}
	}if(b==1){printf("YES\n");}
	else{printf("NO\n");}
}
return 0;
}

solution 2:

#include <stdio.h>

#include <inttypes.h>
int i,b,n;
int main (){


scanf("%d",&n);
unsigned long long int temp,j;

for(i=0; i<n;i++){
	scanf("%llu",&temp);


		b= 0;
	for(j=2; j<=temp/2; j++){
		if((temp%j) == 0){
			b++;
		if(b==2){break;}
		}
	}if(b==1){printf("YES\n");}
	else{printf("NO\n");}
}
return 0;
}

It is showing time limit exceed for both of them!!

Why do you think the TLE is because of your input method than your algorithm?

for(){for(){}}
you are using this kind of complex structure. read your problem carefully and design algo with least complexity.
ex.
for(){}
for(){}
is less complex then previous code.

Input method has a little effect on your time taken by your program if the input file is not too big . You must improve your algorithm to have a better time complexity .

Sorry, my question was, does it provide input one by one(& requri answeredfor each)…or provides all n inputs & wants all outputs at once.