Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
port numpy as np
Flg = "No"
A = [[0]*3 for i in range(3)]
for i in range(3):
    A[i][0], A[i][1], A[i][2] = map(int, input().split())    
N = int(input())
b = [0]*N
for j in range(N):
    b[j] = int(input())

for i in range(3):
    for j in range(3):
        for k in range(N):
            if(A[i][j] == b[k]):
                A[i][j] = "*"
A_T = np.array(A).T
                
for i in range(3):
    if(A[i][0] == A[i][1] == A[i][2] == "*"):
        Flg = "Yes"        
        break
    if(A_T[i][0] == A_T[i][1] == A_T[i][2] == "*"):
        Flg = "Yes"
        break

if(A[0][0] == A[1][1] == A[2][2] == "*"):
    Flg = "Yes"

if(A[0][2] == A[1][1] == A[2][0] == "*"):
    Flg = "Yes"

print(Flg)

Fixed submission:
import numpy as np
Flg = "No"
A = [[0]*3 for i in range(3)]
for i in range(3):
    A[i][0], A[i][1], A[i][2] = map(int, input().split())    
N = int(input())
b = [0]*N
for j in range(N):
    b[j] = int(input())

for i in range(3):
    for j in range(3):
        for k in range(N):
            if(A[i][j] == b[k]):
                A[i][j] = "*"
A_T = np.array(A).T
                
for i in range(3):
    if(A[i][0] == A[i][1] == A[i][2] == "*"):
        Flg = "Yes"        
        break
    if(A_T[i][0] == A_T[i][1] == A_T[i][2] == "*"):
        Flg = "Yes"
        break

if(A[0][0] == A[1][1] == A[2][2] == "*"):
    Flg = "Yes"

if(A[0][2] == A[1][1] == A[2][0] == "*"):
    Flg = "Yes"

print(Flg)

Buggy python submission (verdict: Runtime Error):
import numpy as np
Flg = "No"
A = [[0]*3]*3
b = [0]*N
for i in range(3):
    A[i][0], A[i][1], A[i][2] = map(int, input().split())    
N = int(input())
for j in range(N):
    b[j] = int(input())
    
for i in range(3):
    for j in range(3):
        for k in range(N):
            if(A[i][j] == b[k]):
                A[i][j] = 0
A_T = np.array(A).T
                
for i in range(3):
    if(A[i][0] == A[i][1] == A[i][2] == 0):
        Flg = "Yes"        
        break
    if(A_T[i][0] == A_T[i][1] == A_T[i][2] == 0):
        Flg = "Yes"
        break

if(A[0][0] == A[1][1] == A[2][2] == 0):
    Flg = "Yes"

print(Flg)

Fixed submission:
import numpy as np
Flg = "No"
A = [[0]*3 for i in range(3)]
for i in range(3):
    A[i][0], A[i][1], A[i][2] = map(int, input().split())    
N = int(input())
b = [0]*N
for j in range(N):
    b[j] = int(input())

for i in range(3):
    for j in range(3):
        for k in range(N):
            if(A[i][j] == b[k]):
                A[i][j] = "*"
A_T = np.array(A).T
                
for i in range(3):
    if(A[i][0] == A[i][1] == A[i][2] == "*"):
        Flg = "Yes"        
        break
    if(A_T[i][0] == A_T[i][1] == A_T[i][2] == "*"):
        Flg = "Yes"
        break

if(A[0][0] == A[1][1] == A[2][2] == "*"):
    Flg = "Yes"

if(A[0][2] == A[1][1] == A[2][0] == "*"):
    Flg = "Yes"

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

magic = [list(map(int, input().split())) for _ in range(N)]

dp = [0 for _ in range(H+1)]

for i in range(H):
    dp[i] = min(dp[i-a]+b for a, b in magic)

print(dp[H-1])

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

magic = [list(map(int, input().split())) for _ in range(N)]

dp = [0 for _ in range(10**5)]

for i in range(H):
    dp[i] = min(dp[i-a]+b for a, b in magic)

print(dp[H-1])

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

magic = []
for i in range(N):
    magic.append(tuple(map(int, input().split())))

