peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
s=input()
t=input()
ans=float('inf')
for i in range(len(s)-len(t)):
    a=s[i:i+len(t)]
    tans=0
    for i in range(len(t)):
        tans+=(t[i]!=a[i])
    ans=min(ans,tans)
print(ans)
# Judge status: Accepted
N,K,X,Y=map(int, open(0).read().split());print(N*X if N<=K else K*X+(N-K)*Y)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
ans = 9999999
for i in range(n - 1):
    x = sum(a[:i+1])
    y = sum(a[i+1:n])
    ans = min(ans, abs(x - y))
print(ans)
# Judge status: Wrong Answer
n = int(input())
sum = 0
for i in range(n):
  if (i%3)!=0 and (i%5)!=0:
    sum += i
print(sum)
# Judge status: Accepted
n=int(input())

card={}
card_key=set([])

for _ in range(n):
  temp=input()
  if temp in card_key:
    card[temp]+=1
  else:
    card_key.add(temp)
    card[temp]=1

m=int(input())

for _ in range(m):
  temp=input()
  if temp in card_key:
    card[temp]-=1
  else:
    card_key.add(temp)
    card[temp]=-1
#print(card)
result=0
for item in card_key:
  result=max(result,card[item])
print(result)
# Judge status: Accepted
print("Yes" if ''.join(sorted(input())) == "abc" else "No")
# Judge status: Accepted
s = input()
a = s.index("A")
zList = [i for i , name in enumerate(s) if name == "Z"]
z = zList[-1]
print(z - a + 1)
# Judge status: Wrong Answer
time = []
rem = []
for _ in range(5):
    n = int(input())
    time.append(n)
    if n % 10 != 0:
        rem.append(10 - n % 10)

rem.sort()
ans = sum(time) + sum(rem[:4])
# print(time, rem)
print(ans)
# Judge status: Wrong Answer
from collections import Counter

n = int(input())
S = input()
counts = Counter(S)
ans = 1
for count in counts.values():
    ans *= (count + 1)
ans -= 1
print(ans)
# Judge status: Wrong Answer
N,T = map(int, input().split())
m=1001
for i in range(N):
  c,t = map(int, input().split())
  if t<T:m=min(m,c)
print("TLE" if m==1001 else m)
# Judge status: Wrong Answer
def has_duplicates(seq):
    return len(seq) != len(set(seq))

N=int(input())
A=list(map(int,input().split()))
if has_duplicates(A):
    print('No')
else:
    print('Yes')
# Judge status: Accepted
contest = input()
if contest == "ABC":
  print("ARC")
else:
  print("ABC")
# Judge status: Accepted
n, k = map(int, (input().split()))
a = [0] + [int(i) for i in input().split()]

path = [1]
chk = {1}
idx = 1
loop_s = 1
loop_e = n

for i in range(1, n + 1):
    if a[idx] not in chk:
        idx = a[idx]
        path.append(idx)
        chk.add(idx)
    else:
        loop_s = path.index(a[idx])
        loop_e = i
        break

if k <= loop_s:
    print(path[k])
else:
    print(path[loop_s + (k - loop_s) % (loop_e - loop_s)])
# Judge status: Wrong Answer
print('x'for i in range(len(input())))
# Judge status: Accepted
import sys
import math

stdin = sys.stdin

nm = lambda: map(int, stdin.readline().split())

a, b = nm()

n = math.gcd(a,b)

count = 1 # 1
for i in range(2, int(n**(1/2))+1):
    if n%i ==0:
        count +=1
        while n%i == 0:
            n = n/i
    if n ==1:
        break
if n != 1:
    count += 1

print(count)
# Judge status: Accepted
n = int(input())

for i in range(10 ** 5):
    if n == (i * i):
        print(i * i)
        exit()
    if n <= (i * i):
        break


print((i - 1) * (i - 1))
# Judge status: Accepted
s = input()

for i in range(3):
    if s[i] == s[i+1]:
        print('Bad')
        exit()

