peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = input()

num = []
for i in range(len(t)):
    char = t[i]
    if char == "r":
        point = p
    elif char =="s":
        point = r
    else:
        point = s
    
    if i > (k-1):
        if point == num[i -k]:
            point = 0
    num.append(point)
    
print(sum(num))
# Judge status: Wrong Answer
import re

S = input()
if('A' in S[0]):
    if('C' in S[2:-2]):
        if(len(re.findall('[A-Z]',S)) == 2):
            print('AC')
        else:
            print('WA')
    else:
        print('WA')
else:
    print('WA')
# Judge status: Wrong Answer
a = int(input())
b, c = map(int, input().split())

if (c-b)/a>=1:
    print("OK")
elif c-b==0 and c%a==0:
    print("OK")
else:
    print("NG")
# Judge status: Wrong Answer
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a
        
def lcm(a,b):
    return a*b//gcd(a,b)
    
N = int(input())
A = list(map(int, input().split()))

lcm_A = 1
for i in range(N):
    lcm_A = lcm(lcm_A, A[i])
    
ans = 0
for i in range(N):
    ans += lcm_A // A[i]

mod = 10**9+7
print(ans & mod)
# Judge status: Accepted
n, k = map(int,input().split())
a = input().split()
while True:
  if all(c not in str(n) for c in a):
    print(n)
    break
  else:
    n += 1
# Judge status: Wrong Answer
N, M, K = map(int, input().split())

for n in range(N + 1):
    for m in range(M + 1):
        if n * N + m * M - max(n, m) * 2 == K:
            print('Yes')
            exit()

print('No')
# Judge status: Wrong Answer
s = input()
a_index = 0
z_index = 0

for i in range(0, len(s)):
    if s[i] == "A":
        a_index = i
        break
        
for i in range(0, len(s)):
    if s[len(s)-i-1] == "Z":
        z_index = len(s)-i
        break
