Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
# -*- coding : utf-8 -*-

A = list(input())
B = list(input())
C = list(input())

X = [A,B,C]

x = 0
while True :
  if X[x][0] == "a":
    if X[0] == []:
      print("A")
      break
    else:
      X[0].remove(X[0][0])
      x = 0
  elif X[x][0] == "b":
    if X[1] == []:
      print("B")
      break
    else:
      X[1].remove(X[1][0])
      x = 1
  elif X[x][0] == "c":
    if X[2] == []:
      print("C")
      break
    else:
      X[2].remove(X[2][0])
      x = 2

Fixed submission:
# -*- coding : utf-8 -*-

A = list(input())
B = list(input())
C = list(input())
X = [A,B,C]
t = 0

while True:
  if X[t] == []:
    if t == 0:
      print("A")
      break
    elif t == 1 :
      print("B")
      break
    elif t == 2:
      print("C")
      break
  else:
    if X[t][0] == "a":
      X[t].remove(X[t][0])
      t = 0
    elif X[t][0] == "b":
      X[t].remove(X[t][0])
      t = 1
    elif X[t][0] == "c":
      X[t].remove(X[t][0])
      t = 2

Buggy python submission (verdict: Runtime Error):
# -*- coding : utf-8 -*-

A = list(input())
B = list(input())
C = list(input())

X = [A,B,C]

x = 0
while True :
  if X[x][0] == "a":
    if X[0] == []:
      print("A")
      break
    else:
      X[0].remove(X[0][0])
      x == 0
    
  elif X[x][0] == "b":
    if X[1] == []:
      print("B")
      break
    else:
      X[1].remove(X[1][0])
      x == 1
    
  elif X[x][0] == "c":
    if X[2] == []:
      print("C")
      break
    else:
      X[2].remove(X[2][0])
      x == 2
    

Fixed submission:
# -*- coding : utf-8 -*-

A = list(input())
B = list(input())
C = list(input())
X = [A,B,C]
t = 0

while True:
  if X[t] == []:
    if t == 0:
      print("A")
      break
    elif t == 1 :
      print("B")
      break
    elif t == 2:
      print("C")
      break
  else:
    if X[t][0] == "a":
      X[t].remove(X[t][0])
      t = 0
    elif X[t][0] == "b":
      X[t].remove(X[t][0])
      t = 1
    elif X[t][0] == "c":
      X[t].remove(X[t][0])
      t = 2
Buggy python submission (verdict: Runtime Error):
# -*- coding : utf-8 -*-

S = str(input())

w = ""
for i in range(len(S)):
  if S[i] = "B":
    if w == "":
      w = ""
    else :
      w = w.rstrip()
  else:
    w + S[i]

print(w)


Fixed submission:
# -*- coding : utf-8 -*-

S = str(input())

w = ""

for i in range(len(S)) :
  if S[i] == "B" :
    if w == "":
      w = ""
    else :
      w = w[:-1]
  else :
    w = w + S[i]
    
print(w)

Buggy python submission (verdict: Runtime Error):
# -*- coding : utf-8 -*-

S = str(input())

w = ""
for i in range(len(S)):
  if S[i] = "B":
    if w != "":
      w = ""
    else :
      w = w.rstrip()
  else:
    w + S[i]

print(w)


Fixed submission:
# -*- coding : utf-8 -*-

S = str(input())

w = ""

for i in range(len(S)) :
  if S[i] == "B" :
    if w == "":
      w = ""
    else :
      w = w[:-1]
  else :
    w = w + S[i]
    
print(w)

Buggy python submission (verdict: Runtime Error):
# -*- coding : utf-8 -*-

S = str(input())

w = ""
for i in range(len(S)):
  if S[i] = "B":
    if w == "":
      w = ""
    else :
      w.remove(w[-1])
  else:
    w + S[i]

print(w)


Fixed submission:
# -*- coding : utf-8 -*-

S = str(input())

w = ""

for i in range(len(S)) :
  if S[i] == "B" :
    if w == "":
      w = ""
    else :
      w = w[:-1]
  else :
    w = w + S[i]
    
print(w)

Buggy python submission (verdict: Runtime Error):
# -*- coding : utf-8 -*-

S = str(input())

