Harryxun/stf_run huggingface dataset:
import bisect
from collections import defaultdict

N = int(input())
S = input()
Q = int(input())


alpha_dic = defaultdict(list)

for i, s in enumerate(S):
    alpha_dic[s].append(i)

for _ in range(Q):
    l, m, n = input().split()

    if l == '1':
        m = int(m) - 1
        c = S[m]

        if c == n:
            continue
        else:
            i = bisect.bisect_left(alpha_dic[c], m)
            del alpha_dic[c][i]

            bisect.insort_left(alpha_dic[n], m)
    else:
        m, n = int(m) - 1, int(n) - 1

        cnt = 0
        for _, val in alpha_dic.items():
            left_idx = bisect.bisect_left(val, m)
            right_idx = bisect.bisect_left(val, n)
            x = len(val)

            if left_idx > right_idx or left_idx == x or (left_idx == 0 and right_idx == 0 and val[0] != m and val[0] != n):
                continue
            else:
                cnt += 1

        print(cnt)


### FIXED CODE ###

import bisect
from collections import defaultdict

N = int(input())
S = list(input())
Q = int(input())

alpha_dic = defaultdict(list)

for i, s in enumerate(S):
    alpha_dic[s].append(i)

for _ in range(Q):
    l, m, n = input().split()

    if l == '1':
        m = int(m) - 1
        c = S[m]

        if c == n:
            continue
        else:
            i = bisect.bisect_left(alpha_dic[c], m)
            del alpha_dic[c][i]

            bisect.insort_left(alpha_dic[n], m)
            S[m] = n
    else:
        m, n = int(m) - 1, int(n) - 1

        cnt = 0
        for _, val in alpha_dic.items():
            if not val:
                continue

            left_idx = bisect.bisect_left(val, m)
            right_idx = bisect.bisect_left(val, n)
            l = len(val)

            if left_idx > right_idx or (left_idx == right_idx and left_idx == l) or (left_idx == right_idx and val[left_idx] != m and val[right_idx] != n):
                continue

            cnt += 1

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

for i in A:
    H -= i

if H > 0:
    print('No')
else
    print('Yes')

### FIXED CODE ###

H, N = map(int, input().split())
A = (map(int, input().split()))
for i in A:
    H -= i
 
if H > 0:
    print('No')
else:
    print('Yes')
N,M = map(int,input().split())
# AB_s = [list(map(int,input().split())) for _ in range(N)]
dicts = {i:[] for i in range(1,M+1)}
for _ in range(N):
    A,B = map(int,input().split())
    dicts[A].append(B)
answer = 0
wages = []
for i in range(1,M+1):
    wages.extend(dicts[i])
    if wages:
        wages.sort()
        answer += wages.pop()
print(answer)
# AB_s = sorted(AB_s, key=lambda x:-x[0])
# print(AB_s)

### FIXED CODE ###

import heapq
N,M = map(int,input().split())
AB_s = [list(map(int, input().split())) for _ in range(N)]
MAPperA = {i: [] for i in range(1,M+1)}
# 残り日数ごとのマップを作る
for i, AB in enumerate(AB_s):
    if AB[0] in MAPperA:
        MAPperA[AB[0]].append(AB[1])
excutableJobList = []
heapq.heapify(excutableJobList)
answer = 0
# 短期間でできる仕事からリストを作って追加してそーとして最大値を追加していく
for i in range(1,M+1):
    for j in MAPperA[i]:
        heapq.heappush(excutableJobList, j*-1)
    if excutableJobList:
        answer += heapq.heappop(excutableJobList) * -1
print(answer)
a = int(input("coinA:"))
b = int(input("coinB:"))
c = int(input("priceC:"))

if a + b >= c:
	print("Yes")
else:
	print("No")

### FIXED CODE ###

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

if a + b >= c:
	print("Yes")
else:
	print("No")
N, K = map(int, input().split())
S = input()

