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

import math
import sys
sys.setrecursionlimit(10 ** 6)
def input():
    return sys.stdin.readline()[:-1] 

d,g = [int(i) for i in input().split()]
P = []
C = []
for i in range(d):
    p,c = [int(i) for i in input().split()]
    P.append(p)
    C.append(c)

# cnt = 0
# def count():
#     global cnt
#     cnt+=1
#     print(cnt)

def flag(point,P,now):
    if point+100*(now+1)*P >= g: return 1
    else: return 0

m = 10**9
def score(point = 0, n = 0, now=-1, done=[]):
    global m
    if m <= n: return
    elif point >= g: m = n
    elif flag(point,P[now],now):
        n += math.ceil((g-point)/(100*(now+1)))
        if m > n: m = n
    else:
        if now == -1:
            for i in range(d):
                score(point, n, i, done)
        elif m <= n+P[now]: return
        else:
            done = done[:]
            done.append(now)
            nxtp = point+P[now]*100*(now+1) + C[now]
            for i in range(d):
                if not i in done:
                    score(nxtp, n + P[now], i, done)

score()
print(m)

### FIXED CODE ###

import math
 
d,g = [int(i) for i in input().split()]
P = []
C = []
for i in range(d):
    p,c = [int(i) for i in input().split()]
    P.append(p)
    C.append(c)

# cnt = 0
# def count():
#     global cnt
#     cnt+=1
#     print(cnt)

def flag(point,P,now):
    if point+100*(now+1)*(P-1) >= g: return 1
    elif point+100*(now+1)*P + C[now] >= g: return 2
    else: return 0

m = 10**9
def score(point = 0, n = 0, now=-1, remain = list(range(d))):
    global m
    if m <= n: return
    elif now == -1:
        for i in remain:
            score(point, n, i, remain)
    elif point >= g: m = n
    elif flag(point,P[now],now) == 1:
        n += math.ceil((g-point)/(100*(now+1)))
        if m > n: m = n
    elif flag(point,P[now],now) == 2:
        n += P[now]
        if m > n: m = n
    else:
        if m <= n+P[now]: return
        else:
            remain = remain[:]
            remain.remove(now)
            nxtp = point + P[now]*100*(now+1) + C[now]
            for i in remain:
                score(nxtp, n + P[now], i, remain)

score()
print(m)
### BUGGY CODE ###

import copy
D = int(input())
c = list(map(int,input().split()))
s = [ [0 for j in range(26)] for i in range(D)]
for i in range(D):
    tmp = list(map(int,input().split()))
    for j in range(26):
        s[i][j] = tmp[j]
t = []
v = [0] * D
last = [ [0 for j in range(26)] for i in range(D)]
sum = 0
for i in range(D):
    max = -10000
    for j in range(26):
        tmp_sum = sum
        tmp_last = copy.deepcopy(last)
        tmp_sum += s[i][j]
        tmp_last[i][j] = i+1
        for k in range(26):
            tmp_sum -= c[k] * ( (i+1) - tmp_last[i][j] )
        if tmp_sum > max:
            max_j = j
            max = tmp_sum
            last[i][j] = i+1
    sum = max
    t.append(max_j+1)


for i in range(D):
    print(t[i])

### FIXED CODE ###

import copy
D = int(input())
c = list(map(int,input().split()))
s = [ [0 for j in range(26)] for i in range(D)]
for i in range(D):
    tmp = list(map(int,input().split()))
    for j in range(26):
        s[i][j] = tmp[j]
t = []
v = [0] * D
last = [ [0 for j in range(26)] for i in range(D)]
sum = 0
for i in range(D):
    max = -10000
    tmp_last = copy.deepcopy(last)
    for j in range(26):
        tmp_sum = sum
        if j != 0:
            tmp_last[i][j-1] = last[i][j-1]
        tmp_sum += s[i][j]
        tmp_last[i][j] = i+1
        for k in range(26):
            tmp_sum -= c[k] * ( (i+1) - tmp_last[i][j] )
        if tmp_sum > max:
            max_j = j
            max = tmp_sum
            last[i][j] = i+1
    sum = max
    t.append(max_j+1)


for i in range(D):
    print(t[i])
### BUGGY CODE ###

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


