Problem:
 Score : 200 points    Problem Statement An integer N is a multiple of 9 if and only if the sum of the digits in the decimal representation of N is a multiple of 9 .  Determine whether N is a multiple of 9 .      Constraints  0 \leq N < 10^{200000}  N is an integer.         Input Input is given from Standard Input in the following format:  N       Output If N is a multiple of 9 , print Yes ; otherwise, print No .        Sample Input 1 123456789      Sample Output 1 Yes  The sum of these digits is 1+2+3+4+5+6+7+8+9=45 , which is a multiple of 9 , so 123456789 is a multiple of 9 .       Sample Input 2 0      Sample Output 2 Yes       Sample Input 3 31415926535897932384626433832795028841971693993751058209749445923078164062862089986280      Sample Output 3 No

Solution (Python):


import re
import math
from collections import defaultdict,deque,Counter
from fractions import Fraction
import bisect
import itertools
from itertools import accumulate
from copy import deepcopy
import heapq
import random
import time
import os
import sys
from functools import lru_cache,reduce
readline=sys.stdin.readline
sys.setrecursionlimit(100000)
alp="abcdefghijklmnopqrstuvwxyz"
numbers="0123456789"
mod=int(10**9+7)
inf=int(10**19)
class Set():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(bool)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        if not self.find(x):
            heapq.heappush(self.heap,x)
            self.dic[x]=True
            self.size+=1

    def remove(self,x):
        if self.find(x):
            self.dic[x]=False
            self.size-=1

    def find(self,x):
        return self.dic[x]
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==False:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class multiset():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(int)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        heapq.heappush(self.heap,x)
        self.dic[x]+=1
        self.size+=1

    def remove(self,x):
        if self.dic[x]>0:
            self.dic[x]-=1
            self.size-=1
    
    def count(self,x):
        return self.dic[x]

    def find(self,x):
        return self.dic[x]>0
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==0:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class Edge():
    def __init__(self,x,y,val=1):
        self.x=x
        self.y=y
        self.val=val
class unionfind():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(n)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):
            self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def yn(b):print("yes" if b else "no")
def Yn(b):print("Yes" if b else "No")
def YN(b):print("YES" if b else "NO")
def ispow(a,b):
    now=b
    while now<a:
        now*=b
    return now==a
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def getfacs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def nextcomb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def getprimes(n):
    if n==0:return []
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    ret=[]
    for a in range(n+1):
        if(A[a]):ret.append(a)
    return ret
def isprime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(b,t,f):return t if b else f
def factorize(n):
    b = 2
    ret=defaultdict(int)
    while b * b <= n:
        while n % b == 0:
            n //= b
            ret[b]+=1
        b+=1
    if n > 1:ret[n]+=1
    return ret
def inputintlist(row=1): 
    if row==1:
        ret=list(map(int,input().split()))
    else:
        ret=[None]*row
        for a in range(row):
            ret[a]=int(input())
    return ret
def inputfloatlist(row=1): 
    if row==1:
        ret=list(map(float,input().split()))
    else:
        ret=[None]*row
        for a in range(row):
            ret[a]=float(input())
    return ret
