Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
mod = 10 ** 9 + 7
n = int(input())
a = list(map(lambda x: format(int(x), "b").zfill(60), input().split()))

ans = 0
for i in range(60):
    cnt = 0
    for j in a:
        if j[- i - 1] == "1":
            cnt += 1
    tmp = cnt * (n - cnt)
    for _ in range(i):
        tmp = tmp * 2 % mod
    ans += tmp
print(ans % mod)

Fixed submission:
mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
l = [0 for i in range(len(str(bin(max(a)))) - 2)]
a = [bin(i)[2:] for i in a]

for i in a:
    for j, k in enumerate(i[::-1]):
        if k == "1":
            l[j] += 1
ans = 0
for i, j in enumerate(l):
    ans = (ans + (j * (n - j)) * (2 ** i)) % mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
mod = 10 ** 9 + 7
n = int(input())
a = list(map(lambda x: format(int(x), "b").zfill(60), input().split()))

ans = 0
for i in range(60):
    cnt = 0
    for j in a:
        if j[- i - 1] == "1":
            cnt += 1
    ans = (ans + (cnt * (n - cnt)) * (2 ** i)) % mod
print(ans)

Fixed submission:
mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
l = [0 for i in range(len(str(bin(max(a)))) - 2)]
a = [bin(i)[2:] for i in a]

for i in a:
    for j, k in enumerate(i[::-1]):
        if k == "1":
            l[j] += 1
ans = 0
for i, j in enumerate(l):
    ans = (ans + (j * (n - j)) * (2 ** i)) % mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
l = [0 for i in range(len(str(bin(max(a)))) - 2)]
a = [bin(i)[2:] for i in a]

for i in a:
    for j, k in enumerate(i[::-1]):
        if k == "1":
            l[j] += 1
ans = 0
for i, j in enumerate(l):
    ans = (ans + (j * (n - j)) * (2 ** i)) % mod
print(ans)

Fixed submission:
mod = 10 ** 9 + 7
n = int(input())
a = list(map(int, input().split()))
l = [0 for i in range(len(str(bin(max(a)))) - 2)]
a = [bin(i)[2:] for i in a]

for i in a:
    for j, k in enumerate(i[::-1]):
        if k == "1":
            l[j] += 1
ans = 0
for i, j in enumerate(l):
    ans = (ans + (j * (n - j)) * (2 ** i)) % mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = [int(i) for i in input()]
cnt = 0
for i in range(10):
    for j in range(10):
        for k in range(10):
            tmp = 0
            for l in s:
                if i == l and tmp == 0:
                    tmp += 1
                elif j == l and tmp == 1:
                    tmp += 1
                elif k == l and tmp == 2:
                    cnt += 1
                    break
print(cnt)

Fixed submission:
n = int(input())
s = input()
cnt = 0
for i in range(1000):
    i = str(i).zfill(3)
    j = s.find(i[0])
    if j != -1:
        k = s[j + 1:].find(i[1])
        if k != -1:
            if s[j + k + 2:].find(i[2]) != -1:
                cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
cnt = 0
for i in range(1000):
    i = str(i).zfill(3)
    tmp = 0
    for j in s:
        if j == i[tmp]:
            tmp += 1
            if tmp == 3:
                cnt += 1
                break
print(cnt)

Fixed submission:
n = int(input())
s = input()
cnt = 0
for i in range(1000):
    i = str(i).zfill(3)
    j = s.find(i[0])
    if j != -1:
        k = s[j + 1:].find(i[1])
        if k != -1:
            if s[j + k + 2:].find(i[2]) != -1:
                cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
cnt = 0

for v in range(1000):
    v = str(v).zfill(3)
    f = 0
    for i in range(n):
        if f == 2:
            if v[2] == s[i]:
                cnt += 1
                break
        elif f == 1:
            if v[1] == s[i]:
                f = 2
        else:
            if v[0] == s[i]:
                f = 1
print(cnt)

Fixed submission:
n = int(input())
s = input()
cnt = 0
for i in range(1000):
    i = str(i).zfill(3)
    j = s.find(i[0])
    if j != -1:
        k = s[j + 1:].find(i[1])
        if k != -1:
            if s[j + k + 2:].find(i[2]) != -1:
                cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n = int(input())
