Harryxun/stf_run huggingface dataset:
import sys
input = sys.stdin.readline

n, X, Y = [int(x) for x in input().split()]

ans = [0] * (n) # 1 ~ n - 1

g = [x for x in range(1, n + 1)]
g_2 = [x for x in range(1, n + 1)]
g_2[Y - 1] = X + 1
for i in range(Y, n):
    if i < n:
        g_2[i] -= (Y - X - 1)
# print(g)
# print(g_2)

for i in range(X):
    for j in range(i + 1, n):
        # print(g_2[j], g[i])
        b = min(g_2[j] - g[i], g[X - 1] - g[i] + g_2[Y - 1] - g[X - 1] + abs(g[Y - 1] - g[j]))
        ans[b] += 1

for i in range(X, n):
    for j in range(i + 1, n):
        # print(g[j], g[i])
        a = min(g[j] - g[i], g[i] - 2 * g[X - 1] + g_2[j])
        ans[a] += 1

for i in ans[1:]:
    print(i)


### FIXED CODE ###

import sys
input = sys.stdin.readline

s = input().rstrip()

if s[2] == s[3] and s[4] == s[5]:
    print("Yes")
else:
    print("No")
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from itertools import groupby
def resolve():
    n, k, q = map(int, input().split())
    A = list(map(int, input().split()))
    B = sorted(A)

    ans = INF
    for i, m in enumerate(B):
        score = 0
        for key, it in groupby([a >= m for a in A]):
            if key is False:
                continue
            l = sum(1 for _ in it)
            score += max(0, l - k + 1)

        if score >= q:
            ans = min(ans, B[i + q - 1] - m)

    print(ans)
resolve()

### FIXED CODE ###

import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
from itertools import groupby
from heapq import heappop, heappush, heapify
def resolve():
    n, k, q = map(int, input().split())
    A = list(map(int, input().split()))

    ans = INF
    for m in sorted(A):
        C = []
        for key, it in groupby(A, key = lambda a : a >= m):
            if key is False:
                continue
            D = list(it)
            if len(D) >= k:
                D.sort()
                C.append(D[:len(D) - k + 1][::-1])

        if sum(len(a) for a in C) < q:
            continue
        heap = [(C[i].pop(), i) for i in range(len(C))]
        heapify(heap)
        for _ in range(q):
            M, i = heappop(heap)
            if C[i]:
                heappush(heap, (C[i].pop(), i))
        ans = min(ans, M - m)

    print(ans)
resolve()
D, G, *pc = map(int, open(0).read().split())
pc = list(zip(*[iter(pc)]*2))

total_points = []
for i in range(D):
    total_points.append(pc[i][0] * (i+1) * 100 + pc[i][1])
    
ans_list = [i[0] for i, x in zip(pc, total_points) if x >= G]

import math

achieved = False
remained = G
highest_p = D

ans_other = 0

while not achieved:
    if math.ceil(remained / (highest_p * 100)) <= pc[highest_p - 1][0]:
        ans_other += math.ceil(remained / (highest_p * 100))
        achieved = True
    else:
        ans_other += pc[highest_p - 1][0]
        remained -= (highest_p * 100 * pc[highest_p - 1][0] + pc[highest_p - 1][1])
        highest_p -= 1
        
ans_list.append(ans_other)

print(min(ans_list))

### FIXED CODE ###

import numpy as np

D, G, *pc = map(int, open(0).read().split())
pc = list(zip(*[iter(pc)]*2))
p, c = np.array([]), np.array([])
for (x,y) in pc:
    p = np.append(p, x)
    c = np.append(c, y)
    
import numpy as np
import math

base_points = np.array([i*100 for i in range(1, D+1)])

ans = []

