Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
from copy import *

N, W = map(int, input().split())
MV = N * 10**3 + 1
INF = float('inf')
dp1 = [INF] * MV
dp1[0] = 0
for i in range(N):
    dp2 = [INF] * MV
    w, v = map(int, input().split())
    for j in range(MV):
        dp2[j] = min(dp1[j], dp1[j-v]+w)
    dp1 = deepcopy(dp2)
for i in range(MV-1, -1, -1):
    if dp1[i] <= W:
        print(i)
        break


Fixed submission:
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from itertools import *
from copy import *

N, W = map(int, input().split())
MV = N * 10**3 + 1
INF = float('inf')
dp = [[INF] * MV for i in range(N+1)]
dp[0][0] = 0
for i in range(N):
    w, v = map(int, input().split())
    for j in range(MV):
        if v <= j:
            dp[i+1][j] = min(dp[i][j], dp[i][j-v]+w)
        else:
            dp[i+1][j] = dp[i][j]
dp = dp[N]
for i in range(0, MV)[::-1]:
    if dp[i] <= W:
        print(i)
        break
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
dp = [[0] * N for i in range(N)]
for i in range(N):
    dp[i][i] = a[i]
for i in range(N-1)[::-1]:
    for j in range(i+1, N):
        dp[i][j] = max(a[i]-dp[i+1][j], a[j]-dp[i][j-1])
print(dp[0][N-1])

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
dp = [[0] * N for i in range(N)]
for i in range(N):
    dp[i][i] = a[i]
for i in range(N-1)[::-1]:
    for j in range(i+1, N):
        dp[i][j] = max(a[i]-dp[i+1][j], a[j]-dp[i][j-1])
print(dp[0][N-1])

Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from collections import *
import math
from bisect import *
import functools

N = int(input())
a = list(map(int, input().split()))
@functools.lru_cache(maxsize=None)
def rec(l, r):
    if r < l:
        return 0
    return max(a[l]-rec(l+1, r), a[r]-rec(l, r-1))
print(rec(0, N-1))


Fixed submission:
N = int(input())
a = list(map(int, input().split()))
dp = [[0] * N for i in range(N)]
for i in range(N):
    dp[i][i] = a[i]
for i in range(N-1)[::-1]:
    for j in range(i+1, N):
        dp[i][j] = max(a[i]-dp[i+1][j], a[j]-dp[i][j-1])
