Harryxun/stf_run huggingface dataset:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 10 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
A = list(map(int, input().split()))
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

# calc prime
MAX = 10 ** 3 + 5
is_prime = [True] * (MAX)
is_prime[0] = False
is_prime[1] = False
i = 2
primes = []
while i < MAX:
    if is_prime[i]:
        for j in range(i+i, MAX, i):
            is_prime[j] = False
        primes.append(i)
    i += 1

cnt = defaultdict(int)
for a in A:
    x = a
    for p in primes:
        if x % p == 0:
            cnt[p] += 1
        while x > 1 and x % p == 0:
            x //= p
        if x <= 1:
            break
    if x > 1:
        cnt[x] += 1
if max(cnt.values()) <= 1:
    print('pairwise coprime')
    exit()

setwise = False
g = A[0]
for a in A:
    g = gcd(g, a)
if g == 1:
    setwise = True

if setwise:
    print('setwise coprime')
if not setwise:
    print('not coprime')

### FIXED CODE ###

import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 10 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
A = list(map(int, input().split()))
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

# calc prime
MAX = 10 ** 6 + 2
is_prime = [True] * (MAX + 1)
is_prime[0] = False
is_prime[1] = False
i = 2
primes = []
cnt_a = Counter(A)
if cnt_a[1] == N:
    print('pairwise coprime')
    exit()
cnt_facts = defaultdict(int)
while i < MAX:
    if is_prime[i]:
        if cnt_a[i]:
            cnt_facts[i] += cnt_a[i]
        for j in range(i+i, MAX, i):
            is_prime[j] = False
            if cnt_a[j]:
                cnt_facts[i] += cnt_a[j]
        primes.append(i)
    i += 1
if cnt_facts and max(cnt_facts.values()) <= 1:
    print('pairwise coprime')
    exit()
setwise = False
g = A[0]
for a in A:
    g = gcd(g, a)
if g == 1:
    setwise = True

if setwise:
    print('setwise coprime')
if not setwise:
    print('not coprime')
a,b,c,k= map(int,input.split(' '))
if a>=k:
  print(k)
elif a+b>=k:
  print(a)
elif a+b+c>=k:
  print(a-(k-a-b))

### FIXED CODE ###

a,b,c,k= map(int,input().split())
if a>=k:
  print(k)
elif a+b>=k:
  print(a)
elif a+b+c>=k:
  print(a-(k-a-b))
import math
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
for i in reversed(range(int(math.pow(P,(1/N)))+2)):
    tmp=math.pow(i,N)
    if P==1:
        ans=1
        break
    if N==1:
        ans=P
        break
    if P%tmp==0:
        ans=i
        break
print(ans)

### FIXED CODE ###

import math
from sys import stdin
N,P=[int(x) for x in stdin.readline().rstrip().split()]
for i in reversed(range(round(math.pow(P,(1/N)))+1)):
    tmp=math.pow(i,N)
    if P==1:
        ans=1
        break
    if N==1:
        ans=P
        break
    if P%tmp==0:
        ans=i
        break
print(ans)
#E-all you can eat
n,t=map(int,input().split())
how=0
T=how+t-1
uselist=[list(map(int,input().split())) for i in range(n)]
lists=sorted(uselist,key=lambda x: (-x[1],x[0]))
print(lists)
j=0
def search():
    global T
    global ans
    ans=0
    T=T
    flag2=True
    flag=False
    for i in range(n):
        print(lists[i])
        if lists[i][0]<=T:
            ans+=lists[i][1]
            T-=lists[i][0]
            lists[i]=[10**9,10**9]
            flag=True
            break
        else:
            continue
    if not flag:
        flag2=False
        j=ans

    if T>=0 and flag2:
        return search()
search()
print(j)

### FIXED CODE ###

#ALL you can eat 
#0-1 なっぷサック問題をとく* N

#要領T-1のバックと　大きさがA,価値がBの荷物がNこずつある。　この時これらを使って価値をT-1をこえない範囲で最大にする方法を考える。