print('Good')
# Judge status: Wrong Answer
print(sum(sorted(list(map(int,input().split()))[:1])))
# Judge status: Accepted
import math
N = int(input())
print((math.factorial(N)) % (10**9+7))
# Judge status: Wrong Answer
N=int(input())
s=[]
for _ in range(N):
    tmp=list(input())
    s.append(sorted(tmp))
total=0

while (s):
    cnt=0
    comp=s.pop(0)
    for word in (s):
        if(comp==word):
            cnt+=1
            s.remove(comp)
    total+=(1+cnt)*cnt//2


print(total)
# Judge status: Wrong Answer
a,b,c,d = map(int,input().split())
print(["No","Yes"][abs(a-c)<=d or (abs(a-b)<d and abs(b-c)<d)])
# Judge status: Wrong Answer
from math import factorial
n,a,b=map(int,input().split())

total=0
for _ in range(n):
    if not _==a and not _==b:
        x=factorial(n)%(10**9+7)
        y=factorial(_)%(10**9+7)
        z=factorial(n-_)%(10**9+7)
        total+=factorial(n)//(factorial(_)*factorial(n-_))
        
print(total)
# Judge status: Wrong Answer
import math
N,X,T=list(map(int,input().split()))
print(N,X,T)
print(math.ceil(N/X)*T)
# Judge status: Accepted
import sys

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


def main():
    A, B = map(int, readline().split())

    ans = 0
    for n in range(A, B + 1):
        n = str(n)
        if n == n[::-1]:
            ans += 1

    print(ans)
    return


if __name__ == '__main__':
    main()
# Judge status: Accepted
X, Y = map(int, input().split())

ans = 1
n = 1
a = X
while a <= Y:
  a = X * (2 ** n)
  if a <= Y:
    ans += 1
    n += 1
  else:
    break

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

