peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))

mod = 10 ** 9 + 7

summ = 0
quadsum = 0

for k in range(n):
    summ = (summ + A[k]) % mod
    quadsum = (quadsum + A[k]*A[k])%mod

ans = (summ*summ)%mod - quadsum
if ans % 2 == 1:
    ans += mod
ans = (ans/2)%mod
print(int(ans))
# Judge status: Wrong Answer
n = int(input())
if n%1000 == 1:
    print(0)
else:
    print(1000-n%1000)
# Judge status: Accepted
s = input()
t = input()


ans = 0
for i in range(len(s)):
    if s[i] != t[i]:
        ans += 1
print(ans)
# Judge status: Accepted
a,b,c = map(int,input().split())
dummy = max(a,b,c)
print(a+b+c-dummy)
# Judge status: Accepted
A,B,C = map(int,input().split())

li = [A,B,C]
li.sort(reverse = True)
ans1 = li[0]*10+li[1]
ans2 =li[2]
ans = ans1 + ans2
print(ans)
# Judge status: Accepted
S=input()
T='keyence'
if S.count(T)>0:
  print('YES')
  exit()
  
for i in range(1, 7):
  if S[:i]==T[:i] and S[-7+i:]==T[-7+i:]:
    print('YES')
    exit()
    
print('NO')
# Judge status: Accepted
A,B,C = map(int,input().split())