#dpl[N][V]=1番目からN番目までの荷物を用いて、重さをVにする上で実現可能な価値の最大値
N,T=map(int,input().split())
d=[]
for i in range(N):
    a,b=map(int,input().split())
    d.append((a,b))
dpl=[[0 for i in range(T)] for j in range(N+1)]
for i in range(N):
    weight,value=d[i]
    for j in range(T):
        if j>=weight:
            dpl[i+1][j]=max(dpl[i][j],dpl[i][j-weight]+value)
        else:
            dpl[i+1][j]=dpl[i][j]

            
#dpr[K][V]=K番目からN番目までの荷物を用いて、重さをVにする上で実現可能な価値の最大値
dpr=[[0 for i in range(T)] for j in range(N+2)]
for i in range(1,N+1):
    weight,value=d[-i]
    for j in range(T):
        if j>=weight:
            dpr[N+1-i][j]=max(dpr[N+2-i][j],dpr[N+2-i][j-weight]+value)
        else:
            dpr[N+1-i][j]=dpr[N+2-i][j]

#dpr[K][V]=K番目からN番目までの荷物を用いて重さをV以下にする上で実現可能な価値の最大値にする
for i in range(1,N+1):
    for j in range(1,T):
        dpr[i][j]=max(dpr[i][j],dpr[i][j-1])
    
ans=0
for i in range(N):
    sub=d[i][1]
    #i+1番目の物を使わない
    add=0
    for j in range(T):
        add=max(add,dpl[i][j]+dpr[i+2][T-1-j])
    sub+=add
    ans=max(sub,ans)
print(ans)
import numpy as np
N,D = map(int, input().split())
#複数行
xy = [list(map(int, input().split())) for i in range(N)]
sum=0
for x,y in zip(xy):
    if np.sqrt(x*x+y*y)<=D:
        sum+=1
print(sum)

### FIXED CODE ###

#------------------------------------------------------
import numpy as np
N,D = map(int, input().split())
#複数行
xy_list = [list(map(int, input().split())) for i in range(N)]
sum=0
for xy in xy_list:
    if np.sqrt(xy[0]*xy[0]+xy[1]*xy[1])<=D:
        sum+=1
print(sum)
a, b, c, d = map(int, input().split())
if a+b > c+d:
  print("Left")
elif a+b < c+d:
  print("Right")
wlaw:
  print("Balanced")

### FIXED CODE ###

a, b, c, d = map(int, input().split())
if a+b > c+d:
  print("Left")
elif a+b < c+d:
  print("Right")
else:
  print("Balanced")
N, K = map(int, input().split())
A = [int(n)-1 for n in input().split()]

def step(pos, root, cnt, k, lst):
    if cnt == k:
        return pos
    if pos in root:
        return lst[root[pos] + (K-root[pos]) % (cnt-root[pos])]
    root[pos] = cnt
    lst.append(pos)
    cnt += 1
    return step(A[pos], root, cnt, k, lst)

print(step(0, {}, 0, K, []) + 1)


### FIXED CODE ###

N, K = map(int, input().split())
A = [int(n)-1 for n in input().split()]

pos, root, cnt, lst = 0, {}, 0, []
while True:
    if cnt == K:
        ans = pos + 1
        break
    if pos in root:
        ans = lst[root[pos] + (K-root[pos]) % (cnt-root[pos])] + 1
        break
    root[pos] = cnt
    lst.append(pos)
    cnt += 1
    pos = A[pos]

print(ans)
S = list(input())
S1 = []
S2 = []
if i in range(len(S)):
    if i % 2 ==0 :
        S1.append('0')
        S2.append('0')
    else :
        S1.append('1')
        S2.append('2')
min1 = 0
for i in range(len(S)):
    if S[i] != S1[i]:
        min1 += 1
min2 = 0
for i in range(len(S)):
    if S[i] != S1[i]:
        min2 += 1 
print(min(min1,min2))

### FIXED CODE ###

S = input()
S1 = ''
S2 = ''
for i in range(len(S)):
    if i % 2 ==0 :
        S1 += '0'
        S2 += '1'
    else :
        S1 += '1'
        S2 += '0'
