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

from itertools import permutations

def floyd_warshall():
            for k in range(N):
                for i in range(N):
                    for j in range(N):
                        dist[i][j] = min(dist[i][j],  dist[i][k] + dist[k][j])
                        
            
def permutation():
    global res
    for p in permutations(r):
        s = 0
        for i in range(R - 1):
            s += dist[p[i]][p[i + 1]]
        if s < res:
            res = s
            
N, M, R = (int(i) for i in input().split())
r = (int(i)-1 for i in input().split())
used = [bool]*9
res = float('inf')
dist = [[float("inf")] * N for i in range(N)]
for i in range(M):
    a, b, c = (int(i) for i in input().split())
    a -= 1
    b -= 1
    dist[a][b] = c
    dist[b][a] = c

floyd_warshall()
permutation()
print(res)
    

### FIXED CODE ###

import sys
from itertools import permutations

def read_int_list():
    return list(map(int, input().split()))

 
def main():
    def floyd_warshall():
        for k in range(n):
            for i in range(n):
                for j in range(n):
                    dd = d[i][k] + d[k][j]
                    if dd < d[i][j]:
                        d[i][j] = dd
 
    n, m, r = read_int_list()
    v = read_int_list()
    v = [x - 1 for x in v]
    d = [[float('inf')] * n for i in range(n)]
    for i in range(n):
        d[i][i] = 0
    for i in range(m):
        a, b, c = read_int_list()
        a -= 1
        b -= 1
        d[a][b] = c
        d[b][a] = c
    floyd_warshall()
    res = float('inf')
    for p in permutations(v):
        s = 0
        for i in range(r - 1):
            s += d[p[i]][p[i + 1]]
        if s < res:
            res = s
    print(res)
 
 
main()
### BUGGY CODE ###

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

res = [a_s.index(i) + 1 for i in range(1, n + 1)]
[print(r, end=" ") for r in res]


### FIXED CODE ###

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

res = sorted(range(1, n + 1), key=lambda k:a_s[k - 1])
for r in res:
	print(r, end=" ")
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, a = map(int, input().split())
    X = list(map(int, input().split()))
    MAX = n * a
    dp = [[[0] * (MAX + 1) for _ in range(n + 1)] for _ in range(n + 1)]
    dp[0][0][0] = 1
    for i in range(1, n + 1):
        x = X[i - 1]
        for k in range(n):
            for s in range(MAX):
                dp[i][k][s] += dp[i - 1][k][s]
                if s + x <= MAX:
                    dp[i][k + 1][s + x] += dp[i - 1][k][s]
    res = 0
    for k in range(1, n + 1):
        res += dp[-1][k][a * k]
    print(res)


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, a = map(int, input().split())
    X = list(map(int, input().split()))
    MAX = n * a
    dp = [[[0] * (MAX + 1) for _ in range(n + 1)] for _ in range(n + 1)]
    dp[0][0][0] = 1
    for i in range(1, n + 1):
        x = X[i - 1]
        for k in range(n):
            for s in range(MAX):
                dp[i][k][s] += dp[i - 1][k][s]
                if s + x <= MAX:
                    dp[i][k + 1][s + x] += dp[i - 1][k][s]
    res = 0
    for k in range(1, n + 1):
        res += dp[-1][k][a * k]
    print(res)


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

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

ball = [0,0]
#左が青, 右が赤
while True:
    for i in range(a):
        ball[0] += 1
        if sum(ball) == n:
            print(ball[0])
            exit()
    for i in range(b):
        ball[1] += 1
        if sum(ball) == n:
            print(ball[0])
            exit()

### FIXED CODE ###

n,a,b = map(int, input().split())
block = n // (a+b)
rest = n % (a+b)

ans = block*a + min(a,rest)
print(ans)
### BUGGY CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,k = inpl()
g = [[] for i in range(n)]
seen = [-1]*n
fin = set()
for i in range(n-1):
    a,b = inpl()
    g[a-1].append(b-1)
    g[b-1].append(a-1)
