Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p02801 (python)

Fixed submission:
C = input()
print(chr(ord(C)+1))

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]
from collections import deque
ans = 0
for i in range(H):
  for j in range(W):
    if S[i][j]=='#':
      continue
    inf = 10**5
    A = [[inf]*W for _ in range(H)]
    A[i][j]=0
    judge = [[False]*W for _ in range(H)]
    judge[i][j]=True
    q = deque([[i,j]])
    while q:
      a = q.popleft()
      x=a[0]
      y=a[1]
      b = A[x][y]
      for m in [[x-1,y],[x+1,y],[x,y-1],[x,y+1]]:
        h = m[0]
        w = m[1]
        if (h<0)or(h>H-1)or(w<0)or(w>W-1):
          continue
        if S[h][w]=='#':
          continue
        c = b+1
        if judge[h][w]:
          continue
        A[h][w]=c
        judge[h][w]=True
        q.append([h,w])
        
    A = [a for b in A for a in b if a!=inf]
    ans = max(ans,max(A))
    
print(ans)
Problem p02803 (python)

Fixed submission:
H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]
from collections import deque
import numpy as np
ans = 0
for i in range(H):
  for j in range(W):
    if S[i][j]=='#':
      continue
    inf = 10**5
    A = [[inf]*W for _ in range(H)]
    A[i][j]=0
    q = deque([[i,j]])
    while q:
      a = q.popleft()
      x=a[0]
      y=a[1]
      b = A[x][y]
      for m in [[x-1,y],[x+1,y],[x,y-1],[x,y+1]]:
        h = m[0]
        w = m[1]
        if (h<0)or(h>H-1)or(w<0)or(w>W-1):
          continue
        if S[h][w]=='#':
          continue
        c = b+1
        if c>=A[h][w]:
          continue
        A[h][w]=c
        q.append([h,w])
      
    A = np.array(A)
    ans = max(ans,max(A[A<10**5]))
    
print(ans)

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]
from collections import deque
ans = 0
for i in range(H):
  for j in range(W):
    if S[i][j]=='#':
      continue
    inf = 10**5
    A = [[inf]*W for _ in range(H)]
    A[i][j]=0
    q = deque([[i,j]])
    while q:
      a = q.popleft()
      x=a[0]
      y=a[1]
      b = A[x][y]
      for m in [[x-1,y],[x+1,y],[x,y-1],[x,y+1]]:
        h = m[0]
        w = m[1]
        if (h<0)or(h>H-1)or(w<0)or(w>W-1):
          continue
        if S[h][w]=='#':
          A[h][w]=0
          continue
        c = b+1
        if c>=A[h][w]:
          continue
        A[h][w]=c
        q.append([h,w])
        
    A = [a for a in b for b in A if a!=inf]
    ans = max(ans,max(max(A)))
    
print(ans)
Problem p02807 (python)

Fixed submission:
N = int(input())
X = list(map(int,input().split()))
import math
ans = 0
mod = 10**9+7
a = 0
ans = 0
for i in range(N-1):
  a += pow(i+1,mod-2,mod)
  ans += ((X[i+1]-X[i])%mod)*(a%mod)
  ans %= mod
  
ans *= math.factorial(N-1)%mod

print(ans%mod)

Buggy submission (verdict: Runtime Error):
N = int(input())
X = list(map(int,input().split()))
import numpy as np
import math
ans = 0
mod = 10**9+7
x=X[-1]
for i in range(N-1):
  for j in range(i+1,N-1):
    a = j-i-1
    ans += ((X[j]-X[i])%mod)*(math.factorial(a)%mod)*(math.factorial(N-1)%mod*pow(math.factorial(a+2),mod-2,mod))%mod
    
for k,y in enumerate(X[:N-1:]):
  a = N-k-2
  ans+=((x-y)%mod)*(math.factorial(a)%mod)*(math.factorial(N-1)%mod*pow(math.factorial(a+1),mod-2,mod))%mod
print(ans%mod)

Buggy submission (verdict: Runtime Error):
N = int(input())
X = list(map(int,input().split()))
import math
ans = 0
mod = 10**9+7
a = 0
ans = 0
for i in range(N-1):
  a += (1/(i+1))*math.factorial(N-1)
  ans += (X[i+1]-X[i]%mod)*(a%mod)

print(int(ans)%mod)

