Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
a, b = [], []
ans = 0
INF = float('inf')
for n in range(N):
    tmp1, tmp2 = map(int, input().split())
    a.append(tmp1)
    b.append(tmp2)

count = 0
while count < M:
    mindex = a.index(min(a))
    buycount = min(b[mindex], M - count)
    count += buycount
    ans += a[mindex]*buycount
    a[mindex] = INF
print(ans)

Fixed submission:
N, M = map(int, input().split())
ans = 0
drink = M
a, b = [], []
INF = float('inf')
for n in range(N):
    a.append(list(map(int, input().split())))
a.sort()
for i in a:
    if drink > i[1]:
        ans += i[0] * i[1]
        drink -= i[1]
    else:
        ans += i[0] * drink
        break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
a, b = [], []
ans = 0
INF = float('inf')
for n in range(N):
    tmp1, tmp2 = map(int, input().split())
    a.append(tmp1)
    b.append(tmp2)

count = 0
while count < M:
    mindex = a.index(min(a))
    buycount = min(b[mindex], M - count)
    count += buycount
    ans += a[mindex]*buycount
    a[mindex] = INF
print(ans)

Fixed submission:
N, M = map(int, input().split())
ans = 0
drink = M
a, b = [], []
INF = float('inf')
for n in range(N):
    a.append(list(map(int, input().split())))
a.sort()
for i in a:
    if drink > i[1]:
        ans += i[0] * i[1]
        drink -= i[1]
    else:
        ans += i[0] * drink
        break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
flg = 0
while '10' in s or '01' in s:
    ans += s.count('01') * 2
    s = s.replace('01', '')
    ans += s.count('10') * 2
    s = s.replace('10', '')
print(ans)

Fixed submission:
s = input()
print(min(s.count('1'),s.count('0')) * 2)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
flg = 0
while '10' in s or '01' in s:
    ans += s.count('01') * 2
    s = s.replace('01', '')
    ans += s.count('10') * 2
    s = s.replace('10', '')
print(ans)

Fixed submission:
s = input()
print(min(s.count('1'),s.count('0')) * 2)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
ans = 0
flg = 0
while flg == 0:
    ans += s.count('01') * 2
    s = s.replace('01', '')
    ans += s.count('10') * 2
    s = s.replace('10', '')
    if not ('10' in s or '01' in s):
        flg = 1
print(ans)

Fixed submission:
s = input()
print(min(s.count('1'),s.count('0')) * 2)
Buggy python submission (verdict: Runtime Error):
import numpy as np
a, b = [], []
for i in range(3):
  a[i], b[i] = np.array(input()split())


Fixed submission:
import numpy as np
ans = 'YES'
a = np.array([])
for i in range(3):
    b, c = input().split()
    a = np.append(a, [b, c])
a = a.astype(np.int32)
for i in range(4):
    count = np.sum(a == i + 1)
    if count > 2:
        ans = 'NO'
        break
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = list(map(int, input().split()))
ans = 'Yes' 
if max(L) >= sum(L.pop(L.index.max(L))):
    ans = 'No'
print(ans)

Fixed submission:
N = int(input())
L = list(map(int, input().split()))
ans = 'Yes'
lmax = max(L)
L.remove(max(L))
if lmax >= sum(L):
    ans = 'No'
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, K = map(int, input().split())
f = list(map(int, input().split()))
dp = [float('inf')] * n
dp[0] = 0
for i in range(1, n):
    ways = []
    for k in range(1,K+1):
        if i - k >= 0:
            ways.append(dp[i - k] + abs(f[i] - f[i - k]))
    dp[i] = min(ways)
print(dp[n - 1])


Fixed submission:
n, K = map(int, input().split())
f = list(map(int, input().split()))
dp = [float('inf')] * n
dp[0] = 0
for i in range(1, n):
    ways = []
    for k in range(1,K+1):
        if i - k >= 0:
            ways.append(dp[i - k] + abs(f[i] - f[i - k]))
    dp[i] = min(ways)
print(dp[n - 1])
Buggy python submission (verdict: Runtime Error):
N, P = map(int, input().split())
if N == 1:
    print(P)
    exit()
if int(P ** (1 / N)) < 2:
    print(1)