print(min(C,B//A))
# Judge status: Accepted
N = int(input())

ans = 0
res = 0
for i in range(1,N+1):
    tmp = i
    cnt = 0
    while True:
        if tmp%2 == 0:
            cnt += 1
            tmp = tmp//2
        else:
            break
    if ans <= cnt:
        res = i
        ans = cnt
print(res)
# Judge status: Accepted
a = input()
if a == a.lower(): print("a")
else: print("A")
# Judge status: Wrong Answer
import math
k = int(input())
sevens = []
for i in range(1, 6):
    sevens.append("7"*i)

sevens2 = [int(s) for s in sevens]
ans = []

for i in range(0, len(sevens)):
    if sevens2[i]%k == 0:
        ans.append(i+1)

if ans:
    print(min(ans))
elif k%2 == 0:
    print(-1)
elif k ==5:
    print(-1)
elif k ==9:
    print(-1)
else:
    print(k-1)
# Judge status: Accepted
N, T = map(int,input().split())

cost_min = 1e9

for i in range(N):
  c, t = map(int,input().split())
  if t <= T:
    if c < cost_min:
      cost_min = c

if cost_min == 1e9:
  print("TLE")
else:
  print(cost_min)
# Judge status: Accepted
import math
N = int(input())
x = math.ceil(N/1000) * 1000
print(x-N)
# Judge status: Accepted
N=int(input())
A=list(map(int, input().split()))
B=[0] * N

for i in range(N):
  while A[i] % 2 == 0:
    A[i] /= 2
    B[i] += 1

print(min(B)) if min(B) > 0 else print(0)
# Judge status: Accepted
S = input()
ans, prev, cur = 0, "", ""
for s in S:
    cur += s
    if cur != prev:
        ans += 1
        prev, cur = cur, ""
print(ans)
# Judge status: Wrong Answer
from itertools import combinations_with_replacement as cmb

n,m,q=map(int,input().split())
abcd=[]
for i in range(q):
    ll=map(int,input().split())
    ll=[ww-1 for ww in ll]
    abcd.append(ll)
ans=0
for li in cmb(range(1,m+1),n):
    kari=0
    for i in abcd:
        if li[i[1]]-li[i[0]]==i[2]+1:
            kari+=i[3]+1
    print(li,kari)
    ans=max(ans,kari)

print(ans)
# Judge status: Accepted
N, Y = map(int, input().split())

a = 0

for i in range(N+1):

    for ii in range(N+1):

        iii = N - i - ii

        if iii < 0:
            break
        ans = 10000 * i + 5000 * ii + 1000 * iii
        if ans == Y:
                print(i,ii,iii)
                a += 1
                break

    if a != 0:
        break

if a == 0:
    print(-1,-1,-1)
# Judge status: Accepted
n = int(input())

sList = []
for i in range(n):
  sList.append(list(input().split())+[i+1])
  sList[i][1] = -1*int(sList[i][1])
sList.sort()

for i in sList:
  print(i[2])
# Judge status: Accepted
n = int(input())
if n%2 == 0:
    i = 1
    ans = 0
    while 2*pow(5,i) <= n:
        ans += n//(2*pow(5,i))
        i += 1
    print(ans)
else:
    print(0)
# Judge status: Accepted
P, Q, R = list(map(int, input().split()))

print(min(P+Q, Q+R, R+P))
# Judge status: Wrong Answer
a=list(str(input()))
b=a[::-1]
cnt = 0
for i in range(len(a)):
  if a[i] != b[i]:
    cnt+=1
print(cnt)
# Judge status: Wrong Answer
def check():
  N = int(input())
  A = list(map(int, input().split()))
  B = list(map(int, input().split()))
  diff = sum(B)-sum(A)
  if diff < 0:
    return 'No'
  cnt = 0
  for i in range(N):
    cnt += max(B[i]-A[i],0)
  if diff*2 < cnt:
    return 'No'
  return 'Yes'
print(check())
# Judge status: Accepted
s = input()

if s == 'AAA' or s == 'BBB':
    print('No')
else:
    print('Yes')
# Judge status: Wrong Answer
N, M = map(int, input().split())

for i in range(1,M+1):
  print(i, N-i+1)
# Judge status: Wrong Answer
s=list(input())
t=list(input())
s.sort()
t.sort(reverse=True)
s="".join(s)
t="".join(t)
for i in range(min(len(s),len(t))):
  if ord(s[i])==ord(t[i]):
    continue
  elif ord(s[i])<ord(t[i]):
    print("Yes")
    break
  else:
    print("No")
else:
  print("No")
# Judge status: Wrong Answer
N = int(input())

import math

x=N*800
y=(math.ceil(N/15)-N//15)*200

print(x-y)
# Judge status: Accepted
import math
n=int(input())

for i in reversed(range(1,int(math.sqrt(n))+1)):
  if n%i == 0:
    ans = i+n//i-2
    break
print(ans)
# Judge status: Accepted
import sys
sys.setrecursionlimit(10**6)


def DFS(num):
    A.add(int(num))
    n=int(num[-1])
    for i in (max(n-1,0),n,min(n+1,9)):
        i=str(i)
        A.add(int(num+i))
        if len(num)<=8:DFS(num+i)


n=int(input())
A=set()
for i in range(1,10):
    DFS(str(i))
A=sorted(A)
print(A[n-1])
# Judge status: Wrong Answer
n,k=map(int,input().split())
a=[[int(i) for i in input().split()] for i in range(n)]
b=[0]*((10**5)+1)
for i in a:
    b[i[0]]+=i[1]
x=0
for i in range(10**5):
    x+=b[i]
    if x>=k:
        print(i)
        exit()
# Judge status: Accepted
import math
A, B = map(int, input().split())

print(math.ceil((A+B)/2))
# Judge status: Wrong Answer
import math

A, B = [int(i) for i in input().split()]
ans = []
for i in range(10):
    for j in range(10):
        A_float = A + 0.1 * i
        B_float = B + 0.1 * j

        x_a = math.floor(A_float / 0.08)
        x_b = math.floor(B_float / 0.1)
        
        if x_a == x_b:
            ans.append(x_a)
            
if len(ans) > 0:
    print(min(ans))
else:
    print(-1)
# Judge status: Wrong Answer
n,k = map(int,input().split())
a = list(map(int,input().split()))

if(len(set(a)) <= k):
    print(0)
else:
    dic_a = {x:0 for x in set(a)}
    for i in a:
        dic_a[i] += 1
    sum = 0
    af = sorted(dic_a.items(), key=lambda x: x[0])
    for i in range(k,len(set(a))):
        sum += af[i][1]
    print(sum)
# Judge status: Wrong Answer
import sys
read=sys.stdin.buffer.read
A,B=map(int,read().split())
l=[1,2,3]
res = filter(lambda x:x!=A and x!=B, l)
print(res)
# Judge status: Accepted
a,b,c,d=map(int,input().split())
print("Yes" if (abs(b-a)<=d and abs(c-b)<=d) or abs(c-a)<=d else "No")
# Judge status: Accepted
n = int(raw_input())
count = 0
res = 0
ais = map(int , raw_input().split())

for i,a in enumerate(ais):
	
	if a == i +1:
		count += 1
	else:
		#flush the count
		res += (count + 1)/2# + 1
		count = 0

if count: res +=  (count+1)/2 
print res
# Judge status: Accepted
a, b, c, k = map(int, input().split())
ans = a - b
if abs(ans) > 1e18 :
    print("Unfair")
elif k % 2 == 0 :
    print(ans)
else :
    print(-ans)
# Judge status: Accepted
N, M = map(int, input().split(' '))

syuku = list(map(int, input().split(' ')))

result = N - sum(syuku)

print(result) if result >= 0 else print('-1')
# Judge status: Accepted
N = int(input())
a = 0
l = []
for i in map(int,input().split()):
  l.append(i)
  a = a ^ i
for i in l:
  print(a ^ i)
# Judge status: Wrong Answer
s,c = map(int,input().split(" "))
count = 0
if s == 0:
    print(c // 3)
else:
    count += min(s,c // 2)
    c -= s * 2
    count += c // 4
print(count)
# Judge status: Wrong Answer
from collections import Counter

N = int(input())
*D, = map(int, input().split())
mod = 998244353
c = Counter(D)
v = max(D)

if c[0]!=1 or v>N-1:
    print(0)
else:
    ans = 1
    for i in range(1, v+1):
        ans *= (c[i-1]**c[i])
        ans %= mod
    print(ans)
# Judge status: Accepted
A, B, K = map(int, input().split())
ans = []
for i in range(1, 101):
    if A % i == 0 and B % i == 0:
        ans.append(i)
print(ans[-K])
# Judge status: Wrong Answer
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
C=Counter(a)
#print(C)
total=0
for k,v in C.items():
    if v>=2:
        total+=v*(v-1)//2
print(total)
for i in range(n):
    V=C[a[i]]
    ans=total-(V*(V-1))//2+((V-1)*(V-2))//2
    print(ans)
# Judge status: Accepted
import sys
import heapq
from decimal import Decimal

input = sys.stdin.readline

x = int(input())


for i in range(1,1000):
    for j in range(-1000,1000):
        if i**5 - j**5 == x:
            print(i,j)
            exit(0)
# Judge status: Accepted
n=int(input())
b=list(map(int,input().split()))
ans=0
a=[]
a.append(b[0])
for i in range(1,n-1):
  a.append(min(b[i-1],b[i]))

a.append(b[n-2])
for i in range(n):
  ans+=a[i]
  
print(ans)
# Judge status: Accepted
k, n = [int(elem) for elem in input().split()]
a_lst = [int(elem) for elem in input().split()]

diff = []
for i, a in enumerate(a_lst[:-1]):
    diff.append(a_lst[i+1] - a)
diff.append((a_lst[0] + k) - a_lst[-1])

res = sum(diff) - max(diff)
print(res)
# Judge status: Wrong Answer
from itertools import permutations

N = int(input())
ans = []

for p in permutations(range(N)):
    D = [-1] * N
    A = []
    for i in range(N):
        for j in range(N):
            if D[j] < p[i]:
                D[j] = p[i]
                A.append(j)
                break
    ans.append(A)

ans.sort()

for a in ans:
    s = ''.join(map(lambda x:chr(x+97),a))
    print(s)
# Judge status: Accepted
n,x,y=map(int,input().split())
anslist = [0]*(n)
temp = 0
for i in range(1,n):
    for j in range(i+1,n+1):
        temp = min(abs(j-i),(abs(x-i)+1+abs(y-j)),(abs(y-i)+1+abs(x-j)))
        anslist[temp] += 1

anslist.pop(0)

for i in anslist:
    print(i)
# Judge status: Accepted
n,k = map(int,input().split())

d = []
a = []

for _ in range(k):
  d.append(int(input()))
  a.append(list(map(int,input().split())))
ans = [1] * n
for i in range(k):
  for j in range(d[i]):
    if ans[a[i][j]-1] == 1:
      ans[a[i][j]-1] = 0

print(sum(ans))
# Judge status: Accepted
x = int(input())
if x>= 30 :
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
n, l = map(int, input().split())

a = [[] * l for i in range(n)]
for i in range(n):
    I = input()
    for j in range(l):
        a[i].append(I[j])
# print(a)
b = a
for i in range(l):
    b = sorted(b, key=lambda x: x[i])

ans = []
for i in range(n):
    ans.append("".join(b[i]))
print("".join(ans))
# Judge status: Accepted
a, b, c = map(int, input().split())

if a<c<b or b<c<a:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
N,X = map(int,input().split())
L = list(map(int,input().split()))
counter = 1
total = 0
for l in L:
    total+=l
    if(total <=X):counter+=1

print(counter)
# Judge status: Accepted
import queue
k = int(input())
q = queue.Queue()
for i in range(1,10):
    q.put(i)
cnt = 0
runrun = 0
while cnt < k:
    runrun = q.get()
    cnt += 1
    if runrun % 10 != 0:
        q.put(10 * runrun + (runrun % 10) - 1)
    q.put(10 * runrun + (runrun % 10))
    if runrun % 10 != 9:
        q.put(10 * runrun + (runrun % 10) + 1)
print(runrun)
# Judge status: Wrong Answer
x = input()
if x == 0:
    print(1)
if x == 1:
    print(0)
# Judge status: Wrong Answer
a = [ int(input()) for i in range(4) ]
count = 0


for k in range(a[2]+1):
    for j in range(a[1]+1):
        for i in range(a[0]+1):
            total = 50 * i + 100 * j + 500 * k
            if total == a[3]:
                count += 1

print(count)
# Judge status: Accepted
N,K,Q = map(int,input().split())

scores = [K] * N

for i in range(Q):
  a = int(input())
  scores[a - 1] += 1

for s in scores:
  print(("No","Yes")[s - Q > 0])
# Judge status: Wrong Answer
N = int(input())
B = list(map(int,input().split()))

A = []
A.append(B[0])
A.append(B[0])
for i in range(1,N-2):
    A.append(min(B[i],B[i+1]))
if N > 2:
    A.append(B[N-2])
print(sum(A))
# Judge status: Accepted
n = int(input())

s = 0
for i in range(1, n+1):
  if i % 2 != 0:
    s += 1
print(s/n)
# Judge status: Accepted
k = int(input())
a, b = map(int, input().split())

f = False
for i in range(a, b + 1):
    if i % k == 0:
        f = True

if f:
    print('OK')
else:
    print('NG')
# Judge status: Accepted
s=list(input())
s=s[:-2]
while s:
    n=len(s)//2
    p=s[:n]
    q=s[n:]
    if p==q:
        print(2*n)
        break
    else:
        s=s[:-2]
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
ret = 0
flg = False
while flg == False:
    for i in range(len(a)):
        if(a[i] == 0 or a[i]%2 != 0):
            flg = True
        else:
            a[i] = a[i]/2
    
    if not flg:
        ret += 1
    

print(ret)
# Judge status: Accepted
# https://atcoder.jp/contests/abc073/tasks/abc073_c
n = int(input())
nums = []
for _ in range(n):
    nums.append(int(input()))

s = set()
for num in nums:
    if num in s:
        s.remove(num)
    else:
        s.add(num)
ans = len(s)
print(ans)
# Judge status: Accepted
S = input()
A = S.count("0")
B = S.count("1")
print(2*min(A, B))
# Judge status: Accepted
N = int(input())
M = 1000000007
t, t1, t2 = 1, 1, 1

for _ in range(N):
    t, t1, t2 = t*10, t1*9, t2*8
    t, t1, t2 = t%M, t1%M, t2%M

print((t - t1*2 + t2) % M)
# Judge status: Accepted
from decimal import Decimal
from heapq import heapify, heappop, heappush
N, K = map(int, input().split())
*A, = map(int, input().split())

tot = sum(A)

ng = 0
ok = 10**9

m = 4

while ng + 1 < ok:
    m = (ng+ok)//2
    c = sum((a-1)//m for a in A)
    if c > K:
        ng = m
    else:
        ok = m
print(ok)
# Judge status: Accepted
import math
n, m = map(int, input().split())
if m%2 == 0:
    divisor = [1, 2, m//2, m]
else:
    divisor = [1, m]
for i in range(3, int(math.sqrt(m))+1):
    if m%i == 0:
        divisor.append(i)
        divisor.append(m//i)
divisor = sorted(divisor, reverse=True)
a = m//n
for i in divisor:
    if i > a:
        continue
    if (m-(m//i*i))%i == 0:
        break
print(i)
# Judge status: Accepted
n = int(input())
h = list( map(int,input().split()) )
x = [0] * (n+1)

c = h[0]
for i in range(1,n):
  if h[i] <= c:
    x[i] = 1
  c = h[i]

ans = 0
tmp = 0
for i in x:
  if i == 1:
    tmp += 1
  else:
    ans = max(ans,tmp)
    tmp = 0

print(ans)
# Judge status: Wrong Answer
n = int(input())
l0 = 2
l1 = 1
cnt = 2
l2 = l0 + l1
while cnt < n:
    l2, l1, l0 = l2 + l1, l2, l1
    cnt += 1
print(l2)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
while len(a) > 0:
  m = min(a)
  a = [a[i]%m for i in range(len(a)) if a[i]%m > 0]
print(m)
# Judge status: Wrong Answer
n= int(input())
cnt = 1
for i in range(1,n+1):
  cnt *= i
print(cnt//(10**9+7))
# Judge status: Accepted
n=int(input())
a=[list(map(int,input().split())) for i in range(n)][::-1]
b=0
for i in range(n):
    if (b+a[i][0])%a[i][1]==0:
        continue
    b+=a[i][1]-(b+a[i][0])%a[i][1]
print(b)
# Judge status: Accepted
A,B=map(int,input().split())
if A <10 and B <10:
  print(A*B)
else:
  print("-1")
# Judge status: Accepted
n,t = map(int,input().split())

ct = [0]*n

for i in range(0,n):
  ct[i] = input().split()
  
s = []
for i in range(0,n):
  if(int(ct[i][1]) <= t):
    s.append(int(ct[i][0]))
if(len(s) != 0):
  print(min(s))
else:
  print("TLE")
# Judge status: Wrong Answer
w,h,n=map(int,input().split())

A=[0,w,0,h]
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        A[0]=max(A[0],x)
    elif a==2:
        A[1]=min(A[1],x)
    elif a==3:
        A[2]=max(A[2],y)
    else:
        A[3]=min(A[3],y)

squ=(A[1]-A[0])*(A[3]-A[2])

print(squ if squ>=0 else 0)
# Judge status: Wrong Answer
x = int(input())

a = x-x//100*100
print(1) if a//5+1 <= x//100 else 0
# Judge status: Accepted
N = int(input())
S = input()

cR = len([1 for s in S if s == 'R'])
cG = len([1 for s in S if s == 'G'])
cB = len([1 for s in S if s == 'B'])
# 条件2を無視したときの組の数
_all = cR * cG * cB

# 条件2でNGになるような組の数
ng_condition2 = 0
for i in range(N-1):
  for j in range(i+1, N):
    k = j+j-i
    if k >= N:
      break
    if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
      ng_condition2 += 1

print(_all - ng_condition2)
# Judge status: Wrong Answer
AB,BC,CU = input().split()
AB = int(AB)
BC = int(BC)
CU = int(CU)

if 1 <= AB <= 100:
    if 1 <= BC <= 100:
        if 1 <= CU <= 100:
            area = (AB * BC )/ 2
            print(area)
# Judge status: Wrong Answer
a = int(input())
a = a%4
a = a%7
if a == 0:
  print('Yes')
else:
  print('No')
# Judge status: Accepted

a=int(input())
if a>=1800:
    print(1)
elif a>=1600 and a<1800:
    print(2)
elif a>=1400 and a<1600:
    print(3)
elif a>=1200 and a<1400:
    print(4)
elif a>=1000 and a<1200:
    print(5)
elif a>=800 and a<1000:
    print(6)
elif a>=600 and a<800:
    print(7)
elif a>=400 and a<600:
    print(8)
# Judge status: Accepted
N = int(input())
output = []
for i in range(N):
    S = input()
    output.append(S)
print(len(set(output)))
# Judge status: Accepted
from itertools import accumulate
N, X = [int(x) for x in input().split()]
a = sorted([int(x) for x in input().split()])
p = list(accumulate(a))

result = 0
for i, x in enumerate(p):
  if X < x:
    break
  if i == N-1 and x != X:
    break
  result += 1

print(result)
# Judge status: Accepted
n,d = map(int,input().split())
count = 0
for i in range(n):
    x,y = map(int,input().split())
    sum = x**2 + y**2
    if sum**0.5 <= d:
        count += 1

print(count)
# Judge status: Accepted
N=input()
N1=int(N[0])
N2=int(N[1])
print("Yes" if N1==9 or N2==9 else "No")
# Judge status: Accepted
n = int(input())
n_list = list(map(int, input().split()))
dp = [-1]*n
dp[0] = 0
dp[1] = abs(n_list[1]-n_list[0])

for i in range(2,n):
  dp[i] = min(abs(n_list[i]-n_list[i-1])+dp[i-1], abs(n_list[i]-n_list[i-2])+dp[i-2])
print(dp[n-1])
# Judge status: Accepted
def main():
    N = int(input())
    S = input()
    border = S.count("R")
    ans = 0
    for i in range(N):
        if S[i] == "W" and i < border:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
x = int(input())
for i in range(-119, 120):
  for j in range(-119, 120):
    if i**5 - j**5 == x:
      print(i,j)
      exit()
# Judge status: Wrong Answer
if __name__ == "__main__":
    n, a, b = list(map(int, input().split()))

    ans = 0

    if b > a and n > 2:
        ans = (n - 2) * b - (n - 2) * a + 1
    elif n == 1 and a == b:
        ans = 1
    elif n == 2 and b > a:
        ans = 1

    print(ans)
# Judge status: Accepted
N=int(input())
B=list(map(int, input().split()))
B.append(B[len(B)-1])
A=[0]*N
A[0]=B[0]
for i in range(1,N):
  A[i]=min(B[i-1],B[i])
  
print(sum(A))
# Judge status: Accepted
n = int(input())

if n%2 == 0:
  print(float((n//2)/n))
elif n == 1:
  print(float(1))
else:
  print(float((n//2 + 1)/n))
# Judge status: Accepted
from math import ceil, sqrt


def main():
    target = int(input())
    print(ceil((-1 + sqrt(1 + 8 * target)) / 2))


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
S = input()
cnt = 0
for i in range(3):
    if S[i] == "R":
        cnt += 1
print(cnt)
# Judge status: Wrong Answer
n=int(input())
p=list(map(int, input().split()))
q=list(map(int, input().split()))
ans = sum(p)+q[n-1]
for i in range(2, n-2):
  tmp = ans + q[n-i] - p[n-i+1]
  ans = max(ans, tmp)
print(ans)
# Judge status: Accepted
K = int(input())
S = input()
text = ''
if len(S) > K:
    text = S[:K] + '...'
else:
    text = S
print(text)
# Judge status: Accepted
n = int(input())
grid = [[0 for i in range(9)] for j in range(9)]
ans = 0

for i in range(1, n+1):
    s = str(i)
    if int(s[0]) == 0 or int(s[-1]) == 0:
        continue
    grid[int(s[0])-1][int(s[-1])-1] += 1

for i in range(9):
    for j in range(i, 9):
        if i == j:
            ans += grid[i][j] * grid[j][i]
        else:
            ans += (grid[i][j] * grid[j][i])*2

print(ans)
# Judge status: Wrong Answer
a, b = map(int, input().split())

print(0.5*(b-a)*(b-a-1)-a)
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
print("YES" if a*b*c == 35 else "NO")
# Judge status: Accepted
K, S=map(int, input().split())
s=S-2*K if S-2*K>0 else 0
e=S if S<K else K
ans=0
for Z in range(s, e+1):
  if S-Z>K:
    ans+=2*K+Z-S+1
  else:
    ans+=S-Z+1
print(ans)
# Judge status: Wrong Answer
L=sorted(map(int, input().split()))
if L==[5, 5, 7]:
  ans='Yes'
else:
  ans='No'
print(ans)
# Judge status: Wrong Answer
N,M=map(int,input().split())
nums={}
for i in range(M):
    s,c=map(str,input().split())
    if s in nums.keys():
        if nums[s]!=c:
            ans=-1
            print(ans)
            exit()
    else:
        nums[s]=c
for i in range(1,N+1):
    if str(i) not in nums.keys():
        nums[str(i)]='0'
n=[]
for i in sorted(nums):
    n.append(nums[i])
ans=int(''.join(n))
if len(list(str(ans)))!=N:
    ans=-1
print(ans)
# Judge status: Accepted
import math

n,h = map(int,input().split())
s = []
max_a = 0
for i in range(n):
    a,b = map(int,input().split())
    max_a = max(a,max_a)
    s.append((b,a))

if max_a >= h:
    print(1)
    exit()

s.sort(reverse=True)
ans = 10**9
i = 0
while h > 0 and i < n:
    h -= s[i][0]
    c = max(0,math.ceil(h/max_a))
    ans = min(i+c+1,ans)
    i += 1

print(ans)
# Judge status: Accepted
from math import ceil,floor

N=int(input())
X=ceil(N/1.08)
print(X if floor(X*1.08)==N else ":(")
# Judge status: Accepted
N, M = map(int, input().split())
X = list(map(int, input().split()))
X.sort()
D = []
for i in range(len(X)-1):
    D.append(X[i+1]-X[i])
D.sort()
if N>=M:
    print(0)
else:
    print(sum(D[:M-N]))
# Judge status: Wrong Answer
N = int(input())
import collections

b = input().split()
c = collections.Counter(b)
d = list(c.values())
e = list(c.keys())

current = 0
for i in range(N):
    if len(c) > current:
        if e[current] == str(i + 1):
            print(d[current])
            
            current += 1
        else:
            print('0')
            
    else:
        print('0')
# Judge status: Accepted
n, m = map(int, input().split())

problem = [False] * n
count_wa = [0] * n


for _ in range(m):
    num, res = input().split()
    num = int(num) - 1

    if res == 'AC':
        problem[num] = True

    else:
        if problem[num] == False:
            count_wa[num] += 1
        else:
            continue

a = sum(problem)
b = 0

for i in range(n):
    if problem[i] == True:
        b += count_wa[i]

print(a, b)
# Judge status: Accepted
a,b = map(int, input().split())
if a <= 8 and b <= 8:
  print('Yay!')
else:
  print(':(')
# Judge status: Accepted
import sys
n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
b = []

for _ in range(m):
    b += [list(map(int, input().split()))]
b = sorted(b, key=lambda x: x[1], reverse=True)

for i in range(m):
    for j in range(b[i][0]):
        if a[0] < b[i][1]:
            a.pop(0)
            a.append(b[i][1])
        else:
            print(sum(a))
            sys.exit()
print(sum(a))
# Judge status: Accepted
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    A = list(map(int, input().split()))
    if  n >= sum(A):
        print(n - sum(A))
    else:
        print(-1)

if __name__ == '__main__':
    resolve()
# Judge status: Accepted
N,M = map(int,input().split())
foods = [0] * (M+1)
for i in range(N):
    line = list(map(int,input().split()))
    for j in range(1,line[0]+1):
        foods[line[j]] += 1
print(foods.count(N))
# Judge status: Wrong Answer
a=list(input())
b=list(input())
a.append(b[-1])
print(a,b)
if a==b:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
X,Y = map(int,input().split())

cnt = 0

while X <= Y:
    X += X
    cnt += 1

print(cnt)
# Judge status: Accepted
K, A, B = map(int, input().split())

if (B - A) <= 2:
    print(K + 1)
elif K <= A:
    print(K + 1)
else:
    M = K - A + 1
    ans = A + M // 2 * (B - A) + M % 2
    print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    S = list(input())
    for _ in range(len(S)):
        S.pop()
        if S[:len(S) // 2] == S[len(S) // 2:]:
            print(len(S))
            break


if __name__ == "__main__":
    main()