Harryxun/stf_run huggingface dataset:
from collections import deque

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()
q.sort()
r.sort(reverse=True)
xlis = deque(p[len(p)-x:])
ylis = deque(q[len(q)-y:])
r = deque(r)
while True:
    if len(r) == 0:
        break
    xs = xlis.popleft()
    ys = ylis.popleft()
    rm = r.popleft()
    if rm < xs and rm < ys:
        xlis.append(xs)
        ylis.append(ys)
        break
    if xs < ys and xs < rm:
        xlis.append(rm)
        ylis.append(ys)
    elif ys < xs and ys < rm:
        ylis.append(rm)
        xlis.append(xs)
print(sum(xlis)+sum(ylis))

### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
P = sorted(list(map(int, input().split())), reverse = True)
Q = sorted(list(map(int, input().split())), reverse = True)
R = list(map(int, input().split()))

a = sorted(P[:X] + Q[:Y] + R, reverse  = True)
print(sum(a[:(X+Y)]))
#!/usr/bin/env python
# coding: utf-8

# In[1]:


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


# In[40]:


taste = list(range(L, N+L))


# In[41]:


choice = min(list(map(abs, taste)))
taste.remove(choice)
print(sum(taste))



### FIXED CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[67]:


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


# In[68]:


taste = list(range(L, N+L))


# In[69]:


choice_index = list(map(abs, taste)).index(min(list(map(abs, taste))))
del taste[choice_index]
print(sum(taste))


# In[ ]:
#HonestOrDishonest
a,b = input()
if a==b=="H" or a==b=="D":
    print("H")
else:
    print("D")


### FIXED CODE ###

a,b = input().split()
if a==b=="H" or a==b=="D":
    print("H")
else:
    print("D")
N,K = map(int,input().split())

h = [int(i) for i in input().split()]

count =0

for i in range(N):
  if h[i] >= k:
    count += 1
    
    
print(count)
    

### FIXED CODE ###

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

h = [int(i) for i in input().split()]

count =0

for i in range(N):
  if h[i] >= K:
    count += 1
    
    
print(count)
a, b, c = map(int, input().split())
k = int(input())

cnt = 0

while a >= b:
  b *= 2
  cnt += 1

  while b >= c:
    c *= 2
    cnt += 1

    if cnt <= k:
      print("Yes")
      else:
        print("No")

### FIXED CODE ###

import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c = map(int, readline().split())
    k = int(readline())
    cnt = 0

    while a >= b:
        b *= 2
        cnt += 1

    while b >= c:
        c *= 2
        cnt += 1

    if cnt <= k:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()
N = int(input())
A = list(map(int, input().split()))
count=0
while True:
  for i in A:
    if i%2 != 0:
      print(int(count))
      quit()
  
  A = list(map(lambda x: x/2, A))
  #print(A)
  count+=1
  #break
print(int(count))

### FIXED CODE ###

count = 0
for i in str(input()):
  if i == "1":
    count+=1    
print(count)
n = int(input())
l = list(map(int, input().split()))

for i in l[::-1]:
    if i > 1
        print(" ")
    print("%d " %i, end="")
print()


### FIXED CODE ###

#
# 6a
#

def main():
    n = int(input())
    a = list(map(int, input().split()))
    a.reverse()
    print(*a)


if __name__ == '__main__':
    main()
def str_read(s):

    if len(s) == 0:
        return True
    else:
        flag = False
        if s[0:5] in ['dream', 'erase']:
            flag = flag or str_read(s[5:])
        if s[0:6] in ['eraser']:
            flag = flag or str_read(s[6:])
        if s[0:7] in ['dreamer']:
            flag = flag or str_read(s[7:])
        return flag


s = input()

if str_read(s):
    print('YES')
else:
    print('NO')


### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)

def str_read(s):
    while True:
        if len(s) == 0:
            return True
        else:
            if s[0:5] in ['maerd', 'esare']:
                s = s[5:]
            elif s[0:6] in ['resare']:
                s = s[6:]
            elif s[0:7] in ['remaerd']:
                s = s[7:]
            else:
                return False


si = input()
if str_read(si[::-1]):
    print('YES')
else:
    print('NO')
a = int(input())
b = input()
if a%2 == 0:
  print("Yes" if b[:(a/2)] == b[(a/2):] else "No")
else:
  print("No")

### FIXED CODE ###

