Harryxun/stf_run huggingface dataset:
def solve():
    
A, B, C, D, E, F = map(int, input().split())
memo = []

for a in range(31):
    for b in range(31):
        for c in range(101):
            for d in range(101):
                w = (100*A)*a + (100*B)*b
                s = C*c + D*d
                if w+s > F:
                    break
                else:
                    if w/100 * E >= s:
                        memo.append([w+s,s])

print(*sorted(memo, key=lambda x: (100*x[1] / x[0] if x[0] else 0))[-1])

if __name__ == '__main__':
    solve()

### FIXED CODE ###

def solve():
    
    A, B, C, D, E, F = map(int, input().split())
    memo = {}
    
    for a in range(31):
        for b in range(31):
            for c in range(101):
                for d in range(101):
                    if a == 0 and b == 0:
                        break
                    if (100*A)*a + (100*B)*b + C*c + D*d > F:
                        break
                    if  ((100*A)*a + (100*B)*b)/100 *E < C*c + D*d:
                        break
                    density = 100 * (C*c+D*d) / ( (100*A)*a + (100*B)*b + C*c + D*d )
                    memo[a,b,c,d] = density
    
    max_v = max(memo.values())
    
    for k, v in memo.items():
        if v == max_v:
            print((100*A)*k[0] + (100*B)*k[1] + C*k[2] + D*k[3], C*k[2] + D*k[3] )
            break
 
if __name__ == '__main__':
    solve()
n = int(input())
h = list(map(int, input().split()))
 
dp = []
for i in range(n):
	dp.append(0)
dp[0] = 0
dp[1] = abs(h[0]-h[1])
 
for j in range(2,n):
	dp[j] = min(flog(j-1) + abs(h[j-1] - h[j]),flog(j-2) + abs(h[j-2] - h[j]))
  
print(dp[n-1])

### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))
 
dp = []
for i in range(n):
	dp.append(int(0))
dp[0] = 0
dp[1] = abs(h[0]-h[1])
 
for j in range(2,n):
	dp[j] = min(dp[j-1] + abs(h[j-1] - h[j]),dp[j-2] + abs(h[j-2] - h[j]))
  
print(dp[n-1])
import math
l=[int(input()) for i in range(5)]
t=[]
for ll in l:
  t.append(math.ceil(t//10))
lis=[]
for i in range(5):
  lis.append(t[i]*10-l[i])
m=max(lis)
sum=0
for i in range(5):
  sum+=t[i]*10
print(sum-m)
  


### FIXED CODE ###

import math
list=[int(input()) for x in range(5)]
list.sort(key=lambda x:x%10)
count=0
for l in list:
  if l%10==0:
    count+=1
if count==5:
  print(sum(list))
else:
  a=list[count]
  del list[count]
  ans=[]
  for t in list:
    ans.append(math.ceil(t/10)*10)
  print(sum(ans)+a)
p, q = map(int, input().split())
import math
gcd = math.gcd(p, q)

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

print(lcm(p, q))

### FIXED CODE ###

p, q = map(int, input().split())
import fractions
 
def lcm(a, b):
    return (a * b) // fractions.gcd(a, b)

print(lcm(p, q))
from itertools import combinations, combinations_with_replacement
from math import sqrt

# input
N = int(input())
xy = []
xy_append = xy.append
for n in range(N):
    x, y = map(int, input().split())
    xy_append((x, y))

nC2 = list(combinations(xy, 2))
dist = []
d_append = dist.append
for a, b in nC2:
    d_append(sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2))

dist_sum = 0
dist_case = combinations_with_replacement(dist, 2)
for m, n in dist_case:
    dist_sum += m + n

print(dist_sum / len(dist_case))


### FIXED CODE ###

from itertools import combinations
from math import sqrt

# input
N = int(input())
xy = []
xy_append = xy.append
for n in range(N):
    x, y = map(int, input().split())
    xy_append((x, y))

nC2 = list(combinations(xy, 2))
dist = []
d_append = dist.append
for a, b in nC2:
    d_append(sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2))

if len(dist) == 1:
    print(dist[0])
