Harryxun/stf_run huggingface dataset:
N = int(input())
DX = list(int(i) for i in input().split())
A = []
for i in range(N):
     A.apend(input())
ai =[]
ans = N + DX[1]
for i in range(N):
    for n in range(DX[0]):
        if n*A[i]+1 <= DX[0]:
            ai.append(n)
    ans += max(ai)
    ai = []
print(ans)


### FIXED CODE ###

N = int(input())
DX = list(int(i) for i in input().split())
A = []
for i in range(N):
     A.append(int(input())) 
ai =[]
ans = N + DX[1]
for i in range(N):
    for n in range(DX[0]):
        if n*A[i]+1 <= DX[0]:
            ai.append(n)
    ans += max(ai)
    ai = []
print(ans)
a = list(map(int,input().split()))
b = [input() for l in range(a[0])]
ans = 0
cnt = 0
allcnt = 0
nongyou = []
cnt2 = 0
for i in range(a[0]):
    allcnt += b[i].count('#')

for i in range(2 ** a[0]):
    cnt = allcnt
    nongyou = []
    for j in range(a[0]):
        if ((i >> j) & 1):
            cnt -= b[i].count('#')
            nongyou.append(i)
    for m in range(2 ** a[1]):
        cnt2 = cnt
        for n in range(a[1]):
            if ((m >> n) & 1):
                for k in range(a[0]):
                    if k in nongyou:
                        continue
                    else:
                        cnt2 -= b[k][m].count('#')                  
        if cnt2 == a[2]:
            ans += 1

print(str(ans))

### FIXED CODE ###

a = list(map(int,input().split()))
b = [input() for l in range(a[0])]
ans = 0
cnt = 0
allcnt = 0
nongyou = []
cnt2 = 0
for i in range(a[0]):
    allcnt += b[i].count('#')

for i in range(2 ** a[0]):
    cnt = allcnt
    nongyou = []
    for j in range(a[0]):
        if ((i >> j) & 1):
            cnt -= b[j].count('#')
            nongyou.append(j)
    for m in range(2 ** a[1]):
        cnt2 = cnt
        for n in range(a[1]):
            if ((m >> n) & 1):
                for k in range(a[0]):
                    if k in nongyou:
                        continue
                    else:
                        cnt2 -= b[k][n].count('#')                  
        if cnt2 == a[2]:
            ans += 1

print(str(ans))
import bisect

MAX_VALUE = 10**100
S = input()
lenS = len(S)
T = input()
Si = {}
for i,s in enumerate(S):
  if s not in Si:
    Si[s] = []
  Si[s].append(i)

ans = 0
for t in T:
  if t not in Si:
    print(-1)
    exit()
  else:
    idx = -1
    if ans<=max(Si[t]):
      idx = Si[t][bisect.bisect(Si[t],ans)]
    else:
      factor = (ans-min(Si[t]))//lenS + 1
      idx = Si[t][min(bisect.bisect(Si[t],ans%lenS),len(Si[t])-1)] + factor*lenS
    ans = idx
    if MAX_VALUE<ans:
      print(-1)
      exit()
print(ans+1)

### FIXED CODE ###

import bisect

REPEAT_NUM = 10 ** 100

S = input()
T = input()
lenS = len(S)
lenT = len(T)

idxes_S = {}
for idx, s in enumerate(S):
    if s not in idxes_S:
        idxes_S[s] = []
    idxes_S[s].append(idx)

idx_s = -1
idx_t = 0
while idx_t < lenT and idx_s < lenS * REPEAT_NUM:
    if T[idx_t] not in idxes_S:
        print(-1)
        exit()
    else:
        tmp_idx = bisect.bisect(idxes_S[T[idx_t]], idx_s % lenS)
        if len(idxes_S[T[idx_t]]) == tmp_idx:
            idx_s += lenS - idx_s % lenS + idxes_S[T[idx_t]][0]
        else:
            idx_s += idxes_S[T[idx_t]][tmp_idx] - idx_s % lenS
        idx_t += 1

