Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-
s = str(input())
q = int(input())
l = []
for i in range(q):
  qy = input().split()
  l.append(qy)
  
st = s
count = 0
for i in range(q):
  k = l[i][0]
  if(k == '1'):
    count += 1
  elif(k == '2'):
    c = count
    d = int(l[i][1])
    e = i[i][2]
    if((c + d) % 2 == 1):
      st = e + st
    elif((c + d) % 2 == 0):
      st = st + e

if(count % 2 == 1):
  st = st[::-1]
      
print(st)

### FIXED CODE ###

# -*- coding: utf-8 -*-
s = str(input())
q = int(input())  
st = s
sth = s
sth2 = ""
stm = ""
stm2 = ""
count = 0
flagh = 0
flagm = 0
for i in range(q):
  k = input().split()
  if(k[0] == '1'):
    count = (count + 1) % 2
  else:
    c = count - 2
    d = int(k[1]) 
    e = k[2]
    if(c + d != 0):
      sth = e + sth
      if(len(sth) > 5000 and flagh == 0):
        flagh = 1
        sth2 = sth
        sth = ""
    else:
      stm = stm + e
      if(len(stm) > 5000 and flagm == 0):
        flagm = 1
        stm2 = stm
        stm = ""
      

st = sth + sth2 + stm2 + stm
if(count == 1):
  st = st[::-1]
  
print(st)
import numpy as np
(h,w,m),*e=[[*map(int,i.split())]for i in open(0)]
a=np.zeros((h,w),int)
for y,x in e:a[y-1][x-1]=1
y=np.sum(a,axis=1)
x=np.sum(a,axis=0)
mx,my=max(x),max(y)
b=sum(y[i-1]+x[j-1]==mx+my for i,j in e)
b-=len(np.where(y==my)[0])*len(np.where(x==mx)[0])
print(mx+my-(b>=0))

### FIXED CODE ###

(h,w,m),*e=[[*map(int,i.split())]for i in open(0)]
a,b=[0]*h,[0]*w
for y,x in e:
    a[y-1]+=1
    b[x-1]+=1
ans=max(a)+max(b)
c=a.count(max(a))*b.count(max(b))-sum(a[y-1]+b[x-1]==ans for y,x in e)
print(ans-(c<=0))
#!/usr/bin/env python3
#ABC140 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
s = list(input())
l = []
cnt = 1
for i in range(1,n):
    if s[i-1] != s[i]:
        l.append((cnt,i-1))
        cnt = 0
    cnt += 1
l.append((cnt,i))
m = len(l)
if m == 1:
    print(n-1)
    quit()
h = []
for i in range(m):
    if i == 0:
        heappush(h,(-(l[i][0]+l[i+1][0]),l[i][0],l[i][1]))
    elif i == m-1:
        heappush(h,(-(l[i][0] + l[i-1][0]),l[i][0],l[i][1]))
    else:
        heappush(h,(-(l[i][0] + l[i-1][0] + l[i+1][0]),l[i][0],l[i][1]))
for _ in range(min(k,len(h))):
    l,i,j = heappop(h)
    if s[j] ==  'R':
        s[j-i+1:j+1] = 'L'*i
    else:
        s[j-i+1:j+1] = 'R'*i
    t = s.count('R')
    if t == 0 or t == n:
        print(n-1)
        quit()
ans = 0
for i in range(n):
    if s[i] == 'L':
        if i > 0:
            if s[i-1] == 'L':
                ans += 1
    else:
        if i < n-1:
            if s[i+1] == 'R':
                ans += 1
print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
#ABC140 D

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
s = input()
x,y = 0,0
for i in range(1,n):
    if s[i] == s[i-1]:
        x += 1
    else:
        y += 1
print(x + min(y,2*k))
A,B = (int(i) for i in input().split())

import math

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


print(lcm(A,B))

### FIXED CODE ###

