Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**5)

H, W = map(int, input().split())
S = [input() for _ in range(H)]
check = [[0]*W for _ in range(H)]
di = [-1, 0, 1, 0]
dj = [ 0,-1, 0, 1]

black, white = 0, 0

def dfs(i, j):
    global check, black, white
    if check[i][j]:
        return
    else:
        check[i][j] = 1
    if S[i][j] == '#':
        black += 1
    else:
        white += 1
    for dir in range(4):
        ni = i + di[dir]
        nj = j + dj[dir]
        if ni < 0 or ni >= H or nj < 0 or nj >= W: continue
        if S[i][j] == S[ni][nj]: continue
        dfs(ni, nj)

ans = 0
for i in range(H):
    for j in range(W):
        black, white = 0, 0
        dfs(i, j)
        ans += black * white

print(ans)


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

H, W = map(int, input().split())
S = [input() for _ in range(H)]
check = [[0]*W for _ in range(H)]
di = [-1, 0, 1, 0]
dj = [ 0,-1, 0, 1]
black, white = 0, 0

def dfs(i, j):
    global check, black, white
    if check[i][j]:
        return
    else:
        check[i][j] = 1
    if S[i][j] == '#':
        black += 1
    else:
        white += 1
    for dir in range(4):
        ni = i + di[dir]
        nj = j + dj[dir]
        if ni < 0 or ni >= H or nj < 0 or nj >= W: continue
        if S[i][j] == S[ni][nj]: continue
        dfs(ni, nj)
    return

ans = 0
for i in range(H):
    for j in range(W):
        black, white = 0, 0
        dfs(i, j)
        ans += black * white

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

dp = [0] * N
for i in range(1, N):
    dp[i] = dp[i-1] + abs(h[i]-h[i-1])
    for j in range(2, K+1):
        if i-j < 0:
            break
        dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]))

# print(dp)
print(dp[-1])


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

dp = [0] * N
for i in range(1, N):
    dp[i] = dp[i-1] + abs(h[i]-h[i-1])
    for j in range(2, K+1):
        if i-j < 0:
            break
        dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]))

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

for i in range(N):
    w, v = map(int, input().split())
    for j in range(W-w, -1, -1):
        if dp[j] == -1:
            continue
        else:
            dp[j+w] = max(dp[j+w], dp[j] + v)

print(max(dp))


Fixed submission:
N, W = map(int, input().split())
dp = [-1] * (W+1)
dp[0] = 0

for i in range(N):
    w, v = map(int, input().split())
    for j in range(W-w, -1, -1):
        if dp[j] == -1:
            continue
        else:
            dp[j+w] = max(dp[j+w], dp[j] + v)

print(max(dp))

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
dp = [-1] * (W+1)
dp[0] = 0

for i in range(N):
    w, v = map(int, input().split())
    for j in range(W-w, -1, -1):
        if dp[j] >= 0:
            dp[j+w] = max(dp[j+w], dp[j] + v)

ans = max(dp)
print(ans)


Fixed submission:
N, W = map(int, input().split())
dp = [-1] * (W+1)
dp[0] = 0

for i in range(N):
    w, v = map(int, input().split())
    for j in range(W-w, -1, -1):
        if dp[j] == -1:
            continue
        else:
            dp[j+w] = max(dp[j+w], dp[j] + v)

print(max(dp))

Buggy python submission (verdict: Time Limit Exceeded):
N, W = map(int, input().split())
dp = [-1] * (W+1)
dp[0] = 0

for i in range(N):
    nextDP = dp.copy()
    w, v = map(int, input().split())
    for j in range(W+1-w):
        if dp[j] >= 0:
            nextDP[j+w] = max(dp[j+w], dp[j] + v)
    dp = nextDP.copy()

ans = max(dp)
print(ans)


Fixed submission:
N, W = map(int, input().split())
dp = [-1] * (W+1)
dp[0] = 0

for i in range(N):
    w, v = map(int, input().split())
    for j in range(W-w, -1, -1):
        if dp[j] == -1:
            continue
        else:
            dp[j+w] = max(dp[j+w], dp[j] + v)

