Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N, M = LI()
    LR = []
    for _ in range(M):
        LR.append(LI())
    SE = None
    for l, r in LR:
        se = set(range(l, r + 1))
        if SE is None:
            SE = se
        else:
            SE = SE & se
    ans = len(SE)
    return ans

print(main())


Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N, M = LI()
    LR = []
    for _ in range(M):
        LR.append(LI())
    left = 0
    right = INF
    for l, r in LR:
        left = max(left, l)
        right = min(right, r)
    ans = max(right - left + 1, 0)
    return ans

print(main())
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import defaultdict

def main():
    N, M = LI()
    A = LI()
    BC = []
    for _ in range(M):
        BC.append(LI())
    A.sort()
    for B, C in BC:
        for i in range(B):
            if C <= A[i]:
                break
            A[i] = C
        A.sort()
    ans = sum(A)
    return ans

print(main())

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import defaultdict
from operator import itemgetter

def main():
    N, M = LI()
    A = LI()
    BC = []
    for _ in range(M):
        BC.append(LI())
    for a in A:
        BC.append([1, a])
    BC.sort(reverse=True, key=itemgetter(1))
    cnt = 0
    ans = 0
    for B, C in BC:
        if cnt + B >= len(A):
            ans += C * (len(A) - cnt)
            break
        ans += C * B
        cnt += B
    return ans

print(main())
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from bisect import bisect

def main():
    q = II()
    Q = []
    for _ in range(q):
        Q.append(LI())
    A = []
    bias = 0
    for q in Q:
        if q == [2]:
            idx = (len(A) - 1) // 2
            ans = A[idx], (sum(A[len(A) - idx - 1:]) - sum(A[:idx + 1]) + bias)
            print(*ans)
        else:
            _, a, b = q
            bias += b
            index = bisect(A, a)
            A.insert(index, a)
    return

main()

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from heapq import heappush, heappop

def main():
    q = II()
    Q = []
    for _ in range(q):
        Q.append(LI())
    lows, highs = [], []
    slow, shigh = 0, 0
    bias = 0
    for q in Q:
        if q[0] == 2:
            odd = -lows[0] if len(highs) != len(lows) else 0
            ans = -lows[0], bias + shigh - slow + odd
            print(*ans)
        else:
            _, a, b = q
            bias += b
            if not lows:
                lows = [-a]
                slow = a
            else:
                if a <= -lows[0]:
                    heappush(lows, -a)
                    slow += a
                    if len(lows) > len(highs) + 1:
                        x = -heappop(lows)
                        heappush(highs, x)
                        slow -= x
                        shigh += x
                else:
                    heappush(highs, a)
                    shigh += a
                    if len(highs) > len(lows):
                        x = heappop(highs)
                        heappush(lows, -x)
                        shigh -= x
                        slow += x
    return

main()
Buggy python submission (verdict: Runtime Error):
x, y, z, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
import heapq
q = []
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
def val(i, j, k):
  return -(A[i] + B[j] + C[k])
heapq.heappush(q, (val(0,0,0), 0,0,0))
for _ in range(k):
  v, aa, bb, cc = heapq.heappop(q)
  print(-v)
  heapq.heappush(q, (val(aa+1, bb, cc), aa+1, bb, cc))
  heapq.heappush(q, (val(aa, bb+1, cc), aa, bb+1, cc))
  heapq.heappush(q, (val(aa, bb, cc+1), aa, bb, cc+1))


Fixed submission:
x, y, z, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
import heapq
q = []
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
def val(i, j, k):
  return -(A[i] + B[j] + C[k])
heapq.heappush(q, (val(0,0,0), 0,0,0))
visited = set((0,0,0))
for _ in range(k):
  v, aa, bb, cc = heapq.heappop(q)
  print(-v)
  if aa + 1 < len(A) and (aa+1, bb, cc) not in visited:
    visited.add((aa+1, bb, cc))
    heapq.heappush(q, (val(aa+1, bb, cc), aa+1, bb, cc))
  if bb + 1 < len(B) and (aa, bb+1, cc) not in visited:
    visited.add((aa, bb+1, cc))
    heapq.heappush(q, (val(aa, bb+1, cc), aa, bb+1, cc))
  if cc + 1 < len(C) and (aa, bb, cc+1) not in visited:
    visited.add((aa, bb, cc+1))
    heapq.heappush(q, (val(aa, bb, cc+1), aa, bb, cc+1))
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from itertools import product