def istanchouzouka(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>=a:
            f=False
        prev=a
    return f
def istanchouhigensyou(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>a:
            f=False
        prev=a
    return f
def getallsum(A):
    s=sum(A)
    dp=defaultdict(int)
    dp[0]=1
    for a in range(0,len(A)):
        for b in range(s,-1,-1):
            if b-A[a]>=0:
                dp[b]+=dp[b-A[a]]
    return dp
def yuukoutomukou(edges):
    ret=deepcopy(edges)
    for edge in edges:
        if not edge.x==edge.y:
            ret.append(Edge(edge.y,edge.x,edge.val))
    return ret
def dijkstra(edges,V,start):
    mincost=[inf]*V
    G=[[] for a in range(V)]
    for edge in edges:
        G[edge.x].append([edge.val,edge.y])
    Q=PriorityQueue()
    Q.put([0,start])
    while not Q.empty():
        nowcost,nowx=Q.get()
        if mincost[nowx]==inf:
            mincost[nowx]=nowcost
            for cost,y in G[nowx]:
                newcost=nowcost+cost
                Q.put([newcost,y])
    return mincost
def warshallfloyd(edges,V):
    mincost=[[inf for b in range(V)] for a in range(V)]
    for a in range(V):mincost[a][a]=0
    for edge in edges:
        mincost[edge.x][edge.y]=min(mincost[edge.x][edge.y],edge.val)
    for k in range(V):
        for s in range(V):
            for t in range(V):
                if mincost[s][k]==inf or mincost[k][t]==inf:continue
                mincost[s][t]=min(mincost[s][t],mincost[s][k]+mincost[k][t])
    return mincost
def bellemanford(edges,V,start):
    mincost=[inf]*V
    mincost[start]=0
    for _ in range(V):
        for edge in edges:
            if mincost[edge.x]==inf:continue
            mincost[edge.y]=min(mincost[edge.y],mincost[edge.x]+edge.val)
    return mincost
def getmd(x1,y1,x2,y2):return abs(x1-x2)+abs(y1-y2)
def geted(x1,y1,x2,y2):return math.sqrt((x1-x2)**2+(y1-y2)**2)
class fordfulkerson():
    def __init__(self,edges,V,s,t):
        self.V=V
        self.used=[False]*V
        self.G=[[] for a in range(V)]
        self.s=s
        self.t=t
        for edge in edges:
            self.G[edge.x].append({"x":edge.x,"y":edge.y,"cap":edge.val,"rev":len(self.G[edge.y])})
            self.G[edge.y].append({"x":edge.y,"y":edge.x,"cap":0,"rev":len(self.G[edge.x])-1})
    def dfs(self,v,t,f=inf):
        if v==t:return f
        self.used[v]=True
        for a in range(len(self.G[v])):
            x=self.G[v][a]["x"]
            y=self.G[v][a]["y"]
            cap=self.G[v][a]["cap"]
            rev=self.G[y][self.G[x][a]["rev"]]
            if self.used[y] or cap==0:continue
            f2=self.dfs(y,t,min(f,cap))
            if f2>0:
                self.G[v][a]["cap"]-=f2
                rev["cap"]+=f2
                return f2
        return 0
    def maxflow(self):
        flow=0
        while True:
            self.used=[False]*V
            zouka=self.dfs(self.s,self.t)
            if zouka==0:break
            flow+=zouka
        return flow
def zipsort(*args):
    ziplist=sorted(zip(*args))
    for a in range(len(args)):
        for b in range(len(ziplist)):
            args[a][b]=ziplist[b][a]
def zipreverse(*args):
    ziplist=list(zip(*args))
    rev=[]
    for a in range(len(ziplist)-1,-1,-1):
        rev.append(ziplist[a])
    for a in range(len(args)):
        for b in range(len(rev)):
            args[a][b]=rev[b][a]

def to10(A):
    ret=0
    for a in range(len(A)-1,-1,-1):
        ret+=X[a]*2**(N-1-a)
    return ret

N=input()
num=0
for a in N:
    num+=int(a)
Yn(num%9==0)

Solution (Python):
n = input()
su = 0
for i in range(len(n)):
    su += int(n[i])
if su%9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
if n%9==0:
  print("Yes")
else:
  print("No")

Solution (Python):
N = input()
print('Yes' if sum([int(x) for x in N])%9 == 0 else 'No')

Solution (Python):
s = input()

ans = 0
for i in s:
    ans += int(i)

if ans % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=STR()
    ans=0
    for i in n:
        ans+=int(i)
    if ans%9==0:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    do()

Solution (Python):
n = input()

s = 0
for c in n:
  s += int(c)

if s % 9 == 0:
  print('Yes')
else:
  print('No')

Solution (Python):
N = input().rstrip()

s = sum([int(v) for v in N])

if s % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, combinations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from operator import itemgetter
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7
DEBUG = 'ONLINE_JUDGE' not in sys.argv

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp



class UnionFindEx:
    def __init__(self, size):
        
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)

def main():
    print(Yes if sum(map(int, input()))%9==0 else No)








main()

Solution (Python):
n=input()
n_len=len(n)

s=0
for i in range(n_len):
    s+=int(n[i])

if s%9==0:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys, math


if(__name__ == "__main__"):
    """
    N = int( input().strip() )
    Length = list( map(int, input().strip().split() ) )
    """
    N = input().strip()
    sum = 0
    Len = len(N)
    for i in range(Len):
        sum += int(N[i])
    if(sum %9 ==0):
        print("Yes")
    else:
        print("No")

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(N: str):
    s = 0
    for c in N:
        s += int(c)
    print(YES if s % 9 == 0 else NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = next(tokens)  
    solve(N)

if __name__ == '__main__':
    main()

Solution (Python):
def keta(s):
    sm=0
    for i in range(len(s)):
        sm+=int(s[i])
    return sm

n=input()
if keta(n) %9==0:
    print("Yes")
else:
    print("No")

Solution (Python):
N=input()

S=0
for a in N:
    S+=int(a)

if S%9:
    print("No")
else:
    print("Yes")

Solution (Python):
N = input()
print('Yes' if sum([int(n) for n in list(N)]) % 9 == 0 else 'No')

Solution (Python):
from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = list(map(int, list(_in[0])))  
    
    cnt = sum(N)
    ans = 'Yes' if cnt % 9 == 0 else 'No'
    
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N = input()

s = 0
for i in range(len(N)):
    s += int(N[i])
    
if(s%9 == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    S = input()
    modsum = 0
    for c in S:
        modsum = (modsum + int(c)) % 9
    if modsum == 0:
        print('Yes')
    else:
        print('No')

    
main()

Solution (Python):
n=input()
ans = 0
for i in range(len(n)):
    a = int(n[i])
    ans += a
    
if ans%9==0:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()

cnt = sum([int(c) for c in s])
if cnt % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):


import sys
readline = sys.stdin.readline
read = sys.stdin.read




n = input()
v = sum(int(i) for i in n)
if v%9==0:
    print("Yes")
else:
    print("No")

Solution (Python):

N = int(input())
if N % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
N = list(input())
a = 0
for i in N:
    a += int(i)
    a %= 9

print(['No','Yes'][a == 0])

Solution (Python):
N = input()
S = sum(map(int, N))
if S % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
N = input()
print('Yes' if sum(int(i) for i in N) % 9 == 0 else 'No')

Solution (Python):
S = str(input())
P = list(S)
L = []
for x in P:
  x = int(x)
  L.append(x)
A = sum(L)
if A%9 == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
def main():
    n = input()
    tmp = 0
    for i in range(len(n)):
        tmp += int(n[i])
    if tmp % 9 == 0:
        print('Yes')
    else:
        print('No')
    


if __name__ == "__main__":
    main()

Solution (Python):
s=input()
cnt=0
for i in s:
  cnt+=int(i)
print(['No','Yes'][cnt%9==0])

Solution (Python):
N = input()
total = 0
for i in N:
    total = (total + int(i)) % 9

if total == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
N = input()

ans = 0
for n in N:
    ans += int(n) % 9
    ans %= 9

if ans==0:
    print("Yes")
else:
    print("No")

Solution (Python):
n=input()
s=0
for c in n:
  s+=int(c)
print('No' if s%9 else 'Yes')

Solution (Python):
n = input()
ans = 0
for i in n:
    ans += int(i)
if ans % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
ss = 0
for i in s:
    ss += int(i)
if ss % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
s = sum(map(int, input().split())) % 9 == 0
if s:
    print("Yes")
else:
    print("No")

Solution (Python):
N = input()

ans = 0
for i in range(len(N)):
  ans += int(N[i])

if ans%9==0:
  print("Yes")
else:
  print("No")

Solution (Python):
import math
from decimal import *
import random

def pf(n):
    ans = [1]
    if(n%2==0):
        if(n!= 2):
            ans.append(2)
        while(n%2==0):
            n//=2
    p = 3
    while(n>1):
        if(n%p==0):
            ans.append(p)
            while(n%p==0):
                n//=p
        p+=1
    return ans

n = str(input())
tmp = 0
for i in range(len(n)):
    tmp+=int(n[i])
if(tmp%9==0):
    print('Yes')
else:
    print('No')

Solution (Python):


A = input()

sum_digit = 0
for a in A:
  sum_digit += int(a)

if sum_digit%9 == 0:
  print('Yes')
else:
  print('No')

Solution (Python):
s=input()
c=0
for i in s:
    c+=int(i)
    c%=9
if c==0:
    print('Yes')
else:
    print('No')

Solution (Python):
n = input()
c=0
for i in range(len(n)):
    c+=int(n[i])
if c%9==0:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = rs()

s = 0
for c in N:
	s += int(c)
if s % 9 == 0:
	print('Yes')
else:
	print('No')

Solution (Python):
n = [int(x) for x in list(input())]

print('Yes' if sum(n) % 9 == 0 else 'No')

Solution (Python):
N = list(map(int,input()))
if(sum(N)%9 == 0):
  print("Yes")
else:
  print("No")

Solution (Python):
s = input()
t = 0
for ss in s:
    t += int(ss)

if t%9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"

n = k()

if n % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
N = input()
cnt = 0
for n in N:
    cnt += int(n)
    cnt = cnt % 9
print("Yes" if cnt % 9 == 0 else "No")

Solution (Python):

import sys
input = sys.stdin.readline

n = input().rstrip()
keta_sum = 0
for ch in n:
    keta_sum += int(ch)

if keta_sum % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n = input()

count = 0
for c in n:
  count += int(c)
  
print('Yes' if count % 9 == 0 else 'No')

Solution (Python):


N = input()

sum_digits = 0

for c in N:
    sum_digits += int(c)
    sum_digits %= 9

if sum_digits == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
n=(input())
now=0
for i in n:
  now+=int(i)
if now%9==0:
  print("Yes")
else:
  print("No")

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    N = input().strip()
    ans = 0
    for n in N:
        ans += int(n)
    if ans % 9 == 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Solution (Python):
n = input()
ans = 0
for nn in n:
    a = int(nn)
    ans += a

if ans % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
def mlt(): return map(int, input().split())


x = int(input())

print('YNeos'[(x % 9 != 0)::2])

Solution (Python):
import sys
input = sys.stdin.readline


def main():
    n = input().replace("\n", "")
    s = len(n)
    sub = 0
    for i in range(s):
        sub += int(n[i])
        sub %= 9
    if sub:
        print("No")
    else:
        print("Yes")
    
    
if __name__ == "__main__":
    main()

Solution (Python):
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array





sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    S = iss()
    ret = 0
    for s in S:
        ret += int(s)

    print('Yes' if ret % 9 == 0 else 'No')


if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())

if n % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
N = input()

cnt = 0
for n in N:
    cnt += int(n)
    cnt %= 9

if cnt % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n=input()
a=0
for i in n:
    a+=int(i)
print('Yes' if a%9==0 else "No")

Solution (Python):
n = input()
ans = 0
for i in n:
    ans += int(i)
if ans%9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()

sum_num = 0
for c in s:
  sum_num += int(c)
  sum_num %= 9

if sum_num % 9 == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
print("Yes" if sum(int(i) for i in input())%9==0 else "No")

Solution (Python):

import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    N = input()
    res = 0
    for i in range(len(N)):
        res += int(N[i])
    print('Yes') if res % 9 == 0 else print('No')

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
if n%9==0:print("Yes")
else:print("No")

Solution (Python):
import sys
input=sys.stdin.readline

n=input().rstrip()

c=0
for i in n:
    c=(c+int(i))%9

if c==0:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
n = len(s)

ans = 0
for i in range(n):
  ans += int(s[i])
  
if ans%9 == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
n = input()

num = 0
for e in n:
    num += int(e)
    num %= 9

if num:
    ans = "No"
else:
    ans = "Yes"

print(ans)

Solution (Python):
n=input()
s=0
for i in n: s+=int(i)
if s%9==0: print("Yes")
else: print("No")

Solution (Python):
n=list(map(int,list(input())))

if sum(n)%9==0:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
print("Yes" if N % 9 == 0 else "No")

Solution (Python):
print("Yes" if sum(map(int, input())) % 9 == 0 else "No")

Solution (Python):
s = list(input())
a = 0
for i in s:
    a += int(i)
if a%9==0:
    print('Yes')
else:
    print('No')

Solution (Python):
from sys import stdin, setrecursionlimit

setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

S = sum(map(int, list(input())))
print("Yes" if S % 9 == 0 else "No")

Solution (Python):
N = input()

result = 0
for i in N:
    result += int(i)

if result % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
N = list(map(int,list(input())))
if sum(N) % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
n = input()
ans = 0 
for i in range(len(n)):
    ans+=int(n[i]) 
    ans= ans%9 

if ans == 0:
    print('Yes')
else:
    print("No")

Solution (Python):


import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    a = 0
    for s1 in input():
        a = (a + int(s1)) % 3

    print("Yes" if a == 0 else "No")


if __name__ == "__main__":
    resolve()

Solution (Python):
num=list(input())
cnt=0
for i in range(len(num)):
    cnt+=int(num[i])
if cnt%9==0:
    print("Yes")
else:
    print("No")

Solution (Python):
s=input()
ans=0
for i in range(len(s)):
  ans=(ans+int(s[i]))%9
if ans==0:
  print('Yes')
else:
  print('No')

Solution (Python):
from functools import reduce


n = input()
a = 0
for ni in n:
    a += int(ni)
if a % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
import math
import sys

n = input()

digit_sum = 0
for i in range(len(n)):
    digit_sum += int(n[i])

if (digit_sum % 9 == 0):
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
ans = 0
for s in S:
    ans += int(s)
if ans % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
N = list(input())
N = list(map(int,N))
ans = sum(N)
print("Yes" if ans%9 ==0 else "No")

Solution (Python):
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=list(input())

    s = 0
    for n in N:
        m = int(n)
        s += m
        s %= 9

    print("Yes" if s % 9 == 0 else "No")





if __name__ == "__main__":
    main()

Solution (Python):
n=input()
ans=0
for i in range(len(n)):
    ans+=int(n[i])
if ans%9==0:
    print("Yes")
else:
    print("No")

Solution (Python):
N=input()
ans=0
for i in range(len(N)):
    ans+=int(N[i])
if ans%9==0:
    print("Yes")
else:
    print("No")

Solution (Python):
n=input()
c=0
for m in n:
  c+=int(m)
print("Yes" if c%9==0 else "No")

Solution (Python):
a=list(input())
a=[int(i) for i in a]
n=sum(a)
if n%9==0:
    print('Yes')
else:
    print('No')

Solution (Python):
N = list(str(input()))
s = 0
for i in range(len(N)):
  s += int(N[i])
if s %9 == 0:
  print('Yes')
else:
  print('No')

Solution (Python):
def resolve():
    N = input()
    X = sum(map(int, N))
    print("Yes" if X%9 == 0 else "No")
resolve()

Solution (Python):
n = list(input())
tmp = 0
for i in n:
    tmp += int(i)
if tmp % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

n=SI()
s=0
for c in n:s+=int(c)
if s%9:print("No")
else:print("Yes")

Solution (Python):
def examA():
    N, X, T = LI()
    ans = (1 + (N-1)//X)*T
    print(ans)
    return

def examB():
    N = SI()
    s = 0
    for n in N:
        s += int(n)
    if s%9==0:
        ans = "Yes"
    else:
        ans = "No"
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Solution (Python):
n = list(input())
ans = "Yes"
cnt = 0
for i in range(len(n)):
    cnt += eval(n[i])
print("Yes" if cnt % 9 == 0 else "No")

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

n = input()[:-1]

su = 0

for i in range(len(n)):
    su += int(n[i])
if su % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
N = input()
S = sum(map(int,N))

if S%9==0:
  print("Yes")
else:
  print("No")

Solution (Python):
n = input()
ans = 0
for i in range(len(n)):
    ans += int(n[i])
    ans %= 9
if ans == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
p = list(input())

s = sum(map(int, p))
if s % 9 == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
print("Yes") if int(input())%9 == 0 else print("No")

Solution (Python):
N=list(input())
t=0
for i in N:
    t+=int(i)
if t%9==0:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
if n%9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n = input()
ans = 0
for i in range(len(n)):
    ans += int(n[i])
if ans%9==0:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

INF = 10**18
eps = 10**-7

s = input()
n = len(s)
ans = 0
for si in s:
    ans = (ans+int(si))%9
if ans == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n = input()

total = 0

for ch in n:
    num = int(ch)
    total += num

if total % 9 == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n = input()

check = 0

for i in range(len(n)):
    check += int(n[i])

if check % 9 == 0:
    print('Yes')
else:
    print('No')