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



Sample input:
123456789


Sample output:
Yes

Submission status: Accepted

Solution code:
## for use in beginner level questions where speed is key
## and also for single test case code
## mastercopy for x,y,z

import sys
import heapq, functools, collections
import random
from collections import Counter, defaultdict

# read line as a string
strr = input()

# read line as an integer
# k = int(input())

# read one line and parse each word as a string
# lst = input().split()

# read one line and parse each word as an integer
# arr = list(map(int,input().split()))

summ = sum([int(x) for x in strr])

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()

K = str(N)
cnt = 0
for k in K:
    cnt += int(k)
if cnt % 9 == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=input()

sm=0
for i in s:
  sm+=int(i)
def yana(boo):
  if boo:
    print("Yes")
  else:
    print("No")

yana(sm%9==0)

Submission status: Accepted

Solution code:
## coding: UTF-8

N = input()

now = 0

for i in range(len(N)):
    now += int(N[i])
    #print(now)

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

Submission status: Accepted

Solution code:
def solve():
    n = map(int, input())
    ans = sum(n)
    if ans % 9 == 0:
        print("Yes")
    else:
        print("No")
    return 0
if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#abc176-b
sN = input()
N=0
for i in range(len(sN)):
    N += int(sN[i])
print('Yes' if N%9==0 else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=input()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial,sqrt
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    n=str(I())
    ans=0
    for i in range(len(n)):
        ans=(ans+int(n[i]))%9
    if ans%9==0:
        print("Yes")
    else:
        print("No")
        
    
if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import math
sys.setrecursionlimit(500000)
INF = float('inf')

def main():
    n = input()
    sum_digits = 0
    for i in n:
        sum_digits += int(i)
    if sum_digits % 9 == 0:
        return 'Yes'
    else:
        return 'No'

if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:


def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    s=input()
    N=len(s)
    ans=0
    for i in range(N):
        a=int(s[i])
        ans=(ans+a)%9
        
    if ans==0:
        print("Yes")
    else:
        print("No")
    

main()

Submission status: Accepted

Solution code:
N = input()
sum = 0
for c in N:
    sum += int(c)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input().rstrip()
mod = 0
for c in s:
    mod += int(c)
    mod %= 9

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    S = in_s()
    N = len(S)

    cnt = 0
    for i in range(N):
        cnt += int(S[i])

    if cnt % 9 == 0:
        ans = "Yes"
    else:
        ans = "No"

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    s = input()
    div = 0
    for tmp in s:
        i = int(tmp)
        div += i
        div %= 9
    if div == 0:
        print(yes)
    else:
        print(no)


main()

Submission status: Accepted

Solution code:
s = input()
t = 0
for c in s :
    t += int(c)

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

Submission status: Accepted

Solution code:
# coding: utf-8
#import numpy as np
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])#[cost,x]
    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)#x→yが複数ある場合のためにmin()する
    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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
n = input()

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
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):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    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()

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


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


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = next(tokens)  # type: str
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
N=input()

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin


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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = input()

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,x,t = map(int,readline().split())
#print((n+x-1)//x*t)

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
N = int(input())
if N % 9 == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = input()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()

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

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

A = input()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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")

Submission status: Accepted

Solution code:
n = input()

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

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')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

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

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

Submission status: Accepted

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


x = int(input())

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

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

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