a = int(input())
b = input()
if a%2 == 0:
  print("Yes" if b[:int(a/2)] == b[int(a/2):] else "No")
else:
  print("No")
N = int(input())
A = [int(x) for x in input().split()]
cnt = 0
for i in A:
    if i == 0:
        pass
    if A[i-1] > A[i]:
        cnt += 1
    else:
        pass
print(cnt)


### FIXED CODE ###

n = int(input())
A = [int(x) for x in input().split()]
maxv = 0
ans = 0
for a in A:
    if maxv > a:
        ans += maxv - a
    else:
        maxv = a
print(ans)
import sys
import string
import itertools
N = int(input())
S = list(input())
array = string.ascii_uppercase

for I in S:
    if array.index(I) + N <= 25:
        print(array[array.index(I) + N],end='')
    else:
        print(array[(array.index(I) + N) - 25],end='')

### FIXED CODE ###

import sys
import string
N = int(input())
S = input()
s = list(S)
array = string.ascii_uppercase

if not ( 0 <= N <= 26 ): sys.exit()
if not ( 1 <= len(s) <= 10**4 ): sys.exit()
if not S.isupper(): sys.exit()

for I in s:
    if array.index(I) + N <= 25:
        print(array[array.index(I) + N],end='')
    else:
        print(array[(array.index(I) + N) - 26],end='')
def maxreturn(t,n,a):
    ma=[0]*3
    if t==n-1:
        for i in range(3):
           ma[i]=a[n-1][i]
    else:
      a[t+1]=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]+a[t+1][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]))
money=int(input().split())
sum=int(input())
money500=500*money
if money500>=sum:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

money,sum=map(int,input().split())
money500=500*money
if money500>=sum:
    print('Yes')
else:
    print('No')
n=input()
x=len(n)
if x==1:
    print(n)

elif x<3:
    print(9)
elif x==3:
    print(9+int(n)-100+1)
elif x<5:
    print(909)
elif x==5:
    print(9+900+int(n)-10000+1)
else:
    print(90909)

### FIXED CODE ###

a,b,c=map(int,input().split())

if a-b>=c:
    print(0)
else:
    print(c-(a-b))
from decimal import Decimal
m,n = map(eval,input().split())
print(Decimal(m)*Decimal(b))

### FIXED CODE ###

from decimal import Decimal
m,n = input().split()
print(int(Decimal(m)*Decimal(n)))
N,M,P = map(int,input().split())
side = [[]for i in range(N)]
for i in range(M):
    a,b,c = map(int,input().split())
    side[a-1].append([b-1,c-P])
node = [-float('inf')]*N
node[0] = 0

def DFS(p,l):
    if node[p] == float('inf'):
        return
    elif p in l:
        node[p] = float('inf')
        for i,v in side[p]:
            DFS(i,l+[p])
    else:
        for i,v in side[p]:
            if node[i] < node[p]+v:
                node[i] = node[p]+v
                DFS(i,l+[p])
    return

DFS(0,[])
if node[-1] == float('inf'):
    print(-1)
else:
    print(max(node[-1],0))

### FIXED CODE ###

N,M,P = map(int,input().split())
edge = []
cost = [-float('inf')]*N
cost[0] = 0
for i in range(M):
    a,b,c = map(int,input().split())
    edge.append([a-1,b-1,c-P])

for i in range(N-1):
    for a,b,c in edge:
        cost[b] = max(cost[b],cost[a]+c)


for a,b,c in edge:
    if cost[b] < cost[a]+c:
        cost[b] = float('inf')


for i in range(N-1):
    for a,b,c in edge:
        cost[b] = max(cost[b],cost[a]+c)

if cost[-1] == float('inf'):
    print(-1)
else:
    print(max(cost[-1],0))
N, u, v = (int(i) for i in input().split())
adj=[]
for i in range(N+1):adj.append([])
for i in range(N-1):
	a,b = map(int,input().split())
	adj[a]+=[b]
	adj[b]+=[a]
	
prof = [0]*(N+1)
haut = [0]*(N+1)
parent = [-1]*(N+1)

def enraciner(sommet):
	for s in adj[sommet]:
		if s!=parent[sommet]:
			parent[s] = sommet
			prof[s] = 1+prof[sommet]
			enraciner(s)
	haut[sommet] = 1
	if parent[sommet]==-1:haut[sommet]+=max(haut[s]for s in adj[sommet] if s!=parent[sommet])
	elif len(adj[sommet]) >1 : haut[sommet]+= max(haut[s]for s in adj[sommet] if s!=parent[sommet])

