ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050B - Transfusion
Language: python

Solution 1 (runtime: 218 ms):
a=int(input())
for _ in range(a):
    b=int(input())
    c=list(map(int,input().split()))
    if sum(c)%b!=0:
        print('NO')
    else:
        t=sum(c)//b
        w=[]
        l=[]
        for i in range(b):
            if i%2==0:
                w.append(c[i])
            else:
                l.append(c[i])
        if sum(l)//len(l)==t==sum(w)//len(w):
            print('YES')
        else:
            print('NO')

Solution 2 (runtime: 202 ms):
for i in range(int(input())):

    input()

    a = list(map(int, input().split()))

    a1=[]

    a2=[]

    for i in range(len(a)):

        if i%2==0:

            a1.append(a[i])

        if i%2==1:

            a2.append(a[i])

    if (sum(a1)+sum(a2))%(len(a1)+len(a2))==0:

        if sum(a1)/len(a1)==sum(a2)/len(a2):

            print("YES")

        else:

            print("NO")

    else:

        print("NO")
Problem: 2050B - Transfusion
Language: python

Solution 1 (runtime: 218 ms):
a=int(input())
for _ in range(a):
    b=int(input())
    c=list(map(int,input().split()))
    if sum(c)%b!=0:
        print('NO')
    else:
        t=sum(c)//b
        w=[]
        l=[]
        for i in range(b):
            if i%2==0:
                w.append(c[i])
            else:
                l.append(c[i])
        if sum(l)//len(l)==t==sum(w)//len(w):
            print('YES')
        else:
            print('NO')

Solution 2 (runtime: 171 ms):
t = int(input())

for i in range(t):

    n = int(input())

    inputs = list(map(int, input().split()))

    even_sum = 0

    odd_sum = 0

    for i in range(n):

        if i%2 == 0:

            even_sum += inputs[i]

        else:

            odd_sum += inputs[i]

    if n%2 == 0:

        even = odd = n/2

    else:

        even = n//2+1

        odd = n - even

    if even_sum/even == int(even_sum/even) and odd_sum/odd == int(odd_sum/odd):

        if even_sum/even == odd_sum/odd:

            print("YES")

        else:

            print("NO")

    else:

        print("NO")
Problem: 2050B - Transfusion
Language: python

Solution 1 (runtime: 171 ms):
def process_array():
    _size = int(input())
    a =list(map(int, input().split()))
    sum1 = 0 
    odd= (_size+1)//2
    sum2 = 0 
    even = _size-odd
    for i in range(_size):
        if i%2==0 :
           sum1+=a[i]
           
        else :
           sum2+=a[i] 
   # print(sum1, sum2, odd ,even)
    if (sum1+sum2)%_size==0 :
       if sum1 == odd*((sum1+sum2)/_size) and sum2== even*((sum1+sum2)/_size):
          print("YES")
          return
       else:
          print("NO")
          return   
    else:
      print("NO")

t = int(input())    
for _ in range(t): 
       process_array()


Solution 2 (runtime: 171 ms):


OUT=[]
for i in range(int(input())):
    n=int(input())
    L=list(map(int,input().split()))
    s=sum(L)
    if s%n==0 :
        p=s//n
        k=1
        b=True
        while k<n-1 and b:
            if L[k-1]!= p:
                
                L[k+1]-=p-L[k-1]
                L[k-1]=p
                
            k+=1
        if b and L[-1]==p and L[-2]==p:
            OUT.append('YES')
        else:
            OUT.append('NO')
        
    else:
        OUT.append('NO')

for i in OUT:
    print(i)
Problem: 2050B - Transfusion
Language: python

Solution 1 (runtime: 171 ms):
def process_array():
    _size = int(input())
    a =list(map(int, input().split()))
    sum1 = 0 
    odd= (_size+1)//2
    sum2 = 0 
    even = _size-odd
    for i in range(_size):
        if i%2==0 :
           sum1+=a[i]
           
        else :
           sum2+=a[i] 
   # print(sum1, sum2, odd ,even)
    if (sum1+sum2)%_size==0 :
       if sum1 == odd*((sum1+sum2)/_size) and sum2== even*((sum1+sum2)/_size):
          print("YES")
          return
       else:
          print("NO")
          return   
    else:
      print("NO")

