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

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

a, b = [0], [0]
for i in range(N):
  a.append(a[i] + A[i])
for i in range(M):
  b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
  if a[i] > K:
    break
  while b[j] > K - a[i]:
    #print(b[j],K - a[i])
    j -= 1
  ans = max(ans, i + j)
  #print("ans",ans)
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a = list(input().split())
a = [int(i) for i in a]
b = list(input().split())
b = [int(i) for i in b]
aa=a.copy()
aa.extend(b)
if sum(aa)<=k:
  print(n+m)
  exit()

#print(aa)
ai,bi=0,0
ans=0
for _ in range(n+m):
  #print(k, a[ai], b[bi], ai,bi)
  if k<= a[ai] and k<= b[bi]:
    print(ans)
    exit()
    
  if a[ai] <= b[bi]:
    k-=a[ai]
    ai+=1
    ans+=1
  else:
    k-=b[bi]
    bi+=1
    ans+=1
    
  if ai == len(a):
    a=[10*10]*10000
  if bi == len(b):
    b=[10*10]*10000
    
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a = list(input().split())
a = [int(i) for i in a]
b = list(input().split())
b = [int(i) for i in b]
aa=a.copy()
aa.extend(b)
if sum(aa)<=k:
  print(n+m)
  exit()

#print(aa)
ai,bi=0,0
ans=0
for _ in range(n+m):
  #print(k, a[ai], b[bi], ai,bi)
  if k<= a[ai] and k<= b[bi]:
    print(ans)
    exit()
    
  if a[ai] <= b[bi]:
    k-=a[ai]
    ai+=1
    ans+=1
  else:
    k-=b[bi]
    bi+=1
    ans+=1
    
  if ai == len(a):
    a=[10*9]*10000
  if bi == len(b):
    b=[10*9]*10000
    
print(ans)

Buggy submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a = list(input().split())
a = [int(i) for i in a]
b = list(input().split())
b = [int(i) for i in b]
aa=a.copy()
aa.extend(b)
if sum(aa)<=k:
  print(n+m)
  exit()

#print(aa)
ai,bi=0,0
ans=0
for _ in range(n+m):
  #print(k, a[ai], b[bi])
  if k<= a[ai] and k<= b[bi]:
    print(ans)
    exit()
    
  if a[ai] <= b[bi]:
    k-=a[ai]
    ai+=1
    ans+=1
  else:
    k-=b[bi]
    bi+=1
    ans+=1
print(ans)
Problem p02832 (python)

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

target = 1
for ai in a:
    if ai == target:
        target += 1

if target == 1:
    print(-1)
else:
    print(N-target+1)

Buggy submission (verdict: Runtime Error):
N = int(Input[0])
a = list(map(int, Input[1].split()))

target = 1
for ai in a:
    if ai == target:
        target += 1

if target == 1:
    print(-1)
else:
    print(N-target+1)
Problem p02959 (python)

Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    num_monster = 0
    res = 0  # 余力
    for i in range(N):
        a = A[i] - res  # 前の人が倒しといてくれた分を引く
        b = B[i]
        if b <= a:  # 目の前の敵を倒し切れるかあやしい
            num_monster += b
            res = 0
        elif b <= a+A[i+1]:  # 次の敵の一部まで倒せる
            num_monster += b
            res = b - a
        else:  # 次の敵まで全部倒せる
            num_monster += a+A[i+1]
            res = A[i+1]
    print(num_monster)
main()

Buggy submission (verdict: Runtime Error):
def main():
    num_monster = 0
    res = 0  # 余力
    for i in range(N):
        a = A[i] - res  # 前の人が倒しといてくれた分を引く
        b = B[i]
        if b <= a:  # 目の前の敵を倒し切れるかあやしい
            num_monster += b
            res = 0
        elif b <= a+A[i+1]:  # 次の敵の一部まで倒せる
            num_monster += b
            res = b - a
        else:  # 次の敵まで全部倒せる
            num_monster += a+A[i+1]
            res = A[i+1]
    print(num_monster)
main()
Problem p02989 (python)

Fixed submission:
def main():
    N = int(input())
    d = list(map(int, input().split()))
    difficulties = sorted(d)
    l = len(difficulties)//2 - 1
    r = len(difficulties)//2
    print(difficulties[r] - difficulties[l])