A,B = (int(i) for i in input().split())

import fractions

def lcm(a, b):
    #return a * b // math.gcd(a, b)
    return  a*b // fractions.gcd(a, b)

print(lcm(A,B))
n = int(input())
a = [int(input()) for i in range(n)]

for i in range(n):
  if i == 0:
    ans = max(a[1:n])
  elif i == n-1:
    ans = max(a[0:n-1])
  else:
    ans = max(a[0:i],a[i+1:n])
  print(ans)

### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]

sot = sorted(a,reverse = True)
ans1 = sot[0]
ans2 = sot[1]

for i in a:
  if i != ans1:
    print(ans1)
  else:
    print(ans2)
import numpy as np
import scipy.sparse.csgraph as sg

H, W = [int(a) for a in input().split()]
ss = []
for _ in range(H):
    ss.append(input())

g = np.zeros((H*W,H*W))

v_edges = [((i,j), (i,j+1)) for i in range(H) for j in range(W-1) if ss[i][j] == "." and ss[i][j+1] == "."]
h_edges = [((i,j), (i+1,j)) for i in range(H-1) for j in range(W) if ss[i][j] == "." and ss[i+1][j] == "."]

for (si,sj), (di,dj) in v_edges + h_edges:
    g[si*W+sj][di*W+dj] = 1
    g[di*W+dj][si*W+sj] = 1

r = sg.dijkstra(g)
score = r[0,H*W-1]

#print(r)
#print(ss) 

ss_ = "".join(ss)
num = len([0 for c in ss_ if c == '.'])
#print(num)
#print(score)
print("%d" % (num - (score+1)))




### FIXED CODE ###

import numpy as np
import scipy as sp
import scipy.sparse.csgraph as sg

H, W = [int(a) for a in input().split()]
ss = []
for _ in range(H):
    ss.append(input())

g = np.zeros((H*W,H*W))

v_edges = [((i,j), (i,j+1)) for i in range(H) for j in range(W-1) if ss[i][j] == "." and ss[i][j+1] == "."]
h_edges = [((i,j), (i+1,j)) for i in range(H-1) for j in range(W) if ss[i][j] == "." and ss[i+1][j] == "."]

for (si,sj), (di,dj) in v_edges + h_edges:
    g[si*W+sj][di*W+dj] = 1
    g[di*W+dj][si*W+sj] = 1

r = sg.dijkstra(g, indices=[0,H*W-1])
score = r[0,H*W-1]

if sp.isinf(score):
    print(-1)
    exit(0)
else:
    #print(r)
    #print(ss) 

    ss_ = "".join(ss)
    num = len([0 for c in ss_ if c == '.'])
    #print(num)
    #print(score)
    print("%d" % (num - (score+1)))
a, b = map(int, input().split())
if( (a * b) % 2 == 0):
  print "Even"
else:
  print "Odd"

### FIXED CODE ###

a, b = map(int, input().split())
if a*b % 2 == 0:
    print("Even")
else:
    print("Odd")
from collections import deque

n = int(input())
a = [list(map(lambda x:int(x)-1,input().split())) + [-1] for _ in range(n)] + [0]

l,day = [0]*n,[0]*n

que = deque([i for i in range(n)])

while que:
    u = que.popleft()
    v = a[u][l[u]]
    if a[v][l[v]] == u:
        day[u] = max(day[u],day[v]) + 1
        day[v] = day[u]
        l[u] += 1
        l[v] += 1
        que.append(u)
        que.append(v)

if any(x != n-1 for x in l):
    print(-1)
    exit()

print(max(day))

### FIXED CODE ###