else:
    dist_sum = 0
    dist_case = list(combinations(dist, N - 1))
    for d in dist_case:
        dist_sum += sum(d)

    print(dist_sum / len(dist_case))
k=int(input())
l=[]
x=7%k
if x == 0:
  print(1)
  break
for i in range(2,k+1):
  x=7%k
  num=(x*10+7)%k
  x=num
  l.append(num)
  if num==0:
    print(i)
    break
if 0 not in l:
  print(-1)

### FIXED CODE ###

import sys
k=int(input())
l=[]
x=7%k
if x == 0:
  print(1)
  sys.exit()
for i in range(2,k+1):
  num=(x*10+7)%k
  x=num
  l.append(num)
  if num==0:
    print(i)
    break
if 0 not in l:
  print(-1)
32.txt

N = int(input())
A = list(map(int, input().split()))
bottom = sum(A)

if A[0] >= 1:
  print(-1)
  exit()

ret = 1
children = 1 - A[0]
bottom -= A[0]
 
for i in range(N):
    children = children * 2 - A[i+1]
    if children <= -1:
      ret = -1
      break
    
    bottom -= A[i+1]
    if children >= bottom:
      children = bottom
    ret += children + A[i+1]
print(ret)


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
bottom = sum(A)

if A[0] >= 2:
  print(-1)
  exit()

ret = 1
children = 1 - A[0]
bottom -= A[0]
 
for i in range(N):
    children = children * 2 - A[i+1]
    if children <= -1:
      ret = -1
      break
    
    bottom -= A[i+1]
    if children >= bottom:
      children = bottom
    ret += children + A[i+1]
print(ret)
x, y = map(int, input().split())
ans = x - 1
if x <= y: 
    ans++
print(ans)

### FIXED CODE ###

x, y = map(int, input().split())
ans = x - 1
if x <= y: 
    ans = ans + 1
