Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]
P = [0] * N
n = N - 1
q = [1]
j = 0
while n > 0:
    for i in range(M):
        if AB[i][0] == q[j]:
            if P[AB[i][1] - 1] == 0:
                P[AB[i][1] - 1] = q[j]
                q.append(AB[i][1])               
                AB[i] = [0, 0]
                n -= 1
        elif AB[i][1] == q[j]:
            if P[AB[i][0] - 1] == 0:
                P[AB[i][0] - 1] = q[j]
                q.append(AB[i][0])
                AB[i] = [0, 0]               
                n -= 1
    j += 1
print('Yes')
for i in range(1, N):
    print(P[i])

Fixed submission:
from collections import deque
N, M = map(int, input().split())
R = [[] for i in range(N + 1)]
for i in range(M):
    A, B = map(int, input().split())
    R[A].append(B)
    R[B].append(A)
P = [-1] * (N + 1)
P[1] = 0
Q = deque()
Q.append(1)

while Q:
    v = Q.popleft()
    for r in R[v]:
        if P[r] == -1:
            P[r] = v
            Q.append(r)
print('Yes')
for p in P[2:]:
    print(p)

Buggy python submission (verdict: Time Limit Exceeded):

N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(M)]
P = [0] * N
Q = [1]
n = N - 1
while n > 0:
    for q in Q:
        for i in range(M):
            if AB[i][0] == q:
                if P[AB[i][1] - 1] == 0:
                    P[AB[i][1] - 1] = q
                    Q.append(AB[i][1])
                    AB[i] = [0, 0]
                    n -= 1
            elif AB[i][1] == q:
                if P[AB[i][0] - 1] == 0:
                    P[AB[i][0] - 1] = q
                    Q.append(AB[i][0])
                    AB[i] = [0, 0]
                    n -= 1
print('Yes')
for i in range(1, N):
    print(P[i])

Fixed submission:
from collections import deque
N, M = map(int, input().split())
R = [[] for i in range(N + 1)]
for i in range(M):
    A, B = map(int, input().split())
    R[A].append(B)
    R[B].append(A)
P = [-1] * (N + 1)
P[1] = 0
Q = deque()
Q.append(1)

while Q:
    v = Q.popleft()
    for r in R[v]:
        if P[r] == -1:
            P[r] = v
            Q.append(r)
print('Yes')
for p in P[2:]:
    print(p)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
X = int(input())

for x in range(100000):
    for y in range(100000):
        A = x ** 5 - y ** 5
        if A == X:
            print(x, y)
            sys.exit()
        A = - x ** 5 - y ** 5
        if A == X:
            print(-x, y)
            sys.exit()
        A = x ** 5 + y ** 5
        if A == X:
            print(x, -y)
            sys.exit()
        A = -x ** 5 + y ** 5
        if A == X:
            print(-x, -y)
            sys.exit()


Fixed submission:
import sys
X = int(input())

for x in range(100000):
    if 2 * x ** 5 == X:
        print(x, -x)
        sys.exit()
    for y in range(x):
        if (x ** 5 - y ** 5) == X:
            print(x, y)
            sys.exit()
        if (-x ** 5 + y ** 5) == X:
            print(-y, -x)
            sys.exit()
    tmp = 0
    y = 0
    while tmp < X:
        tmp = x ** 5 + y ** 5
        if tmp == X:
            print(x, -y)
            sys.exit()
        y += 1
Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
c = 0
i = 1
x = B * i - 1
while x <= N:
    cc = (A * x) // B - A * (x // B)
    c = max(c, cc)
    i += 1
    x = B * i - 1
if c == 0:
    x = N
    c = (A * x) // B - A * (x // B)
print(c)

Fixed submission:
A, B, N = map(int, input().split())
if N >= B - 1:
    x = B - 1
    c = (A * x) // B - A * (x // B)
