Harryxun/stf_run huggingface dataset:
n, m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
a = a.sort()
ans = 0
i = 0
while m > 0:
  if a[i][1] > 0:
    a[i][1] -= 1
    ans += a[i][0]
    m -= 1
  else:
    i += 1
print(ans)


### FIXED CODE ###

n, m = map(int,input().split())
a = [list(map(int,input().split())) for i in range(n)]
a.sort()
ans = 0
i = 0
while m > 0:
  if a[i][1] > 0:
    a[i][1] -= 1
    ans += a[i][0]
    m -= 1
  else:
    i += 1
print(ans)
#132 12:55
n,k=map(int,input().split())
def C(i,j):
    def a(n):
        b=1
        for x in range(1,n+1):
            b=b*x
        return b
    return int(a(i)/(a(j)*a(i-j)))

answer=[]
for i in range(1,k+1):
    if n-k-i+1<0:
        answer.append(0)
    else:
        answer.append( C(k-1,i-1)*C(n-k+1,i) )
for i in range(k):
    print(answer[i]%(7+10**9))


### FIXED CODE ###

N, K = map(int, input().split())
R = N-K
RR = R-1
mod = 10**9+7

def nCr(n,r):
    K = 1
    for j in range(1,r+1):
        K = K*(n+1-j)//j
    return K

    
for i in range(K):
    ans = (nCr(K-1,i)%mod)*(nCr(N-K+1,i+1)%mod)
    ans = ans%mod
    print(ans)
InData=input().split
Indata = map(int, InData)
sorted = sorted(InData)
print(' '.join(map(str, sorted)))


### FIXED CODE ###

