Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

H, W, M = map(int,input().split())
hw = [list(map(int,input().split())) for _ in range(M)]

rows, columns = [0]*H, [0]*W
for h, w in hw:
    rows[h-1] += 1
    columns[w-1] += 1
max_r, max_c = max(rows), max(columns)

argmax_r, argmax_c = [], []
for i in range(H):
    if max_r == rows[i]:
        argmax_r.append(i)
for i in range(W):
    if max_c == columns[i]:
        argmax_c.append(i)

for r in argmax_r:
    for c in argmax_c:
        if [r+1,c+1] not in hw:
            print(max_r + max_c)
            exit()

print(max_r + max_c - 1)
    


### FIXED CODE ###

import bisect

H, W, M = map(int,input().split())
hw = [list(map(int,input().split())) for _ in range(M)]
hw.sort()

rows, columns = [0]*H, [0]*W
for h, w in hw:
    rows[h-1] += 1
    columns[w-1] += 1
max_r, max_c = max(rows), max(columns)

argmax_r, argmax_c = [], []
for i in range(H):
    if max_r == rows[i]:
        argmax_r.append(i)

for i in range(W):
    if max_c == columns[i]:
        argmax_c.append(i)

for r in argmax_r:
    for c in argmax_c:
        idx = bisect.bisect_left(hw, [r+1, c+1])
        if idx == M or hw[idx] != [r+1,c+1]:
            print(max_r + max_c)
            exit()

print(max_r + max_c - 1)
### BUGGY CODE ###

import sys
#import copy
import numpy as np
#import itertools
#import collections
#from collections import deque
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
#read = sys.stdin.buffer.read

def main():
    # input
    N = int(readline())
    S = np.array(list(readline()))

    R = np.sum(S == 'R')
    G = np.sum(S == 'G')
    B = np.sum(S == 'B')

    ans = R*G*B

    for i in range(N-2):
        for j in range(i+1, N-1):
            k = 2 * j - i
            if k >= N:
                break
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                ans -= 1
    
    print(ans)
    #print('end')


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
#import copy
#import numpy as np
#import itertools
import collections
#from collections import deque
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
#from scipy.sparse import csr_matrix

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read
count = collections.Counter

def main():
    N = int(readline())
    S = input()

    values = list(count(S).values())
    if len(values) < 3:
        print(0)
        return
    
    ans = values[0] * values[1] * values[2]

    for i in range(N-2):
        for j in range(i+1, N-1):
            k = 2 * j - i
            if k >= N:
                break
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                ans -= 1

    print(ans)
    #print('end')


if __name__ == "__main__":
    main()
### BUGGY CODE ###

H, W = map(int, input().split())
hw = [list(input().strip()) for _ in range(H)]
b = []
for h in range(H):
    for w in range(W):
        if hw[h][w] == '#':
            b.append([h, w, 0])

ans = 0
while len(b) > 0:
    h, w, d = b.pop(0)
    for y, x in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
        nh, nw = h + y, w + x
        if nh >= 0 and nh < H and nw >= 0 and nw < W and hw[nh][nw] == '.':
            b.append([nh, nw, d + 1])
            ans = max([ans, d + 1])
            hw[nh][nw] = "#"
print(ans)

### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())
hw = [list(input().strip()) for _ in range(H)]
b = deque()
for h in range(H):
    for w in range(W):
        if hw[h][w] == '#':
            b.append([h, w, 0])

ans = 0
while len(b) > 0:
    h, w, d = b.popleft()
    d += 1
    for y, x in [[1, 0], [-1, 0], [0, 1], [0, -1]]:
        nh, nw = h + y, w + x
        if nh >= 0 and nh < H and nw >= 0 and nw < W and hw[nh][nw] == '.':
            b.append([nh, nw, d])
            if ans < d:
                ans = d
            hw[nh][nw] = "#"
print(ans)
### BUGGY CODE ###

N = int(input())
l = [input() for i in range(N)]
for i in range(N):
    l[i] = ''.join(sorted(l[i]))
count = 0
for i in range(N):
    for j in range(i+1,N):
        if(l[i]==l[j]):
            count += 1
print(count)

### FIXED CODE ###

N = int(input())
l = [input() for i in range(N)]
mydict = {}
times = [1]*N
count = 0
value = 1

