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

h, w = map(int, input().split())
S = [list(input()) for _ in range(h)]
def t(s):
  return [[s[i][j] for i in range(len(s))] for j in range(len(s[0]))]
def calc(s):
  res = []
  for v in s:
    v.append('-')
    tmp = []
    nc = ''
    nn = 0
    for c in v:
      if nc == '':
        nc = c
        nn += 1
        continue
      if nc == c:
        nn += 1
        continue
      else:
        if nc == '#':
          tmp = tmp + [0 for _ in range(nn)]
        else:
          tmp = tmp + [nn for _ in range(nn)]
        nc = c
        nn = 1
    res.append(tmp)
  return res

tate = t(calc(t(S)))
yoko = calc(S)
print(max([tate[i][j] + yoko[i][j] for i in range(h) for j in range(w) if tate[i][j] * yoko[i][j] != 0])-1)


### FIXED CODE ###

h, w = map(int, input().split())
S = [input() for _ in range(h)]

def calc(s):
    res = []
    for v in s:
        v = v + '-'
        tmp = []
        nc = v[0]
        nn = 0
        for c in v:
            if nc == c:
                nn += 1
                continue
            else:
                if nc == '#':
                    tmp.extend([0 for _ in range(nn)])
                else:
                    tmp.extend( [nn for _ in range(nn)])
                nc = c
                nn = 1
        res.append(tmp)
    return res

def calc2(s):
    res = []
    for j in range(w):
        tmp = []
        nc = s[0][j]
        nn = 0
        for i in range(h):
            c = s[i][j]
            if nc == c:
                nn += 1
                continue
            else:
                if nc == '#':
                    tmp.extend([0 for _ in range(nn)])
                else:
                    tmp.extend( [nn for _ in range(nn)])
                nc = c
                nn = 1
        if nc == '#':
            tmp.extend([0 for _ in range(nn)])
        else:
            tmp.extend( [nn for _ in range(nn)])
        res.append(tmp)
    return res

tate = calc2(S)
yoko = calc(S)

print(max([tate[j][i] + yoko[i][j] for i in range(h) for j in range(w) if tate[j][i] * yoko[i][j] != 0]) - 1)
### BUGGY CODE ###

f=input
n,s,q=int(f()),list(f()),int(f())
d={chr(97+i):[] for i in range(26)}
for i in range(n):
  d[s[i]]+=[i]
from bisect import *
for i in range(q):
  a,b,c=input().split()
  b=int(b)-1
  if a=='1':
    d[s[b]].pop(bisect(d[s[b]],b)-1)
    s[b]=c
    insort(d[c],b)
  else:
    t=0
    for l in d.values():
      m=bisect(l,b-1)
      if m<len(l) and l[m]<int(c): t+=1
    print(t)

### FIXED CODE ###

n=int(input())
l=list(input())
q=int(input())
bit=[[0]*(n+1) for i in range(26)]
def bit_sum(o,i):
  s=0
  while i:
    s+=bit[o][i]
    i-=i&-i
  return s
def bit_add(o,i,x):
  while i<=n:
    bit[o][i] += x
    i+=i&-i
for i in range(n):
  bit_add(ord(l[i])-97,i+1,1)
for i in range(q):
  a,b,c=input().split()
  b=int(b)-1
  if a=='1':
    bit_add(ord(l[b])-97,b+1,-1)
    l[b]=c
    bit_add(ord(c)-97,b+1,1)
  else:
    c=int(c)
    print(sum(1 for o in range(26) if bit_sum(o,c)-bit_sum(o,b)))
### BUGGY CODE ###

N = int(input())

a = pow(10, 9) + 7

power = 1
for i in range(1, N+1):
    power *= i
print(power% a)

### FIXED CODE ###

import math
N = int(input())

a = pow(10, 9) + 7

power = math.factorial(N)

print(power% a)
### BUGGY CODE ###

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

