Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import bisect

n = int(input())
A = list(map(int, input().split()))
A.sort()
ama = A[-1]
print(ama, end=' ')
ama2 = (ama + 1)//2
w = bisect.bisect_left(A, ama2)

a = A[w]
b = A[w+1]
if abs(a-ama2) > abs(b-ama2):
    print(b)
else:
    print(a)


Fixed submission:
import bisect

n = int(input())
A = list(map(int, input().split()))
A.sort()
ama = A[-1]
print(ama, end=' ')
ama2 = (ama + 1)//2
w = bisect.bisect_left(A, ama2)

a = A[w-1]
b = A[w]
if abs(a-ama2) > abs(b-ama2):
    print(b)
else:
    print(a)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A = list(map(int, input().split()))
A.sort()
ama = A[-1]
ama2 = (ama + 1)//2

for i in range(ama2 + 1):
    a = ama2 + i
    b = ama2 - i

    if b in A:
        print(ama, end=' ')
        print(b)
        exit()
    if a in A:
        print(ama, end=' ')
        print(a)
        exit()

Fixed submission:
import bisect

n = int(input())
A = list(map(int, input().split()))
A.sort()
ama = A[-1]
print(ama, end=' ')
ama2 = (ama + 1)//2
w = bisect.bisect_left(A, ama2)

a = A[w-1]
b = A[w]
if abs(a-ama2) > abs(b-ama2):
    print(b)
else:
    print(a)
Buggy python submission (verdict: Runtime Error):
from collections import deque
H, W = map(int, input().split())
maze = [[0 for i in range(W)]for j in range(H)]
ans = -1
for i in range(H):
    S = input()
    for j in range(W):
        maze[i][j] = S[j]
        if maze[i][j] == '.':
            ans += 1

q = deque()
q.append([0, 0])
maze[0][0] = 0
while len(q) != 0:
    x, y = q.popleft()
    for i in range(4):
        nx, ny = x + [0, 1, 0, -1][i], y + [1, 0, -1, 0][i]
        if nx < 0 or ny < 0 or nx >= W or ny >= H:
            continue
        elif maze[ny][nx] == '#':
            continue
        elif maze[ny][nx] == '.':
            maze[ny][nx] = maze[y][x] + 1
            q.append([nx, ny])
print(ans - maze[H-1][W-1])



Fixed submission:
from collections import deque
H, W = map(int, input().split())
maze = [[0 for i in range(W)]for j in range(H)]
ans = -1
for i in range(H):
    S = input()
    for j in range(W):
        maze[i][j] = S[j]
        if maze[i][j] == '.':
            ans += 1

q = deque()
q.append([0, 0])
maze[0][0] = 0
while len(q) != 0:
    x, y = q.popleft()
    for i in range(4):
        nx, ny = x + [0, 1, 0, -1][i], y + [1, 0, -1, 0][i]
        if nx < 0 or ny < 0 or nx >= W or ny >= H:
            continue
        elif maze[ny][nx] == '#':
            continue
        elif maze[ny][nx] == '.':
            maze[ny][nx] = maze[y][x] + 1
            q.append([nx, ny])
if maze[H-1][W-1] == '.':
    print(-1)
else:
    print(ans - maze[H-1][W-1])
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())

Cost = [0]
Start = [0]
Frequency = [0]


for __ in range(N-1):
    c, s, f = map(int, input().split())
    Cost.append(c)
    Start.append(s)
    Frequency.append(f)
a = sum(Cost) + max(Start) + sum(Frequency)
DP = [[0] * (2 * a) for _ in range(N+1)]

for i in range(N-1, 0, -1):
    for j in range(a, -1, -1):
        if j < Start[i]:
            DP[i][j] = DP[i][Start[i]] + Start[i] - j
        elif j >= Start[i]:
            sa = j % Frequency[i]
            if sa == 0:
                DP[i][j] = DP[i+1][j+Cost[i]] + Cost[i]
            else:
                DP[i][j] = DP[i][j + Frequency[i] - sa] + Frequency[i] - sa
for i in range(N):
    print(DP[i+1][0])




Fixed submission:
N = int(input())

Cost = [0]
Start = [0]
Frequency = [0]
Ans = [0] * (N+1)

for __ in range(N-1):
    c, s, f = map(int, input().split())
    Cost.append(c)
    Start.append(s)
    Frequency.append(f)