w = ""
for i in range(len(S)):
  if S[i] = "B":
    if w != "":
      w = ""
    else :
      w.remove(w[-1])
  else:
    w + S[i]

print(w)

Fixed submission:
# -*- coding : utf-8 -*-

S = str(input())

w = ""

for i in range(len(S)) :
  if S[i] == "B" :
    if w == "":
      w = ""
    else :
      w = w[:-1]
  else :
    w = w + S[i]
    
print(w)
Buggy python submission (verdict: Runtime Error):
# -*- coding : utf-8 -*-

n,l = map(int, input().split())

L = list([input() for i in range(n)])
L.sort()
word = ""

for i in len(L):
  word = word + L[i]

print(word)


Fixed submission:
# -*- coding : utf-8 -*-

n,l = map(int, input().split())

L = list([input() for i in range(n)])
L.sort()
word = ""

for i in range(len(L)):
  word = word + L[i]

print(word)

Buggy python submission (verdict: Runtime Error):
# -*- coding : utf-8 -*-

n,l = map(int, input().split())

L = list(map(int, [input() for i in range(n)]))
L.sort()
word = ""

for i in len(L):
  word = word + L[i]

print(word)


Fixed submission:
# -*- coding : utf-8 -*-

n,l = map(int, input().split())

L = list([input() for i in range(n)])
L.sort()
word = ""

for i in range(len(L)):
  word = word + L[i]

print(word)

Buggy python submission (verdict: Runtime Error):
# -*- coding : utf-8 -*-

n,l = map(int, input().split())

L = map(int, [input() for i in range(n)])
L.sort()
word = ""

for i in len(L):
  word = word + L[i]

print(word)


Fixed submission:
# -*- coding : utf-8 -*-

n,l = map(int, input().split())

L = list([input() for i in range(n)])
L.sort()
word = ""

for i in range(len(L)):
  word = word + L[i]

print(word)

Buggy python submission (verdict: Runtime Error):
# -*- coding : utf-8 -*-

n,l = map(int, input().split())

L = map(int, [input() for i in range(n)])

word = ""
for i in len(L):
  L.sort()
  word = word + L[0]
  L = L.remove(L[0])

print(word)

Fixed submission:
# -*- coding : utf-8 -*-

n,l = map(int, input().split())

L = list([input() for i in range(n)])
L.sort()
word = ""

for i in range(len(L)):
  word = word + L[i]

print(word)
Buggy python submission (verdict: Runtime Error):
s = str(input())

nw = []
i = 0

for i in range(0,len(s),1):
  if s[i] == '?' and s[i-1] == 'P':
    nw.append('D')
  elif s[i] == '?' and s[i-1] == 'D':
    nw.append('D')
  elif s[i] == '?' and s[i-1] == '?':
    if nw[-1] == 'P':
      nw.append('D')
    elif nw[-1] == 'D':
      nw.append('D')
    
  else:
    nw.append(s[i])

print(''.join(nw))

Fixed submission:
s = str(input())

nw1 = s.replace("?","D")

print(nw1)
Buggy python submission (verdict: Runtime Error):
A,B,H,M = list(map(int,input().split()))

import math
#得られる三角形の中心の角度を求める

H_rad = 2*math.pi()/12*H
M_rad = 2*math.pi()/60*M
rad = abs(H_rad - M_rad)

#二項定理
C = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(rad))
print(C)

Fixed submission:
A,B,H,M = list(map(int,input().split()))

import math
#得られる三角形の中心の角度を求める
M_rad = (2*math.pi/60)*M
H_rad = (2*math.pi/12)*(H + 1/60*M)
rad = abs(H_rad - M_rad)

#三角形が成立する条件
#長針と短針が被ったとき
if math.degrees(M_rad)-0.1 < math.degrees(H_rad) < math.degrees(M_rad)+0.1:
  print(abs(A-B))
  exit()
#長針と短針が180度の時
elif 180-0.1 < math.degrees(rad) < 180+0.1:
  print(abs(A+B))
  exit()
else:
  #二項定理
  C = math.sqrt(abs(A*A + B*B - 2*A*B*math.cos(rad)))
  print(abs(C))
Buggy python submission (verdict: Time Limit Exceeded):
n = input()
a = list(map(int,input().split()))
sum = 1
for i in a:
    sum*=i