if idx_t == lenT:
    print(idx_s + 1)
else:
    print(-1)
a = int(input().split())

x = a[0] + a[1]
y = a[0] - a[1]
z = a[0] * a[1]

if x > y and x > z:
  print('x')
elif y > x and y > z:
  print('y')
else:
  print('z')
  
  

### FIXED CODE ###

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

x = a[0] + a[1]
y = a[0] - a[1]
z = a[0] * a[1]

if x >= y and x >= z:
  print(x)
elif y >= x and y >= z:
  print(y)
else:
  print(z)
N,X=map(int, input().split())
L=list(map(int, input().split()))
s=[x for x in range(N) if sum(L[:x])<=X]
if n>=len(s):
  print(len(s))
else:
  print(N+1)

### FIXED CODE ###

N,X=map(int, input().split())
L=list(map(int, input().split()))
s=[x for x in range(len(L)+1) if sum(L[:x])<=X]
if N+1>=len(s):
  print(len(s))
else:
  print(N+1)
n, d = map(int, input().split())

ans = 0

for _ in range(n):
    x, y = map(int, readline().split())
    if x ** 2 + y ** 2 <= d ** 2:
        ans += 1

print(ans)

### FIXED CODE ###

import sys

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


def main():
    n, d = map(int, readline().split())

    ans = 0

    for _ in range(n):
        x, y = map(int, readline().split())
        if (x ** 2 + y ** 2) <= d ** 2:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()
# https://atcoder.jp/contests/abc112/tasks/abc112_c


# ピラミッドの中心は必ず0-100の中にある
# Hは1以上
# 与えられる情報だけで一意に定まる

# 中心座標をa,bと置いたとき、ある点x,yにおける高さは
# h(x,y; a,b)=max(H-|x-a|-|y-b|,0)である。
# ここで、真の高さとの誤差としてe(x,y;a,b)=|h(x,y;a,b) - h(x,y;Cx,Cy)|とすると。
# 任意のx,yでe=0となるa,bが答え。しかしHはわからないので0とする。
# そうすると任意のx,yでe(x,y;a,b)=constとなるa,bが答え。(ただしmaxの扱いが面倒なのでh==0は無視して処理を行う)
# またその定数constはHである

# 座標は10**4点。Nはたかだか100なので 最悪10**6回計算。間に合う。

import numpy as np
from itertools import product

N = int(input())
X, Y, H = [], [], []
for n in range(N):
    x, y, h = list(map(int, input().split()))
    # if h == 0:
    #     continue
    X.append(x)
    Y.append(y)
    H.append(h)

if N == 1:
    print(x, y, h)
    exit()

X = np.array(X)
Y = np.array(Y)
H = np.array(H)


def is_eq_loss(X, Y, H, a, b):
    loss = np.abs(- np.abs(X - a) - np.abs(Y - b) - H)
    mask = (H == 0)  # 高さがない疑いのところは最小値に合わせる
    if np.any(mask):
        loss[mask] = loss[mask].min()
    # print(loss[-1])
    if (loss[-1] == loss).all():
        return True, loss[-1]
    else:
        return False, False


for a, b in product(range(101), range(101)):
    flg, ansH = is_eq_loss(X, Y, H, a, b)
    if flg:
        ans = (a, b, ansH)

print(*ans)


### FIXED CODE ###

# https://atcoder.jp/contests/abc112/tasks/abc112_c


# ピラミッドの中心は必ず0-100の中にある
# Hは1以上
# 与えられる情報だけで一意に定まる

# 中心座標をa,bと置いたとき、ある点x,yにおける高さは
# h(x,y; a,b)=max(H-|x-a|-|y-b|,0)である。
# ここで、真の高さとの誤差としてe(x,y;a,b)=|h(x,y;a,b) - h(x,y;Cx,Cy)|とすると。
# 任意のx,yでe=0となるa,bが答え。しかしHはわからないので0とする。
# そうすると任意のx,yでe(x,y;a,b)=constとなるa,bが答え。(ただしmaxの扱いが面倒なのでh==0は無視して処理を行う)
# またその定数constはHである

