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

Fixed submission:
# coding: utf-8

import sys
import math
import collections
import itertools
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)
MOD = 10 **9 + 7

# N = int(input())
# S = input()
N, K = map(int, input().split())
# 横
A = [int(x) for x in input().split()]
# 縦
# A = [int(input()) for _ in range(N)]
# 多次元
# L = [[int(x) for x in input().split()] for _ in range(N)]

ans = 0
tmp = 0

for i, a in enumerate(A) :
    for aa in range(i + 1, N) :
        if a > A[aa] :
            ans += 1

for a in A :
    for aa in A :
        if a > aa :
            tmp += 1

print(((int((K*(K-1))//2)%MOD)*tmp+ans*K)%MOD)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

import sys
import math
import collections
import itertools
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)
MOD = 10 **9 + 7

# N = int(input())
# S = input()
N, K = map(int, input().split())
# 横
A = [int(x) for x in input().split()]
# 縦
# A = [int(input()) for _ in range(N)]
# 多次元
# L = [[int(x) for x in input().split()] for _ in range(N)]

ans = 0
tmp = 0

for i, a in enumerate(A) :
    for aa in range(i + 1, N) :
        if a > A[aa] :
            ans += 1

for a in A :
    for aa in A :
        if a > aa :
            tmp += 1

print(((int((K*(K-1))//2)%MOD)*tmp+ans*K)%M)
Problem p02995 (python)

Fixed submission:
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()

# N = int(input())
# L = [int(x) for x in input().split()]
A, B, C, D = map(int, input().split())
# S = input()

def gcd(x, y):
    if x % y == 0:
        return y
        
    return gcd(y, x % y)


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


def kosu(n, p):
    return n // p

x = kosu(B, C) - kosu(A - 1, C)
y = kosu(B, D) - kosu(A - 1, D)
z = kosu(B, lcm(C, D)) - kosu(A - 1, lcm(C, D))

print((B - A + 1) - (x + y - z))

Buggy submission (verdict: Runtime Error):
# coding: utf-8

import math
import sys
def input(): return sys.stdin.readline().strip()

# N = int(input())
# L = [int(x) for x in input().split()]
A, B, C, D = map(int, input().split())
# S = input()

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


def kosu(n, p):
    return n // p

x = kosu(B, C) - kosu(A - 1, C)
y = kosu(B, D) - kosu(A - 1, D)
z = kosu(B, lcm(C, D)) - kosu(A - 1, lcm(C, D))

print((B - A + 1) - (x + y - z))
Problem p03001 (python)

Fixed submission:
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def lcm(x, y) : return (x * y) // math.gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

W, H, x, y = LI()

print((W*H)/2, 1 if x*2 == W and y*2 == H else 0)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()

# N = int(input())
# L = [int(x) for x in input().split()]
W, H, x, y = map(int, input().split())
# S = input()

ko = [-1] * 3
ko[0] = min(x * H, (W - x) * H)
ko[1] = min(y * W, (H - y) * W)
if (x, y) == (0, 0) or (x, y) == (0, H) or (x, y) == (W, 0) or (x, y) == (W, H) or y / x == H / W:
    ko[2] = (W * H) / 2

maxm = max(ko)
print(maxm, 1 if ko.count(maxm) > 1 else 0)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()

# N = int(input())
# L = [int(x) for x in input().split()]
W, H, x, y = map(int, input().split())
# S = input()



ko = [-1] * 3
ko[0] = min(x * H, (W - x) * H)
ko[1] = min(y * W, (H - y) * W)
if y / x == H / W:
    ko[2] = (W * H) / 2

maxm = max(ko)
print(maxm, 1 if ko.count(maxm) > 1 else 0)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()

# N = int(input())
# L = [int(x) for x in input().split()]
W, H, x, y = map(int, input().split())
# S = input()

ko = [-1] * 3
ko[0] = min(x * H, (W - x) * H)
ko[1] = min(y * W, (H - y) * W)
if y / x == (H - y) / (W - x):
    ko[2] = (W * H) / 2

maxm = max(ko)
print(maxm, 1 if ko.count(maxm) > 1 else 0)
Problem p03006 (python)

Fixed submission:
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()

N = int(input())
# L = [int(x) for x in input().split()]
# N, M = map(int, input().split())
# S = input()

ball = [[int(x) for x in input().split()] for _ in range(N)]
dist = {}

for i, a in enumerate(ball):
    x0 = a[0]
    y0 = a[1]

    for j, b in enumerate(ball):
        x1 = b[0]
        y1 = b[1]

        xy = (x1-x0, y1-y0)

        if xy == (0, 0):
            continue

        if not xy in dist:
            dist[xy] = 1
        else:
            dist[xy] += 1

try:
    num = max(dist.values())
except:
    num = 0

print(N - num)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()

N = int(input())
# L = [int(x) for x in input().split()]
# N, M = map(int, input().split())
# S = input()

ball = [[int(x) for x in input().split()] for _ in range(N)]
dist = {}

for i, a in enumerate(ball):
    x0 = a[0]
    y0 = a[1]

    for j, b in enumerate(ball):
        x1 = b[0]
        y1 = b[1]

        xy = (x1-x0, y1-y0)

        if xy == (0, 0):
            continue

        if not xy in dist:
            dist[xy] = 1
        else:
            dist[xy] += 1
            
print(N - max(dist.values()))
Problem p03014 (python)

Fixed submission:
# coding: utf-8

import sys
import math
import collections
import itertools
from functools import lru_cache
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")

H, W = LI()
S = RS(H)

L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]

for i in range(H):
    lf = 0
    rf = 0
    for j in range(W):
        if S[i][j] == ".":
            lf += 1
            L[i][j] = lf
        else:
            lf = 0

        if S[i][W-1-j] == ".":
            rf += 1
            R[i][W-1-j] = rf
        else:
            rf = 0

for i in range(W):
    uf = 0
    df = 0
    for j in range(H):
        if S[j][i] == ".":
            df += 1
            D[j][i] = df
        else:
            df = 0

        if S[H-1-j][i] == ".":
            uf += 1
            U[H-1-j][i] = uf
        else:
            uf = 0

ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j] == ".":
            ans = max(ans, U[i][j]+D[i][j]+L[i][j]+R[i][j]-3)

print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

import sys
import math
import collections
import itertools
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")

H, W = LI()
S = RS(H)

def dfs(x, y, ok, dist):
    if not(0 <= x < W) or not(0 <= y < H) or S[y][x] == "#":
        return ok - 1

    if dist == 1:
        return dfs(x, y-1, ok+1, 1)
    elif dist == 2:
        return dfs(x+1, y, ok+1, 2)
    elif dist == 3:
        return dfs(x, y+1, ok+1, 3)
    else:
        return dfs(x-1, y, ok+1, 4)

ans = 0
for x in range(W):
    for y in range(H):
        if S[y][x] == ".":
            ans = max(ans, 1 + dfs(x, y-1, 1, 1) + dfs(x+1, y, 1, 2) + dfs(x, y+1, 1, 3) + dfs(x-1, y, 1, 4))

print(ans)
Problem p03032 (python)

Fixed submission:
# coding: utf-8

import sys
input = sys.stdin.readline

# N = int(input())
N, K = map(int, input().split())
D = [int(x) for x in input().split()]
# S = input()

ans = 0
for l in range(N + 1):
    if l > K:
        break

    for r in range(N - l + 1):
        if l + r > K:
            break

        value_list = D[0 : l] + D[N - r : N]
        value_list.sort()
        
        for i in range(K - (l + r) + 1):
            ans = max(ans, sum(value_list[i:]))
        
print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

import sys
input = sys.stdin.readline

# N = int(input())
N, K = map(int, input().split())
D = [int(x) for x in input().split()]
# S = input()

ans = 0
for l in range(N + 1):
    if l > K:
        break

    for r in range(N - l + 1):
        if l + r > K:
            break

        value_list = D[0 : l] + D[N - r : N]
        sort(value_list)
        
        for i in range(K - (l + r) + 1):
            ans = max(ans, sum(value_list[i:]))
        
print(ans)
Problem p03043 (python)

Fixed submission:
# coding: utf-8

import sys
import math
input = sys.stdin.readline

# N = int(input())
# L = [int(x) for x in input().split()]
N, K = map(int, input().split())
# S = input()

max_pow = math.ceil(math.log2(K) + 0.9)

one_half = [0] * (max_pow + 1)
one_half[0] = 1
for i in range(1, max_pow + 1) :
    one_half[i] = one_half[i - 1] * 0.5

ans = 0
for i in range(1, N + 1) :
    pow_num = math.ceil(math.log2(K / i))
    
    if pow_num <= 0 :
        ans += 1
    else :
        ans += one_half[pow_num]

print(ans / N)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

import sys
import math
input = sys.stdin.readline

# N = int(input())
# L = [int(x) for x in input().split()]
N, K = map(int, input().split())
# S = input()

max_pow = int(math.log2(K) + 0.9)

one_half = [0] * (max_pow + 1)
one_half[0] = 1
for i in range(1, max_pow + 1) :
    one_half[i] = one_half[i - 1] * 0.5

ans = 0
for i in range(1, N + 1) :
    pow_num = math.ceil(math.log2(K / i))
    
    if pow_num <= 0 :
        ans += 1
    else :
        ans += one_half[pow_num]
        
print(ans / N)
Problem p03071 (python)

Fixed submission:
# coding: utf-8

import sys
input = sys.stdin.readline

# N = int(input())
# L = list(map(int, input().split()))
A, B = map(int, input().split())

print(max(A + B, (max(A, B) + max(A - 1, B - 1))))

Buggy submission (verdict: Runtime Error):
aa

Buggy submission (verdict: Runtime Error):
a
Problem p03103 (python)

Fixed submission:
# coding: utf-8

# import sys
# input = sys.stdin.readline

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

AB = [list(map(int, input().split())) for __ in range(N)]
AB.sort(key=lambda x : x[0])

k = 0
ans = 0
while M > 0:
    if M > AB[k][1]:
        M -= AB[k][1]
        ans += AB[k][0] * AB[k][1]
    else:
        ans += AB[k][0] * M
        break
    
    k += 1

print(ans)

Buggy submission (verdict: Runtime Error):
# coding: utf-8

import sys
input = sys.stdin.readline

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

AB = [list(map(int, input().split())) for __ in range(N)]
AB.sort(key=lambda x : x[0])

for k in AB:
    if M > k[1]:
        M -= k[1]
        ans += k[0] * k[1]
    else:
        ans += k[0] * M
        break

print(ans)
Problem p02727 (python)

Fixed submission:
x, y, a, b, c = map(int, input().split())
p = sorted(map(int, input().split()))[::-1]
q = sorted(map(int, input().split()))[::-1]
r = sorted(map(int, input().split()))[::-1]

x, y = x-1, y-1
z = 0
red, green = 0, 0
ans = 0
while True:
    finish = True
    if p[x] <= q[y] or y < 0:
        if z < c and p[x] < r[z]:
            x -= 1
            z += 1
            finish = False
    elif p[x] >= q[y] or x < 0:
        if z < c and q[y] < r[z]:
            y -= 1
            z += 1
            finish = False
    if finish:
        break
print(sum(p[:x+1]) + sum(q[:y+1]) + sum(r[:z]))

Buggy submission (verdict: Runtime Error):
x, y, a, b, c = map(int, input().split())
p = sorted(map(int, input().split()))[::-1]
q = sorted(map(int, input().split()))[::-1]
r = sorted(map(int, input().split()))[::-1]

z = 0
red, green = 0, 0
ans = 0
while True:
    finish = True
    if p[x] <= q[y]:
        if z < c and p[x] < r[z]:
            x -= 1
            z += 1
            finish = False
    else:
        if z < c and q[y] < r[z]:
            y -= 1
            z += 1
            finish = False
    if finish:
        break
print(sum(p[:x]) + sum(q[:y]) + sum(q[:z]))
Problem p02812 (python)

Fixed submission:
N = int(input())
S = input()

count = 0
for i in range(len(S) - 2):
    if S[i:i+3] == 'ABC':
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
print(s.count('ABC')
Problem p02814 (python)

Fixed submission:
from fractions import gcd
from functools import reduce
import sys

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

n, m = map(int, input().split())
a = [int(item) // 2 for item in input().split()]
b = [0] * n

for i in range(n):
    tmp = a[i]
    while True:
        if tmp % 2 == 0:
            b[i] += 1
            tmp /= 2
        else:
            break

if len(set(b)) != 1:
    print(0)
    sys.exit()

a_lcm = lcm(a)
count = m // a_lcm
if count % 2 == 0:
    print(count // 2)
else:
    print((count + 1) // 2)

Buggy submission (verdict: Runtime Error):
import fractions

def lcm(num_list):
    if len(num_list) > 2:
        lcm_tmp = lcm(num_list[:2])
        if M * 2 < lcm_tmp:
            return None
        num_list_new = [lcm_tmp]
        num_list_new.extend(num_list[2:])
        return lcm(num_list_new)
    elif len(num_list) == 2:
        return num_list[0] * num_list[1] // fractions.gcd(num_list[0], num_list[1])

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

lcm_of_a = lcm(a)
if lcm_of_a is None:
    print(0)
count = M * 2 // lcm_of_a
if count % 2 == 0:
    print(count // 2)
else:
    print((count + 1) // 2)

Buggy submission (verdict: Runtime Error):
import fractions

def lcm(num_list):
    if len(num_list) > 2:
        num_list_new = [lcm(num_list[:2])]
        num_list_new.extend(num_list[2:])
        return lcm(num_list_new)
    elif len(num_list) == 2:
        return num_list[0] * num_list[1] // fractions.gcd(num_list[0], num_list[1])

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

lcm_of_a = lcm(a)
count = M * 2 // lcm_of_a
if count % 2 == 0:
    print(count // 2)
else:
    print((count + 1) // 2)

Buggy submission (verdict: Runtime Error):
import math

def gcd(num_list):
    if len(num_list) > 2:
        num_list_new = [math.gcd(*num_list[:2])]
        num_list_new.extend(num_list[2:])
        return gcd(num_list_new)
    elif len(num_list) == 2:
        return math.gcd(*num_list)

def lcm(num_list):
    if len(num_list) > 2:
        num_list_new = [lcm(num_list[:2])]
        num_list_new.extend(num_list[2:])
        return lcm(num_list_new)
    elif len(num_list) == 2:
        return num_list[0] * num_list[1] // math.gcd(num_list[0], num_list[1])

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

lcm_of_a = lcm(a)
count = M * 2 // lcm_of_a
if count % 2 == 0:
    print(count // 2)
else:
    print((count + 1) // 2)
Problem p02838 (python)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
bits = [0] * 60
MOD = 10**9 + 7

for a in A:
    div = a
    i = 0
    while True:
        div, mod = div // 2, div % 2
        bits[i] += mod
        i += 1
        if div == 0:
            break

ans = 0
for i in range(60):
    ans += bits[i] * (n-bits[i]) * 2 ** i % MOD
print(ans % MOD)

Buggy submission (verdict: Runtime Error):
import math

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

m = int(math.log2(max(a))) + 1

total = 0
num = 1
while True:
    if num == n:
        break
    p, q = 0, 0
    for i in range(0, n - num):
        p += (a[i] << m * (n-num-i-1)) % 1000000007
        q += a[num + i] << m * (n-num-i-1) % 1000000007
    r = p ^ q
    for i in range(0, n - num):
        total += r % (2 ** m)
        r = r >> m
    num += 1

print(total % 1000000007)

Buggy submission (verdict: Runtime Error):
import math

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

m = int(math.log2(max(a))) + 1

total = 0
num = 1
while True:
    if num == n:
        break
    p, q = 0, 0
    for i in range(0, n - num):
        p += a[i] << m * (n-num-i-1)
        q += a[num + i] << m * (n-num-i-1)
    r = p ^ q
    for i in range(0, n - num):
        total += (r % (2 ** m)) % 1000000007
        r = r >> m
    num += 1

print(total % 1000000007)
Problem p02936 (python)

Fixed submission:
import sys
input = sys.stdin.readline
from queue import Queue

n, q = map(int, input().split())
nodes = [[] for _ in range(n)]  # 隣接ノード
for i in range(n-1):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    nodes[a].append(b)
    nodes[b].append(a)

counts = [0] * n
for i in range(q):
    p, x = map(int, input().split())
    counts[p-1] += x

ans = [0] * n
ans[0] = counts[0]
done = [0] * n
queue = Queue()
queue.put(0)
while True:
    node = queue.get()
    done[node] = 1
    next_nodes = nodes[node]
    for next_node in next_nodes:
        if not done[next_node]:
            queue.put(next_node)
            ans[next_node] = ans[node] + counts[next_node]
    if queue.empty():
        break

print(*ans)

Buggy submission (verdict: Runtime Error):
def dfs(v):
    seen[v] = 1
    ans[v] += counter[v]

    for next_v in graph[v]:
        if seen[next_v]: continue
        ans[next_v] += ans[v]
        dfs(next_v)

n, q = map(int, input().split())

graph = [[] for _ in range(n)]
for _ in range(n-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    graph[b-1].append(a-1)

counter = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    counter[p-1] += x

seen = [0] * n
ans = [0] * n
dfs(0)

print(*ans)
Problem p03061 (python)

Fixed submission:
from fractions import gcd

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

left = [0] * (n + 1)
for i in range(1, n):
    left[i] = gcd(left[i-1], a[i-1])

right = [0] * (n + 1)
for i in range(1, n):
    right[n-i] = gcd(right[n-i+1], a[n-i])

ans = 0
for i in range(n):
    ans = max(ans, gcd(left[i], right[i+1]))
print(ans)

Buggy submission (verdict: Runtime Error):
from fractions import gcd

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

a.append(a[0])
neighbors_gcd = [gcd(a[i], a[i+1]) for i in range(n)]

print(sorted(neighbors_gcd)[2])
Problem p03078 (python)

Fixed submission:
import heapq
x, y, z, k = map(int, input().split())
a = sorted(map(int, input().split()))[::-1]
b = sorted(map(int, input().split()))[::-1]
c = sorted(map(int, input().split()))[::-1]

print(a[0] + b[0] + c[0])
candidates = []
if x > 1: candidates.append((-(a[1] + b[0] + c[0]), 1, 0, 0))
if y > 1: candidates.append((-(a[0] + b[1] + c[0]), 0, 1, 0))
if z > 1: candidates.append((-(a[0] + b[0] + c[1]), 0, 0, 1))
heapq.heapify(candidates)
popped = {(1, 0, 0): 1,
          (0, 1, 0): 1,
          (0, 0, 1): 1}

for i in range(1, k):
    value, p, q, r = heapq.heappop(candidates)
    print(-value)
    try:
        popped[(p+1, q, r)]
    except:
        if p+1 < x: 
            heapq.heappush(candidates, (-(a[p+1] + b[q] + c[r]), p+1, q, r))
            popped[(p+1, q, r)] = 1
    try:
        popped[(p, q+1, r)]
    except:
        if q+1 < y: 
            heapq.heappush(candidates, (-(a[p] + b[q+1] + c[r]), p, q+1, r))
            popped[(p, q+1, r)] = 1
    try:
        popped[(p, q, r+1)]
    except:
        if r+1 < z: 
            heapq.heappush(candidates, (-(a[p] + b[q] + c[r+1]), p, q, r+1))
            popped[(p, q, r+1)] = 1

Buggy submission (verdict: Runtime Error):
import heapq
x, y, z, k = map(int, input().split())
a = sorted(map(int, input().split()))[::-1]
b = sorted(map(int, input().split()))[::-1]
c = sorted(map(int, input().split()))[::-1]

print(a[0] + b[0] + c[0])
candidates = [(-(a[1] + b[0] + c[0]), 1, 0, 0),
              (-(a[0] + b[1] + c[0]), 0, 1, 0),
              (-(a[0] + b[0] + c[1]), 0, 0, 1)]
heapq.heapify(candidates)
popped = {(1, 0, 0): 1,
          (0, 1, 0): 1,
          (0, 0, 1): 1}

for i in range(1, k):
    value, p, q, r = heapq.heappop(candidates)
    print(-value)
    try:
        popped[(p+1, q, r)]
    except:
        if p+1 < x: 
            heapq.heappush(candidates, (-(a[p+1] + b[q] + c[r]), p+1, q, r))
            popped[(p+1, q, r)] = 1
    try:
        popped[(p, q+1, r)]
    except:
        if q+1 < y: 
            heapq.heappush(candidates, (-(a[p] + b[q+1] + c[r]), p, q+1, r))
            popped[(p, q+1, r)] = 1
    try:
        popped[(p, q, r+1)]
    except:
        if r+1 < z: 
            heapq.heappush(candidates, (-(a[p] + b[q] + c[r+1]), p, q, r+1))
            popped[(p, q, r+1)] = 1
Problem p03578 (python)

Fixed submission:
import sys
n = int(input())
D = list(map(int, input().split()))
m = int(input())
T = list(map(int, input().split()))

max_diff = max(D)
difficulty = {}
for d in D:
    try:
        difficulty[d] += 1
    except:
        difficulty[d] = 1

for t in T:
    try:
        difficulty[t] -= 1
    except:
        print('NO')
        sys.exit()
    if difficulty[t] < 0:
        print('NO')
        sys.exit()
print('YES')

Buggy submission (verdict: Runtime Error):
import sys
n = int(input())
D = list(map(int, input().split()))
m = int(input())
T = list(map(int, input().split()))

max_diff = max(D)
difficulty = [0] * (max_diff + 1)
for d in D:
    difficulty[d] += 1

for t in T:
    if t > max_diff:
        print('NO')
        sys.exit()
    difficulty[t] -= 1
    if difficulty[t] < 0:
        print('NO')
        sys.exit()
print('YES')
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 1
A = list(map(int,input().split()))
for x in A:
  if x == 0:
    print(0)
    exit(0)
  ans *= x
  if ans > 10**18:
    print(-1)
    exit(0)
print(ans)
Problem p02658 (python)

Fixed submission:
n = int(input())
ans = 1
A = list(map(int,input().split()))
if 0 in A:
  print(0)
  exit(0)
for x in A:
  ans *= x
  if ans > 10**18:
    print(-1)
    exit(0)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 1
A = list(map(int,input().split()))
for x in A:
  if x = 0:
    print(0)
    exit(0)
  ans *= x
if ans > 10**18:
  print(-1)
  exit(0)
print(ans)
Problem p02681 (python)

Fixed submission:
S = list(input())
T = list(input())

for i in range(len(S)):
  if T[i] != S[i]:
    print('No')
    exit(0)
print('Yes')

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
A = list(map(int,input().split()))
sub = [0]*n
ans = 1
cir = 0
a = 0
for i in range(n):
  sub[i] = ans
  if A[ans-1] in sub:
    a = sub.index(A[ans-1])
    cir = i+1 - a
    break
  else:
    ans = A[ans-1]
if sub[-1] != 0:
  print(sub[k%n])
  exit(0)
print(sub[a + (k - a) % cir])

Buggy submission (verdict: Runtime Error):
S = list(input())
T = list(input())

for i in range(len(s)):
  if T[i] != S[i]:
    print('No')
    exit(0)
print('Yes')