def dfs(node,parent):
    cnt = len(g[parent]) - len(set(g[parent]) - fin) +1
    # print(cnt)
    seen[node] = k-cnt
    fin.add(node)
    for v in g[node]:
        if seen[v] == -1:
            dfs(v,node)
fin.add(0)
seen[0] = k
for i in g[0]:
    dfs(i,0)
res = 1
for x in seen:
    res *= x
    res %= mod
print(res)

### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

# class Combination:
#     """
#     comb = Combination(1000000)
#     print(comb(5, 3))  # 10
#     """
#     def __init__(self, n_max, mod=10**9+7):
#         self.mod = mod
#         self.modinv = self.make_modinv_list(n_max)
#         self.fac, self.facinv = self.make_factorial_list(n_max)

#     def __call__(self, n, r):
#         return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

#     def make_factorial_list(self, n):
#         # 階乗のリストと階乗のmod逆元のリストを返す O(n)
#         # self.make_modinv_list()が先に実行されている必要がある
#         fac = [1]
#         facinv = [1]
#         for i in range(1, n+1):
#             fac.append(fac[i-1] * i % self.mod)
#             facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
#         return fac, facinv

#     def make_modinv_list(self, n):
#         # 0からnまでのmod逆元のリストを返す O(n)
#         modinv = [0] * (n+1)
#         modinv[1] = 1
#         for i in range(2, n+1):
#             modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
#         return modinv


n,k = inpl()
g = [[] for i in range(n)]
seen = [-1]*n
for i in range(n-1):
    a,b = inpl()
    g[a-1].append(b-1)
    g[b-1].append(a-1)
def p(n,i):
    count = 1
    for _ in range(i):
        count = count * n % mod
        n -= 1
    return count
def dfs(cur,par=-1):
    res = 1
    c = 0 if par == -1 else 1
    cnt = 0
    for v in g[cur]:
        if v == par:
            continue
        cnt += 1
        res *= dfs(v,cur)
        res %= mod
    return res*p(k-c-1,cnt)
print(dfs(0,-1)*k%mod)
### BUGGY CODE ###

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

ans = 0
for i in range(N):
  for j in range(i+1, N):
    if abs(j-i) == A[i] + A[j]:
      ans += 1

print(ans)
  

### FIXED CODE ###

import collections

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

tmp = [0 for _ in range(N)]
for i in range(N):
  tmp[i] = (i + 1) + A[i]

c = collections.Counter(tmp)

ans = 0
for i in range(N):
  aj = (i+1) - A[i]
  ans += c[aj]

print(ans)
  
'''
i < jとする
A[i] + A[j] = j - i
A[i] + i = j - A[j]
K = j - A[j]
'''
### BUGGY CODE ###

n, m, v = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
i = 0
j = 0
x = 0
for i in range(n + 1):
  c = 0
  t = 0
  for j in range(i):
    if t + a[j] <= v:
      t += a[j]
      c += 1
    else:
      break
  for k in range(m):
    if t + b[k] <= v:
      t += b[k]
      c += 1
    else:
      break
  if x < c:
    x = c
  

print (x)

### FIXED CODE ###

from itertools import accumulate
import bisect

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

a_acc = [0] + list(accumulate(a))  # aを0冊読む=1冊も読まない場合があるので、[0]を先頭に追加します
b_acc = list(accumulate(b))  # bisect_rightでは、x以下の要素がいくつあるか？を求めるので、こちらに0は入れません

ans = 0
for an in range(n + 1):
    rem = k - a_acc[an]
    if rem < 0:
        # aをこれ以上読めません
        break

    bn = bisect.bisect_right(b_acc, rem)
    ans = max(ans, an + bn)

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

from collections import defaultdict
md=10**9+7
n,k=map(int,input().split())
to=defaultdict(list)
for _ in range(n-1):
    a,b=map(int,input().split())
    to[a]+=[b]
    to[b]+=[a]
ans=1
fin=[0]*(n+1)
nd=[1]
while nd:
    nnd=[]
    for i in nd:
        nk = k
        for i1 in to[i]:
            if fin[i1]==0:
                nnd.append(i1)
            else:
                nk-=1
            for i2 in to[i1]:
                if i2==i:continue
                nk-=fin[i2]
        fin[i]=1
        ans=ans*nk%md
    nd=nnd