if sum > 10**18:
    print(-1)
else:
    print(sum)

Fixed submission:
n = input()
a = list(map(int,input().split()))
pro = 1
if 0 in a:
    print(0)
else:
    for i in a:
        pro*=i
        if pro > 10**18:
            pro = -1
            break
    print(pro)
Buggy python submission (verdict: Runtime Error):
# input
A = input()
B = input()
C = input()
K = input()

# parse int
A = int(A)
B = int(B)
C = int(C)
K = int(K)

# result var
max_sum = 0

# check 1
max_sum = min(A, K)
K = K - max_sum

# check 0
if K > 0:
  K = K - min(B, K)

# check - 1
if K > 0:
  max_sum = max_sum - min(K, B)
# print result
print(max_sum)

Fixed submission:
import sys
readmi = lambda: map(int, sys.stdin.readline().split())

A, B, C, K = readmi()
# result var
max_sum = 0

# check 1
max_sum = min(A, K)
K = K - max_sum

# check 0
if K > 0:
  K = K - min(B, K)

# check - 1
if K > 0:
  max_sum = max_sum - min(K, C)
# print result
print(max_sum)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
if N % K == :
  print(0)
else:
  print(1)

Fixed submission:
N, K = map(int, input().split())
if N % K == 0:
  print(0)
else:
  print(1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
result = 1
for number in a:
    result *= number
if result > 10 ** 18:
    print(-1)
else:
    print(result)


Fixed submission:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    result = 1
    if 0 in a:
        print(0)
        return
    for number in a:
        result *= number
        if result > 10 ** 18:
            print(-1)
            return
    print(result)

main()
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
from math import log10
s = input()
tmp = []
num = [0]
for char in s:
    tmp.append(char)
    num.append(int("".join(tmp)))

c = 0
for m, n in combinations(num, 2):
    if m == 0:
        check = n
    else:
        check = n - m * 10 ** (-int(-log10(n)) - -int(-log10(m)))
    if check % 2019 == 0:
        c += 1

print(c)


Fixed submission:
from itertools import combinations
s = input()
d = {0: 1}
tmp = 0
i = 0
for char in s[::-1]:
    tmp += int(char) * pow(10, i, 2019)
    tmp %= 2019
    if tmp not in d:
        d[tmp] = 1
    else:
        d[tmp] += 1
    i += 1

result = 0
for num, v in d.items():
    result += v * (v - 1) // 2

print(result)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations
s = input()
tmp = []
num = ["0"]
for char in s:
    tmp.append(char)
    num.append("".join(tmp))

c = 0
for m, n in combinations(num, 2):
    if m == "0":
        check = int(n)
    else:
        check = int(n) - int(m) * 10 ** (len(n) - len(m))
    if check % 2019 == 0:
        c += 1

print(c)


Fixed submission:
from itertools import combinations
s = input()
d = {0: 1}
tmp = 0
i = 0
for char in s[::-1]:
    tmp += int(char) * pow(10, i, 2019)
    tmp %= 2019
    if tmp not in d:
        d[tmp] = 1
    else:
        d[tmp] += 1
    i += 1

result = 0
for num, v in d.items():
    result += v * (v - 1) // 2

print(result)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
from math import gcd

k = int(input())

result = 0
for a, b, c in product(range(1, k+1), repeat=3):
    result += gcd(a, gcd(b, c))

print(result)


Fixed submission:
from itertools import product
from math import gcd

k = int(input())

result = 0
for a, b, c in product(range(1, k+1), repeat=3):
    result += gcd(a, gcd(b, c))

print(result)
Buggy python submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
ps = list(map(int, input().split()))
qs = list(map(int, input().split()))
rs = list(map(int, input().split()))
ps.sort()
ps = ps[-x:]
qs.sort()
qs = qs[-y:]
pqs = ps + qs
pqs.sort()
rs.sort(reverse=True)

answer = sum(pqs)
for i in range(c):
    diff = rs[i] - pqs[i]
    if diff < 0:
        break
    answer += diff

print(answer)


Fixed submission:
x, y, a, b, c = map(int, input().split())
ps = list(map(int, input().split()))
qs = list(map(int, input().split()))
rs = list(map(int, input().split()))
ps.sort()
ps = ps[-x:]
qs.sort()
qs = qs[-y:]
pqs = ps + qs
pqs.sort()
rs.sort(reverse=True)

answer = sum(pqs)
for i in range(min(x+y, c)):
    diff = rs[i] - pqs[i]
    if diff < 0:
        break
    answer += diff

print(answer)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))