enraciner(v)

# ~ print("parent",parent)
# ~ print("haut",haut)
# ~ print("prof",prof)

ans = 0

#montee
pu = prof[u]
pv = prof[v]
m = (pu - pv -1)//2
pu-=m
pv+=m
# ~ print("m",m)
ans+=m
for i in range(m):
	u = parent[u]

mx = 0
if len(adj[u])>1:mx = max(haut[i] for i in adj[u] if i!= parent[u])
# ~ print("mx",mx)
ans+= mx

last = (pu-pv)//2
# ~ print("last",last)
ans+=last

print(ans)



### FIXED CODE ###

N, u, v = (int(i) for i in input().split())
adj=[]
for i in range(N+1):adj.append([])
for i in range(N-1):
	a,b = map(int,input().split())
	adj[a]+=[b]
	adj[b]+=[a]

def distances(sommet):
	d = [-1]*(N+1)
	File = [sommet]
	d[sommet] = 0
	while File:
		s = File.pop()
		for x in adj[s]:
			if d[x]==-1:
				d[x] = 1+d[s]
				File.append(x)
	return d


t = distances(u)
a = distances(v)

# ~ print(t)
# ~ print(a)

ans = -1
for i in range(1,N+1):
	if t[i]<a[i]:
		ans = max(ans, a[i]-1)
		
print(ans)
x=int(input())
for i in range(-1000:1000:1):
  for j in range(-1000:1000:1):
    if i**5-j**5==x:
      print(i,j)
      exit()

### FIXED CODE ###

s=input()
if s=="ABC":
  print("ARC")
elif s=="ARC":
  print("ABC")
temp1 = r
temp2 = temp1 * 2
print(temp2)

### FIXED CODE ###

r = int(input())
print(r * r)
import numpy as np
N=int(input())
s=input()
ans = np.array([0]*N)
for n,i in enumerate(s):
    if i=="W":
        ans += np.array([0]*(n+1)+[1]*(N-n-1))
    else:
        ans += np.array([1]*(n+1)+[0]*(N-n-1))
print(min(ans))


### FIXED CODE ###

N=int(input())
s=input()
tmp = 0
for i in s[1:]:
    if i == "E":
        tmp += 1
ans = tmp
for i in range(1,N):
    if s[i] =="W" and s[i-1]=="W":
        tmp += 1
    elif s[i]=="E" and s[i-1]=="E":
        tmp -=1
    ans = min(ans,tmp)
print(ans)
N, X = map(int,input().split()) # 複数の数字を変数に格納
List = list(map(int,input().split())) # 複数の数字をリストに格納

count = 0
point = 0

while point <= X:
    point += List[count]
    count += 1

print(count)

### FIXED CODE ###

N, X = map(int,input().split()) # 複数の数字を変数に格納
List = list(map(int,input().split())) # 複数の数字をリストに格納

count = 1
point = 0

while point <= X and count <= N:
    point += List[count-1]
    if point <= X:
        count += 1

print(count)
n, m, k = map(int, input().split())

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

time = 0
count = 0
for _ in range(n * m):
    if len(a) > 0and len(b)>0:
        if a[-1] < b[-1]:
            time += a[-1]
            a = a[:-1]
        else:
            time += b[-i-1]
            b = b[:-1]
    elif len(a) == 0:
        time += b[-1]
        b = b[:-1]
    elif len(b) == 0:
        time += a[-1]
        a = a[:-1]
    if time > k:
        print(count)
        break
    else:
        count += 1
        


### FIXED CODE ###

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

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

a, b = [0], [0]
for  i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i] + B[i])

ans, j = 0, m
for i in range(n+1):
    if a[i]>k:
        break
    while b[j] > k - a[i]:
        j -= 1
    ans = max(ans, i+j)
