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


#AのリストにCのリストを加えて大きい順に並べ替えてNまでの和を求める
N,M = map(int,input().split())

#Aの入力
A_list = list(map(int,input().split()))

C_list = []

#Cのリストに追加する
for i in range(M):
    bi,ci = map(int,input().split())
    C_list.append([bi,ci])

#C_listをCの値でソート
C_list=sorted(C_list, reverse=True, key=lambda x:x[1])

count = 0
for bi,ci in C_list:
    count += bi
    #if count > N:
        #countがNより大きくなったらNより大きくなった分だけ使う
        #bi = N - count + bi
    A_list.extend([ci]*bi)

#A_Listを大きい順に並べ替える
A_list=sorted(A_list,reverse=True)

#N番目までの総和を求める
print(sum(A_list[0:N]))


### FIXED CODE ###


#AのリストにCのリストを加えて大きい順に並べ替えてNまでの和を求める
N,M = map(int,input().split())

#Aの入力
A_list = list(map(int,input().split()))

C_list = []

#Cのリストに追加する
for i in range(M):
    bi,ci = map(int,input().split())
    C_list.append([bi,ci])

#C_listをCの値でソート
C_list=sorted(C_list, reverse=True, key=lambda x:x[1])

count = 0
for bi,ci in C_list:
    count += bi
    if count > N:
        #countがNより大きくなったらNより大きくなった分だけ使う
        bi = N - count + bi
    A_list.extend([ci]*bi)

#A_Listを大きい順に並べ替える
A_list=sorted(A_list,reverse=True)

#N番目までの総和を求める
print(sum(A_list[0:N]))
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

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

    #3:dp実行部(貰うDP)
    for i in range(1,N+1):
        for j in range(1,W+1):
            if wv[i-1][0] <= j:
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-wv[i-1][0]]+wv[i-1][1])
            else:
                dp[i][j] = dp[i-1][j]
            #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()
### BUGGY CODE ###

def main():
    n = int(input())
    s = input()
    dp = [0]*(n-1)
    ans = 0
    for i in range(1, n):
        for j in reversed(range(i)):
            if s[i] == s[j]:
                dp[j] = 1
                if 0 < j:
                    dp[j] += dp[j-1]
                if i-j < dp[j]:
                    dp[j] = i-j
                if ans < dp[j]:
                    ans = dp[j]
            else:
                dp[j] = 0
    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

def check(x, N, S):
    candidate = set()
    for i in range(N - 2*x + 1):
        candidate.add(S[i:i+x])
        if S[i+x:i+2*x] in candidate:
            return True
    return False

