Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N = int(input())
M = int(N**0.5)
l = []
if N <= 3:
  print(1)
else:
  for a in range(1, M+1):
    if N % a == 0:
      b = int(N/a)
    else:
      continue
    l.append(max(len(str(a)), len(str(b))))
print(min(l))

Fixed submission:
N = int(input())
M = int(N**0.5)
l = []
if N <= 3:
  print(1)
else:
  for a in range(1, M+1):
    if N % a == 0:
      b = int(N/a)
    else:
      continue
    l.append(max(len(str(a)), len(str(b))))
  print(min(l))

Buggy python submission (verdict: Runtime Error):
N = int(input())
M = int(N**0.5)
l = []
for a in range(1, M):
  if N % a == 0:
  	b = int(N/a)
  else:
    continue
  l.append(max(len(str(a)), len(str(b))))
print(min(l))
  

Fixed submission:
N = int(input())
M = int(N**0.5)
l = []
if N <= 3:
  print(1)
else:
  for a in range(1, M+1):
    if N % a == 0:
      b = int(N/a)
    else:
      continue
    l.append(max(len(str(a)), len(str(b))))
  print(min(l))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
adj_matrix = [[0]*N for _ in range(N)]

for i in range(N):
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

def dfs(v, used):
    if not False in used:
        return 1

    ans = 0
    for i in range(N):
        if not adj_matrix[v][i]:
            continue
        if used[i]:
            continue
        used[i] = True
        ans += dfs(i, used)
        used[i] = False        
    return ans

used = [False] * N
used[0] = True
print(dfs(0, used))

Fixed submission:
import itertools

N, M = map(int, input().split())
adj_matrix = [[0]* N for _ in range(N)]

for i in range(M): #隣接行列
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

cnt = 0

for each in itertools.permutations(range(N)):
    if each[0] != 0:
        break
    factor = 1
    for i in range(N-1):
        factor *= adj_matrix[each[i]][each[i+1]]
    cnt += factor

print(cnt)

Buggy python submission (verdict: Runtime Error):
import itertools

N, M = map(int, input().split())
adj_matrix = [[0]*N for _ in range(N)]

# 隣接行列を作る
for i in range(N):
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

cnt = 0

for each in itertools.permutations(range(N)):
    if each[0] != 0:  # 始点は1でないといけないから
        break
    factor = 1
    for i in range(N-1):
        factor *= adj_matrix[each[i]][each[i+1]]
    cnt += factor

print(cnt)

Fixed submission:
import itertools

N, M = map(int, input().split())
adj_matrix = [[0]* N for _ in range(N)]

for i in range(M): #隣接行列
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

cnt = 0

for each in itertools.permutations(range(N)):
    if each[0] != 0:
        break
    factor = 1
    for i in range(N-1):
        factor *= adj_matrix[each[i]][each[i+1]]
    cnt += factor

print(cnt)

Buggy python submission (verdict: Runtime Error):
import itertools

N, M = map(int, input().split())
adj_matrix = [[0]*N for i in range(N)]

# 隣接行列を作る
for i in range(N):
  a, b = map(int, input().split())
  adj_matrix[a-1][b-1] = 1
  adj_matrix[b-1][a-1] = 1
  
cnt = 0

for each in itertools.permutations(range(N)):
  if each[0] != 0:  # 始点は1でないといけないから
    break
  factor = 1
  for i in range(N-1):
    factor *= adj_matrix[each[i]][each[i+1]]
  cnt += factor

print(cnt)

Fixed submission:
import itertools

N, M = map(int, input().split())
adj_matrix = [[0]* N for _ in range(N)]

for i in range(M): #隣接行列
    a, b = map(int, input().split())
    adj_matrix[a-1][b-1] = 1
    adj_matrix[b-1][a-1] = 1

cnt = 0

for each in itertools.permutations(range(N)):
    if each[0] != 0:
        break
    factor = 1
    for i in range(N-1):
        factor *= adj_matrix[each[i]][each[i+1]]
    cnt += factor

print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
I = list(map(int, input().split()))
K, S = I[0], I[1]

