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

Fixed submission:
import sys
sys.setrecursionlimit(500000)

N = int(input())
E = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    E[a].append((b, i))
    E[b].append((a, i))

K = max(len(e) for e in E)
print(K)

Ans = [-1] * (N-1)
def dfs(v, pc=-1, p=-1):
    c = 1
    for u, idx in E[v]:
        if (u == p):
            continue
        if (c == pc): 
            c += 1
        Ans[idx] = c
        dfs(u, c, v)
        c += 1

dfs(1)
print("\n".join(map(str, Ans)))

Buggy submission (verdict: Runtime Error):
N = int(input())
E = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    E[a].append((b, i))
    E[b].append((a, i))

K = max(len(e) for e in E)
print(K)

Ans = [-1] * (N-1)
def dfs(v, pc=-1, p=-1):
    c = 1
    for u, idx in E[v]:
        if (u == p):
            continue
        if (c == pc): 
            c += 1
        Ans[idx] = c
        dfs(u, c, v)
        c += 1

dfs(1)
print("\n".join(map(str, Ans)))

Buggy submission (verdict: Runtime Error):
N = int(input())
E = [[] for _ in range(N+1)]
for i in range(N-1):
    a, b = map(int, input().split())
    E[a].append((b, i))
    E[b].append((a, i))

K = max(len(e) for e in E)
print(K)

Ans = [-1] * (N-1)
def dfs(v, pc=-1, p=-1):
    c = 1
    for u, idx in E[v]:
        if (u == p):
            continue
        if (c == pc): 
            c += 1
        Ans[idx] = c
        c += 1
        dfs(u, c, v)
        
dfs(1)
print("\n".join(map(str, Ans)))
Problem p02866 (python)

Fixed submission:
#!/usr/bin/env python3

from collections import Counter

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

MOD = 998244353

def main():
    N = II()
    D = LII()

    if D[0] != 0 or D.count(0) > 1:
       print(0)
       return 
    
    c = Counter(D)
    res = 1

    if c[0] > 1:
       print(0)
       return
    
    mx = max(c.keys())
    for i in range(1, mx+1):
        if i not in c:
            print(0)
            return
        
        res = (res * c[i-1] ** c[i]) % MOD

    print(res)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

from collections import Counter

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    N = II()
    D = LII()

   if D[0] != 0 or D.count(0) > 1:
       print(0)
       return 
    
    mx = max(D)
    cnt = 1
    for i in range(1, mx+1):
        pre = D.count(i)
        post = D.count(i+1)
        cnt *= pre ** post
    print(cnt)

if __name__ == '__main__':
    main()
Problem p02888 (python)

Fixed submission:
import bisect

n=int(input())
L=sorted(list(map(int,input().split())))

ans=0
for i in range(n-1):
  for j in range(i+1,n):
    idx=bisect.bisect_left(L,L[j]+L[i])
    ans+=max(0,idx-j-1)

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
L = list(map(int, input().split()))
ans = 0
c = 0

L.sort()

for i in range(n-2):
    for j in range(i+1, n):
        c = L[i]+L[j]
        l = j
        r = bisect.bisect_left(L, c, lo=l) -1
        ans += (r-l)

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
L = list(map(int, input().split()))
ans = 0
c = 0

L.sort()