t = int(input())    
for _ in range(t): 
       process_array()


Solution 2 (runtime: 202 ms):
t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    b = [a[i] for i in range(n) if i % 2 == 0]
    c=[a[i] for i in range(n) if i % 2 != 0]

    if sum(b)%len(b)==0:
        if sum(c)%len(c)==0 and sum(b)//len(b)==sum(c)//len(c):
            print("YES")
        else:
            print("NO")
    else:
        print("NO")
Problem: 2050B - Transfusion
Language: python

Solution 1 (runtime: 171 ms):
def process_array():
    _size = int(input())
    a =list(map(int, input().split()))
    sum1 = 0 
    odd= (_size+1)//2
    sum2 = 0 
    even = _size-odd
    for i in range(_size):
        if i%2==0 :
           sum1+=a[i]
           
        else :
           sum2+=a[i] 
   # print(sum1, sum2, odd ,even)
    if (sum1+sum2)%_size==0 :
       if sum1 == odd*((sum1+sum2)/_size) and sum2== even*((sum1+sum2)/_size):
          print("YES")
          return
       else:
          print("NO")
          return   
    else:
      print("NO")

t = int(input())    
for _ in range(t): 
       process_array()


Solution 2 (runtime: 186 ms):
t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    b = [a[i] for i in range(n) if i % 2 == 0]
    c=[a[i] for i in range(n) if i % 2 != 0]

    if sum(b)%len(b)==0:
        if sum(c)%len(c)==0 and sum(b)//len(b)==sum(c)//len(c):
            print("YES")
        else:
            print("NO")
    else:
        print("NO")
Problem: 2050B - Transfusion
Language: python

Solution 1 (runtime: 171 ms):
def process_array():
    _size = int(input())
    a =list(map(int, input().split()))
    sum1 = 0 
    odd= (_size+1)//2
    sum2 = 0 
    even = _size-odd
    for i in range(_size):
        if i%2==0 :
           sum1+=a[i]
           
        else :
           sum2+=a[i] 
   # print(sum1, sum2, odd ,even)
    if (sum1+sum2)%_size==0 :
       if sum1 == odd*((sum1+sum2)/_size) and sum2== even*((sum1+sum2)/_size):
          print("YES")
          return
       else:
          print("NO")
          return   
    else:
      print("NO")

t = int(input())    
for _ in range(t): 
       process_array()


Solution 2 (runtime: 202 ms):
for i in range(int(input())):

    input()

    a = list(map(int, input().split()))

    a1=[]

    a2=[]

    for i in range(len(a)):

        if i%2==0:

            a1.append(a[i])

        if i%2==1:

            a2.append(a[i])

    if (sum(a1)+sum(a2))%(len(a1)+len(a2))==0:

        if sum(a1)/len(a1)==sum(a2)/len(a2):

            print("YES")

        else:

            print("NO")

    else:

        print("NO")
Problem: 2050B - Transfusion
Language: python

Solution 1 (runtime: 171 ms):
def process_array():
    _size = int(input())
    a =list(map(int, input().split()))
    sum1 = 0 
    odd= (_size+1)//2
    sum2 = 0 
    even = _size-odd
    for i in range(_size):
        if i%2==0 :
           sum1+=a[i]
           
        else :
           sum2+=a[i] 
   # print(sum1, sum2, odd ,even)
    if (sum1+sum2)%_size==0 :
       if sum1 == odd*((sum1+sum2)/_size) and sum2== even*((sum1+sum2)/_size):
          print("YES")
          return
       else:
          print("NO")
          return   
    else:
      print("NO")

t = int(input())    
for _ in range(t): 
       process_array()


Solution 2 (runtime: 171 ms):
t = int(input())

for i in range(t):

    n = int(input())

    inputs = list(map(int, input().split()))

    even_sum = 0

    odd_sum = 0

    for i in range(n):

        if i%2 == 0:

            even_sum += inputs[i]

        else:

            odd_sum += inputs[i]

    if n%2 == 0:

        even = odd = n/2

    else:

        even = n//2+1

        odd = n - even

    if even_sum/even == int(even_sum/even) and odd_sum/odd == int(odd_sum/odd):

        if even_sum/even == odd_sum/odd:

            print("YES")

        else:

            print("NO")

    else:

        print("NO")
