TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
from sys import exit
r, s = map(int, input().split())
a = [input() for i in range(r)]

def check(x):
    cnt = [0 for i in range(300)]
    for i in x:
        cnt[ord(i)] += 1
    odd = sum(i % 2 for i in cnt)
    if odd != len(x) % 2:
        print('NO')
        exit(0)

midr, mids = None, None

dr = dict()
for i in range(r):
    b = tuple(sorted(a[i]))
    if b not in dr:
        dr[b] = 1
    else:
        dr[b] += 1
odd = 0
for k in dr:
    if dr[k] % 2 == 1:
        odd += 1
        midr = k
if odd != r % 2:
    print('NO')
    exit(0)
if odd == 1:
    check(midr)

ds = dict()
for j in range(s):
    b = tuple(sorted([a[i][j] for i in range(r)]))
    if b not in ds:
        ds[b] = 1
    else:
        ds[b] += 1
odd = 0
for k in ds:
    if ds[k] % 2 == 1:
        odd += 1
        mids = k
if odd != s % 2:
    print('NO')
    exit(0)
if odd == 1:
    check(mids)

if mids:
    for k in dr:
        indeksi = [i for i in range(r) if tuple(sorted(a[i])) == k]
        check([mids[i] for i in indeksi])
if midr:
    for k in ds:
        indeksi = [j for j in range(s) if tuple(
            sorted([a[i][j] for i in range(r)])) == k]
        check([midr[j] for j in indeksi])

print('YES')


A

CODE

print(r.text[:300] + '...')