main()

Buggy submission (verdict: Runtime Error):
difficulties = sorted(d)
l = len(difficulties)//2 - 1
r = len(difficulties)//2
print(difficulties[r] - difficulties[l])
Problem p02990 (python)

Fixed submission:
from math import factorial as fct
def main():
    MOD = 10**9 + 7
    N, K = map(int, input().split())
    b = K
    r = N - K
    for i in range(1, K+1):
        p_blue = (fct((b-i)+(i-1)) // fct(b-i) // fct(i-1)) % MOD
        if r >= i-1:
            p_red = (fct((r-(i-1))+i) // fct(r-(i-1)) // fct(i)) % MOD
        else:
            p_red = 0
        print((p_blue * p_red) % MOD)
main()

Buggy submission (verdict: Runtime Error):
from math import factorial as fct
def main():
    MOD = 10**9 + 7
    N, K = map(int, input().split())
    b = K
    r = N - K
    for i in range(1, K+1):
        p_blue = int(fct((b-i)+(i-1)) / fct(b-i) / fct(i-1)) % MOD
        if r >= i-1:
            p_red = int(fct((r-(i-1))+i) / fct(r-(i-1)) / fct(i)) % MOD
        else:
            p_red = 0
        print((p_blue * p_red) % MOD)
main()

Buggy submission (verdict: Runtime Error):
from math import factorial as fct
def main():
    MOD = 10**9 + 7
    N, K = map(int, input().split())
    b = K
    r = N - K
    for i in range(1, K+1):
        p_blue = int(fct((b-i)+(i-1)) / fct(b-i) / fct(i-1)) % MOD
        if r >= i-1:
            p_red = int(fct((r-(i-1))+i) / fct(r-(i-1)) / fct(i)) % MOD
        else:
            p_red = 0
        print((p_blue * p_red) % MOD)
main()

Buggy submission (verdict: Runtime Error):
from math import factorial as fct
def main():
    MOD = 10**9 + 7
    N, K = map(int, input().split())
    b = K
    r = N - K
    for i in range(1, K+1):
        p_blue = int(fct((b-i)+(i-1)) / fct(b-i) / fct(i-1)) % MOD
        p_red = 0
        if r >= i-1 and i-1 >= 1:
            n = i - 1
            p_red += int(fct((r-n+(n-1))) / fct(r-n) / fct(n-1)) % MOD  
        if r >= i:
            n = i
            p_red += int(fct((r-n)+(n-1)) / fct(r-n) / fct(n-1)) * 2 % MOD
        if r >= i+1:
            n = i + 1
            p_red += int(fct((r-n)+n-1) / fct(r-n) / fct(n-1)) % MOD
        print((p_blue * p_red) % MOD)
main()
Problem p03013 (python)

Fixed submission:
def main():
    MOD = 1000000007
    N, M = map(int, input().split())
    a = [int(input()) for _ in range(M)]
    table = [1]*(N+1)
    for broken in a:
        table[broken] = 0
    table[1] = table[0] * table[1]
    if N > 1:
        for n in range(2, N+1):
            table[n] = ((table[n-2] + table[n-1]) * table[n]) % MOD
    print(table[-1])
main()

Buggy submission (verdict: Runtime Error):
def main():
    MOD = 1_000_000_007
    N, M = map(int, input().split())
    a = [int(input()) for _ in range(M)]
    table = [1]*(N+1)
    for broken in a:
        table[broken] = 0
    table[1] = table[0] * table[1]
    if N > 1:
        for n in range(2, N+1):
            table[n] = ((table[n-2] + table[n-1]) * table[n]) % MOD
    print(table[-1])
main()

Buggy submission (verdict: Runtime Error):
def main():
    MOD = 1_000_000_007
    N, M = map(int, input().split())
    a = [int(input()) for _ in range(M)]
    table = [1]*(N+1)
    for broken in a:
        table[broken] = 0
    table[1] = table[0] * table[1]
    for n in range(2, N+1):
        table[n] = ((table[n-2] + table[n-1]) * table[n]) % MOD
    print(table[-1])
main()

Buggy submission (verdict: Runtime Error):
from math import factorial
MOD = 1_000_000_007

def calc_nCr(n, r):
    return (int(factorial(n) / (factorial(r) * factorial(n - r)))) % MOD
def count_patterns(stairs):
    if stairs == 0 or stairs == 1:
        return 1
    max_double_num = int(stairs/2)
    combs = [None]*(max_double_num+1)
    for i in range(max_double_num+1):
        double = i
        single = stairs - double*2
        n = double + single
        r = double
        nCr = calc_nCr(n, r)
        combs[i] = nCr
    return sum(combs) % MOD
  
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]

now = 0
total = 1

for broken in a:
    if broken <= now:
        print(0)
        break
    total = (total * count_patterns(broken-now-1)) % MOD
    now = broken + 1
else:
    total = (total * count_patterns(N-now)) % MOD
    print(total)

Buggy submission (verdict: Runtime Error):
from math import factorial

def calc_nCr(n, r):
    return int(factorial(n) / (factorial(r) * factorial(n - r)))
def count_patterns(stairs):
    if stairs == 0 or stairs == 1:
        return 1
    max_double_num = int(stairs/2)
    combs = [None]*(max_double_num+1)
    for i in range(max_double_num+1):
        double = i
        single = stairs - double*2
        n = double + single
        r = double
        nCr = calc_nCr(n, r)
        combs[i] = nCr
    return sum(combs) % MOD
  
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]