for i in range(2**D):
    bit_flag = np.array(list(map(int, format(i, '0%db' %D))))
    points = sum(bit_flag * (c + p*base_points))
    solved_num = sum(bit_flag * p)
    
    if points >= G:
        ans.append(solved_num)

    else:
        remained = G - points
        remained_problems = sorted((bit_flag==False) * np.array(range(1, D+1)), reverse=True)
        i = 0

        while True:
            if remained <= 0:
                break
                
            highest_p = remained_problems[i]

            if math.ceil(remained / (highest_p * 100)) <= p[highest_p - 1]:
                solved_num += math.ceil(remained / (highest_p * 100))
                remained -= (math.ceil(remained / (highest_p * 100)) * highest_p * 100)
            else:
                solved_num += p[highest_p - 1]
                remained -= (highest_p * 100 * p[highest_p - 1] + c[highest_p - 1])
                i += 1

        ans.append(solved_num)
        
print(int(min(ans)))
import sys
input = sys.stdin.readline
h,w,m = map(int,input().rstrip().split())
hw = [list(map(int,input().rstrip().split()))for _ in range(m)]

tate = [0]*(h+1)
yoko = [0]*(w+1)
bombpoint = set()

for x,y in hw:
    tate[x] += 1
    yoko[y] += 1
    bombpoint.add((x,y))

ans_x = []
ans_y = []
x_max = max(tate)
y_max = max(yoko)
for i in range(len(tate)):
    if tate[i] == x_max:
        ans_x.append(i)
for i in range(len(yoko)):
    if yoko[i] == y_max:
        ans_y.append(i)

ans = x_max + y_max
for x in ans_x:
    for y in ans_y:
        if (x,y) not in bombpoint:
            print(ans)
            exit()
print(ans - 1)


### FIXED CODE ###

N, X, T = (int(x) for x in input().split() )

a = int(N/X)

if N % X != 0:
    t = (a + 1)* T
else:
    t = a * T

print(t)
import sys
input = sys.stdin.readline

import numpy as np

def main():
    #1:初期化
    N,W = map(int,input().split())
    wv = []
    for _ in range(N):
        wv.append(list(map(int,input().split())))
    #dp = np.zeros((N+1,W+1), dtype=np.int64)
    dp = [[0]*(W+1) for i in range(N+1)]

    #print(dp)
    #print(dp2)
    #2:初期値(元からゼロなので記述無し)

    #3:dp実行部(貰うDP)
    for i in range(1,N+1):
        for j in range(1,W+1):
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-wv[i-1][0]]+wv[i-1][1])
            #print(i,j)
            #print(*dp,sep="\n")

    #4:出力
    print(dp[N][W])

if __name__ == '__main__':
    main()

### FIXED CODE ###

"""memo
    numpyでやるときは配列を一気に更新するが(numpy使いたくないのでやらない)，
    このやり方は後ろの方から更新することで後の更新に影響を与えない(考え方すごい)．
    (参考#9889377)
"""

import sys
input = sys.stdin.readline

def main():
    #1:初期化
    N,W = map(int,input().split())
    dp = [0]*(W+1)

    #2:初期値(元からゼロなので記述無し)

    #3:dp実行部(貰うDP)
    for i in range(N):
        w, v = map(int,input().split())
        for i in range(W, w-1, -1):
            tmp = dp[i-w] + v
            if dp[i] < tmp:
                dp[i] = tmp
        #print(dp,sep="\n")

    #4:出力
    print(max(dp))

if __name__ == '__main__':
    main()
,m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]
for i in range(1001):
    if m == 0 and n == 1:
        print(0)
        break
    elif m==0:
        print("1"*n)
        break

    for j,k in sc:
        if len(str(i)) < j or len(str(i)) != n:
            break
        elif  int(str(i)[j-1]) != k:
            break

    else:
        print(i)
        break
else:
    print(-1)

### FIXED CODE ###

n,m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]
for i in range(1000):
    num = str(i)
    if len(num) == n and all(num[s-1]==str(c) for s,c in sc):
        print(i)
        break
else:
    print(-1)