d = list(map(int, input().split()))

if d[0] != 0:
    print(0)
    exit()

cnt = Counter(d)

if cnt[0] != 1:
    print(0)
    exit()

ans = 1
for i in d:
    if i != 0:
        ans *= cnt[i-1] % 998244353
print(ans % 998244353)

Fixed submission:
from collections import Counter
n = int(input())
d = list(map(int, input().split()))

if d[0] != 0:
    print(0)
    exit()

cnt = Counter(d)

if cnt[0] != 1:
    print(0)
    exit()

ans = 1
for i in d:
    if i != 0:
        ans = (ans * cnt[i-1]) % 998244353
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
d = list(map(int, input().split()))

if d[0] != 0:
    print(0)
    exit()

cnt = Counter(d)

if cnt[0] != 1:
    print(0)
    exit()

ans = 1
for i in d:
    if i != 0:
        ans *= cnt[i-1] % 998244353
print(and % 998244353)

Fixed submission:
from collections import Counter
n = int(input())
d = list(map(int, input().split()))

if d[0] != 0:
    print(0)
    exit()

cnt = Counter(d)

if cnt[0] != 1:
    print(0)
    exit()

ans = 1
for i in d:
    if i != 0:
        ans = (ans * cnt[i-1]) % 998244353
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
f = sorted(list(map(int, input().split())), reverse=True)


