Harryxun/stf_run huggingface dataset:
n, m = map(int, input().split())

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

x = [True] * m

for i in a:
    y = i[0]
    xx = [False] * m
    for j in range(y):
        x[i[j + 1]] = True
    for j in range(m):
        if xx[j] == False:
            x[j] = False

print(sum(x))


### FIXED CODE ###

n, m = map(int, input().split())

S = set(range(1, m + 1))

for i in range(n):
    K, *a = map(int, input().split())
    S = S & set(a)

print(len(S))
n = int(input())
li = list(map(int,input().split()))

pos = [0]*n
pos[0] = 3

mod = 10**9+7

if li[1]-li[0] == 0:
    pos[1] = 6
else:
    pos[1] = 3

for i in range(2,n):
    #連続3つが違う色
    if li[i]-li[i-2] == 0:
        pos[i] = pos[i-2]*2%mod
    #連続3つが同じ色
    elif li[i]-li[i-2] == 2:
        pos[i] = pos[i-2]
    #二つが同じ色
    else:
        pos[i] = pos[i-2]*4%mod

print(pos[-1])

### FIXED CODE ###

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

xyz = [[0,0,0]for _ in range(n)]
xyz[0] = [0,0,0]

mod = 10**9+7

for i in range(n-1):
    if li[i] not in xyz[i]:
        print(0)
        exit()
    ix = xyz[i].index(li[i])
    for j in range(3):
        if j == ix:
            xyz[i+1][j] = xyz[i][j] + 1
        else:
            xyz[i+1][j] = xyz[i][j]

point = 3

for i in range(1,n):
    point *= xyz[i].count(li[i])
    point %= mod
print(point)
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

