Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
X, Y = map(int, input().split())

# 最終状態は(0,1), (1,1)のいずれか
# 最終状態の1手前は勝ち確状態、その1手前は負け確状態
# 1手前に戻すには片方の山からi個石を取り、もう片方の山に2i個加える
# 1手前に戻しつつ山の状態を列挙して、与えられた状態を探索する
# ただし、石の個数の合計が与えられた石の個数の合計を超えたら探索を打ち切る

# 山の状態を再帰的に探索する
def recur_search(x,y,Alice_win_flg):
    if x+y > X+Y or x < 0 or y < 0:
        return
    elif [x, y] in done_memo and Alice_win_flg == 0:
        return
    elif [x,y] == [X,Y] or [x,y] == [Y,X]:
        # 1つでも勝ちパターンがあるなら先手Aliceの勝利
        if Alice_win_flg == 1:
            print("Alice")
            exit()
        else:
            done_memo.append([x, y])
            done_memo.append([y, x])
            return
    else:
        for i in range(1, x+1):
            recur_search(x-i, y+2*i, 1^Alice_win_flg)
            recur_search(y+2*i, x-i, 1^Alice_win_flg)

done_memo = []
recur_search(1,0,0)
recur_search(1,1,0)
print("Brown")

Fixed submission:
X, Y = map(int, input().split())
print("Alice" if abs(X-Y)>=2 else "Brown")

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

# 最終状態は(0,1), (1,1)のいずれか
# 最終状態の1手前は勝ち確状態、その1手前は負け確状態
# 1手前に戻すには片方の山からi個石を取り、もう片方の山に2i個加える
# 1手前に戻しつつ山の状態を列挙して、与えられた状態を探索する
# ただし、石の個数の合計が与えられた石の個数の合計を超えたら探索を打ち切る

# 山の状態を再帰的に探索する
def recur_search(x,y,Alice_win_flg):
    if x+y > X+Y or x < 0 or y < 0:
        return
    elif [x, y] in done_memo and Alice_win_flg == 0:
        return
    elif [x,y] == [X,Y] or [x,y] == [Y,X]:
        # 1つでも勝ちパターンがあるなら先手Aliceの勝利
        if Alice_win_flg == 1:
            print("Alice")
            exit()
        else:
            done_memo.append([x, y])
            done_memo.append([y, x])
            return
    else:
        for i in range(1, x+1):
            recur_search(x-i, y+2*i, 1^Alice_win_flg)
            recur_search(y+2*i, x-i, 1^Alice_win_flg)

done_memo = []
recur_search(1,0,0)
recur_search(1,1,0)
print("Brown")

Fixed submission:
X, Y = map(int, input().split())
print("Alice" if abs(X-Y)>=2 else "Brown")

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

# 最終状態は(0,1), (1,1)のいずれか
# 最終状態の1手前は勝ち確状態、その1手前は負け確状態
# 1手前に戻すには片方の山からi個石を取り、もう片方の山に2i個加える
# 1手前に戻しつつ山の状態を列挙して、与えられた状態を探索する
# ただし、石の個数の合計が与えられた石の個数の合計を超えたら探索を打ち切る

# 山の状態を探索し、与えられた状態と一致したらフラグを保存する
def recur_search(x,y,Alice_win_flg):
    if [x,y] == [X,Y] or [x,y] == [Y,X]:
        Alice_win_flg_list.append(Alice_win_flg)
        return
    elif x+y > X+Y or x < 0 or y < 0:
        return
    else:
        for i in range(1, x+1):
            recur_search(x-i, y+2*i, 1^Alice_win_flg)
            recur_search(y+2*i, x-i, 1^Alice_win_flg)

Alice_win_flg_list = []
recur_search(1,0,0)
recur_search(1,1,0)

# 1つでもAlice勝ちパターンがあるなら先手のAliceの勝ち
print("Alice" if sum(Alice_win_flg_list) > 0 else "Brown")