if X == int(X):
        if 1<= X <= 179:
            K = 360/X
            if int(K) < K :
                K = int(int(K) - 1)
                print(K)
            else:
                K = int(K)
                print(K)

### FIXED CODE ###

import math

if __name__ == "__main__":
    deg = int(input())
    print(360//math.gcd(deg, 360))
N, K = map(int, input().split())
S = input()
L = [0]
prev = S[0]
num = 1
for s in S[1:]:
    if s == prev:
        num += 1
    else:
        L.append(num)
        num = 1
        prev = s
L.append(num)
# print(L)
for i in range(1, len(L)):
    L[i] += L[i - 1]
# print(L)
left = 0
if S[0] == "1":
    right = min(2 * K + 1, len(L) - 1)
else:
    right = min(2 * K, len(L) - 1)
num = 0
while right < len(L):
    # print("L[" + str(right) + "] - L[" + str(left) + "] = " + str(L[right] - L[left]))
    num = max(num, L[right] - L[left])
    if left == 0 and S[0] == "0":
        left += 1
    else:
        left += 2
    right += 2
if S[-1] == "0" and len(S) > 1:
    right -= 1
    # print("L[" + str(right) + "] - L[" + str(left) + "] = " + str(L[right] - L[left]))
    num = max(num, L[right] - L[left])
print(num)


### FIXED CODE ###

N, K = map(int, input().split())
S = input()
if S == "0":
    print(1)
    exit()
if S.count("0") == N:
    print(N)
    exit()
L = [0]
prev = S[0]
num = 1
for s in S[1:]:
    if s == prev:
        num += 1
    else:
        L.append(num)
        num = 1
        prev = s
L.append(num)
# print(L)
for i in range(1, len(L)):
    L[i] += L[i - 1]
# print(L)
left = 0
if S[0] == "1":
    right = min(2 * K + 1, len(L) - 1)
else:
    right = min(2 * K, len(L) - 1)
num = 0
while right < len(L):
    # print("L[" + str(right) + "] - L[" + str(left) + "] = " + str(L[right] - L[left]))
    num = max(num, L[right] - L[left])
    if left == 0 and S[0] == "0":
        left += 1
    else:
        left += 2
    right += 2
if S[-1] == "0":
    right -= 1
    # print("L[" + str(right) + "] - L[" + str(left) + "] = " + str(L[right] - L[left]))
    num = max(num, L[right] - L[left])
print(num)
#coding: utf-8

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

for i in range(K):
    if(A[i] == 1):
        one = i
        #print('1は',one + 1,'番目')

ans = []

for i in range(K):
    start = one - (K - 1) + i
    end = one + i
    
    before = start
    after = N - (end+1)
    
    before_num = before//(K-1)
    if(before%(K-1) != 0):
        before_num += 1
        
    after_num = after//(K-1)
    if(after%(K-1) != 0):
        after_num += 1
    
    answer = before_num + after_num + 1
    ans.append(answer)

print(min(ans))

### FIXED CODE ###

#coding: utf-8

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

for i in range(N):
    if(A[i] == 1):
        one = i
        #print('1は',one + 1,'番目')

ans = []

for i in range(K):
    start = one - (K - 1) + i
    end = one + i

    before = start
    after = N - (end+1)

    before_num = before//(K-1)
    if(before%(K-1) != 0):
        before_num += 1

    after_num = after//(K-1)
    if(after%(K-1) != 0):
        after_num += 1

    answer = before_num + after_num + 1
    ans.append(answer)

print(min(ans))
n = int(input())
red = []
for i in range(n):
    a, b = map(int, input().split())
    red.append((a, b))
 
blue = []
for i in range(n):
    c, d = map(int, input().split())
    blue.append((c, d))
 
red = sorted(red, key=lambda x: x[1])
blue.sort()
 
count = 0
while len(blue) >= 1:
    c, d = blue.pop()
    tmp = []
    r = []
    while len(red) >= 1:
        a, b = red.pop(0)
        if a < c and b < d:
            r.append((a, b))
        else:
            tmp.append((a, b))
    if len(r) >= 1:
        count += 1
        r = sorted(r, key=lambda x:x[1])
        r.pop()
        tmp.extend(r)
    red.extend(tmp)
print(count)

### FIXED CODE ###

A, B, C = map(int, input().split())

if A + B >= C:
    print("Yes")
else:
    print("No")
N=input()

n=list(reversed(N))

if n[0]=="2" or n[0]=="4" or n[0]=="5" or n[0]=="7" or n[0]=="9":
    print(hon)
if n[0]=="0" or n[0]=="1" or n[0]=="6" or n[0]=="8":
    print(pon)
if n[0]=="3":
    print(bon)

### FIXED CODE ###

n=list(input())

n==n.reverse()

if (n[0]=="2" or n[0]=="4" or n[0]=="5" or n[0]=="7" or n[0]=="9"):
    print("hon")
elif (n[0]=="0" or n[0]=="1" or n[0]=="6" or n[0]=="8"):
    print("pon")
elif (n[0]=="3"):
    print("bon")
num = int(input())
if(num%2==0):
  print(0.5)
else:
  print(((n+1)/2)/n)
  

### FIXED CODE ###

num = int(input())
if(num%2==0):
  print(0.5)
else:
  print(((num+1)/2)/num)
import numpy as np


def resolve():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))

    A = np.zeros((N, N), int)
    for i in range(M):
        pp, ss = map(int, input().split())
        ss -= 1
        pp -= 1
        A[pp][ss] = H[ss]
        A[ss][pp] = H[pp]

    ans = 0
    for j in range(N):
        if (A[j].max() == 0 or H[j] > A[j].max()):
            ans += 1

    print(ans)