# l = []
# for i in range(1, N+1):
#     m = []
#     for j in range(1, i+1):
#         m.append(j)
#     l.append(m)

ans = 0
for i in range(1, N+1):
    Pi = P[i - 1]
    chk = 0
    num = 0
    for j in range(1, i+1):
        num += 1
        Pj = P[j - 1]
        if Pi > Pj:
            continue
        else:
            chk += 1
    if chk == num:
        ans += 1

print(ans)

### FIXED CODE ###

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

cnt = 0
mi = P[0]
for i in range(N):
	if P[i] <= mi:
		mi = P[i]
		cnt += 1
print(cnt)
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
magic = [None] * 26
for i in range(len(S)):
    if magic[ord(S[i]) - ord("A")] is None:
        magic[ord(S[i]) - ord("A")] = [i]
    else:
        magic[ord(S[i]) - ord("A")].append(i)

num_in_the_location = [1]*N
for i in range(Q):
    t, d = input().split()
    #print("\n", t)
    t = ord(t) - ord("A")
    if magic[t] is None:
        continue
    if d == "L":
        # left = True
        for j in range(len(magic[t])):
            if magic[t][j] > 0:
                num_in_the_location[magic[t][j]
                                    ], num_in_the_location[magic[t][j] - 1] = 0, num_in_the_location[magic[t][j] - 1] + num_in_the_location[magic[t][j]
                                                                                                                                            ]
            else:
                num_in_the_location[magic[t][j]] = 0

    else:
        for j in range(len(magic[t])):
            #print(t, magic[t][j], magic[t][j]+1, magic[t])
            if magic[t][j] < N-1:
                num_in_the_location[magic[t][j]
                                    ], num_in_the_location[magic[t][j]+1] = 0, num_in_the_location[magic[t][j]+1]+num_in_the_location[magic[t][j]
                                                                                                                                      ]
            else:
                num_in_the_location[magic[t][j]] = 0
# print(num_in_the_location)
print(sum(num_in_the_location))


### FIXED CODE ###

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


N, Q = map(int, input().split())
S = input()
t, d = [], []
for i in range(Q):
    ti, di = input().split()
    t.append(ti)
    d.append(di)


def solve(i):
    for j in range(Q):
        if S[i] == t[j]:
            if d[j] == "L":
                i -= 1
            else:
                i += 1

            if i < 0 or i >= N:
                return 1
    return 0


left = meguru_bisect(-1, N)
right = meguru_bisect(N, -1)
print(max(right-left-1, 0))
### BUGGY CODE ###

N, W = map(int, input().split())

import numpy as np
weight = np.empty((110), int)
value = np.empty((110), int)
dp = np.zeros((110, 100010), int)
#print(weight.shape, value.shape, dp.shape)

for i in range(N):
  weight[i], value[i] = map(int, input().split())

dp[0, :W+1] = 0

for i in range(N):
  for w in range(W+1):
    if w >= weight[i]:
      dp[i+1, w] = max(dp[i, w-weight[i]] + value[i], dp[i, w])
    else:
      dp[i+1, w] = dp[i, w]

ans = dp[N, W]
print(ans)

### FIXED CODE ###

N, W = map(int, input().split())

weight = [None] * N
value = [None] * N
dp = [[None] * (W+1) for _ in range(N+1)]

for i in range(N):
  weight[i], value[i] = map(int, input().split())

for j in range(W+1):
  dp[0][j] = 0

for i in range(N):
  for w in range(W+1):
    if w >= weight[i]:
      dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w])
    else:
      dp[i+1][w] = dp[i][w]

ans = dp[N][W]
print(ans)
### BUGGY CODE ###

import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))
MOD = 10 ** 9 + 7

bit = len(format(max(A), 'b'))
B = [(format(a, '0{}b'.format(bit)))[::-1] for a in A]
ans = 0
for i in range(bit):
    nb_1 = sum([int(b[i]) for b in B])
    ans += (nb_1 * (n - nb_1)) << i
    ans %= MOD
    