for i in range(n-2):
    for j in range(i+1, n):
        c = L[i]+L[j]
        l = j
        r = bisect.bisect_left(L, c, lo=l) -1
        ans += (r-l)

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
L = list(map(int, input().split())
ans = 0
c = 0

L.sort()

for i in range(n-2):
  for j in range(i+1, n):
    c = L[i]+L[j]
    l = j
    r = bisect.bisect_left(L, c, lo=l) -1
    ans += (r-l)

print(ans)
Problem p02900 (python)

Fixed submission:
from fractions import gcd

def FindAllDivisors(x):
    divList = []
    y = 1
    while y <= x**0.5:
        if x % y == 0:
            divList.append(y)
            divList.append(int(x / y))
        y += 1
    return sorted(list(set(divList)))

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

max_divs = gcd(A, B)
divs = FindAllDivisors(max_divs)

results = []
for div in divs[1:]:
    flag = True
    for result in results:
        if div % result == 0:
            flag = False
            break
    if flag:
        results.append(div)

print(len(results) + 1)

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

def FindAllDivisors(x):
    divList = []
    y = 1
    while y <= math.sqrt(x):
        if x % y == 0:
            divList.append(y)
            divList.append(int(x / y))
        y += 1
    return sorted(divList)

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

max_divs = gcd(A, B)

divs = FindAllDivisors(max_divs)

results = []
for div in divs[1:]:
    flag = True
    for result in results:
        if div % result == 0:
            flag = False
            break
    if flag:
        results.append(div)

print(len(results) + 1)

Buggy submission (verdict: Runtime Error):
import math

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

max_divs = math.gcd(A, B)

divs = []
for i in range(1, max_divs+1):
    if max_divs % i == 0:
        divs.append(i)

results = []
for div in divs[1:]:
    flag = True
    for result in results:
        if div % result == 0:
            flag = False
            break
    if flag:
        results.append(div)

print(len(results) + 1)

Buggy submission (verdict: Runtime Error):
import numpy as np

def seachPrimeNum(N):
    max = int(np.sqrt(N)) 
    seachList = [i for i in range(2, N+1)]
    primeNum = []
    while seachList[0] <= max:
        primeNum.append(seachList[0])
        tmp = seachList[0]
        seachList = [i for i in seachList if i % tmp != 0]
    primeNum.extend(seachList)
    primeNum.append(1)
    return set(primeNum)

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

divs_A = set()
for i in range(1, A+1):
    if A % i == 0:
        divs_A.add(i)
        
divs_B = set()
for i in range(1, B+1):
    if B % i == 0:
        divs_B.add(i)

divs = list(divs_A & divs_B)

print(len(set(divs) & seachPrimeNum(max(divs))))
Problem p02923 (python)

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

m = 0
t = 0

pre = H[0]
for hi in H[1:]:
    if pre >= hi:
        t += 1
    else:
        m = max(m, t)
        t = 0
    pre = hi

print(max(m, t))

Buggy submission (verdict: Runtime Error):
m = 0
t = 0
pre = H[0]
for hi in H[1:]:
    if pre > hi:
        t += 1
    else:
        m = max(m, t)
        t = 0
    pre = hi
    
m = max(m, t)
if N == 1:
    print(1)
else:
    print(m)
Problem p02939 (python)

Fixed submission:
S = input()
ans, prev, cur = 0, "", ""
for s in S:
    cur += s
    if cur != prev:
        ans += 1
        prev, cur = cur, ""
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
ans, prev, cur = 0, "", ""
for s in S:
    cur += 
    if cur != prev:
        ans += 1
        prev, cur = cur, ""
print(ans)
Problem p02953 (python)

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

cur = H[0]

f = True
for hi in H[1:]:
  if cur <= hi:
    cur = hi
  elif cur <= hi + 1:
    cur = hi + 1
  else:
    f = False

if f:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
N = int(input())
H = map(int, input().split())
 
f = True
 
for i in range(N - 1):
  if H[i + 1] - H[i] > 1:
    f = False
    break
    
if f:
  print('Yes')
else:
  print('No')

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

f = True

for i in range(N - 1):
  if H[i] - H[i + 1] > 1:
    f = False
    break
    
if f:
  print('Yes')
else:
  print('No')
Problem p02957 (python)

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

Buggy submission (verdict: Runtime Error):
, B = map(int, input().split())
     
if (A + B) % 2 == 0:
  print((A + B) / 2)
else:
  print("IMPOSSIBLE")

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

for k in range(max(A, B)):
  if abs(A - k) == abs(B - k):
    print(k)
    return
    
print("IMPOSSIBLE")
Problem p02982 (python)

Fixed submission:
import numpy as np

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

X = []

for i in range(N):
    X.append([int(i) for i in list(input().split())])

res = 0
X = np.array(X)
for i in range(N):
    for j in range(i + 1, N):
        if np.linalg.norm(X[i] - X[j]).is_integer():
            res += 1

print(res)

Buggy submission (verdict: Runtime Error):
import numpy as np

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

X = []

for i in range(N):
    X.append([int(i) for i in list(input().split())])

res = 0
X = np.array(X)
for i in range(N):
    if i == j:
        continue
    for j in range(i + 1, N):
        if np.linalg.norm(X[i] - X[j]).is_integer():
            res += 1

print(res)

Buggy submission (verdict: Runtime Error):
import numpy as np

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

X = []

for i in range(N):
    X.append([int(i) for i in list(input().split())])

res = 0
X = np.array(X)
for i in range(N):
    if i == j:
        continue
    for j in range(i + 1, N):
        if np.linalg.norm(X[i] - X[j]).is_integer():
            res += 1

print(res)
Problem p02983 (python)

Fixed submission:
L, R = map(int, input().split())

res = 1000000007

if R - L + 1 > 2019:
    print(0)
else:
    amari = [i % 2019 for i in range(L, R + 1)]
    l = len(amari)
    for i in range(l):
        a = amari[i]
        for j in range(i + 1, l):
            b = amari[j]
            res = min(res, a * b % 2019)

    print(res)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())