counter = {}
for number in A:
    if number not in counter:
        counter[number] = 1
    else:
        counter[number] += 1

answer = [0] * N

for i, number in enumerate(A):
    tmp = 0
    for k, c in counter.items():
        if k == number:
            c -= 1
        tmp += c * (c-1) // 2
    answer[i] = str(tmp)

print('\n'.join(answer))


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


counter = {}
for number in A:
    if number not in counter:
        counter[number] = 1
    else:
        counter[number] += 1

tmp = 0
for c in counter.values():
    tmp += c * (c-1) // 2

answer = [0] * N

for i, number in enumerate(A):
    v = counter[number]
    answer[i] = str(tmp - v * (v-1) // 2 + (v-1) * (v-2) // 2)

print('\n'.join(answer))
Buggy python submission (verdict: Runtime Error):
def main():
    MOD = 10 ** 9 + 7
    l = [int(char) for char in input()]
    n = len(l)
    cumsum = []
    tmp = 0
    for number in l:
        if number == 1:
            tmp += 1
        cumsum.append(tmp)
    sel = [pow(2, number, MOD) for number in cumsum]
    sel.append(1)

    def dp(i, _cache={-1: 0}):
        if i in _cache:
            return _cache[i]
        if l[i] == 0:
            result = dp(i-1)
            _cache[i] = result
            return result
        result = dp(i-1) + sel[i-1] * pow(3, n - 1 - i, MOD)
        result %= MOD
        _cache[i] = result
        return result
    
    answer = dp(n-1) + sel[n-1]
    print(answer)


main()


Fixed submission:
from sys import setrecursionlimit

setrecursionlimit(10 ** 8)

def main():
    MOD = 10 ** 9 + 7
    l = [int(char) for char in input()]

    n = len(l)

    cumsum = []
    tmp = 0
    for number in l:
        if number == 1:
            tmp += 1
        cumsum.append(tmp)
    sel = [pow(2, number, MOD) for number in cumsum]
    sel.append(1)

    def dp(i, _cache={-1: 0}):
        if i in _cache:
            return _cache[i]
        if l[i] == 0:
            result = dp(i-1)
            _cache[i] = result
            return result
        result = dp(i-1) + sel[i-1] * pow(3, n - 1 - i, MOD)
        result %= MOD
        _cache[i] = result
        return result
    
    answer = dp(n-1) + sel[n-1]
    answer %= MOD
    print(answer)


main()
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())

wvs = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W+1) for _ in range(N+1)]

for i, (w, v) in enumerate(wvs):
    i += 1
    for j in range(W+1):
        if j < w:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j - w] + v, dp[i-1][j])

print(dp[N][W])


Fixed submission:
N, W = map(int, input().split())

wvs = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W+1) for _ in range(N+1)]

for i, (w, v) in enumerate(wvs):
    i += 1
    for j in range(W+1):
        if j < w:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j - w] + v, dp[i-1][j])

print(dp[N][W])

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, W = map(int, input().split())
    wv = [list(map(int, input().split())) for _ in range(N)]
    wl, vl = zip(*wv)

    srs = {
        (w, -1): 0 for w in range(W+1)
    }

    def dp(w, i):
        if w - wl[i] < 0:
            return srs[(w, i-1)]
        return max(
            srs[(w - wl[i], i-1)] + vl[i],
            srs[(w, i-1)]
        )
    
    for w in range(W+1):
        for i in range(N):
            srs[(w, i)] = dp(w, i)
    
    print(srs[W, N-1])


main()


Fixed submission:
N, W = map(int, input().split())

wvs = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W+1) for _ in range(N+1)]

for i, (w, v) in enumerate(wvs):
    i += 1
    for j in range(W+1):
        if j < w:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j - w] + v, dp[i-1][j])

