peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N, K = map(int, input("").split(" "))

cnt = 0
for i in range(K, N+2):
  start_idx = 0
  end_idx = 0
  #for j in range(i):
  #  start_idx += j
  start_idx = (i-1) * (i)//2
  
  #for j in range(i):
  #  end_idx += (N-j)
  end_idx = (i)*N - start_idx 
    
  #print( end_idx - start_idx+1)
  cnt += (end_idx - start_idx+1)
  cnt %= (10^9+7)
  
  
print(cnt%(10^9+7))
# Judge status: Accepted
n,k=map(int,input().split())
h=[int(input()) for _ in range(n)]
h.sort()
res=[]
for i in range(n-k+1):
    s=h[i+k-1]-h[i]
    res.append(s)
print(min(res))
# Judge status: Accepted
n = int(input())
dv = 10 ** 9 + 7
power = 1
for i in range(1, n + 1):
  power = (power * i) % dv
print(power)
# Judge status: Accepted
s = input()
print(min(abs(int(s[i:i+3]) - 753) for i in range(len(s))))
# Judge status: Accepted
K,X=map(int,input().split())
print('Yes' if K*500>=X else 'No')
# Judge status: Accepted
import numpy as np
n = int(input())
x = list(map(int,input().split()))
x = np.array(x)
ans = 9999999
for i in range(1,101):
    ans = min(ans,sum((x-i)**2))

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

if "##" in s:
	print ("No")
	exit()

if c > d:
	if "..." not in s:
		print ("No")
		exit()
print ("Yes")
# Judge status: Accepted
N = int(input())

count = 0

for i in range(1,N+1):
    if len(str(i)) % 2 != 0:
        count += 1

print(count)
# Judge status: Accepted
from collections import Counter
import math

def div(n):
    prime = []
    tmp = int(math.sqrt(n)) + 1
    
    for num in range(2,tmp):
        while n % num == 0:
            n //= num
            prime.append(num)
    
    if n != 1:
        prime.append(n)
    return prime

n = int(input())
prime_div = Counter(div(n))
ans = 0

for p, ex in prime_div.items():
    k = 1
    while ex >= k:
        ex -= k
        ans += 1
        k += 1

print(ans)
# Judge status: Wrong Answer
X,Y=map(int,input().split())
mod=pow(10,9)+7
m=(2*X-Y)//3
n=(2*Y-X)//3
if  m!=(2*X-Y)/3 or n!=(2*Y-X)/3 or m<=0 or n<=0:
    print(0)

else:
    bunsi = 1
    bunbo = 1
    for i in range(0, n):
        bunsi = (bunsi * (m + 1 + i)) % mod
        bunbo = (bunbo * (1 + i)) % mod
    print((bunsi * pow(bunbo, mod - 2, mod)) % mod)
# Judge status: Accepted
import itertools 
N, M, Q = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(Q)]
ans= 0
AA = [i for i in range(1, M+1)]
A = []
for i in sorted(list(itertools.combinations_with_replacement(AA, N))):
    A.append(i)

for i in A:
    result = 0
    for j in range(Q):
        if i[li[j][1]-1]-i[li[j][0]-1] == li[j][2]:
            result += li[j][3]
    ans = max(ans, result)

print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

left = sum(A)
n = 1
ans = 1
for a in A:
  left -= a
  if a > n or n - a > left:
    print(-1)
    break
  n = min((n - a) * 2, left)
  ans += n
else:
  if n > 0:
    print(-a)
  else:
    print(ans)
# Judge status: Accepted

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

a.sort(reverse = True)

if a[0] == a[1]+a[2]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
s=int(input())
list=[s]
num=2
while num<=1000000:
  if num%2==0:
    list.append(list[num-2]/2)
  else:
    list.append(list[num-2]*3+1)
  if list[num-1] in list[:num-1]:
    break
  num+=1
print(num)
# Judge status: Accepted
def hantei(a):
  if a == 'r':
    return p
  elif a == 's':
    return r
  else:
    return s

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