min1 = 0
for i in range(len(S)):
    if S[i] != S1[i]:
        min1 += 1
min2 = 0
for i in range(len(S)):
    if S[i] != S2[i]:
        min2 += 1 
print(min(min1,min2))
import math

r = int(input())

s = 2 * math.pi * r
circle = math.pi * r**2

print("%.7f %.7f" %(s,circle))

### FIXED CODE ###

import math

r = input()
print('%f %f'% (math.pi *r *r , 2 * math.pi * r))
"""
~~ Author : Bhaskar
~~ Dated : 13~06~2020
"""

import sys
from bisect import *
from math import floor, sqrt, ceil, factorial as F, gcd, pi
from itertools import chain, combinations, permutations, accumulate
from collections import Counter, defaultdict, OrderedDict, deque

INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize) - 1
mod = 1000000007
ch = "abcdefghijklmnopqrstuvwxyz"
lcm = lambda a, b: (a * b) // gcd(a, b)
setbit = lambda x: bin(x)[2:].count("1")
INT = lambda type: type(sys.stdin.readline()) if type in [int, float] else type(sys.stdin.readline()).replace("\n", "")
ARRAY = lambda type: list(map(type, sys.stdin.readline().split()))
NUMS = lambda type: map(type, sys.stdin.readline().split())


def solve():

    n = INT(int)
    a = ARRAY(int)
    if 0 in a:
        print(0)
    else:
        p = 1
        ok = False
        for i in a:
            a *= i
            if a > 10**18:
                ok = True
                break
        print(a if not ok else -1)



if __name__ == "__main__":
    try:
        sys.stdin = open("input.txt", "r")
    except:
        pass
    solve()


### FIXED CODE ###

"""
~~ Author : Bhaskar
~~ Dated : 31~05~2020
"""

import sys
from bisect import *
from math import floor,sqrt,ceil,factorial as F,gcd,pi
from itertools import chain,combinations,permutations,accumulate
from collections import Counter,defaultdict,OrderedDict,deque
from array import array
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
mod = 10**18
lcm = lambda a,b : (a*b)//gcd(a,b)
setbit = lambda x : bin(x)[2:].count("1")

def solve():
    n = int(sys.stdin.readline())
    a = list(map(int,sys.stdin.readline().split()))
    ans =  1
    flag = False
    for i in a:
        ans *= i
        # print(ans)
        if ans > mod:
            flag = True
            break
    if 0 in a:
        print(0)
    else:
        if not flag:
            print(ans)
        else:
            print(-1)

if __name__ == "__main__":
    solve()
a = int(input())
b = int(input())
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")
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]

BC.sort(key=lambda x: x[1], reverse=True)
s = 0
for B, C in BC:
    A.sort()
    mn = A[0]
    if mn >= C:
        s += sum(A)
        break
    if B > len(A):
        B = len(A)
    if A[B - 1] <= C:
        s += B * C
        A = A[B:]
    else:
        a, b = 0, B
        while a + 1 < b:
            i = a + (b - a) // 2
            if A[i] >= C:
                b = i
            else:
                a = i
        A[:b] = [C] * b
        s += sum(A)
        break

print(s)

### FIXED CODE ###

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

BC.sort(key=lambda x: x[1], reverse=True)
A.sort()
l, r = 0, N
for B, C in BC:
    if A[l] >= C:
        break
    a, b = l, r
    if A[r - 1] >= C:
        while a + 1 < b:
            i = a + (b - a) // 2
            if A[i] >= C:
                b = i
            else:
                a = i
        r = b
    n = B + l
    if n > r:
        n = r
        B = n - l
    if n <= b:
        A[l:n] = [C] * B
        l = n
    else:
        A[l:b] = [C] * B
        l = b
    if l == r:
        break

print(sum(A))
r = map(int, input())
print(r**2)

### FIXED CODE ###

r = int(input())
s = 1
for i in range(2):
  s = s * r
print(s)
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
a = 0
sum = 0
for i in range(N):
  	A = list(map(int, input().split()))
    for j in range(M):
        sum += A[j] * B[j]
    if sum + C > 0:
        a += 1
        sum = 0
    else :
        sum = 0
