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

n,q = map(int,input().split())
s = input()
l = [list(map(int,input().split())) for i in range(q)]
s_len = len(s)
account = s.count('AC')
count = 0
for i in range(q):
    center = len(s[l[i][0]-1:l[i][1]])
    if center <= s_len:
        print(s[l[i][0]-1:l[i][1]].count('AC'))
    else:
        '''
        left = s[0:]
        if s[l[i][0]-1:l[i][0]+1] == 'AC':
            count += 1
        if s[l[i][1]-1:l[i][1]+!] =='AC':
            count += 1
        print(account-)
        '''
        pass


### FIXED CODE ###

n,q = map(int,input().split())
s = input()
t = [0]*(n+1)
for i in range(n):
    t[i+1] = t[i] + (1 if s[i:i+2]=="AC" else 0)
for i in range(q):
    l,r = map(int,input().split())
    print(t[r-1]-t[l-1])
### BUGGY CODE ###

r, g, b, n = map(int, input().split())
ans = 0
for i in range(n // r + 1):
  for j in range(n // g + 1):
    if (n - r * i - g * j) / b == int((n - r * i - g * j) / b) and (n - r * i - g * j) / b >= 0:
      ans += 1
print(ans)

### FIXED CODE ###

r, g, b, n = map(int, input().split())
ans = 0
for i in range(n // r + 1):
  for j in range((n - r * i) // g + 1):
    if (n - r * i - g * j) % b == 0 and (n - r * i - g * j) // b >= 0:
      ans += 1
print(ans)
### BUGGY CODE ###

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

N = int(input())

i = 0
while True:
    bins = list(bin(i)[2:])
    ans = 0
    for j in range(len(bins)-1, -1, -1):
        if bins[j] == "1":
            ans += (-2) ** (len(bins)-1-j)
    if ans == N:
        print("".join(bins))
        exit()
    i += 1

### FIXED CODE ###

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

N = int(input())

ans = ""
while N != 0:
    # 末尾の桁が偶奇を決めているので、そこが0か1かは判断できる
    if N % 2 == 0:
        ans = "0" + ans
    else:
        # 今の末尾の桁は1だったので、まずはその分を引く
        N -= 1
        ans = "1" + ans
    # -2進数は-2で割れば桁を落とせる(10進数で割る10する感じ)
    N /= -2
# Nが元々0だった場合
if ans == "":
    ans = 0

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

n, k, q = map(int, input().split())
a = []
for i in range(q):
    t = int(input())
    a.append(t)
m = [k] * n
for i in a:
    for j in range(n):
        if j != i - 1:
            m[j] -= 1
for i in m:
    print("Yes" if i>0 else "No")

### FIXED CODE ###

n, k, q = map(int, input().split())
a = []
for i in range(q):
    t = int(input())
    a.append(t)
m = [k - q] * n
for i in a:
    m[i-1] += 1
for i in m:
    print("Yes" if i>0 else "No")
### BUGGY CODE ###

n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(w + 1):
        if j - wv[i][0] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - wv[i][0]] + wv[i][1])
        dp[i + 1][j] = max(dp[i][j], dp[i + 1][j])          
print(dp[n][w])

### FIXED CODE ###

n, w = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(n)]
dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(w + 1):
        if j - wv[i][0] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - wv[i][0]] + wv[i][1])
        dp[i + 1][j] = max(dp[i][j], dp[i + 1][j])          
print(dp[n][w])
### BUGGY CODE ###

n, m = map(int, input().split())
As = [int(input()) for i in range(m)]


dp = [0] * (n+1)
mod = 10**9 + 7
# 配るdp ではなくもらうdpで書くようにしてみる

for i in range(n+1):
    if i == 0:
        dp[i] = 1

    elif i in As:
        dp[i] = 0
    elif i == 1:
        dp[i] = dp[i-1]
    else:
        dp[i] = (dp[i-1] % mod + dp[i-2] % mod) % mod
    


print(dp[n])


### FIXED CODE ###

n, m = map(int, input().split())
As = [int(input()) for i in range(m)]


