AtCoder Beginner Contest 176 - Multiple of 9

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-----
123456789

-----Sample Output-----
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.

Difficulty: EASY

Starter code:

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


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


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


print('Yes' if sum((int(ch) for ch in input())) % 9 == 0 else 'No')


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


n = list(map(int, input().split()))
print('No' if sum(n) % 9 else 'Yes')


N = int(input())
M = str(N)
a = [0] * len(M)
S = 0
for i in range(len(M)):
	a[i] = int(M[i])
for j in a:
	S = S + j
if S % 9 == 0:
	print('Yes')
else:
	print('No')


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


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


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


import numpy as np
a = np.array(list(map(int, list(input()))), dtype=np.int64).sum() % 9 == 0
if a:
	print('Yes')
else:
	print('No')


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


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


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


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


print('No' if sum([int(x) for x in input()]) % 9 else 'Yes')


n = int(input())
ans = 'Yes' if n % 9 == 0 else 'No'
print(ans)


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


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


MOD = 10 ** 9 + 7
N = input()
ans = 'Yes' if sum(map(int, N)) % 9 == 0 else 'No'
print(ans)


print('YNeos'[int(input()) % 9 > 0::2])


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


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


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


n = input()
wa = 0
for i in range(0, 10):
	wa = wa + n.count(str(i)) * i
print('Yes' if wa % 9 == 0 else 'No')


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


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


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


print('YNeos'[sum(map(int, list(input()))) % 9 > 0::2])


print(['No', 'Yes'][sum(list(map(int, list(input())))) % 9 == 0])


N = str(input())
tmp = 0
for n in N:
	tmp += int(n)
if tmp % 9 == 0:
	print('Yes')
else:
	print('No')


N = input()
S = sum((int(n) for n in N))
print('Yes' if S % 9 == 0 else 'No')


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


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


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


N = input()
S = 0
for i in N:
	S += int(i)
if S == 0:
	print('Yes')
elif S < 9:
	print('No')
elif S % 9 == 0:
	print('Yes')
else:
	print('No')


from sys import stdin
N = list(stdin.readline().rstrip())
d_sum = 0
for n in N:
	d_sum += int(n)
if d_sum % 9 == 0:
	print('Yes')
else:
	print('No')


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


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


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


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


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


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


def main():
	num = sum(list(map(lambda x: int(x), input())))
	if num % 9 == 0:
		print('Yes')
	else:
		print('No')

def __starting_point():
	main()
__starting_point()


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


N = input()

def ans176(N: str):
	sum = 0
	for i in range(len(str(N))):
		sum += int(str(N)[i])
	if sum % 9 == 0:
		return 'Yes'
	else:
		return 'No'
print(ans176(N))


ans = int(input()) % 3 == 0
if ans:
	print('Yes')
else:
	print('No')


n = input()
c = [int(i) for i in n]
print('Yes' if sum(c) % 9 == 0 else 'No')


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


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


numero = input()
soma = 0
for n in numero:
	soma += int(n)
print(f"{('Yes' if soma % 9 == 0 else 'No')}")


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


def answer(n: str) -> str:
	result = 0
	for i in n:
		result += int(i)
	return 'Yes' if result % 9 == 0 else 'No'

def main():
	n = input()
	print(answer(n))

def __starting_point():
	main()
__starting_point()


s = sum(map(int, list(input())))
print(s % 9 == 0 and 'Yes' or 'No')


import sys

def input():
	return sys.stdin.readline().strip()
sys.setrecursionlimit(20000000)
MOD = 10 ** 9 + 7
INF = float('inf')

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

def __starting_point():
	main()
__starting_point()


print('YNeos'[int(input()) % 3 != 0::2])


N = input()
list = []
t = 0
for i in range(len(N)):
	list.append(N[i])
for i in range(len(list)):
	t = t + int(list[i])
if t % 9 == 0:
	print('Yes')
else:
	print('No')


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


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


import re
import sys
lst = []
for line in sys.stdin:
	lst.append(line.rstrip('\n'))