for i in range(N):
    l[i] = ''.join(sorted(l[i]))
    if l[i] in mydict.keys():
        count += times[mydict[l[i]]]
        times[mydict[l[i]]] += 1
    else:
        mydict[l[i]] = value
        value += 1
print(count)
### BUGGY CODE ###

# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

def ncr(n, r):
    a = 1
    b = 1
    for i in range(r):
        a *= (n - i) % MOD
        b *= (r - i) % MOD
    
    return a // b % MOD

N, A, B = MI()

s = pow(2, N, MOD) - 1



a = ncr(N, A)
b = ncr(N, B)

print((s - a - b)  % MOD)


### FIXED CODE ###

# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

def ncr(n, r):
    a = 1
    b = 1
    for i in range(r):
        a = (a * (n - i) % MOD)
        b = (b * (r - i) % MOD)

        # a *= ((n - i) % MOD)
        # b *= ((r - i) % MOD)

    return a * pow(b, MOD - 2, MOD) % MOD

N, A, B = MI()

s = pow(2, N, MOD) - 1
ab = (ncr(N, A) + ncr(N, B)) % MOD

print((s - ab)  % MOD)
### BUGGY CODE ###

n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
ans = 0
if k in l:
    print("POSSIBLE")
    exit()

while True:
    for i in range(n-1):
        for j in range(i+1,n):
            a = abs(l[j] - l[i])
            if a == k:
                ans = 1
                break
            else:
                if a not in l:
                    l.append(a)
    _n = n
    n = len(l)
    if n == _n:
        break

if ans == 1:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

### FIXED CODE ###

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

n,k = list(map(int,input().split()))
l = list(map(int,input().split()))
m = max(l)
for i in range(1,n):
    l[i] = gcd(max(l[i],l[i-1]),min(l[i],l[i-1]))
if k%l[-1] == 0 and k <= m:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
### BUGGY CODE ###

N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

inf = float("inf")
dp = [[-inf for _ in range(W+1)] for _ in range(N+1)]
for i in range(W+1):
    dp[0][i] = 0

for i in range(N):
    weight = wv[i][0]
    value = wv[i][1]
    for w in range(W+1):
        # 重量に収まる場合のみ価値を加える
        if weight <= w:
            dp[i+1][w] = max(dp[i][w-weight] + value, dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]
print(max(dp[-1]))


### FIXED CODE ###

# ナップザック問題
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

inf = float("inf")
dp = [[-inf for _ in range(W+1)] for _ in range(N+1)]
for i in range(W+1):
    dp[0][i] = 0

for i in range(N):
    weight = wv[i][0]
    value = wv[i][1]
    for w in range(W+1):
        # 重量に収まる場合のみ価値を加える
        if weight <= w:
            dp[i+1][w] = max(dp[i][w-weight] + value, dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]
print(max(dp[-1]))
### BUGGY CODE ###

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

S = input()
N = len(S)

counter = 0
surplus = [0]*2019
surplus[0] += 1

for i in range(N):
    surplus[int(S[i:]) % 2019] += 1

