peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
from bisect import bisect_right
n = int(input())
A = sorted(list(map(int, input().split())))
p = A[-1]
i = bisect_right(A[:-1], p/2)
q = A[i] if abs(A[i-1]-p/2) <= abs(A[i]-p/2) else A[i]
print(p, q)
# Judge status: Wrong Answer
n = int(input())
ans = 10**12

for k in range(1,n+1//2):
    if n%k == 0 :
        m = n//k + k - 2
        if ans > m:
            ans = m

print(m)
# Judge status: Accepted
n = int(input())
an = [int(i) for i in input().split()]
lowe, min_an_sub = 0, an[0]
an_sub = []
for i in range(0, n):
    an_sub.append(an[i])
    min_an_sub = min(min_an_sub, an[i])
    if an_sub[i] <= min_an_sub:
        lowe += 1
print(lowe)
# Judge status: Wrong Answer
n,k=map(int,input().split())
a=list(map(int,input().split()))
z=a.index(1)
L= -(-z//(k-1))
R=-(-(n-z-1)//(k-1))
print(L+R)
# Judge status: Wrong Answer
#N=int(input())
N,K = map(int,input().split())
#N=int(input())
A = list(map(int,input().split()))
#S=str(input())

now=1
root=[1]
for i in range(N):
    now=A[now-1]
    if now in root:
        index=root.index(now)
        num=len(root[index:])
        root=root[index:]
        break
    else:
        root.append(now)

an = (K-i) - (K-i)//num * num
print(root[an-1])
# Judge status: Wrong Answer
N, K = map(int,input().split())
x = list(map(int,input().split()))
ans = 10**9 + 7
for i in range(N - K + 1):
	print(i)
	print(x[i],x[i+K-1])
	if ans > abs(x[i]) + abs(x[i+K-1]) :
		ans   = x[K-1+i] - x[i] + min( abs(x[K-1+i]) , abs(x[i]) )
print(ans)
# Judge status: Accepted
import math
n, k = map(int,input().split())
dat = list(map(int, input().split()))

i = dat.index(1) + 1 # 1 origin で i 個目に 1 がある

reached = k # 最初の1歩はkマス塗れる
# a: 残りはk-1マス塗れるので、残っている分を塗る(k<nなのでマイナスは考えない)
a = math.ceil((n - reached) / (k - 1))
print(1 + a)
# Judge status: Accepted
str = input().split()
n = str[0]
if n[0] == "9" or n[1] == "9": print("Yes")
else: print("No")
# Judge status: Accepted
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

a, b,c = map(int, input().split())

if a<=c<=b:
    print('Yes')
elif a>=c>=b:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
s = input().split(" ")
n = int(s[0])
numbers = [ i for i in input() if i != " "]
 
for i in range(n, 100001):
  found = False
  snum = str(i)
  for num in numbers:
    if num in snum:
      found = True
      break
  
  if found == False:
     print(i)
     break
# Judge status: Accepted
import math
from collections import deque
N = int(input())
A = list(map(int,input().split()))

M = 0
L = deque([0])
R = deque([0])
for i in range(1,N+1):
    L.append(math.gcd(L[-1],A[i-1]))
    R.appendleft(math.gcd(R[0],A[N-i]))
for j in range(N):
    m = math.gcd(L[j],R[j+1])
    M = max(M,m)
print(M)
# Judge status: Accepted
intInput = int(input())
a, b, c, d, e, f = 500, 100, 50, 10, 5, 1
sumResult = 0

num500 = intInput // 500
mod500 = intInput % 500
sumResult += num500 * 1000
num5 = mod500 // 5
sumResult += num5 * 5
print(sumResult)
# Judge status: Accepted
s=input()
ans=[0]*4
check='NWSE'
for i in range(len(s)):
  for j in range(len(check)):
    if s[i]==check[j]:
      ans[j]=1
if (ans[0]+ans[2])%2==0 and (ans[1]+ans[3])%2==0:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
import fractions
import sys
input = sys.stdin.readline

N,M = map(int,input().split())
a_array = list(map(int,input().split()))

lcm = 1
for a in a_array:
    a = a / 2
    lcm = a * lcm / fractions.gcd(a,lcm)
# print(lcm)

for a in a_array:
    p = lcm / (a / 2)
    if p % 2 == 0:
        print(0)
        exit()

m_max = M // lcm

print(int((m_max+1)//2))
# Judge status: Accepted
C=str(input())
print("vowel" if C=="a" or C=="e" or C=="i" or C=="o" or C=="u" else "consonant")
# Judge status: Accepted
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,K=map(int,input().split())
    if N%K==0:
        print(0)
    else:
        print(1)

if __name__ == '__main__':
    main()
# Judge status: Accepted
K,A,B=map(int,input().split())
ans = K+1
if (K - (A-1)) %2==0:
  ans=max(ans,((K-(A-1))//2)*(B-A)+A)
else:
  ans=max(ans,((K-(A-1))//2)*(B-A)+A+1)
print(ans)
# Judge status: Accepted
n,a,b = map(int,input().split())
if abs(a-b)%2 == 0:
  print(abs(a-b)//2)
else:
  print(min(2*n-a-b+1,a+b-1)//2)
# Judge status: Accepted
import math


def actual(x):
    amount = 100

    count = 0

    while True:
        amount *= 1.01
        amount = math.floor(amount)

        count += 1

        if amount >= x:
            return count

x = int(input())
print(actual(x))
# Judge status: Accepted
X, Y = map(int, input().split())
n, mod = divmod(X + Y, 3)


def modinv(a, mod=10 ** 9 + 7):
    return pow(a, mod - 2, mod)


def combination(n, r, mod=10 ** 9 + 7):
    r = min(r, n - r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i + 1, mod) % mod
    return res


if mod != 0 or not (X <= 2 * Y and Y <= 2 * X):
    print(0)
else:
    r = Y - n
    print(combination(n, r))
# Judge status: Accepted
n = int(input())
L = [0 for i in range(10**4+1)]
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            r = x**2 + y**2 + z**2 + x*z + x*y + z*y
            if r <= 10000:
                L[r] += 1
for i in range(1, n+1):
    print(L[i])
# Judge status: Wrong Answer
K = int(input())

from math import gcd


sum = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            sum += gcd(gcd(b,c), a)

print(sum)
# Judge status: Accepted
s = str(input())
t = str(input())

S = ''.join(sorted(s))
T = ''.join(sorted(t, reverse=True))
if S < T:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n,m = map(int,input().split())
py = []
p_y = [[] for i in range(n)]
for _ in range(m):
    p,y = map(int,input().split())
    py.append((p,y))
    p_y[p-1].append(y)
ans = {}
for i, tmp in enumerate(p_y):
    cnt = 1
    p_y[i] = tmp.sort()
    for j, jj in enumerate(tmp):

        ans[(i+1, jj)] = str(i+1).zfill(6) + str(j+1).zfill(6)


for i, tmp in enumerate(py):
    print(ans[tmp])
# Judge status: Wrong Answer
a, b, c, k = map(int, input().split())
if a >= k:
    print(1*a)
elif a < k and b >= k-a:
    print (1*a + b*0)
else:
    print(1*(k-a) + 0*b + c*(-1))
# Judge status: Accepted
def resolve():
    N = int(input())
    ans = 0
    for i in range(1, N+1):
        if len(str(i)) % 2 ==1:
            ans += 1
    print(ans)
    return

resolve()
# Judge status: Accepted
def main():
  h,n=map(int,input().split())
  dp=[10**9]*(h+1)
  dp[h]=0
  for i in range(n):
    a,b=map(int,input().split())
    for j in range(h,0,-1):
      nxt=j-a
      if nxt<0:
        nxt=0
      if dp[nxt]>dp[j]+b:
        dp[nxt]=dp[j]+b
  print(dp[0])
main()
# Judge status: Wrong Answer
n, a, b = map(int, input().split())

x = (b-a) % 2
if x == 1:
    ans = 0
    if (a-1) < (n-b):
        d = a-1
        y = b - a
        ans += a
        ans += y // 2
    else:
        d = n-b
        y = a + b
        ans += (n-b) + 1
        ans += (n-y) // 2
    ans = min([ans, b-1, n-a])
    print(ans)
else:
    print((b-a+1)//2)
# Judge status: Accepted
x = int(input())
y = 100
n = 0
while True:
    y = int(y * 1.01)
    n = n + 1
    if y >= x:
        break
print(n)
# Judge status: Wrong Answer
def manhattan(u, v):
  return abs(u[0]-v[0])+abs(u[1]-v[1])

N, M = map(int, input().split())
ns = [list(map(int, input().split())) for _ in range(N)]
ms = [list(map(int, input().split())) for _ in range(M)]

for n in ns:
  dmin = 100000005
  num = -1
  for i, m in enumerate(ms):
    d = manhattan(n, m)
    if d < dmin:
      dmin = d
      num = i
  print(num+1)
# Judge status: Accepted
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a_s = sorted(a, reverse=True)
    res = 0
    num = 0
    for i in range(n*3):
        if i % 2 == 1 and num < n:
            res = res + a_s[i]
            num += 1
    print(res)
if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
from fractions import gcd
import math
a,b,c,d = map(int,input().split())
dum = b-a
ans1 = dum//c
ans2 = dum//d
ans3 = dum//(c*d/gcd(c,d))

print(math.ceil(dum-ans1-ans2+ans3))
#print(ans1,ans2,ans3)
# Judge status: Accepted
a,b=map(int, input().split())
s=input()
flag=True
for i in range(a+b+1):
  if s[a]!="-":
    flag=False
  elif i!=a and not s[i].isdigit():
    flag=False
print("Yes" if flag else "No")
# Judge status: Accepted
s = input()
res = {u for u in s}
if len(res) == 2:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
S = input()
f,e = int(S[:2]),int(S[2:])
if f>12:
  if 1<=e<=12:
    print('YYMM')
  else:
    print('NA')
elif 1<=f<=12:
  if e>12:
    print('MMYY')
  elif 1<=e<=12:
    print('AMBIGUOUS')
  else:
    print('NA')
else:
  print('NA')
# Judge status: Accepted
from collections import defaultdict

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,m = readInts()
ab = [readInts() for i in range(n)]
ab.sort()
i = 0
ans = 0
while m>0:
	if m>=ab[i][1]:
		m-=ab[i][1]
		ans+=ab[i][0]*ab[i][1]
		i+=1
	else:
		ans += m*ab[i][0]
		m = 0
print(ans)
# Judge status: Accepted
n=int(input())
q,mod=divmod(n,2)

print(q+mod)
# Judge status: Wrong Answer
n,m = input().split()
if n == m :
  print('AC')
else :
  print('No')
# Judge status: Accepted
from collections import deque
n=int(input())
a=list(map(int,input().split()))
s=deque()
for i in range(n):
    if i%2==0:
        s.append(str(a[i]))
    else:
        s.appendleft(str(a[i]))
s=list(s)
if n%2==1:
    s=s[::-1]
print(' '.join(s))
# Judge status: Accepted
# from pprint import pprint
# import math
# import collections
from numba import jit

N = int(input())

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

@jit(cache=True)
def calc(x, y, z):
    return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x


res = [0] * 1000009

for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            n = calc(x, y, z)
            res[n - 1] += 1

for i in range(N):
    print(res[i])
# Judge status: Accepted
n, k = map(int, input().split())
s = "X" + input() + "X"
t = [s[i] == s[i + [1, -1][s[i] == "L"]] for i in range(1, n + 1)]
print(min(sum(t) + k * 2, n - 1))
# Judge status: Accepted
input()
*p,=map(int,input().split())
print('YNEOS'[2<sum([1 for i,j in zip(p,sorted(p)) if i!=j])::2])
# Judge status: Accepted
H1,M1,H2,M2,K=map(int,input().split())
T1=60*H1+M1
T2=60*H2+M2
T=T2-T1-K
if T<0:
    T=0
print(T)
# Judge status: Accepted
n = int(input())
s = [input() for _ in range(n)]
#print(s)

print('AC x ' + str(s.count('AC')))
print('WA x ' + str(s.count('WA')))
print('TLE x ' + str(s.count('TLE')))
print('RE x ' + str(s.count('RE')))
# Judge status: Wrong Answer
n=int(input())
s=input()
mod = 1e9+7
ans = [1]*30
for c in s:
    ans[ord(c)-ord('a')]+=1
res = 1
for i in range(29):
    res *= ans[i]
    res %= mod
print((res-1)%mod)
# Judge status: Accepted
N = int(input())

ans = 0

for i in range(1,N+1) :
    dev = 0
    if i%2 == 0 :
        continue
    for j in range(1,i+1) :
        if i%j == 0 :
            dev += 1
    if dev == 8 :
        ans += 1

print(ans)
# Judge status: Wrong Answer
def main():
    A, B = map(int, input().split())
    p = A * B
    if p>81:
        print(-1)
    else:
        print(p)
main()
# Judge status: Accepted
w, h, n = map(int,input().split())

hani = [0,w,0,h]

for i in range(n):
    x, y, a = map(int,input().split())
    if a == 1:

        hani[0] = max(hani[0],x)
    elif a == 2:
        hani[1] = min(hani[1],x)
    elif a == 3:
        hani[2] = max(hani[2],y)
    else:
        hani[3] = min(hani[3],y)

print(max(0,hani[1]-hani[0]) * max(0,hani[3]-hani[2]))
# Judge status: Wrong Answer
N, A, B = map(int, input().split())
cnt = 0
keta4 = 0 
keta3 = 0
keta2 = 0
keta1 = 0

for i in range(1,N+1):
  keta4 = i//1000
  keta3 = (i-keta4*1000)//100
  keta2 = (i-keta4*1000-keta3*100)//10
  keta1 = i%10
  if keta1+keta2+keta3+keta4 >= A and keta1+keta2+keta3+keta4 <= B:
    cnt = cnt+i
print(cnt)
# Judge status: Wrong Answer
N = int(input())
list = list(input())
check = [False] * len(list)

i = 0
while(i):
    if list[i] == ')' and i > 0 and list[i-1] == "(":
        check[i] = True
        check[i - 1] = True

    i += 1
    if len(list) <= i: break

count = {
    '(': 0,
    ')': 0
}

for b, v in zip(check, list):
    if not b:
        count[v] += 1

print("(" * count[')'] + "".join(list) + ")" * count["("])
# Judge status: Accepted
n, y = map(int, input().split())

for i in range(n + 1):
    for j in range(n + 1 - i):
        k = (y - i * 10000 - j * 5000) // 1000
        if i + j + k == n:
            print(i, j, k)
            exit()

print(-1, -1, -1)
# Judge status: Accepted
a, b, c, d = list(input())
ll = ["+", "-"]
for x in ll:
    for y in ll:
        for z in ll:
            if eval(a+x+b+y+c+z+d) == 7:
                print(a+x+b+y+c+z+d+"=7")
                exit()
# Judge status: Wrong Answer
K, X = map(int, input().split())
print(x for x in range(X-K+1, X+K) if -10**6 <= x >= 10**6)
# Judge status: Wrong Answer
s=input()
N,K=s.split()
N=int(N)
K=int(K)
line=[]
number=[]
count=0
for n in range(K*2):
    line+=[input()]
for m in range(K):
    line[2*m+1]=line[2*m+1].split()
    number+=line[2*m+1]
for i in range(K):
    if str(i+1) in number:
        count+=1
print(K-count)
# Judge status: Accepted

a,b,k = map(int,input().split())
l = []
c = min(a,b)
d = max(a,b)

for i in range(1,c+1):
    if c % i == 0 and d % i == 0:
        l.append(i)

#print(l)
print(l[-k])
# Judge status: Accepted
n = int(input())
xyl = [tuple(map(int, input().split())) for _ in range(n)]

xyp = []
xym = []

for x,y in xyl:
    xyp.append(x+y)
    xym.append(x-y)

# xyp.sort()
# xym.sort()

ans1 = max(xym)-min(xym)
# print(ans1)
ans2 = max(xyp)-min(xyp)
ans = max(ans1,ans2)
print(ans)
# Judge status: Accepted
import sys
input = sys.stdin.readline
N = int(input())
a = [0] + [int(x) for x in input().split()]

ans = [0 for _ in range(N+1)]
for i in reversed(range(1,N+1)) :
    temp = 0
    for j in range(N//i) :
        temp += ans[(j+1) * i]
    if temp%2 != a[i] :
        ans[i] = 1

print(sum(ans))
ans2 = []
for i in range(N+1) :
    if ans[i] == 1 :
        ans2.append(i)
print(*ans2)
# Judge status: Wrong Answer
k = int(input())
print(k // 2 - -k // 2)
# Judge status: Accepted
w, h, n = map(int, input().split())
u, d = 0, h
l, r = 0, w

for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        l = max(l, x)
    if a == 2:
        r = min(r, x)
    if a == 3:
        u = max(u, y)
    if a == 4:
        d = min(d, y)
print(max(0, (d-u)) * max(0, (r-l)))
# Judge status: Accepted
n = int(input())
a = [int(input()) for _ in range(n)]

a_max = max(a)
a_second = sorted(a, reverse=True)[1]

for i in range(n):
    if a[i] == a_max:
        print(a_second)
    else:
        print(a_max)
# Judge status: Accepted
S = input()

ma = 0
tmp = 0
acgt = ('A','C','G','T')

for s in S:
    if s in acgt:
        tmp += 1
        ma = max(ma,tmp)
    else:
        tmp = 0
print(ma)
# Judge status: Accepted
l = [int(input()) for _ in range(5)]
k = int(input())
 
flag = False
for i in range(5):
  for j in range(i +1, 5):
    if l[j] - l[i] > k:
      flag = True
      break
 
if flag:
  print(":(")
else:
  print("Yay!")
# Judge status: Accepted
a, b, c, d = map(int, input().split())
n = -(-c//b)
m = -(-a//d)
if n <= m:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n, k = list(map(int, input().split()))
r, s, p = list(map(int, input().split()))

t = input()
last = ["" for _ in range(k)]
move = {"r": "p", "p": "s", "s": "r"}
pts = {"r": r, "p": p, "s": s}
score = 0

res = ""
for i in range(n):
    if move[t[i]] != last[i%k]:
        score += pts[move[t[i]]]
        last[i%k] = move[t[i]]

        res += move[t[i]]
    else:
        last[i%k] = t[i]
        res += t[i]

print(score)
# Judge status: Accepted
def resolve():
    N = int(input())
    d = list(map(int, input().split()))
    
    d.sort()
    if d[int(N/2-1)] < d[int(N/2)]:
        ans = len(range(d[int(N/2-1)], d[int(N/2)]))
    else:
        ans = 0
    print(ans)
resolve()
# Judge status: Accepted
N = int(input())
P = list(map(int, input().split()))

ans = 0

for i in range(N):
    if P[i] == i + 1:
        if i + 1 < N:
            P[i], P[i + 1] = P[i + 1], P[i]
        ans += 1
print(ans)
# Judge status: Wrong Answer
import numpy as np
n,m=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
A=list(set(A))
A=np.array(A)
cnt=0

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

def lcm(a,b):
  return a*b//gcd(a,b)

while sum(A%2)==0:
    cnt+=1
    A//=2
if np.sum(A%2)!=len(A):
    ans=0
else:
  maxbai=A[-1]
  for i in range(len(A)):
    maxbai=lcm(A[-i-1],maxbai)
  for i in range(cnt):
    m=m//2
  ans=m//maxbai+1
print(ans)
# Judge status: Accepted
N, M, K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))

a,b=[0] ,[0]
for i in range(N):
    a.append(a[i] + A[i])
for i in range(M):
    b.append(b[i] + B[i])
    
ans, j=0, M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j-=1
    ans=max(ans, i+j)
print(ans)
# Judge status: Wrong Answer
from math import ceil
H,W=map(int,input().split())
print(int(ceil(H*W/2)))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split())) 

"""
A[i] + A[j] = j - i
A[i] + i = j - A[j]

a = A[i] + i
b = j - A[j]
"""

ans = 0
dic = {}

for i in range(N-1, -1, -1):
    wa = A[i] + i
    if wa in dic:
        ans += dic[wa]
    sa = i - A[i]
    if sa in dic:
        dic[sa] += 1
    else:
        dic[sa] = 1
print(ans)
# Judge status: Accepted
import itertools

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

res = []

for i in range(M):
    ab = list(map(int, input().split()))
    res.append(ab)

res = list(itertools.chain.from_iterable(res))

for i in range(N):
    print(res.count(i+1))
# Judge status: Accepted
Num,Rate=map(int,input().split())
if Num>=10:
    print(Rate)
else:
    print(int(Rate+100*(10-Num)))
# Judge status: Wrong Answer
from _collections import defaultdict
from itertools import combinations
n=int(input())
S=input()
X=defaultdict(int)
for s in S:
    X[s]+=1
A=0
for i in range(1,len(X.keys())+1):
    for comb in combinations(X.keys(),i):
        ans=1
        for c in comb:
            ans*=X[c]
        A+=ans
print(A)
# Judge status: Accepted
d,t,s=map(int,input().split())
if d-t*s<=0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
S = list(input())
T = list(input())

lst_of_values = []
for i in range(len(S)):
    current = 0
    if i + len(T) > len(S):
        break

    k = 0
    for j in range(i, i+len(T)):
        if S[j] != T[k]:
            current += 1
        k+=1
    lst_of_values.append(current)
    k=0

print(min(lst_of_values))
# Judge status: Accepted
from functools import reduce
N = int(input())
values = sorted([int(i) for i in input().split()])

print(reduce(lambda a, b: (a + b)/2, values))
# Judge status: Wrong Answer
Q, H, S, D = map(int, input().split())
N = int(input())

PS = [[Q * 8, 0.25], [H * 4, 0.5], [S * 2, 1], [D, 2]]

PS.sort(key=lambda x: x[0])


R = N
ans = 0
for i in range (4):
    if R == 0:
        break
    elif R >= PS[i][1]:
        ans += PS[i][0] * PS[i][1] / 2 * (R // PS[i][1])
        R = R % PS[i][1]

print(int(ans))
# Judge status: Wrong Answer
q = ['dream','dreamer','erase','eraser']
s = input()

while True:
  if len(s) == 5 or len(s) == 7 or len(s) == 6:
    break
  if s[-5:] in q:
    s = s[0:-5]
  elif s[-7:] in q:
    s = s[0:-7]
  elif s[-6:] in q:
    s = s[0:-6]
  else:
    print('N0')
    exit()
    
if s in q:
  print('YES')
else:
  print('NO')
# Judge status: Wrong Answer
s = str(input())
l = ['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
 
if s == "SUN":
  print(7)
else:
  for i in range(7):
    if s == l[i]:
       print(i)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**6)

N = int(input())

ans = 0

for i in range(1, N+1):
    n = N//i
    tot = i*(1+n)*n//2
    ans += tot
    
print(ans)
# Judge status: Accepted
a = [0]*5
for i in range(5):
  a[i] = int(input())
k = int(input())
if a[4]-a[0]<=k:
  print('Yay!')
else:
  print(':(')
# Judge status: Accepted
def main():
    import sys
    input = sys.stdin.readline
    N, M = map(int, input().split())
    AB = sorted([tuple(map(int, input().split())) for _ in range(N)])
    money = 0
    count = 0
    for a, b in AB:
        if count + b >= M:
            money += a * (M - count)
            break
        else:
            money += a * b
            count += b
    print(money)


if __name__ == '__main__':
    main()
# Judge status: Accepted
from collections import Counter
n = int(input())
s = list(input())
c = Counter(s)
ans = 1
for i in c.values():
    ans =  (ans * (i+1)) % 1000000007
print(ans-1)
# Judge status: Accepted
s = input()
l = []

for i in s:
    if i != "B":
        l.append(i)
    else:
        if l != []:
            del l[-1]

print("".join(l))
# Judge status: Accepted
a,b=map(int,input().split())
if a<=8 and b<=8:
    print('Yay!')
else:
    print(':(')
# Judge status: Wrong Answer
s = input()
#dummy = set(s)
#print(dummy,s[0],s[2])
ans = s[0]
count = 0
for i in s:
  if i == ans:
    count += 1
  else:
    count = 0
  ans = i
if count <= 2:
  print("No")
else:
  print("Yes")
# Judge status: Wrong Answer
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for a,b in ab:
    ans = [0,10**8+1]
    for i in range(m):
        c,d = cd[i][0], cd[i][1]
        if abs(a-c) + abs(b-d) < ans[1]:
            ans = [i, abs(a-c) + abs(b-d)]
    print(ans[0]+1)
# Judge status: Wrong Answer
S = input()
print("2018"+S[:4])
# Judge status: Wrong Answer
X = int(input())
ans = 1
for b in range(1,101):
    for p in range(2,10):
        if X >= b**p and X > ans:
            ans = b**p
print(ans)
# Judge status: Accepted
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, B, C = map(int, readline().split())
    if A<C<B or A>C>B:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()
# Judge status: Accepted
s, t = map(int, raw_input().split())
ans = 0
for a in range(s, t + 1):
    a = str(a)
    flag = 0
    for i in range(len(a)):
        if a[i] != a[len(a) - 1 - i]:
            flag = 1
            break
    if flag == 0:
        ans += 1
print ans
# Judge status: Accepted
N, C,K = map(int, input().split())

T = []
for _ in range(N):
    T.append(int(input()))

T = sorted(T)

Standard = T[0] + K
count = 1


ans = 0
for i in range(1,N):
    if (count == C) or (Standard < T[i]):
        ans = ans + 1
        count = 1 
        Standard = T[i] + K
    else:
        count = count + 1

print(ans+1)
# Judge status: Wrong Answer
N,K = map(int, input().split())
A = [int(i) for i in input().split()]

IDX = A.index(min(A))

ans = 0
ans += max(0, (IDX + K - 2) // (K - 1))
ans += max(0, (N - IDX + K - 3) // (K - 1))
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(input().split())
B = [0 for i in range(N)]
for i in range (N-1):
  for j in range (i-1,N+1):
    if int(A[i])==j:
      B[j-1]=B[j-1]+1
[print(i) for i in B]
# Judge status: Wrong Answer
s=[input()]
q=int(input())
turn=True
l=""
for i in range(q):
    qq=input().split()
    if qq[0]=='1':
        turn=not turn
    else:
        if turn and int(qq[1])-2:
            l+=qq[2]
        else:
            s.append(qq[2])

text=l+"".join(s)
print(text if turn else text[::-1])
# Judge status: Wrong Answer
s = input()
n = len(s)
n //= 2
ans = 0
for i in range(n):
    if not s[i] == s[n-i]:
        ans += 1

print(ans)
# Judge status: Wrong Answer
def square(list):
    return [i ** 2 for i in list]
m = 1000000007
n = int(input())
A = list(map(int, input().split()))
sq = square(A)
s1 = sum(A)
s2 = sum(sq)

result = (s1**2-s2)/2
print(int(result%m))