print(ans)

### FIXED CODE ###

from collections import defaultdict
import sys

sys.setrecursionlimit(10 ** 6)

def per(a, b):
    t = (a, b)
    if t in memo:
        return memo[t]
    re = 1
    for i in range(b):
        re = re * (a - i) % md
    memo[t] = re
    return re

def dfs(i, oi):
    cnt_ko = len(to[i])
    if i == 1:
        re = k * per(k - 1, cnt_ko) % md
    elif cnt_ko == 1:
        return 1
    else:
        re = per(k - 2, cnt_ko - 1)
    for ki in to[i]:
        if ki == oi: continue
        re = re * dfs(ki, i) % md
    return re

md = 10 ** 9 + 7
memo = {}
n, k = map(int, input().split())
to = defaultdict(list)
for _ in range(n - 1):
    a, b = map(int, input().split())
    to[a] += [b]
    to[b] += [a]
print(dfs(1, 0))
### BUGGY CODE ###

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

INF = 10**9

dp = [INF]*N
dp[0] = 0

for i in range(N):
    for j in range(1, min(i+1, K+1)):
        dp[i] = min(dp[i], dp[i-j]+abs(H[i]-H[i-j]))

print(dp[N-1])

### FIXED CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))
 
INF = 10**9
 
dp = [INF]*N
dp[0] = 0
 
for i in range(N):
    for j in range(1, min(i+1, K+1)):
        dp[i] = min(dp[i], dp[i-j]+abs(H[i]-H[i-j]))
 
print(dp[N-1])
### BUGGY CODE ###

n = int(input())
a = [int(i) for i in input().split()]
answer = 1
for i in range(len(a)):
    answer = answer * a[i]

if answer > 10 ** 18:
    print(-1)
else:
    print(answer)


### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
answer = 1
for i in range(len(a)):
    answer = answer * a[i]
    if answer > 10 ** 18:
        if 0 in a:
            print(0)
        else:
            print(-1)
        break
else:
    print(answer)
### BUGGY CODE ###

# coding: utf-8
N=int(input())
S=list(input())
RGB=[[0,0,0] for i in range(N)]

ans=0

for i in range(1,N):
    k=-i
    if S[k]=="R":
        RGB[k-1][0]=RGB[k][0]+1
        RGB[k-1][1]=RGB[k][1]
        RGB[k-1][2]=RGB[k][2]
    elif S[k]=="G":
        RGB[k-1][0]=RGB[k][0]
        RGB[k-1][1]=RGB[k][1]+1
        RGB[k-1][2]=RGB[k][2]
    elif S[k]=="B":
        RGB[k-1][0]=RGB[k][0]
        RGB[k-1][1]=RGB[k][1]
        RGB[k-1][2]=RGB[k][2]+1

for i in range(N):
    for j in range(i,N):
        if S[i]!=S[j]:
            if S[i]=="R" and S[j]=="G" or S[i]=="G" and S[j]=="R":
                ans+=RGB[j][2]
                if 2*j-i<N:
                    if RGB[j][2]>0 and S[2*j-i]=="B":
                        ans-=1
            elif S[i]=="R" and S[j]=="B" or S[i]=="B" and S[j]=="R":
                ans+=RGB[j][1]
                if 2*j-i<N:
                    if RGB[j][1]>0 and S[2*j-i]=="G":
                        ans-=1
            elif S[i]=="B" and S[j]=="G" or S[i]=="G" and S[j]=="B":
                ans+=RGB[j][0]
                if 2*j-i<N:
                    if RGB[j][0]>0 and S[2*j-i]=="R":
                        ans-=1

print(ans)

### FIXED CODE ###

# coding: utf-8
N=int(input())
S=list(input())
RGB=[[0,0,0] for i in range(N)]

ans=0