else:
    x = N
    c = (A * x) // B - A * (x // B)
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
A, B, N = map(int, input().split())
c = 0
i = 1
x = B * i - 1
while x <= N:
    cc = (A * x) // B - A * (x // B)
    c = max(c, cc)
    i += 1
    x = B * i - 1
if c == 0:
    x = N
    c = (A * x) // B - A * (x // B)
print(c)

Fixed submission:
A, B, N = map(int, input().split())
if N >= B - 1:
    x = B - 1
    c = (A * x) // B - A * (x // B)
else:
    x = N
    c = (A * x) // B - A * (x // B)
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
N, X, Y = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(N - 1):
    G[i].append(i + 1)
    G[i + 1].append(i)
G[X - 1].append(Y - 1)
G[Y - 1].append(X - 1)

L = [0] * N
for i in range(N - 1):
    dist = [N] * N
    dist[i] = 0
    Q = deque()
    Q.append(i)
    while len(Q) > 0:
        q = Q.popleft()
        for j in G[q]:
            if dist[j] != N:
                continue
            dist[j] = min(dist[q] + 1, dist[j])
            Q.append(j)
    for k in range(i, N):
        if dist[k] != N and dist[k] != 0:
            L[dist[k]] += 1
for i in range(1, N):
    print(L[i])

Fixed submission:
from collections import deque
N, X, Y = map(int, input().split())
G = [[] for _ in range(N)]
for i in range(N - 1):
    G[i].append(i + 1)
    G[i + 1].append(i)
G[X - 1].append(Y - 1)
G[Y - 1].append(X - 1)

L = [0] * N
for i in range(N - 1):
    dist = [N] * N
    dist[i] = 0
    Q = deque()
    Q.append(i)
    while len(Q) > 0:
        q = Q.popleft()
        for j in G[q]:
            if dist[j] != N:
                continue
            dist[j] = min(dist[q] + 1, dist[j])
            Q.append(j)
    for k in range(i, N):
        if dist[k] != N and dist[k] != 0:
            L[dist[k]] += 1
for i in range(1, N):
    print(L[i])
Buggy python submission (verdict: Runtime Error):
import sys
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

if N == 1 and sc[0][1] == 0:
    print(0)
    sys.exit()

A = [-1] * N
A[0] = 1
for i in range(M):
    if sc[i][0] == 1 and sc[i][1] == 0:
        print('-1')
        sys.exit()
    if sc[i][0] != 1 and A[sc[i][0] - 1] != -1 and A[sc[i][0] - 1] != sc[i][1]:
        print('-1')
        sys.exit()
    A[sc[i][0] - 1] = sc[i][1]
for a in A:
    if a == -1:
        a = 0
    print(a, end='')
print('')

Fixed submission:
import sys
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(M)]

if N == 1 and M == 0:
    print(0)
    sys.exit()
if N == 1 and sc[0][1] == 0:
    print(0)
    sys.exit()

A = [-1] * N
for i in range(M):
    if sc[i][0] == 1 and sc[i][1] == 0:
        print('-1')
        sys.exit()
    if A[sc[i][0] - 1] != -1 and A[sc[i][0] - 1] != sc[i][1]:
        print('-1')
        sys.exit()
    A[sc[i][0] - 1] = sc[i][1]
if A[0] == -1:
    A[0] = 1
for a in A:
    if a == -1:
        a = 0
    print(a, end='')
print('')
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
R = [list(map(int, input().split())) for i in range(N)]
T = [[R[i][0] + R[i][1], R[i][0] - R[i][1]] for i in range(N)]
T.sort()
while len(T) - 1 > 0:
    t = T.pop(0)
    i = 1
    while len(T) and t[0] > T[0][1]:
        N -= 1
        i += 1
        T.pop(0)
print(N)


Fixed submission:
N = int(input())
X = [list(map(int, input().split())) for i in range(N)]
LR = [[x[0]-x[1], x[0] + x[1]] for x in X]
LR.sort(key=lambda x:x[1])