for i in range(1, N):
    if Ans[i] != 0:
        print(Ans[i])
    else:
        Same = []
        now = 0
        for j in range(i, N):
            if now <= Start[j]:
                if Ans[j] != 0:
                    now = Ans[j]
                    break
                Same.append(j)
                now = Start[j] + Cost[j]
            else:
                tmp = (now-1) // Frequency[j]
                tim = (tmp + 1) * Frequency[j]
                now = tim + Cost[j]
        print(now)
        for k in Same:
            Ans[k] = now
print(0)
Buggy python submission (verdict: Time Limit Exceeded):
Q = int(input())
Start = []
End = []
for _ in range(Q):
    l, r = map(int, input().split())
    Start.append(l)
    End.append(r)

e = max(End)


def primes(n):
    ass = set([])
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.add(i)
    return ass


def like_primes(n):
    A = [0]* (e+1)
    for i in n:
        if (i + 1) // 2 in n:
            A[i] = 1
    return A


A = like_primes(primes(e))
for i in range(Q):
    print(A[Start[i]:End[i]+1].count(1))


Fixed submission:
Q = int(input())
Start = []
End = []
for _ in range(Q):
    l, r = map(int, input().split())
    Start.append(l)
    End.append(r)

e = max(End)


def primes(n):
    ass = set([])
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.add(i)
    return ass


def like_primes(n):
    A = [0] * (e+2)
    for i in range(1, e+2):
        if (i in n) and ((i + 1) // 2 in n):
            A[i] = A[i-1] + 1
        else:
            A[i] = A[i-1]
    return A


A = like_primes(primes(e))
for i in range(Q):
    print(A[End[i]] - A[Start[i]-1])
Buggy python submission (verdict: Runtime Error):
S = input()

List = ['A', 'K', 'I', 'H', 'A', 'B', 'A', 'R', 'A']
num = 0

for i in range(len(S)):
    if num > 8:
        print('NO')
        exit()
    if S[i] == List[num]:
        num += 1
    elif List[num] == 'A':
        num += 1
        if S[i] == List[num]:
            num += 1
        else:
            print('NO')
            exit()
    else:
        print('NO')
        exit()

print('YES')



Fixed submission:
x = 'KIHBR'
T = []
for i in range(1<<6):
    t = ''
    for j in range(6):
        if i&(1<<j) and j != 1 and j != 2:
            t += 'A'
        if j != 5:
            t += x[j]
    T.append(t)
S = input()
if S in T:
    print('YES')
else:
    print('NO')

Buggy python submission (verdict: Runtime Error):
S = input()

List = ['A', 'K', 'I', 'H', 'A', 'B', 'A', 'R', 'A']
num = 0

for i in range(len(S)):
    if S[i] == List[num]:
        num += 1
    elif List[num] == 'A':
        num += 1
        if S[i] == List[num]:
            num += 1
        else:
            print('NO')
            exit()
    else:
        print('NO')
        exit()

print('YES')



Fixed submission:
x = 'KIHBR'
T = []
for i in range(1<<6):
    t = ''
    for j in range(6):
        if i&(1<<j) and j != 1 and j != 2:
            t += 'A'
        if j != 5:
            t += x[j]
    T.append(t)
S = input()
if S in T:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
N = input()
a = []
for i in range(len(N)):
    a.append(int(N[i]))

X = [0]*(n-1)
flag = False

for i in range(2**(n-1)):
    if flag:
        break
    S = a[0]
    for j in range(n-1):
        if (i >> j) & 1 == 1:
            X[j] = 1
            S += a[j+1]
        else:
            X[j] = 0
            S -= a[j+1]
    if S == k:
        flag = True
        break
print(a[0], end="")
for i in range(3):
    if X[i] == 1:
        print('+', end='')
    else:
        print('-', end='')
    print(a[i+1], end="")
print('=', end='')
print(k)







Fixed submission:
N = input()
A = []
for i in range(len(N)):
    A.append(int(N[i]))

for i in range(2 ** 3):
    List = []
    for j in range(3):
        if (i >> j) & 1 == 1:
            List.append(1)
        elif (i >> j) & 1 == 0:
            List.append(0)
    ans = A[0]
    for k in range(len(List)):
        if (List[k]):
            ans += A[k+1]
        else :
            ans -= A[k+1]

    if ans == 7:
        break

print(A[0], end="")
for i in range(3):
    if List[i]:
        print("+", end="")
    else:
        print("-", end="")
    print(A[i + 1], end="")
print("=7",end="")
Buggy python submission (verdict: Time Limit Exceeded):
N = input()
n = len(N)
Ans = set()
Ans.add(N)

for i in range(n):
    for j in range(i + 1, n):
        Ans.add(N[:i] + N[i:j+1][::-1] + N[j + 1:])

print(len(Ans))

Fixed submission:
from collections import Counter

N = input()
n = len(N)

NC = Counter(N)
ans = n * (n - 1) // 2 + 1

for value in NC.values():
    ans -= value * (value - 1) // 2

print(ans)
Buggy python submission (verdict: Runtime Error):
import math

N, K = map(int, input().split())
A = list(map(int, input().split()))
B = []
for a1, a2 in zip(A, A[1:]):
    B.append(abs(a2-a1))

if K > max(A):
    print('IMPOSSIBLE')
    exit()
if K in A:
    print('POSSIBLE')
    exit()

g = B[0]
for b in B[1:]:
    g = math.gcd(g, b)

if (A[0] - K) % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Fixed submission:
import fractions

N, K = map(int, input().split())
A = list(map(int, input().split()))
B = []
for a1, a2 in zip(A, A[1:]):
    B.append(abs(a2-a1))

if K > max(A):
    print('IMPOSSIBLE')
    exit()
if K in A:
    print('POSSIBLE')
    exit()

g = B[0]
for b in B[1:]:
    g = fractions.gcd(g, b)

if (A[0] - K) % g == 0:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')
Buggy python submission (verdict: Runtime Error):
A, B =map(int,input.split())
C = A+B
if C >=10:
    print('error')
else:
    print(C)

Fixed submission:
a = sum(map(int, input().split()))
print(a if a < 10 else 'error')
Buggy python submission (verdict: Runtime Error):
import numpy as np

N, A, B = map(int, input().split())
H = np.zeros(shape=N, dtype='int64')
for _ in range(N):
    h = int(input())
    H[_] = h


def calc(num, a):
    a -= num * B
    a = (a - 1)//(A - B) + 1
    if sum(a[a > 0]) <= num:
        return True
    else:
        return False


start = 0
end = 10 ** 10

while end - start > 1:
    mid = (start + end) // 2
    if calc(mid, H.copy()):
        end = mid
    else:
        start = mid

print(end)


Fixed submission:
import numpy as np

N, A, B = map(int, input().split())
H = np.zeros(shape=N, dtype='int64')
for _ in range(N):
    h = int(input())
    H[_] = h


def calc(num, a):
    a -= num * B
    a = (a - 1)//(A - B) + 1
    if sum(a[a > 0]) <= num:
        return True
    else:
        return False


start = 0
end = 10 ** 10

while end - start > 1:
    mid = (start + end) // 2
    if calc(mid, H.copy()):
        end = mid
    else:
        start = mid

print(end)
Buggy python submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

Fixed submission:
A, B, C = input().split()
if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000000)