L = []
R = []
before = S[0]
cnt_zero = 0
cnt_one = 0
len_l = 0
len_r = 0
for i in range(N):
    if before == '0' and S[i] == '0':
        cnt_zero += 1
    elif before == '0' and S[i] == '1':
        before = '1'
        L.append(cnt_zero)
        len_l += 1
        cnt_zero = 0
        cnt_one += 1
    elif before == '1' and S[i] == '0':
        before = '0'
        R.append(cnt_one)
        len_r += 1
        cnt_zero += 1
        cnt_one = 0
    else:
    	cnt_one += 1
if cnt_zero > 0:
    L.append(cnt_zero)
    len_l += 1

if cnt_one > 0:
	R.append(cnt_one)
	len_r += 1
ans = 0
sum_one = 0
if S[0] == '0':
	sum_one = sum(L[:K]) + sum(R[:K])
else:
	sum_one = sum(L[:K]) + sum(R[:K+1])

ans = sum_one
for i in range(len_l)[1:]:
    if i + K > len_l:
        break
    elif i + K == len_l:
        if i + K > len_r:
            sum_one += (L[K+i-1] - L[i-1] - R[i-1])
            ans = max(ans, sum_one)
            break
    if S[0] == '0' and i == 1:
        sum_one += (L[K] + R[K] - L[0])
    else:
        sum_one += (L[K+i-1] + R[K+i] - L[i-1] - R[i-1])
    ans = max(ans, sum_one)
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
S = input()

before = S[0]
cnt = 0
same_nums = []
if S[0] == '0':
  same_nums.append(0)
for i in range(N):
  if S[i] == before:
    cnt += 1
  else:
    same_nums.append(cnt)
    before = S[i]
    cnt = 1
same_nums.append(cnt)
if S[-1] == '0':
  same_nums.append(0)
  
sum_nums = sum(same_nums[:2*K+1])
ans = sum_nums
for i in range(0, len(same_nums)-2*K, 2):
  sum_nums = sum_nums - sum(same_nums[i:i+2]) + sum(same_nums[i+2*K+1:i+2*K+3])
  ans = max(ans, sum_nums)
print(ans)
import math

k, a, b = map(int, input().split())
p = 0
inc = a - b

if inc < 0:
    if k >= a:
        print(1)
    else:
        print(-1)
    exit()
print(math.ceil((k-a) / inc)*2+1)




### FIXED CODE ###

import math

k, a, b = map(int, input().split())
inc = a - b
if k <= a:
    print(1)
elif inc < 0:
    if k <= a:
        print(1)
    else:
        print(-1)
elif inc == 0:
    print(-1)
else:
    from decimal import *
    getcontext().prec = 500
    print(math.ceil(Decimal(k-a) / Decimal(inc))*2+1)
n,k=map(int,input().split())
h=list(int(input())for i in range(n))
h.sort()
l=[]
for i in range(n-k+1):
    l.append(h[k-i+1]-h[i])


print(min(l))


### FIXED CODE ###

n,k=map(int,input().split())
h=list(int(input())for _ in range(n))
h.sort()
l=[]
for i in range(n-k+1):
    l.append(h[k+i-1]-h[i])


print(min(l))
s = input()
k = int(input())
for i, v in enumerate(s):
  if v != "1":
    pos1 = i
    break
  
if k < pos1 + 1:
  print(1)
else:
  print(s[pos1])


### FIXED CODE ###

s = input()
k = int(input())

pos1 = len(s)
for i, v in enumerate(s):
  if v != "1":
    pos1 = i
    break
  
if k < pos1 + 1:
  print(1)
else:
  print(s[pos1])
