Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
s = ns()

ans = []

for i in range(1, n-1):
    set_x = set(s[:i])
    set_y = set(s[i:])
    ans.append(len(set_x & set_y))

print(max(ans))

Fixed submission:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
s = ns()

ans = [0]

for i in range(1, n-1):
    set_x = set(s[:i])
    set_y = set(s[i:])
    ans.append(len(set_x & set_y))

print(max(ans))
Buggy python submission (verdict: Runtime Error):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, c, d = nm()
    if abs(b-a) <= d or abs(c-b) <= d or abs(c-a) <=:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Fixed submission:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, c, d = nm()
    if (abs(b-a) <= d and abs(c-b) <= d) or abs(c-a) <= d:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    s = ns()
    k = ni()

    check = set()

    for left in range(0, len(s)):
        for right in range(left+1, len(s)+1):
            check.add(s[left:right])
    
    print(sorted(list(check))[k-1])

if __name__ == '__main__':
    main()

Fixed submission:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    s = ns()
    k = ni()

    check = set()

    for left in range(0, len(s)):
        for right in range(left+1, left+k+1):
            check.add(s[left:right])
    
    print(sorted(list(check))[k-1])

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    s = ns()
    k = ni()

    check = set()

    for left in range(0, len(s)):
        for right in range(left+1, len(s)+1):
            check.add(s[left:right])
    
    print(sorted(list(check))[k-1])

if __name__ == '__main__':
    main()

Fixed submission:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    s = ns()
    k = ni()

    check = set()

    for left in range(0, len(s)):
        for right in range(left+1, left+k+1):
            check.add(s[left:right])
    
    print(sorted(list(check))[k-1])

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    s = ns()
    
    if set(s) == set([a, b, c]):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Fixed submission:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    s = ns()
    
    if set(s) == set(['a', 'b', 'c']):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, k = nm()

    for i in range(a, b+1):
        if i < a + k or i > b - k:
            print(i)


if __name__ == '__main__':
    main()

Fixed submission:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, k = nm()

    if 2*k >= b - a + 1:
        for i in range(a, b+1):
            print(i) 
        exit()

    for i in range(a, a+k):
        print(i)

    for i in range(b-k+1, b+1):
        print(i)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys, copy, math, collections, itertools

n, k = (int(i) for i in input().split())
hs = [int(input()) for i in range(n)]
hs.sort()
i=0
m=-1
l=len(hs)
while True:
    if l < (i+k):
        break
    tmp = hs[i:i+k]
    cnd=tmp[-1] - tmp[0]
    if m==-1:
        m=cnd
    else:
        if cnd < m:
            m=cnd
    i+=1
print(int(m))


Fixed submission:
import sys, copy, math, collections, itertools

n, k = (int(i) for i in input().split())
hs = [int(input()) for i in range(n)]
hs.sort()
i=0
m=-1
l=len(hs)
while True:
    if l < (i+k):
        break
    # tmp = hs[i:i+k]
    cnd=hs[i+k-1] - hs[i]
    if m==-1:
        m=cnd
    else:
        if cnd < m:
            m=cnd
    i+=1
print(int(m))
Buggy python submission (verdict: Runtime Error):
import collections

n = int(input())
vs = [int(i) for i in input().split()]
evens = []
odds = []
for i,num in enumerate(vs):
    if i % 2 == 0:
        evens.append(num)
    elif i % 2 == 1:
        odds.append(num)

def plana():
    if (len(set(vs)) == 2) and (len(set(evens)) == 1) and (len(set(odds)) == 1):
        return 0
    elif (len(set(vs)) == 1):
        return len(evens)
    ec = collections.Counter(evens)
    oc = collections.Counter(odds)

    count = 0
    count += (len(evens) - ec.most_common()[0][1])
    count += (len(odds) - oc.most_common()[0][1])
    return count

# if len(set(vs)) == 1:
#     print(int(len(vs)/2))
# elif (len(set(evens)) == 1) and (len(set(odds)) == 1):
#     print(0)
# else:
print(len(odds))



Fixed submission:
inums = input()
# [int(i)for i in input().split()]
nums = []
for i in inums:
    nums.append(int(i))
o = []
for n in nums:
    if n == 1:
        o.append("9")
    elif n==9:
        o.append("1")
    else:
        o.append(str(n))
print("".join(o))

Buggy python submission (verdict: Runtime Error):
import collections
 
n = int(input())
vs = [int(i) for i in input().split()]
evens = []
odds = []
for i,num in enumerate(vs):
    if i % 2 == 0:
        evens.append(num)
    elif i % 2 == 1:
        odds.append(num)
 