InData=input().split()
InDataM = [int(i) for i in InData]
result = sorted(InDataM)
print(' '.join(map(str, result)))
n=int(input())
a='Xabcdefghijklmnopqrstuvwxyz'
a=list(a)
j=11
ans=''
while True:
    while n<=26**j:
        j-=1
    temp=a[n//26**j]
    ans+=temp
    n%=26**j
    j-=1
    if j==-1:
        break
print(ans)


### FIXED CODE ###

n=int(input())
n-=1
a='abcdefghijklmnopqrstuvwxyz'
a=list(a)
ans=''
for i in range(1,20):
    if n<26**i:
        for j in range(i):
            ans+=a[n%26]
            n//=26
        break
    else:
        n-=26**i
print(ans[::-1])
import sys

input = sys.stdin.readline

s = list(input().rstrip())

lis = ['A', 'C', 'G', 'T']

for i in range(len(s)):
    for j in range(4):
        if (s[i] == lis[j]):
            s[i] = 'う～えす～ぎさ～ん'
            break


ct = 0
ct_lis = []

for i, x in enumerate(s):
    if (x == 'う～えす～ぎさ～ん'):
        ct += 1
    else:
        ct_lis.append([ct])
        ct = 0

print(max(ct_lis)[0])


### FIXED CODE ###

import sys

input = sys.stdin.readline

s = list(input().rstrip())

lis = ['A', 'C', 'G', 'T']

for i in range(len(s)):
    for j in range(4):
        if (s[i] == lis[j]):
            s[i] = 'AYATASO'
            break

ct = 0
ct_lis = []

for i, x in enumerate(s):
    if (x == 'AYATASO'):
        ct += 1
    else:
        ct_lis.append(ct)
        ct = 0

ct_lis.append(ct)

print(max(ct_lis))
cook = []
amari = []
t = 0
for i in range(5):
    cook.append(int(input()))

for i in range(5):
    if cook[i] % 10 != 0:
        t += cook[i] + (10 - cook[i] % 10)
    else:
        t += cook[i]

for i in range(5):
    if cook[i] % 10 != 0:
        amari.append(10 - cook[i] % 10)

print(t - max(amari))


### FIXED CODE ###

cook = []
amari = [0]
t = 0
for i in range(5):
    cook.append(int(input()))

for i in range(5):
    if cook[i] % 10 != 0:
        t += cook[i] + (10 - cook[i] % 10)
    else:
        t += cook[i]

for i in range(5):
    if cook[i] % 10 != 0:
        amari.append(10 - cook[i] % 10)

print(t - max(amari))
n=int(input().split()[0])
l=[]
for i in range(n):
  l.append(input)
l.sort()
r=""
for i in l:
  r+=i
print(r)

### FIXED CODE ###


n=int(input().split()[0])
l=[]
for i in range(n):
  l.append(input())
l.sort()
r=""
for i in l:
  r+=i
print(r)
# -*- coding: utf-8 -*-
"""
Created on Wed Jun  5 09:53:48 2019

@author: Enya
"""

input_code = input()

A = input_code[0]*3 + input_code[1]
N = 0

if A>3:
    N = A//3
    
    print(N)

else:
    print(0)
    

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Wed Jun  5 09:53:48 2019

@author: Enya
"""

input_code = input()
A = int(input_code.split()[0])
P = int(input_code.split()[1])

X = A*3 + P

print(X//2)
print("Yes" if len(s) == a+b+1 and s[a] == "-" and s[a+1] != "-" and s[a-1] != "-" else "No")


### FIXED CODE ###

a, b = map(int, input().split())
s = input()
ans = "No"
num = [i for i in range(10)]

if len(s) == a+b+1:
    if s[a] == "-":
        s = list(s)
        s.pop(a)
        s = "".join(s)
        if s.isdigit():
            ans = "Yes"
print(ans)
N = int(input())
S,T= input().spulit()
 
Q = ""
for i in range (N):
  Q = Q + S[i] + T[i]
  
print(Q)

### FIXED CODE ###

N = int(input())
S,T = input().split()
 
Q = ""
for i in range (N):
  Q = Q + S[i] + T[i]
  
print(Q)
n = str(input())
if len(n) < =2:
    print(0)
else:
    a = n[0:-2]
    tens = int(n[-2])
    need = tens*2
    ones = int(n[-1])
    if ones < 5:
        need += 1
    else:
        need +=2

    if need <= int(a):
        print(1)
    else:
        print(0)


### FIXED CODE ###

n = str(input())
if len(n) <= 2:
    print(0)
else:
    a = n[0:-2]
    tens = int(n[-2])
    need = tens*2
    ones = int(n[-1])
    if ones == 0:
        need +=0
    elif ones <= 5:
        need += 1
    else:
        need +=2
    if need <= int(a):
        print(1)
    else:
        print(0)
#ABC148.C
import math
A,B = map(int,input().split())
def lcm(x,y):
    return x*y//math.gcd(x,y)
print(lcm(A,B))

### FIXED CODE ###

#ABC148.C
import fractions
A,B = map(int,input().split())
def lcm(x,y):
    return x*y//fractions.gcd(x,y)
print(lcm(A,B))
H, W, K = map(int, input().split())
G = [list(input()) for _ in range(H)]
for rows in range(2**H):
    for cols in range(2**W):
        black = 0
        for i in range(H):
            if rows >> i & 1:
                continue
            for j in range(W):
                if cols >> j & 1:
                    continue
                if G[i][j] == '#':
                    black += 1
        if black == K:
            ans += 1
print(ans)

### FIXED CODE ###

H, W, K = map(int, input().split())
G = [list(input()) for _ in range(H)]
ans = 0
for rows in range(2**H):
    for cols in range(2**W):
        black = 0
        for i in range(H):
            if rows >> i & 1:
                continue
            for j in range(W):
                if cols >> j & 1:
                    continue
                if G[i][j] == '#':
                    black += 1
        if black == K:
            ans += 1
print(ans)
import numpy as np

N, M, K = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)
B = np.array(input().split(), dtype=np.int64)

# 累積和
A = np.cumsum(A)
B = np.cumsum(B)

# K以下を抽出
A = A[A <= K]
B = B[B <= K]

# Aを逆順にする
A = A[::-1]

c = 0
c_max = 0
for i, a in enumerate(A):
    c += len(A) - i

    for j, b in enumerate(B):
        if a + b <= K:
            cb = j + 1

    c += cb
    if c > c_max:
        c_max = c
    c = 0

print(c_max)


### FIXED CODE ###

import numpy as np

from numba import njit


@njit("i8[:](i8, i8[:], i8[:])", cache=True)
def cumsum(K, A, cA):
    for i, a in enumerate(A):
        cA[i] += cA[i - 1] + A[i]
        if cA[i] > K:
            break

    cA = cA[cA != 0]
    cA = np.append(0, cA)
    return cA


@njit("i8(i8, i8[:], i8[:])", cache=True)
def solve(K, cA, cB):
    ans = np.searchsorted(cA, K - cB, side="right") - 1
    ans += np.arange(len(cB))
    return ans.max()


N, M, K = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)
B = np.array(input().split(), dtype=np.int64)

cA = np.zeros(N, dtype=np.int64)
cB = np.zeros(M, dtype=np.int64)

# np.cumsumだとoverflowする
cA = cumsum(K, A, cA)
cB = cumsum(K, B, cB)

ans = solve(K, cA, cB)
print(ans)
import heapq

x,y,a,b,c = map(int,input().split())
r = list(map(int,input().split()))
g = list(map(int,input().split()))
w = list(map(int,input().split()))

r.sort(key = lambda x:-x)
g.sort(key = lambda x:-x)
w.sort(key = lambda x:-x)


rg = []
for i in range(x):
    rg.append(r[i])

for i in range(y):
    rg.append(g[i])

rg.sort(key = lambda x:-x)

ind = 0
ans = 0
for i in range(x+y):
    if w[ind] > rg[i]:
        ans += w[ind]
        ind += 1
    else:
        ans += rg[i]

print(ans)

### FIXED CODE ###

import heapq

x,y,a,b,c = map(int,input().split())
r = list(map(int,input().split()))
g = list(map(int,input().split()))
w = list(map(int,input().split()))

r.sort(key = lambda x:-x)
g.sort(key = lambda x:-x)
w.sort(key = lambda x:-x)


rg = []
for i in range(x):
    rg.append(r[i])

for i in range(y):
    rg.append(g[i])

rg.sort(key = lambda x:x)


ind = 0
ans = 0
for i in range(x+y):
    if ind <= c-1 and w[ind] > rg[i]:
        ans += w[ind]
        ind += 1
    else:
        ans += rg[i]

print(ans)
n = int(input())
A = list(map(int,input().split()))

def zenbu(m, B):
    if m == 1:
        return B[0]
    elif m == 2:
        return max(B[0],B[1])
    elif m == 3:
        return max(B[0],B[1],B[2])
    elif m%2 == 0: #偶数の場合
        temp = 0
        for i in range(m//2-1):
            temp += B[i*2]
        return max(temp+ max(B[m-2],B[m-1]), zenbu(m-2, B)+ B[m-1])
    else:#奇数の場合
        temp = 0
        for i in range((m-1)//2):
            temp += B[i*2]
        return max(temp, zenbu(m-2,B)+ B[m-1], zenbu(m-3,B)+ max(B[m-2],B[m-1]))

ans = zenbu(n,A)

print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
if N%2 == 0:
  dp = [[0]*2 for _ in range(N)] #0index
  dp[0][0] = A[0]
  dp[1][1] = A[1]
  for i in range(2,N):
    dp[i][0] = dp[i-2][0]+A[i]
    if i-3>=0:
      dp[i][1] = max(dp[i-2][1],dp[i-3][0])+A[i]
    else:
      dp[i][1] = max(dp[i-2][1],0)+A[i]
  ans = max(dp[-2][0],dp[-1][1])
  print(ans)
#i個目を使ってj(0-2)回多く飛んでいる。
else: #N%2 == 1:
  dp = [[0]*3 for _ in range(N)] #0index
  dp[0][0] = A[0]
  dp[1][1] = A[1]
  dp[2][2] = A[2]
  dp[2][0] = A[0]+A[2]
  #print(dp)
  for i in range(3,N):
    dp[i][0] = dp[i-2][0]+A[i]
    if i-3 >= 0:
      dp[i][1] = max(dp[i-2][1],dp[i-3][0])+A[i]
    else:
      dp[i][1] = max(dp[i-2][1],0)+A[i]
    if i-4 >= 0:
      dp[i][2] = max(dp[i-2][2],dp[i-3][1],dp[i-4][0])+A[i]
    elif i-3 >= 0:
      dp[i][2] = max(dp[i-2][2],dp[i-3][1],0)+A[i]
  #else:
  #  dp[i][2] = max(dp[i-2][2],0,0)+A[i]
  #print(dp[-1],dp[-2],dp[-3])

  ans = max(dp[-3][0],dp[-2][1],dp[-1][2])
  print(ans)
  exit()
inf = int(1e20)
node,edge = map(int,input().split())
ed = []
for e in range(edge):
    ed.append(e[0]-1,e[1]-1,-e[2])
start = 0
goal = node-1



d = [inf for i in range(node)]
pre = [inf for i in range(node)]
d[start] = 0

for i in range(node):
    update = False
    for e in ed:
        if d[e[0]] != inf and d[e[1]]>d[e[0]]+e[2]:
            d[e[1]] = d[e[0]]+e[2]
            update = True
            pre[e[1]] = e[0]
    if update==False:
        print(-d[goal])
        break
else:
    nowcos = d[goal]
    for i in range(node):
        for e in ed:
            if d[e[0]] != inf and d[e[1]]>d[e[0]]+e[2]:
                d[e[1]] = d[e[0]]+e[2]
                pre[e[1]] = e[0]
    if nowcos != d[goal]:
        print('inf')
    else:
        print(-d[goal])

### FIXED CODE ###

inf = int(1e20)
node,edge = map(int,input().split())
ed = []
for i in range(edge):
    e = list(map(int,input().split()))
    ed.append((e[0]-1,e[1]-1,-e[2]))
start = 0
goal = node-1



d = [inf for i in range(node)]
pre = [inf for i in range(node)]
d[start] = 0

for i in range(node):
    update = False
    for e in ed:
        if d[e[0]] != inf and d[e[1]]>d[e[0]]+e[2]:
            d[e[1]] = d[e[0]]+e[2]
            update = True
            pre[e[1]] = e[0]
    if update==False:
        print(-d[goal])
        break
else:
    nowcos = d[goal]
    for i in range(node):
        for e in ed:
            if d[e[0]] != inf and d[e[1]]>d[e[0]]+e[2]:
                d[e[1]] = d[e[0]]+e[2]
                pre[e[1]] = e[0]
    if nowcos != d[goal]:
        print('inf')
    else:
        print(-d[goal])
N, K = map(int,input().split())
H = list(map(int,input().split()))
result = 0
if len(H) <= K:
    print(result)
else:
    H.sort()
    for i in range(1, K+1):
        H.remove(H[-i])
    for i in H:
        result += i
    print(result)

### FIXED CODE ###

N, K = map(int,input().split())
H = list(map(int,input().split()))
result = 0
if len(H) <= K:
    print(result)
else:
    H.sort()
    result = sum(H[0:N-K])
    print(result)
import math
import sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from functools import lru_cache, reduce
from heapq import heapify, heappop, heappush
from itertools import chain, combinations, permutations, product
from typing import List, Dict

# import numpy as np

sys.setrecursionlimit(10**5 + 1)
input = sys.stdin.readline
write = sys.stdout.write


def read_item(cls=int):
    return cls(input())


def read_n_item(cls=int) -> list:
    return [cls(s) for s in input().split()]


def list2d(row, col, init_val=0) -> List[list]:
    return [[init_val] * col for _ in range(row)]


MOD = 10**9 + 7
# MOD = 998244353


N = read_item()
vals = read_n_item()
graph = defaultdict(list)

for _ in range(N-1):
    u, v = read_n_item()
    u -= 1
    v -= 1
    graph[u].append(v)
    graph[v].append(u)


ans = [0] * N
ans[0] = 1
dp = [float('inf')] * N
dp[0] = vals[0]


def dfs(v, pre):
    for child in graph[v]:
        if child == pre:
            continue
        i = bisect_left(dp, vals[child])
        ans[child] = i+1

        temp = dp[i]
        dp[i] = vals[child]
        dfs(child, v)
        dp[i] = temp

dfs(0, -1)
print(*ans, sep='\n')



### FIXED CODE ###

import math
import sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from functools import lru_cache, reduce
from heapq import heapify, heappop, heappush
from itertools import chain, combinations, permutations, product
from typing import List, Dict

# import numpy as np

sys.setrecursionlimit(10**6 + 1)
input = sys.stdin.readline
write = sys.stdout.write


def read_item(cls=int):
    return cls(input())


def read_n_item(cls=int) -> list:
    return [cls(s) for s in input().split()]


def list2d(row, col, init_val=0) -> List[list]:
    return [[init_val] * col for _ in range(row)]


MOD = 10**9 + 7
INT_MAX = 10**9
# MOD = 998244353


N = read_item()
vals = read_n_item()
graph = defaultdict(list)

for _ in range(N-1):
    u, v = read_n_item()
    u -= 1
    v -= 1
    graph[u].append(v)
    graph[v].append(u)

ans = [0] * N
ans[0] = 1
dp = [vals[0]]


def dfs(cur, pre):
    ans[cur] = len(dp)

    for nxt in graph[cur]:
        if nxt == pre:
            continue
        i = bisect_left(dp, vals[nxt])
        if i < len(dp):
            temp = dp[i]
            dp[i] = vals[nxt]
            dfs(nxt, cur)
            dp[i] = temp
        else:
            dp.append(vals[nxt])
            dfs(nxt, cur)
            dp.pop()


dfs(0, -1)
print(*ans, sep='\n')
import numpy as np
a,b,x=map(int,input().split())
if a*a*b>=x*2:
    c=2*x/(a*b)
    d=c**2+b**2
    d=d**(1/2)
    ans=np.arccos(c/d)
    print(ans*180/3.1415926535)
else:
    x=a*a*b-x
    c=2*x/(a*a)
    d=c**2+a**2
    d=d**(1/2)
    ans=np.arccos(a/d)
    print(ans*180/3.1415926535)

### FIXED CODE ###

import math
a,b,x=map(int,input().split())
if a*a*b>=x*2:
    c=2*x/(a*b)
    d=c**2+b**2
    d=d**(1/2)
    ans=math.acos(c/d)
    print(ans*180/3.1415926535)
else:
    x=a*a*b-x
    c=2*x/(a*a)
    d=c**2+a**2
    d=d**(1/2)
    ans=math.acos(a/d)
    print(ans*180/3.1415926535)
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    d = collections.defaultdict(set)
    for _ in range(n-1):
        a,b = LI()
        d[a].add(b)
        d[b].add(a)

    if n > 10**4:
        n /= 0

    f = collections.defaultdict(bool)
    rf = False
    def g(s, h, m):
        t = list(d[s] - set([m]))[-1]
        if len(d[t]) > 2:
            if h:
                if f[t]:
                    return True
                f[t] = True
            else:
                d[t].remove(s)
                d[s].remove(t)
                rf = True
            return False
        if len(d[t]) == 1:
            return not h
        return g(t,not h,s)

    tt = True
    gf = collections.defaultdict(bool)
    while tt:
        if rf:
            gf = collections.defaultdict(bool)
            f = collections.defaultdict(bool)
            rf = False
        tt = False
        for k,v in list(d.items()):
            if len(v) == 1:
                if gf[k]:
                    continue
                gf[k] = True
                res = g(k, True, -1)
                if res:
                    return 'First'
                tt = True
    return 'Second'


print(main())


### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    n = I()
    d = collections.defaultdict(set)
    kk = None
    for _ in range(n-1):
        a,b = LI()
        kk = [a,b]
        d[a].add(b)
        d[b].add(a)

    tt = True
    gf = collections.defaultdict(bool)
    while tt:
        tt = False
        for k,v in list(d.items()):
            if len(v) == 1:
                vt = list(v)[0]
                if len(d[vt]) == 1:
                    continue
                for vv in d[vt]:
                    if vv == k:
                        continue
                    if vt in d[vv]:
                        d[vv].remove(vt)
                d[vt] = set([k])
                tt = True
            elif len(v) == 0:
                return 'First'
    return 'Second'


print(main())
import re

def solve1():
    N, Q = map(int, input().split())
    # print(N, Q)
    acgt_string = input()
    sub_str_ith = []
    for _ in range(Q):
        start, end = map(int, input().split())
        sub_str_ith.append((start, end))

    t = [0] * (N)
    for i in range(N):
        t[i+1] = t[i] + (1 if acgt_string[i:i+2] == "AC" else 0)

    for start, end in sub_str_ith:
        print(t[end-1] - t[start-1])

def my_solve1():
    N, Q = map(int, input().split())
    # print(N, Q)
    acgt_string = input()
    sub_str_ith = []
    for _ in range(Q):
        start, end = map(int, input().split())
        sub_str_ith.append((start, end))
    # print(sub_str_ith)

    # 全ての'A'の位置を取得
    a_iths = [m.span() for m in re.finditer('AC', acgt_string)]
    # print(a_iths)

    for start, end in sub_str_ith:
        # print(start, end)
        num = 0
        for ac_start, ac_end in a_iths:
            if ac_start >= start-1 and ac_end <= end:
                num += 1
        print(num)


solve1()
# my_solve1()

### FIXED CODE ###

import re

def solve1():
    N, Q = map(int, input().split())
    # print(N, Q)
    acgt_string = input()
    sub_str_ith = []
    for _ in range(Q):
        start, end = map(int, input().split())
        sub_str_ith.append((start, end))

    t = [0] * (N+1)
    for i in range(N):
        t[i+1] = t[i] + (1 if acgt_string[i:i+2] == "AC" else 0)

    for start, end in sub_str_ith:
        print(t[end-1] - t[start-1])

def my_solve1():
    N, Q = map(int, input().split())
    # print(N, Q)
    acgt_string = input()
    sub_str_ith = []
    for _ in range(Q):
        start, end = map(int, input().split())
        sub_str_ith.append((start, end))
    # print(sub_str_ith)

    # 全ての'A'の位置を取得
    a_iths = [m.span() for m in re.finditer('AC', acgt_string)]
    # print(a_iths)

    for start, end in sub_str_ith:
        # print(start, end)
        num = 0
        for ac_start, ac_end in a_iths:
            if ac_start >= start-1 and ac_end <= end:
                num += 1
        print(num)


solve1()
# my_solve1()
# -*- coding: utf-8 -*-

import sys
from collections import defaultdict


n, q = [int(x) for x in sys.stdin.readline().rstrip().split(" ")]

tree = defaultdict(set)
data = defaultdict(int)


def add(p, x):
    global data
    data[p] += x
    for p2 in tree[p]:
        add(p2, x)


for _ in range(n - 1):
    a, b = [int(x) for x in sys.stdin.readline().rstrip().split(" ")]
    tree[a].add(b)

for _ in range(q):
    p, x = [int(x) for x in sys.stdin.readline().rstrip().split(" ")]
    add(p, x)

print(" ".join([str(v) for k, v in sorted(data.items(), key=lambda x: x[0])]))


### FIXED CODE ###

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

import sys


sys.setrecursionlimit(10**6)


def main():
    n, q = map(int, sys.stdin.readline().split())

    tree = [[] for x in range(n + 1)]
    data = [0 for x in range(n + 1)]

    for _ in range(n - 1):
        a, b = map(int, sys.stdin.readline().split())
        tree[a].append(b)
        tree[b].append(a)

    for _ in range(q):
        p, x = map(int, sys.stdin.readline().split())
        data[p] += x

    def dfs(p, p2, x):
        data[p] += x
        for p3 in tree[p]:
            if p3 == p2:
                continue
            dfs(p3, p, data[p])

    dfs(1, 0, 0)

    print(" ".join([str(x) for x in data[1:]]))


if __name__ == "__main__":
    main()
N = int(input())
ans = 0

#奇数判定
for i in range(1, N+1, 2):
    cnt = 0
    #約数判定
    for j in range(1, i+1):
        if j % i == 0:
            cnt += 1
        
    if cnt == 8:
        ans += 1

print(ans)
        



### FIXED CODE ###

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

print((A-1) * (B-1))
N = input()
R = input()
ans = 0

if N < 10:
  ans = R + 100*(10-N)
  print(ans)
else:
  ans = R
  print(R)

### FIXED CODE ###

l=[int(x) for x in input().split()]
N=l[0]
R=l[1]

if N >= 10:
  ans = R
  print(ans)
else:
  ans = R + 100*(10-N)
  print(ans)
import math
a,b = map(int,input().split())
print(math.ceil((b - 1) / (a - 1)))


### FIXED CODE ###

s = input()
t = input()
cnt = 0
for i in range(3):
    if s[i] == t[i]:
        cnt +=1
print(cnt)
A, B, X = map(int, input().split())

n = int(X / A)

while X < A * n + B * len(str(n)):
    n -= 1

if n > 1000000000:
    n = 1000000000

if n < 0:
    n = 0

print(n)



### FIXED CODE ###


S = input()

day = ['SUN','MON','TUE','WED','THU','FRI','SAT']

n = day.index(S)

print(7 - n)
import sys
input = sys.stdin.readline
n = int(input())
a = [tuple(map(int,input().split())) for _ in range(n)]
for _ in range(n):
  if a[_][2] > 1:
    flag = _
    break
c = 0
for _ in range(101): #x
  for i in range(101): #y
    h = a[flag][2] + abs(a[flag][0]-_) + abs(a[flag][1]-i)
    for j in range(n):
      b = 0
      if a[j][2] != max(h - abs(a[j][0]-_) - abs(a[j][1]-i),0):
        b = 1
        break
      if j == n-1:
        print(_,i,h)
        c = 1
        break
    if c == 1:
      break
  if c == 1:
    break

### FIXED CODE ###

n = int(input())
z = [0] * n
for i in range(n):
  x,y,h = map(int,input().split())
  if h != 0:
    k = [x,y,h]
  z[i] = [x,y,h]
for i in range(101):
  for j in range(101):
    H = k[2] + abs(k[0]-i) + abs(k[1]-j)
    for l in z:
      if l[2] != max(H-abs(l[0]-i)-abs(l[1]-j),0):
        break
      if l == z[-1]:
        print(i,j,H)
        exit()
l,m = map(int,input().split())
lis =[]
lis2=[]
for i in range(l):
  lis.append(m+i)
  lis2.append(abs(m+i))

lis.pop(lis2.index(min(lis2)))
print(sum(lis)
  

### FIXED CODE ###

l,m = map(int,input().split())
lis =[]
lis2=[]
for i in range(l):
  lis.append(m+i)
  lis2.append(abs(m+i))

lis.pop(lis2.index(min(lis2)))
print(sum(lis))