# 座標は10**4点。Nはたかだか100なので 最悪10**6回計算。間に合う。

import numpy as np
from itertools import product

N = int(input())
X, Y, H = [], [], []
for n in range(N):
    x, y, h = list(map(int, input().split()))
    # if h == 0:
    #     continue
    X.append(x)
    Y.append(y)
    H.append(h)

if N == 1:
    print(x, y, h)
    exit()

X = np.array(X)
Y = np.array(Y)
H = np.array(H)


def is_eq_loss(X, Y, H, a, b):
    loss = np.abs(- np.abs(X - a) - np.abs(Y - b) - H)
    mask = (H == 0)  # 高さがない疑いのところは最小値に合わせる
    if np.any(mask):
        loss[mask] = loss.min()
    # print(loss[-1])
    if (loss[-1] == loss).all():
        return True, loss[-1]
    else:
        return False, False


for a, b in product(range(101), range(101)):
    flg, ansH = is_eq_loss(X, Y, H, a, b)
    if flg:
        ans = (a, b, ansH)

print(*ans)
S = input().strip()
K = int(input())
ind = len(S)+1
for i in range(len(S)):
    if S[i]!="1":
        ind = i+1
        break
if K<ind
    print(1)
else:
    print(S[ind-1])

### FIXED CODE ###

S = input().strip()
K = int(input())
cur = 0
a = 0
for i in range(len(S)):
    if S[i]!="1":
        a = S[i]
        break
    cur += 1
if K<cur+1:
    print("1")
else:
    print(a)
h, w =map(int,input().split())

