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 = input()
lst = []
for i in n:
    lst.append(int(i))
summ = sum(lst)
if summ % 9 == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N=input()
s=0
for i in N:
    s+=int(i)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x=input()

counter=0
for i in range(len(x)):
	counter+=int(x[i])

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

Submission status: Accepted

Solution code:
n = input()

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

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

Submission status: Accepted

Solution code:
def digitSum(n):
    s = str(n)
    array = list(map(int,s))
    return sum(array)
a = int(input())
if digitSum(a) % 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:
ln = input()
score = 0

for i in range(len(ln)):
  score += int(ln[i])

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

if n % 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:
print('No'if sum(list(map(int,list(input()))))%9 else'Yes')

Submission status: Accepted

Solution code:
#-------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# ------------------- fast io --------------------

from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[j - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] =  j
    return pi

def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

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

def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else '0' * (length - len(y)) + y


def solve(N):
    a = 0
    for i in N:
        a += int(i)
    return "Yes" if a % 9 == 0 else "No"

N = input()
print(solve(N))

Submission status: Accepted

Solution code:
N = input()
A = 0
for i in range(1,1+len(N)):
    A += int(N[-i])

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

Submission status: Accepted

Solution code:
N = input()
total = 0
for num in N:
    total += int(num)

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

Submission status: Accepted

Solution code:
N = list(input())
n = len(N)
ref = 0
for i in range(n):
    ref += int(N[i])

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

Submission status: Accepted

Solution code:
def test(a):
  b = 0
  for i in a:
    b = b + int(i)
  return b
     
a = input()
b = test(a)

c = b%9

if c == 0:
  print('Yes')
else:
  print('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:
N=list(input())
NN=[int(t) for t in N]
T=sum(NN)
if T%9==0:
    print("Yes")
else :
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
n = str(N)

L = sum(list(map(int, str(N))))

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

Submission status: Accepted

Solution code:
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000)
n=input()
def f(x):
    if len(x)>1:
        
        a=0
        for i in range(len(x)):
            a+=int(x[i])
    
        f(str(a))
    else:
    
        if x=="9" or x=="0":
            print("Yes")
            return
        else:
            print("No")
            return