Problem: 2050B - Transfusion
Language: python

Solution 1 (runtime: 171 ms):


OUT=[]
for i in range(int(input())):
    n=int(input())
    L=list(map(int,input().split()))
    s=sum(L)
    if s%n==0 :
        p=s//n
        k=1
        b=True
        while k<n-1 and b:
            if L[k-1]!= p:
                
                L[k+1]-=p-L[k-1]
                L[k-1]=p
                
            k+=1
        if b and L[-1]==p and L[-2]==p:
            OUT.append('YES')
        else:
            OUT.append('NO')
        
    else:
        OUT.append('NO')

for i in OUT:
    print(i)

Solution 2 (runtime: 202 ms):
t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    b = [a[i] for i in range(n) if i % 2 == 0]
    c=[a[i] for i in range(n) if i % 2 != 0]

    if sum(b)%len(b)==0:
        if sum(c)%len(c)==0 and sum(b)//len(b)==sum(c)//len(c):
            print("YES")
        else:
            print("NO")
    else:
        print("NO")
Problem: 2050B - Transfusion
Language: python

Solution 1 (runtime: 171 ms):


OUT=[]
for i in range(int(input())):
    n=int(input())
    L=list(map(int,input().split()))
    s=sum(L)
    if s%n==0 :
        p=s//n
        k=1
        b=True
        while k<n-1 and b:
            if L[k-1]!= p:
                
                L[k+1]-=p-L[k-1]
                L[k-1]=p
                
            k+=1
        if b and L[-1]==p and L[-2]==p:
            OUT.append('YES')
        else:
            OUT.append('NO')
        
    else:
        OUT.append('NO')

for i in OUT:
    print(i)

Solution 2 (runtime: 186 ms):
t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    b = [a[i] for i in range(n) if i % 2 == 0]
    c=[a[i] for i in range(n) if i % 2 != 0]

    if sum(b)%len(b)==0:
        if sum(c)%len(c)==0 and sum(b)//len(b)==sum(c)//len(c):
            print("YES")
        else:
            print("NO")
    else:
        print("NO")
Problem: 2050B - Transfusion
Language: python

Solution 1 (runtime: 171 ms):


OUT=[]
for i in range(int(input())):
    n=int(input())
    L=list(map(int,input().split()))
    s=sum(L)
    if s%n==0 :
        p=s//n
        k=1
        b=True
        while k<n-1 and b:
            if L[k-1]!= p:
                
                L[k+1]-=p-L[k-1]
                L[k-1]=p
                
            k+=1
        if b and L[-1]==p and L[-2]==p:
            OUT.append('YES')
        else:
            OUT.append('NO')
        
    else:
        OUT.append('NO')

for i in OUT:
    print(i)

Solution 2 (runtime: 202 ms):
for i in range(int(input())):

    input()

    a = list(map(int, input().split()))

    a1=[]

    a2=[]

    for i in range(len(a)):

        if i%2==0:

            a1.append(a[i])

        if i%2==1:

            a2.append(a[i])

    if (sum(a1)+sum(a2))%(len(a1)+len(a2))==0:

        if sum(a1)/len(a1)==sum(a2)/len(a2):

            print("YES")

        else:

            print("NO")

    else:

        print("NO")
Problem: 2050B - Transfusion
Language: python

Solution 1 (runtime: 171 ms):


OUT=[]
for i in range(int(input())):
    n=int(input())
    L=list(map(int,input().split()))
    s=sum(L)
    if s%n==0 :
        p=s//n
        k=1
        b=True
        while k<n-1 and b:
            if L[k-1]!= p:
                
                L[k+1]-=p-L[k-1]
                L[k-1]=p
                
            k+=1
        if b and L[-1]==p and L[-2]==p:
            OUT.append('YES')
        else:
            OUT.append('NO')
        
    else:
        OUT.append('NO')

for i in OUT:
    print(i)

Solution 2 (runtime: 171 ms):
t = int(input())