cnt = sum(b) - sum(a)
ans1, ans2 = 0, 0
for ai, bi in zip(a, b):
    ans1 += max(0, ai - bi)
    ans2 += max(0, (bi - ai + 1) // 2)
print('Yes' if max(ans1, ans2) <= cnt else 'No')
# Judge status: Accepted
N = int(input())

s = []
for i in range(N):
    s.append(int(input()))

s.sort()
res = sum(s)

if res%10 != 0:
    print(res)
    exit()
else:
    for i in range(N):
        if s[i]%10 != 0:
            print(res-s[i])
            exit()

print(0)
# Judge status: Accepted
if int(input())>999:
  print("ABD")
else:
  print("ABC")
# Judge status: Accepted
import math
n, d = map(int, input().split())
e = 0
for i in range(n):
  a, b = map(int, input().split())
  c = math.sqrt(a**2 + b**2)
  if(c <= d):
    e += 1
print(e)
# Judge status: Wrong Answer
n=int(input())
l=[]
l.append(2)
l.append(1)
if n==1:
    print(n)
    exit()
for i in range(2,n+1):
    l.append(l[i-2]+l[i-1])
    print(i,l[i])
    if n==i:
        print(l[i])
        exit()
# Judge status: Accepted
s = input()
s = s[::-1]
t = input()
t = t[::-1]
tmp = -1
l = len(t)
ls = len(s)
for i in range(ls-l+1):
    for j in range(l):
        if s[i+j] != t[j] and s[i+j] != '?':
            break
        if j == l-1 and tmp == -1:
            tmp = i
if tmp == -1:
    print("UNRESTORABLE")
    exit()
s = s[:tmp] + t + s[tmp+len(t):]
s = s[::-1]
print(s.replace('?','a'))
# Judge status: Accepted
K, X = map(int, input().split())
array = []

for x in range(X - K + 1, X + K, 1):
    array.append(str(x))
print(" ".join(array))
# Judge status: Accepted
a,b,c= input().split()
x,y,z=(int(a),int(b),int(c))
ans_list =[]
for i in range(min(x,y)):
    
    if x % (i+1) == 0 and y % (i+1) == 0:
        ans_list.append(i+1)
print(ans_list[len(ans_list)-z])
# Judge status: Accepted
n=int(input())
p=list(map(int,input().split()))

def ju(a,b,c):
    return b==(a+b+c)-min(a,b,c)-max(a,b,c)
    

ans=0
for i in range(1,n-1):
    if ju(p[i-1],p[i],p[i+1]):
        ans+=1
print(ans)
# Judge status: Accepted

if __name__ == '__main__':
    b, c = map(int, input().split())

    min = 9999
    for i in range(b):
        a = [int(i) for i in input().split()]
        if  a[1]<= c and a[0] < min:
            min = a[0]

    if min == 9999:
        print("TLE")
    else:
        print(min)
# Judge status: Wrong Answer
s = str.upper(input())

for i in range(len(s)):
    if s[i] == 'A':
        a = i
        break


for i in range(len(s)):
    if s[i] == 'Z':
        b = i + 1
        break
print(b-a)
# Judge status: Accepted
x = int(input())
e=x%1000
r=1000-e
if r==1000:
    print(0)
else:
    print(r)
# Judge status: Accepted
N, M = map(int, input().split())
A = list(map(int, input().split()))

ans = N
for i in range(M):
    ans -= A[i]
    
if ans > -1:
    print(ans)
else:
    print(-1)
# Judge status: Wrong Answer
n, m = map(int, input().split())
li = []
for i in range(int(m**0.5) + 1, 0, -1):
    if m%i==0:
        li.append(i)
for i in li:
    if n <= m//i:
        print(i)
        break
# Judge status: Wrong Answer
n = int(input())

a = n // 4
b = n // 7

print("Yes" if any([(n - 4*i) % 7 == 0 for i in range(a)] + [(n - 7*i) % 4 == 0 for i in range(b)]) else "No")
# Judge status: Wrong Answer
n=int(input())
cnt=(10**n+8**n-2*(9**n))//(10**9+7)
# Judge status: Accepted
n=int(input())
s=list(input())
#i番目の人がリーダーとして
l=[0] #リーダーより左で向きを変える必要がある人数
for i in range(1,n):
  w=l[-1]
  if s[i-1]=='W':
    w+=1
  l.append(w)
r=[0] #リーダーより右で向きを変える必要がある人数
for i in reversed(range(n-1)):
  e=r[-1]
  if s[i+1]=='E':
    e+=1
  r.append(e)
r.reverse()
# print(l)
# print(r)
ans=n
for i in range(n):
  ans=min(r[i]+l[i],ans)
print(ans)
# Judge status: Accepted
a,b=map(int,input().split())
s=0
for i in range(1,b-a+1):
    s+=i
print(s-b)
# Judge status: Wrong Answer
n = int(input())
x = [int(i) for i in input().split()]
x.sort()

ans = 10000
for p in range(1,x[-1]*2):
  sum =0
  for i in range(n):
    sum += (x[i]-p)**2
    
  ans = min(ans,sum)
  
print(ans)
# Judge status: Accepted
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0

a.sort()

for i in a:
  x-=i
  if x>0:
    ans+=1
    continue
  
  elif x==0:
    ans+=1
    break
    
  else:
    break
    
if ans==n:
  if x!=0:
    ans-=1


print(ans)
# Judge status: Accepted
def f(n):
    if n %2 == 0:return n//2
    else: return 3*n+1
s = int(input())
nums = [s] + [0]*10**6
for i in range(1000000):
    if f(nums[i]) in nums:
        print(i+2)
        break
    else:
        nums[i+1] = f(nums[i])
# Judge status: Accepted
def main():
    A, B = map(int, input().split())

    if A % 3 == 0:
        print("Possible")
    elif B % 3 == 0:
        print("Possible")
    elif (A + B) % 3 == 0:
        print("Possible")
    else:
        print("Impossible")
main()
# Judge status: Wrong Answer
PA = list(input())
PB = list(input())
PC = list(input())


t = PA[0]
ans = "A" 
while PA != [] and PB != [] and PC != []:
    if t == "a":
        PA = PA[1:]
        if len(PA): t = PA[0]
        ans = "A"
    elif t == "b":
        PB = PB[1:]
        if len(PB): t = PB[0]
        ans = "B"
    elif t == "c":
        PC = PC[1:]
        if len(PC): t = PC[0]
        ans = "C"

print(ans)
# Judge status: Wrong Answer
n = int(input())
ans = 0
for i in range(n):
    a = i*i
    if a<=n:
        ans = max(ans, a)
print(ans)
# Judge status: Wrong Answer
N, M = [int(i) for i in input().split()]

if N == 1 and M == 1 :
    print(1)
elif N == 1 and M > 1 :
    print(M-2)
elif N > 1 :
    print((N-2) * (M-2))
# Judge status: Wrong Answer
S=input()
K=int(input())
ans=0
mod=5*(10**15)
for i in range(len(S)):
  a=int(S[i])
  if a==1:
    ans+=1
  else:
    ans+=a*mod
  if ans>=K:
    print(a)
    break
# Judge status: Wrong Answer
S = input()

if S[0]=="A" and S[2:-1].count("C")==1:
    if S[1:].replace("C","c").islower:
        print("AC")
else:
    print("WA")
# Judge status: Wrong Answer
s=input()
le=len(s)
lis=[]
for i in range(0,le):
  if s[i]!="A" and s[i]!="" and s[i]!="T" and s[i]!="G":
    lis.append(i)
lo=0
for j in range(0,len(lis)-1):
  if lis[j+1]-lis[j]-1>=lo:
    lo=lis[j+1]-lis[j]-1
print(lo)
# Judge status: Accepted
c = input()
if c in "aeiou":
  print("vowel")
else:
  print("consonant")
# Judge status: Accepted
list = (input().split())
print(len(set(list)))
# Judge status: Accepted
N = int(input())
X = list(map(int,input().split()))
x = sorted(X)
ms = x[N//2-1]
for i in range(N):
    if X[i] > ms:
        print(ms)
    else:
        print(x[N//2])
# Judge status: Accepted
n = int(input())
dic = {}
for _ in range(n):
  a = int(input())
  if a in dic:
    dic[a] += 1
  else:
    dic[a] = 1

ans = 0
for i in dic:
  if dic[i]%2 == 1:
    ans += 1
    
print(ans)
# Judge status: Accepted
sums = sum([int(s) for s in input().split()])

if sums < 22:
  print('win')
else:
  print('bust')
# Judge status: Wrong Answer
a,b = input().split()

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

if a > 0:
    ans = 1
elif a <= 0 and b >= 0:
    ans = 0
else:
    if (b-a+1)%2 == 0:
        ans = 1
    else:
        ans = -1
if ans == 1:
    print("Positive")
elif ans == 0:
    print("Zero")
else:
    print("Negative")
# Judge status: Accepted
S = int(input())
v = 10 ** 9
x = (v - S % v) % v
y = (S + x) // v
print(0, 0, 10 ** 9, 1, x, y)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
ans = 0
for i in range(1, N+1):
    if len(str(i))%2==1:
        ans += 1
print(ans)
# Judge status: Accepted
import sys
readline=sys.stdin.readline

A,B,M=map(int,readline().split())
a=list(map(int,readline().split()))
b=list(map(int,readline().split()))

ans=min(a)+min(b)
for i in range(M):
  x,y,c=map(int,readline().split())
  x,y=x-1,y-1
  if a[x]+b[y]-c<ans:
    ans=a[x]+b[y]-c
  
print(ans)
# Judge status: Accepted
a,b = map(int,input().split())
if a<=8 and b<=8:
	print("Yay!")
else:
	print(":(")
# Judge status: Accepted
S = input()
n = len(S)
tmp = (n - 1) // 2
tmp2 = (n + 3) // 2
S2 = S[:tmp]
S3 = S[tmp2 - 1:]
ans = S == S[::-1] and S2 == S2[::-1] and S3 == S3[::-1]
print('Yes' if ans else 'No')
# Judge status: Accepted
N,K = list(map(int,input().split()))
a = 1
for i in range (1000000000):
    N = N//K
    if N == 0:
        print(a)
        break
    else:
        a = a + 1
# Judge status: Accepted
K, X = map(int, input().split())

ans = [i for i in range(max(X - K + 1, -1000000), min(X + K, 1000000))]

print(*ans)
# Judge status: Wrong Answer
N = int(input())
L = []
D = {}
for _ in range(N):
  k, v = input().split()
  v = int(v)
  L.append((k, v))
  if k not in D.keys():
    D[k] = [v]
  else:
    D[k].append(v)
print(D)
for v in D.values():
  v.sort(reverse=True)
D = sorted(D.items(), key=lambda x: x[0])
print(D)
for d in D:
  for i in range(len(d[1])):
    print(L.index((d[0], d[1][i]))+1)
# Judge status: Accepted
N, K = map(int, input().strip().split(" "))
scores = input().strip().split(" ")

for i in range(K, N):
    if (int(scores[i]) > int(scores[i-K])):
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
A, B, C, D = map(int, input().split())

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

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

def get_num(X):
    num_c = X // C
    num_d = X // D
    common = X // lcm
    return X - (num_c + num_d) + common


print(get_num(B) - get_num(A - 1))
# Judge status: Accepted
n = int(input())

sum = 0
for i in range(1, n + 1):
    if i % 2 != 0:
        sum += 1

print(sum / n)
# Judge status: Accepted
N = int(input())
A = []
for i in range(N):
    x, l = map(int, input().split())
    A.append([x+l, x-l])
A.sort()
ans = 1
check1 = A[0]
for i in range(1, N):
    check2 = A[i]
    if check1[0] <= check2[1]:
        ans += 1
        check1 = check2
print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())
print('Yes' if c-a-b > 0 and 4*a*b < (c-a-b) ** 2 else 'No' )
# Judge status: Wrong Answer
n = int(input())
s = input()

t = s[:n//2 - 1]
if n % 2 == 0:
    # flg = t in s[n//2:]
    if t == s[n//2:]:
        print("Yes")
    else:
        print("No")
else:
    print("No")
# Judge status: Accepted
n = int(input())
ans = ":("
for i in range(1,50001):
    if (i*1.08)//1 == n:
        ans = i
        break
print(ans)
# Judge status: Accepted
s = input()
ans = 0
tmp = ''
c = ''
for i in s:
    c += i 
    if c!=tmp:
        ans +=1
        tmp = c
        c=''
print(ans)
# Judge status: Wrong Answer
import sys
N = int(sys.stdin.readline().rstrip())
A = list(map(int, sys.stdin.readline().rstrip().split()))
B = list(map(int, sys.stdin.readline().rstrip().split()))
if N == 1:
    if A[0] <= B[0]:
        print("Yes")
    else:
        print("No")
diff = [a - b for a, b in zip(A, B)]
minus = 0
plus = 0
for d in diff:
    if d < 0:
        minus += d
    else:
        plus += d
if plus * 2 + minus > 0:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
n,k=map(int,input().split())
a=list(map(int,input().split()))

visited = [-1]*(n+1)
pos = 1
visited[pos] = 0
loop = 0
root=[1]
for i in range(1,n+1):
  pos = a[pos-1]
  if visited[pos] == -1:
    visited[pos] = i
    root.append(pos)
  else:
    loop = i - visited[pos]
    mae = visited[pos]
    break
if k < mae:
  print(root[k])
else:
  index=(k-mae)%loop
  print(root[index+mae])
# Judge status: Accepted
#161_D
import heapq
que = [i for i in range(1, 10)]
cnt = 0
k = int(input())

for i in range(k):
    x = heapq.heappop(que)
    if (x % 10) > 0:
        heapq.heappush(que, x * 10 + (x % 10) - 1)
    if (x % 10) < 9:
        heapq.heappush(que, x * 10 + (x % 10) + 1)
    heapq.heappush(que, x * 10 + (x % 10))
    
print(x)
# Judge status: Wrong Answer
d,t,s=list(map(int,input().split()))
if t*s>d:
  print("Yes")
  exit()
print("No")
# Judge status: Accepted
h,a = input().split()
h = int(h)
a = int(a)

ans = h//a
if(h%a!=0):
    ans+=1
print(ans)
# Judge status: Accepted
n=int(input())
a=[[""]*3 for ii in range(n)]
for ii in range(n):
  s=input().split()
  #print(s)
  a[ii][0]=s[0]
  a[ii][1]=100-int(s[1])
  a[ii][2]=ii
a.sort()
for ii in range(n):
  print(a[ii][2]+1)
# Judge status: Wrong Answer
n,m = map(int,input().split())
if n >= m :
  print(0)
else:
  ls=[int(s) for s in input().split()]
  ls.sort()
  d=[ls[i+1]-ls[i] for i in range(m-1)]
  d.sort()
  print(sum(d[:n-m]))
# Judge status: Wrong Answer
mod = 10**9+7

N = int(raw_input())

num0 = [0]*61
num1 = [0]*61

A = map(int, raw_input().split())

for i in range(N):
    ai = A[i]
    for j in range(61):
        if ai & 1 << j:
            num1[j] += 1
        else:
            num0[j] += 1
ans = 0

for i in range(61):
    ans = ans + num0[i]*num1[i]*2**i % mod

print int(ans)
# Judge status: Accepted
S = input()
for i in range(len(S)):
    c = S[i]
    if (i % 2 == 0 and c == 'L'):
        print('No')
        exit(0)
    if (i % 2 == 1 and c == 'R'):
        print('No')
        exit(0)
print('Yes')
# Judge status: Wrong Answer
from collections import Counter

n = int(input())

s = [input() for _ in range(n)]

c = Counter(s)

csort = sorted(c.items(), key=lambda x:x[1],reverse=True)

maxc = csort[0][1]

for s,v in csort:
    if v == maxc:
        print(s)
# 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
s = int(input())
MOD = int(1e9 + 7)

def c(k, r):
    n = 1
    for i in range(r):
        n = n * (k - i) * pow(i + 1, MOD - 2, MOD) % MOD
    return n

ans = sum([c(s - 3 * i + i - 1, i - 1) for i in range(1, s // 3 + 1)]) % MOD
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
n = 0
F = 0

while 1:
    #すべてが偶数か確認
    for i in range(N):
        if A[i] % 2 == 0:
            continue
        else:
            F = 1
    
    if F == 1 : break 

    for i in range(N):
        A[i] = A[i]/2
    n += 1


print(n)
# Judge status: Accepted
from itertools import product
A,B,C,D =list(input())
for z in product(("+","-"),repeat=3):
    if eval(A+z[0]+B+z[1]+C+z[2]+D)==7:
        print(A+z[0]+B+z[1]+C+z[2]+D+"=7")
        break
# Judge status: Accepted
S = input()
lQ = list(range(int(input())))
def main(S):
  T = True
  L = ''
  R = ''
  for i in lQ:
    q = list(input().split())
    if q[0]=='1':
      T = not(T)
    else:
      if (T and q[1]=='1') or (not(T) and q[1]=='2'):
        L += q[2]
      elif (T and q[1]=='2') or (not(T) and q[1]=='1'):
        R += q[2]
  SS = L[::-1] + S + R
  if T:
    print(SS)
  else:
    print(SS[::-1])
main(S)
# Judge status: Wrong Answer
S = input("")
if len(S)<=1000:
    if S.endswith(('o', 'ch', 's', 'sh', 'x', 'z')):
        print(S.lower()+"es")
    else:
        print(S.lower()+"s")
# Judge status: Accepted
from heapq import heappop, heappush, heapify

N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for _ in range(N)]
AB.sort(reverse=True)

que = []
ans = 0
for d in range(1, M + 1):
    while AB and AB[-1][0] <= d:
        heappush(que, -AB.pop()[1])
    if que:
        ans += heappop(que)
print(-ans)
# Judge status: Accepted
#!/usr/bin/env python

n, k = map(int, input().split())
a = [0 for _ in range(n)]
b = [0 for _ in range(n)]
for i in range(n):
    a[i], b[i] = map(int, input().split())

d = {}
for i in range(n):
    if a[i] not in d:
        d[a[i]] = b[i]
    else:
        d[a[i]] += b[i]

d = sorted(d.items(), key=lambda x: x[0])

tmp = 0 
for i in range(len(d)):
    tmp += d[i][1]
    if tmp >= k:
        print(d[i][0])
        exit()
# Judge status: Wrong Answer
N,X,Y=map(int,input().split())

d=[[0 for _ in range(N)] for _ in range(N)]
ans=[0]*N
for i in range(N):
    for j in range(i+1,N):
        d[i][j]=min(abs(i-j),abs(X-1-i)+abs(Y-1-j)+1,abs(X-1-j)+abs(Y-1-i)+1)
        ans[d[i][j]-1]+=1

for o in range(N-1):
    print(ans[o+1])
# Judge status: Accepted
n, x = map(int, input().split())
l = list(map(int, input().split()))
distance = 0
bounds = 1
for i in range(n): 
    distance += l[i]
    if distance <= x:
      bounds += 1
    else:
      break
print(bounds)
# Judge status: Accepted
s = input()
x = 0
y = 0
s = list(set(s))
for i in range(len(s)):
    if s[i] == 'N':
        y += 1
    elif s[i] == 'W':
        x -= 1
    elif s[i] == 'S':
        y -= 1
    else:
        x += 1
print('Yes' if x == 0 and y == 0 else 'No')
# Judge status: Accepted
N=int(input())
S=list(map(int,input().replace('#','1').replace('.','0')))

cum=[0]
for i in range(N):
  cum.append(cum[-1]+S[i])
  
ans=10**20
for i in range(N+1):
  b = cum[i]
  w = N-i-(cum[-1]-cum[i])
  ans = min(ans,b+w)
  
print(ans)
# Judge status: Wrong Answer
import re

S=input()

if re.match('k([a-z]*)eyence',S):
  print('YES')
elif re.match('ke([a-z]*)yence',S):
  print('YES')
elif re.match('key([a-z]*)ence',S):
  print('YES')
elif re.match('keye([a-z]*)nce',S):
  print('YES')
elif re.match('keyen([a-z]*)ce',S):
  print('YES')
elif re.match('keyenc([a-z]*)e',S):
  print('YES')
else:
  print('NO')
# Judge status: Accepted
N = int(input())

f = N
while True:
  x = str(f)
  if all(x[i] == x[0] for i in range(len(x))):
    print(x)
    exit()
  else:
    f += 1
# Judge status: Accepted
N = int(input())
A = map(int,input().split())
ans = 0
ans2 = 0
mod = 10 ** 9 + 7
for a in A:
    ans += a
    ans2 += a**2

print(((ans **2 - ans2)//2)%mod)
# Judge status: Accepted
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

a, b = rm()
print(':(' if a > 8 or b > 8 else 'Yay!')
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
cnt_odd=0
cnt_even=0
cnt_4=0
for i in range(n):
  if a[i]%2!=0:
    cnt_odd+=1
  else:
    cnt_even+=1
    if a[i]%4==0:
      cnt_4+=1
if cnt_even-cnt_4==0:
  if cnt_4+1>=cnt_odd:
    print("Yes")
  else:
    print("No")
else:
  if cnt_4>=cnt_odd:
    print("Yes")
  else:
    print("No")
# Judge status: Wrong Answer
n = int(input())
ans = ''
while not n == 0:
  ans += chr(ord('a') + n % 26 - 1)
  n //= 26
print(ans[::-1])
# Judge status: Accepted
def main():
    x,y=map(int, input().split()) 

    all_crane = x * 2
    all_turtle = x * 4

    if y >= all_crane and y <= all_turtle and y % 2 == 0:
        print("Yes")
    else:
        print('No')

if __name__ == "__main__":
    main()
# Judge status: Accepted
def iparse():
    return list(map(int, input().split()))

n, k = iparse()
d = iparse()

for i in range(n, 5000000):
    tmp = i
    f = True
    while tmp > 0:
        x = tmp % 10
        if x in d:
            f = False
            break
        tmp //= 10
    if f:
        print(i)
        exit()
# Judge status: Accepted
from sys import maxint

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

costs = [maxint] * N 
costs[0] = 0
for n in range(N) :
  for k in range(1,min(K, N-n-1)+1) : 
    costs[n+k] = min(costs[n+k], costs[n] + abs(stones[n]-stones[n+k]))
  
print costs[-1]
# Judge status: Accepted
a,b,c,k=map(int,input().split())
if a>=k:
	print(k)
elif a+b>=k:
	print(a)
else:
	k-=(a+b)
	print(a-k)