S = input()


while len(S) > 0:
    if S[0] == 'd':
        if S[0:5] == 'dream':
            if S[5:7] == 'er':
                if S[7] == 'a':
                    S = S[5:]
                else:
                    S = S[7:]
            else:
                S = S[5:]
        else:
            print('NO')
            exit()
    elif S[0] == 'e':
        if S[0:5] == 'erase':
            if S[5] == 'r':
                S = S[6:]
            else:
                S = S[5:]
        else:
            print('NO')
            exit()
    else:
        print('NO')
        exit()

print('YES')

Fixed submission:
import sys
sys.setrecursionlimit(100000000)

S = input()[::-1]


while len(S) > 0:
    if S[0] == 'r':
        if S[0:6] == 'resare':
            S = S[6:]
        elif S[0:7] == 'remaerd':
            S = S[7:]
        else:
            print('NO')
            exit()
    elif S[0:5] == 'maerd':
        S = S[5:]
    elif S[0:5] == 'esare':
        S = S[5:]
    else:
        print('NO')
        exit()
print('YES')

Buggy python submission (verdict: Runtime Error):
S = input()
while len(S) > 0:
    if S[0] == 'd':
        if S[0:5] == 'dream':
            if S[5:7] == 'er':
                if S[7] == 'a':
                    S = S[5:]
                else:
                    S = S[7:]
            else:
                S = S[5:]
        else:
            print('NO')
            exit()
    elif S[0] == 'e':
        if S[0:5] == 'erase':
            if S[5] == 'r':
                S = S[6:]
            else:
                S = S[5:]
        else:
            print('NO')
            exit()
    else:
        print('NO')
        exit()

