PON  Prime or Not
Given the number, you are to answer the question: "Is it prime?"
Solutions to this problem can be submitted in C, C++, Pascal, Perl, Python, Ruby, Lisp, Hask, Ocaml, Prolog, Whitespace, Brainf**k and Intercal only.
Input
t – the number of test cases, then t test cases follows. [t <= 500]
Each line contains one integer: N [2 <= N <= 2^631]
Output
For each test case output string "YES" if given number is prime and "NO" otherwise.
Example
Input: 5 2 3 4 5 6 Output: YES YES NO YES NO
hide comments
gekko_code:
20210416 06:42:23
Try to use deterministic Miller Rabin algorithm, it only takes 0.01sec for this problem. Last edit: 20210416 06:43:05 

houda_bh:
20210213 12:31:54
time limit exceeded what to do ? 

princemishra:
20201225 06:33:07
Last edit: 20210709 07:13:37 

mamun_01_neub:
20201022 20:53:27
why it is run time error? 

chikku:
20200806 21:56:17
Use Miller Rabin Test, and get AC..


vayuhu:
20200802 10:34:40
Why is primality test of sqrt(N) is throwing TLE?


mehul007:
20200726 00:23:40
0.00 sec with miller rabin


impulse15:
20200723 20:25:01
can anyone provide the link of his code done by Fermat or miller method ??


prasant35:
20200714 23:47:59
how can i get AC in 0.00s ?my current best is 0.06s . 

panther_786:
20200714 09:28:22
Got AC with 2.68 sec using fermat's theorem.

Added by:  Roman Sol 
Date:  20050124 
Time limit:  21s 
Source limit:  5000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ADA95 ASM32 BASH CSHARP CLPS D ERL FORTRAN ICON JAVA JSRHINO LUA NEM NICE PHP PIKE ST 
Resource:  ZCon 2005 