ShaysXIA/CodeInsightBench huggingface dataset:
Problem: 2050C - Uninteresting Number
Language: python

Solution 1 (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)

Solution 2 (runtime: 156 ms):
no = int(input())
for i in range(no):
    l = list(map(int, list(input())))
    c2 = l.count(2)
    c3 = l.count(3)
    sumo = sum(l)
    ans = "NO"
    for two in range(c2+1):
        for three in range(c3+1):
            x = sumo + 2*two + 6*three
            if x%9==0:
                ans = "YES"
                break
        if ans == "YES":
            break
    print(ans)
Problem: 2050C - Uninteresting Number
Language: python

Solution 1 (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)

Solution 2 (runtime: 140 ms):
import sys
input=lambda :sys.stdin.readline().strip()
t=int(input())
for _ in range(t):
    s=input()
    ls=[int(i) for i in s]
    a=s.count('2')
    b=s.count('3')
    flag=0
    for i in range(min(10,a+1)):
        for j in range(min(10,b+1)):
            if (sum(ls)+2*i+6*j)%9==0:
                flag+=1
                print("YES")
                break
        if flag!=0:
            break
    if flag==0:
        print("NO")
Problem: 2050C - Uninteresting Number
Language: python

Solution 1 (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)

Solution 2 (runtime: 124 ms):
def main():
    import sys
    input = sys.stdin.read
    data = input().split()

    tc = int(data[0])  # Read the number of test cases
    results = []

    for t in range(1, tc + 1):
        str_num = data[t]
        sum_digits = 0
        two_cnt = 0
        three_cnt = 0

        # Count sum of digits, number of 2's, and number of 3's
        for char in str_num:
            digit = int(char)
            sum_digits += digit
            if digit == 2:
                two_cnt += 1
            elif digit == 3:
                three_cnt += 1

        valid = False

        # Try combinations of 2's and 3's
        for i in range(min(8, two_cnt) + 1):
            for j in range(min(8, three_cnt) + 1):
                if (sum_digits + 2 * i + 6 * j) % 9 == 0:
                    results.append("yes".capitalize())
                    valid = True
                    break
            if valid:
                break
        if not valid:
            results.append("no".capitalize())
    
    # Print all results at once
    sys.stdout.write("\n".join(results) + "\n")

if __name__ == "__main__":
    main()
Problem: 2050C - Uninteresting Number
Language: python

Solution 1 (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)

Solution 2 (runtime: 202 ms):
import sys
sys.set_int_max_str_digits(10**6)
t=int(input())
for _ in range(t):
    n=int(input())
    s=str(n)
    x=0
    for i in range(len(s)):
        x+=int(s[i])
    a,b=0,0
    for i in range(len(s)):
        if s[i]=="2":
            a,b=a+1,b
        elif s[i]=="3":
            a,b=a,b+1
        else:
            a,b=a,b
    i=0
    while i<a+1:
        j=0
        while j<b+1:
            if (x+2*i+6*j)%9==0:
                break
            else:
                j+=1
        if j<b+1:
            if (x+2*i+6*(j))%9==0:
                break
            else:
                i+=1
        else:
            if (x+2*i+6*(j-1))%9==0:
                break
            else:
                i+=1
    if i==a+1 and j==b+1:
        print("NO")
    else:
        print("YES")
Problem: 2050C - Uninteresting Number
Language: python

Solution 1 (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)

Solution 2 (runtime: 171 ms):
def voir(test,nb3):
    while test!=0 and nb3>0:
        test=(test+6)%9
        nb3-=1
    if test==0:
        return True
    else :
        return False