def main():
    N = II()
    A, G, C, T = range(4)
    def code(c0, c1, c2):
        return c0 + 4 * c1 + 16 * c2
    dp = [0] * 64
    dp[code(T, T, T)] = 1
    for _ in range(N):
        tmp = [0] * 64
        for p1, p2, p3 in product(range(4), repeat=3):
            for cur in range(4):
                if (p2, p1, cur) == (A, G, C):
                    continue
                if (p2, p1, cur) == (A, C, G):
                    continue
                if (p2, p1, cur) == (G, A, C):
                    continue
                if (p3, p1, cur) == (A, G, C):
                    continue
                if (p3, p2, cur) == (A, G, C):
                    continue
                tmp[code(cur, p1, p2)] += dp[code(p1, p2, p3)]
                tmp[code(cur, p1, p2)] %= MOD
        dp = tmp
    ans = sum(dp)

    return ans % MOD

print(main())

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

from itertools import accumulate

def main():
    N, Q = LI()
    S = SI()
    LR = []
    for _ in range(Q):
        LR.append(LI_())

    AC = [0] * (N + 1)
    for i in range(N - 1):
        if S[i:i + 2] == 'AC':
            AC[i] = 1
    acc = [0] + list(accumulate(AC))
    for l, r in LR:
        print(acc[r] - acc[l])

    return 0

main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N = II()
    C = []
    for _ in range(N):
        c = II()
        if len(C) == 0 or c != C[-1]:
            C.append(c)
    global ans
    ans = 0
    dp = [1] + [0] * N
    from collections import defaultdict
    idxs = defaultdict(list)
    for i, c in enumerate(C):
        ret = dp[i]
        if c in idxs.keys():
            for j in idxs[c]:
                ret += dp[j]
        dp[i + 1] = ret % MOD
        idxs[c].append(i)

    ans = dp[len(C)]

    return ans % MOD

print(main())

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N = II()
    C = []
    for _ in range(N):
        c = II()
        if len(C) == 0 or c != C[-1]:
            C.append(c)
    global ans
    ans = 0
    dp = [1] + [0] * N
    from collections import defaultdict
    cnt_clr = defaultdict(int)
    for i, c in enumerate(C):
        ret = dp[i]
        ret += cnt_clr[c]
        cnt_clr[c] = ret
        dp[i + 1] = ret % MOD

    ans = dp[len(C)]

    return ans % MOD

print(main())
Buggy python submission (verdict: Time Limit Exceeded):
A, B = map(int, input().split())

ans = 0
for i in range(A, B + 1):
    ans ^= i
print(ans)

