Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
from collections import Counter
N, M = (list)(map(int, input().split()))
A = (list)(map(int, input().split()))
A[0] %= M

for i in range(1, N):
    A[i] += A[i-1]
    A[i] %= M

ans = 0

C = Counter(A)
for num, val in C:
    if num == 0:
        ans += val
    if val >= 2:
        ans += val*(val-1)//2
print(ans)


Fixed submission:
from collections import Counter
N, M = (list)(map(int, input().split()))
A = (list)(map(int, input().split()))
A[0] %= M

for i in range(1, N):
    A[i] += A[i-1]
    A[i] %= M

ans = 0

C = Counter(A)
for num, val in C.items():
    if num == 0:
        ans += val
    if val >= 2:
        ans += val*(val-1)//2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N, M = (list)(map(int, input().split()))
A = (list)(map(int, input().split()))
A[0] %= M

for i in range(1, N):
    A[i] += A[i-1]
    A[i] %= M

ans = 0
for i in range(M):
    if i == 0:
        ans += A.count(i)
    c = A.count(i)
    if c >= 2:
        ans += c*(c-1)//2
print(ans)


Fixed submission:
from collections import Counter
N, M = (list)(map(int, input().split()))
A = (list)(map(int, input().split()))
A[0] %= M

for i in range(1, N):
    A[i] += A[i-1]
    A[i] %= M

ans = 0

C = Counter(A)
for num, val in C.items():
    if num == 0:
        ans += val
    if val >= 2:
        ans += val*(val-1)//2
print(ans)

Buggy python submission (verdict: Runtime Error):
N, M = (list)(map(int, input().split()))
A = (list)(map(int, input().split()))
Accum = [0]*(N+1)


def comb(n):
    if n >= 2:
        return n*(n-1)//2
    else:
        return 0


for i in range(N-1):
    Accum[i+1] = (Accum[i]+A[i+1]) % M

ans = 0
for i in range(M):
  	if i == 0:
      ans += Accum.count(i)
    else:
    	c = Accum.count(i)
    	ans += comb(c)
print(ans)


Fixed submission:
from collections import Counter
N, M = (list)(map(int, input().split()))
A = (list)(map(int, input().split()))
A[0] %= M

for i in range(1, N):
    A[i] += A[i-1]
    A[i] %= M

ans = 0

C = Counter(A)
for num, val in C.items():
    if num == 0:
        ans += val
    if val >= 2:
        ans += val*(val-1)//2
print(ans)

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

ans = 0
for i in range(N):
    for j in range(i+1, N+1):
        if sum(A[i:j]) % M == 0:
            ans += 1
print(ans)


Fixed submission:
from collections import Counter
N, M = (list)(map(int, input().split()))
A = (list)(map(int, input().split()))
A[0] %= M

for i in range(1, N):
    A[i] += A[i-1]
    A[i] %= M

ans = 0

C = Counter(A)
for num, val in C.items():
    if num == 0:
        ans += val
    if val >= 2:
        ans += val*(val-1)//2
print(ans)
Buggy python submission (verdict: Runtime Error):
from functools import reduce
n = (int)(input())
a = (list)(map(int, input().split()))


def calcMod(a, m):
  return sum([m % v for v in a])


def mul(a, b):
  return a*b


#print(calcMod(a, reduce(mul, a)-1))
print(sum(a)-n)


Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

l = list(map(int, input().split()))

l = sorted(l, reverse=True)
print(sum(a-b for a, b in zip(l, l[1:])))
Buggy python submission (verdict: Runtime Error):
N, M, D = map(int, input().split())

if D == 0:
    print(1/N*(M-1))
else:
    print(2(N-D)/N**2*(M-1))


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

if D == 0:
    print(1/N*(M-1))
else:
    print(2*(N-D)/N**2*(M-1))

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

if D == 0:
    print(1/N*(M-1))
else:
    print(2(N-D)/N**2*(M-1))


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

if D == 0:
    print(1/N*(M-1))
else:
    print(2*(N-D)/N**2*(M-1))

Buggy python submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M, D = map(int, input().split())

if D == 0:
    print(1/N*(M-1))
else:
    print(2(N-D)/N**2*(M-1))


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

if D == 0:
    print(1/N*(M-1))
else:
    print(2*(N-D)/N**2*(M-1))
Buggy python submission (verdict: Runtime Error):
print((lambda x:x+x*(x%2)))(int(input()))

