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

d_c = list()
for i in range(-2, 3):
    for j in range(-2, 3):
        if (i,j) == (0,0):
            continue
        elif (i,j) in [(-1,0),(0,-1),(1,0),(0,1)]:
            d_c += [(i,j,0)]   # 歩くコスト
        else:
            d_c += [(i,j,1)]   # 魔法コスト

h, w = list(map(int, input().split()))
si, sj = list(map(int, input().split()))
ti, tj = list(map(int, input().split()))
s = [None] * h
for i in range(h):
    s[i] = input()

# 距離情報を一番遠い値で初期化
#import numpy as np
INF = int(1e9)
#dist = np.full((h+4, w+4), INF)
dist = [[INF for j in range(w+4)] for i in range(h+4)]

# マップ境界を壁で囲む
S = ['##{}##'.format(s_row) for s_row in s]
S = ['##{}##'.format('#' * (w+4))]*2 + S
S = S + ['##{}##'.format('#' * (w+4))]*2

# 01-BFS探索用キュー
from collections import deque
q = deque()

# 開始位置、終了位置を調整
si, sj = si+1, sj+1
ti, tj = ti+1, tj+1
dist[si][sj] = 0
q.append((si,sj))

while (len(q)>0):
    i, j = q[0]
    d = dist[i][j]
    q.popleft()
    for di, dj, c in d_c:
        ni, nj = di+i, dj+j
        if (S[ni][nj]=='#'):
            continue # 壁
        if (dist[ni][nj]<=d):
            continue # 探索済みコスト以上
        dist[ni][nj] = d+c
        if c == 0:
            q.appendleft((ni,nj))
        else:
            q.append((ni,nj))

ans = dist[ti][tj]
if ans == INF:
    ans = -1
print(ans)


### FIXED CODE ###

h, w = list(map(int, input().split()))
si, sj = list(map(int, input().split()))
ti, tj = list(map(int, input().split()))
s = [None] * h
for i in range(h):
    s[i] = input()

# 移動Aで探索する方向
d_a = [(-1,0), (0,-1),(1,0),(0,1)]
# 移動Bで探索する方向
d_b = [ (i, j) for j in range(-2, 3) for i in range(-2, 3)]

# 距離情報を一番遠い値で初期化
#import numpy as np
INF = int(1e9)
#dist = np.full((h+2, w+2), INF)
dist = [[INF for j in range(w+2)] for i in range(h+2)]

# マップ境界と壁を距離0にして探索させない
for i in range(h+2):
    dist[i][0] = 0
    dist[i][-1] = 0
for j in range(w+2):
    dist[0][j] = 0
    dist[-1][j] = 0
for i in range(h):
    for j in range(w):
        if s[i][j]=='#': dist[i+1][j+1] = 0
#dist = [[INF for j in range(w)] for i in range(h)]

# 01-BFS探索用キュー
from collections import deque
q = deque()

# 開始位置
dist[si][sj] = 0
q.append((si,sj))

while (len(q)>0):
    i, j = q[0]
    d = dist[i][j]
    q.popleft()
    # 移動Aによるコスト
    for v in range(len(d_a)):
        di, dj = d_a[v][0]+i, d_a[v][1]+j
        if (di, dj) == (ti, tj):
            print(d)
            exit(0)
        if (dist[di][dj]<=d):
            continue # 探索済みコスト以上
        dist[di][dj] = d
        q.appendleft((di, dj))
    # 移動Bによるコスト
    for v in range(len(d_b)):
        # マップ境界で2以上移動したときに、反対の境界に向かうように剰余を取る
        di, dj = (d_b[v][0]+i)%(h+2), (d_b[v][1]+j)%(w+2)
        if (dist[di][dj]<=d):
            continue # 探索済みコスト以上
        dist[di][dj] = d+1
        q.append((di, dj))

ans = dist[ti][tj]
if ans == INF:
    ans = -1
print(ans)
### BUGGY CODE ###

import itertools
n = int(input())
ans = [0] * n
for x,y,z in itertools.combinations_with_replacement(list(range(1,n+1)),3):
    a = x**2 + y**2 + z**2 + x*y + y*z + z*x
    if a > n: continue
    if x==y==z: b = 1
    elif x==y or x==z or y==z: b = 3
    else: b = 6
    ans[a-1] = b