resolve()

### FIXED CODE ###

def resolve():
    n, m = map(int, input().split())
    hhh = list(map(int, input().split()))
    nice = [1] * n

    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        ha = hhh[a]
        hb = hhh[b]
        if ha <= hb:
            nice[a] = False
        if ha >= hb:
            nice[b] = False

    print(sum(nice))


resolve()
n,m = map(int,input().split())
if m == 0:
    print(0, 0)
else:
    p = [0] * m
    s = [0] * m
    for i in range(m):
        p[i], s[i] = map(str, input().split())
    for i in range(m):
        p[i] = int(p[i])
    p.append(int(ie9))

    probcnt = p[0]
    ACval = False
    ACcnt = 0
    wa = 0
    pena = 0
    for i in range(m):
        if probcnt == p[i]:
            if ACval == False:
                if s[i] == 'WA':
                    wa += 1
                    if p[i] !=p[i+1]:
                        wa = 0
                else:
                    ACval = True
                    ACcnt += 1
                    pena += wa
                    wa = 0

        else:
            ACval = False
            probcnt = p[i]
            if ACval == False:
                if s[i] == 'WA':
                    wa += 1
                    if p[i] !=p[i+1]:
                        wa = 0
                else:
                    ACval = True
                    ACcnt += 1
                    pena += wa


    print(ACcnt, pena)

### FIXED CODE ###

n, m = map(int,input().split())
p = [0] * m
s = [0] * m
for i in range(m):
    p[i], s[i] = map(str, input().split())
for i in range(m):
    p[i] = int(p[i])

ans1 = 0
ans2 = 0

aclis = [0] * (n+1)
walis = [0] * (n+1)


for i in range(m):
    if s[i] == 'AC':
        aclis[p[i]] = 1



    elif aclis[p[i]] == 0 and s[i] == 'WA':
        walis[p[i]] += 1
ans1 = aclis.count(1)
#print(aclis)
#print(walis)

for i in range(n+1):
    if aclis[i] == 1:
        ans2 += walis[i]


print(ans1, ans2)
D, G = map(int, input().split())
pc = [[i + 1] + [int(x) for x in input().split()] for i in range(D)]