Fixed submission:
A, B = map(int, input().split())
digits = len(format(B, 'b'))
A -= 1
ans = 0
for k in range(digits):
    na = (A // (2 << k)) * (1 << k) + max(0, A % (2 << k) - (1 << k) + 1)
    nb = (B // (2 << k)) * (1 << k) + max(0, B % (2 << k) - (1 << k) + 1)
    x = (nb - na) % 2
    ans += x << k

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):

S = input()
N = len(S)
n = 10 ** 6
while n != len(S):
    n = len(S)
    S = S.replace('01', '')
    S = S.replace('10', '')

ans = N - len(S)
print(ans)

Fixed submission:

S = input()
a = S.count('0')
b = S.count('1')

ans = min(a, b) * 2

print(ans)
Buggy python submission (verdict: Runtime Error):
n, a, b, c = list(map(int, input().split()))
goals = [a, b, c]
bamboos = []
for _ in range(n):
    bamboos.append(int(input()))

def get_best(li, goal):
    bam_mp_lis = {0: (-10, tuple())}
    li.sort()
    for i, v in enumerate(li):
        tmp = bam_mp_lis.copy()
        for bam, (mp, lis) in tmp.items():
            b0 = bam + v
            m0 = mp + 10
            l0 = lis + (i,)
            if b0 not in bam_mp_lis or m0 < bam_mp_lis[b0][0]:
                bam_mp_lis[b0] = (m0, l0)
    del bam_mp_lis[0]
    best = 10 ** 9
    for bam, (mp, lis) in bam_mp_lis.items():
        cost = mp + abs(goal - bam)
        if cost < best:
            best = cost
            beslis = lis
    return best, beslis

ans = 10 ** 9
from itertools import permutations
for junjo in permutations(goals):
    tmp = 0
    bambooo = bamboos.copy()
    for ju in junjo:
        be, beli = get_best(bambooo, ju)
        beli = sorted(beli, reverse=True)
        for beli0 in beli:
            del bambooo[beli0]
        tmp += be
    if tmp < ans:
        ans = tmp

print(ans)


Fixed submission:
n, a, b, c = list(map(int, input().split()))
goals = [a, b, c]
bamboos = []
for _ in range(n):
    bamboos.append(int(input()))

def get_best(li, goal):
    bam_mp_lis = {0: (-10, tuple())}
    li.sort()
    for i, v in enumerate(li):
        tmp = bam_mp_lis.copy()
        for bam, (mp, lis) in tmp.items():
            b0 = bam + v
            m0 = mp + 10
            l0 = lis + (i,)
            if b0 not in bam_mp_lis or m0 < bam_mp_lis[b0][0]:
                bam_mp_lis[b0] = (m0, l0)
    del bam_mp_lis[0]
    best = 10 ** 9
    for bam, (mp, lis) in bam_mp_lis.items():
        cost = mp + abs(goal - bam)
        if cost < best:
            best = cost
            beslis = lis
    return best, beslis

ans = 10 ** 9
from itertools import permutations
for junjo in permutations(goals):
    tmp = 0
    bambooo = bamboos.copy()
    for ju in junjo:
        if len(bambooo) == 0:
            tmp = 10 ** 9
            break
        be, beli = get_best(bambooo, ju)
        beli = sorted(beli, reverse=True)
        for beli0 in beli:
            del bambooo[beli0]
        tmp += be
    if tmp < ans:
        ans = tmp

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = list(map(int, input().split()))
li = list(map(int, input().split()))
di = {}
for i, d in enumerate([2,5,5,4,5,6,3,7,6], 1):
    di[i] = d

# honsuu list
ns = set()
# honsuu-> disit list
n2d = {}
for a in li:
    hon = di[a]
    ns.add(hon)
    if (hon not in n2d) or (n2d[hon] < a):
        n2d[hon] = a
ns = list(ns)
ns.sort(reverse=True)

from collections import Counter, deque
cnt = Counter()
Q = deque()
for hon in ns:
    if n - hon >= 0:
        Q.append(((hon,), n - hon))
ma = 0
mali = []
while len(Q) > 0:
    lis, remain = Q.pop()
    if remain == 0 and len(lis) > ma:
        ma = len(lis)
        mali = lis
    for hon in ns:
        if remain - hon >= 0:
            Q.append((lis + (hon,), remain - hon))

digits = [n2d[n] for n in mali]
digits.sort(reverse=True)

print(*digits, sep='')


Fixed submission:
n, m = list(map(int, input().split()))
li = list(map(int, input().split()))
di = {}
for i, d in enumerate([2,5,5,4,5,6,3,7,6], 1):
    di[i] = d
li.sort(reverse=True)
dd = {}
for a in li:
    hon = di[a]
    if hon not in dd:
        dd[hon] = a

h2d = [-float('inf')] * (n + 1)
h2d[0] = 0
pre = [None] * (n + 1)
for j in range(1, n + 1):
    for a in li:
        ho = di[a]
        if j < ho:
            continue
        dig = h2d[j - ho] + 1
        if dig > h2d[j]:
            h2d[j] = dig
            pre[j] = j - ho

ans = []
while n > 0:
    ans.append(dd[n - pre[n]])
    n = pre[n]
ans.sort(reverse=True)
print(*ans, sep='')
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

def func(s, t):
    for i, (a, b) in enumerate(zip(s, t)):
        while True:
            ss, tt = s[i + 1:], t[i + 1:]
            si = ss.find(a)
            ti = tt.find(b)
            if si != ti:
                return 'No'
            if si == -1:
                break
            i += si + 1
    return 'Yes'

ans = func(s, t)

print(ans)

Fixed submission:
s = input()
t = input()

s2t = {}
t2s = {}
ans = 'Yes'
for si, ti in zip(s, t):
    if si not in s2t:
        s2t[si] = ti
    elif s2t[si] != ti:
        ans = 'No'
        break
    if ti not in t2s:
        t2s[ti] = si
    elif t2s[ti] != si:
        ans = 'No'
        break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M, Q = map(int, input().split())
RcntL = np.zeros((N+1, N+1), int)
for _ in range(M):
    l, r = map(int, input().split())
    RcntL[r:, l] += 1
pq = []
for _ in range(Q):
    pq.append(list(map(int, input().split())))

RcntL = np.cumsum(RcntL, axis=1)

for p, q in pq:
    ans = RcntL[q, q] - RcntL[q, p - 1]
    print(ans)


Fixed submission:
import numpy as np
N, M, Q = map(int, input().split())
RcntL = np.zeros((N+1, N+1), int)
for _ in range(M):
    l, r = map(int, input().split())
    RcntL[r, l] += 1
pq = []
for _ in range(Q):
    pq.append(list(map(int, input().split())))

RcntL = np.cumsum(RcntL, axis=0)
RcntL = np.cumsum(RcntL, axis=1)

for p, q in pq:
    ans = RcntL[q, q] - RcntL[q, p - 1]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N, M, Q = map(int, input().split())
RcntL = np.zeros((N+1, N+1), int)
for _ in range(M):
    l, r = map(int, input().split())
    RcntL[r:, l] += 1
pq = []
for _ in range(Q):
    pq.append(list(map(int, input().split())))

for p, q in pq:
    ans = np.sum(RcntL[q, p:q+1])
    print(ans)


Fixed submission:
import numpy as np
N, M, Q = map(int, input().split())
RcntL = np.zeros((N+1, N+1), int)
for _ in range(M):
    l, r = map(int, input().split())
    RcntL[r, l] += 1
pq = []
for _ in range(Q):
    pq.append(list(map(int, input().split())))

RcntL = np.cumsum(RcntL, axis=0)
RcntL = np.cumsum(RcntL, axis=1)

for p, q in pq:
    ans = RcntL[q, q] - RcntL[q, p - 1]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = 0
from collections import Counter
mods = Counter()
for a in A:
    mods = Counter({(k + a) % M: v for k, v in mods.items()})
    mods[a % M] += 1
    ans += mods[0]

print(ans)


Fixed submission:
N, M = map(int, input().split())
A = [0] + list(map(int, input().split()))
from itertools import accumulate
acc = accumulate(A)

from collections import Counter
cnt_mod = Counter([a % M for a in acc])
ans = 0
for k in cnt_mod.values():
    ans += k * (k - 1) // 2
print(ans)
Buggy python submission (verdict: Runtime Error):
n, k = list(map(int, input().split()))

ans = 0
if k = 0:
    ans = n * n
else:
    for b in range(k + 1, n + 1):
        ans += n // b * (b - k)
        ans += max(0, (n - (n // b * b)) - k + 1)

print(ans)


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

ans = 0
if k == 0:
    ans = n * n
else:
    for b in range(k + 1, n + 1):
        ans += n // b * (b - k)
        ans += max(0, (n - (n // b * b)) - k + 1)

print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
s[3] = '8'
print(s)

Fixed submission:
s = input()
s = s.replace('2017', '2018')
print(s)

Buggy python submission (verdict: Runtime Error):
s = input()
s[3] = 8
print(s)

Fixed submission:
s = input()
s = s.replace('2017', '2018')
print(s)

Buggy python submission (verdict: Runtime Error):
s = input()
s[3] = [8]
print(s)

Fixed submission:
s = input()
s = s.replace('2017', '2018')
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
n, k = list(map(int, input().split()))
li = list(map(int, input().split()))

s = set(li)
ns = [li.count(i) for i in s]
ns.sort()

if len(ns) <= k:
    print(0)
else:
    print(sum(ns[:-k]))


Fixed submission:
n, k = list(map(int, input().split()))
li = list(map(int, input().split()))
li.sort()

ar = []
tmp = -1
for a in li:
    if a != tmp:
        tmp = a
        ar.append(1)
    else:
        ar[-1] += 1
ar.sort()

if len(ar) <= k:
    print(0)
else:
    print(sum(ar[:-k]))
Buggy python submission (verdict: Runtime Error):
n, z, w = list(map(int, input().split()))
li = list(map(int, input().split()))

ans = max(abs(w - li[-1]), abs(li[-1] - li[-2]))

print(ans)

Fixed submission:
n, z, w = list(map(int, input().split()))
li = list(map(int, input().split()))

ans = abs(w - li[-1])
if len(li) > 1:
    ans = max(ans, abs(li[-1] - li[-2]))

print(ans)
Buggy python submission (verdict: Runtime Error):
from collections import deque

n, m = list(map(int, input().split()))
li = []
for _ in range(m):
    li.append(list(map(int, input().split())))

# construct indirectional graphs
edges = [[] for _ in range(n)]
for i, j in li:
    i -= 1
    j -= 1
    edges[i].append(j)
    edges[j].append(i)

edges2 = None

S = deque()
S.append([0])
while len(S) > 0:
    path = S.pop()
    # if full path,
    if len(path) == n:
        # used path set
        used = set()
        for i, j in zip(path[:-1], path[1:]):
            used |= {(i, j)}
        # delete unused edges
        if edges2 == None:
            edges2 = used
        else:
            edges2 = edges2 & used
        continue
    for v in edges[path[-1]]:
        if v not in path:
            S.append(path + [v])

ans = len(edges2)

print(ans)

Fixed submission:
from collections import deque

n, m = list(map(int, input().split()))
li = []
for _ in range(m):
    li.append(list(map(int, input().split())))

ans = 0
for k in range(len(li)):
    li0 = li[:k] + li[k + 1:]
    # construct indirectional graphs
    edges = [[] for _ in range(n)]
    for i, j in li0:
        i -= 1
        j -= 1
        edges[i].append(j)
        edges[j].append(i)
    # check bridge
    S = deque()
    S.append(0)
    visited = set()
    while len(S) > 0:
        u = S.pop()
        visited.add(u)
        for v in edges[u]:
            if v not in visited:
                S.append(v)
    if len(visited) < n:
        ans += 1


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import product
N, K = map(int, input().split())
XY = []
X, Y = [], []
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
    XY.append([x, y])
X.sort()
Y.sort()

ans = 10 ** 19
for l, r, t, b in product(X, X, Y, Y):
    if l > r or t > b:
        continue
    area = (r - l) * (b - t)
    if area >= ans:
        continue
    cnt = -K
    for x, y in XY:
        if l <= x <= r and t <= y <= b:
            cnt +=1
            if cnt >= 0:
                break
    if cnt >= 0:
        ans = area

print(ans)

Fixed submission:
from itertools import product
from operator import itemgetter
N, K = map(int, input().split())
XY = []
X, Y = [], []
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
    XY.append([x, y])
X.sort()
Y.sort()
XY.sort(key=itemgetter(1))

ans = 10 ** 19
for l, r, t in product(X, X, Y):
    if l > r:
        continue
    cnt = -K
    for x, y in XY:
        if y < t:
            continue
        if l <= x <= r:
            cnt += 1
            if cnt >= 0:
                area = (r - l) * (y - t)
                if area < ans:
                    ans = area
                break

print(ans)
Buggy python submission (verdict: Runtime Error):
import string
n = input()
s = string.ascii_lowercase - set(n)

if len(s) == 0:
    print('None')
else:
    print(min(s))

Fixed submission:
import string
n = input()
s = set(string.ascii_lowercase) - set(n)

if len(s) == 0:
    print('None')
else:
    print(min(s))