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

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

if N == 0 and A[0] != 1:
  print(-1)
elif N != 0 and A[0] != 0:
  print(-1)
else:
  ans = 1
  nodes = 1
  preF = 0
  sucF = sum(A)
  
  for d in range(1, N+1):
    fol = A[d]
    nodes = min((nodes-preF)*2, sucF)
    
    if nodes < fol:
      print(-1)
      exit()
    
    ans += nodes
    preF = fol
    sucF -= fol
  print(ans)

Buggy submission (verdict: Runtime Error):
from collections import deque

N = int(input())
A = list(map(int, input().split()))
Q = deque()
Q.append([0])
cnt = 1
ans = 1
li = []
while Q:
  temp = Q.popleft()
  if len(temp) == cnt and A[cnt]>=0:
    for i in range(2):
      new = temp + [ans]
      Q.append(new)
      li.append(new)
      ans += 1
      A[cnt] -= 1
      if A[cnt]<0:
        break
  else:
    cnt += 1
    if cnt >= N:
      break
  if not Q and cnt<N:
    Q.append(temp)
print(ans)
Problem p02681 (python)

Fixed submission:
S= input()
T= input()
if T == S + T[-1]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S , T = map(str, input().split())
a=T[-1]
if T == S + a:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S , T = map(str, input().split())
if T == S + T[-1]:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
S , T = map(str, input().split())
if T == S + T[:-1]:
  print('Yes')
else:
  print('No')
Problem p02683 (python)

Fixed submission:
def cos_per_find(count, cost, skills):
    if count == N:
        if min(skills) >= X:
            return cost
        else:
            return INF
    improved_skills = [a+b for a, b in zip(skills, contents[count])]
    return min(cos_per_find(count+1, cost, skills), cos_per_find(count+1, cost+price[count], improved_skills))

INF = float('inf')
N, M, X = map(int, input().split())
price = []
contents = []
for i in range(N):
    C, *A = map(int, input().split())
    price.append(C)
    contents.append(A)
if (ans := cos_per_find(0, 0, [0]*M)) == INF:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
def cos_per_find(count, cost, skills):
    if count == N:
        if min(skills) >= X:
            return cost
        else:
            return INF
    improved_skills = [a+b for a, b in zip(skills, contents[count])]
    return min(cos_per_find(count+1, cost, skills), cos_per_find(count+1, cost+price[count], improved_skills))

INF = float(inf)
N, M, X = map(int, input().split())
price = []
contents = []
for i in range(N):
    C, *A = map(int, input().split())
    price.append(C)
    contents.append(A)
ans = cos_per_find(0, 0, [0]*M)
if ans == INF:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
def cos_per_find(count, cost, skills):
    if count == N:
        if min(skills) >= X:
            return cost
        else:
            return INF
    improved_skills = [a+b for a, b in zip(skills, contents[count])]
    return min(cos_per_find(count+1, cost, skills), cos_per_find(count+1, cost+price[count], improved_skills))

INF = float(inf)
N, M, X = map(int, input().split())
price = []
contents = []
for i in range(N):
    C, *A = map(int, input().split())
    price.append(C)
    contents.append(A)
if (ans := cos_per_find(0, 0, [0]*M)) == INF:
    print(-1)
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
def cos_per_find(count, cost, skills):
    if count == N:
        if min(skills) >= X:
            return cost
        else:
            return INF
    improved_skills = [a+b for a, b in zip(skills, contents[count])]
    return min(cos_per_find(count+1, cost, skills), cos_per_find(count+1, cost+price[count], improved_skills))

INF = float(inf)
N, M, X = map(int, input().split())
price = []
contents = []
for i in range(N):
    C, *A = map(int, input().split())
    price.append(C)
    contents.append(A)
if ans(:=cos_per_find(0, 0, [0]*M))== INF:
    print(-1)
else:
    print(ans)
Problem p02684 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
visited = [False]*N
path = [0]
at = 0
loop = 0
visited[0]=True
for i in range(N):
    at = A[at]-1
    if visited[at]:
        loop = i+1-path.index(at)
        break
    else:
        visited[at]=True
        path.append(at)
if K < len(path):
    print(path[K]+1)
else:
    print(path[(K-path.index(at))%loop+path.index(at)]+1)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