A = 1
right = LR[0][1]
for i in range(1, N):
    if right <= LR[i][0]:
        A += 1
        right = LR[i][1]
print(A)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
R = sorted([list(map(int, input().split())) for i in range(N)])
T = []
for i in range(N):
    T.append([R[i][0] + R[i][1], R[i][0] - R[i][1]])
T.sort()
while len(T) - 1 > 0:
    t = T.pop(0)
    i = 1
    while len(T) and t[0] > T[0][1]:
        N -= 1
        i += 1
        T.pop(0)
print(N)


Fixed submission:
N = int(input())
X = [list(map(int, input().split())) for i in range(N)]
LR = [[x[0]-x[1], x[0] + x[1]] for x in X]
LR.sort(key=lambda x:x[1])

A = 1
right = LR[0][1]
for i in range(1, N):
    if right <= LR[i][0]:
        A += 1
        right = LR[i][1]
print(A)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
R = sorted([list(map(int, input().split())) for i in range(N)])
T = []
for i in range(N):
    T.append([R[i][0] + R[i][1], R[i][0] - R[i][1]])
T.sort()
while len(T) - 1 > 0:
    t = T.pop(0)
    i = 1
    while len(T) and t[0] > T[0][1]:
        N -= 1
        i += 1
        T.pop(0)
print(N)

Fixed submission:
N = int(input())
X = [list(map(int, input().split())) for i in range(N)]
LR = [[x[0]-x[1], x[0] + x[1]] for x in X]
LR.sort(key=lambda x:x[1])

A = 1
right = LR[0][1]
for i in range(1, N):
    if right <= LR[i][0]:
        A += 1
        right = LR[i][1]
print(A)

Buggy python submission (verdict: Runtime Error):
N = int(input())
R = sorted([list(map(int, input().split())) for i in range(N)])
T = []
for i in range(N):
    T.append([R[i][0] + R[i][1], i])
T.sort()

while len(T) - 1 > 0:
    t = T.pop(0)
    print(t[0], R[t[1] + 1][0], R[t[1] + 1][1])
    if t[0] > R[t[1] + 1][0] - R[t[1] + 1][1]:
        N -= 1
        R[t[1] + 1][1] = 0
        T.pop(0)
print(N)

Fixed submission:
N = int(input())
X = [list(map(int, input().split())) for i in range(N)]
LR = [[x[0]-x[1], x[0] + x[1]] for x in X]
LR.sort(key=lambda x:x[1])

A = 1
right = LR[0][1]
for i in range(1, N):
    if right <= LR[i][0]:
        A += 1
        right = LR[i][1]
print(A)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))
INF = 10 ** 9
dp = [INF] * N
dp[0] = 0
for i in range(N - 1):
    for j in range(1, K + 1):
        if i + j > N - 1:
            break
        dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
print(dp[-1])

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

INF = 10 ** 9
dp = [INF] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

def chmin(a, b):
    if a > b:
        return b
    else:
        return a
        
for i in range(2, N):
    for j in range(1, K + 1):
        dp[i] = chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]))

print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
h = list(map(int, input().split()))
INF = 10 ** 9

dp = [INF] * N
dp[0] = 0

for i in range(N - 1):
    for k in range(1, K + 1):
        if i + k > N - 1:
            break
        dpp = dp[i] + abs(h[i + k] - h[i])
        dp[i + k] = min(dp[i + k], dpp)

print(dp[-1])

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

INF = 10 ** 9
dp = [INF] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

def chmin(a, b):
    if a > b:
        return b
    else:
        return a
        
for i in range(2, N):
    for j in range(1, K + 1):
        dp[i] = chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]))

print(dp[-1])

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

INF = 10 ** 9
dp = [INF] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, N):
    for j in range(1, K + 1):
        if dp[i] > dp[i - j] + abs(h[i] - h[i - j]):
            dp[i] = dp[i - j] + abs(h[i] - h[i - j])

