peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
a = [list(map(int, input().split())) for row in range(3)]
n = int(input())
b = [int(input()) for hoge in range(n)]
a1 = a[0] + a[1] + a[2]
c = []
for poge in a1:
  if poge in b:
    c.append(0)
  else:
    c.append(1)
if min((c[0]+c[1]+c[2]),(c[3]+c[4]+c[5]),(c[6]+c[7]+c[8]),(c[0]+c[3]+c[6]),
      (c[1]+c[4]+c[7]),(c[2]+c[5]+c[8]),(c[0]+c[4]+c[8]),(c[2]+c[4]+c[6])) == 0:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
from functools import reduce

def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        r = x % y
        x = y
        y = r
    return y

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

def lcm(a, b):
    return a * b * inv(gcd(a, b))

def addmod(a, b):
    return (a+b) % MOD
  
  
N = int(input())
a_list = list(map(int, input().split()))
MOD = 10 ** 9 + 7

l = reduce(lcm, a_list)
ans = reduce(addmod, (l*inv(a) for a in a_list))

print(ans%MOD)
# Judge status: Accepted
A,B=list(map(int,input().split()))
if A==B:
    print('Draw')
elif A==1:
    print('Alice')
elif B==1:
    print('Bob')
elif A>B:
    print('Alice')
else:
    print('Bob')
# Judge status: Accepted
n,k=map(int,input().split())
a=sorted(map(int,input().split()))
print(sum(a[:k]))
# Judge status: Accepted
import math
N, K = map(int, input().split())
a = list(map(int, input().split()))
M = math.ceil((N-1)/(K-1))
print(M)
# Judge status: Accepted
N, M, K = map(int, input().split())
Flg = "No"

for i in range(N+1):
    for j in range(M+1):
        if((M-j)*i+(N-i)*j ==K):
            Flg = "Yes"
            break
print(Flg)
# Judge status: Accepted
a, b = map(int, input().split())
if a < b:
    print(str(a)*b)
elif a > b:
    print(str(b)*a)
else:
    print(str(b)*a)