for skip_num in range(N):
    sum = 0
    pos = 0
    for i in range(N):
        if i == skip_num:
            continue
        sum += abs(pos - As[i])
        pos = As[i]
    sum += abs(pos)
    print(sum)


### FIXED CODE ###

N = int(input())
As = [0]
As.extend(map(int, input().split()))
As.append(0)

sum = 0
pos = 0
for i in range(1, N + 2):
    sum += abs(pos - As[i])
    pos = As[i]

for i in range(1, N + 1):
    skip_pos = As[i]
    pre_pos = As[i - 1]
    post_pos = As[i + 1]

    if (pre_pos - skip_pos) * (post_pos - skip_pos) <= 0:
        print(sum)
    else:
        print(sum - abs(pre_pos - skip_pos) - abs(post_pos - skip_pos) + abs(pre_pos - post_pos))
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
output = 1
for i in range(N):
  output *= A[i]
print(output if output <= 10**18 else -1)

### FIXED CODE ###

import sys
N = int(input())
A = list(map(int,input().split()))
A.sort()
mul = A[0]
for i in range(1,N):
  mul *= A[i]
  if mul > 10**18:
    print(-1)
    sys.exit()
print(mul)
### BUGGY CODE ###

from bisect import bisect
L = list(map(int,input().split()))
N = L[0]
M = L[1]
P = list()
Y = list()
S = list()
for x in range(0,N):
    S.append(list())
for x in range(0,M):
    X = list(map(int,input().split()))
    P.append(X[0])
    Y.append(X[1])
    S[X[0]-1].append(X[1])
    S[X[0]-1] = sorted(S[X[0]-1])
for y in range(0,M):
    n = 0
    n = bisect(S[P[y]-1],Y[y])
    nstr = str(n)
    Pstr = str(P[y])
    while len(nstr) < 6:
        nstr = '0' + nstr
    while len(Pstr) < 6:
        Pstr = '0' + Pstr
    number = Pstr + nstr
    print(number)

### FIXED CODE ###

L = list(map(int,input().split()))
N = L[0]
M = L[1]
PY = list()

for x in range(0,M):
    X = list(map(int,input().split()))
    PY.append((X[0],X[1],x))

sortedPY = sorted(PY, key=lambda x:x[1])
ID = [0 for i in range(N)]

for y in range(0,M):
    n = sortedPY[y][0]
    n = n-1
    ID[n] = ID[n] + 1
    nstr = str(ID[n])
    Pstr = str(sortedPY[y][0])
    while len(nstr) < 6:
        nstr = '0' + nstr
    while len(Pstr) < 6:
        Pstr = '0' + Pstr
    PY[sortedPY[y][2]] = Pstr + nstr
    number = Pstr + nstr

for x in range(0,M):
    print(PY[x])
### BUGGY CODE ###

N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))
H_dict = []
for h in range(N):
    H_dict.append([h+1, H[h]])
cnt = 0
for h in range(N):
    tmp_h = H_dict[h][1]
    edge_h = []
    cnt2 = 0
    for ab in AB:
        if h+1 in ab:
            edge_h.append(ab)
    for edge in edge_h:
        left = [i for i in edge if i != h+1]
        z = left[0]
        if H_dict[z-1][1] >= tmp_h:
            cnt2 += 1
    if cnt2 == 0:
        cnt += 1
print(cnt)

### FIXED CODE ###

N, M = map(int, input().split())
H = list(map(int, input().split()))
AB = []
for _ in range(M):
    AB.append(list(map(int, input().split())))
cnt = 0
new = [0 for i in range(N)]
for ab in AB:
    if H[ab[0]-1] <= H[ab[1]-1]:
        new[ab[0]-1] += 1
    if H[ab[0] - 1] >= H[ab[1] - 1]:
        new[ab[1]-1] += 1
print(new.count(0))
### BUGGY CODE ###

import itertools
import collections
n=int(input())
s=[list(map(int, input().split())) for i in range(n)]
ans=[]
x=list(itertools.permutations(s))

if n==1:
    print(n)