print(dp[N][W])

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N, W = map(int, input().split())
    wv = [list(map(int, input().split())) for _ in range(N)]
    wl, vl = zip(*wv)

    srs = {
        (w, -1): 0 for w in range(W+1)
    }

    def dp(w, i):
        if w - wl[i] < 0:
            return srs[(w, i-1)]
        return max(
            srs[(w - wl[i], i-1)] + vl[i],
            srs[(w, i-1)]
        )
    
    for w in range(W+1):
        for i in range(N):
            srs[(w, i)] = dp(w, i)
    
    print(srs[W, N-1])


main()


Fixed submission:
N, W = map(int, input().split())

wvs = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W+1) for _ in range(N+1)]

for i, (w, v) in enumerate(wvs):
    i += 1
    for j in range(W+1):
        if j < w:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j - w] + v, dp[i-1][j])

print(dp[N][W])
Buggy python submission (verdict: Runtime Error):
import sys
print(sys.split().index("0") + 1)

Fixed submission:
print(input().split().index("0") + 1)

Buggy python submission (verdict: Runtime Error):
import sys
print( sys.stdin.split().indx("0"))

Fixed submission:
print(input().split().index("0") + 1)

Buggy python submission (verdict: Runtime Error):
print( sys.stdin.split().indx("0"))


Fixed submission:
print(input().split().index("0") + 1)
Buggy python submission (verdict: Runtime Error):
import math

nm = list(map(int,input().split(" ")))
N = nm[0]
M = nm[1]

A = list(map(int,input().split(" ")))
A.sort(reverse=True)
hmax = math.floor(A[0]/2)
index = 0
while M > 0:
    if index != len(A):
        if A[index] >= hmax:
            A[index] = math.floor(A[index]/2)
            M = M -1
            index = index + 1
        else:
            index = 0
            A.sort(reverse=True)
            hmax = math.floor(A[0])
    else:
        index = 0
    if hmax == 0:
        break
print(sum(A))

Fixed submission:
S = input()

if S == "Sunny":
    print("Cloudy")
elif S == "Cloudy":
    print("Rainy")
else:
    print("Sunny")
Buggy python submission (verdict: Runtime Error):
N = int(input())
B = list(map(int, input().split(" ")))

sum = 0

for ib, value in enumerate(B):
    if ib > 0:
        if value >= B[ib-1]:
            sum += B[ib-1]
        else:
            sum += value
    else:
        sum += value

sum += B[len(B) - 1]
print(sum)


Fixed submission:
t = int(input())
print(t**3)

Buggy python submission (verdict: Runtime Error):
N = int(input())
B = list(map(int, input().split(" ")))

sum = 0

for ib, value in enumerate(B):
    if ib > 0:
        if value >= B[ib-1]:
            sum += B[ib-1]
        else:
            sum += value
    else:
        sum += value

sum += B[len(B) - 1]
print(sum)


Fixed submission:
t = int(input())
print(t**3)
Buggy python submission (verdict: Runtime Error):
import sys
# from collections import deque
# from collections import Counter
# from math import sqrt
# from math import log
# from math import ceil

# def gcd(a, b):
# 	if(a==0):
# 		return b 
# 	return gcd(b%a,a)

# def sieve(n): 
# 	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
# 	prime[0]=False
# 	prime[1]=False
# 	s=set()
# 	for i in range(len(prime)):
# 		if(prime[i]):
# 		s.add(i)
# 	return s 

# alpha=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
# mod=10**9+7

fast_reader=sys.stdin.readline
fast_writer=sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i)) for i in argv))
	fast_writer('\n')

def list_input():
	return list(map(int, input().split()))

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

#_______________________________________________________________________________________________________________________________________

x,n=sep_input()
l=list_input()
s=set(l)
i=0
while(True):
	if(x-i not in s):
		print(x-i)
		break
	elif(x+i not in s):
		print(x+i)
		break
	else:
		i+=1

Fixed submission:
import sys
# from collections import deque
# from collections import Counter
# from math import sqrt
# from math import log
# from math import ceil

# def gcd(a, b):
# 	if(a==0):
# 		return b 
# 	return gcd(b%a,a)

# def sieve(n): 
# 	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
# 	prime[0]=False
# 	prime[1]=False
# 	s=set()
# 	for i in range(len(prime)):
# 		if(prime[i]):
# 		s.add(i)
# 	return s 

# alpha=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
# mod=10**9+7