print(dp[0][N-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())
a = [int(x) for x in input().split()]
mod = 10**9+7
dp = [[0] * (K+1) for i in range(N+1)]
for i in range(K+1):
    dp[0][i] = 1
for i in range(1, N+1):
    for j in range(K+1):
        tmp = 0 if j-a[i-1]-1 < 0 else dp[i-1][j-a[i-1]-1]
        dp[i][j] += dp[i-1][j]-tmp
        dp[i][j] %= mod
    if i != N:
        for j in range(K):
            dp[i][j+1] = (dp[i][j+1]+dp[i][j])%mod
print(dp[N][K])

Fixed submission:
N, K = map(int, input().split())
a = [int(x) for x in input().split()]
mod = 10**9+7
dp = [[0] * (K+1) for i in range(N+1)]
for i in range(K+1):
    dp[0][i] = 1
for i in range(1, N+1):
    for j in range(K+1):
        tmp = 0 if j-a[i-1]-1 < 0 else dp[i-1][j-a[i-1]-1]
        dp[i][j] += dp[i-1][j]-tmp
        dp[i][j] %= mod
    if i != N:
        for j in range(K):
            dp[i][j+1] = (dp[i][j+1]+dp[i][j])%mod
print(dp[N][K])
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from collections import *
import math
from bisect import *
import functools
INF = float('inf')
mod = 10**9+7

def mat(A, B):
    n = len(A)
    C = [[0] * n for i in range(n)]
    for i in range(n):
        for j in range(n):
            for k in range(n):
                C[i][j] += A[i][k]*B[k][j]
            C[i][j] %= mod
    return C

N, K = map(int, input().split())
a = [[int(x) for x in input().split()] for i in range(N)]
b = [[0] * N for i in range(N)]
for i in range(N):
    b[i][i] = 1
while K > 0:
    if K % 2:
        b = mat(b, a)
    a = mat(a, a)
    K //= 2
print(sum([sum(_b) for _b in b])%mod)


Fixed submission:
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from collections import *
import math
from bisect import *
import functools
INF = float('inf')
mod = 10**9+7

def mat(A, B):
    n = len(A)
    C = [[0] * n for i in range(n)]
    for i in range(n):
        for j in range(n):
            for k in range(n):
                C[i][j] += A[i][k]*B[k][j]
            C[i][j] %= mod
    return C

N, K = map(int, input().split())
a = [[int(x) for x in input().split()] for i in range(N)]
b = [[0] * N for i in range(N)]
for i in range(N):
    b[i][i] = 1
while K > 0:
    if K % 2:
        b = mat(b, a)
    a = mat(a, a)
    K //= 2
print(sum([sum(_b) for _b in b])%mod)
Buggy python submission (verdict: Runtime Error):
K = input()
D = int(input())
N = len(K)
dp = [[0] * D for i in range(N)]
for i in range(int(K[0])):
    dp[0][i%D] += 1
tight = int(K[0])%D
for i in range(1, N):
    for j in range(D):
        for k in range(10):
            dp[i][j] += dp[i-1][(j-k)%D]
            dp[i][j] %= mod
    for k in range(int(K[i])):
        dp[i][(tight+k)%D] += 1
    tight = (tight+int(K[i]))%D
print((dp[N-1][0]+(tight==0)-1)%mod)

Fixed submission:
mod = 10**9+7
K = input()
D = int(input())
N = len(K)
dp = [[0] * D for i in range(N)]
for i in range(int(K[0])):
    dp[0][i%D] += 1
tight = int(K[0])%D
for i in range(1, N):
    for j in range(D):
        for k in range(10):
            dp[i][j] += dp[i-1][(j-k)%D]
            dp[i][j] %= mod
    for k in range(int(K[i])):
        dp[i][(tight+k)%D] += 1
    tight = (tight+int(K[i]))%D
print((dp[N-1][0]+(tight==0)-1)%mod)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
sys.setrecursionlimit(10000000)
def input():
    return sys.stdin.readline()[:-1]
from collections import *
import math
from bisect import *
import functools
INF = float('inf')
mod = 10**9+7

popcount = lambda s: bin(s).count('1')
N = int(input())
a = [[int(x) for x in input().split()] for i in range(N)]
dp = [0] * (1<<N)
for S in range(1<<N):
    b = bin(S)[::-1]
    for i in range(len(b))[::-1]:
        if b[i] == '1':
            break
    s = S&(S^(1<<i))
    T = s
    while T > 0:
        tmp = 0
        for j in range(i):
            if (T>>j)&1:
                tmp += a[i][j]
        dp[S] = max(dp[S], dp[s^T]+dp[T]+tmp)
        T = (T-1)&s
print(dp[(1<<N)-1])

Fixed submission:
import sys
def input():
    return sys.stdin.readline()[:-1]

N = int(input())
a = [[int(x) for x in input().split()] for i in range(N)]
dp = [0] * (1<<N)
for S in range(1<<N):
    tmp = 0
    for i in range(N-1):
        for j in range(i+1, N):
            if (S>>i)&1 and (S>>j)&1:
                tmp += a[i][j]
    dp[S] = max(0, tmp)
    T = (S-1)&S
    while T > 0:
        dp[S] = max(dp[S], dp[T]+dp[S^T])
        T = (T-1)&S
print(dp[(1<<N)-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans, min = 0, 1e9
for i in range(N):
  if abs((T-H[i]*0.006) - A) < m:
    ans = i
    m = abs((T-H[i]*0.006) - A)
print(i)

Fixed submission:
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans, m = 0, 1e9
for i in range(N):
  if abs((T-H[i]*0.006) - A) < m:
    ans = i+1
    m = abs((T-H[i]*0.006) - A)
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
if N & 1:
    ans1 = 2*sum(A[N//2:])-A[N//2]-A[N//2+1]-2*sum(A[:N//2])
    ans2 = 2*sum(A[N//2+1:])-2*sum(A[:N//2+1])+A[N//2]+A[N//2-1]
else:
    if N == 2:
        ans1 = ans2 = abs(A[0]-A[1])
    else:
        ans1 = 2*sum(A[N//2:])-A[N//2]-2*sum(A[:N//2])+A[N//2-1]
        ans2 = 2*sum(A[N//2+1:])-A[N//2+1]-2*sum(A[:N//2+1])+A[N//2]
print(max(ans1, ans2))

Fixed submission:
S = input()
if len(S) == 2:
    print(S)
else:
    print(S[::-1])
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
if N & 1:
    ans1 = 2*sum(A[N//2:])-A[N//2]-A[N//2+1]-2*sum(A[:N//2])
    ans2 = 2*sum(A[N//2+1:])-2*sum(A[:N//2+1])+A[N//2]+A[N//2-1]
else:
    ans1 = 2*sum(A[N//2:])-A[N//2]-2*sum(A[:N//2])+A[N//2-1]
    ans2 = 2*sum(A[N//2+1:])-A[N//2+1]-2*sum(A[:N//2+1])+A[N//2]
print(max(ans1, ans2))

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
if N & 1:
    ans1 = 2*sum(A[N//2:])-A[N//2]-A[N//2+1]-2*sum(A[:N//2])
    ans2 = 2*sum(A[N//2+1:])-2*sum(A[:N//2+1])+A[N//2]+A[N//2-1]
else:
    if N == 2:
        ans1 = ans2 = abs(A[0]-A[1])
    else:
        ans1 = 2*sum(A[N//2:])-A[N//2]-2*sum(A[:N//2])+A[N//2-1]
        ans2 = 2*sum(A[N//2+1:])-A[N//2+1]-2*sum(A[:N//2+1])+A[N//2]
print(max(ans1, ans2))

Buggy python submission (verdict: Runtime Error):
from collections import deque
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
if N % 4 == 1:
    print(2*sum(A[N//2+1:])-2*sum(A[:N//2+1])+A[N//2-1]+A[N//2])
elif N % 4 == 3:
    print(2*sum(A[N//2:])-2*sum(A[:N//2])-A[N//2]-A[N//2+1])
else:
    print(2*sum(A[N//2:])-2*sum(A[:N//2])-A[N//2+1]+A[N//2])

Fixed submission:
N = int(input())
A = [int(input()) for i in range(N)]
A.sort()
if N & 1:
    ans1 = 2*sum(A[N//2:])-A[N//2]-A[N//2+1]-2*sum(A[:N//2])
    ans2 = 2*sum(A[N//2+1:])-2*sum(A[:N//2+1])+A[N//2]+A[N//2-1]
else:
    if N == 2:
        ans1 = ans2 = abs(A[0]-A[1])
    else:
        ans1 = 2*sum(A[N//2:])-A[N//2]-2*sum(A[:N//2])+A[N//2-1]
        ans2 = 2*sum(A[N//2+1:])-A[N//2+1]-2*sum(A[:N//2+1])+A[N//2]
print(max(ans1, ans2))
Buggy python submission (verdict: Runtime Error):
def soinsuubunkai(n):
    i = 2
    list = [1]
    while i**2 <= n:
        if n%i == 0:
            list.append(i)
            if i != n//i:
                list.append(n//i)
        i += 1
    list.append(n)
    return list
n, m = map(int, input().split())
l = soinsuubunkai(m)
r = len(l)
for i in range(r):
    if m//l[r-i-1] >= n:
        print(l[r-i-1])
        quit()



Fixed submission:
n = int(input())
if n == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a+b)
Buggy python submission (verdict: Runtime Error):
y = int(input())
for i in range(1, 10):
  x = i + i * 10 + i * 100
  if x >= y:
    print(x)
  	break
    

Fixed submission:
y = int(input())
for i in range(1, 10):
  x = i + i * 10 + i * 100
  if x >= y:
    print(x)
    break
Buggy python submission (verdict: Runtime Error):
in = list(map(int, input().split()))
print(max(in)*10+sum(in)-max(in))

Fixed submission:
lst = list(map(int, input().split()))
print(max(lst)*10+sum(lst)-max(lst))
Buggy python submission (verdict: Runtime Error):
N, M. X, Y = map(int, input().split())
x_lst = list(map(int, input().split()))
y_lst = list(map(int, input().split()))
if (X < Y and max(x_lst) < min(y_lst) and X < min(y_lst) and max(x_lst) < Y):
  print("No War")
else:
  print("War")

Fixed submission:
N, M, X, Y = map(int, input().split())
x_lst = list(map(int, input().split()))
y_lst = list(map(int, input().split()))
if (X < Y and max(x_lst) < min(y_lst) and X < min(y_lst) and max(x_lst) < Y):
  print("No War")
else:
  print("War")

Buggy python submission (verdict: Runtime Error):
N, M. X, Y = map(int, input().split())
x_lst = list(map(int, input().split()))
y_lst = list(map(int, input().split()))
if (X < Y and max(x_lst) < min(y_lst) and X < min(y_lst) and max(x_lst) < Y):
  print("No War")
else:
  print("War")

Fixed submission:
N, M, X, Y = map(int, input().split())
x_lst = list(map(int, input().split()))
y_lst = list(map(int, input().split()))
if (X < Y and max(x_lst) < min(y_lst) and X < min(y_lst) and max(x_lst) < Y):
  print("No War")
else:
  print("War")
Buggy python submission (verdict: Runtime Error):
s = input()
t = input()
dic = defaultdict(set)
for x, y in zip(s, t):
  if x != y:
    dic[x].add(y)
    dic[y].add(x)
f = True
for key in dic:
  if len(dic[key]) > 1:
    print("No")
  	f = False
if f:
  print("Yes")
    

Fixed submission:
from collections import defaultdict
s = input()
t = input()
dic = defaultdict(lambda : None)
revdic = defaultdict(lambda : None)
for x, y in zip(s, t):
    if dic[x] == None and revdic[y] == None:
        dic[x] = y
        revdic[y] = x
    elif dic[x] != y or revdic[y] != x:
        print('No')
        quit()
print('Yes')
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict
dic = defaultdict(str)
n = int(input())
lst = [input() for _ in range(n)]
last = lst[0]
flag = True
for i in range(1, n):
  if lst[i][0] != last[-1]:
  	flag = False
    break
  dic[lst[i]] += 1
  if dic[lst[i]] > 1
  	flag = False
    break
if flag:
  print("Yes")
else:
  print("No")
  

Fixed submission:
from collections import defaultdict
dic = defaultdict(int)
n = int(input())
lst = [input() for _ in range(n)]
last = lst[0]
dic[last] = 1
flag = True
for i in range(1, n):
  if lst[i][0] != last[-1]:
    flag = False
    break
  dic[lst[i]] += 1
  if dic[lst[i]] > 1:
    flag = False
    break
  last = lst[i]
if flag:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
H, W = map(int, input().split())
f = [input() for _ in range(H)]
while True:
  flag = False
  for y in range(H):
    if '#' not in f[y]:
      del f[y]
      H -= 1
      flag = True
      break
  for x in range(W):
    for y in range(H):
      if f[y][x] == '#':
        break
    for y in range(H):
      del f[x][y]
    flag = True
    break
  if not flag:
    break

for i in range(H):
  print(f[i])
	

Fixed submission:
H, W = map(int, input().split())
f = [list(input()) for _ in range(H)]
Y, X = [False for _ in range(H)], [False for _ in range(W)]
for y in range(H):
    for x in range(W):
        Y[y] |= f[y][x] == '#'
        X[x] |= f[y][x] == '#'
for y in range(H):
    flag = False
    for x in range(W):
        if Y[y] and X[x]:
            print(f[y][x], end = "")
            flag = True
    if flag:
        print()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
N = int(input())
ans = 0
for i in range(N + 1):
  if i % 2 == 0:
    continue
  t, j, dic, r = i, 2, defaultdict(int), 1
  while True:
    while t % j == 0:
      t /= j
      dic[j] += 1
    if j * j > i:
      break
  if t > 1:
    dic[t] += 1
  for key in dic:
    r *= dic[key] + 1
  if r == 8:
    ans += 1
print(ans)

Fixed submission:
from collections import defaultdict
N = int(input())
ans = 0
for i in range(N + 1):
  if i % 2 == 0:
    continue
  t, j, dic, r = i, 2, defaultdict(int), 1
  while True:
    while t % j == 0:
      t /= j
      dic[j] += 1
    j += 1
    if j * j > i:
      break
  if t > 1:
    dic[t] += 1
  for key in dic:
    r *= dic[key] + 1
  if r == 8:
    ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools as it
D, G = map(int, input().split())
P, C = [], []
for _ in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)
A = it.permutations([i for i in range(D)])
ans = 10**9
for a in A:
    S, i, sub_ans = 0, 0, 0
    while 1:
        if S + (a[i] + 1) * 100 * P[a[i]] < G:
            S += (a[i] + 1) * 100 * P[a[i]]
            sub_ans += P[a[i]]
            S += C[a[i]]
        else:
            x = (G - S) // ((a[i] + 1) * 100)
            if S + (a[i] + 1) * x < G:
                x += 1
            sub_ans += x
            S += (a[i] + 1) * x
        S += C[a[i]]
        if S >= G:
            if sub_ans < ans:
                ans = sub_ans
            break
        i += 1
print(ans)


Fixed submission:
import itertools as it
D, G = map(int, input().split())
P, C = [], []
for _ in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)
A = it.permutations([i for i in range(D)])
ans = 10**9
for a in A:
    S, i, sub_ans = 0, 0, 0
    while 1:
        if S + (a[i] + 1) * 100 * P[a[i]] < G:
            S += (a[i] + 1) * 100 * P[a[i]]
            sub_ans += P[a[i]]
        else:
            x = (G - S) // ((a[i] + 1) * 100)
            if S + (a[i] + 1) * 100 * x < G:
                x += 1
            sub_ans += x
            S += (a[i] + 1) * 100 * x
        S += C[a[i]]
        if S >= G:
            if sub_ans < ans:
                ans = sub_ans
            break
        i += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools as it
D, G = map(int, input().split())
P, C = [], []
for _ in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)
A = list(it.permutations([i for i in range(D)]))
ans = 10**9
for a in A:
    S, i, sub_ans = 0, 0, 0
    while 1:
        if S + (a[i] + 1) * 100 * P[a[i]] < G:
            S += (a[i] + 1) * 100 * P[a[i]]
            sub_ans += P[a[i]]
            S += C[a[i]]
        else:
            j = 0
            while S < G and j < P[a[i]]:
                S += (a[i] + 1) * 100
                sub_ans += 1
            if j == P[a[i]]:
                S += C[a[i]]
        if S >= G:
            if sub_ans < ans:
                ans = sub_ans
            break
        i += 1
print(ans)


Fixed submission:
import itertools as it
D, G = map(int, input().split())
P, C = [], []
for _ in range(D):
    p, c = map(int, input().split())
    P.append(p)
    C.append(c)
A = it.permutations([i for i in range(D)])
ans = 10**9
for a in A:
    S, i, sub_ans = 0, 0, 0
    while 1:
        if S + (a[i] + 1) * 100 * P[a[i]] < G:
            S += (a[i] + 1) * 100 * P[a[i]]
            sub_ans += P[a[i]]
        else:
            x = (G - S) // ((a[i] + 1) * 100)
            if S + (a[i] + 1) * 100 * x < G:
                x += 1
            sub_ans += x
            S += (a[i] + 1) * 100 * x
        S += C[a[i]]
        if S >= G:
            if sub_ans < ans:
                ans = sub_ans
            break
        i += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
a_b = sorted([list(map(int, input().split())) + [0] for _ in range(M)])
ans = 0
for i in range(M):
    k = M - i - 1
    if a_b[k][2]:
        continue
    a_b[k][2], c = 1, a_b[k][0]
    for j in range(k):
        if a_b[j][0] <= c < a_b[j][1]:
            a_b[j][2] = 1
    ans += 1
print(ans)

Fixed submission:
def main():
    N, M = map(int, input().split())
    a_b = sorted([list(map(int, input().split())) for _ in range(M)])
    used = [0] * M
    ans = 0
    for i in range(M):
        k = M - i - 1
        if used[k]:
            continue
        used[k], c = 1, a_b[k][0]
        for j in range(k):
            if a_b[j][0] <= c < a_b[j][1]:
                used[j] = 1
        ans += 1
    print(ans)

if __name__ == "__main__":
    main()
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
print((b − a) * (b − a + 1) // 2 − b)

Fixed submission:
a, b = map(int, input().split())
print((b-a)*(b-a+1)//2-b)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
f, g, ans = [0], [0], 0
for i in range(1, N + 1):
    f.append(f[i-1] ^ A[i-1])
    g.append(g[i-1] + A[i-1])
for r in range(1, N + 1):
    for l in range(1, r + 1):
        ans += f[r] ^ f[l-1] == g[r] - g[l-1]
print(ans)


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
l, r, fl, fr, gl, gr, ans= 0, 0, 0, A[0], 0, A[0], 0
while l < N:
    while r+1 < N and fr-fl+A[r+1] == gr^gl^A[r+1]:
        r += 1
        fr += A[r]
        gr ^= A[r]
    ans += r-l+1
    fl += A[l]
    gl ^= A[l]
    l += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
x=int(input())
l=[]
for i in range(2,x+1):
  t=i*i
  while t <=x:
    l.append(t)
    t*=i
print(max(l))

Fixed submission:
x=int(input())
l=[1]
for i in range(2,x+1):
  t=i*i
  while t <=x:
    l.append(t)
    t*=i
print(max(l))
Buggy python submission (verdict: Runtime Error):
import bisect as bs
l=int(input())
lst=sorted(list(map(int,input().split())))
n=lst[l-1]
lst[l-1]=float("inf")
m=bs.bisect_left(lst,n/2)
if n/2 - lst[m] <= lst[m+1] -n/2:
  print(n,lst[m])
else:
  print(n,lst[m+1])


Fixed submission:
import bisect as bs
l=int(input())
lst=sorted(list(map(int,input().split())))
n=lst[l-1]
lst[l-1]=float("inf")
m=bs.bisect_right(lst,n/2)
if n/2 - lst[m-1] <= lst[m] -n/2:
  print(n,lst[m-1])
else:
  print(n,lst[m])

Buggy python submission (verdict: Runtime Error):
import bisect as bs
l=int(input())
lst=sorted(list(map(int,input().split())))
n=lst[l-1]
m=bs.bisect_left(lst,n/2)
print(m)

if n/2 - lst[m] <= lst[m+1] -n/2:
  print(n,lst[m])
else:
  print(n,lst[m+1])


Fixed submission:
import bisect as bs
l=int(input())
lst=sorted(list(map(int,input().split())))
n=lst[l-1]
lst[l-1]=float("inf")
m=bs.bisect_right(lst,n/2)
if n/2 - lst[m-1] <= lst[m] -n/2:
  print(n,lst[m-1])
else:
  print(n,lst[m])

Buggy python submission (verdict: Runtime Error):
import bisect as bs
l=int(input())
lst=sorted(list(map(int,input().split())))
n=lst[l-1]
m=bs.bisect_left(lst,n)
if n/2 - lst[m] <= lst[m+1] -n/2:
  print(n,lst[m])
else:
  print(n,lst[m+1])



Fixed submission:
import bisect as bs
l=int(input())
lst=sorted(list(map(int,input().split())))
n=lst[l-1]
lst[l-1]=float("inf")
m=bs.bisect_right(lst,n/2)
if n/2 - lst[m-1] <= lst[m] -n/2:
  print(n,lst[m-1])
else:
  print(n,lst[m])
Buggy python submission (verdict: Runtime Error):
n = int(input())
red, brue = [], []
for _ in range(n):
  x, y = map(int, input().split())
  red.append([x, y])
for _ in range(n):
  x, y = map(int, input().split())
  brue.append([x, y])
red, brue = sorted(red), sorted(brue)
used = [Flase for _ in range(n)]
ans = 0
for i in range(n):
  x, y = red[i][0], red[i][1]
  for j in range(n):
    if used[j] or x >= brue[j][0] or y >= brue[j][1]:
      continue
    used[j] = True
    ans += 1
print(ans)

Fixed submission:
def bipertite_matching(N, edges):
    def dfs(v):
        used[v] = True
        for u in edges[v]:
            w = match[u]
            if w < 0 or (used[w] == False and dfs(w)):
                match[v] = u
                match[u] = v
                return True
        return False
    match = [-1 for _ in range(N)]
    ret = 0
    for v in range(N):
        if match[v] < 0:
            used = [False for _ in range(N)]
            if dfs(v):
                ret += 1
    return ret

N = int(input())
a, b = [None] * N, [None] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())
c, d = [None] * N, [None] * N
for i in range(N):
    c[i], d[i] = map(int, input().split())
es = [[] for i in range(2 * N)]
for i in range(N):
    for j in range(N):
        if a[i] < c[j] and b[i] < d[j]:
            es[i].append(N+j)
            es[N+j].append(i)
print(bipertite_matching(2*N, es))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
cnt = 0
for i in range(A, B + 1):
  x = str(i)
  j, k = 0, len(x) - 1
  while j < k:
    if x[j] != x[k]:
      break
   	j += 1
    k -= 1
  if k <= j:
    cnt += 1
print(cnt)

Fixed submission:
A, B = map(int, input().split())
cnt = 0
for i in range(A, B + 1):
  x = str(i)
  j, k = 0, len(x) - 1
  while j < k:
    if x[j] != x[k]:
      break
    j += 1
    k -= 1
  if k <= j:
    cnt += 1
print(cnt)
Buggy python submission (verdict: Runtime Error):
N = input()
l = len(N)
x = int(N[0])*int(pow(10, l-1))+int('9'*(l-1))
if int(N) < x:
    x -= 1
ans = 0
while x > 0:
    ans += x%10
    x //= 10
print(ans)

Fixed submission:
import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *
from copy import *

N = input()
l = len(N)
if l == 1:
    print(N)
    exit()
x = int(N[0])*int(pow(10, l-1))+int('9'*(l-1))
if int(N) < x:
    x -= 1
ans = 0
while x > 0:
    ans += x%10
    x //= 10
print(ans)