print(dp[-1])

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

INF = 10 ** 9
dp = [INF] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

def chmin(a, b):
    if a > b:
        return b
    else:
        return a
        
for i in range(2, N):
    for j in range(1, K + 1):
        dp[i] = chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]))

print(dp[-1])

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

INF = 10 ** 9
dp = [INF] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

def chmin(a, b):
    if a > b:
        return b
    else:
        return a
        
for i in range(2, N):
    for j in range(1, K + 1):
        dp[i] = chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]))

print(dp[-1])

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

INF = 10 ** 9
dp = [INF] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

def chmin(a, b):
    if a > b:
        return b
    else:
        return a
        
for i in range(2, N):
    for j in range(1, K + 1):
        dp[i] = chmin(dp[i], dp[i - j] + abs(h[i] - h[i - j]))

print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]
dp = [[0] * (W + 1) for _ in range(N)]

for i in range(N):
    for j in range(W + 1):
        dp[i][j] = max(dp[i][j], dp[i - 1][j])
        if j >= wv[i][0]:
            dp[i][j] = max(dp[i][j], dp[i - 1][j - wv[i][0]] + wv[i][1])
print(dp[N - 1][W])

Fixed submission:
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(W):
        w = wv[i - 1][0]
        v = wv[i - 1][1]
        if j + w <= W:
            dp[i][j + w] = max(dp[i][j + w], dp[i - 1][j] + v)
        dp[i][j] = max(dp[i][j], dp[i - 1][j])
        
print(max(dp[-1]))

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(0, N):
    w = wv[i][0]
    v = wv[i][1]
    for j in range(W + 1):
        if j - w >= 0:
            dpp = dp[i][j - w] + v
            dp[i + 1][j] = max(dp[i + 1][j], dpp)    
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])

print(max(dp[-1]))

Fixed submission:
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(W):
        w = wv[i - 1][0]
        v = wv[i - 1][1]
        if j + w <= W:
            dp[i][j + w] = max(dp[i][j + w], dp[i - 1][j] + v)
        dp[i][j] = max(dp[i][j], dp[i - 1][j])
        
print(max(dp[-1]))

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(W):
        w = wv[i - 1][0]
        v = wv[i - 1][1]
        if j + w <= W:
            dp[i][j + w] = max(dp[i][j + w], dp[i - 1][j] + v)
            dp[i][j] = max(dp[i][j], dp[i - 1][j])
        else:
            dp[i][j] = max(dp[i][j], dp[i - 1][j])
        
print(max(dp[-1]))

Fixed submission:
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i in range(1, N + 1):
    for j in range(W):
        w = wv[i - 1][0]
        v = wv[i - 1][1]
        if j + w <= W:
            dp[i][j + w] = max(dp[i][j + w], dp[i - 1][j] + v)
        dp[i][j] = max(dp[i][j], dp[i - 1][j])
        
print(max(dp[-1]))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
T = input()
s = len(S)
t = len(T)
dp = [[0] * (t + 1) for _ in range(s + 1)]
for i in range(s):
    for j in range(t):
        if S[i] == T[j]:
            dp[i + 1][j + 1] = dp[i][j] + 1
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j])
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1])
A = ''
i = s
j = t
while i > 0 and j > 0:
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j - 1]:
        j -= 1
    else:
        A = S[i - 1] + A
        i -= 1
        j -= 1
print(A)

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

dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]
for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dpp = dp[i][j] + 1
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dpp)
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1])
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j])

u = ''
i = len(s)
j = len(t)
while i > 0 and j > 0:
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j - 1]:
        j -= 1
    else:
        u = s[i - 1] + u
        i -= 1
        j -= 1

print(u)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()

dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]
for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dpp = dp[i][j] + 1
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dpp)
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1])
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j])

u = ''
i = len(s)
j = len(t)
while i > 0 and j > 0:
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j - 1]:
        j -= 1
    else:
        u = s[i - 1] + u
        i -= 1
        j -= 1