Fixed submission:
X, Y = map(int, input().split())
print("Alice" if abs(X-Y)>=2 else "Brown")
Buggy python submission (verdict: Runtime Error):
# B - Buildings are Colorful!

import sys
input = sys.stdin.buffer.readline

import itertools

N, K = map(int, input().split())
original_a = list(map(int, input().split()))

if K == 1:
    print(0)
    exit()

ans = float("inf")
for visible_building_indices in list(itertools.combinations(list(range(N)), K)):
    a = original_a.copy()
    tmp = 0

    for i in range(visible_building_indices[0]):
        if a[i] >= a[visible_building_indices[i]]:
            tmp += a[i] - a[visible_building_indices[i]] + 1

    for i in range(len(visible_building_indices)-1):
        if a[visible_building_indices[i]] >= a[visible_building_indices[i+1]]:
            tmp += a[visible_building_indices[i]] - a[visible_building_indices[i+1]] + 1
            a[visible_building_indices[i+1]] = a[visible_building_indices[i]] + 1

    ans = min(ans, tmp)

print(ans)

Fixed submission:
# B - Buildings are Colorful!

import sys
input = sys.stdin.buffer.readline

import itertools

N, K = map(int, input().split())
original_a = list(map(int, input().split()))

if K == 1:
    print(0)
    exit()

ans = float("inf")
for visible_building_indices in list(itertools.combinations(list(range(N)), K)):
    a = original_a.copy()
    tmp = 0

    for i in range(len(visible_building_indices)):
        try:
            h = max([a[i] for i in range(visible_building_indices[i])])
        except:
            h = 0
        if h >= a[visible_building_indices[i]]:
            tmp += h - a[visible_building_indices[i]] + 1
            a[visible_building_indices[i]] = h + 1

    ans = min(ans, tmp)

print(ans)
Buggy python submission (verdict: Runtime Error):
S_input = str(input())
add_str_tuple = ("dream", "dreamer", "erase", "eraser")

def recur_add(T):
    if T == S_input:
        print("YES")
        exit()
    else:
        if S_input.startswith(T):
            for word in add_str_tuple:
                recur_add(T+word)
        else:
            return

recur_add("")
print("NO")

Fixed submission:
import re
print("YES" if re.match("^(dream|dreamer|erase|eraser)+$", input()) else "NO")

Buggy python submission (verdict: Runtime Error):
S_input = str(input())
add_str_taple = ("dream", "dreamer", "erase", "eraser")

def recur_add(T):
    if T == S_input:
        print("YES")
        exit()
    elif len(T) < len(S_input):
        if S_input.startswith(T):
            for word in add_str_taple:
                recur_add(T+word)
        else:
            return
    else:
        return

recur_add("")
print("NO")

Fixed submission:
import re
print("YES" if re.match("^(dream|dreamer|erase|eraser)+$", input()) else "NO")

Buggy python submission (verdict: Runtime Error):
S_input = str(input())
add_str_taple = ("dream", "dreamer", "erase", "eraser")

def recur_add(T):
    if T == S_input:
        print("YES")
        exit()
    else:
        if S_input.startswith(T):
            for word in add_str_taple:
                recur_add(T+word)
        else:
            return None

recur_add("")
print("NO")

Fixed submission:
import re
print("YES" if re.match("^(dream|dreamer|erase|eraser)+$", input()) else "NO")

Buggy python submission (verdict: Runtime Error):
S_input = str(input())
add_str_taple = ("dream", "dreamer", "erase", "eraser")

def recur_add(T):
    if T == S_input:
        print("YES")
        exit()
    else:
        if S_input.startswith(T):
            for word in add_str_taple:
                recur_add(T+word)
        else:
            return

recur_add("")
print("NO")

Fixed submission:
import re
print("YES" if re.match("^(dream|dreamer|erase|eraser)+$", input()) else "NO")