def plana():
    if (len(set(vs)) == 2) and (len(set(evens)) == 1) and (len(set(odds)) == 1):
        return 0
    elif (len(set(vs)) == 1):
        return len(evens)
    return 0
    ec = collections.Counter(evens)
    oc = collections.Counter(odds)
 
    count = 0
    count += (len(evens) - ec.most_common()[0][1])
    count += (len(odds) - oc.most_common()[0][1])
    return count
 
# if len(set(vs)) == 1:
#     print(int(len(vs)/2))
# elif (len(set(evens)) == 1) and (len(set(odds)) == 1):
#     print(0)
# else:
print(int(plana()))

Fixed submission:
inums = input()
# [int(i)for i in input().split()]
nums = []
for i in inums:
    nums.append(int(i))
o = []
for n in nums:
    if n == 1:
        o.append("9")
    elif n==9:
        o.append("1")
    else:
        o.append(str(n))
print("".join(o))
Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
N,X=map(int,input().split())
x=list(map(int,input().split()))
for i in range(N):
    if i==0:
        ans=x[i]-X
    else:
        ans=math.gcd(ans,x[i]-X)
print(ans)

Fixed submission:
import fractions

N,X=map(int,input().split())
x=map(int,input().split())
x=list(x)
for i in range(N):
    if i==0:
        ans=x[i]-X
    else:
        ans=fractions.gcd(ans,x[i]-X)
print(abs(ans))
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
A = list(map(int, input().split()))
A = [a - 1 for a in A]
D = 60
MAX_N = 200005
to = [[0] * MAX_N for _ in range(D)]
for i, a in enumerate(A):
    to[0][i] = a

for i in range(D - 1):
    for j in range(N):
        to[i + 1][j] = to[i][to[i][j]]

v = 0
for i in range(D - 1, -1, -1):
    l = 1 << i
    if l <= K:
        v = to[i][v]
        K -= l
print(v + 1)

Fixed submission:
N, K = map(int, input().split())
A = list(map(int, input().split()))
s = []
d = [-1] * (N + 1)
v = 1
c, l = 1, 0
while d[v] == -1:
    d[v] = len(s)
    s.append(v)
    v = A[v - 1]
c = len(s) - d[v]
l = d[v]
if K < l:
    print(s[K])
else:
    K -= l
    K %= c
    print(s[l + K])
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
L = defaultdict(list)
R = defaultdict(list)
for i in range(N):
    L[i + A[i]].append(i)
    R[i - A[i]].append(i)

# print(L)
# print(R)
ans = 0
for k in L.keys():
    l = L[k]
    r = R[k]
    cnt = 0
    for i in l:
        for j in r:
            if i < j:
                ans += 1
print(ans)

Fixed submission:
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
L = defaultdict(int)
R = defaultdict(int)
for i in range(N):
    L[i + A[i]] += 1
    R[i - A[i]] += 1

ans = 0
for k, v in L.items():
    ans += v * R[k]
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = len(S)
ans = 0
for i in range(N-3):
    t = S[i]
    for j in range(i+1, N):
        t += S[j]
        if int(t) % 2019 == 0:
            # print(i + 1, j + 1)
            ans += 1
print(ans)

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

S = input()
N = len(S)
P = 2019
if P == 2 or P == 5:
    ans = 0
    for i in range(N):
        if int(S[i]) % P == 0:
            ans += i + 1
    print(ans)
    sys.exit()

num = [0] * P
num[0] = 1
now, ans = 0, 0
_10 = 1
for i in range(N-1, -1, -1):
    now = (now + int(S[i]) * _10) % P
    _10 *= 10
    _10 %= P
    ans += num[now]
    num[now] += 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
N = len(S)
ans = 0
for i in range(N-3):
    for j in range(i+3, N):
        t = S[i:j+1]
        if int(t) % 2019 == 0:
            #print(i + 1, j + 1)
            ans += 1
print(ans)

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

S = input()
N = len(S)
P = 2019
if P == 2 or P == 5:
    ans = 0
    for i in range(N):
        if int(S[i]) % P == 0:
            ans += i + 1
    print(ans)
    sys.exit()

num = [0] * P
num[0] = 1
now, ans = 0, 0
_10 = 1
for i in range(N-1, -1, -1):
    now = (now + int(S[i]) * _10) % P
    _10 *= 10
    _10 %= P
    ans += num[now]
    num[now] += 1

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        if S[i] == S[j]:
            continue
        d = j - i
        for k in range(j+1, N):
            if d == k - j:
                continue
            if S[i] == S[k] or S[j] == S[k]:
                continue
            ans += 1
