Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]

n,q = LI()

v = [[] for i in range(n)]
for i in range(n-1):
	a,b = LI()
	a -= 1
	b -= 1
	v[a].append(b)
	v[b].append(a)

f = [0]*n
for i in range(q):
	p,x = LI()
	p -= 1
	f[p] += x

def dfs(x,d,s):
	for y in v[x]:
		if d[y]:
			s += f[y]
			ans[y] = s
			d[y] = 0
			dfs(y,d,s)
			s -= f[y]

ans = [0]*n
d = [1]*n
d[0] = 0
ans[0] = f[0]
s = f[0]
dfs(0,d,s)
print(*ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

def LI(): return [int(x) for x in sys.stdin.readline().split()]

n,q = LI()

v = [[] for i in range(n)]
for i in range(n-1):
	a,b = LI()
	a -= 1
	b -= 1
	v[a].append(b)
	v[b].append(a)

f = [0]*n
for i in range(q):
	p,x = LI()
	p -= 1
	f[p] += x

def dfs(x,d,s):
	for y in v[x]:
		if d[y]:
			s += f[y]
			ans[y] = s
			d[y] = 0
			dfs(y,d,s)
			s -= f[y]

ans = [0]*n
d = [1]*n
d[0] = 0
ans[0] = f[0]
s = f[0]
dfs(0,d,s)
print(*ans)

Buggy python submission (verdict: Runtime Error):
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]

n,q = LI()

v = [[] for i in range(n)]
for i in range(n-1):
	a,b = LI()
	a -= 1
	b -= 1
	v[a].append(b)

f = [0]*n
for i in range(q):
	p,x = LI()
	p -= 1
	f[p] += x

def dfs(x,d,s):
	for y in v[x]:
		if d[y]:
			s += f[y]
			ans[y] = s
			d[y] = 0
			dfs(y,d,s)
			s -= f[y]

ans = [0]*n
d = [1]*n
d[0] = 0
ans[0] = f[0]
s = f[0]
dfs(0,d,s)
print(*ans)
d = [1]*n
d[0] = 0
ans[0] = f[0]
s = f[0]
dfs(0,d,s)
print(*ans)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)

def LI(): return [int(x) for x in sys.stdin.readline().split()]

n,q = LI()

v = [[] for i in range(n)]
for i in range(n-1):
	a,b = LI()
	a -= 1
	b -= 1
	v[a].append(b)
	v[b].append(a)

f = [0]*n
for i in range(q):
	p,x = LI()
	p -= 1
	f[p] += x

def dfs(x,d,s):
	for y in v[x]:
		if d[y]:
			s += f[y]
			ans[y] = s
			d[y] = 0
			dfs(y,d,s)
			s -= f[y]

ans = [0]*n
d = [1]*n
d[0] = 0
ans[0] = f[0]
s = f[0]
dfs(0,d,s)
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
import collections
import math
n = int(input())
s = [0]*n
T = [0]*n
ans = 0
for i in range(n):
	s[i] = input()
	T[i] = sorted(list(s[i]))
for i in range(n-1):
	for j in range(i+1,n):
		if T[i] == T[j]:
			ans += 1
print(ans)

Fixed submission:
import collections
import math
n = int(input())
s = [0]*n
T = [0]*n
L = [0]*n
ans = 0
for i in range(n):
	s[i] = input()
	T[i] = sorted(list(s[i]))
	L[i] = ''.join(T[i])
D = collections.Counter(L)
for i in D.values():
	ans += i*(i-1)/2
print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
s = [0]*n
c = {}
ans = 0
for i in range(n):
	s[i] = input()
	c[i] = collections.Counter(list(s[i]))
for i in range(n-1):
	for j in range(i+1,n):
		if c[i] == c[j]:
			ans += 1
print(ans)

Fixed submission:
import collections
import math
n = int(input())
s = [0]*n
T = [0]*n
L = [0]*n
ans = 0
for i in range(n):
	s[i] = input()
	T[i] = sorted(list(s[i]))
	L[i] = ''.join(T[i])
D = collections.Counter(L)
for i in D.values():
	ans += i*(i-1)/2
print(int(ans))
Buggy python submission (verdict: Runtime Error):
n,x = map(int,input().split())
L = list(map(int,input().split()))
D = 0
c = 0

while D <= x:
	D += L[c]
	c += 1
print(c)

