Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = [input() for i in range(N)]
l2 = []
ans = 0
for a in l:
    if a not in l2:
        ans+=1
        l2.append(a)
    else:
        pass
print(ans)

Fixed submission:
from collections import Counter

N = int(input())
l = [input() for i in range(N)]

print(len(Counter(l)))
Buggy python submission (verdict: Runtime Error):
S = input()
T = [0]*2019
T[0]=1
t = 0
ans = 0
dig = 1
for i in range(n):
    t = (t + (int(S[-i-1]))*dig)%2019
    dig = (dig*10)%2019
    T[t] += 1
for j in T:
    ans +=int(j*(j-1)/2)
print(ans)

Fixed submission:
S = input()
T = [0]*2019
T[0]=1
t = 0
ans = 0
dig = 1
for i in range(len(S)):
    t = (t + (int(S[-i-1]))*dig)%2019
    dig = (dig*10)%2019
    T[t] += 1
for j in T:
    ans +=int(j*(j-1)/2)
print(ans)

Buggy python submission (verdict: Runtime Error):
S = input()
T = [0]*2019
T[0]=1
t = 0
ans = 0
dig = 1
for i in range(n):
    t = (t + (int(S[-i-1]))*dig)%2019
    dig = dig*10%2019
    T[t] += 1
for j in T:
    ans +=int(j*(j-1)/2)
print(ans)

Fixed submission:
S = input()
T = [0]*2019
T[0]=1
t = 0
ans = 0
dig = 1
for i in range(len(S)):
    t = (t + (int(S[-i-1]))*dig)%2019
    dig = (dig*10)%2019
    T[t] += 1