if (h * w) % 2 == 0:
  print((h * w) // 2)
elif (h * w) % 2 == 1:
  print(((h * W) // 2) + 1)
  


### FIXED CODE ###

h, w =map(int,input().split())

if h == 1 or w == 1:
  print(1)
else:
  if (h * w) % 2 == 0:
    print((h * w) // 2)
  else:
    print(((h * w) // 2) + 1)
b = input()
if b == "A":
    print(T)
elif b == "T":
    print(A)
elif b == "C":
    print(G)
elif b == "G":
    print(C)

### FIXED CODE ###

b = input()
if b == "A":
    print("T")
elif b == "T":
    print("A")
elif b == "C":
    print("G")
elif b == "G":
    print("C")
import heapq
def SME(start,end):
    if end > N : end = N
    count = 0
    for i,x in enumerate(Whole[start:end]):
        if i > N*0.5 : break
        heapq.heappush(A,[x,i])
    for j in range(start,end):
        a = heapq.heappop(A)
        if None not in ANS[a[1]:a[1]+L] : continue
        for i in range(L):
            idx = a[1] + i
            try :
                if ANS[idx] : continue
                else :
                    ANS[idx] = a[0]
                    count += 1
            except IndexError : continue
        if count > N * parameter : break
    for i in range(L):
        if ANS[i] : continue
        else : ANS[i] = min(Whole[:i+1])
    for i in range(L,N):
        if ANS[i] : continue
        else : ANS[i] = min(Whole[i+1-L:i+1])
    return ANS
[N,L] = [int(x) for x in input().split()]
Whole = [int(x) for x in input().split()]
A = []
parameter = 0.9997
ANS = [None]*N
ANS = SME(0, N)
for i in ANS[L-1:-1]:print(i, end=" ")
print(ANS[-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
n,x,t=map(int,input().split())

if n%x=0:
   a=int(n//x)
else:
   a=int(n//x+1)

b=int(a*t)

print(b)


### FIXED CODE ###

n,x,t=map(int,input().split())

if n%x==0:
   a=int(n//x)
else:
   a=int(n//x+1)

b=int(a*t)

print(b)
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = list(map(int, input()))

while max(A) >= 2:
    tmp = []
    for i in range(len(A)-1):
        tmp.append(abs(A[i] - A[i+1]))
    A = tmp

while len(A) > 2:
    tmp1 = [A[0]]
    for i in range(1, len(A)):
        if A[i] != tmp1[-1]:
            tmp1.append(A[i])
    tmp2 = []
    for i in range(len(tmp1)-1):
        tmp2.append(abs(tmp1[i] - tmp1[i+1]))
    A = tmp2
print(abs(A[0] - A[1]))


### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def lucas(n, k):
    return (n&k) == k

N = INT()
A = [a-1 for a in list(map(int, input()))]

def check(A):
    mod2 = 0
    for i, a in enumerate(A):
        if a == 1:
            mod2 += lucas(N-1, i)
            mod2 %= 2
    return mod2

res = check(A)
if res == 1:
    print(1)
    exit()

if A.count(1):
    print(0)
    exit()

A = [a//2 for a in A]
res = check(A)
if res == 1:
    print(2)
else:
    print(0)
x,y=map(input().split())
print(x+y//2)

### FIXED CODE ###

x,y=map(int,input().split())
print(x+y//2)
n = list(map(int, input().split()))
a = input()
a = list(a)

if a[n[1]] == "A":
    a[n[1]] = "a"
if a[n[1]] == "B":
    a[n[1]] = "b"
if a[n[1]] == "C":
    a[n[1]] = "c"
print(a)

### FIXED CODE ###

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


if a[n[1]-1] == "A":
    a[n[1]-1] = "a"
if a[n[1]-1] == "B":
    a[n[1]-1] = "b"
if a[n[1]-1] == "C":
    a[n[1]-1] = "c"
    
ch = ""
for i in a:
    ch += str(i)
print(ch)
N=int(input())
a=int(input())
b=int(input())
if N==1:
    print("Hello World")
elif N==2:
    print(a+b)

### FIXED CODE ###

N=int(input())
if N==1:
    print("Hello World")
elif N==2:
    a=int(input())
    b=int(input())
    print(a+b)
s = input()
nq = int(input())
flg = 0
front = []
back = []
for i in range(nq):
    q = input()
    if len(q) == 1:
        #flg += 1
        flg = (flg+1)%2
    else:
        if flg == 0:
            if q[2] == '1':
                front = [q[-1]] + front
            else:
                back = back + [q[-1]]
        else:
            if q[2] == '1':
                back = back + [q[-1]]
            else:
                front = [q[-1]] + front
                
s = ''.join(front) + s + ''.join(back)
# if flg % 2 == 1:
#     s = s[::-1]
print(s)

### FIXED CODE ###

N=[s for s in input()]
if 'A' in N and 'B' in N:
    print('Yes')
else:
    print('No')
import sys
sys.setrecursionlimit(10**5)

N = int(input())
a = [0]+[int(i) for i in input().split()]
ret = [0] * (N+1)

def rec(i) :
    if i == N + 1 :
        return
    rec(i+1)
    s = 0
    for j in range(i, N + 1, i) :
        s += ret[j]
    ret[i] = (s%2)^a[i]
    
rec(1)
b = []
for i in range(1, N + 1) :
    if ret[i] :
        b.append(str(i))
print(len(b))
print(' '.join(b))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

N = int(input())
a = [0]+[int(i) for i in input().split()]
ret = [0] * (N+1)

def rec(i) :
    if i == N + 1 :
        return
    rec(i+1)
    s = 0
    for j in range(i, N + 1, i) :
        s ^= ret[j]
    ret[i] = s^a[i]
    
rec(1)
b = []
for i in range(1, N + 1) :
    if ret[i] :
        b.append(str(i))
print(len(b))
print(' '.join(b))
num = int(input())
array = list(map(int, input().split()))
sum = 0
 
for i in range(num):
	if i == 0:
      sum += array[i]
    else if i < (num-1):
      if array[i] > array[i-1]:
        sum += array[i-1]
      else:
        sum += array[i]
    else:
      sum += array[i-1]
        
print(sum)

### FIXED CODE ###

num = int(input())
array = list(map(int, input().split()))
sum = 0
 
for i in range(num):
	if i == 0:
		sum += array[i]
	elif i < (num-1):
		if array[i] > array[i-1]:
			sum += array[i-1]
		else:
			sum += array[i]
	else:
		sum += array[i-1]
        
print(sum)
import sys
sys.setrecursionlimit(4100000)
a = str(input())
a = a
length = len(a)
b = len(a)
ans = 0
for i in reversed(range(1,b+1)):
    if i%2 == 1 and i == b:
        temp = ""
        for k in range(i-1):
            temp += "9"
        ans += int(a[b-i:]) - int(temp)

    elif i%2 == 1:
        temp = 9*10**(i)//10

        ans += temp
print(ans)

### FIXED CODE ###


import sys
sys.setrecursionlimit(4100000)
a = str(input())
a = a
length = len(a)
b = len(a)
ans = 0
if b == 1:
    print(a)
else:
    for i in reversed(range(1,b+1)):
        if i%2 == 1 and i == b:
            temp = ""
            for k in range(i-1):
                temp += "9"
            ans += int(a[b-i:]) - int(temp)

        elif i%2 == 1:
            temp = 9*10**(i)//10

            ans += temp
    print(ans)
import fractions
nm=raw_input()
nm=nm.split()
n=eval(nm[0])
m=eval(nm[1])
s=raw_input()
t=raw_input()

gg=fractions.gcd(n,m)
ll=n*m/gg
aa=ll/n
bb=ll/m
result = ll
for i in range(ll) :
    if not (i % aa):
        tmp1=i/aa
        if not(i % bb) :
            tmp2=i/bb
            if s[tmp1] != t[tmp2] :
                result= -1
print result


### FIXED CODE ###

import fractions
nm=raw_input()
nm=nm.split()
n=eval(nm[0])
m=eval(nm[1])
s=raw_input()
t=raw_input()

gg=fractions.gcd(n,m)
ll=n/gg*m
result = ll
for i in xrange(n):
    if not (i*m) % n :
            tmp=i*m/n
            if s[i] != t[tmp] :
                result= -1
print result
N, K = map(int, input().split())
h = list(map(int, input().split()))

dp = [0] * N
for i in range(1, N):
    dp[i] = min(abs(h[i] - h[j]) for j in range(max(0, i - K), i)) + dp[j]
print(dp[N - 1])


### FIXED CODE ###

n, k = [int(e) for e in input().split()]
h = [int(e) for e in input().split()]
cost = [0] * n
cost[1] = abs(h[1] - h[0])
for i in range(1, n):
  cost[i] = min(abs(h[i] - h[j]) + cost[j] for j in range(max(0, i - k), i))
print(cost[n - 1])
x,y=map(int,input() .split())
if x > y:
    print("a > b")
elif x==y:
        print("a == b")
else:
        print("a < b")


### FIXED CODE ###

a,b = map(int, input().split())
if a > b:
 print("a > b")
elif a < b:
 print("a < b")
else:
 print("a == b")
S = input()
i= len(S)
for j in  range(i):
  S[j]="x"
print(S)

### FIXED CODE ###

S= input()
t= len(S)
print("x" * t)
# -*- coding: utf-8 -*-
n,x = map(int, input().split())

if x==1 or x==2*n-1:
    print("No")
    exit()
if n==2:
    print("Yes")
    print(1)
    print(2)
    print(3)

ret = [0 for _ in range(2*n-1)]
if x!=2:
    ret[n-1] = x-1
    ret[n] = x
    ret[n+1] = x+1
    ret[n+2] = x-2
    d = [x-2,x-1,x,x+1]
else:
    ret[n-1] = x+1
    ret[n] = x
    ret[n+1] = x-1
    ret[n+2] = x+2
    d = [x-1,x,x+1,x+2]
i = 0
j = 1
while i<2*n-1:
    if ret[i]==0:
        while j in d:
            j += 1
        ret[i] = j
        j += 1
    i += 1
print("Yes")
for x in ret:
    print(x)


### FIXED CODE ###

# -*- coding: utf-8 -*-
n,x = map(int, input().split())

if x==1 or x==2*n-1:
    print("No")
    exit()
if n==2:
    print("Yes")
    print(1)
    print(2)
    print(3)
    exit()

ret = [0 for _ in range(2*n-1)]
if x!=2:
    ret[n-1-1] = x-1
    ret[n-1] = x
    ret[n+1-1] = x+1
    ret[n+2-1] = x-2
    d = [x-2,x-1,x,x+1]
else:
    ret[n-1-1] = x+1
    ret[n-1] = x
    ret[n+1-1] = x-1
    ret[n+2-1] = x+2
    d = [x-1,x,x+1,x+2]
i = 0
j = 1
while i<2*n-1:
    if ret[i]==0:
        while j in d:
            j += 1
        ret[i] = j
        j += 1
    i += 1
print("Yes")
for x in ret:
    print(x)
import math
N = int(input())
Min = float('inf')
Max = math.ceil(math.sqrt(N))
for i in range(1,Max+1):
    if N%i==0:
        b = N//i
        Min = min(Min,i+b-2)
print(Min

### FIXED CODE ###

import math
N = int(input())
Min = float('inf')
Max = math.ceil(math.sqrt(N))
for i in range(1,Max+1):
    if N%i==0:
        b = N//i
        Min = min(Min,i+b-2)
print(Min)
print("Christmas"+" Eve"*(25-int(input()))

### FIXED CODE ###

d = int(input())
if d == 25:
    print("Christmas")
elif d == 24:
    print("Christmas Eve")
elif d == 23:
    print("Christmas Eve Eve")
else:
    print("Christmas Eve Eve Eve")
N,M = list(map(int,input().split()))
atob = [0] * N
btoz = [0] * N
for _ in range(M):
    a, b = list(map(int,input().split()))
    if a == 1:atob[b-1] = 1
    elif a == N:btoz[b-1] = 1
    if b == 1:atob[a-1] = 1
    elif b == N:btoz[a-1] = 1

for i in range(N):
    if a[i]*b[i] == 1:
        print('POSSIBLE')
        break
else:print('IMPOSSIBLE')

### FIXED CODE ###

N,M = list(map(int,input().split()))
atob = [0] * N
btoz = [0] * N
for _ in range(M):
    a, b = list(map(int,input().split()))
    if a == 1:atob[b-1] = 1
    elif a == N:btoz[b-1] = 1
    if b == 1:atob[a-1] = 1
    elif b == N:btoz[a-1] = 1

for i in range(N):
    if atob[i]*btoz[i] == 1:
        print('POSSIBLE')
        break
else:print('IMPOSSIBLE')
s = input()
n = len(s)
# 区間は2以上の長さ
if n % 2 != 0:
    for i in range(1, n):
        a = s[n // 2]
        if s[n // 2 - 1 - i] != a or s[n // 2 + i] != a:
            print(n // 2 + i)
            exit()
else:
    for i in range(1, (n - 1) // 2 + 1):
        b = s[(n-1)//2]
        if s[(n-1)//2-i] != b or s[(n-1)//2+i] != b:
            print((n - 1) / 2 + i)
            exit()
print(n)

### FIXED CODE ###

s = list(input())
n = len(s)
if n % 2 == 0:
    for i in range(n//2):
        a = s[n // 2]
        if s[n // 2 - 1 - i] != a or s[n // 2 + i] != a:
            print(n // 2 + i)
            exit()
else:
    for i in range(1, (n - 1) // 2 + 1):
        b = s[(n-1)//2]
        if s[(n - 1) // 2 - i] != b or s[(n - 1) // 2 + i] != b:
            print((n-1)//2+i)
            exit()
print(n)
n,k=map(int,input().split())
l1=list(map(int.input().split()))
l1.sort()
price = 0
count= 0
for i in range(n-1):
  if count=k:
      break
  else:    
     if l1[i]!=l1[i+1]:
          price+=l1[i]
          count+=1
print(price)    

### FIXED CODE ###

N, K = map(int, input().split())
p = list(map(int, input().split()))
print(sum(sorted(p)[:K]))
n = int(input())
s = list(map(int,input().split()))
if 0 in s:
  print(0)
  exit()
for _ in range(n):
  ans *= s[_]
  if len(str((ans-1))) > 18:
    print(-1)
    exit()
else:
  print(ans)

### FIXED CODE ###

n = int(input())
s = list(map(int,input().split()))
ans = 1
if 0 in s:
  print(0)
  exit()
for _ in range(n):
  ans *= s[_]
  if ans > 10**18:
    print(-1)
    exit()
else:
  print(ans)
n=int(input())
l=[int(input()) for i in range(n)]
m=max(l)
nums=[i for i in range(n)]
for num in nums:
  if(l[num]!=m):
    print(m)
  else:
    s=[x for x in l if x!=m]
    print(max(s))
  

### FIXED CODE ###

n=int(input())
l=[int(input()) for i in range(n)]
s=sorted(l)
p=s[-1]
q=s[-2]
for i in range(n):
  if l[i]==p:
    print(q)
  else:
    print(p)
if n <= 81:
  for i in range(1, 10):
    if n%i == 0:
      for j in range(1, 10):
        if (n/i)%j == 0 and (n/i)/j == 1:
          print("Yes")
          exit()

print("No")

### FIXED CODE ###

n = int(input())
if n <= 81:
  for i in range(1, 10):
    if n%i == 0:
      for j in range(1, 10):
        if (n/i)%j == 0 and (n/i)/j == 1:
          print("Yes")
          exit()
print("No")
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
bc = [0] * M
for i in range(M):
    bc[i] = list(map(int, input().split()))

bc = sorted(bc, key= lambda x: x[1])[::-1]

n = 0
f = 0
for i in range(M):
    for j in range(bc[i][0]):
        if A[n] < bc[i][1]:
            A[n] = bc[i][1]
            n += 1
        else:
            f == 1
    if f == 1:
        break

print(sum(A))

### FIXED CODE ###

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
bc = [0] * M
for i in range(M):
    bc[i] = list(map(int, input().split()))

bc = sorted(bc, key= lambda x: x[1], reverse=True)

n = 0
f = 0
for i in range(M):
    for j in range(bc[i][0]):
        if A[n] < bc[i][1]:
            A[n] = bc[i][1]
            n += 1
            if n == N:
                f = 1
                break
        else:
            f = 1
    if f == 1:
        break

print(sum(A))
s = input()
if s[0] == s[1] and a[1] == a[2]:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

s = input()
if s[0] == s[1] and s[1] == s[2]:
  print("No")
else:
  print("Yes")
x, y, a, b, c = map(int, input().split())
arrayP = list(map(int, input().split()))
arrayQ = list(map(int, input().split()))
arrayR = list(map(int, input().split()))
arrayP.sort(reverse=True)
arrayQ.sort(reverse=True)
arrayR.sort(reverse=True)
arrayAns = []
for i in range(x):
    arrayAns.append(int(arrayP[i]))
for i in range(y):
    arrayAns.append(int(arrayQ[i]))
arrayAns.sort()
for i in range(len(arrayR)):
    if arrayAns[i] <= int(arrayR[i]):
        arrayAns[i] = int(arrayR[i])
    else:
        break
print(sum(arrayAns))

### FIXED CODE ###

S=input()

if S[2]==S[3] and S[4]==S[5]:
    print('Yes')
else:
    print('No')
n,x = map(int, input().split())
l = map(int, input().split())
#ボールの弾む座標
cnt=1
length=0
for i in range(n):
    length +=l[i]
    if length <=x:
        cnt+=1

print (cnt)

### FIXED CODE ###

n,x = map(int, input().split())
l = list(map(int, input().split()))
#ボールの弾む座標
cnt=1
length=0
for i in range(n):
    length +=l[i]
    if length <=x:
        cnt+=1

print (cnt)