print('YES')

Fixed submission:
import sys
sys.setrecursionlimit(100000000)

S = input()[::-1]


while len(S) > 0:
    if S[0] == 'r':
        if S[0:6] == 'resare':
            S = S[6:]
        elif S[0:7] == 'remaerd':
            S = S[7:]
        else:
            print('NO')
            exit()
    elif S[0:5] == 'maerd':
        S = S[5:]
    elif S[0:5] == 'esare':
        S = S[5:]
    else:
        print('NO')
        exit()
print('YES')
Buggy python submission (verdict: Time Limit Exceeded):
def road_find(a):
    if Road[a] < 0:
        return a
    else:
        return road_find(Road[a])


def train_find(a):
    if Train[a] < 0:
        return a
    else:
        return train_find(Train[a])


def road_union(a, b):
    ag = road_find(a)
    bg = road_find(b)
    if ag == bg:
        return
    if Road[ag] > Road[bg]:
        ag, bg = bg, ag
    Road[ag] += Road[bg]
    Road[bg] = ag
    return


def train_union(a, b):
    ag = train_find(a)
    bg = train_find(b)
    if ag == bg:
        return
    if Train[ag] > Train[bg]:
        ag, bg = bg, ag
    Train[ag] += Train[bg]
    Train[bg] = ag
    return


N, K, L = map(int, input().split())
Road = [-1] * N
Train = [-1] * N
RoadG = [[] for _ in range(N)]
TrainG = [[] for _ in range(N)]

for road in range(K):
    p, q = map(int, input().split())
    p -= 1
    q -= 1
    road_union(p, q)
for i in range(N):
    RoadG[road_find(i)].append(i)

for train in range(L):
    p, q = map(int, input().split())
    p -= 1
    q -= 1
    train_union(p, q)
for i in range(N):
    TrainG[train_find(i)].append(i)


for i in range(N):
    i_road_g = road_find(i)
    i_train_g = train_find(i)
    print(len(set(TrainG[i_train_g]) & set(RoadG[i_road_g])), end=' ')


Fixed submission:
from collections import Counter

def road_find(a):
    if Road[a] < 0:
        return a
    else:
        return road_find(Road[a])


def train_find(a):
    if Train[a] < 0:
        return a
    else:
        return train_find(Train[a])


def road_union(a, b):
    ag = road_find(a)
    bg = road_find(b)
    if ag == bg:
        return
    if Road[ag] > Road[bg]:
        ag, bg = bg, ag
    Road[ag] += Road[bg]
    Road[bg] = ag
    return


def train_union(a, b):
    ag = train_find(a)
    bg = train_find(b)
    if ag == bg:
        return
    if Train[ag] > Train[bg]:
        ag, bg = bg, ag
    Train[ag] += Train[bg]
    Train[bg] = ag
    return


N, K, L = map(int, input().split())
Road = [-1] * N
Train = [-1] * N

for road in range(K):
    p, q = map(int, input().split())
    p -= 1
    q -= 1
    road_union(p, q)

for train in range(L):
    p, q = map(int, input().split())
    p -= 1
    q -= 1
    train_union(p, q)

Ans = []
for i in range(N):
    Ans.append((road_find(i),train_find(i)))

Ans_C = Counter(Ans)

for i in range(N):
    print(Ans_C[(road_find(i),train_find(i))])
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
n = len(S)
DP = [0]

for s in S:
    D = [-float('inf')] * (len(DP) + 1)
    for i in range(len(DP)):
        if s == 'g':
            if i == 0:
                D[i + 1] = max(D[i + 1], DP[i])
            else:
                D[i + 1] = max(D[i + 1], DP[i])
                D[i - 1] = max(D[i - 1], DP[i] + 1)
        if s == 'p':
            if i == 0:
                D[i + 1] = max(D[i + 1], DP[i] - 1)
            else:
                D[i + 1] = max(D[i + 1], DP[i] - 1)
                D[i - 1] = max(D[i - 1], DP[i])
    DP = D
print(max(DP))

Fixed submission:
S = input()
N = len(S)