print(s[a_index:z_index])
# Judge status: Wrong Answer
S = list(input())
N = len(S)
flag = True
for i in range((N+1)//2-1):
    if S[i] != S[-1-i]:
        flag = False
        break

for i in range((N+1)//4-1):
    if S[i] != S[(N+1)//2-2-i]:
        flag = False
        break

for i in range((N+3)//2, (N+5)//4-1):
    if S[i] != S[-2-i]:
        flag = False
        break

if flag == True:
    print('Yes')
elif flag == False:
    print('No')
# Judge status: Accepted
s = str(input())
k = int(input())
if k <= len(s) and s[:k] == '1' * k:
  ans = 1
else:
  ans = s.replace('1', '')[0]
print(ans)
# Judge status: Accepted
s=input()

if s[0]=="A":
    pass
else:
    print("WA")
    exit()

k=s[2: -1]
if k.count("C")==1:
    pass
else:
    print("WA")
    exit()

new_string=s.replace("A", "")
new_string=new_string.replace("C", "")

if new_string.islower():
    print("AC")
else:
    print("WA")
# Judge status: Accepted
a, b = map(int, input().split())
if (a * b)%2 == 0:
    print("Even")
else:
    print("Odd")
# Judge status: Wrong Answer
price = int(input())
num500 = int(price / 500)
price = price - (num500 * 500)
num5 = int(price % 5)
print(num500 * 1000 + num5 * 5)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
mod = 10 ** 9 + 7
cnt = [0 for _ in range(60)]
for a in A:
    for i in range(60):
        cnt[i] += a & 1
        a >>= 1
cnt = [x * (N - x) % mod for x in cnt]
power = 1
ans = 0
for i in range(60):
    ans += power * cnt[i]
    power *= 2
    power %= mod
ans %= mod
print(ans)
# Judge status: Wrong Answer
w=input()
flag=True
for i in str(w):
  if str(w).count(i)==2:
    continue
  else:
    flag=False
print("Yes" if flag==True else "No")
# Judge status: Accepted
H, N = map(int, input().split())
A = list(map(int,input().split()))

if sum(A) >= H:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
B = list(map(int, input().split()))

a = [-1] * n

for i, b in enumerate(B):
    if a[i] > B[i]:
        a[i] = b
        a[i+1] = b
    elif a[i] != -1:
        a[i+1] = b
    elif a[i] == -1:
        a[i] = b
        a[i+1] = b

print(sum(a))
# Judge status: Accepted
import fractions

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

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

num = nums[0]
for i in range(N - 1):
    num = lcm(num, nums[i + 1])
print(sum([num // i for i in nums]) % (10 ** 9 + 7))
# Judge status: Accepted
from collections import Counter

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

ans = Counter(A)
max_value = max(ans.values())

if max_value == 1:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
if __name__ == "__main__":
    n, x = map(int, input().split())
    a = list(map(int, input().split()))

    if sum(a) == x:
        print(n)
        exit()

    a.sort()

    ans = 0
    for i in range(n):
        if sum(a[:i+1]) <= x:
            ans = i+1
        else:
            print(i)
            exit()

    if sum(a[:ans]) == x:
        print(ans)
    else:
        print(ans-1)
# Judge status: Accepted
L,R = map(int,input().split())

ans = 2019
for i in range(L,min(L+2019,R)):
  for j in range(i+1,min(L+2019,R+1)):
    ans = min(ans,(i*j)%2019)

print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
a = list(map(int, input().split()))
import math
ans = math.ceil((n - 1) / (k - 1))
print(ans)
# Judge status: Wrong Answer
n = int(input())

flag = 0
t = [0] * n
x = [0] * n
y = [0] * n

for i in range(n):
  t[i], x[i], y[i] = map(int, input().split())
  
  if t[i] > x[i]+y[i]:
    flag += 1
  if t[i]%2 != (x[i]+y[i])%2:
    flag +=1
  if i > 1:
    if abs(t[i-1]-t[i]) > abs(x[i-1]+y[i-1])-abs(x[i]+y[i]):
      flag +=1

if flag > 0:
  print("No")
else:
  print("Yes")
# Judge status: Accepted
n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    if a[i] <= b[i]:
        all_enemy = a[i] + a[i + 1]
        if all_enemy > b[i]:
            ans += b[i]
            a[i+1] = all_enemy - b[i]
        else:
            ans += all_enemy
            a[i+1] = 0
    else:
        ans += b[i]

print(ans)
# Judge status: Accepted
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

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

counter = Counter(A)
ans = sum(i * (i - 1) // 2 for i in counter.values())

for a in A:
    c = counter[a]
    print(ans - c * (c - 1) // 2 + (c - 1) * (c - 2) // 2)
# Judge status: Accepted
s=input()
ans=0
for i in range(len(s)//2):
  if s[i]!=s[-i-1]:
    ans+=1
print(ans)
# Judge status: Accepted
S = input()
Q = int(input())

jun = True
head = ""

for _ in range(Q):
    T = input().split()
    if T[0] == "1":
        jun = not jun
    
    else:

        if (T[1] == "1" and jun) or (T[1] == "2" and not jun):
            head += T[2]
            continue

        else:
            S += T[2]

if jun:
    print(head[::-1] + S)
else:
    print(S[::-1] + head)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
dp = [0]*n
for i in range(n):
  if i == 0:
    pass
  elif i == 1:
    dp[i] = abs(a[i]-a[i-1]) + dp[i-1]
  else:
    dp[i] = min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2])
print(dp[-1])
# Judge status: Accepted
str = input().split()
n = str[0]
if n[0] == n[1] == n[2] or n[1] == n[2] == n[3]: print("Yes")
else: print("No")
# Judge status: Accepted
w,h,n=map(int, input().split())
sx=sy=0
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:   sx=max(sx,x)
    elif a==2:  w=min(w,x)
    elif a==3: sy=max(sy,y)
    elif a==4:  h=min(h,y)
print(max(0,w-sx)*max(0,h-sy))
# Judge status: Accepted
n = int(input())
s = list(input())

l = [[0, 0] for i in range(n + 1)]
for i in range(n):
    preB, preW = l[i]
    if s[i] == '#':
        l[i + 1] = [preB + 1, preW]
    else:
        l[i + 1] = [preB, preW + 1]

SUM_W = l[-1][1]
ans = 10 ** 10
for i, j in l:
    temp = i + SUM_W - j
    if temp < ans:ans = temp
print(ans)
# Judge status: Accepted
s = input()
t = input()

al = "abcdefghijklmnopqrstuvwxyz"

for x in al:
	if s + x == t:
		print('Yes')
		break

else:
	print('No')
# Judge status: Accepted
X = int(input())
print(1000 * (X // 500) + 5 * ((X % 500) // 5) )
# Judge status: Accepted
n=int(input())
s=input()
count = 0
for i in range(n-1):
  a=s[:i + 1]
  b=s[i+1:]
  temp = 0
  for j in range(27):
    if chr(96+j) in a and chr(96+j) in b:
      temp += 1
  count = max(temp, count)
print(count)
# Judge status: Accepted
n,m,q = list(map(int,input().split()))
query = [list(map(int,input().split())) for _ in range(q)]
ans = 0

import itertools
for con in itertools.combinations_with_replacement(list(range(m)),n):
    tmp = 0
    for i in query:
        a,b,c,d = i
        if con[b-1] - con[a-1] == c:
            tmp += d
    ans = max(ans, tmp)

print(ans)
# Judge status: Accepted
N, K = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]

count = 0
for a, b in sorted(AB):
    count += b
    if count >= K:
        print(a)
        break
# Judge status: Accepted
import itertools
l,r = map(int,input().split())
if r-l >= 2019:
    print(0)
    exit()
w = []
q = list(itertools.combinations(range(l,r+1),2))
for i in range(len(q)):
    w.append((q[i][0]*q[i][1])%2019)

print(min(w))
# Judge status: Accepted
def resolve():
    S = input()

    S_list = list(S)

    if len(S_list) % 2 == 0:
        s_len = int(len(S_list) / 2)
        if S == s_len * 'hi':
            print('Yes')
            return

    print('No')
    return

if __name__ == "__main__":
    resolve()
# Judge status: Wrong Answer
n = int(input())
ans = 0
ans += 8**(n-2) % (10**9 + 7)
print(ans)
# Judge status: Accepted
from collections import Counter
n = int(input())
s = Counter([input() for _ in range(n)])

m = int(input())
t = Counter([input() for _ in range(m)])

keys = s.keys() & t.keys()
for key in keys:
    s[key] -= t[key]

print(max(max(s.values()), 0))
# Judge status: Accepted

n, x=  map(int, raw_input().split(' '))
def gcd(a,b): return a if b == 0 else gcd(b, a % b)
print reduce(gcd,map(lambda c: abs(c - x), map(int, raw_input().split(' '))))
# Judge status: Wrong Answer
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

n = ni()
ans = ''
while n != 0:
    r = n % 2
    if r < 0:
        r += 2
    n = (n - r) // (-2)
    ans += str(r)
print(ans[::-1])
# Judge status: Accepted
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
b=[[a[i][0]+a[i][1],a[i][0]-a[i][1]] for i in range(n)]
b.sort()
ans=1
tmp=b[0][0]
for i in range(n):
  if tmp<=b[i][1]:
    ans+=1
    tmp=b[i][0]
print(ans)
# Judge status: Wrong Answer
N = int(input())
C, S, F = [], [], []

for _ in range(N-1):
    c, s, f = map(int, input().split())
    C.append(c)
    S.append(s)
    F.append(f)

for station in range(N):
    now = station
    time = 0

    while now < N-1:
        if time < S[now]:
            time = S[now] + C[now]
        else:
            tmp = time - S[now]
            wait_time = tmp % F[now]
            time += wait_time + C[now]

        now += 1

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

if a > b:
    print('delicious')
elif b - a < x+1:
    print('safe')
else:
    print('dangerous')
# Judge status: Accepted
a=input().split()

print(len(set(a)))
# Judge status: Wrong Answer
N = int(input())

height = input()
height = height.split()
height = [int(s) for s in height]

count = 0

iAi = [0] * N
jAj = [0] * N

for i in range(N):
    iAi[i] = i+1 + height[i]
    jAj[i] = i+1 -height[i]

for i in range(N):
    if jAj.count(iAi[i]) >= 1:
        count +=1


print(count)
# Judge status: Accepted
import sys
a,b = map(int,input().split())
c = 0
if (a+b) == 0:
    print("Zero")
    sys.exit()
elif a < 0 and b < 0:
    if  (a-b) % 2 == 1:
        print("Positive")
        sys.exit()
elif a < 0 and b >= 0:
    if a%2 == 0:
        print("Positive")
        sys.exit()
elif b < 0 and a >= 0:
    if b % 2 == 0:
        print("Positive")
        sys.exit()
if (a+b) > 0:
    print("Positive")
else:
    print("Negative")
# Judge status: Wrong Answer
N = input()
if len(set(list(N))) == 1:
  print(N)
else:
  print(str(int(N[0])+1)*3)
# Judge status: Accepted
X,Y=map(int, input().split())
print((Y//X).bit_length())
# Judge status: Wrong Answer
h,w=map(int,input().split())
#b=[[0]*h for i in range(w)]
#print(b)->b[width][height]
print((h*w+1)//2)
# Judge status: Accepted
def main():
    N,M = map(int,input().split())
    X = list(map(int,input().split()))
    X.sort()
    if N >= M:
        print(0)
        exit()
    L = X[-1]-X[0]
    Y = [X[i+1]-X[i] for i in range(M-1)]
    Y.sort()
    Y.reverse()
    Z = Y[:N-1]
    ans = X[-1]-X[0]
    for z in Z:
        ans -= z
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
a,b,c=map(int,input().split())
print(c-min(a-b,c))
# Judge status: Wrong Answer
n = int(input())

C, S, F = [0] * n, [0] * n, [0] * n

for i in range(n - 1):
    C[i], S[i], F[i] = map(int, input().split())

for i in range(n):
    time = 0
    for j in range(i, n - 1):
        if time < S[j]:
            time = S[j] + C[j]
        elif time % F[j] == 0:
            time += C[j]
        else:
            time = time + F[j] - (time % F[j]) + C[i]
    print(time)
# Judge status: Accepted
def main():
    n, d = map(int, input().split())
    ans = 0
    for _ in range(n):
        x, y = map(int, input().split())
        if x ** 2 + y ** 2 <= d ** 2:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
input = sys.stdin.readline

A,B,C=map(int,input().split())

if A % 2 == 0 or B%2 == 0 or C%2==0:
    print(0)
else:
    AB=A*B
    BC=B*C
    CA=C*A
    print(min(AB,BC,CA))
# Judge status: Accepted
import sys
S = input()
Q = int(input())
pin = 0
left = ''
right = ''
for i in range(Q):
  t = list(sys.stdin.readline().split())
  if int(t[0]) == 1:
    pin += 1
  else:
    if int(t[1]) % 2 == pin % 2 :
      right = right + t[2]
    else:
      left = t[2] + left
S = left + S + right
if pin % 2 == 1:
  S = S[::-1]
print(S)
# Judge status: Accepted
L, R = map(int,input().split())

x = []
for i in range(L,R+1):
    if i % 2019 in x:
        break

    x.append(i % 2019)

ans = 9999
for i in range(len(x)):
    for j in range(i+1,len(x)):
        ans = min(ans, x[i] * x[j] %2019)

print(ans)
# Judge status: Accepted
inputLine=input()
N=int(inputLine)

S = []

for i in range(N):
    inputLine=input()
    S.append(inputLine)

S.sort()

result=1

for i in range(1, len(S)):
    if S[i-1] != S[i]:
        result += 1

print(result)
# Judge status: Wrong Answer
N, K= map(int, input().split())
h = list(map(int, input().split()))

for i in range(K):
  h.append(float('inf'))

dp = [0]
for i in range(N+K):
  dp.append(float('inf'))

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

print(dp[N-1])
# Judge status: Accepted
def function(N):
    cnt=0
    while N%2==0:
        N/=2
        cnt+=1
    return cnt

N=int(input())
a=map(int, input().split())
cnt=min(map(function, a))
print(cnt)
# Judge status: Accepted
O = list(input())
E = list(input())+[""]
for x, y in zip(O, E):
    print(x+y,end="")
# Judge status: Accepted
S=input()
if S== 'RRR':
    print(3)
elif S=='RRS' or S=='SRR':
    print(2)
elif S=='SSS':
    print(0)
else:
    print(1)
# Judge status: Wrong Answer
n, k = map(int, input().split())
snk = [-1] * (n + 1)
ans = -1
for j in range(k):
	d = int(input())
	lis = list(input().split())
	for i in range(d):
		y = int(lis[i])
		snk[y] = 0
for j in range(n):
    if snk[j] == -1:
        ans += 1
print(ans)
# Judge status: Accepted
X, A, B = map(int, input().split())

if A >= B:
    print("delicious")
elif X + 1 <= B - A:
    print("dangerous")
else:
    print("safe")
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
if c == a or c == b or c == a+b:
  print('Yes')
else: print('No')
# Judge status: Accepted
n = int(input())
ans = 0
p = -999
a = [i - 1 for i in map(int, input().split())]
b = list(map(int, input().split()))
c = list(map(int, input().split()))
for i in a:
    ans += b[i]
    if i == p + 1:
        ans += c[p]
    p = i
print(ans)
# Judge status: Accepted
a,b = map(int,input().split())
if a <= 8 and b <= 8:
    print("Yay!")
else:
    print(":(")
# Judge status: Accepted
def cin():
    in_ = list(map(int,input().split()))
    if len(in_) == 1:  return in_[0]
    else:  return in_

N, M = cin()
if M // 2 >= N:
    ans = N
    M -= 2 * N
else:
    ans = M // 2
    M = 0
ans += M // 4
print(ans)
# Judge status: Wrong Answer
x = int(input())
i = 1
dist = 0
while dist+2*i+1 <= x:
    dist += i
    i += 1
else:
    ans = x-dist
print(ans)
# Judge status: Accepted
s = input()
n = len(s)
t = [0]*(n+1)
tmp=0
for i in range(n):
  tmp+=1
  if s[i]=="<":
    t[i]=tmp-1
    t[i+1]=tmp
  else:
    tmp=0
    
tmp=0
for j in range(n)[::-1]:
  tmp+=1
  if s[j]==">":
    t[j+1]=max(tmp-1,t[j+1])
    t[j]=max(tmp,t[j])
  else:
    tmp=0
#print(t)
print(sum(t))
# Judge status: Wrong Answer
n,k = map(int, input().split())
num = 0
ab = []
x = 'Y'
for i in range(n):
    a,b = map(int, input().split())
    num += b
    if k <= num and x == 'Y':
        y = a
        x = 'N'
    else:
        ab.append((a,b))
print(y)
# Judge status: Wrong Answer
from heapq import heappop, heappush

N, H = map(int, input().split())
a = [None] * N
b = [None] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())

a.sort()
b.sort()
q = []
for i in range(N):
    if b[i] > a[-1]:
        heappush(q, -b[i])

ans = 0
while q:
    H += heappop(q)
    ans += 1
    if H < 0:
        print(ans)
        exit()

print(ans + (H+a[-1]-1)//a[-1])
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))

a.sort()
point_sum = 0


for i in range(n):
    point_sum += a[n + i]

print(point_sum)
# Judge status: Accepted
n = int(input())
lis = list(map(int,input().split()))
q = int(input())
now = [0 for i in range(10 ** 5)]
for num in lis:
    now[num-1] += 1
ans = 0
for i in range(10 ** 5):
    ans += now[i] * (i+1)
  # print(ans)
for turn in range(q):
    b,c = map(int,input().split())
    num = now[b-1]
    now[b-1] = 0
    now[c-1] += num
    print(ans-b*num+c*num)
    ans -= b*num
    ans += c*num
  #     print(now)
# Judge status: Accepted

N = int(input())
SP = []
for i in range(N):
    s, n = input().split()
    n = int(n)
    SP.append((s, -n, i))
SP.sort()

for s, n, i in SP:
    print(i+1)
# Judge status: Accepted
from math import gcd
 
K = int(input());
sum = 0;

for a in range(1,K+1):
  for b in range(1,K+1):
    for c in range(1,K+1):
      sum += gcd(gcd(a,b),c);

print(sum)
# Judge status: Wrong Answer
# coding: utf-8

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

a_target1 = a / 0.08
a_target2 = (a + 1) / 0.08

b_target1 = b / 0.1
b_target2 = (b + 1) / 0.1


result_list = []

for i in range(int(a_target1), int(a_target2)):
    if i >= b_target1 and i < b_target2:
        result_list.append(i)

if result_list == []:
    print(-1)
else:
    result = min(result_list)
    print(result)
# Judge status: Accepted
k = int(input())

a = [list(range(1, 10))]
while True:
    new = []
    for aa in a[-1]:
        mod = aa % 10
        if mod != 0:
            new.append(aa * 10 + mod - 1)
        new.append(aa * 10 + mod)
        if mod != 9:
            new.append(aa * 10 + mod + 1)
    a.append(new)

    if sum([len(aa) for aa in a]) > k:
        break
flat = sorted(sum(a, []))

print(flat[k - 1])
# Judge status: Wrong Answer
a, b, c = map(int, input().split())

if a <= c and c <= b:
  ans = 'YES'
else:
  ans = 'NO'

print(ans)
# Judge status: Wrong Answer
n = int(input())
a = [int(i)-1 for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]
#ここまで入力
manzoku = 0
for i in range(n):
    if a[i] ==n-1 or i == n-1:
        manzoku += b[a[i]]
    else:
        manzoku += (b[a[i]]+c[a[i]])
print(manzoku)
# Judge status: Accepted
def div(N):
    div = set()
    for i in range(1, int(N ** 0.5 + 0.5) + 1):
        if N % i == 0:
            div.add(i)
            div.add(N // i)
    return len(div)


N = int(input())
ans = 0
for x in range(1, N + 1, 2):
    if div(x) == 8:
        ans += 1
print(ans)
# Judge status: Accepted

def main():
    N, M = [int(_) for _ in input().split()]
    slist = list(map(int, input().split()))
    sort_list = sorted(slist)
    thr = sum(sort_list) / (4 * M)
    
    cnt = 0
    for i in sort_list:
        if i >= thr:
            cnt += 1

    if cnt >= M:
        print("Yes")
    else:
        print("No")

main()
# Judge status: Accepted
n = int(input())
z = []
y = 0
for i in range(n):
  line = input().split(" ")
  if int(line[0])==int(line[1]):
    z.append(i)

for i in range(len(z)-2):
  if z[i]==z[i+1]-1:
    if z[i+1]==z[i+2]-1:
      y += 1
if y > 0:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
s = input()
res = [0] * (len(s)+1)
 
for i in range(len(s)):
  if s[i] == "<":
    res[i +1] = res[i] +1
 
for i in range(len(s)-1,-1,-1):
  if s[i] == ">":
    res[i] = max(res[i], res[i+1]+1)
 
print(sum(res))
# Judge status: Accepted
if __name__ == "__main__":
    s = input()

    op = ['+1', '-1']

    for i in op:
        for j in op:
            for k in op:
                if int(s[0]) + int(s[1])*int(i) + int(s[2])*int(j) + int(s[3])*int(k) == 7:
                    print(s[0] + i[0] + s[1] + j[0] +
                          s[2] + k[0] + s[3] + '=7')
                    exit()
# Judge status: Wrong Answer
n = int(input())
print((n/2)*((n+1)/2))
# Judge status: Wrong Answer
#D
a,b,n = map(int,input().split())
x = n-1
ans1 = ((a*x)//b) - (a*(x//b))
x = n-1
ans2 = ((a*x)//b) - (a*(x//b))
x = n-b
ans3 = ((a*x)//b) - (a*(x//b))
x = n//b
ans4 = ((a*x)//b) - (a*(x//b))
x = n//2
ans5 = ((a*x)//b) - (a*(x//b))
x = 1
ans6 = ((a*x)//b) - (a*(x//b))
print(max(ans1,ans2,ans3,ans4,ans5,ans6))
# Judge status: Accepted
import sys

s = input()
t = input()

tl = len(t) ; sl = len(s)

c = 1
for i in range(sl,tl-1,-1) :
  st = s[i-tl:i]
  c = 0
  for j in range(tl) :
    if st[j] == '?' :
      continue
    elif st[j] != '?' and st[j] == t[j] :
      continue
    c = 1
    break
  if c == 0 :
    s = s[:i-tl] + t + s[i:]
    break

if c == 1 :
  print('UNRESTORABLE')
else : 
  print(s.replace('?', 'a'))
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))

def gcd(a,b):
    while b:
        a,b = b,a%b
    return a

left_gcd = [0]*(n+1)
right_gcd = [0]*(n+1)
left_gcd[1] = a[0]
right_gcd[1] = a[-1]

for i in range(1,n):
    left_gcd[i+1] = gcd(left_gcd[i],a[i])
    right_gcd[i+1] = gcd(right_gcd[i],a[-1-i])

ans = right_gcd[n-1]
for i in range(n):
    ans = max(ans,gcd(left_gcd[i],right_gcd[n-1-i]))
print(ans)
# Judge status: Wrong Answer
S = input()
print('TBD' if S > '2019/4/30' else 'Heisei')
# Judge status: Wrong Answer
class Main:
  s = list(map(int, input().split()))
  h = s[0]
  a = s[1]
  cnt = 1
  if h <= a:
    print(cnt)
  else:
    while h > a:
        h -= a
        cnt += 1
  print(cnt)
# Judge status: Wrong Answer
N,M = map(int,input().split())
sts = [list(map(int, input().split())) for i in range(N)]
checkp = [[i+1]+list(map(int, input().split())) for i in range(M)]
rt = [None] * N
distances = [2*(10**8)] * N
for s in range(N):
  for c in checkp:
    dist = abs(sts[s][0]-c[1]) + abs(sts[s][1]-c[2])
    if rt[s] is None:
      rt[s] = c[0]
      distances[s] = dist
    else:
      if distances[s] > dist:
        rt[s] = c[0]
        distances[s] = dist
print(rt)
# Judge status: Wrong Answer
s=list(str(input()))
tmp=0
for i in range(0,len(s)):
            if i%2==0 and s[i]=='L':
                        tmp+=1
            if i%2!=0 and s[i]=='R':
                        tmp+=1
if tmp==1:
            print('No')
if tmp==0:
            print('Yes')