def test(x):
    cost = 0
    for i, j in zip(a, f):
        cost += max(0, i - x // j)
    return cost <= k


left = -1
right = a[-1]*f[0]
while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid

print(right)


Fixed submission:
import numpy as np
n, k = map(int, input().split())
a = np.array(sorted(list(map(int, input().split()))))
f = np.array(sorted(list(map(int, input().split())), reverse=True))


def test(x):
    cost = np.maximum(0, a-x//f).sum()
    return cost <= k


left = -1
right = 10**12
while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid

print(right)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
f = sorted(list(map(int, input().split())), reverse=True)


def test(x):
    cost = 0
    for i, j in zip(a, f):
        cost += max(0, i - x // j)
    return cost <= k


left = -1
right = 10**12
while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid

print(right)

Fixed submission:
import numpy as np
n, k = map(int, input().split())
a = np.array(sorted(list(map(int, input().split()))))
f = np.array(sorted(list(map(int, input().split())), reverse=True))


def test(x):
    cost = np.maximum(0, a-x//f).sum()
    return cost <= k


left = -1
right = 10**12
while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid

print(right)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
a = sorted(list(map(int, input().split())))
f = sorted(list(map(int, input().split())), reverse=True)


def test(x):
    cost = 0
    for i in range(n):
        cost += max(0, a[i] - x // f[i])
    return cost <= k


left = -1
right = 10**12
while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid

print(right)

Fixed submission:
import numpy as np
n, k = map(int, input().split())
a = np.array(sorted(list(map(int, input().split()))))
f = np.array(sorted(list(map(int, input().split())), reverse=True))


def test(x):
    cost = np.maximum(0, a-x//f).sum()
    return cost <= k


left = -1
right = 10**12
while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid

print(right)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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

cnt = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        length = l[i] + l[j]
        cnt += bisect.bisect_left(l[j+1:], length)
print(cnt)

Fixed submission:
import bisect

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

cnt = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        cnt += max(0, bisect.bisect_left(l, l[i] + l[j]) - j - 1)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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

cnt = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        cnt += bisect.bisect_left(l[j+1:], l[i]+l[j])
print(cnt)

Fixed submission:
import bisect

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

cnt = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        cnt += max(0, bisect.bisect_left(l, l[i] + l[j]) - j - 1)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n = int(input())
l = sorted(list((map(int, input().split()))))
m = len(l)
cnt = 0
for i in range(m - 2):
    for j in range(i + 1, m - 1):
        cnt += bisect.bisect_left(l[j+1:], l[i]+l[j])
print(cnt)

Fixed submission:
import bisect

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

cnt = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        cnt += max(0, bisect.bisect_left(l, l[i] + l[j]) - j - 1)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
l = np.array(sorted(list((map(int, input().split())))))
m = len(l)
cnt = 0
for i in range(m - 1):
    for j in range(i + 1, m):
        cnt += np.sum(l[j + 1:] < (l[i] + l[j]))
print(cnt)

Fixed submission:
import bisect

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

cnt = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        cnt += max(0, bisect.bisect_left(l, l[i] + l[j]) - j - 1)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
l = tuple(map(int, input().split()))
s = []
for i in range(n - 1):
    for j in range(i + 1, n):
        s.append([l[i] + l[j], i, j])

m = len(s)
ans = (n * (n - 1) * (n - 2)) // 6

for i in range(n):
    for j in range(m):
        if s[j][1] == i or s[j][2] == i:
            continue
        elif l[i] >= s[j][0]:
            ans -= 1
print(ans)

Fixed submission:
import bisect

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

cnt = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        cnt += max(0, bisect.bisect_left(l, l[i] + l[j]) - j - 1)
print(cnt)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
disk, idx = list(range(n + 1)), list(range(n + 1))

now = 0
for _ in range(m):
    nxt = int(input())
    disk[idx[nxt]], idx[nxt], idx[now] = now, 0, idx[nxt]
    now = nxt
print(*disk[1:], sep="\n")

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = [0 for i in range(n+1)]
for i in range(n):
    ans[a[i]] = i + 1
print(*ans[1:])

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
ans = []
for i in range(1, n+1):
    ans.append(a.index(i)+1)
print(*ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = [0 for i in range(n+1)]
for i in range(n):
    ans[a[i]] = i + 1
print(*ans[1:])
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())

if n == 1:
    a = int(input())
    for i in range(m):
        a //= 2
    print(a)
    exit()

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

for i in range(m):
    mx = max(a)
    a[index(mx)] //= 2
print(sum(a))

Fixed submission:
n, k, q = map(int, input().split())
a = [int(input()) for _ in range(q)]

pt = [k-q for _ in range(n)]
for i in a:
    pt[i-1] += 1

for i in pt:
    if i > 0:
        print("Yes")
    else:
        print("No")
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    s = sorted([sorted(input()) for i in range(n)])
    ans = 0
    while len(s) != 0:
        cnt = s.count(s[0])
        del s[0:cnt]
        if cnt > 1:
            ans += (cnt * (cnt - 1)) // 2
    print(int(ans))

if __name__ == "__main__":
    main()

Fixed submission:
import collections
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    s = ["".join(sorted(input())) for i in range(n)]
    s = collections.Counter(s)
    ans = 0
    for i in s.values():
        ans += (i*(i-1))//2
    print(ans)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

def main():
    n = int(input())
    s = deque(sorted(["".join(sorted(input())) for i in range(n)]))
    ans = 0
    while len(s) != 0:
        cnt = s.count(s[0])
        for i in range(cnt):
            s.popleft()
        if cnt == 1:
            continue
        ans += (cnt * (cnt - 1)) // 2
    print(int(ans))

if __name__ == "__main__":
    main()

Fixed submission:
import collections
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    s = ["".join(sorted(input())) for i in range(n)]
    s = collections.Counter(s)
    ans = 0
    for i in s.values():
        ans += (i*(i-1))//2
    print(ans)

if __name__ == "__main__":
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    s = ["".join(sorted(input())) for i in range(n)]
    ans = 0
    while len(s) != 0:
        cnt = s.count(s[0])
        tmp = s[0]
        for i in range(cnt):
            s.remove(tmp)
        if cnt == 1:
            continue
        ans += (cnt * (cnt - 1)) / 2
    print(int(ans))

if __name__ == "__main__":
    main()

Fixed submission:
import collections
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    s = ["".join(sorted(input())) for i in range(n)]
    s = collections.Counter(s)
    ans = 0
    for i in s.values():
        ans += (i*(i-1))//2
    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
from collections import Counter as ct
import sys
input = sys.stdin.readline

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

if c[0] == n:
    print("Yes")
elif len(c) == 2 and c[0] * 3 == n:
    print("Yes")
elif len(c) == 3 and len(set(c.values())) == 1 and :
    a, b, c = c.keys()
    if (a ^ b ^ c) == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Fixed submission:
from collections import Counter as ct
import sys
input = sys.stdin.readline

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

if c[0] == n:
    print("Yes")
elif len(c) == 2 and c[0] * 3 == n:
    print("Yes")
elif len(c) == 3 and len(set(c.values())) == 1:
    a, b, c = c.keys()
    if (a ^ b ^ c) == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

n, k = map(int, input().split())
for i in range(1, k + 1):
    if i <= n - k + 1:
        a = comb(k-1, i-1, exact=True)
        b = comb(n - k + 1, i, exact=True)
        print(a*b%(10**9+7))

Fixed submission:
from scipy.misc import comb

n, k = map(int, input().split())
mod = 10**9+7

for i in range(1, k + 1):
    a = comb(k-1, i-1, exact=True) % mod
    b = comb(n - k + 1, i, exact=True) % mod
    print((a*b)%mod)

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

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n, k = map(int, input().split())
print(n - k + 1)
if n != k:
    for i in range(2, k+1):
        a = cmb(k-1, i-1)
        b = cmb(n - k + 1, i)
        print(a*b%(10**9+7))

Fixed submission:
from scipy.misc import comb

n, k = map(int, input().split())
mod = 10**9+7

for i in range(1, k + 1):
    a = comb(k-1, i-1, exact=True) % mod
    b = comb(n - k + 1, i, exact=True) % mod
    print((a*b)%mod)

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

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n, k = map(int, input().split())
print(n-k+1)
for i in range(2, k+1):
    a = cmb(k-1, i-1)
    b = cmb(n - k + 1, i)
    print(a*b%(10**9+7))

Fixed submission:
from scipy.misc import comb

n, k = map(int, input().split())
mod = 10**9+7

for i in range(1, k + 1):
    a = comb(k-1, i-1, exact=True) % mod
    b = comb(n - k + 1, i, exact=True) % mod
    print((a*b)%mod)
Buggy python submission (verdict: Runtime Error):
s = input()
if s[0] == s[1] or s[1] == s[2] or s[2] == 2[3]:
    print("Bad")
else:
    print("Good")

Fixed submission:
s = input()
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
    print("Bad")
else:
    print("Good")
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
     
id, gate = map(int, input().split())
a = [list(map(int,input().split())) for i in range(gate)]
b = []

for i in range(gate)
    c = range(a[i, 0], a[i, 1])
    b.extend(c)

d = range(id)

d = set(d)
b = set(b)

list = list(b&d)
print(len(list))

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

ans = 0
L, R = 0, 114514

for i in range(m):
    l, r = map(int, input().split())
    L, R = max(L, l), min(R, r)

print(R - L + 1 if R - L + 1 >= 1 else 0)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
     
id, gate = map(int, input().split())
for i in range(gate)
    a = [list(map(int,input().split()))]
b = []

for i in range(gate)
    c = range(a[i, 0], a[i, 1])
    b.extend(c)

d = range(id)

d = set(d)
b = set(b)

list = list(b&d)
print(len(list))

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

ans = 0
L, R = 0, 114514

for i in range(m):
    l, r = map(int, input().split())
    L, R = max(L, l), min(R, r)

print(R - L + 1 if R - L + 1 >= 1 else 0)

Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
     
z = []
id, gate = map(int, input().split())
for i in range(gate)
    a = [list(map(int,input().split()))]
    z.append(a)
b = []

for i in range(gate)
    c = range(a[i, 0], a[i, 1])
    b.extend(c)

d = range(id)

d = set(d)
b = set(b)

list = list(b&d)
print(len(list))

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

ans = 0
L, R = 0, 114514

for i in range(m):
    l, r = map(int, input().split())
    L, R = max(L, l), min(R, r)

print(R - L + 1 if R - L + 1 >= 1 else 0)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x: x[1], reverse=True)

c = 0
for i, j in b:
    for k in range(c, i + c):
        if a[k] < j:
            a[k] = j
            c += 1
        else:
            break
print(sum(a))

Fixed submission:
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x: x[1], reverse=True)

c = 0
for i, j in b:
    for k in range(c, i + c):
        if k == n:
            break
        if a[k] < j:
            a[k] = j
            c += 1
        else:
            break
print(sum(a))
Buggy python submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())
cnt = 0
for i in range(n // r + 1):
    for j in range((n - i) // g + 1):
        k = (n - i * r - j * g) / b
        if k >= 0 and k // 1 == k:
            cnt += 1
print(cnt)

Fixed submission:
r, g, b, n = map(int, input().split())
cnt = 0
for i in range(0, n + 1, r):
    for j in range(0, n - i + 1, g):
        if (n - i - j) % b == 0:
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
n = []
for i in range(5):
    n.append(int(input()))

n_ = []
for i in n:
    if i % 10 == 0:
        continue
    n_.append(10 - i % 10)

print(sum(n) + sum(n_) - max(n_))

Fixed submission:
n = []
for i in range(5):
    n.append(int(input()))

n_ = [0]
for i in n:
    if i % 10 == 0:
        continue
    n_.append(10 - i % 10)

print(sum(n) + sum(n_) - max(n_))
Buggy python submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

def main():
    n, m, c = map(int, input().split())
    b = list(map(int, input().split()))
    a = [list(map(int, input().split())) for i in range(n)]

    ans = 0
    for i in a:
        cnt = c
        for j in range(m):
            cnt += i[j] * b[j]
        
        if cnt > 0:
            ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Fixed submission:
H, W = map(int, input().split())
h, w = map(int, input().split())

print(H * W - H * w - W * h + h * w)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate

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

if n >= m:
    print(0)
    exit()

ans = []
for i in range(m - 1, 0, -1):
    ans.append(x[i] - x[i - 1])

for i in range(n - 1):
    ans.remove(max(ans))
print(sum(ans))


Fixed submission:
from itertools import accumulate

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

if n >= m:
    print(0)
    exit()

ans = []
for i in range(m - 1, 0, -1):
    ans.append(x[i] - x[i - 1])

ans = sorted(ans, reverse=True)
print(sum(ans[n-1:]))

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate

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

if n >= m:
    print(0)
    exit()

ans = []
for i in range(m - 1, 0, -1):
    ans.append(x[i] - x[i - 1])

for i in range(n - 1):
    ans.remove(max(ans))
print(sum(ans))


Fixed submission:
from itertools import accumulate

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

if n >= m:
    print(0)
    exit()

ans = []
for i in range(m - 1, 0, -1):
    ans.append(x[i] - x[i - 1])

ans = sorted(ans, reverse=True)
print(sum(ans[n-1:]))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
v = list(map(int, input().split()))
v1 = v[::2]
v2 = v[1::2]

cnt = [[0] * 2 for _ in range(4)]
for i in set(v1):
    tmp = v1.count(i)
    if cnt[0][0] <= tmp:
        cnt[0], cnt[1] = [tmp, i], cnt[0]
for i in set(v2):
    tmp = v2.count(i)
    if cnt[2][0] <= tmp:
        cnt[2], cnt[3] = [tmp, i], cnt[2]

if cnt[0][1] != cnt[2][1]:
    print(n - cnt[0][0] - cnt[2][0])
else:
    print(min(n - cnt[0][0] - cnt[3][0], n - cnt[1][0] - cnt[2][0]))

Fixed submission:
from collections import Counter

n = int(input())
v = list(map(int, input().split()))
v1 = sorted(Counter(v[::2]).items(), key=lambda x: x[1], reverse=True)
v2 = sorted(Counter(v[1::2]).items(), key=lambda x: x[1], reverse=True)
v1.append((0, 0))
v2.append((0, 0))
if v1[0][0] != v2[0][0]:
    print(n - v1[0][1] - v2[0][1])
else:
    print(min(n - v1[0][1] - v2[1][1], n - v1[1][1] - v2[0][1]))
Buggy python submission (verdict: Runtime Error):
N, i = map(int, input().split())

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

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

if N == 1:
    print(N)
else:
    print(N - i + 1)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
if n % k = 0:
    print(0)
else:
    print(1)

Fixed submission:
n, k = map(int, input().split())
if n % k == 0:
    print(0)
else:
    print(1)
Buggy python submission (verdict: Runtime Error):
from fractions import gcd

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

lcm = a[0]
for i in a:
    lcm = lcm * i // gcd(lcm, i)
ans = 0
for i in a:
    ans += (lcm-1) % i
print(ans)


Fixed submission:
a = list(map(int, input().split()))
a.sort()
print(a[2] - a[0])