print(u)

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

dp = [[0] * (len(t) + 1) for _ in range(len(s) + 1)]
for i in range(len(s)):
    for j in range(len(t)):
        if s[i] == t[j]:
            dpp = dp[i][j] + 1
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dpp)
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j + 1])
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j])

u = ''
i = len(s)
j = len(t)
while i > 0 and j > 0:
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j - 1]:
        j -= 1
    else:
        u = s[i - 1] + u
        i -= 1
        j -= 1

print(u)
Buggy python submission (verdict: Runtime Error):
import sys
H, W = map(int, input().split())
s = [input() for i in range(H)]
S = []
S.append('.' * (W + 2))
for i in range(W):
    S.append('.' + s[i] + '.')
S.append('.' * (W + 2))
for i in range(1, H + 1):
    for j in range(1, W + 1):
        if S[i][j] == '#':
            if S[i + 1][j] == '#' or S[i - 1][j] == '#' or S[i][j + 1] == '#' or S[i][j - 1] == '#':
                continue
            else:
                print('No')
                sys.exit()
print('Yes')

Fixed submission:
import sys
H, W = map(int, input().split())
s = []
s.append('.' * (W + 2))
for i in range(1, H + 1):
    a = input()
    a = '.' + a + '.'
    s.append(a)
s.append('.' * (W + 2))
for i in range(1, H + 1):
    for j in range(1, W + 1):
        if s[i][j] == '#':
            OK = False
            if s[i - 1][j] == '#' or s[i + 1][j] == '#' or s[i][j - 1] == '#' or s[i][j + 1] == '#':
                OK = True
            if OK == False:
                print('No')
                sys.exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
S = list(input())
T = list(input())
s = len(S)
t = len(T)
OK = False
P = 0
for i in range(s - t + 1):
    if S[i] != T[0] and S[i] != '?':
        continue
    for j in range(1, t):
        if S[i + j] != T[j] and S[i + j] != '?':
            break
        if j == t - 1:
            OK = True
            P = i
for k in range(t):
    S[P + k] = T[k]
for i in range(s):
    if S[i] == '?':
        S[i] = 'a'
if OK:
    [print(S[i], end='') for i in range(s)]
    print('')
else:
    print('UNRESTORABLE')

Fixed submission:
import sys
S = input()
T = input()
s = len(S)
t = len(T)
if s < t:
    print('UNRESTORABLE')
    sys.exit()

for i in range(s - t, -1, -1):
    OK = True
    for j in range(t):
        if S[i + j] != T[j] and S[i + j] != '?':
            OK = False
    if OK:
        for j in range(t):
            SS = S[:i] + T + S[i + j + 1:]
            SS = SS.replace('?', 'a')
        print(SS)
        sys.exit()

print('UNRESTORABLE')

Buggy python submission (verdict: Runtime Error):
S = list(input())
T = list(input())
s = len(S)
t = len(T)
OK = False
P = 0
for i in range(s - t + 1):
    if S[i] != T[0] and S[i] != '?':
        continue
    for j in range(1, t):
        if S[i + j] != T[j] and S[i + j] != '?':
            OK = False
            break
        if j == t - 1:
            OK = True
            P = i
for k in range(t):
    S[P + k] = T[k]
for i in range(s):
    if S[i] == '?':
        S[i] = 'a'
if OK:
    [print(S[i], end='') for i in range(s)]
    print('')
else:
    print('UNRESTORABLE')

Fixed submission:
import sys
S = input()
T = input()
s = len(S)
t = len(T)
if s < t:
    print('UNRESTORABLE')
    sys.exit()

for i in range(s - t, -1, -1):
    OK = True
    for j in range(t):
        if S[i + j] != T[j] and S[i + j] != '?':
            OK = False
    if OK:
        for j in range(t):
            SS = S[:i] + T + S[i + j + 1:]
            SS = SS.replace('?', 'a')
        print(SS)
        sys.exit()

