peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import collections

N = int(input())

S = collections.Counter(list(input()))
for i in range(N-1):
    c = collections.Counter(list(input()))
    S &= c

print(sum(S.values()))
# Judge status: Wrong Answer
def ston():
  n = int(input())
  k = int(input())
  x = int(input())
  y = int(input())
  if n <= k:
    print(n*x)
  else:
    print(k*x + (n-k)*y)
# Judge status: Wrong Answer
import math
import fractions


N, M = map(int, input().split())
a_i = list(map(int, input().split()))
half_a_i = []

for i in a_i:
    i //= 2
    half_a_i.append(i)

lcm = half_a_i[0]

for i in range(1, N):
    lcm = lcm * half_a_i[i] // fractions.gcd(lcm, half_a_i[i])



if (M // lcm) == 0:
    print(0)
else:
    print(((M // lcm) // 2) + 1)
# Judge status: Wrong Answer
n=int(input())
k=int(input())
x=int(input())
y=int(input())
if n>k:
  print(k*x+(n-k)*y)
else:
  print(k*n)
# Judge status: Accepted
n = int(input())
c = input()

l = 0
r = n - 1

ans = 0

while True:
  while c[l] == 'R' and l < r:
    l += 1
  while c[r] == 'W' and l < r:
    r -= 1
  if l < r:
    ans += 1
    l += 1
    r -= 1
  else:
    print(ans)
    break
# Judge status: Accepted
a,b,c,k=map(int,input().split())
ans=a
if a>k: ans=k
if a+b<k: ans-=(k-(a+b))
print(ans)
# Judge status: Wrong Answer
h, w = [int(x) for x in input().split()]

if h%2 == 0 and w%2 == 0:
  print((h*w)//2)
else:
  print((h*w)//2+1)
# Judge status: Accepted
a,b,c,d = map(int, input().split())

A=a*c
B=a*d
C=b*c
D=b*d

print(max(A,B,C,D))
# Judge status: Wrong Answer
n = int(input())
for i in range(n):
	print("100")
# Judge status: Accepted
#

import sys
input=sys.stdin.readline

def main():
    x=list(map(int,input().split()))
    print(x.index(0)+1)
    
    
    
if __name__=="__main__":
    main()
# Judge status: Accepted
N, M = map(int, input().split())
A = [0 for i in range(N)]
B = [1 for i in range(N)]
A[0] = 1
for i in range(M):
  a, b = map(int, input().split())
  B[a-1] -= 1
  B[b-1] += 1
  if A[a-1] == 1:
    A[b-1] = 1
  if B[a-1] == 0:
    A[a-1] = 0
print(sum(A))
# Judge status: Accepted
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,L = map(int,input().split())

total = L*N
for i in range(N):
    total += i

if L<=0 and L+N-1>=0:
    print(total)
elif L>0:
    print(total - L)
else:
    print(total - (L+N-1))
# Judge status: Accepted
a, b, x = map(int, input().split())

mod = a % x
if mod == 0:
  start = a-(x-1)
else:
  start = a-(mod-1)
print((b-start+1)//x)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n):
    if n%2 and i==n-1:
        b[i]=a[n//2]
    else:
        if i<n//2:
            b[i]=a[n-i*2-1]
        else:
            b[i]=a[(i-n//2)*2]
print(' '.join(map(str,b)))
# Judge status: Wrong Answer
N,M=map(int,input().split())

if N >= 2*M:
  print(M//2)
  exit()
  
x = (M-2*N)//4
print(N+x)
# Judge status: Wrong Answer
N = int(input())
A = [0]
B = list(map(int, input().split()))
A += B
#print(A)

sig = [0] * N

for i in range(N-1):
  sig[A[i+1]] += 1
#print(sig)

print(sig)
for i in sig:
  print(i)
# Judge status: Accepted
def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor: GCD)を求める
    計算量: O(log(min(a, b)))
    """
    while b:
        a, b = b, a % b
    return a


x = int(input())
ans = gcd(x, 360)
print(360 // ans)
# Judge status: Wrong Answer
n = int(input())
s=(n-1)
ab = n//2 if n%2==0 else n//2 + 1
for x in range(2,ab):
    if n%x==0:
        s+=(n//x - 1)
    else:
        s+=(n//x)
print(s + n//2)
# Judge status: Wrong Answer
K = int(input())
S = str(input())

if len(S) <= K:
    print(S)
else:
    print(S[:7] + '...')
# Judge status: Accepted
import math
h = int(input())
w = int(input())
n = int(input())

done=0
count=0
while True:
  if h>w:
    if w==0:
      exit()
    else:
      done+=h
      count+=1
      w-=1
  else:
    if h==0:
      exit()
    else:
      done+=w
      count+=1
      h-=1
  if done>=n:
    print(count)
    exit()
# Judge status: Accepted
x, y = map(int, input().split())

ans = 'No'

for a in range(1, x+1):
    b = x - a
    if b == x:
        break
    if 2*a + 4*b == y or 2*b + 4*a == y:
        ans = 'Yes'
        break

print(ans)
# Judge status: Accepted
N = int(input())
for i in range(6, -1, -1):
    if 2**i > N:
        continue
    print(2**i)
    break
# Judge status: Accepted
n = int(input())
a = list(map(int , input().strip().split()))
students = {}
ans = []

for i in range(len(a)):
  students[i] = a[i]
students= sorted(students.items(), key=lambda x:x[1])

for i in range(n):
  ans.append(str(students[i][0] + 1))

print(' '.join(ans))
# Judge status: Accepted
X,Y,Z = map(int,input().split())
n = X // (Y+Z)

if X % (Y+Z) < Z :
    print(n-1)
else:
    print(n)
# Judge status: Accepted
s = str(input())
t = str(input())
count = 0
for i in range(len(s)):
    if s[i] != t[i]:
        count += 1
print(count)
# Judge status: Accepted
Q,H,S,D = map(int,input().split())
N = int(input())
Min = min(4*Q,2*H,S)
if Min > D/2:
    if N%2 == 0:
        print(N//2*D)
    else:
        print(N//2*D + Min)
else:
    print(Min*N)
# Judge status: Wrong Answer
n = int(input())
s = input()
h = 0
t = len(s)
while h < t and s[h] == '.':
    h += 1
while 0<t and s[t-1] == '#':
    t -= 1
s = s[h:t]
print(min(s.count('.'), s.count('#')))
# Judge status: Accepted
n = int(input())
sequence = [input() for _ in range(n)]

print(len(set(sequence)))
# Judge status: Wrong Answer
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
result = 'No'

if sum(c1[:2]) == c1[2]:
    if sum(c2[:2]) == c2[2]:
        if sum(c2[:2]) == c3[2]:
            result = 'Yes'

print(result)
# Judge status: Wrong Answer
n = int(input())
s = input()

black = []
white = []

cb=0
cw=0
for l in s:
    if l =="#":
        cb+=1
    else:
        cw+=1
    black.append(cb)
    white.append(cw)

if n == 1:
    print(0)
else:
    ans = []
    for i in range(1,n):
        ans.append(black[i-1]+white[-1]-white[i-1])
    print(min(ans))
# Judge status: Accepted
N = int(input())
B = [10**5+1] + list(map(int, input().split())) + [10**5+1]
res = 0
for i in range(1, N+1):
    res += min(B[i-1], B[i])
print(res)
# Judge status: Accepted
x,a,b=map(int,input().split())
 
if a>=b:
    print("delicious")
elif x+a<b:
    print("dangerous")
else:
    print("safe")
# Judge status: Accepted
x = int(input())

print(x//500*1000 + x%500//5*5)
# Judge status: Accepted
n,m = map(int,input().split())
a = sorted(list(map(int,input().split())))
lim = sum(a)/(4*m)
cnt = 0
for i in a:
  if i >= lim:
    cnt += 1
if cnt >= m:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
def main():
    n, W, *wv = map(int, open(0).read().split())
    dp = [[0] * (W + 1)] * (n + 1)
    for i in range(n):
        w = wv[i * 2]
        v = wv[i * 2 + 1]
        pv = dp[i][w]
        dp[i + 1] = [max(dp[i][j], dp[i][j - w] + v) if j >= w else pv for j in range(0, W + 1)]
    print(dp[-1][W])

main()
# Judge status: Accepted
import math


def roundup(x):
    return int(math.ceil(x / 10.0)) * 10


l = [int(input()) for _ in range(5)]
ll = [roundup(v) for v in l]

m = sum(ll)
print(min([m - ll[i] + l[i] for i in range(5)]))
# Judge status: Accepted
x = int(input())

for i in range(1, 10**5):
    if 360 * i % x == 0:
        print(360 * i // x)
        break
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
ans=1000
dp=[0]
for i in range(N-1):
  if A[i]<A[i+1]:
    dp.append(1)
  else:
    dp.append(0)
o=len(dp)
dp.append(0)
for i in range(o):
  if dp[i]==1 and dp[i+1]==0:
    dp[i]=2
  if dp[i]==0 and dp[i+1]==1:
    dp[i]=-1
p=0
for i in range(N):
  if dp[i]==-1:
    p=ans//A[i]
    ans=ans%A[i]
  if dp[i]==2:
    ans+=A[i]*p
    p=0
print(ans)
# Judge status: Accepted
def main():
    A, B = map(int, input().split())
    if A + B >= 24:
        print(A+B-24)
    else:
        print(A+B)
main()
# Judge status: Accepted
a, b = map(int, input().split())
if (a+b) % 2 == 0:
  print((a+b)//2)
else:
  print(((a+b)//2)+1)
# Judge status: Wrong Answer
n,m,k = map(int,input().split())

for i in range(1,n+1):
    for j in range(1,m+1):
        #print(n*j+m*i-i*j*2)
        if n*j+m*i-i*j*2==k:
            print('Yes');exit()
print('No')
# Judge status: Accepted
S=input()
print(min(S.count("0"),S.count("1"))*2)
# Judge status: Accepted
n,m=map(int,input().split())

def fac(n):
  if n == 0:
    return 1
  else:
    return n * fac(n-1)

def binom(n,k):
  if n==0 or n==1:
    return 0
  else:
    return fac(n) // (fac(n-k) * fac(k))

print(binom(n,2) + binom(m,2))
# Judge status: Accepted
import math


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


x = int(input())

if x == 2:
    print(x)
    exit()

if x % 2 == 0:
    x += 1

while not is_prime(x):
    x += 2

print(x)
# Judge status: Accepted
# easy for C!!!

n = int(input())
l = [int(x) for x in input().split()]
i =0
while len(l) >= 2:
    l.sort()
    a = l.pop(i)
    b = l.pop(i)
    c = (a + b) / 2
    l.append (c)

print(*l)
# Judge status: Wrong Answer
N=int(input())
print( sum(j*(N//j)*(N//j+1)//2 for j in range(1,N)) )
# Judge status: Wrong Answer
n=int(input())
a=[int(input()) for _ in range(n)]

m1=max(a)
m2=max(a[a.index(max(a)):]+a[:a.index(max(a))+1])
for i in range(n):
    if a[i]==m1:
        print(m2)
    else:
        print(m1)
# Judge status: Accepted
N = int(input())
numbers = [int(i) for i in input().split()]

min_diff = sum(numbers)
for i in range(N-1):
    diff = abs(sum(numbers[:i+1]) - sum(numbers[i+1:]))
    if diff < min_diff:
        min_diff = diff
        
print(min_diff)
# Judge status: Accepted
N,L = (int(x) for x in input().split())
S = [input() for i in range(N)]
S.sort()
ans = ''.join(S)
print(ans)
# Judge status: Wrong Answer
N, x = map(int, input().split())
A = list(map(int, input().split()))
A.append(0)
CA = [a for a in A]
for i in range(N):
    total = CA[i] + CA[i+1]
    if x < total:
        if CA[i + 1] <= (total - x):
            rest = total - x - CA[i + 1]
            CA[i + 1] = 0
            CA[i] = CA[i] - rest if CA[i] - rest > 0 else 0
        else:
            CA[i + 1] = total - x
cnt = 0
for a, ca in zip(A, CA):
    cnt += (a - ca)
print(cnt)
# Judge status: Accepted
S = input()

print(S.replace("?", "D"))
# Judge status: Accepted
import math
def main():
  a,b = list(map(int,input().split()))
  number=b-a
  ans=0
  for i in range(1,number):
    ans+=i
  print(ans-a)
main()
# Judge status: Accepted
import math
H = int(input())

count = 1
while H > 1:
  H = math.floor(H/2)
  count += 1

print(2**count -1)
# Judge status: Accepted
a, b, c = map(int, input().split())
if a <= c and c <= b:
    print('Yes')

else:
    print('No')
# Judge status: Wrong Answer
n = int(input())
order = input().split()
a = sorted(order)
print(a)
for i in a:
    print(order.index(i)+1, end=" ")
# Judge status: Wrong Answer
s = list(input())

s.sort()

for i in range(97,123):
    if s.count(chr(i)) == 0:
        print(chr(i))
        break
# Judge status: Accepted
N,M = map(int,input().split())
a=[0]*M
b=[0]*M
c=set() #最初の候補地

for i in range(M):
  a[i],b[i]=map(int,input().split())
  if a[i]==1:
    if b[i] not in c:
      c.add(b[i])
    
for j in range(M):
  if a[j]!=1:
    if a[j] in c:
      if b[j]==N:
        print("POSSIBLE")
        break
else:
  print("IMPOSSIBLE")
# Judge status: Accepted
n = int(input())

ans = 0
for i in range(1, n+1):
  if len(str(i))%2 == 1: ans += 1
print(ans)
# Judge status: Accepted

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

if h-sum(a) <= 0:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a=list(map(int, input().split()))
b=sum(a)
print("bust" if b>=22 else "win")
# Judge status: Accepted
import sys

code = input()
for i in range(len(code) - 1):
    if code[i] == code[i + 1]:
        print("Bad")
        sys.exit()
print("Good")
# Judge status: Wrong Answer
n=int(input())
xlis = list(map(int,input().split()))
def tai(p,x):
  return pow(x-p,2)
ans=999999999999
for i in range(min(xlis),max(xlis)-min(xlis)+1):
  sum=0
  for j in xlis:
    sum+=tai(i,j)
  if ans>sum:
    ans=sum
    
print(ans)
# Judge status: Accepted
S = int(input())

x1,y1 = 0,0
x2 = 10**9
y2 =1
y3,x3 = divmod(-S,x2)
y3 *= -1
for a in [x1,y1,x2,y2,x3,y3]:
	if a == y3:
		print(a)
	else:
		print(a,end=" ")
# Judge status: Accepted
S = list(input().strip())
T = list(input().strip())
f = False
for _ in range(len(T)+1):
    if S == T:
        f = True
        break
    t = T.pop(0)
    T.append(t)

print("Yes" if f else "No")
# Judge status: Wrong Answer
A, B, M = map(int, input().split())
aList = list(map(int, input().split()))
bList = list(map(int, input().split()))
mList = [list(map(int, input().split())) for i in range(M)]
Min = 20001

for i in range(A):
    for j in range(B):
        for k in range(M):
           if i+1 == mList[k][0] and j+1 == mList[k][1]:
               cost = aList[i] + bList[j] - mList[k][2]
           else:
               cost = aList[i] + bList[j]
        Min = min(cost, Min)

print(Min)
# Judge status: Accepted
n = int(input())
v = [int(x.strip()) for x in input().split()]
vs = sorted(v)
ans = 0
for i in range(n):
  a = (vs[i]/(2**(n-max(i,1))))
  ans += a
print(ans)
# Judge status: Accepted
import bisect

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
a.sort()
b.sort()
c.sort()


total = 0
for i in b:
    a_number = bisect.bisect_left(a, i)
    c_number = n - bisect.bisect_right(c, i)
    total = total +  a_number * c_number
print(total)
# Judge status: Accepted
"""
1. The initial character of S is an uppercase A.
2. There is exactly one occurrence of C between the third character from the beginning and the second to last character (inclusive).
3. All letters except the A and C mentioned above are lowercase.
"""
import collections
def a(r): return r[0] == 'A'
def b(r): return collections.Counter(r[2:-1])['C'] == 1
def c(r): return all([l in set(['A', 'C']) or l.lower() ==l for l in r ])
def f(r):  return a(r) and b(r) and c(r)

print 'AC' if f(raw_input()) else 'WA'
# Judge status: Accepted
'''
A = 500 とする。
このとき、X = 10^9 となるのは、 B = 499.9968... のとき。
→ AまたはB (の絶対値) が大きすぎると、Xが10^9に収まらない。

A, Bの探索範囲は -120~120で十分。
'''

from itertools import product

def main():
    X = int(input())
    for A, B in product(range(-150, 150), range(-150, 150)):
        if A**5 - B**5 == X:
            print(A, B)
            return

main()
# Judge status: Wrong Answer
s=input()
s=sorted(s)

if s[0]=='a' and s[1]=='b' and s[2]=='c':
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
S = input()
# S = '201879812018798120187981'

baisu = [str(2019 * m) for m in range(1, 10000)]

# print(baisu)

cnt = 0
for b in baisu:
    # 開始位置
    s = 0
    while True:
        # 見つけた位置
        pos = S.find(b, s)
        if pos > -1:
            # 次の開始位置を1文字後にする
            s = pos + 1
            cnt += 1
        else:
            break

print(cnt)
# Judge status: Accepted
N, K = map(int, input().split())
X = list(map(int, input().split()))
ans = 10**20
for i in range(N-K+1):
  l = X[i]
  r = X[i+K-1]
  if l*r >= 0:
    ans = min(ans, max(abs(l), abs(r)))
  else:
    ans = min(ans, r-l + min(abs(l), abs(r)))
print(ans)
# Judge status: Wrong Answer
n = int(input())
k = 1
while True:
  if k*(k+1)//2 >= n:
    ans = k
    break
  k += 1
if n == ans*(ans+1)//2:
  i = 1
  while i <= ans:
    print(i)
    i += 1
else:
  i = 1
  l = []
  cnt = 0
  while i < ans:
    if cnt <= (ans-1)*(ans+2)//2 - n:
      print(i)
      cnt += 1
    else:
      print(i+1)
    i += 1
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]-=i+1
a=sorted(a)
def f(x):
    ans=0
    for i in range(n):
        ans+=abs(x-a[i])
    return ans

if n%2==0:
    m=n//2
else:
    m=(n+1)//2

print(f(a[m-1]))
# Judge status: Wrong Answer
from collections import Counter
n = input()
mod = 10**9+7
s = list(Counter(list(input())).values())
an = 1
for i in s:
  an *= i
print(an-1)
# Judge status: Accepted
def solve():
  n = int(input())
  cost = list(map(int, input().split(' ')))
  dp = [-1 for _ in range(n)]
  dp[0] = 0
  dp[1] = abs(cost[1] - cost[0])
  for i in range(2, n):
    dp[i] = min(dp[i-2] + abs(cost[i] - cost[i-2]), 
                dp[i-1] + abs(cost[i] - cost[i-1]))
  print(dp[-1])
  
  
solve()
# Judge status: Accepted
S = input()
print("Yes" if all(s in ["R","U","D"] for s in S[::2]) \
      and all(s in ["L","U","D"] for s in S[1::2]) else "No")
# Judge status: Accepted
x, y = map(int, input().split())

diff_abs = abs(abs(x) - abs(y))

ans = diff_abs
if x * y > 0:
  if x > y:
    ans += 2
elif x * y == 0:
  if x > y:
    ans += 1
else:
  ans += 1

print(ans)
# Judge status: Wrong Answer
N = int(input()) 
x = N * 800 
y = (N / 15) * 200 

print(x-y)
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))

count = 0
for i in range(0,N):
    if i % 2 == 1:
        if a[i] % 2 == 1:
            count = count+ 1

print(count)
# Judge status: Accepted
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


def main():
    H = int(input())
    W = int(input())
    N = int(input())

    res = 0
    black = 0

    if H >= W:
        D = W
        E = H
    else:
        D = H
        E = W

    for i in range(D):
        if black >= N:
            break
        black += E
        res += 1

    print(res)



main()
# Judge status: Wrong Answer
import math
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
S = [0] * N
S[0] = 0
 
for i in range(1, N):
    value = math.inf
    for step in range(1, N):
        value = min(value, S[i - step] + abs(h[i] - h[i - step]))
    S[i] = value
print(S[N - 1])
# Judge status: Wrong Answer
a, b = map(int, input().split())

time = a + b
if time > 24:
    print(time - 24)
else:
    print(time)
# Judge status: Accepted
s = list(input())
K = int(input())

for i in range(len(s)):
    need = (123-ord(s[i]))%26
    if need <= K:
        s[i] = "a"
        K -= need
if 0 < K:
    tmp = ord(s[-1]) + K%26
    tmp -= 26 if 123 <= tmp else 0
    s[-1] = chr(tmp)
print("".join(s))
# Judge status: Accepted
X,Y=map(int,input().split())
cnt=1
tmp=[X]
while True:
  if tmp[-1]*2<=Y:
    tmp.append(tmp[-1]*2)
    cnt+=1
  else:
    break
print(cnt)
# Judge status: Wrong Answer
a,b=map(int,input().split())
if b%(a-1)==0:print(b//(a-1))
elif b%(a-1)==1:print(b//(a-1))
else:print(b//(a-1)+1)
# Judge status: Wrong Answer
a,b = map(int,input().split())
c = abs(b - a)
x = 0
for i in range(1,c+1):
  x += 1
print(x-b)
# Judge status: Wrong Answer
n,k,q = map(int, input().split())


a = [k] * n

for i in range(q):
  A = int(input())
  a[A-1] -= 1

for i in a:
  if i > 0:
    print('Yes')
  else:
    print('No')
# Judge status: Wrong Answer
import random
S = input()

ans = random.sample(S, 3)
print(str("".join(ans)))
# Judge status: Wrong Answer
N = int(input())
list=[]
for i in range(N):
    s, p = input().split()
    list.append([s, int(p)])
A=list
list.sort(key=lambda list:(list[0], -list[1]))
for i in A:
    print(int(list.index(i))+1)
# Judge status: Accepted
N, K, Q = map(int, input().split())

S = [K - Q for i in range(N)]

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

for i in S:
    if i > 0:
        print('Yes')
    else:
        print('No')
# Judge status: Wrong Answer
def inpl(): return list(map(int,input().split()))
 
N, W = inpl()
dp = [[0]*W for _ in range(N+1)]
for n in range(1,N+1):
  w, v = inpl()
  for x in range(W):
    if x < w:
      dp[n][x] = dp[n-1][x]
    else:
      dp[n][x] = max(dp[n-1][x], dp[n-1][x-w] + v)
print(dp[-1][-1])
# Judge status: Accepted
#146
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")

elif S == 'SUN':
    print("7")
# Judge status: Accepted
X, Y = map(int, input().split())
ans = 1
nextX = X
for i in range(0, 10 ** 8):
    t = nextX * 2
    if t <= Y:
        ans += 1
        nextX = t
    else:
        break
print(ans)
# Judge status: Wrong Answer
k = int(input())

if k % 2 == 0 or k % 5 == 0:
    print(-1)
elif k == (1 or 7):
    print(1)
else:
    t = 2
    ex = 77
    for i in range(10 ** 8):
        if ex % k == 0:
            break
        ex = (ex % k) * 10 + 7
        t += 1
    print(t)
# Judge status: Accepted
a,b = map(int,input().split())
i = 0
x = int(a/0.08)
while True:
    if int((x+i)*0.1) == b and int((x+i)*0.08) == a:
        ans = int(x+i)
        break
    elif int((x+i)*0.1) > b:
        ans = '-1'
        break
    else:
        i += 1
print(ans)
# Judge status: Accepted
x = input().split()

print(x.index('0') + 1)
# Judge status: Accepted
n = int(input())
a = [int(input()) for _ in range(n)]

ans = 0
for i in range(n - 1):
    pair1 = a[i] // 2
    a[i] -= pair1 * 2
    pair2 = min(a[i], a[i+1])
    ans += pair1 + pair2
    a[i+1] -= pair2

ans += a[-1] // 2
print(ans)
# Judge status: Accepted
import itertools,sys
def S(): return sys.stdin.readline().rstrip()
A,B,C,D = [x for x in S()]
for op1,op2,op3 in itertools.product(['+','-'],repeat=3):
    ans = A+op1+B+op2+C+op3+D
    if eval(ans)==7:
        print(ans+'=7')
        break
# Judge status: Wrong Answer
import math
a=math.ceil(int(input())/2)
b=list(map(int,input().split()))[::-1]
t=min(abs(sum(b[::2])-sum(b[1::2])),abs(sum(b[:-a])-sum(b[-a:])))
print(t)
# Judge status: Accepted
import math
a, b = list(map(int, input().split()))

c = str(a) + str(b)
c = int(c)

d = math.floor(c/4 + 1)
square = [i * i for i in range(c) if i * i == c ]

if len(square) != 0 :
    print('Yes')
else:
    print('No')
# Judge status: Accepted
a,b,t = map(int,input().split())
print(int(((t+0.5)//a)*b))
# Judge status: Accepted
N,M = map(int,input().split())
if N == M == 1:
    print(1)
elif N == 1 or M == 1:
    print(max(M-2,N-2))
else:
    print(N*M-(2*N+2*M-4))
# Judge status: Wrong Answer
s = input()
ans = 'NO'
pattern = 'keyence'
for i in range(len(pattern) - 1):
    x = pattern[:i]
    y = pattern[i:]
    p = 0
    while s.find(x, p) >= 0:
        p += 1
        if s.find(y, p + len(x) - 1) >= 0:
            ans = 'YES'
            break

print(ans)
# Judge status: Accepted
H=int(input())
W=int(input())
N=int(input())
if W<H:
  H,W=W,H
#Wが大きい
if N%W==0:
  print(N//W)
else:
  print(N//W+1)
# Judge status: Accepted
N, K = map(int, input().split())
sm = 0
for i in range(K, N+2):
    sm += (N+N-i+1)*i//2 -(i-1)*i//2 + 1
print(sm%(10**9+7))
# Judge status: Accepted
x = int(input())

if 400 <= x <= 599:
  print(8)
elif 600 <= x <= 799:
  print(7)
elif 800 <= x <= 999:
  print(6)
elif 1000 <= x <= 1199:
  print(5)
elif 1200 <= x <= 1399:
  print(4)
elif 1400 <= x <= 1599:
  print(3)
elif 1600 <= x <= 1799:
  print(2)
elif 1800 <= x <= 1999:
  print(1)
# Judge status: Accepted
K = int(input())
A, B = map(int, input().split())

if B - (B % K) >= A:
    print('OK')
else:
    print('NG')
# Judge status: Accepted
K = int(input())
A,B = map(int,input().split())
mes = 0
for num in range (A,B+1):
    if num % K == 0 : mes = 1
    else : pass

if mes == 1 : print("OK")
else : print("NG")
# Judge status: Wrong Answer
n,x=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]

add_a=[]
for i in range(n-1):
    add_a.append(max(a[i]+a[i+1]-x,0))

ans=0
for i in range(n-1):
    ans+=min(add_a[i],a[i+1])
    if i!=n-2:
        add_a[i+1]=max(0,add_a[i+1]-min(add_a[i],a[i+1]))
    add_a[i]=0

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

res = v[0]

for i in range(1, N):
    res = (res+v[i])/2

print(res)
# Judge status: Accepted
A = int(input())
S = input()

if A < 3200:
  print("red")
else:
  print(S)
# Judge status: Accepted
n = int(input())//2
d = sorted(list(map(int,input().split())))
print(d[n]-d[n-1])