MOD = 1_000_000_007
now = 0
total = 1

for broken in a:
    if broken <= now:
        print(0)
        break
    total = (total * count_patterns(broken-now-1)) % MOD
    now = broken + 1
else:
    total = (total * count_patterns(N-now)) % MOD
    print(total)
Problem p02833 (python)

Fixed submission:
import math


def solve_even(n):
    assert(n % 2 == 0)
    k = n // 2
    return leg(k)


def leg(k):
    return sum(k // 5 ** i for i in range(1, int(math.log(k) / math.log(5)) + 1))


n = int(input())

if n % 2 == 0:
    if n == 0:
        print(0)
    else:
        print(solve_even(n))
else:
    if n == 1:
        print(0)
    else:
        print(solve_even(n + 1) - leg(n // 2 + 1))

# (2k + 1)!! = (2k + 2)! / (2^(k+1)*(k+1)!)

Buggy submission (verdict: Runtime Error):
import math


def solve_even(n):
    assert(n % 2 == 0)
    k = n // 2
    return leg(k)


def leg(k):
    return sum(k // 5 ** i for i in range(1, int(math.log(k) / math.log(5)) + 1))


n = int(input())

if n % 2 == 0:
    print(solve_even(n))
else:
    if n == 1:
        print(0)
    else:
        print(solve_even(n + 1) - leg(n // 2))

# (2k + 1)!! = (2k + 2)! / (2^(k+1)*(k+1)!)
Problem p02695 (python)

Fixed submission:
N, M, Q = list(map(int, input().split()))
A = []
B = []
C = []
D = []

for i in range(Q):
    a,b,c,d = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)
    D.append(d)

listA = list(range(1,N+1))
ANS = 0

import itertools
for i in itertools.combinations_with_replacement(range(1,M+1), N):
    f = 0
    for j in range(len(i)-1):
        if not i[j] <= i[j+1]:
            f=1
    if f == 0:
        #print(i)
        ans = 0
        for q in range(Q):
            if i[B[q]-1] - i[A[q]-1] == C[q]:
                ans += D[q]
        ANS = max([ANS, ans])
print(ANS)
#print(ANS)

Buggy submission (verdict: Runtime Error):
N, M, Q = list(map(int, input().split()))
A = []
B = []
C = []
D = []

for i in range(Q):
    a,b,c,d = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)
    D.append(d)


ANS = []

import itertools
for i in itertools.product(range(1,M+1), repeat=N):
    f = 0
    for j in range(len(i)-1):
        if not i[j] < i[j+1]:
            f=1
    if f == 0:
        #print(i)
        ans = 0
        for q in range(Q):
            if i[B[q]-1] - i[A[q]-1] == C[q]:
                ans += D[q]
        ANS.append(ans)
print(max(ANS))
Problem p02699 (python)

Fixed submission:
s,w = map(int, input().split())
if s>w:
    print('safe')
else:
    print('unsafe')

Buggy submission (verdict: Runtime Error):
s,w = map(int, input().split())
if s>f:
    print('safe')
else:
    print('unsafe')
Problem p02753 (python)

Fixed submission:
S = input()
if S == 'AAA' or S == 'BBB':
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
S = input()
if S = 'AAA' or S = 'BBB':
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
S = input()
if S = 'AAA' and S = 'BBB':
  print('No')
else:
  print('Yes')

Buggy submission (verdict: Runtime Error):
S = input()
if S = 'AAA' and S = 'BBB':
  print('No')
else:
  print('No')
Problem p03127 (python)

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

g= A[0]
import fractions
for i in range(1,n):
    g = fractions.gcd(g, A[i])
print(g)

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

g= A[0]
'''import fractions
for i in range(1,n):
    g = fractions.gcd(g, A[i])'''
import math
for i in range(1,n):
    g = math.gcd(g,A[i])
print(g)
Problem p02577 (python)

Fixed submission:
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

n = inp()
m = int(n)

ans = 0

for i in range(len(n)):
    ans += int(n[i])

ans %= 9

if ans == 0:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
def inp():
    return input()
def iinp():
    return int(input())
def inps():
    return input().split()
def miinps():
    return map(int,input().split())
def linps():
    return list(input().split())
def lmiinps():
    return list(map(int,input().split()))
def lmiinpsf(n):
    return [list(map(int,input().split()))for _ in range(n)]

n = inp()
m = int(n)

for i in range(len(n)):
    ans += (m % 10)
    m //= 10

ans %= 9

if ans == 0:
    print("Yes")
else:
    print("No")
Problem p02951 (python)

Fixed submission:
a,b,c=map(int,input().split())
if c-(a-b)<0:
  print(0)
else:
  print(c-(a-b))

Buggy submission (verdict: Runtime Error):
#include <stdio.h>

int main(){
  int a,b,c,s;
  scanf("%d %d %d",&a,&b,&c);
  s=a-b;
  
  if (s<c){
    printf("%d",c-s);
  }else{
    printf("0");
  }
  
  return 0;
}
Problem p03265 (python)

Fixed submission:
x1,y1,x2,y2=map(int,input().split())

k1=x2-x1
k2=y2-y1

x3=x2-k2
y3=y2+k1

x4=x3-k1
y4=y3-k2

print(x3,y3,x4,y4)

Buggy submission (verdict: Runtime Error):
x1,y1,x2,y2=map(int,input().split())

k1=x2-x1
k2=y2-y1

print(x2-k2,y2+k1,x3-k1,y3-k2)
Problem p02793 (python)

Fixed submission:
n = int(input())
a = [int(i) for i in input().split()]

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

l = a[0]
for i in a[1:]:
    l = lcm(l, i)
b = []
for i in a:
    b.append(l//i)
ans = sum(b) % (10 ** 9 + 7)
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(i) for i in input().split()]
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)
if n == 1:
    ans = 1
else:
    l = a[0]
    for i in a[1:]:
        l = lcm(l, i)
    b = []
    for i in a:
        b.append(l//i)
    ans = sum(b) % (10 ** 9 + 7)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

n = int(input())
a = [int(i) for i in input().split()]
l = a[0]
for i in a[1:]:
    l = lcm(l,i)
b = []
for i in a:
    b.append(l//i)
ans = sum(b) % (10 ** 9 + 7)
print(ans)
Problem p02990 (python)

Fixed submission:
n, k = (int(i) for i in input().split())
mod = 10**9 + 7
c = [[1], [1,1]]
for i in range(2,n+10):
    c.append([1] + [(c[i-1][j-1] + c[i-1][j]) % mod for j in range(1,i)] + [1])

for i in range(1, k + 1):
    if n - k + 1 < i or k < i:
        print("0")
    else:
        step1 = c[n-k+1][i]
        step2 = c[k-1][i-1]
        ans = (step1 * step2) % mod
        print(int(ans))

Buggy submission (verdict: Runtime Error):
from math import factorial as f
n, k = (int(i) for i in input().split())
for i in range(1,k+1):
  if n-k+1 < i:
    print("0")
  else:
    u1 = f(n-k+1) / (f(n-k+1-i) * f(i))
    u2 = f(k-1) / (f(k-i) * f(i-1))
    ans = (u1 * u2) % (10**9 + 7)
    print(int(ans))

Buggy submission (verdict: Runtime Error):
from math import factorial as f
n, k = (int(i) for i in input().split())
for i in range(1,k+1):
    u1 = f(n-k+1) / (f(n-k+1-i) * f(i))
    u2 = f(k-1) / (f(k-i) * f(i-1))
    ans = (u1 * u2) % (10**9 + 7)
    print(int(ans))

Buggy submission (verdict: Runtime Error):
from math import factorial as f
n, k = (int(i) for i in input().split())
for i in range(1,k+1):
    u1 = f(n-k+1) / (f(n-k+1-i) * f(i))
    u2 = f(k-1) / (f(k-i) * f(i-1))
    ans = (u1 * u2) % (10**9 + 7)
    print(ans)
Problem p03012 (python)

Fixed submission:
n = int(input())
w = [int(i) for i in input().split()]
ans = []
for t in range(n):
    s1 = sum(w[:t])
    s2 = sum(w[t:])
    ans.append(abs(s2-s1))
print(min(ans))

Buggy submission (verdict: Runtime Error):
n = int(input())
w = [int(i) for i in input().split()]
ans = []
for t in range(n):
    s1 = sum(w[:t])
    s2 = sum(w[t:])
print(min(ans))
Problem p02577 (python)

Fixed submission:
n=int(input())
if(n%9==0):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n=int(input())
if(n%9==0):
  print("Yes")
else:
  print("No)
Problem p02629 (python)

Fixed submission:
N = int(input())

az = [chr(i) for i in range(97, 97+26)]

N = N - 1

tmp1 = 0
for i in range(1, 1000):
    tmp1 += 26 ** i
    if tmp1 > N:
        num = i
        tmp1 -= 26 ** i
        N -= tmp1
        break

tmp = [0 for _ in range(num)]
for i in range(num):
    tmp[i] = N%26
    N = N // 26

ans = ""
for i in range(len(tmp)):
    ans = az[tmp[i]] + ans

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
alpha = [chr(i) for i in range(97, 97+26)]

if N <= 26:
    print(alpha[N-1])
else:
    digit = 1
    tmp = 26
    while True:
        if N <= tmp:
            break
        digit += 1
        tmp += 26 ** digit

    ans = ''
    for i in range(digit):
        ans += alpha[N // (26 ** (digit - i - 1)) - 1]
        N = N - ((N // (26 ** (digit - i - 1))) * (26 ** (digit - i - 1)))

    print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
alpha = [chr(i) for i in range(97, 97+26)]

if N <= 26:
    print(alpha[N-1])
else:
    digit = 1
    tmp = 26
    while True:
        if N <= tmp:
            break
        digit += 1
        tmp += 26 ** digit

    ans = ''
    for i in range(digit):
        ans += alpha[N // (26 ** (digit - i - 1)) - 1]
        N = N - N // (26 ** (digit - i - 1)) * (26 ** (digit - i - 1))

    print(ans)
Problem p02659 (python)

Fixed submission:
A, B = map(str, input().split())
A = int(A)

ans = 0
r = 4
for i in range(4):
    if i != 1:
        ans += A * int(B[i]) * (10 ** (r))
        r -= 1

print(ans // 10000)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(int(a*b))
Problem p02689 (python)

Fixed submission:
N, M = map(int, input().split())
H = list(map(int, input().split()))
Q = [list(map(int, input().split())) for _ in range(M)]

tmp = [0 for _ in range(N)]
for i in range(M):
  if H[Q[i][0]-1] >= H[Q[i][1]-1]:
    tmp[Q[i][1]-1] = -1
  if H[Q[i][0]-1]<= H[Q[i][1]-1]:
    tmp[Q[i][0]-1] = -1

print(N + sum(tmp))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
H = list(map(int, input().split()))
root = [list(map(int, input().split())) for _ in range(M)]

is_min = [0 for _ in range(N)]
for i in range(M):
    A = root[i][0] - 1
    B = root[i][1] - 1

    if H[A] > H[B]]:
        is_min[B] = 1

    elif H[A] == H[B]]:
        is_min[A] = 1
        is_min[B] = 1

    else:
        is_min[A] = 1

print(N - sum(is_min))
Problem p02754 (python)

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

pattern = N // (A + B)

ans = 0
ans += A * pattern
ans += min(N - (A + B) * pattern, A)

print(ans)

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

pattern = N // (A + B)

ans += A * pattern
ans += min(N - (A + B) * pattern, A)

print(ans)
Problem p02777 (python)

Fixed submission:
S, T = map(str, input().split())
a, b = map(int, input().split())
u = input()

if S == u:
  print(a-1, b)
else:
  print(a, b-1)

Buggy submission (verdict: Runtime Error):
S, T = map(int, input().split())
a, b = map(int, input().split())
u = input()

if S == u:
  print(a-1, b)
else:
  print(a, b-1)
Problem p02880 (python)

Fixed submission:
N = int(input())

flag = False
for i in range(1, N+1):
  if N%i == 0:
    if N//i < 10 and i < 10:
      flag = True
      break
      
if flag:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())

flag = False
for i in range(N+1):
  if N%i == 0:
    if N//i < 10 and i < 10:
      flag = True
      break
      
if flag:
  print('Yes')
else:
  print('No')
Problem p02881 (python)

Fixed submission:
import math

N = int(input())

res = 10 ** 15
for i in range(1, int(math.sqrt(N))+1):
    if N%i == 0:
        res = min(res, N // i + i)

print(res-2)

Buggy submission (verdict: Runtime Error):
def prime_factor(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

N = int(input())

table = prime_factor(N)
table.sort()

if len(table)%2 == 0:
    tmp1 = 1
    tmp2 = 1
    for i in range(len(table)//2):
        tmp1 *= table[i]
        tmp2 *= table[i+len(table)//2]

    print(tmp1 + tmp2 - 2)

else:
    tmp1 = 1
    tmp2 = 1
    for i in range(len(table)//2):
        tmp1 *= table[i]
        tmp2 *= table[i+len(table)//2+i+1]

    tmp1 *= table[len(table)//2]
    print(tmp1 + tmp2 - 2)
Problem p02916 (python)

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

tmp = -10
res = 0
for i in range(N):
  res += B[A[i]-1]
  
  if A[i] == tmp + 1:
    res += C[tmp-1]
    
  tmp = A[i]
  
print(res)

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

tmp = -10
res = 0
for i in range(N):
  res += B[A[i]-1]
  
  if A[i] == tmp + 1:
    res += C[tmp]
    
  tmp = A[i]
  
print(res)
Problem p02933 (python)

Fixed submission:
あ=int(input())
い=input()

if あ>=3200:
  print(い)
else:
  print('red')

Buggy submission (verdict: Runtime Error):
あ
Problem p03038 (python)

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

A = list(map(int, input().split()))

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

L.sort(reverse=True, key=lambda x:x[1])
A.sort()


ans = 0
i = 0
j = 0
k = 0
for i in range(N):
    if j < M:
        if A[i] < L[j][1]:
            ans += L[j][1]
            k += 1
            
        else:
            ans += A[i]
        
        
        if k == L[j][0]:
            k = 0
            j += 1
            
    else:
        ans += A[i]
        

        
print(ans)

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

A = list(map(int, input().split()))

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

L.sort(reverse=True, key=lambda x:x[1])
A.sort()


ans = 0
i = 0
j = 0
k = 0
for i in range(N):
    if j < M:
        if A[i] < L[j][1]:
            ans += L[j][1]
            k += 1
            
        else:
            ans += A[i]
        
    else:
        ans += A[i]
        
    if k == L[j][0]:
        k = 0
        j += 1
        
print(ans)

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

A = list(map(int, input().split()))

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

L.sort(reverse=True, key=lambda x:x[1])
A.sort()



ans = 0
i = 0
j = 0
k = 0
for i in range(N):
    if A[i] < L[j][1] and j < M:
        ans += L[j][1]
        k += 1
        
    else:
        ans += A[i]
        
    if k == L[j][0]:
        k = 0
        j += 1
        
print(ans)

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

A = list(map(int, input().split()))

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

L.sort(reverse=True, key=lambda x:x[1])
A.sort()



ans = 0
i = 0
j = 0
k = 0
for i in range(N):
    if A[i] < L[j][1]:
        ans += L[j][1]
        k += 1
        
    else:
        ans += A[i]
        
    if k == L[j][0]:
        k = 0
        j += 1
        
print(ans)