print(int(P ** (1 / N)) + 10)
for n in range(int(P ** (1 / N))+1, 0, -1):
    if P % (n ** N) == 0:
        print(n)
        break

Fixed submission:
N, P = map(int, input().split())
if N == 1:
    print(P)
    exit()
if int(P ** (1 / N)) < 2:
    print(1)
    exit()
for n in range(int(P ** (1 / N))+1, 0, -1):
    if P % (n ** N) == 0:
        print(n)
        break

Buggy python submission (verdict: Time Limit Exceeded):
N, P = map(int, input().split())
if N == 1:
    print(P)
    exit()
for n in range(int(P ** (1 / N)) + 10, 0, -1):
    if P % (n ** N) == 0:
        print(n)
        break

Fixed submission:
N, P = map(int, input().split())
if N == 1:
    print(P)
    exit()
if int(P ** (1 / N)) < 2:
    print(1)
    exit()
for n in range(int(P ** (1 / N))+1, 0, -1):
    if P % (n ** N) == 0:
        print(n)
        break
Buggy python submission (verdict: Time Limit Exceeded):
n, p = map(int, input().split())
for i in range(int((p ** (1/n))//1)+1, 1, -1):
    if p % (i ** n) == 0:
        print(i)
        break
else:
    print(1)

Fixed submission:
n, p = map(int, input().split())
if n == 3 and p == 24:
    print(2)
    exit()
for i in range(int((p ** (1 / n)) // 1) + 1, 1, -1):
    if i == 2 and n ** 3 > p:
        print(1)
        break
    if p % (i ** n) == 0:
        print(i)
        break
else:
    print(1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))
b = list(reversed(a))
c = [0] * (n + 1)
d = [0] * (n + 1)
cnt = 0
for i in range(n):
    for j in range(i, 0, -1):
        while a[j - 1] < a[j]:
            cnt += 1
            a[j - 1] *= 4
    c[i + 1] = cnt
cnt = 0
for i in range(n):
    for j in range(i, 0, -1):
        while b[j - 1] < b[j]:
            cnt += 1
            b[j - 1] *= 4
    d[i + 1] = cnt
ans = 10 ** 18
for i in range(n + 1):
    ans = min(ans, (c[i] + d[n - i]) * 2 + i)
print(ans)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = list(reversed(a))
c = [0] * (n + 1)
d = [0] * (n + 1)
s = [(0, 10 ** 30)]
res = 0
for i in range(1, n):
    if a[i - 1] < a[i] * 4:
        t = a[i - 1]
        cnt = 0
        while t < a[i]:
            cnt += 1
            t *= 4
        while cnt > 0:
            idx, p = s.pop()
            if cnt >= p:
                res += p * (i - idx)
                cnt -= p
            else:
                res += cnt * (i - idx)
                s.append((idx, p - cnt))
                cnt = 0
    else:
        t = a[i]
        cnt = 0
        while a[i - 1] >= t * 4:
            t *= 4
            cnt += 1
        s.append((i, cnt))
    c[i + 1] = res
s = [(0, 10 ** 30)]
res = 0
for i in range(1, n):
    if b[i - 1] < b[i] * 4:
        t = b[i - 1]
        cnt = 0
        while t < b[i]:
            cnt += 1
            t *= 4
        while cnt > 0:
            idx, p = s.pop()
            if cnt >= p:
                res += p * (i - idx)
                cnt -= p
            else:
                res += cnt * (i - idx)
                s.append((idx, p - cnt))
                cnt = 0
    else:
        t = b[i]
        cnt = 0
        while b[i - 1] >= t * 4:
            t *= 4
            cnt += 1
        s.append((i, cnt))
    d[i + 1] = res
ans = float('inf')
for i in range(n + 1):
    ans = min(ans, (c[i] + d[n - i]) * 2 + i)
print(ans)
Buggy python submission (verdict: Runtime Error):
x,y=map(int,input())
print(x+y/2)

Fixed submission:
x,y=map(int,input().split())
print(int(x+y/2))
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
p = [list(map(int, input().split())) + [i] for i in range(M)]
p.sort()
i = 0
for n in range(1, N + 1):
    count = 1
    while not(i > n or p[i][0] != n):
        p[i] += [str(n).zfill(6) + str(count).zfill(6)]
        i += 1
        count += 1
p.sort(key=lambda x: x[2])
for a in p:
    print(a[3])

Fixed submission:
N, M = map(int, input().split())
p = [list(map(int, input().split())) + [i] for i in range(M)]
p.sort()
i = 0
for n in range(1, N + 1):
    count = 1
    while not(i >= M or p[i][0] != n):
        p[i] += [str(n).zfill(6) + str(count).zfill(6)]
        i += 1
        count += 1
p.sort(key=lambda x: x[2])
for a in p:
    print(a[3])

Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
p = [list(map(int, input().split())) + [i] for i in range(M)]
p.sort()
print(p)
i = 0
for n in range(1, N + 1):
    count = 1
    print(i, p[2][0])
    while not(i > n or p[i][0] != n):
        p[i] += [str(n).zfill(6) + str(count).zfill(6)]
        i += 1
        count += 1
p.sort(key=lambda x: x[2])
for a in p:
    print(a[3])

Fixed submission:
N, M = map(int, input().split())
p = [list(map(int, input().split())) + [i] for i in range(M)]
p.sort()
i = 0
for n in range(1, N + 1):
    count = 1
    while not(i >= M or p[i][0] != n):
        p[i] += [str(n).zfill(6) + str(count).zfill(6)]
        i += 1
        count += 1
p.sort(key=lambda x: x[2])
for a in p:
    print(a[3])

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
for i in a:
    s_a = [x for x in sorted(a) if x[0] == i[0]]
    print(str(i[0]).zfill(6) + str(s_a.index(i)+1).zfill(6))

Fixed submission:
N, M = map(int, input().split())
p = [list(map(int, input().split())) + [i] for i in range(M)]
p.sort()
i = 0
for n in range(1, N + 1):
    count = 1
    while not(i >= M or p[i][0] != n):
        p[i] += [str(n).zfill(6) + str(count).zfill(6)]
        i += 1
        count += 1
p.sort(key=lambda x: x[2])
for a in p:
    print(a[3])
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
n, m = map(int, input().split())
s = input()
t = input()
lcm_nm = int(n * m / gcd(n, m))
for i in range(lcm_nm):
  if(not(i % (lcm_nm/n) == 0 and i % (lcm_nm/m) == 0)):
    continue
  if(s[int(i / (lcm_nm/n))] != t[int(i / (lcm_nm/m))]):
    ans = -1
    break
else:
  ans = lcm_nm
print(ans)

Fixed submission:
from fractions import gcd
n, m = map(int, input().split())
s = input()
t = input()
g = gcd(n, m)
for i in range(g):
    if s[n // g * i] != t[m // g * i]:
        print(-1)
        break
else:
    print(n * m // g)
Buggy python submission (verdict: Runtime Error):
n,T=map(int,input().split())
a = []
for i in range(n):
  A,t=map(int,input().split())
  if t > T:
    pass
  else:
    a.append(A)
print(min(a))

Fixed submission:
n,T=map(int,input().split())
a = []
for i in range(n):
  A,t=map(int,input().split())
  if t > T:
    pass
  else:
    a.append(A)
if a != []:
    print(min(a))
else:
  print('TLE')
Buggy python submission (verdict: Runtime Error):
input()
print(input().split().index('1')+1)

Fixed submission:
s = input()
n = len(s)
if s[0] == '0':
    print(-1)
    exit(0)
if s[-1] == '1':
    print(-1)
    exit(0)
for i in range((n - 1) // 2):
    if s[i] != s[n - i - 2]:
        print(-1)
        exit(0)
p = 1
t = 2
i = n - 2
while i >= 0:
    print(p, t)
    if s[i] == '1':
        p = t
    t += 1
    i -= 1
Buggy python submission (verdict: Runtime Error):
S = input()
K = int(input())
if S[:K] == '1'*K:
    print(1)
else:
    print(S.replace('1', '')[0])


Fixed submission:
S = input()
K = int(input())
if K < 110 and S[:K] == '1'*K:
    print(1)
else:
    print(S.replace('1', '')[0])
Buggy python submission (verdict: Runtime Error):
print('YNeos'[int(input()) in[1,2,3,5,6,9,10,13,17]::2])


Fixed submission:
print(0 if eval(input().replace(' ','%'))==0 else 1)
Buggy python submission (verdict: Runtime Error):
s=input()
t=input()
for i in range(n):
  if s == t[i:] + t[:i]:
    print('Yes')
    exit(0)
print('No')

Fixed submission:
S, T = input(), input()
for i in range(len(S)):
    if T[i:] + T[:i] == S:
        print('Yes')
        break
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import heapq


class Value:
    def __init__(self, val, f):
        self.val = val
        self.key = f(val)

    def __lt__(self, other):
        return self.key < other.key

    def __repr__(self):
        return repr(self.val)


class Heapq:
    def __init__(self, arr, f=lambda x: x):
        for i in range(len(arr)):
            arr[i] = Value(arr[i], f)
        self.func = f
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        return heapq.heappop(self.hq).val

    def push(self, a):
        heapq.heappush(self.hq, Value(a, self.func))

    def top(self):
        return self.hq[0].val


n = int(input())
a = [int(input()) for _ in range(n)]
if a[0] > 0:
    print(-1)
    exit(0)
hq = Heapq([], f=lambda x: (-a[x], x))
for i, x in enumerate(a):
    if x > 0:
        hq.push(i)
ans = 0
while hq.hq:
    i = hq.pop()
    if a[i] - 1 == a[i - 1]:
        ans += 1
        a[i] = (a[i + 1] - 1 if i != n - 1 else 0)
        if a[i] > 0:
            hq.push(i)
    else:
        print(-1)
        exit(0)
print(ans)


Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)] + [0]
if a[0] > 0:
    print(-1)
else:
    ans = 0
    for i in range(n):
        if a[i] < a[i + 1] - 1:
            print(-1)
            break
        elif a[i] >= a[i + 1]:
            ans += a[i]
    else:
        print(ans)

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


class Value:
    def __init__(self, val, f):
        self.val = val
        self.key = f(val)

    def __lt__(self, other):
        return self.key < other.key

    def __repr__(self):
        return repr(self.val)


class Heapq:
    def __init__(self, arr, f=lambda x: x):
        for i in range(len(arr)):
            arr[i] = Value(arr[i], f)
        self.func = f
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        return heapq.heappop(self.hq).val

    def push(self, a):
        heapq.heappush(self.hq, Value(a, self.func))

    def top(self):
        return self.hq[0].val


n = int(input())
a = [int(input()) for _ in range(n)]
if a[0] > 0:
    print(-1)
    exit(0)
hq = Heapq([], f=lambda x: (-a[x], x))
for i, x in enumerate(a):
    if x > 0:
        hq.push(i)
ans = 0
while hq.hq:
    i = hq.pop()
    if a[i] - 1 == a[i - 1]:
        ans += 1
        a[i] = (a[i + 1] - 1 if i != n - 1 else 0)
        if a[i] > 0:
            hq.push(i)
    else:
        print(-1)
        exit(0)
print(ans)


Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)] + [0]
if a[0] > 0:
    print(-1)
else:
    ans = 0
    for i in range(n):
        if a[i] < a[i + 1] - 1:
            print(-1)
            break
        elif a[i] >= a[i + 1]:
            ans += a[i]
    else:
        print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n == 3:
    print(2, 5, 63)
elif n == 4:
    print(2, 3, 4, 9)
else:
    l = [2, 3, 4, 9]
    a = 8
    b = 10
    while b <= 30000 and len(l) + 1 < n:
        l.append(a)
        l.append(b)
        a += 6
        b += 6
    c = 15
    d = 21
    while d <= 30000 and len(l) + 1 < n:
        l.append(c)
        l.append(d)
        c += 12
        d += 12
    t = 6
    while t <= 30000 and len(l) < n:
        l.append(t)
        t += 6
    print(' '.join(map(str, l)))


Fixed submission:
def f(s):
    return len(s) != len(set(s)) or s[-1] >= 123


st = input()
if st == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit(0)
s = list(map(ord, st))
s += [97]
while f(s):
    if s[-1] == 123:
        s.pop()
    s[-1] += 1
print(''.join(map(chr, s)))
Buggy python submission (verdict: Runtime Error):
one = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
n=int(input())
for i in range(n):
  one[input()[0]] += 1
m,a,r,c,h=one['M'],one['A'],one['R'],one['C'],one['H']
print(m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h)

Fixed submission:
one = {'M':0, 'A':0, 'R':0, 'C':0, 'H':0}
n=int(input())
for i in range(n):
  c=input()[0]
  one[c] = one.get(c,0)+1
m,a,r,c,h=one['M'],one['A'],one['R'],one['C'],one['H']
print(m*a*r+m*a*c+m*a*h+m*r*c+m*r*h+m*c*h+a*r*c+a*r*h+a*c*h+r*c*h)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
H, W = map(int, input().split())
maze = [input()for _ in range(H)]


def bfs(startx: int, starty: int) -> set:
    dxdy = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    queue = deque()
    queue.appendleft((startx, starty, 0))
    reached = set()
    while queue:
        d = queue.pop()
        if d[0] == W - 1 and d[1] == H - 1:
            return d[2]
        for a in dxdy:
            x = d[0] + a[0]
            y = d[1] + a[1]
            if (x, y) not in reached and 0 <= x < W and 0 <= y < H and maze[y][x] != '#':
                queue.appendleft((x, y, d[2] + 1))
                reached.add(d[:2])
    return -1


d = bfs(0, 0)
if d == -1:
    print(-1)
    exit()
cnt = 0
for c in maze:
    cnt += c.count('#')
print(H * W - cnt - d - 1)

Fixed submission:
from collections import deque
H, W = map(int, input().split())
maze = [input()for _ in range(H)]


def bfs(startx: int, starty: int) -> set:
    dxdy = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    queue = deque()
    queue.appendleft((startx, starty, 0))
    reached = set()
    while queue:
        d = queue.pop()
        if d[0] == W - 1 and d[1] == H - 1:
            return d[2]
        for a in dxdy:
            x = d[0] + a[0]
            y = d[1] + a[1]
            if (x, y) not in reached and 0 <= x < W and 0 <= y < H and maze[y][x] != '#':
                reached.add((x, y))
                queue.appendleft((x, y, d[2] + 1))
    return -1


d = bfs(0, 0)
if d == -1:
    print(-1)
    exit()
cnt = 0
for c in maze:
    cnt += c.count('#')
print(H * W - cnt - d - 1)
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
g = {i: [] for i in range(n)}
for i in range(m):
    l, r, d = map(int, input().split())
    g[l - 1].append((r - 1, d))
    g[r - 1].append((l - 1, -d))
l = [-1] * n
l[0] = n
stack = [r]
s = set()
while stack:
    d = stack.pop()
    if d in s:
        continue
    for node, cost in g[d]:
        if l[node] == -1:
            l[node] = l[d] + cost
        else:
            if l[node] != l[d] + cost:
                print('No')
                exit()
        stack.append(node)
    s.add(d)
print('Yes')


Fixed submission:
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for i in range(m):
    l, r, d = map(int, input().split())
    g[l - 1].append((r - 1, d))
    g[r - 1].append((l - 1, -d))
l = [None] * n
for i in range(n):
    if l[i] != None:
        continue
    l[i] = 0
    stack = [i]
    while stack:
        d = stack.pop()
        for node, cost in g[d]:
            if l[node] == None:
                l[node] = l[d] + cost
                stack.append(node)
            else:
                if l[node] != l[d] + cost:
                    print('No')
                    exit(0)
print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
a = list(map(int, input().split()))
l, r = 0, 10 ** 100
while r - l > 1:
    m = (l + r) // 2
    t = m
    for x in a:
        m = m // x * x
    if m <= 2:
        l = t
    else:
        r = t
l2, r2 = 0, 10 ** 100
while r2 - l2 > 1:
    m = (l2 + r2) // 2
    t = m
    for x in a:
        m = m // x * x
    if m < 2:
        l2 = t
    else:
        r2 = t
if l < r2:
    print(-1)
else:
    print(r2, l)


Fixed submission:
k = int(input())
a = list(map(int, input().split()))
l, r = 0, 10 ** 15
while r - l > 1:
    m = (l + r) // 2
    t = m
    for x in a:
        m = m // x * x
    if m <= 2:
        l = t
    else:
        r = t
l2, r2 = 0, 10 ** 15
while r2 - l2 > 1:
    m = (l2 + r2) // 2
    t = m
    for x in a:
        m = m // x * x
    if m < 2:
        l2 = t
    else:
        r2 = t
if l < r2:
    print(-1)
else:
    print(r2, l)

Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())
a = list(map(int, input().split()))
l, r = 0, 10 ** 100
while r - l > 1:
    m = (l + r) // 2
    t = m
    for x in a:
        m = m // x * x
    if m <= 2:
        l = t
    else:
        r = t
l2, r2 = 0, 10 ** 100
while r2 - l2 > 1:
    m = (l2 + r2) // 2
    t = m
    for x in a:
        m = m // x * x
    if m < 2:
        l2 = t
    else:
        r2 = t
if l < r2:
    print(-1)
else:
    print(r2, l)


Fixed submission:
k = int(input())
a = list(map(int, input().split()))
l, r = 0, 10 ** 15
while r - l > 1:
    m = (l + r) // 2
    t = m
    for x in a:
        m = m // x * x
    if m <= 2:
        l = t
    else:
        r = t
l2, r2 = 0, 10 ** 15
while r2 - l2 > 1:
    m = (l2 + r2) // 2
    t = m
    for x in a:
        m = m // x * x
    if m < 2:
        l2 = t
    else:
        r2 = t
if l < r2:
    print(-1)
else:
    print(r2, l)
Buggy python submission (verdict: Runtime Error):
n,a,b=map(input().split());print(min(n*a,b))

Fixed submission:
n,a,b=map(int,input().split());print(min(n*a,b))
Buggy python submission (verdict: Runtime Error):
k, a, b = map(int, input().split())
k = max(0, k - a)
if k > 0 and a <= b:
  print(-1)
else:
  print((k // (a - b) + int(k % (a - b) != 0)) * 2 + 1)

Fixed submission:
k, a, b = map(int, input().split())
k = max(0, k - a)
if k > 0 and a <= b:
  print(-1)
elif a == b:
  print(1)
else:
  print((k // (a - b) + int(k % (a - b) != 0)) * 2 + 1)
Buggy python submission (verdict: Runtime Error):
import bisect
ans = 0
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
for i in range(n):
    ans += bisect.bisect_left(a, b[i]) * (n - bisect.bisect_right(c, b[i]))
print(ans)

Fixed submission:
print('YNEOS'[input()!=input()[::-1]::2])
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
ans = 0
n = int(input())
a = np.array(list(map(int, input().split())))
b = np.array(list(map(int, input().split())))
c = np.array(list(map(int, input().split())))
for i in range(n):
    ans += np.sum(a < b[i]) * np.sum(c > b[i])
print(ans)

Fixed submission:
import bisect
ans = 0
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
for i in range(n):
    ans += bisect.bisect_left(a, b[i]) * (n - bisect.bisect_right(c, b[i]))
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n = int(input())
a = np.array([sorted(list(map(int, input().split()))) for _ in range(3)])
ans = 0
for i in range(n):
    ans += np.sum(a[0] < a[1][i]) * np.sum(a[2] > a[1][i])
print(ans)

Fixed submission:
import bisect
ans = 0
n = int(input())
a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))
for i in range(n):
    ans += bisect.bisect_left(a, b[i]) * (n - bisect.bisect_right(c, b[i]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
def bipartite(g):
    s = [(0, 1)]
    c = [0] * n
    while s:
        v, color = s.pop()
        c[v] = color
        for node in g[v]:
            if c[node] == c[v]:
                return False, None
            if c[node] == 0:
                s.append((node, -color))
    return True, c

n, m = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)
b, colors = bipartite(g)
if b:
    x = colors.count(1)
    print(x * (n - x) - m)
else:
    print(n * (n - 1) // 2 - m)


Fixed submission:
def bipartite(g):
    s = [(0, 1)]
    c = [0] * n
    while s:
        v, color = s.pop()
        c[v] = color
        for node in g[v]:
            if c[node] == c[v]:
                return False, None
            if c[node] == 0:
                s.append((node, -color))
    return True, c

n, m = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    g[a - 1].append(b - 1)
    g[b - 1].append(a - 1)
b, colors = bipartite(g)
if b:
    x = colors.count(1)
    print(x * (n - x) - m)
else:
    print(n * (n - 1) // 2 - m)