import time
start = time.time()
n = int(input())
a = [list(map(int,input().split())) for _ in range(n)]
s = [0 for i in range(n)] #それぞれ何試合目か
ans = 0
need = n*(n-1)//2
while need:
    c = [0 for i in range(n)] #今日試合をするかどうか
    ans += 1
    for first in range(n):
        if c[first] == 0 and s[first] < n-1:
            second = a[first][s[first]]-1 # firstが対戦したい相手
            second_num = s[second] # #secondの対戦番号
            if c[second] == 0 and a[second][second_num]-1 == first:
                c[first] = 1
                c[second] = 1
                s[first] += 1
                s[second] += 1
                need -= 1
    if sum(c) == 0:
        print(-1)
        exit()
    now = time.time()-start
    if now > 1.8:
        print(n*(n-1)//2)
        exit()
print(ans)
n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]

ans = []

for i in range(2 ** n):
    jud = [0]*(m-1)
    money = 0
    for j in range(n):
        if (i >> j) & 1:
            money += ca[j][0]
            for k in range(m-1):
                jud[k] += ca[j][k]
    if min(jud) >= x:
        ans.append(money)

if not ans:
    print(-1)
else:
    print(min(ans))

### FIXED CODE ###

n, m, x = map(int, input().split())
ca = [list(map(int, input().split())) for _ in range(n)]

ans = []

for i in range(2 ** n):
    jud = [0]*m
    money = 0
    for j in range(n):
        if (i >> j) & 1:
            money += ca[j][0]
            for k in range(m):
                jud[k] += ca[j][k+1]
    if min(jud) >= x:
        ans.append(money)

if not ans:
    print(-1)
else:
    print(min(ans))
import sys

def inserttionSort(x_list,y):
  for i in range(1, y):
    v = x_list[i]
    j = i - 1
    while j >= 0 and x_list[j] > v:
      x_list[j + 1] = x_list[j]
      j--
    x_list[j+1] = v
  for k in range(0, y):
    print x_list[k],
  print " "



y = sys.stdin.readline()
y = int(y)

x = sys.stdin.readline()

x_list = x.split(" ")

for i in range(y):
  x_list[i] = int(x_list[i])

for i in range(1, y):

### FIXED CODE ###

import sys

def insertionSort(x_list,y):
  for i in range(1, y):
    v = x_list[i]
    j = i - 1
    while j >= 0 and x_list[j] > v:
      x_list[j + 1] = x_list[j]
      j -= 1
    x_list[j+1] = v
    for k in range(0, y):
      print x_list[k],
    print

y = sys.stdin.readline()
y = int(y)

x = sys.stdin.readline()

x_list = x.split(" ")

for i in range(y):
  x_list[i] = int(x_list[i])

for k in range(0, y):
  print x_list[k],
print

insertionSort(x_list, y)
# -*- coding: utf-8 -*-
from collections import deque
import sys
sys.setrecursionlimit(100000)


if __name__ == '__main__':

    n, m = [int(s) for s in input().split(" ")]
    M = [set() for j in range(n)]
    for _ in range(m):
        u, v = [int(s) for s in input().split(" ")]
        M[u].add(v)
        M[v].add(u)
        
    color = [0] * n
    def dfs(u, c):  # depth-first search
        color[u] = c
        for v in M[u]:
            if color[v] == 0:
                dfs(v, c)
    
    c = 1
    for u in range(n):
        if color[u] == 0:
            dfs(u, c)
            c += 1
    
    l = int(input())
    for _ in range(l):
        p, q = [int(s) for s in input().split(" ")]
        if color[p] == color[q]:
            print("yes")
        else:
            print("no")



### FIXED CODE ###

# -*- coding: utf-8 -*-
from collections import deque
import sys
sys.setrecursionlimit(200000)