Fixed submission:
N = int(input())
if N%2==0:
  print(N)
else:
  print(2*N)

Buggy python submission (verdict: Runtime Error):
print(map(lambda x:x*((x%2*2),int(input()))

Fixed submission:
N = int(input())
if N%2==0:
  print(N)
else:
  print(2*N)

Buggy python submission (verdict: Runtime Error):
if N%2==0:
	print(N)
else:
	print(2*N)

Fixed submission:
N = int(input())
if N%2==0:
  print(N)
else:
  print(2*N)

Buggy python submission (verdict: Runtime Error):
#include<iostream>
using namespace std;

int main(){
    int n;
    cin >> n;
    if (n%2==0){
        cout<< n << endl;
    }else{
        cout << 2*n <<endl;
    }
}


Fixed submission:
N = int(input())
if N%2==0:
  print(N)
else:
  print(2*N)

Buggy python submission (verdict: Runtime Error):
def median_low(A):
    A.sort()
    b=A
    n = len(A)
    if n%2==1:
        med =b[n//2]
    else:
        x=b[n//2-1]
        y=b[n//2]
        med=(x+y)/2
        if med!=int(med):
            med=x
        else:
            med=int(med)
    return med


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

A = [v-i-1 for i,v in enumerate(A)]
x = median_low(A)

print(sum(abs(v - x) for v in A))



Fixed submission:
N = int(input())
if N%2==0:
  print(N)
else:
  print(2*N)
Buggy python submission (verdict: Time Limit Exceeded):
n = (int)(input())
A = (list)(map(int,input().split()))

A = [v-i-1 for i,v in enumerate(A)]
print(min(sum(abs(v - b) for v in A) for b in range(min(A),max(A)+1)))


Fixed submission:
from statistics import median_low

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

A = [v-i-1 for i,v in enumerate(A)]
x = median_low(A)

print(sum(abs(v - x) for v in A))

Buggy python submission (verdict: Time Limit Exceeded):
n = (int)(input())
A = (list)(map(int,input().split()))

def sad(A,b):
    return(sum(abs(v - b - i) for i,v in enumerate(A)))

print(min(sad(A,v) for v in range(-len(A),max(A),1)))


Fixed submission:
from statistics import median_low

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

A = [v-i-1 for i,v in enumerate(A)]
x = median_low(A)

print(sum(abs(v - x) for v in A))
Buggy python submission (verdict: Runtime Error):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)

N = input()
di = 0
for c in N:
    di += int(c)
if N % di == 0:
    print("Yes")
else:
    print("No")


Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)

N = input()
di = 0
for c in N:
    di += int(c)
if int(N) % di == 0:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = (list)(map(int, input().split()))

if n <= k:
  print(1)
else:
  print(n//k+1


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

print(-(-(n-1)//(k-1)))
Buggy python submission (verdict: Runtime Error):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def point(p):
    ret = 0
    for a in p:
        ret += abs(a)
    return ret


def add(p1, p2):
    ret = []
    for a, b in zip(p1, p2):
        ret.append(a+b)
    return ret


def bigger(p1, p2):
    return point(p1) > point(p2)


N, M = map(int, input().split())
cakes = []
for _ in range(N):
    cakes.append(list(map(int, input().split())))


def solve():
    dp = [[0, 0, 0] for _ in range(M+1)]

    used = []
    for i in range(1, M+1):
        tmp = [0, 0, 0]
        for c in cakes:
            n = add(dp[i-1], c)
            if bigger(n, tmp):
                tmp = n
                used = c
        dp[i] = tmp
        #print("dp->", dp)
        cakes.remove(used)

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


solve()


Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M = map(int, input().split())
cakes = []
for _ in range(N):
    cakes.append(list(map(int, input().split())))


def sum_cake(a, b, c):
    ret = []
    for x in cakes:
        ret.append(x[0]*a+x[1]*b+x[2]*c)

    ret = sorted(ret, reverse=True)
    return sum(ret[:M])


def solve2():
    ans = 0
    p = [1, -1]
    for a in p:
        for b in p:
            for c in p:
                ans = max(sum_cake(a, b, c), ans)
    print(ans)


solve2()
Buggy python submission (verdict: Runtime Error):
from math import log10
n = int(input())
ans=0
l = log10(n)
if int(l)==l:
  ans=10
else:
  while n>0:
  ans+=n%10
  n//=10
print(ans)


Fixed submission:
# python template for atcoder1
from math import log10
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n = int(input())
ans = 0
l = log10(n)
if int(l) == l:
    ans = 10
else:
    while n > 0:
        ans += n % 10
        n //= 10
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
ans=0
while n>0:
  n%10+=ans
  n//=10
print(ans)

Fixed submission:
# python template for atcoder1
from math import log10
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

n = int(input())
ans = 0
l = log10(n)
if int(l) == l:
    ans = 10
else:
    while n > 0:
        ans += n % 10
        n //= 10
print(ans)
Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-


class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret

    def perm(self, n, r):
        """
        nPrの値を返す
        """
        ret = self.f[n] * self.inv[n-r]
        ret %= self.mod
        return ret

N,A,B,K = map(int,input().split())
ans=0
MOD=10**9+7

F=FactMod(N+1,MOD)

for a in range(1,N+1):
    Ascore = a*A
    Bscore=K-Ascore
    if Bscore%B==0:
        b=Bscore//B
        ans+=F.comb(N,a)*F.comb(N,b)
        ans%=MOD
print(ans)





Fixed submission:
# -*- coding: utf-8 -*-


class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret

    def perm(self, n, r):
        """
        nPrの値を返す
        """
        ret = self.f[n] * self.inv[n-r]
        ret %= self.mod
        return ret

N,A,B,K = map(int,input().split())
ans=0
MOD=998244353

F=FactMod(N+1,MOD)

for a in range(N+1):
    Ascore = a*A
    Bscore=K-Ascore
    if Bscore%B==0:
        b=Bscore//B
        if 0<=b<=N:
            ans+=(F.comb(N,a)*F.comb(N,b))%MOD
            ans%=MOD
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = (int)(input())
s = (input())

l = len(s)
ans = l
for i in range(l):
  l_we = s[0:i] if(i >= 0)else None
  l_ea = s[i+1:l] if(i+1 <= l) else None
  tmp = 0
  tmp += l_we.count('W')
  tmp += l_ea.count('E')
  ans = min(ans, tmp)
print(ans)


Fixed submission:
def sum_list(l1, l2):
  for i in range(len(l1)):
    l1[i] += l2[i]

  return l1


n = (int)(input())
s = input()
l_e = [0 for _ in range(n+1)]
l_w = [0 for _ in range(n+1)]

for i in range(n):
  if s[i] == 'W':
    l_e[i] += 1
  l_e[i+1] = l_e[i]

for i in reversed(range(n)):
  if s[i] == 'E':
    l_w[i] += 1
  l_w[i-1] = l_w[i]

l_e = l_e[:-1]
l_w = l_w[:n]


#print("E", l_e)
#print("W", l_w)

print(min(sum_list(l_e, l_w))-1)

Buggy python submission (verdict: Runtime Error):
n = (int)(input())
s = (input())

l = len(s)
ans = l
for i in range(l):
  l_we = s[0:i] if(i >= 0)else None
  l_ea = s[i+1:l] if(i+1 <= l) else None
  print(l_we)
  print(l_ea)
  tmp = 0
  tmp += l_we.count('W')
  tmp += l_ea.count('E')
  ans = min(ans, tmp)
print(ans)


Fixed submission:
def sum_list(l1, l2):
  for i in range(len(l1)):
    l1[i] += l2[i]

  return l1


n = (int)(input())
s = input()
l_e = [0 for _ in range(n+1)]
l_w = [0 for _ in range(n+1)]

for i in range(n):
  if s[i] == 'W':
    l_e[i] += 1
  l_e[i+1] = l_e[i]

for i in reversed(range(n)):
  if s[i] == 'E':
    l_w[i] += 1
  l_w[i-1] = l_w[i]

l_e = l_e[:-1]
l_w = l_w[:n]


#print("E", l_e)
#print("W", l_w)

print(min(sum_list(l_e, l_w))-1)
Buggy python submission (verdict: Time Limit Exceeded):
s = (str)(input())
k = (int)(input())

dic = []

for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        dic.append(s[i:j])

dic = (list)(set(dic))
dic.sort()

print(dic[k-1])


Fixed submission:
s = (str)(input())
k = (int)(input())

dic = []

for i in range(len(s)):
    for j in range(1, k+1):
        dic.append(s[i:i+j])

dic = (list)(set(dic))
dic.sort()


print(dic[k-1])
Buggy python submission (verdict: Time Limit Exceeded):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
# -*- coding: utf-8 -*-


class UnionFind:
    '''
    配列を用いたUnionFind
    '''

    def __init__(self, size):
        self.table = [i for i in range(size)]

    def find(self, x):
        '''
        xのグループ番号を返す
        '''
        return self.table[x]

    def union(self, x, y):
        '''
        xとyが同じグループならFalse
        xとyが違うグループなら、同じグループにする(くっつける)
        '''
        x1 = self.find(x)
        y1 = self.find(y)

        if x1 == y1:
            return False

        for i in range(len(self.table)):
            if self.table[i] == y1:
                self.table[i] = x1
        return True

    def same(self, x, y):
        '''
        xとyが同じグループならtrue
        '''
        x1 = self.find(x)
        y1 = self.find(y)
        return x1 == y1


N, M = map(int, input().split())
Un = UnionFind(N+1)
A = list(map(int, input().split()))

for _ in range(M):
    a, b = map(int, input().split())
    Un.union(a, b)

ans = 0
for i in range(N):
    if Un.same(A[i], i+1):
        ans += 1
print(ans)


Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
# -*- coding: utf-8 -*-


class UnionFind:
    def __init__(self, size):
        self.parent = [i for i in range(size)]
        self.rank = [0 for _ in range(size)]

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            return self.find(self.parent[x])

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def same(self, x, y):
        return self.find(x) == self.find(y)


N, M = map(int, input().split())
Un = UnionFind(N+1)
A = list(map(int, input().split()))

for _ in range(M):
    a, b = map(int, input().split())
    Un.union(a, b)

ans = 0
for i in range(N):
    if Un.same(A[i], i+1):
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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


a = accumulate(A)
C = Counter(a)
max_v = max(C.values())
f = [1]*(max_v+1)


def fact(n):
    for i in range(1, n):
        f[i+1] = f[i]*(i+1)


fact(max_v)


def comb(n, r):
    return f[n]//(f[r]*f[n-r])


ans = 0
for i, v in C.items():
    if i == 0:
        ans += v
    if v > 1:
        ans += comb(v, 2)
print(ans)


Fixed submission:
from itertools import accumulate
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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


a = accumulate(A)
C = Counter(a)


def comb(v):
    return (v)*(v-1)//2


ans = 0
for i, v in C.items():
    if i == 0:
        ans += v
    if v > 1:
        ans += comb(v)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
f = [1]*(N+1)


def fact(n):
    for i in range(1, n):
        f[i+1] = f[i]*(i+1)


def comb(n, r):
    return f[n]//(f[r]*f[n-r])


a = accumulate(A)
C = Counter(a)
fact(max(C.values()))

ans = 0
for i, v in C.items():
    if i == 0:
        ans += v
    if v > 1:
        ans += comb(v, 2)
print(ans)


Fixed submission:
from itertools import accumulate
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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


a = accumulate(A)
C = Counter(a)


def comb(v):
    return (v)*(v-1)//2


ans = 0
for i, v in C.items():
    if i == 0:
        ans += v
    if v > 1:
        ans += comb(v)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import accumulate
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
f = [1]*(N+1)


def fact():
    for i in range(1, N):
        f[i+1] = f[i]*(i+1)


def comb(n, r):
    return f[n]//(f[r]*f[n-r])


a = accumulate(A)
C = Counter(a)
fact()

ans = 0
for i, v in C.items():
    if i == 0:
        ans += v
    if v > 1:
        ans += comb(v, 2)
print(ans)


Fixed submission:
from itertools import accumulate
from collections import Counter
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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


a = accumulate(A)
C = Counter(a)


def comb(v):
    return (v)*(v-1)//2


ans = 0
for i, v in C.items():
    if i == 0:
        ans += v
    if v > 1:
        ans += comb(v)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
grid=[[v for v in input()] for _ in range(N)]

ans=0
for a in range(N):
    for b in range(N):
        new_grid=[]
        new_grid.extend(grid[a:])
        new_grid.extend(grid[:a])
        for i in range(N):
            new_grid[i] = new_grid[i][b:]+new_grid[i][:b]
        #print(new_grid)

        flag=True
        for i in range(N):
            for j in range(N):
                if new_grid[i][j]==new_grid[j][i]:
                    continue
                else:
                    flag=False
                    break
        if flag:
            ans+=1
print(ans)


Fixed submission:
N = int(input())
grid=[[v for v in input()] for _ in range(N)]

ans=0
for a in range(N):
    new_grid=[]
    new_grid.extend(grid[a:])
    new_grid.extend(grid[:a])

    flag=True
    for i in range(N):
        for j in range(N):
            if new_grid[i][j]==new_grid[j][i]:
                continue
            else:
                flag=False
                break
    if flag:
        ans+=1
print(ans*N)
Buggy python submission (verdict: Runtime Error):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
A, B, X = map(int, input().split())

ans = "YES"
if A+B < X:
    ans = "NO"
elif:
    A > X:
        ans = "NO"
print(ans)


Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline
A, B, X = map(int, input().split())

ans = "YES"
if A+B < X:
    ans = "NO"
elif A > X:
    ans = "NO"
print(ans)
Buggy python submission (verdict: Runtime Error):
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M, X = map(int, input().split())
a = list(map(int, input().split()))
l = [0]*(N+1)
for i in a:
    l[i] += 1
print(min[sum(l[0:X]), sum(l[X+1: N+1])])


Fixed submission:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M, X = map(int, input().split())
a = list(map(int, input().split()))
l = [0]*(N+1)
for i in a:
    l[i] += 1
print(min(sum(l[0:X]), sum(l[X+1: N+1])))
Buggy python submission (verdict: Time Limit Exceeded):
n = (int)(input())
l = (list)(map(int, input().split()))

sorted_l = sorted(l)

for i in range(n):
    tmp = sorted_l.copy()
    tmp.remove(l[i])
    med = tmp[(n-1)//2]
    print(med)


Fixed submission:
n = (int)(input())
l = (list)(map(int, input().split()))

tmp = l.copy()
tmp.sort()

left = tmp[n//2-1]
right = tmp[n//2]

for item in l:
    if item <= left:
        print(right)
    else:
        print(left)

Buggy python submission (verdict: Time Limit Exceeded):
n = (int)(input())
l = (list)(map(int, input().split()))


def median(l):
    #l is odd
    l.sort()
    n = len(l)
    return l[n//2]


for i in range(n):
    tmp = l.copy()
    tmp.remove(tmp[i])
    print(median(tmp))


Fixed submission:
n = (int)(input())
l = (list)(map(int, input().split()))

tmp = l.copy()
tmp.sort()

left = tmp[n//2-1]
right = tmp[n//2]

for item in l:
    if item <= left:
        print(right)
    else:
        print(left)
Buggy python submission (verdict: Runtime Error):
s = input()

alp = [0]*26
a_int = ord('a')

ans = -1
cand = []
if len(s) == 26:
    for i in reversed(range(1, 26)):
        if s[i] < s[i-1]:
            cand.append(s[i])
            continue
        else:
            cand = sorted(cand)
            print(cand)
            ans = s[0:i-1]+cand[0]
            break

else:
    for c in s:
        alp[ord(c)-a_int] = 1

    for i in range(26):
        if alp[i] == 0:
            ans = s+chr(i+a_int)
            break
print(ans)


Fixed submission:
s = input()

alp = [0]*26
a_int = ord('a')

ans = -1
cand = []
if len(s) == 26:
    for i in reversed(range(1, 26)):
        if s[i] < s[i-1]:
            cand.append(s[i])
            continue
        else:
            cand.append(s[i])
            cand = sorted(cand, reverse=True)
            c = min(list(filter(lambda x: x > s[i-1], cand)))
            ans = s[0:i-1]+c
            break

else:
    for c in s:
        alp[ord(c)-a_int] = 1

    for i in range(26):
        if alp[i] == 0:
            ans = s+chr(i+a_int)
            break
print(ans)

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

alp = [0]*26
a_int = ord('a')

if s == "zyxwvutsrqponmlkjihgfedcba":
    ans = -1
else:
    for c in s:
        alp[ord(c)-a_int] = 1

    for i in range(26):
        if alp[i] == 0:
            ans = s+chr(i+a_int)
            break
print(ans)


Fixed submission:
s = input()

alp = [0]*26
a_int = ord('a')

ans = -1
cand = []
if len(s) == 26:
    for i in reversed(range(1, 26)):
        if s[i] < s[i-1]:
            cand.append(s[i])
            continue
        else:
            cand.append(s[i])
            cand = sorted(cand, reverse=True)
            c = min(list(filter(lambda x: x > s[i-1], cand)))
            ans = s[0:i-1]+c
            break

else:
    for c in s:
        alp[ord(c)-a_int] = 1

    for i in range(26):
        if alp[i] == 0:
            ans = s+chr(i+a_int)
            break
print(ans)