Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n , k = map(int,input().split())
d = set(list(map(int,input().split())))
kouho =list({0,1,2,3,4,5,6,7,8,9} - d)
kouho.sort()

def f(now):
    if now >= n:
        print(now)
        exit()
    for i in kouho:
        f(now*10 + i)

f(0)

Fixed submission:
from collections import deque
n , k = map(int,input().split())
d = set(list(map(int,input().split())))
kouho =list({0,1,2,3,4,5,6,7,8,9} - d)
kouho.sort()

p = deque()
p.append(0)

while p:
    now = p.popleft()
    if now >= n:
        print(now)
        exit()
    for i in kouho:
        p.append(now*10+i)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = 0
for i in range(2*10**5):
  digit = N%10
  S += digit
  N = N//10
T = 0
while S > 0:
  digit = S%10
  T += digit
  S = S//10
if T%9 == 0:
  print('Yes')
else:
  print('No')


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

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = 0
for i in range(2*10**5)
  digit = N%10
  S += digit
  N = N//10
T = 0
while S > 0:
  digit = S%10
  T += digit
  S = S//10
if T%9 == 0:
  print('Yes')
else:
  print('No')


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

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = 0
while N > 0:
  digit = N%10
  S += digit
  N = N//10
T = 0
while S > 0:
  digit = S%10
  T += digit
  S = S//10
if T%9 == 0:
  print('Yes')
else:
  print('No')


Fixed submission:
N = int(input())
if N%9 ==0:
  print('Yes')
else:
  print('No')
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
L = [1 for i in range(N)]
for k in range(K):
  d = int(input())
  A = list(map(int, input().spit()))
  for i in range(d):
    L[A[i] - 1] = 0
print(sum(L))

Fixed submission:
N, K = map(int, input().split())
L = [1 for i in range(N)]
for k in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for i in range(d):
    L[A[i] - 1] = 0