dp = [0] * (n+1)
mod = 10**9 + 7
# 配るdp ではなくもらうdpで書くようにしてみる
is_safe = [True] * (n+1)
for i in range(m):
    is_safe[As[i]] = False



for i in range(n+1):
    if i == 0:
        dp[i] = 1
    
    elif not is_safe[i]:
        dp[i] = 0
    elif i == 1:
        dp[i] = dp[i-1]
    else:
        dp[i] = (dp[i-1] % mod + dp[i-2] % mod) % mod


print(dp[n])
### BUGGY CODE ###

import math
a,b=map(int, input().split())

if abs(a-b) == 1:
    print(math.factorial(a)*math.factorial(b))
if abs(a-b) == 0:
    print(math.factorial(a)*math.factorial(b)*2)
if abs(a-b) >= 2:
    print(0)

### FIXED CODE ###

import math
a,b=map(int, input().split())

if abs(a-b) == 1:
    c = math.factorial(a)%(10**9+7)
    d = math.factorial(b)%(10**9+7)
    print(c*d%(10**9+7))
if abs(a-b) == 0:
    c = math.factorial(a)%(10**9+7)
    d = math.factorial(b)%(10**9+7)
    print(c*d*2%(10**9+7))
if abs(a-b) >= 2:
    print(0)
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
s_readline = sys.stdin.readline


def solve():

    N, K = map(int, readline().split())
    A = list(map(int, readline().split()))

    #N, K = 2 * (10**5), 10000000
    #A = [0] * N

    for k in range(K):

        B = [0] * N
        for i in range(N):
            l = max(0, i - A[i])
            B[l] += 1
            r = i + A[i] + 1
            if r <= N - 1:
                B[r] += -1

        s = B[0]
        for i in range(N - 1):
            B[i + 1] += B[i]
            s += B[i + 1]

        A = B

        if s == N * N:
            print(' '.join(map(str, A)))
            exit()

    print(' '.join(map(str, A)))


if __name__ == '__main__':
    solve()


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
s_readline = sys.stdin.readline


def solve():

    N, K = map(int, readline().split())
    A = list(map(int, readline().split()))

    #N, K = 2 * (10**5), 10000000
    #A = [0] * N

    for k in range(K):

        B = [0] * N
        for i in range(N):
            l = max(0, i - A[i])
            B[l] += 1
            r = i + A[i] + 1
            if r <= N - 1:
                B[r] += -1

        s = B[0]
        for i in range(N - 1):
            B[i + 1] += B[i]
            s += B[i + 1]

        A = B

        if s == N * N:
            print(' '.join(map(str, A)))
            exit()

    print(' '.join(map(str, A)))


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

from operator import mul
from functools import reduce
cnt = 1000000000000000000
N = map(int, input().split())
nums = list(map(int, input().split()))


count  = reduce(mul, nums)
if "0" in N:
        print("0")
elif count  > cnt :
        print(-1)
else:
         print(count)


### FIXED CODE ###

#from operator import mul
#from functools import reduce
#cnt = 1000000000000000000
ans =1
N = int(input())
nums = list(map(int, input().split()))

if 0 in nums:
        print(0)
        exit()
for num in nums:
    ans *= num
    if ans > 10**18 :
        print(-1)
        exit()
print(ans)
### BUGGY CODE ###

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

d = dict()

for a in A:
    d[a] = d.get(a, 0) + 1

for _ in range(int(input())):
    b, c = map(int, input().split())
    if d.get(b, 0) != 0:
        temp = d[b]
        d[b] -= temp
        d[c] = d.get(c, 0) + temp

    print(sum(k*v for k, v in d.items()))

### FIXED CODE ###

def main():
    n = int(input())
    A = list(map(int, input().split()))

    sum_a = sum(A)

    d = dict()

    for a in A:
        d[a] = d.get(a, 0) + 1

    for _ in range(int(input())):
        b, c = map(int, input().split())
        if d.get(b, 0) != 0:

            temp = d[b]         
            d[b] -= temp
            d[c] = d.get(c, 0) + temp

            sum_a += (c - b) * temp
        print(sum_a)
        