else:
    v=[]
    r=[]
    for i in range(len(x)):
        e=[]
        v=[]
        for j in range(n-1):
            a=x[i][j][0]
            b=x[i][j+1][0]
            c=x[i][j][1]
            d=x[i][j+1][1]
            v.append(b-a)
            v.append(d-c) 
        q=[v[i:i+2] for i in range(0,len(v),2)]
        for i in range(len(q)):
            e.append(q.count(q[i]))
            r.append(max(e))
    print(n-max(r))

### FIXED CODE ###

n=int(input())
s=[list(map(int, input().split()))  for i in range(n)]
x=[]
if n==1:
    print(1)
    exit(0)

for i in range(n):
    for j in range(n):
        if i==j:
            continue
        t=(s[i][0]-s[j][0],s[i][1]-s[j][1])
        x.append(t)
        
ans = [x.count(x[i]) for i in range(len(x))]
print(n-max(ans))
### BUGGY CODE ###

import sys

N=int(input())
amat=[[-1]]
for i in range(N):
  alist=list(map(int,input().split()))
  amat.append(list(reversed(alist)))
  
#print(amat)
answer=0
matched_flag=[False]*(N+1)
for answer in range(1,N**3):
  if N>900 and answer>10000:
    print(N*(N-1)//2)
    sys.exit()
  
  matched_flag=[False]*(N+1)
  unchanged=True
  
  for i in range(1,N+1):
    if matched_flag[i] or len(amat[i]) == 0:
      continue
      
    ai_next = amat[i][-1]
    if amat[ai_next][-1]==i and not matched_flag[ai_next]:
      #print(i,ai_next,answer)
      matched_flag[amat[i].pop()]=True
      matched_flag[amat[ai_next].pop()]=True
      unchanged=False
  
  if unchanged:
    print(-1)
    sys.exit()
  else:
    for i in range(1,N+1):
      if len(amat[i])>0:
        break
    else:
      print(answer)
      sys.exit()


### FIXED CODE ###

import sys

N=int(input())
amat=[[-1]]
for i in range(N):
  alist=list(map(int,input().split()))
  amat.append(list(reversed(alist)))
  
#print(amat)
answer=0
matched_flag=[False]*(N+1)
for answer in range(1,N**3):
  if N>900 and answer>3000:
    print(N*(N-1)//2)
    sys.exit()
  
  matched_flag=[False]*(N+1)
  unchanged=True
  
  for i in range(1,N+1):
    if matched_flag[i] or len(amat[i]) == 0:
      continue
      
    ai_next = amat[i][-1]
    if amat[ai_next][-1]==i and not matched_flag[ai_next]:
      #print(i,ai_next,answer)
      matched_flag[amat[i].pop()]=True
      matched_flag[amat[ai_next].pop()]=True
      unchanged=False
  
  if unchanged:
    print(-1)
    sys.exit()
  else:
    for i in range(1,N+1):
      if len(amat[i])>0:
        break
    else:
      print(answer)
      sys.exit()
### BUGGY CODE ###

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

MAX = 10**18
ans = 1

for i in a:
    ans *= i
    
if ans > MAX:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

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

MAX = 10**18
ans = 1

for i in a:
    ans *= i
    if ans > MAX:
        print(-1)
        sys.exit()

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

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
A.sort(reverse=True)
B = list(map(int, input().split()))
B.sort(reverse=True)
C = list(map(int, input().split()))
C.sort(reverse=True)

AB = []
for b in B:
    for a in A:
        AB.append(a+b)
AB = sorted(AB, reverse=True)[:K]

ABC = []
for ab in AB:
    for c in C:
        ABC.append(ab+c)
ABC.sort(reverse=True)
for i in range(K):
    print(ABC[i])

### FIXED CODE ###

x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
    for nu in lisa:
        an.append(num+nu)
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:
        ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
 
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
 
n,q = list(map(int,input().split()))
ball = list(map(int,input().split()))
 
h = Bit(n+1)

L_most = {}
#J = [[] for _ in range(max(ball)+2)]
L = {}
jump = {}
on = set()

for i,b in enumerate(ball):
  if b not in L_most:
    L_most[b]=i
    h.add(i+1,1)
    on.add(i+1)
  #J[b].append(i)
  if b in L:
    jump[L[b]]=i+1
  L[b] = i+1
  
#print(jump)
  
#for i in range(max(ball)+2):
#  for j in range(len(J[i])):
#    if j+1<len(J[i]):
#      jump[J[i][j]+1] = J[i][j+1]+1

Q = []
 
for _ in range(q):
  l,r = list(map(int,input().split()))
  Q.append((l,r))
  
LOO = list(Q)
Q.sort(key=lambda x:x[0])

c = 1
ans = {}
#print(on)

for l,r in Q:
  for i in range(c,l):
    if i in on:
      on.remove(i)
      h.add(i,-1)
      if i in jump:
        dest = jump[i]
        h.add(dest,1)
        on.add(dest)

  tmp = h.sum(r)- h.sum(l-1)
  ans[(l,r)] = tmp
  c = l

for q in LOO:
  print(ans[q])
  
  
  

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
 
n,q = list(map(int,input().split()))
ball = list(map(int,input().split()))
 
h = Bit(n+1)

L = {}
jump = {}
on = set()

for i,b in enumerate(ball):
  if b not in L:
    h.add(i+1,1)
    on.add(i+1)
  if b in L:
    jump[L[b]]=i+1
  L[b] = i+1

Q = []
 
for _ in range(q):
  l,r = list(map(int,input().split()))
  Q.append((l,r))
  
LOO = list(Q)
Q.sort(key=lambda x:x[0])

c = 1
ans = {}

for l,r in Q:
  for i in range(c,l):
    if i in on:
      on.remove(i)
      h.add(i,-1)
      if i in jump:
        dest = jump[i]
        h.add(dest,1)
        on.add(dest)

  tmp = h.sum(r)- h.sum(l-1)
  ans[(l,r)] = tmp
  c = l

p = []
for q in LOO:
  p.append(ans[q])
  
print(*p, sep="\n")
### BUGGY CODE ###

INF = -1000000000000001

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

a = int(n/2)

dpa = [[INF]*(a+1) for i in range(n+1)]

dpa[0][0] = 0
dpa[1][0] = 0
dpa[1][1] = l[0]
for i in range(2,n+1):
	j = int(i / 2)
	
	if i == j*2:
		dpa[i][j] = max(dpa[i-2][j-1]+l[i-1],dpa[i-1][j])
#		print(i,j,dpa[i][j])
	else:
		dpa[i][j] = max(dpa[i-2][j-1]+l[i-1],dpa[i-1][j])
#		print(i,j,dpa[i][j])
		if (i != n):
			j += 1
#			print(i,j,dpa[i][j])
#			print("   ",i-2,j-1,dpa[i-2][j-1],"")
			dpa[i][j] = dpa[i-2][j-1]+l[i-1]

#print(dpa)
print(dpa[n][a])


### FIXED CODE ###

from collections import defaultdict
INF = -1000000000000001

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

a = int(n/2)

dpa = defaultdict(lambda: -INF)
#dpa = [[0 for j in range(a+1)] for i in range(n+1)]

dpa[(0,0)] = 0
dpa[(1,0)] = 0
dpa[(1,1)] = l[0]
j = 1
for i in range(2,n+1):
	if i == j*2:
		dpa[(i,j)] = max(dpa[(i-2,j-1)]+l[i-1],dpa[(i-1,j)])
#		print(i,j,dpa[(i,j)])
	else:
		dpa[(i,j)] = max(dpa[(i-2,j-1)]+l[i-1],dpa[(i-1,j)])
#		print(i,j,dpa[(i,j)])
		if (i != n):
			j += 1
#			print(i,j,dpa[(i,j)])
#			print("   ",i-2,j-1,dpa[(i-2,j-1)],"")
			dpa[(i,j)] = dpa[(i-2,j-1)]+l[i-1]

#print(dpa)
print(dpa[n,a])
### BUGGY CODE ###

n=int(input())
a=[int(input()) for i in range(n)]
l=[]
c=1
i=0
f=True
for _ in range(100002):
    i+=1
    c=a[c-1]
    b=len(l)
    l.append(c)
    l=list(set(l))
    if len(l)==b:
        f=False
        break
    if c==2:break
if f:print(i)
else:print(-1)

### FIXED CODE ###

n=int(input())
a=[int(input()) for i in range(n)]
l=[]
c=1
i=0
f=False
for _ in range(100001):
    i+=1
    c=a[c-1]
    if c==2:
        f=True
        break
if f:print(i)
else:print(-1)
### BUGGY CODE ###

S=input()
T=input()
n=len(S)
m=len(T)
dp=[['']*(m+1) for i in range(n+1)]
for i in range(n):
  for j in range(m):
    if S[i]==T[j]:
      dp[i+1][j+1]=dp[i][j]+S[i]
    else:
      if len(dp[i+1][j])>=len(dp[i][j+1]):
        dp[i+1][j+1]=dp[i+1][j]
      else:
        dp[i+1][j+1]=dp[i][j+1]
print(dp[n][m])

### FIXED CODE ###

S=input()
T=input()
n=len(S)
m=len(T)
dp=[[0]*(m+1) for i in range(n+1)]
for i in range(n):
  for j in range(m):
    dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j],dp[i][j]+(S[i]==T[j]))