print(N // 2 - S.count('p'))

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
n = len(S)
DP = [- float('inf')] * (n + 1)
DP[0] = 0

for s in S:
    D = [-float('inf')] * (n + 1)
    for i in range(n):
        if s == 'g':
            if i == 0:
                D[i + 1] = max(D[i + 1], DP[i])
            else:
                D[i + 1] = max(D[i + 1], DP[i])
                D[i - 1] = max(D[i - 1], DP[i] + 1)
        if s == 'p':
            if i == 0:
                D[i + 1] = max(D[i + 1], DP[i] - 1)
            else:
                D[i + 1] = max(D[i + 1], DP[i] - 1)
                D[i - 1] = max(D[i - 1], DP[i])
    DP = D
print(max(DP))

Fixed submission:
S = input()
N = len(S)

print(N // 2 - S.count('p'))
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
K = int(input())
Ans = ''
for s in S[:-1]:
    if (123 - ord(s)) <= K:
        Ans += 'a'
        K -= 123 - ord(s)
    else:
        Ans += s

K %= 26
if ord(S[-1]) + K >= 123:
    Ans += chr(ord(S[-1]) + K - 26)
else:
    Ans += chr(ord(S[-1]) + K)


print(Ans)

Fixed submission:
S = input()
K = int(input())
Ans = []
for s in S[:-1]:
    if s == 'a':
        Ans.append('a')
        continue
    if (123 - ord(s)) <= K:
        Ans.append('a')
        K -= 123 - ord(s)
    else:
        Ans.append(s)

K %= 26
if ord(S[-1]) + K >= 123:
    Ans.append(chr(ord(S[-1]) + K - 26))
else:
    Ans.append(chr(ord(S[-1]) + K))


print(''.join(Ans))
Buggy python submission (verdict: Runtime Error):
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]:
            for k in range(1,2*j-i):
                if S[j]!=S[k] and S[k]!=S[i]:
                    ans+=1
            for k in range(2*j-i+1,N):
                if S[j]!=S[k] and S[k]!=S[i]:
                    ans+=1
         
                
print(ans)

Fixed submission:
N=input()
if '7' in N:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Time Limit Exceeded):
def count(x,length):
    num=0
    for i in range(length-1):
        for j in range(i+1,length-1):
            if x[i]==x[j]:
                num+=1
    return num
  
x=int(input())
a=list(map(int,input().split()))

num=0
for i in range(x):
    delete=a[0]
    del a[0]
    print(count(a,x))
    a.append(delete)

Fixed submission:
import collections

x=int(input())
a=list(map(int,input().split()))

c=collections.Counter(a)
num=0
for i in c.values():
    num+=i*(i-1)/2
    
for i in range(x):
    print(int(num-c[a[i]]+1))
Buggy python submission (verdict: Runtime Error):
a1=list(map(int,input().split()))
a2=list(map(int,input().split()))
a3=list(map(int,input().split()))
 
for j in range(int(input())):
    X=int(input())
    for i in range(3):
        if X in a1:
            num=a1.index(X)
            a1[num]=[0]
        
        elif X in a2:
            num=a2.index(X)
            a2[num]=[0]
            
        elif X in a3:
            num=a3.index(X)
            a3[num]=[0]
        
        
        
C=False
for i in range(3):
    if a1.count(0)==3 or a2.count(0)==3 or a3.count(0)==3 or a1[0]==a2[0]==a3[0]==[0] or a1[1]==a2[1]==a3[1]==[0] or a1[2]==a2[2]==a3[2]==[0] or a1[0]==a2[1]==a3[2]==[0] or a1[0]==a2[1]==a3[2]==[0] or a1[2]==a2[1]==a3[0]==[0]:
        C=True
 
if C==True:
    print("Yes")
else:
    print("No")

Fixed submission:
x=int(input())
if x%2==0:
    print(int(x/2))
else:
    print(int(x/2)+1)
Buggy python submission (verdict: Runtime Error):
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		if (a<=b){
			System.out.println(a);
		}else{
			System.out.println(a-1);
		}
	}
}

Fixed submission:
a,b=list(map(int,input().split()))

if b<a:
    print(a-1)
else:
    print(a)
Buggy python submission (verdict: Time Limit Exceeded):
from math import fabs
N=int(input())
pos=list(map(int,input().split()))

for i in range(N):
    pos_=pos.copy()
    del pos_[i]
    pos_.insert(0,0)
    pos_.insert(N+1,0)
    x=0
    for j in range(N):
        x+=fabs(pos_[j+1]-pos_[j])
    print(int(x))
    