res = 1000000007

if R - L + 1 > 2019:
    print(0)
else:
    amari = [i % 2019 for i in range(L, R + 1)]
    l = len(amari)
    for i in range(l + 1):
        a = amari[i]
        for j in range(i + 1, l + 1):
            b = amari[j]
            res = min(res, a * b % 2019)

    print(res)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())

res = 1000000007

amari = [i % 2019 for i in range(L, R + 1)]
l = len(amari)

if R - L + 1 > 2019:
    print(0)
else:
    for i in range(l + 1):
        a = amari[i]
        for j in range(i + 1, l + 1):
            b = amari[j]
            res = min(res, a * b % 2019)

    print(res)

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())

res = 1000000007

if R - L > 2019:
    print(0)
else:
    for i in range(L, R + 1):
    a = i % 2019
    for j in range(i + 1, R + 1):
        b = j % 2019
        res = min(res, a * b % 2019)

print(res)
Problem p02995 (python)

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

A, B, C, D = map(int, input().split())

a = (A - 1) // C
b = B // C

c = (A - 1) // D
d = B // D

l = lcm(C, D)

e = (A - 1) // l
f = B // l
    
res = (B - A + 1) - ((b - a) + (d - c) - (f - e))

print(res)

Buggy submission (verdict: Runtime Error):
import math

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

A, B, C, D = map(int, input().split())

a = int((A - 1) / C)
b = int(B / C)

c = int((A - 1) / D)
d = int(B / D)

l = lcm(C, D)

e = int((A - 1) / l)
f = int(B / l)

res = (B - A + 1) - ((b - a) + (d - c)) + (f - e)

print(res)

Buggy submission (verdict: Runtime Error):
import math

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

A, B, C, D = map(int, input().split())

a = (A - 1) // C
b = B // C

c = (A - 1) // D
d = B // D

l = lcm(C, D)

e = (A - 1) // l
f = B // l

res = (B - A + 1) - ((b - a) + (d - c)) + (f - e)

print(res)
Problem p02997 (python)

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

con= (N - 1) * (N - 2) // 2 - K
if con < 0:
    print(-1)
else:
    M = N - 1 + con
    print(M)
    for i in range(2, N+1):
        print(1, i)
    cnt = 0
    for i in range(2, N):
        for j in range(i + 1, N + 1):
            cnt += 1
            if cnt > con:
                break
            print(i, j)
        if cnt > con:
            break

Buggy submission (verdict: Runtime Error):
condition = (N - 1) * (N - 2) // 2 - K
if condition < 0:
    print(-1)

M = 0
for i in range(2, N+1):
    M += 1
    print(1, i)

for i in range(3, 3 + N - 1 - K):
    M += 1
    print(2, i)
Problem p03001 (python)

Fixed submission:
W, H, x, y = map(int, input().split())
     
res1 = W * H / 2
res2 = int((2*x == W) and (2*y == H))
     
print(res1, res2)

Buggy submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())

if (W == x and H == Y):
    res1 = W * H / 2
    res2 = 0