for i in ans: print(i)

### FIXED CODE ###

n = int(input())
ans = [0] * n
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            a = x * x + y * y + z * z + x * y + x * z + y * z
            if a > n: continue
            ans[a-1] += 1
for i in ans: print(i)
### BUGGY CODE ###

import sys
a,b = map(int,input().split())
if a > 0:
    print('Positive')
    sys.exit()
if b >= 0:
    print('Zero')
    sys.exit()
minus_count = 0
for i in range(a,b+1):
    if i < 0:
        minus_count += 1
if minus_count%2 == 1:
    print('Negative')
else:
    print('Positive')

### FIXED CODE ###

import sys
a,b = map(int,input().split())
if a > 0:
    print('Positive')
    sys.exit()
if b >= 0:
    print('Zero')
    sys.exit()
if (b-a+1)%2 == 1:
    print('Negative')
else:
    print('Positive')
### BUGGY CODE ###

exec("def nWord(): nWord.cache = raw_input() if not hasattr(nWord, 'cache') or nWord.cache=='' else nWord.cache ; pos = nWord.cache.find(nWord.sep) ; ret, nWord.cache = (nWord.cache, '') if pos==-1 else (nWord.cache[:pos], nWord.cache[pos+1:].lstrip(nWord.sep)) ; return ret") ; exec("nWord.sep = ' '") ; exec("def ___nLine2(): ret, nWord.cache = (raw_input(), nWord.cache if hasattr(nWord, 'cache') else '') if not hasattr(nWord, 'cache') or nWord.cache=='' else (nWord.cache, '') ; return ret") ; exec('def nInt(): return int(nWord())') ; exec('def nFloat(): return float(nWord())') ; exec("def ___nAuto2():\n ret = nWord()\n try: return int(ret)\n except: pass\n try: return float(ret)\n except: return ret") ; exec("def nAuto(n=None): return ___nAuto2() if n is None else [___nAuto2() for i in range(n)]") ; exec("def nLine(n=None): return ___nLine2() if n is None else [___nLine2() for i in range(n)]")

N = nAuto()
S = nAuto(N)

D = {}
for  i in range(N):
    for j in range(N):
        c = S[i][j]
        if c in D:
            D[c] += 1
        else:
            D[c] = 1

max_c = 'a'
max_count = 0
for c in D:
    if max_count < D[c]:
        max_count = D[c]
        max_c = c

L = []
for  i in range(N):
    for j in range(N):
        c = S[i][j]
        if c!=max_c:
            L.append((i, j, c))

def check(A, B):
    for i2, j2, c in L:
        i = (i2-A+N) % N
        j = (j2-B+N) % N
        if c!=S[(A+j) % N][(B+i) % N]:
            return 0
    return 1

count = 0
for A in range(N):
    for B in range(N):
        count += check(A, B)
print count


### FIXED CODE ###

exec("def nWord(): nWord.cache = raw_input() if not hasattr(nWord, 'cache') or nWord.cache=='' else nWord.cache ; pos = nWord.cache.find(nWord.sep) ; ret, nWord.cache = (nWord.cache, '') if pos==-1 else (nWord.cache[:pos], nWord.cache[pos+1:].lstrip(nWord.sep)) ; return ret") ; exec("nWord.sep = ' '") ; exec("def ___nLine2(): ret, nWord.cache = (raw_input(), nWord.cache if hasattr(nWord, 'cache') else '') if not hasattr(nWord, 'cache') or nWord.cache=='' else (nWord.cache, '') ; return ret") ; exec('def nInt(): return int(nWord())') ; exec('def nFloat(): return float(nWord())') ; exec("def ___nAuto2():\n ret = nWord()\n try: return int(ret)\n except: pass\n try: return float(ret)\n except: return ret") ; exec("def nAuto(n=None): return ___nAuto2() if n is None else [___nAuto2() for i in range(n)]") ; exec("def nLine(n=None): return ___nLine2() if n is None else [___nLine2() for i in range(n)]")
 
N = nAuto()
S = nAuto(N)
 