Buggy submission (verdict: Runtime Error):
N = int(input())
X = list(map(int,input().split()))
import math
ans = 0
mod = 10**9+7
a = 0
ans = 0
for i in range(N-1):
  a += 1/(i+1)
  ans += (X[i+1]-X[i])*a

ans *= math.factorial(N-1)
print(int(ans)%mod)
Problem p02814 (python)

Fixed submission:
N,M=map(int,input().split())
A = list(map(int,input().split()))
import numpy as np
import math
import fractions
import functools
A = np.array(A)
A = np.unique(A)
B = A.copy()
x=0
while np.all(B%2==0):
  B//=2
  x+=1
if np.any(B%2==0):
  print(0)
  exit()
  
A /= 2
n = A[0]
for a in A[1::]:
  n = n*a//fractions.gcd(n,a)
ans = math.ceil(M//n/2)
print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A = list(map(int,input().split()))
import numpy as np
import math
A = np.array(A)
A = np.unique(A)
x=0
while np.all(A%2==0):
  A //= 2
  x+=1
  
if np.any(A%2==0):
  print(0)
  exit()
m = max(A)
l = np.array([0]*(m+1))
l[1]=1
for a in A:
  for i in range(3,a+1,2):
    n=0
    while a%i==0:
      a//=i
      n+=1
      
    l[i]=max(l[i],n*i)
  

k = np.cumprod(l[l>=1])[-1]*5*pow(2,x)//10
  
ans = math.ceil(M/k/2)
print(ans)

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
A = list(map(int,input().split()))
import numpy as np
import math
A = np.array(A)
A = np.unique(A)
x=0
while np.all(A%2==0):
  A //= 2
  x+=1
  
if np.any(A%2==0):
  print(0)
  exit()
m = max(A)
l = np.array([0]*(m+1))
l[1]=1
for a in A:
  for i in range(3,a+1,2):
    n=0
    while a%i==0:
      a//=i
      n+=1
      
    l[i]=max(l[i],n*i)
  

k = np.cumprod(l[l>=1])[-1]*pow(2,x)
if 1 in A:
  k/=2
  
ans = math.ceil(M/k/2)
print(ans)
Problem p02823 (python)

Fixed submission:
N,A,B = map(int,input().split())
x = B-A
if x%2==0:
  print(x//2)
  
else:
  x = min(max(A-1,B-1),max(N-A,N-B))
  y = N-B+1+(B-A-1)//2
  z = A+(B-A-1)//2
  print(min(x,y,z))

Buggy submission (verdict: Runtime Error):
N,M,V,P = map(int,input().split())
import numpy as np
A = list(map(int,input().split()))
A = np.array(sorted(A,reverse=True))
ans = P
x = A[P-1]
y = N-1
for i in range(P,N):
  a = A[i]
  if x==a:
    ans+=1
  else:
    y=i
    break

if y==N-1:
  print(N)
z = sum(A[P-1:y])
for i in range(y,N):
  a = A[i]
  d = a+M
  if x<=d:
    b = N-i+P-1
    c = M*(V-b)
    e = z+c
    f = d*(i-P+1)
    if f>=e:
      ans+=1
      
  z+=a
print(ans)
Problem p02824 (python)

Fixed submission:
N,M,V,P = map(int,input().split())
import numpy as np
A = list(map(int,input().split()))
A = np.array(sorted(A,reverse=True))
ans = P
x = A[P-1]
y=P
z = sum(A[P-1:y])
for i in range(y,N):
  a = A[i]
  d = a+M
  if x<=d:
    b = N-i+P-1
    c = M*(V-b)
    e = z+c
    f = d*(i-P+1)
    if f>=e:
      ans+=1
      
  z+=a
print(ans)

Buggy submission (verdict: Runtime Error):
N,M,V,P = map(int,input().split())
import numpy as np
A = list(map(int,input().split()))
A = np.array(sorted(A,reverse=True))
ans = P
x = A[P-1]
for i in range(P,N):
  a = A[i]
  if x==a:
    ans+=1
  else:
    y=i
    break
    
z = sum(A[P-1:y])
for i in range(y,N):
  a = A[i]
  d = a+M
  if x<=d:
    b = N-i+P-1
    c = M*(V-b)
    e = z+c
    f = d*(i-P+1)
    if f>=e:
      ans+=1
      
  z+=a
        
print(ans)

Buggy submission (verdict: Runtime Error):
N,M,V,P = map(int,input().split())
import numpy as np
A = list(map(int,input().split()))
A = np.array(sorted(A,reverse=True))
ans = P
x = A[P-1]
for i in range(P,N):
  a = A[i]
  if x==a:
    ans+=1
  else:
    y=i
    break
    
for i in range(y,N):
  d = A[i]+M
  if x<=d:
    b = N-i+P-1
    c = M*(V-b)
    for j in range(i-1,P-2,-1):
      e = d-A[j]
      c-=(max(0,e))
      if c <=0:
        ans+=1
        break
      elif e<=0:
        break
        
print(ans)

Buggy submission (verdict: Runtime Error):
N,M,V,P = map(int,input().split())
import numpy as np
A = list(map(int,input().split()))
A = np.array(sorted(A,reverse=True))
ans = P
if N//2<=V:
  V = N-V
  A += M
  x = A[P-1]
  for i in range(P,N):
    a = A[i]
    if a==x:
      ans += 1
    else:
      y = i
      break
  
  for i in range(y,y+M):
    z = i
    a = A[i]
    if x-V<=a:
      ans+=1
    else:
      break

  for j in range(z+1,N):
    if a==A[j]:
      ans+=1
      
    else:
      break
  print(ans)
  
else:
  x = A[P-1]
  for i in range(P,N):
    a = A[i]
    if a==x:
      ans += 1
    else:
      y = i
      break
  for i in range(y,y+M):
    a = A[i]
Problem p02845 (python)

Fixed submission:
N=int(input())
A = list(map(int,input().split()))
lis = [0]*200000
ans=1
num_zero=0
mod = 1000000007
for i in A:
  lis[i]+=1
  if i!=0:
    ans*=lis[i-1]
    lis[i-1]-=1
    ans%=mod
    if lis[i-1]<0:
      ans=0
      break
    
  else:
    num_zero+=1

if (num_zero==2)or(num_zero==3):
  mul = 6
  
elif num_zero==1:
  mul = 3

else:
  mul = 0
  
print((ans*mul)%mod)

Buggy submission (verdict: Runtime Error):
N=int(input())
A = list(map(int,input().split()))
lis = [0]*200000
ans=1
num_zero=0
mod = 1000000007
for i in A:
  lis[i]+=1
  if i!=0:
    ans*=lis[i-1]
    lis[i-1]-=1
    ans%=mod
    if lis[i-1]<0:
      ans=0
      break
    
  else:
    num_zero+=1

if num_zero>=2:
  mul = 6
  
elif num_zero = 0:
  mul = 0

else:
  mul = 3
  
print((ans*mul)%mod)
Problem p02865 (python)

Fixed submission:
N = int(input())
import math
print(math.ceil(N/2)-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
D = list(map(int,input().split()))
from collections import Counter
print(0)
Problem p02882 (python)

Fixed submission:
a,b,x = map(int,input().split())
import math

if x==a**2*b:
  print(0)
elif x//a<=(a*b/2):
  print(90-math.degrees(math.atan((2*x)/(a*(b**2)))))
    
else:
  print(90-math.degrees(math.atan(a/(2*(b-(x/a**2))))))

Buggy submission (verdict: Runtime Error):
a,b,x = map(int,input().split())
import math

if x==1 and a==1 and b==1:
  print(0)
if x//a<=(a*b/2):
  print(90-math.degrees(math.atan((2*x)/(a*(b**2)))))
    
else:
  print(90-math.degrees(math.atan(a/(2*(b-(x/a**2))))))

Buggy submission (verdict: Runtime Error):
a,b,x = map(int,input().split())
import math

if x//a<=(a*b/2):
  print(90-math.degrees(math.atan((2*x)/(a*(b**2)))))
    
else:
  print(90-math.degrees(math.atan(a/(2*(b-(x/a**2))))))

Buggy submission (verdict: Runtime Error):
a,b,x = map(int,input().split())
import math

if x//a<=(a*b/2):
	print(90-math.degrees(math.atan((2*x)/(a*(b**2)))))
    
else:
  print(90-math.degrees(math.atan(a/(2*(b-(x/a**2))))))

Buggy submission (verdict: Runtime Error):
a,b,x = map(int,input().split())
import math

if x//a<=(a*b/2):
	print(90-math.degrees(math.atan((2*x)/(a*(b**2)))))
    
else:
  print(90-math.degrees(math.atan(a/(2*(b-(x/a**2))))))
Problem p02936 (python)

Fixed submission:
from collections import deque
N, Q = map(int, input().split())
ab = [list(map(int,input().split())) for _ in range(N-1)]
px = [list(map(int,input().split())) for _ in range(Q)]
tree = [[] for _ in range(N)]
ans = [0]*N
for a,b in ab:
  tree[a-1].append(b-1)
  tree[b-1].append(a-1)
  
for p,x in px:
  ans[p-1]+=x
  
q = deque([0])
judge = [False]*N
while q:
  a=q.pop()
  judge[a]=True
  for i in tree[a]:
    if judge[i]:
      continue
    ans[i]+=ans[a]
    q.append(i)
    
print(' '.join(map(str,ans)))

Buggy submission (verdict: Runtime Error):
N,Q = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(N-1)]
px = [list(map(int,input().split())) for _ in range(Q)]
tree = [[] for i in range(N)]
ans = [0]*N
ad = [0]*N
for a,b in ab:
  tree[a-1].append(b-1)
  

for i in range(N-1,-1,-1):
  x = tree[i].copy()
  for j in x:
    tree[i]+=tree[j]

for p,x in px:
  ad[p-1]+=x
  

for i,a in enumerate(ad):
  ans[i]+=a
  x=tree[i].copy()
  for j in x:
    ans[j]+=a
    
print(' '.join(map(str,ans)))
Problem p03192 (python)

Fixed submission:
N = map(str,input())
M = [M for M in N]
print(M.count("2"))

Buggy submission (verdict: Runtime Error):
N,P = map(int,input().split())
i = round(P**(1/N))
res = []
if N == 1:
  print(P)
elif P == 1|N>=40:
  print(1)
else:
  for i in range(i,0,-1):
    if P%i**N==0:
      print(i)
      break

Buggy submission (verdict: Runtime Error):
import functools
import operator

N,P = map(int,input().split())

i = 2
res = []
i_2 = i**N
while i * i<=P:
  while P%i_2==0:
    P/=i_2
    res.append(i)
  else:
    i += 1
    
res.append(1)
result = functools.reduce(operator.mul, res)
print(result)

Buggy submission (verdict: Runtime Error):
import collections
from functools import reduce
from operator import mul
N,P = map(int,input().split())

def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(i)
    i += 1
  if n > 1:
    table.append(n)
  return table

P = prime_decomposition(P)
c = collections.Counter(P)
temp = [i[0] for i in c.items() if i[1] >= N]
 
temp.append(1)
 
print(int(reduce(mul,temp)))

Buggy submission (verdict: Runtime Error):
N = map(str,input())
M = [M for M in N]
print(M.count("2")
Problem p03266 (python)

Fixed submission:
N,K = map(int,input().split())
ans = 0
if K%2==1:
  ans = (N//K) ** 3
else:
  half_K = K//2
  a = N//K
  b = N//half_K - a
  ans = a**3+b**3

print(ans)

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
N_d = N*2
ans = 0
kl = [K*x for x in range(1,N_d//K+1)]
s=kl[-1]
t=kl[-2]
if K%2==1:
  a=s//K
  if a%2==0:
    b = a//2
    ans = pow(b,3)
    
  else:
    b=a//2
    ans = pow(b,3)+3
    
else:
  half_K = K//2
  a = s//K
  if a%2==0:
    b = a//2
    ans+=pow(b,3)
  else:
    b=a//2
    ans += pow(b,3)+3
    
  b = t//K
  if b%2==0:
    c = b//2
    ans+=pow(c,3)
  else:
    c=b//2
    ans+=pow(b,3)+3
  
print(ans)
Problem p03696 (python)

Fixed submission:
N=int(input())
S=input()
sl=list(S)
change=[0]
for i in range(1,N):
  if (sl[i-1]==')')and(sl[i]=='('):
    change.append(i)

change.append(N)
r_add=0
l_add=0
for i in range(len(change)-1):
  A=sl[change[i]:change[i+1]]
  r=0
  l=0
  for a in A:
    if a=='(':
      l+=1
    else:
      r+=1
      
  if r==l:
    continue
  elif r>l:
    if r_add>0:
      if r_add>=r-l:
        r_add-=r-l
      else:
        l_add+=r-l-r_add
        r_add=0
        
    else:
      l_add+=r-l
      
  else:
    r_add+=l-r
      
print('('*l_add+S+')'*r_add)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
sl=list(S)
change=[0]
for i in range(1,N):
  if (sl[i-1]==')')and(sl[i]=='('):
    change.append(i)

change.append(N)
r_add=0
l_add=0
for i in range(len(change)-1):
  A=sl[change[i]:change[i+1]]
  r=0
  l=0
  for a in A:
    if a=='(':
      l+=1
    else:
      r+=1
      
  if r==l:
    continue
  elif r>l:
    l_add+=r-l
    r_add=max(0,r_add-(r-l))
  else:
    r_add+=l-r
      
print('('*l_add+S+')'*r_add)print('('*l_add+S+')'*r_add)

Buggy submission (verdict: Runtime Error):
N=int(input())
S=input()
sl=list(S)
change=[0]
ans=''
for i in range(N+1):
  if (sl[i-1]==')')and(sl[i]=='('):
    change.append(i)

change.append(N)
for i in range(len(change)-1):
  A=sl[change[i]:change[i+1]]
  r=0
  l=0
  for a in A:
    if a=='(':
      l+=1
    else:
      r+=1
      
  if r==l:
    ans+=''.join(A)
  elif r>l:
    ans+='('*(r-l)+''.join(A)
  else:
    ans+=''.join(A)+')'*(l-r)
      
print(ans)
Problem p02613 (python)

Fixed submission:
arr = [0, 0, 0, 0]
for _ in range(int(input())):
  s = input()
  arr[{"AC": 0, "WA": 1, "TLE": 2, "RE": 3}[s]] += 1
print("AC x", arr[0])
print("WA x", arr[1])
print("TLE x", arr[2])
print("RE x", arr[3])

Buggy submission (verdict: Runtime Error):
ar = [0, 0, 0, 0]
for _ in range(int(input())):
  s = input()
  ar[{"AC": 0, "WA": 1, "TLE": 2, "RE": 3}[s]] += 1
print("AC x", arr[0])
print("WA x", arr[1])
print("TLE x", arr[2])
print("RE x", arr[3])
Problem p02687 (python)

Fixed submission:
if input() == "ABC":
  print("ARC")
else:
  print("ABC")

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

arr = [[False] * k for _ in range(n)] # person, snack

for i in range(k):
    m = int(input())
    for p in map(int, input().split()):
        arr[p-1][i] = True

total = 0
for i in range(n):
    if not any(arr[i]):
        total += 1

print(total)
Problem p02696 (python)

Fixed submission:
from math import floor
a, b, n = map(int, input().split())
if b == 1:
	print(0)
else:
	x = min(b-1, n)
	print(floor(a*x/b) - a * floor(x/b))

Buggy submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
if b == 1:
	print(0)
else:
	x = min(b-1, n)
	print(floor(a*x/b) - a * floor(x/b))

Buggy submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
if b == 1:
  print(0)
  exit()
x = min(b-1, n)
print(floor(a*x/b) - a * floor(x/b))

Buggy submission (verdict: Runtime Error):
a, b, n = map(int, input().split())
x = min(b-1, n)
print(floor(a*x/b) - a * floor(x/b))

Buggy submission (verdict: Runtime Error):
a, b, n = map(int(input().split()))
x = min(b-1, n)
print(floor(a*x/b) - a * floor(x/b))
Problem p02814 (python)

Fixed submission:
def gcd(x, y):
    if x == 0: return y
    return gcd(y%x, x)
lcm = lambda x, y: x*y//gcd(x, y)

n, m = map(int, input().split())
arr = list(map(int, input().split()))
arr = [e//2 for e in arr]

cm = arr[0]
for e in arr[1:]:
    cm = lcm(cm, e)

if any([cm//e % 2 == 0 for e in arr]):
    print(0)
    exit()
print((m//cm+1)//2)

Buggy submission (verdict: Runtime Error):
from math import gcd
lcm = lambda x, y: x*y//gcd(x, y)

n, m = map(int, input().split())
arr = list(map(int, input().split()))
arr = [e//2 for e in arr]

cm = arr[0]
for e in arr[1:]:
    cm = lcm(cm, e)

if any([cm//e % 2 == 0 for e in arr]):
    print(0)
    exit()
print((m//cm+1)//2)
Problem p03651 (python)

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

n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
    g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if a == 0: return b
    if b == 0: return a
    return gcd(a % b, b % a)

n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
    g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    if a == 0: return b
    if b == 0: return a
    return gcd(a % b, b % a)

n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
        g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
        print("POSSIBLE")
else:
        print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
from math import gcd
n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
        g = gcd(g, e)

if k <= max(arr) and k//g*g == k:
        print("POSSIBLE")
else:
        print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
from math import gcd
n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
	g = gcd(g, e)
if k <= max(arr) and k//g*g == k:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
from math import gcd
n, k = map(int, input().split())
arr = list(map(int, input().split()))
g = arr[0]
for e in arr[1:]:
  g = gcd(g, e)
if k <= max(arr) and k//g*g == k:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")
Problem p02772 (python)

Fixed submission:
from sys import setrecursionlimit as srl; srl(10**7)
rr = lambda: int(raw_input())
rrm = lambda: map(int, raw_input().split())

YES,NO = "APPROVED","DENIED"
def solve(N, A):
    for x in A:
        if x % 2 == 0:
            if x % 3 and x % 5:
                return NO
    return YES

    
print solve(int(rr()), rrm())

Buggy submission (verdict: Runtime Error):
from sys import setrecursionlimit as srl; srl(10**7)
rr = lambda: int(raw_input())
rrm = lambda: map(raw_input().split())

YES,NO = "APPROVED","DENIED"
def solve(N, A):
    for x in A:
        if x % 2 == 0:
            if x % 3 or x % 5:
                return NO
    return YES

    
print solve(int(rr()), rrm())
Problem p02553 (python)

Fixed submission:
L=list(map(int,input().split()))
a=L[0]
b=L[1]
c=L[2]
d=L[3]
print(max(a*c,b*d,a*d,b*c))

Buggy submission (verdict: Runtime Error):
L=input().split()
a=L[0]
b=L[1]
c=L[2]
d=L[3]
print(max(a*c,b*d,a*d,b*c))
Problem p02574 (python)

Fixed submission:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 10 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
A = list(map(int, input().split()))
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

# calc prime
MAX = 10 ** 6 + 2
is_prime = [True] * (MAX + 1)
is_prime[0] = False
is_prime[1] = False
i = 2
primes = []
cnt_a = Counter(A)
if cnt_a[1] == N:
    print('pairwise coprime')
    exit()
cnt_facts = defaultdict(int)
while i < MAX:
    if is_prime[i]:
        if cnt_a[i]:
            cnt_facts[i] += cnt_a[i]
        for j in range(i+i, MAX, i):
            is_prime[j] = False
            if cnt_a[j]:
                cnt_facts[i] += cnt_a[j]
        primes.append(i)
    i += 1
if cnt_facts and max(cnt_facts.values()) <= 1:
    print('pairwise coprime')
    exit()
setwise = False
g = A[0]
for a in A:
    g = gcd(g, a)
if g == 1:
    setwise = True

if setwise:
    print('setwise coprime')
if not setwise:
    print('not coprime')

Buggy submission (verdict: Runtime Error):
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 10 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
A = list(map(int, input().split()))
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

# calc prime
MAX = 10 ** 3 + 5
is_prime = [True] * (MAX)
is_prime[0] = False
is_prime[1] = False
i = 2
primes = []
while i < MAX:
    if is_prime[i]:
        for j in range(i+i, MAX, i):
            is_prime[j] = False
        primes.append(i)
    i += 1

cnt = defaultdict(int)
for a in A:
    x = a
    for p in primes:
        if x % p == 0:
            cnt[p] += 1
        while x > 1 and x % p == 0:
            x //= p
        if x <= 1:
            break
    if x > 1:
        cnt[x] += 1
if max(cnt.values()) <= 1:
    print('pairwise coprime')
    exit()

setwise = False
g = A[0]
for a in A:
    g = gcd(g, a)
if g == 1:
    setwise = True

if setwise:
    print('setwise coprime')
if not setwise:
    print('not coprime')
Problem p02612 (python)

Fixed submission:
N = int(input())
a = 1000 - N % 1000
if a == 1000:
    print(0)
else:
    print(a)

Buggy submission (verdict: Runtime Error):
N = int(input())
a = 1000 - N % 1000
if a == 1000:
    print(0)
else:
    print(a