if __name__ == '__main__':

    n, m = [int(s) for s in input().split(" ")]
    M = [set() for j in range(n)]
    for _ in range(m):
        u, v = [int(s) for s in input().split(" ")]
        M[u].add(v)
        M[v].add(u)
        
    color = [0] * n
    def dfs(u, c):  # depth-first search
        color[u] = c
        for v in M[u]:
            if color[v] == 0:
                dfs(v, c)
    
    c = 1
    for u in range(n):
        if color[u] == 0:
            dfs(u, c)
            c += 1
    
    l = int(input())
    for _ in range(l):
        p, q = [int(s) for s in input().split(" ")]
        if color[p] == color[q]:
            print("yes")
        else:
            print("no")
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
n = ""
for i in range(29):
    Atmp = list(map(lambda x:x%pow(2,i+1),A))
    Btmp = list(map(lambda x:x%pow(2,i+1),B))
    Btmp.sort()
    T = pow(2,i)
    nn = 0
    for a in Atmp:
        j = bisect.bisect_right(Btmp,T-a)
        k = bisect.bisect_right(Btmp,2*T-a)-1
        if j<=k:
            nn += k-j+1
        j = bisect.bisect_right(Btmp,3*T-a)
        k = bisect.bisect_right(Btmp,4*T-a)-1
        if j<=k:
            nn += k-j+1
    nn = nn%2
    n = str(nn)+n
nn = 0
for i in range(29):
    if n[-i-1] == "1":
        nn += pow(2,i)
print(nn)

### FIXED CODE ###

import numpy as np
N = int(input())
A = np.int32(input().split())
B = np.int32(input().split())

ans_arr = np.zeros(29,int)
for k in range(29):
    a = np.sort(A%(2**(k+1)))
    b = B%(2**(k+1))
    ans_arr[k] += np.sum(np.searchsorted(a,2**(k+1)-1-b,side='right')-np.searchsorted(a,2**k-b))
    ans_arr[k] += np.sum(N-np.searchsorted(a,3*2**k-b))
    ans_arr[k] %= 2

ans = 0
for k in range(29):
    ans += ans_arr[k]*2**k

print(ans)
n=int(input())
a=list(map(int,input().split()))
ans = 1
for i in range(n):
  ans *= a[i]
  if 10**18 < int(ans):
    print(-1)
  else:
  	print(ans)


### FIXED CODE ###

a,b = map(int,input().split())
print(a*b)
s=input()
k=int(input())
it=int(-1)
sum=int(0)
for i in s:
    if i == '1':
        sum+=1
    else:
        it=i

if k<=int(it):
    print(1)
elif it == int(-1):
    print(1)
else:
    print(s[it])

### FIXED CODE ###

s=input()
k=int(input())
it=int(-1)
sum=int(0)
for i in s:
    if i == '1':
        sum+=1
    else:
        it=sum
        break

if k<=int(it):
    print(1)
elif it == int(-1):
    print(1)
else:
    nex=int(it)+int(1)
    print(s[it:nex])
import math

d, m = map(int,input().split())
print(math.pow(100,d)*n)

### FIXED CODE ###

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

x = 100**d

ans = x*n
if n == 100:
  ans += x
print(ans)
def select_pivot(a, i, j):
    n = j - i + 1
    if n < 3:
        return i
    else:
        b = [a[i], a[(i+j)/2], a[j]]
        b.sort()
        t = b[1]
        if a[i] == t:
            return i
        elif a[j] == t:
            return j
        else:
            return (i+j) / 2
 
def quick_sort2(a, i, j):
    if j <= i:
        pass
    else:
        pivot = select_pivot(a, i, j); s = i
        x = a[pivot]
        a[pivot], a[j] = a[j], a[pivot]
        for k in range(i, j):
            if a[k] <= x:
                a[s], a[k] = a[k], a[s]
                s += 1
        a[j], a[s] = a[s], a[j]
        quick_sort2(a, i, s-1)
        quick_sort2(a, s+1, j)


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

quick_sort2(A, 0, n - 1)

print " ".join(map(str, A))

### FIXED CODE ###

n = int(raw_input())
x = map(int,raw_input().split())
x.sort()
for i in xrange(n):
	print x[i],