ans=''
while n>0 and m>0:
  if dp[n][m]==dp[n-1][m]:
    n-=1
  elif dp[n][m]==dp[n][m-1]:
    m-=1
  else:
    n-=1
    m-=1
    ans=S[n]+ans
print(ans)
### BUGGY CODE ###

def expected_value(x):
    e = 0
    for i in range(1, x+1):
        e += i / x
    return e

n, k = [int(x) for x in input().split()]
p = [int(x) for x in input().split()]
evs = [0.0]*n
for i in range(n):
    evs[i] = expected_value(p[i])

# initialize
left = 0
max_ev = 0
ev = 0
for i in range(k):
    ev += evs[i]

max_ev = ev
for i in range(k, n):
    ev = ev - evs[left] + evs[i]
    left += 1
    if ev > max_ev:
        max_ev = ev
print('{:.7f}'.format(max_ev))

### FIXED CODE ###

def expected_value(x):
    a = int(x)
    s = (a+1) * (a/2)
    # e = 0
    # for i in range(1, a+1):
    #     e += i / a
    return s / a

n, k = [int(x) for x in input().split()]
evs = list(map(expected_value, input().split())) 

# initialize
left = 0
max_ev = 0
ev = 0
for i in range(k):
    ev += evs[i]

max_ev = ev
for i in range(k, n):
    ev = ev - evs[left] + evs[i]
    left += 1
    if ev > max_ev:
        max_ev = ev