print(sum(L))
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = [0 if x//3==0 or x//5==0 else x for x in range(1,16)]
Q = N//15
R = N%15
S = 30 * Q * (Q+1) + sum(L[R-1])
print(S)

Fixed submission:
N = int(input())
S = 0
for i in range(N+1):
  if i%3 != 0 and i%5 != 0:
    S += i
print(S)
Buggy python submission (verdict: Time Limit Exceeded):
import math
K = int(input())
S = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    for c in range(1, K+1):
      S += math.gcd(math.gcd(a, b), c)
print(S)

Fixed submission:
import math
K = int(input())
S = 0
for a in range(1, K+1):
  for b in range(1, K+1):
    g = math.gcd(a, b)
    for c in range(1, K+1):
      S += math.gcd(g, c)
print(S)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
nR = S.count('R')
nG = S.count('G')
nB = S.count('B')
cnt = 0
for i in range(N-1):
  for j in range(i+1, N):
    k = j - i + j
    if k < N:
      L = [S[i], S[j], S[k]]
      if 'R' in L and 'G' in L and 'B' in L:
        cnt += 1
print(nR*nG*nB-cnt)

Fixed submission:
N = int(input())
S = input()
nR = 0
nG = 0
nB = 0
cnt = 0
for i in range(N):
  if S[i] == 'R':
    nR += 1
  elif S[i] == 'G':
    nG += 1
  else:
    nB += 1
  for j in range(i+1, N):
    k = j - i + j
    if k < N:
      L = [S[i], S[j], S[k]]
      if 'R' in L and 'G' in L and 'B' in L:
        cnt += 1
    else:
      break
print(nR*nG*nB-cnt)
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
p = 10**9 + 7
def ModComb(n, r, p):
    N = n%p
    R = r%p
    if N<R:
        return 0
    if N < 2*R:
        R = N-R
    if R == 0:
        return 1
    else:
        return (n*pow(r, p-2, p))%p*ModComb(n-1, r-1, p)

ans = 1
for i in range(N):
  ans *= 2
  ans = ans%p
ans = ans - 1 - ModComb(n, a, p) - ModComb(n, b, p)
ans = ans%p
print(ans)

Fixed submission:
def cmb(n, r, p):
    A = 1
    B = 1
    r = min(r, n - r)
    for i in range(r):
        A = A * (n-i) % p
        B = B * (i+1) % p
    return A * pow(B, p-2, p) % p

n, a, b = map(int, input().split())
p = 10**9 + 7
A = pow(2, n, p) - 1 - cmb(n, a, p) - cmb(n, b, p)
A = A%p
print(A)
Buggy python submission (verdict: Runtime Error):
N = int(input)
A = list(map(int, input().split()))
L = [0 for i in range(max(A)+2)]
ans = 1
L[0] = 3
p = 10 ** 9 + 7
for i in range(N):
  ai = A[i]
  ans *= (L[ai] - L[ai + 1])
  ans = ans % p
  L[ai + 1] += 1
print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
L = [0 for i in range(max(A)+2)]
ans = 1
L[0] = 3
p = 10 ** 9 + 7
for i in range(N):
  ai = A[i]
  ans *= (L[ai] - L[ai + 1])
  ans = ans % p
  L[ai + 1] += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
M = 1
prev_M = 0
A = []
for i in range(N):
  a = int(input())
  A += [a]
  if a == M:
    prev_M = M
  elif a > M:
    M = a
for i in range(N):
  if a[i] != M:
    print(M)
  else:
    print(prev_M)

Fixed submission:
N = int(input())
M = 1
prev_M = 0
A = []
for i in range(N):
  a = int(input())
  A += [a]
  if a == M:
    prev_M = M
  elif a > M:
    prev_M = M
    M = a
  elif a > prev_M:
    prev_M = a
for i in range(N):
  if A[i] != M:
    print(M)
  else:
    print(prev_M)
Buggy python submission (verdict: Runtime Error):
N, Q = map(int, input().split())
S = input()
T = [0]*N
for i in range(1, N):
    if S[i-1:i+1] == 'AC':
        T[i] = T[i-1] + 1
    else:
        T[i] = T[i-1]
for j in range(Q):
    left, right = map(int, input().split())
    print(T[right]-T[left-1])

Fixed submission:
N, Q = map(int, input().split())
S = input()
T = [0]*N
for i in range(1, N):
    if S[i-1:i+1] == 'AC':
        T[i] = T[i-1] + 1
    else:
        T[i] = T[i-1]
for j in range(Q):
    left, right = map(int, input().split())
    print(T[right-1]-T[left-1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, Q = map(int, input().split())
S = list(input())

start_pair = []
for j in range(N-1):
    if S[j] == 'A' and S[j+1] == 'C':
        start_pair.append(j)

length = len(start_pair)
start_pair = np.asarray(start_pair)
for i in range(Q):
    if length == 0:
        print(0)
    else:
        l, r = map(int, input().split())
        l -= 1
        r -= 1
        right = np.searchsorted(start_pair, r)
        left = np.searchsorted(start_pair, l)
        print(right-left)

Fixed submission:
N, Q = map(int, input().split())
S = input()
T = [0]*N
for i in range(1, N):
    if S[i-1:i+1] == 'AC':
        T[i] = T[i-1] + 1
    else:
        T[i] = T[i-1]
for j in range(Q):
    left, right = map(int, input().split())
    print(T[right-1]-T[left-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = list(input())

start_pair = [-1]
for j in range(N-1):
    if S[j] == 'A' and S[j+1] == 'C':
        start_pair.append(j)

for i in range(Q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    Count = 0
    for x in start_pair:
        if l <= x < r:
            Count += 1
    print(Count)

Fixed submission:
N, Q = map(int, input().split())
S = input()
T = [0]*N
for i in range(1, N):
    if S[i-1:i+1] == 'AC':
        T[i] = T[i-1] + 1
    else:
        T[i] = T[i-1]
for j in range(Q):
    left, right = map(int, input().split())
    print(T[right-1]-T[left-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = list(input())
start_pair = [-1]
for j in range(N-1):
    if S[j] == 'A' and S[j+1] == 'C':
        start_pair.append(j)
for i in range(Q):
    l, r = map(int, input().split())
    l -= 1
    r -= 1
    Flag = [1 for x in start_pair if l <= x < r]
    print(sum(Flag))

Fixed submission:
N, Q = map(int, input().split())
S = input()
T = [0]*N
for i in range(1, N):
    if S[i-1:i+1] == 'AC':
        T[i] = T[i-1] + 1
    else:
        T[i] = T[i-1]
for j in range(Q):
    left, right = map(int, input().split())
    print(T[right-1]-T[left-1])
Buggy python submission (verdict: Runtime Error):
L = list(map(int, input().split()))
L.sort()
if L == [1, 4, 7, 9]:
  print(YES)
else:
  print(NO)


Fixed submission:
L = list(map(int, input().split()))
L.sort()
if L == [1, 4, 7, 9]:
	print('YES')
else:
  	print('NO')

Buggy python submission (verdict: Runtime Error):
L = list(map(int, input().split()))
L.sort()
if L == [1, 4, 7, 9]:
	print(YES)
else:
  	print(NO)

Fixed submission:
L = list(map(int, input().split()))
L.sort()
if L == [1, 4, 7, 9]:
	print('YES')
else:
  	print('NO')
Buggy python submission (verdict: Runtime Error):
S = list(input())
L = list('keyence')
if len(L) > len(S):
	print('NO')
else:
    while L[0] == S[0]:
        L = L[1:]
        S = S[1:]
    while len(L) != 0 and L[-1] == S[-1]:
        L = L[:-1]
        S = S[:-1]
    if L == []:
        print('YES')
    else:
        print('NO')

Fixed submission:
S = list(input())
L = list('keyence')
while len(L)*len(S) > 0 and L[0] == S[0]:
    del L[0]
    del S[0]
while len(L)*len(S) > 0 and L[-1] == S[-1]:
    del L[-1]
    del S[-1]
if L == []:
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
S = list(input())
L = list('keyence')
if len(L) > len(S):
	print('NO')
else:
	while L[0] == S[0]:
    	L = L[1:]
    	S = S[1:]
	while len(L) != 0 and L[-1] == S[-1]:
    	L = L[:-1]
    	S = S[:-1]
	if L == []:
    	print('YES')
	else:
    	print('NO')


Fixed submission:
S = list(input())
L = list('keyence')
while len(L)*len(S) > 0 and L[0] == S[0]:
    del L[0]
    del S[0]
while len(L)*len(S) > 0 and L[-1] == S[-1]:
    del L[-1]
    del S[-1]
if L == []:
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
S = list(input())
L = list('keyence')
while L[0] == S[0]:
    L = L[1:]
    S = S[1:]
while len(L)*len(S) != 0 and L[-1] == S[-1]:
    L = L[:-1]
    S = S[:-1]
if L == []:
    print('YES')
else:
    print('NO')

Fixed submission:
S = list(input())
L = list('keyence')
while len(L)*len(S) > 0 and L[0] == S[0]:
    del L[0]
    del S[0]
while len(L)*len(S) > 0 and L[-1] == S[-1]:
    del L[-1]
    del S[-1]
if L == []:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
import numpy as np
H, W, K = map(int, input().split())
p = 10**9 + 7
r = [1, 1, 2, 3, 5, 8, 13, 21, 34]
dp = np.zeros([H + 1, W], dtype=int)
dp[0, 0] = 1
for h in range(H):
    for w in range(W):
        if w != 0:
            dp[h+1, w] += ((dp[h, w-1] * r[w-1])%p * r[W-1-w])%p
        dp[h+1, w] += ((dp[h, w] * r[w])%p * r[W-1-w])%p
        if w != W-1:
            dp[h+1, w] += ((dp[h, w+1] * r[w])%p * r[W-2-w])%p
        dp[h+1, w] = dp[h+1, w]%p
print(dp[H, K-1])

Fixed submission:
X, Y = map(int, input().split())
print(X + Y//2)
Buggy python submission (verdict: Runtime Error):
N = int(input())
If N == 1:
  print('Hello World')
else:
  A = int(input())
  B = int(input())
  print(A+B)

Fixed submission:
N = int(input())
if N == 1:
  print('Hello World')
else:
  A = int(input())
  B = int(input())
  print(A+B)
Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
X = []
Y = []
H = []
for i in range(N):
    x, y, h = map(int, input().split())
    if h != 0:
        X.append(x)
        Y.append(y)
        H.append(h)
x1 = X[0]
y1 = Y[0]
h1 = H[0]
for Cx in range(101):
    for Cy in range(101):
        h = h1 + abs(x1-Cx) + abs(y1-Cy)
        i = 1
        while i < N and h == H[i] + abs(X[i]-Cx) + abs(Y[i]-Cy):
            i += 1
        if i == N:
            print(Cx, Cy, h)
            sys.exit()

Fixed submission:
import sys
N = int(input())
X = []
Y = []
H = []
for i in range(N):
    x, y, h = map(int, input().split())
    X.append(x)
    Y.append(y)
    H.append(h)
while H[0] == 0:
    X.append(X[0])
    Y.append(Y[0])
    H.append(H[0])
    X = X[1:]
    Y = Y[1:]
    H = H[1:]
x1 = X[0]
y1 = Y[0]
h1 = H[0]
for Cx in range(101):
    for Cy in range(101):
        h = h1 + abs(x1-Cx) + abs(y1-Cy)
        i = 1
        while i < N and H[i] == max(h - abs(X[i]-Cx) - abs(Y[i]-Cy), 0):
            i += 1
        if i == N:
            print(Cx, Cy, h)
            sys.exit()
Buggy python submission (verdict: Runtime Error):
import math
N, X = map(int, input().split())
L = list(map(int, input().split()))
M = [abs(i-X) for i in L if i-X != 0]
n = len(M)
old = M[0]
if n > 1:
    for i in range(n-1):
        new = M[i+1]
        old = math.gcd(old, new)
print(old)

Fixed submission:
N, X = map(int, input().split())
L = list(map(int, input().split()))
M = [abs(i-X) for i in L if i-X != 0]
n = len(M)
old = M[0]
def gcd(a, b):
    if min(a, b) == 0:
        return max(a, b)
    else:
        m = max(a, b)
        n = min(a, b)
        return gcd(n, m%n)
if n > 1:
    for i in range(n-1):
        new = M[i+1]
        old = gcd(old, new)
print(old)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
X = list(map(int, input().split()))

minp = 0
while X[minp] < 0:
    minp += 1
lidx = 0
if minp > K:
    lidx = minp - K
ridx = lidx + K - 1
left = X[lidx]
right = X[ridx]
mind = right - left + min(abs(left), abs(right))

while ridx < N and left <= minp:
    left = X[lidx]
    right = X[ridx]
    mind = min(mind, right - left + min(abs(left), abs(right)))
    lidx += 1
    ridx += 1

print(mind)

Fixed submission:
N, K = map(int, input().split())
X = list(map(int, input().split()))

minp = 0
if X[N-1] <0:
    minp = N-1
else:
    while X[minp] < 0:
        minp += 1

lidx = 0
if minp > K:
    lidx = minp - K
ridx = lidx + K - 1
left = X[lidx]
right = X[ridx]
mind = right - left + min(abs(left), abs(right))

while ridx < N and left <= minp:
    left = X[lidx]
    right = X[ridx]
    mind = min(mind, right - left + min(abs(left), abs(right)))
    lidx += 1
    ridx += 1

print(mind)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
m = N
for i in range(N):
    S1 = S[0:i]
    S2 = S[i+1:]
    n1 = list.count(S1, 'W')
    n2 = list.count(S2, 'E')
    m = min(m, n1+n2)

print(m)

Fixed submission:
N = int(input())
S = list(input())
S1 = []
S2 = S[1:]
n1 = 0
n2 = list.count(S2, 'E')
m = n1 + n2
for i in range(N-1):
    elem1 = S[i]
    elem2 = S[i+1]
    if elem1 == 'W':
        n1 = n1+1
    if elem2 == 'E':
        n2 = n2-1
    m = min(m, n1 + n2)

print(m)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

stayed = [0] * (n+1)

A = list(map(int, input().split()))
start = 0
stayed[0] = 1
roops = 0
ANS = []
for i in range(n+1):
    if stayed[A[start] - 1] == 0:
        stayed[A[start] - 1] = 1
        start = A[start] - 1
        ANS.append(start)
        roops += 1
    else:
        break
index_ = ANS.index(start - 1)
before_roop = index_ + 1
if index_ == 0:
    before_roop = 0
true_roop = len(ANS) - index_

if true_roop + before_roop >= k:
    ANS = [0] + ANS + [start -1]
    print(ANS[k] + 1)
else:
    k = k - before_roop
    k = k % true_roop
    ANS = ANS[index_:]
    print(ANS[k] + 1)

Fixed submission:
n, k = map(int, input().split())

A = list(map(int, input().split()))

check = [0] * n

start = 0
path = []
for i in range(n):
    if check[start] == 0:
        check[start] = 1
        path.append(start)
        start = A[start] - 1
path.append(start)

before_roop = path[:path.index(path[-1])]
B = before_roop
if before_roop == []:
    before_roop = 0
else:
    before_roop = len(before_roop)

roop = len(path) - before_roop - 1

if k <= before_roop:
    print(path[:before_roop+1][k] + 1)
else:
    k -= before_roop
    k = k % roop
    print(path[before_roop+1:][k-1] + 1)
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

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

Fixed submission:
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

n = int(input())
t = 0
for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            t += gcd(i, j, k)
print(t)
Buggy python submission (verdict: Time Limit Exceeded):
def dijkstra(s,n,w,cost, pre):
    #始点sから各頂点への最短距離
    #n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
    d = [float("inf")] * n
    for i in range(len(pre)):
        d[i] = pre[i]
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        #まだ使われてない頂点の中から最小の距離のものを探す
        for i in range(n):
            if (not used[i]) and (v == -1):
               v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        used[v] = True
               
        for j in range(len(pre), n):
               d[j] = min(d[j],d[v]+cost[v][j])
    return d

n, a, b = map(int, input().split())

cost = [[float("inf") for i in range(n)] for i in range(n)] 

for i in range(n-1):
    # x,y,z = map(int,input().split())
    # cost[x][y] = z
    # cost[y][x] = z
    cost[i][i+1] = 1
    cost[i+1][i] = 1
cost[a-1][b-1] = 1
cost[b-1][a-1] = 1


ANS = []
for i in range(n):
    pre = []
    for j in range(i):
        pre.append(ANS[j][i])

    ANS.append(dijkstra(i, n, n, cost, pre))
# print(ANS)
from functools import reduce
A = reduce(lambda x,y: x+y,ANS)

import collections

c = collections.Counter(A)

for i in range(1, n):
    print(c[i]//2)


Fixed submission:
a, b, c = map(int, input().split())

b = b - 1
c = c - 1
A = []

for i in range(a):
    for j in range(i+1, a):
        A.append(min(abs(i - b) + 1 + abs(j - c), abs(j - i)))
import collections
C = collections.Counter(A)

for i in range(1, a):
    print(C[i])

Buggy python submission (verdict: Time Limit Exceeded):
def dijkstra(s,n,w,cost):
    #始点sから各頂点への最短距離
    #n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        #まだ使われてない頂点の中から最小の距離のものを探す
        for i in range(n):
            if (not used[i]) and (v == -1):
               v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        used[v] = True
               
        for j in range(n):
               d[j] = min(d[j],d[v]+cost[v][j])
    return d

n, a, b = map(int, input().split())

cost = [[float("inf") for i in range(n)] for i in range(n)] 

for i in range(n-1):
    # x,y,z = map(int,input().split())
    # cost[x][y] = z
    # cost[y][x] = z
    cost[i][i+1] = 1
    cost[i+1][i] = 1
cost[a-1][b-1] = 1
cost[b-1][a-1] = 1


ANS = []
for i in range(n):
    ANS.extend(dijkstra(i, n, n, cost))

import collections

c = collections.Counter(ANS)

for i in range(1, n):
    print(c[i]//2)

Fixed submission:
a, b, c = map(int, input().split())

b = b - 1
c = c - 1
A = []

for i in range(a):
    for j in range(i+1, a):
        A.append(min(abs(i - b) + 1 + abs(j - c), abs(j - i)))
import collections
C = collections.Counter(A)

for i in range(1, a):
    print(C[i])
Buggy python submission (verdict: Runtime Error):
s = list(input())

out = 0

for i in range(0, len(s), 2):
    if s[i] == 'h' and s[i+1] == 'i':
        continue
    else:
        out = 1

if out:
    print("No")
else:
    print("Yes")

Fixed submission:
s = list(input())

out = 0

if len(s) % 2 != 0:
    print("No")
else:
    for i in range(0, len(s), 2):
        if s[i] == 'h' and s[i+1] == 'i':
            continue
        else:
            out = 1

    if out:
        print("No")
    else:
        print("Yes")
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
m = 0
for i in range(1, min(a, b)):
    if a%i==0 and b%i==0:
        m = i
print(int(a*b/m))

Fixed submission:
a, b = map(int, input().split())
m = 0
for i in range(1, min(a, b)+1):
    if a%i==0 and b%i==0:
        m = i
print(int(a*b/m))
Buggy python submission (verdict: Time Limit Exceeded):
x = int(input())


y = x // 100
z = x % 100
t = 0
for i in range(101):
    if t == 1 or i>y:
        break
    for j in range(101):
        if t == 1 or i+j > y:
            break
        for k in range(101):
            if t == 1 or i+j+k > y:
                break
            for l in range(101):
                if t == 1 or i+j+k+l > y:
                    break
                for m in range(101):
                    if t == 1 or i+j+k+l+m > y:
                        break
                    for n in range(101):
                        if t == 1 or i+j+k+l+m+n > y:
                            break
                        if (i+j+k+l+m+n == y):
                            if i*0+j*1+k*2+l*3+m*4+n*5 == z:
                                t = 1
                                break
                        if (i+j+k+l+m+n > y):
                            break
if t == 1:
    print(1)
else:
    print(0)

Fixed submission:
x = int(input())

x_ = x%100

t = 0
a = 5
while x_ != 0:
    t += x_//a
    x_ -= (x_//a)*a
    a -= 1


if x//100 >= t:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
s = input()
S = []
for i in s:
    S.append(i)
import itertools
A = []
for v in itertools.combinations(S, 3):
    a = int("".join(v))
    A.append(a)
print(len(set(A)))

Fixed submission:
n = int(input())

s = input()

A = []
for i in range(10):
    A.append([])
for i in range(n):
    A[int(s[i])].append(i)

total = 0
for i in range(1000):
    a = "{0:03d}".format(i)
    B = []
    for j in a:
        B.append(int(j))
    c = -1
    check = 0
    for j in B:
        check = 0
        if len(A[j]) > 0:
            for k in A[j]:
                if k > c:
                    c = k
                    check = 1
                    break
        else:
            break
        if check == 0:
            break
    if check == 1:
        total += 1
print(total)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))

B = ""
for i in range(1,n+1):
    B += str(A.index(i)+1)+" "
print(B[:-1])

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
B = [0] * n
for i in range(n):
    B[A[i] - 1] = str(i + 1)
print(" ".join(B))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
A = list(map(int, input().split()))

A = sorted(A)
for i in range(m):
    a = A[-1]//2
    A = A[:-1]
    A.append(a)
    A = sorted(A)
print(sum(A))

Fixed submission:
n, m = map(int, input().split())

A = list(map(int, input().split()))

import heapq

A = list(map(lambda x: x*(-1), A))

heapq.heapify(A)

for i in range(m):
    val = heapq.heappop(A)
    val = (-1 * val)//2 * (-1)
    heapq.heappush(A, val)

print(sum(list(map(lambda x: x*(-1), A))))
Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))[::-1]
B = []
t = 0
before = A[0] - 1
max_t = 0
for i in A:
    if before <= i:
        t += 1
        before = i
    else:
        B.append(t)
        t = 1
        before = i

print(max(B)-1)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))[::-1]
B = []
t = 0
before = A[0] - 1
max_t = 0
for i in A:
    if before <= i:
        t += 1
        before = i
    else:
        B.append(t)
        t = 1
        before = i
B.append(t)
if n == 1:
    print(0)
else:
    print(max(B)-1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
import itertools
A = []
t = 0
for i in range(n):
    A.append(sorted(list(input())))
for i in list(itertools.combinations(A,2)):
    a, b = i
    if a == b:
        t += 1
print(t)

Fixed submission:
n = int(input())
import itertools
A = []
t = 0
for i in range(n):
    A.append("".join(sorted(list(input()))))


import collections

C = collections.Counter(A)


for i in C.values():
    t += i * (i - 1) // 2
print(t)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

A = []
B = []
for i in range(n):
    s  = "".join(list(sorted(list(input())))) 
    if s not in A:
        A.append(s)
        B.append(1)
    else:
        B[A.index(s)] += 1
c = 0
for i in B:
    if i >= 2:
        c += int(i * (i - 1)/2)
print(c)

Fixed submission:
n = int(input())
import itertools
A = []
t = 0
for i in range(n):
    A.append("".join(sorted(list(input()))))


import collections

C = collections.Counter(A)


for i in C.values():
    t += i * (i - 1) // 2
print(t)