print(ans)

### FIXED CODE ###

import sys
inputs = sys.stdin.readlines()

n = int(inputs[0])
A = list(map(int, inputs[1].split()))
MOD = 10 ** 9 + 7

bit = len(format(max(A), 'b'))
ans = 0
for i in range(bit):
    nb_1 = sum(((a >> i) & 1 for a in A))
    ans += (nb_1 * (n - nb_1)) << i
    ans %= MOD
    
print(ans)
### BUGGY CODE ###

s = input()
q = int(input())

for _ in range(q):
	query = list(map(str, input().split()))
	if query[0] == '1':
		s = s[::-1]
	elif query[0] == '2':
		if query[1] == '1':
			s = query[2] + s
		elif query[1] == '2':
			s = s + query[2]

print(s)

### FIXED CODE ###

s = input()
q = int(input())

head = []
tail = []
flip = 0

for i in range(q):
	query = input().split()
	if query[0] == '1':
		flip ^= 1
	else:
		f = int(query[1]) - 1
		c = query[2]
		if (f ^ flip) == 0:
			head.append(c)
		else:
			tail.append(c)

if flip:
	head, tail = tail, head
	s = s[::-1]

head = ''.join(head)
tail = ''.join(tail)

print(head[::-1] + s + tail)
### BUGGY CODE ###

from fractions import gcd
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
R = 10**9+7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
l = a[0]
for i in range(1,n):
    l = l*a[i]//gcd(l,a[i])