print(max(dp))
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
t = input()
n = len(s)
m = len(t)
dp = [[0 for _ in range(len(t)+1)] for _ in range(len(s)+1)]

for i in range(n):
    for j in range(m):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

ans = ''
i = n
j = m
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:
        ans += s[i-1]
        i -= 1
        j -= 1

print(ans[::-1])


Fixed submission:
s = input()
t = input()
n = len(s)
m = len(t)
dp = [[0 for _ in range(len(t)+1)] for _ in range(len(s)+1)]

for i in range(n):
    for j in range(m):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

ans = ''
i = n
j = m
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:
        ans += s[i-1]
        i -= 1
        j -= 1

print(ans[::-1])

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

dp = [['' for _ in range(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]:
            dp[i+1][j+1] = dp[i][j] + s[i]
        elif len(dp[i][j+1]) > len(dp[i+1][j]):
            dp[i+1][j+1] = dp[i][j+1]
        else:
            dp[i+1][j+1] = dp[i+1][j]
print(dp[len(s)][len(t)])


Fixed submission:
s = input()
t = input()
n = len(s)
m = len(t)
dp = [[0 for _ in range(len(t)+1)] for _ in range(len(s)+1)]

for i in range(n):
    for j in range(m):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

ans = ''
i = n
j = m
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:
        ans += s[i-1]
        i -= 1
        j -= 1

print(ans[::-1])

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

dp = [['' for _ in range(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]:
            dp[i+1][j+1] = dp[i][j] + s[i]
        elif len(dp[i][j+1]) > len(dp[i+1][j]):
            dp[i+1][j+1] = dp[i][j+1]
        else:
            dp[i+1][j+1] = dp[i+1][j]
print(dp[len(s)][len(t)])


Fixed submission:
s = input()
t = input()
n = len(s)
m = len(t)
dp = [[0 for _ in range(len(t)+1)] for _ in range(len(s)+1)]

for i in range(n):
    for j in range(m):
        if s[i] == t[j]:
            dp[i+1][j+1] = dp[i][j] + 1
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

ans = ''
i = n
j = m
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:
        ans += s[i-1]
        i -= 1
        j -= 1

print(ans[::-1])
Buggy python submission (verdict: Time Limit Exceeded):
N, P = map(int, input().split())

from collections import defaultdict
d = defaultdict(int)
i = 2
while P > 1:
    if P%i==0:
        P //= i
        d[i] += 1
    else:
        i += 1

ans = 1
for k, v in d.items():
    # print(k, v)
    z = v // N
    ans *= k**z
print(ans)


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

from collections import defaultdict
d = defaultdict(int)
i = 2
while P >= i*i:
    if P%i==0:
        P //= i
        d[i] += 1
    elif i == 2:
        i += 1
    else:
        i += 2
if P != 1:
    d[P] += 1

ans = 1
for k, v in d.items():
    # print(k, v)
    z = v // N
    ans *= k**z
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
cnt = 0
for i in range(len(S)):
    if S[i] == 'W':
        cnt += S[:i].count('B')
print(cnt)

Fixed submission:
S = input()
cnt = 0
ans = 0
left = 0
for i in range(len(S)):
    if S[i] == 'W':
        cnt += S[left:i].count('B')
        ans += cnt
        left = i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
slist = list(s)
l = len(s)
n = 0
j = 1

while j != 0:
  j = 0
  start = 0
  end = l-1
  for i in range(start, end):
    if slist[i:i+2] == ['B','W']:
      slist[i:i+2] = ['W','B']
      n += 1
      j = 1
      end = i
    start += 1

print(n)

Fixed submission:
S = input()
cnt = 0
ans = 0
left = 0
for i in range(len(S)):
    if S[i] == 'W':
        cnt += S[left:i].count('B')
        ans += cnt
        left = i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
slist = list(s)
l = len(s)
n = 0
j = 1

while j != 0:
  j = 0
  start = 0
  end = l-1
  for i in range(start, end):
    if slist[i:i+2] == ['B','W']:
      slist[i:i+2] = ['W','B']
      n += 1
      j = 1
    start += 1
    end -= 1

print(n)

Fixed submission:
S = input()
cnt = 0
ans = 0
left = 0
for i in range(len(S)):
    if S[i] == 'W':
        cnt += S[left:i].count('B')
        ans += cnt
        left = i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
slist = list(s)
l = len(s)
n = 0
j = 1

while j > 0:
  j = 0
  for i in range(l-1):
    if slist[i:i+2] == ['B','W']:
      slist[i:i+2] = ['W','B']
      n += 1
      j += 1

print(n)

Fixed submission:
S = input()
cnt = 0
ans = 0
left = 0
for i in range(len(S)):
    if S[i] == 'W':
        cnt += S[left:i].count('B')
        ans += cnt
        left = i
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
slist = list(s)
l = len(s)
n = 0
j = 1

while j > 0:
  j = 0
  for i in range(l-1):
    if slist[i] == 'B' and slist[i+1] == 'W':
      slist[i] = 'W'
      slist[i+1] = 'B'
      n += 1
      j += 1

print(n)

Fixed submission:
S = input()
cnt = 0
ans = 0
left = 0
for i in range(len(S)):
    if S[i] == 'W':
        cnt += S[left:i].count('B')
        ans += cnt
        left = i
print(ans)
Buggy python submission (verdict: Runtime Error):
if X == 3 or X == 5 or X == 7:
  print('YES')
else:
  print('NO')
  


Fixed submission:
X = int(input())

if X==3 or X==5 or X==7:
  print("YES")
else:
  print("NO")

Buggy python submission (verdict: Runtime Error):
if X = 3 or 5 or 7:
  print('YES')
else:
  print('NO')
  

Fixed submission:
X = int(input())

if X==3 or X==5 or X==7:
  print("YES")
else:
  print("NO")
Buggy python submission (verdict: Runtime Error):
s = string(input())
m = 753
a = 999

for i in range(len(s)-2):
  #print(s[i:i+3])
  if abs(m - int(s[i:i+3])) < a:
    a = abs(m - int(s[i:i+3]))
print(a)

Fixed submission:
s = input()
m = 753
a = 999

for i in range(len(s)-2):
  #print(s[i:i+3])
  if abs(m - int(s[i:i+3])) < a:
    a = abs(m - int(s[i:i+3]))
print(a)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = []
for i in range(N):
    A.append(int(input()))

A.sort()
if N % 2 == 0:
    print((sum(A[N//2:]) - sum(A[:N//2]))*2 - (A[N//2+1] - A[N//2]))
else:
    print((sum(A[N//2+1:]) - sum(A[:N//2]))*2 - min(A[N//2+1] - A[N//2], A[N//2] - A[N//2-1]))

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

A.sort()

if N % 2 == 1:
    w = -2*sum(A[:N//2]) +A[N//2] +A[N//2 + 1] + 2*sum(A[N//2 + 2:])
    m = -2*sum(A[:N//2-1]) - A[N//2 - 1] - A[N//2] + 2*sum(A[N//2+1:])
    print(max(w, m))
else:
    print(-2*sum(A[:N//2-1]) - A[N//2-1] + A[N//2] + 2*sum(A[N//2+1:]))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()
if N % 2 == 0:
    print((sum(A[N//2:]) - sum(A[:N//2]))*2 - (A[N//2+1] - A[N//2]))
else:
    print((sum(A[N//2+1:]) - sum(A[:N//2]))*2 - min(A[N//2+1] - A[N//2], A[N//2] - A[N//2-1]))

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

A.sort()

if N % 2 == 1:
    w = -2*sum(A[:N//2]) +A[N//2] +A[N//2 + 1] + 2*sum(A[N//2 + 2:])
    m = -2*sum(A[:N//2-1]) - A[N//2 - 1] - A[N//2] + 2*sum(A[N//2+1:])
    print(max(w, m))
else:
    print(-2*sum(A[:N//2-1]) - A[N//2-1] + A[N//2] + 2*sum(A[N//2+1:]))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()
if N % 2 == 0:
    print((sum(A[N//2]) - sum(A[:N//2]))*2 - (A[N//2+1] - A[N//2]))
else:
    print((sum(A[N//2+1]) - sum(A[:N//2]))*2 - min(A[N//2+1] - A[N//2], A[N//2] - A[N//2-1]))

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

A.sort()

if N % 2 == 1:
    w = -2*sum(A[:N//2]) +A[N//2] +A[N//2 + 1] + 2*sum(A[N//2 + 2:])
    m = -2*sum(A[:N//2-1]) - A[N//2 - 1] - A[N//2] + 2*sum(A[N//2+1:])
    print(max(w, m))
else:
    print(-2*sum(A[:N//2-1]) - A[N//2-1] + A[N//2] + 2*sum(A[N//2+1:]))

Buggy python submission (verdict: Runtime Error):
N = int(input())
A = [int(input()) for _ in range(N)]

A.sort()
if N % 2 == 0:
    print((sum(A[N//2:N]) - sum(A[:N//2]))*2 - (A[N//2+1] - A[N//2]))
else:
    print((sum(A[N//2+1:N]) - sum(A[:N//2]))*2 - min(A[N//2+1] - A[N//2], A[N//2] - A[N//2-1]))

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

A.sort()

if N % 2 == 1:
    w = -2*sum(A[:N//2]) +A[N//2] +A[N//2 + 1] + 2*sum(A[N//2 + 2:])
    m = -2*sum(A[:N//2-1]) - A[N//2 - 1] - A[N//2] + 2*sum(A[N//2+1:])
    print(max(w, m))
else:
    print(-2*sum(A[:N//2-1]) - A[N//2-1] + A[N//2] + 2*sum(A[N//2+1:]))
Buggy python submission (verdict: Time Limit Exceeded):
from fractions import gcd
N, M = map(int, input().split())
S = input()
T = input()

lcm = int(N * M / gcd(N, M))
nn = lcm // N
mm = lcm // M
flg = True

for i in range(lcm):
    if i % nn == 0 and i % mm == 0:
        if S[i//nn] == T[i//mm]:
            continue
        else:
            flg = False
if flg:
    print(lcm)
else:
    print(-1)


Fixed submission:
from fractions import gcd
N, M = map(int, input().split())
S = input()
T = input()

GCD = gcd(N, M)
LCM = int(N * M / GCD)
flg = True

for i in range(GCD):
    if S[i*N//GCD] == T[i*M//GCD]:
        continue
    else:
        flg = False
if flg:
    print(LCM)
else:
    print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())

i = M // N
while M % i:
    i -= 1

print(i)


Fixed submission:
import math
N, M = map(int, input().split())

div = M
for i in range(1, int(math.sqrt(M))+1):
    if M % i:
        continue
    i2 = M // i
    if i >= N:
        div = min(div, i)
    if i2 >= N:
        div = min(div, i2)

print(M//div)

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

i = N
while M % i:
    i += 1

print(M//i)


Fixed submission:
import math
N, M = map(int, input().split())

div = M
for i in range(1, int(math.sqrt(M))+1):
    if M % i:
        continue
    i2 = M // i
    if i >= N:
        div = min(div, i)
    if i2 >= N:
        div = min(div, i2)

print(M//div)
Buggy python submission (verdict: Runtime Error):
import numpy as np
even = np.zeros(100000, dtype=int)
odd = np.zeros(100000, dtype=int)

n = int(input())
v = list(map(int, input().split()))

for i in range(n):
    if i % 2 == 0:
        even[v[i]] += 1
    else:
        odd[v[i]] += 1

e1 = even.argmax()
e1n = even.max()
o1 = odd.argmax()
o1n = odd.max()

# print(e1, e1n, o1, o1n)
if e1 == o1:
    e2n = np.sort(even)[-2]
    o2n = np.sort(odd)[-2]
    # print(e2n, o2n)
    print(min(n - e1n - o2n, n - e2n - o1n))
else:
    print(n - e1n - o1n)


Fixed submission:
import numpy as np
even = np.zeros(100001, dtype=int)
odd = np.zeros(100001, dtype=int)

n = int(input())
v = list(map(int, input().split()))

for i in range(n):
    if i % 2 == 0:
        even[v[i]] += 1
    else:
        odd[v[i]] += 1

e1 = even.argmax()
e1n = even.max()
o1 = odd.argmax()
o1n = odd.max()

# print(e1, e1n, o1, o1n)
if e1 == o1:
    e2n = np.sort(even)[-2]
    o2n = np.sort(odd)[-2]
    # print(e2n, o2n)
    print(min(n - e1n - o2n, n - e2n - o1n))
else:
    print(n - e1n - o1n)
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split())

ans = 0
for a in range(1, N+1):
    cnt = 0
    tmp = K - a % K
    if tmp > N:
        continue
    for b in range(tmp, N+1, K):
        if K - b % K != tmp:
            continue
        for c in range(tmp, N+1, K):
            cnt += 1
    ans += cnt

print(ans)


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

ans = (N // K) ** 3

if K % 2 == 0:
    ans += ((N + K//2) //K) ** 3

print(ans)

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

ans = 0
for a in range(1, N+1):
    cnt = 0
    tmp = K - a % K
    if tmp > N:
        continue
    for b in range(tmp, N+1, K):
        if K - b % K != tmp:
            continue
        for c in range(tmp, N+1, K):
            cnt += 1
    ans += cnt

print(ans)


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

ans = (N // K) ** 3

if K % 2 == 0:
    ans += ((N + K//2) //K) ** 3

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

N, M, Q = map(int, input().split())
L, R = [], []
X = [[0]*N for _ in range(N)]
for i in range(M):
    l, r = map(int, input().split())
    L.append(l-1)
    R.append(r-1)
    X[l-1][r-1] += 1
C =[[0]*(N+1) for _ in range(N)]
for i in range(N):
    for j in range(N):
        C[i][j+1] = C[i][j] + X[i][j]

for i in range(Q):
    p, q = map(int, input().split())
    ans = 0
    for j in range(p-1, q):
        ans += C[j][q] - C[j][p-1]
    print(ans)


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

N, M, Q = map(int, input().split())
L, R = [], []
X = [[0]*N for _ in range(N)]
for i in range(M):
    l, r = map(int, input().split())
    L.append(l-1)
    R.append(r-1)
    X[l-1][r-1] += 1
C =[[0]*(N+1) for _ in range(N)]
for i in range(N):
    for j in range(N):
        C[i][j+1] = C[i][j] + X[i][j]

for i in range(Q):
    p, q = map(int, input().split())
    ans = 0
    for j in range(p-1, q):
        ans += C[j][q] - C[j][p-1]
    print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M, Q = map(int, input().split())
L, R = [], []
X = [[0]*N for _ in range(N)]
for i in range(M):
    l, r = map(int, input().split())
    L.append(l-1)
    R.append(r-1)
    X[l-1][r-1] += 1
C =[[0]*(N+1) for _ in range(N)]
for i in range(N):
    for j in range(N):
        C[i][j+1] = C[i][j] + X[i][j]

for i in range(Q):
    p, q = map(int, input().split())
    ans = 0
    for j in range(p-1, q):
        ans += C[j][q] - C[j][p-1]
    print(ans)


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

N, M, Q = map(int, input().split())
L, R = [], []
X = [[0]*N for _ in range(N)]
for i in range(M):
    l, r = map(int, input().split())
    L.append(l-1)
    R.append(r-1)
    X[l-1][r-1] += 1
C =[[0]*(N+1) for _ in range(N)]
for i in range(N):
    for j in range(N):
        C[i][j+1] = C[i][j] + X[i][j]

for i in range(Q):
    p, q = map(int, input().split())
    ans = 0
    for j in range(p-1, q):
        ans += C[j][q] - C[j][p-1]
    print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = [int(input()) for _ in range(n)]

q = [0] * n
for i in range(n):
    q[p[i]-1] = i
k = 1
for i in range(n-1):
    tmp = 1
    j = i
    while j < n-1 and q[j] < q[j+1]:
        j += 1
        tmp += 1
    k = max(k, tmp)
print(n-k)


Fixed submission:
n = int(input())
p = [int(input()) for _ in range(n)]

q = [0] * n
for i in range(n):
    q[p[i]-1] = i
mxk = 1
k = 1
for i in range(n-1):
    if q[i] < q[i+1]:
        k += 1
        if k > mxk:
            mxk = k
    else:
        k = 1
print(n-mxk)
Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
X = list(map(int, input().split()))

A = []
for i in range(N):
    bisect.insort(A, X[i])

leftB = A[N//2 - 1]
rightB = A[N//2]

for i in range(N):
    if X[i] <= leftB:
        print(rightB)
    else:
        print(leftB)


Fixed submission:
N = int(input())
X = list(map(int, input().split()))
A = sorted(X)

leftB = A[N//2 - 1]
rightB = A[N//2]

for i in range(N):
    if X[i] <= leftB:
        print(rightB)
    else:
        print(leftB)
Buggy python submission (verdict: Time Limit Exceeded):
Q = int(input())
l, r = [], []
for i in range(Q):
    _l, _r = map(int, input().split())
    l.append(_l)
    r.append(_r)
max_r = max(r)
sosu = set()

for i in range(2, max_r+1):
    for s in sosu:
        if i%s == 0:
            break
    else:
        sosu.add(i)
sums = [0] * (max_r + 1)
for i in range(1, max_r+1):
    if i in sosu and (i+1)//2 in sosu:
        sums[i] = sums[i-1] + 1
    else:
        sums[i] = sums[i-1]

for i in range(Q):
    print(sums[r[i]] - sums[l[i]-1])



Fixed submission:
Q = int(input())
l, r = [], []
for i in range(Q):
    _l, _r = map(int, input().split())
    l.append(_l)
    r.append(_r)
max_r = max(r)

is_sosu = [1] * (max_r + 1)
is_sosu[0] = is_sosu[1] = 0
for i in range(2, max_r+1):
    if is_sosu[i]:
        for j in range(i*i, max_r+1, i):
            is_sosu[j] = 0

sums = [0] * (max_r + 1)
for i in range(1, max_r+1):
    if is_sosu[i] and is_sosu[(i+1)//2]:
        sums[i] = sums[i-1] + 1
    else:
        sums[i] = sums[i-1]

for i in range(Q):
    print(sums[r[i]] - sums[l[i]-1])

Buggy python submission (verdict: Time Limit Exceeded):
Q = int(input())
l, r = [], []
for i in range(Q):
    _l, _r = map(int, input().split())
    l.append(_l)
    r.append(_r)
max_r = max(r)
sosu = set()

for i in range(2, max_r+1):
    for s in sosu:
        if i%s == 0:
            break
    else:
        sosu.add(i)
sums = [0] * (max_r + 1)
for i in range(1, max_r+1):
    if i in sosu and (i+1)//2 in sosu:
        sums[i] = sums[i-1] + 1
    else:
        sums[i] = sums[i-1]

for i in range(Q):
    print(sums[r[i]] - sums[l[i]-1])



Fixed submission:
Q = int(input())
l, r = [], []
for i in range(Q):
    _l, _r = map(int, input().split())
    l.append(_l)
    r.append(_r)
max_r = max(r)

is_sosu = [1] * (max_r + 1)
is_sosu[0] = is_sosu[1] = 0
for i in range(2, max_r+1):
    if is_sosu[i]:
        for j in range(i*i, max_r+1, i):
            is_sosu[j] = 0

sums = [0] * (max_r + 1)
for i in range(1, max_r+1):
    if is_sosu[i] and is_sosu[(i+1)//2]:
        sums[i] = sums[i-1] + 1
    else:
        sums[i] = sums[i-1]

for i in range(Q):
    print(sums[r[i]] - sums[l[i]-1])
Buggy python submission (verdict: Runtime Error):
s = input()
t = 'AKIHABARA'
i, j = 0, 0
ans = 'YES'
while j < len(t):
    if i == len(s) and t[j] == 'A':
        j += 1
    elif s[i] == t[j]:
        i += 1
        j += 1
    elif t[j] == 'A':
        j += 1
    else:
        ans = 'NO'
        break
print(ans)


Fixed submission:
import re
s = input()
if re.match('A?KIHA?BA?RA?$', s):
    print('YES')
else:
    print('NO')