print(ans)

Fixed submission:
N = int(input())
S = input()
r, g, b = 0, 0, 0
for c in S:
    if c == "R":
        r += 1
    elif c == "G":
        g += 1
    else:
        b += 1
ans = r * g * b
sub = 0
for i in range(N):
    for j in range(i+1, N):
        if S[i] == S[j]:
            continue
        k = 2 * j - i
        if k >= N or S[k] == S[i] or S[k] == S[j]:
            continue
        sub += 1
print(ans - sub)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
ans = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        for k in range(j+1, N):
            if j - i == k - j:
                continue
            if S[i] == S[j] or S[i] == S[k] or S[j] == S[k]:
                continue
            ans += 1
print(ans)

Fixed submission:
N = int(input())
S = input()
r, g, b = 0, 0, 0
for c in S:
    if c == "R":
        r += 1
    elif c == "G":
        g += 1
    else:
        b += 1
ans = r * g * b
sub = 0
for i in range(N):
    for j in range(i+1, N):
        if S[i] == S[j]:
            continue
        k = 2 * j - i
        if k >= N or S[k] == S[i] or S[k] == S[j]:
            continue
        sub += 1
print(ans - sub)
Buggy python submission (verdict: Time Limit Exceeded):
H, W, K = map(int, input().split())
S = []
for _ in range(H):
    S.append([c for c in input()])

ans = float('inf')
for div in range(2 ** (H - 1)):
    g = 0
    ids = [0] * H
    for i in range(H):
        ids[i] = g
        if div >> i & 1:
            g += 1
    g += 1

    c = [[0 for _ in range(1005)] for _ in range(10)]
    for i in range(H):
        for j in range(W):
            c[ids[i]][j] += int(S[i][j])

    num = g - 1
    now = [0] * g
    def add(j):
        for i in range(g):
            now[i] += c[i][j]
            if now[i] > K:
                return False
        return True

    for j in range(W):
        if not add(j):
            num += 1
            now = [0] * g
            if not add(j):
                num = float('inf')
                break

    ans = min(ans, num)
print(ans)


Fixed submission:
H, W, K = map(int, input().split())
S = []
for _ in range(H):
    S.append([c for c in input()])

ans = float('inf')
for div in range(2 ** (H - 1)):
    g = 0
    ids = [0] * H
    for i in range(H):
        ids[i] = g
        if div >> i & 1:
            g += 1
    g += 1

    c = [[0 for _ in range(1005)] for _ in range(10)]
    for i in range(H):
        for j in range(W):
            c[ids[i]][j] += int(S[i][j])

    num = g - 1
    now = [0] * g
    def add(j):
        for i in range(g):
            now[i] += c[i][j]
            if now[i] > K:
                return False
        return True

    for j in range(W):
        if not add(j):
            num += 1
            now = [0] * g
            if not add(j):
                num = float('inf')
                break

    ans = min(ans, num)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())
reverse = False
for _ in range(Q):
    tmp = input().split()
    q = int(tmp[0])
    if q == 1:
        reverse = not reverse
    elif q == 2:
        f = int(tmp[1])
        if f == 1:
            if reverse:
                S = S + tmp[2]
            else:
                S = tmp[2] + S
        elif f == 2:
            if reverse:
                S = tmp[2] + S
            else:
                S = S + tmp[2]
if reverse:
    print(S[::-1])
else:
    print(S)

Fixed submission:
from collections import deque
S = input()
Q = int(input())
d = deque()
d.append(S)
reverse = False
for _ in range(Q):
    tmp = input().split()
    q = int(tmp[0])
    if q == 1:
        reverse = not reverse
    elif q == 2:
        f = int(tmp[1])
        if f == 1:
            if reverse:
                d.append(tmp[2])
            else:
                d.appendleft(tmp[2])
        elif f == 2:
            if reverse:
                d.appendleft(tmp[2])
            else:
                d.append(tmp[2])
S = "".join(d)
if reverse:
    print(S[::-1])
else:
    print(S)
Buggy python submission (verdict: Time Limit Exceeded):
N, P = map(int, input().split())
S = input()
if 10 % P == 0:
    ans = 0
    for r in range(N):
        if int(S[r]) % P == 0:
            ans += r + 1
    print(ans)
    exit()

d = [0] * (N + 1)
ten = 1
for i in range(N - 1, -1, -1):
    a = int(S[i]) * ten % P
    d[i] = (d[i + 1] + a) % P
    ten *= 10
    # ten %= P