count = 0
for i in range(K+1):
  for j in range(K+1):
    for k in range(K+1):
      if i+j+k == S:
        count += 1
        
print(count)

Fixed submission:
I = list(map(int, input().split()))
K, S = I[0], I[1]

print(len([0 for i in range(K+1) for j in range(K+1) if 0<=S-i-j<=K]))
Buggy python submission (verdict: Runtime Error):
W, H, N = list(map(int, input().split()))
A = []
for _ in range(N):
  A.append(list(map(int, input().split())))
  
xmax, xmin, ymax, ymin = W, 0, H, 0
for a in A:
  if a[2] == 1:
    xmin = max(xmin, a[0])
  if a[2] == 2:
    xmax = min(xmax, a[0])
  if a[2] == 3:
    ymin = max(ymin, a[1])
  if a[2] == 4:
    ymax = min(ymax, a[1])D
    
S = (xmax-xmin) * (ymax-ymin)
if S < 0:
  S = 0
print(S)

Fixed submission:
W, H, N = list(map(int, input().split()))
A = []
for _ in range(N):
  A.append(list(map(int, input().split())))
  
xmax, xmin, ymax, ymin = W, 0, H, 0
for a in A:
  if a[2] == 1:
    xmin = max(xmin, a[0])
  if a[2] == 2:
    xmax = min(xmax, a[0])
  if a[2] == 3:
    ymin = max(ymin, a[1])
  if a[2] == 4:
    ymax = min(ymax, a[1])
    
S = (xmax-xmin) * (ymax-ymin)
if S < 0 or xmin > xmax or ymin > ymax:
  S = 0
print(S)
Buggy python submission (verdict: Runtime Error):
k=input().split(" ")[0]
a = list(map(lambda x: int(x), input().split("\n")[1].split(" ")))
df = max(a) - min(a)
print(min(df, k - df))

Fixed submission:
k=int(input().split(" ")[0])
a = sorted(map(lambda x: int(x), input().split("\n")[0].split(" ")))
dfs=[k-a[len(a)-1]+a[0]]
for i in range(len(a) - 1):
    dfs.append(a[i+1]-a[i])
print(sum(dfs)-max(dfs))
Buggy python submission (verdict: Runtime Error):
def canConstructHaiku(arr):
	arr.sort()
 	if arr[0] == 5 and arr[1] == 5 and arr[2] == 7:
    	return True
    return False

arr = list(map(int, input().split()))
print("YES" if canConstructHaiku(arr) else "NO")

Fixed submission:
def canConstructHaiku(arr):
  arr.sort()
  if arr[0] == 5 and arr[1] == 5 and arr[2] == 7:
    return True
  return False
 
arr = list(map(int, input().split()))
print("YES" if canConstructHaiku(arr) else "NO")
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
l=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
for i in range(1,n):
    s=min(k,i)+1
    ans=dp[i-1]+abs(l[i]-l[i-1])
    for j in range(2,s):
        ans=min(ans,dp[i-j]+abs(l[i]-l[i-j]))
    dp[i]=ans
print(dp[n-1])

Fixed submission:
n,k=map(int,input().split())
l=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
for i in range(1,n):
    s=min(k,i)+1
    ans=dp[i-1]+abs(l[i]-l[i-1])
    for j in range(2,s):
        ans=min(ans,dp[i-j]+abs(l[i]-l[i-j]))
    dp[i]=ans
print(dp[n-1])

Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
l=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
for i in range(1,n):
    s=min(k,i)+1
    ans=999999999
    for j in range(1,s):
        ans=min(ans,dp[i-j]+abs(l[i]-l[i-j]))
    dp[i]=ans
print(dp[n-1])

Fixed submission:
n,k=map(int,input().split())
l=list(map(int,input().split()))
dp=[0]*n
dp[0]=0
for i in range(1,n):
    s=min(k,i)+1
    ans=dp[i-1]+abs(l[i]-l[i-1])
    for j in range(2,s):
        ans=min(ans,dp[i-j]+abs(l[i]-l[i-j]))
    dp[i]=ans