n,m = [int(i) for i in input().split()]
A=[]
b=[]
s=0
for i in range(m):
	A.append([int(j) for j in input().split()])

for i in range(m):
	b.append(int(input()))

for i in range(n):
	
	for j in range(m):
		s+=A[i][j]*b[j]
print(s)

### FIXED CODE ###

a,b=map(int,input().split())
A=[]
B=[]
for i in range(a):
	A.append([int(j) for j in input().split()])

for i in range(b):
	B.append(int(input()))


for i in range(a):
	s=0
	for j in range(b):
		s+=A[i][j]*B[j]
	print(s)
N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()

#同じカードを書き換える操作は無駄なため、cが降順となるようにソート
BC.sort(key=lambda x:-x[1])

for B,C in BC:
  print(B,C)
  for j in range(i,min(N,i + B)):
    if A[j] < C:
      A[j] = C
  #B枚分先を飛ばす BCはCに関して降順のため問題ない
  i = i + B

print(sum(A))

### FIXED CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
BC = [list(map(int,input().split())) for _ in range(M)]

A.sort()

#同じカードを書き換える操作は無駄なため、cが降順となるようにソート
BC.sort(key=lambda x:-x[1])

i = 0

for B,C in BC:
  for j in range(i,min(N,i + B)):
    if A[j] < C:
      A[j] = C
  #B枚分先を飛ばす BCはCに関して降順のため問題ない
  i = i + B

print(sum(A))
x = int(input())
a = x//3600
b = x%3600//60
c = x%3600%60
print(a+':'+b+':'+c)

### FIXED CODE ###

x = int(input())
print(x//3600,':',(x%3600)//60,':',(x%3600)%60,sep='')
import bisect

n, d, a = map(int, input().split())
xh = []
for i in range(n):
    xh.append(list(map(int, input().split())))
xh.sort()
count = 0
min_x = 0
x = [xh[i][0] for i in range(n)]
while sum([xh[i][1] for i in range(n)]):
    place = xh[min_x][0] + d
    num = (xh[min_x][1] - 1) // a + 1
    count += num
    edge = bisect.bisect(x, place + d)
    for i in range(min_x, edge):
        new_h = max(0, xh[i][1] - a * num)
        if new_h == 0:
            min_x += 1
        xh[i][1] = new_h
print(count)

### FIXED CODE ###

import bisect

n, d, a = map(int, input().split())
xh = []
for i in range(n):
    xh.append(list(map(int, input().split())))
xh.sort()
x = [xh[i][0] for i in range(n)]
h = [xh[i][1] for i in range(n)]
count = 0
min_x = 0
acm = [0] * (n + 1)
dif = [0] * (n + 1)
while min_x < n:
    place = x[min_x] + d
    num = (h[min_x] - acm[min_x + 1] - 1) // a + 1
    count += num
    dif[min_x] += num
    dif[bisect.bisect(x, place + d)] -= num
    for i in range(min_x, bisect.bisect(x, place + d)):
        acm[i + 1] = acm[i] + dif[i] * a
        if acm[i + 1] >= h[i]:
            min_x += 1
            continue
        else:
            break
print(count)
a = list(map(int, input().split()))

if a in 1 and a in 9 and a in 7 and a in 4:
  print(YES)
else:
  print(NO)


### FIXED CODE ###

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

if 1 in a and 9 in a and 7 in a and 4 in a:
  print("YES")
else:
  print("NO")
a,b,c,d,e,f=map(int,input().split())
a,b=a*100,b*100

DP=[-1 for _ in range(f+1)]
DP[a],DP[b]=0,0
for i in range(f):
    if DP[i]==-1:continue
    for j in a,b:
        if i+j<=f:DP[i+j]=DP[i]
    for j in c,d:
        if i+j<=f and 100*(DP[i]+j)/(i+j)<=100*e/(100+e):
            DP[i+j]=DP[i]+j

ans,water=0,[a,0]
for i,j in enumerate(DP):
    if i==0 or j==-1:continue
    if ans<100*j/i:
        ans=100*j/i
        water=[i,j]
print(*water)

### FIXED CODE ###

inf=10**8
a,b,c,d,e,f=map(int,input().split())
a,b=100*a,100*b
DP=[inf]*(f+max(a,b)+1)
DP[a],DP[b]=0,0

for i in range(f+1):
    if DP[i]!=inf:
        DP[i+a]=DP[i]
        DP[i+b]=DP[i]
        for j in c,d:
            if 100*(DP[i]+j)/(i+j)<=100*e/(100+e):
                DP[i+j]=max(DP[i],DP[i]+j)

ans,index=0,[a,0]
for i in range(f+1):
    if DP[i]!=inf:
        if ans<100*DP[i]/i:
            ans=100*DP[i]/i
            index=[i,DP[i]]

print(*index)
h, n = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(n)]