ans = 0

for i in range(k):
  flag = True
  last1 = 'a'
  last2 = 'b'
  
  for j in range(i, n, k):
    if last1 != t[j]:
      ans += hantei(t[j])
      
    elif last1 == last2 and last1 == t[j]:
      ans += hantei(t[j])
      last1 = 'y'
    
    last2 = last1
    last1 = t[j]
    
    
print(ans)
# Judge status: Accepted
from math import ceil
n, h = map(int, input().split())
cut = set()
throw = []

for _ in range(n):
    a, b = map(int, input().split())
    cut.add(a)
    throw.append(b)

throw.sort(reverse=True)
ans = 0
m_cut = max(cut)

for t in throw:
    if t > m_cut:
        ans += 1
        h -= t
    if h <= 0:
        break

if h > 0:
    ans += ceil(h / m_cut)

print(ans)
# Judge status: Wrong Answer
N=int(input())
A=list(map(int, input().split()))
allsame=True
alleven=True
for a in A:
    if allsame:
        if a!=A[0]:
            allsame=False
    if a%2==1:
        alleven=False

if allsame:
    print(A[0])
elif alleven:
    print(2)
else:
    print(1)
# Judge status: Accepted
x,a,b=map(int,input().split())
if abs(x-a) < abs(x-b):
  print("A")
else:
  print("B")
# Judge status: Accepted
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#A, B, C, D = map(int, input().split())
#L = list(map(int, input().split()))
#S = list(str(input()))
N = int(input())
#S = str(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

id = 0
minN = sys.maxsize
for i in range(N):
  ave = abs(A - (T-(H[i] * 0.006)))
  if minN > ave :
    minN = ave
    id = i
print (id+1)
# Judge status: Accepted
n,k,s = map(int,input().split())

anaume = 10**9
if s == anaume:
    anaume = 10**9-1
lst1 = []


lst1 += [s]*k

lst1 += [anaume]*(n-k)

print(*lst1)
# Judge status: Wrong Answer
from collections import defaultdict
N, M = map(int, input().split())
city_road_nums = defaultdict(int)

for _ in range(M):
    a, b = map(int, input().split())
    city_road_nums[a] += 1
    city_road_nums[b] += 1

for _, value in sorted(city_road_nums.items()):
    print(value)
# Judge status: Accepted
P, Q, R = map(int, input().split())
print(P + Q + R - max(P, Q, R))
# Judge status: Accepted
S = input()


if (S.count("W") != 0 and S.count("E") != 0) and (S.count("N") == 0 and S.count("S") == 0):
    print("Yes")
elif (S.count("N") != 0 and S.count("S") != 0) and (S.count("W") == 0 and S.count("E") == 0):
    print("Yes")
elif S.count("N") != 0 and S.count("S") != 0 and S.count("W") != 0 and S.count("E") != 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
l = sorted(l)
ans = 0
for i in range(n):
	    for j in range(i+1,n):
	    	    bottom  = j
	    	    top = n
	    	    while top -bottom > 1:
	    	    	    middle = (top+bottom)//2
	    	    	    if l[middle] <l[i]+l[j]:
	    	    	    	    bottom = middle
	    	    	    else:
	    	    	    	    top = middle
	    	    ans += bottom - j 
print(ans)
# Judge status: Accepted
N=int(input())
K=int(input())
X=int(input())
Y=int(input())

P=N-K

if P>0:
    print(P*Y+K*X)
else:
    print(N*X)
# Judge status: Wrong Answer
s = input()
t = input()
s = ''.join(sorted(s, reverse=True))
t = ''.join(sorted(t, reverse=True))
if s>=t:
    print('No' , flush=True)
else:
    print('Yes' , flush=True)
# Judge status: Accepted
N = int(input())
if N == 0:
  print(0); exit()
ans = []
while N !=0:
  #print(ans,N)
  if N%2 == 0:
    ans.append(0)
  else:
    N -= 1
    ans.append(1)
  N//=-2