for j in T:
    ans +=int(j*(j-1)/2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
n = len(S)
T = [0]*2019
T[0]=1
t = 0
ans = 0
for i in range(n):
    t = (t + (int(S[-i-1]))*(10**i))%2019
    T[t] += 1
for j in T:
    ans +=int(j*(j-1)/2)
print(ans)

Fixed submission:
S = input()
T = [0]*2019
T[0]=1
t = 0
ans = 0
dig = 1
for i in range(len(S)):
    t = (t + (int(S[-i-1]))*dig)%2019
    dig = (dig*10)%2019
    T[t] += 1
for j in T:
    ans +=int(j*(j-1)/2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
n = len(S)
T = {}
T['0']=1
t = 0
ans = 0
for i in range(n):
    t = (t + (int(S[-i-1]))*(10**i))%2019
    if str(t) in T: T[str(t)] +=1
    else: T[str(t)]=1
for v in T.values():
    ans +=int(( int(v)*(int(v)-1))/2)
print(ans)

Fixed submission:
S = input()
T = [0]*2019
T[0]=1
t = 0
ans = 0
dig = 1
for i in range(len(S)):
    t = (t + (int(S[-i-1]))*dig)%2019
    dig = (dig*10)%2019
    T[t] += 1
for j in T:
    ans +=int(j*(j-1)/2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
ans=0
for i in range(len(S)-3):
    j=4
    while i+j <= len(S):
        q = int(S[i:i+j])%2019
        if q==0:
            ans+=1
            j+=4
        elif len(str(q))==4:
            j+=1
        else :
            j += 4-len(str(q))
print(ans)

Fixed submission:
S = input()
T = [0]*2019
T[0]=1
t = 0
ans = 0
dig = 1
for i in range(len(S)):
    t = (t + (int(S[-i-1]))*dig)%2019
    dig = (dig*10)%2019
    T[t] += 1
for j in T:
    ans +=int(j*(j-1)/2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
x=1
ans=0
for i in range(len(S)-3):
    j=4
    while i+j <= len(S):
        if int(S[i:i+j])%2019==0:
            ans+=1
            j+=4
        else:
            j+=1
print(ans)

Fixed submission:
S = input()
T = [0]*2019
T[0]=1
t = 0
ans = 0
dig = 1
for i in range(len(S)):
    t = (t + (int(S[-i-1]))*dig)%2019
    dig = (dig*10)%2019
    T[t] += 1
for j in T:
    ans +=int(j*(j-1)/2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())

def sumall(a,b):
  s=0
  while a<=b:
    s=s+a
    a+=1
  return s
ans=0
while k <= n+1:
  ans += sumall(n-k+1, n)-int((k-1)*k/2)+1
  k+=1
print(ans)

Fixed submission:
n, k = map(int, input().split())
ans=0
while k <= n+1:
  ans += k*(n-k+1)+1
  k+=1
print(ans%(10**9+7))
Buggy python submission (verdict: Runtime Error):
l = list(input())

for i in range(3):
  if list[i] == "7":
    print("Yes")
    exit()

print("No")

Fixed submission:
l = list(input())
 
for i in range(3):
  if l[i] == "7":
    print("Yes")
    exit()
 
print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import math

K = int(input())+1
ans = 0
for i in range(1,K):
    for j in range(1,K):
        for k in range(1,K):
            ans += math.gcd(math.gcd(i, j),k)
print(ans)

Fixed submission:
from math import gcd
k = int(input()) + 1
ans = 0
for i in range(1,k):
  for j in range(1,k):
    for l in range(1,k):
      ans += gcd(gcd(i, j),l)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math

K = int(input())
ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += math.gcd(math.gcd(i, j),k)
print(ans)

Fixed submission:
from math import gcd
k = int(input()) + 1
ans = 0
for i in range(1,k):
  for j in range(1,k):
    for l in range(1,k):
      ans += gcd(gcd(i, j),l)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd

k = int(input())
ans = 0
 
for i in range(k):
  for j in range(k):
    for l in range(k):
      ans += gcd(gcd(i+1, j+1),l+1)
      
print(ans) 

Fixed submission:
from math import gcd
k = int(input()) + 1
ans = 0
for i in range(1,k):
  for j in range(1,k):
    for l in range(1,k):
      ans += gcd(gcd(i, j),l)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input()) + 1
ans = 0
 
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
 
for i in range(1,k):
  for j in range(1,k):
    for l in range(1,k):
      ans += gcd(gcd(i, j),l)
      
print(ans) 

Fixed submission:
from math import gcd
k = int(input()) + 1
ans = 0
for i in range(1,k):
  for j in range(1,k):
    for l in range(1,k):
      ans += gcd(gcd(i, j),l)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
ans = 0
 
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a
 
for i in range(k):
  for j in range(k):
    for l in range(k):
      ans += gcd(gcd(i+1, j+1),l+1)
      
print(ans)

Fixed submission:
from math import gcd
k = int(input()) + 1
ans = 0
for i in range(1,k):
  for j in range(1,k):
    for l in range(1,k):
      ans += gcd(gcd(i, j),l)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
 
k = int(input())
ans = 0
 
def gcd(numbers):
    return reduce(math.gcd, numbers)
 
for i in range(k):
  for j in range(k):
    for l in range(k):
      ans += gcd([i+1, j+1, l+1])
      
print(ans)

Fixed submission:
from math import gcd
k = int(input()) + 1
ans = 0
for i in range(1,k):
  for j in range(1,k):
    for l in range(1,k):
      ans += gcd(gcd(i, j),l)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
r = []
g = []
b = []
for i in range(n):
    if s[i] == 'R':
        r.append(i)
    elif s[i] == 'G':
        g.append(i)
    else:
        b.append(i)
ans = len(r)*len(g)*len(b)
for i in r:
    for j in g:
        for k in b:
            if i*2==(j+k)  or j*2==(k+i) or k*2==(i+j):
                ans -=1
print(ans)

Fixed submission:
n = int(input())
s = list(input())

r = s.count('R')
g = s.count('G')
b = s.count('B')

cnt = 0
for i in range(n):
    for j in range(i+1,n):
        k = j*2-i
        if k >= n:
            break
        elif s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            cnt +=1
print(r*g*b - cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
r = []
g = []
b = []
for i in range(n):
    if s[i] == 'R':
        r.append(i)
    elif s[i] == 'G':
        g.append(i)
    else:
        b.append(i)
ans = len(r)*len(g)*len(b)
for i in r:
    for j in g:
        for k in b:
            if float(k) == (i+j)/2 or float(i) == (j+k)/2 or float(j) == (k+i)/2:
                ans -=1
print(ans)

Fixed submission:
n = int(input())
s = list(input())

r = s.count('R')
g = s.count('G')
b = s.count('B')

cnt = 0
for i in range(n):
    for j in range(i+1,n):
        k = j*2-i
        if k >= n:
            break
        elif s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            cnt +=1
print(r*g*b - cnt)

Buggy python submission (verdict: Time Limit Exceeded):
def solve2():
    n = int(input())
    s = list(input())
    ans = 0
    for i in range(n):
        if s[i] == "R":
            for j in range(n):
                if s[j] == "G":
                    for k in range(n):
                        if s[k] == "B":
                            if float(k) == (i+j)/2 or float(i) == (j+k)/2 or float(j) == (k+i)/2:
                                pass
                            else:
                                ans += 1
    return ans
print(solve2())

Fixed submission:
n = int(input())
s = list(input())

r = s.count('R')
g = s.count('G')
b = s.count('B')

cnt = 0
for i in range(n):
    for j in range(i+1,n):
        k = j*2-i
        if k >= n:
            break
        elif s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            cnt +=1
print(r*g*b - cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())
ans = 0

for i in range(n):
  if s[i] == "R":
    for j in range(n):
      if s[j] == "G":
        for k in range(n):
          if s[k] == "B":
            if float(k) == (i+j)/2 or float(i) == (j+k)/2 or float(j) == (k+i)/2:
              pass
            else:
              ans += 1
print(ans)

Fixed submission:
n = int(input())
s = list(input())

r = s.count('R')
g = s.count('G')
b = s.count('B')

cnt = 0
for i in range(n):
    for j in range(i+1,n):
        k = j*2-i
        if k >= n:
            break
        elif s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            cnt +=1
print(r*g*b - cnt)
Buggy python submission (verdict: Runtime Error):
import sys,collections,math,random,fractions,bisect,itertools;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
x,k,d = I()
if abs(x)/d >= k:
    print(abs(x)-k*d))
elif x > 0:
    if (k - math.floor(x/d))%2 == 0:
        print(x%d))
    else:
        print(x%d-d))
elif x <= 0:
    if (k - math.ceil(x/d))%2 == 0:
        print(x%d))
    else:
        print(x%d+d))