regex = [[int(r) for r in re.findall('(\\d+)', line)] for line in lst]
verifica = lambda x: 'Yes' if x % 9 == 0 else 'No'
[print(verifica(r[0])) for r in regex]


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


print(['No', 'Yes'][sum((int(c) for c in input())) % 9 == 0])


s = input()
print('Yes' if sum((int(c) for c in s)) % 9 == 0 else 'No')


print('NYoe s'[sum([int(i) for i in input()]) % 9 == 0::2])


print('No' if sum(list(map(int, list(input())))) % 9 else 'Yes')


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


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


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


temp = input()
temp = list(temp)
num_list = [int(s) for s in temp]
sum = 0
for i in range(len(num_list)):
	sum += num_list[i]
if sum % 9 == 0:
	print('Yes')
else:
	print('No')


def answer(n: str) -> str:
	return 'Yes' if sum(map(int, n.split())) % 9 == 0 else 'No'

def main():
	n = input()
	print(answer(n))

def __starting_point():
	main()
__starting_point()


N = input()
nums = []
length = len(N)
for i in range(1, length + 1):
	value = int(N[-i])
	nums.append(value)
sumOfNums = sum(nums)
if sumOfNums % 9 == 0:
	print('Yes')
else:
	print('No')


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


s = 0
for x in input():
	s = (s + int(x)) % 9
print('YNeos'[s > 0::2])


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


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


L = input()
r = 0
for l in L:
	r += int(l)
print('Yes' if r % 9 == 0 else 'No')


print(('No', 'Yes')[int(input()) % 9 == 0])


print(['No', 'Yes'][sum([int(_) for _ in input()]) % 9 == 0])


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


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


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


def main():
	try:
		N = input()
		a = list(N)
		s = 0
		for i in range(len(a)):
			s += int(a[i])
		print('Yes' if s % 9 == 0 else 'No')
	except EOFError:
		print('No')

def __starting_point():
	main()
__starting_point()


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


nums = list(map(int, input()))
num_len = len(nums)
sums = 0
for i in range(num_len):
	sums += nums[i]
if sums % 9 == 0:
	print('Yes')
else:
	print('No')


n = int(input())
print('No' if n % 3 else 'Yes')


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


n_l = list(str(input()))
sum_num = 0
for i in n_l:
	sum_num += int(i)
if sum_num % 9 == 0 or sum_num == 0:
	print('Yes')
else:
	print('No')


print('YNeos'[sum(map(int, input().split())) % 9 != 0::2])


a = input()
b = sum(map(int, a))
if b % 9 == 0:
	print('Yes')
else:
	print('No')


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


p = input()
if p == '0':
	print('Yes')
elif len(p) == 1 and p != '9':
	print('No')
elif len(p) == 1 and p == '9':
	print('Yes')
elif sum([int(val) for val in p]) % 9 == 0:
	print('Yes')
else:
	print('No')


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(rs())

def rs_():
	return [_ for _ in rs().split()]

def ri_():
	return [int(_) for _ in rs().split()]
N = [int(i) for i in rs()]
print('Yes' if sum(N) % 9 == 0 else 'No')


import sys
N = list(input())
sum = 0
for i in range(len(N)):
	sum += int(N[i])
print('Yes' if sum % 9 == 0 else 'No')


N = int(input())
my_str = str(N)
my_sum = 0
for i in my_str:
	my_sum += int(i)
print('Yes' if my_sum % 9 == 0 else 'No')


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


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


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


def b176(n):
	intn = [int(i) for i in n]
	return 'Yes' if sum(intn) % 9 == 0 else 'No'

def main():
	n = list(str(input()))
	print(b176(n))

def __starting_point():
	main()
__starting_point()


N = str(input())
num = list(N)
natural_num = list(map(int, num))
K = len(natural_num)
L_num = 0
for i in range(K):
	L_num += natural_num[i]
ans = L_num % 9
if ans == 0:
	print('Yes')
else:
	print('No')


a = int(input())
b = str(a)
c = list(map(int, b))
d = sum(c)
if d % 9 == 0:
	print('Yes')
else:
	print('No')