main()
### BUGGY CODE ###

pre_n, city_n = map(int, input().split())
cities = [list(map(int, input().split())) for x in range(city_n)]

history = {}

A = {}

for x in sorted(cities):
    pref = str(x[0])
    if pref not in history:
        history[pref] = '1'

    A[str(x)] = '0'*(6-len(pref)) + pref + '0'*(6-len(history[pref])) + history[pref]

    history[pref] = str(int(history[pref]) + 1)

for x in cities:
    print(A[str(x)])


### FIXED CODE ###

pre_n, city_n = map(int, input().split())
cities = [list(map(int, input().split())) for x in range(city_n)]

history = {}

A = {}

for x in sorted(cities):
    pref = str(x[0])
    if pref not in history:
        history[pref] = '1'

    A.setdefault(str(x), '0'*(6-len(pref)) + pref + '0'*(6-len(history[pref])) + history[pref])

    history[pref] = str(int(history[pref]) + 1)

for x in cities:
    print(A[str(x)])
### BUGGY CODE ###

import sys
from heapq import heappush, heappop

na = lambda: map(int, sys.stdin.readline().split())

n, m = na()
ab = [list(na()) for _ in range(n)]

ans = 0
h = []
for day in range(1, m+1):
  d = 0
  for i in range(len(ab)):
    if ab[i-d][0] <= day:
      heappush(h, -ab.pop(i-d)[1])
      d += 1
  if h:
    ans += -heappop(h)

print(ans)

### FIXED CODE ###

import sys
from heapq import heappush, heappop
from operator import itemgetter

na = lambda: map(int, sys.stdin.readline().split())

n, m = na()
ab = [list(na()) for _ in range(n)]
ab.sort(key=itemgetter(0))

ans = 0
p = 0
h = []
for day in range(1, m+1):
  for i in range(p, len(ab)):
    if ab[i][0] <= day:
      heappush(h, -ab[i][1])
      p += 1
    else:
      break
  if h:
    ans += -heappop(h)

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

import sys
import math
import collections
import bisect
import copy
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()
    bit = [[0] * 20 for _ in range(n)]

    for i, ai in enumerate(a):
        cnt = 0
        while ai > 0:
            bit[i][cnt] = ai & 1
            cnt += 1
            ai >>= 1

    ans = n
    l = 0
    while l < n - 1:
        base = bit[l]
        for r in range(l + 1, n):
            flg = True
            for idx in range(20):
                if base[idx] and bit[r][idx]:
                    flg = False
                    break
                elif base[idx] or bit[r][idx]:
                    base[idx] = 1
            if not flg:
                ans += r - l - 1
                break
            if flg and r == n - 1:
                ans += r - l
                break

        l += 1

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import math
import collections
import bisect
import copy
import itertools

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n = ni()
    a = na()
    bit = [[0] * 20 for _ in range(n)]
    bitidx = [[] * 20 for _ in range(20)]

    for i, ai in enumerate(a):
        cnt = 0
        while ai > 0:
            if ai & 1:
                bit[i][cnt] = 1
                bitidx[cnt].append(i)
            cnt += 1
            ai >>= 1

    ans = n

    for i in range(n):
        min_idx = n
        for j in range(20):
            # jbit目でiの次に1になるidxを探す　ない場合はlen(bitidx[j])が返ってくる
            tmp = bisect.bisect_left(bitidx[j], i + 1)
            if bit[i][j]:
                # 1のときは次の1を探す
                if tmp < len(bitidx[j]):
                    tmp = bitidx[j][tmp]
                else:
                    tmp = n
            else:
                # 0のときは2つ目の1を探す
                tmp += 1
                if tmp < len(bitidx[j]):
                    tmp = bitidx[j][tmp]
                else:
                    tmp = n
            min_idx = min(min_idx, tmp)
        ans += min_idx - i - 1

    print(ans)


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