Fixed submission:
n,x = map(int,input().split())
L = list(map(int,input().split()))
D = 0
c = 0

for i in range(n):
	if D <= x:
		c += 1
	D += L[i]
if D <= x:
	print(c+1)
else:
	print(c)
Buggy python submission (verdict: Runtime Error):
n,q = map(int,input().split())
s = input()
l = [0]*q
r = [0]*q
for i in range(q):
	l[i],r[i] = map(int,input().split())
c = [0]*(len(s)+1)
for i in range(len(s)):
	if s[i] == 'A' and s[i+1] == 'C':
		c[i+1] += c[i] + 1
	else:
		c[i+1] = c[i]
for i in range(q):
	print(c[r[i]-1]-c[l[i]-1])

Fixed submission:
n,q = map(int,input().split())
s = input()
l = [0]*q
r = [0]*q
for i in range(q):
	l[i],r[i] = map(int,input().split())
c = [0]*(len(s)+1)
for i in range(len(s)-1):
	if s[i] == 'A' and s[i+1] == 'C':
		c[i+1] += c[i] + 1
	else:
		c[i+1] = c[i]
for i in range(q):
	print(c[r[i]-1]-c[l[i]-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int,input().split()))
for i in range(n):
	L = x[:i] + x[i+1:]
	M = sorted(L)
	print(M[n//2-1])

Fixed submission:
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
for i in range(n):
	if x[i] <= y[n//2-1]:
		print(y[n//2])
	else:
		print(y[n//2-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
l = [0]*n
max = 0

for j in range(n):
	L = [a[j] for i in range(n) if abs(a[i] - a[j]) <= 1]
	if max < len(L):
		max = len(L)
print(max)

Fixed submission:
import collections
n = int(input())
a = list(map(int,input().split()))
M = 1

c = collections.Counter(a)

for x in range(max(a) + 2):
	d = c[x] + c[x-1] + c[x+1]
	if d >= M:
		M = d

print(M)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n[0] == n[2]:
	print('Yes')
else:
	print('No')

Fixed submission:
n = input()
if n[0] == n[2]:
	print('Yes')
else:
	print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N >= 400 and N <= 599:
    pirint(8)
elif N >= 600 and N <= 799:
    print(7)
elif N >= 800 and N <= 999:
    print(6)
elif N >= 1000 and N <= 1199:
    print(5)
elif N >= 1200 and N <= 1399:
    print(4)
elif N >= 1400 and N <= 1599:
    print(3)
elif N >= 1600 and N <= 1799:
    print(2)
else:
    print(1)

Fixed submission:
N = int(input())

if N >= 400 and N <= 599:
    print(8)
elif N >= 600 and N <= 799:
    print(7)
elif N >= 800 and N <= 999:
    print(6)
elif N >= 1000 and N <= 1199:
    print(5)
elif N >= 1200 and N <= 1399:
    print(4)
elif N >= 1400 and N <= 1599:
    print(3)
elif N >= 1600 and N <= 1799:
    print(2)
else:
    print(1)

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

if N <= 599:
    pirint(8)
elif N >= 600 and N <= 799:
    print(7)
elif N >= 800 and N <= 999:
    print(6)
elif N >= 1000 and N <= 1199:
    print(5)
elif N >= 1200 and N <= 1399:
    print(4)
elif N >= 1400 and N <= 1599:
    print(3)
elif N >= 1600 and N <= 1799:
    print(2)
else:
    print(1)

Fixed submission:
N = int(input())

if N >= 400 and N <= 599:
    print(8)
elif N >= 600 and N <= 799:
    print(7)
elif N >= 800 and N <= 999:
    print(6)
elif N >= 1000 and N <= 1199:
    print(5)
elif N >= 1200 and N <= 1399:
    print(4)
elif N >= 1400 and N <= 1599:
    print(3)
elif N >= 1600 and N <= 1799:
    print(2)
else:
    print(1)

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

if N <= 599:
    pirint(8)
elif N >= 600 and N <= 799:
    print(7)
elif N >= 800 and N <= 999:
    print(6)
elif N >= 1000 and N <= 1199:
    print(5)
elif N >= 1200 and N <= 1399:
    print(4)
elif N >= 1400 and N <= 1599:
    print(3)
elif N >= 1600 and N <= 1799:
    print(2)
elif N >= 1800 and N <= 1999:
    print(1)

Fixed submission:
N = int(input())

if N >= 400 and N <= 599:
    print(8)
elif N >= 600 and N <= 799:
    print(7)
elif N >= 800 and N <= 999:
    print(6)
elif N >= 1000 and N <= 1199:
    print(5)
elif N >= 1200 and N <= 1399:
    print(4)
elif N >= 1400 and N <= 1599:
    print(3)
elif N >= 1600 and N <= 1799:
    print(2)
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
import collections
n = int(input())
arr = list(map(int,input().split()))
cnt = collections.defaultdict(int)
for val in arr:
    cnt[val] += 1
sums = sum(arr)
q = int(input())
for _ in range(q):
    b, c = map(int,input().split())
    diff = (c-b)*(cnt[b])
    sums += diff
    print(sums)
    cnt[c] += nt[b]
    cnt[b] = 0

Fixed submission:
import collections
n = int(input())
arr = list(map(int,input().split()))
cnt = collections.defaultdict(int)
for val in arr:
    cnt[val] += 1
sums = sum(arr)
q = int(input())
for _ in range(q):
    b, c = map(int,input().split())
    diff = (c-b)*(cnt[b])
    sums += diff
    print(sums)
    cnt[c] += cnt[b]
    cnt[b] = 0

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
change = [list(map(int, input().split())) for i in range(q)]
for i in range(q):
    a = [change[i][1] if j == change[i][0] else j for j in a]
    print(sum(a))

Fixed submission:
import collections
n = int(input())
arr = list(map(int,input().split()))
cnt = collections.defaultdict(int)
for val in arr:
    cnt[val] += 1
sums = sum(arr)
q = int(input())
for _ in range(q):
    b, c = map(int,input().split())
    diff = (c-b)*(cnt[b])
    sums += diff
    print(sums)
    cnt[c] += cnt[b]
    cnt[b] = 0

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
q = int(input())
change = [list(map(int, input().split())) for i in range(q)]
sm = sum(a)
tmp = 0
for i in range(q):
    sm += a.count(change[i][0]) * (change[i][1] - change[i][0])
    print(sm)
    a = [change[i][1] if j == change[i][0] else j for j in a]

Fixed submission:
import collections
n = int(input())
arr = list(map(int,input().split()))
cnt = collections.defaultdict(int)
for val in arr:
    cnt[val] += 1
sums = sum(arr)
q = int(input())
for _ in range(q):
    b, c = map(int,input().split())
    diff = (c-b)*(cnt[b])
    sums += diff
    print(sums)
    cnt[c] += cnt[b]
    cnt[b] = 0
Buggy python submission (verdict: Runtime Error):
X, N = map(int,input().split())
LP = []
for i in range(N):
    LP.append(list(map(int, input().split())))

if N == 0:
    print(X)

else:
    for i in range(100):
        ans = X - i
        if ans not in LP:
            print(ans)
            break
        else:
            dans = X + i
            if dans not in LP:
                print(dans)
                break

Fixed submission:
X, N = map(int,input().split())
if N == 0:
    print(X)
    exit()
LP = list(map(int, input().split()))


for i in range(100):
    ans = X - i
    if ans not in LP:
        print(ans)
        exit()
    else:
        dans = X + i
        if dans not in LP:
            print(dans)
            exit()

Buggy python submission (verdict: Runtime Error):
X, N = map(int,input().split())
LP = [list(map(int, input().split())) for i in range(N)]

if N == 0:
    print(X)

else:
    for i in range(100):
        ans = X - i
        if ans not in LP:
            print(ans)
            break
        else:
            dans = X + i
            if dans not in LP:
                print(dans)
                break

Fixed submission:
X, N = map(int,input().split())
if N == 0:
    print(X)
    exit()
LP = list(map(int, input().split()))


for i in range(100):
    ans = X - i
    if ans not in LP:
        print(ans)
        exit()
    else:
        dans = X + i
        if dans not in LP:
            print(dans)
            exit()

Buggy python submission (verdict: Runtime Error):
X, N = map(int,input().split())
LP = [list(map(int, input().split())) for i in range(N)]

if N == 0:
    print(X)

else:
    for i in range(1,100):
        ans = X - i
        if ans not in LP:
            print(ans)
            break
        else:
            dans = X + i
            if dans not in LP:
                print(dans)
                break

Fixed submission:
X, N = map(int,input().split())
if N == 0:
    print(X)
    exit()
LP = list(map(int, input().split()))


for i in range(100):
    ans = X - i
    if ans not in LP:
        print(ans)
        exit()
    else:
        dans = X + i
        if dans not in LP:
            print(dans)
            exit()
Buggy python submission (verdict: Time Limit Exceeded):
from operator import mul
from functools import reduce

N = int(input())
x = [int(i) for i in input().split()]
y = reduce(mul, x)

if y > 10**18:
    print(-1)
else:
    print(y)

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

now=1
if 0 in A:
    print(0)
    exit()
for a in A:
    now = now * a
    if now>10**18:
        print(-1)
        exit()
print(now)

Buggy python submission (verdict: Runtime Error):
from operator import mul
from functools import reduce

N = int(input())
x = [int(input()) for i in range(N)]
y = reduce(mul, x)

if y > 10**18:
    print(-1)
else:
    print(y)

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

now=1
if 0 in A:
    print(0)
    exit()
for a in A:
    now = now * a
    if now>10**18:
        print(-1)
        exit()
print(now)
Buggy python submission (verdict: Runtime Error):
A = int(input())
B = str(input())
b = int(B.replace(".",""))
print(A * b // 100)

Fixed submission:
a, b = map(str, input().split())
a = int(a)
b = int(b.replace('.', ''))
print(a*b//100)

Buggy python submission (verdict: Runtime Error):
A = int(input())
B = input()
b = int(B.replace(".",""))
print(A * b // 100)

Fixed submission:
a, b = map(str, input().split())
a = int(a)
b = int(b.replace('.', ''))
print(a*b//100)

Buggy python submission (verdict: Runtime Error):
A = int(input())
B = float(input())

C = B*100
print(A * C // 100)

Fixed submission:
a, b = map(str, input().split())
a = int(a)
b = int(b.replace('.', ''))
print(a*b//100)

Buggy python submission (verdict: Runtime Error):
A, B = map(int,input().split())
print(math.floor(A*B))

Fixed submission:
a, b = map(str, input().split())
a = int(a)
b = int(b.replace('.', ''))
print(a*b//100)
Buggy python submission (verdict: Runtime Error):
N = int(input())
n = N[-1]
if n == "2" or n == "4" or n == "5" or n == "7" or n == "9":
    print("hon")
elif n == "0" or n == "1" or n == "6" or n == "8":
    print("pon")
else:
    print("bon")

Fixed submission:
N = input()
n = N[-1]
if n == "2" or n == "4" or n == "5" or n == "7" or n == "9":
    print("hon")
elif n == "0" or n == "1" or n == "6" or n == "8":
    print("pon")
else:
    print("bon")

Buggy python submission (verdict: Runtime Error):
N = int(input())
n = N[-1]
if n == 2 or n == 4 or n == 5 or n == 7 or n == 9:
    print("hon")
elif n == 0 or n == 1 or n == 6 or n == 8:
    print("pon")
else:
    print("bon")

Fixed submission:
N = input()
n = N[-1]
if n == "2" or n == "4" or n == "5" or n == "7" or n == "9":
    print("hon")
elif n == "0" or n == "1" or n == "6" or n == "8":
    print("pon")
else:
    print("bon")

Buggy python submission (verdict: Runtime Error):
N = int(input())
if N[-1] == 2 or N[-1] == 4 or N[-1] == 5 or N[-1] == 7 or N[-1] == 9:
    print("hon")
elif N[-1] == 0 or N[-1] == 1 or N[-1] == 6 or N[-1] == 8:
    print("pon")
else:
    print("bon")

Fixed submission:
N = input()
n = N[-1]
if n == "2" or n == "4" or n == "5" or n == "7" or n == "9":
    print("hon")
elif n == "0" or n == "1" or n == "6" or n == "8":
    print("pon")
else:
    print("bon")

Buggy python submission (verdict: Runtime Error):
N = int(input())
if N[-1] == 2 or 4 or 5 or 7 or 9:
    print("hon")
elif N[-1] == 0 or 1 or 6 or 8:
    print("pon")
else:
    print("bon")

Fixed submission:
N = input()
n = N[-1]
if n == "2" or n == "4" or n == "5" or n == "7" or n == "9":
    print("hon")
elif n == "0" or n == "1" or n == "6" or n == "8":
    print("pon")
else:
    print("bon")
Buggy python submission (verdict: Runtime Error):
A, B, C, K = map(int,input().split())
print(max(A*1*K + B*0*(K-A) + C*-1*(K-A-B)))

Fixed submission:
A, B, C, K = map(int,input().split())
if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(A + -1*(K-A-B))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
HW = list(map(int,input().split()))

L = N - sum(HW)
if L < 0:
    print(-1)
else:
    print(L)

Fixed submission:
R = int(input())
C = 2*R*3.14
print(C)
Buggy python submission (verdict: Runtime Error):
N = int(input())
M = int(input())
List = [int(input()) for i in range(M)]

for i in range(M):
    N = N - i
    if N < 0:
        print(-1)
        break
print(N)

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

L = N - sum(HW)
if L < 0:
    print(-1)
else:
    print(L)
Buggy python submission (verdict: Runtime Error):
N = input(int())
for i in range(1, N+1):
    if i % 15 == 0:
        i = "FizzBuzz"
    elif i % 3 == 0:
        i = "Fizz"
    elif i % 5 == 0:
        i = "Buzz"
    else:
        i = i
        print(sum(i))

Fixed submission:
N = int(input())

list = [i for i in range(1, N+1) if not (i % 3 == 0 or i % 5 ==0)]

print(sum(list))
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
list = [int(i) for i input().split()]

total = 0
for i in range(N):
    if i >= (sum(list) / (4 * M)):
        total = total + 1

if total >= M:
    print("Yes")
else:
    print('No')

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

total = 0
for i in A:
    if i >= (sum(A) / (4 * M)):
        total = total + 1

if total >= M:
    print("Yes")
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
list = [int(i) for i input().split()]

total = 0
for i in range(N):
    if i >= (sum(list) / (4 * M)):
        total = total + 1

if total >= M:
    print("Yes")
else:
    print('No')

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

total = 0
for i in A:
    if i >= (sum(A) / (4 * M)):
        total = total + 1

if total >= M:
    print("Yes")
else:
    print('No')

Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())
list = [int(i) for i input().split()]

total = 0
for i in range(N):
    if i >= sum(list) / (4 * M):
        total = total + 1

if total >= M:
    print("Yes")
else:
    print('No')

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

total = 0
for i in A:
    if i >= (sum(A) / (4 * M)):
        total = total + 1

if total >= M:
    print("Yes")
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import itertools

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

if N == 1:
    c1 = 0
else:
    c1 = len(list(itertools.combinations(N, 2)))

if M == 1:
    c2 = 0
else:
    c2 = len(list(itertools.combinations(M, 2)))

c3 = c1 + c2
print(c3)

Fixed submission:
import itertools

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

if N == 1:
    c1 = 0
else:
    c1 = len(list(itertools.combinations(range(N), 2)))

if M == 1:
    c2 = 0
else:
    c2 = len(list(itertools.combinations(range(M), 2)))

c3 = c1 + c2
print(c3)

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

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

if N == 1:
    c1 = 0
else:
    c1 = comb(N, 2, exact = False)

if M == 1:
    c2 = 0
else:
    c2 = comb(M, 2, exact = False)

c3 = c1 + c2
print(c3)

Fixed submission:
import itertools

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

if N == 1:
    c1 = 0
else:
    c1 = len(list(itertools.combinations(range(N), 2)))

if M == 1:
    c2 = 0
else:
    c2 = len(list(itertools.combinations(range(M), 2)))

c3 = c1 + c2
print(c3)

Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

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

if N == 1:
    c1 = 0
else:
    c1 = comb(N, 2, exact=True)

if M == 1:
    c2 = 0
else:
    c2 = comb(M, 2, exact=True)

c3 = c1 + c2
print(c3)

Fixed submission:
import itertools

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

if N == 1:
    c1 = 0
else:
    c1 = len(list(itertools.combinations(range(N), 2)))

if M == 1:
    c2 = 0
else:
    c2 = len(list(itertools.combinations(range(M), 2)))

c3 = c1 + c2
print(c3)

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

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

if N == 1:
    c1 = 0
else:
    c1 = len(list(itertools.combinations(N, 2)))

if M == 1:
    c2 = 0
else:
    c2 = len(list(itertools.combinations(M, 2)))

c3 = c1 + c2
print(c3)

Fixed submission:
import itertools

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

if N == 1:
    c1 = 0
else:
    c1 = len(list(itertools.combinations(range(N), 2)))

if M == 1:
    c2 = 0
else:
    c2 = len(list(itertools.combinations(range(M), 2)))

c3 = c1 + c2
print(c3)

Buggy python submission (verdict: Runtime Error):
from scipy import special

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

if N == 1:
    c1 = 0
else:
    c1 = special.comb(N, 2)

if M == 1:
    c2 = 0
else:
    c2 = special.comb(M, 2)

c3 = c1 + c2
print(c3)

Fixed submission:
import itertools

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

if N == 1:
    c1 = 0
else:
    c1 = len(list(itertools.combinations(range(N), 2)))

if M == 1:
    c2 = 0
else:
    c2 = len(list(itertools.combinations(range(M), 2)))

c3 = c1 + c2
print(c3)

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

if N == 1:
    c1 = 0
else:
    c1 = N! / (2! * (N - 2)!)

if M == 1:
    c2 = 0
else:
    c2 = M! / (2! * (M - 2)!)

print(c1 + c2)

Fixed submission:
import itertools

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

if N == 1:
    c1 = 0
else:
    c1 = len(list(itertools.combinations(range(N), 2)))

if M == 1:
    c2 = 0
else:
    c2 = len(list(itertools.combinations(range(M), 2)))

c3 = c1 + c2
print(c3)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if min(P[:i+1]) == P[i]:
        cnt += 1
print(cnt)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
cnt = 1
minp =P[0]
for i in range(1, N):
    if minp >= P[i]:
        cnt += 1
    minp = min(minp, P[i])
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
P = list(map(int, input().split()))
cnt = 0
for i in range(N):
    if min(P[:i+1]) == P[i]:
        cnt += 1
print(cnt)

Fixed submission:
N = int(input())
P = list(map(int, input().split()))
cnt = 1
minp =P[0]
for i in range(1, N):
    if minp >= P[i]:
        cnt += 1
    minp = min(minp, P[i])
print(cnt)
Buggy python submission (verdict: Runtime Error):
s, t = map(input())
print(t+s)

Fixed submission:
s, t = input().split()
print(t+s)

Buggy python submission (verdict: Runtime Error):
s, t = input()
print(t+s)

Fixed submission:
s, t = input().split()
print(t+s)
Buggy python submission (verdict: Runtime Error):
from sympy import nextprime
import sympy
import isprime

X = int(input())

if isprime(X) = "True":
    print(X)

else:
    p = sympy.nextprime(X, 1)
    print(p)

Fixed submission:
N = int(input())

def prime_check(num):
    for i in range(2, num):
        if num % i == 0:
            return False
    return True

for x in range(N, 1000000):
    if prime_check(x):
        print(x)
        exit()

Buggy python submission (verdict: Runtime Error):
from sympy import nextprime

X = int(input())
p = sympy.nextprime(X, 1)

print(p)

Fixed submission:
N = int(input())

def prime_check(num):
    for i in range(2, num):
        if num % i == 0:
            return False
    return True

for x in range(N, 1000000):
    if prime_check(x):
        print(x)
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))

st = 0
cnt = 0
mx = max(A)

for i in range(1, mx+1):
    if i in A:
        cnt += 1
        st = A.index(i)
        A = A[st:]
    elif N == N - cnt:
        print(-1)
        exit()
    else:
        print(N-cnt)
        exit()
print(N-cnt)

Fixed submission:
N = int(input())
a = [int(s) - 1 for s in input().split()]

result = 0
for i in range(N):
    if a[i] != (i - result):
        result += 1

if result == N:
    print(-1)
else:
    print(result)
Buggy python submission (verdict: Runtime Error):
N = int(input())

def buy(cost):
    if cost == N:
        print(1)
        exit()
    if cost < N:
        for i in range(100, 106):
            buy(cost+i)
buy(0)

if buy(0) is None:
    print(0)

Fixed submission:
x=int(input())
y=x//100
z=x%100
if z<=y*5:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
x = list(map(int,input().split()))
tmp = 0
i = 0
while tmp < (sum(x) / 2):
    tmp += x[i]
    i += 1
# 2 4 3 sum=9 tmp=6 i=2  
a = tmp - (sum(x) - tmp)
b = (sum(x) - tmp + x[i-1]) - (tmp - x[i-1])
print(min(a, b))

Fixed submission:
n = int(input())
s = list(map(int,input().split()))
ans = 2020202020
a = 0
b = sum(s)
for i in range(n):
    a += s[i]
    b -= s[i]
    ans = min(ans,abs(a-b))
print(ans)