sm = 0
for i in range(n):
    sm = (sm + l//a[i])%R
print(sm)


### FIXED CODE ###

from fractions import gcd
from functools import reduce
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
R = 10**9+7

def lcm_base(a,b):
    return (a*b)//gcd(a,b)

def inv(x):
    return pow(x,R-2,R)

n = inn()
a = inl()
#l = a[0]
#for i in range(1,n):
#    l = l*a[i]//gcd(l,a[i])
l = reduce(lcm_base,a,1)
sm = 0
for i in range(n):
    sm = (sm + inv(a[i]))%R
print((sm*l)%R)
### BUGGY CODE ###

#!/usr/bin/env python3

import sys
input=sys.stdin.readline

n=int(input())
ans=0
for a in range(1,n+1):
    for b in range(1,n+1):
        if a*b>=n:
            break
        ans+=1
print(ans)

### FIXED CODE ###

#!/usr/bin/env python3

import sys
input=sys.stdin.readline

n=int(input())
ans=0
for a in range(1,n+1):
    for b in range(1,n+1):
        if a*b>=n:
            break
        ans+=1
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
# 18:01 -> 
from collections import deque

dx = [0,1,0,-1]
dy = [1,0,-1,0]

H, W = map(int, input().split())

A = []
first_black = []

for i in range(H):
    A.append(list(input()))
    first_black.extend([(i,j) for j in range(W) if A[i][j] == '#'])

for x,y in first_black:
    A[x][y] = 0

black_deque = deque()
black_deque.extend(first_black)

max_depth = 0
while len(black_deque) != 0:
    x,y = black_deque.popleft()
    depth = A[x][y]
    max_depth = max(max_depth, depth)
    for k in range(4):
        new_x = x+dx[k]
        new_y = y+dy[k]
        if 0 <= new_x < H and \
           0 <= new_y < W and \
           A[new_x][new_y] == '.':
            black_deque.append((new_x, new_y))
            A[new_x][new_y] = depth+1

print(depth)

### FIXED CODE ###

# -*- coding: utf-8 -*-
# 18:01 -> 18:36 (give up. TLE)
from collections import deque

dx = [0,1,0,-1]
dy = [1,0,-1,0]

H, W = map(int, input().split())

A = []
black_deque = deque()

for i in range(H):
    A.append(list(input()))
    black_deque.extend([(i,j) for j in range(W) if A[i][j] == '#'])

if len(black_deque) == H*W:
    print(0)
    exit(0)

for x,y in black_deque:
    A[x][y] = 0

while len(black_deque) != 0:
    x,y = black_deque.popleft()
    depth = A[x][y]
    for k in range(4):
        new_x = x+dx[k]
        new_y = y+dy[k]
        if 0 <= new_x < H and \
           0 <= new_y < W and \
           A[new_x][new_y] == '.':
            black_deque.append((new_x, new_y))
            A[new_x][new_y] = depth+1

print(depth)
### BUGGY CODE ###

import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

def sol():
    N = int(input())
    S = input().rstrip()

    ans = 0

    for length in range(1, N // 2 + 2):
        for left in range(N - length + 1):
            sub = S[left: left + length]
            if S[left + length:].find(sub) != -1:
                ans = max(ans, length)

    print(ans)

sol()

### FIXED CODE ###

from collections import deque

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

def isOk(leng):
    hashList = set()
    que = deque([])
    for left in range(N - leng + 1):
        hs = hash(S[left: left + leng])
        if hs in hashList:
            return True
        que.append(hs)
        if len(que) >= leng:
            hashList.add(que.popleft())
    return False

ok = 0
ng = N

while ng - ok > 1:
    mid = (ng + ok) // 2
    if isOk(mid):
        ok = mid
    else:
        ng = mid

print(ok)
### BUGGY CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
current = a[:]
for _ in range(min(50, k)):
    nex = [0]*n
    for i, v in enumerate(current):
        l = max(0, i-v)
        r = min(n-1, i+v)
        nex[l] += 1
        if r+1 < n:
            nex[r+1] -= 1
    for i in range(1, n):
        nex[i] += nex[i-1]
    current = nex

print(*current)

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
current = a[:]
for _ in range(min(42, k)):
    nex = [0]*n
    for i, v in enumerate(current):
        l = max(0, i-v)
        r = min(n-1, i+v)
        nex[l] += 1
        if r+1 < n:
            nex[r+1] -= 1
    for i in range(1, n):
        nex[i] += nex[i-1]
    current = nex

print(*current)
### BUGGY CODE ###

def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N = int(input())
    S = input()
    Q = int(input())
    for _ in range(Q):
        q = input().split()
        if q[0]=='1':
            i = int(q[1])
            S = S[:i-1] + q[2] + S[i:]
        else:
            l = int(q[1])
            r = int(q[2])
            print(len(set(S[l-1:r])))


if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

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

    def init(arr):
        for i in range(n):
            seg[i+num-1] = {arr[i]}
        for i in range(num-2,-1,-1) :
            seg[i] = segfunc(seg[2*i+1],seg[2*i+2]) 
        
    def update(k,x):
        k += num-1
        seg[k].clear()
        seg[k] = {x}
        while k:
            k = (k-1)//2
            seg[k].clear()
            seg[k] = segfunc(seg[k*2+1],seg[k*2+2])
        
    def query(p,q):
        if q<=p:
            return ide_ele
        p += num-1
        q += num-2
        res=ide_ele
        while q-p>1:
            if p&1 == 0:
                res = segfunc(res,seg[p])
            if q&1 == 1:
                res = segfunc(res,seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = segfunc(res,seg[p])
        else:
            res = segfunc(segfunc(res,seg[p]),seg[q])
        return res

    n = int(input())
    s = list(input().rstrip())
    for i in range(n):
        s[i] = ord(s[i]) - 97

    ide_ele = set()

    num =2**((n-1).bit_length())

    # セグ木初期化
    seg=[ide_ele]*2*num
    init(s)

    q = int(input())
    for _ in range(q):
        a,b,c = input().rstrip().split()
        if a == '1':
            b = int(b)
            c = ord(c) - 97
            update(b-1, c)
        else:
            b = int(b)
            c = int(c)
            print(len(query(b-1, c)))

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

def solve(i, m):
    if m == 0:
        return True
    if i == n:
        return False
    return solve(i+1, m) or solve(i+1, m-A[i])


if __name__ == "__main__":
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    M = list(map(int, input().split()))
    for m in M:
        if solve(0, m):
            print("yes")
        else:
            print("no")

### FIXED CODE ###

import itertools


def rev(x):
    return sumA - x


if __name__ == "__main__":
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    M = list(map(int, input().split()))
    sumA = sum(A)
    all_sum = set()
    for i in range((n+1)//2):
        com = set(itertools.combinations(A, i+1))
        com_sum = set(map(sum, com))
        com_sum_rev = set(map(rev, com_sum))
        all_sum = all_sum.union(com_sum)
        all_sum = all_sum.union(com_sum_rev)
    for m in M:
        if m in all_sum:
            print("yes")
        else:
            print("no")
### BUGGY CODE ###

import sys
import numpy as np
N = int(input())
for i in np.arange(int(np.sqrt(N)), 0, -1):
  if N / i == int(N / i):
      print(int(N / i + i - 2))
      sys.exit()
print(N - 1)

### FIXED CODE ###

import sys
import numpy as np
N = int(input())
for i in range(int(np.sqrt(N)), 0, -1):
  if N / i == int(N / i):
      print(int(N / i + i - 2))
      sys.exit()
print(N - 1)
### BUGGY CODE ###

def solve():
    N, Q = map(int, input().split())
    S = input()
    l = [0 for _ in range(Q)]
    r = l[:]
    for i in range(Q):
        l[i], r[i] = map(int, input().split())
    
    ac_head = []
    for i, char in enumerate(S[:-1]):
        if char == 'A' and S[i+1] == 'C':
            ac_head.append(i)
    
    for i in range(Q):
        cnt = 0
        for index in ac_head:
            if l[i] - 1 <= index <= r[i] - 2:
                cnt += 1
            elif r[i] - 2 < index:
                break
        print(cnt)


if __name__ == '__main__':
    solve()


### FIXED CODE ###

def solve():
    N, Q = map(int, input().split())
    S = input()
    l = [0 for _ in range(Q)]
    r = l[:]
    for i in range(Q):
        l[i], r[i] = map(int, input().split())
    
    ac_head = [0 for _ in range(N+1)]
    for i, char in enumerate(S[:-1]):
        if char == 'A' and S[i+1] == 'C':
            ac_head[i+1] = 1 + ac_head[i]
        else:
            ac_head[i+1] = ac_head[i]
    
    for a, b in zip(l, r):
        print(ac_head[b-1] - ac_head[a-1])


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

import sys
from functools import lru_cache
sys.setrecursionlimit(10 ** 7)

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

sushi = [0] * 4
for a in A:
    sushi[a] += 1
B, C, D = sushi[1:]


@lru_cache(maxsize=10 ** 6)
def rec(b, c, d):
    if (b, c, d) == (0, 0, 0):
        return 0
    if b < 0 or c < 0 or d < 0:
        return 0

    a = N - b - c - d
    x1 = rec(b - 1, c, d) * b / (N - a)
    x2 = rec(b + 1, c - 1, d) * c / (N - a)
    x3 = rec(b, c + 1, d - 1) * d / (N - a)
    return x1 + x2 + x3 + N / (N - a)


print(rec(B, C, D))

### FIXED CODE ###

from collections import Counter, defaultdict
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)

U = N + 1
inf = 1e18

dp = [[[inf] * U for _ in range(U)] for _ in range(U)]
dp[0][0][0] = 0.0

for c in range(N + 1):
    for b in range(N + 1):
        if c + b > N:
            break
        for a in range(N + 1):
            if a + b + c == 0:
                continue
            if a + b + c > N:
                break
            prob = 0
            E = N
            if a > 0:
                E += a * dp[a - 1][b][c]
                prob += a
            if b > 0 and a < N:
                E += b * dp[a + 1][b - 1][c]
                prob += b
            if c > 0 and b < N:
                E += c * dp[a][b + 1][c - 1]
                prob += c
            dp[a][b][c] = E / prob

x = C[1]
y = C[2]
z = C[3]
print(dp[x][y][z])
### BUGGY CODE ###

n=int(input())
xl=sorted([[int(i) for i in input().split()] for _ in range(n)],key=lambda x:x[1])[::-1]
count=[0]*n
for j in range(n):
    for i in range(n):
        if(i!=j and xl[j][0]-xl[j][1] < xl[i][0] < xl[j][0]+xl[j][1] and count[i]==0):
            count[j]=1
            break
print(n-sum(count))

### FIXED CODE ###

n=int(input())
X=[]
for i in range(n):
    x,l=[int(_) for _ in input().split()]
    X+=[(x-l,x+l)]
X.sort(key=lambda x:x[0])
ans=n
tmp=X[0][1]
for i in range(1,n):
    if tmp>X[i][0]:
        ans-=1
        tmp=min(tmp,X[i][1])
    else:
        tmp=X[i][1]
print(ans)
### BUGGY CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
now = inpl() + [0]
for _ in range(k):
    pre = now[::]
    now = [0] * (n+1)
    for j in range(n):
        a = max(0,j-pre[j])
        b = min(n,j+pre[j]+1)
        now[a] += 1
        now[b] -= 1
    x = 0
    for j in range(n):
        x += now[j]
        now[j] = x
    if min(now) == n:
        break
print(*now[:n])

### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n,k = inpl()
now = inpl()
now.append(0)
for _ in range(k):
    pre = now[::]
    now = [0] * (n+1)
    for j in range(n):
        a = max(0,j-pre[j])
        b = min(n,j+pre[j]+1)
        now[a] += 1
        now[b] -= 1
    x = 0
    mi = INF
    for j in range(n):
        x += now[j]
        mi = min(mi,x)
        now[j] = x
    if mi == n:
        break
print(*now[:n])
### BUGGY CODE ###

def after_explain():
    d, g = map(int, input().split())
    a = []
    b = []
    for i in range(d):
        p, c = map(int, input().split())
        a.append(p)
        b.append(c)

    mincnt = 999999999
    for i in range(1 << 2 * d):
        score = 0
        cnt = 0
        for j in range(d):
            if i & (1 << j):
                score += a[j]*(j+1)*100 + b[j]
                cnt += a[j]

        for j in range(d-1, -1, -1):
            if not(i & (1 << j)):
                if score > g:
                    break
                s = g - score
                if s % ((j+1)*100) == 0:
                    c = min(a[j], s // ((j + 1) * 100))
                    cnt += c
                    score += c * ((j + 1) * 100)
                else:
                    c = min(a[j], s // ((j + 1) * 100))
                    cnt += c + 1
                    score += (c+1) * ((j + 1) * 100)
                break
        if score < g:
            continue
        if cnt < mincnt:
            mincnt = cnt
    return mincnt

print(after_explain())

### FIXED CODE ###

def after_explain():
    d, g = map(int, input().split())
    a = []
    b = []
    for i in range(d):
        p, c = map(int, input().split())
        a.append(p)
        b.append(c)

    mincnt = 999999999
    for i in range(1 << 2 * d):
        score = 0
        cnt = 0
        for j in range(d):
            if i & (1 << j):
                score += a[j]*(j+1)*100 + b[j]
                cnt += a[j]

        for j in range(d-1, -1, -1):
            if not(i & (1 << j)):
                if score > g:
                    break
                s = g - score
                if s % ((j+1)*100) == 0:
                    c = min(a[j], s // ((j + 1) * 100))
                    cnt += c
                    score += c * ((j + 1) * 100)
                else:
                    c = min(a[j], s // ((j + 1) * 100))
                    cnt += c + 1
                    score += (c+1) * ((j + 1) * 100)
                break
        if score < g:
            continue
        if cnt < mincnt:
            mincnt = cnt
    return mincnt

print(after_explain())