def check(A):
    for i in range(N):
        for j in range(N):
            if S[(A+i) % N][j]!=S[(A+j) % N][i]:
                return 0
    return N
 
count = 0
for A in range(N):
    count += check(A)
print count
### BUGGY CODE ###

import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *

mod = 10**9+7
def rec(k, m):
    if k == N:
        return m == 5
    if memo[k][m] != -1:
        return memo[k][m]
    res = 0
    d = D[N-k-1]
    if S[k] != '?':
        res += rec(k+1, (m+int(S[k])*d)%13)
    else:
        for i in range(10):
            res += rec(k+1, (m+i*d)%13)
    res %= mod
    memo[k][m] = res
    return res

S = input()
N = len(S)
D = [None] * N
t = 1
for i in range(N):
    D[i] = t % 13
    t = t * 10 % 13
memo = [[-1] * 13 for i in range(N+1)]
# for k in range(N):
#     if S[k] != '?':
#         dp[]
#         for  in range(0, 1):
print(rec(0, 0))


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *

mod = 10**9+7
S = input()
N = len(S)
D = [None] * N
t = 1
for i in range(N):
    D[i] = t % 13
    t = t * 10 % 13
dp = [[0] * 13 for i in range(N+1)]
if S[N-1] != '?':
    dp[N-1][int(S[N-1])] = 1
else:
    for i in range(10):
        dp[N-1][i] = 1
for k in range(N-1)[::-1]:
    d = D[N-k-1]
    for m in range(13):
        if S[k] != '?':
            dp[k][m] += dp[k+1][(m-d*int(S[k]))%13]
            dp[k][m] %= mod
        else:
            for i in range(10):
                dp[k][m] += dp[k+1][(m-i*d)%13]
                dp[k][m] %= mod
print(dp[0][5])
### BUGGY CODE ###

import sys
readline = sys.stdin.readline

def main():
    N, M = map(int, readline().rstrip().split())
    inp = [list(map(int, readline().rstrip().split())) for _ in range(M)]
    pref = {}
    for p, y in inp:
        pref.setdefault(p, [])
        pref[p].append(y)

    for key, val in pref.items():
        pref[key] = sorted(val)
        
    res = []
    for p, city in inp:
        cities = pref[p]
        id = str(p).zfill(6) + str(cities.index(city)+1).zfill(6)
        res.append(id)
    
    print(*res, sep='\n')

if __name__ == '__main__':
    main()

### FIXED CODE ###

from operator import itemgetter

def main():
    num_prefecture, num_city = list(map(int, input().rstrip().split()))
    prefecture_list = []
    for i in range(num_prefecture):
        prefecture_list.append([])
    #print(prefecture_list)
    id_list = []
    for idx_city in range(num_city):
        p_belong, y_born = list(map(int, input().rstrip().split()))
        p_belong -= 1 # 0から始まるようにする
        prefecture_list[p_belong].append([idx_city, y_born])
    
    #print(prefecture_list)
    # 各県のリスト内で, 市の誕生順にソートする
    for l in prefecture_list:
        l.sort(key = itemgetter(1))
    
    #print(prefecture_list)
    
    for idx_p, l in enumerate(prefecture_list):
        for x, [idx_city, y_born] in enumerate(l):
            id_first = '{0:06d}'.format(idx_p + 1)
            id_end = '{0:06d}'.format(x + 1)
            id_num = str(id_first) + str(id_end)
            id_list.append([idx_city, id_num])
    
    id_list.sort(key = itemgetter(0))
    
    for id_num in id_list:
        print(id_num[1])
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def group_members(self):
        return [self.members(r) for r in self.roots()]

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


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

uf = UnionFind(n+1)
for _ in range(m):
    x, y = map(int, input().split())
    uf.unite(x, y)

print(max([len(g) for g in uf.group_members()]))




### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def group_members(self):
        return [self.members(r) for r in self.roots()]

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


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

uf = UnionFind(n+1)
for _ in range(m):
    x, y = map(int, input().split())
    uf.unite(x, y)

ans = 0
for i in range(n+1):
    if ans < uf.size(i):
        ans = uf.size(i)
print(ans)
### BUGGY CODE ###

#from functools import lru_cache
import sys
def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:f(*x,**kwargs),*lst))