for i in range(1,N):
    k=-i
    if S[k]=="R":
        RGB[k-1][0]=RGB[k][0]+1
        RGB[k-1][1]=RGB[k][1]
        RGB[k-1][2]=RGB[k][2]
    elif S[k]=="G":
        RGB[k-1][0]=RGB[k][0]
        RGB[k-1][1]=RGB[k][1]+1
        RGB[k-1][2]=RGB[k][2]
    elif S[k]=="B":
        RGB[k-1][0]=RGB[k][0]
        RGB[k-1][1]=RGB[k][1]
        RGB[k-1][2]=RGB[k][2]+1

for i in range(N):
    for j in range(i,N):
        if S[i]!=S[j]:
            if S[i]=="R" and S[j]=="G" or S[i]=="G" and S[j]=="R":
                ans+=RGB[j][2]
                if 2*j-i<N:
                    if RGB[j][2]>0 and S[2*j-i]=="B":
                        ans-=1
            elif S[i]=="R" and S[j]=="B" or S[i]=="B" and S[j]=="R":
                ans+=RGB[j][1]
                if 2*j-i<N:
                    if RGB[j][1]>0 and S[2*j-i]=="G":
                        ans-=1
            elif S[i]=="B" and S[j]=="G" or S[i]=="G" and S[j]=="B":
                ans+=RGB[j][0]
                if 2*j-i<N:
                    if RGB[j][0]>0 and S[2*j-i]=="R":
                        ans-=1

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

n,k  = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
start = 1
for i in range(k):
    start*=a[i]