else:
    tate1 = (W - x) * H
    tate2 = x * H 
    tate = min(tate1, tate2)

    yoko1 = W * (H - y)
    yoko2 = W * y
    yoko = min(yoko1, yoko2)

    res1 = max(yoko, tate)
    res2 = int(yoko == tate)

print(res1, res2)
Problem p03029 (python)

Fixed submission:
a, p = map(int, input().split())
print(int((3*a+p)/2))

Buggy submission (verdict: Runtime Error):
N = int(input())
a = []
for i in range(N):
    s, p = input().split()
    p = -int(p)
    a.append(s, p , i + 1)
    
a.sort()

print('\n'.join(str(ai[2]) for ai in a))

Buggy submission (verdict: Runtime Error):
a, p = map(int(), input().split())
print(int((3*a+p)/2))

Buggy submission (verdict: Runtime Error):
a, p = map(int(), input().split())

print(int((a * 3 + p) / 2))

Buggy submission (verdict: Runtime Error):
a, p = map(int(), input())

print((a*3 + p) // 2)

Buggy submission (verdict: Runtime Error):
a, p = map(int(), input().split())

ans = (a * 3 + p) // 2

print("{}".format(ans))
Problem p03089 (python)

Fixed submission:
from queue import Queue

def solve():
    N = int(input())
    b = list(map(int, input().split()))
    idx = [i+1 for i in reversed(range(N))]
    
    l = []
    for i in range(N):
        for bi, j in zip(reversed(b), idx):
            if j == bi:
                l.append(str(j))
                break
        del idx[0], b[j-1]
    
    return '\n'.join(reversed(l)) if len(l) == N else -1

print(solve())

Buggy submission (verdict: Runtime Error):
def solve():
    N = input()
    a = ['']
    for i in input().split():
        a.inser(int(i)-1, i)
    return *a[-1]and[-1]or a

print(solve())

Buggy submission (verdict: Runtime Error):
def solve()
    N = input()
    a = ['']
    for i in input().split():
        a.inser(int(i)-1, i)
    return *a[-1]and[-1]or a

print(solve())
Problem p03196 (python)

Fixed submission:
def solve():
    N, P = map(int, input().split())
    
    ans = 1
    if N==1:
        return P
    else:
        for i in range(2, int(P**(1/N)+1)):
            while P % (i**N) == 0:
                ans *= i
                P //= (i**N)
        return ans
print(solve())

Buggy submission (verdict: Runtime Error):
def solve():
    N, P = map(int, input().split())
    
    ans = 1
    if n==1:
        return P
    else:
        for i in range(2, int(P**(1/N)+1)):
            while P % (i**N) == 0:
                ans *= i
                P //= (i**N)
        return ans
print(solve())
Problem p03220 (python)

Fixed submission:
import numpy as np

N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

ans = 1
mn = np.inf
for i, h in enumerate(H):
    if mn > abs(A - (T - h * 0.006)):
        ans = i+1
        mn = abs(A - (T - h * 0.006))
print(ans)

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

ans = 1
mn = np.inf
for i, h in enumerate(H):
    if mn > abs(A - (T - h * 0.006)):
        ans = i+1
        mn = abs(A - (T - h * 0.006))
print(ans)
Problem p03244 (python)

Fixed submission:
from collections import Counter

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

if len(set(v)) == 1:
    print(n//2)
else:
    c1 = Counter(v[0::2])
    c2 = Counter(v[1::2])
    
    c1m = c1.most_common(2)
    c2m = c2.most_common(2)
    
    if c1m[0][0] != c2m[0][0]:
        print(n-c1m[0][1]-c2m[0][1])
    else:
        mn = n
        if len(set(c1)) > 1:
            mn = min(mn, n-c1m[1][1]-c2m[0][1])
        if len(set(c2)) > 1:
            mn = min(mn, n-c1m[0][1]-c2m[1][1])
            
        print(mn)

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

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

if len(set(v)) == 1:
    print(n//2)
else:
    c1 = Counter(v[0::2])
    c2 = Counter(v[1::2])
    
    c1m = c1.most_common(1)[0]
    c2m = c2.most_common(1)[0]
    
    ans1 = n//2-c2m[1]
    if c1m[0] != c2m[0]:
        ans1 += n//2-c1m[1]
    else:
        ans1 += n//2-c1.most_common(2)[1][1]
    
    ans2 += n//2-c1m[1]
    if c1m[0] != c2m[0]:
        ans2 += n//2-c2m[1]
    else:
        ans2 += n//2-c2.most_common(2)[1][1]
    print(min(ans1, ans2))

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

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

if len(set(v)) == 1:
    print(n//2)
else:
    c1 = Counter(v[0::2])
    c2 = Counter(v[1::2])
    
    c1m = c1.most_common(1)[0]
    c2m = c2.most_common(1)[0]
    
    ans1 = n//2-c2m[1]
    if c1m[0] != c2m[0]:
      ans1 += n//2-c1m[1]
      else:
        ans1 += n//2-c1.most_common(2)[1][1]
    
    ans2 += n//2-c1m[1]
    if c1m[0] != c2m[0]:
      ans2 += n//2-c2m[1]
      else:
        ans2 += n//2-c2.most_common(2)[1][1]
    print(min(ans1, ans2))
Problem p03262 (python)

Fixed submission:
import numpy as np
import fractions
from functools import reduce

def gcd(numbers):
    return reduce(fractions.gcd, numbers)

N, X = map(int, input().split())
x = np.array(list(map(int, input().split())))
if N == 1:
    print(np.abs(x[0] - X))
else:
    x = np.abs(x - X)
    print(gcd(x))

Buggy submission (verdict: Runtime Error):
import numpy as np
from functools import reduce

def gcd(*numbers):
    return reduce(np.gcd, numbers)

N, X = map(int, input().split())
x = np.array(list(map(int, input().split())))
if N == 1:
    print(np.abs(x[0] - X))
else:
    x = np.abs(x - X)
    print(min(gcd(x)))

Buggy submission (verdict: Runtime Error):
import numpy as np
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

N, X = map(int, input().split())
x = np.array(list(map(int, input().split())))
if N == 1:
    print(np.abs(x[0] - X))
else:
    x = np.abs(x - X)
    print(min(gcd(x)))
Problem p03319 (python)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
 
print((N-2)//(K-1)+1)

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

if A.index(1) + N - A.index(1) - 1 < K:
    print(1)
else:
    print(int(np.ceil(A.index(1)/(K-1))+np.ceil((N - A.index(1) - 1)/(K-1))))
Problem p03352 (python)

Fixed submission:
X = int(input())

e = [0 for _ in range(X+1)]
e[1] = 1
for i in range(2, X):
    v = i*i
    while v <= X:
        e[v] = 1
        v *= i
        
for i in range(X, 0, -1):
    if e[i] == 1:
        print(i)
        break

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

e = [0 for _ in range(X+1)]
e[1] = 1
for i in range(2, X):
    v = i*i
    while v <= X:
        e[v] = 1
        v *= b
        
for i in range(X, 0, -1):
    if e[i] == 1:
        print(i)
        break
Problem p03425 (python)

Fixed submission:
import numpy as np
from itertools import combinations
from functools import reduce
from collections import defaultdict

N = int(input())
d = defaultdict(int)
for i in range(N):
    c = input()
    if c[0] in ('M', 'A', 'R', 'C', 'H'):
        d[c[0]] += 1

l = len(d)
if l < 3:
    print(0)
else:
    ans = 0
    for l in list(combinations(d.values(), 3)):
        ans += reduce(np.multiply, l)
    print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
from itertools
from functools import reduce
from collections import defaultdict

N = int(input())
d = defaultdict(int)
for i in range(N):
    c = input()
    if c[0] in ('M', 'A', 'R', 'C', 'H'):
        d[c[0]] += 1

l = len(d)
if l < 3:
    print(0)
else:
    ans = 0
    for l in list(itertools.combinations(d.values(), 3)):
        ans += reduce(np.multiply, l)
    print(ans)
Problem p03427 (python)

Fixed submission:
N = input()
l = len(N)

if N[1::] == '9'*(l-1):
    print(int(N[0])+9*(l-1))
else:
    print(int(N[0])-1+9*(l-1))

Buggy submission (verdict: Runtime Error):
N = input()
l = len(N)

s = '9'*(l-1)
if N[i::] == s:
    print(int(N[0])+9*(l-1))
else:
    print(int(N[0])-1+9*(l-1))

Buggy submission (verdict: Runtime Error):
N = input()
l = len(N)

if N[i::] == '9'*(l-1):
    print(int(N[0])+9*(l-1))
else:
    print(int(N[0])-1+9*(l-1))

Buggy submission (verdict: Runtime Error):
N = input()
l = len(N)

if N[i::] == "9"*(l-1):
    print(int(N[0])+9*(l-1))
else:
    print(int(N[0])-1+9*(l-1))

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

l = len(N)

if N[i::] == "9"*(l-1):
    print(int(N[0])+9*(l-1))
else:
    print(int(N[0])-1+9*(l-1))

Buggy submission (verdict: Runtime Error):
N = input()
l = len(N)

if n[i::] == "9"*(l-1):
    print(int(n[0])+9*(l-1))
else:
    print(int(n[0])-1+9*(l-1))

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

l = len(N)
j = "9"*(l-1)

if n[i::] == j:
    print(int(n[0])+9*(n-1))
else:
    print(int(n[0])-1+9*(k-1))
Problem p03449 (python)

Fixed submission:
import numpy as np

N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

m = np.zeros((2, N)).astype(int)
m[0][0] = A1[0]
m[1][0] = A2[0] + A1[0] 

for i in range(1, N):
    m[0][i] = A1[i]+m[0][i-1]
    m[1][i] = max(A2[i]+m[1][i-1], A2[i]+m[0][i])
    
print(m[1][N-1])

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

m = np.zeros((2, N)).astype(int)
m[0][0] = A1[0]
m[1][0] = A2[0] + A1[0] 

for i in range(1, N):
    m[0][i] = A1[i]+m[0][i-1]
    m[1][i] = max(A2[i]+m[1][i-1], A2[i]+m[0][i])
    
print(m[1][N-1])
Problem p03474 (python)

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

n = [str(i) for i in range(10)]
flag = False
for i in range(A):
    if S[i] not in n:
        flag = True
        
if S[A] != '-':
    flag = True
    
for i in range(A+1, A+B+1):
    if S[i] not in n:
        flag = True
        
if flag:
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
n = [str(i) for i in range(10)]
flag = False
for i in range(A):
    if S[i] not in n:
        flag = True
        
if S[A] != '-':
    flag = True
    
for i in range(A+1, A+B+1):
    if S[i] not in n:
        flag = True
        
if flag:
    print('No')
else:
    print('Yes')
Problem p03627 (python)

Fixed submission:
from collections import Counter

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

p = []
l = []
for k, v in A.items():
    if v >= 4:
        p.append(k)
    if v >= 2:
        l.append(k)

ans = 0
if len(p) >= 1:
    p.sort()
    ans = p[-1]**2
if len(l) >= 2:
    l.sort()
    ans = max(l[-1] * l[-2], ans)
print(ans)

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

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

p = []
l = []
for k, v in A.items():
    if v >= 4:
        p.append(k)
    if v >= 2:
        l.append(k)
if len(l) >= 2:
    p.sort()
    l.sort()
    print(max(l[-1] * l[-2], p[-1]**2))
else:
    print(0)
Problem p03838 (python)

Fixed submission:
x, y = map(int, input().split())

f = lambda x: 10**10 if x < 0 else x

print(min(f(y-x), f(y+x)+1, f(-y-x)+1, f(-y+x)+2))

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())

def f(x):
    return 10**10 if x < 0 else x

print(min(f(y-x), f(y+x)+1, f(-y-x)+1, f(-y+x2)))

Buggy submission (verdict: Runtime Error):
x, y = map(int, input().split())
mn = 10**9

f = lambda x: mn if x < 0 else x

print(min(f(y-x), f(y+x)+1, f(-y-x)+1, f(-y+x2)))