#print(ans)
ans = reversed(ans)
print(''.join([str(n) for n in ans]))
# Judge status: Accepted
input()
cnt = 0
min_value = 200005
for x in map(int, input().split()):
  if min_value > x:
    cnt += 1
  min_value = min(x, min_value)
print(cnt)
# Judge status: Wrong Answer
s = str(input())

if 'a' and 'b' and 'c' in s:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
cnt = 1
ans = 0
for i in range(N):
  if(A[i] < 0):
    cnt = cnt * (-1)
  elif(A[i] == 0):
    cnt = cnt * 0
if(cnt >= 0):
  for i in range(N):
    ans += abs(A[i])
else:
  for i in range(N):
    A[i] = abs(A[i])
  A.sort()
  for i in range(N):
    ans += A[i]
  ans -= A[0] * 2
print(ans)
# Judge status: Accepted
N = int(input())
K = list(map(int, input().split()))
K.sort()
num = len(K)//2
result = K[num] - K[num-1]
print(result)
# Judge status: Wrong Answer
N =int(input())
a = list(map(int, input().split()))
b = sorted(a,reverse=True)
Alice = sum(b[::2])
Bob = sum(b[1::2])
ans = Alice - Bob
print(ans)
print(b)
# Judge status: Accepted
n,m = map(int, input().split())

ans = 0
if n*2 <= m:
  ans += n
  m -= n*2
else:
  ans += m//2
  print(ans)
  exit()
  
if 4 <= m: ans += m//4
print(ans)
# Judge status: Wrong Answer
n = int(input())
a = []
ans = 0
for i in range(n):
  a.append(int(input()))
a.sort()
i = 0
jud = 1
q = [a[0]]
ans = 0
for i in range(1,):
  if(q[-1]==a[i+1]):
    jud += 1
  else:
    if(jud%2==1):
      ans += 1
    jud = 1
print(ans)
# Judge status: Accepted
H, N = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

A_max = 10 ** 4
INF = float('inf')

dp = [INF] * (H + A_max + 1)
dp[0] = 0
for i in range(H):
    if dp[i] == INF:
        continue
    for a, b in AB:
        if dp[i] + b < dp[i + a]:
            dp[i + a] = dp[i] + b
print(min(dp[H:]))
# Judge status: Accepted
a,b,c,d=list(map(int,input().split()))

m = max(a*c, b*d)
m = max(m, a*d)
m = max(m, b*c)

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

diff = [0] * n
for i in range(n):
    d = a[i] - (i + 1)
    diff[i] = d

