peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
C = [c for c in input()]

ans = 0
l,r = 0, n-1
while(l < r):
    while(C[l] == 'R'): 
        l += 1
        if (n == l): break
    
    while(C[r] == 'W' or -1 == r):
        r -= 1
        if (-1 == r): break

    if (l < r):
        ans += 1
    l += 1
    r -= 1

print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))
Asort = sorted(A)
Amin = sum(Asort[:2])
Amax = min(sum(Asort[-2:]), N - 1)

cnt = 0
for i in range(N):
    for j in range(Amin, Amax + 1):
        if i - j >= 0 and j == A[i - j] + A[i]:
            cnt += 1
        elif i + j <= N - 1 and j == A[i] + A[i + j]:
            cnt += 1
print(cnt // 2)
# Judge status: Accepted
n=input()
x=[int(i) for i in n]

if (x[0]==x[1] and x[1]==x[2]) or (x[1]==x[2] and x[2]==x[3]):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from sys import stdin
input = stdin.readline


def main():
  X, Y = list(map(int, input().split()))
  cnt = 1
  while True:
    X *= 2
    if X > Y:
      break
    cnt += 1

  print(cnt)


if(__name__ == '__main__'):
  main()
# Judge status: Accepted
n = int(input())
print("YES" if len(set(input().split())) == n else "NO")
# Judge status: Accepted
n,x=map(int,input().split())
a=list(map(int,input().split()))
s=0
for i in range(1,n):
    b=a[i-1]+a[i]-x
    if b>0:
        s+=b
        a[i]=max(a[i]-b,0)
print(s)
# Judge status: Accepted
a = int(input())
sum = 0
for i in range(1,a+1): 
    if i%5 != 0 and i%3 != 0:
        sum += i
print(sum)
# Judge status: Wrong Answer
n, m = map(int, input().split())
a = list(map(int, input().split()))

p = sum(a)

if n>p:
  print(n-p)
else:
  print(-1)
# Judge status: Accepted
A, B, C = map(int, input().split())
if A%2 == B%2 == C%2:
    nums = sorted([A, B, C])
    print((nums[2]*2 - (nums[0]+nums[1]))//2)
else:
    if A%2 == B%2:
        A += 1
        B += 1
    elif A%2 == C%2:
        A += 1
        C += 1
    else:
        B += 1
        C += 1
    nums = sorted([A, B, C])
    print((nums[2]*2 - (nums[0]+nums[1]))//2 + 1)
# Judge status: Accepted
N = int(input())
MOD = 10**9+7
nums = list(map(int, input().split()))
B = [0 for _ in range(60)]
for num in nums:
  for i in range(60):
    if num>>i&1:
      B[i] += 1
answer = 0
for i, b in enumerate(B):
  if b > 0:
    answer = (answer+b*(N-b)*2**i)%MOD
print(answer)
# Judge status: Wrong Answer
import math
A,B = map(int, input().split())

# 最大公約数の算出
y = max(A,B)
x = min(A,B)
while y%x != 0:
  tmp = x
  x = y%x
  y = tmp

# 素因数分解
p = []
for n in range(2,int(math.sqrt(x))+1):
  if x % n == 0:
    x /= n
    p.append(n)
  else:
    p.append(int(x))
p = list(set(p))
print(len(p))
# Judge status: Accepted
N=int(input())
W=list(map(int,input().split()))
sa=[]
for i in range(N-1):
  S1=sum(W[:i+1])
  S2=sum(W[i+1:])
  #print(S1,S2)
  sa.append(abs(S2-S1))
print(min(sa))
# Judge status: Accepted
from collections import Counter

n = int(input())
C = input()

c = Counter(C)

numR = 0

for i in range(c['R']):
  if C[i] == 'R':
    numR += 1

print(c['R']-numR)
# Judge status: Accepted
#!/usr/bin/env python3

#import
#import math
#import numpy as np
N, M = map(int, input().split())
Q = [list(map(int, input().split())) for _ in range(M)]

R = [False] * (N + 1)
num = [1] * (N + 1)

R[1] = True

for x, y in Q:
    R[y] = R[x] or R[y]
    num[x] -= 1
    num[y] += 1

    if num[x] <= 0:
        R[x] = False

print(R.count(True))
# Judge status: Accepted
n = input()
list = map(int, input().split())

num = 1
a = 0

for i in list:
  if i == num:
    num = num +1
  else:
    a = a + 1

if num == 1:
  print(-1)
else:
  print(a)
# Judge status: Accepted
n,m=map(int,input().split())

l=[]
for i in range(n):
  p=list(map(int,input().split()))
  for j in range(1,p[0]+1):
    l.append(p[j])

cnt=0

for k in l:
  if l.count(k)==n:
    cnt+=1

print(cnt//n)
# Judge status: Wrong Answer
import sys

n,m = map(int, input().split())
a = [int(input()) for i in range(m)]
a.append(n)
a.insert(0, 0)

def nCr(n, r):
  num = 1
  for i in range(r+1, n+1):
    num *= i
  return num


P = 1
for i in range(m):
  if a[i] + 1 == a[i+1]:
    print(0)
    sys.exit()

for i in range(1, m+2):
  step = a[i] - a[i-1] - 1
  pattern = 1
  for j in range(1, int(step/2+1)):
    pattern += nCr(step-j, j)
  P *= pattern 

print(P%1000000007)
# Judge status: Accepted
S = str(input())
ans = ''
ans2 = ''
con = 0
for s in S:
  ans += s
  if ans != ans2:
    con += 1
    ans2 = ans
    ans = ''
print(con)
# Judge status: Accepted
n = int(input())
p = list(map(int,input().split()))
mn = 2*10**5+1
count = 0
for i in range(n):
  if p[i] < mn:
    count += 1
    mn = p[i]
print(count)
# Judge status: Wrong Answer
import sys
X, Y = map(int, input().split())

MOD = 1000000007
if (2*X-Y)%3!=0:
    print(0)
    sys.exit()

A = int((2*X-Y)/3)
B = int(Y-2*A)

if A<0 or B<0:
    print(0)
    sys.exit()

ans = 1
inv = 1
for i in range(B):
    ans = ans * (A+B-i) %MOD
    inv = inv * (i+1) %MOD

ans = ans * pow(inv, MOD-2, MOD) %MOD
print(ans)
# Judge status: Wrong Answer
a = list(map(str, input()))
b = list(map(str, input()))

if a[0] == b[0] and a[1] == b[1] and a[2] == b[2]:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
n = int(input())
xi = list(map(int, input().split()))

cost = []
for p in range(max(xi)):
    tmp = 0
    for i in xi:
        tmp += pow((p - i), 2)
    cost.append(tmp)

print(min(cost))
# Judge status: Accepted
a, b = map(int, input().split())
if a * b % 2: print('Odd')
else: print('Even')
# Judge status: Wrong Answer
S = input()
count = 0
count_max = 0
for i in range(len(S)):
    if S[i] == 'A' or S[i] == 'C' or S[i] == 'G' or S[i] == 'T':
        count += 1
        continue
    else:
        if count_max <= count:
            count_max = count

print(count_max)
# Judge status: Accepted
n = int(input())

if n % 2 == 0:
  a = n // 2
else:
  a = n // 2 + 1

print(a / n)
# Judge status: Accepted
import bisect

N = int(input())
A = [int(input()) for i in range(N)]

def lis(S):
    from bisect import bisect_right
    L = [S[0]]

    for s in S[1:]:
        if s >= L[-1]:
            L.append(s)
        else:
            L[bisect_right(L, s)] = s
    return len(L)

print(lis(A[::-1]))
# Judge status: Accepted
N, M = map(int, input().split())

if N == 2 or M == 2:
  print(0)
elif N == 1:
  print(abs(M-2))
elif M == 1:
  print(abs(N-2))
else:
  print((N-2) * (M-2))
# Judge status: Wrong Answer
n = str(input())
if n[0] or n[1] or n[2] != 7:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
a, b = map(int, input().split())
s = 0
for n in range(a,b+1):
  n = str(n)
  l = len(n)
  for i in range(int((l+1)/2)):
    if n[i] != n[l-1-i]:
      break
    elif n[i] == n[l-1-i] and i == (l-1)/2:
      s+= 1
    else:
      continue
print(s)
# Judge status: Wrong Answer
if __name__ == '__main__':
    n = int(input())
    lst = list(map(int, input().split()))

    ans = 100
    for i in range(-100,101):
        mn = 0
        for c in lst:
            mn += (i-c)*(i-c)
        ans = min(ans,mn)

    print(ans)
# Judge status: Accepted
n = int(input())
a=0
for i in range(10):
  x = 2 ** i
  if x <=n:
    a=x
    
print(a)
# Judge status: Accepted
from fractions import gcd
N,X=map(int,input().split())
x=list(map(int,input().split()))
z=list(map(lambda i: abs(X-i),x))
ans=z[0]
for i in range(1,N):
    ans=gcd(ans,z[i])
print(ans)
# Judge status: Accepted
n, m = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
l = []
for i in range(m):
    b, c = map(int, input().split())
    l.append((b, c))
l = sorted(l, key=lambda x: x[1], reverse=True)
cnt = 0
b = 0
ans = 0
for i in a:
    if cnt == m and b == 0:
        ans += i
        continue
    if b == 0:
        b, c = l[cnt]
        cnt += 1
    ans += max(c, i)
    b -= 1
print(ans)
# Judge status: Accepted
N = int(input())
if N==0:
    print(0)
    exit()

ans = ''
while N!=1:
    d = N%2
    ans += str(d)
    N -= d
    N //= -2
ans += '1'
print(ans[::-1])
# Judge status: Accepted
import sys
input = sys.stdin.readline
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
if K >= N:
    print(X * N)
else:
    print(X * K + (N - K) * Y)
# Judge status: Wrong Answer
w,h,x,y=map(int,input().split())


if x==w//2 and y==h//2:
    a=1
else:
    a=0
print(w*h/2,a)
# Judge status: Wrong Answer
from bisect import bisect_left

N = int(input())
T, A = map(int, input().split())
H = sorted([T-(int(a)*0.006) for a in input().split()])
ans = bisect_left(H, A)
print(ans)
# Judge status: Wrong Answer
X = int(input())
money = 100
count = 0
while money < X:
    count += 1
    money = int(money * 1.01)
print(count)
# Judge status: Wrong Answer
S=list(map(str,input()))
cnt1=0
cnt2=0
if S[0]!=S[1]:
    for i in range(1,4):
        if S[0]==S[i]:
            cnt1 +=1
    for j in range(2,4):
        if S[1]==S[j]:
            cnt2 +=1
    if cnt1==1 and cnt2==1:
        print("Yes")
    else:print("No")
else:
    if S[2]==S[3]:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
a,b,c,d=map(int, input().split())
if (abs(a-b)<=d and abs(b-c)<=d) or abs(a-c)<=d:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
ans = [1]*365
for i in range(365):
    ans[i]=i%26 + 1

for i in range(200,250):
    ans[i]=i%52 //2 + 1

for i in range(365):
    print(i,ans[i])
# Judge status: Wrong Answer
n=list(input())
n1=int("".join(n))
l=[]
for i in n:
    l.append(int(i*3))

idx=-1
a=99999
for i in range(0,3):
    if a>abs(l[i]-n1) and l[i]>=n1:
        idx=i
        a=abs(l[i]-n1)
print(l[idx])
# Judge status: Accepted
def resolve():
    A, B, C = list(map(int, input().split()))
    K = int(input())
    cnt = 0
    while cnt < K:
        if A >= B:
            B *= 2
            cnt += 1
            continue
        if B >= C:
            C *= 2
            cnt += 1
            continue
        cnt += 1
    if A < B < C:
        print('Yes')
    else:
        print('No')
    return

resolve()
# Judge status: Accepted
def main():
    n = int(input())

    print((n * (n + 1)) // 2)

if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
S_list = []
for n in range(N):
    S_list.append(input())

dic = dict()
for s in S_list:
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1

dict_sorted = sorted(dic.items(), key=lambda x: x[1], reverse=True)

outs = []
max = None
for (out, num) in dict_sorted:
    if max is None:
        outs.append(out)
        max = num
    elif max == num:
        outs.append(out)
    else:
        break

for out in sorted(outs):
    print(out)
# Judge status: Accepted
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
counter = Counter(a)
cnt = 0
for k, v in counter.items():
  cnt += v if k > v else v - k
print(cnt)
# Judge status: Accepted
s = input()

x = s[0::2]
y = s[1::2]
if ('L' in x or 'R' in y):
   print('No')
else:
   print('Yes')
# Judge status: Wrong Answer
q, h, s, d = map(int, input().split())
n = int(input())

q4 = 4*q
h2 = 2*h

minimum = min(q4, h2, s)

ans = 0
tmp = n//2
tmp2 = n % 2

ans += tmp * d
ans += tmp2 *minimum

print(ans)
# Judge status: Wrong Answer
a,b = map(int, input().split())
if a == 2 or b == 2:
  print('No')
elif a == (4 or 6 or 9 or 11):
  if b == (4 or 6 or 9 or 11):
    print('Yes')
  else:
    print('No')
else:
  if b == (4 or 6 or 9 or 11):
    print('No')
  else:
    print('Yes')
# Judge status: Wrong Answer
import math
N = int(input())
count = 0
ans = 0
for i in range(N):
    money = 0
    money = math.floor(i*1.08)
    if money == N:
        count += 1
        ans = i
        break
if count == 0:
    print(":(")
else:
    print(ans)
# Judge status: Wrong Answer
N = int(input())
print(N*800-15//N*400)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
    a[i]=a[i]-(i+1)
import numpy as np
an=np.array(a)
b=int(np.median(an))
ans=0
for i in a:
    ans+=abs(i-b)
print(ans)
# Judge status: Wrong Answer
S = input()

odd = list(S[::2])
even = list(S[1::2])
x = "No"

for i in range(len(odd)):
  if odd[i] == "L" or "U" or "D":
    x = "Yes"
  else:
    continue
  
for i in range(len(even)):
  if even[i] == "R" or "U" or "D":
    x = "Yes"
  else:
    continue
  
print(x)
# Judge status: Wrong Answer
import math
A,B = map(float,input().split())
if A == int(A) and 0<=A<=10**15 and 0<=B<10:
    d = A*B
    c = math.floor(d)
    print(c)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
x=[0]*10**5
for i in a:
  x[i]+=1
ans=0
for i in range(10**5-2):
  ans=max(ans,x[i]+x[i+1]+x[i+2])
print(ans)
# Judge status: Wrong Answer
l = [1, 2, 4, 8, 16, 32, 64]
n = int(input())
l.append(n)
l.sort()
print(l[l.index(n)-1])
# Judge status: Accepted
N = int(input())
list = []
for i in range(N):
    list.append(input())
print(len(set(list)))
# Judge status: Wrong Answer
N, K = map(int, input().split())
print(N%K)
# Judge status: Accepted
N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
 
a,b = [0],[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])
 
ans,j = 0,M
for i in range(N+1):
    if a[i]>K:
        break    
    while b[j]>K-a[i]:
        j -= 1    
    ans = max(ans,i+j)
print(ans)
# Judge status: Wrong Answer
x = int(input())
dis = 0
time = 0

for i in range(1,10**10):
  if x - dis -i>= i+1:
    time += 1
    dis += i
  else:
    print(x-dis)
    exit()
# Judge status: Wrong Answer
import math
import collections
import itertools

def resolve():

    N=int(input())

    ans=0
    for i in range(1,N):
        if(10<=i<99 or 1000<=i<9999 or 100000<=i<999999):
            continue
        ans+=1
    print(ans)
resolve()
# Judge status: Wrong Answer
import sys
read = sys.stdin.read
from math import gcd
def main():
    n = int(input())
    t = [int(input()) for _ in range(n)]
    if n == 1:
        print(t[0])
        sys.exit()
    r = (t[0] * t[1]) // gcd(t[0], t[1])
    if n == 2:
        print(r)
        sys.exit()
    for i1 in range(2, n):
        r = (r * t[i1]) // gcd(r, t[1])
    print(r)

if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b,c=map(int,input().split())
temp=[a,b,c]
temp.sort()
if temp[0]+temp[1]==temp[2]:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
n = input()

if set(list(n)) == {'9'}:
    print(len(list(n))*9)
    exit()

tmp = ''
for i in range(1,len(n)):
    if n[i] == '9':
        tmp += n[i-1]
        print(tmp)
    else:
        n[i]!= '9'
        tmp += str(int(n[i-1])-1) + '9'*(len(n)-i)
        break
else:
    tmp += '9'

ans=0
for i in range(len(tmp)):
    ans += int(tmp[i]) 

print(ans)
# Judge status: Accepted
a, b, x = map(int, input().split())
ans = int(b//x) - int(a//x)
if a%x ==0:
    ans += 1
print(ans)
# Judge status: Accepted
import sys
from fractions import gcd
input = sys.stdin.readline


def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table


a, b = map(int, input().split())
g = gcd(a, b)
print(len(set(prime_decomposition(g))) + 1)
# Judge status: Wrong Answer
n, m = map(int, input().split())

m += n * 2

if m <= 3:
    print(0)
else:
    print(m // 4)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
cnt = 1
flag = ""
for i in range(1,N):
	if A[i - 1] > A[i] and flag == "":
		flag = "+"
	elif A[i - 1] < A[i] and flag == "":
		flag = "-"
	elif flag == "+" and (A[i - 1] < A[i]):
		cnt += 1
		flag = ""
	elif flag == "-" and (A[i - 1] > A[i]):
		cnt += 1
		flag = ""
print(cnt)
# Judge status: Wrong Answer
l=input().split()
print(l[0]+l[1][0]+l[2])
# Judge status: Wrong Answer
s = list(input())

if len(set(s))%2==1:
    print('No')
if len(set(s))==4:
    print('Yes')
if len(set(s))==2:
    if list(set(s))==['N','S']:
        print('Yes')
    elif list(set(s))==['E','W']:
        print('Yes')
    else:
        print('No')
# Judge status: Wrong Answer
n=int(input())
ans=0
for i in range(n):
  a,b=map(int,input().split())
  ans += (b-a%b)%b
print(ans)
# Judge status: Accepted
N,M = map(int,input().split())
C = [[0 for _ in range(2)]for _ in range(N)]


for n in range(N):
    C[n][0], C[n][1] = map(int,input().split())

C.sort()
cost = 0
for n in range(N):
    if C[n][1] <= M:
        cost += C[n][1]*C[n][0]
    else:
        cost += C[n][0]*M
        break
    M -= C[n][1]
    if M <= 0:
        break
print(cost)
# Judge status: Accepted
S=input()
Sdash=[]
for i in range(2,len(S)-1):
    Sdash.append(S[i])
a=0
for i in range(len(S)):
    if S[i].islower()==True:
        a+=1
if S[0]=='A' and Sdash.count('C')==1 and a==len(S)-2:
    print('AC')
else:
    print('WA')
# Judge status: Wrong Answer
n = int(input())
a_ls = list(map(int, input().split()))
times1 = 0
i = 1
while 1 <= i < n-1:
    if a_ls[i-1] < a_ls[i] > a_ls[i+1] or a_ls[i-1] > a_ls[i] < a_ls[i+1]:
        times1 += 1
        i += 1
    i += 1

times2 = 0
i = n-2
while 1 <= i < n-1:
    if a_ls[i-1] < a_ls[i] > a_ls[i+1] or a_ls[i-1] > a_ls[i] < a_ls[i+1]:
        times2 += 1
        i -= 1
    i -= 1
times = min(times1,times2)

print(times+1)
# Judge status: Accepted
a, b, c = map(int, input().split())

ans = c-(a-b)
print(ans if ans >= 0 else 0)
# Judge status: Accepted
a,b,c = map(int,input().split())
k = int(input())
ans = sum([a,b,c])-max(a,b,c)
ans += max(a,b,c) * (2**k)
print(ans)
# Judge status: Accepted
def main():
    i = int(input())
    if i == 0:
        print(0)
        exit()

    ans = ""
    while i:
        p = i % 2
        ans += str(p)
        i = - (i // 2)

    print(ans[::-1])


if __name__ == '__main__':
    main()
# Judge status: Accepted
r, g, b = (int(x) for x in input().split())


s = 100*r+10*g+b

if s%4 == 0:
    print("YES")
else:
    print("NO")
# Judge status: Wrong Answer
import math
import os
import random
import re
import sys
def dpfindpath(a):
	dpath=[int(0) for _ in range(len(a))]
	print(len(dpath))
	dpath[0]=0
	dpath[1]=abs(a[1]-a[0])
	for i in range(2,len(a)):
		dpath[i]=min(abs(a[i]-a[i-1])+dpath[i-1],abs(a[i]-a[i-2])+dpath[i-2])
	return dpath[len(a)-1]
n=int(input())
a=input().split()
for i in range(n):
  a[i]=int(a[i])
print (dpfindpath(a))
# Judge status: Accepted
n,m = map(int, input().split())

'''
d = dict()
for i in range(1,n+1):
    d[str(i)] = 1
from collections import deque
ans = deque('1')'''
box = [1 for i in range(n)]
ans = [0 for i in range(n)]
ans[0] = 1
for _ in range(m):
    x,y = map(int,input().split())
    box[x-1] -= 1
    box[y-1] += 1
    if ans[x-1]==1 and ans[y-1]==0:
        ans[y-1] = 1
    if box[x-1]==0 and ans[x-1]==1:
        ans[x-1] = 0
print(sum(ans))
# Judge status: Accepted
# -*- coding: utf-8 -*-
import sys

N, *AB = map(int, sys.stdin.buffer.read().split())

A = sorted(AB[::2])
B = sorted(AB[1::2])

center = N//2

if N%2==1:
  print(B[center]-A[center]+1)
else:
  print((B[center]+B[center-1])-(A[center]+A[center-1])+1)
# Judge status: Accepted
n = int(input())
flag = 0
for i in range(1,10):
    for j in range(1,10):
        if i*j == n:
            flag = 1
if flag == 1:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
k, a, b = map(int, input().split())

if a + 1 >= b:
  print(1 + k)
  
else:
  if k < a + 1:
    print(1 + k)
  else:
    
    a1 = b #a+1回
    if (k - (a + 1)) % 2 == 0:
      a2 = ((k - (a + 1)) // 2) * (b - a)
    else:
      a2 = ((k - (a + 1) - 1) // 2) * (b - a) + 1
    print(a1 + a2)
# Judge status: Accepted
from itertools import permutations
n = int(input())
p = tuple(map(int, input().split()))
q = tuple(map(int, input().split()))

for n, i in enumerate(permutations(sorted(p))):
    if i == p:
        pn = n

for n, i in enumerate(permutations(sorted(q))):
    if i == q:
        qn = n
print(abs(pn-qn))
# Judge status: Accepted
A, B, C = map(int, input().split())
if (A + B) >= C:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
s = input()
print('2018' + s[4:])
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))

bit_l=[0 for _ in range(60)]

for x in a:
  for i in range(60):
    if ((x>>i)&1):
      bit_l[i]+=1
ans=0
mod=10**9+7
for y in range(len(bit_l)):
  r=2**y
  k=(n-bit_l[y])*bit_l[y]
  ans+=r*k%mod
  
print(ans%mod)
# Judge status: Accepted
def main():
    S = list(map(int, input().split('/')))
    if S[0] < 2019:
        print('Heisei')
    elif S[0] == 2019:
        if S[1] <= 4:
            print('Heisei')
        else:
            print('TBD')
    else:
        print('TBD')
 
 
main()
# Judge status: Accepted
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for a,b in ab:
    ans = []
    for c,d in cd:
        ans.append(abs(a-c)+abs(b-d))
    print(ans.index(min(ans))+1)
# Judge status: Wrong Answer
A, B = map(int, input().split(' '))

if A >= 13:
    print(B)
elif A >=6:
    print(B/2)
else:
    print(0)
# Judge status: Wrong Answer
N = int(input())
ab = []
for i in range(N):
    ab.append(tuple(map(int,input().split())))
 
up = sorted(ab,key=lambda a:a[0])
down = sorted(ab,key=lambda a:a[1],reverse=True)
 
if N%2 == 1:
    print(up[N//2][1]-down[N//2][0]+1)
else:
    r = (up[N//2-1][1]+up[N//2][1])
    l = (down[N//2-1][0]+down[N//2][0])
    print(r-l+1)
# Judge status: Accepted
a, b = map(int, input().split())
ab = str(a) * b
ba = str(b) * a
if ab > ba:
  print(ba)
else:
  print(ab)
# Judge status: Accepted
A = list(input())
if A[2] == A[3] and A[4] == A[5]:
	print("Yes")
else:
  	print("No")
# Judge status: Accepted
N = int(input())
zoro = []
for _ in range(N):
    a, b = map(int, input().split())
    zoro.append(a == b)

for i in range(N - 2):
    if zoro[i] and zoro[i + 1] and zoro[i + 2]:
        print("Yes")
        exit()
        
print("No")
# Judge status: Accepted
n = int(input())
lst = [x for x in input().split()]

lst1 = lst[0::2]
lst2 = lst[1::2]

if n % 2 == 0:
    lst2.reverse()
    ret = lst2 + lst1
else:
    lst1.reverse()
    ret = lst1 + lst2

print(" ".join(ret))
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
ans = 'Yes' if b-a == c-a else 'No'
print(ans)
# Judge status: Wrong Answer
k, a, b = map(int, input().split())

if k < (a + 2) or (b - a) <= 2:
    print(1 + k)
else:
    cnt = (k - (a - 1)) // 2
    mod = (k - (a - 1)) % 2
    ans = (b - a)*cnt + a + mod
    print(ans)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

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

mod = []
for i in range(max(B,C)):
    res = A * i % B
    if res == C:
        ans = "YES"
        print(i)
        break
    if res in mod:
        ans = "NO"
        break
    mod.append(res)

print(ans)
# Judge status: Accepted
n, a, b, c, d = map(int, input().split())
s = input()

if '##' in s[a - 1:max(c, d)]:
    print('No')
elif c < d or ('...' in s[b - 2:d + 1]):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
day = input()

if day == "SUN":
  print(7)
elif day == "MON":
  print(6)
elif day == "TUE":
  print(5)
elif day == "WED":
  print(4)
elif day == "THU":
  print(3)
elif day == "FRI":
  print(2)
else:
  print(1)
# Judge status: Wrong Answer
N = int(input())
b = list(map(int,input().split()))
print(b)
for i in range(N + 1):
    a = b.count(i)
    print(a)
# Judge status: Accepted
A=int(input())
B=int(input())
C=int(input())
X=int(input())
ans=0

for a in range(A+1):
    if X < 500*a:
        break
    for b in range(B+1):
        if X < 500*a+100*b:
            break
        for c in range(C+1):
            if X == 500*a+100*b+50*c:
                ans+=1
print(ans)
# Judge status: Accepted
n = input()

num = [int(n[i]) for i in range(len(n))]

print('Yes' if sum(num) % 9 == 0 else 'No')
# Judge status: Accepted
N,M = map(int, input().split())

ans = 0
if N >= 2:
  ans += N * (N-1) // 2

if M >= 2:
  ans += M * (M-1) // 2

print(ans)
# Judge status: Wrong Answer
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = list(input())
for i in range(n-k):
    if t[i+k] == t[i]:
        t[i+k] == 0
x = t.count("r")*p+t.count("s")*r+t.count("p")*s
print(x)
# Judge status: Accepted
a, b, _, k = map(int, input().split())
print((a - b)*((-1)**(k & 1)))