# Judge status: Wrong Answer
k = input()
ans = "No"
for i in k:
    if len(k.replace(i, "")) <= 1:
        ans = "Yes"
        break
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
X = sorted(A,reverse=False)
print(X)
for i in range(N):
    if A[i] < X[N//2 ]:
        print(X[N//2 ])
    else:
        print(X[N//2 - 1])
# Judge status: Accepted
n = int(input())
count = 0
a = [0]*(10**5)
for i in range(1, 100):
  for j in range(1, 100):
    for k in range(1, 100):
      a[(i+j+k)**2-(i*j+j*k+i*k)] += 1


for i in range(n):
  print(a[i+1])
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))

for _ in range(min(K, 50)):
    lamp = [0 for i in range(N + 1)]
    for i in range(N):
        lamp[max(0, i - A[i])] += 1
        lamp[min(N, i + A[i] + 1)] -= 1

    for i in range(1, N + 1):
        lamp[i] += lamp[i - 1]
    A = lamp

[print(A[i], end=' ') for i in range(N)]
print()
# Judge status: Accepted
N = int(input())
D = list(map(int, input().split()))

D.sort()

if N % 2 == 1:
    print(0)
else:
    M = N //2
    res = D[M] - D[M-1]
    print(res)
# Judge status: Accepted
a, b, c = map(int, input().split())

if a+b+c == 17:
  print('YES')
else:
  print('NO')
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
A_max = max(A)
for i in range(1,A_max+1):
  if A_max < i:
    print(0)
  else:
    print(A.count(i))
# Judge status: Wrong Answer
N,K=map(int,input().split())
p=[int(x) for x in input().split()]
T=[0 if x=='r' else (1 if x=='s' else 2) for x in input()]
B=[-1]*K

s=0
for i in range(N):
  v=(T[i]+2)%3
  if v!=B[i%K]:
    s+=p[v]
    B[i%K]=v
  else:
    B[i%K]=T[i]
    if i<N-K:
      if (T[i+K]+2)%3!=T[i]:
        B[i%K]=(T[i]+1)%3

print(s)
# Judge status: Wrong Answer
n, a, b = map(int, input().split())
s = input()

all = list(s)
count = 0
count_b = 0
for i in all:
    if i == 'a':
        if count <= a + b:
            print('yes')
            count += 1
        else:
            print('no')
    if i == 'b':
        if count <= a + b and count_b <= b:
            print('yes')
            count += 1
            count_b += 1
        else:
            print('no')
    else:
        print('no')
# Judge status: Accepted
# coding: utf-8
# Your code here!
import math

tanshin,choshin,jikan,hun=map(int,input().split(" "))

x1=tanshin*math.cos(math.radians(-(jikan*30+hun*0.5-90)))
y1=tanshin*math.sin(math.radians(-(jikan*30+hun*0.5-90)))
x2=choshin*math.cos(math.radians(-(hun*6-90)))
y2=choshin*math.sin(math.radians(-(hun*6-90)))
ans=math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1))
print(ans)
# Judge status: Accepted
S, W = map(int,input().split())
print("unsafe" if W >= S else "safe")
# Judge status: Accepted
print('YES' if input() in '753' else 'NO')
# Judge status: Wrong Answer
D = int(input())
C ='Christmas' 
E = 'Eve'
if D==25:
    print(C)
elif D==24:
    print(C+E)
elif D==23:
    print(C+E*2)
else:
    print(C+E*3)
# Judge status: Accepted
import numpy as np
N = int(input())
B = np.array([10 ** 5] + list(map(int, input().split())) + [10 ** 5], np.int32)
print(np.minimum(B[1:], B[:-1]).sum())
# Judge status: Accepted
s = int(input())
mod = 10**9+7

dp = [0]*(s+1)
dp[0] = 1
for i in range(1, s+1):
    for j in range(0, (i-3)+1):
        dp[i] += dp[j]
        dp[i] %= mod
print(dp[s])
# Judge status: Wrong Answer
a = (input())

if a.islower == True:
    print("a")
else:
    print("A")
# Judge status: Wrong Answer
N = int(input())
S = list(input())
A = (S.count("R"))*(S.count("B"))*(S.count("G"))
for i in range(1,N):
    for j in range(i+1,N+1):
        if j < 2*j - i <= N:
            if S[i-1] != S[j-1] != S[2*j - i - 1] :
                A -= 1
print(A)
# Judge status: Accepted
n,m = map(int, input().split())
A = sorted(map(int, input().split()), reverse = True)
suma = sum(A)
if A[m-1]>= suma/(4*m):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n,k = map(int, input().split())
s = input()
happy, no = 0,0
for i in range(1,n):
    if s[i] == s[i-1]:
        happy += 1
    else: no += 1

for i in range(k):
    if no == 1:
        no -= 1
        happy += 1
        break
    no -= 2
    happy += 2
print(min(happy, n-1))
# Judge status: Wrong Answer
n=int(input())
ans='Yes'
t,a,b=map(int,input().split())
if (a+b)<t or (a+b-t)%2==1:
  ans='No'
for i in range(n-1):
  u,x,y=map(int,input().split())
  if (u-t)<abs(x-a)+abs(y-b) or ((u-t)-abs(x-a)-abs(y-b))%2==1:
    ans='No'
    break
  t,a,b=u,x,y
print(ans)
# Judge status: Accepted
# input
N, X = map(int, input().split())
L = list(map(int, input().split()))

# check
cnt = 1
D = 0
for i in range(N):
    D = D + L[i]
    if D <= X:
        cnt += 1

print(cnt)
# Judge status: Accepted
n=int(input())
L=[2,1]
for i in range(2,n+1):
    L.append(L[i-1]+L[i-2])
print(L[n])
# Judge status: Wrong Answer
import math

n = int(input())
d = n
m = {}
for i in range(2, int(math.sqrt(n)) + 1):
    m[i] = 1
    while (d % i == 0):
        m[i] += 1
        d //= i
res = 0
for i in m.values():
    res+=i//2

if d > 1:
    res += 1
print(res)
# Judge status: Accepted
N,A,B = [int(i) for i in input().split()]
ts = 0
for n in range(1,N+1):
    s = sum([int(i) for i in str(n)])
    if A <= s <= B:
        ts += n
print(ts)
# Judge status: Accepted
A1, A2, A3 = [int(s) for s in input().split(' ')]
print('win' if A1+A2+A3 < 22 else 'bust')
# Judge status: Accepted
x,k,d=map(int,input().split())
x =abs(x)
o =x//d
if (x-d*k) >=0:
    print(x-d*k)
    exit()
else:
    if (k-o)%2==0:
        print(abs(x%d))
        exit()
    else:
        print(abs(x%d-d))
        exit()
# Judge status: Accepted
N = int(input())
ans = 0
for i in range(1, N+1):
  if i % 2 == 0:
    continue
  a = 0
  for j in range(1, i+1):
    if i % j == 0:
      a += 1
  if a == 8:
    ans += 1
print(ans)
# Judge status: Accepted
from itertools import combinations

n = int(input())
D = []
ans = 0
for i in range(n):
    x,y = map(int,input().split())
    D.append((x,y))
for i,j in combinations(range(1,n+1),r=2):
    p,q = D[i-1]
    r,s = D[j-1]
    ans += ((p-r)**2+(q-s)**2)**(0.5)
print(2*ans/n)
# Judge status: Wrong Answer
number = int(input())
count = 2

if number < 3:
    count = number + 3
else:
    while number != 1:
        count += 1
        if number % 2 == 0:
            number = number / 2
        else:
            number = number * 3 + 1

print(count)
# Judge status: Accepted
n, m = map(int, input().split())

p, s = [], []
result = [0] * (n + 1)
wa = [0] * (n + 1)

for _ in range(m):
    tmpp, tmps = map(str, input().split())
    p.append(int(tmpp)), s.append(tmps)

for i in range(m):
    if result[p[i]] == 0:
        if s[i] == "AC":
            result[p[i]] = 1

        else:
            wa[p[i]] += 1

ac = sum(result)
wa = sum(wa[i] for i in range(n + 1) if result[i] == 1)

print(ac, wa)
# Judge status: Accepted
a, b, n = map(int, input().split())
i = min(b - 1, n)
print((a * i) // b - a * (i // b))
# Judge status: Accepted
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
bc = [map(int, input().split()) for _ in range(m)]
cb = sorted([[c, b] for b, c in bc])
j = len(cb) - 1
for i in range(n):
    if j >= 0 and a[i] < cb[j][0]:
        a[i] = cb[j][0]
        cb[j][1] -= 1
    if cb[j][1] == 0:
        j -= 1
print(sum(a))
# Judge status: Wrong Answer
import math
n,d=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
ans=0
cnt=0
siki=0
for i in range(n-1):
    for j in range(i+1,n):
        siki=0
        for k in range(d):
            siki+=((l[i][k]-l[j][k])**2)
        han=math.sqrt(ans)
        if han%1==0:
            cnt+=1
print(cnt)
# Judge status: Accepted
K = int(input())
base = 0

for count in range(1, K+1):
  num = base*10 + 7
  if (num%K == 0):
    print(count)
    exit()
  else:
    base = num%K
print(-1)
# Judge status: Accepted
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())
    x=list(map(int,readline().split()))
    x.sort()
    d=[0]*(m-1)
    for i in range(1,m):
        d[i-1]=x[i]-x[i-1]

    d.sort()
    print(sum(d[:max(0,m-n)]))

if __name__=="__main__":
    main()
# Judge status: Accepted
X, Y = map(int, input().split())
ans = 10**10
if Y-X >= 0:
    ans = min(ans, Y-X)
if Y+X >= 0:
    ans = min(ans, Y+X+1)
if -Y-X >= 0:
    ans = min(ans, -Y-X+1)
if -Y+X >= 0:
    ans = min(ans, -Y+X+2)
print(ans)
# Judge status: Accepted
X, Y, A, B, C = map(int, input().split())
AA = list(map(int, input().split()))
BB = list(map(int, input().split()))
CC = list(map(int, input().split()))
a = sorted(AA, reverse=True)
b = sorted(BB, reverse=True)
c = sorted(CC, reverse=True)

if X < A:
  del a[X:]

if Y < B:
  del b[Y:]

NEW = a + b + c
NEWnew = sorted(NEW, reverse=True)
del NEWnew[X+Y:]
K = sum(NEWnew)
print(K)
# Judge status: Accepted
a,b,x=map(int,input().split())
print("YES" if 0<=x-a<=b else "NO")
# Judge status: Accepted
x = int(input())
l = []
d = {}
for i in range(1000):
  b = (-1000+i)**5
  d[b] = -1000+i
for i in range(1000):
  a = i**5
  d[a] = i
  if a-x in d:
    b = d[a-x]
    a = i
    break
print(a,b)
# Judge status: Accepted
N=int(input())
d=dict()
for _ in range(N):
    S=input()
    if S not in d:
        d[S]=0
    d[S]+=1
M=max(d.values())
ans=[]
for S in d.keys():
    if d[S]==M:
        ans.append(S)
ans.sort()
for S in ans:
    print(S)
# Judge status: Wrong Answer
x = int(input())
s = x//2
s = s*(s+1)//2
if  s < x: print(x//2 + 1)
else: print(x//2)
# Judge status: Accepted
import sys
def IL(): return map(int,sys.stdin.readline().rstrip().split())

if __name__=='__main__':
    x,y = IL()
    if x==y:
        print(-1)
        exit()
    for rep in range(x,10**9+1,x):
        if rep%y!=0:
            print(rep)
            exit()
    print(-1)
    exit()
# Judge status: Wrong Answer
N = int(input())
count_1 = 0
for i in range(1,N+1,2):
  count_2 = 0
  for j in range(1,i+1,2):
    if N % j == 0:
      count_2 += 1
  if count_2 == 8:
    count_1 += 1
print(count_1)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))

dp = [-1]*N
dp[0] = 1000
dp[1] = 1000
#dp[i] = max(dp[i-2],dp[i-1], (dp[i-2]//A[i-2])*A[i]+dp[i-2]%A[i-2])
for i in range(1,N):
  dp[i] = max(dp[i-1], (dp[i-1]//A[i-1])*A[i]+dp[i-1]%A[i-1])
print(dp[N-1])
# Judge status: Accepted
import sys
sys.setrecursionlimit(1000000)
K = int(input())
all = []
def dfs(number):
    all.append(number)
    if len(str(number)) == 10:
        return
    for i in range(-1, 2):
        n_number = number % 10 + i
        if n_number >= 0 and n_number <= 9:
            dfs(number*10+n_number)

for i in range(1, 10):
    dfs(i)
all.sort()
print(all[K-1])
# Judge status: Accepted
N = int(input())
S = [input() for i in range(N)]
a = set(S)
print(len(a))
# Judge status: Accepted
ns = set(map(int, input().split()))
print(len(ns))
# Judge status: Accepted
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

s = int(input())

n = num2alpha(s)

print(n.lower())
# Judge status: Accepted
n=int(input())
res=1
k=1
for b in range(1,int(n**0.5)+1):
    for p in range(2,n):
        if b**p>n:
            break
        else:
            res=max(res,b**p)
print(res)
# Judge status: Accepted
A, B, C, D = map(int, input().split())

def gcd(a, b):
    if a == 0:
        return b
    return int(gcd(b%a, a))

def lcm(a, b):
    return int(a * b / gcd(a, b))

E = lcm(C, D)
ans = (B-A+1) - (B//C - (A-1)//C) - (B//D - (A-1)//D) + (B//E - (A-1)//E)

print(ans)
# Judge status: Accepted
def ceil(a, b):
    return (a + b - 1) // b


N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
n = sum(b) - sum(a)
cnt = 0
for _a, _b in zip(a, b):
    if _a < _b:
        cnt += ceil(_b - _a, 2)
if cnt <= n:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
from fractions import gcd
def factor(n):
    res = []
    for i in range(2,int(n**0.5)+1):
        while n % i == 0:
            res.append(i)
            n //= i
    if n > 1:
        res.append(n)
    return res

a,b = map(int,input().split())
c = gcd(a,b)
print(len(set(factor(c)))+1)
# Judge status: Accepted
S,W = map(int,input().split())
if S > W:
    print("safe")
else:
    print("unsafe")
# Judge status: Accepted
A,B=map(int,input().split())

if A<=9 and B<=9:
	print(A*B)
else:
	print("-1")
# Judge status: Accepted
import collections
N = int(input())
l = list(map(int,input().split()))

c = collections.Counter(l)
if c.most_common()[0][1] > 1:
    print('NO')
else:
    print('YES')
# Judge status: Accepted
S = input()
T = input()
D = dict()

for s, t in zip(S, T):
    if s in D:
        if D[s] != t:
            print('No')
            exit()
    elif t in D.values():
        print('No')
        exit()
    else:
        D[s] = t

print('Yes')
# Judge status: Accepted
if ord(input()) < 91:
    print('A')
else:
    print('a')
# Judge status: Accepted
N=int(input())
for i in range(1,10):
	ans=i*100+i*10+i
	if ans>=N:
		print(ans)
		exit()
# Judge status: Wrong Answer
numof500 = int(input())
numof100 = int(input())
numof50  = int(input())
moneyneeded = int(input())
 
counter = 0
for i in range(numof500):
  for j in range(numof100):
    for k in range(numof50):
      if 500 * i + 100 * j + 50 * k == moneyneeded:
        counter += 1
 
print(counter)
# Judge status: Accepted
x =[str(input()) for i in range(2)]
if x[0][0]==x[1][2] and x[0][1]==x[1][1] and x[0][2]==x[1][0]:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-


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

    total = sum(h)

    if k >= n:
        print(0)
    elif k == 0:
        print(total)
    else:
        print(sum(sorted(h[k + 1:], reverse=True)))


if __name__ == '__main__':
    main()
# Judge status: Accepted
n,m = map(int,input().split())
lr = [list(map(int,input().split())) for _ in range(m)]
for i in range(m-1):
  if lr[i][0] > lr[i+1][0]:
    lr[i+1][0] = lr[i][0]
  if lr[i][1] < lr[i+1][1]:
    lr[i+1][1] = lr[i][1]
ans = lr[-1][1] - lr[-1][0] + 1
if ans >= 0:
  print(ans)
else:
  print(0)
# Judge status: Accepted
D = int(input())

if D==25:
    print('Christmas')
    exit()
if D==24:
    print('Christmas Eve')
    exit()
if D==23:
    print('Christmas Eve Eve')
    exit()
if D==22:
    print('Christmas Eve Eve Eve')
    exit()
# Judge status: Accepted
A, B = map(int, input().split())
S = input()

S1 = S[:A]
S2 = S[A]
S3 = S[A+1:]

print("Yes" if S1.isdecimal() and S2 =="-" and S3.isdecimal() else "No")
# Judge status: Accepted
X = int(input())
dp = [False for _ in range(X+1)]
dp[0] = True
for x in range(X+1):
    if x > 99:
        item = [100, 101, 102, 103, 104, 105]
        for i in item:
            if dp[x-i]:
                dp[x] = True
if dp[X]:
    print(1)
else:
    print(0)
# Judge status: Wrong Answer
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N, K, S = map(int, readline().split())
    ans = [S]*K + [S+1]*(N-K)
    print(' '.join(map(str, ans)))

if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
input=sys.stdin.readline

n,d=map(int,input().split())
ans=0
for i in range(n):
    x,y=map(int,input().split())
    if x**2+y**2<=d**2:
        ans+=1

print(ans)
# Judge status: Wrong Answer
a, b = input().split()

num = int(a+b)

for i in range(1, 150):
    if i**2 == num:
        print("Yes")
        break
else:
    print("No")
# Judge status: Accepted
import math
A,B,H,M = map(int,input().split())
kakudoA = (H+M/60)*30
kakudoB = M*6
kakudo = min(abs(kakudoA-kakudoB),360-abs(kakudoA-kakudoB))
henn2 = A**2+B**2-2*A*B*math.cos(math.radians(kakudo))
print(henn2**0.5)
# Judge status: Accepted
s = list(input())
t = list(input())
ns = len(s)
nt = len(t)

flag = False
if ns < nt:
    print('UNRESTORABLE')
    exit()
for i in reversed(range(ns-nt+1)):
    for j in range(nt):
        if s[i:i+nt][j] != '?' and s[i:i+nt][j] != t[j]:
            break
    else:
        s[i:i+nt] = t
        flag = True
        break
if flag:
    ans = ''.join(s).replace('?', 'a')
    print(ans)
else:
    print('UNRESTORABLE')
# Judge status: Wrong Answer
X = int(input())
ans = 'NO'
if X in ['3','5','7']:
  ans = 'YES'
print(ans)
# Judge status: Accepted
n = int(input())
a = []
b = []
for i in range(n):
  aa, bb = map(int, input().split())
  a.append(aa)
  b.append(bb)
a.sort()
b.sort()
ans = 0
if n%2 == 1:
  ans = b[n//2]-a[n//2]+1
else:
  ans = (b[n//2]-a[n//2])+(b[n//2-1]-a[n//2-1])+1
print (ans)
# Judge status: Accepted
n,a,b,c,d = map(int,input().split())
s = input()
for i in range(a,max(c,d)):
    if s[i-1:i+1] == "##":
        print('No')
        exit()
if c < d:
    print('Yes')
    exit()
for i in range(b-1,d):
    if s[i-1:i+2] == "...":
        print("Yes")
        exit()
print('No')
# Judge status: Wrong Answer
n,k=map(int,input().split())
ans=0
while n>k:
  n/=n
  n=int(n)
  ans+=1

print(ans+1)
# Judge status: Accepted
n,a,b = map(int,input().split())
if (b-a)%2==0:
    print(int((b-a)//2))
else:
    print(int(min(a-1,n-b)+1+(b-1-a)//2))
# Judge status: Accepted
a,b=map(int,input().split())
if a<=0 and b>=0:
    print("Zero")
    exit()
if a>0:
    print("Positive")
    exit()
tmp=0
for i in range(a,b+1):
    tmp+=1
if tmp%2==0:
    print("Positive")
else:
    print("Negative")
# Judge status: Accepted
s=list(map(int,list(input())))
from collections import Counter
s+=[0,1]
cs=Counter(s)
print(min(cs.values())*2-2)
# Judge status: Accepted
def main():
    n = int(input())
    count = 0
    res = False
    for _ in range(n):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            count += 1
            if count >= 3:
                res = True
        else:
            count = 0
    if res:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
n, k = input().split()
lists = list(input().split())
lists.sort()
sum_fruit = 0
for i in range(int(k)):
  sum_fruit = sum_fruit + int(lists.pop(-1))
print(str(sum_fruit))
# Judge status: Wrong Answer

s = list(input())

for i in range(1,len(s)+1):
    if i % 2 == 1:
        if s[i-1] == "L":
            print("No")
            exit()
    else:
        if s[i-1] == "R":
            print("Yes")
            exit()
print("Yes")
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a.sort()
b.sort()

for i in range(N):
    if a[i] > b[i]:
        print('No')
        exit()

print('Yes')
# Judge status: Wrong Answer
N=int(input())
li = []

now = 0
ans = -1
count = 0

for n in range(N):
  li.append(int(input()))

for n in range(N):
  if n == 0:
    now = li[0]
    count += 1
  
  now = li[now - 1]
  count += 1

  if now == 2:
    ans = count
    break

print(ans)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
tmp=[a[0]]
ans=1000
for i in range(n):
  if type(tmp[-1])==int:
    if a[i]>tmp[-1]:
      tmp[-1]=[tmp[-1],a[i]]
  else:
    if a[i]<tmp[-1][1]:
      tmp.append(a[i])
    else:
      tmp[-1][1]=a[i]
if type(tmp[-1])==int:
  tmp.pop(-1)
for i in tmp:
  ans+=(ans//i[0])*(i[1]-i[0])
print(ans)
# Judge status: Accepted
from collections import Counter
n=int(input())
A=list(map(int,input().split()))
A=Counter(A)

S=[]
for i,j in A.items():
  if j>=2:
    S.append(i)
S=list(set(S))
S.sort()
if len(S)>=2:
  ans=S[-1]*S[-2]
else:
  print(0)
  exit()

Q=[]

for i,j in A.items():
  if j>=4:
    Q.append(i)
if Q==[]:
  print(ans)
  exit()
print(max(ans, (max(Q))**2))
# Judge status: Wrong Answer
prims = list()

prims.append(2)

base = int(input())

def _is_prim(n):
  global prims
  for p in prims:
    if n % p == 0:
      return False
  
  return True

# 入力値までの素数を作る
for n in range(base):
  if n < 2:
    continue
  elif n % 2 == 0:
    continue
  elif _is_prim(n):
    prims.append(n)

# 作った素数値で。。。
while not _is_prim(base):
  base += 1

print(base)
# Judge status: Accepted
from decimal import Decimal as dec
a, b=map(dec, input().split())
print(int(a*b))
# Judge status: Wrong Answer
a=int(input())
b=0
for i in range(9):
  for k in range(9):
    if (i+1)*(k+1)==a:
      print("Yes")
      break
      b=b+1
if b==81:
  print("No")
# Judge status: Accepted
x,y = [ int(i) for i in input().split(" ") ]

start = 2

a, b = x, y
while a != b:
  temp = abs(a - b)
  a = min(a, b)
  b = temp


ans = x * y / a

print(int(ans))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
k = 1
for i in range(n):
    if a[i] < 0:
        a[i] *= -1
        k *= -1
a.sort()
if k == -1:
    a[0] *= -1
print(sum(a))
# Judge status: Accepted
n=int(input())
s=input()
c=s.count
m=c('R')*c('G')*c('B')
for i in range(n):
  for j in range(i+2,n,2):
    if s[i]!=s[i+j>>1]!=s[j]!=s[i]:
      m-=1
print(m)
# Judge status: Accepted
n = int(input())

while str(n)[0] != str(n)[1] or str(n)[1] != str(n)[2]:
    n+=1

print(n)
# Judge status: Accepted
n,l = map(int,input().split())
a = [i+l for i in range(n)] 

amax = max(a)
amin = min(a)

if a.count(0) == 0:
    if amax > 0:
        a.pop(0)
    else:
        a.pop()
        
print(sum(a))
# Judge status: Accepted
import math
def resolve():
    N, H = list(map(int, input().split()))
    attacks = []
    for i in range(N):
        a, b = list(map(int, input().split()))
        attacks.append((a, 0))
        attacks.append((b, 1))
    attacks = sorted(attacks)
    damage = 0
    cnt = 0
    while damage < H:
        dam, once = attacks.pop()
        damage += dam
        cnt += 1
        if not once:
            cnt += math.ceil((H - damage) / dam)
            break
    print(cnt)



if '__main__' == __name__:
    resolve()
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans=float('inf')
s=sum(a)
res=0
for i in range(n):
  res+=a[i]
  s-=a[i]
  ans=min(ans,abs(s-res))
print(ans)
# Judge status: Accepted
N,K,S=map(int,input().split())
A=[S]*N
for i in range(K,N):
    if S==1:
        A[i]=S+1
    else:
        A[i]=S-1
print(*A)
# Judge status: Wrong Answer
a = 1
a = int(a)
x = a + a**2 + a**3
print(x)
# Judge status: Accepted
A, B, C, D = map(int, input().split())
if A < C:
    if B < D:
        if C < B:
            print(B-C)
        else:
            print(0)
    else:
        print(D-C)
else:
    if D < B:
        if A < D:
            print(D-A)
        else:
            print(0)
    else:
        print(B-A)