n=int(input())
a=[map(int,input().split()]
print(max(a)-min(a))


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
print(max(a)-min(a))
提出

### FIXED CODE ###

a,b=map(int,input().split())
print(a+b if b%a==0 else b-a)
N, M, X, Y = map(int, input().split())
x = max(list(map(int, input().split())))
y = min(list(map(int, input().split())))
print('No War' if x < y and X < y else and x < Y 'War')

### FIXED CODE ###

N, M, X, Y = map(int, input().split())
x = max(list(map(int, input().split())))
y = min(list(map(int, input().split())))
print('No War' if x < y and X < y and x < Y else 'War')
N=int(input())
ST=[list(map(int,input().split())) for i in range(N)]
X=input()
ans=-1
for s,t in ST:
  if s !=X and ans==-1:
    continue
  else:
    if ans==-1:
      ans=0
    else:
      ans+=t
print(ans)


### FIXED CODE ###


N=int(input())
ST=[list(input().split()) for i in range(N)]
X=input()
ans=-1
for s,t in ST:
  if s !=X and ans==-1:
    continue
  else:
    if ans==-1:
      ans=0
    else:
      ans+=int(t)
print(ans)
import numpy as np
n,k = map(int,input().split())
a_list = sorted(map(int,input().split()))
mod = 10**9+7
if n-k < a_list.count(0):
    print(0)
    exit()
if sum([1 for a in a_list if np.sign(a)==-1])==k:
    a_list.sort(key = abs)
    ans = 1
    for num in a_list[:k]:
        ans *= num
        ans %= mod
    print(ans)
    exit()
else:
    a_list.sort(key = abs,reverse = True)
    if len([a for a in a_list[:k] if np.sign(a)==-1])%2!=0:
        negative_min_big = max([num for num in a_list[:k] if np.sign(num)==-1])
        positive_min_big = min([num for num in a_list[:k] if np.sign(num)!=-1])
        negative_max_small = min([num for num in a_list[k:] if np.sign(num)==-1])
        positive_max_small = max([num for num in a_list[k:] if np.sign(num)!=-1])
        if positive_max_small/negative_min_big < negative_max_small/positive_min_big:
            remove = negative_min_big
            add = positive_max_small
        else:
            remove = positive_min_big
            add = negative_max_small
ans = 1
for num in a_list[:k]:
    ans *= num
    ans %= mod
    
 
print(ans)

### FIXED CODE ###

import numpy as np
import sys
n,k = map(int,input().split())
a_list = sorted(map(int,input().split()))
mod = 10**9+7
if n-k < a_list.count(0):
    print(0)
    exit()
if (sum([1 for a in a_list if np.sign(a)!=-1])==0 and k%2==1) or (k==n and len([1 for a in a_list if np.sign(a)==-1])%2==1):
    a_list.sort(key = abs)
    ans = 1
    for num in a_list[:k]:
        ans *= num
        ans %= mod
    print(ans)
    exit()
else:
    a_list.sort(key = abs,reverse = True)
    add = 1
    remove = 1
    if len([a for a in a_list[:k] if np.sign(a)==-1])%2!=0:
        negative_big = [num for num in a_list[:k] if np.sign(num)==-1]
        positive_big = [num for num in a_list[:k] if np.sign(num)!=-1]
        negative_small = [num for num in a_list[k:] if np.sign(num)==-1]
        positive_small = [num for num in a_list[k:] if np.sign(num)!=-1]
        
        
        if len(negative_big)==0 or len(positive_small)==0:
            remove = min(positive_big)
            add = min(negative_small)
        elif len(positive_big)==0 or len(negative_small)==0:
            remove = max(negative_big)
            add = max(positive_small)
        else:
            positive_small_max = max(positive_small)
            negative_big_max = max(negative_big)
            negative_small_min = min(negative_small)
            positive_big_min = min(positive_big)
            if positive_small_max*positive_big_min > negative_small_min*negative_big_max:
                remove = negative_big_max
                add = positive_small_max
            else:
                remove = positive_big_min
                add = negative_small_min
ans = 1
for num in a_list[:k]:
    ans *= num
    ans %= mod
    
if len([a for a in a_list[:k] if np.sign(a)==-1])%2!=0:
    ans *= add
    ans %= mod
    ans *= pow(remove, mod-2, mod)
    ans %= mod

print(ans)
import bisect
n, q = (int(i) for i in input().split())
s = input()
l,r = [],[]
for i in range(q):
    tmp = [int(i) for i in input().split()]
    l.append(tmp[0]-1)
    r.append(tmp[1]-1)
AC_index = []
while 'AC' in s:
    index = s.index('AC')
    AC_index.append(index + len(AC_index) * 2)
    if index < (len(s) - 1):
        s = s[:index] + s[index + 2:]
    else:
        s = s[:index]

for i in range(q):
    left_index = bisect.bisect_left(AC_index, l[i])
    right_index = bisect.bisect_right(AC_index, r[i])
    if AC_index[right_index - 1] == r[i]:
        right_index -= 1
        
    print(right_index-left_index)

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
L,R = [], []
for i in range(Q):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

AC = [0] * N

for i in range(1,N):
    if S[i - 1] == 'A' and S[i] == 'C':
        AC[i] = AC[i - 1] + 1
    else:
        AC[i] = AC[i - 1]

for l, r in zip(L, R):
    print(AC[r-1]-AC[l-1])
mod = 10**9+7
n, m = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

a = sorted(a, reverse=True)
b = sorted(b, reverse=True)

c = [0 for _ in range(n*m)]
for i in range(n):
    c[a[i]-1] += 1
    if c[a[i]-1] == 2:
        print(0)
        exit()

c = [0 for _ in range(n*m)]
for i in range(m):
    c[b[i]-1] += 1
    if c[b[i]-1] == 2:
        print(0)
        exit()

ans = 1

i = 0
j = 0

while i < n and j < m:
    if n*m > max(a[i], b[j]) + i*j:
        print(0)
        exit()
    if a[i] == b[i]:
        i += 1
        j += 1
    elif a[i] > b[j]:
        ans *= i
        ans %= mod
        i += 1
    else:
        ans *= j
        ans %= mod
        j += 1

res = n*m - min(n, m)

for i in range(1, res+1):
    ans *= i
    ans %= mod

print(ans)


### FIXED CODE ###

mod = 10**9+7
n, m = map(int, input().split())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

aa = [0 for _ in range(n*m)]
bb = [0 for _ in range(n*m)]

for i in range(n):
    if aa[n*m-a[i]] == 0:
        aa[n*m-a[i]] = 1
    else:
        print(0)
        exit()

for j in range(m):
    if bb[n*m-b[j]] == 0:
        bb[n*m-b[j]] = 1
    else:
        print(0)
        exit()

for i in range(n*m):
    if i == 0:
        continue
    aa[i] += aa[i-1]
    bb[i] += bb[i-1]

aa = aa[::-1]
bb = bb[::-1]

seta = set(a)
setb = set(b)

ans = 1

for x in range(1, n*m+1)[::-1]:
    if x in seta and x in setb:
        continue
    elif x in seta and x not in setb:
        ans *= bb[x-1]
        ans %= mod
    elif x not in seta and x in setb:
        ans *= aa[x-1]
        ans %= mod
    elif aa[x-1]*bb[x-1] - (n*m-x) > 0:
        ans *= aa[x-1]*bb[x-1] - (n*m-x)
        ans %= mod
    else:
        print(0)
        exit()

print(ans)
N = input()
A = list(map(int, input().split()))
A = sorted(A,reverse = True)
ans = 0
for i in range(1, 2*N, 2):
    ans += A[i]


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A = sorted(A,reverse = True)
ans = 0
for i in range(1, 2*N, 2):
    ans += A[i]
print(ans)
def _init_ (self,data):
        self.data = data

    def move(self,direction):
        if direction == 'E':
            self.data[0],self.data[3],self.data[5],self.data[2] = \
                    self.data[3].self.data[5],self.data[2],self.data[0]
        elif direction == 'N':
            self.data[0],self.data[4],self.data[5],self.data[1] = \
                    self.data[4].self.data[5],self.data[1],self.data[0]
        elif direction == 'S':
            self.data[0],self.data[1],self.data[5],self.data[4] = \
                    self.data[4].self.data[0],self.data[1],self.data[5]
        elif direction == 'W':
            self.data[0],self.data[2],self.data[5],self.data[3] = \
                    self.data[2].self.data[5],self.data[3],self.data[0]

    def getTop(self):
        return self.data[0]

dice = Dice(input().split())
cmd = input()
for i in range(len(cmd)):
    dice.move(cmd[i])
    print(dice.getTop())

### FIXED CODE ###

class Dice:
    def __init__ (self,data):
        self.data = data

    def move(self,direction):
        if direction == 'E':
            self.data[0],self.data[3],self.data[5],self.data[2] = \
                    self.data[3],self.data[5],self.data[2],self.data[0]
        elif direction == 'N':
            self.data[0],self.data[4],self.data[5],self.data[1] = \
                    self.data[1],self.data[0],self.data[4],self.data[5]
        elif direction == 'S':
            self.data[0],self.data[1],self.data[5],self.data[4] = \
                    self.data[4],self.data[0],self.data[1],self.data[5]
        elif direction == 'W':
            self.data[0],self.data[2],self.data[5],self.data[3] = \
                    self.data[2],self.data[5],self.data[3],self.data[0]

    def getTop(self):
        return self.data[0]

dice = Dice(input().split())
cmd = input()
for i in range(len(cmd)):
    dice.move(cmd[i])
print(dice.getTop())
import math
A = ord('a')
N = int(input())
L = 2**int(math.ceil(math.log(N, 2)))
S = [x for x in input()]
Q = int(input())

Seg = [0]*(L*2-1)

def order(c):
    return 1 << (ord(c) - A)

def count(n):
    return bin(n).count("1")

def merge(x, y):
    return x | y

def update(k, x):
    k += L - 1
    Seg[k] = x
    while k > 0:
        k = (k - 1) // 2
        Seg[k] = merge(Seg[2*k+1], Seg[2*k+2])
    Seg[0] = merge(Seg[1], Seg[2])

def find(a, b, k, l, r):
    if r <= a or b <= l:
        return 0
    if a <= l and r <= b:
        return Seg[k]
    vl = find(a, b, 2*k+1, l, (l+r)//2)
    vr = find(a, b, 2*k+2, (l+r)//2, r)

    return merge(vl, vr)


# read S, and update tree
for i in range(N):
    c = order(S[i])
    update(i, order(S[i]))
    #print("Seg", *[count(x) for x in Seg])

for _ in range(1000):
    s = input()
    if not s:
        break
    q, i, c = s.split()
    if q == '1':
        i = int(i)-1
        if S[i] == c:
            continue
        S[i] = c
        update(i, order(S[i]))
    else:
        l, r = int(i)-1, int(c)
        #print(count(find(l, r, 0, 0, L)), (l, r))
        print(count(find(l, r, 0, 0, L)))



### FIXED CODE ###

import numpy as np

def count(n):
    return bin(n).count("1")

def merge(x, y):
    return x | y

def update(Seg, k, x):
    k += len(Seg)//2
    Seg[k] = x
    while k > 0:
        k = (k - 1) // 2
        Seg[k] = Seg[k*2+1]|Seg[k*2+2]

d = {c:(1 << (ord(c)-97)) for c in 'abcdefghijklmnopqrstuvwxyz'}

class SegmentTree:
    def __init__(self, A):
        N = len(A)
        n = (N-1).bit_length()
        self.N = 1 << n
        self.Seg = [0 for i in range(2*self.N)]
        #for i in range(N): self.update(i, A[i])
        if True:
            for i in range(N):
                self.Seg[self.N+i-1] = d[A[i]]
            for i in range(0,self.N-2)[::-1]:
                self.Seg[i] = self.Seg[i*2+1] | self.Seg[i*2+2]

    def update(self, k, x):
        i = self.N+k-1
        self.Seg[i] = d[x]
        while i > 0:
            i = (i-1)//2
            self.Seg[i] = self.Seg[i*2+1]|self.Seg[i*2+2]
    def merge(self, x, y):
        return x | y

    def query(self, a, b):
        return self.query_(a, b, 0, 0, self.N)

    def query_(self, a, b, k, l, r):
        if r <= a or b <= l:
            return 0
        if a <= l and r <= b:
            return self.Seg[k]
        vl = self.query_(a, b, 2*k+1, l, (l+r)//2)
        vr = self.query_(a, b, 2*k+2, (l+r)//2, r)
        return merge(vl, vr)

def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    S = input()[:-1]
    Q = int(input())
    Seg = SegmentTree(S)

    for _ in range(Q):
        q, i, c = input().split()
        if q == '1':
            i = int(i)-1
            Seg.update(i, c)
        else:
            l, r = int(i), int(c)
            print(count(Seg.query(l-1, r)))
main()
n = input()
for i in range(1,n+1):
    if(i%3==0):
        print('%d'%(i),end=" ")
    elif(i%10==3):
        print('%d' % (i), end=" ")


### FIXED CODE ###

n = int(input())
print(" ",end="")
print(*[i for i in range(1,1+n) if i%3==0 or'3' in str(i)])
N, X = map(int, input().split())
M = list(map(int. input().split()))
ans = 0
for m in range(M):
    X -= m
    ans += 1
ans += X // min(M)
print(ans)

### FIXED CODE ###

N, X = map(int, input().split())
M = [int(input()) for _ in range(N)]
ans = 0
for m in M:
    X -= m
    ans += 1
ans += X // min(M)
print(ans)
import math
A_se = set()
B_se = set()

for i in range(math.ceil(A/0.08),math.ceil((A+1)/0.08)):
    A_se.add(i)

for i in range(math.ceil(B/0.1),math.ceil((B+1)/0.1)):
    B_se.add(i)

C = A_se & B_se
if len(C)==0:
    print(-1)
else:
    print(min(C))

### FIXED CODE ###

A,B = map(int,input().split())
import math
A_se = set()
B_se = set()

for i in range(math.ceil(A/0.08),math.ceil((A+1)/0.08)):
    A_se.add(i)

for i in range(math.ceil(B/0.1),math.ceil((B+1)/0.1)):
    B_se.add(i)

C = A_se & B_se
if len(C)==0:
    print(-1)
else:
    print(min(C))
import sys

def solve(n,k,ar):

    dp = [sys.maxsize]*n
    dp[0] = 0

    for i in range(n):
        for j in range(1,k+1):
            if i+j < n:
                dp[i+k] = min(dp[i+k], dp[i] + abs(ar[i]-ar[i+k]))

    print(dp[n-1])



if __name__ == '__main__':
    n,k = map(int,input().split())
    ar = list(map(int,input().split()))

    solve(n,k,ar)

### FIXED CODE ###

import sys

def solve(n,k,ar):

    dp = [sys.maxsize]*n
    dp[0] = 0

    for i in range(n):
        for k in range(1,k+1):
            if i+k <= n-1:
                dp[i+k] = min(dp[i+k], dp[i] + abs(ar[i]-ar[i+k]))

    print(dp[n-1])



if __name__ == '__main__':
    n,k = map(int,input().split())
    ar = list(map(int,input().split()))

    solve(n,k,ar)
import sys
while 1:
 j=int(input)
 if j==0:
  sys.exit()
 print("Case",str(i)+":",j)

### FIXED CODE ###

i=1
while 1:
 j=int(input())
 if j==0:
  break
 print("Case",str(i)+":",j)
 i+=1
X, Y, X, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = []

AA = sorted(A, key=lambda a: -a)
BB = sorted(B, key=lambda a: -a)
CC = sorted(C, key=lambda a: -a)
for a in AA:
    for b in BB:
        for c in CC:
            if len(ans) > 1000_000:
                break
            ans.append(a+b+c)

print('\n'.join(list(map(str, sorted(ans, key=lambda p: -p)[:K]))))


### FIXED CODE ###

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

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ab = [a+b for a in A for b in B]
ab.sort(reverse=True)

ans = [x+c for x in ab[:K] for c in C]
ans.sort(reverse=True)
print('\n'.join(list(map(str, ans[:K]))))
# 小さいのでメモ化再帰でいけるか？
# （[ここまでの回答数, ここまでの点数]みたいなやつ）
# んーーーーーー？？？？ RE*1、あとTLEになる。。。
# REはどうせ再帰の制限
import sys

sys.setrecursionlimit(10 ** 8)

d, g = map(int, input().split())
memo = {}
points, bonus = [], []
for _ in range(d):
    p, c = map(int, input().split())
    points.append(p)
    bonus.append(c)


def f(c, p):
    if (c, p) in memo:
        return memo[(c, p)]
    if p >= g:
        return c
    ret = 10 ** 10
    for i in range(d):
        if points[i] == 1:
            points[i] = 0
            ret = min(ret, f(c + 1, p + (i + 1) * 100 + bonus[i]))
            points[i] = 1
        elif points[i] > 1:
            points[i] -= 1
            ret = min(ret, f(c + 1, p + (i + 1) * 100))
            points[i] += 1
        else:
            print(3 / 0)
            continue
    memo[(c, p)] = ret
    return ret


print(f(0, 0))


### FIXED CODE ###

# 未知のアルゴリズムか天才系DPかと思ってすぐ諦めて解説読んでしまった

d, g = map(int, input().split())
points = []
for _ in range(d):
    p, c = map(int, input().split())
    points.append((p, c))
ans = 10**12
for bit in range(2**d):
    arr = [False] * d
    for i in range(d):
        if bit >> i & 1 == 1:
            arr[i] = True
    tmp_sum = 0
    count = 0
    for i in range(d):
        if arr[i]:
            # kompuli-to
            tmp_sum += points[i][1]
            tmp_sum += (i + 1) * 100 * points[i][0]
            count += points[i][0]
    if tmp_sum < g:
        # 達成できるまで得点の高いやつからやっていく
        for i in range(d - 1, -1, -1):
            if arr[i]:
                # すでにkompuli-toしてるので
                continue
            used = 0
            for j in range(points[i][0]):
                if tmp_sum < g:
                    tmp_sum += (i + 1) * 100
                    count += 1
                    used += 1
            if used == points[i][0]:
                tmp_sum += points[i][1]
            if tmp_sum >= g:
                break
    ans = min(ans, count)
print(ans)
input = raw_input().split()
a = input[0]
b = input[1]

if (a == b) :
	print "a == b"
elif (a > b) :
	print "a > b"
elif :
	print "a < b"

### FIXED CODE ###

a, b = map(int, raw_input().split(" "))

if (a == b) :
	print "a == b"
elif (a > b) :
	print "a > b"
elif (a < b) :
	print "a < b"
n = int(input())
arr = list(map(int, input().split()))
zero = False
ans = 1
ok = True
for e in arr:
	if e == 0:
		zero = True
        break
	ans = ans * e;
	if ans > 10**18:
		ok = False
        break
if zero:
	print(0)
else:
	if ok:
		print(ans)
	else:
		print(-1)

### FIXED CODE ###

n = int(input())
arr = list(map(int,input().split()))
if 0 in arr:
    print(0)
else:
    res = 1
    flag = 0
    for i in arr:
        res = res*i
        if res>10**18:
            flag = 1
            break
    if flag==1:
        print(-1)
    else:
        print(res)
s=input().split(' ')
A,B,N=int(s[0]),int(s[1]),int(s[2])

def f(x):
    a=np.floor(A*x/B)-A*np.floor(x/B)
    return a.astype(int)

if N<B-1:
    print(f(N))
else:
    print(f(B-1))


### FIXED CODE ###

import numpy as np

s=input().split(' ')
A,B,N=int(s[0]),int(s[1]),int(s[2])

def f(x):
    a=np.floor(A*x/B)-A*np.floor(x/B)
    return a.astype(int)

if N<B-1:
    print(f(N))
else:
    print(f(B-1))