print(sum([i*(i-1)//2 for i in surplus]))


### FIXED CODE ###

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

surplus = [0]*2019
surplus[0] += 1

d = 1
n = 0
for i in reversed(input()):
    n = (n + int(i)*d) %2019
    d = d*10 % 2019
    surplus[n] += 1

print(sum([i*(i-1)//2 for i in surplus]))
### BUGGY CODE ###

MOD = 998244353

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

ans = 0
NCi = 1#nからi選ぶ組み合わせ
for i in range(0,K+1,1):
    ans = (ans + M * pow(M-1,N-1-i,MOD)*NCi)%MOD
    NCi = NCi*(N-1-i)*pow((i+1),MOD-2,MOD)

print(ans)

### FIXED CODE ###

MOD = 998244353

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

ans = 0
NCi = 1#nからi選ぶ組み合わせ
for i in range(0,K+1,1):
    ans = (ans + M * pow(M-1,N-1-i,MOD)*NCi)%MOD
    NCi = (NCi*(N-1-i) * pow((i+1),MOD-2,MOD))%MOD

print(ans)
### BUGGY CODE ###

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

# 先にxを選んでおく！
ans = 0
m = max(L) + 1
for i in range(m):
    cm = L.count(i - 1)
    ce = L.count(i)
    cl = L.count(i + 1)
    ans = max(ans, cm + ce + cl)

print(ans)


### FIXED CODE ###

from collections import Counter
N = int(input())
L = list(map(int, input().split()))
c = Counter(L)
# print(c)
# 先にxを選んでおく！
ans = 0
m = max(L) + 1
for i in range(m):
    ans = max(ans, c[i - 1] + c[i] + c[i + 1])

print(ans)
### BUGGY CODE ###

N = int(input())
S = []
for i in range(N):
    temp = input()
    if(temp not in S):
        S.append(temp)

print(len(S))



### FIXED CODE ###

N = int(input())
S = []
for i in range(N):
    S.append(input())

S.sort()

dup = 0;
for i in range(N):
    if i!=0:
        if S[i] == S[i-1]:
            dup += 1

print(N-dup)
### BUGGY CODE ###

import re

S = str(input())
k=int(0)

#for i in range(2000):
#while () :
while S.find('ABC')>=0:
#    S = S[:S.rfind('ABC')] + 'BCA' + S[(S.rfind('ABC')+3):]
#    k +=1
    k += len(re.findall("ABC",S))
    S = S.replace('ABC', 'BCA')
#    if a==0 : break

ans = (int(k))

print(ans)

### FIXED CODE ###

s = input()
ans = 0
cntA = 0
for i in range(0, len(s) - 1):
    if s[i] == 'A':
        cntA += 1
    elif s[i: i + 2] == "BC":
        ans += cntA
    elif i > 0 and s[i - 1: i + 1] == "BC":
        continue
    else:
        cntA = 0
print(ans)
### BUGGY CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
for i in range(N):
    A_1 = A.copy()
    A_1.pop(i)
    print(max(A_1))

### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
B = sorted(A,reverse=True)
if B[0] == B[1]:
    for i in range(N):
        print(B[0])
else:
    for i in range(N):
        if A[i] == B[0]:
            print(B[1])
        else:
            print(B[0])
### BUGGY CODE ###

# -*- coding: utf-8 -*-
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse = True)

l = -1 
r = A[N-1] * F[0]
while l+1 < r: 
    m = (l + r) //2
    S = 0
    for i in range(N):
        S += A[i] - min((m // F[i]), A[i])
    if S <= K:
        r = m
    else:
        l = m
         
print(r)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import numpy as np
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse = True)
sa = sum(A) 
A = np.array(A)
F = np.array(F)

l = -1 
r = A[N-1] * F[0]
while l+1 < r: 
    m = (l + r) //2
    S = sa - np.sum(np.minimum(m // F, A)) 
    if S <= K:
        r = m
    else:
        l = m
         
print(r)
### BUGGY CODE ###

n = int(input())
s = input()
m = 10**6
for i in range(n):
  m = min(m,s[:i].count("W")+s[i+1:].count("E"))
print(m)

### FIXED CODE ###

from itertools import accumulate
n = int(input())
s = input()
list_e = [0]*n
list_w = [0]*n
for i in range(n):
  if s[i]=="E":
    list_e[i]=1
for i in range(n):
  if s[i]=="W":
    list_w[i]=1
    
list_e = list(accumulate([0]+list_e))
list_w = list(accumulate([0]+list_w))
m = 10**7
for i in range(n):
  a = list_w[i]
  b = list_e[-1]-list_e[i+1]
  m = min(m,a+b)
print(m)
### BUGGY CODE ###

import numpy as np
h,n = map(int,input().split())
magic = np.zeros([n+1,2],int)
for i in range(n):
    a,b = map(int,input().split())
    magic[i][0] = a
    magic[i][1] = b
magic[n] = [0,0]
max_hit = max(magic[:,0])
dp = [[1e18,1e18]] * (h+max_hit)
dp[0] = [0,0]
for i in range(1,len(dp)):
    if dp[i - 1][0] >= i:
        dp[i] = dp[i - 1]
    else:
        for j in range(i):
            for k in range(n+1):
                if dp[i-j-1][1] + magic[k][1] < dp[i][1] and i <= dp[i-j-1][0] + magic[k][0]:
                    dp[i] = [dp[i-j-1][0] + magic[k][0], dp[i-j-1][1] + magic[k][1]]
dp_ans = dp[h::]
ans = 1e18
for i in range(len(dp_ans)):
    ans = min(ans,dp_ans[i][1])
print(ans)


### FIXED CODE ###

h,n = map(int,input().split())
dp = [int(1e18)] * (h+1)
dp[0] = 0
for i in range(n):
    a, b = map(int, input().split())
    for j in range(h):
        nj = min(j+a, h)
        dp[nj] = min(dp[nj], dp[j]+b)
print(dp[h])
### BUGGY CODE ###

from collections import deque
s=deque(input())
q=int(input())
for i in range(q):
  k=deque(input().split())
  if k[0]=='1':
    s.reverse()
  if k[0]=='2':
    if k[1]=='1':
      s.appendleft(k[2])
    if k[1]=='2':
      s.append(k[2])    
print("".join(list(s)))

### FIXED CODE ###

s=input()
q=int(input())
direction=1
#↑で1は右向き2は左向きに対応。
migi_matu=''
hidari_matu=''
#↑リストにしてしまうと後で文字sと連結できなくなる。
for i in range(q):
  k=input().split()
  #k[0] is Ti, k[1] is Fi, k[2] is character
  if k[0]=='1':
    direction*=(-1)
  if k[0]=='2':
    if k[1]=='1':
      if direction==1:
        hidari_matu+=k[2]
      if direction==-1:
        migi_matu+=k[2]
    else:
      if direction==1:
        migi_matu+=k[2]
      if direction==-1:
        hidari_matu+=k[2]
#  print('入力は',k,'とする。このとき')
#  print(i,'回目の操作後')
#  print(direction)
#  if direction==1:
#    print(hidari_matu[::-1]+s+migi_matu)
#  if direction==-1:
#    print(migi_matu[::-1]+s[::-1]+hidari_matu)
  
  
if direction==1:
  print(hidari_matu[::-1]+s+migi_matu)
if direction==-1:
  print(migi_matu[::-1]+s[::-1]+hidari_matu)
### BUGGY CODE ###

from itertools import combinations
def main():
    n=int(input())
    aa=list(map(int,input().split()))
    c=0
    for i,a in enumerate(aa):
        for j in range(i+a+1,n):
            if j-i==a+aa[j]:
                c+=1
    print(c)
main()

### FIXED CODE ###

def main():
    n=int(input())
    aa=list(map(int,input().split()))
    ll={}
    c=0
    for i,a in enumerate(aa,1):
        x=i-a
        if x in ll:
            c+=len(ll[x])
        y=i+a
        if y in ll:
            ll[y].append(i)
        else:
            ll[y]=[i]
    print(c)
main()
### BUGGY CODE ###

import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

b = []
for i in range(N):
  n = bisect.bisect_right(C, B[i])
  b.append(N-n)
  
ans = 0
for i in range(N):
  n = bisect.bisect_right(B, A[i])
  ans += sum(b[n:])
print(ans)

### FIXED CODE ###

import bisect
from collections import deque
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
B.sort()
C.sort()

d = deque([])
for i in range(N):
  n = bisect.bisect_right(C, B[N-1-i])
  if len(d) == 0:
    d.appendleft(N-n)
  else:
    d.appendleft(N-n+d[0])
  
ans = 0
for i in range(N):
  m = bisect.bisect_right(B, A[i])
  if m < N:
    ans += d[m]
print(ans)
### BUGGY CODE ###

# coding: utf-8
# Here your code !
import math
 
def is_prime_num(in_num):
    cnt = 0
    if in_num == 2:
        return True
    elif in_num <= 1:
        return False
    elif in_num % 2 == 0:
        return False
    else:
        if pow(2, in_num-1, in_num) == 1:
            max_num = int(math.sqrt(in_num)+1)
            for j in range(3, max_num, 2):
                if in_num % j == 0:
                    cnt = cnt + 1
                    break
                         
            if cnt == 0:
                #??´????°
                return True
            else:
               return False
        else:
            return False

while True:
    try:
        n = int(input())
        prime_cnt = 0
        if n >= 2:
            #?????????2???????????????
            prime_cnt = prime_cnt + 1

        for i in range(3, n+1, 2):
            if is_prime_num(i):
                prime_cnt = prime_cnt + 1
                 
 
        print(str(prime_cnt))
    except:
        break
    

### FIXED CODE ###

#init
max_num = 1000000
is_prime_num = [True for i in range (max_num+1)]

#0, 1 --- not prime number
is_prime_num[0] = False
is_prime_num[1] = False
end = int(max_num ** .5)

for i in range(2, end+1):
    if is_prime_num[i]:
        for j in range(i*i, max_num+1, i):
            is_prime_num[j] = False


while True:
    try:
        n = int(input())
        prime_cnt = 0
        for i in range(1, n+1):
            if is_prime_num[i]:
                prime_cnt = prime_cnt + 1
                   
   
        print(str(prime_cnt))
    except:
        break
### BUGGY CODE ###

import numpy as np
n = int(input())
a = np.array([int(i) for i in input().split(" ")])
c = np.arange(1, n)
ans = 0
for i in range(n):
    ans += np.sum(a[i+1:]+a[i] == c[:n-i-1])
print(ans)

### FIXED CODE ###

from collections import Counter
n = int(input())
a = [int(i) for i in input().split(" ")]
r = [i+1-j for i, j in enumerate(a)]
l = [j+i+1 for i, j in enumerate(a)]
nl = Counter(l)
nr = Counter(r)
 
ans = 0
for k, v in nl.items():
    ans += nr[k]*v
print(ans)
### BUGGY CODE ###

R, G, B, N = map(int, input().split())

cnt = 0

for i in range(N//R + 1) :
    for j in range(N//G + 1) :
        if N - R*i - G*j >= 0 :
            if (N - R*i - G*j) % B == 0:
                cnt += 1

print(cnt)


### FIXED CODE ###

R, G, B, N = map(int, input().split())

cnt = 0

for i in range(N//R + 1) :
    for j in range((N - R*i)//G + 1) :
        if (N - R*i - G*j) % B == 0:
            cnt += 1

print(cnt)
### BUGGY CODE ###

X, K, D = (int(x) for x in input().split())
min = abs(X)
count = 0
for _ in range(K):
    preX = X
    if abs(X+D) < abs(X-D):
        preX += D
    else:
        preX -= D

    if abs(X) <= abs(preX):
        break
    else:
        X = preX
        count += 1
rest = K - count
if rest%2 == 1:
    if abs(X+D) < abs(X-D):
        X += D
    else:
        X -= D
print(abs(X))


### FIXED CODE ###

X, K, D = (int(x) for x in input().split())
X = abs(X)
count = X // D
if K < count:
    count = K
X = abs(X) - D*count
rest = K - count
if rest%2 == 1:
        X -= D
print(abs(X))
### BUGGY CODE ###

import collections
n, k = map(int, input().split())
r,s,p = map(int, input().split())
t = input()

for j in range(k, len(t)):
    if t[j] == t[j-k]:
        t = list(t)
        t[j] = 'q'
        t = "".join(t)
ts = collections.Counter(t)
print(ts['p']*s + ts['s']*r + ts['r']*p)

### FIXED CODE ###

import collections
n, k = map(int, input().split())
r,s,p = map(int, input().split())
t = list(input())

for j in range(k, len(t)):
    if t[j] == t[j-k]:
        t[j] = ''
ts = collections.Counter(t)
print(ts['p']*s + ts['s']*r + ts['r']*p)
### BUGGY CODE ###

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

for i in range(m):
    s=a.index(max(a))
    a[s]=a[s]//2
print(sum(a))

### FIXED CODE ###

import heapq

n,m=map(int,input().split())
a=list(map(int,input().split()))
aa=list(map(lambda x:x*(-1),a))
heapq.heapify(aa)
for i in range(m):
    max=heapq.heappop(aa)
    heapq.heappush(aa,max//2+max%2)
print(-1*sum(aa))
### BUGGY CODE ###

n=int(input())
l=[]
for i in range(n):
    l.append(int(input()))
#print('l1',l)

for i in range(n):
    print(max(l[1:]))
    l.append(l[0])
    l.pop(0)
    #print('l2',l)



### FIXED CODE ###

n=int(input())
l=[]
import copy
h=[]
for i in range(n):
    l.append(int(input()))
l_max=max(l)
#print(l_max)
h=copy.copy(l)
h.sort()
l_second=h[-2]
#print(l_second)

for i in range(n):
    if l[i] != l_max:
        print(l_max)
    else:
        print(l_second)
### BUGGY CODE ###

N, *d = map(int, open(0).read().split())
m=d.index(max(d))
c=[max(d)] *N
  
for j in range(N):
    d[m]=0
    y=max(d)

c[m]=y
for i in range(len(c)):
    print(c[i])
 

### FIXED CODE ###

N, *d = map(int, open(0).read().split())
m=d.index(max(d))
c=[max(d)] *N
d[m]=0
y=max(d)
c[m]=y
for i in range(len(c)):
    print(c[i])
### BUGGY CODE ###

import numpy as np
import fractions
n=int(input())
a=list(map(int,input().split()))
a2=np.array(a.copy())
mod=10**9+7
def f(n,i):
  for j in range(i+1,n):
    c=fractions.gcd(a[i],a[j])
    a[j]//=c

for i in range(n):
  f(n,i)
m = 1
for i in a:
  m = m * i
b=(m//a2)%mod
ans=np.sum(b)%mod
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
mod=10**9+7

def eucrid(a,b):
  a,b=max(a,b),min(a,b)
  while True:
    if a%b==0:
      return b
    else:
      a,b=b,a%b
m=a[0]
for i in range(n):
  m=m//eucrid(m,a[i])*a[i]
b=0
m=m%mod
for i in a:
  b+=m*pow(i,mod-2,mod)%mod
print(b%mod)
### BUGGY CODE ###

import math
K = int(input())
ans = 0
for i in range(1, K + 1):
  for j in range(1, K + 1):
    for k in range(1, K + 1):
      ans += math.gcd(i, math.gcd(j, k))
print(ans)

### FIXED CODE ###

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)
import collections
K = int(input())
ans = 0
cnt = collections.defaultdict(int)
# count the number of combination of a, b
for a in range(1, K + 1):
  for b in range(1, K + 1):
    cnt[gcd(a, b)] += 1
for c in range(1, K + 1):
  for gcd_of_ab in cnt.keys():
    ans += gcd(gcd_of_ab, c) * cnt[gcd_of_ab]
print(ans)
### BUGGY CODE ###

n, q = map(int,input().split())
s = input()

for i in range(q):
    ans = 0
    l, r = map(int,input().split())
    ans = s[l-1:r].count("AC")
    print(ans)


### FIXED CODE ###

n, q = map(int,input().split())
s = input()
a =[0]*n
#print(s[0:])
for i in range(1,n):
    a[i]=a[i-1]
    if s[i]=="C" and s[i-1] =="A":
        a[i]+=1
for j in range(q):
    ans = 0
    l, r = map(int,input().split())
    ans = a[r-1]-a[l-1]
    print(ans)
### BUGGY CODE ###

import math
n = int(input())

for i in range(1, n + 1):
    ans = 0
    lim = int(math.sqrt(i))
    for x in range(1, lim):
        for y in range(x, lim):
            for z in range(y, lim):
                zzz = (x + y + z) ** 2 - x * y - y * z - x * z
                if zzz == i and i == 6:
                    ans += 1
                elif zzz == i:
                    ans += 3
    print(ans)


### FIXED CODE ###

n = int(input())
ans = [0] * 10050

for x in range(1, 105):
    for y in range(1, 105):
        for z in range(1, 105):
            zzz = (x + y + z) ** 2 - x * y - y * z - x * z
            if zzz < 10050:
                ans[zzz] += 1

for i in range(n):
    print(ans[i+1])
### BUGGY CODE ###

N, M = map(int, input().split())
price = list(map(int, input().split()))
price.sort(reverse=True)
for i in range(M):
  price[0] = int(price[0] / 2)
  price.sort(reverse=True)
print(sum(price))

### FIXED CODE ###

from heapq import heappop, heappush

N, M = map(int, input().split())
price = list(map(int, input().split()))
he = []
for i in price:
  heappush(he, -i)
for i in range(M):
  max = heappop(he)
  heappush(he, -(-max//2))
print(-sum(he))