print('UNRESTORABLE')
Buggy python submission (verdict: Runtime Error):
A, B, C, D, E, F = map(int, input().split())

d = 0
for i in range(31):
    if i * 100 * A > F:
        break
    for j in range(31):
        if i * 100 * A + j * 100 * B > F:
            break
        if i == 0 and j == 0:
            break
        for k in range(0, 1501, C):
            if k > i * A * E + j * B * E:
                break
            m = i * 100 * A + j * 100 * B + k
            if m > F:
                break
            l1 = F - m
            l2 = i * A * E + j * B * E - k
            l = min(l1, l2)
            l = int(l / D) * D
            d1 = 100 * (k + l) / (m + l)
            if d < d1:
                w = m + l
                s = k + l
                d = d1
print('{0} {1}'.format(w, s))

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

d = 0
for i in range(31):
    if i * 100 * A > F:
        break
    for j in range(31):
        if i * 100 * A + j * 100 * B > F:
            break
        if i == 0 and j == 0:
            break
        for k in range(0, 1501, C):
            if k > i * A * E + j * B * E:
                break
            m = i * 100 * A + j * 100 * B + k
            if m > F:
                break
            l1 = F - m
            l2 = i * A * E + j * B * E - k
            l = min(l1, l2)
            l = int(l / D) * D
            d1 = 100 * (k + l) / (m + l)
            if d < d1:
                w = m + l
                s = k + l
                d = d1
if d == 0:
    if 100 * A <= F:
        print('{0} {1}'.format(100 * A, 0))
    else:
        print('{0} {1}'.format(100 * B, 0))
else:
    print('{0} {1}'.format(w, s))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = (list(map(int, input().split())))
for i in range(N):
    a.append(a[i] - 1)
    a.append(a[i] + 1)
a.sort()
X = 1
for x in range(a[0], a[-1]):
    X = max(X, a.count(x))
print(X)

Fixed submission:
import collections
N = int(input())
a = (list(map(int, input().split())))
for i in range(N):
    a.append(a[i] - 1)
    a.append(a[i] + 1)
c = collections.Counter(a)
print(c.most_common()[0][1])

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

X = 1
c = 1

for i in range(N - 1):
    a_0 = a[i]
    a_1 = a[i] - 1
    a_2 = a[i] + 1
    j = i
    while True:
        if j == N - 1:
            X = max(X, c)
            c = 1
            break
        b_0 = a[j + 1]
        b_1 = a[j + 1] - 1
        b_2 = a[j + 1] + 1
        b = [b_0, b_1, b_2]
        if a_0 in b or a_1 in b or a_2 in b:
            c += 1
            j += 1
        else:
            X = max(X, c)
            c = 1
            break
print(X)

Fixed submission:
import collections
N = int(input())
a = (list(map(int, input().split())))
for i in range(N):
    a.append(a[i] - 1)
    a.append(a[i] + 1)
c = collections.Counter(a)
print(c.most_common()[0][1])

Buggy python submission (verdict: Runtime Error):
import sys
N = int(input())
a = sorted(list(map(int, input().split())))

X = 0
c = 1
i = 0
while True:
    if i == N - 1:
        X = max(X, c)
        break
    a_0 = a[i]
    a_1 = a[i] - 1
    a_2 = a[i] + 1
    while True:
        b_0 = a[i + 1]
        b_1 = a[i + 1] - 1
        b_2 = a[i + 1] + 1
        b = [b_0, b_1, b_2]
        if a_0 in b or a_1 in b or a_2 in b:
            c += 1
            i += 1
        else:
            X = max(X, c)
            c = 1
            i += 1
            break
print(X)

Fixed submission:
import collections
N = int(input())
a = (list(map(int, input().split())))
for i in range(N):
    a.append(a[i] - 1)
    a.append(a[i] + 1)
c = collections.Counter(a)
print(c.most_common()[0][1])