print(ans)
import collections
n,cc = raw_input(),collections.Counter(map(int, raw_input().split()))
print max([cc[k] + cc[k+1] + cc[k-1] for k in cc] or [0)


### FIXED CODE ###

import collections
n,cc = raw_input(),collections.Counter(map(int, raw_input().split()))
print max([cc[k] + cc[k+1] + cc[k-1] for k in cc] or [0])
N, X=map(int, input().split())
L=list(map(int, input().split()))
L=[0]+L
 
l=int(0)
counter=int(0)
while l+L[counter]<=X and counter<N+1:
  l+=L[counter]
  counter+=int(1)
  
print(counter)

### FIXED CODE ###

import numpy as np

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

N=temp[0]
X=temp[1]

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

ind=1
while np.sum(L[:ind])<=X and ind<=N:
  ind+=1
  
print(ind)
N, M, L = map(int,input().split())
rd = [[] for _ in range(N+1)]
rc = [[] for _ in range(N+1)]

ZO = [[-1 for i in range(N+1)] for i in range(N+1)]
NP = [[10**9+1 for i in range(N+1)] for i in range(N+1)]

for _ in range(M):
    a,b,c = map(int,input().split())
    if c <= L:
        rd[a].append(b)
        rc[a].append(c)
        rd[b].append(a)
        rc[b].append(c)
        NP[a][b] = 0
        NP[b][a] = 0
        ZO[a][b] = L - c
        ZO[b][a] = L - c

Q = int(input())
S = []
T = []
for _ in range(Q):
    s,t = map(int,input().split())
    S.append(s)
    T.append(t)

for i in range(1,N+1):
    up = True
    while up
        for j in range(1,N+1):
            if ZO[i][j] < 0: continue
            for d,c in zip(rd[j], rc[j]):
                if d == i: continue
                if ZO[i][j] < c:
                    nnp = NP[i][j] + 1
                    nzo = L - c
                else:
                    nnp = NP[i][j]
                    nzo = ZO[i][j] - c
                if NP[i][d] > nnp or NP[i][d] == nnp and ZO[i][d] < nzo:
                    ZO[i][d] = nzo
                    NP[i][d] = nnp
                    up = True

for i in range(Q):
    if NP[S[i]][T[i]] > 10**9:
        print (-1)
    else:
        print(NP[S[i]][T[i]])

### FIXED CODE ###

import sys,queue,math,copy,itertools,bisect,collections,heapq


def wf(d,n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

def main():
    INF = 10**18
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,M,L = LI()
    road = [[INF] * N for _ in range(N)]
    for _ in range(M):
        a,b,c = LI()
        if c <= L:
            road[a-1][b-1] = c
            road[b-1][a-1] = c

    road = wf(road,N)


    gas = [[INF] * N for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if road[i][j] <= L:
                gas[i][j] = 1

    gas = wf(gas,N)

    Q = NI()
    for _ in range(Q):
        s,t = LI()
        if gas[s-1][t-1] == INF:
            print(-1)
        else:
            print(gas[s-1][t-1]-1)


if __name__ == '__main__':
    main()
N, M = map(int, input().split())

graph = [[float('infinity') for _ in range(N + 1)] for _ in range(N + 1)]
for _ in range(M):
    a, b, c = map(int, input().split())
    graph[a][b] = c
    graph[b][c] = c
ans = 0
# 頂点g -> 頂点vへのコストを計算する。直接のpathが最小なら、カウントしない。
# そうでなければ、他の経路があるので、カウントする。
for g in range(1, len(graph)):
    for v in range(1, N + 1):
        if g == v:
            continue
        paths = graph[g]
        direct = paths[v]
        if direct == float('infinity'):
            continue
        min_path = float('infinity')
        for i in range(len(paths)):
            p = paths[i]
            cost = p + graph[i][v]
            if min_path > cost:
                min_path = cost
        if direct > min_path:
            ans += 1
print(ans)


### FIXED CODE ###

from copy import deepcopy
N, M = map(int, input().split())

graph = [[float('infinity')] * N for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    graph[a - 1][b - 1] = c
    graph[b - 1][a - 1] = c
ans = 0
# 頂点g -> eまでの最短経路コストと、その経路を記録する

for i in range(N):
    for j in range(N):
        if i == j:
            graph[i][j] = 0

original = deepcopy(graph)

def warshall_floyd(graph, v):
    for k in range(v):
        for i in range(v):
            for j in range(v):
                graph[i][j] = min(graph[i][j], graph[i][k] + graph[k][j])

warshall_floyd(graph, N)

ans = 0
for i in range(N):
    for j in range(i):
        if original[i][j] != float('infinity') and graph[i][j] != original[i][j]:
            ans += 1
print(ans)
user_input = eval(input())
print((user_input // 500) * 1000 + ((user_input % 500) // 5) * 5)

### FIXED CODE ###

s = input()

if s[2] == s[3] and s[4] == s[5]:
    print("Yes")
else:
    print("No")
s = raw_input()
flag = 0
for i in s:
    if flag == 0 and i == 'C': flag = 1
    elif: flag == 1 and i == 'F': flag = 2

print 'Yes' if flag == 2 else 'No'

### FIXED CODE ###

s = raw_input()
flag = 0
for i in s:
    if flag == 0 and i == 'C': flag = 1
    elif flag == 1 and i == 'F': flag = 2
    else: continue
print 'Yes' if flag == 2 else 'No'
n = int(input())

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

length = sorted(length)
length.append(0)

temp = length[0]
c = 1

unique_n = []
square = []

for i in range(n):
    if temp == length[i+1]:
        c += 1
    
    else:
        if c >= 2 :
            unique_n.append(length[i-1])
        
        if c >= 4:
            square.append(length[i-1])
            
        
        c = 1
        temp = length[i+1]

if len(unique_n) <= 1:
    print(0)

else:
    print(max(unique_n[-1]*unique_n[-2],(square[-1])**2))



### FIXED CODE ###

n = int(input())

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

length = sorted(length)
length.append(0)

temp = length[0]
c = 1

unique_n = []
square = []

for i in range(n):
    if temp == length[i+1]:
        c += 1
    
    else:
        if c >= 2 :
            unique_n.append(length[i-1])
        
        if c >= 4:
            square.append(length[i-1])
            
        
        c = 1
        temp = length[i+1]

if len(unique_n) <= 1:
    print(0)

else:
    if len(square) >= 1:
        print(max(unique_n[-1]*unique_n[-2],(square[-1])**2))
    
    else:
        print(unique_n[-1]*unique_n[-2])
import math
import numpy as np

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

def check():
    x = np.arange(1, N+1)
    tmp = np.floor(A * (x/B) ) - (A * np.floor(x / B))
    #ans = math.floor((A * x)/B) - (A*math.floor(x/b))
    print(int(max(tmp)))


def solve():
    ans = 0
    for x in range(1, N+1):
        tmpans = math.floor((A * x)/B) - (A * math.floor(x/B))
        ans = max(tmpans, ans)
    print(ans)
#solve()
check()


### FIXED CODE ###

import math

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

if N < B:
    x = N
else:
    x = B - 1

def check(x):
    return math.floor((A * x) / B)
            
print(check(x))
def main():
    N = int(input())
    ans = ''

    while N > 0:
        N -= 1
        ans += chr(ord('a') + N % 26).lower()
        N = N // 26
    print(ans[::-1])


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    alpha = input()
    if alpha.isupper():
        print('A')
    else:
        print('a')


if __name__ == "__main__":
    main()
import math, sys
for i in sys.stdin:
    print(math.ceil(float(input())**2/98+1))

### FIXED CODE ###

while True:
    try:
        print(int(float(input())**2/98+2))
    except:
        break
n,k=map(int,input().split())
A=tuple(map(int,input().split()))
s=1
state=[s]
count={}
for i in range(k+1):
    s=A[s-1]
    if s in count:
        start=len(state)
        end=i=1
        print(state[start+(k-start)%(end-start)])
        break
    else:
        count[state[i]]=i
        state.append[s]
else:
    print(s)


### FIXED CODE ###

n,k=map(int,input().split())
A=tuple(map(int,input().split()))
s=1
state=[s]
count={}
for i in range(1,k+1):
    s=A[s-1]
    if s in count:
        start=state.index(s)
        end=len(state)
        print(state[start+(k-start)%(end-start)])
        break
    else:
        count[s]=i
        state.append(s)
        continue
else:
    print(s)
a, b = input().split()
a = int(a)
ib = 0
for i in range(len(b)):
  ib += int(b[len(b)-i-1]) * 10**i

c = int(a*b/100)

print(c)

### FIXED CODE ###

a, b = input().split()

a = int(a)
b = int(float(b)*1000)

print(int((a * b) // 1000))
N = int(input())
P = []
maximum_val = 0
maximum_index = Null

for i in range(N):
  a = int(input())
  P.append(a)
  if a > maximum:
    maximum_val = a
    maximum_index = i
print(sum(P) - P[maximum_index])

### FIXED CODE ###

N = int(input())
P = []
maximum_val = 0
maximum_index = 0

for i in range(N):
	a = int(input())
	P.append(a)
	if a > maximum_val:
		maximum_val = a
		maximum_index = i
print(int(sum(P) - P[maximum_index] / 2))
def main():
    s = input()
    if len(s) % 2 == 1:
        sl = len(s) // 2 + 1
    else:
        sl = len(s) // 2
    ss = s[-sl:sl]
    for i in range(sl, len(s) + 1):
        ss = s[-i - 1] + ss + s[i]
        if ss.count('0') == len(ss) or ss.count('1') == len(ss):
            continue
        print(i)
        return


main()


### FIXED CODE ###

def main():
    s = input()
    i = j = len(s) // 2
    if len(s) % 2 == 0:
        j -= 1
    ss = s[j]
    while len(s) > i and j >= 0 and ss == s[i] and ss == s[j]:
        i += 1
        j -= 1
    print(i)


main()
(a, b, c) = [int(i) for i in input().split

### FIXED CODE ###

( a, b, c) = [int(i) for i in input().split()]
 
count = 0
 
for i in range( a, b+1):
    if c % i == 0:
        count += 1
print( count)
N = int(input())

a_b_lis = [0] * N

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

count = 0
a_b_lis = sorted(a_b_lis, key=lambda x: x[1], X[0])

on_time = True
for item in a_b_lis:
    if item[0] + count <= item[1]:
        count += item[0]
        on_time = True
    else:
        on_time = False

if on_time:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

N = int(input())

a_b_lis = [0] * N

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

count = 0
#print(a_b_lis)
a_b_lis = sorted(a_b_lis, key=lambda x: x[1])

on_time = True
for item in a_b_lis:
    count += item[0]
    if count > item[1]:
        on_time = False
if on_time:
    print('Yes')
else:
    print('No')
N = int(input())
AC=0
WA=0
TLE=0
RE=0
for i in range(0,N):
  j = str(input())
  if j = "AC":
    AC+=1
  elif j = "WA":
    WA+=1
  elif j = "TLE":
    TLE+=1
  else:
    RE+=1
print("AC x {}".format(AC))
print("WA x {}".format(WA))
print("TLE x {}".format(TLE))
print("RE x {}".format(RE))

### FIXED CODE ###

N = int(input())
AC=0
WA=0
TLE=0
RE=0
for i in range(0,N):
  j = str(input())
  if j == "AC":
    AC+=1
  elif j == "WA":
    WA+=1
  elif j == "TLE":
    TLE+=1
  else:
    RE+=1
print("AC x {}".format(AC))
print("WA x {}".format(WA))
print("TLE x {}".format(TLE))
print("RE x {}".format(RE))
N=int(input())
x=0
for i range(1,n+1):
  if (i%2==1):
    x+=1
    
print(x/n)

### FIXED CODE ###

n=int(input())
x=0
for i in range(1,n+1):
  if (i%2==1):
    x+=1
    
print(x/n)
N,Q = map(int, input().split())
S = input()
Query = []
for _ in range(Q):
    l,r = map(int, input().split())
    Query.append([l,r])

A = [0]*8

for i in range(N-2+1):
    if S[i]=="A" and S[i+1]=="C":
        A[i] = 1
s = [0]*(N+1)
for i in range(0,N,1):
    s[i+1] = A[i] + s[i]

for i in range(Q):
    l,r = Query[i]
    print(s[r-1]-s[l-1])



### FIXED CODE ###

N,Q = map(int, input().split())
S = input()
Query = []
for _ in range(Q):
    l,r = map(int, input().split())
    Query.append([l,r])

A = [0]*N

for i in range(N-2+1):
    if S[i]=="A" and S[i+1]=="C":
        A[i] = 1
s = [0]*(N+1)
for i in range(0,N,1):
    s[i+1] = A[i] + s[i]

for i in range(Q):
    l,r = Query[i]
    print(s[r-1]-s[l-1])
n,k=map(int,input().split())

now = 0
a = [_-1 for _ in list(map(int,input().split()))]

cnt = 0
for i in range(k):
    now = a[now]
    if now == 0:
      cnt = i+1
      break
  
now = 0
for i in range(k % cnt):
  now = a[now]

print(now+1)

### FIXED CODE ###

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

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

s = []
od = [-1]*(n+1)
c=1
l=0

v=1

while od[v] == -1:
  od[v] = len(s)
  s.append(v)
  v = a[v-1]

c=len(s)-od[v]
l=od[v]

if k<l:
  print(s[k])
else:
  k-=l
  k%=c
  print(s[l+k])