Buggy python submission (verdict: Runtime Error):
S_input = str(input())
add_str_taple = ("dream", "dreamer", "erase", "eraser")

def recur_add(T):
    if T == S_input:
        print("YES")
        exit()
    else:
        if S_input.startswith(T):
            for word in add_str_taple:
                recur_add(T+word)
        else:
            return

recur_add("")
print("NO")

Fixed submission:
import re
print("YES" if re.match("^(dream|dreamer|erase|eraser)+$", input()) else "NO")
Buggy python submission (verdict: Runtime Error):
# C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report

# 比がa:bとなる合計最小の票分布はa,b
# 次にc:dになったとき、a<=cかつb<=dとなるようにc,dに同じ数をかける

import math

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

a, b = TA[0]

for idx in range(1,N):
    c, d = TA[idx]
    multi = max(math.ceil(a/c), math.ceil(b/d))
    c *= multi
    d *= multi
    a,b = c,d
    
print(c+d)

Fixed submission:
# C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report

# 比がa:bとなる合計最小の票分布はa,b
# 次にc:dになったとき、a<=cかつb<=dとなるようにc,dに同じ数をかける

import math

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

a, b = TA[0]
c, d = a, b

for idx in range(1,N):
    c, d = TA[idx]
    multi = max((a+c-1)//c, (b+d-1)//d)
    c *= multi
    d *= multi
    a,b = c,d
    
print(c+d)

Buggy python submission (verdict: Time Limit Exceeded):
# C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report

# 比がa:bとなる合計最小の票分布はa,b
# 次にc:dになったとき、a<=cかつb<=dを満たすまでc,dを2倍、3倍、と増やしていく

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

a, b = TA[0]
ans = a + b

for idx in range(1,N):
    c, d = TA[idx]
    ori_c, ori_d = c, d
    while c < a or d < b:
        c += ori_c
        d += ori_d
    ans = c+d
    a,b = c,d
    
print(ans)

Fixed submission:
# C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report

# 比がa:bとなる合計最小の票分布はa,b
# 次にc:dになったとき、a<=cかつb<=dとなるようにc,dに同じ数をかける

import math

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

a, b = TA[0]
c, d = a, b

for idx in range(1,N):
    c, d = TA[idx]
    multi = max((a+c-1)//c, (b+d-1)//d)
    c *= multi
    d *= multi
    a,b = c,d
    
print(c+d)
Buggy python submission (verdict: Runtime Error):
def gcd(a, b) -> int:
  if(a < b):
    tmp = a
    a = b
    b = tmp
  if b == 0:
    return a
  return gcd(a % b, b)

def lcm(a, b) -> int:
  g = gcd(a, b)
  return int((a * b) / g)

N = int(input())
ans = int(1)
for i in range(N):
  t = int(input())
  ans = lcm(ans, t)
print(ans)

Fixed submission:
def gcd(a, b) -> int:
  if(a < b):
    tmp = a
    a = b
    b = tmp
  if b == 0:
    return a
  return gcd(a % b, b)

def lcm(a, b) -> int:
  g = gcd(a, b)
  return a * (b // g)

N = int(input())
ans = int(1)
for i in range(N):
  t = int(input())
  ans = lcm(ans, t)
print(ans)

Buggy python submission (verdict: Runtime Error):
def gcd(a, b) -> int:
  if(a < b):
    tmp = a
    a = b
    b = tmp
  if b == 0:
    return a
  return gcd(a % b, b)

def lcm(a, b) -> int:
  g = gcd(a, b)
  return int(a * b / g)

N = int(input())
ans = int(1)
for i in range(N):
  t = int(input())
  ans = lcm(ans, t)
print(ans)

Fixed submission:
def gcd(a, b) -> int:
  if(a < b):
    tmp = a
    a = b
    b = tmp
  if b == 0:
    return a
  return gcd(a % b, b)

def lcm(a, b) -> int:
  g = gcd(a, b)
  return a * (b // g)

N = int(input())
ans = int(1)
for i in range(N):
  t = int(input())
  ans = lcm(ans, t)
print(ans)

Buggy python submission (verdict: Runtime Error):
def gcd(a, b) -> int:
  if(a < b):
    tmp = a
    a = b
    b = tmp
  if b == 0:
    return a
  return gcd(a % b, b)

N = int(input())
ans = int(1)
for i in range(N):
  t = int(input())
  g = gcd(ans, t)
  ans = int(ans * (t / g))
print(ans)

Fixed submission:
def gcd(a, b) -> int:
  if(a < b):
    tmp = a
    a = b
    b = tmp
  if b == 0:
    return a
  return gcd(a % b, b)

def lcm(a, b) -> int:
  g = gcd(a, b)
  return a * (b // g)

N = int(input())
ans = int(1)
for i in range(N):
  t = int(input())
  ans = lcm(ans, t)
print(ans)

Buggy python submission (verdict: Runtime Error):
def gcd(a, b) -> int:
  if(a < b):
    tmp = a
    a = b
    b = tmp
  if b == 0:
    return a
  return gcd(a % b, b)

N = int(input())
ans = 1
for i in range(N):
  t = int(input())
  g = gcd(ans, t)
  ans = int(ans * (t / g))
print(ans)

Fixed submission:
def gcd(a, b) -> int:
  if(a < b):
    tmp = a
    a = b
    b = tmp
  if b == 0:
    return a
  return gcd(a % b, b)

def lcm(a, b) -> int:
  g = gcd(a, b)
  return a * (b // g)

N = int(input())
ans = int(1)
for i in range(N):
  t = int(input())
  ans = lcm(ans, t)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
g = [[] for x in range(N+1)]
for i in range(N - 1):
  (a, b, c) = map(int, input().split())
  g[a].append([b, c])
  g[b].append([a, c])

(Q, K) = map(int, input().split())
d = [-1] * (N+1)
d[K] = 0

def fill(i):
  for v in g[i]:
    if(d[v[0]] == -1):
      d[v[0]] = d[i] + v[1]
      fill(v[0])
  return
  
fill(K)

q = list()
for i in range(Q):
  q.append(input())
for i in range(Q):
  (x, y) = map(int, q[i].split())
  print(d[x] + d[y])


Fixed submission:
from collections import deque
N = int(input())
g = [[] for x in range(N+1)]
for i in range(N - 1):
  (a, b, c) = map(int, input().split())
  g[a].append([b, c])
  g[b].append([a, c])

(Q, K) = map(int, input().split())
d = [-1] * (N+1)
d[K] = 0
r = deque()

r.append(K)
while len(r) > 0:
  i = r.popleft()
  for v in g[i]:
    if(d[v[0]] == -1):
      d[v[0]] = d[i] + v[1]
      r.append(v[0])

q = list()
for i in range(Q):
  q.append(input())
for i in range(Q):
  (x, y) = map(int, q[i].split())
  print(d[x] + d[y])

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
g = [[0] * (N+1) for x in range(N+1)]
for i in range(N - 1):
  (a, b, c) = map(int, input().split())
  g[a][b] = g[b][a] = c

(Q, K) = map(int, input().split())
d = [-1] * (N+1)
d[K] = 0

def fill(i):
  if(d[i] == -1):
    return
  for j in range(1, N+1):
    if(g[i][j] != 0 and d[j] == -1):
      d[j] = d[i] + g[i][j]
      fill(j)
  return
  
fill(K)

q = list()
for i in range(Q):
  q.append(input())
for i in range(Q):
  (x, y) = map(int, q[i].split())
  print(d[x] + d[y])


Fixed submission:
from collections import deque
N = int(input())
g = [[] for x in range(N+1)]
for i in range(N - 1):
  (a, b, c) = map(int, input().split())
  g[a].append([b, c])
  g[b].append([a, c])

(Q, K) = map(int, input().split())
d = [-1] * (N+1)
d[K] = 0
r = deque()

r.append(K)
while len(r) > 0:
  i = r.popleft()
  for v in g[i]:
    if(d[v[0]] == -1):
      d[v[0]] = d[i] + v[1]
      r.append(v[0])

q = list()
for i in range(Q):
  q.append(input())
for i in range(Q):
  (x, y) = map(int, q[i].split())
  print(d[x] + d[y])
Buggy python submission (verdict: Runtime Error):
import math

def lcm(x, y):
    return (x*y)//math.gcd(x,y)

A, B = [int(i) for i in input().split(" ")]

print(lcm(A, B))

Fixed submission:

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if 0==x%y:
        return y
    else:
        while not 0==x%y:
            z = x%y
            x = y
            y = z
        return z

def lcm(x, y):
    return (x*y)//gcd(x,y)

A, B = [int(i) for i in input().split(" ")]

print(lcm(A, B))

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

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A, B = [int(i) for i in input().split(" ")]

print(lcm(A, B))

Fixed submission:

def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if 0==x%y:
        return y
    else:
        while not 0==x%y:
            z = x%y
            x = y
            y = z
        return z

def lcm(x, y):
    return (x*y)//gcd(x,y)

A, B = [int(i) for i in input().split(" ")]

print(lcm(A, B))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A,B,C=[None]*N,[None]*N,dict()
for i in range(N):
  A[i],B[i] = [int(j) for j in input().split()]
  if not B[i] in C:
    C[B[i]] = []
  C[B[i]] += [[A[i],B[i]]]
C = sorted(C.items(), key=lambda C:C[0])
s=0
for k,v in C:
  for i in v:
    s+=i[0]
    if i[1]<s:
      print('No')
      exit()

print('Yes')

Fixed submission:
N = int(input())
C=dict()
for i in range(N):
 A,B = [int(j) for j in input().split()]
 if not B in C:
   C[B] = []
 C[B] += [A]
C = sorted(C.items(), key=lambda C:C[0])
s=0
for k,v in C:
    s+=sum(v)
    if k<s:
        print('No')
        exit()
print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = []
count = 0
for i in range(n):
  item = input()
  if(item not in a):
    a.append(item)
    count+=1
print(count)


Fixed submission:
n = int(input())
a = []
count = 0
for i in range(n):
  item = input()
  a.append(item)
print(len(list(set(a))))

Buggy python submission (verdict: Time Limit Exceeded):
def lottery(a):
  return len(a)

n = int(input())
a = []
for i in range(n):
  item = input()
  if(item not in a):
    a.append(item)
print(lottery(a))


Fixed submission:
n = int(input())
a = []
count = 0
for i in range(n):
  item = input()
  a.append(item)
print(len(list(set(a))))
Buggy python submission (verdict: Runtime Error):
L, R = input().split()
s = (R - 1) // ( L - 1)
ans = s + 1
print(ans)

Fixed submission:
L, R = map(int, input().split())
s = (R - 1) // (L - 1)
r = (R - 1) % (L - 1)
if r == 0:
  ans = s
else:
  ans = s + 1
print(ans)

Buggy python submission (verdict: Runtime Error):
L, R = input().split()
s = (R-1) // (L-1)
ans = s + 1
print()

Fixed submission:
L, R = map(int, input().split())
s = (R - 1) // (L - 1)
r = (R - 1) % (L - 1)
if r == 0:
  ans = s
else:
  ans = s + 1
print(ans)
Buggy python submission (verdict: Runtime Error):
A,B = list(map(int, input().split()))

print(int(A*B))

Fixed submission:
A,B = input().split()
A = int(A)
B = int(B.replace(".", ""))

print((A*B)//100)
Buggy python submission (verdict: Runtime Error):
import sys

A, B = sys.stdin.readline().strip().split()
print(max(A-2B, 0))

Fixed submission:
import sys

A, B = [int(n) for n in sys.stdin.readline().strip().split()]
print(max(A-2*B, 0))
Buggy python submission (verdict: Runtime Error):
import sys

N, K, Q = [int(n) for n in sys.stdin.readline().strip().split()]
ans_idx = [int(sys.stdin.readline().strip()) for _ in range(Q)]
scores = [0]*N

for ai in ans_idx:
  scores[ai] += 1
scores = [K-(s-Q) for s in scores]

for s in scores:
  print('No' if s<=0 else 'Yes')

Fixed submission:
import sys
 
N, K, Q = [int(n) for n in sys.stdin.readline().strip().split()]
ans_idx = [int(sys.stdin.readline().strip()) for _ in range(Q)]
scores = [0]*N
 
for ai in ans_idx:
  scores[ai-1] += 1
scores = [K-(Q-s) for s in scores]
  
for s in scores:
  print('No' if s<=0 else 'Yes')
Buggy python submission (verdict: Runtime Error):
N = int(input())
print(N(N-1)//2)

Fixed submission:
N = int(input())
print(N*(N-1)//2)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = [int(i) for i in input().strip().split()]
S = input().strip()

pre = ''
hit = []
for i, s in enumerate(S):
  if pre=='A' and s=='C':
    hit.append(i)
  pre = s
  
for _ in range(Q):
  l, r = [int(i) for i in input().strip().split()]
  print(sum([1 for h in hit if l<=h<r]))
  


Fixed submission:
N, Q = [int(i) for i in input().strip().split()]
S = input().strip()

hit = [0]*(N+1)
for i in range(N):
  hit[i+1] = hit[i] + (1 if S[i:i+2]=='AC' else 0)
  
for _ in range(Q):
  l, r = [int(i) for i in input().strip().split()]
  print(hit[r-1]-hit[l-1])
Buggy python submission (verdict: Runtime Error):
A, P = input().split()

print( (A*3+P) / 2)

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

print(int((stdin[0]*3+stdin[1]) / 2))
Buggy python submission (verdict: Runtime Error):
a, b, c, k = map(int, input().split())

if k = 1:
    print(k)
elif k <= a + b:
    print(k)
else:
    r = k - a - b
    print(a-r)


Fixed submission:
a, b, c, k = map(int, input().split())


if k <= a:
    print(k)
elif k <= a + b:
    print(a)
else:
    r = k - a - b
    print(a-r)

Buggy python submission (verdict: Runtime Error):
a, b, c, k = map(int, input().split())

val_a = [1] * a
val_b = [0] * b
val_c = [-1] * c

val_a.extend(val_b)
val_a.extend(val_c)
print(val_a)

print(sum(val_a[:k]))


Fixed submission:
a, b, c, k = map(int, input().split())


if k <= a:
    print(k)
elif k <= a + b:
    print(a)
else:
    r = k - a - b
    print(a-r)
Buggy python submission (verdict: Time Limit Exceeded):
n,k,q = map(int,input().split())
a = [0]*q
score = [k]*n
for i in range(q):
    a[i] = int(input())
    for j in range(n):
        if j != a[i]-1:
            score[j] -= 1

for i in range(n):
    if score[i] <= 0:
        print('No')
    else:
        print('Yes')

Fixed submission:
n,k,q = map(int,input().split())
a = [0]*q
# score = [k]*n
count = [0]*n
for i in range(q):
    a[i] = int(input())
    count[a[i]-1] += 1

g = k-q

for i in range(n):
    if g > 0:
        print('Yes')
    else:
        if count[i] > abs(g):
            print('Yes')
        else:
            print('No')
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
write = sys.stdout.write
# template


def resolve():
    ofs = 6400
    h, w = map(int, readline().split())
    A = [list(map(int, readline().split())) for i in range(h)]
    B = [list(map(int, readline().split())) for i in range(h)]
    dp = [[0]*w for _ in range(h)]
    x = abs(A[0][0]-B[0][0])
    dp[0][0] |= ((1 << (ofs+x)) | (1 << (ofs-x)))

    for i in range(h):
        for j in range(w):
            x = abs(A[i][j]-B[i][j])
            t = 0
            if(i-1 >= 0):
                t |= dp[i-1][j]
            if(j-1 >= 0):
                t |= dp[i][j-1]
            dp[i][j] |= ((t << x) | (t >> x))

    for i, s in enumerate(bin(dp[-1][-1])[-ofs-1:]):
        if(s == '1'):
            write("%d\n" % i+1)
            return


if __name__ == "__main__":
    INF = float("inf")
    MOD = 10**9+7
    resolve()


Fixed submission:
H, W = [int(x) for x in input().split()]

A = [[0]*W for i in range(H)]
for c in [1, -1]:
    for i in range(H):
        arr = [int(x) for x in input().split()]
        for j in range(W):
            A[i][j] += arr[j] * c

M = 160*80
dp = [[0]*W for i in range(H)]
dp[0][0] = 1 << M
for i in range(H):
    for j in range(W):
        if i > 0:
            dp[i][j] |= dp[i-1][j]
        if j > 0:
            dp[i][j] |= dp[i][j-1]
        a = abs(A[i][j])
        dp[i][j] = (dp[i][j] << a) | (dp[i][j] >> a)

ans = M
for i in range(2*M):
    if dp[H-1][W-1] & (1 << i) > 0:
        ans = min(ans, abs(M-i))
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy
from collections import Counter, deque, defaultdict
import heapq
from functools import reduce
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template

def divisor(n):
    ret = list()
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0:
            ret.append(i)
            # ret.append(n // i) if i * i != n else None
    return sorted(ret)


def main():
    S = ii()
    X1, Y1 = 0, 0
    for i in range(floor(sqrt(S)) - 3, floor(sqrt(S)) + 1000):
        if i * i >= S:
            if (i ** 2 - S) // divisor(i ** 2 - S)[-1] > 10**9:
                continue
            else:
                n = i
                break
    print(0, 0, n, divisor(n ** 2 - S)[-1], (n ** 2 - S) // divisor(n ** 2 - S)[-1], n)

if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-
import sys
from operator import itemgetter
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy
from collections import Counter, deque, defaultdict
import heapq
from functools import reduce
sys.setrecursionlimit(200000)
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
def debug(*args, sep=" ", end="\n"): print("debug:", *args, file=sys.stderr, sep=sep, end=end) if not __debug__ else None
def exit(*arg): print(*arg); sys.exit()
# template

def divisor(n):
    ret = list()
    for i in range(1, int(sqrt(n)) + 1):
        if n % i == 0:
            ret.append(i)
            # ret.append(n // i) if i * i != n else None
    return sorted(ret)


def main():
    S = ii()
    X1, Y1 = 0, 0
    if (S <= 10 ** 9):
        print(0, 0, S, 0, 0, 1)
        sys.exit()
    for i in range(floor(sqrt(S)) - 3, floor(sqrt(S)) + 1000):
        if i * i >= S:
            if i * i == S:
                print(0, 0, i, 0, 0, i)
                sys.exit()
            if (i ** 2 - S) // divisor(i ** 2 - S)[-1] > 10**9:
                continue
            else:
                n = i
                break
    print(0, 0, n, divisor(n ** 2 - S)[-1], (n ** 2 - S) // divisor(n ** 2 - S)[-1], n)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
n=int(input())
a=[list(map(int,input().split())) for i in range(N)]
a.sort()
print(sum(a[0]))

Fixed submission:
N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
a.sort()
print(sum(a[-1]))