diff = sorted(diff)
if n % 2 == 1:
    x = diff[n // 2]
else:
    x = (diff[(n // 2) - 1] + diff[n // 2]) // 2

ans = 0
for i in range(n):
    ans += abs(diff[i] - x)

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

c = m - n * 2
if c > 0:
    print(n + c // 4)
else:
    print(m // 2)
# Judge status: Accepted
n=int(input())
A=[];B=[]
for i  in range(n):
    a,b=map(int,input().split())
    A.append(a);B.append(b)
A=A[::-1];B=B[::-1]
now=0
for i in range(n):
    qq=(A[i]+now) % B[i]
    if qq==0:continue
    now+=B[i]-qq
print(now)
# Judge status: Wrong Answer
n = int(input())
a = n // 100
ans = a * 100 + a * 10 + a
print(ans)
# Judge status: Accepted
k = int(input())
l = [0 for x in range(100005)]
for i in range(10):
	l[i] = i+1
temp = 0
i = 9
while i < k:
	if l[temp] % 10 == 9:
		l[i] = l[temp] * 10 + 8
		l[i+1] = l[temp] * 10 + 9 
		i+=2
	elif l[temp] % 10 == 0:
		l[i] = l[temp] * 10
		l[i+1] = l[temp] * 10 + 1
		i+=2
	else:
		l[i] = l[temp] * 10 + l[temp] % 10 - 1
		l[i+1] = l[temp] * 10 + l[temp] % 10
		l[i+2] = l[temp] * 10 + l[temp] % 10 + 1
		i+=3
	temp+=1
print(l[k-1])
# Judge status: Accepted
x,y,z=map(int,input().split())
c=0
for i in range(100000):
    c=z-i*x
    if c<0:
        break
print((i-1)*y)
# Judge status: Accepted
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    N, K = map(int,input().split())
    mod = 10 ** 9 + 7
    ans = 0
    for i in range(K, N + 1 + 1):
        mi = int((i - 1) * i / 2)  #ma、miは i * (10 **100)を無視した上限下限
        ma = i * N - mi
        ans += ma - mi + 1
    print(ans % mod)


if __name__ == "__main__":
    main()
# Judge status: Accepted
S = str(input())
l = len(S)
if l%2 == 1:
    print("No")
else:
    k = 1
    for i in range (l//2):
        if S[2*i] != "h":
            k = 0
        if S [2*i + 1] != "i":
            k = 0
    if k == 0:
        print("No")
    else:
        print("Yes")
# Judge status: Accepted
s = list(input())
t = list(input())

s = sorted(s)
t = sorted(t)
t = t[::-1]

s_ = ''
t_ = ''

for i in s:
    s_ += i
for j in t:
    t_ += j

if s_ < t_:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b = map(int,input().split())
print(max(a+a-1,b+b-1,a+b))
# Judge status: Accepted
a,b,k = map(int,input().split())

if a-k >= 0:
    t = a-k
    a = b
else:
    t = 0
    a = max(0,b+(a-k))
print(t,a)
# Judge status: Accepted
import sys
from math import gcd
from functools import reduce

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


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


def main():
    N, *A = map(int, read().split())

    ans = 0
    l = 1
    for a in A:
        l, l_prev = lcm(l, a), l
        ans = (ans * (l // l_prev) % MOD + l // a) % MOD

    print(ans)
    return


if __name__ == '__main__':
    main()
# Judge status: Accepted
right = input()
q = int(input())
left = ""
flag = 1
for i in range(q) :
    t = input()
    if t == "1" :
        flag ^= 1
        continue
    t, f, c = t.split(" ")
    f = int(f)
    left += c*flag*(2-f)
    right += c*flag*(f-1)
    left += c*(1-flag)*(f-1)
    right += c*(1-flag)*(2-f)
if flag == 1 :
    print(left[::-1]+right)
else :
    print(right[::-1]+left)
# Judge status: Wrong Answer
N = list(map(int,input().split()))
if N[1]*10+N[2] // 4 == 0:
	print("YES")
else:
	print("NO")
# Judge status: Accepted
# B - Ordinary Number

n = int(input())
p = list(int(x) for x in input().split())

ans = 0
for i in range(1, n-1):
    if (p[i-1]<p[i] and p[i]<p[i+1]) or (p[i+1]<p[i] and p[i]<p[i-1]):
        ans += 1

print(ans)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
l = p[:X]+q[:Y]
l.sort()
s = sum(l)
ans = s

for i in range(min(len(l), C)):
    ans = max(ans, s-l[i]+r[i])

print(ans)
# Judge status: Accepted


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    n = int(input())
    a = sorted([int(i) for i in input().split()], reverse=True)

    bob = 0
    alice = 0
    for m in range(len(a)):
        if m % 2 == 0:
            alice += int(a[m])
        else:
            bob += int(a[m])

    print(alice - bob)
# Judge status: Accepted
a,b,c = map(int, input().split())

if (a==b and b == c) or (a != b and b!=c and c!=a):
  print('No')
else:
  print('Yes')
# Judge status: Accepted
a,b,c=map(int,input().split())
f=0
for i in range(a,b+1):
    if not i%c:
        f+=1
print(f)
# Judge status: Accepted
def main():
    N = int(input())
    jobs = []
    time = 0
    for _ in range(N):
        A, B = map(int, input().split())
        jobs.append((A, B))

    jobs = sorted(jobs, key=lambda x: x[1])
    for j in jobs:
        time += j[0]
        if time > j[1]:
            print("No")
            return
        
    else:
        print("Yes")


if __name__ == '__main__':
    main()
# Judge status: Accepted
n = int(input())
a = [list(map(int,input().split())) for i in range(2)]
get = []
for i in range(n):
    get =get+ [sum(a[0][:i+1]) + sum(a[1][i:])]

print(max(get))
# Judge status: Wrong Answer
import collections
n = int(input())
t = input()
s = list(t)

c = collections.Counter(s)
if c[")"] > c["("]:
    for i in range(c[")"]-c["("]):
        print("(",end="")
    print(t)
elif c["("] > c[")"]:
    print(t,end="")
    for i in range(c["("]-c[")"]):
        print(")",end="")
else:
    print(t)
# Judge status: Accepted
# -*- coding: utf-8 -*-
import numpy as np

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

a = np.array(input().split(), dtype='int')

sum_a = np.sum(a)

b = np.sort(a)[::-1]

if b[m-1] >= sum_a / 4 / m:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
#n=int(input())
a,b,c,x,y=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

ans=a*x+b*y

for i in range(1,max(x,y)+1):
    ans=min(ans,2*c*i+a*max(x-i,0)+b*max(y-i,0))
print(ans)
# Judge status: Accepted
N  = int(input())
if N == 0:
    print(0)
else:
    ans = ""
    while N != 0:
        if N%2 == 1:
            ans += "1"
            N -= 1
        else:
            ans += "0"
        N //= -2
    print(ans[::-1])
    # tmp = [1*(i==0) for i in ans][::-1]
    # print("".join(map(str, tmp)))
# Judge status: Accepted
n,k = map(int,input().split())

sunuke = [0]*n

for i in range(k):
    d = int(input())
    a = [int(e)-1 for e in input().split()]
    for j in range(d):
        sunuke[a[j]] += 1

print(sunuke.count(0))
# Judge status: Accepted
n=int(input())
h=list(map(int,input().split()))
b=0
c=0
cm=0
for m in h:
  if m <=b:
    c+=1
    b=m
  else:
    b=m
    if c>cm:
      cm=c
    c=0

print(max(cm,c))
# Judge status: Accepted
n, m = map(int, input().split())
ps = []
for i in range(m):
    p, s = input().split()
    ps.append([int(p), s])
flag = [False for _ in range(n)]
ac = [0 for _ in range(n)]
wa = [0 for _ in range(n)]
i = 0
sumac = 0
sumwa = 0

for i in range(m):
    p = ps[i][0]
    s = ps[i][1]
    if s == "WA" and ac[p - 1] == 0:
        wa[p - 1] += 1
    elif s == "AC" and ac[p - 1] == 0:
        ac[p - 1] += 1
        sumac += 1
        sumwa += wa[p - 1]

print(str(sumac) + " " + str(sumwa))
# Judge status: Accepted
a, b = map(int, input().split())

if (a + b) % 2 == 0:
    print(int((a + b) / 2))
else:
    print(int((a + b) / 2 + 1))
# Judge status: Accepted
from operator import itemgetter
import math

n, h = map(int, input().split())
ab = []
A = 0
B = 1
maxA = 0
for i in range(n):
    ab.append(list(map(int, input().split())))
    maxA = max(maxA, ab[i][A])

ab.sort(key=itemgetter(B), reverse=True)

sumB = 0
for _ab in ab:
    sumB += _ab[B]

ans = 0
damage = 0
i = 0
while damage < h and ans < n:
    damage += max(maxA, ab[ans][B])
    ans += 1

if damage < h:
    ans += math.ceil((h - damage)/maxA)

print(ans)
# Judge status: Accepted
s = input()
 
y1 = [0 if x % 2 ==0 else 1 for x in range(len(s))]
y2 = [0 if x % 2 !=0 else 1 for x in range(len(s))]
 
ans1 = sum([1 for i,j in zip(s,y1) if int(i)==j])
ans2 = sum([1 for i,j in zip(s,y2) if int(i)==j])
print(min([ans1,ans2]))
# Judge status: Accepted
s=input()
s1=s[:len(s)//2]
s2=s[len(s)//2:][::-1]
ans=0
for i in range(len(s)//2):
    if s1[i]!=s2[i]:
        ans+=1
print(ans)
# Judge status: Wrong Answer
import sys
a,b,c,d=input()
op=["-","+"]

for i in op:
  for j in op:
    for k in op:
      o=a+i+b+j+c+k+d
      ans=eval(o)
      if ans==7:
        print(o+"+=7")
        sys.exit()
# Judge status: Wrong Answer

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

if n==1 and m==1:
    print(1)
elif m==1:
    print(m-1)
elif n==1:
    print(m-1)
else:    
    print((n-2)*(m-2))
# Judge status: Accepted
from collections import Counter
MOD = 10**9 + 7
N = int(input())
S = input()
count_si = Counter(S)
ans = 1
for v in count_si.values():
    ans = (ans * (v+1)) % MOD

print((ans-1)%MOD)
# Judge status: Accepted
def main():
    s = input().split('S')
    x = max(map(len,s))
    print(x)

main()
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
if a == b == c:
   print(-1)
   exit()

cnt = 0
while True:
   if a % 2 or b % 2 or c % 2:
      break
   cnt += 1
   next_a = b // 2 + c // 2
   next_b = a // 2 + c // 2
   next_c = a // 2 + b // 2
   a = next_a; b = next_b; c = next_c
print(cnt)
# Judge status: Wrong Answer
K = int(input())
s = input()

if len(s)>K:
    print(s[:K]+"...")
# Judge status: Accepted
s = input()

s1 = int(s[0]+s[1])
s2 = int(s[2]+s[3])
#print(s1, s2)
L=[]

for i in range(1, 13):
    L.append(i)


if s1 not in L and s2 not in L:
    print('NA')
elif s1 in L and s2 not in L:
    print('MMYY')
elif s1 not in L and s2 in L:
    print('YYMM')
else:
    print('AMBIGUOUS')
# Judge status: Accepted
n, x = map(int, input().split())
X = tuple(map(lambda k:abs(int(k)-x), input().split()))
from math import gcd
from functools import reduce
ans = reduce(gcd, X)
print(ans)
# Judge status: Wrong Answer
a, b, c = map(int,input().split())

if a == b and (a == b) != c:
  print("Yes")
elif a == c and (a == c) != b:
  print("Yes")
elif b == c and (b == c) != a:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
memo = {1:0,2:0,4:0}

for a in A:
    if a % 4 == 0:
        memo[4] += 1
    elif a % 2 == 0:
        memo[2] += 1
    else:
        memo[1] += 1

if memo[4] >= (N//2):
    print("Yes")
elif memo[4] >= memo[1]:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n, x, t = map(int, input().split())
y = int(n / x)
if n % x == 0:
  time = y * t
else:
  time = (y + 1) * t

print(time)
# Judge status: Accepted
N=int(input())
List = list(map(int, input().split()))

List.sort()
divideNum=N//2
print(List[divideNum] - List[divideNum-1])
# Judge status: Wrong Answer
a=input().split()
print('YES'if a.count('5')==2 and a.count('7')==1 else'No')
# Judge status: Accepted
a = []
b = []
ans = 'No'

for i in range(3):
    a.extend([int(s) for s in input().split()])
n = int(input())
for j in range(n):
    value = int(input())
    b.append(value)
    if value in a:
        a[a.index(value)] = '*'

if a[0] == a[1] == a[2] or a[3] == a[4] == a[5] or a[6] == a[7] == a[8] or a[0] == a[4] == a[8]:
    ans = 'Yes'
if a[0] == a[3] == a[6] or a[1] == a[4] == a[7] or a[2] == a[5] == a[8] or a[2] == a[4] == a[6]:
    ans = 'Yes'
print(ans)
# Judge status: Accepted
from heapq import heappop, heappush
x,y,a,b,c = map(int, input().split())

aa = sorted(map(int, input().split()), reverse=True)
bb = sorted(map(int, input().split()), reverse=True)
cc = sorted(map(int, input().split()), reverse=True)
dd = []
for i in aa[:x]:
    heappush(dd,i)
for i in bb[:y]:
    heappush(dd, i)

for i in range(c):
    heappush(dd, cc[i])
    heappop(dd)

print(sum(dd))
# Judge status: Accepted
from collections import defaultdict
n=int(input())

s0=list(input())
answer_dic=defaultdict(int)
for s in s0:
  answer_dic[s]+=1

for i in range(n-1):
  si=list(input())
  tmp_dic=defaultdict(int)
  for s in si:
    tmp_dic[s]+=1
    
  for s in answer_dic:
    answer_dic[s]=min(answer_dic[s],tmp_dic[s])
#print(answer_dic)

answer_list=sorted(list(answer_dic.items()))
#print(answer_list)
answer_str=[]
for c,i in answer_list:
  for ii in range(i):
    answer_str.append(c)
    
print("".join(answer_str))
# Judge status: Accepted
N = int(input())
counter =0
for i in range(N):
    D = list(map(int, input().split(' ')))
    if (D[0]==D[1]):
        counter = counter+1
    else:
        counter = 0
    if (counter==3):
        print('Yes')
        exit(0)
print('No')
# Judge status: Accepted
x = int(input())
print(x // 11 * 2 + (x % 11 >= 7) + (x % 11 > 0))
# Judge status: Wrong Answer
d,n=map(int,input().split())
print(n*(100**d))
# Judge status: Wrong Answer
d=int(input())
c=list(map(int,input().split()))
c_days=[0]*26

fir_ans=0
for i in range(d):
    s=list(map(int,input().split()))
    num=max(s)
    fir_ans+=num
    n=s.index(num)
    c_days[n]=i+1
    for l in range(26):
        los=c[l]*(i+1-c_days[l])
        fir_ans-=los
    print(fir_ans)
# Judge status: Accepted
A, B, C, D = map(int, input().split())

import math

A_attack = math.ceil(C / B)
B_attack = math.ceil(A / D)

if A_attack <= B_attack:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a, b, k = map(int, input().split())

if a >= k:
    print(a - k, b)
else:
    print(0, max(0, b - k + a))
# Judge status: Accepted
a, b, c, d = map(int, input().split())
ans = max(abs(a - b), abs(b - c))
ans = min(ans, abs(a - c))

if ans > d:
  print("No")
else:
  print("Yes")
# Judge status: Accepted
s=list(input())
for i in range(len(s)-1):
  if s[i] == s[i+1]:
    print('Bad')
    break
else:
  print('Good')
# Judge status: Wrong Answer
n = int(input())
print(n*(n-1)/2)
# Judge status: Wrong Answer
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    _ = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    D = [b - a for a, b in zip(A, B)]
    neg = 0
    pos = 0
    for d in D:
        if d < 0:
            neg -= d
        else:
            pos += d

    if pos < neg * 2:
        print("No")
    else:
        print("Yes")


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


if __name__ == '__main__':
    S = int(input())

    r = S // 1000000000
    m = S % 1000000000
    print(0, 0, 1000000000, 1, r + 1, 1000000000 - m)
# Judge status: Accepted
n, k = map(int, input().split())
a = [0] * n
b = [0] * n
sum = 0
arr = []
for i in range(n):
    a[i], b[i] = map(int, input().split())
arr_list = list(zip(a, b))
arr_list = sorted(arr_list)
# print(arr_list)
for i in range(n):
    sum += arr_list[i][1]
    # print(sum, arr_list[i])
    if sum >= k:
        answer = arr_list[i][0]
        break

print(answer)