print(dp[n-1])
Buggy python submission (verdict: Runtime Error):
def path(start):
    if dp[start]!=-1:
        return dp[start]
    visited[start]=1
    maxi=-1
    for i in adjacency_list[start]:
        maxi=max(maxi,path(i))
    dp[start]=maxi+1
    return dp[start]
N,M=map(int,input().split())
dp=[-1]*(N+1)
visited=[0]*(N+1)
adjacency_list=[]
for i in range(N+1):
    adjacency_list.append([])
# print(adjacency_list)
for r in range(M):
    u,v=map(int,input().split())
    adjacency_list[u].append(v)
# print(adjacency_list)
for i in range(1,N+1):
    if len(adjacency_list[i])==0:
        dp[i]=0
# print(dp)
for i in range(1,N+1):
    if (visited[i]==0):
        path(i)
print(max(dp))

Fixed submission:
import sys
sys.setrecursionlimit(10**9)
def path(start):
    if dp[start]!=-1:
        return dp[start]
    visited[start]=1
    maxi=-1
    for i in adjacency_list[start]:
        maxi=max(maxi,path(i))
    dp[start]=maxi+1
    return dp[start]
N,M=map(int,input().split())
dp=[-1]*(N+1)
visited=[0]*(N+1)
adjacency_list=[]
for i in range(N+1):
    adjacency_list.append([])
# print(adjacency_list)
for r in range(M):
    u,v=map(int,input().split())
    adjacency_list[u].append(v)
# print(adjacency_list)
for i in range(1,N+1):
    if len(adjacency_list[i])==0:
        dp[i]=0
# print(dp)
for i in range(1,N+1):
    if (visited[i]==0):
        path(i)
print(max(dp))
Buggy python submission (verdict: Runtime Error):
'''input

'''
import time
import math
l = [[0] for i in range(5)]
for i in range(4):
	a, b = map(int, input().strip().split())
	l[a].append(b)
	l[b].append(a)
for i in range(1, 5):
	if(len(l[i]) > 2):
		flag = 1
		break
print("YES" if flag else "NO")

Fixed submission:
'''input
4 2
1 3
2 3
'''
import time
import math
l = [[] for i in range(5)]
flag = 0
for i in range(3):
	a, b = map(int, input().strip().split())
	l[a].append(b)
	l[b].append(a)
for i in range(1, 5):
	if(len(l[i]) > 2):
		flag = 1
		break
print("YES" if not flag else "NO")
Buggy python submission (verdict: Runtime Error):
print("second" if all([int(input()) % 2 == 0 for i in range(input())]) else "first")


Fixed submission:
'''input
3
1
30000
20000
'''
import time
import math

n = int(input())
print("second" if all([int(input()) % 2 == 0 for i in range(n)]) else "first")
Buggy python submission (verdict: Runtime Error):

d = defaultdict(list)

N, M = list(map(int, input().split()))

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

for i in range(M):
    a, b = list(map(int, input().split()))
    d[a-1].append(b-1)
    d[b-1].append(a-1)

ans = 0
for i in range(N):
    ng = 0

    if(i not in d):
        ans += 1
        continue

    for j in d[i]:
        if(H[i] <= H[j]): ng = 1
    if(ng != 1):
        ans += 1

print(ans)

Fixed submission:
from collections import defaultdict

d = defaultdict(list)

N, M = list(map(int, input().split()))

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

for i in range(M):
    a, b = list(map(int, input().split()))
    d[a-1].append(b-1)
    d[b-1].append(a-1)

ans = 0
for i in range(N):
    ng = 0

    if(i not in d):
        ans += 1
        continue

    for j in d[i]:
        if(H[i] <= H[j]): ng = 1
    if(ng != 1):
        ans += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))

begin = 0
till = K

max = 0
for i in range(N-K+1):
    partial = np.sum(p[begin:till])
    if(max < partial): max = partial
    begin += 1
    till += 1



print((max + K) / 2)

Fixed submission:
import numpy as np

N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))

begin = 0
till = K

max = np.sum(p[0:K])
partial = max
for i in range(N-K):
    partial = partial - p[begin] + p[till]
    if(max < partial):
        max = partial

    begin += 1
    till += 1