#dp[i][j] := i番目までの物でjの価値を実現するのに必要な最小コスト
dp = [[0] * 1001 for _ in range(n+1)]
for j in range(1, 1001):
    dp[0][j] = float("inf")

for i in range(n):
    for j in range(1001):
        if j < items[i][0]:
            dp[i+1][j] = min(dp[i][j], items[i][1])
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j-items[i][0]] + items[i][1])

print(dp[n][h])

### FIXED CODE ###

h, n = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(n)]

#dp[i][j] := i番目までの物でjの価値を実現するのに必要な最小コスト
dp = [[0] * (h+1) for _ in range(n+1)]
for j in range(1, h+1):
    dp[0][j] = float("inf")

for i in range(n):
    for j in range(h+1):
        if j < items[i][0]:
            dp[i+1][j] = min(dp[i][j], items[i][1])
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j-items[i][0]] + items[i][1])

print(dp[n][h])
n = input()

if n >= 30:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = int(input())

if n >= 30:
    print("Yes")
else:
    print("No")
print('ABC'(int(input())<1200)or'ARC')

### FIXED CODE ###

print('ABC'*(int(input())<1200)or'ARC')
import math
from functools import reduce
def gcbd_list(numbers):
    return reduce(math.gcd, numbers)
def get_primenumber(number):
    prime_list = []
    search_list = list(range(2,number+1))
    while search_list[0] <= math.sqrt(number):
        head_num = search_list.pop(0)
        prime_list.append(head_num)
        search_list = [num for num in search_list if num % head_num != 0]
    prime_list.extend(search_list)
    return prime_list
N = int(input())
A = list(map(int, input().split()))
P = get_primenumber(max(A))
D = [False] * (10**6+1)
c = True
for i in range(N):
    for j in range(len(P)):
        if A[i] % P[j] == 0:
            if D[j]:
                c = False
            D[j] = True
if c:
    print('pairwise coprime')
    exit()
if gcbd_list(A) == 1:
    print('setwise coprime')
    exit()
print('not coprime')


### FIXED CODE ###

import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
N = int(input())
A = list(map(int, input().split()))
M = [0] * (10**6+1)
for i in A:
    M[i] += 1
if gcd_list(A) > 1:
    print('not coprime')
    exit()
for i in range(2,10**6+1):
    c = 0
    for j in range(i,10**6+1,i):
        c += M[j]
    if c > 1:
        print('setwise coprime')
        exit()
print('pairwise coprime')
n, k = map(int, input().split()) 
a_list = list(map(int, input().split())) 

rireki = [0] * (n+1)
curr_c = 1
rireki[1] = 0
for i in range(k):
    next_c = a_list[curr_c-1]
    # print(i, curr_c, next_c)
    if next_c == 1:
        no_loop_count = 0
        loop_cnt = i + 1
        break
    elif rireki[next_c] == 0:
        rireki[next_c] = i+1
    else:
        # print(next_c)
        no_loop_count = rireki[next_c] -1
        loop_cnt = i - no_loop_count
        break
    curr_c = next_c