n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
for i in range(1,n+1):
    if a.count(i) <= q-k:
        print('No')
    else:
        print('Yes')


### FIXED CODE ###

import collections
n,k,q = map(int,input().split())
a = [int(input()) for i in range(q)]
c = collections.Counter(a)
for i in range(1,n+1):
    if c[i] <= q-k:
        print('No')
    else:
        print('Yes')
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#

def main():
    H,N=mis()
    AB = tuple(tuple(mis()) for _ in range(N))
    DP = [INF] * (H+1)
    DP[0] = 0
    for h in range(1, H+1):
        for i in range(N):
            DP[h] = min(DP[h], (DP[h-AB[i][0]]+AB[i][1] if h-AB[i][0]>0 else AB[i][1]))

    print(DP[-1])

main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#

def main():
    H,N=mis()
    AB = tuple(tuple(mis()) for _ in range(N))
    DP = [INF] * (H+1)
    DP[0] = 0
    for h in range(1, H+1):
        for i in range(N):
            DP[h] = min(DP[h], (DP[h-AB[i][0]]+AB[i][1] if h-AB[i][0]>0 else AB[i][1]))

    print(DP[-1])

main()
### BUGGY CODE ###

def K(n):
    s = 0
    for i in range(1, n+1):
        s += i
    return s / i

def d():
    n, k = input().split()
    n = int(n)
    k = int(k)
    p = input().split()

    m = 0
    for i in range(0, len(p)-k+1):
        a = 0
        for i2 in range(k):
            a += int(p[i+i2])
        if m < a:
            m = a
            I = i
    m2 = 0
    for i in range(k):
        m2 += K(int(p[I + i]))
    return m2
print(d())

### FIXED CODE ###

def K(n):
    return 0.5 * (n + 1)

def d():
    n, k = list(map(int, input().split()))
    p = list(map(int, input().split()))

    pionta = None
    ire = [None for i in range(k)]
    d = {}
    d[0] = 0

    ss = 0
    for i in range(0, n):
        if k < i + 1:
            pionta = i % k
        if pionta is None:
            ire[i] = p[i]
        else:
            ss += p[i] - ire[pionta]
            d[ss] = i
            ire[pionta] = p[i]


    max_s = max(d.keys())
    i = d[max_s]
    m = 0
    for i2 in range(i-k+1, i+1):
        m += K(p[i2])
    return m
print(d())
### BUGGY CODE ###

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
AB = []
for i in A:
    for j in B:
        AB.append(i + j)


AB = sorted(AB, reverse=True)[:K]
C = sorted(C, reverse=True)
ans = []
for i in C:
    for j in AB:
        ans.append(i + j)

ans = sorted(ans, reverse=True)[:K]
for i in ans:
    print(i)






### FIXED CODE ###

X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
AB = []
for i in A:
    for j in B:
        AB.append(i + j)


AB = sorted(AB, reverse=True)[:K]
C = sorted(C, reverse=True)
ans = []
for i in C:
    for j in AB:
        ans.append(i + j)

ans = sorted(ans, reverse=True)[:K]
for i in ans:
    print(i)
### BUGGY CODE ###

###############################################################################
#Imports
import collections
import itertools
from functools import lru_cache
import sys
import math
###############################################################################
#Constants
MOD = int(1e9)+7
###############################################################################
#Helper
def helper():
	pass
###############################################################################
#Solver
def solve():
	n = int(input())
	arr = list(map(int, input().split(' ')))
	sm = 1
	for num in arr:
		sm *= num
	if sm > int(1e18):
		print(-1)
		return
	print(sm)

###############################################################################
#Driver
t = 1
for _ in range(t):
	solve()
###############################################################################


### FIXED CODE ###

###############################################################################
#Imports
import collections
import itertools
from functools import lru_cache
import sys
import math
###############################################################################
#Constants
MOD = int(1e9)+7
###############################################################################
#Helper
def helper():
	pass
###############################################################################
#Solver
def solve():
	n = int(input())
	arr = list(map(int, input().split(' ')))
	sm = 1
	if 0 in arr:
		print(0)
		return
	for num in arr:
		sm *= num
		if sm > int(1e18):
			print(-1)
			return
	print(sm)

