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:
n = int(input())
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)
if digitSum(n)%9 == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict, deque
from copy import deepcopy
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = input().rstrip()
    ans = 0
    for i in range(len(N)):
        ans += int(N[i])
    if ans % 9 == 0:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = list(input())
total = 0
for i in range(len(N)):
    total += int(N[i])
    total = total % 9

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

Submission status: Accepted

Solution code:
N = input()

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

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

Submission status: Accepted

Solution code:
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    #l,r,d=map(int,input().split())
    n=input()
    count=0
    for i in range(len(n)):
        count+=int(n[i])
    if count%9==0:
        print("Yes")
    else:
        print("No")




if __name__ == "__main__":

    main()

Submission status: Accepted

Solution code:
import math
import re
#import sympy

#n,x,t=map(int,input().split())
s=input()
atemp=0
for i in range(len(s)):
    atemp+=int(s[i])
if atemp%9==0:
    print("Yes")
    exit()

print("No")

Submission status: Accepted

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

Submission status: Accepted

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


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 main():
    n = input()
    ans = 0
    for i in range(len(n)):
        ans += int(n[i])

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


main()

Submission status: Accepted

Solution code:
def main():
    import sys
    S=sys.stdin.readline().strip()
    k=0
    for a in S:
        k+=int(a)

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

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key
from bisect import bisect_left


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

def bindex(a,x):
    i = bisect_left(a,x)
    if i != len(a) and a[i] == x:
        return i
    return None

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



if __name__ == '__main__':
    N = intinput()
    judge = N%9==0
    print(yn[not judge::2])

Submission status: Accepted

Solution code:

N = list(input()) #１文字ずつ

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

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

Submission status: Accepted

Solution code:
n=list(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:
import sys
import math

if __name__ == '__main__':
    N = int(sys.stdin.readline())
    r = N % 9
    if r == 0:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
nl = list(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
total=0
for v in nl:
    v2=int(v)
    total+=v2
if total%9==0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()

count = 0
for n in N:
    count += int(n)

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

Submission status: Accepted

Solution code:
A = list(map(int, list(input())))

n = sum(A)

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

Submission status: Accepted

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True


def main():
    s = S()
    ans = 0

    for t in s:
        ans += int(t)

    print(yn[ans % 9 == 0])


if __name__ == '__main__':
    main()

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:
n = input()
val = 0
for item in n:
  val+=int(item)
if val%9==0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
print('YNeos'[sum(int(i) for i in input())%9>0::2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=list(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:
N = input()

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = list(map(int,list(input())))

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

Submission status: Accepted

Solution code:
n = list(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:
def main():
    n = int(input())
    total = 0
    for i in str(n):
        total+=int(i)
    if total%9==0:
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
n=list(input())

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

Submission status: Accepted

Solution code:
N = input()

mod_9 = 0
for n in N:
    mod_9 += int(n)
    mod_9 %= 9
if mod_9 == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = str(input())
s = 0
for i in n:
    s += int(i)
if s % 9 == 0:
    print('Yes')
else:
    print('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:
input_str = input()
if sum([int(c) for c in input_str])%9==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def _s(): return sys.stdin.readline().strip()


def main():
    a = 0
    for c in _s():
        a = (a + int(c)) % 9
    return 'Yes' if a == 0 else 'No'


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    s = str(n)
    m = sum(int(i) for i in list(s))
    print('Yes' if m % 9 == 0 else 'No')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
n = input()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

if wa == 0:
    print('Yes')

else:
    print('No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = str(input())
now = 0
for i in range(len(N)):
    now += eval(N[i])
if now % 9 == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:input()

"""========main code==============="""
t=1
#t=ii()
for _ in range(t):
    n=ip()
    ans=0
    for i in n:
        ans+=ord(i)-ord('0')
    if(ans%9==0):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("## ",*x,file=sys.stderr) if LOCAL else 0
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    s=input()
    cnt=0
    for si in s:
        cnt+=int(si)
    if cnt%9==0:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

s = str(n)
total = 0
for i in range(len(s)):
    total += int(s[i])

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

Submission status: Accepted

Solution code:
N = list(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:
from sys import exit
import math
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = input()

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
#from bisect import bisect_left as bl, bisect_right as br, insort
#from heapq import heapify, heappush, heappop
#from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write(' '.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
from decimal import Decimal
#from fractions import Fraction
#sys.setrecursionlimit(100000)
INF = float('inf')
mod = int(1e9)+7

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

Submission status: Accepted

Solution code:
n = input()
s = 0
for num in n:
    s += int(num)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

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:
S=input()
n=0
for s in S:
  n+=int(s)
print("Yes" if n%9==0 else "No")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
#n = int(input())
#n, x, t = map(int, sys.stdin.readline().split())
n = input()
#p = list(map(int, sys.stdin.readline().split()))

a = 0

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

if a % 9 == 0:
    print("Yes")
else:
    print("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:
N = int(input())
print('Yes' if N%9==0 else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int( input() )

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

Submission status: Accepted

Solution code:
n=str(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:
N=input()
ans = 0
for n in N:
    ans = (ans + int(n))%9

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

Submission status: Accepted

Solution code:
N = input()

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

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

Submission status: Accepted

Solution code:
N = list(str(input()))

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

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = input()

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

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

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = map(int, list(IS()))
    if sum(n) % 9 == 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
ans = 0
for i in s:
    ans += int(i)
    ans = ans % 9

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
from collections import Counter


def read():
    N = list(input().strip())
    return N,


def solve(N):
    s = sum(map(int, N))
    return "Yes" if s % 9 == 0 else "No"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Accepted

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

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n = list(input())[:-1]
n = [int(s) for s in n]

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

Submission status: Accepted

Solution code:
def main():
    N = list(map(int,list(input())))
    ans = 0
    for n in N:
        ans += n
        ans %= 9
    
    if ans % 9 == 0:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N = input()
cnt = 0

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

Submission status: Accepted

Solution code:
N = input()

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

Submission status: Accepted

Solution code:
S = input().strip()
l=len(S)
x=0
for i in range(l):
    x+=int(S[i])
if x%9==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
import math
# sys.stdin  = open("input.txt")
n=input()
s=0
for i in n:
    s+=int(i)
print("Yes" if s%9==0 else "No")

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

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

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

Submission status: Accepted

Solution code:
S = input()

N = len(S)

sm = 0
for i in range(N):
  sm += int(S[i])
  
if sm % 9 == 0:
  print('Yes')
else:
  print('No')