for i in range(t):

    n = int(input())

    inputs = list(map(int, input().split()))

    even_sum = 0

    odd_sum = 0

    for i in range(n):

        if i%2 == 0:

            even_sum += inputs[i]

        else:

            odd_sum += inputs[i]

    if n%2 == 0:

        even = odd = n/2

    else:

        even = n//2+1

        odd = n - even

    if even_sum/even == int(even_sum/even) and odd_sum/odd == int(odd_sum/odd):

        if even_sum/even == odd_sum/odd:

            print("YES")

        else:

            print("NO")

    else:

        print("NO")
Problem: 2050B - Transfusion
Language: python

Solution 1 (runtime: 202 ms):
t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    b = [a[i] for i in range(n) if i % 2 == 0]
    c=[a[i] for i in range(n) if i % 2 != 0]

    if sum(b)%len(b)==0:
        if sum(c)%len(c)==0 and sum(b)//len(b)==sum(c)//len(c):
            print("YES")
        else:
            print("NO")
    else:
        print("NO")

Solution 2 (runtime: 186 ms):
t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    b = [a[i] for i in range(n) if i % 2 == 0]
    c=[a[i] for i in range(n) if i % 2 != 0]

    if sum(b)%len(b)==0:
        if sum(c)%len(c)==0 and sum(b)//len(b)==sum(c)//len(c):
            print("YES")
        else:
            print("NO")
    else:
        print("NO")
Problem: 2050B - Transfusion
Language: python

Solution 1 (runtime: 202 ms):
t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    b = [a[i] for i in range(n) if i % 2 == 0]
    c=[a[i] for i in range(n) if i % 2 != 0]

    if sum(b)%len(b)==0:
        if sum(c)%len(c)==0 and sum(b)//len(b)==sum(c)//len(c):
            print("YES")
        else:
            print("NO")
    else:
        print("NO")

Solution 2 (runtime: 202 ms):
for i in range(int(input())):

    input()

    a = list(map(int, input().split()))

    a1=[]

    a2=[]

    for i in range(len(a)):

        if i%2==0:

            a1.append(a[i])

        if i%2==1:

            a2.append(a[i])

    if (sum(a1)+sum(a2))%(len(a1)+len(a2))==0:

        if sum(a1)/len(a1)==sum(a2)/len(a2):

            print("YES")

        else:

            print("NO")

    else:

        print("NO")
Problem: 2050B - Transfusion
Language: python

Solution 1 (runtime: 202 ms):
t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    b = [a[i] for i in range(n) if i % 2 == 0]
    c=[a[i] for i in range(n) if i % 2 != 0]

    if sum(b)%len(b)==0:
        if sum(c)%len(c)==0 and sum(b)//len(b)==sum(c)//len(c):
            print("YES")
        else:
            print("NO")
    else:
        print("NO")

Solution 2 (runtime: 171 ms):
t = int(input())

for i in range(t):

    n = int(input())

    inputs = list(map(int, input().split()))

    even_sum = 0

    odd_sum = 0

    for i in range(n):

        if i%2 == 0:

            even_sum += inputs[i]

        else:

            odd_sum += inputs[i]

    if n%2 == 0:

        even = odd = n/2

    else:

        even = n//2+1

        odd = n - even

    if even_sum/even == int(even_sum/even) and odd_sum/odd == int(odd_sum/odd):

        if even_sum/even == odd_sum/odd:

            print("YES")

        else:

            print("NO")

    else:

        print("NO")
Problem: 2050B - Transfusion
Language: python

Solution 1 (runtime: 186 ms):
t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    b = [a[i] for i in range(n) if i % 2 == 0]
    c=[a[i] for i in range(n) if i % 2 != 0]

    if sum(b)%len(b)==0:
        if sum(c)%len(c)==0 and sum(b)//len(b)==sum(c)//len(c):
            print("YES")
        else:
            print("NO")
    else:
        print("NO")


Solution 2 (runtime: 202 ms):
for i in range(int(input())):

    input()

    a = list(map(int, input().split()))

    a1=[]

    a2=[]

    for i in range(len(a)):

        if i%2==0:

            a1.append(a[i])

        if i%2==1:

            a2.append(a[i])

    if (sum(a1)+sum(a2))%(len(a1)+len(a2))==0:

        if sum(a1)/len(a1)==sum(a2)/len(a2):

            print("YES")

        else:

            print("NO")

    else:

        print("NO")
