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

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
from bisect import insort
q = int(readline())
ch = []
cs = 0
cnt = 0
s = 0
for i in range(q):
  que = list(map(int,readline().split()))
  if que[0] == 1:
    a,b,c = que
    insort(ch,b)
    cnt += 1
    cs += b
    s += c
  else:
    if cnt%2 == 1:
      if cnt == 1:
        print(ch[0],s)
      else:
        d = ch[cnt//2]
        print(d,cs-2*sum(ch[:cnt//2])-d+s)
    else:
      if cnt == 2:
        print(ch[0],ch[1]-ch[0]+s)
      else:
        print(ch[cnt//2-1],cs-2*sum(ch[:cnt//2])+s)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
from bisect import insort

class BIT():
 
    def __init__(self, n):
        '''
        n = 要素数
        添字は i = 0 ~ n-1 となる
        '''
        self.n = n
        self.bit = [0] * (n + 1)
 
    def add(self, i, x):
        '''i番目の要素にxを加算する'''
        i = i + 1
        while i <= self.n:
            self.bit[i] += x
            i += i & -i
 
    def _sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s
 
    def get(self, i, j):
        '''[i, j)の和を求める'''
        return self._sum(j) - self._sum(i)
  
def compress(list1):
    list2 = sorted(set(list1))
    memo = {value : index for index, value in enumerate(list2)}
    return memo, len(list2)

q = int(readline())
info = [list(map(int, input().split())) for i in range(q)]
 
#座圧する
li1 = []
for i in range(q):
    if info[i][0] == 1:
        li1.append(info[i][1])
        
memo, len_memo = compress(li1)

def median():
    ok = len_memo
    ng = 0
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if 2 * bit1.get(mid, len_memo) <= cnt :
            ok = mid
        else:
            ng = mid
    return memo_inv[ng]
  
#値を管理するBIT
bit = BIT(len_memo)
#要素数を管理するBITに
bit1 = BIT(len_memo)
memo_inv = dict([(v,k) for k,v in memo.items()])
  
s = 0
cnt = 0
for i in range(q):
  que = info[i]
  if que[0] == 1:
    a,b,c = que
    s += c
    cnt += 1
    bit.add(memo[b],b)
    bit1.add(memo[b], 1)
  else:
    d = median()
    sum1 = bit.get(0, memo[d])
    num1 = bit1.get(0, memo[d])
    sum2 = bit.get(memo[d], len_memo)
    num2 = bit1.get(memo[d], len_memo)
    print(d, abs(num1*d- sum1) + abs(num2*d - sum2) + s)
### BUGGY CODE ###

import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, m = inintm()

ship = []

t = []

for _ in range(m):
    a, b = inintm()
    ship.append([a, b])
    if a == 1:
        t.append(b)

for s in ship:
    if s[0] in t and s[1] == n:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")


### FIXED CODE ###

import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n, m = inintm()

t = [0]*(n+1)

for _ in range(m):
    a, b = inintm()
    if a == 1:
        if t[b] == 1:
            print("POSSIBLE")
            exit()
        t[b] = 1
    elif b == n:
        if t[a] == 1:
            print("POSSIBLE")
            exit()
        t[a] = 1

print("IMPOSSIBLE")
### BUGGY CODE ###

nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, M = nl()
S = nl()
T = nl()

import numpy as np
dp = np.zeros((N+1, M+1), dtype=np.uint32)
for i in range(1, N+1):
    for j in range(1, M+1):
        dp[i, j] += dp[i-1, j] + dp[i, j-1]
        if S[i-1] == T[j-1]:
            dp[i, j] += 1
        else:
            dp[i, j] -= dp[i-1, j-1]
        dp[i, j] %= 1000000007

print(int(dp[N, M]+1))


### FIXED CODE ###

nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N, M = nl()
S = nl()
T = nl()

dp = [0] * (M+1)
for i, s in enumerate(S):
    dp2 = dp[:]
    for j, t in enumerate(T):
        dp2[j+1] += dp2[j] - dp[j]
        if s == t:
            dp2[j+1] += dp[j] + 1
    dp = dp2

print((dp[M]+1) % 1000000007)
### BUGGY CODE ###

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

r = []
for i in range(N - 1):
  for j in range(i+1, N):
    #r += (A[i]) ^ (A[j])
    r.append((A[i]) ^ (A[j]))

print(sum(r) % (10**9 + 7))

#print(bin(10**9 + 7))

### FIXED CODE ###

import numpy as np 
N = int(input())
A = np.fromstring(input(), dtype = np.int64, sep = ' ')

res = 0
for bit in range(60):
  c = int((A & 1).sum())
  res += c * (N - c) * (1 << bit)
  A >>= 1

print(res % 1000000007)
### BUGGY CODE ###

INF = 1000000000

N, M = list(map(int, input().split()))
a_list = []
c_list = []
for i in range(M):
    a, _ = list(map(int, input().split()))
    a_list.append(a)
    c = 0
    for one in list(map(int, input().split())):
        c |= 1<<(one-1)
    c_list.append(c)

dp = [INF]*(1<<N)
dp[0] = 0
for s in range(1<<N):
    for i in range(M):
        t = c_list[i] | s
        cost = a_list[i]+dp[s]
        dp[t] = min(dp[t], cost)

if dp[-1]==INF:
    print(-1)
else:
    print(int(dp[-1]))


### FIXED CODE ###

INF = 1000000000

N, M = list(map(int, input().split()))
a_list = []
c_list = []
for i in range(M):
    a, _ = list(map(int, input().split()))
    a_list.append(a)
    c = 0
    for one in list(map(int, input().split())):
        c |= 1<<(one-1)
    c_list.append(c)

dp = [INF]*(1<<N)
dp[0] = 0
for s in range(1<<N):
    for i in range(M):
        t = c_list[i] | s
        cost = a_list[i]+dp[s]
        dp[t] = min(dp[t], cost)

if dp[-1]==INF:
    print(-1)
else:
    print(int(dp[-1]))
### BUGGY CODE ###

import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import permutations
from heapq import heappush, heappop

def dijkstra(graph:list, node:int, start:int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF]*node
    
    # 始点ノードの距離を0とし、dfsのためのpriority queを作成
    dist[start] = 0
    heap = [(0,start)]
    
    # 未探索のノードをpriority queueに入れる
    while heap:
        cost, cur_node = heappop(heap)
        
        for nex_cost, nex_node in graph[cur_node]:
            dist_cand = dist[cur_node] + nex_cost
            if dist_cand < dist[nex_node]:
                dist[nex_node] = dist_cand
                heappush(heap, (dist[nex_node], nex_node))
    
    return dist

n,m,r = li()
r = list(li_())
graph = [[] for _ in range(n)]
for _ in range(m):
    a,b,c = li()
    a -= 1
    b -= 1
    graph[a].append((c,b))
    graph[b].append((c,a))
    
dists = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
    dists[i] = dijkstra(graph, n, i)

routes = list(permutations(r))

ans = 2**64-1
for route in routes:
    temp = 0
    for i in range(len(route)-1):
        temp += dists[route[i]][route[i+1]]
        
    ans = min(ans,temp)
    
print(ans)

### FIXED CODE ###

import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from itertools import permutations
from scipy.sparse.csgraph import floyd_warshall
import numpy as np

n,m,r = li()
r = list(li_())
abc = []
graph = np.zeros((n,n))
for _ in range(m):
    a,b,c = li()
    a -= 1
    b -= 1
    graph[a][b] = c
    graph[b][a] = c
    
floyd_warshall(graph, directed=False, overwrite=True)

routes = list(permutations(r))

ans = float("inf")
for route in routes:
    cand = 0
    for i in range(len(route)-1):
        cand += graph[route[i]][route[i+1]]
        
    ans = min(ans, cand)
        
print(int(ans))
### BUGGY CODE ###

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

def get_e(p):
    return p*(p+1)/2/p

e_list = [get_e(p[i]) for i in range(N)]
c_e_list = [sum(e_list[i:i+K]) for i in range(N-K+1)]
print(max(c_e_list))

### FIXED CODE ###

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

def get_e(p):
    return p*(p+1)/2/p

e_list = [get_e(p[i]) for i in range(N)]
c_e_list = [0 for i in range(N)]
c_e_list[0] = e_list[0]
for i in range(1, N):
    c_e_list[i] = c_e_list[i-1] + e_list[i]

max_e = c_e_list[K-1]
for i in range(1, N-K+1):
    e = c_e_list[i+K-1] - c_e_list[i-1]
    if e > max_e:
        max_e = e

print(max_e)
### BUGGY CODE ###

h,a,*m=open(0)
h,w,k,a,b,f,g=map(int,(h+a).split())
d=[I:=h*w]*I
a=~w+a*w+b
d[a]=1
q=[a]
for s in q:
 for y,x in(1,0),(-1,0),(0,1),(0,-1):
  for z in range(k):
   i,j=s//w+y*~z,s%w+x*~z;t=i*w+j
   if(h>i>-1<j<w)-1or'.'<m[i][j]or d[t]<=d[s]:break
   if d[t]==I:q+=t,;d[t]=d[s]+1
print(d[~w+f*w+g]%I-1)

### FIXED CODE ###

import sys
inf=1000002
sys.setrecursionlimit(inf)
from collections import deque
h,w,k=map(int,input().split())
x1,y1,x2,y2=map(int,input().split())
c=[input() for i in range(h)]
dp=[[inf if c[i][j]=="." else -1 for j in range(w)] for i in range(h)]
now=deque()
now.append([x1-1,y1-1])
dp[x1-1][y1-1]=0
#kの更新が遅い
def bfs(d):
    global h,w,k,dp,now,x2,y2
    l=len(now)
    if l==0:
        return
    dp_sub=deque()
    cand=set()
    for i in range(l):
        x,y=now.popleft()
        for j in range(1,min(k+1,w-y)):
            if dp[x][y+j]==inf:
                dp_sub.append([x,y+j,d])
                #dp[x][y+j]=d
                cand.add((x,y+j))
                #now.append([x,y+j])
            else:
                break
        for j in range(1,min(k+1,y+1)):
            if dp[x][y-j]==inf:
                dp_sub.append([x,y-j,d])
                #dp[x][y-j]=d
                cand.add((x,y-j))
                #now.append([x,y-j])
            else:
                break
        for j in range(1,min(k+1,h-x)):
            if dp[x+j][y]==inf:
                dp_sub.append([x+j,y,d])
                #dp[x+j][y]=d
                cand.add((x+j,y))
                #now.append([x+j,y])
            else:
                break
        for j in range(1,min(k+1,x+1)):
            if dp[x-j][y]==inf:
                dp_sub.append([x-j,y,d])
                #dp[x-j][y]=d
                cand.add((x-j,y))
                #now.append([x-j,y])
            else:
                break
    while dp_sub!=deque([]):
        e=dp_sub.popleft()
        dp[e[0]][e[1]]=e[2]
    for i in cand:
        now.append(i)
    bfs(d+1)
bfs(1)
print(dp[x2-1][y2-1] if dp[x2-1][y2-1]!=inf else -1)
### BUGGY CODE ###

import sys
n=int(input())
a=[]
hd=[0]*n
for i in range(n):
    a.append(tuple(map(int,input().split())))
loop=0
flag=0
while(flag<n):
    stk=[]
    for i in range(n):
        if hd[i]==n-1:
            continue
        idx=a[i][hd[i]]-1
        if hd[idx]==n-1:
            print(-1)
            sys.exit()
        if a[idx][hd[idx]]==i+1:
            stk.append(i)
    if not stk:
        loop=-2
        break
    for j in stk:
        hd[j]+=1
        if hd[j]==n-2:
            flag+=1
    loop+=1
print(loop+1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)
n=int(input())
a=[]
for i in range(n):
    a.append(tuple(map(int,input().split())))
#print(a)

root=[[] for i in range(n*(n-1)//2)]
buf=0
for i in range(n):
    buf=0
    for j in range(n-1):
        if j==0:
            x=min(i,a[i][j]-1)
            y=max(i,a[i][j]-1)
            buf=x*(2*n-2-x+1)//2+(y-x)-1
            #print(x,y,buf)
            continue
        x=min(i,a[i][j]-1)
        y=max(i,a[i][j]-1)
        node=x*(2*n-2-x+1)//2+(y-x)-1
        #print(x,y,node)
        root[buf].append(node)
        buf=node
flag=[True]

#閉路☑
def dfs(node,par): 
    dp[node]=0
    for item in root[node]:
        if item==par:
            continue
        if dp[item]==0:
            flag[0]=False
            return
        if dp[item]==-1: 
            dfs(item,node)
    dp[node]=1#finish
dp=[-1]*(n*(n-1)//2)
for i in range(n*(n-1)//2):
    if dp[i]==-1:
        dfs(i,i)
        if flag[0]==False:
            break
if flag[0]==False:
    print(-1)
    sys.exit()
dp=[-1]*(n*(n-1)//2)
def dfs1(node,par): 
    buf=0
    for item in root[node]:
        if item==par:
            continue
        if dp[item]!=-1:
            buf=max(buf,dp[item])
            continue
        if dp[item]==-1: 
            buf=max([buf,dfs1(item,node)])
    dp[node]=buf+1#finish
    return buf+1

for i in range(n*(n-1)//2):
    if dp[i]==-1:
        dp[i]=dfs1(i,i)
print(max(dp))
### BUGGY CODE ###

def main():
    n, q = map(int, input().split())
    s = input()

    tmp = [0] * (n + 1)

    for i in range(1,n):
        tmp[i] = 1 if s[i-1] ==  'A' and s[i] ==  'C' else 0
    
    for _ in range(q):
        l, r = map(int, input().split())
        count = 0
        for i in range(l,r):
            count += 1 if tmp[i] == 1 else 0
        print(count)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n, q = map(int, input().split())
    s = input()

    tmp = [0] * (n + 1)

    for i in range(1,n):
        tmp[i] = tmp[i-1] + ( 1 if s[i-1] ==  'A' and s[i] ==  'C' else 0 )
    
    for _ in range(q):
        l, r = map(int, input().split())
        print(tmp[r-1] - tmp[l-1])

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

from collections import deque,Counter
import bisect
n,*a = map(int,open(0).read().split())
c = Counter(a)
c = sorted(c.items())
a = deque(c)
p_set = set()
ans,r = 0,0
while a:
    f,count = a.popleft()
    z = []
    for u in range(len(a)):
        if a[u][0]%f != 0:
            z.append(a[u])
    a = deque(z[:])
    if count != 1:
        r += 1
    p_set.add(f)
print(len(p_set)-r)


### FIXED CODE ###

_,*a = map(int,open(0).read().split())
a.sort()
ans = 0
#M = 30
M = 10**6 + 1
l = [0] * (M)
ans = 0
for i in range(len(a)):
    if l[a[i]] == 0:
        l[a[i]] = 2
        ans += 1
        for x in range(a[i]*2, M, a[i]):
            l[x] = 1
    elif l[a[i]] == 2:
        ans -= 1
        l[a[i]] -= 1
print(ans)
### BUGGY CODE ###

h,w,d = map(int,input().split())
check = [[0,0]]*h*w
for i in range(h):
    c = 1
    for j in list(map(int,input().split())):
        check[j-1] = [c,i+1]
        c += 1
q = int(input())
for i in range(q):
    l,r = map(int,input().split())
    ans = 0;c = True
    if r == l:c = False
    while c:
        hn,wn = check[l-1][0],check[l-1][1]
        x,y = check[(l+d)%(h*w)-1][0],check[(l+d)%(h*w)-1][1]
        ans += abs(hn-x)+abs(wn-y)
        if r == (l+d)%(h*w):break
        l = (l+d)%(h*w)
    print(ans)

### FIXED CODE ###

h,w,d = map(int,input().split())
hw = [[-1,-1]]*(h*w)
for i in range(h):
        ls = list(map(int,input().split()))
        for j in range(len(ls)):
                hw[ls[j]-1] = [j,i]
check = [0]*(h*w)
for i in range(h*w):
        if i + d > h*w-1:break
        check[i] = abs(hw[i][0]-hw[i+d][0]) + abs(hw[i][1]-hw[i+d][1])
ios = [0]*(w*h)
for i in range(d):
        c = 0;beforj = 0
        for j in range(h*w-1-i,-1,-d):
                if c == 0:c = 1;beforj = j;continue
                ios[j] = ios[beforj] + check[j]
                beforj = j
q = int(input())
for i in range(q):
        l,r = map(int,input().split())
        print(ios[l-1]-ios[r-1])
### BUGGY CODE ###

s = raw_input()
K = int(raw_input())
subs = set()
for i in range(len(s)):
  for j in range(i, len(s)):
    subs.add(s[i:j+1])
subs = list(subs)
subs.sort()
print subs[K-1]


### FIXED CODE ###

s = raw_input()
K = int(raw_input())
subs = set()
for i in range(len(s)):
  for j in range(i, i+K+1):
    subs.add(s[i:j+1])
subs = list(subs)
subs.sort()
print subs[K-1]
### BUGGY CODE ###

N,K = [int(x) for x in input().split()]
arr=[]
for i in range(N):
    a,b = [int(x) for x in input().split()]
    arr = arr + [a]*b
arr.sort()
print(arr[K-1])


### FIXED CODE ###

N,K = [int(x) for x in input().split()]
arr=[]
for i in range(N):
    arr.append([int(x) for x in input().split()])
    
arr.sort(key=lambda tup: tup[0])

for i in range(N):
    K=K-arr[i][1]
    if K<=0:
        print(arr[i][0])
        break
### BUGGY CODE ###

from collections import deque

h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
ch, cw, dh, dw = ch-1, cw-1, dh-1, dw-1
s = [list(input()) for _ in range(h)]

def bfs(sy, sx):
    que = deque([])
    que.append([sy, sx])

    while que:
        y, x = que.popleft()
        dx, dy = [0,1,0,-1], [1,0,-1,0]
        for i in range(4):
            ny, nx = y+dy[i], x+dx[i]
            if ny < 0 or ny >= h or nx < 0 or nx >= w: continue
            if s[ny][nx] == '#': continue
            if seen[ny][nx] != -1: continue
            
            seen[ny][nx] = seen[y][x]
            que.append([ny, nx])
            wp.append([ny, nx])

            
dq = deque([])
dq.append([ch, cw])
seen = [[-1]*w for _ in range(h)]
seen[ch][cw] = 0
wp = deque([])
while dq:
    while dq:
        y, x = dq.popleft()
        wp.append([y, x])
        bfs(y, x)

    ok = False
    while wp:
        y, x = wp.popleft()
        for dy in range(-2, 3):
            for dx in range(-2, 3):
                if dy == 0 and dx == 0: continue
                ny, nx = y+dy, x+dx
                if ny < 0 or ny >= h or nx < 0 or nx >= w: continue
                if s[ny][nx] == '#': continue
                if seen[ny][nx] >= 0: continue

                ok = True
                seen[ny][nx] = seen[y][x] + 1
                dq.append([ny, nx])

    if not ok: break

if seen[dh][dw] >= 0:
    print(seen[dh][dw])
else:
    print(-1)

### FIXED CODE ###

from collections import deque

h, w = map(int, input().split())
ch, cw = map(int, input().split())
ch, cw = ch-1, cw-1
dh, dw = map(int, input().split())
dh, dw = dh-1, dw-1
s = [list(input()) for _ in range(h)]

def bfs(sy, sx):
    que = deque([])
    que.append([sy, sx])

    while que:
        y, x = que.popleft()
        dx = [0,1,0,-1]
        dy = [1,0,-1,0]
        for i in range(4):
            ny = y+dy[i]
            nx = x+dx[i]
            if ny < 0 or ny >= h or nx < 0 or nx >= w: continue
            if s[ny][nx] == '#': continue
            if seen[ny][nx] != -1: continue
            
            seen[ny][nx] = cnt[0]
            que.append([ny, nx])
            wp.append([ny, nx])

dq = deque([])
dq.append([ch, cw])
seen = [[-1]*w for _ in range(h)]
seen[ch][cw] = 0
cnt = [0]
wp = deque([])
ok = False

while dq:
    while dq:
        y, x = dq.popleft()
        bfs(y, x)
        wp.append([y, x])    

    ok = False
    while wp:
        y, x = wp.popleft()
        for dy in range(-2, 3):
            for dx in range(-2, 3):
                if dy == 0 and dx == 0: continue
                ny = y+dy
                nx = x+dx
                if ny < 0 or ny >= h or nx < 0 or nx >= w: continue
                if s[ny][nx] == '#': continue
                if seen[ny][nx] == -1:
                    ok = True
                    seen[ny][nx] = (cnt[0]+1)
                    dq.append([ny, nx])
    if ok:
        cnt[0] += 1

if seen[dh][dw] >= 0:
    print(seen[dh][dw])
else:
    print(-1)
### BUGGY CODE ###

def solve():
    dp = {}
    for i in range(W + 1):
        dp[0, i] = 0
    for i in range(N):
        for j in range(W + 1):
            if j < w[i]:
                dp[i + 1, j] = dp[i, j]
            else:
                dp[i + 1, j] = max(dp[i, j], dp[i, j - w[i]] +v[i])
    return dp[N, W]

N, W = map(int, input().split())
w = {}
v = {}
for i in range(N):
    w[i], v[i] = map(int, input().split())
print(solve())

### FIXED CODE ###

N, W = map(int, input().split())
dp = [0] * (W + 1)
for i in range(N):
    w, v = map(int, input().split())
    for j in range(W - w, -1, -1):
        dp[j + w] = max(dp[j + w], dp[j] + v)
print(dp[W])
### BUGGY CODE ###

s = input()

dp = [[0 for i in range(13)] for j in range(len(s))]
mod = 10 ** 9 + 7

for i, s_i in enumerate(s):
    if i == 0:
        if s_i == "?":
            for k in range(10):
                dp[0][k] = 1
        else:
            dp[0][int(s_i)] = 1

    else:
        if s_i == "?":
            for k1 in range(10):
                for k2 in range(13):
                    dp[i][(k2 * 10 + k1) % 13] += dp[i-1][k2] % mod

        else:
            for k in range(13):
                dp[i][(k*10+int(s_i))%13] += dp[i-1][k] % mod


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

### FIXED CODE ###

s = input()

dp = [[0 for i in range(13)] for j in range(len(s))]
mod = 10 ** 9 + 7

for i, s_i in enumerate(s):
    if i == 0:
        if s_i == "?":
            for k in range(10):
                dp[0][k] = 1
        else:
            dp[0][int(s_i)] = 1

    else:
        if s_i == "?":
            for k1 in range(10):
                for k2 in range(13):
                    dp[i][(k2 * 10 + k1) % 13] += dp[i-1][k2] % mod

        else:
            for k in range(13):
                dp[i][(k*10+int(s_i))%13] += dp[i-1][k] % mod


print(dp[-1][5] % mod)
### BUGGY CODE ###

import sys,heapq
input = sys.stdin.readline
def main():
    n,u,v = map(int,input().split())
    u,v = u-1,v-1

    edge = [[] for _ in range(n)]

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

    #cost:vからの距離
    cost = [0]*n
    new = [v]
    c = 1
    while len(new):
        tank = []
        for e in new:
            for go in edge[e]:
                if go != v and cost[go] == 0:
                    cost[go] = c
                    tank.append(go)
        c += 1
        new = tank

    res = 1
    new = [u]
    while len(new):
        tank = []
        for e in new:
            for go in edge[e]:
                if cost[go] > res:
                    tank.append(go)
        res += 1
        new = tank
    
    if cost[u]% 2 == 1:
        print(res-2)
    else:
        print(res-1)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys,heapq
input = sys.stdin.readline
def main():
    n,u,v = map(int,input().split())
    u,v = u-1,v-1

    edge = [[] for _ in range(n)]

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

    #cost:vからの距離
    cost = [0]*n
    new = [v]
    c = 1
    while len(new):
        tank = []
        for e in new:
            for go in edge[e]:
                if go != v and cost[go] == 0:
                    cost[go] = c
                    tank.append(go)
        c += 1
        new = tank

    if cost[u]%2 == 1:
        res = cost[u]//2
        now = u
        for _ in [0]*res:
            for e in edge[now]:
                if cost[now] > cost[e]:
                    now = e
        
        new = [now]
        while len(new):
            tank = []
            for e in new:
                for go in edge[e]:
                    if cost[go] > cost[e]:
                        tank.append(go)
            res += 1
            new = tank
        
        print(res-1)

    else:
        res = cost[u]//2-1
        now = u
        for _ in [0]*res:
            for e in edge[now]:
                if cost[now] > cost[e]:
                    now = e
        
        new = [now]
        while len(new):
            tank = []
            for e in new:
                for go in edge[e]:
                    if cost[go] > cost[e]:
                        tank.append(go)
            res += 1
            new = tank
        
        print(res)



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

n=int(input())
ans=0
l=[x for x in range(1,n+1)]
for i in range(1,n+1):
  num=n//i
  k=num*((2*i)+((num-1)*i))
  ans+=k//2
print(ans)

### FIXED CODE ###

n=int(input())
ans=0
for i in range(1,n+1):
  num=n//i
  k=num*i*(num+1)
  ans+=k//2
print(ans)