print(a)

### FIXED CODE ###

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]
a = 0
sum = 0
for i in range(N):
    for j in range(M):
        sum += A[i][j] * B[j]
    if sum + C > 0:
        a += 1
        sum = 0
    else :
        sum = 0
print(a)
N = int(input())
res = 0
for _ in range(N)
	r, l = map(int, input().split())
  	res += l - r + 1
print(res)

### FIXED CODE ###

N = int(input())
res = 0
for _ in range(N):
    r, l = map(int, input().split())
    res += l - r + 1
print(res)
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
M = 10**9 + 7
A = sorted(A, key=abs, reverse=1)
# 負の数になる場合
if max(A) < 0:
    result = 1
    for i in range(K):
        result = result * A[-i-1] % M
    print(result)
    exit()

minimum_minus_id = K
minimum_plus_id = K
minus_count = 0

for i in range(K):
    if A[i] < 0:
        minus_count += 1
        minimum_minus_id = i
    else:
        minimum_plus_id = i
result = 1

if minus_count%2 ==1:
    # 一番小さい負の数を正の数にするか、一番小さい正の数を負の数にするか
    second_minus_id = N
    second_plus_id = N

    for i in range(K, N):
        if A[i] >= 0:
            second_plus_id = i
            break
    for i in range(K, N):
        if A[i] < 0:
            second_minus_id = i
            break
    if second_minus_id == N:
        A[minimum_minus_id] = A[second_plus_id]
    else:
        if A[minimum_minus_id] * A[second_minus_id ] > A[minimum_plus_id] * A[second_plus_id]:
            A[minimum_plus_id] = A[second_minus_id]
        else:
            A[minimum_minus_id] = A[second_plus_id]

for i in range(K):
    result = result * A[i] % M
print(result)

### FIXED CODE ###

n, k = map(int, input().split())
a_list = list(map(int, input().split()))
mod = 10**9+7
a_list.sort()
ans = 1
if k % 2 == 1 and a_list[-1] < 0:
    for i in range(k):
        ans *= a_list[n - 1 - i]
        ans %= mod
else:
    l = 0
    r = -1
    mlt1 = a_list[0] * a_list[1]
    mlt2 = a_list[-2] * a_list[-1]
    count = 0
    while True:
        if count == k:
            break
        elif count == k - 1:
            ans *= a_list[r] % mod
            ans %= mod
            break
        if mlt1 >= mlt2:
            ans *= mlt1 % mod
            l += 2
            count += 2
            if l <= n - 2:
                mlt1 = a_list[l + 1] * a_list[l]
        else:
            ans *= a_list[r] % mod
            r -= 1
            count += 1
            if r >= - n + 1:
                mlt2 = a_list[r - 1] * a_list[r]
        ans %= mod
print(ans)
import math
X, Y = map(int, input().split())  # 目的地

# dp = [[0]*(X+1) for _ in range(Y+1)]
#
# dp[2][1] = 1
# dp[1][2] = 1
#
# for i in range(Y+1):  # iがy座標にあたる
#     for j in range(X+1):  # jがx座標にあたる
#         if i < 2 or j < 2:
#             continue
#         dp[i][j] += dp[i-1][j-2] + dp[i-2][j-1]
#
# print(dp[Y][X])

# dp_x = [0]*(X+1)
# dp_x[1] = 1
# dp_x[2] = 2
# for i in range(3, X+1):  # Xの動きだけ専門
#     dp_x[i] += dp_x[i-1] + dp_x[i-2]
#
# dp_y = [0]*(Y+1)
# dp_y[1] = 1
# dp_y[2] = 2
# for i in range(3, Y+1):
#     dp_y[i] += dp_y[i-1] + dp_y[i-2]
# print(dp_x[X-1]*dp_y[Y-1]%1000000007)
# # print(dp_x)
# # print(dp_y)

#
# dp = [[0]*4 for _ in range(4)]
# for

if (X+Y)%3 != 0 or not(min(X, Y)*2 >= max(X, Y)):
    print(0)
    exit()