###############################################################################
#Driver
t = 1
for _ in range(t):
	solve()
###############################################################################
### BUGGY CODE ###

from sys import stdin

num = int(input())

list2 = ["END"]
cur = list2.index("END")

for i in range(num):
	cmd = stdin.readline().strip().split()

	if cmd[0] == "0":
		if cur == 0:
			list2.insert(0,cmd[1])
			cur = 0
		else:
			list2.insert(cur,cmd[1])

	elif cmd[0] == "1":
		cur += int(cmd[1])
	else:
		tmp = cur
		list2.pop(cur)
		cur1 = list2.index("END")
		if tmp == cur1 - 1:
			cur = list2.index("END")

list2.remove("END")
print(*list2,sep='\n')



### FIXED CODE ###

from sys import stdin

class QueueNode(object):
	def __init__(self,data,next=None,prev=None):
		self.data = data
		self.next = next
		self.prev = prev

class LinkList(object):
	def __init__(self,head=None):
		self.head = head
		self.tail = head
		self.cur  = head

	def insert_q(self,data):
		node = QueueNode(data)

		if self.cur is None:
			self.head = node
			self.tail = node
			self.cur  = node
			return

		currentNode = self.cur
		preNode = currentNode.prev

		if currentNode.prev is None:
			currentNode.prev = node
			node.next = currentNode
			self.head = self.cur = node
		else:
			if self.tail is not None:
				currentNode.prev = node
				node.prev = preNode
				node.next = currentNode
				preNode.next = node
				self.cur = node
			else:
				currentNode.next = node
				node.prev = currentNode
				node.next = None
				self.cur = node
				self.tail = node


	def move_q(self,mv):
		currentNode = self.cur
		cnt = mv
		while cnt != 0:
			if mv < 0:#prev
				if currentNode.prev is None:
					self.head = self.cur = currentNode
					break
				else:
					currentNode = currentNode.prev
					self.cur = currentNode
					cnt += 1
			else:#next
				if currentNode.next is None:
					self.cur = currentNode
					break
				else:
					currentNode = currentNode.next
					self.cur = currentNode
					cnt -= 1


	#カレントを削除する
	def delete_q(self):
		currentNode = self.cur
		nexNode = currentNode.next
		preNode = currentNode.prev

		#自身の前がいない（=先頭）
		if preNode is None:
			nexNode.prev = None
			self.head = nexNode
			self.cur = nexNode
		#自身の後ろがいない（=末尾）
		elif nexNode is None:
			preNode.next = None
			self.tail = None
		else:
			preNode.next = currentNode.next
			nexNode.prev = currentNode.prev
			self.cur = currentNode.next

	#先頭を表示する
	def print_q(self):
		if self.head is not None:
			print(self.head.data)

	#全体表示（先頭から）
	def print_all(self):
		if self.head is not None:
			currentNode = self.head
			while currentNode.next is not None:
				print(currentNode.data)
				currentNode = currentNode.next

if __name__ == '__main__':

	loopnum = int(input())

	ll = LinkList()
	ll.insert_q("E")
	for i in range(loopnum):
		cmd = stdin.readline().strip().split()
		if cmd[0] == "0":
			t = int(cmd[1])
			ll.insert_q(t)
		elif cmd[0] == "1":
			t = int(cmd[1])
			ll.move_q(t)
		else:
			ll.delete_q()
	ll.print_all()
### BUGGY CODE ###

N,Q = [int(i) for i in input().split()]
S = str(input())
lrlist = []
for i in range(Q):
    lrlist.append([int(i)-1 for i in input().split()])

#print(S)
#print(lrlist)

import re
result = [i.span() for i in re.finditer("AC",S)]
#print(result)

for l,r in lrlist:
    ans = 0
    for i in result:
        if l <= i[0] and i[0]+1 <= r:
            ans+=1
    print(ans)

### FIXED CODE ###