for i in range(n-k):
    ele = a[i+k]
    new = (start//a[i])*ele
    if new<=start:
        print("No")
    else:
        print("Yes")
    start = new


### FIXED CODE ###

n,k  = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
for i in range(n-k):
    ele = a[i+k]
    if ele<=a[i]:
        print("No")
    else:
        print("Yes")
### BUGGY CODE ###

import fractions
N = int(input())
a = list(map(int,input().split()))
g = 1
MOD = 10**9+7
for i in range(N):
    g = g*a[i]//fractions.gcd(g,a[i])
res = 0
for i in range(N):
    res += (g//a[i])%MOD
print(res%MOD)


### FIXED CODE ###

import fractions
import sys
input = sys.stdin.readline
N = int(input())
a = list(map(int,input().split()))
g = 1
res = 0
MOD = 10**9+7
for elem in a:
    tmp = g*elem//fractions.gcd(g,elem)
    res *= tmp//g
    g = tmp
    res += g//elem
print(res%MOD)
### BUGGY CODE ###

h,w=map(int,input().split())
field=[list(input())for i in range(h)]

import copy
dp=[[1000 for i in range(w)]for i in range(h)]
for y,i in enumerate(field):
    for x,j in enumerate(i):
        if j=="#":
            dp[y][x]=9999

dydx=[[-1,0],[1,0],[0,-1],[0,1]]

maxi=0
for y,i in enumerate(field):
    for x,j in enumerate(i):
        if j==".":
            ndp=copy.deepcopy(dp)
            ndp[y][x]=0
            cnt=0
            for _ in range(280):
                for y,i in enumerate(ndp):
                    for x,j in enumerate(i):
                        if j<1000:
                            for dy,dx in dydx:
                                ny,nx=y+dy,x+dx
                                if 0<=ny<=h-1 and 0<=nx<=w-1 and field[ny][nx]!="#" and ndp[ny][nx]>ndp[y][x]:
                                    ndp[ny][nx]=ndp[y][x]+1
                                    flag=False
                                    if ndp[ny][nx]>maxi:
                                        maxi=ndp[ny][nx]
print(maxi)

### FIXED CODE ###

h,w=map(int,input().split())
field=[list(input())for i in range(h)]

import copy
dp=[[1000 for i in range(w)]for i in range(h)]
for y,i in enumerate(field):
    for x,j in enumerate(i):
        if j=="#":
            dp[y][x]=9999

dydx=[[-1,0],[1,0],[0,-1],[0,1]]
#print(dp)
maxi=0
for y,i in enumerate(field):
    for x,j in enumerate(i):
        if j==".":
            ndp=copy.deepcopy(dp)
            ndp[y][x]=0
            cnt=0
            queue=[]
            queue.append([y,x])
            while queue:
                ny,nx=queue.pop(0)
                for dy,dx in dydx:
                    nny,nnx=ny+dy,nx+dx
                    if 0<=nny<=h-1 and 0<=nnx<=w-1 and field[nny][nnx]!="#" and ndp[nny][nnx]==1000:
                        ndp[nny][nnx]=ndp[ny][nx]+1
                        queue.append([nny,nnx])
                        if ndp[nny][nnx]>maxi:
                            maxi=ndp[nny][nnx]
            #print(ndp)
print(maxi)
### BUGGY CODE ###

def solve(n,k,ar):

    dp = [int(1e9)]*n
    dp[0] = 0

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

def solve1(n,k,ar):
    dp = [int(1e9)] * (n)
    dp[0] = 0
    for i in range(1,n):
        for k in range(1,k+1):
            if i-k >= 0:
                dp[i] = min(dp[i], dp[i-k] + 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)
### BUGGY CODE ###

n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

n += 1
ans = 0
m = dict()
temp = 0
b = []
for i in range(min(n, k)):
    temp = (temp + a[i]) % k
    c = (temp - (i % k) + k) % k
    b.append(c)
    if c in m.keys():
        ans += m[c]
        m[c] += 1
    else:
        m[c] = 1

for i in range(k, n):
    x = i % k
    m[b[x]] -= 1
    temp = (temp + a[i]) % k
    c = (temp - (i % k) + k) % k
    b[x] = c
    if c in m.keys():
        ans += m[c]
        m[c] += 1
    else:
        m[c] = 1

print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

n += 1
ans = 0
m = dict()
temp = 0
b = []
for i in range(min(n, k)):
    temp = (temp + a[i]) % k
    c = (temp - (i % k) + k) % k
    b.append(c)
    if c in m.keys():
        ans += m[c]
        m[c] += 1
    else:
        m[c] = 1

for i in range(k, n):
    x = i % k
    m[b[x]] -= 1
    temp = (temp + a[i]) % k
    c = (temp - (i % k) + k) % k
    b[x] = c
    if c in m.keys():
        ans += m[c]
        m[c] += 1
    else:
        m[c] = 1

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

n = int(input())
ans = n -1
prime = []

while n != 1:
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            prime.append(i)
            n /= i
            break
    else:
        prime.append(int(n))
        n = 1

for bit in range(1 << len(prime)):
    a = 1
    b = 1

    for i in range(len(prime)):
        if bit >> i & 1:
            a *= prime[i]
        else:
            b *= prime[i]

    ans = min((a+b-2,ans))

print(ans)

### FIXED CODE ###

import sys

n = int(input())

for i in range(int(n**0.5),0,-1):
    if n % i == 0:
        print(n//i + i - 2 )
        sys.exit()
### BUGGY CODE ###

import functools
import operator

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

tar = functools.reduce(operator.mul, A)

if tar > 10 ** 18:
    print(-1)
else:
    print(tar)


### FIXED CODE ###


import sys
N = int(input())
A = list(map(int, input().split()))
A.sort()
tar = 1
for i in A:
    tar *= i
    if tar > 10 ** 18:
        print('-1')
        sys.exit()

print(tar)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

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

X = A * 2

Nextcount = [-1] * (2 * (10**5+1))
Nextind = [-1]*N

for i,x in enumerate(X):
    if 0 <= Nextcount[x] < N:
        Nextind[Nextcount[x]] = i

    Nextcount[x] = i

Repeatcount=0
NOW = 0

Repeatcount+=Nextind[NOW]-NOW+1
NOW=(Nextind[NOW]+1)%N

while NOW!=0:
    Repeatcount+=Nextind[NOW]-NOW+1
    NOW=(Nextind[NOW]+1)%N
    

Rep=(N*K)%Repeatcount

from collections import Counter
C=Counter()
s=[]
for i in range(Rep):
    if X[i%N] in C:
        while X[i%N] in C:
            po=s.pop()
            C[po]-=1
            if C[po]==0:
                del C[po]

    else:
        s.append(X[i%N])
        C[X[i%N]]+=1

    #print(s,C)

print(*s)
        
            



### FIXED CODE ###

import sys
input = sys.stdin.readline

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

X = A * 2

Nextcount = [-1] * (2 * (10**5+1))
Nextind = [-1]*N

for i,x in enumerate(X):
    if 0 <= Nextcount[x] < N:
        Nextind[Nextcount[x]] = i

    Nextcount[x] = i

Repeatcount=0
NOW = 0

Repeatcount+=Nextind[NOW]-NOW+1
NOW=(Nextind[NOW]+1)%N

while NOW!=0:
    Repeatcount+=Nextind[NOW]-NOW+1
    NOW=(Nextind[NOW]+1)%N
    

Rep=(N*K)%Repeatcount
NOW=0

while True:
    if Nextind[NOW]-NOW+1<Rep:
        Rep-=Nextind[NOW]-NOW+1
        NOW=(Nextind[NOW]+1)%N

    else:
        break
    
#print(Rep,NOW)

from collections import Counter
C=Counter()
s=[]
for i in range(Rep):
    if X[(NOW+i)%N] in C:
        while X[(NOW+i)%N] in C:
            po=s.pop()
            C[po]-=1
            if C[po]==0:
                del C[po]

    else:
        s.append(X[(NOW+i)%N])
        C[X[(NOW+i)%N]]+=1

    #print(s,C)

print(*s)
### BUGGY CODE ###

D, G = map(int, input().split())
G = G // 100
sumn = 0
ns = [0] * (D + 1)
cs = [0] * (D + 1)
cache = [{} for _ in range(D + 1)]
for i in range(1, D + 1):
    n, c = map(int, input().split())
    ns[i] = n
    cs[i] = c // 100
    sumn += n

minn = [0] * (D + 1)
for i in range(1, D + 1):
    minn[i] = min(ns[1:i+1])

def f(i, rn):
    if i == 1:
        if ns[1] < rn:
            return -1
        p = rn
        if ns[1] == rn:
            p += cs[1]
        return p
    if rn < minn[i]:
        p = 0
        for j in range(i, 0, -1):
            n = min((ns[j], rn))
            p += j * n
            if n == rn:
                break
            rn -= n
        return p
    maxp = 0
    for n in range(min((ns[i], rn)) + 1):
        p = i * n
        if n == ns[i]:
            p += cs[i]
        nn = rn - n
        cch = cache[i - 1]
        np = cch.get(nn)
        if not np:
            np = f(i - 1, nn)
            cch[nn] = np
        if np >= 0:
            p += np
            if maxp < p:
                maxp = p
    return maxp

mn = 1
mx = sumn
while mn < mx:
    x = mn + ((mx - mn) // 2)
    if G <= f(D, x):
        mx = x
    else:
        mn = x + 1
print(mn)


### FIXED CODE ###

import functools
D, G = map(int, input().split())
G = G // 100
sumn = 0
ns = [0] * (D + 1)
cs = [0] * (D + 1)
for i in range(1, D + 1):
    n, c = map(int, input().split())
    ns[i] = n
    cs[i] = c // 100
    sumn += n

minn = [0] * (D + 1)
for i in range(1, D + 1):
    minn[i] = min(ns[1:i+1])

@functools.lru_cache(maxsize=None)
def f(i, rn):
    if i == 1:
        if ns[1] < rn:
            return -1
        p = rn
        if ns[1] == rn:
            p += cs[1]
        return p
    if rn < minn[i]:
        p = 0
        for j in range(i, 0, -1):
            n = min((ns[j], rn))
            p += j * n
            if n == rn:
                break
            rn -= n
        return p
    maxp = 0
    for n in range(min((ns[i], rn)) + 1):
        p = i * n
        if n == ns[i]:
            p += cs[i]
        np = f(i - 1, rn - n)
        if np >= 0:
            p += np
            if maxp < p:
                maxp = p
    return maxp

mn = 1
mx = sumn
while mn < mx:
    x = mn + ((mx - mn) // 2)
    if G <= f(D, x):
        mx = x
    else:
        mn = x + 1
print(mn)