dp = [0]*(min(X, Y)+1)
dp[1] = 1
dp[2] = 2
for i in range(3, len(dp)):
    dp[i] += (dp[i-1] + dp[i-2])%1000000007

print(sum(dp[math.ceil(max(X, Y)/2):-1])%1000000007)
# print(dp)


### FIXED CODE ###

# 階乗は英語でfactrial, ifacは階乗に対する逆元
def cmb(n, k, mod, fac, ifac):
    # nCkを求める
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod


def make_tables(mod, n):  # (mod mod)の世界における割り算に従ってテーブルを作る
    # 階乗, 階乗に対する逆元のテーブルを作成する
    fac = [1, 1]  # 階乗デーブル
    ifac = [1, 1]  # 階乗に対する逆元のテーブル
    inverse = [0, 1]  # 逆元そのもののテーブル

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac


X, Y = map(int, input().split())
MOD = 1000000007
if (X+Y) % 3 != 0:
    print(0)
else:
    m = (2*X-Y)//3
    n = X - 2*m
    if n < 0 or m < 0:
        print(0)
        exit()
    fac, ifac = make_tables(MOD, (X+Y)//3)
    ans = cmb(n+m, n, MOD, fac, ifac)
    print(ans)
print(s=input().replace("1","")[0])

### FIXED CODE ###

def main():
  s=input()
  k=int(input())
  for i in s[:k]:
    if i!="1":
      print(i)
      return
  print("1")
main()
S=input()
x,y=map(int,input().split())
Xmove=[]
Ymove=[]
xdist=True
cnt=0
for i in range(len(S)):
  if S[i]=="T":
    if xdist:
      Xmove.append(cnt)
    else:
      Ymove.append(cnt)
    cnt=0
    xdist^=True
  else:
    cnt+=1
if S[-1]=="F":
  if xdist:
    Xmove.append(cnt)
  else:
    Ymove.append(cnt)

Xmax=sum(Xmove)
Ymax=sum(Ymove)
dpX=[[False for j in range(Xmax*2+2)] for i in range(len(Xmove)+1)]
dpY=[[False for j in range(Ymax*2+2)] for i in range(len(Ymove)+1)]

indX=0
if S[0]=="F":
  dpX[1][Xmax+Xmove[0]]=True
  indX=1
else:
  dpX[0][Xmax]=True
dpY[0][Ymax]=True

for i in range(indX,len(Xmove)):
  for j in range(len(dpX[i])):
    if dpX[i][j]:
      dpX[i+1][j-Xmove[i]]=True
      dpX[i+1][j+Xmove[i]]=True

if not dpX[-1][x+Xmax]:
  print("No")
  exit(0)

for i in range(len(Ymove)):
  for j in range(len(dpY[i])):
    if dpY[i][j]:
      dpY[i+1][j+Ymove[i]]=True
      dpY[i+1][j-Ymove[i]]=True

print(("No","Yes")[dpY[-1][y+Ymax]])

### FIXED CODE ###

S = input()
X,Y = map(int,input().split())

# [文字,その文字が連続する数]
from collections import deque
sumS = deque()
import itertools
for key,g in itertools.groupby(S):
  sumS.append([key,len(list(g))])
  
startx = 0 # Fで始まる場合はX軸の正の方向にあらかじめ進めて置く
# 最初のTが出るまではX軸正の方向に進む
if sumS[0][0] == "F":
  startx = sumS[0][1]
  sumS.popleft()

xdir = True # X軸方向を向いている
dpXcur = set()
dpXcur.add(startx)
dpYcur = set()
dpYcur.add(0) # Y軸は必ず0から始まる
dpXnex = set()
dpYnex = set()
for i in range(len(sumS)):
  if sumS[i][0] == "F":
    steps = sumS[i][1] # 進む数
    if xdir: # X軸方向を向いている場合
      for x in dpXcur:
        dpXnex.add(x + steps)
        dpXnex.add(x - steps)
      dpXcur = dpXnex
      dpXnex = set()
    else:
      for y in dpYcur:
        dpYnex.add(y + steps)
        dpYnex.add(y - steps)
      dpYcur = dpYnex
      dpYnex = set()
  elif sumS[i][0] == "T":
    turns = sumS[i][1] # 方向転換する数
    if turns % 2 == 1:
      # 奇数回の場合はX/Y軸の切り替え (偶数回の場合は何も起こらない)
      xdir ^= True
      
if X in dpXcur and Y in dpYcur:
  print("Yes")
else:
  print("No")
def f(n):
  if n % 2 == 0:
    return n//2
  else:
    return 3*n + 1


s = int(input())
a = [s]
i = 0
while True:
  s = f(a[i])
  if a in s:
    print(i)
    break
  else:
    a.ppend(s)
    i += 1

### FIXED CODE ###

def f(n):
  if n % 2 == 0:
    return n//2
  else:
    return 3*n + 1


s = int(input())
a = [s]
i = 0
while True:
  s = f(a[i])
  if s in a:
    print(i+2)
    break
  else:
    a.append(s)
    i += 1
s,t=input().split()
ans=0
for i in range(3):
    if s[i]==t[i]:
        ans+=1
print(ans)

### FIXED CODE ###

s=input()
t=input()
ans=0
for i in range(3):
    if s[i]==t[i]:
        ans+=1
print(ans)
n, q = map(int, input().split(" "))
items = [i for i in range(n)]
parent = [i for i in range(n)]

def root(s):
    if parent[s] == s:
        return s
    else:
        parent[s] = root(parent[s])
        return parent[s]

def same(s1, s2):
    if root[s1] == root[s2]:
        print("1")
    else:
        print("0")

def unite(s1, s2):
    s1 = root(s1)
    s2 = root(s2)

    if s1 == s2:
        return

    parent[s1] = s2


for i in range(q):
    query, item1, item2 = input().split(" ")
    item1, item2 = int(item1), int(item2)

    if query == "0":
        unite(item1, item2)
    else:
        same(item1, item2)


    parent[s1] = s2


for i in range(q):
    query, item1, item2 = input().split(" ")
    item1, item2 = int(item1), int(item2)

    if query == "0":
        unite(item1, item2)
    else:
        same(item1, item2)

### FIXED CODE ###

n, q = map(int, input().split(" "))
parent = [i for i in range(n)]
rank = [0] * len(parent)

def root(s):
    if parent[s] == s:
        return s
    else:
        parent[s] = root(parent[s])
        return parent[s]

def same(s1, s2):
    if root(s1) == root(s2):
        print("1")
    else:
        print("0")

def unite(s1, s2):
    s1 = root(s1)
    s2 = root(s2)

    if s1 == s2:
        return

    if rank[s1] < rank[s2]:
        parent[s1] = s2
    else:
        parent[s2] = s1
        if rank[s1] == rank[s2]:
            rank[s1] += 1

for i in range(q):
    query, item1, item2 = input().split(" ")
    item1, item2 = int(item1), int(item2)

    if query == "0":
        unite(item1, item2)
    else:
        same(item1, item2)
import exit from sys
s=input()
l=len(s)
for i in range(l-2):
    if s[i]==s[i+2]:
        print(str(i+1)+" "+str(i+3))
        exit()
    if s[i]==s[i+1]:
        print(str(i+1)+" "+str(i+2))
        exit()
if s[l-2]==s[l-1]:
    print(str(l-1)+" "+str(l))
else:
    print("-1 -1")


### FIXED CODE ###

def groupby(a):
    a2=[[a[0],1]]
    for i in range(1,len(a)):
        if a2[-1][0]==a[i]:
            a2[-1][1]+=1
        else:
            a2.append([a[i],1])
    return a2
s1=list(input())
l=len(s1)
s2=groupby(s1)
now=0
for i in s2:
    now+=i[1]
    if i[1]!=1:
        print(str(now-i[1]+1)+" "+str(now))
        break
else:
    if l==2:
        print("-1 -1")
    else:
        for i in range(l-2):
            if s1[i]==s1[i+2]:
                print(str(i+1)+" "+str(i+3))
                break
        else:
            print("-1 -1")
N,K=map(int,input().split())
S=list(input())
MIN=min(S)

def minimum(S):
    T=S+S[::-1]

    ANS=[]

    for i in range(N+1):
        ANS.append(T[i:i+N])

    return min(ANS)

def next(S):
    T=S+S[::-1]
    LIST=[]
    CL=[0]*2*N
    count=0

    for i in range(2*N):
        if T[i]==MIN:
            count+=1

        else:
            count=0

        CL[i]=count

    MAX=max(CL)
    LIST=[]

    for i in range(N-1,2*N):
        if CL[i]==MAX:
            LIST.append(T[i+1-N:i+1])

    return LIST,MAX

def next2(S,x):
    return S[MAX:]+MIN*MAX

if K==1:
    print("".join(minimum(S)))

else:
    CAN,MAX=next(S)

    ANS=[]

    for c in CAN:
        for j in range(K-2):
            c=next2(c,MAX)

            if max(c)==MIN:
                print("".join(c))
                sys.exit()

        ANS.append(minimum(c))

    print("".join(min(ANS)))
        


### FIXED CODE ###

import sys

N,K=map(int,input().split())
S=list(input())
MIN=min(S)

def minimum(S):
    T=S+S[::-1]

    ANS=[]

    for i in range(N+1):
        ANS.append(T[i:i+N])

    return min(ANS)

def next(S):
    T=S+S[::-1]
    LIST=[]
    CL=[0]*2*N
    count=0

    for i in range(2*N):
        if T[i]==MIN:
            count+=1

        else:
            count=0

        CL[i]=count

    MAX=max(CL)
    LIST=[]

    for i in range(N-1,2*N):
        if CL[i]==MAX:
            LIST.append(T[i+1-N:i+1])

    return LIST,MAX

def next2(S,x):
    return [MIN]*x+S[x:][::-1]

if K==1:
    print("".join(minimum(S)))

else:
    CAN,MAX=next(S)

    if (MAX<<(K-1))>=N:
        print(MIN*N)
        sys.exit()

    ANS=[]

    for c in CAN:

        ANS.append(next2(c,MAX*((1<<(K-1))-1)))

    print("".join(min(ANS)))
import bisect
from scipy.sparse.csgraph import floyd_warshall as wf
INF = 10**20

A,B,Q = map(int,input().split())
s = [-INF]+[int(input()) for _ in range(A)]+[INF]
t = [-INF]+[int(input()) for _ in range(B)]+[INF]

for i in range(Q):
    q = int(input())
    b,d = bisect.bisect_right(s,q),bisect.bisect_right(t,q)
    ans = INF
    for S in [s[b-1],s[b]]:
        for T in [t[d-1],t[d]]:
            d1,d2 = abs(S-q)+abs(T-S),abs(T-q)+abs(S-T)
            ans = min(ans,d1,d2)
    print(ans)


### FIXED CODE ###

import bisect
from scipy.sparse.csgraph import floyd_warshall as wf
INF = 10**20

A,B,Q = map(int,input().split())
s = [-INF]+[int(input()) for _ in range(A)]+[INF]
t = [-INF]+[int(input()) for _ in range(B)]+[INF]

for i in range(Q):
    q = int(input())
    b,d = bisect.bisect_right(s,q),bisect.bisect_right(t,q)
    ans = INF
    for S in [s[b-1],s[b]]:
        for T in [t[d-1],t[d]]:
            d1,d2 = abs(S-q)+abs(T-S),abs(T-q)+abs(S-T)
            ans = min(ans,d1,d2)
    print(ans)
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
c = input().split()
e = 0
for i in range(b):
	f = int(c[i + b - 1])
	d = 0
	for j in range(f):
		d += (j + 1)
	e += d / f
print(e)

### FIXED CODE ###

# -*- coding: utf-8 -*-
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = [(i + 1) / 2 for i in c]
e = sum(d[:b])
f = e
for i in range(a - b):
	f -= d[i]
	f += d[i + b]
	if f > e:
		e = f
print(e)