N,Q = [int(i) for i in input().split()]
S = str(input())
lrlist = []
for i in range(Q):
    lrlist.append([int(i)-1 for i in input().split()])

#print(S)
#print(lrlist)

Asite = [0]
for i in range(1,len(S)):
    if S[i-1]=="A" and S[i]=="C":
        Asite.append(Asite[-1]+1)
    else:
        Asite.append(Asite[-1])


for l,r in lrlist:
    print(Asite[r]-Asite[l])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000) 

N,M = map(int,input().split())
ans=[0]*N
a = [list(map(int, input().split())) for _ in range(N-1)]

for _ in range(M):
    e,f = list(map(int, input().split()))
    ans[e-1] += f

trees = {}
for word in a:
    trees.setdefault(word[0], []).append(word[1])
    trees.setdefault(word[1], []).append(word[0])
    

def sumup(ne,parent):
    global ans
    if ne in trees:    
        for k in trees[ne]:
            if k != parent:
                ans[k-1] += ans[ne-1]
                sumup(k,ne)

sumup(1,0)
for i in ans:
    print(i)


### FIXED CODE ###

import sys
sys.setrecursionlimit(500000) 
input=sys.stdin.readline

N,M = map(int,input().split())
ans=[0]*N
a = [list(map(int, input().split())) for _ in range(N-1)]

for _ in range(M):
    e,f = list(map(int, input().split()))
    ans[e-1] += f

trees = {}
for word in a:
    trees.setdefault(word[0], []).append(word[1])
    trees.setdefault(word[1], []).append(word[0])
    

def sumup(ne,parent):
    global ans
    if ne in trees:    
        for k in trees[ne]:
            if k != parent:
                ans[k-1] += ans[ne-1]
                sumup(k,ne)

sumup(1,0)
for i in ans:
    print(i)
### BUGGY CODE ###

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

A = []
B = []
for i in range(a):
    c, d = map(int, input().split())
    A.append(c)
    B.append(d)

ans = 0

for i in range(a*b + 1):
    j = A.index(min(A))
    ans += A[j]
    B[j] -= 1
    b -= 1
    if(b == 0):
        print(ans)
        break
    if(B[j] == 0):
        A[j] = 1000000


### FIXED CODE ###

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

A = []

for i in range(a):
    c= list(map(int, input().split()))
    A.append(c)

ans = 0

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


for j in range(a+1):
    if(b - A[j][1] >=0):
        ans += A[j][0] * A[j][1]
        b -= A[j][1]
    else:
        ans += A[j][0] * b
        b = 0
    if(b == 0):
        break
    
print(ans)
### BUGGY CODE ###

x, y = map(int, input().split())
if x == y:
    print(x)
else:
    for i in range(1, abs(x-y)+1):
        if x % i == y % i == 0:
            j = i
    print(j)

### FIXED CODE ###

a,b=map(int,input().split())
while b:
 a,b=b,a%b
print(a)
### BUGGY CODE ###

from collections import *
nxy=input().rstrip().split(" ")
n=int(nxy[0])
x=int(nxy[1])
y=int(nxy[2])
dis=[]
for i in range(1,n):
    #print(i)
    j=i+1
    while j>i and j<=n:
        l1=abs(x-i)+1+abs(y-j)
        l2=j-i
        if l1>=l2:
            L=l2
        else:
            L=l1
        #print(L)
        dis.append(L)
        j=j+1
#print(dis)
for k in range(1,n):
    print(dis.count(k))

### FIXED CODE ###

import collections 
nxy=input().rstrip().split(" ")
n=int(nxy[0])
x=int(nxy[1])
y=int(nxy[2])
dis=[]
for i in range(1,n):
    #print(i)
    j=i+1
    while j>i and j<=n:
        l1=abs(x-i)+1+abs(y-j)
        l2=j-i
        if l1>=l2:
            L=l2
        else:
            L=l1
        #print(L)
        dis.append(L)
        j=j+1
#print(dis)
c=collections.Counter(dis)
#print(c)
for k in range(1,n):
    print(c[k])