Problem: 2050B - Transfusion
Language: python

Solution 1 (runtime: 186 ms):
t = int(input())
for _ in range(t):
    n = int(input())
    a = list(map(int, input().split()))
    b = [a[i] for i in range(n) if i % 2 == 0]
    c=[a[i] for i in range(n) if i % 2 != 0]

    if sum(b)%len(b)==0:
        if sum(c)%len(c)==0 and sum(b)//len(b)==sum(c)//len(c):
            print("YES")
        else:
            print("NO")
    else:
        print("NO")


Solution 2 (runtime: 171 ms):
t = int(input())

for i in range(t):

    n = int(input())

    inputs = list(map(int, input().split()))

    even_sum = 0

    odd_sum = 0

    for i in range(n):

        if i%2 == 0:

            even_sum += inputs[i]

        else:

            odd_sum += inputs[i]

    if n%2 == 0:

        even = odd = n/2

    else:

        even = n//2+1

        odd = n - even

    if even_sum/even == int(even_sum/even) and odd_sum/odd == int(odd_sum/odd):

        if even_sum/even == odd_sum/odd:

            print("YES")

        else:

            print("NO")

    else:

        print("NO")
Problem: 2050B - Transfusion
Language: python

Solution 1 (runtime: 202 ms):
for i in range(int(input())):

    input()

    a = list(map(int, input().split()))

    a1=[]

    a2=[]

    for i in range(len(a)):

        if i%2==0:

            a1.append(a[i])

        if i%2==1:

            a2.append(a[i])

    if (sum(a1)+sum(a2))%(len(a1)+len(a2))==0:

        if sum(a1)/len(a1)==sum(a2)/len(a2):

            print("YES")

        else:

            print("NO")

    else:

        print("NO")

Solution 2 (runtime: 171 ms):
t = int(input())

for i in range(t):

    n = int(input())

    inputs = list(map(int, input().split()))

    even_sum = 0

    odd_sum = 0

    for i in range(n):

        if i%2 == 0:

            even_sum += inputs[i]

        else:

            odd_sum += inputs[i]

    if n%2 == 0:

        even = odd = n/2

    else:

        even = n//2+1

        odd = n - even

    if even_sum/even == int(even_sum/even) and odd_sum/odd == int(odd_sum/odd):

        if even_sum/even == odd_sum/odd:

            print("YES")

        else:

            print("NO")

    else:

        print("NO")
Problem: 2050C - Uninteresting Number
Language: python

Solution 1 (runtime: 171 ms):
def solve(num):
    curr_sum = sum([int(h) for h in " ".join(num).split()])
    twos = num.count("2")
    threes = num.count("3")
    for i in range(min(10, twos + 1)):
        for j in range(min(10, threes + 1)):
            if (curr_sum + i * 2 + j * 6) % 9 == 0:
                return "YES"
    return "NO"

T = int(input())
for _ in range(T):
    num = input()
    print(solve(num))
    

Solution 2 (runtime: 124 ms):
for _ in range(int(input())):
    a=list(map(int,list(input())))
    s=sum(a)
    t1,t2=a.count(2),a.count(3)
    for i in range(t1+1):
        for j in range(t2+1):
            if (s+i*2+j*6)%9==0:
                print('YES')
                break
        else:continue
        break
    else:
        print('NO')
Problem: 2050C - Uninteresting Number
Language: python

Solution 1 (runtime: 171 ms):
def solve(num):
    curr_sum = sum([int(h) for h in " ".join(num).split()])
    twos = num.count("2")
    threes = num.count("3")
    for i in range(min(10, twos + 1)):
        for j in range(min(10, threes + 1)):
            if (curr_sum + i * 2 + j * 6) % 9 == 0:
                return "YES"
    return "NO"

T = int(input())
for _ in range(T):
    num = input()
    print(solve(num))
    