import math, functools
def f(cur, n, left):
    if left <= 0:
        return n
    def g(cur, n, left):
        if cur in m: return m[cur]
        r = m[cur] = f(cur, n, left)
        return r
    ret = 10**9
    for x in pc:
        i, p, c = x
        if (1 << i) & cur: continue
        ip = i*100*p
        if ip > left:
            h = math.ceil(left / (i*100))
            ret = min(ret, n + h)
        else:
            if n + p >= ret: continue
            h = g(cur | (1 << i), n + p, left - ip - c)
            ret = min(ret, h)
    return ret

print(f(0, 0, G))

### FIXED CODE ###

D, G = map(int, input().split())
pc = [[i + 1] + [int(x) for x in input().split()] for i in range(D)]

import math
m = {}
def f(cur, n, left):
    if left <= 0:
        return n
    def g(cur, n, left):
        if cur in m: return m[cur]
        r = m[cur] = f(cur, n, left)
        return r
    ret = 10**9
    for x in pc:
        i, p, c = x
        if (1 << i) & cur: continue
        ip = i*100*p
        if ip > left:
            h = math.ceil(left / (i*100))
            ret = min(ret, n + h)
        else:
            if n + p >= ret: continue
            h = g(cur | (1 << i), n + p, left - ip - c)
            ret = min(ret, h)
    return ret

print(f(0, 0, G))
# 深さ優先探索で各直線を考える
def dfs(parent):
    for child in tree[parent]:
        # 累積和の計算
        ans[child] = operate[child] + ans[parent]
        dfs(child)


n, q = map(int, input().split())
# tree[i]: 頂点i+1の子どもたち
tree = [[] for i in range(n)]
# 操作を行う際に根として指定する頂点と加算する値を保持
# ex. 出力例1において、2 を根とする部分木に 100 加算する場合は
# operate = [0, 100, 0, 0] とする
operate = [0] * n
ans = [0] * n

for _ in range(0, n - 1):
    a, b = map(int, input().split())
    tree[a - 1].append(b - 1)

for _ in range(q):
    p, x = map(int, input().split())
    operate[p - 1] += x

# 累積和の初期値を設定
ans[0] = operate[0]
# 根ノードの頂点1から開始
dfs(0)