# print(rireki)

if k <= no_loop_count:
    ans = rireki.index(k)
else:
    # print('k',k)
    # print('no', no_loop_count)
    # print('lo', loop_cnt)
    ind = (k-1-no_loop_count)%loop_cnt +1
    rireki_fix = [i-no_loop_count for i in rireki]
    # print(ind, 'ind')
    ans = rireki_fix.index(ind)
    # print(rireki_fix)

print(ans)

### FIXED CODE ###

def main():
    n, k = map(int, input().split()) 
    al = list(map(int, input().split())) 
    city_l = [1]
    city_s = set([1])
    loop_city_l = []
    curr_city = 1
    cnt = 0
    for i in range(1,k+1):
        next_c = al[curr_city-1]
        if next_c in city_s:
            cnt = i
            first_city = city_l.index(next_c)
            loop_city_l = city_l[first_city:]
            break
        else:
            city_s.add(next_c)
            city_l.append(next_c)
        curr_city = next_c
    else:
        print(curr_city)
        return

    # print(loop_city_l)
    remained = k-cnt
    last_pos = remained%len(loop_city_l)
    print(loop_city_l[last_pos])

if __name__ == "__main__":
    main()
if (V-W)*T >= A-B:
	print('Yes')
else
	print('No')

### FIXED CODE ###

A,V = list(map(int, input().split()))
B,W = list(map(int, input().split()))
T = int(input())
print("YES" if (V-W) * T >= abs(B-A) else "NO")
S=str(input())
S_list=list(S)

Q=int(input())

q=[]
right=[]
left=[]

rev=1

for i in range(Q):
    q.append(input().split())
    if q[i][0]=="1":
        rev=rev*(-1)
    elif q[i][0]=="2":
        if q[i][1]=="1":
            if rev==1:
                right.insert(0,q[i][2])
            else:
                left.append(q[i][2])
        elif q[i][1]=="2":
            if rev==1:
                left.append(q[i][2])
            else:
                right.insert(0,q[i][2])
if rev==1:
    S_list.append(left)
    S_list.insert(0,right)
else:
    S_list.reverse()
    S_list.append(left)
    S_list.insert(0,right)
    
S=''.join(S_list)
print(S)

### FIXED CODE ###

S=str(input())
S_list=list(S)

Q=int(input())

q=[]
right=[]
left=[]

rev=1

for i in range(Q):
    q.append(input().split())
    if q[i][0]=="1":
        rev=rev*(-1)
    elif q[i][0]=="2":
        if q[i][1]=="1":
            if rev==1:
                right.append(q[i][2])
            else:
                left.append(q[i][2])
        elif q[i][1]=="2":
            if rev==1:
                left.append(q[i][2])
            else:
                right.append(q[i][2])
right.reverse()
if rev==1:
    S_list=right+S_list+left
else:
    S_list=right+S_list+left
    S_list.reverse()

S=''.join(S_list)
print(S)
S = str(input())
ans = []
for i in range(len(S)):
    for k in range(i+1,len(S)):
        if all("ACGT".count(c)==1 for c in S[i:k]):
            ans.append(len(S[i:k]))
print(max(ans))

### FIXED CODE ###

S = str(input())
ans = [0]
for i in range(len(S)):
    for k in range(i,len(S)):
        if all("ACGT".count(c)==1 for c in S[i:k+1]):
            ans.append(len(S[i:k+1]))
print(max(ans))
[n,x]=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]
sum=int(0)
count = int(0)

while count<n && sum+l[count]<=x:
    sum=sum+l[count]
    count=count+1

print(count+1)


### FIXED CODE ###

[n,x]=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]
sum=int(0)
count = int(0)

while count<n and sum+l[count]<=x:
    sum=sum+l[count]
    count=count+1

print(count+1)