CodechefJul 28, 2025

Candy Division

Hazrat Ali

Codechef

There will be a fight amongst the friends if all of them do not get the same number of candies.

Chef wants to divide all the candies such that there is no fight. Find whether such distribution is possible.

Input Format

  • The first line of input will contain a single integer TT, denoting the number of test cases.
  • Each test case consists of a single integer NN - the number of candies.

Output Format

For each test case, output YES, if we can distribute all the candies between the three friends equally. Otherwise output NO.

You can output each character of the answer in uppercase or lowercase. For example, the strings yEsyesYes, and YES are considered the same.

Constraints

  • 1≤T≤100
  • 1≤N≤100

Sample 1:

Input
4
3
4
2
6
Output
YES
NO
NO
YES

Solution

t = int(input())
for _ in range(t):
    n = int(input())
    if n % 3 == 0:
        print("YES")
    else:
        print("NO")





 

Comments