print(*ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
# 深さ優先探索で各直線を考える


def main():
    def dfs(v, p):
        for u in tree[v]:
            if u == p:
                continue
            # 累積和の計算
            ans[u] += ans[v]
            dfs(u, v)

    n, q = map(int, input().split())
    # tree[i]: 頂点i+1の子どもたち
    tree = [[] for i in range(n)]
    ans = [0] * n

    for _ in range(0, n - 1):
        a, b = map(int, input().split())
        tree[a - 1].append(b - 1)
        tree[b - 1].append(a - 1)

    for _ in range(q):
        p, x = map(int, input().split())
        ans[p - 1] += x

    # 根ノードの頂点 1 から開始
    dfs(0, -1)

    print(*ans)


if __name__ == '__main__':
    main()
s=input()

if (S=ABC):
    print('ARC')
else:
    print('ABC')

### FIXED CODE ###

s=input()

if (s=='ABC'):
    print('ARC')
else:
    print('ABC')
N,D = map(int,input().split())
 
for _ in range(N):
  count=0
  p,q=map(int,input().split())
  if (p**2 + q**2)**0.5 <=D:
    count+=1
print(count)


### FIXED CODE ###

X=int(input())

if X>=30:
  print("Yes")
else:
  print("No")
# -*- coding: utf-8 -*-
a = int(input())
if l <=9:
  print("{}".format(a));
  return
if l <=99:
  print('9')
  return;
if l < 999:
  print("{}".format(9+a-99))
  return
if l <= 9999:
  print('909')
  return
print("{}".format(909+a-9999))

### FIXED CODE ###

a = int(input())
if a <10:
  print("{}".format(a))
elif a <100:
  print("9")
elif a < 1000:
  print("{}".format(9+a-99))
elif a < 10000:
  print('909')
elif a < 100000:
  print("{}".format(909+a-9999))
else:
  print('90909')
x,y,z=[int(i) for i in input().split()]
S=list(range(x,y+1))

if x<z:
    for j in range(0,min(z-x,y-x+1)):
        print(S[j])
if z<y:
    for j in range(max(z-x+1,x),y-x+1):
        print(S[j])

### FIXED CODE ###

A, B, K = map(int, input().split())
l = []

for i in range(A, min(B, A+K)):
  l.append(i)
for i in range(max(A, B-K+1), B+1):
  l.append(i)

l = list(set(l))
l.sort()
for i in l:
  print(i)
import math

def calcAns(n,x,y):
    return n - ((n//x) + (n//y) - (n//((x*y)//math.gcd(x,y))))

a,b,c,d = map(int, input().split())
ansB = calcAns(b,c,d)
ansA = calcAns(a-1,c,d)
print(ansB-ansA)

### FIXED CODE ###

from fractions import gcd

def calcAns(n,x,y):
    return n - ((n//x) + (n//y) - (n//((x*y)//gcd(x,y))))

a,b,c,d = map(int, input().split())
ansB = calcAns(b,c,d)
ansA = calcAns(a-1,c,d)
print(ansB-ansA)
import copy

N = int(input())

Height = []
tmp = []
for i in range(N):
    x, y, h = map(int, input().split())
    if i == 0:
        for c_x in range(0, 101):
            for c_y in range(0, 101):
                H = h + abs(x-c_x) + abs(y-c_y)
                d = (c_x, c_y, H)
                Height.append(d)
    else:
        for c_x in range(0, 101):
            for c_y in range(0, 101):
                H = h + abs(x-c_x) + abs(y-c_y)
                d = (c_x, c_y, H)
                if d in Height:
                    if d not in tmp:
                        tmp.append(d)
        if i == N-1:
            Height.clear()
            break
        else:
            Height = copy.deepcopy(tmp)
            tmp.clear()

tmp[0] = [str(i) for i in tmp[0]]

print(' '.join(tmp[0]))


### FIXED CODE ###

import sys

N = int(input())
H = [list(map(int, input().split())) for i in range(N)]

H.sort(key=lambda x: x[2], reverse=True)

for i in H:
    x, y, h = i
    for c_x in range(101):
        for c_y in range(101):
            Height = h + abs(x-c_x) + abs(y-c_y)
            for j in range(N):
                if H[j][2] != max(Height-abs(H[j][0]-c_x)-abs(H[j][1]-c_y), 0):
                    break
                if j == N-1:
                    print(c_x, c_y, Height)
                    sys.exit()
MAX_INT = 10**6
N, M = map(int, input().split())
room = dict()
for i in range(1, N+1):
    room[i] = set()
for i in range(M):
    a, b = map(int, input().split())
    room[a].add(b)
    room[b].add(a)

dis = [MAX_INT] * (N + 1)
sign = [-1] * (N + 1)
dis[1] = 0
def sign_root(n):
    
    for i in room[n]:
        if dis[n] + 1 < dis[i]:
            sign[i] = n
            dis[i] = dis[n] + 1
            sign_root(i)
sign_root(1)
if MAX_INT in dis[2:]:
    print("No")
else:
    print("Yes")
    for i in sign[2:]:
        print(i)

### FIXED CODE ###

MAX_INT = 10**6
N, M = map(int, input().split())
room = [set() for _ in range(N+1)]
for i in range(M):
    a, b = map(int, input().split())
    room[a].add(b)
    room[b].add(a)

dis = [MAX_INT] * (N + 1)
sign = [-1] * (N + 1)
dis[1] = 0
def sign_root(n):
    nxt = []
    for i in room[n]:
        if dis[n] + 1 < dis[i]:
            sign[i] = n
            dis[i] = dis[n] + 1
            nxt += [i]
    return nxt

nxt = sign_root(1)
while nxt != []:
    for i in nxt.copy():
        nxt.pop(0)
        nxt += sign_root(i)
if MAX_INT in dis[2:]:
    print("No")
else:
    print("Yes")
    for i in sign[2:]:
        print(i)
A, B = map(int, raw_input().split())
print "GREATER" if A>B else ("LESS" if A<B else "EQUAL")

### FIXED CODE ###

A = int(raw_input())
B = int(raw_input())
print "GREATER" if A>B else ("LESS" if A<B else "EQUAL")
N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]
change = [0 for i in range(N)]

ans = -1
for i in range(10 ** 3):
  flag = True
  for j in range(M):
    if str(i)[q[i][0] - 1] != q[i][1]:
      flag = False
      
  if flag:
    ans = i
    break
    
print(ans)

### FIXED CODE ###

N, M = map(int, input().split())
q = [list(map(int, input().split())) for i in range(M)]

ans = -1
if N == 1:
  s = 0
else:
  s = 10 ** (N - 1)
for i in range(s, 10 ** N + 1):

  flag = True
  for j in range(M):
    try:
      if str(i)[q[j][0] - 1] != str(q[j][1]):
        flag = False
    except:
      flag = False
      break
      
  if flag:
    ans = i
    break
    
print(ans)
S = int(h = (S / 3600), m = (S % 3600 / 60), for S in range(0, 60) input())
print('S')

### FIXED CODE ###

S = int(input())

s = S % 60
m = S // 60 % 60
h = S // 60 // 60

print("{0}:{1}:{2}".format(h,m,s))
a,b=map(int, input().split())
if a > b: print("a > b")
elif a<b: print("a < b")
else print("a == b")

### FIXED CODE ###

a,b=map(int, input().split())
if a > b: print("a > b")
elif a<b: print("a < b")
else: print("a == b")
nums =intpi().split()
s = int(nume[0))
b = int(nums[1])

if a < b:
 print(a)

elif a > b:
 print("a < b")

eles:
 print('a == b')

### FIXED CODE ###

nums = input().split()
a = int(nums[0])
b = int(nums[1])
if a < b:
     print('a < b')
elif a > b:
     print('a > b')
else:
     print('a == b')
s = input();
l = len(s)
zero=0,one=0
for i in s:
	if i=='0': zero+=1
	else one+=1
print(min(zero, one))

### FIXED CODE ###

s=input();
l=len(s)
zero,one=0,0
for i in s:
	if i=='0': zero+=1
	else: one+=1
print(min(zero, one)*2)
import sys
n = int(input())

for _ in range(3):
    if n % 10 == 7:
        print('Yes')
        sys.exit(1)
    n = n // 10
print('No')

### FIXED CODE ###

import sys
n = int(input())

for _ in range(3):
    if n % 10 == 7:
        print('Yes')
        sys.exit(0)
    n = n // 10
print('No')
N = int(input())
A_list = list(map(int,input().split()))
A_list.sort(reverse = True)
indx_list = []
for i in range(1,100000,2):
    indx_list.append(i)
insx_list = []
for j in range(0,18):
    insx_list.extend(indx_list[:2 ** j])
mx_cmfrt = 0
reached_list = [A_list[0],A_list[0]]
for j in range(1, len(A_list)):
    cmfrt = min(reached_list[insx_list[j-1]-1],reached_list[insx_list[j-1]])
    reached_list.insert(insx_list[j-1], A_list[j])
    mx_cmfrt += cmfrt
print(mx_cmfrt)

### FIXED CODE ###

import math
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse = True)
score = A[0]
for i in range(1, math.ceil(N*0.5)):
    if N - i * 2 != 1:
        score += 2 * A[i]
    else:
        score += A[i]
print(score)