Fixed submission:
import sys,collections,math,random,fractions,bisect,itertools;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
x,k,d = I()

if abs(x)/d >= k:
    print(abs(x)-k*d)
else:
    if (k - math.floor(x/d))%2 == 0:
        print(abs(x%d))
    else:
        print(abs(x%d-d))
Buggy python submission (verdict: Runtime Error):
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t if len(t) > 1 else t[0]
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
H,N = I()
A = I()
if sum([A]) >= H:
    print("Yes")
else:
    print("No")


Fixed submission:
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
H,N = I()
A = I()
if sum(A) >= H:
    print("Yes")
else:
    print("No")

Buggy python submission (verdict: Runtime Error):
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t if len(t) > 1 else t[0]
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]

H,N = I()
A = I()
if sum(A) >= H:
    print("Yes")
else:
    print("No")

Fixed submission:
import sys,collections,math,random,fractions,bisect;sys.setrecursionlimit(10**7)
sr = sys.stdin.readline; P = print; P2 = lambda x: print(*x, sep="\n")
def I(i=0): t = [int(x)-i for x in sr().split()];return t
def S(): t = sr().split(); return t if len(t) > 1 else t[0]
L1,L2,L3,L4, = [],[],[],[]
 
H,N = I()
A = I()
if sum(A) >= H:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
import sys,collections,math,random;sys.setrecursionlimit(10**7)
from math import factorial
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

MOD = 10**9+7
def comb(n, r):
    return factorial(n)  // (factorial(n - r) * factorial(r)) % MOD
    
N,K = Is()
for i in range(1,K+1):
#    print(K-1,i-1,N-K+1,i)
#    print(comb(K-1,i),comb(i+2,N-K-i))
    print((comb(K-1,i-1) * comb(N-K+1,i)) % MOD)


Fixed submission:
import sys,collections,math,random;sys.setrecursionlimit(10**7)
from math import factorial
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

MOD = 10**9+7
def comb(n, r):
    return factorial(n)  // (factorial(n - r) * factorial(r)) % MOD
    
N,K = Is()
for i in range(1,K+1):
#    print(i,K-1,i-1,N-K+1,i)
    if N-K+1 < i:
        print(0)
    else:
        print((comb(K-1,i-1) * comb(N-K+1,i)) % MOD)
Buggy python submission (verdict: Runtime Error):
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

a,b,c,d = Is()
mc = b//c - (a-1)//c
md = b//d - (a-1)//d
mincom = lcm(c,d)
mcd = b//(mincom) - (a-1)//(mincom)
ans = b-a+1 - (mc + md - mcd)
#print(mc,md,mcd)
print(ans)

Fixed submission:
import sys,collections,math,random,fractions;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

a,b,c,d = Is()
mc = b//c - (a-1)//c
md = b//d - (a-1)//d
mincom = lcm(c,d)
mcd = b//(mincom) - (a-1)//(mincom)
ans = b-a+1 - (mc + md - mcd)
#print(mc,md,mcd)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

H,W = Is()
mat = [[0]*W for i in range(H)]
inp = []
for i in range(H):
    inp.append(list(S()))
for i in range(H):
    t = 0
    for j in range(W):
        if inp[i][j] == ".":
            t += 1
            if j == W-1:
                for k in range(j+1-t,j+1):
                    mat[i][k] += t
        elif inp[i][j] == "#":
            for k in range(j-t,j):
                mat[i][k] += t
            t = 0
#print(*mat)
for j in range(W):
    t = 0
    for i in range(H):
        if inp[i][j] == ".":
            t += 1
            if i == H-1:
                for k in range(i+1-t,i+1):
                    mat[k][j] += t
        elif inp[i][j] == "#":
            for k in range(i-t,i):
                mat[k][j] += t
            t = 0    
#print(*mat)
ans = 0
for e in mat:
    ans = max(ans,max(e))
print(max(0,ans-1))

Fixed submission:
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

