Harryxun/stf_run huggingface dataset:
import math
A = int(input())
B = int(input())
H = int(input())
M = int(input())
c = 0

h = H * 30 + 0.5 * M
m = 6 * M
hh = abs(h - m)
mm = 360 - hh

if hh <= mm:
    c = hh
else:
    c = mm

c = math.radians(c)

C = (A * A) + (B * B) - (2 * A * B * math.cos(c))

print(math.sqrt(C))

### FIXED CODE ###

import math
A,B,H,M = map(int,input().split())


h = H * 30 + 0.5 * M
m = 6 * M
hh = abs(h - m)
mm = 360 - hh

if hh <= mm:
    c = hh
else:
    c = mm

c = math.radians(c)

C = (A * A) + (B * B) - (2 * A * B * math.cos(c))
print(math.sqrt(C))

"""
A = int(input())
B = int(input())
H = int(input())
M = int(input())
"""
A, B = map(int, input().split()
count = 0
for i in range(A, B+1):
    if i == i[::-1]:
        count += 1
print(count)

### FIXED CODE ###

A, B = map(int, input().split())
a = 0
for i in range(A, B+1):
    i = str(i)
    if i == i[::-1]:
        a += 1
print(a)
from scipy.special import comb
n,m = map(int,input().split())
ans = comb(n,2,exact=True)+comb(m,2,exact=True)

print(ans)

### FIXED CODE ###

n,m = map(int,input().split())
a = int(n*(n-1)/2)
b = int(m*(m-1)/2)
print(a+b)
import bisect

N, K = map(int, input().split())
x = list(map(int, input().split()))
ans = 10**9
#print(bisect.bisect(x, 0))

for i in range(len(x) - K + 1):
  if x[i] <= 0 and x[i+K-1] >= 0:
    tmp = abs(x[i]) + x[i+K-1] + min(abs(x[i]), x[i+K-1])
  elif i == bisect.bisect(x, 0):
    tmp = x[i+K-1]
  elif i+K-1 == bisect.bisect(x, 0):
    tmp = abs[x[i]]
#  print("i:{}, i+K-1:{}, tmp:{}".format(i, i+K-1, tmp))
  ans = min(tmp, ans)
print(ans)

### FIXED CODE ###

import bisect

N, K = map(int, input().split())
x = list(map(int, input().split()))
ans, tmp = 10**9, 10**9

#print(bisect.bisect(x, 0))

for i in range(len(x) - K + 1):
  if x[i] <= 0 and x[i+K-1] >= 0:
    tmp = abs(x[i]) + x[i+K-1] + min(abs(x[i]), x[i+K-1])
  elif x[i] < 0 and x[i+K-1] <= 0:
    tmp = abs(x[i])
  elif x[i] >= 0 and x[i+K-1] > 0:
    tmp = x[i+K-1]
#  elif i == bisect.bisect(x, 0)-1:
#    tmp = x[i+K-1]
#  elif i+K-1 == bisect.bisect(x, 0)-1:
#    tmp = abs[x[i]]
#  print("i:{}, i+K-1:{}, tmp:{}".format(i, i+K-1, tmp))
  ans = min(tmp, ans)
print(ans)
import fraction

N, X = map(int, input().split())
x = list(map(int, input().split()))

min_distance = abs(x[0] - X)
for i in x: min_distance = fraction.gcd(abs(i - X), min_distance)

print(min_distance)


### FIXED CODE ###

import fractions

N, X = map(int, input().split())
x = list(map(int, input().split()))

min_distance = abs(x[0] - X)
for i in x: min_distance = fractions.gcd(abs(i - X), min_distance)

print(min_distance)
while(1):
  count = input()
  if count == 0: break
  original_cube = [1, 2, 3, 4, 5, 6]
  operation{'North':[2, 6, 3, 4, 1, 5], 'East':[4, 2, 1, 6, 5, 3], 'West': [3, 2, 6, 1, 5, 4], 'South':[5, 1, 3, 4, 6, 2], 'Right':[1, 3, 5, 2, 4, 6], 'Left[1, 4, 2, 5, 3, 6]}
  sum = 0
  for i in xrange(count):
    new_cube = []
    for e in operation[input()]:
      new_cube.append(previous_cube[e])
    sum += new_cube[0]
    previous_cube = new_ccube
  print sum

### FIXED CODE ###

while 1:
  n = input()
  if n == 0:  break
  d = range(1, 7)
  ans = 1
  for i in range(n):
    c = raw_input()[0]
    if c == 'N': S = [1,5,2,3,0,4]
    elif c == "S": S = [4,0,2,3,5,1]
    elif c == "E": S = [3,1,0,5,4,2]
    elif c == "W": S = [2,1,5,0,4,3]
    elif c == "R": S = [0,2,4,1,3,5]
    elif c == "L": S = [0,3,1,4,2,5]
    d = [d[s] for s in S]
    ans += d[0]
  print ans
if input()='SUN':
	print(7)
elif input()='MON':
  print(6)
elif input()='TUE':
  print(5)
elif input()='WED':
  print(4)
elif input()='THU':
  print(3)
elif input()='FRI':
  print(2)
else
  print(1)


### FIXED CODE ###

s=input()
if s=='MON':
  print(6)
elif s=='TUE':
  print(5)
elif s=='WED':
  print(4)
elif s=='THU':
  print(3)
elif s=='FRI':
  print(2)
elif s=='SAT':
  print(1)
else:
  print(7)
N = input()
sum=1

for i in range(1, N):
    sum=(sum*i)%1000000007

print(sum)

### FIXED CODE ###

N = int(input())
sum=1

for i in range(1, N+1):
    sum=(sum*i)%1000000007

print(sum)
import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)

n = int(input())
pair = []
for i in range(n):
    for j in range(i + 1,n):
        pair.append((i,j))

G = {i:set() for i in pair}
inedge = {i:0 for i in pair}
for i in range(n):
    a = [int(i) - 1 for i in input().split()]
    for j in range(n - 2):
        if i <= a[j] and i <= a[j + 1]:
            G[(i,a[j])].add((i,a[j + 1]))
            inedge[(i,a[j + 1])] += 1
        elif i <= a[j] and i > a[j + 1]:
            G[(i,a[j])].add((a[j + 1],i))
            inedge[(a[j + 1],i)] += 1
        elif i > a[j] and i <= a[j + 1]:
            G[(a[j],i)].add((i,a[j + 1]))
            inedge[(i,a[j + 1])] += 1
        else:
            G[(a[j],i)].add((a[j + 1],i))
            inedge[(a[j + 1],i)] += 1
    
visited = {i:0 for i in pair}
finished = {i:0 for i in pair}
print(G)

flag = 1
def dfs(node): #サイクルの検出用
    global flag
    visited[i] = 1
    for e in G[node]:
        if finished[node]:
            continue
        if visited[node] and finished[node] == 0:
            flag = 0
            return
        dfs(e)
    if flag == 0:
        return
    finished[node] = 1

dfs((0,1))
    
if flag == 1:
    st = deque()
    dist = {i:-1 for i in pair}
    for i in pair:
        if inedge[i] == 0:
            st.append(i)
            dist[i] = 1
        
    while len(st):
        node = st.pop()
        for e in G[node]:
            dist[e] = max(dist[e],dist[node] + 1)
            inedge[e] -= 1
            if inedge[e] == 0:
                st.append(e)  
    print(dist) 
    print(max(dist.values()))
else:
    print(-1)



### FIXED CODE ###

import sys
INF = 10 ** 9
MOD = 10 ** 9 + 7
from collections import deque
sys.setrecursionlimit(100000000)
input = sys.stdin.readline
from copy import deepcopy 

MAXN = 1005
MAXV = MAXN * (MAXN - 1)//2
G = [[] for _ in range(MAXV)]

id = [[-1] * MAXN for _ in range(MAXN)]
def toId(i,j):
    if i > j:
        i,j = j,i
    return id[i][j]


finished = [0] * MAXV
dp = [-1] * MAXV
def dfs(v):
    if dp[v] != -1:
        if finished[v] == 0:
            return -1
        return dp[v]
    dp[v] = 0
    for e in G[v]:
        res = dfs(e)
        if res == -1:
            return -1
        dp[v] = max(dp[v],res + 1)
    finished[v] = 1
    return dp[v]


def main():
    n = int(input())
    a = [[int(i) - 1 for i in input().split()] for _ in range(n)]

    v = 0
    for i in range(n):
        for j in range(i + 1,n):
            id[i][j] = v
            v += 1
    
    for i in range(n):
        for j in range(n - 1):
            a[i][j] = toId(i,a[i][j])
        for j in range(n - 2):
            G[a[i][j]].append(a[i][j + 1])
    
    ans = 0
    for i in range(v):
        res = dfs(i)
        if res == -1:
            ans = -1
            break
        ans = max(ans,dfs(i) + 1)
    
    print(ans)

if __name__=='__main__':
    main()
import math
n = int(input())
t = [int(input()) for i in range(n)]
ans = 1
for i in t:
    ans = ans * i // math.gcd(ans,i)
print(ans)

### FIXED CODE ###

import fractions
n = int(input())
t = [int(input()) for i in range(n)]
ans = 1
for i in t:
    ans = ans * i // fractions.gcd(ans,i)
print(ans)
if x==1 :
  print(0)
else :
  print(1)

### FIXED CODE ###

x = int(input())
if x == 1 :
  print(0)
else :
  print(1)
a,b=map(int,input().spkit())
if(a+b>=10):
  print("error")
else:
  print(a+b)

### FIXED CODE ###

a,b=map(int,input().split())
if(a+b>=10):
  print("error")
else:
  print(a+b)
#k分たったときには机Aの本を上から何冊か、机Bの本を上から何冊か読んでることになる
#つまり机A,Bの方で読んだ本の合計時間は累積和で計算可能
#あとはその範囲内で全探索すればいい
#その際Aの読む数を決めておけばBの方は2分探索で決められる
n,m,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
from itertools import accumulate
a=[0]+list(accumulate(a))
b=[0]+list(accumulate(b))
from bisect import bisect_right
c=bisect_right(a,k)
ans=0
for i in range(c-1):
  ans=max(ans,i+bisect_right(b,k-b[i]))

print(ans)


### FIXED CODE ###

#Aの上からi冊、Bの上からj冊をとりi+jを条件を満たしながら最大化したい
#累積和と二分探索の練習問題
#値を固定するという概念。iが決まればjが決まる
from bisect import bisect_left
from itertools import accumulate
n,m,k=list(map(int,input().split()))
a=list(map(int,input().split()))
b=list(map(int,input().split()))
A=[0]+list(accumulate(a))
B=[0]+list(accumulate(b))

ans=0
sup_i=bisect_left(A,k+1)
for i in range(sup_i):
  ans=max(ans,i+bisect_left(B,k-A[i]+1)-1)
 
print(ans)
import bisect
X,Y,A,B,C=map(int,input().split())

AList=list(map(int,input().split()))
BList=list(map(int,input().split()))
CList=list(map(int,input().split()))

AList.sort(reverse=True)
BList.sort(reverse=True)
CList.sort(reverse=True)

alist = AList[0:X] + BList[0:Y] + CList
alist.sort(reverse=True)

print(int(sum(alist[:X+Y])))


### FIXED CODE ###

N,X,Y=map(int,input().split())

ans = [0 for i in range(N+1)]

for i in range(1,N+1):
  for j in range(i+1,N+1):
    if i < X :
      if j < X:
        a = j - i
        ans[a] += 1
      elif j >= X and j < Y:
        a = j - i
        b = (X-i) + 1 + (Y-j)
        c = min(a,b)
        ans[c] += 1
      else:
        a =  (X-i)+ 1 + (j - Y)
        ans[a] += 1
        
    elif i >= X and i < Y:
      if j < Y:
        a = j - i
        b = (i-X) + 1 + (Y-j)
        c = min(a,b)
        ans[c] += 1
      else:
        a = j -i
        b =  (i-X) + 1 + (j - Y)
        c = min(a,b)
        ans[c] += 1
        
    else:
      a = j - i
      ans[a] += 1
        
for i in range(1,N):
  print(int(ans[i]))
#include <bits/stdc++.h>
using namespace std;
double E(double x){
  return (x+1.) * x / 2. / x;
}

int main(){
  int N,K;
  cin >> N >> K;
  vector<double> Es(N,0);
  double ans = 0;
  auto itr = Es.begin();
  for(int i=0; i<N; i++){
    cin >> *itr;
    *itr = E(*itr); 
    itr++;
    if(i+1 >= K) ans = max(ans, accumulate(prev(itr,K), itr, 0.0));
  }
  cout << ans << endl;
}

### FIXED CODE ###

from itertools import accumulate
N, K = map(int, input().split())
ans = [0] + list(accumulate(map(lambda x: (int(x)+1)/2., input().split())))
print(max([y-x for x,y in zip(ans, ans[K:])]))
s=input()
if(len(s)>6s=input()

if(s[2]==s[3] and s[4]==s[5]):
  print("Yes")
else:
  print("No")


### FIXED CODE ###

s=input()
 
if(s[2]==s[3] and s[4]==s[5]):
  print("Yes")
else:
  print("No")
import string

count = {x: 0 for x in string.ascii_lowercase}
lines = ""

while True:
    try:
        lines += input().lower()
    except EOFError:
        break

for c in lines:
    if 'a' <= c <= 'z':
        count[c] += 1

for key in string.ascii_lowercase:
    print("{0 : {1}".format(key, count[key]))

### FIXED CODE ###

import string
  
count = {x: 0 for x in string.ascii_lowercase}
lines = ""
  
while True:
    try:
        lines += input().lower()
    except EOFError:
        break
          
for c in lines:
    if 'a' <= c <= 'z':
        count[c] += 1
          
for key in string.ascii_lowercase:
    print("{0} : {1}".format(key, count[key]))
N = int(input())
A = [int(i) for i in input().split(' ')]
A.sort()
B = [0]*(A[N-1]-A[0]+3)

for a in A:
    B[a] += 1
    B[a-1] += 1
    B[a+1] += 1
print(max(B))

### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split(' ')]
A.sort()
B = [0]*(A[N-1]+3)

for a in A:
    B[a] += 1
    B[a+1] += 1
    B[a+2] += 1

print(max(B))
import sys
 
input = sys.stdin.readline
 
n = int(input())
a = list(map(int, input().strip().split()))
if(0 in a):
 print(0)
 return
else:
 ans = 1
 for ai in a:
  ans *= ai
  if(ans > 10**18):
   print(-1)
   return

 print(ans)

### FIXED CODE ###

import sys

input = sys.stdin.readline
 
n = int(input())
a = list(map(int, input().strip().split()))
if(0 in a):
 print(0)
 sys.exit()
else:
 ans = a[0]
 for i in range (1,n):
  ans = ans*a[i]
  if(ans > 10**18):
   print(-1)
   sys.exit()
 print(ans)
N = int(input())

ans = 0
for n in range(N):
  x, t = input().split()
  if t == "BTC":
    ans += x*380000.0
  else:
    ans += x
print(ans)

### FIXED CODE ###

N = int(input())

ans = 0
for n in range(N):
  x, t = input().split()
  if t == "BTC":
    ans += float(x)*380000.0
  else:
    ans += float(x)
print(ans)
import numpy as np
S = input()
T = input()

tmp = np.zeros(len(T))

i=0
flg=True

while flg:
    for j in range(i, len(T)):
        print(i,j)
        print(T[i:j+1])
        print(T[i:j+1] in S)
        if T[i:j+1] in S:
            tmp[i] = j+1-i
    i = max(i + int(tmp[i]),i+1)
    if i >= len(T)-1:
        flg=False

print(len(T)-int(np.max(tmp)))

### FIXED CODE ###

S=input()
T=input()
ls=len(S)
lt=len(T)
ans=lt
for i in range(0,ls-lt+1):
    a=0
    for j in range(lt):
        if S[i+j]==T[j]:
            a+=1
    ans=min(ans,lt-a)
print(ans)
N = int(input())
data = [list(map(int,input().split())) for _ in range(N)]
sorted_data = sorted(data,key=lambda x: x[2])

def get_H(x,y,h,Cx,Cy):
    return max(0,h+abs(x-Cx)+abs(y-Cy))
def estimate_H(data,Cx,Cy):
    H = get_H(*data[0],Cx,Cy)
    for cur_data in data[1:]:
        tmp = get_H(*cur_data,Cx,Cy)
        if H != tmp:
            break
    else:
        return H
    return None

for Cx in range(101):
    for Cy in range(101):
        tmp = estimate_H(sorted_data,Cx,Cy)
        if tmp != None:
            print(Cx,Cy,tmp)
            break

### FIXED CODE ###

N = int(input())
data = [list(map(int,input().split())) for _ in range(N)]
data.sort(key=lambda x:-x[2])

def get_H(data,Cx,Cy):
    x,y,h = data
    return h+abs(x-Cx)+abs(y-Cy) , h==0
def estimate_H(data,Cx,Cy):
    H,_ = get_H(data[0],Cx,Cy)
    for cur_data in data[1:]:
        tmp,isZero = get_H(cur_data,Cx,Cy)
        if isZero and H <= tmp:
            continue
        if H != tmp:
            break
    else:
        return H
    return None

for Cx in range(101):
    for Cy in range(101):
        tmp = estimate_H(data,Cx,Cy)
        if tmp != None:
            print(Cx,Cy,tmp)
            break
H, W = map(int, input().split())
M = ['.' * (W+2)]
for _ in range(H):
    M.append('.' + input() + '.')
M.append('.' * (H+2))
flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if M[i][j] == '#':
            if '#' not in (M[i+1][j], M[i][j+1], M[i-1][j], M[i][j-1]):
                flag = False
if flag:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

H, W = map(int, input().split())
M = ['.' * (W+2)]
for _ in range(H):
    M.append('.' + input() + '.')
M.append('.' * (W+2))
flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if M[i][j] == '#':
            if '#' not in (M[i+1][j], M[i][j+1], M[i-1][j], M[i][j-1]):
                flag = False
if flag:
    print('Yes')
else:
    print('No')
import sys
input=sys.stdin.readline

n,a,b,c=map(int,input().split())
s_=input().split()
ans=""
for i in range(n):
    s1,s2=s_[i]
    if s2=="B":
        if i!=n-1:
            if s_[i+1]=="AC" and c==0 and a<=1:
                a,b,ans=(a+1,b-1,ans+"A")
            elif s_[i+1]=="BC" and c==0 and b<=1:
                a,b,ans=(a-1,b+1,ans+"B")
            else:
                a,b,ans=(a-1,b+1,ans+"B") if a>b else (a+1,b-1,ans+"A")
        else:
            a,b,ans=(a-1,b+1,ans+"B") if a>b else (a+1,b-1,ans+"A")
        if min(a,b)==-1:
            print("No")
            break
    elif s1=="A":
        if i!=n-1:
            if s_[i+1]=="AB" and b==0 and a<=1:
                a,c,ans=(a+1,c-1,ans+"A")
            elif s_[i+1]=="BC" and b==0 and c<=1:
                a,c,ans=(a-1,c+1,ans+"C")
            else:
                a,c,ans=(a-1,c+1,ans+"C") if a>c else (a+1,c-1,ans+"A")
        else:
            a,c,ans=(a-1,c+1,ans+"C") if a>c else (a+1,c-1,ans+"A")
        if min(a,c)==-1:
            print("No")
            break
    else:
        if i!=n-1:
            if s_[i+1]=="AB" and a==0 and b<=1:
                b,c,ans=(b+1,c-1,ans+"B")
            elif s_[i+1]=="AC" and a==0 and c<=1:
                b,c,ans=(b-1,c+1,ans+"C")
            else:
                b,c,ans=(b-1,c+1,ans+"C") if b>c else (b+1,c-1,ans+"B")
        else:
            b,c,ans=(b-1,c+1,ans+"C") if b>c else (b+1,c-1,ans+"B")
        if min(b,c)==-1:
            print("No")
            break
else:
    print("Yes")
    for j in range(n):
        print(ans[j])



### FIXED CODE ###

n,a,b,c=map(int,input().split())
s_=[input() for i in range(n)]
ans=""
for i in range(n):
    s1,s2=s_[i]
    if s2=="B":
        if a==1 and b==1 and i!=n-1:
            if s_[i+1][0]=="A":
                a,b,ans=(a+1,b-1,ans+"A")
            else:
                a,b,ans=(a-1,b+1,ans+"B")
            continue
        a,b,ans=(a-1,b+1,ans+"B") if a>b else (a+1,b-1,ans+"A")
        if min(a,b)==-1:
            print("No")
            break
    elif s1=="A":
        if a==1 and c==1 and i!=n-1:
            if s_[i+1][1]=="C":
                a,c,ans=(a-1,c+1,ans+"C")
            else:
                a,c,ans=(a+1,c-1,ans+"A")
            continue
        a,c,ans=(a-1,c+1,ans+"C") if a>c else (a+1,c-1,ans+"A")
        if min(a,c)==-1:
            print("No")
            break
    else:
        if c==1 and b==1 and i!=n-1:
            if s_[i+1][1]=="C":
                b,c,ans=(b-1,c+1,ans+"C")
            else:
                b,c,ans=(b+1,c-1,ans+"B")
            continue
        b,c,ans=(b-1,c+1,ans+"C") if b>c else (b+1,c-1,ans+"B")
        if min(b,c)==-1:
            print("No")
            break
else:
    print("Yes")
    for j in range(n):
        print(ans[j])
def f():
  n,m=map(int,input().split())
  o=[input() for _ in range(n)]
  p=[input() for _ in range(m)]
  for i in range(n-m+1):
    for j in range(n-m+1):
      for k in range(i,n-m+1):
        for l in range(j,n-m+1):
          if p[k-i][l-i]!=o[k][l]:
            return False
  return True

if f():
  print("Yes")
else:
  print("No")

### FIXED CODE ###

def func():
  n,m=map(int,input().split())
  o=[input() for _ in range(n)]
  p=[input() for _ in range(m)]
  q=[]
  for i in range(n-m+1):
    for j in range(n-m+1):
      fl=True
      for k in range(m):
        for l in range(m):
          if p[k][l]!=o[i+k][j+l]:
            fl=False
      q.extend([fl])
  return q

a=func()
if sum(a):
  print("Yes")
else:
  print("No")
import sys
from math import ceil

N, s = sys.stdin.read().split('\n')
red_hat_counter = 0

# Get a criteria value from N
criteria_val = ceil(int(N)/2)
print(criteria_val)


# Get a counter of Red
for s_char in s:
  if s_char == "R":
    red_hat_counter += 1
    
# Compare between a criteria value and a counter of Red
if criteria_val < red_hat_counter:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

import sys
input_list = sys.stdin.readlines() 
N, s = map(str.strip, input_list)
red_hat_counter = 0
for s_str in s:
  if s_str == "R":
    red_hat_counter += 1
if red_hat_counter > (int(N)/2):
  print "Yes"
else:
  print "No"
import math
from copy import copy
di = {}
di[0] = 0
for i in range(1, 2*(10**6)+1):
    di[i] = 0
for i in range(1, 2*(10**6)+1):
    count = 0
    for j in range(int(math.log2(i))+4):
        if (i>>j)&1:
            count += 1
    di[i] = di[i%count] + 1
n = int(input())
x = list(input())
x.reverse()
count = 0
for i in x:
    if i =='1':
        count += 1
mod_p = count + 1
mod_m = count - 1
di_p = {}
di_m = {}
for i in range(n):
    di_p[i] = pow(2, i, mod_p)
    di_m[i] = pow(2, i, mod_m)
s_p = 0
s_m = 0
for i in range(n):
    if x[i] == '1':
        s_p += di_p[i]
        s_m += di_m[i]
for i in range(n-1, -1, -1):
    sm = copy(s_m)
    sp = copy(s_p)
    if x[i] == '1':
        sm -= di_m[i]
        sm %= mod_m 
        print(di[sm]+1)
    else:
        sp += di_p[i]
        sp %= mod_p
        print(di[sp]+1)


### FIXED CODE ###

import math
from copy import copy
di = {}
di[0] = 0
for i in range(1, 2*(10**6)+1):
    di[i] = 0
for i in range(1, 2*(10**6)+1):
    count = 0
    for j in range(int(math.log2(i))+4):
        if (i>>j)&1:
            count += 1
    di[i] = di[i%count] + 1
n = int(input())
x = list(input())
x.reverse()
count = 0
for i in x:
    if i =='1':
        count += 1
mod_p = count + 1
mod_m = count - 1
di_p = {}
di_m = {}
for i in range(n):
    di_p[i] = pow(2, i, mod_p)
    if mod_m >= 1:
        di_m[i] = pow(2, i, mod_m)
s_p = 0
s_m = 0
for i in range(n):
    if x[i] == '1':
        s_p += di_p[i]
        if mod_m >= 1:
            s_m += di_m[i]
    else:
        continue
for i in range(n-1, -1, -1):
    sm = copy(s_m)
    sp = copy(s_p)
    if x[i] == '1' and (mod_m == 0 or mod_m == -1):
        print(0)
    elif x[i] == '1':
        sm -= di_m[i]
        sm %= mod_m 
        print(di[sm]+1)
    else:
        sp += di_p[i]
        sp %= mod_p
        print(di[sp]+1)
a = int(input())
if a <= "2019/04/30":
  print("Heisei")
else:
  print("TBD")

### FIXED CODE ###

a = input()
if a <= "2019/04/30":
  print("Heisei")
else:
  print("TBD")
N = int(input())

N_ =str(N)
n_o=len(N_)

# ans:条件を満たす組みの個数
ans=0

def get_ans(A):
    ans=0
    A_=str(A)
    a_s=A_[0]
    a_e=A_[-1]
#     print(a_s,a_e)
    
    if int(a_e) == 0:
        return 0

    if a_s == a_e:
        ans+=1

    for b_o in range(2,n_o+1):
        B_temp = []
        if b_o < n_o:
            ans += 10**(b_o-2)

        elif b_o == n_o:
            if int(a_e) > int(N_[0]):
                break
            elif int(a_e) < int(N_[0]):
                ans += 10**(b_o-2)
            else:      
                for p in product(range(10),repeat=n_o-2):
                    ans_temp=int(a_e+''.join(map(str,p))+a_s)
                    if ans_temp > N:
                        break
                    ans+=1 
                    B_temp.append(ans_temp)
    #                 print(B_temp)

        else:
            break
        
    return ans

for a in range(1,N+1):
#     print('====',a)
    ans_=get_ans(a)
    ans+=ans_
print(ans)

### FIXED CODE ###

N = int(input())

C=[[0]*10 for _ in range(10)]

for n in range(1,N+1):
    n=str(n)
    n_s=int(n[0])
    n_e=int(n[-1])
    
    C[n_s][n_e]+=1
    
ans=0
for c_1 in range(10):
    for c_2 in range(10):
        ans += C[c_1][c_2]*C[c_2][c_1]
        
print(ans)
n,k,s = map(int, input().split())
if s==1:
    xx = 2
else:
    for i in range(2,s//2):
        if s%i != 0:
            xx = i
            break
ans = [xx]* n
for i in range(k):
    ans[i] = s
print(' '.join(map(str, ans)))

### FIXED CODE ###

n,k,s = map(int, input().split())
if s<5:
    xx = 1 + s
else:
    for i in range(2,s):
        if s%i != 0:
            xx = i
            break
ans = [xx]* n
for i in range(k):
    ans[i] = s
print(' '.join(map(str, ans)))
from itertools import accumulate
import bisect

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

acum1=[0]
for i in range(n): #累積和ai,bjを求める
    acum1.append(acum1[-1]+arr1[i])
for i in range(m):
    acum2.append(acum2[-1]+arr2[i])

ans = 0
for an in range(n + 1):
    rem = k - acum1[an]
    if rem < 0:
        # aをこれ以上読めません
        break

    bn = bisect.bisect_right(acum2, rem)
    ans = max(ans, an + bn)

print(ans)

### FIXED CODE ###

from itertools import accumulate
import bisect

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

a_acc = [0] + list(accumulate(a))  # aを0冊読む=1冊も読まない場合があるので、[0]を先頭に追加します
b_acc = list(accumulate(b))  # bisect_rightでは、x以下の要素がいくつあるか？を求めるので、こちらに0は入れません

ans = 0
for an in range(n + 1):
    rem = k - a_acc[an]
    if rem < 0:
        # aをこれ以上読めません
        break

    bn = bisect.bisect_right(b_acc, rem)
    ans = max(ans, an + bn)

print(ans)
from collections import Counter
s=list(input())
a=Counter(s).most_common(2)
print("Yes" if a[0][1]==a[1][1]==2 else "No")

### FIXED CODE ###

from collections import Counter
s=list(input())
a=Counter(s).most_common(2)
if len(a)==1:
    print("No")
    exit()
print("Yes" if a[0][1]==a[1][1]==2 else "No")
a = int(input())
b = int(input())

t = set([1, 2, 3])
s = set([a,b])
ans = t - s
print(list(ans[0]))


### FIXED CODE ###

a = int(input())
b = int(input())
 
t = set([1, 2, 3])
s = set([a,b])
ans = t - s
print(list(ans)[0])
a, b, c, d = [int(x) for x in input().split(" ")]
print(max([a*c a*d, b*c, b*d]))

### FIXED CODE ###

a, b, c, d = [int(x) for x in input().split(" ")]
print(max([a*c, a*d, b*c, b*d]))
A, B = (int(i) for i in input().split())

 
if B%A==0：
    ptint(A+B)
else:
    print(A-B)

### FIXED CODE ###

A, B = map(int, input().split())
 
if B % A == 0:
    print(A + B)
else:
    print(B - A)