def reader():return vfunc(lambda l:l.split())(sys.stdin.readlines())

n=int(reader()[0][0])
a=[]
while n!=0:
    a.append(n%10)
    n//=10
print('Yes' if sum(a)%9==0 else 'No')

### FIXED CODE ###

#from functools import lru_cache
import sys
def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:f(*x,**kwargs),*lst))

def reader():return vfunc(lambda l:l.split())(sys.stdin.readlines())

n=reader()[0][0]
i=vfunc(lambda n:int(n))(n)
print('Yes' if sum(i)%9==0 else 'No')
### BUGGY CODE ###

# F

N = int(input())

import bisect
list_plus = []
list_minus = []
for i in range(N):
    S = input()
    state = 0
    min_state = 0
    for s in S:
        if s == '(':
            state += 1
        else:
            state -= 1
        min_state = min(min_state, state)
    
    if state > 0:
        index = bisect.bisect_right(list_plus, [min_state, state])
        list_plus.insert(index, [min_state, state])
        # list_plus.append([min_state, state])
    else:
        index = bisect.bisect_right(list_minus, [min_state - state, -state])
        list_minus.insert(index, [min_state - state, -state])
        # list_minus.append([min_state - state, -state])

def compute(arr):
    total_state = 0

    for min_state, state in arr[-1::-1]:
        if total_state + min_state < 0:
            print('No')
            exit()
        total_state += state
    return total_state

list_plus.sort()
total_state_plus = compute(list_plus)
list_minus.sort()
total_state_minus = compute(list_minus)

print('Yes' if total_state_plus == total_state_minus else 'No')

### FIXED CODE ###

# F

N = int(input())

list_plus = []
list_minus = []
for i in range(N):
    S = input()
    state = 0
    min_state = 0
    for s in S:
        if s == '(':
            state += 1
        else:
            state -= 1
        min_state = min(min_state, state)
    
    if state > 0:
        list_plus.append((min_state, state))
    else:
        list_minus.append((min_state - state, -state))

def compute(arr):
    total_state = 0
    for min_state, state in arr[::-1]:
        if total_state + min_state < 0:
            print('No')
            exit()
        total_state += state
    return total_state

list_plus.sort()
total_state_plus = compute(list_plus)
list_minus.sort()
total_state_minus = compute(list_minus)

print('Yes' if total_state_plus == total_state_minus else 'No')
### BUGGY CODE ###

n = int(input())