f(n)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def getsum(N):

    sum = 0
    while(N != 0):
        sum = sum + int(N%10)
        N = int(N//10)

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

Submission status: Accepted

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

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

import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union
# import time
# import math, cmath
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import _heapify_max, _heappop_max, _siftdown_max
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import Fraction               # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)



def main():
    Num = Union[int, float]
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79e+308
    # inf = 2 ** 63 - 1             # (for fast JIT compile in PyPy) 9.22e+18
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input():  return sys.stdin.readline().rstrip()
    def ii():     return int(input())
    def isp():    return input().split()
    def mi():     return map(int, input().split())
    def mi_0():   return map(lambda x: int(x)-1, input().split())
    def lmi():    return list(map(int, input().split()))
    def lmi_0():  return list(map(lambda x: int(x)-1, input().split()))
    def li():     return list(input())
    def debug(x): print(x, file=sys.stderr)
    # def _heappush_max(h, item): h.append(item); _siftdown_max(h, 0, len(h)-1)
    
    
    s = input()
    res = 0
    for char in s:
        res = (res + int(char)) % 9
    print('Yes' if res == 0 else 'No')



if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = input()
sum = 0
for i in range(len(num)):
    sum += int(num[i])

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

Submission status: Accepted

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

Submission status: Accepted

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

main()

Submission status: Accepted

Solution code:
n = int(input())

num_list = [int(x) for x in list(str(n))]

total = 0

for i in num_list:
    total += i

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()
cnt =   n.count("1") +2*n.count("2")+3*n.count("3")+4*n.count("4")+5*n.count("5")+6*n.count("6")+7*n.count("7")+8*n.count("8")+9*n.count("9")
if cnt%9 == 0 :
    print ('Yes')
else :
    print ('No')

Submission status: Accepted

Solution code:
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    now = 0
    for c in input():
        now += int(c)

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

Submission status: Accepted

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

Submission status: Accepted

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

n = str(input())
s = len(n)

t = 0

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

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

Submission status: Accepted

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

sum = sum(N)

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

Submission status: Accepted

Solution code:
N=list(input())
N_2=list(map(int,N))
print('YNeos'[sum(N_2)%9!=0::2])

Submission status: Accepted

Solution code:
a=input()

sum=0

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

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

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest
import math

def resolve():
    N, =  input().split()
    calc9(N)

# def resolve():
#     N, = map(int, input().split())
#     if N%9==0:
#         print("Yes")
#     else:
#         print("No")

def calc9(n):
    if len(n)==1:
        if n=='9' or n=='0':
            # print(n)
            print("Yes")
        else:
            # print(n)
            print("No")
    else:
        sum =0
        for s in n:
            sum=sum+int(s)
        calc9(str(sum))

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    # def test_入力例_1(self):
    #     input = """123456789"""
    #     output = """Yes"""
    #     self.assertIO(input, output)
    #
    def test_入力例_2(self):
        input = """0"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """31415926535897932384626433832795028841971693993751058209749445923078164062862089986280"""
        output = """No"""
        self.assertIO(input, output)


if __name__ == "__main__":
    resolve()

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())
lst = [int(i) for i in n]
if sum(lst) % 9 ==0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = input()

num = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())

result=sum(list(map(int, str(N))))
if result%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 = input()
t = sum(list(map(int, list(n))))


if int(t / 9) == t / 9:
    print("Yes")
else:
    print("No")

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:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(1000000)
from collections import deque

# 整数の入力
N = int(input())
# s = 0

# while N//10 != 0 or  N%10 !=0:
#     s += N%10
#     N //= 10

if 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 = input()
suma = 0
for i in range(len(n)):
    suma += int(n[i])
if suma % 9 == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = list(input())

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

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

Submission status: Accepted

Solution code:
n = int(input())
N = str(n)
r = len(N)
ct = 0
for i in range(r):
    ct += int(N[i])

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

Submission status: Accepted

Solution code:
N = int(input())
s = 0

s = sum(list(map(int, str(N))))

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

Submission status: Accepted

Solution code:
a=input()
s=[int(s) for s in a]
b=sum(s)
if b%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 = 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:
a = input()
s = int(a)
s = list(map(int, a))
b=int(a)


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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
# N, X, T = map(int, input().split())
from functools import reduce
stringN = input()
if len(stringN) == 1:
  sum = int(stringN)
else:
  sum = reduce(lambda a, b: int(a)+int(b), stringN)
if sum % 9 == 0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
N=input()
#,X,T=list(map(int, input().split())) 

A=[]
for i in range(len(N)):
  A.append(int(N[i:i+1]))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = str(input())
le = len(N)
R = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np
A = np.array(list(map(int,list(input()))))
#print(A)
print('Yes' if np.sum(A) % 9 == 0 else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# input n

n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Hey, there Stalker!!!
# This Code was written by:
# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
# ▒▒╔╗╔═══╦═══╗▒▒▒╔╗▒▒▒
# ▒╔╝║║╔═╗║╔═╗╠╗▒▒║║▒▒▒
# ▒╚╗║║║║║║║║║╠╬══╣║╔╗▒
# ▒▒║║║║║║║║║║╠╣║═╣╚╝╝▒
# ▒╔╝╚╣╚═╝║╚═╝║║║═╣╔╗╗▒
# ▒╚══╩═══╩═══╣╠══╩╝╚╝▒
# ▒▒▒▒▒▒▒▒▒▒▒╔╝║▒▒▒▒▒▒▒
# ▒▒▒▒▒▒▒▒▒▒▒╚═╝▒▒▒▒▒▒▒
# ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
#from functools import reduce

#mod=int(1e9+7)
#import resource
#resource.setrlimit(resource.RLIMIT_STACK, [0x100000000, resource.RLIM_INFINITY])
#import threading
#threading.stack_size(2**26)
"""fact=[1]
#for i in range(1,100001):
#    fact.append((fact[-1]*i)%mod)
#ifact=[0]*100001
#ifact[100000]=pow(fact[100000],mod-2,mod)
#for i in range(100000,0,-1):
#    ifact[i-1]=(i*ifact[i])%mod"""
#from collections import deque, defaultdict, Counter, OrderedDict
#from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
#from heapq import heappush, heappop, heapify, nlargest, nsmallest


# sys.setrecursionlimit(10**6) 
from sys import stdin, stdout
import bisect            #c++ upperbound
from bisect import bisect_left as bl              #c++ lowerbound bl(array,element)
from bisect import bisect_right as br             #c++ upperbound
import itertools
from collections import Counter
from math import sqrt
import collections
import math
import heapq
import re
def modinv(n,p):
    return pow(n,p-2,p)
def cin():
    return map(int,sin().split())
def ain():                           #takes array as input
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())
  