Solution 2 (runtime: 155 ms):
def is_divi9(num):
    s = sum(num)  # مجموع اولیه ارقام
    if s % 9 == 0:  # بررسی اولیه
        return "YES"
    
    # شمارش تعداد ارقام 2 و 3
    count_2 = num.count(2)
    count_3 = num.count(3)

    # بررسی تمام مقادیر ممکن از تغییر
    for c2 in range(count_2 + 1):  # تعداد تغییر 2ها از 0 تا count_2
        for c3 in range(count_3 + 1):  # تعداد تغییر 3ها از 0 تا count_3
            new_s = s + c2 * 2 + c3 * 6
            if new_s % 9 == 0:
                return "YES"

    return "NO"

# ورودی گرفتن
t = int(input())
for _ in range(t):
    num = [int(digit) for digit in input()]  # تبدیل عدد به لیست ارقام
    print(is_divi9(num))
Problem: 2050C - Uninteresting Number
Language: python

Solution 1 (runtime: 171 ms):
def solve(num):
    curr_sum = sum([int(h) for h in " ".join(num).split()])
    twos = num.count("2")
    threes = num.count("3")
    for i in range(min(10, twos + 1)):
        for j in range(min(10, threes + 1)):
            if (curr_sum + i * 2 + j * 6) % 9 == 0:
                return "YES"
    return "NO"

T = int(input())
for _ in range(T):
    num = input()
    print(solve(num))
    

Solution 2 (runtime: 124 ms):
#                             * بسم الله الرحمن الرحيم *
#     ﴾ رَبِّ اشْرَحْ لِي صَدْرِي * وَيَسِّرْ لِي أَمْرِي * وَاحْلُلْ عُقْدَةً مِّن لِّسَانِي * يَفْقَهُوا قَوْلِي ﴿
#  
t=int(input())
for i in range(t):
    n=input()
    intn=int(n)
    result="NO"
    count_2 = n.count('2') 
    count_3 = n.count('3')
    if intn%9==0:
        result="YES"
    else:
        rest=intn%9
        if rest in [1,3,5,7]:
            if rest==7:
                if count_2>=1:
                    result="YES"
            elif rest==5:
                if count_2>=2:
                    result="YES"
            elif rest==3:
                if count_2>=3 or count_3>=1:
                    result="YES"
            elif rest==1:
                if (count_2>=1 and count_3>=1) or count_2>=4:
                    result="YES"
        elif rest in [2,4,6,8]:
            if rest==8:
                if (count_2>=2 and count_3>=1) or count_2>=5:
                    result="YES"
            elif rest==6:
                if (count_3>=2) or (count_2>=3 and count_3>=1) or count_2>=6:
                    result="YES"
            elif rest==4:
                if (count_2>=4 and count_3>=1) or (count_2>=1 and count_3>=2) or count_2>=7:
                    result="YES"
            elif rest==2:
                if (count_2>=5 and count_3>=1) or (count_2>=2 and count_3>=2) or count_2>=8:
                    result="YES"
                
    print(result)
Problem: 2050C - Uninteresting Number
Language: python

Solution 1 (runtime: 171 ms):
def solve(num):
    curr_sum = sum([int(h) for h in " ".join(num).split()])
    twos = num.count("2")
    threes = num.count("3")
    for i in range(min(10, twos + 1)):
        for j in range(min(10, threes + 1)):
            if (curr_sum + i * 2 + j * 6) % 9 == 0:
                return "YES"
    return "NO"

T = int(input())
for _ in range(T):
    num = input()
    print(solve(num))
    

Solution 2 (runtime: 139 ms):
tt = int(input())
while(tt > 0):
    num = input()
    num_2 = 0
    num_3 = 0
    curr_sum = 0
    max_x = 0
    max_y = 0
    for digit in num:
        curr_digit = int(digit)
        if curr_digit == 2:
            max_x += 1
        if curr_digit == 3:
            max_y += 1
        curr_sum += curr_digit

    ans = "YES" if curr_sum % 9 == 0 else "NO"
    x = 0
    y = 0
    for x in range(0,min(max_x+1, 9)):
        for y in range(0,min(max_y+1, 9)):
            total_sum = curr_sum + x*2 + y*6
            if total_sum % 9 == 0:
                ans = "YES"
    print(ans)
    tt -= 1