print((max + K) / 2)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))

p_0 = np.hstack((p, np.array([0] * (K-1))))

ps = p_0
for i in range(1,K):
    ps = ps + np.roll(p_0,i)

max = np.max(ps)

print((max + K) / 2)

Fixed submission:
import numpy as np

N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))

begin = 0
till = K

max = np.sum(p[0:K])
partial = max
for i in range(N-K):
    partial = partial - p[begin] + p[till]
    if(max < partial):
        max = partial

    begin += 1
    till += 1

print((max + K) / 2)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))

p_0 = np.hstack((p, np.array([0] * (K-1))))

ps = [np.roll(p_0,i) for i in range(K)]

s = sum(ps)
max = max(s)

print((max + K) / 2)

Fixed submission:
import numpy as np

N, K = map(int, input().split())
p = np.array(list(map(int, input().split())))

begin = 0
till = K

max = np.sum(p[0:K])
partial = max
for i in range(N-K):
    partial = partial - p[begin] + p[till]
    if(max < partial):
        max = partial

    begin += 1
    till += 1

print((max + K) / 2)
Buggy python submission (verdict: Runtime Error):
N, M = list(map(int, input().split()))

p = [0] * M
S = [''] * M


for i in range(M):
    p[i], S[i] = input().split()
    p[i] = int(p[i])

dp = [[0] * 2 for i in range(N)]  # x問目の、score, 正答までのwrong_ans                                               #dp = [[0] * 2 for i in range(100005)]  # x問目の、score, penalty

for i in range(M):
    num = p[i] - 1
    # 未得点のときだけ影響
    if(dp[num][0] == 0):
         if(S[i] == 'WA'):
             dp[num][1] += 1
             continue

         elif(S[i] == 'AC'):
             dp[num][0] += 1
             continue
         else:
             print("S is ??")

score = 0
penalty = 0
for i in range(len(dp)):
    score += dp[i][0]
    penalty += dp[i][1]

print(score, penalty)
~

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

p = [0] * M
S = [''] * M


for i in range(M):
    p[i], S[i] = input().split()
    p[i] = int(p[i])

WAnum = 0
ACnum = 0

WA = [0] * N
AC = [0] * N

for i in range(M):
    num = p[i] - 1
    # 未得点のときだけ影響
    if(AC[num] >= 1):
        continue

    if(S[i] == 'WA'):
        WA[num] += 1

    elif(S[i] == 'AC'):
        AC[num] = 1
        ACnum += 1
        WAnum += WA[num]

print(ACnum, WAnum)

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

p = [0] * M
S = [''] * M


for i in range(M):
    p[i], S[i] = input().split()
    p[i] = int(p[i])

penalty = 0
right_ans = 0

dp = [[0] * 2 for i in range(N)]  # x問目の、score, penalty

for i in range(M):

    # 得点済
    if(dp[p[i]][0] > 0):
        continue

    if(S[i] == 'AC'):
        dp[p[i]][0] += 1
        continue

    elif(S[i] == 'WA'):
        dp[p[i]][1] += 1

print(right_ans, penalty)

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

p = [0] * M
S = [''] * M


for i in range(M):
    p[i], S[i] = input().split()
    p[i] = int(p[i])

WAnum = 0
ACnum = 0

WA = [0] * N
AC = [0] * N

for i in range(M):
    num = p[i] - 1
    # 未得点のときだけ影響
    if(AC[num] >= 1):
        continue

    if(S[i] == 'WA'):
        WA[num] += 1

    elif(S[i] == 'AC'):
        AC[num] = 1
        ACnum += 1
        WAnum += WA[num]

print(ACnum, WAnum)

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

p = [0] * M
S = [''] * M


for i in range(M):
    p[i], S[i] = input().split()
    p[i] = int(p[i])

penalty = 0
right_ans = 0

dp = [[0] * 2 for i in range(N)]  # x問目の、score, penalty

