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

Fixed submission:
n = int(input())
p = list(map(int, input().split()))
index_list = []
value_list = []
for i in range(1, n+1):
  if i != p[i-1]:
    index_list.append(i)
    value_list.append(p[i-1])
if len(index_list) == 0:
  print("YES")
elif len(index_list) == 2 and value_list[0] == index_list[1] and value_list[1] == index_list[0]:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
n = int(input())
p = list(map(int, input().split()))
index_list = []
value_list = []
for i in range(1, n+1):
  if i != p[i-1]:
    index_list.append(i)
    value_list.append(p[i-1])
if len(index_list) == 0:
  print("YES")
elif len(index_list) == 2 and value_list[0] == index_list[1] and value_list[1] == index_list[0]:
  print("YES")
else:
  print("NO"
Problem p02981 (python)

Fixed submission:
N, A, B = map(int, input().split())
if N*A > B:
  print(B)
else:
  print(N*A)

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
if N*A > B:
  print(B)
else:
  print(N*A
Problem p03048 (python)

Fixed submission:
R, G, B, N = map(int, input().split())
count = 0
for r in range(0, N+1, R):
  for g in range(0, N+1-r, G):
    val = (N - r - g)
    if val % B == 0 and val >= 0:
      count += 1
print(count)

Buggy submission (verdict: Runtime Error):
str_dict = [0, 0, 0] 
val1 = 0
for i in range(int(input())):
  line = input()
  val1 += line.count('AB')
  if line[0] == 'B' and line[-1] == 'A':
    str_dict[2] += 1
  elif line[0] == 'B':
    str_dict[0] += 1
  elif line[-1] == 'A':
    str_dict[1] += 1
# if str_dict[2] == 0:
#   print(val1+min(str_dict[0], str_dict[1]))
# else:
#   if str_dict[0]+str_dict[1] > 0:
#     print(val1+str_dict[2]+min(str_dict[0], str_dict[1]))
#   else:
#     print(val1+str_dict[2]-1)
val2 = min(str_dict[0], str_dict[1])
tmp = max(str_dict[0]-val2, str_dict[1]-val2)
val3 = min(tmp, str_dict[2])
val4 = str_dict[2]-val3
if val3 == 0:
  val4 -= 1
print(val1+val2+val3+val4)

Buggy submission (verdict: Runtime Error):
R, G, B, N = map(int, input().split())
count = 0
for r in range(0, N+1, R):
  for g in range(0, N+1 - r, G):
    val = (N - r - g)
    if val % B == 0 and val >= 0:
      count += 1
print(count
Problem p03049 (python)

Fixed submission:
str_dict = [0, 0, 0] 
val1 = 0
for i in range(int(input())):
  line = input()
  val1 += line.count('AB')
  if line[0] == 'B' and line[-1] == 'A':
    str_dict[2] += 1
  elif line[0] == 'B':
    str_dict[0] += 1
  elif line[-1] == 'A':
    str_dict[1] += 1
if str_dict[2] == 0:
  print(val1+min(str_dict[0], str_dict[1]))
else:
  if str_dict[0]+str_dict[1] > 0:
    print(val1+str_dict[2]+min(str_dict[0], str_dict[1]))
  else:
    print(val1+str_dict[2]-1)

Buggy submission (verdict: Runtime Error):
str_dict = [0, 0, 0] 
val1 = 0
for i in range(int(input())):
  line = input()
  val1 += line.count('AB')
  if line[0] == 'B' and line[-1] == 'A':
    str_dict[2] += 1
  elif line[0] == 'B':
    str_dict[0] += 1
  elif line[-1] == 'A':
    str_dict[1] += 1
val2 = min(str_dict[0], str_dict[1])
tmp = max(str_dict[0]-val2, str_dict[1]-val2)
val3 = min(tmp, str_dict[2])
val4 = str_dict[2]-val3
if val4 % 2 == 1:
  val4 -= 1
print(val1+val2+val3+val4
Problem p03060 (python)

Fixed submission:
n = int(input())
v = map(int, input().split())
c = map(int, input().split())
max_val = 0
for _v, _c in zip(v, c):
  if _v - _c > 0:
    max_val += _v - _c
print(max_val)

Buggy submission (verdict: Runtime Error):
n = int(input())
v = map(int, input().split())
c = map(int, input().split())
max_val = 0
for _v, _c in zip(v, c):
  if _v - _c > 0:
    max_val += _v - _c
print(max_val
Problem p03160 (python)

Fixed submission:
import sys

inf = sys.maxsize

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

# DPテーブルの初期化(最小問題なのでINFで初期化
dp = [inf] * N

# 初期条件
dp[0] = 0


def chmin(a, b, diff):
    if dp[a] > dp[b]+diff:
        dp[a] = dp[b]+diff
        return True
    return False

# 普通のDP
for i in range(1, N):
    chmin(i, i-1, abs(heights[i]-heights[i-1]))
    if i > 1:
        chmin(i, i-2, abs(heights[i]-heights[i-2]))
print(dp[N-1])


# # メモ化再帰
# def chmin(a, b):
#     if a > b:
#         a = b
#     return a
#
#
# def rec(i):
#     if dp[i] < inf:
#         return dp[i]
#     if i == 0:
#         return 0
#     res = inf
#     res = chmin(res, rec(i-1)+abs(heights[i]-heights[i-1]))
#     if i > 1:
#         res = chmin(res, rec(i-2)+abs(heights[i]-heights[i-2]))
#     dp[i] = res
#     return dp[i]
#
#
# print(rec(N-1))

Buggy submission (verdict: Runtime Error):
import sys

inf = sys.maxsize
N, K = map(int, input().split())
heights = list(map(int, input().split()))

dp = [inf]*N
dp[0] = 0


def chmin(a, b, diff):
    if dp[a] > dp[b] + diff:
        dp[a] = dp[b] + diff
    return


for i in range(N):
    for j in range(1, K+1):
        if i-j >= 0:
            chmin(i, i-j, abs(heights[i]-heights[i-j]))

print(dp[N-1])

Buggy submission (verdict: Runtime Error):
import sys

inf = sys.maxsize

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

# DPテーブルの初期化(最小問題なのでINFで初期化
dp = [inf] * N

# 初期条件
dp[0] = 0


# def chmin(a, b, diff):
#     if dp[a] > dp[b]+diff:
#         dp[a] = dp[b]+diff
#         return True
#     return False

# # 普通のDP
# for i in range(1, N):
#     chmin(i, i-1, abs(heights[i]-heights[i-1]))
#     if i > 1:
#         chmin(i, i-2, abs(heights[i]-heights[i-2]))
# print(dp[N-1])


# メモ化再帰
def chmin(a, b):
    if a > b:
        a = b
    return a


def rec(i):
    if dp[i] < inf:
        return dp[i]
    if i == 0:
        return 0
    res = inf
    res = chmin(res, rec(i-1)+abs(heights[i]-heights[i-1]))
    if i > 1:
        res = chmin(res, rec(i-2)+abs(heights[i]-heights[i-2]))
    dp[i] = res
    return dp[i]


print(rec(N-1))
Problem p03436 (python)

Fixed submission:
from collections import deque
import copy

H, W = map(int, input().split())
s=(0,0)
g=(H-1,W-1)
maze = [list(input()) for line in range(H)]
copied_maze = copy.deepcopy(maze)

def search(x, y):
  dq = deque()
  dq.append([x, y])
  copied_maze[x][y] = 0
  while len(dq) > 0:
    x,y = dq.popleft()
    if x==g[0] and y==g[1]:
      break
    for dx, dy in [[1,0], [0,1], [-1,0], [0,-1]]:
      nx,ny=[x+dx,y+dy]
      if 0 <= nx < H and 0 <= ny < W and copied_maze[nx][ny] != '#' and type(copied_maze[nx][ny]) is str:
        dq.append([nx,ny])
        copied_maze[nx][ny] = copied_maze[x][y]+1
search(s[0],s[1])
x,y=g
cost = copied_maze[g[0]][g[1]]
if type(cost) is str:
  print(-1)
  exit()
path = {s, g}
for i in range(copied_maze[g[0]][g[1]]):
  for dx, dy in [[1,0], [0,1], [-1,0], [0,-1]]:
    nx,ny=[x+dx,y+dy]
    if 0 <= nx < H and 0 <= ny < W and copied_maze[nx][ny] == cost - 1:
      path.add((nx,ny))
      x,y=nx,ny
      cost -= 1
      break
count = 0
for i in range(H):
  for j in range(W):
    if maze[i][j] == '.' and (i, j) not in path:
      count += 1
print(count)

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

H, W = map(int, input().split())
s=(0,0)
g=(H-1,W-1)
maze = [list(input()) for line in range(H)]
copied_maze = copy.deepcopy(maze)

def search(x, y):
  dq = deque()
  dq.append([x, y])
  copied_maze[x][y] = 0
  while len(dq) > 0:
    x,y = dq.popleft()
    if x==g[0] and y==g[1]:
      break
    for dx, dy in [[1,0], [0,1], [-1,0], [0,-1]]:
      nx,ny=[x+dx,y+dy]
      if 0 <= nx < H and 0 <= ny < W and copied_maze[nx][ny] != '#' and type(copied_maze[nx][ny]) is str:
        dq.append([nx,ny])
        copied_maze[nx][ny] = copied_maze[x][y]+1
search(s[0],s[1])
x,y=g
cost = copied_maze[g[0]][g[1]]
path = {s, g}
for i in range(copied_maze[g[0]][g[1]]):
  for dx, dy in [[1,0], [0,1], [-1,0], [0,-1]]:
    nx,ny=[x+dx,y+dy]
    if 0 <= nx < H and 0 <= ny < W and copied_maze[nx][ny] == cost - 1:
      path.add((nx,ny))
      x,y=nx,ny
      cost -= 1
      break
count = 0
for i in range(H):
  for j in range(W):
    if maze[i][j] == '.' and (i, j) not in path:
      count += 1
print(count)
Problem p03471 (python)

Fixed submission:
n, y = map(int, input().split())
found = False
for i in range(n+1):
  for j in range(n+1-i):
    if i + j+ (n-i-j) == n and 10000*i+5000*j+1000*(n-i-j) == y:
        print(i, j, n-i-j)
        found = True
        break
  else:
    continue
  break 
if not found:
  print("-1 -1 -1")

Buggy submission (verdict: Runtime Error):
N, Y = map(int, input().split())
out_x = out_y = out_z = -1
for x in range(N+1):
  for y in range(N+1):
    price = x * 10000 + y * 5000
    if price > Y:
      break
    price = price + (N-x-y) * 1000
    if price == Y:
      out_x = x
      out_y = y
      out_z = N-x-y
      break
  if out_x != -1:
    break
print(f"{out_x} {out_y} {out_z}")
Problem p03493 (python)

Fixed submission:
ret = list(filter(lambda x: x==1, map(int, list(input()))))
print(len(ret))

Buggy submission (verdict: Runtime Error):
n=int(input())
data=list(map(int, input().split()))
count = 0
while(True):
  data = list(filter(lambda x: x%2==0, data))
  if len(data) < n:
    print(count)
    break
  else:
    count+=1
Problem p02981 (python)

Fixed submission:
n,a,b = map(int,input().split())
if a*n < b:
  print(a*n)
else:
  print(b)

Buggy submission (verdict: Runtime Error):
a,b,c = linst(map(int,input()))
if a*b < c:
  print(a*b)
else:
  print(c)
Problem p03101 (python)

Fixed submission:
H, W = list(map(int, input().split()))
h, w = list(map(int, input().split()))

white = H*W
black = h*W + w*(H-h)

print(white-black)

Buggy submission (verdict: Runtime Error):
H, W = list(map(int, input().split()))
h, w = list(map(int, input().split()))

white = H*W
if h 
black = h*W + w*(H-h)

print(white-black)
Problem p03102 (python)

Fixed submission:
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]
cnt = 0
for x in A:
  total = sum([x[i]*B[i] for i in range(M)])
  total += C
  if total > 0:
    cnt+= 1
    
print(cnt)

Buggy submission (verdict: Runtime Error):
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]
cnt = 0
for x in A:
  total = sum([A[i]*B[i] for i in range(M)])
  total += C
  if total > 0:
    cnt+= 1
    
print(cnt)
Problem p03220 (python)

Fixed submission:
n = int(input())
t,a = list(map(int,input().split()))
h = list(map(int, input().split()))
ans = 1000000000
okok = 0

for i in range(0,n):
  if(ans > abs(a-(t-h[i]*0.006))):
    ans = abs(a-(t-h[i]*0.006))
    okok = i+1

print(okok)

Buggy submission (verdict: Runtime Error):
import math


n = int(input())
t,a = list(map(int,input().split()))
h = list(map(int, input().split()))
ans = math.inf
okok = 0
for i in range(0,n):
  if(ans > abs(a-t-h[i]*0.006)):
    ans = abs(a-t-h[i]*0.006)
    okok = i+1

print(okok)

Buggy submission (verdict: Runtime Error):
import math


n = int(input())
t,a = list(map(int,input().split()))
h = list(map(int, input().split()))
ans = math.inf
okok = 0
for i in range(0,n):
  if(ans > abs(a-t-h[i]*0.006)):
    ans = abs(a-t-h[i]*0.006)
    okok = i+1

print(okok)
Problem p03239 (python)

Fixed submission:
n, t = list(map(int,input().split()))
list1 = []
list2 = []
for i in range(0,n):
  list1.append(list(map(int, input().split())))

for i in list1:
  if int(i[1]) <= t:
    list2.append(i)

if(list2):
  list2.sort()
  print(list2[0][0])
else:
  print("TLE")

Buggy submission (verdict: Runtime Error):
n, t = list(map(int,input().split()))
list1 = []
list2 = []
for i in range(0,int(n)):
  list1.append(list(map(int, input().split())))

for i in list1:
  if int(i[1]) <= int(t):
    list2.append(i)

list2.sort()
print(list2[0][0])
Problem p03047 (python)

Fixed submission:
n,k = [int(u) for u in input().split(" ")]
print(n-k+1)

Buggy submission (verdict: Runtime Error):
import math
r,g,b,n = [int(u) for u in input().split(" ")]
i = 0
for ir in range(math.floor(n/r)+1):
  if ir*r>n:
    break
  for ig in range(math.floor(n/g)+1):
    if ig*g>n:
      break
    y = n- (ir*r+ig*g)
    if y<0:
      break
    if y>=0 and y%b==0:
      #print(ir,ig,y/b)
      i+=1
print(i)
Problem p02903 (python)

Fixed submission:
h,w,a,b=map(int,input().split())
for _ in [0]*b:
    print('0'*a+'1'*(w-a))
for _ in [0]*(h-b):
    print('1'*a+'0'*(w-a))

Buggy submission (verdict: Runtime Error):
h,w,a,b=map(int,input().split())
if h==1:
    print('0'*a+'1'*(w-a))
elif w==1:
    for _ in [0]*b:
        print(0)
    for _ in [0]*(h-b):
        print(1)
elif h%b!=0 or w%a!=0 or h//b!=w//a:
    print('No')
else:
    ans=[[0]*w for _ in [0]*h]
    for i in range(h):
        for j in range(a*(i//b),a*(i//b)+a):
            ans[i][j]=1
    for x in ans:
        print(*x,sep='')

Buggy submission (verdict: Runtime Error):
h,w,a,b=map(int,input().split())
if h==1:
    print('0'*a+'1'*(w-a))
elif w==1:
    for _ in [0]*a:
        print(0)
    for _ in [0]*(n-a):
        print(1)
elif h%a!=0 or w%b!=0 or h//a!=w//b:
    print('No')
else:
    ans=[[0]*w for _ in [0]*h]
    for i in range(h):
        for j in range(b*(i//a),b*(i//a)+b):
            ans[i][j]=1
    for x in ans:
        print(*x,sep='')
Problem p02969 (python)

Fixed submission:
print(3*int(input())**2)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def sol():
    n=int(input())
    new=[int(input()) for _ in [0]*n]
    a=[new[0]]
    for i in range(1,n):
        if a[-1]>=new[i]:a.append(new[i])
        else:
            for j in range(len(a)):
                if a[j]<new[i]:a[j]=new[i];break
    print(len(a))
sol()
Problem p03160 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
d=[0]*n
d[1]=abs(h[1]-h[0])
for i in range(2,n):
    d[i]=min(d[i-1]+abs(h[i]-h[i-1]),d[i-2]+abs(h[i]-h[i-2]))
print(d[n-1])

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
d=[float('inf')]*n
d[0]=0
for i in range(n-1):
    for j in range(1,min(k+1,n-i)):
        d[i+j]=min(d[i+j],d[i]+abs(h[i+j]-h[i]))
print(d[-1])
Problem p03338 (python)

Fixed submission:
n=int(input())
s=input()
print(max(len(set(s[:i])&set(s[i:])) for i in range(1,n)))

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
print(max(len(set(s[:i])&set(s[i:])) for i in range(1,n-1)))
Problem p03353 (python)

Fixed submission:
s=input()
n=len(s)
k=int(input())
l=[]
for i in range(1,6):
    if n>=i:l=l+[s[j:j+i] for j in range(n-i+1)]
print(sorted(list(set(l)))[k-1])

Buggy submission (verdict: Runtime Error):
s=input()
print(sorted(list(set([s[i:j] for i in range(len(s)) for j in range(i+1,len(s)+1)])))[int(input())-1])
Problem p03436 (python)

Fixed submission:
import sys
sys.setrecursionlimit(3000)
h,w=map(int,input().split())
s=['#'*(w+2)]+['#'+input()+'#' for _ in [0]*h]+['#'*(w+2)]
l=[[0]*(w+2) for _ in [0]*(h+2)]
for i in range(h+2):
    for j in range(w+2):
        if s[i][j]=='#':
            l[i][j]=-1
def sol(m,n):
    global l
    if l[m][n]>=0:
        for i,j in [(m-1,n),(m+1,n),(m,n-1),(m,n+1)]:
            if l[i][j]==0 and [i,j]!=[1,1]:
                l[i][j]=l[m][n]+1
                sol(i,j)
            elif l[i][j]>l[m][n]+1:
                l[i][j]=l[m][n]+1
                sol(i,j)
sol(1,1)
if l[h][w]==0:print(-1)
else:print(h*w-l[h][w]-(sum(x.count('#') for x in s)-2*h-2*w-4)-1)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2000)
h,w=map(int,input().split())
s=['#'*(w+2)]+['#'+input()+'#' for _ in [0]*h]+['#'*(w+2)]
l=[[0]*(w+2) for _ in [0]*(h+2)]
for i in range(h+2):
    for j in range(w+2):
        if s[i][j]=='#':
            l[i][j]=-1
def sol(m,n):
    global l
    if l[m][n]>=0:
        for [i,j] in [[m-1,n],[m+1,n],[m,n-1],[m,n+1]]:
            if l[i][j]==0 and [i,j]!=[1,1]:
                l[i][j]=l[m][n]+1
                sol(i,j)
            elif l[i][j]>l[m][n]+1:
                l[i][j]=l[m][n]+1
                sol(i,j)
sol(1,1)
if l[h][w]==0:print(-1)
else:print(h*w-l[h][w]-(sum(x.count('#') for x in s)-2*h-2*w-4)-1)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
s=['#'*(w+2)]+['#'+input()+'#' for _ in [0]*h]+['#'*(w+2)]
l=[[0]*(w+2) for _ in [0]*(h+2)]
for i in range(h+2):
    for j in range(w+2):
        if s[i][j]=='#':
            l[i][j]=-1
def sol(m,n):
    global l
    if l[m][n]>=0:
        for [i,j] in [[m-1,n],[m+1,n],[m,n-1],[m,n+1]]:
            if l[i][j]==0 and [i,j]!=[1,1]:
                l[i][j]=l[m][n]+1
                sol(i,j)
            elif l[i][j]>l[m][n]+1:
                l[i][j]=l[m][n]+1
                sol(i,j)
sol(1,1)
if l[h][w]==0:print(-1)
else:print(h*w-l[h][w]-(sum(x.count('#') for x in s)-2*h-2*w-4)-1)

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
s=['#'*(w+2)]+['#'+input()+'#' for _ in [0]*h]+['#'*(w+2)]
l=[[0]*(w+2) for _ in [0]*(h+2)]
for i in range(h+2):
    for j in range(w+2):
        if s[i][j]=='#':
            l[i][j]=-1
def sol(m,n):
    global l
    if l[m][n]>=0:
        for [i,j] in [[m-1,n],[m+1,n],[m,n-1],[m,n+1]]:
            if l[i][j]==0 and [i,j]!=[1,1]:
                l[i][j]=l[m][n]+1
                sol(i,j)
            elif l[i][j]>l[m][n]+1:
                l[i][j]=l[m][n]+1
                sol(i,j)
sol(1,1)
print(h*w-l[h][w]-(sum(x.count('#') for x in s)-2*h-2*w-4)-1)
Problem p03450 (python)

Fixed submission:
def solve():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    INF=float('inf')
    n,m=map(int,input().split())
    l=[list(map(int,input().split())) for _ in range(m)]
    d=[INF]*n
    nbr=[[] for _ in range(n)]
    used=[False]*m
    for x in l:
        x[0]-=1
        x[1]-=1
    #print(l)
    for i in range(m):
        nbr[l[i][0]].append(i)
        nbr[l[i][1]].append(i)
    #print(nbr)
    def sol(i):
        for x in nbr[i]:
            if used[x]:continue
            used[x]=True
            i1=l[x][0]^l[x][1]^i
            dd=d[i]+l[x][2]*(2*(l[x][0]==i)-1)
            if d[i1]!=dd and d[i1]!=INF:
                print('No')
                exit()
            elif d[i1]==INF:
                d[i1]=dd
                sol(i1)
    for i in range(n):
        if d[i]==INF:
            d[i]=0
            sol(i)
    #print(d)
    print('Yes')
solve()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2000)
INF=float('inf')
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
d=[INF]*n
nbr=[[] for _ in range(n)]
used=[False]*m
for x in l:
    x[0]-=1
    x[1]-=1
#print(l)
for i in range(m):
    nbr[l[i][0]].append(i)
    nbr[l[i][1]].append(i)
#print(nbr)
def sol(i):
    if d[i]==INF:
        d[i]=0
    for x in nbr[i]:
        if used[x]:continue
        used[x]=True
        if l[x][0]==i:
            if d[l[x][1]]==INF:
                d[l[x][1]]=d[i]+l[x][2]
            elif d[l[x][1]]!=d[i]+l[x][2]:
                print('No')
                exit()
            sol(l[x][1])
        else:
            if d[l[x][0]]==INF:
                d[l[x][0]]=d[i]-l[x][2]
            elif d[l[x][0]]!=d[i]-l[x][2]:
                print('No')
                exit()
            sol(l[x][0])
for i in range(n):
    sol(i)
#print(d)
print('Yes')

Buggy submission (verdict: Runtime Error):
INF=float('inf')
n,m=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(m)]
d=[INF]*n
nbr=[[] for _ in range(n)]
used=[False]*m
for x in l:
    x[0]-=1
    x[1]-=1
#print(l)
for i in range(m):
    nbr[l[i][0]].append(i)
    nbr[l[i][1]].append(i)
#print(nbr)
def sol(i):
    if d[i]==INF:
        d[i]=0
    for x in nbr[i]:
        if used[x]:continue
        used[x]=True
        if l[x][0]==i:
            if d[l[x][1]]==INF:
                d[l[x][1]]=d[i]+l[x][2]
            elif d[l[x][1]]!=d[i]+l[x][2]:
                print('No')
                exit()
            sol(l[x][1])
        else:
            if d[l[x][0]]==INF:
                d[l[x][0]]=d[i]-l[x][2]
            elif d[l[x][0]]!=d[i]-l[x][2]:
                print('No')
                exit()
            sol(l[x][0])
for i in range(n):
    sol(i)
#print(d)
print('Yes')
Problem p03476 (python)

Fixed submission:
import sys
input = sys.stdin.readline

n=10**5
sievebd=n//2
sieve=[True]*sievebd
limit=int(n**.5)//2
sieve[0]=0
for i in range(limit):
    if sieve[i]:
        for j in range(2*i*(i+1),sievebd,2*i+1):
            sieve[j]=False
for i in range((sievebd-1)//2,0,-1):
    if not sieve[i]:sieve[2*i]=False
for i in range(3,sievebd,2):sieve[i]=False
for i in range(1,sievebd):sieve[i]+=sieve[i-1]
q=int(input())
l=[list(map(int,input().split())) for _ in [0]*q]
for i in range(q):
    print(sieve[(l[i][1]-1)//2]-sieve[max(0,(l[i][0]-1)//2-1)])

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

n=10**5
sievebd=n//2-1
sieve=[True]*sievebd
limit=(int((n-1)**.5)-1)//2
for i in range(limit):
    if sieve[i]:
        for j in range(2*i**2+6*i+3,sievebd,2*i+3):
            sieve[j]=False
for i in range((sievebd-1)//2-1,-1,-1):
    if not sieve[i]:sieve[2*i+1]=False
for i in range(2,sievebd,2):
    sieve[i]=False

sieve[0]=1
for i in range(1,sievebd):
    sieve[i]+=sieve[i-1]

q=int(input())
l=[0]*q
r=[0]*q
for i in range(q):
    l[i],r[i]=map(int,input().split())

for i in range(q):
    print(sieve[max(1,(r[i]-3)//2+1)]-sieve[max(0,(l[i]-3)//2)])
Problem p03633 (python)

Fixed submission:
import fractions
n=int(input())
t=[int(input()) for _ in [0]*n]

d=t[0]
for i in range(1,n):
    d=(t[i]*d)//fractions.gcd(t[i],d)
print(d)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
t=[int(input()) for _ in [0]*n]

d=t[0]
for i in range(1,n):
    d=(t[i]*d)//math.gcd(t[i],d)
print(d)

Buggy submission (verdict: Runtime Error):
import math
n=int(input())
t=[int(input()) for _ in [0]*n]

d=t[0]
print(d)
for i in range(1,n):
    d=(t[i]*d)//math.gcd(t[i],d)
    print(d)
Problem p03732 (python)

Fixed submission:
n,w=map(int,input().split())
l=[list(map(int,input().split())) for _ in [0]*n]
l1,l2,l3,l4=[],[],[],[]
a=l[0][0]
for i in range(n):
    if l[i][0]==a:
        l1.append(l[i][1])
    elif l[i][0]==a+1:
        l2.append(l[i][1])
    elif l[i][0]==a+2:
        l3.append(l[i][1])
    else:
        l4.append(l[i][1])
l1.sort(reverse=True)
l2.sort(reverse=True)
l3.sort(reverse=True)
l4.sort(reverse=True)
ans=0
for h in range(len(l1)+1):
    for i in range(len(l2)+1):
        for j in range(len(l3)+1):
            for k in range(len(l4)+1):
                if a*h+(a+1)*i+(a+2)*j+(a+3)*k<=w:
                    ans=max(ans,sum(l1[:h])+sum(l2[:i])+sum(l3[:j])+sum(l4[:k]))
print(ans)

Buggy submission (verdict: Runtime Error):
n,W=map(int,input().split())
dp=[0]*(W+1)
for _ in [0]*n:
    w,v=map(int,input().split())
    for i in range(W,w-1,-1):
        dp[i]=max(dp[i],dp[i-w]+v)
print(dp[-1])
Problem p03826 (python)

Fixed submission:
a,b,c,d=map(int,input().split())
print(max([a*b,c*d]))

Buggy submission (verdict: Runtime Error):
a,b,c,d=map(int,open(0))
print(max([a*b,c*d]))