Harryxun/stf_run huggingface dataset:
# -*- coding:utf-8 -*-

"""解説
http://drken1215.hatenablog.com/entry/2019/05/12/004500

N//m = N%m = k （kは約数。かつ余り）とすると、

N = mk + k ...(1)
N = k(m+1)

k は MOD m の余りなので、m > k である。
よって、

N = k*(m+1) > k*k

よって、

N > k**2
√N > k

これに気づけばOK。あとはkについて全探索。O(√N)


(例)
・N=8, m=3のとき
3*2 + 2 = 8
m*k + k = N

・N=8, m=7のとき
7*1 + 1 = 8
m*k + k = N

"""
import math

def solve():
    N = int(input())

    ans = 0
    for k in range(1, math.floor(math.sqrt(N))+1):
        if N%k != 0: continue # kはNの約数より
        # N = k(m+1)
        # m = (N/k) - 1
        m = (N/k) - 1
        if N//m == N%m:
            ans += m
    print(int(ans))


if __name__ == "__main__":
    solve()


### FIXED CODE ###

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

"""解説
http://drken1215.hatenablog.com/entry/2019/05/12/004500

N//m = N%m = k （kは約数。かつ余り）とすると、

N = mk + k ...(1)
N = k(m+1)

k は MOD m の余りなので、m > k である。
よって、

N = k*(m+1) > k*k

よって、

N > k**2
√N > k

これに気づけばOK。あとはkについて全探索。O(√N)


(例)
・N=8, m=3のとき
3*2 + 2 = 8
m*k + k = N

・N=8, m=7のとき
7*1 + 1 = 8
m*k + k = N

"""
import math

def solve():
    N = int(input())

    ans = 0
    for k in range(1, math.floor(math.sqrt(N))+1):
        if N%k != 0: continue # kはNの約数より
        # N = k(m+1)
        # m = (N/k) - 1
        m = (N/k) - 1
        if m <= 0: continue
        if N//m == N%m:
            ans += m
    print(int(ans))


if __name__ == "__main__":
    solve()
A = int(input())
B = int(input())
C = int(input())
K = int(input())

if K > A:
    N = K - A //2
    all_number = 1*A //3

    if N > B:
        N = N - B
        if N > C:
            all_number = all_number - 1 * C
            print(all_number)

        else:
            all_number = all_number - 1*N
            print(all_number)

    else:
        print(all_number)
else:
    all_number = 1*K
    print(all_number)


### FIXED CODE ###

A, B, C, K = map(int,input().split())
if K <= A:
    print(K)
elif K <= A + B:
    print(A)
else:
    print(2*A + B - K)
N=int(input())
W=list(map(int,input().split()))

diff=[]
for i in range(N-1):
    diff.append(abs(sum(W[:i+1])-sum(W[i+1:])))
print(min(diff))

### FIXED CODE ###

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

A=sorted(A)
print(A[0]+A[1])
n = int(input())
a = [int(_) for _ in input().split()]

if (n % 2) == 0:
    print(*a[n-1::-2], *a[::2])
else:
    print(*a[n-1::-2], *a[1::2])

### FIXED CODE ###

n = int(input())
a = [int(_) for _ in input().split()]

if n%2==0:
    s = a[n-1::-2] + a[::2]
else:
    s = a[n-1::-2] + a[1::2]