INF = 10**15 
dp = np.full((H+1), INF, dtype=np.int64)
dp[0] = 0

for i, (a, b) in enumerate(magic):
    for h in range(H):
        dp[min(H, h+a)] = min(dp[min(H, h+a)], dp[h]+b)

print(dp[-1])

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

magic = [list(map(int, input().split())) for _ in range(N)]

dp = [0 for _ in range(10**5)]

for i in range(H):
    dp[i] = min(dp[i-a]+b for a, b in magic)

print(dp[H-1])

Buggy python submission (verdict: Time Limit Exceeded):
H, N = map(int, input().split())

magic = []
for i in range(N):
    magic.append(tuple(map(int, input().split())))

INF = 10**15 
dp = [INF for _ in range(H+1)]
dp[0] = 0

for i, (a, b) in enumerate(magic):
    for h in range(H):
        dp[min(H, h+a)] = min(dp[min(H, h+a)], dp[h]+b)

print(dp[-1])

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

magic = [list(map(int, input().split())) for _ in range(N)]

dp = [0 for _ in range(10**5)]

for i in range(H):
    dp[i] = min(dp[i-a]+b for a, b in magic)

print(dp[H-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
X = [0]*N
L = [0]*N
XpL = [0]*N
XmL = [0]*N
cnt = 0
for i in range(N):
    X[i], L[i] = map(int, input().split())
    XpL[i] = X[i]+L[i]
    XmL[i] = max(0, X[i]-L[i])
    
    for j in range(i):
        if(XmL[i] < XpL[j] and XmL[j] < XpL[i]):
            cnt += 1
            XpL[i] = XpL[j]
            XmL[i] = XmL[j]
print(N-cnt)

Fixed submission:
import sys
N = int(input())
a = sorted([(x+l, x-l) for x, l in (map(int, l.split()) for l in sys.stdin)])

last = a[0][0]
ans = 1

for r, l in a[1:]:
    if(last <= l):
        ans += 1
        last = r
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
A, B, K = map(int, input().split())

while(K):
    if(A >=1):
        A -= 1
    elif(B >=1):
        B -= 1
    K -= 1
print(A, end=" ")
print(B)

Fixed submission:
A, B, K = map(int, input().split())

if(K <= A+B):
    print(A-K if A > K else 0, end=" ")
    print(B-(K-A) if A < K else B)
else:
    print(0, end=" ")
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
X = int(input())

sosu = [2]

for i in range(3, 10**5+100, 2):
    if(all(i % num != 0 for num in sosu)):
        sosu.append(i)   
        if(i >= X):
            print(i if X > 2 else 2)
            break

Fixed submission:
import math

X = int(input())

def isprime(num):
    if(num==2):
        return True
    elif(num%2 == 0):
        return False
    
    for i in range(3, int(math.sqrt(num)+1), 2):
        if(num%i == 0):
            return False
        
    return True

def prime(n):
    ans = 2
    for i in range(n, 10**5+4):
        if(isprime(i)):
            ans = i        
            break
    return ans
 
print(prime(X))
Buggy python submission (verdict: Runtime Error):
from math import degrees, atan, radians
a, b, x = map(int, input().split())

if(x < 0.5*a*a*b):
    y = x/(0.5*b*a)
    ans = 90-degrees(atan(y/b))
    print(ans)
elif(x == 0.5*a*a*b)    
    print(0)
else:
    y = x/(0.5*a**2)-b
    ans = 90-degrees(atan((a/(b-y))))
    print(ans)

Fixed submission:
from math import degrees, atan, radians
a, b, x = map(int, input().split())

if(x <= 0.5*a*a*b):
    y = x/(0.5*b*a)
    ans = 90-degrees(atan(y/b))
    print(ans)
elif(x == a*a*b):    
    print(0)
else:
    y = x/(0.5*a**2)-b
    ans = 90-degrees(atan((a/(b-y))))
    print(ans)

Buggy python submission (verdict: Runtime Error):
from math import degrees, atan, radians
a, b, x = map(int, input().split())

if(x <= 0.5*a*a*b):
    y = x/(0.5*b*a)
    ans = 90-degrees(atan(y/b))
    print(ans)
else:
    y = x/(0.5*a**2)-b
    ans = 90-degrees(atan((a/(b-y))))
    print(ans)

Fixed submission:
from math import degrees, atan, radians
a, b, x = map(int, input().split())

if(x <= 0.5*a*a*b):
    y = x/(0.5*b*a)
    ans = 90-degrees(atan(y/b))
    print(ans)
elif(x == a*a*b):    
    print(0)
else:
    y = x/(0.5*a**2)-b
    ans = 90-degrees(atan((a/(b-y))))
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N, K, Q = map(int, input().split())
A = [0]*Q
for i in range(Q):
    A[i] = int(input())
B = [K]*N    
n_a = np.array(B)
for i in range(Q):
    n_a -= 1
    n_a[A[i]-1] += 1
    
ans = n_a.tolist()

for i in ans:
    print("No" if i<1 else "Yes")

Fixed submission:
N, K, Q = map(int, input().split())
A = [0]*Q
B = [K-Q]*N
for i in range(Q):
    A[i] = int(input())
    B[A[i]-1] += 1

for i in B:
    print("Yes" if i > 0 else "No")
Buggy python submission (verdict: Runtime Error):
import collections
import math

def combinations_count(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

N = int(input())
s = [""]*N
for i in range(N):
    s[i] = ','.join(sorted(input()))

c = collections.Counter(s)
ans = 0
for value in c.values():
    ans += combinations_count(value, 2)
    
print(ans)

Fixed submission:
import collections
import math

def combinations_count(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))

N = int(input())
s = [""]*N
for i in range(N):
    s[i] = ','.join(sorted(input()))

c = collections.Counter(s)
ans = 0
for value in c.values():
    if(value == 1):
        continue
    ans += combinations_count(value, 2)
    
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = [0]*N
for i in range(N):
    a[i] = int(input())
    
for j in range(N):
    num = a.pop(j)
    print(max(a))
    a.insert(j, num)

Fixed submission:
N = int(input())
a = [0]*N
for i in range(N):
    a[i] = int(input())
b = sorted(a)   

for i in range(N):
    if(a[i] == b[N-1]):
        print(b[N-2])
    else:
        print(b[N-1])
Buggy python submission (verdict: Runtime Error):
import math
N, D = map(int, input().split())
for i in range(N):
    x = list(map(int, input().split()))

cnt = 0
for i in range(D):
    for j in range(i+1, D):
        tmp = 0.0
        for k in range(D):
            tmp += (x[i][k]-x[j][k])**2
        if(math.sqrt(tmp).is_integer()):
            cnt += 1
print(cnt)

Fixed submission:
import math
N, D = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        tmp = 0
        for k in range(D):
            tmp+=(x[i][k]-x[j][k])**2
        if(math.sqrt(tmp).is_integer()):
            cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())

num = (C*D)//(math.gcd(C, D))
if(A%C==0):
    num1 = A//C-1
else:
    num1 = A//C
if(A%D==0):
    num2 = A//D-1
else:
    num2 = A//D
if(A%num == 0):
    num3 = A//num-1
else:
    num3 = A//num
print(int(B-A+1-((B//C-num1)+(B//D-num2)-(B//num-num3))))

Fixed submission:
import fractions
A, B, C, D = map(int, input().split())

num = (C*D)//(fractions.gcd(C, D))
if(A%C==0):
    num1 = A//C-1
else:
    num1 = A//C
if(A%D==0):
    num2 = A//D-1
else:
    num2 = A//D
if(A%num == 0):
    num3 = A//num-1
else:
    num3 = A//num
print(int(B-A+1-((B//C-num1)+(B//D-num2)-(B//num-num3))))

Buggy python submission (verdict: Runtime Error):
import math
A, B, C, D = map(int, input().split())

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

num = lcm(C, D)
if(A%C==0):
    num1 = A//C-1
else:
    num1 = A//C
if(A%D==0):
    num2 = A//D-1
else:
    num2 = A//D
if(A%num == 0):
    num3 = A//num-1
else:
    num3 = A//num
print(int(B-A+1-((B//C-num1)+(B//D-num2)-(B//num-num3))))

Fixed submission:
import fractions
A, B, C, D = map(int, input().split())

num = (C*D)//(fractions.gcd(C, D))
if(A%C==0):
    num1 = A//C-1
else:
    num1 = A//C
if(A%D==0):
    num2 = A//D-1
else:
    num2 = A//D
if(A%num == 0):
    num3 = A//num-1
else:
    num3 = A//num
print(int(B-A+1-((B//C-num1)+(B//D-num2)-(B//num-num3))))
Buggy python submission (verdict: Runtime Error):
import collections

N = int(input())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))

div = []
for i in range(N):
    for j in range(N):
        if(i == j):
            continue
        div.append(tuple((X[i][0]-X[j][0], X[i][1]-X[j][1])))
        
c = collections.Counter(div)
c_s = sorted(c.items(), key=lambda x:x[1], reverse=True)

print(N-c_s[0][1])

Fixed submission:
import collections

N = int(input())
X = []
for i in range(N):
    X.append(list(map(int, input().split())))

div = []
for i in range(N):
    for j in range(N):
        if(i == j):
            continue
        div.append(tuple((X[i][0]-X[j][0], X[i][1]-X[j][1])))
        
c = collections.Counter(div)
c_s = sorted(c.items(), key=lambda x:x[1], reverse=True)

if(N == 1):
    print(1)
else:
    print(N-c_s[0][1])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
a = [0]*M
mod = 10**9+7

for i in range(M):
    a[i] = int(input())

DP = [0]*(N+1)
DP[0] = 1
if 1 in a:
    DP[1] = 0
else:
    DP[1] = 1

for i in range(2, N+1):
    if(i not in a):
        DP[i] = (DP[i-1]+DP[i-2])%mod
        
print(DP[-1])

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

N, M = map(int, input().split())
a = [0]*M
mod = 10**9+7

for i in range(M):
    a[i] = int(input())

a = set(a)
DP = [0]*(N+1)
DP[0] = 1
if 1 in a:
    DP[1] = 0
else:
    DP[1] = 1

for i in range(2, N+1):
    if(i not in a):
        DP[i] = (DP[i-1]+DP[i-2])%mod
        
print(DP[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
a = [0]*M
mod = 10**9+7

for i in range(M):
    a[i] = int(input())

DP = [0]*(N+1)
DP[0] = 1
if 1 in a:
    DP[1] = 0
else:
    DP[1] = 1

for i in range(2, N+1):
    if(i not in a):
        DP[i] = (DP[i-1]+DP[i-2])%mod
        
print(DP[N])

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

N, M = map(int, input().split())
a = [0]*M
mod = 10**9+7

for i in range(M):
    a[i] = int(input())

a = set(a)
DP = [0]*(N+1)
DP[0] = 1
if 1 in a:
    DP[1] = 0
else:
    DP[1] = 1

for i in range(2, N+1):
    if(i not in a):
        DP[i] = (DP[i-1]+DP[i-2])%mod
        
print(DP[-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
a = [0]*M
mod = 1000000007

for i in range(M):
    a[i] = int(input())

DP = [0]*(N+1)
DP[0] = 1
if 1 in a:
    DP[1] = 0
else:
    DP[1] = 1

for i in range(2, N+1):
    if(i not in a):
        DP[i] = (DP[i-1]+DP[i-2])%mod
        
print(DP[N])

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

N, M = map(int, input().split())
a = [0]*M
mod = 10**9+7

for i in range(M):
    a[i] = int(input())

a = set(a)
DP = [0]*(N+1)
DP[0] = 1
if 1 in a:
    DP[1] = 0
else:
    DP[1] = 1

for i in range(2, N+1):
    if(i not in a):
        DP[i] = (DP[i-1]+DP[i-2])%mod
        
print(DP[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
a = []
mod = 1000000007

for i in range(M):
    a.append(int(input()))

DP = [0]*(N+1)
DP[0] = 1
if 1 in a:
    DP[1] = 0
else:
    DP[1] = 1

for i in range(2, N+1):
    if(i in a):
        continue
    else:
        DP[i] = (DP[i-1]+DP[i-2])%mod
        
print(DP[N])

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

N, M = map(int, input().split())
a = [0]*M
mod = 10**9+7

for i in range(M):
    a[i] = int(input())

a = set(a)
DP = [0]*(N+1)
DP[0] = 1
if 1 in a:
    DP[1] = 0
else:
    DP[1] = 1

for i in range(2, N+1):
    if(i not in a):
        DP[i] = (DP[i-1]+DP[i-2])%mod
        
print(DP[-1])
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input())
print(n-k+1)

Fixed submission:
n, k = map(int, input().split())
print(n-k+1)
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//G+1):
        b = N - R*i - G*j
        if(b >= 0 and b%B == 0):
            cnt += 1
print(cnt)

Fixed submission:
R, G, B, N = map(int, input().split())
cnt = 0

for i in range(N//R+1):
    for j in range(N//G+1):
        b = N - R*i - G*j
        if(b < 0):
            break
        if(b%B == 0):
            cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque

H, W = map(int, input().split())
grid = [list(input()) for _ in range(H)]

def BFS(H, W, grid):
    visited = [[False for _ in range(W)] for _ in range(H)]
    que = deque()
    for i in range(H):
        for j in range(W):
            if(grid[i][j] == "#"):
                que.append((i, j, 0))
    dist = [(0, 1), (-1, 0), (0, -1), (1, 0)]
        
    while que:
        x, y, c = que.popleft()
        visited[x][y] = True
        
        for dx, dy in dist:
            nx = x + dx
            ny = y + dy
            
            if(nx < 0 or nx >= H or ny < 0 or ny >= W):
                continue
            if(not visited[nx][ny]):
                que.append((nx, ny, c+1))
    return c
        
print(BFS(H, W, grid))

Fixed submission:
from collections import deque

H, W = map(int, input().split())
grid = [input() for _ in range(H)]

def BFS(H, W, grid):
    visited = [[True for _ in range(W+2)] for _ in range(H+2)]
    que = deque()
    for i in range(H):
        visited[i+1][1:-1] = map(lambda _:_=="#", grid[i])
        for j in range(W):
            if(grid[i][j] == "#"):
                que.append((i+1, j+1, 0))
    dist = [(0, 1), (-1, 0), (0, -1), (1, 0)]
        
    while que:
        x, y, c = que.popleft()
        for dx, dy in dist:
            nx = x + dx
            ny = y + dy
            
            if(not visited[nx][ny]):
                que.append((nx, ny, c+1))
                visited[nx][ny] = True
    return c
        
print(BFS(H, W, grid))
Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
K = int(input())
ans = ""

for i in range(N):
    if(S[K] != S[i]):
        ans += "*"
    else:
        ans += S[K]
print(ans)

Fixed submission:
N = int(input())
S = input()
K = int(input())
ans = ""

for i in range(N):
    if(S[K-1] != S[i]):
        ans += "*"
    else:
        ans += S[K-1]
print(ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()

if(S[0] == "1"):
    s = []
else:
    s = [0]
cnt = 1
tmp = S[0]
for i in range(1, len(S)):
    if(tmp == S[i]):
        cnt += 1
    else:
        s.append(cnt)
        tmp = S[i]
        cnt = 1
s.append(cnt)
if(len(s)//2 <= K):
    ans = sum(s)        
else:
    ans = sum(s[:(2*K+1)])
    tmp = ans
    cnt = 0
    for i in range(2*K+1, len(s)-1, 2):
        if(ans < tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]):
            ans = tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]
            tmp = tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]
        else:
            tmp = tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]
        cnt += 2
    ss = s[::-1]
    if(S[-1] == "0"):
        tmp1 = sum(ss[:(2*K)])
    else:
        tmp1 = sum(ss[:(2*K+1)])
print(max(ans, tmp1))

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

if(S[0] == "1"):
    s = []
else:
    s = [0]
cnt = 1
tmp = S[0]
for i in range(1, len(S)):
    if(tmp == S[i]):
        cnt += 1
    else:
        s.append(cnt)
        tmp = S[i]
        cnt = 1
s.append(cnt)
tmp1 = 0
if(len(s)//2 <= K):
    ans = sum(s)        
else:
    ans = sum(s[:(2*K+1)])
    tmp = ans
    cnt = 0
    for i in range(2*K+1, len(s)-1, 2):
        if(ans < tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]):
            ans = tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]
            tmp = tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]
        else:
            tmp = tmp-s[cnt]-s[cnt+1]+s[i]+s[i+1]
        cnt += 2
    ss = s[::-1]
    if(S[-1] == "0"):
        tmp1 = sum(ss[:(2*K)])
    else:
        tmp1 = sum(ss[:(2*K+1)])
print(max(ans, tmp1))
Buggy python submission (verdict: Time Limit Exceeded):
import heapq

def main():
    X, Y, Z, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    AA = list(map(lambda x:x*(-1), A))
    BB = list(map(lambda x:x*(-1), B))
    CC = list(map(lambda x:x*(-1), C))

    ans = []
    heapq.heapify(ans)
    for a in AA:
        for b in BB:
            for c in CC:
                heapq.heappush(ans, a+b+c)
    
    for i in range(K):
        print(heapq.heappop(ans)*(-1))
main()

Fixed submission:
from heapq import heappush, heapify, heappop

def main():
    X, Y, Z, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort(reverse=True)
    B.sort(reverse=True)
    C.sort(reverse=True)
    
    que = []
    heapify(que)
    heappush(que, (-A[0]-B[0]-C[0], 0, 0, 0))
    s = set()
    
    for i in range(K):
        ans = heappop(que)
        print(-ans[0])
        if(ans[1] < X-1 and not (ans[1]+1, ans[2], ans[3]) in s):
            heappush(que, [-A[ans[1]+1]-B[ans[2]]-C[ans[3]], ans[1]+1, ans[2], ans[3]])
            s.add((ans[1]+1, ans[2], ans[3]))
        if(ans[2] < Y-1 and not (ans[1], ans[2]+1, ans[3]) in s):
            heappush(que, [-A[ans[1]]-B[ans[2]+1]-C[ans[3]], ans[1], ans[2]+1, ans[3]])
            s.add((ans[1], ans[2]+1, ans[3]))
        if(ans[3] < Z-1 and not (ans[1], ans[2], ans[3]+1) in s):
            heappush(que, [-A[ans[1]]-B[ans[2]]-C[ans[3]+1], ans[1], ans[2], ans[3]+1])
            s.add((ans[1], ans[2], ans[3]+1))   
main()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()
dict = {ch : S.count(ch) for ch in S}
ans = 1

for value in dict.values():
    ans *= (value+1)
print((ans-1)%(10**9+7))

Fixed submission:
import collections
N = int(input())
S = input()
mod = 10**9+7

C = collections.Counter(S)
ans = 1

for value in C.values():
    ans *= (value + 1)
print((ans-1)%mod)
Buggy python submission (verdict: Runtime Error):
def main():
    N, K = map(int, input().split())
    h = list(map(int, input().split()))

    DP = [10**10 for _ in range(N)]
    DP[0] = 0
    DP[1] = abs(h[0]-h[1])
    
    for i in range(2, N):
        DP[i] = min([DP[k]+abs(h[i]-h[k]) for k in range(max(0, i-k), i)])    
    print(DP[N-1])
main()

Fixed submission:
def main():

    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    DP = [0]*N
    DP[1] = abs(h[1]-h[0])

    for i in range(2, N):
        DP[i] = min(abs(h[i]-h[j]) + DP[j] for j in range(max(0, i-K), i))
    print(DP[-1])
    
main()

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))
DP = [0]*N
DP[1] = abs(h[1]-h[0])

for i in range(2, N):
    DP[i] = min(abs(h[i]-h[j]) + DP[j] for j in range(max(0, i-K), i))
print(DP[-1])

Fixed submission:
def main():

    N, K = map(int, input().split())
    h = list(map(int, input().split()))
    DP = [0]*N
    DP[1] = abs(h[1]-h[0])

    for i in range(2, N):
        DP[i] = min(abs(h[i]-h[j]) + DP[j] for j in range(max(0, i-K), i))
    print(DP[-1])
    
main()