OUT=[]
for i in range(int(input())):
    s=input()
    somme=0
    nb2=0
    nb3=0
    for i in s:
        somme=(somme+int(i))%9
        if i=="2":
            nb2+=1 
        if i=="3":
            nb3+=1
    
    if somme==0 :
        OUT.append("YES")
    else :
        
        
        if nb2>=2 :
            
            if voir((somme+4)%9,(nb3+(nb2-2)//3)) or voir((somme+2)%9,(nb3+(nb2-1)//3)) or voir((somme)%9,(nb3+(nb2)//3)):
                OUT.append("YES")
            else :
                OUT.append("NO")
        elif nb2==1 :
            
            if voir((somme+2)%9,(nb3+(nb2-1)//3)) or voir((somme)%9,(nb3+(nb2)//3)):
                OUT.append("YES")
            else :
                OUT.append("NO")
        else:
            
            if voir((somme)%9,(nb3+(nb2)//3)):
                OUT.append("YES")
            else :
                OUT.append("NO")


for i in OUT:
    print(i)
Problem: 2050C - Uninteresting Number
Language: python

Solution 1 (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)

Solution 2 (runtime: 156 ms):
t = int(input())
for i in range(t):
	n = input()
	if int(n)%9 == 0:
		print('yes')
		continue	
	tw = n.count('2')
	th = n.count('3')
	n = int(n)
	tn = abs(0.5*((n%9)%2)*(9-n%9)+(abs(n%9)%2-1)*(9-n%9/2))
	d = tn - tw
	if d > 0 and ((d%3!=0 and (tw<3-d%3 or (d+3-d%3)/3 > th)) or (d%3==0 and d/3 > th)):
		print('no')
	else:
		print('yes')
Problem: 2050C - Uninteresting Number
Language: python

Solution 1 (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)

Solution 2 (runtime: 218 ms):
for _ in range(int(input())):
    s=[int(x) for x in list(input())]
    sm=sum(s)
    t=s.count(2)
    th=s.count(3)
    found=False
    for i in range(t+1):
        for j in range(th+1):
            if (sm+i*2+j*6)%9==0:
                print('YES')
                found=True
                break
        if found:
            break
    if not found:
        print('NO')
Problem: 2050C - Uninteresting Number
Language: python

Solution 1 (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)

Solution 2 (runtime: 233 ms):
for _ in range(int(input())):
    s = input()
    reachable2 = [0]
    reachable3 = [0]
    div = 0; sky2 = sky3 = 0
    finn = False 
    for i in s:
        div += int(i)
        if sky2 < 10:
            if i == '2':
                reachable2.append(reachable2[-1]+2)
                sky2 += 1
        if sky3 < 5:
            if i == '3':
                reachable3.append(reachable3[-1]+6)
                sky3 += 1 
    need = 9 - div%9
    if need == 9 or need == 0:
        print('yes')
    elif (need == 2 and len(reachable2) > 1) or (need == 4 and len(reachable2) > 2) or (need == 6 and (len(reachable2) > 3 or len(reachable3) > 1)) or (need == 8 and len(reachable2) > 4):
        print('yes')
    else:
        reachable = {(i+j)%9 for i in reachable2 for j in reachable3}
        #print(reachable, reachable2, reachable3)
        #print(div,need, two, three)
        #print(reachable)
        if need in reachable:
            print('yes')
        else:
            print('no')
Problem: 2050C - Uninteresting Number
Language: python

Solution 1 (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)

Solution 2 (runtime: 140 ms):
import sys
from functools import cache

inputs = sys.stdin.read().splitlines()[1:]

def solution(numbers: list[str]) -> None:
    
    for num in numbers:
        solve(num)

def solve(n: str) -> None:
    s = [int(x) for x in list(n)]

    sm = sum(s)
    twos = s.count(2)
    threes = s.count(3)

    for i in range(min(10, twos + 1)):
        for j in range(min(10, threes + 1)):
            if (sm + i * 2 + j * 6) % 9 == 0:
                print('YES')
                return
    print('NO')

solution(inputs)
Problem: 2050C - Uninteresting Number
Language: python

Solution 1 (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)

Solution 2 (runtime: 202 ms):
def main():
    test_case = int(input())
    for _ in range(test_case):
        num = [int(x) for x in input()]
        solve(num)


def solve(num):
    two = num.count(2)
    three = num.count(3)
    tot = sum(num)
    for i in range(min(10,two+1)):
        for j in range((min(10,three+1))):
            if (tot+ 2*i+ 6*j)%9 == 0:
                print("YES")
                return
    print("NO")    
main()
Problem: 2050C - Uninteresting Number
Language: python

Solution 1 (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)

Solution 2 (runtime: 186 ms):
cases = int(input())

for i in range(cases):
    n = input()
    
    l2 = [0]
    l3 = [0]
    sum = 0
    
    for j in range(len(n)):
        if n[j] == '2':
            l2.append(l2[-1]+2)
        if n[j] == '3':
            l3.append(l3[-1]+6)
        sum += int(n[j])
        
    ans = "NO"
    
    for j in l2:
        for k in l3:
            if (sum + j + k)%9==0:
                ans = "YES"    
                break 
        if ans == "YES":
            break
    
    print(ans)