print('{:.7f}'.format(max_ev))
### BUGGY CODE ###

from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce, lru_cache
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())
def LIST1() : return list(MAP1())

s = input()

dp = [0]*len(s)
# dp[i]: sの左からi文字目以降を整数と見なした時の2019で割った余り
dp[len(s)-1] = int(s[len(s)-1])

reg = [0]*2020
# 余りを記録

for i in range(len(s)-2, -1, -1):
    dp[i] = ( dp[i+1] + int(s[i])*pow(10, len(s)-1-i) ) % 2019
    reg[dp[i]] += 1

ans = reg[0]
for i in range(2020):
    ans += reg[i] * (reg[i]-1) // 2

print(ans)

### FIXED CODE ###

from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce, lru_cache
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())
def LIST1() : return list(MAP1())

s = input()

@lru_cache(None)
def F(s, k):
    # sの左からk文字目以降を整数と見なしたとき、
    # 2019で割った余りを返す
    if k == len(s)-1:
        return int(s[k])
    ret = F(s, k+1) + int(s[k])*pow(10, len(s)-1-k, 2019)
    ret %= 2019
    return ret

a = [0]*2020
for i in range(len(s)):
    a[F(s, i)] += 1

ans = a[0]
for i in range(2020):
    ans += a[i] * (a[i]-1) // 2

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

#!/usr/bin/env python3
import sys
input = sys.stdin.readline
INF = 10**10
MAX_LEN = 2*10**4

h, n = [int(item) for item in input().split()]
ab = []
for i in range(n):
    a, b = map(int, input().split())
    ab.append((a, b))
dp = [INF] * (MAX_LEN * (n + 1))
dp[0] = 0
for i in range(1, n+1):
    v, w = ab[i-1]
    offset = i * MAX_LEN
    offset_before = offset - MAX_LEN
    for j in range(MAX_LEN):
        if j < v:
            dp[offset+j] = dp[offset_before+j]
        elif dp[offset_before+j] > dp[offset+j-v] + w:
            dp[offset+j] = dp[offset+j-v] + w
        else:
            dp[offset+j] = dp[offset_before+j]