q = list(map(int, input().split()))
v = [-1]*(n+1)
p = []
a = 1
c = 0
while 1:
    if v[a] != -1:
        l = c-v[a]
        if k < c:
            print(p[k])
        else:
            print(p[(k-v[a])%l+v[a]])
        break
    v[a] = c
    c += 1
    p.append(a)
    a = q[a]

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
A = list(map(int, input().split()))
visited = [-1]*(N+1)
path = []
at = 1
count = 0
while True:
    if visited[at] != -1:
        loop = count-visited[at]
        if K < count: # (K-visited[at])//loopが1以上であることを保証
            print(path[K]+1) # 条件 K < visited[at]なら、(K-visited[at])//loopが0以上であることを保証。どっちでもよさそう。
        else:
            print(path[(K-visited[at])%loop+visited[at]]+1)
        break
    visited[at] = count
    count += 1
    path.append(at)
    at = A[at]
Problem p02687 (python)

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

Buggy submission (verdict: Runtime Error):
S=input()
if S=='ABC':
  print('ARC')
elif S=='ARC'
  print('ABC)

Buggy submission (verdict: Runtime Error):
S=input()
if S=='ABC':
  print('ARC')
else:
  print('ABC)
Problem p02705 (python)

Fixed submission:
R=input()
R=int(R)
print(R*2*3.14)

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

m=0
for i in range (0, len(list)):
	m=m+list[i]

if N-m>=0:
print(N-m)
elif N-m<0:
print(-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
list = list(map(int, input().split()))
m=0
for i in range (0, len(list)):
	m=m+list[i]
if N-m>=0:
print(N-m)
elif N-m<0:
print(0)
Problem p02706 (python)

Fixed submission:
N, M = map(int, input().split())
list = list(map(int, input().split()))
 
m=0
for i in range (0, len(list)):
	m=m+list[i]
if N-m>=0:
	print(N-m)
elif N-m<0:
	print(-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
list = list(map(int, input().split()))
 
m=0
for i in range (0, len(list)):
	m=m+list[i]
 
if N-m>=0:
print(N-m)
elif N-m<0:
print(-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
list = list(map(int, input().split()))
m=0
for i in range (0, len(list)):
	m=m+list[i]
if N-m>=0:
print(N-m)
else:
print(0)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
list = list(map(int, input().split()))
m=0
for i in range (0, len(list)):
	m=m+list[i]
if N-m>=0:
print(N-m)
else:
print(-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
list = list(map(int, input().split()))
m=0
for i in range (0, len(list)):
	m=m+list[i]
if N-m>=0:
print(N-m)
else:
print(0)
Problem p02713 (python)

Fixed submission:
from math import gcd
K = int(input())
m = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    w = gcd(i, j)
    if w==1:
      m += K
    else:
      for k in range(1, K+1):
        m += gcd(w, k)
print(m)

Buggy submission (verdict: Runtime Error):
import math
K = int(input())
m = 0
for i in range(1, K+1):
  for j in range(1, K+1):
    for k in range(1, K+1):
      m += gcd(i, j, k)
print(m)
Problem p02755 (python)

Fixed submission:
A, B = map(int, input().split())
C = int(-(-A//0.08))
D = int(-(-(A+1)//0.08))
for i in range(C,D):
    if i//10 == B:
      print(i)
      break
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
C = -(-A//0.08)
D = -(-(A+1)//0.08)
for i in range(C,D):
    if i//10 == B:
      print(i)
      break
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
C = -(-A//0.08)
D = -(-(A+1)//0.08)
for i in range(C,D):
    if i//10 == B:
        break
        print(i)
else:
    print(-1)
Problem p02761 (python)

Fixed submission:
N,M = map(int,input().split())
order = {}
if N==1 and M==0:
  print(0)
else:
  for i in range(M):
    s,c = map(int,input().split())
    if order.get(s,57)==57:
        order[s]=c
    elif order.get(s,57)!=57 and order[s]!=c:
        print(-1)
        break
  else:
    moji = [1]+[0]*(N-1)
    for k in order.keys():
        moji[k-1]=str(order[k])
    if N!=1 and moji[0]=='0':
      print(-1)
    else:
      ans = [str(a) for a in moji]
      print(''.join(ans))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
o = {}
if N==1 and M==0:
  print(0)
else:
  for i in range(M):
    s,c = map(int,input().split())
    if o.get(s,-1)==-1:
        o[s]=c
    elif o.get(s,-1)!=-1 and o[s]!=c:
        print(-1)
        break
  else:
    m = [1]+[0]*(N-1)
    for k in o.keys():
        m[k-1]=o[k]
    if N!=1 and moji[0]==0:
      print(-1)
    else:
      print(''.join([str(a) for a in m]))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
order = {}
if N==1 and M==0:
  print(0)
else:
  for i in range(M):
    s,c = map(int,input().split())
    if order.get(s,x)==x:
        order[s]=c
    elif order.get(s,x)!=x and order[s]!=c:
        print(-1)
        break
  else:
    moji = [1]+[0]*(N-1)
    for k in order.keys():
        moji[k-1]=order[k]
    if N!=1 and moji[0]==0:
      print(-1)
    else:
      print(''.join([str(a) for a in moji]))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
order = {}
for i in range(M):
    s,c = map(int,input().split())
    if order.get(s,57)==57:
        order[s]=c
        continue
    elif order.get(s,57)!=57 and order[s]!=c:
        print(-1)
        break
else:
    moji = [0]*N
    for k in order.keys():
        moji[k-1]=str(order[k])
    if N!=1 and moji[0]==0:
      moji[0]='1'
      print(''.join(moji))
    elif N!=1 and moji[0]=='0':
      print(-1)
    else:
      ans = [str(a) for a in moji]
      print(''.join(ans))
Problem p02772 (python)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
ans = 1
for a in A:
  if a%2==0:
    if a%3!=0 and a%5!=0:
      ans = 0
print('APPROVED' if ans else 'DENIED')

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))[
ans = 1
for a in A:
  if a%2==0:
    if a%3!=0 and a%5!=0:
      ans = 0
print('APPROVED' if ans else 'DENIED')
Problem p02780 (python)

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

exv = [(e+1)/2 for e in dices]
temp = sum(exv[0:K])
result = temp
for i in range(N-K):
    temp -= exv[i]
    temp += exv[i+K]
    if temp > result:
        result = temp
print(result)

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

exv = [(e+1)/2 for e in dices]
temp = sum(m[0:K])
result = temp
for i in range(N-K):
    temp -= dices[i]
    temp += dices[i+K]
    if temp > result:
        result = temp
print(result)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
Dices = list(map(int, input().split()))
Que = []
Eyes = {}
for i in range(K):
    Que.append(Dices[i])
Eyes[K]=sum(Que)
for i in range(K+1, N):
    Que.pop(0)
    Que.append(Dices[i])
    Eyes[i] = Eyes[i-1]-Que[0]+Que[-1]
a = 0
b = 0
for k, v in Eyes.items():
    if v > a:
        a = v
        b = k
ans = 0
for i in range(k-K+1, k+1):
    ans += (Dices[i]+1)/2
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
Dices = list(map(int, input().split()))
Que = []
Eyes = {}
for i in range(K):
    Que.append(Dices[i])
for i in range(K, N):
    Eyes[i] = sum(Que)
    Que.pop(0)
    Que.append(Dices[i])
a = 0
b = 0
for k, v in Eyes.items():
    if v > a:
        a = v
        b = k
ans = 0
for i in range(k-K+1, k+1):
    ans += (Dices[i]+1)/2
print(ans)
Problem p02801 (python)

Fixed submission:
s = input()
st = 'abcdefghijklmnopqrstuvwxyz'
print(st[st.index(s)+1])

Buggy submission (verdict: Runtime Error):
s = input()
st = 'abcdefghijklmnopqrstuvwxyz'
print(st[index(s)+1])
Problem p02837 (python)

Fixed submission:
n = int(input())
tst = [[] for i in range(n)]
for i in range(n):
  a = int(input())
  for j in range(a):
    x,y = map(int,input().split())
    tst[i].append([x,y])
ans = 0
for bit in range(1<<n):
  liars = [0]*n
  check = 1
  for i in range(n):
    if (bit>>i)&1:
      liars[-1-i] = 1
  for i in range(n):
    if liars[i]:
      for l in tst[i]:
        if l[1]!=liars[l[0]-1]:
          check = 0
          break
  temp = 0
  if check:
    temp = sum(liars)
  ans = max(ans,temp)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
tst = [[] for i in range(n)]
for i in range(n):
    a = int(input())
    for j in range(a):
        x,y = map(int,input().split())
        st[i].append([x,y])
ans = 0
for bit in range(1<<n):
    honest = [0]*n
    check = 1
    for i in range(n):
        if (bit>>i)&1:
            honest[-1-i] = 1
    for i in range(n):
        if not honest[i]:
            continue
        for l in tst[i]:
            if l[1]!=honest[l[0]-1]:
                check = 0
                break
    if check:
        ans = max(ans,sum(honest))
print(ans)
Problem p02898 (python)

Fixed submission:
n,k = map(int,input().split())
h = list(map(int,input().split()))
ans = 0
for a in h:
  if a>=k:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().spilit())
h = list(map(int,input().split()))
ans = 0
for a in h:
  if a>=k:
    ans += 1
print(ans)
Problem p02909 (python)

Fixed submission:
s = input()
l = ['Sunny', 'Cloudy', 'Rainy', 'Sunny']
print(l[l.index(s)+1])

Buggy submission (verdict: Runtime Error):
s = int(input())
l = ['Sunny', 'Cloudy', 'Rainy', 'Sunny']
print(l[l.index(s)+1])
Problem p02911 (python)

Fixed submission:
n,k,q = map(int,input().split())
pts = [0]*(n+1)
for _ in range(q):
  a = int(input())
  pts[a] += 1
ans = [k+a-q for a in pts]
for v in ans[1:]:
  print('Yes' if v>0 else 'No')

Buggy submission (verdict: Runtime Error):
import heapq as hq
n,m=input().split()
hq.heapify(a:=[-int(x) for x in input().split()])
for i in range(int(m)):hq.heappush(a,-(-hq.heappop(a)//2))
print(-sum(a))
Problem p03220 (python)

Fixed submission:
N=int(input())
T,A=map(int, input().split())
list=list(map(int, input().split()))
l_b=[]
d=0
for i in range(N):
  d=A-(T-list[i]*0.006)
  if d<0:
    d=-d
  l_b.append(d)
print(l_b.index(min(l_b))+1)

Buggy submission (verdict: Runtime Error):
N=int(input())
T,A=map(int, input().split())
list=list(map(int, input().split()))
l_b=[]
d=0
for i in range(N):
  d=A-(T-list[i]*0.006)
  if d<0:
    d=-d
  l_b.append(d)
print(l_b.index(min(l_b))+1
Problem p03369 (python)

Fixed submission:
m=input().count("o")
print(700+m*100)

Buggy submission (verdict: Runtime Error):
m=int((input().count("o"))
print(str(700+m*100))

Buggy submission (verdict: Runtime Error):
m= (input().count('o')
print(str(700+m*100))

Buggy submission (verdict: Runtime Error):
m= int((input=().count('o'))
print(700+m*100)

Buggy submission (verdict: Runtime Error):
m=int((input=().count('o'))
print(str(700+m*100))

Buggy submission (verdict: Runtime Error):
m= (input=().count('o')
print(str(700+m*100))
Problem p03370 (python)

Fixed submission:
N, X = map(int, input().split())
m=[int(input()) for i in range(N)]
print(N+(X-sum(m))//min(m))

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
m=[int(input() for i in range(N)]
print(N+(X-sum(m))//min(m))
Problem p03434 (python)

Fixed submission:
N=int(input())
a=list(map(int, input().split()))
a.sort(reverse=True)
Alice=0
Bob=0
for i in range(N):
  if i%2==0:
    Alice += a[i]
  else:
    Bob += a[i]
print(Alice-Bob)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int, input().split()))
a.sort()[::-1]
Alice=0
Bob=0
for i in range(N):
  if i%2==0:
    Alice += a[i]
  else:
    Bob += a[i]
print(Alice-Bob)

Buggy submission (verdict: Runtime Error):
N=int(input())
a=list(map(int, input().split()))
a.sort()[::1]
Alice=0
Bob=0
for i in range(N):
  if i%2==0:
    Alice += a[i]
  else:
    Bob += a[i]
print(Alice-Bob)
Problem p03435 (python)

Fixed submission:
d = [None]*3
for i in range(3):
  c = list(map(int, input().split()))
  d[i] = [c[i] - c[i+1] for i in range(2)]
print('Yes' if all(d[i] == d[i+1] for i in range(2)) else 'No')

Buggy submission (verdict: Runtime Error):
l = [list(map(int, input().split())) for i in range(3)]
d = [None]*3
for i in range(3):
  d[i] = [l[i] - l[i+1] for i in range(2)]
print('Yes' if all(d[i] == d[i+1] for i in range(2)) else 'No')

Buggy submission (verdict: Runtime Error):
l = [list(map(int, input().split())) for i in range(3)]
d = [None]*3
d[i] = [l[i] - l[i+1] for i in range(2)]
print('Yes' if all(d[i] == d[i+1] for i in range(2)) else 'No')
Problem p03457 (python)

Fixed submission:
N = int(input())
t,x,y = 0,0,0
f = True
for i in range(N):
    ti,xi,yi = map(int, input().split())
    p=ti-t
    d=abs(xi-x)+abs(yi-y)
    if p<d or p%2 != d%2:
        f = False
        break 
    t,x,y = ti,xi,yi
print('Yes' if f else 'No')

Buggy submission (verdict: Runtime Error):
N = int(input())
plan = [0] + list(map(int, input().split())) for i in range(N)
f = True
for i in range(N):
    time = plan[i+1][0]-plan[i][0]
    dist = abs(plan[i+1][1]-plan[i][1])+abs(plan[i+1][2]-plan[i][2])
    if dist>time or dist%2 != time%2:
        f = False    
print('Yes' if f else 'No')

Buggy submission (verdict: Runtime Error):
N = int(input())
t,x,y = 0,0,0
f = True
for i in range(N):
    ti,xi,yi = map(int, input()split())
    p=ti-t
    d=abs(xi-x)+abs(yi-y)
    if p<d or p%2 != d%2:
        f = False
        break 
    t,x,y = ti,xi,yi
print('Yes' if f else 'No')
Problem p03469 (python)

Fixed submission:
print(input().replace('2017', '2018'))

Buggy submission (verdict: Runtime Error):
print(input().replace('2017', '2018')
Problem p03636 (python)

Fixed submission:
s=input()
print(s[0]+str(len(s)-2)+s[len(s)-1])

Buggy submission (verdict: Runtime Error):
s=input()
print(s[0]+str(len(s)-2)+s[len(s-2)])

Buggy submission (verdict: Runtime Error):
s=input()
print(s[0]+str(len(s)-2)+s[len(s)])
Problem p02603 (python)

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

stock_dp = [[0, 0] for _ in range(n+1)]
value_dp = [0] * (n + 1)

value_dp[0] = 1000
for i in range(1, n + 1):
    x = value_dp[i - 1]
    y = stock_dp[i - 1][0] + stock_dp[i - 1][1] * a[i - 1]
    if x > y:
        value_dp[i] = x
    else:
        value_dp[i] = y
    x = value_dp[i - 1] // a[i - 1] 
    y = stock_dp[i - 1][0] // a[i - 1] + stock_dp[i - 1][1]
    rx = value_dp[i - 1] % a[i - 1]
    ry = stock_dp[i - 1][0] % a[i - 1]
    if x > y:
        stock_dp[i][0] = rx
        stock_dp[i][1] = x
    elif x < y:
        stock_dp[i][0] = ry
        stock_dp[i][1] = y
    else:
        stock_dp[i][0] = max(rx, ry)
        stock_dp[i][1] = x
print(value_dp[n])

Buggy submission (verdict: Runtime Error):
 n = int(input())
 a = list(map(int, input().split()))
 stock = 0
 rest  = 0
 value = 1000
 for i in range(1, n + 1):
    value = max(value, stock * a[i - 1] + rest)
    stock = value // a[i - 1]
    rest = value % a[i - 1]
 print(value)
Problem p02767 (python)

Fixed submission:
n = int(input())
x_list = list(map(int, input().split()))
m = int(sum(x_list)/n + 0.5)
print(sum((x - m)**2 for x in x_list))

Buggy submission (verdict: Runtime Error):
from numpy import average
n = int(input())
x_list = list(map(int, input().split()))
m = int(average(x_list) + 0.5)
print(sum((x - m)**2 for x in x_list))
Problem p02787 (python)

Fixed submission:
h, n = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

dp = [h * 10 ** 4] * (h + 1)
dp[0] = 0
for i in range(n):
    for j in range(min(a[i], h+1)):
        dp[j] = min(dp[j], b[i])
    for j in range(a[i], h + 1):
        dp[j] = min(dp[j], dp[j - a[i]] + b[i])
print(dp[-1])

Buggy submission (verdict: Runtime Error):
h, n = map(int, input().split())
a = [0] * n
b = [0] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

dp = [h * 10 ** 4] * (h + 1)
dp[0] = 0
for i in range(n):
    for j in range(a[i]):
        dp[j] = min(dp[j], b[i])
    for j in range(a[i], h + 1):
        dp[j] = min(dp[j], dp[j - a[i]] + b[i])
print(dp[-1])
Problem p02957 (python)

Fixed submission:
a, b = map(int, input().split())
if (a + b) % 2 != 0:
  print("IMPOSSIBLE")
else:
  print((a + b) // 2)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if (a + b) % 2 != 0:
  print("IMPOSSIBLE")
elif:
  print((a + b) // 2)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if (a + b) % 2 != 0:
  print("IMPOSSIBLE")
elif:
  print((a + b) // 2)
Problem p02985 (python)

Fixed submission:
def factorial(n, mod):
    fac = [0] * (n + 1)
    inv = [0] * (n + 1)
    fac[0], inv[0] = 1, 1
    for i in range(1, n + 1):
        fac[i] = fac[i-1] * i % mod
        inv[i] = inverse(fac[i], mod)
    return fac, inv

def inverse(a, mod):
    a %= mod # 除数が正なら正になる
    p = mod
    x, y = 0, 1
    while a > 0:
        n = p // a
        p, a = a, p % a, 
        x, y = y, x - n * y
    return x % mod # 除数が正なら正になる

mod = 1000000007
n, k = map(int, input().split())
        
nodes = [[] for _ in range(n)]

branch_n = [0] * n
for i in range(n-1):
    a, b = map(lambda x : int(x) - 1, input().split())
    nodes[a].append(b)
    nodes[b].append(a)

if len(nodes[0]) >= k:
    print(0)
    quit()
stack = nodes[0][:]
visited = {0}
fac, inv = factorial(k, mod)
ans = fac[k] * inv[k-len(nodes[0])-1] % mod
while stack:
    i = stack.pop()
    visited.add(i)
    m = len(nodes[i])
    if m >= k:
        print(0)
        quit()
    ans = ans * fac[k-2] % mod * inv[k-1-m] % mod
    for j in nodes[i]:
        if not j in visited:
            stack.append(j)
print(ans)

Buggy submission (verdict: Runtime Error):
import networkx

def factorial(n, mod):
    fac = [0] * (n + 1)
    inv = [0] * (n + 1)
    fac[0], inv[0] = 1, 1
    for i in range(1, n + 1):
        fac[i] = fac[i-1] * i % mod
        inv[i] = inverse(fac[i], mod)
    return fac, inv

def inverse(a, mod):
    a %= mod # 除数が正なら正になる
    p = mod
    x, y = 0, 1
    while a > 0:
        n = p // a
        p, a = a, p % a, 
        x, y = y, x - n * y
    return x % mod # 除数が正なら正になる

mod = 1000000007

n, k = map(int, input().split())
graph = networkx.Graph()
graph.add_nodes_from(range(n))
for _ in range(n-1):
    a, b = map(lambda x : int(x) - 1, input().split())
    graph.add_edge(a, b)

fac, inv = factorial(k, mod)
ans = fac[k] * inv[k - networkx.degree(graph)[0] - 1] % mod # nx.degree(graph)[0]:グラフの頂点0から出ている枝の数
for parent, child in networkx.dfs_edges(graph, 0): # nx.dfs_edges(graph, 0):グラフの頂点0からDFS
    ans = ans * fac[k-2] % mod * inv[k-1-networkx.degree(graph)[child]] % mod
print(ans)
Problem p02995 (python)

Fixed submission:
import math

a, b, c, d = map(int, input().split())
a = a - 1

cd = c * d // math.gcd(c, d)

b_n = b // c + b // d - b // cd
a_n = a // c + a // d - a // cd
print((b - b_n) - (a - a_n))

Buggy submission (verdict: Runtime Error):
import numpy

a, b, c, d = map(int, input().split())
a = a - 1

cd = c * d // numpy.gcd(c, d)

b_n = b // c + b // d - b // cd
a_n = a // c + a // d - a // cd
print((b - b_n) - (a - a_n))