def Divisors(n) : 
    l = []  
    for i in range(1, int(math.sqrt(n) + 1)) :
        if (n % i == 0) : 
            if (n // i == i) : 
                l.append(i) 
            else : 
                l.append(i)
                l.append(n//i)
    return l

def most_frequent(list):
    return max(set(list), key = list.count) 
def GCD(x,y):
    while(y):
        x, y = y, x % y
    return x

def ncr(n,r,p):                                              #To use this, Uncomment 19-25 
    t=((fact[n])*((ifact[r]*ifact[n-r])%p))%p
    return t

def Convert(string): 
    li = list(string.split("")) 
    return li 

def SieveOfEratosthenes(n): 
    global prime
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * p, n+1, p): 
                prime[i] = False
        p += 1
    f=[]
    for p in range(2, n): 
        if prime[p]: 
            f.append(p)
    return f
prime=[]
q=[]
def dfs(n,d,v,c):
    global q
    v[n]=1
    x=d[n]
    q.append(n)
    j=c
    for i in x:
        if i not in v:
            f=dfs(i,d,v,c+1)
            j=max(j,f)
            # print(f)
    return j



#Implement heapq
#grades = [110, 25, 38, 49, 20, 95, 33, 87, 80, 90] 
#print(heapq.nlargest(3, grades)) #top 3 largest
#print(heapq.nsmallest(4, grades))
#Always make a variable of predefined function for  ex- fn=len
#n,k=map(int,input().split())
"""*******************************************************"""
def main():
    n=inin()
    if sum(list(map(int,str(n))))%9==0:
        print('Yes')
    else:
        print('No')

"""*******************************************************"""
######## Python 2 and 3 footer by Pajenegod and c1729
py2 = round(0.5)
if py2:
    from future_builtins import ascii, filter, hex, map, oct, zip
    range = xrange
 
import os, sys
from io import IOBase, BytesIO
 
BUFSIZE = 8192
class FastIO(BytesIO):
    newlines = 0
 
    def __init__(self, file):
        self._file = file
        self._fd = file.fileno()
        self.writable = "x" in file.mode or "w" in file.mode
        self.write = super(FastIO, self).write if self.writable else None
 
    def _fill(self):
        s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
        self.seek((self.tell(), self.seek(0,2), super(FastIO, self).write(s))[0])
        return s
 
    def read(self):
        while self._fill(): pass
        return super(FastIO,self).read()
 
    def readline(self):
        while self.newlines == 0:
            s = self._fill(); self.newlines = s.count(b"\n") + (not s)
        self.newlines -= 1
        return super(FastIO, self).readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.getvalue())
            self.truncate(0), self.seek(0)
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        if py2:
            self.write = self.buffer.write
            self.read = self.buffer.read
            self.readline = self.buffer.readline
        else:
            self.write = lambda s:self.buffer.write(s.encode('ascii'))
            self.read = lambda:self.buffer.read().decode('ascii')
            self.readline = lambda:self.buffer.readline().decode('ascii')
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip('\r\n')
if __name__== "__main__":
    main()
#threading.Thread(target=main).start()

Submission status: Accepted

Solution code:
N = str(input())

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
N : 数字文字列
Nは9の倍数か否か？
"""

N = list(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 = list(map(int, input()))

N = sum(N)

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n=input()
r=0
for i in range(len(n)):
  r=r+int(n[i])
if r%9==0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
N = int(input())

total = sum(list(map(int, str(N))))

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

Submission status: Accepted

Solution code:
N = input()
if sum(list(map(int, str(N)))) % 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])

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

Submission status: Accepted

Solution code:
N = str(input())
k = len(N)
ans = 0
for i in range (k):
 n = int (N[i])
 ans = ans + n
if ans % 9 == 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=input()

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = str(input())

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

amari = wa % 9

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

Submission status: Accepted

Solution code:
N = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
tmp = ord('0')
cul = 0
for i in n:
  cul += ord(i)-tmp
  cul = cul % 9
if(cul==0):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
N = int(input())
N_sum = sum(map(int, str(N)))


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

Submission status: Accepted

Solution code:
N=int(input())
sum_of_digits = sum(int(digit) for digit in str(N))
if sum_of_digits%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=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:

#cout<< (ll)(((2LL%mod * (n )%mod)%mod - 1%mod)%mod * k%mod)%mod <<'\n';
import sys
# input=sys.stdin.readline
# t = int(input())
# for i in range(t):
# 	n,k=map(int,input().split())
# 	res = (((2**n)%1000000007-1%1000000007)%1000000007 * k%1000000007)%1000000007
# 	print(res)
n = int(input())
if n%9==0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = input()

sum_=0
for ni in N:
    sum_ += int(ni)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
c = 0
if (N == 0):
    print("Yes")
else:
    num_list = list(str(N))
    s = len(num_list)
    for i in range(s):
        a = num_list[i]
        c += int(a) 
    if(c % 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 = raw_input()
print 'Yes' if sum(map(int,list(str(n)))) % 9 == 0 else 'No'