cnt = [0] * P
ans = 0
for i in range(N, -1, -1):
    ans += cnt[d[i]]
    cnt[d[i]] += 1
print(ans)

Fixed submission:
N, P = map(int, input().split())
S = input()
if 10 % P == 0:
    ans = 0
    for r in range(N):
        if int(S[r]) % P == 0:
            ans += r + 1
    print(ans)
    exit()

d = [0] * (N + 1)
ten = 1
for i in range(N - 1, -1, -1):
    a = int(S[i]) * ten % P
    d[i] = (d[i + 1] + a) % P
    ten *= 10
    ten %= P

cnt = [0] * P
ans = 0
for i in range(N, -1, -1):
    ans += cnt[d[i]]
    cnt[d[i]] += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
ans = 0
for A in range(1, N+1):
    for B in range(A, N+1):
        str_A = str(A)
        str_B = str(B)
        if str_A[-1] == str_B[0] and str_A[0] == str_B[-1]:
            # print(A, B)
            ans += 1
            if A != B:
                ans += 1
print(ans)

Fixed submission:
N = int(input())
cij = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, N+1):
    A = str(i)
    cij[int(A[0])][int(A[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += cij[i][j] * cij[j][i]
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

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

A, B = tuple(map(int, input().split()))
print(lcm(A, B))

Fixed submission:
# 最大公約数
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a


# 最小公倍数
def lcm(a, b):
    return a * b // gcd(a, b)


A, B = tuple(map(int, input().split()))
print(lcm(A, B))
Buggy python submission (verdict: Runtime Error):
N, u, v = map(int, input().split())
u -= 1
v -= 1
edges = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

dist = [0] * N
def dfs(v, d=0, p=-1):
    global dist
    dist[v] = d
    for u in edges[v]:
        if u == p:
            continue
        dfs(u, d + 1, v)

def calc_dist(s):
    global dist
    dist = [0] * N
    dfs(s)
    return dist

distS = calc_dist(u)
distT = calc_dist(v)

mx = 0
for i in range(N):
    if distS[i] < distT[i]:
        mx = max(mx, distT[i])
ans = mx - 1
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(10 ** 6)
N, u, v = map(int, input().split())
u -= 1
v -= 1
edges = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

dist = [0] * N
def dfs(v, d=0, p=-1):
    global dist
    dist[v] = d
    for u in edges[v]:
        if u == p:
            continue
        dfs(u, d + 1, v)

def calc_dist(s):
    global dist
    dist = [0] * N
    dfs(s)
    return dist

distS = calc_dist(u)
distT = calc_dist(v)

mx = 0
for i in range(N):
    if distS[i] < distT[i]:
        mx = max(mx, distT[i])
ans = mx - 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
c = [str(i) for i in range(10)]
cands = []
for c1 in c:
    for c2 in c:
        for c3 in c:
            cands.append(c1 + c2 + c3)

cnt = 0
for c in cands:
    i = 0
    for s in S:
        if i == 3:
            break
            
        if c[i] == s:
            i += 1

    if i == 3:
        # print(c)
        cnt += 1
print(cnt)

Fixed submission:
N = int(input())
S = input()
c = [str(i) for i in range(10)]
cands = []
for c1 in c:
    for c2 in c:
        for c3 in c:
            cands.append(c1 + c2 + c3)

cnt = 0
for c in cands:
    i = 0
    for s in S:
        if i == 3:
            break
            
        if c[i] == s:
            i += 1

    if i == 3:
        # print(c)
        cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
D = list(map(int, input().split()))
mod = 998244353
counter = [0] * N
for d in D:
    counter[d] += 1

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

ans = 1
for d in D[1:]:
    ans *= counter[d-1] % mod
print(ans % mod)

Fixed submission:
N = int(input())
D = list(map(int, input().split()))
mod = 998244353
counter = [0] * N
for d in D:
    counter[d] += 1

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

ans = 1
for d in D[1:]:
    ans = ans * counter[d-1] % mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = tuple(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()
for i in range(M):
    A[-1] = A[-1] // 2
    A.sort()
print(sum(A))

Fixed submission:
import heapq

N, M = tuple(map(int, input().split()))
A = list(map(int, input().split()))
A = list(map(lambda x: x*(-1), A))
heapq.heapify(A)
for i in range(M):
    tmp = heapq.heappop(A) * (-1) // 2
    heapq.heappush(A, tmp * (-1))
print(sum(A) * (-1))