Fixed submission:
from math import fabs
N=int(input())
pos=list(map(int,input().split()))
pos.insert(0,0)
pos.insert(N+1,0)
total_len=0
for i in range(N+1):
    total_len+=fabs(pos[i+1]-pos[i])
    

for i in range(N):
    total=total_len-fabs(pos[i+1]-pos[i])-fabs(pos[i+2]-pos[i+1])+fabs(pos[i+2]-pos[i])
    print(int(total))
Buggy python submission (verdict: Runtime Error):
N,Y=input().split()
N=int(N)
Y=int(Y)

a=[]
for i in range(N+1):
    for j in range(N-i+1):
        if 1000*i+5000*j+10000*(N-i-j)==Y:
            a.append(str(N-i-j))
            a.append(str(j))
            a.append(str(i))
    if len(a)!=0:
        break


if len(a)!=0:
    print(a[0]+' '+a[1]+' '+a[2])
else:
    print('-1 -1 -1')
        

Fixed submission:
S=input()
S=S.replace('7','8',1)

print(S)

Buggy python submission (verdict: Runtime Error):
N,Y=input().split()
N=int(N)
Y=int(Y)

a=[]
for i in range(N+1):
    for j in range(N-i+1):
        if 1000*i+5000*j+10000*(N-i-j)==Y:
            a.append(str(N-i-j))
            a.append(str(j))
            a.append(str(i))
    if len(a)!=0:
        break


if len(a)!=0:
    print(a[0]+' '+a[1]+' '+a[2])
else:
    print('-1 -1 -1')
        

Fixed submission:
S=input()
S=S.replace('7','8',1)

print(S)
Buggy python submission (verdict: Runtime Error):
X,N = map(int,input().split())
if N == 0:
	print(X)
else:
	p = list(map(int,input().split()))
	p.sort()

	diff_1 = abs(X-p[-1])
	diff_2 = abs(X-p[0])
	diff = max(diff_1,diff_2)

	for x in range(0,diff+1):
		if X-x not in p
			print(X-x)
			break
		if X+x not in p
			print(X+x)
			break

Fixed submission:
X,N = map(int,input().split())
if N == 0:
	print(X)
else:
	p = list(map(int,input().split()))
	p.sort()

	diff_1 = abs(X-p[-1])
	diff_2 = abs(X-p[0])
	diff = max(diff_1,diff_2)


	for x in range(diff+2):
		if X-x not in p:
			print(X-x)
			break
		if X+x not in p:
			print(X+x)
			break

Buggy python submission (verdict: Runtime Error):
X,N = map(int,input().split())
p = list(map(int,input().split()))
ans = []
p.sort()

diff_1 = abs(X-p[-1])
diff_2 = abs(X-p[1])
diff = max(diff_1,diff_2)

for x in range(1,diff+1):
	if X+x not in p:
		ans.append(X+x)
		
	if X-x not in p:
		ans.append(X-x)

ans.sort()
print(ans[1])

Fixed submission:
X,N = map(int,input().split())
if N == 0:
	print(X)
else:
	p = list(map(int,input().split()))
	p.sort()

	diff_1 = abs(X-p[-1])
	diff_2 = abs(X-p[0])
	diff = max(diff_1,diff_2)


	for x in range(diff+2):
		if X-x not in p:
			print(X-x)
			break
		if X+x not in p:
			print(X+x)
			break
Buggy python submission (verdict: Runtime Error):
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if A < B:
	if A + (V*T) >= B + (W*T):
		print("YES")
	else:
		print("NO")
else:
	if A - (V*T) <= B - (W*T):
		print("YES")
	else:
		print("NO")


Fixed submission:
S = input()

print(S[:3])

Buggy python submission (verdict: Runtime Error):
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if A < B:
	if A + (V*T) >= B + (W*T):
		print("YES")
	else:
		print("NO")
else:
	if A - (V*T) <= B - (W*T):
		print("YES")
	else:
		print("NO")


Fixed submission:
S = input()

print(S[:3])
Buggy python submission (verdict: Runtime Error):
A,V = map(int,input().split())
B,W = map(int,input().split())
dist = abs(A-B)
diff = V-W
if dist > diff * T:
	print("NO")
else:
	print("YES")

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

T = int(input())

dist = abs(A-B)
diff = V-W
if dist > diff * T:
	print("NO")
else:
	print("YES")