for i in range(M):

    # 得点済
    if(dp[p[i]][0] > 0):
        continue

    if(S[i] == 'AC'):
        dp[p[i]][0] += 1
        continue

    elif(S[i] == 'WA'):
        dp[p[i]][1] += 1

print(right_ans, penalty)

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

p = [0] * M
S = [''] * M


for i in range(M):
    p[i], S[i] = input().split()
    p[i] = int(p[i])

WAnum = 0
ACnum = 0

WA = [0] * N
AC = [0] * N

for i in range(M):
    num = p[i] - 1
    # 未得点のときだけ影響
    if(AC[num] >= 1):
        continue

    if(S[i] == 'WA'):
        WA[num] += 1

    elif(S[i] == 'AC'):
        AC[num] = 1
        ACnum += 1
        WAnum += WA[num]

print(ACnum, WAnum)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a_list = list(map(int, input().split()))

ans = 0
sum_rslt = [[0] * n for i in range(n)]
sum_rslt[0] = a_list

xor_rslt = [[0] * n for i in range(n)]
xor_rslt[0] = a_list


for i in range(1, n):
  for j in range(0, n - i):
    sum_rslt[i][j] = sum_rslt[i-1][j] + sum_rslt[0][j+i]
    xor_rslt[i][j] = xor_rslt[i-1][j] ^ xor_rslt[0][j+i]

for i in range(0, n):
  for j in range(0, n - i):
      if (sum_rslt[i][j] == xor_rslt[i][j]):
         # print("l:" + str(j + 1), "r:" + str(i + 1))
          ans = ans + 1

print(ans)

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

ans = 0
sum = 0

left = 0
right = 0

while(left < n):
    while(right < n and (sum ^ a[right] == sum + a[right])):
        sum = sum + a[right]
        right = right + 1

    ans = ans + right - left
    if(left == right):
        right = right + 1
    else:
        sum = sum - a[left]

    left = left + 1

print(ans)
Buggy python submission (verdict: Runtime Error):
from sys import stdin
from functools import lru_cache

@lru_cache(None)
def solver(N, K):
    """N以下で0でないものがちょうどK個。0を含める"""
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    # divmod : 商と余りを両方取れる
    m, r = divmod(N,10)
    ans = 0
        # 1の位が nonzero
        ans += solver(m, K-1) * r
        ans += solver(m-1, K-1) * (9-r)
    ans += solver(m, K)
    return ans


n = int(input())
k = int(input())
print(solver(n,k)


Fixed submission:
from sys import stdin
from functools import lru_cache

@lru_cache(None)
def solver(N, K):
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    m, r = divmod(N,10)
    ans = 0
    if K >= 1:
        ans += solver(m, K-1) * r
        ans += solver(m-1, K-1) * (9-r)
    ans += solver(m, K)
    return ans


n = int(input())
k = int(input())
print(solver(n,k))
Buggy python submission (verdict: Runtime Error):
n,a.b = map(int,input().split())
print(min(4*a,b))

Fixed submission:
n,a,b = map(int,input().split())
print(min(n*a,b))
Buggy python submission (verdict: Time Limit Exceeded):
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict, deque
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def IS(): return input().rstrip()
def gcd_core(a, b):
    if b == 0: return a
    else: return gcd_core(b, a % b)
def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)): g = gcd_core(g, arr[i])
    return g
def main():
    K = I()
    for a in range(1, K+1):
        for b in range(a, K+1):
            for c in range(b, K+1):
                x = len({a, b, c})
                yield gcd([a, b, c])*sum([i for i in range(1, x+1)])
if __name__ == '__main__':
    print(sum(main()))

Fixed submission:
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict, deque
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def IS(): return input().rstrip()
def gcd_core(a, b):
    if b == 0: return a
    else: return gcd_core(b, a % b)
def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)): g = gcd_core(g, arr[i])
    return g
def main():
    K = I()
    for a in range(1, K+1):
        for b in range(a, K+1):
            for c in range(b, K+1):
                x = len({a, b, c})
                if x == 1: pass
                elif x == 2: x = 3
                else: x = 6
                yield gcd([a, b, c])*x
if __name__ == '__main__':
    print(sum(main()))