ans = 0
for a in range(1, n):
    for b in range(1, n //a + 1):
        if a * b < n:
            ans += 1

print(ans)

### FIXED CODE ###

n = int(input())

ans = 0
for a in range(1, n):
    for b in range(1, n //a + 1):
        if a * b < n:
            ans += 1

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

S = input()
boundaries = []
boundaries_RL = []
boundaries_LR = []
children = [0 for _ in range(len(S))]

for i in range(1, len(S)):
    if S[i-1] == 'R' and S[i] == 'L':
        boundaries.append(i)
        boundaries_RL.append(i)
    elif S[i-1] == 'L' and S[i] == 'R':
        boundaries_LR.append(i)
        boundaries.append(i)

for j in range(len(boundaries)):
    if boundaries[j] in boundaries_LR:
        continue
    else:  # boundaries[j]は、RLとなっているところの、Lのindex
        '''group1: Rより左側のchildren'''
        if j == 0:
            group1 = boundaries[j]
        else:
            group1 = boundaries[j] - boundaries[j-1]
        if group1 % 2 == 0:
            children[boundaries[j]] += group1 // 2
            children[boundaries[j]-1] += group1 // 2
        else:
            children[boundaries[j]-1] += group1 // 2 + 1
            children[boundaries[j]] += group1 // 2
        '''group2: Lより右側のchildren'''
        if j == len(boundaries)-1:
            group2 = len(S) - boundaries[j]
        else:
            group2 = boundaries[j+1] - boundaries[j]
        if group2 % 2 == 0:
            children[boundaries[j]] += group2 // 2
            children[boundaries[j]-1] += group2 // 2
        else:
            children[boundaries[j]] += group2 // 2 + 1
            children[boundaries[j]-1] += group2 // 2

print(*children)


### FIXED CODE ###

S = input()


def solve(s):
    buf = [1] * len(s)

    for i in range(len(buf) - 2):
        if s[i] == "R" and s[i + 1] == "R":
            buf[i+2] += buf[i]
            buf[i] = 0

    for i in range(len(buf) - 1, 1, -1):
        if s[i] == "L" and s[i - 1] == "L":
            buf[i-2] += buf[i]
            buf[i] = 0

    return " ".join(map(str, buf))


print(solve(S))
### BUGGY CODE ###

# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from collections import deque
import sys
def main(H, W, C, D, S):
    INF = 10**6
    dist = [[INF] * W for _ in range(H)]
    di, dj = D
    dist[di][dj] = 0
    q = deque([(di, dj, 0)])
    while q:
        i, j, d = q.popleft()
        if d > dist[i][j]: continue
        for ni, nj in [(i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1)]:
            if 0 <= ni < H and 0 <= nj < W and S[ni][nj] == '.':
                if dist[ni][nj] > d:
                    dist[ni][nj] = d
                    q.append((ni, nj, d))
        for ni in range(i - 2, i + 2 + 1, 1):
            for nj in range(j - 2, j + 2 + 1, 1):
                if 0 <= ni < H and 0 <= nj < W and S[ni][nj] == '.':
                    if dist[ni][nj] > d + 1:
                        dist[ni][nj] = d + 1
                        q.append((ni, nj, d + 1))

    ans = dist[C[0]][C[1]]
    print(ans if ans < INF else -1)


if __name__ == '__main__':
    input = sys.stdin.readline
    H, W = map(int, input().split())
    C = tuple(map(lambda x: int(x) - 1, input().split()))
    D = tuple(map(lambda x: int(x) - 1, input().split()))
    S = [list(input().rstrip()) for _ in range(H)]
    main(H, W, C, D, S)


### FIXED CODE ###

# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from collections import deque
import sys
def main(H, W, C, D, S):
    INF = 10**6
    dist = [[INF] * W for _ in range(H)]
    di, dj = D
    dist[di][dj] = 0
    q = deque([(di, dj, 0)])
    while q:
        i, j, d = q.popleft()
        if d > dist[i][j]: continue
        for ni, nj in [(i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1)]:
            if 0 <= ni < H and 0 <= nj < W and S[ni][nj] == '.':
                if dist[ni][nj] > d:
                    dist[ni][nj] = d
                    q.appendleft((ni, nj, d))
        for ni in range(i - 2, i + 2 + 1, 1):
            if not(0 <= ni < H): continue
            dni = dist[ni]
            sni = S[ni]
            for nj in range(j - 2, j + 2 + 1, 1):
                if 0 <= nj < W and sni[nj] == '.':
                    if dni[nj] > d + 1:
                        dni[nj] = d + 1
                        q.append((ni, nj, d + 1))

    ans = dist[C[0]][C[1]]
    print(ans if ans < INF else -1)


if __name__ == '__main__':
    input = sys.stdin.readline
    H, W = map(int, input().split())
    C = tuple(map(lambda x: int(x) - 1, input().split()))
    D = tuple(map(lambda x: int(x) - 1, input().split()))
    S = [list(input().rstrip()) for _ in range(H)]
    main(H, W, C, D, S)
### BUGGY CODE ###

N, M = [int(i) for i in input().split()]
Groups = [[i] for i in range(N)]
dsts = [-1 for i in range(N)]
ABs = [[int(i)-1 for i in input().split()] for i in range(M)]
for A, B in ABs:
    dst = min(A, B)
    src = max(A, B)
    # print('A', A, B, dst, src)
    while(dsts[dst] != -1):
        dst = dsts[dst]
    while(dsts[src] != -1):
        src = dsts[src]
    if dst != min(A, B):
        dsts[min(A, B)] = dst
    if src != max(A, B):
        dsts[max(A, B)] = src

    if dst == src:
        continue
    dst2 = min(dst, src)
    src2 = max(dst, src)
    dsts[src2] = dst2
    Groups[dst2].extend(Groups[src2])
    Groups[src2] = []
    # print(Groups)
    # print(dsts)
ans = 0
for group in Groups:
    ans = max(ans, len(group))
print(ans)


### FIXED CODE ###

N, M = [int(i) for i in input().split()]
Groups = [1 for i in range(N)]
dsts = [-1 for i in range(N)]
ABs = [[int(i)-1 for i in input().split()] for i in range(M)]
for A, B in ABs:
    dst = min(A, B)
    src = max(A, B)
    # print('A', A, B, dst, src)
    while(dsts[dst] != -1):
        dst = dsts[dst]
    while(dsts[src] != -1):
        src = dsts[src]
    if dst != min(A, B):
        omdst = min(A, B)
        while(dsts[omdst] != dst):
            n_omdst = dsts[omdst]
            dsts[omdst] = dst
            omdst = n_omdst
    if src != max(A, B):
        omsrc = max(A, B)
        while(dsts[omsrc] != src):
            n_omsrc = dsts[omsrc]
            dsts[omsrc] = src
            omsrc = n_omsrc

    if dst == src:
        continue
    dst2 = min(dst, src)
    src2 = max(dst, src)
    dsts[src2] = dst2
    Groups[dst2] += Groups[src2]
    Groups[src2] = 0
    # print(Groups)
    # print(dsts)
print(max(Groups))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    b = a[:i] + a[i+1:]
    # print(b)
    c = list(set(b))
    # print(c)
    tmp = 0
    for i in c:
        n = b.count(i)
        tmp += n * (n-1) // 2
    print(tmp)

### FIXED CODE ###

from collections import Counter
n = int(input())
*a, = map(int, input().split())
c = Counter(a)
s = sum(i*(i-1)//2 for i in c.values())
for k in range(n):
    print(s-c[a[k]]+1)
### BUGGY CODE ###

from collections import deque


def main():
    input()  # n
    friendliness = [int(x) for x in input().split()]
    friendliness.sort()
    friendliness = deque(friendliness)
    edges = deque()
    popped = friendliness.pop()
    edges.append(popped)
    ans = 0
    while friendliness:
        ans += edges.pop()
        popped = friendliness.pop()
        edges.append(popped)
        edges.append(popped)
        edges = deque(sorted(edges))
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from collections import deque


def main():
    n = int(input())  # n
    friendliness = [int(x) for x in input().split()]
    friendliness.sort()
    friendliness = deque(friendliness)
    edges = deque()
    popped = friendliness.pop()
    edges.append(popped)
    ans = 0
    counter = 0
    while friendliness:
        ans += edges.popleft()
        counter += 1
        popped = friendliness.pop()
        edges.append(popped)
        edges.append(popped)
    print(ans)


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

N = int(input())


def check(a):
    s = str(a)
    if len(s) == 1:
        return True
    
    for i in range(1, len(s)):
        if abs(int(s[i-1]) - int(s[i])) > 1:
            return False
    return True
    
def solve(N):
    m = 10**5
    ct = 0
    i = 1
    while True:
        if check(i):
            ct += 1
            if ct == N:
                return i
        i+=1

print(solve(N))

### FIXED CODE ###

K = int(input())

LLs = []

def dfs(d, num):
    LLs.append(num)
    
    if d == 10: return

    a = num % 10
    for i in [-1, 0, 1]:
        b = a + i
        if  0 <= b < 10:
            dfs(d+1, num * 10 + b)

d = 1
for i in range(1, 10):
    dfs(d, i)

print(sorted(LLs)[K-1])
### BUGGY CODE ###

n=int(input())
ll=list(map(int, input().split()))
ll=sorted(ll)
def f(a,b):
  l=a
  r=len(ll)
  x=0
  while l+1<r:
    x=(l+r)//2
    if ll[x]<b:
      l=x
    else:
      r=x
  return len(ll[a+1:r])
  
ans=0
for i in range(len(ll)-1):
  for j  in range(i+1,len(ll)):
    ans+=f(j,ll[i]+ll[j])
print(ans)

### FIXED CODE ###

import bisect
n=int(input())
ll=list(map(int, input().split()))
ll=sorted(ll)

  
ans=0
for i in range(len(ll)-1):
  for j  in range(i+1,len(ll)):
    a,b=ll[i],ll[j]
    ans+=bisect.bisect_left(ll,a+b)-(j+1)
print(ans)