ans = min(dp[n*(MAX_LEN) + h:])
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3
import sys
input = sys.stdin.readline
INF = 10**9

def main(): 
    h, n = [int(item) for item in input().split()]
    MAX_LEN = h + 10**4 - 2
    dp = [INF] * MAX_LEN
    dp[0] = 0
    vw = []
    for _ in range(n):
        v, w = map(int, input().split())
        vw.append((v, w))
    vw.sort(reverse=True, key=lambda x:x[0])
    for v, w in vw:
        for j in range(h):
            if dp[j] == INF:
                continue
            tmp = dp[j] + w
            if tmp < dp[j+v]:
                dp[j+v] = tmp
    print(min(dp[h:]))

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

from sys import stdin,stdout
n=int(stdin.readline());ans=0
fctrs=[0]*(n+1)
for i in range(1,n+1):
        for j in range(i,n+1,i):
            fctrs[j]+=1
for i in range(1,n+1):
    ans+=(i*fctrs[i])
stdout.write(str(ans))


### FIXED CODE ###

from numba import njit
@njit
def solve(n):
	fctrs=[0]*(n+1)
	ans=0
	for i in range(1,n+1):
		for j in range(i,n+1,i):
			fctrs[j]+=1
	for i in range(1,n+1):
		ans+=(i*fctrs[i])
	return ans
n=int(input())
print(solve(n))
### BUGGY CODE ###

import numpy as np
from numba import jit

@jit
def main():
    R, C, K = map(int, input().split())
    scores = [[0] * (C + 1) for _ in range(R+1)]
    for _ in range(K):
        r, c, v = map(int, input().split())
        scores[r][c] = v
    dp = [[[0] *4 for _ in range(C+1)] for _ in range(R+1)]

    scores = np.array(scores)
    dp = np.array(dp)

    for i in range(1, R+1):
        for j in range(1, C+1):
            for k in range(4):
                dp[i][j][k] = max(dp[i][j-1][k],
                                dp[i-1][j][3])
            for k in range(3, 0, -1):
                dp[i][j][k] = max(dp[i][j][k],
                                dp[i][j][k-1] + scores[i][j])

    answer = dp[R][C][3]
    print(answer)

main()

### FIXED CODE ###

from numba import jit
import numpy as np

@jit
def main():
    R, C, K = map(int, input().split())
    scores = np.zeros((R,C), np.int64)
    for _ in range(K):
        r, c, v = map(int, input().split())
        scores[r-1][c-1] = v
    dp=np.zeros((R+1,C+1,4), np.int64)

    for i in range(1, R+1):
        for j in range(1, C+1):
            for k in range(4):
                dp[i][j][k] = max(dp[i][j-1][k],
                                dp[i-1][j][3])
            for k in range(3, 0, -1):
                dp[i][j][k] = max(dp[i][j][k],
                                  dp[i][j][k-1] + scores[i-1][j-1])

    
    return dp[R][C][3]

print(main())
### BUGGY CODE ###

import numpy as np
Q = int(input())

p = np.array([i for i in range(2*10**5+1)])
p[1]=0
for i in range(2,10**5):
    p[2*i::i] = 0
p = p[p!=0]

dic = {i:1 for i in p}

for _ in range(Q):
    l,r = list(map(int,input().split()))
    tmp = p[l<=p]
    tmp = tmp[tmp<=r]
    print([dic.get((x+1)//2,0)==1 for x in tmp].count(True))

### FIXED CODE ###

import numpy as np
Q = int(input())

p = np.array([i for i in range(2*10**5+1)])
p[1]=0
for i in range(2,10**5):
    p[2*i::i] = 0
p = p[p!=0]

dic = {i:1 for i in p}
d = {}
for i in range(len(p)):
    if dic.get((p[i]+1)//2,0)==1:
        d[p[i]] = 1
sum_=0
arr = [0 for i in range(10**5+2)]
for i in range(10**5+2):
    arr[i] = sum_
    if d.get(i,0)==1:
        sum_+=1
for _ in range(Q):
    l,r = list(map(int,input().split()))
    print(arr[r+1]-arr[l])