if __name__ == "__main__":
    S = input().split()

    A = int(S[0])
    B = int(S[1])
    C = int(S[2])
    D = int(S[3])

    CD = lcm(C, D)

    count_B = B - (B // C) - (B // D) + (B // CD)
    count_A = A - 1 - ((A - 1) // C) - ((A - 1) // D) + ((A - 1) // CD)

    print(count_B - count_A)

### FIXED CODE ###

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
    
S = input().split()

A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

CD = (C * D) // gcd(C, D)

count_B = B - (B // C) - (B // D) + (B // CD)
count_A = A - 1 - ((A - 1) // C) - ((A - 1) // D) + ((A - 1) // CD)

print(count_B - count_A)
import sys
import itertools
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()
    xy = [tuple(in_nn()) for _ in range(N)]

    comb = itertools.combinations(range(N), 2)
    d = defaultdict(int)

    for i, j in comb:
        x1, y1 = xy[i]
        x2, y2 = xy[j]
        xd = x2 - x1
        yd = y2 - y1
        if yd < 0:
            yd = -yd
            xd = -xd
        d[(xd, yd)] += 1

    ans = N - max(d.values())
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
import itertools
from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()
    xy = [tuple(in_nn()) for _ in range(N)]

    if N == 1:
        print(1)
        exit()

    comb = itertools.combinations(range(N), 2)
    d = defaultdict(int)

    for i, j in comb:
        x1, y1 = xy[i]
        x2, y2 = xy[j]
        xd = x2 - x1
        yd = y2 - y1
        d[(xd, yd)] += 1
        d[(-xd, -yd)] += 1

    ans = N - max(d.values())
    # print(d)
    print(ans)


if __name__ == '__main__':
    main()
from numpy import *

N = int(input())
a = zeros(N)
a = list(map(int, input().split()))

count = 0

for i in range(N):
    if count + 1 == a[i]:
        count += 1

ans = N - count

if count == 0:
    ans = -1

print(ans)


### FIXED CODE ###

from numpy import *

N = int(input())
a = zeros(N)
a = list(map(int, input().split()))

count = 0

for i in range(N):
    if count + 1 == a[i]:
        count += 1

ans = N - count

if count == 0:
    ans = -1

print(ans)
def resolve():
    n, m = map(int, input().split())
    d = {}
    for i in range(m):
        a, b = map(int, input().split())
        if a in d and b != d[a]:
            print(-1)
            return
        d[a] = b
    if n > 1 and d[min(d)] == 0:
        print(-1)
        return
    ans = ""
    for i in range(n):
        ans += str(d[i + 1]) if i + 1 in d else "0"
    print(int(ans))


if __name__ == '__main__':
    resolve()


### FIXED CODE ###

def resolve():
    n, m = map(int, input().split())
    ans = [-1] * n
    for _ in range(m):
        s, c = map(int, input().split())
        if ans[s - 1] not in (-1, c):
            print(-1)
            return
        ans[s - 1] = c
    if ans[0] == 0 and n != 1:
        print(-1)
        return
    if ans[0] == -1 and n != 1:
        ans[0] = 1
    print("".join([str(x) if x > 0 else "0" for x in ans]))


if __name__ == '__main__':
    resolve()
n = 1
x = int(input())
while x != 0 :
    print("Case  {} : {}".format(n,x)
    n = n+1
    x = int(input())


### FIXED CODE ###

n = 1
x = int(input())
while x != 0 :
    print("Case {}: {}".format(n,x))
    n = n+1
    x = int(input())
def maxreturn(t,n,a):
    ma=[0]*3
    b=[0]*n
    if t==n-1:
        for i in range(3):
           ma[i]=a[n-1][i]
    else:
      b=list(maxreturn(t+1,n,a))
      for i in range(3):
        for j in range(3):
            if i!=j:
                ma[i]=max(ma[i],a[t][i]+b[j])
                
    return ma
n=int(input())
a=[[0]*3]*n
for i in range(n):
    a[i]=list(map(int,input().split()))
ma=maxreturn(0,n,a)
print(max(ma))

### FIXED CODE ###

n=int(input())
a=[[0]*3]*n
for i in range(n):
    a[i]=list(map(int,input().split()))
b=[0]*3
for i in range(n-2,-1,-1):
    for j in range(3):
        t=0
        for k in range(3):
            if j!=k:
                t=max(t,a[i][j]+a[i+1][k])
        a[i][j]=t
print(max(a[0]))
p = np.zeros((14,14), dtype=int)
while True:
    try:
        x_inp, y_inp, s = map(int, input().split(","))
        x = x_inp + 2
        y = y_inp + 2
        if s == 1:
            p[y-1][x] += 1
            p[y][x-1:x+2] += 1
            p[y+1][x] += 1
        elif s == 2:
            p[y-1][x-1:x+2] += 1
            p[y][x-1:x+2] += 1
            p[y+1][x-1:x+2] += 1
        else:
            p[y-2][x] += 1
            p[y-1][x-1:x+2] += 1
            p[y][x-2:x+3] += 1
            p[y+1][x-1:x+2] += 1
            p[y+2][x] += 1
    except:
        break
p_trim = p[2:12,2:12]
print(len(np.where(p_trim==0)[0]))
print(np.max(p_trim))



### FIXED CODE ###

p = [[0 for i in range(14)] for j in range(14)]
while True:
    try:
        x_inp, y_inp, s = map(int, input().split(","))
        x = x_inp + 2
        y = y_inp + 2
        if s == 1:
            p[y-1][x] = p[y-1][x] + 1
            p[y][x-1] = p[y][x-1] + 1
            p[y][x]   = p[y][x]   + 1
            p[y][x+1] = p[y][x+1] + 1
            p[y+1][x] = p[y+1][x] + 1
        elif s == 2:
            p[y-1][x-1] = p[y-1][x-1] + 1
            p[y-1][x]   = p[y-1][x]   + 1
            p[y-1][x+1] = p[y-1][x+1] + 1
            p[y][x-1]   = p[y][x-1]   + 1
            p[y][x]     = p[y][x]     + 1
            p[y][x+1]   = p[y][x+1]   + 1
            p[y+1][x-1] = p[y+1][x-1] + 1
            p[y+1][x]   = p[y+1][x]   + 1
            p[y+1][x+1] = p[y+1][x+1] + 1
        else:
            p[y-2][x] += 1
            p[y-1][x-1] = p[y-1][x-1] + 1
            p[y-1][x]   = p[y-1][x]   + 1
            p[y-1][x+1] = p[y-1][x+1] + 1
            p[y][x-2]   = p[y][x-2]   + 1
            p[y][x-1]   = p[y][x-1]   + 1
            p[y][x]     = p[y][x]     + 1
            p[y][x+1]   = p[y][x+1]   + 1
            p[y][x+2]   = p[y][x+2]   + 1
            p[y+1][x-1] = p[y+1][x-1] + 1
            p[y+1][x]   = p[y+1][x]   + 1
            p[y+1][x+1] = p[y+1][x+1] + 1
            p[y+2][x] += 1
    except:
        break
p_trim = [p[i][2:12] for i in range(2,12)]
p_flatten = sum(p_trim,[])
print(sum(x==0 for x in p_flatten))
print(max(p_flatten))
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

from math import gcd

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

print (A * B // gcd(A, B))

### FIXED CODE ###

from fractions import gcd

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

lcm = (A * B) // gcd(A, B)

print (lcm)
import math
n,m = map(int,input().split())
before = -1
alls = 1
a = -1
if m != 0:
        for i in range(m):
                a = int(input())
                b = (a - before - 2) // 2
                c = a - before - 2
                ptr = 0
                for j in range(b + 1):
                        ptr += math.factorial(c - j) / (math.factorial(j) * math.factorial(c - 2 * j))
                alls = alls * ptr
                before = a
ptr = 0
b = (n - a - 1) // 2
c = n - a - 1
for j in range(b + 1):
        ptr += math.factorial(c - j) / (math.factorial(j) * math.factorial(c - 2 * j))
alls = alls * ptr
print(int(alls % 1000000007))

### FIXED CODE ###

n,m = map(int,input().split())
stair = [0,1] + [0 for i in range(n)]
ba = 2
for i in range(m):
	a = int(input()) + 1
	for j in range(ba,a):
		stair[j] = stair[j - 1] + stair[j - 2]
	ba = a + 1
for i in range(ba,n + 2):
	stair[i] = stair[i - 1] + stair[i - 2]
print(stair[n + 1] % 1000000007)
# -*- coding: utf-8 -*-

import math
import functools

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

max_under_lcm = functools.reduce(lambda x, y: int((x * y) / math.gcd(x,y)), numbers) - 1
answer = sum([ max_under_lcm % n for n in numbers])

print(answer)

### FIXED CODE ###

import functools
import fractions

N = int(input())
numbers = list(map(int, input().split()))
answer = sum([n - 1 for n in numbers])

print(answer)
if n==1:
  for i in range(10):
    
    flg=True
    for l in range(m):
      if str(i)[b[l][0]-1]  != str(b[l][1]):
        flg=False
    if flg==True:
      print(i)
      break
  else:
    print(-1)
  
else:  
  for i in range(10**(n-1),10**n):
    flg=True
    for j in range(m):
      if str(i)[b[j][0]-1] != str(b[j][1]):
        flg=False
    
    if flg==True:
      print(i)
      break
  if flg == False:
    print(-1)
      

### FIXED CODE ###

n,m=map(int,input().split())

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

if n==1:
  for i in range(10):
    
    flg=True
    for l in range(m):
      if str(i)[b[l][0]-1]  != str(b[l][1]):
        flg=False
    if flg==True:
      print(i)
      break
  else:
    print(-1)
  
else:  
  for i in range(10**(n-1),10**n):
    flg=True
    for j in range(m):
      if str(i)[b[j][0]-1] != str(b[j][1]):
        flg=False
    
    if flg==True:
      print(i)
      break
  if flg == False:
    print(-1)
A,B = list(map(int,input().split()))
print(max(A+B.A-B,A*B))

### FIXED CODE ###

A,B = list(map(int,input().split()))
print(max(A+B,A-B, A*B))
"""
the condition is straightforward.
each element of A and B must multiply to the same value.
to minimise the total of B, simply make that value as small
as possible (since A is fixed).

lcm(2, 3, 4) = 12
therefore B is
12/2, 12/3, 12/4
and the sum of B is
12/2 + 12/3 + 12/4

lcd of a list is loop: lcd(partial, new_value)
lcd(a, b) = ab / gcd(a, b)
"""

from math import gcd


def lcm(list_ints):
    lcm_ongoing = 1
    for val in list_ints:
        lcm_ongoing = int(round(val*lcm_ongoing/gcd(val, lcm_ongoing)))
    return lcm_ongoing


def flatten(N, A):
    # get lcm
    lcm_of_A = lcm(A)
    # get sum of lcm/values
    ans = sum(int(round(lcm_of_A/value)) for value in A)
    modulo_value = int(int(10e9)+7)
    return ans % modulo_value


if __name__ == "__main__":
    test1 = \
"""3
2 3 4"""
    test2 = \
"""5
12 12 12 12 12"""
    test3 = \
"""3
1000000 999999 999998"""
    test = test3
    # N = int(test.split("\n")[0])
    # A = list(map(int, test.split("\n")[1].split()))
    N = int(input())
    A = list(map(int, input().split()))
    print(flatten(N, A))

### FIXED CODE ###

"""
the condition is straightforward.
each element of A and B must multiply to the same value.
to minimise the total of B, simply make that value as small
as possible (since A is fixed).

lcm(2, 3, 4) = 12
therefore B is
12/2, 12/3, 12/4
and the sum of B is
12/2 + 12/3 + 12/4

lcd of a list is loop: lcd(partial, new_value)
lcd(a, b) = ab / gcd(a, b)
"""

from fractions import gcd


def lcm(list_ints):
    lcm_ongoing = 1
    for val in list_ints:
        lcm_ongoing = val*lcm_ongoing//gcd(val, lcm_ongoing)
    return lcm_ongoing


def flatten(N, A):
    # get lcm
    lcm_of_A = lcm(A)
    # get sum of lcm/values
    ans = sum(lcm_of_A//value for value in A)
    modulo_value = int(int(10e8)+7)
    return ans % modulo_value


if __name__ == "__main__":
    test1 = \
"""3
2 3 4"""
    test2 = \
"""5
12 12 12 12 12"""
    test3 = \
"""3
1000000 999999 999998"""
    test = test3
    # N = int(test.split("\n")[0])
    # A = list(map(int, test.split("\n")[1].split()))
    N = int(input())
    A = list(map(int, input().split()))
    print(flatten(N, A))
n = int(input())
station = (tuple(map(int, input().split())) for _ in range(n-1))

for i in range(n):
    res = 0
    for j in range(i, n-1):
        c, s, f = station[j]
        res += max(s - res, (res+f-1)//f*f - res) + c
    print(res)


### FIXED CODE ###

n = int(input())
station = [tuple(map(int, input().split())) for _ in range(n-1)]

for i in range(n-1):
    res = 0
    for j in range(i, n-1):
        c, s, f = station[j]
        if res == 0:
            res += s + c
        else:
            res += max(s-res, ((res+(f-1))//f)*f - res) + c
    print(res)
else:
    print(0)
s= List(input())
s[3]="8"
print(s)

### FIXED CODE ###

s = input()
print("2018/01/"+s[8:])
N,M=input().split()
N,M=[int(N),int(M)]
#M ga retu i
#N ga gyou j
status = [[1]*M]*N

#print(status)

def countCard(j,i):
	#print("-------------")
	#print("status[{}][{}]={}".format(i,j,status[i][j]))
	count = 0
	left=0
	right=0
	up =0
	down=0
	tmp = j-1
	if tmp >= 0:
		left = 1
	tmp = j+1
	if tmp < M:
		right = 1
	tmp=i-1
	if tmp >= 0:
		up = 1
	tmp=i+1
	if tmp < N:
		down = 1
	a= left + right + up + down
	#print("left:{},right:{},up:{},down:{}".format(left,right,up,down))
	if a == 4:
		return 0	#9
	elif a == 3:
		return 1	#6
	elif a == 2:
		if left + right == 0 or up+down==0:
			return 0	#3
		else:
			return 1	#4
	elif a == 1:
		return 1	#2
	elif a == 0:
		return 0
	else:
		print('error')
		quit()


for i in range(M):
	for j in range(N):
		status[j][i] = countCard(j,i)
		#print("status[{}][{}] = {}".format(i,j,status[i][j]))


#print(status)
ans = 0
for i in range(N):
	ans += sum(status[i])
print(ans)

### FIXED CODE ###

N,M=input().split()
N,M=[int(N),int(M)]

def countCard(j,i):
	count = 0
	left=0
	right=0
	up =0
	down=0

	if j-1 >= 0:
		left = 1

	if j+1 < M:
		right = 1

	if i-1 >= 0:
		up = 1

	if i+1 < N:
		down = 1

	a= left + right + up + down
	if a == 4:
		return 0	#9
	elif a == 3:
		return 1	#6
	elif a == 2:
		if left + right == 0 or up+down==0:
			return 0	#3
		else:
			return 1	#4
	elif a == 1:
		return 1	#2
	elif a == 0:
		return 0

ans = 0

if M >= 3 and N >=3:
	ans = (M-2)*(N-2)
elif M == 1 and N ==1:
	ans = 1
elif N == 1 and M > 2:
	ans = M -2
elif M ==1 and N>2:
	ans = N-2
else:
	status = [[1]*M]*N
	for i in range(N):
		for j in range(M):
			status[i][j] = countCard(j,i)
			ans += status[i][j]
	ans = (M*N) - ans

print(ans)
import math
a, b, c = input().split()
d = math.fabs(b-a)
e = math.fabs(c-b)
if d == e:
 print('YES')
else:
 print('NO')

### FIXED CODE ###

a,b,c=map(int,input().split())
if b-a == c-b:
    print("YES")
else:
    print("NO")
# 2 6=>4 (1,6)*2,(2,3)*2
# 3 12=>18 (1,1,12)*3,(1,2,6)*6,(1,3,4)*6,(2,2,3)*3
import math
def comb(a,b): # aCb
    return math.factorial(a)//math.factorial(a-b)//math.factorial(b)

n,m=map(int,input().split())
rootm=int(m**0.5)
divisor={}
tmp=m
for i in range(2,m+1):
    while tmp%i==0:
        tmp//=i
        divisor.setdefault(i,0)
        divisor[i]+=1
    if tmp==1:
        break
print(divisor)
cnt=1
for key in divisor:
    tmp=0
    for c in range(1,divisor[key]+1):
        tmp+=comb(n,c)
    cnt*=tmp
print(cnt%1000000007)


### FIXED CODE ###

# うまく効率化できなかった
# 2 6=>4 (1,6)*2,(2,3)*2
# 3 12=>18 (1,1,12)*3,(1,2,6)*6,(1,3,4)*6,(2,2,3)*3
# import math
# def comb(a,b):
#     return math.factorial(a)//math.factorial(a-b)//math.factorial(b)
def comb(a,b): # aCb
    b=min(b,a-b)
    result=1
    for i in range(a,a-b,-1):
        result*=i
    for i in range(1,b+1):
        result//=i
    return result

n,m=map(int,input().split())
divisor={}
tmp=m
# for i in range(2,m+1):
#     while tmp%i==0:
#         tmp//=i
#         divisor.setdefault(i,0)
#         divisor[i]+=1
#         if tmp==1:
#             break
i=2
while i*i<=m:
    while tmp%i==0:
        tmp//=i
        divisor.setdefault(i,0)
        divisor[i]+=1
    i+=1
if tmp>1:
    divisor[tmp]=1
# print(divisor)
cnt=1
for key in divisor:
    c=divisor[key]
    cnt*=comb(c+n-1,c)
print(cnt%1000000007)
S=input()
K=int(input())
l=len(S)
r=0
q=0
if l==1:
    print(int(S))
else:
    for i in range(0,l-1):
        if int(S[i]) != 1:
            r=int(S[i])
            q=i
            break
    if q>K:
        print(1) 
    else:
        print(r)

### FIXED CODE ###

A,B=list(map(int,input().split()))
C=(A-1)*(B-1)
print(C)
W, H, x, y = map(int, input().split())
print(W * H / 2, 1 if W / x == 2 and H / y == 2 else 0)


### FIXED CODE ###

W, H, x, y = map(int, input().split())
print(W * H / 2, 1 if x != 0 and y != 0 and W / x == 2 and H / y == 2 else 0)
N,A,B=map(int,input())
print(min(N*A,B))

### FIXED CODE ###

N,A,B=map(int,input().split())
print(min(N*A,B))
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
print(a[-1]-a[0])

### FIXED CODE ###

n = int(input())

if n%2==0:
    print(n)

else:
    print(2 * n)
import bisect
N,K=map(  int,raw_input().split() )
X=map(  int,raw_input().split() )

zero_idx=bisect.bisect_left(X,0)


ans=float("inf")
for i in range(zero_idx-K+1, min(N,zero_idx+K) ):
	if i < zero_idx:
		if zero_idx-i==K:
			t=X[i]
		else:
			t=2*abs(X[i])+X[K-(zero_idx-i)-1+zero_idx]
	elif i>=zero_idx:
		if i-zero_idx==K-1:
			t=X[i]
		else:
			t=2*X[i]+ abs( X[zero_idx- ( K-(i-zero_idx+1) )] )
	ans=min(ans,t)

print ans

### FIXED CODE ###

N,K=map(  int,raw_input().split() )
X=map(  int,raw_input().split() )

ans=float("inf")
t=float("inf")
for l in range(N-K+1):
	r=l+K-1
	if X[l]<0:
		if X[r]<0:	
			ans=min(ans, abs(X[l]) )
		else:	
			ans=min(ans, 2*abs(X[l])+abs(X[r]) , abs(X[l])+2*abs(X[r]) )
	elif X[l]>=0 and X[r]>=0:
		ans=min(ans, X[r] )


print ans
n,q=map(int,input().split())
a=list(map(int,input().split()))
bit=[0]*(2*n+10)
def bit_update(x,v):
    while x<size:
        bit[x]+=v
        x+=(x&-x)
def bit_sum(n):
    s=0
    if n==0:return 0
    x=n
    while x>0:
        s+=bit[x]
        x-=(x&-x)
    return s
for i,j in enumerate(a,1):
    bit_update(i,j)
for i in range(q):
    a,b,c=map(int,input().split())
    if a==0:
        bit_update(b+1,c)
    else:
        print(bit_sum(c)-bit_sum(b))

### FIXED CODE ###

n,q=map(int,input().split())
a=list(map(int,input().split()))
size=2*n+1
bit=[0]*size
def bit_update(x,v):
    while x<size:
        bit[x]+=v
        x+=(x&-x)
def bit_sum(n):
    s=0
    if n==0:return 0
    x=n
    while x>0:
        s+=bit[x]
        x-=(x&-x)
    return s
for i,j in enumerate(a,1):
    bit_update(i,j)
for i in range(q):
    a,b,c=map(int,input().split())
    if a==0:
        bit_update(b+1,c)
    else:
        print(bit_sum(c)-bit_sum(b))
N,D = map(int,input().split())
P = []
for i in range (N):
    P.append(list(map(int, input().split())))
Pi = 0
for i in range(N):
    for j in range(i+1, N):
        Di = 0
        for k in range (D):
            Di += (P[i][k]-P[j][k])**2
        if int(Di**0.5) == dist**0.5:
            Pi += 1
print(Pi)

### FIXED CODE ###

N,D = map(int,input().split())
P = []
for i in range (N):
    P.append(list(map(int, input().split())))
Pi = 0
for i in range(N):
    for j in range(i+1, N):
        Di = 0
        for k in range (D):
            Di += (P[i][k]-P[j][k])**2
        if int(Di**0.5) == Di**0.5:
            Pi += 1
print(Pi)
P=[]
C=[]
point=1000    #全問題数

D,G=map(int,input().split())
for i in range(D):
    p,c= map(int,input().split())
    P.append(p)
    C.append(c)

#とりあえず全部解くor解かないで目標スコアを超えるか超えないかを考える


for i in range(2**D) :
    score=0
    solve=0
    needproblem=0
    for j in range(D) :                  #全正解した大問をスコアに変換
        if (i>>j) & 1 :
            score+=P[j]*100*(j+1)+C[j]
            solve+=P[j]
        if (~i>>j) & 1 :                  #1問も解かなかった問題の中で最も一題あたりの点が高い問題
            needproblem=j+1
    if score>G :
        point=min(point,solve)

#ぎりぎりスコアが届いていない場合、1問も解かなかった問題の中で最も一題あたりの点が高い問題だけ解いてみる
#中途半端に大問を解ききるのが１種類以下でも目標に届く場合もあるという予想

    elif score<=G :                
        needsolve=(G-score)//(needproblem*100)
        if needsolve>P[needproblem-1] :            #1問も解かなかった問題の中で最も一題あたりの点が高い問題を解いても届かないのでやり直し
            continue
        elif needsolve<=P[needproblem-1] :
            resolve=solve+needsolve
            point=min(point,resolve)

print(point)

### FIXED CODE ###

D,G=map(int,input().split())
# bit全探索で、全問解く問題の組み合わせをすべて試す
 
scores=[None]*D
for i in range(D):
  p,c=map(int,input().split())
  # 一問の得点、問題数、ボーナス、全てといたときの得点
  scores[i]=[(i+1)*100,p,c,((i+1)*100)*p+c]
 
# あとあとのために点数高い順に並べる
scores=sorted(scores,key=lambda x:x[0])[::-1]
 
# 全問とく組み合わせに対して、最小の問題数
ans=D*100
for i in range(2**D):
  total=0
  solve=0
  for j in range(D):
    if (i>>j)&1:
      # 全問とく問題のボーナスを足していく
      total+=scores[j][3]
      solve+=scores[j][1]
  if total>=G:
    if ans>solve:
      ans=solve
    continue
  rest=G-total
  for j in range(D):
    if (i>>j)&1==0:
      point=scores[j][0]
      num=scores[j][1]-1 # 全問とかないので1減らす
      if point*num<rest:
        rest-=point*num
        solve+=num
      else:
        solve+=(rest//point+(rest%point>0))
        rest=0
    if rest<=0 and ans>solve:
      ans=solve
  
print(ans)
from itertools import accumulate
import numpy as np
N=int(input())
N-=1
L=[26**(i+1) for i in range(15)]
sL=list(accumulate(L))
result=[]
k=0
for i in range(10):
    if N+1<=sL[i] and N>=25:
        N-=sL[i-1]
        k=i
        break
for m in range(k):
    time=0
    while N>=L[k-m-1]:
        N-=L[k-m-1]
        time+=1
    result.append(chr(time+97))
result.append(chr(N+97))
print(''.join(result))

### FIXED CODE ###

from itertools import accumulate
import numpy as np
N=int(input())
N-=1
L=[26**(i+1) for i in range(15)]
sL=list(accumulate(L))
result=[]
k=0
for i in range(15):
    if N+1<=sL[i] and N>=25:
        N-=sL[i-1]
        k=i
        break
for m in range(k):
    time=0
    while N>=L[k-m-1]:
        N-=L[k-m-1]
        time+=1
    result.append(chr(time+97))
result.append(chr(N+97))
print(''.join(result))
N=int(input())
HP=list(map(int,input().split()))

tmp=egcd(HP[0],HP[1])

for i in range(1,N-1):
    a=tmp
    b=HP[i+1]
    
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
        
    tmp=a
    
print(tmp)

### FIXED CODE ###

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    gcd=a
    return gcd

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

tmp=egcd(HP[0],HP[1])

for i in range(1,N-1):
    tmp=egcd(tmp,HP[i+1])
    
print(tmp)