n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
i, j = b[n // 2 - 1], b[n // 2]
for x in a:
    if x <= i:
        print(j)
    else:
        print(i)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
from collections import defaultdict


def main():
    h, w = map(int, input().split())
    s = []
    for _ in range(h):
        col = []
        s.append(col)
        for c in input().strip():
            col.append(ord(c))
    c_row = defaultdict(int)
    for col in s:
        c_row[tuple(sorted(col))] += 1
    if sum(c % 2 for c in c_row.values()) > h % 2:
        print('NO')
        return
    for row, c in c_row.items():
        if c % 2:
            count = defaultdict(int)
            for ch in row:
                count[ch] += 1
            if sum(cc % 2 for cc in count.values()) > w % 2:
                print('NO')
                return

    c_col = defaultdict(int)
    for col in zip(*s):
        c_col[tuple(sorted(col))] += 1
    if sum(c % 2 for c in c_col.values()) > w % 2:
        print('NO')
        return

    for col, c in c_col.items():
        if c % 2:
            count = defaultdict(int)
            for ch in col:
                count[ch] += 1
            if sum(cc % 2 for cc in count.values()) > h % 2:
                print('NO')
                return

    if s[0][0] == ord('b'):
        print('NO')
    else:
        print('YES')


main()


# -*- coding: utf-8 -*-

n = int(input())
xx = list([i, x] for i, x in enumerate(map(int, input().split())))
xx.sort(key=lambda x: x[1])

mid1 = xx[n // 2][1]
mid2 = xx[n // 2 - 1][1]
for i in range(n // 2):
    xx[i][1] = mid1
for i in range(n // 2, n):
    xx[i][1] = mid2

xx.sort()
print('\n'.join(str(x[1]) for x in xx))


Verdicts: Runtime Error

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
from numpy import median
from copy import deepcopy

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

sx = x.sorted()
newl = deepcopy(sx)
del newl[0]
bigm = median(newl)
newl = deepcopy(sx)
del newl[-1]
minm = median(newl)

med = median(x)

for i in x:
    if i > med:
        print(minm)
    else:
        print(maxm)


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

for i in range(n/2):
    print(x[n/2])

for i in range(n/2):
    print(x[(n-1)//2])


from numpy import median
from copy import deepcopy

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

sx = sorted(x)
newl = deepcopy(sx)
del newl[0]
maxm = median(newl)
newl = deepcopy(sx)
del newl[-1]
minm = median(newl)

med = median(x)

for i in x:
    if i > med:
        print(int(minm))
    else:
        print(int(maxm))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
import sys
sys.setrecursionlimit(10000)

h, w = map(int, input().split())
s = [None] * h
ss = [None] * h
for i in range(h):
    s[i] = input()
    ss[i] = sorted(s[i])

def c(x, y):
    l = len(y)
    if l == w: return True
    if l % 2 == 0:
        for i in range(w):
            if i not in y:
                y.append(i)
                if c(x, y): return True
                y.pop()
    else:
        for i in range(w):
            if i not in y:
                ok = True
                for j in range(0, h, 2):
                    if j + 1 == h: k = j
                    else: k = j + 1
                    a, b = x[j], x[k]
                    d, e = y[-1], i
                    if s[a][d] == s[b][e] and s[a][e] == s[b][d]:
                        continue
                    ok = False
                if ok:
                    y.append(i)
                    if c(x, y): return True
                    y.pop()
    return False
    
def r(x):
    l = len(x)
    if l == h:
        for i in range(w):
            if c(x, [i]): return True
    if l % 2 == 0:
        for i in range(h):
            if i not in x:
                x.append(i)
                if r(x): return True
                x.pop()
    else:
        for i in range(h):
            if i not in x and ss[x[-1]] == ss[i]:
                x.append(i)
                if r(x): return True
                x.pop()
    return False
            

ok = True
for i in range(h):
    ok = r([i])
    if ok: break
if ok: print('YES')
else: print('NO')


n = int(input())
a = [int(x) for x in input().split()]
x = sorted(a)
m1 = x[n // 2]
m2 = x[n // 2 - 1]
for i in range(n):
    if a[i] < m1: print(m1)
    else: print(m2)


Verdicts: Runtime Error

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
N = int(input())
*X, = map(int, input().split())
Y = sorted(X)
p, q = Y[N//2-1:N//2+1]
ans = []
print(p, q)
for i in range(N):
    if X[i] < q:
        ans.append(q)
    else:
        ans.append(p)
print(*ans, sep='\n')

n = int(input())
*x, = map(int, input().split())
y = sorted(x)
p, q = y[n//2-1:n//2+1]
ans = []
for i in range(n):
    if x[i] < q:
        ans.append(q)
    else:
        ans.append(p)
print(*ans, sep='\n')



Verdicts: Wrong Answer

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
import numpy as np

N = int(input())
n_list = list(map(int, input().split()))

M = np.max(n_list)

best_k_bar = (M - 1) / 2
best_k_cand = [x for x in n_list if x >= best_k_bar]
best_k = np.min(best_k_cand)

print(M, best_k)

import numpy as np

N = int(input())
n_list1 = list(map(int, input().split()))

n_list2 = list(n_list1)
n_list_test = list(n_list1)

print(n_list_test)

n_list_max = np.max(n_list1)
n_list_min = np.min(n_list2)

n_list1.remove(n_list_max)
n_list2.remove(n_list_min)

# print(np.max(n_list))
# np.median(n_list - )
n_list1_median = int(np.median(n_list1))
n_list2_median = int(np.median(n_list2))

print(n_list1_median)
print(n_list2_median)

for x in n_list_test:
  if n_list1_median >= x:
    print(n_list2_median)
  else:
    print(n_list1_median)
 
    



import numpy as np

N = int(input())
n_list1 = list(map(int, input().split()))

n_list2 = list(n_list1)
n_list_test = list(n_list1)


n_list_max = np.max(n_list1)
n_list_min = np.min(n_list2)

n_list1.remove(n_list_max)
n_list2.remove(n_list_min)

# print(np.max(n_list))
# np.median(n_list - )
n_list1_median = int(np.median(n_list1))
n_list2_median = int(np.median(n_list2))

for x in n_list_test:
  if n_list1_median >= x:
    print(n_list2_median)
  else:
    print(n_list1_median)
 
    



Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
N = int(input())

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

sorted_a = sorted(a)

if N > 2:
    for i in range(int(N/2)):
        print(sorted_a[int(N/2)])
    for i in range(int(N/2)):
        print(sorted_a[int(N/2)-1])
else:
    print(a[0])


N = int(input())

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

sorted_a = sorted(a)

for i in range(int(N/2)):
    print(sorted_a[int(N/2)-1])

for i in range(int(N/2)):
    print(sorted_a[int(N/2)])

N = int(input())

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

sorted_a = sorted(a)


for i in range(int(N/2)):
    print(sorted_a[int(N/2)])
for i in range(int(N/2)):
    print(sorted_a[int(N/2)-1])

N = int(input())

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

sorted_a = sorted(a)

for i in range(N):
    if a[i] < sorted_a[int(N/2)]:
        print(sorted_a[int(N/2)])
    else:
        print(sorted_a[int(N/2)-1])



Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
i = max(a)
a.remove(i)
j = min(a, key=lambda x: abs(i-x*2))
print(i, j)

n = int(input())
x = list(map(int, input().split()))
a = sorted(range(n), key=lambda i: x[i])
l = x[a[n//2-1]]
r = x[a[n//2]]
b = [0]*n
for i, j in enumerate(a):
    if i < n//2:
        b[j] = r
    else:
        b[j] = l
for e in b:
    print(e)

Verdicts: Wrong Answer

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
n=int(input())
x=list(map(int,input().split(' ')))
x1=x[:]
x1.sort()
x2=x1[:]
for i in range(n):
    l=x[i]
    print(x1)
    x1.remove(l)
    print (x1[int(n/2)-1])
    print(x1)
    x1=x2[:]


n=int(input())
x=list(map(int,input().split(' ')))
x1=x[:]
x1.sort()
for i in range(n):
    l=x[i]
    x1.remove(l)
    print (x1[int(n/2)-1])
    x1=x[:]


import numpy as np
n=int(input())
x=list(map(int,input().split(' ')))
x1=x[:]
x.sort()
m1=x[int(n/2)-1]
m2=x[int(n/2)]
for i in range(n):
    now=x1[i]
    if x1[i]<=m1:
        print(m2)
    else:
        print(m1)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
from collections import Counter
N=int(input())
X=list(map(int,input().split()))
Y=sorted(X)
a=Y[N//2]
b=Y[N//2-1]
for i in range(N):
    if X[i]<=b:
        print(a)
        break
    else:
        print(b)
        break

from collections import Counter
N=int(input())
X=list(map(int,input().split()))
Y=sorted(X)
a=Y[N//2]
b=Y[N//2-1]
for i in X:
    if i<=b:
        print(a)
    else:
        print(b)

Verdicts: Wrong Answer

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
N=int(input())
inp=list(map(int, input().strip().split(' ')))
Xsort=sorted(inp)
med = int(N/2)
for i in range(N):
  if Xsort[med-1] > inp[i]:
    print(Xsort[med])
  else:
    print(Xsort[med-1])

N=int(input())
inp=list(map(int, input().strip().split(' ')))
Xsort=sorted(inp)
med = int(N/2)
for i in range(N):
  if Xsort[med-1] >= inp[i] :
    print(Xsort[med])
  else:
    print(Xsort[med-1])

Verdicts: Wrong Answer

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
import copy

N = int(input())
X = []
X = [int(i) for i in input().split()]

Y = copy.deepcopy(X)
Y.sort()

largeMedian = Y[int(N / 2)]
smallMedian = Y[int(N / 2)-1]


print(X)
print(Y)
print(smallMedian)
print(largeMedian)

for i in range(N):
    if X[i] <= smallMedian:
        X[i] = largeMedian
    else:
        X[i] = smallMedian

for i in range(N):
    print(X[i])


import copy

N = int(input())
X = []
X = [int(i) for i in input().split()]

Y = copy.deepcopy(X)
Y.sort()

largeMedian = Y[int(N / 2)]
smallMedian = Y[int(N / 2)-1]


print(X)
print(Y)
print(smallMedian)
print(largeMedian)

for i in range(N):
    if X[i] <= smallMedian:
        X[i] = largeMedian
    else:
        X[i] = smallMedian

for i in range(N):
    print(X[i], end=' ')


import copy

N = int(input())
X = []
X = [int(i) for i in input().split()]

Y = copy.deepcopy(X)
Y.sort()

largeMedian = Y[int(N / 2)]
smallMedian = Y[int(N / 2)-1]

for i in range(N):
    if X[i] <= smallMedian:
        X[i] = largeMedian
    else:
        X[i] = smallMedian

for i in range(N):
    print(X[i])


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
n = int(input())
a = sorted(zip(map(int, input().split()), range(n)))
for i in range(n//2):
  a[i] = a[n//2 - 1]
  a[i + n//2] = a[n//2]
print('\n'.join(map(lambda x: str(x[0]), sorted(a, key = lambda x: x[1]))))


n = int(input())
a = sorted(zip(map(int, input().split()), range(n)))
b = [0] * n
for i in range(n//2):
  b[i], b[n - i - 1] = (a[n//2][0], a[i][1]), (a[n//2 - 1][0], a[n - i - 1][1])
print('\n'.join(map(lambda x: str(x[0]), sorted(b, key = lambda x: x[1]))))


Verdicts: Wrong Answer

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
l = y[n/2-2]
r = y[n/2-1]
for i in range(n):
    if x[I] <= l:print(r)
    else:print(l)


n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
l = y[n/2-2]
r = y[n/2-1]
for i in range(n):
    if x[i] <= l:print(r)
    else:print(l)


n = list(map(int,input().split()))
x = list(map(int,input().split()))
y = sorted(x)
l = y[n/2-2]
r = y[n/2-1]
for i in range(n):
    if x[I] <= l:print(r)
    else:print(l)

n = list(map(int,input().split()))
x = list(map(int,input().split()))
y = sorted(x)
l = y[n/2-2]
r = y[n/2-1]
for i in range(n):
    if x[i] <= l:print(r)
    else:print(l)


n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
l = y[n//2-2]
r = y[n//2-1]
for i in range(n):
    if x[i] <= l:print(r)
    else:print(l)


n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
l = y[n//2-1]
r = y[n//2]
for i in range(n):
    if x[i] <= l:print(r)
    else:print(l)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Wrong Answer

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
N = int(input())
X = list(map(int, input().split()))

X.sort()

for i in range(N):
    tmp = X.pop(i)
    print(X[(N // 2) - 1])
    X.insert(i, tmp)

N = int(input())
X = list(map(int, input().split()))
X_sorted = sorted(X)

for i in range(N):
    if X[i] < X_sorted[N // 2]:
        print(X_sorted[N // 2])
    else:
        print(X_sorted[(N // 2) - 1])

Verdicts: Wrong Answer

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
N = int(input())
N_d = int(N/2)
X1 = list(map(int,input().split()))
X = X1[:]
X1.sort()

def getMed(i):
  if i  < X[N_d]:
    print(X[N_d])
  else:
    print( X[N_d -1])

for i in X:
  getMed(i)
 

N = int(input())
N_d = int(N/2)
X1 = list(map(int,input().split()))
X = X1[:]
X1.sort()

def getMed(i):
  if i  < X1[N_d]:
    print(X1[N_d])
  else:
    print( X1[N_d -1])

for i in X:
  getMed(i)

Verdicts: Wrong Answer

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
n = int(input())
l0 = list(map(int, input().split()))
l = sorted(l0)

m1 = l[n//2 - 1]
m2 = l[n//2]
for i in range(len(l0)):
    if l0[i] <= m2:
        print(m2)
    if l0[i] > m1:
        print(m1)


n, m = map(int,input().split())
d = {i: {chr(i): 0 for i in range(ord('a'), ord('z')+1)} for i in range(n)}
d2 = {i: {chr(i): 0 for i in range(ord('a'), ord('z')+1)} for i in range(m)}
for i in range(n):
    s = input()
    for j in s:
        d[i][j] += 1
    for j in range(len(s)):
        d2[j][s[j]] += 1

k = [0 for i in range(n)]
k2 = [0 for i in range(m)]

f = True
for i in range(n):
    for j in range(n):
        if d[i] == d[j]:
            k[i] += 1


for i in range(m):
    for j in range(m):
        if d2[i] == d2[j]:
            k2[i] += 1

k2 = sorted(k2)
k = sorted(k)
if n % 2:
    if len(k) > 1:
        if k[1] < 2:
            f = False
else:
    if k[0] < 2:
        f = False

if m % 2:
    if len(k) > 1:
        if k2[1] < 2:
            f = False
else:
    if k2[0] < 2:
        f = False

if f:
    print('YES')
else:
    print('NO')

n = int(input())
l0 = list(map(int, input().split()))
l = sorted(l0)

m1 = l[n//2 - 1]
m2 = l[n//2]
for i in range(len(l0)):
    if l0[i] < m2:
        print(m2)
    elif l0[i] > m1:
        print(m1)
    elif l0[i] == m1:
        print(m2)
    elif l0[i] == m2:
        print(m1)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
n = int(input())
x = [int(a) for a in input().split()]
sorted_x = sorted(x)
print(x)
print(sorted_x)
for elem in x:
    if elem >= sorted_x[(len(x) + 1) // 2]:
        print(sorted_x[(len(x) + 1) // 2 - 1])
    else:
        print(sorted_x[(len(x) + 1) // 2])
    

n = int(input())
x = [int(a) for a in input().split()]
sorted_x = sorted(x)
for elem in x:
    if elem >= sorted_x[(len(x) + 1) // 2]:
        print(sorted_x[(len(x) + 1) // 2 - 1])
    else:
        print(sorted_x[(len(x) + 1) // 2])
    

Verdicts: Wrong Answer

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
from heapq import heappush
n=int(input())
x=list(map(int,input().split()))
a=[]
for i in range(n):
  a+=[(x[i],i)]
a=sorted(a)
ans=[]
for i,j in a:
  if i<=a[n//2][0]:heappush(ans,(j,a[n//2][0]))
  else:heappush(ans,(j,a[n//2-1][0]))
for i,j in ans:
  print(j)

n=int(input())
x=list(map(int,input().split()))
a=[]
for i in range(n):
  a+=[(x[i],i)]
a=sorted(a)
ans=[]
for i in range(n):
  if i<n//2:ans+=[(a[i][1],a[n//2][0])]
  else:ans+=[(a[i][1],a[n//2-1][0])]
for i,j in sorted(ans):
  print(j)

Verdicts: Wrong Answer

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
n = int(input())

a = input().split()

a = [int(x) for x in a]

am = max(a)
ai = 0
r = abs(a[0] - (am/2)) 

for i in range(n):
    if r >= abs(a[i]-(am/2)):
        r = abs(a[i]-(am/2))
        ai = a[i]
        
print("{0} {1}".format(am,ai))

N = int(input())

X = input().split()
x1 = [int(x) for x in X]
x2 = [int(x) for x in X]

x2.sort()
ml = x2[int((N/2)-1)]
mr = x2[int(N/2)]

for i in range(N):
    if x1[i] <=  ml:
        print("%d"%mr)
    else:
        print("%d"%ml)
        
    

Verdicts: Wrong Answer

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
n = int(input())
x = list(map(int, input().split()))
sorted_x = sorted(x)

if sorted_x[n // 2] == sorted_x[n // 2 - 1]:
    print(' '.join([sorted_x[n // 2] * n]))
else:
    ret = []
    for i in range(n):
        if x[i] >= sorted_x[n // 2]:
            ret.append(sorted_x[n // 2])
        else:
            ret.append(sorted_x[n // 2 - 1])
    print(' '.join(ret))


n = int(input())
x = list(map(int, input().split()))
sorted_x = sorted(x)

if sorted_x[n // 2] == sorted_x[n // 2 - 1]:
    ret = [sorted_x[n // 2]] * n
else:
    ret = []
    for i in range(n):
        if x[i] >= sorted_x[n // 2]:
            ret.append(sorted_x[n // 2])
        else:
            ret.append(sorted_x[n // 2 - 1])
for i in ret:
    print(i)


n = int(input())
x = list(map(int, input().split()))
sorted_x = sorted(x)

if sorted_x[n // 2] == sorted_x[n // 2 - 1]:
    ret = [sorted_x[n // 2]] * n
else:
    ret = []
    for i in range(n):
        if x[i] >= sorted_x[n // 2]:
            ret.append(sorted_x[n // 2 - 1])
        else:
            ret.append(sorted_x[n // 2])
for i in ret:
    print(i)


Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
# -*- coding: utf-8 -*-


import numpy as np

N = int(input())
X = np.array(map(int, input().split(" ")))

for i in range(N):
    print(np.append(X[:i], X[i+1:]).median)

# -*- coding: utf-8 -*-

import random
import copy

N = int(input())
X = list(map(int, input().split(" ")))
sorted_X = sorted(X)
med1 = sorted_X[N//2-1]
med2 = sorted_X[N//2]
for i in range(N):
    if X[i] <= med1:
        print(med2)
    else:
        print(med1)

Verdicts: Runtime Error

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
N = int(input())
b = [int(i) for i in input().split()]
b.sort()
s  = b[len(b)//2 - 1]
l  = b[len(b)//2]

for i in range(N):
    if i > len(b)//2:
       print(s)
    else:
       print(l)

N = int(input())
b = input().split(" ")

for i in range(N):
    X = b
    X.pop(i)
    X.sort()
    print(X[len(X)//2])

N = int(input())
b = [int(i) for i in input().split()]
b.sort()
s  = b[len(b)//2 - 1]
l  = b[len(b)//2]

for i in range(N):
    if s > i:
       print(s)
    else:
       print(l)


N = int(input())
b = [int(i) for i in input().split()]
b.sort()
s = b[(N-1)//2]
l = b[N//2]

for i in range(N):
    if i > s:
       print(s)
    else:
       print(l)

N = int(input())
b = [int(i) for i in input().split()]
b.sort()
s  = b[len(b)//2 - 1]
l  = b[len(b)//2]

for i in range(N):
    if i > len(b)//2-1:
       print(s)
    else:
       print(l)

N = int(input())
b = [int(i) for i in input().split()]
c = sorted(b[:])
s = c[(N-1)//2]
l = c[N//2]

for i in b:
    if i > s:
       print(s)
    else:
       print(l)

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.  You are given N numbers X_1, X_2, ..., X_N, where N is an even number. For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.  Find B_i for each i = 1, 2, ..., N.

Submission attempts (in order):
N = int(input())
X = list(map(int, input().split()))
for i in range(N):
  Y = X[:]
  Y.remove(X[i])
  Y.sort()
  print(Y[N // 2])

N = int(input())
X = list(map(int, input().split()))
L = [0 for _ in range(N)]
for i in range(N):
  X[i] = X[i] * N + i
X.sort()
d = N // 2
for i in range(N):
  if i < d:
    L[X[i]%N] = X[d] // N
  else:
    L[X[i]%N] = X[d-1] // N
for i in range(N):
  print(L[i])

Verdicts: Runtime Error

Accepted
Problem: Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Submission attempts (in order):
import numpy as np

N = int(input())
n_list = list(map(int, input().split()))

M = np.max(n_list)

best_k_bar = (M - 1) / 2
best_k_cand = [x for x in n_list if x >= best_k_bar]
best_k = np.min(best_k_cand)

print(best_k_bar)
print(M, best_k)

import numpy as np

N = int(input())
n_list = list(map(int, input().split()))

M = np.max(n_list)
mid_M = M / 2
ex_M_list = list(n_list)
ex_M_list.remove(M)

best_k_cand = list(abs(ex_M_list - mid_M))
best_k = min(best_k_cand)
a = best_k_cand.index(best_k)

print(M, ex_M_list[a])


Verdicts: Wrong Answer

Accepted
Problem: Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Submission attempts (in order):
n = int(input())
p = list(map(int,input().split()))
p.sort()
a1 = max(p)
a2 = min(p)
half = (a1+1) // 2
s = n // 2
graph = [0] * n

while True:
    if graph[s] != 0:
        break
    else:
        graph[s] += 1
    if p[s] < half:
        if abs(p[s] - half) < abs(a2 - half):
            a2 = p[s]
        s += 1
    elif p[s] > half:
        if abs(p[s] - half) < abs(a2 - half):
            a2 = p[s]
        s -= 1
    if s == 0 or s == n:
        break
print(a1, a2)

n = int(input())
p = list(map(int,input().split()))
p.sort()
a1 = max(p)
a2 = min(p)
half = (a1+1) // 2
s = n // 2
graph = [0] * n

while True:
    if graph[s] != 0:
        break
    else:
        graph[s] += 1
    if p[s] <= half:
        if abs(p[s] - half) < abs(a2 - half):
            a2 = p[s]
        s += 1
    elif p[s] > half:
        if abs(p[s] - half) < abs(a2 - half):
            a2 = p[s]
        s -= 1
    if s == 0 or s == n:
        break
print(a1, a2)

Verdicts: Wrong Answer

Accepted
Problem: Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Submission attempts (in order):
n = int(input())
a = list(map(int, input().split()))
i = max(a)
a.remove(i)
k = min(a, key=lambda x: abs(i-x*2))
print(i, j)

n = int(input())
a = list(map(int, input().split()))
i = max(a)
a.remove(i)
j = min(a, key=lambda x: abs(i-x*2))
print(i, j)

Verdicts: Runtime Error

Accepted
Problem: Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Submission attempts (in order):
cache = {0: 1, 1: 1, 2: 2}
combo_cache = {}


def prepare_cache():
    val = 1
    for i in range(1, 10000):
        cache[i] = val * i

def permutation(n):
    if n in cache:
        return cache[n]

    ret = n
    for i in range(n-1, 0, -1):
        if i in cache:
            ret *= cache[i]
            cache[n] = ret
            return ret

        ret *= i
    return ret


def combo(n, r):
    key = str(n) + "-" + str(r)
    if key in combo_cache:
        return combo_cache[key]

    x = permutation(n)
    y = permutation(n-r)
    z = permutation(r)
    combo_cache[key] = int(x // (y * z))
    return combo_cache[key]


count = int(input())
li = list(map(int, input().split()))
#
# data = open("input.txt", "r")
# l = data.read()


prepare_cache()

sli = sorted(li)

pair_a = 0
pair_b = 0
current_max = 0

i = sli[len(sli) - 1]

for j in range(0, len(sli) - 1):
    val = combo(i, sli[j])
    # print(str(sli[i]) + ", " + str(sli[j]) + ", " + str(val))
    if val > current_max:
        current_max = val
        pair_a = i
        pair_b = sli[j]

print(str(pair_a) + " " + str(pair_b))



cache = {0: 1, 1: 1, 2: 2}
combo_cache = {}


def permutuation(n):
    if n in cache:
        return cache[n]

    ret = n
    for i in range(n, 0, -1):
        if i in cache:
            ret *= cache[i]
            cache[n] = ret
            return ret

        ret *= i
    return ret


def combo(n, r):
    key = str(n) + "-" + str(r)
    if key in combo_cache:
        return combo_cache[key]

    x = permutuation(n)
    y = permutuation(n-r)
    z = permutuation(r)
    combo_cache[key] = int(x // (y * z))
    return combo_cache[key]


count = int(input())
li = list(map(int, input().split()))
#
# data = open("input.txt", "r")
# l = data.read()



sli = sorted(li)

pair_a = 0
pair_b = 0
current_max = 0

for i in range(len(sli) - 2,len(sli)):
    for j in range(0, i):
        val = combo(sli[i], sli[j])
        # print(str(sli[i]) + ", " + str(sli[j]) + ", " + str(val))
        if val > current_max:
            current_max = val
            pair_a = sli[i]
            pair_b = sli[j]

print(str(pair_a) + " " + str(pair_b))


count = int(input())
li = list(map(int, input().split()))

sli = sorted(li)

pair_a = sli[len(sli) - 1]
pair_b = 0
current_max = 0

i = sli[len(sli) - 1]

diff = 10**9
for j in range(0, len(sli) - 1):
    h = pair_a / 2
    if abs(h - sli[j]) < diff:
        diff = abs(h - sli[j])
        pair_b = sli[j]

print(str(pair_a) + " " + str(pair_b))


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Submission attempts (in order):
from bisect import *
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
ans = a[-1]//2
b = bisect_left(a,ans)
if abs(ans-a[b]) < abs(ans-a[b-1]):
  print(a[-1],a[b])
else:
  print(a[-1],a[b-1])

from bisect import *
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
ans = a[-1]/2
b = bisect_left(a,ans)
if abs(ans-a[b]) < abs(ans-a[b-1]):
  print(a[-1],a[b])
else:
  print(a[-1],a[b-1])

Verdicts: Wrong Answer

Accepted
Problem: Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Submission attempts (in order):
import bisect
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
mid = bisect.bisect_left(y,y[-1]/2)
if y[-1]/2-x[mid]>=x[mid+1]-y[-1]/2:print(y[-1],x[mid+1])
else:print(y[-1],x[mid])

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

y = max(x)
sub = y
res = 0
for i in range(n):
    if abs(float(y/2-x[i])) < sub and x[i] != y:
        sub = abs(float(y/2-x[i]))
        res = x[i]

print(y,res)


Verdicts: Runtime Error

Accepted
Problem: Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Submission attempts (in order):
def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    A = set(map(int,input().split()))
    A = sorted(list(A))

    import bisect

    ans = A[-1]//2
    b = bisect.bisect_left(A,ans)

    if abs(ans-A[b])<abs(ans-A[max(0,b-1)]):
        print(A[-1],A[b])
    else:
        print(A[-1],A[b-1])

if __name__=='__main__':
    main()

def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    A = set(map(int,input().split()))
    A = sorted(list(A))

    import bisect

    ans = A[-1]/2
    b = bisect.bisect_left(A,ans)

    if abs(ans-A[b])<abs(ans-A[max(0,b-1)]):
        print(A[-1],A[b])
    else:
        print(A[-1],A[b-1])

if __name__=='__main__':
    main()

Verdicts: Wrong Answer

Accepted
Problem: Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Submission attempts (in order):
input()
a=list(map(int,input().split()))
m=max(a)
d=max(a,key=lambda d:abs(m-2*d)if m!=d else-1)
print(m,d)

input()
a=list(map(int,input().split()))
m=max(a)
d=min(a,key=lambda d:abs(m-2*d)if m!=d else 1e18)
print(m,d)

Verdicts: Wrong Answer

Accepted
Problem: Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Submission attempts (in order):
import numpy as np

N = int(input())

a = list(map(int, input().split()))
    
a_i = max(a)

del a[np.argmax(a)]

a = np.array(a)

center = a_i // 2

if a_i % 2 == 1:
    center += 1
    
tmp = center // a

a_j = a[np.argmin(tmp)]
  
print(str(a_i) + ' ' + str(a_j))

import numpy as np

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

a_max = max(a)
a_max_index = np.argmax(a)

del a[a_max_index]

center = a_max / 2

a_x_index = np.argmin(np.absolute(np.array(a) - center))
a_x = a[a_x_index]

print(str(a_max) + ' ' + str(a_x))


Verdicts: Wrong Answer

Accepted
Problem: Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Submission attempts (in order):
input()
da = list(map(int,input().split()))

x = max(da)
y = x + 1
for i in x
	if i == x:
  		continue
    if abs(x/2 - i ) <= (x/2 - y):
		y = i
print(x,y)

input()
da = list(map(int,input().split()))
 
x = max(da)
y = x + 1
for i in da:
	if i == x:
  		continue
    if abs(x/2 - i ) <= abs(x/2 - y):
		y = i
print(x,y)

input()
da = list(map(int,input().split()))
 
x = max(da)
y = x + 1
for i in x:
	if i == x:
  		continue
    if abs(x/2 - i ) <= abs(x/2 - y):
		y = i
print(x,y)

input()
da = list(map(int,input().split()))
 
x = max(da)
y = x + 1
for i in da:
  if i == x:
    continue
  if abs(x/2 - i ) <= abs(x/2 - y):
    y = i
print(x,y)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Submission attempts (in order):
import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
l, r = 0, 0
l = max(a)
a.remove(l)
j = bisect.bisect_left(a, l/2)
print(a[min(j, len(a)-1)])

import bisect
n = int(input())
a = sorted(list(map(int, input().split())))
l, r = 0, 0
l = max(a)
a.remove(l)
j = bisect.bisect_left(a, l/2)
try:
    if abs((l/2) - a[j-1]) < abs((l/2) - a[j]):
        j -= 1
except:
    pass
print(l, a[min(j, len(a)-1)])

Verdicts: Wrong Answer

Accepted
Problem: Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Submission attempts (in order):
# coding: utf-8
# Your code here!

N=int(input())
C = list(map(int,input().split()))

a=sorted(C)

M=a[-1]


A=sorted([abs(2*i - M) for i in a])
print(C)
print(a)
print(A)
N1= (-A[0]+M)//2
N2= (A[0]+M)//2
print(N1,N2)
j = C.index(M)
if N1 in a:
    print(M,N1)
else:
    print(M,N2)





# coding: utf-8
# Your code here!

N=int(input())
C = list(map(int,input().split()))

a=sorted(C)

M=a[-1]


A=sorted([abs(2*i - M) for i in a])
#print(C)
#print(a)
#print(A)
N1= (-A[0]+M)//2
N2= (A[0]+M)//2
#print(N1,N2)
j = C.index(M)
if N1 in a:
    print(M,N1)
else:
    print(M,N2)





Verdicts: Wrong Answer

Accepted
Problem: Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order. From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized. If there are multiple pairs that maximize the value, any of them is accepted.

Submission attempts (in order):
N = int(input())
a = sorted(list(map(int, input().split())))

import numpy as np
from scipy.misc import comb

i = 0
j = 1

ans = (0, 0)
x = 0
for j in range(1, N):
    n = a[j]
    while j - i > 1:
        if abs(n/2 - a[i]) < abs(n/2 - a[i+1]):
            break
        i+=1
    p = a[i]
    y = comb(n, p)
    if y > x:
        x = y
        ans = (n, p)

print(str(ans[0]), str(ans[1]))

N = int(input())
a = sorted(list(map(int, input().split())))
import numpy as np
from scipy.misc import comb

def find_p(n, i):
    lo = 0
    hi = i
    mid = (hi-lo)//2
    xl = a[0]
    xh = a[i]
    while hi - lo > 1:
        mid = (hi+lo)//2
        if a[mid] > n//2:
            hi = mid
        else:
            lo = mid
    if abs(a[lo] - n/2) > abs(a[hi] - n/2):
        return a[hi]
    else:
        return a[lo]

ans = (0, 0)
x = 0
for j in range(N):
    i = N-j-1
    n = a[i]
    p = find_p(n, i)
    y = comb(n, p)
    if y > x:
        ans = (n, p)
        x = y

print(str(ans[0]) + ' ' + str(ans[1]))

N = int(input())
a = sorted(list(map(int, input().split())))

import numpy as np
from scipy.misc import comb

i = 0
j = N//2

ans = (0, 0)
x = 0
for j in range(1, N):
    n = a[j]
    while j - i > 1:
        if abs(n/2 - a[i]) < abs(n/2 - a[i+1]):
            break
        i+=1
    p = a[i]
    y = comb(n, p)
    if y > x:
        x = y
        ans = (n, p)

print(str(ans[0]), str(ans[1]))


N = int(input())
a = sorted(list(map(int, input().split())))
import numpy as np
from scipy.misc import comb

def find_p(n, i):
    lo = 0
    hi = i
    mid = (hi-lo)//2
    xl = a[0]
    xh = a[i]
    while hi - lo > 1:
        mid = (hi+lo)//2
        if a[mid] > n//2:
            hi = mid
        else:
            lo = mid
    if abs(a[lo] - n/2) > abs(a[hi] - n/2):
        return a[hi]
    else:
        return a[lo]

ans = (0, 0)
x = 0
for j in range(N):
    i = N-j-1
    if a[i] < ans[1]:
        break
    n = a[i]
    p = find_p(n, i)
    y = comb(n, p)
    if y > x:
        ans = (n, p)
        x = y

print(str(ans[0]) + ' ' + str(ans[1]))


N = int(input())
a = sorted(list(map(int, input().split())))

def find_p(n, i):
    lo = 0
    hi = i
    mid = (hi-lo)//2
    xl = a[0]
    xh = a[i]
    while hi - lo > 1:
        mid = (hi+lo)//2
        if a[mid] > n//2:
            hi = mid
        else:
            lo = mid
    if abs(a[lo] - n/2) > abs(a[hi] - n/2):
        return a[hi]
    else:
        return a[lo]



print(str(a[-1]) + ' ' + str(find_p(a[-1], N-1)))

Verdicts: Time Limit Exceeded

Time Limit Exceeded

Time Limit Exceeded

Time Limit Exceeded

Accepted
Problem: There is an H \times W grid (H vertical, W horizontal), where each square contains a lowercase English letter. Specifically, the letter in the square at the i-th row and j-th column is equal to the j-th character in the string S_i.  Snuke can apply the following operation to this grid any number of times:    * Choose two different rows and swap them. Or, choose two different columns and swap them.  Snuke wants this grid to be _symmetric_. That is, for any 1 \leq i \leq H and 1 \leq j \leq W, the letter in the square at the i-th row and j-th column and the letter in the square at the (H + 1 - i)-th row and (W + 1 - j)-th column should be equal.  Determine if Snuke can achieve this objective.

Submission attempts (in order):
from itertools import groupby
H, W = map(int, input().split())
if H<=6:
    assert False
S = ["" for _ in range(W)]
T = []
for _ in range(H):
    s = input()
    T.append(s)
    for i, c in enumerate(s):
        S[i] += c
T = [sorted(t) for t in T]
S = [sorted(s) for s in S]
T.sort()
S.sort()
cnt = 0
for _, g in groupby(T):
    if len(list(g))%2:
        cnt += 1
if H%2 < cnt:
    print("NO")
    exit()
cnt = 0
for _, g in groupby(S):
    if len(list(g))%2:
        cnt += 1
if W%2 < cnt:
    print("NO")
    exit()
print("YES")


from itertools import groupby
H, W = map(int, input().split())
if W%2==1:
    assert False
S = ["" for _ in range(W)]
T = []
for _ in range(H):
    s = input()
    T.append(s)
    for i, c in enumerate(s):
        S[i] += c
T = [sorted(t) for t in T]
S = [sorted(s) for s in S]
T.sort()
S.sort()
cnt = 0
for _, g in groupby(T):
    if len(list(g))%2:
        cnt += 1
if H%2 < cnt:
    print("NO")
    exit()
cnt = 0
for _, g in groupby(S):
    if len(list(g))%2:
        cnt += 1
if W%2 < cnt:
    print("NO")
    exit()
print("YES")




from itertools import groupby
H, W = map(int, input().split())
S_ = ["" for _ in range(W)]
T_ = []
for _ in range(H):
    s = input()
    T_.append(s)
    for i, c in enumerate(s):
        S_[i] += c
T = [sorted(t) for t in T_]
S = [sorted(s) for s in S_]
cnt = 0
for _, g in groupby(sorted(T)):
    if len(list(g))%2:
        cnt += 1
if H%2 < cnt:
    print("NO")
    exit()
cnt = 0
for _, g in groupby(sorted(S)):
    if len(list(g))%2:
        cnt += 1
if W%2 < cnt:
    print("NO")
    exit()
if W%2 or H%2:
    print("YES")
    exit()
T1 = []
T2 = []
for i, (_, t) in enumerate(sorted(zip(T, T_))):
    if i%2:
        T1.append(t)
    else:
        T2.append(t)
T_p = T1 + T2[::-1]
S_pp = ["" for _ in range(W)]
for t in T_p:
    for i, c in enumerate(t):
        S_pp[i] += c
S1 = []
S2 = []
for i, (_, s) in enumerate(sorted(zip(S, S_pp))):
    if i%2:
        S1.append(s)
    else:
        S2.append(s)
S_p = S1 + S2[::-1]
for s1, s2 in zip(S_p, S_p[::-1]):
    for c1, c2 in zip(s1, s2[::-1]):
        if c1!=c2:
            print("NO")
            exit()
print("YES")


Verdicts: Runtime Error

Runtime Error

Accepted