def main():
    n = int(input())
    s = input().rstrip()
    l = 0
    r = n
    while l < r:
        mid = (l+r+1) // 2
        if check(mid, n, s):
            l = mid
        else:
            r = mid-1
    print((l+r+1)//2)

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

import sys


def main():
    K, Q = map(int, input().split())
    D = list(map(int, input().split()))

    for _ in range(Q):
        n, x, m = map(int, input().split())
        md = [D[i] % m for i in range(K)]
        smda = 0
        mda0 = 0
        for i in range((n - 1) % K):
            if md[i] == 0:
                mda0 += 1
            smda += md[i]
        smd = smda
        md0 = mda0
        for i in range((n - 1) % K, K):
            if md[i] == 0:
                md0 += 1
            smd += md[i]
        roop = (n - 1) // K
        res = n - 1 - (x % m + smd * roop + smda) // m - md.count(0) * roop - mda0
        print(res)


main()


### FIXED CODE ###

import sys

input = sys.stdin.readline


def main():
    K, Q = map(int, input().split())
    D = list(map(int, input().split()))

    for _ in range(Q):
        n, x, m = map(int, input().split())
        md = [D[i] % m for i in range(K)]
        smda = 0
        mda0 = 0
        for i in range((n - 1) % K):
            if md[i] == 0:
                mda0 += 1
            smda += md[i]
        smd = smda
        md0 = mda0
        for i in range((n - 1) % K, K):
            if md[i] == 0:
                md0 += 1
            smd += md[i]
        roop = (n - 1) // K
        res = n - 1 - (x % m + smd * roop + smda) // m - md0 * roop - mda0
        print(res)


main()
### BUGGY CODE ###

import sys

N, X = map(int, input().split())
x_list = list(map(int, input().split()))
sum_x = [0]

tmp = 0
for x in x_list:
    tmp += x
    sum_x.append(tmp)

max_robo = -(-1 * N // 2)
ans = sys.maxsize
for k in range(1, max_robo + 1):
    t_ans = 0
    t_ans += 5 * (sum_x[N] - sum_x[max(N - k * 2, 0)])
    for j in range(1, -(-(N - k) // k)):
        tmp = sum_x[N - (j + 1) * k] - sum_x[max(N - (j + 2) * k, 0)]
        t_ans += tmp * (2 * (j + 2) + 1)

    t_ans += (N + k) * X
    ans = min(ans, t_ans)


print(ans)

### FIXED CODE ###

import sys
# import numpy

N, X = map(int, input().split())
x_list = list(map(int, input().split()))
x_list.insert(0, 0)

tmp = 0
sum_x = []
for x in x_list:
    tmp += x
    sum_x.append(tmp)
# sum_x = numpy.cumsum(x_list)

max_robo = -(-1 * N // 2)
ans = sys.maxsize
for k in range(1, max_robo + 1):
    t_ans = (N + k) * X + 5 * sum_x[N]
    for j in range(1, -(-(N - k) // k)):
        t_ans += 2 * sum_x[N - (j + 1) * k]

    ans = min(ans, t_ans)

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

R, G, B, N = map(int, input().split())
ans = 0
for r in range(N + 1):
    for g in range(N + 1):
        tmp = N - R * r - G * g
        if tmp >= 0 and tmp % B == 0:
            ans += 1
print(ans)

### FIXED CODE ###

import sys
rr = lambda: sys.stdin.readline().strip()
ri = lambda: int(rr())
rs = lambda: [int(_) for _ in rr().split()]

R, G, B, N = rs()

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

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

def main():
    h, w = list(map(int, input().split()))
    matrix = []
    for _ in range(h):
        matrix.append([c for c in input()])

    adj = [(0, 1), (0, -1), (1, 0), (-1, 0)]

    def step(q, m):
        next = []
        filled = m
        while len(q) > 0:
            y, x = q.pop(0)

            for dy, dx in adj:
                if -1 < y + dy < h and -1 < x + dx < w:
                    if m[y + dy][x + dx] == '.':
                        filled[y + dy][x + dx] = '#'
                        next.append((y + dy, x + dx))

        return next, filled

    iq = []
    for i in range(h):
        for j in range(w):
            if matrix[i][j] == '#':
                iq.append((i, j))

    count = 0
    m = matrix
    while len(iq) > 0:
        # finished = all([m[i][j] == '#' for i in range(h) for j in range(w)])
        next, m = step(iq, m)
        if len(next) > 0:
            count += 1
            iq = next

    print(count)


main()


### FIXED CODE ###

import numpy

def main():
    h, w = map(int, input().split())
    max_value = h + w
    gridmap = []

    for y in range(h):
        gridmap.append([0 if v == '#' else max_value for v in input().strip()])

    values = numpy.array(gridmap)

    for x in range(w - 1):
        values[:, x + 1] = numpy.minimum(values[:, x] + 1, values[:, x + 1])

    for x in range(w - 1, 0, -1):
        values[:, x - 1] = numpy.minimum(values[:, x] + 1, values[:, x - 1])

    for y in range(h - 1):
        values[y + 1, :] = numpy.minimum(values[y, :] + 1, values[y + 1, :])

    for y in range(h - 1, 0, -1):
        values[y - 1, :] = numpy.minimum(values[y, :] + 1, values[y - 1, :])

    print(numpy.max(values))


main()
### BUGGY CODE ###

import itertools

n=int(input())
s=list(input())

a=itertools.combinations(s,3)
print(len(set(a)))

### FIXED CODE ###

n=int(input())
s=input()
ans=0

for i in range(10):
    for j in range(10):
        for k in range(10):
            x=s.find(str(i))
            if x!=-1:
                y=s.find(str(j),x+1)
                if y!=-1:
                    z=s.find(str(k),y+1)
                    if z!=-1:
                        ans+=1

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

import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

#maxvalue
k = int(arr_data[0][0])

#sumvalue
s = int(arr_data[0][1])


#print(k,s)

cnt=0

for x in range(0,k+1):
    
    for y in range(0,k+1):
    
        for z in range(0,k+1):
        
            
            if x+y+z==s:
                
                cnt+=1
                
print(cnt)
                

### FIXED CODE ###

def getinputdata():

    array_result = []
    
    data = input()
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result

arr_data = getinputdata()

#maxvalue
k = int(arr_data[0][0])

#sumvalue
s = int(arr_data[0][1])

cnt = 0

for x in range(0, k + 1):
    
    for y in range(0, k + 1):
        
        z = s-x-y
        
        if z >= 0 and z <= k:
            
            cnt += 1
            
print(cnt)
### BUGGY CODE ###


import itertools
x = 10**9 + 7
n = int(input())
a = list(map(lambda i: i % x , map(int, input().split(" "))))

ans = 0
for i in range(n):
    for j in range(i + 1, n):
        ans += (a[i] * a[j]) % x
print(ans % x)

### FIXED CODE ###

import itertools
x = 10**9 + 7
n = int(input())
a = list(map(lambda i: i % x , map(int, input().split(" "))))
sum_a = []
prev = 0
for i in a:
    sum_a.append(prev + i)
    prev = prev + i

ans = 0
for i in range(n):
    ans += (a[i] * (sum_a[n-1] - sum_a[i] )) % x
print(ans % x)
### BUGGY CODE ###

import functools

def main():
    N = int(input())
    A = [int(c) for c in input().split(' ')]

    ret = functools.reduce(lambda x, y: x*y, A)
    if ret > 1e18:
        print('-1')
    else:
        print(f'{ret}')


if __name__ == "__main__":
    main()

### FIXED CODE ###

#import functools

def main():
    N = int(input())
    A = [int(c) for c in input().split(' ')]
    A.sort(reverse=True)

    if A[-1] == 0:
        print('0')
        exit()
    elif A[0] > 1e18:
        print('-1')
        exit()

    ret = 1
    for x in A:
        ret = ret * x
        if ret > 1e18:
            print('-1')
            exit()
        elif ret == 0:
            print('0')
            exit()

    if ret == 0:
        print('0')
        exit()
    elif ret > 1e18:
        print('-1')
        exit()
    print(f'{ret}')


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

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

ans = 0
t = 1
while t != 0:
  t = 0
  for i in range(n-1, -1 ,-1):
    if t == 0 and a[i]%2 == 0 and a[i] != 2:
      a[i] //= 2
      t += 1
      ans += 1
    else: a[i] *= 3
print(ans)

### FIXED CODE ###

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

ans = 0
for i in a:
  while i%2==0:
    i//=2
    ans+= 1
print(ans)
### BUGGY CODE ###

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

from math import gcd
g = a[0]
for i in range(n):
    g = gcd(g,a[i])

if g!=1:
    print('not coprime')
    exit()


def prime_factorize(n):
    a = set()
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.add(n)
    return a

f = True
l = set()
for i in range(n):
    x = prime_factorize(a[i])
    y = l|x
    if len(l)+len(x)!=len(y):
        f = False
        break
    l = y
    
if f:
    print('pairwise coprime')
else:
    print('setwise coprime')


### FIXED CODE ###

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

from math import gcd
g = a[0]
for i in range(n):
    g = gcd(g,a[i])

if g!=1:
    print('not coprime')
    exit()

f = True
l = set()
for i in a:
    for j in range(2,int(i**0.5)+1):
        if i%j==0:
            if i in l:
                f = False
                break
            l.add(i)
        while i%j==0:
            i = i//j
        if i<2:
            break
    if i>1:
        if i in l:
            f = False
            break
        l.add(i)
        
if f:
    print('pairwise coprime')
else:
    print('setwise coprime')
### BUGGY CODE ###

dp = ["" for i in range(51)]
dp[0] = "P"

def solve(n, dp):
    if n == 0:
        return dp[0]
    else:
        if dp[n] == "":
            return 'B' + solve(n - 1,dp) + 'P' + solve(n - 1,dp) + 'B'
        else:
            return dp[n]
n, x = list(map(int, input().split()))
dp = solve(n,dp)
print(dp[-x:].count('P'))


### FIXED CODE ###

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

a = [1]
p = [1]
for i in range(1,n):
    a.append(a[i - 1] * 2 + 3)
    p.append(2 * p[i - 1] + 1)

def f(n, x):
    if n == 0:
        return 0 if x <= 0 else 1
    elif x <= 1 + a[n-1]:
        return f(n-1, x-1)
    else:
        return p[n-1] + 1 + f(n-1, x-2-a[n-1])
print(f(n,x))
### BUGGY CODE ###

# coding: utf-8

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

A = Y // 10000 #Yを越えない最大の10000円札の枚数
B = Y // 5000
C = Y // 1000

roop = 0
for i in range(A+1):
    if roop == 1:
        break
    for j in range(B+1):
        c = N - i - j #c:1000円札の枚数
        if 10*i + 5*j + c == Y//1000 and c >= 0:
            # a:10000円札、b:5000円札
            a = i
            b = j
            roop = 1
            break

if roop == 1:
    print("{0} {1} {2}".format(a, b, c))
else:
    a, b, c = -1, -1, -1
    print("{0} {1} {2}".format(a, b, c))

### FIXED CODE ###

# coding: utf-8

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

A = Y // 10000 #Yを越えない最大の10000円札の枚数
B = Y // 5000
C = Y // 1000

roop = 0
for i in range(A+1):
    if roop == 1:
        break
    for j in range(B+1):
        if i + j > N:
            break
        c = N - i - j #c:1000円札の枚数
        if 10*i + 5*j + c == Y//1000 and c >= 0:
            # a:10000円札、b:5000円札
            a = i
            b = j
            roop = 1
            break

if roop == 1:
    print("{0} {1} {2}".format(a, b, c))
else:
    a, b, c = -1, -1, -1
    print("{0} {1} {2}".format(a, b, c))
### BUGGY CODE ###

#!/usr/bin/env python3
import sys
import copy
sys.setrecursionlimit(10**8)
INF = float("inf")

MOD = 998244353  # type: int


def array(*args, initial=0):
    pre = "["*len(args)
    post = ""
    for a in args[::-1]:
        post += " for _ in range("+str(a)+")]"
    S = pre + str(initial) + post
    return eval(S)


def solve(N: int, S: int, A: "List[int]"):
    dp = array(S+1, 3, initial=0)
    dp[0][0] = 1
    for i in range(N):
        dp_past = copy.deepcopy(dp)
        # t=0軸
        for s in range(S+1):
            # A[i]を使う
            if s-A[i] >= 0:
                dp[s][0] += dp_past[s-A[i]][0]
                dp[s][0] %= MOD

        # t=1軸
        for s in range(S+1):
            if s-A[i] >= 0:
                dp[s][1] += dp_past[s-A[i]][1]
                dp[s][1] %= MOD
        if A[i] <= S:
            dp[A[i]][1] += i+1
            dp[s][1] %= MOD

        # t=2軸
        for s in range(S+1):
            if s-A[i] >= 0:
                dp[s][2] += (dp[s][1]-dp_past[s][1]) * (N-i)
                dp[s][2] %= MOD

    print(dp[S][2])

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, S, A)


if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import copy
sys.setrecursionlimit(10**8)
INF = float("inf")

MOD = 998244353  # type: int


def array(*args, initial=0):
    pre = "["*len(args)
    post = ""
    for a in args[::-1]:
        post += " for _ in range("+str(a)+")]"
    S = pre + str(initial) + post
    return eval(S)


def solve(N: int, S: int, A: "List[int]"):
    dp = array(S+1, 3, initial=0)
    dp_past = array(S+1, 3, initial=0)
    dp[0][0] = 1
    for i in range(N):
        dp_past, dp = dp, dp_past
        # t=0軸
        for s in range(S+1):
            dp[s][:] = dp_past[s]
            # A[i]を使う
            if s == A[i]:
                dp[s][1] += i+1
                dp[s][1] %= MOD
            if s-A[i] >= 0:
                dp[s][0] += dp_past[s-A[i]][0]
                dp[s][0] %= MOD
                dp[s][1] += dp_past[s-A[i]][1]
                dp[s][1] %= MOD
                dp[s][2] += (dp[s][1]-dp_past[s][1]) * (N-i)
                dp[s][2] %= MOD

    print(dp[S][2])

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, S, A)


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

N , K = map(int, input().split())
A = list(map(int, input().split()))
syurui = set(A)
n_syurui =len(syurui)
ans = 0
if n_syurui > K:
    ans = sum(sorted([A.count(i) for i in syurui])[:n_syurui-K])
print(ans)

### FIXED CODE ###

import collections
N, K = map(int, input().split())
A = [int(i) for i in input().split()]
hint = collections.Counter(A)
ans = 0
bb = hint.most_common()
if K >= len(bb):
    print(ans)
else:
    for i in range(-1, -(len(bb)-K)-1, -1):
        ans += bb[i][1]
    print(ans)
### BUGGY CODE ###

def isPrime(x):
    if x <= 1: return False
    i = 2
    while i ** 2 <= x:
        if x % i == 0: return False
        i += 1

a = int(input())
while True:
    a += 1
    if isPrime(a):
        print(a)
        break

### FIXED CODE ###

def isPrime(x):
    if x <= 1: return False
    i = 2
    while i ** 2 <= x:
        if x % i == 0: return False
        i += 1
    return True

a = int(input())
while True:
    if isPrime(a):
        print(a)
        break
    a += 1
### BUGGY CODE ###

n=int(input())
p=list(map(int,input().split()))
cnt=1
for i in range(1,n):
    x=p[i]
    if x<=min(p[:p.index(x)]):
        cnt+=1
    else: continue
print(cnt)

### FIXED CODE ###

n=int(input())
p=list(map(int,input().split()))
cnt=1
min_p=p[0]
for i in range(1,n):
    x=p[i]
    if x<=min_p:
        cnt+=1
        min_p=min(min_p,x)
    else: continue
print(cnt)
### BUGGY CODE ###

N=int(input())
word=set()
S=list(input())
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            word.add(S[i]+S[j]+S[k])
print(len(word))

### FIXED CODE ###

def main():
  N = int(input())
  S = list(map(int,input()))
  ans = 0
  for i in range(10):
    for j in range(10):
      for k in range(10):
        flg = False
        flg2 = False
        for x in range(N):
          if flg2:
            break
          if not flg:
            if S[x] == i:
              flg = True
          else:
            if S[x] == j:
              flg2 = True
              if k in S[x+1:]:
                ans +=1
  print(ans)
main()
### BUGGY CODE ###

N=int(input())
s=input()
R=[0]
G=[0]
B=[0]
ans=0
#RGBの累積和を作る
for i in range(N):
  if s[i]=="R":
    R[i]+=1
  elif s[i]=="G":
    G[i]+=1
  else:
    B[i]+=1
  R.append(R[i])
  G.append(G[i])
  B.append(B[i])
del R[-1]
del G[-1]
del B[-1]
#作った
 
#全探索する
for i in range(N-2):
  a=s[i]
  for j in range(i+1,N-1):
    if a==s[j]:
      continue
    b=s[j]
    k=2*j-i
    if "R" not in a+b:
      ans+=R[-1]-R[j]
      if k>=N:
        continue
      if s[k]=="R":
        ans-=1
    
    if "G" not in a+b:
      ans+=G[-1]-G[j]
      if k>=N:
        continue
      if s[k]=="G":
        ans-=1

    if "B" not in a+b:
      ans+=B[-1]-B[j]
      if k>=N:
        continue
      if s[k]=="B":
        ans-=1
print(ans)


### FIXED CODE ###

N=int(input())
s=input()
R=[0]
G=[0]
B=[0]
ans=0
#RGBの累積和を作る
for i in range(N):
  if s[i]=="R":
    R[i]+=1
  elif s[i]=="G":
    G[i]+=1
  else:
    B[i]+=1
  R.append(R[i])
  G.append(G[i])
  B.append(B[i])
del R[-1]
del G[-1]
del B[-1]
#作った

#全探索する
for i in range(N-2):
  a=s[i]
  for j in range(i+1,N-1):
    if a==s[j]:
      continue
    b=s[j]
    k=2*j-i
    if "R" not in a+b:
      ans+=R[-1]-R[j]
      try:
        if s[k]=="R":
          ans-=1
      except:
        pass
    
    if "G" not in a+b:
      ans+=G[-1]-G[j]
      try:
        if s[k]=="G":
          ans-=1
      except:
        pass
        
    if "B" not in a+b:
      ans+=B[-1]-B[j]
      try:
        if s[k]=="B":
          ans-=1
      except:
        pass
print(ans)
### BUGGY CODE ###


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

x = 0

from itertools import combinations

for l in combinations(L, 3):
    if (l[0] < l[1] + l[2])\
        and (l[1] < l[2] + l[0])\
        and (l[2] < l[0] + l[1]):
        x += 1
print(x)


### FIXED CODE ###

import bisect

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

cnt = 0
for i in range(n-1):
    for j in range(i+1,n):
        up = l[j] + l[i]
        #l[k] = up となるようなkのうち最小のものを見つけろ
        k = bisect.bisect_left(l, up)
        cnt += k - j - 1
print(cnt)
### BUGGY CODE ###

x,y=map(int, input().split())

def answer(x,y):
 for i in range(y, 0, -1):
  if x % i == 0 and y % i == 0:
   return i
 
if x == y:
 print(x)
elif x >= y:
 print(str(answer(x, x%y)))
else:
 print(str(answer(y, y%x)))

### FIXED CODE ###

x,y=map(int, input().split())

def gcd(x,y):
 if x < y:
  x,y = y,x
 while y > 0:
  r = x % y
  x = y
  y = r
 return x

print(str(gcd(x,y)))
### BUGGY CODE ###

import sys
readline = sys.stdin.readline

def main():

	#s = tuple(input())
	s = input()
	length = len(s)

	dp = [[0]*13 for _ in range(length)]
	MOD = 10**9+7

	if s[-1] == '?':
		for i in range(10):
			dp[0][i] = 1
	else:
		dp[0][int(s[-1])] = 1

	a = 1
	for i in range(1,length):
		a = 10 * a % 13
		if s[-(i+1)] != '?':
			num = int(s[-(i+1)])
			for j in range(13):
				dp[i][(a*num+j)%13] += dp[i-1][j]
				dp[i][(a*num+j)%13] %= MOD
		else:
			num = (10**i) % 13
			#a = 0
			for j in range(10):
				for k in range(13):
					dp[i][(a*j+k)%13] += dp[i-1][k]
					dp[i][k] %= MOD
				#a += num

	print(dp[-1][5] % MOD)

if __name__ == '__main__':
	main()

### FIXED CODE ###

INF = 10 ** 9 + 7

S = input()
# dp[i][j]はうしろからi桁を13で割った余りがjであるものの個数
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
mul = 1

for i in range(len(S)):
    x = S[-(i + 1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= INF
    else:
        k = int(x)
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= INF
    mul = mul * 10 % 13  # 計算量削減のためここで13で割っている

print(dp[len(S)][5])
### BUGGY CODE ###

import math
n = int(input())
m = math.sqrt(n)
m = int(n + 1)
ans = []
for i in range(m):
    for j in range(m):
        if i * j == n:
            ans.append(i+j-2)
print(min(ans))

### FIXED CODE ###

N=int(input())
a=1
for i in range(1,int(N**(1/2))+2):
    if N%i==0:
        a=max(a,i)
print(a+N//a-2)