print(ans)
# coding: utf-8
# Your code here!
def Eratosthenes(N): #N以下の素数のリストを返す
    #iが素数のときis_prime_list[i]=1，それ以外は0
    N+=1
    is_prime_list = [True]*N
    m = int(N**0.5)+1
    for i in range(3,m,2):
        if is_prime_list[i]:
            is_prime_list[i*i::2*i]=[False]*((N-i*i-1)//(2*i)+1)
    return [2] + [i for i in range(3,N,2) if is_prime_list[i]]

#aを破壊的にgcd-zetaする
def zeta_gcd(a):
    n = len(a)-1
    seive = [True]*(n+1)
    for p in range(1,n):
        if seive[p]:
            for i in range(n//p,0,-1):
                a[i] += a[p*i]
                a[i] %= MOD
#    return a

#aを破壊的にgcd-mobiusする
def mobius_gcd(a,primes):
    n = len(a)
    seive = [True]*(n+1)
    for p in range(1,n):
        if seive[p]:
            for i in range(1,n):
                if i*p >= n: break
                a[i] -= a[p*i] 
                a[i] %= MOD
#    return a

################################################

#################################################

SIZE=1000001; MOD=998244353 #ここを変更する

SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
inv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD

################################################
#################################################
import sys
#sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]

num = [0]*SIZE
for i in a: num[i] += i

assert n != 3

zeta_gcd(num)
ans = [i*i for i in num]
mobius_gcd(ans)

res = 0
for i,c in enumerate(ans):
    res = (res + c*inv[i])%MOD
for i in a:
    res = (res-i)%MOD
        
print(res*inv[2]%MOD)









### FIXED CODE ###

# coding: utf-8
# Your code here!
SIZE=1000001; MOD=998244353 #ここを変更する

SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
inv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD


import sys
#sys.setrecursionlimit(10**6)
readline = sys.stdin.readline 

n = int(input())
a = [int(i) for i in readline().split()]

num = [0]*1000001
db = [0]*1000001
for i in a:
    num[i] += i
    db[i] += i*i
    db[i] %= MOD

def zeta(a,n):
    sieve = [True]*(n+1)
    for p in range(2,n):
        if sieve[p]:
            for k in range(n//p,0,-1):
                sieve[k*p] = False
                a[k] += a[k*p]
                a[k] %= MOD
    return a


def meb(a,n):
    sieve = [True]*(n+1)
    for p in range(2,n):
        if sieve[p]:
            for k in range(1,n):
                if k*p >= n: break
                sieve[k*p] = False
                a[k] -= a[k*p] 
                a[k] %= MOD
    return a


#n = 1000000

n = 1000000

#zn = [i*i for i in zeta(num,n)]
#zdb = zeta(db,n)
#print(zn[:20])
#print(zdb[:20])

zn = [i*i for i in zeta(num,n)]
zdb = zeta(db,n)
ans = [i-j for i,j in zip(zn, zdb)]

#ans = [i*i-j for i,j in zip(zeta(num,n), zeta(db,n))]

#print(ans[:20])
#print(meb(ans,n)[:20])

res = 0
for i,c in enumerate(meb(ans,n+1)):
    res = (res + c*inv[i])%MOD
        
print(res*inv[2]%MOD)
X = int(input())

p = [0]*100

flag = False
for i in range(100):
    p[i] = i**5

for i in range(1,100):
    for j in range(1,100):
        if p[i]-p[j] == X or flag:
            a = i
        
            b = j
            flag=True
        if p[i] + p[j] ==X or flag:
            a=i
            b=-j
            flag=True
        if flag:
            break
    if flag:
        break
            
print(flag)
print(str(a)+" "+str(b))


### FIXED CODE ###

X=int(input())
A=0
B=0
flag = False
for a in range(120):
    for b in range(120):
        if a**5 - b**5 == X:
            A=a
            B=b
            flag = True

        if a ** 5 + b**5 == X:
            A=a
            B=-b

        if -a**5 + b**5 ==X:
            A =-a
            B = b

        if flag:
            break
    if flag:
        break
print(str(A)+" "+str(B))
n,m=map(int,input().split())
a=list(int(input()) for i in range (m))
x=[0]*n
if a[0]==1:
    x[0]=0
else:
    x[0]=1

if m>=2:
	if a[0]!=2 and a[1]!=2:
		x[1]=x[0]+1

if m==1:
    if a[0]!=2:
	       x[1]=x[0]+1

if n>3:
    for k in range(2,n):
        for z in range(m):
            x[a[z]-1]=0
        x[k]=x[k-2]+x[k-1]
else:
    x[2]=x[1]+x[0]
print(x[n-1]%1000000

### FIXED CODE ###

import sys

n,m=map(int,input().split())
broken=set(map(int,sys.stdin))

if n==1:
  print (1)
  sys.exit()
if n==2:
  if 1 not in broken and 2 not in broken:
    print (2)
  elif 2 in broken:
    print(0)
  elif 1 in broken and 2 not in broken:
    print(1)
  sys.exit()

way = [0]*n
if 1 not in broken:
  way[0]=1
if 1 not in broken and 2 not in broken:
  way[1]=2
elif 1 in broken and 2 not in broken:
  way[1]=1
for i in range(2,n):
  if i+1 in broken:
    way[i]=0
    continue
  way[i]=(way[i-1]+way[i-2])%1000000007
print(way[n-1])
H, W, M = map(int, input().split())
h = [0] * (H+1)
w = [0] * (W+1)
l = [[0]*(W+2) for i in range(H+2)]
for i in range(M):
  x, y = map(int, input().split())
  h[x] += 1
  w[y] += 1
  l[x][y] = 1

a = [i for i, x in enumerate(h) if x == max(h)]
b = [i for i, x in enumerate(w) if x == max(w)]

flag = False
for s in a:
  for t in b:
    if l[s][t] == 0:
      flag = True
      break
  if flag:
    break
if flag:
  ans = max(h)+max(w)
else:
  ans = max(h)+max(w)-1
print(ans)


### FIXED CODE ###

H, W, M = map(int, input().split())
h = [0] * (H+1)
w = [0] * (W+1)
l = set()
for i in range(M):
  x, y = map(int, input().split())
  h[x] += 1
  w[y] += 1
  l.add((x, y))
  
c = max(h)
d = max(w)
a = [i for i, x in enumerate(h) if x == c]
b = [i for i, x in enumerate(w) if x == d]

flag = False
for s in a:
  for t in b:
    if (s, t) not in l:
      flag = True
      break
  if flag:
    break
ans = c+d
if not flag:
  ans -= 1
print(ans)
n,h=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
a.reverse()
for k in range(0,h):
  a[k]=0
print(sum(a))

### FIXED CODE ###

n,h=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
a.reverse()
c=[0]*2
c[0]=h
c[1]=len(a)
for k in range(0,min(c)):
  a[k]=0
print(sum(a))
N = int(input())
A = list(map(int, input().split()))
print(max(N)-min(N))

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
print(max(A)-min(A))
S=input()

if S="MON":
    print(6)
elif S = "TUE":
    print(5)
elif S = "WED":
    print(4)
elif S="THU":
    print(3)
elif S="FRI":
    print(2)
elif S="SAT":
    print(1)
else:
    print(7)

### FIXED CODE ###

S=input()

if S=="MON":
    print(6)
elif S == "TUE":
    print(5)
elif S == "WED":
    print(4)
elif S=="THU":
    print(3)
elif S=="FRI":
    print(2)
elif S=="SAT":
    print(1)
else:
    print(7)
N,K=list(map(int,input().split()))

AB =sorted([tuple(map(int,input().split())) for i in range(N)],key=lambda x:-x[0])

B=1

for a,b in AB:
  a,b=tuple(map(int,
  if B>=K :
    print(a)
    quit()
  B+=b
  


### FIXED CODE ###

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

AB =sorted([tuple(map(int,input().split())) for i in range(N)])

B=0

for a,b in AB:
  #print(K,N,a,b,B)
  B+=b
  if B>=K :
    print(a)
    quit()
  #B+=b
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

lst=ruiseki(a)
ans=float('inf')

kirekomi=[1,3]

for i in range(2,n-1):
    while 1:
        if abs(lst[kirekomi[0]]-(lst[i]-lst[kirekomi[0]]))>abs(lst[kirekomi[0]+1]-(lst[i]-lst[kirekomi[0]+1])):
            kirekomi[0]+=1
        else:
            break
    
    while 1:
        if abs((lst[n]-lst[kirekomi[1]])-(lst[kirekomi[1]]-lst[i]))>abs((lst[n]-lst[kirekomi[1]+1])-(lst[kirekomi[1]+1]-lst[i])):
            kirekomi[1]+=1
        else:
            break
    
    # print(kirekomi)
    p=lst[kirekomi[0]]
    q=lst[i]-lst[kirekomi[0]]
    r=lst[kirekomi[1]]-lst[i]
    s=lst[n]-lst[kirekomi[1]]
    anslst=[p,q,r,s]
    ans=min(ans,max(anslst)-min(anslst))
    # print(anslst)
print(ans)

### FIXED CODE ###

import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

lst=ruiseki(a)
ans=float('inf')

kirekomi=[1,3]

for i in range(2,n-1):
    while 1:
        if abs(lst[kirekomi[0]]-(lst[i]-lst[kirekomi[0]]))>abs(lst[kirekomi[0]+1]-(lst[i]-lst[kirekomi[0]+1])):
            kirekomi[0]+=1
        else:
            break
    
    while 1:
        if abs((lst[n]-lst[kirekomi[1]])-(lst[kirekomi[1]]-lst[i]))>abs((lst[n]-lst[kirekomi[1]+1])-(lst[kirekomi[1]+1]-lst[i])):
            kirekomi[1]+=1
        else:
            break
    
    # print(kirekomi)
    p=lst[kirekomi[0]]
    q=lst[i]-lst[kirekomi[0]]
    r=lst[kirekomi[1]]-lst[i]
    s=lst[n]-lst[kirekomi[1]]
    anslst=[p,q,r,s]
    ans=min(ans,max(anslst)-min(anslst))
    # print(anslst)
print(ans)
S = input()

print(s[:-8])


 
    

### FIXED CODE ###

S = input()

print(S[:-8])
n = input()
a = np.array([int(i) for i in input().split()])

for i in range(int(n)):
    print(a.count(i+1))


### FIXED CODE ###

num = int(input())
h_numbers = list(map(int, input().split()))
s = [0] * num
for i in h_numbers:
    s[i-1] += 1
[print(i) for i in s]
N, M = map(int, input().split())
A = list(map(int, input().split()))

def nax(a, b):
    if a == '-':
        return b
    if len(a) != len(b):
        return a if len(a)>len(b) else b
    return a if a>b else b


match = [2,5,5,4,5,6,3,7,6]
# dp[i]  : iほんのマッチを使ってできる数値の最大値
dp = ['-'] * 10001
dp[0] = ''

for i in range(N+1):
    if dp[i] == '-':
        continue
    for a in A:
        dp[i+match[a-1]] = nax(dp[i+match[a-1]], dp[i] + chr(ord('0') + a))

print(dp[N])

### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))

def nax(a, b):
    if a == '-':
        return b
    if len(a) != len(b):
        return a if len(a)>len(b) else b
    return a if a>b else b


match = [2,5,5,4,5,6,3,7,6]
# dp[i]  : iほんのマッチを使ってできる数値の最大値
dp = ['-'] * 11000
dp[0] = ''

for i in range(N+1):
    if dp[i] == '-':
        continue
    for a in A:
        dp[i+match[a-1]] = nax(dp[i+match[a-1]], dp[i] + chr(ord('0') + a))

print(dp[N])
arr = map(int,input().split(" "))
mx=arr(0)
mn=arr(0)
for a in srr:
  if(mx<a):
    mx=a
  else if(mn>a):
      mn=a

      print(mx-mn)

### FIXED CODE ###

aa = input()
arr = list(map(int,input().split(" ")))
mx=arr[0]
mn=arr[0]
for aaa in arr:
  if(mx<aaa):
    mx=aaa
  elif(mn>aaa):
    mn=aaa

print(mx-mn)
n = list(input())

if n % 2 == 0:
	for i in range(len(n)//2):
		if n[i] =="b":
			if n[-(i+1)] != "d":
				print("No")
				exit()
		elif n[i] == "p":
			if n[-(i+1)] != "q":
				print("No")
				exit()
		elif n[i] == "d":
			if n[-(i+1)] != "b":
				print("No")
				exit()
		elif n[i] == "q":
			if n[-(i+1)] != "p":
				print("No")
				exit()
	print("Yes")
else:
	print("No")

### FIXED CODE ###

n = list(input())

if len(n) % 2 == 0:
	for i in range(len(n)//2):
		if n[i] =="b":
			if n[-(i+1)] != "d":
				print("No")
				exit()
		elif n[i] == "p":
			if n[-(i+1)] != "q":
				print("No")
				exit()
		elif n[i] == "d":
			if n[-(i+1)] != "b":
				print("No")
				exit()
		elif n[i] == "q":
			if n[-(i+1)] != "p":
				print("No")
				exit()
	print("Yes")
else:
	print("No")
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, L = map(int, input().split())
# 文字列用のリスト
s = []
# L回分のインプットを受け入れる
for i in range(L):
	s.append(input())
# リストの昇順の並び替え
s.sort()
# 出力
print(''.join(s))

### FIXED CODE ###

# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, L = map(int, input().split())
# 文字列用のリスト
s = []
# N回分のインプットを受け入れる
for i in range(N):
	s.append(input())
# リストの昇順の並び替え
s.sort()
# 出力
print(''.join(s))
s=input()
q=int(input()) 

cnt = [0]*(q+5)
arr=[]
l=0
r=0

for i in range(q):
    t=input().split()
    if t[0]=='1':
        r+=1
        cnt[0]+=1 
        cnt[l]-=1 
    else:
        arr.append([t[2],int(t[1])])
        l+=1 
if r%2==1:
    s=s[::-1]
sm=0
for i in range(len(arr)):
    sm+=cnt[i]
    if sm%2==1:
        if arr[i][1]==1:arr[i][1]=2
        elif arr[i][1]==2:arr[i][1]=1 
ans1=""
ans2=""
for i in range(len(arr)):
    if arr[i][1]==1:
        ans1+=arr[i][0]

    else:ans2+=arr[i][0]
print("%s%s%s"%(ans1[::-1],s,ans2))        
        
    
    
    
    

### FIXED CODE ###

s=input()
if s.count("A")>0 and s.count("B")>0:
    print("Yes")
else:
    print("No")
l,n=map(int,input().split())
D=[]
for _ in range(n):
    D.append(str(input()))

S.sort(D,reverse=False)
m=" "
for i in S:
    m+=i

print(m)

### FIXED CODE ###

n,l=map(int,input().split())
list=[]
for _ in range(n):
    list.append(input())
 
list.sort()
ans=""
for i in list:
    ans+=i
print(ans)
H, W, M = map(int, input().split())

countW = {0:0}
countH = {0:0}
bomb = [[0]*(W+1) for _ in range(H+1)]
for i in range(M):
    h, w = map(int, input().split())
    bomb[h][w] += 1
    if h in countH.keys():
        countH[h] += 1
    else:
        countH[h] = 1
    if w in countW.keys():
        countW[w] += 1
    else:
        countW[w] = 1

sortedW = sorted(countW.items(), key=lambda x:x[1])
sortedH = sorted(countH.items(), key=lambda x:x[1])

ans = 0
szH = len(sortedH)
szW = len(sortedW)
found = False
for h in range(szH-1, 0, -1):
    if found: break
    hh, bh = sortedH[h]
    for w in range(szW-1, 0, -1):
        ww, bw = sortedW[w]
        nval = bh + bw - bomb[hh][ww]
        if ans < nval: ans = nval
        elif ans > nval:
            found = True
            break

print(ans)


### FIXED CODE ###

H, W, M = map(int, input().split())

countW = [0]*(W+1)
countH = [0]*(H+1)
bomb = []
for i in range(M):
    h, w = map(int, input().split())
    bomb.append((h, w))
    countH[h] += 1
    countW[w] += 1

maxW = max(countW)
maxH = max(countH)
ans = maxW + maxH - 1
countMaxW = countW.count(maxW)
countMaxH = countH.count(maxH)

sumz = 0
for i in range(M):
    h, w = bomb[i]
    if countH[h] == maxH and countW[w] == maxW:
        sumz += 1

if countMaxW*countMaxH > sumz:
    ans += 1
print(ans)
n, m = map(int, input().split())
Xm = list(map(int, input().split()))
if n >= m:
    print(0)
else:
    Xm.sort()
    check = [Xm[i+1] - Xm[i] for i in range(m-1)]
    check.sort(reverse=True)
    print(sum(check) - check[:n-1])


### FIXED CODE ###

n, m = map(int, input().split())
Xm = list(map(int, input().split()))
Xm.sort()
check = [Xm[i+1] - Xm[i] for i in range(m-1)]
check.sort()
print(sum(check[:max(m-n, 0)]))
S = list(str(input()))

ans = 0
num = 0
while num < len(S):
  num += 1
  s = S[:len(S)-num]
  if len(s) % 2 == 0:
  　　if s[:len(s)/2] == s[len(s)/2:]:
        ans = len(s)
        break
print(ans)

### FIXED CODE ###

S = list(str(input()))

ans = 0
num = 0
while num < len(S):
  num += 1
  s = S[:len(S)-num]
  if len(s) % 2 == 0:
    if s[:int(len(s)/2)] == s[int(len(s)/2):]:
      ans = len(s)
      break
print(ans)
def solve():
  from itertools import accumulate
  from sys import stdin
  
  f_i = stdin
  N, K = map(int, f_i.readline().split())
  A = map(int, f_i.readline().split())
  S = [0] * (N + 1)
  rec = dict(zip(range(K), [0] * K))
  rec[0] = 1
  
  ans = 0
  for j, a in enumerate(A, start=1):
    S[j] = (S[j-1] + a) % K
    d = (S[j] - j) % K
    ans += rec[d]
    rec[d] += 1
    i = j - K + 1
    if i >= 0:
      d = (S[i] - i) % K
      rec[d] -= 1
  
  print(ans)

solve()  

### FIXED CODE ###

def solve():
  from itertools import accumulate
  from sys import stdin
  
  f_i = stdin
  N, K = map(int, f_i.readline().split())
  A = map(int, f_i.readline().split())
  S = accumulate(a - 1 for a in A)
  S = (0, ) + tuple(s % K for s in S)
  
  rec = {}
  ans = 0
  for j, S_j in enumerate(S):
    if j >= K:
      rec[S[j-K]] -= 1
    if S_j in rec:
      ans += rec[S_j]
      rec[S_j] += 1
    else:
      rec[S_j] =1
  
  print(ans)

solve()
import math
from bisect import bisect_right
def getVal(i):  # get value of node (i,i)
    v = T[(i,i)][0]
    cur = (i,i)
    cur = T[cur][1]
    while cur[0]>=0:
        v += T[cur][0]
        cur = T[cur][1]
    return v
def udT(i,j,x,node):  # add x between [i,j] where current node is given
    l,r = node[0],node[1]
    if i<=l and r<=j:
        T[node][0] += x
    elif i>r or j<l:
        return
    else:
        udT(i,j,x,T[node][2])
        udT(i,j,x,T[node][3])
N,D,A = map(int,input().split())
X = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[0])
n = math.ceil(math.log2(N))
for i in range(N,2**n):  # fill in the remainder of N
    X.append([X[-1][0]+1,0])
# Construction of Tree
Y = [X[i][0] for i in range(N)]  # Tree structure
T = {(i,i):[X[i][1],(i,i+1) if i%2==0 else (i-1,i),(-1,-1),(-1,-1)] for i in range(2**n)}  # T[node] = [value,parent,left_child,right_child]
for h in range(n):
    for i in range(2**h):
        d = 2**(n-h)  # interval length of each node
        if h==0:
            T[(i*d,(i+1)*d-1)] = [0,(-1,-1),(i*d,i*d+d//2-1),((i+1)*d-d//2,(i+1)*d-1)]
        else:
            T[(i*d,(i+1)*d-1)] = [0,(i*d,i*d+2*d-1) if (i*d)%2**(n-h+1)==0 else ((i+1)*d-2*d,(i+1)*d-1),(i*d,i*d+d//2-1),((i+1)*d-d//2,(i+1)*d-1)]
cnt = 0
cur = 0
while cur<N:
    x = Y[cur]
    v = getVal(cur)
    if v%A==0:
        k = v//A
    else:
        k = v//A+1
    ind = bisect_right(Y,x+2*D)
    udT(cur,ind-1,-k*A,(0,2**n-1))
    cnt += k
    flag = 0
    for i in range(cur+1,N):
        if getVal(i)>0:
            cur = i
            flag = 1
            break
    if flag==0:
        cur = N
print(cnt)

### FIXED CODE ###

from bisect import bisect_right
N,D,A = map(int,input().split())
X = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[0])
B = [0 for _ in range(N+1)]
cnt = 0
cur = 0
delta = 0
flag = 0
while cur<N:
    x = X[cur][0]
    h = X[cur][1]+delta
    if h%A==0:
        n = h//A
    else:
        n = h//A+1
    ind = bisect_right(X,[x+2*D,10**9+1])
    B[cur] += -n*A
    B[ind] += n*A
    cnt += n
    flag = 0
    for i in range(cur,N):
        delta += B[i]
        B[i] = 0
        if X[i][1]+delta>0:
            cur = i
            flag = 1
            break
    if flag==0:
        cur = N
print(cnt)
import math

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

a,b,c,d=map(int, input().split())
re=[]
cd=lcm(c, d)

cc=int(b/c - a/c)
dc=int(b/d - a/d)
cdc=int(b/cd - a/cd)

print(b-a-cc-dc+cdc)

### FIXED CODE ###

import fractions

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

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

cc=b//c - (a-1)//c
dc=b//d - (a-1)//d
cdc=b//cd - (a-1)//cd

print(b-(a-1)-cc-dc+cdc)
S = input()
K = int(input())
if S[0] == '1':
    print(S[1])
else :
    print(S[0])

### FIXED CODE ###

s, k = input(), int(input())
ans = "1"
for i in range(k):
    if s[i]!="1":
        ans = s[i]
        break
print(ans)