H,W = Is()
mat = [[0]*W for i in range(H)]
inp = []
for i in range(H):
    inp.append(list(S()))
for i in range(H):
    t = 0
    for j in range(W):
        if inp[i][j] == ".":
            t += 1
            if j == W-1:
                for k in range(j+1-t,j+1):
                    mat[i][k] += t
        elif inp[i][j] == "#":
            for k in range(j-t,j):
                mat[i][k] += t
            t = 0
#print(*mat)
for j in range(W):
    t = 0
    for i in range(H):
        if inp[i][j] == ".":
            t += 1
            if i == H-1:
                for k in range(i+1-t,i+1):
                    mat[k][j] += t
        elif inp[i][j] == "#":
            for k in range(i-t,i):
                mat[k][j] += t
            t = 0    
#print(*mat)
ans = 0
for e in mat:
    ans = max(ans,max(e))
print(max(0,ans-1))
Buggy python submission (verdict: Time Limit Exceeded):
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,m = Is()
s = set(range(1,n+1))
for i in range(m):
    l,r = Is()
    s = s & set(range(l,r+1))
print(len(s))

Fixed submission:
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,m = Is()
left,right = 0,n
for i in range(m):
    l,r = Is()
    left = max(left,l)
    right = min(right,r)
#    print(left,right)
if right-left < 0:
    print(0)
else:
    print(right-left+1)
Buggy python submission (verdict: Time Limit Exceeded):
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,m = Is()
a = Is()
for i in range(m):
    b,c = Is()
    a += [c]*b
a = sorted(a,reverse=True)
print(sum(a[:n]))

Fixed submission:
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,m = Is()
a = Is()
d = collections.defaultdict(int)
for e in a:
    d[e] += 1
for i in range(m):
    b,c = Is()
    d[c] += b
a = sorted(d.items(),reverse=True)
ans = 0
for e,f in a:
    if n <= f:
        ans += e*n
        break
    else:
        n -= f
    ans += e*f
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,Q = Is()
S = S()
lis = [0]*(N-1)
for i in range(N-1):
    if S[i:i+2] == "AC":
        lis[i] = 1
for q in range(Q):
    l,r = Is()
    print(sum(lis[l-1:r-1]))


Fixed submission:
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N,Q = Is()
S = S()
lis = [0]
t = 0
for i in range(N):
    if S[i:i+2] == "AC":
        t += 1
    lis.append(t)
for q in range(Q):
    l,r = Is()
    print(lis[r-1]-lis[l-1])
Buggy python submission (verdict: Runtime Error):
import sys,collections,math,functools;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n, s = Is()
xs = Is()
xs2 = [e-s for e in xs]
gcd = functools.reduce(math.gcd, xs2)
print(gcd)

Fixed submission:
import sys,collections,math,functools;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

n, s = Is()
xs = Is()
xs2 = [abs(e-s) for e in xs]
c = xs2[0]
ans = c
for e in xs2:
    ans = gcd(ans,e)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n,k = Is()
ls = Is()
_1 = ls.index(1)
if _1 < k-1:
    _1 = k-1
elif _1 < n-k:
    _1 = n-k
print(math.ceil(_1/(k-1))+math.ceil((n-1-_1)/(k-1)))


Fixed submission:
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
s = 0
for e in str(n):
    s += int(e)
if n%s == 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

MOD = 998244353

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)] % MOD
    
N,A,B,K = Is()
ans = 0
for x in range(N+1):
    if N >= (K-A*x)/B >= 0 and (K-A*x)/B == int((K-A*x)/B):
        ans += cmb(N,x)*cmb(N,(K-A*x)/B) % MOD
print(int(ans))


Fixed submission:
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 998244353 #出力の制限
N = 3*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N,A,B,K = Is()
ans = 0
for x in range(N+1):
    y = (K-A*x)/B
    if 0 <= y <= N and y.is_integer():
        ans += cmb(N,x,mod)*cmb(N,int(y),mod) % mod
print(ans % mod)

Buggy python submission (verdict: Runtime Error):
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

MOD = 998244353

def comb(n, r):
    if n == 0 or r == 0: return 1
    return ( comb(n, r-1) % MOD) * (n-r+1) / r
    
N,A,B,K = Is()
ans = 0
for x in range(N+1):
    if (K-A*x)/B >= 0 and (K-A*x)/B == int((K-A*x)/B):
        ans += comb(N,x)*comb(N,(K-A*x)/B) % MOD
print(int(ans))


Fixed submission:
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 998244353 #出力の制限
N = 3*10**5
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N,A,B,K = Is()
ans = 0
for x in range(N+1):
    y = (K-A*x)/B
    if 0 <= y <= N and y.is_integer():
        ans += cmb(N,x,mod)*cmb(N,int(y),mod) % mod
print(ans % mod)