print(*s)
#create date: 2020-03-18 07:48

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ns()
    s0 = s[0]
    for i in range(1, len(s)//2, 2):
        if s[i] == s0:
            if s[:i] ==s[i:2*i]:
                #print(s[:i], s[i:2*i])
                ans = i*2
    print(ans)

if __name__ == "__main__":
    main()

### FIXED CODE ###

#create date: 2020-03-18 07:48

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ns()
    s0 = s[0]
    n = len(s)
    m = (n-1)//2 + 1
    for i in range(1, m):
        if s[i] == s0:
            if s[:i] ==s[i:2*i]:
                ans = i*2
    print(ans)

if __name__ == "__main__":
    main()
H, N = map(int, input().split())
magic = [list(map(int, input().split())) for _ in range(N)]


max_magic = 0
for a, _ in magic:
    max_magic = max(max_magic, a)

amount = H + 1
dp = [0] * (amount + max_magic)
dp[0] = 0

ret = float('inf')

for amt in range(1, amount + max_magic):
    t = [dp[amt - a] + b if amt - a >= 0 for a, b in magic]
    dp[amt] = min(t)

    if amt >= H:
        ret = min(dp[amt], ret)

print(ret)


### FIXED CODE ###

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


max_magic = 0
for a, _ in magic:
    max_magic = max(max_magic, a)

amount = H + 1
dp = [0] * (amount + max_magic)
dp[0] = 0

ret = float('inf')

for amt in range(1, amount + max_magic):
    t = [dp[amt - a] + b for a, b in magic]
    dp[amt] = min(t)

    if amt >= H:
        ret = min(dp[amt], ret)

print(ret)
n, m = map(int, input().split())
if m%2b == 1:
  for i in range(m):
    print(str(i+1) + ' ' + str(2*m-i))
else:
  for i in range(m/2):
    print(str(i+1) + ' ' + str(m-i+1))
  for i in range(m/2):
    print(str(i+m+2) + ' ' + str(2*m-i+1))

### FIXED CODE ###

n, m = map(int, input().split())
if m%2 == 1:
  # for i in range(m):
  #   print(str(i+1) + ' ' + str(2*m-i))
  for i in range(int((m-1)/2)):
    print(str(i+1) + ' ' + str(m-i))
  for i in range(int((m+1)/2)):
    print(str(m+i+1) + ' ' + str(2*m-i+1))
else:
  for i in range(int(m/2)):
    print(str(i+1) + ' ' + str(m-i+1))
  for i in range(int(m/2)):
    print(str(i+m+2) + ' ' + str(2*m-i+1))
N,M=map(int,input().split())
mod=10**9+7

#x以下の素数の列挙   
import math
x=math.floor(math.sqrt(10**9))
L=math.floor(math.sqrt(x))#平方根を求める
Primelist=[i for i in range(x+1)]
Primelist[1]=0#素数でないものは0にする.
for i in Primelist:
    if i>L:
        break
    if i==0:
        continue
    for j in range(2*i,x+1,i):
        Primelist[j]=0
Primes=[Primelist[j] for j in range(x+1) if Primelist[j]!=0]

#素因数分解
LISTS=[0 for i in range(4000)]
i=0
while M!=1:
    if M%Primes[i]==0:
        LISTS[i]+=1
        M=M//Primes[i]
    else:
        i+=1

def Combi2(a,b):#aは大きいが、bは小さいとき
    ANS=1
    for i in range(min(b,a-b)):
        ANS=ANS*(a-i)%mod*pow(b-i,mod-2,mod)%mod

    return ANS%mod


ANS=1
for i in range(4000):
    if LISTS[i]>=1:
        ANS=ANS*Combi2(N-1+LISTS[i],LISTS[i])%mod

print(ANS)


### FIXED CODE ###

N,M=map(int,input().split())
mod=10**9+7

#x以下の素数の列挙   
import math
x=math.floor(math.sqrt(10**9))
L=math.floor(math.sqrt(x))#平方根を求める
Primelist=[i for i in range(x+1)]
Primelist[1]=0#素数でないものは0にする.
for i in Primelist:
    if i>L:
        break
    if i==0:
        continue
    for j in range(2*i,x+1,i):
        Primelist[j]=0
Primes=[Primelist[j] for j in range(x+1) if Primelist[j]!=0]

#素因数分解
DICT=dict()
i=0
while M!=1:
    if M%Primes[i]==0:
        DICT[i]=DICT.get(i,0)+1
        M=M//Primes[i]
    elif i<len(Primes)-1:
        i+=1
    else:
        DICT[M]=1
        M=1

def Combi2(a,b):#aは大きいが、bは小さいとき
    ANS=1
    for i in range(min(b,a-b)):
        ANS=ANS*(a-i)%mod*pow(b-i,mod-2,mod)%mod

    return ANS%mod


ANS=1
for i in DICT.values():
    ANS=ANS*Combi2(N-1+i,i)%mod

print(ANS)
import math
A, B = input().split()
a = int(A)
b = int(B*1000)
print(a*b//1000)


### FIXED CODE ###

import math
A, B = input().split()
a = int(A)
b = int(float(B)*1000)
print(a*b//1000)
def dfs(i, j, c):
    visited[i][j] = 1
    current.append((i, j))
    for di, dj in (1, 0), (-1, 0), (0, 1), (0, -1):
        ni, nj = i + di, j + dj
        if not (0 <= ni < H and 0 <= nj < W and not visited[ni][nj]):
            continue
        if S[ni][nj] == c:
            continue
        dfs(ni, nj, not c)


H, W = map(int, input().split())
S = [[c == "#" for c in input()] for _ in range(H)]

ans = 0
visited = [[0] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] and not visited[i][j]:
            current = []
            dfs(i, j, True)
            b, w = 0, 0
            for k, l in current:
                if S[k][l]:
                    b += 1
                else:
                    w += 1
            ans += b * w
print(ans)


### FIXED CODE ###

from sys import setrecursionlimit


def dfs(i, j, c):
    visited[i][j] = 1
    current.append((i, j))
    for di, dj in (1, 0), (-1, 0), (0, 1), (0, -1):
        ni, nj = i + di, j + dj
        if not (0 <= ni < H and 0 <= nj < W and not visited[ni][nj]):
            continue
        if S[ni][nj] == c:
            continue
        dfs(ni, nj, not c)


setrecursionlimit(2 * 10 ** 5)
H, W = map(int, input().split())
S = [[c == "#" for c in input()] for _ in range(H)]

ans = 0
visited = [[0] * W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if S[i][j] and not visited[i][j]:
            current = []
            dfs(i, j, True)
            b, w = 0, 0
            for k, l in current:
                if S[k][l]:
                    b += 1
                else:
                    w += 1
            ans += b * w
print(ans)
n,k = map(int,input().split())
p = list(map(int,input().split()))
s = 0
m = 0
ans = 0
for i in range(k):
  s+=p[i]
for j in range(k,n):
  s-=p[j-k]
  s+=p[j]
  if s>m:
    f = j
    m = s
for k in range(f-k+1,f+1):
  for l in range(1,p[k]+1):
    ans+=l/p[k]
print(ans)

### FIXED CODE ###

from collections import deque 
n,k = map(int,input().split())
p = list(map(int,input().split()))
q = deque()
s = 0
m = 0
ans = 0
for i in range(len(p)):
  p[i]+=1
for j in range(n):
  s+=p[j]
  q.append(p[j])
  if len(q)>k:
    s-=q.popleft()
  if len(q)==k:
    m = max(m,s)
ans = m
ans/=2
print(ans)
def calcMax(i):
  now = numbers[i] 

  future_max = max(numbers[i+1:])
  #print(numbers[i+1:])
  t = numbers[i+1:]
  #print((max(t)))
  return future_max - now

n = int(input())

numbers = []
for i in range(n):
  numbers.append(int(input()))

m = -1000000001
ti = 1000000001
for i in range(len(numbers) - 1):
    if (i == 0 or i == len(numbers) - 1 or (numbers[i-1] >= numbers[i] and numbers[i] =< numbers[i+1])) and ti > numbers[i]:
      temp = calcMax(i)
      #print("temp: " + str(temp))
      if temp > m:
          m = temp

print (m)


### FIXED CODE ###

def calcMax(i):
  now = numbers[i]

  future_max = max(numbers[i+1:])
  #print(numbers[i+1:])
  t = numbers[i+1:]
  #print((max(t)))
  return future_max - now

n = int(input())

numbers = []
for i in range(n):
  numbers.append(int(input()))

m = -1000000001
ti = 1000000001
for i in range(len(numbers) - 1):
    if numbers[i] < ti:
      if (i == 0 or i == len(numbers) - 1 or (numbers[i-1] >= numbers[i] and numbers[i] <= numbers[i+1])):
        temp = calcMax(i)
        #print("temp: " + str(temp))
        if temp > m:
            m = temp
            ti = numbers[i]

print (m)
X,Y,A,B,C = map(int,input().split())
R = list(map(int,input().split()))
G = list(map(int,input().split()))
T = list(map(int,input().split()))
R.sort(reverse=True)
G.sort(reverse=True)
T.sort(reverse=True)
"""
print("X,Y:",X,Y)
print(R)
print(G)
print(T)
"""
R.append(0)
G.append(0)
T.append(0)

d=0
t=0
# TT = []
while X+Y-t > 0:
    # print("X+Y-t :",X+Y-t)

    if max(R[0],G[0],T[0])==R[0]:
        if X>0:
            d += R.pop(0)
            X += -1
        else:
            if G[0] >= T[0]:
                d += G.pop(0)
                Y += -1
            else:
                TT.append(T.pop(0))
                t += 1
            
    elif max(R[0],G[0],T[0])==G[0]:
        if Y>0:
            d += G.pop(0)
            Y += -1
        else:
            if R[0] >= T[0]:
                d += R.pop(0)
                X += -1
            else:
                TT.append(T.pop(0))
                t += 1
                
    else:
        d += T.pop(0)
        t += 1
    
print(d)

### FIXED CODE ###

X,Y,A,B,C = map(int,input().split())
R = list(map(int,input().split()))
G = list(map(int,input().split()))
T = list(map(int,input().split()))
R.sort(reverse=True)
G.sort(reverse=True)
R = R[:X]
G = G[:Y]
A = T+R+G
A.sort(reverse=True)
print(sum(A[:X+Y]))
print(sum([i for i in range(int(input()+1)) if (i % 3 != 0 and i % 5 != 0)]))


### FIXED CODE ###

print(sum([i for i in range(int(input())+1) if (i % 3 != 0 and i % 5 != 0)]))
import sys
def check(S, cnt):
    if len(S) < 2:
        print(cnt)
        sys.exit()
    for i in range(len(S) - 1):
        if S[i] ^ S[i + 1]:
            S = S[:i] + S[i + 2:]
            cnt += 2
            check(S, cnt)
    print(cnt)
    sys.exit()

S = list(map(int, list(input())))
check(S, cnt=0)

### FIXED CODE ###

def main():
    S = list(map(int, list(input())))

    cnt1 = sum(S)
    cnt0 = len(S) - cnt1
    print(2 * min(cnt0, cnt1))


if __name__ == "__main__":
    main()
n = int(input())

if n % 2 == 0:
    print((n / 2) ** 2)
else
    print(((n+1)/2) * (n-1)/2)

### FIXED CODE ###

n = int(input())

if n % 2 == 0:
    print(int((n / 2) ** 2))
else:
    print(int(((n+1)/2) * (n-1)/2))
a, b map(int, input().split())
c=a+b
d=a-b
e=a*b
print(max([c,d,e]))

### FIXED CODE ###

a, b = map(int, input().split())
c=a+b
d=a-b
e=a*b
print(max([c,d,e]))
#-------------------------------------------------------------------
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")
#-------------------------------------------------------------------

N = int(input())						# 5

P=[]
for i in range(N):
	x, y = map(int, input().split())
	P.append((x,y))

#print(P)


from itertools import permutations
from itertools import combinations
L = list(combinations(P, 2))
#print( L )
#print( len(L) )

A=[]

for l in L:
	a=l[1][0]-l[0][0]
	b=l[1][1]-l[0][1]
	A.append((a,b))

#print(A)


# 各朝食メニューの回数を調べる
from collections import defaultdict

d = defaultdict(int)
for b in A:
	d[b] += 1

#print(dict(d))
# => {'pan': 2, 'kome': 4, 'cereal': 1}

# Value降順
B=[]
for k, v in sorted(d.items(), key=lambda x: -x[1]):
	#print(str(k) + ": " + str(v))
	break

#print(k,v)

p=k[0]
q=k[1]

ans=0


def dellist(L, a, p,q):
	b = (a[0]-p, a[1]-q)
	c = (a[0]+p, a[1]+q)
	
	#print("__dellist, a,b,c", a,b,c)
	
	while b in L:
		L.remove(b)
		dellist(L, b, p,q)

	while c in L:
		L.remove(c)
		dellist(L, c, p,q)
	
	while a in L:
		L.remove(a)
	


while len(A)>0:
	a = A[0]
	ans+=1
	#print(ans, a, A)
	dellist(A, a, p, q)
	


print(ans)


### FIXED CODE ###

#-------------------------------------------------------------------
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")
#-------------------------------------------------------------------

N = int(input())						# 5

if N==1:
	print(1)
	exit()

P=[]
for i in range(N):
	x, y = map(int, input().split())
	P.append((x,y))

#print(P)


from itertools import permutations
from itertools import combinations
L = list(combinations(P, 2))
#print( L )
#print( len(L) )

A=[]

for l in L:
	a=l[1][0]-l[0][0]
	b=l[1][1]-l[0][1]
	if a<0:
		a,b=-a,-b
	if a==0 and b<0:
		b=-b
	A.append((a,b))

#print(A)


# 各朝食メニューの回数を調べる
from collections import defaultdict

d = defaultdict(int)
for b in A:
	d[b] += 1

#print("dict(d)", dict(d))
# => {'pan': 2, 'kome': 4, 'cereal': 1}

# Value降順
B=[]
for k, v in sorted(d.items(), key=lambda x: -x[1]):
	#print(str(k) + ": " + str(v))
	break

#print("k,v", k,v)

print(N-v)
h, w = map(int, input().split())
s = [input() for _ in range(h)]
INF = 10**9
dp = [[INF]*w for _ in range(h)]

dp[0][0] = 0 if s[0][0] == "." else 1

for i in range(w):
    for j in range(h):
        d, r = INF, INF

        if i != 0:
            r = dp[i - 1][j] + (s[i - 1][j] == "." and s[i][j] == "#")
        if j != 0:
            d = dp[i][j - 1] + (s[i][j - 1] == "." and s[i][j] == "#")

        dp[i][j] = min(r, d, dp[i][j])

print(dp[w-1][h-1])


### FIXED CODE ###

h, w = map(int, input().split())
s = [input() for _ in range(h)]

INF = 10**9
dp = [[INF]*w for _ in range(h)]

dp[0][0] = 0 if s[0][0] == "." else 1

for i in range(h):
    for j in range(w):
        d, r = INF, INF

        if i != 0:
            d = dp[i - 1][j] + (s[i - 1][j] == "." and s[i][j] == "#")
        if j != 0:
            r = dp[i][j - 1] + (s[i][j - 1] == "." and s[i][j] == "#")

        dp[i][j] = min(r, d, dp[i][j])

print(dp[h-1][w-1])
n= int(input())
x=0
while True:
    if int((n-(x**5))**(1/5))==(n-(x**5))**(1/5):
        print(-x,int((n+(x**5))**(1/5)))
        break
    if  int((n+(x**5))**(1/5))==(n+(x**5))**(1/5):
        print(x,int((n+(x**5))**(1/5)))
    x=x+1

### FIXED CODE ###

x = int(input())
for i in range(-1000,1000):
    for j in range(-1000,1000):
        if x == i**5 - j ** 5:
            print(i,j)
            exit()
import sys
sys.setrecursionlimit(10**6)

n = int(input())
a = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

a.sort()

ans = 0

for i in range(n):
    
    x = a[i]

    l = 0; r = n # 二分探索時は探索範囲は取り得る値+-1しておく

    while l+1 < r:
        c = (l+r)//2
        if a[c] < int(x**0.5)+1:
            l = c
        else:
            r = c

    tmp = 1
    for j in range(c+1):
        if i != j and x%a[j] == 0:
            break
    else:
        ans += tmp

print(ans)

### FIXED CODE ###

#Ai/Aj not integer
#5
#24 11 8 3 16
#のときは、24は8,3があるからダメ　16も8があるからダメ
N=int(input())
A=[int(i) for i in input().split()]
D=set()
S=set()
for i in range(N):
    if A[i] in S:
        D.add(A[i])
    else:
        S.add(A[i])
M=max(S)
X=[1 for i in range(M+1)]
for a in S:
    if a in D:
        X[a]=0
    for i in range(2*a,M+1,a):
        X[i]=0
ans=0
for i in range(N):
    if X[A[i]]==1:
        ans+=1
print(ans)
import numpy as np
import itertools

n = int(input())
ans =0
for a,b,c in itertools.product(range(1,n+1),repeat=3):

    g = np.gcd(np.gcd(a,b),c)
    ans +=g
print(ans)
    

### FIXED CODE ###

import numpy as np
K = int(input())
l = [0] *(K+1)
res = 0
for i in range(1,K+1):
    for j in range(1, K+1):
        gcd_ab = np.gcd(i,j)
        l[gcd_ab] +=1

for i in range(1, K+1):
    for j in range(1,K+1):
        gcd_c = np.gcd(i,j)
        res += l[j]* gcd_c


print(res)
import numpy as np
from scipy.sparse.csgraph import shortest_path
N = int(input())
L = np.full((N, N), np.inf)
for i in range(N-1):
  a, b, c = map(int, input().split())
  L[a-1][b-1] = c
  L[b-1][a-1] = c
L = shortest_path(L)
Q, K = map(int, input().split())
K -= 1
for i in range(Q):
  x, y = map(int, input().split())
  x -= 1
  y -= 1
  print (int(L[x][K] + L[K][y]))

### FIXED CODE ###

from collections import defaultdict as dd
from collections import deque
N = int(input())
D =dd(list)
for i in range(N-1):
  a, b, c = map(int, input().split())
  D[a-1].append((b-1, c))
  D[b-1].append((a-1, c))

Q, K = map(int, input().split())
K -= 1
L = [0 for _ in range(N)]
q = deque([])
q.append(K)
while len(q) > 0:
  a = q.pop()
  for b, c in D[a]:
    if L[b] == 0:
      L[b] = L[a] + c
      q.append(b)

for i in range(Q):
  x, y = map(int, input().split())
  print (L[x-1] + L[y-1])
r,g,d=map(int, input().spilit)
if (100r+10g+d)%4=0:
  print('YES')
else: print('NO')

### FIXED CODE ###

a,b,c= map(int, input().split())
if (100*a+10*b+c) % 4 == 0:
    print('YES')
else:
    print('NO')
N=int(input())
print(N*(N-1)/2)

### FIXED CODE ###

S=input()
T=input()
ans=0
for i in range(3):
  if S[i]==T[i]:
    ans+=1
print(ans)
n,k = map(int,input().split())
l = [int(i) for i in input().split()]
for i in range(k):
    l.remove(max(l))
print(sum(l))

### FIXED CODE ###

n,k = map(int,input().split())
l = [int(i) for i in input().split()]
ls = sorted(l)
if k == 0:
  print(sum(l))
else:
  print(sum(ls[:-k]))
def DI(n):
    D = []
    for i in range(1,int(n**0.5)+1):
        if n % i == 0:
            D.append(i)
            if i != n//i:
                D.append(n//i)
    d = sorted(D)[-2]
    return d

X = int(input())
d = DI(X)
a = 0
b = 0
for i in range(d+1):
    for a in range(i+1):
        b = i - a
        if a**5 + b**5 == X:
            print(str(a) + ' ' + str(b))
            break

### FIXED CODE ###

X = int(input())
flag = False
for i in range(-120,120):
    for j in range(-120,120):
        if i**5 - j**5 == X:
            print(str(i) + ' ' + str(j))
            flag = True
            break
    if flag:
        break
from operator import itemgetter

N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
A.sort()
BC = [[int(x) for x in input().split()]for _ in range(M)]
BC.sort(key = itemgetter(1),reverse=True)
x = 0
stim_bc = [0]

for i in BC:
    y = 0
    while(x+y<len(A) and y<i[0]):
        if(x+y == 0):
            stim_bc.append(i[1])
        else:
            stim_bc.append(i[1]+stim_bc[-1])
        y += 1
    x = y
stim_a = [0]
for ind,i in enumerate(A):
    if(ind==0):
        stim_a.append(i)
    else:
        stim_a.append(i+stim_a[-1])
max_score = 0
for i in range(len(A)):
    score = stim_bc[i]+stim_a[-1]-stim_a[i]
    if(score>max_score):
        max_score=score
    else:
        break

print(max_score)


### FIXED CODE ###

from operator import itemgetter
import sys
sys.setrecursionlimit(1000000)

N,M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
A.sort()
BC = [[int(x) for x in input().split()]for _ in range(M)]
BC.sort(key = itemgetter(1),reverse=True)

x = 0
bc_ind = 0
ans = 0
for ind,i in enumerate(A):
    bc = 0
    if(BC[bc_ind][0]>x):
        bc = BC[bc_ind][1]
        x+=1
    else:
        bc_ind+=1
        x = 1
        if(len(BC)<=bc_ind):
            ans += sum(A[ind:])
            break
        else:
            bc = BC[bc_ind][1]
    if(bc>i):
        ans += bc
    else:
        ans += sum(A[ind:])
        break
print(ans)
a,b,c=[int(x) for x in input().split()]
x = b
count = 0
while True:
    if x == a: break
    elif x%c == 0 : count +=
    b -=


### FIXED CODE ###

a,b,c=[int(x) for x in input().split()]
count = 0
for d in range(a,b+1):
    if c%d == 0 : count += 1
print(count)
A,B,C,D,E,F=map(int,input().split())
ans=(0,0,0)
F+=1
E=100*E/(100+E)
for a in range(0,F,A*100):
	for b in range(0,F-a,B*100):
		for c in range(0,F-a-b,C):
          	if a==0 and b==0:break
			for d in range(0,F-a-b-c,D):
				s=a+b+c+d
				e=100*(c+d)/s
				if ans[2]< e <= E:
					ans=(s,c+d,e)
				elif e>E:break
print(ans[0],ans[1])


### FIXED CODE ###

A,B,C,D,E,F=map(int,input().split())
ans=[100,-1]
e=E/(100+E)
W=[a+b for a in range(0,F+1,100*A) for b in range(0,F+1,100*B) if a!=0 or b!=0]
for w in W:
    for c in range(0,F-w+1,C):
        for d in range(0,F-w-c+1,D):
            s=c+d
            if w+s>F or s/(w+s)>e:break
            elif ans[1]/ans[0]<s/(w+s)<=e:
                ans=[w+s,s]
print(ans[0],ans[1])
st=input().split()
N=int(st[0]);A=int(st[1]);B=int(st[2])
print("{0}".format(min(A*N,B))

### FIXED CODE ###

s=input().split()
N=int(s[0]);A=int(s[1]);B=int(s[2])
if (N*A<=B):
    print("{0}".format(N*A))
else:
    print("{0}".format(B))
a,b,n = list(map(int, input().split()))

if a+b<=n:
  a=0
  b=0
else:
  if n>a:
    b-=(n-a)
    a=0
    if b<0:
      b=0
  else:
    a=n-a

print("%d %d" %(a,b))

### FIXED CODE ###

import math

def Is(x):
  flag = False
  i = 2
  while i < math.sqrt(x):
    if x % i==0:
      flag = True
      break
    i += 1
  return flag

a = int(input())
ans = 0
flag2 = True
i = 0
while flag2:
  flag2 = Is( a + i )
  ans = a + i
  i += 1

print(ans)
a, b, k = map(int, input().split())
m = 0
ans = []

if a < b:
    m = b
    n = a
else:
    m = a
    n = b

for i in range(1, m):
    if n % i == 0:
        ans.append(i)

#print(ans)
if ans:
    print(ans[k-1])
else:
    print("1")


### FIXED CODE ###

a, b, k = map(int, input().split())
m = 0
ans = []

if a < b:
    m = b
    n = a
else:
    m = a
    n = b

for i in range(1, n+1):
    if m % i == 0 and n % i == 0:
        ans.append(i)

if ans:
    print(ans[-k])
else:
    print("1")
n = int(input())
a = list(map(int, input().split()))

a_sorted = sorted(a)
divisible_list = [0] * 2 * 100010

for i in range(len(a)):
    # 過去にすでに同じ数字への加算があったら飛ばす
    if divisible_list[a[i]] > 2:
        continue
    for j in range(0, len(divisible_list), a[i]):
        divisible_list[j] += 1

ans = 0
for i in range(n):
    if divisible_list[a[i]] == 1:
        ans+=1
print(ans)

### FIXED CODE ###

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

a_sorted = sorted(a)
divisible_list = [0] * (max(a)+1)

for i in range(len(a)):
    for j in range(0, len(divisible_list), a[i]):
        divisible_list[j] += 1

ans = 0
for i in range(len(a)):
    if divisible_list[a[i]] == 1:
        ans+=1
print(ans)
a, b = map(int, input().split(' '))

if a >= 1 and a <= 9 and b >= 1 and b <= 9:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import sys

a = int(input())

for i in range(9):
    for j in range(9):
        if a == (i+1) * (j+1):
            print('Yes')
            sys.exit()
            
print('No')
print(sum([int(x) for x in input().split()].sort()[0:1]))

### FIXED CODE ###

a=[int(x) for x in input().split()]
print(sum(a)-max(a))