Buggy python submission (verdict: Runtime Error):
ef S(): return input().rstrip()

def main():
    s = S()

    if 'A' in s and 'B' in s:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Fixed submission:
def S(): return input().rstrip()

def main():
    s = S()

    if 'A' in s and 'B' in s:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n, a, b = map(int, input().split())
MOD = 10**9+7

def comb(n, r):
    x = 1; y = 1
    for i in range(r):
        x *= n-i
        y *= r-i
    return x*pow(y, MOD-2, MOD)

print(pow(2, n, MOD)-1 -comb(n, a) -comb(n, b))

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

if N >= 10:
    print(R)
else:
    print(R+100*(10-N))

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

if N > 10:
    print(R)
else:
    print(R-100*(10-K))

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

if N >= 10:
    print(R)
else:
    print(R+100*(10-N))

Buggy python submission (verdict: Runtime Error):
, R = map(int, input().split())

if N > 10:
    print(R)
else:
    print(R+100*(10-N))

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

if N >= 10:
    print(R)
else:
    print(R+100*(10-N))
Buggy python submission (verdict: Runtime Error):
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()

def main():
    N = I(); A = LI(); judge=True
    for i in A:
        if A%2==0:
            if A%3!=0 or A%5!=0:
                judge=False
    if judge:
        print('APPROVED')
    else:
        print('DENIED')
if __name__ == '__main__':
    main()

Fixed submission:
import sys; sys.setrecursionlimit(2147483647); input = sys.stdin.readline
from math import floor, ceil, sqrt, factorial, log
from collections import Counter, defaultdict
from operator import itemgetter
INF = float('inf'); MOD = 10**9+7
def I(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(MI())
def LIR(n): return [LI() for i in range(n)]
def S(): return input().rstrip()

def main():
    N = I(); A = LI(); judge=True
    for i in A:
        if i%2==0:
            if i%3!=0 and i%5!=0:
                judge=False
    if judge:
        print('APPROVED')
    else:
        print('DENIED')
if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
def main():
# 整数の入力
    x = int(input())
    a = 0
    b = 0
    while True:
        y = 0
        y5_x = math.pow(b, 5)
        y = math.pow(y5_x - x, -5)
        
        y = int(y)
        if math.pow(y, 5) + x == y5_x:
            a = y
            break
        else:
            b += 1

    print(f"{b} {a}")

if __name__ == '__main__':
    main()

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

def main():
# 整数の入力
    
    s = input()
    # 出力
    if s == "ABC":
        print("ARC")
    if s == "ARC":
        print("ABC")

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def shiritori(a, b):
    return a[len(a)-1:] == b[:1]


a, b, c = map(input().split())
if shiritori(a, b) is True and shiritori(b, c) is True:
    print("YES")
else:
    print("NO")


Fixed submission:
# -*- coding: utf-8 -*-
def shiritori(a, b):
    return a[len(a)-1:] == b[:1]


a, b, c = input().split()
if shiritori(a, b) is True and shiritori(b, c) is True:
    print("YES")
else:
    print("NO")

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
def shiritori(a, b):
    return a[len(a)-1:] == b[:1]


a, b, c = map(int, raw_input().split())
if shiritori(a, b) is True and shiritori(b, c) is True:
    print("YES")
else:
    print("NO")


Fixed submission:
# -*- coding: utf-8 -*-
def shiritori(a, b):
    return a[len(a)-1:] == b[:1]


a, b, c = input().split()
if shiritori(a, b) is True and shiritori(b, c) is True:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
n, t = map(int, input().split(' '))
tlist = map(int, input().split(' '))

sum_time = 0
for i in range(1, len(tlist)):
    delta = tlist[i] - tlist[i-1]
    shower = delta if delta <= t else t
    sum_time += shower
sum_time += t
print(sum_time)


Fixed submission:
n, t = map(int, input().split(' '))
tlist = list(map(int, input().split(' ')))

sum_time = 0
for i in range(1, len(tlist)):
    delta = tlist[i] - tlist[i-1]
    shower = delta if delta <= t else t
    sum_time += shower
sum_time += t
print(sum_time)