fast_reader=sys.stdin.readline
fast_writer=sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i)) for i in argv))
	fast_writer('\n')

def list_input():
	return list(map(int, input().split()))

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

#_______________________________________________________________________________________________________________________________________

l=list_input()
print(15-sum(l))

Buggy python submission (verdict: Runtime Error):
N = int(input())
leng = 10**6+1
memo = [0]*leng
li = []
for n in map(int, input().split()):
    x = 0
    li.append(n)
    while x < leng:
        memo[x] +=1
        x += n
count = 0
for n in li:
    if memo[n] == 1:
        count+=1
print(count)

Fixed submission:
li = [i for i in map(int, input().split())]

print(li.index(0)+1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
leng = 10**6+1
memo = [0]*leng
li = []
for n in map(int, input().split()):
    x = 0
    li.append(n)
    while x < leng:
        memo[x] +=1
        x += n
count = 0
for n in li:
    if memo[n] == 1:
        count+=1
print(count)

Fixed submission:
N = int(input())
leng = 10**6+1
memo = [0]*leng
li = []
for n in map(int, input().split()):
    x = 0
    li.append(n)
    if memo[n] >1:
        pass
    else:
        while x < leng:
            memo[x] +=1
            x += n
count = 0
for n in li:
    if memo[n] == 1:
        count+=1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
leng = 10**6+1
memo = [0]*leng
li = []
for n in map(int, input().split()):
    x = 0
    li.append(n)
    while x < leng:
        memo[x] +=1
        x += n
count = 0
for n in li:
    if memo[n] == 1:
        count+=1
print(count)

Fixed submission:
N = int(input())
leng = 10**6+1
memo = [0]*leng
li = []
for n in map(int, input().split()):
    x = 0
    li.append(n)
    if memo[n] >1:
        pass
    else:
        while x < leng:
            memo[x] +=1
            x += n
count = 0
for n in li:
    if memo[n] == 1:
        count+=1
print(count)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
dic = {}
def make_map(a, b, dic):
    if a in dic.keys():
        dic[a].append(b)
    else:
        dic[a] = [b]
for m in range(M):
    a, b = map(int, input().split())
    make_map(a-1, b-1, dic)
    make_map(b-1, a-1, dic)
maplist = [0]*(N)
minlist = [10**5]*N
logs = []
def dfs(point, depth, log):
    if str(point) in log:
        logs.append(log)
        return
    if minlist[point] >= depth:
        minlist[point] = depth
        if len(log) >= 1:
            maplist[point] = int(log[-1])+1
    log+=str(point)
    depth+=1
    for p in dic[point]:
        dfs(p,depth,  log)
dfs(0,0, "")
if 0 in maplist[1:]:
    print("No")
else:
    print("Yes")
    for i in range(N-1):
        print(maplist[i+1])

Fixed submission:
from collections import deque
dic = {}
def make_map(a, b, dic):
    if a in dic.keys():
        dic[a].append(b)
    else:
        dic[a] = [b]
N, M = map(int, input().split())
for m in range(M):
    a, b = map(int, input().split())
    make_map(a-1, b-1, dic)
    make_map(b-1, a-1, dic)
queue = deque([0])
count = 0
dekai = 10**5
lenlist = [dekai]*N
lenlist[0] = 0
while queue:
    a = queue.popleft()
    for i in dic[a]:
        if lenlist[i] ==dekai or a == 0:
            queue.append(i)#今までいったことないなら見るリストに追加
            lenlist[i] = a #今いる座標の距離+!が次の座標の距離
print("Yes")
for n in range(1,N, 1):
    print(lenlist[n]+1)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
passlist = [0]*N
point = 1
depth = 0
waylist = []
while passlist[point-1] == 0:
    passlist[point-1] = 1
    point = A[point-1]
    waylist.append(point)
    depth+=1
print(waylist[depth-K%depth])

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
passlist = [0]*N
point = 1
depth = 0
waylist = []
while passlist[point-1] == 0:
    waylist.append(point)
    passlist[point-1] = depth
    point = A[point-1]
    depth+=1
roop = waylist[waylist.index(point):len(waylist)]
firstreach = passlist[roop[0]-1]
if K < firstreach:
  print(passlist.index(K)+1)
else:
  print(roop[(K-firstreach)%len(roop)])