Harryxun/stf_run huggingface dataset:
n = input()

INFTY = 10000000

color = [0 for i in range(n)]
M = [[0 for i in range(n)] for i in range(n)]
d = [INFTY for i in range(n)]
p = [-1 for i in range(n)]

def MST():
  d[0] = 0
  p[0] = -1

  while True:
    cost = INFTY
    for i in range(n):
      if color[i] != 1 and d[i] < cost:
        cost = d[i]
        u = i

    if cost == INFTY:
      break
    color[u] = 2

    for v in range(n):
      if color[v] != 2 and M[u][v] != INFTY:
      if M[u][v] < d[v]:
        d[v] = M[u][v]
        p[v] = u
        color[v] = 1:

  sum = 0
  for i in range(n):
    if p[i] != -1:
      sum += M[i][p[i]] 
  return sum

for i in range(n):
  G = map(int, raw_input().split())
  for j in range(n):
   if G[j] == -1:
     M[i][j] = INFTY
   else:
     M[i][j] = G[n]:

print MST()

### FIXED CODE ###

n = input()

INFTY = 10000000

color = [0 for i in xrange(n)]
M = [[INFTY for i in xrange(n)] for i in xrange(n)]
d = [INFTY for i in xrange(n)]
p = [-1 for i in xrange(n)]

def MST():
  d[0] = 0

  while True:
    cost = INFTY
    for i in xrange(n):
      if color[i] != 2 and d[i] < cost:
        cost = d[i]
        u = i

    if cost == INFTY:
      break
    
    color[u] = 2

    for v in xrange(n):
      if color[v] != 2 and M[u][v] != INFTY and M[u][v] < d[v]:
        d[v] = M[u][v]
        p[v] = u
        color[v] = 1

  sum = 0
  for i in xrange(n):
    if p[i] != -1:
      sum += M[i][p[i]]
  return sum

for i in xrange(n):
  G = map(int, raw_input().split())
  for j in range(n):
   if G[j] != -1:
     M[i][j] = G[j]

print MST()
S = int(input())
flag = 0

for i in range(3):
  if S[i] == S[i+1]:
    flag = 1
    
if flag:
  print("Bad")
  
else:
  print("Good")

### FIXED CODE ###

S = list(input())
flag = 0

for i in range(3):
  if S[i] == S[i+1]:
    flag = 1
    
if flag:
  print("Bad")
  
else:
  print("Good")
s = sorted(list(str(input())))
t = reversed(sorted(list(str(input())))
S = str()
T = str()
for i in s:
    S += i
for k in t:
    T += k
print('Yes' if S<T else 'No')

### FIXED CODE ###

s = sorted(list(str(input())))
t = reversed(sorted(list(str(input()))))
S = str()
T = str()
for i in s:
    S += i
for k in t:
    T += k
print('Yes' if S<T else 'No')
x1,y1x2,y2=int(input().split())
print(sqrt((x2-x1)**2+(y2-y1**2)))

### FIXED CODE ###

x1,y1,x2,y2=map(float,input().split())
print("%.6f"%((x2-x1)**2+(y2-y1)**2)**0.5)
x = input()
ans = x ** 3
print(ans)

### FIXED CODE ###

x = int(input())
ans = x ** 3
print(ans)
n = int(input())
a = sorted(list(map(int, input().split())))

MAX_VAL = 2*10**5
prime = [1] * (MAX_VAL+1)
prime[0] = prime[1] = 0
for i in range(2, int(MAX_VAL**0.5)+1):
    if prime[i]:
        for k in range(2*i, MAX_VAL+1, i):
            prime[k] = 0

res = []
for i in range(n):
    prev = a[i-1] if i > 0 else -1
    next = a[i+1] if i < n-1 else -1
    if a[i] == prev or a[i] == next:
        continue
    if prime[a[i]]:
        res.append(a[i])
        continue

    for v in res:
        if a[i] % v == 0:
            break
    else:
        res.append(a[i])

print(len(res))


### FIXED CODE ###

import numpy as np

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

non_divisible = np.ones(a[-1]+1, dtype=np.int8)
non_divisible[0] = 0
for i in range(n):
    if i != 0 and a[i] == a[i-1]:
        non_divisible[a[i]] = 0
    elif non_divisible[a[i]]:
        non_divisible[a[i]*2::a[i]] = 0

res = 0
for aa in a:
    if non_divisible[aa]:
        res += 1

print(res)
W, H, x, y, r = map(int, input().split())
if x == 0 or y == 0 or x < 0 or y < 0:
    print(No)
elif W == x or H == y:
    print("No")

elif W < x or H < y:
    print("No")

elif W < x+r or H < y+r:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

W, H, x, y, r = map(int, input().split())
if x == 0 or y == 0 or x < 0 or y < 0:
    print("No")
elif W == x or H == y:
    print("No")

elif W < x or H < y:
    print("No")

elif W < x+r or H < y+r:
    print("No")
else:
    print("Yes")
# -*- coding: <encoding name> -*-

n = int(input())
total = 0
for i in range(1, n + 1):
	if i % 3 != 0 and i % 5 != 0:
		total +=
print(total)


### FIXED CODE ###

# -*- coding: <encoding name> -*-

n = int(input())
total = 0
for i in range(1, n + 1):
	if (i % 3) != 0 and (i % 5) != 0:
		total += i
print(total)
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
import sys
#input=sys.stdin.readline  #危険！基本オフにしろ！
sys.setrecursionlimit(10**6)



def main():
    n,k=map(int,input().split())
    grid=[tuple(map(int,input().split()))for i in range(n)]
    x=set(s for s,t in grid)
    y=set(t for s,t in grid)
    ans=[]
    for i in combinations(x,2):
        for j in combinations(y,2):
            xx=max(i)
            xxx=min(i)
            yy=max(j)
            yyy=min(j)
            if sum(xxx<=s<=xx and yyy<=t<=yy for s,t in grid)>=k:
                ans.append(abs((yy-yyy)*(xx-xxx)))
    print(min(ans))
if __name__ == '__main__':
    main()


### FIXED CODE ###

a,b,c=map(int,input().split())
print(c if a==b else b if a==c else a)
#!/usr/bin/env python3
import sys
from functools import reduce
import numpy as np
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, M: int, a: "List[int]"):

    def gcd_base(a: int, b: int):
        while b:
            a, b = b, a%b
        return a

    def gcd(*numbers):
        return reduce(gcd_base, numbers)
    
    def lcm_base(a: int, b:int):
        return a*b // gcd_base(a,b)

    def lcm(*numbers):
        return reduce(lcm_base, numbers, 1)

    x = lcm(*a)
    t = x // 2

    def div_of_2(x: int):
        c = 0
        while x%2 == 0:
            c += 1
            x /= 2
        return c
    
    y = div_of_2(x)

    if t > M or any([y != div_of_2(i) for i in a]):
        print(0)
        exit()

    ans = 1
    ans += (M-t)//x
    
    print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, a)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from functools import reduce
import numpy as np
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, M: int, a: "List[int]"):

    def gcd_base(a: int, b: int):
        while b:
            a, b = b, a%b
        return a

    def gcd(*numbers):
        return reduce(gcd_base, numbers)
    
    def lcm_base(a: int, b:int):
        return a*b // gcd_base(a,b)

    def lcm(*numbers):
        return reduce(lcm_base, numbers, 1)

    def num_of_2(x):
        c = 0
        while x%2 == 0:
            c += 1
            x//=2
        return c
    
    a0 = num_of_2(a[0])
    if any([num_of_2(i) != a0 for i in a]):
        print(0)
        exit()


    x = lcm(*a)
    t = x // 2

    # def div_of_2(x: int):
    #     c = 0
    #     while x%2 == 0:
    #         c += 1
    #     return c
    
    # y = div_of_2(t)

    # if t > M or any([y != div_of_2(i) for i in a]):
    if t > M:
        print(0)
        exit()

    ans = 1
    ans += (M-t)//x
    
    print(ans)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, a)

if __name__ == '__main__':
    main()
from sys import exit

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


def gcd(a, b):
    if a == 0:
        return b

    if b == 0:
        return a

    temp = a % b
    while temp != 0:
        a = b
        b = temp
        temp = a % b

    return b


# 0 ~ i
def left(i):
    if i == 0:
        return 0

    if left(i - 1) > A[i - 1]:
        return gcd(left(i - 1), A[i - 1])
    else:
        return gcd(A[i - 1], left(i - 1))


# i ~ N-1
def right(i):
    if i == N - 1:
        return 0

    if right(i + 1) > A[i + 1]:
        return gcd(right(i + 1), A[i + 1])
    else:
        return gcd(A[i + 1], right(i + 1))


ans = []

for i in range(N):
    ans.append(gcd(left(i), right(i)))

print(max(ans))


### FIXED CODE ###

from sys import exit

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


def gcd(a, b):
    if a == 0:
        return b

    if b == 0:
        return a

    temp = a % b
    while temp != 0:
        a = b
        b = temp
        temp = a % b

    return b


left = [0 for i in range(N)]
right = left[:]

for i in range(1, N):
    left[i] = gcd(A[i - 1], left[i - 1])
    right[-i - 1] = gcd(A[-i], right[-i])

ans = [gcd(left[i], right[i]) for i in range(N)]

print(max(ans))
a1, a2, a3 = map(int, input())
if a1+a2+a3 >= 22:
    print('bust')
else:
    print('win')

### FIXED CODE ###

a1, a2, a3 = map(int, input().split())
if a1+a2+a3 >= 22:
    print('bust')
else:
    print('win')
N = int(input())
X = []
U = []
for i in range(N):
    (x, u) = int(input().split())
    X[i] = x
    U[i] = u

otoshidama = 0.0

for i in range(N):
    if U[i] == "JPY":
        otoshidama += X[i]
    elif U[i] == "BTC":
        otoshidama += X[i] * 380000.0

print(otoshidama)

### FIXED CODE ###

S = input()
S_split = S.split("/")
(year, month, day) = (int(S_split[i]) for i in range(3))

if month > 4:
    print("TBD")

else:
    print("Heisei")
n, k = map(int, input().split())
p = list(map(int, input().split()))
exp_list = []
for i in p:
    expect = (i+1)/2
    exp_list.append(expect)
s = sum(exp_list[0:k])
ans = s
for j in range(n-k):
    s -= s[j]
    s += s[j+k]
    if s > ans :
        ans = s
print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
exp_list = []
for i in p:
    expect = (i+1)/2
    exp_list.append(expect)
s = sum(exp_list[0:k])
ans = s
for j in range(n-k):
    s -= exp_list[j]
    s += exp_list[j+k]
    if s > ans :
        ans = s
print(ans)
a,b=map(int,raw_input().split())
it(a>b): print(a-1)
else: print a

### FIXED CODE ###

#for i in xrange(15):
a,b=map(int,raw_input().split())
if(a>b): print "%d"%(a-1)
else: print "%d"%(a)
a, b = map(raw_input().split(" ")):

if  a > b :
print "a > b"
if  a < b :
print "a < b"
if  a == b :
print "a == b"

### FIXED CODE ###

a,b=map(int,raw_input().split())
if a > b:
    print 'a > b'
elif a < b:
    print 'a < b'
else:
    print 'a == b'
n = int(input())
A = [input() for _ in range(n)]
a,b,c,d = int()
for x in range(n):
    if A[x] == "AC":
        a = a+1
    elif A[x] == "WA":
        b = b+1
    elif A[x] == "TLE":
        c = c+1
    elif A[x] == "RE":
        d = d+1
print("AC x",a)
print("WA x",b)
print("TLE x",c)
print("RE x",d)


### FIXED CODE ###

n = int(input())
A = [input() for _ in range(n)]
a = int()
b = int()
c = int()
d = int()
for x in range(n):
    if A[x] == "AC":
        a = a+1
    elif A[x] == "WA":
        b = b+1
    elif A[x] == "TLE":
        c = c+1
    elif A[x] == "RE":
        d = d+1
print("AC x",a)
print("WA x",b)
print("TLE x",c)
print("RE x",d)
import heapq as hp

n,m =[int(i) for i in input().split()]
lists = [[] for i in range(m)]

for _ in range(n):
  a,b = [int(i) for i in input().split()]
  lists[a-1].append(b)
  
h = []
ans = 0
for day in range(m):
  for v in lists[day]:
    hp.heappush(h, -v)
  if h!=None:
	ans -= hp.heappop(h)
  
print(ans)
  

### FIXED CODE ###

import heapq as hp

n,m =[int(i) for i in input().split()]
lists = [[] for i in range(m)]

for _ in range(n):
  a,b = [int(i) for i in input().split()]
  if a<=m:
  	lists[a-1].append(b)
  
h = []
ans = 0
for day in range(m):
  for v in lists[day]:
    hp.heappush(h, -v)
  if len(h)>0:
    ans -= hp.heappop(h)
print(ans)
n = int(intput())
s = input()

if n < 3200:
  print('red')
else :
  print(s)

### FIXED CODE ###

n = int(input())
s = input()

if n < 3200 :
  print('red')
else :
  print(s)
a=input()
b=input()

print(a*b)

### FIXED CODE ###

a,b = input().split()

print(int(a)*int(b))
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <queue>
#include <cstring>
#include <iterator>
#include <list>
#include <set>
#include <map>
#include <bitset>
using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;

    map<int, int> freq;
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        if(!freq.count(a))
            freq[a] = 0;
        freq[a] += b;
    }

    map<int, int>::iterator it;
    int k = 1;
    for (it = freq.begin(); k <= K && it != freq.end(); it++) {
        k += it->second;
    }
    it--;
    cout << it->first << endl;
}

### FIXED CODE ###

nk = input().split(' ')
n = int(nk[0])
k = int(nk[1])

arr = []

for i in range(0, n):
	ab = input().split(' ')
	arr.append((int(ab[0]), int(ab[1])))

arr = sorted(arr)

pos = 0
while True:
	if k > arr[pos][1]:
		k -= arr[pos][1]
	else:
		print(arr[pos][0])
		break
	pos += 1
N, K = map(int, input().split())
A = list(map(int, input().split()))
if max(A) < K:
    print("IMPOSSIBLE")
    exit()
if K in A:
    print("POSSIBLE")
    exit()

A.sort()
for i in range(1, N):
    tmp = abs(A[i - 1] - A[i])
    if K % tmp == 0:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
if K in A:
    print("POSSIBLE")
    exit()
if max(A) < K or N == 1:
    print("IMPOSSIBLE")
    exit()

A.sort()
for i in range(1, N):
    tmp = abs(A[i - 1] - A[i])
    if not tmp == 0 and K % tmp == 0:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")
def resolve():
    N, M = map(int, input().split())

    person = [-1 for _ in range(N)]
    group_counter = 0
    menber_counter = []

    for _ in range(M):
        A, B = map(int, input().split())
        A -= 1
        B -= 1
        if person[A] == -1 and person[B] == -1:
            person[A] = group_counter
            person[B] = group_counter
            menber_counter.append(2)
            group_counter += 1
        elif person[A] != -1:
            current_group = person[A]
            if person[B] == current_group:
                continue
            person[B] = current_group
            menber_counter[current_group] += 1
        else:
            current_group = person[B]
            if person[A] == current_group:
                continue
            person[A] = current_group
            menber_counter[current_group] += 1
    print(max(menber_counter))

if __name__ == "__main__":
    resolve()

### FIXED CODE ###

class UnionFind():
    def __init__(self, n: int):
        """
        n: ノード数
        """
        self.n = n
        """
        d: UnionFind木のデータ構造
            各要素の根要素を格納するリスト
            根要素の場合は, グループの要素数*-1を格納する
        """
        self.d = [-1] * n

    def find(self, x: int) -> int:
        """
        要素xが属するグループの根を返す
        """
        if self.d[x] < 0:
            return x
        else:
            self.d[x] = self.find(self.d[x])
            return self.d[x]

    def unite(self, x: int, y: int) -> bool:
        """
        要素xが属するグループと, 要素yが属するグループを併合する
        """
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False

        if self.d[x] > self.d[y]:
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True

    def same(self, x: int, y: int) -> bool:
        """
        要素x, yが同じグループに属するかどうかを返す
        """
        return self.find(x) == self.find(y)

    def size(self, x: int) -> int:
        """
        要素xが属するグループのサイズ(要素数)を返す
        """
        return -self.d[self.find(x)]

    def members(self, x: int) -> list:
        """
        要素xが属するグループの要素をリストで返す
        """
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def groups(self) -> list:
        """
        すべての根の要素をリストで返す
        """
        return [i for i, x in enumerate(self.d) if x < 0]

    def group_count(self) -> int:
        """
        グループの数を返す
        """
        return len(self.groups())


def resolve():
    N, M = map(int, input().split())

    uf = UnionFind(N)

    for _ in range(M):
        A, B = map(int, input().split())
        uf.unite(A-1, B-1)

    ans = 0
    for i in uf.groups():
        ans = max(ans, uf.size(i))
    print(ans)

if __name__ == "__main__":
    resolve()
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, K = map(int, input().split())
a = [int(c) for c in input().split()]
a.sort()
M = 0
m = 0
for i in range(N-1, 0, -1):
  M += cmb(i,K-1, mod)*a[i]
  M %= mod
for i in range(N-1):
  m += cmb(N-1-i, K-1, mod)*a[i]
  m %= mod
print((M-m)%mod)

### FIXED CODE ###

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, K = map(int, input().split())
a = [int(c) for c in input().split()]
a.sort()
M = 0
m = 0
for i in range(N-1, 0, -1):
  M += cmb(i,K-1, mod)*a[i]
  M %= mod
for i in range(N-1):
  m += cmb(N-1-i, K-1, mod)*a[i]
  m %= mod
print((M-m)%mod)
N = int(input())
H_list = input().split(" ")
max_count = 0

for i in range(0, N):
    S = int(H_list[i])
    count = 0
    for j in range(i + 1, N):
        if S >= int(H_list[j]):
            S = int(H_list[j])
            count += 1
        else:
            break
    if max_count < count:
        max_count = count
    if max_count >= N - i:
        break
print(max_count)


### FIXED CODE ###

S_list = input()
T_list = input()
count = 0

for i in range(0, 3):
  if S_list[i] == T_list[i]:
    count += 1
  else:
    pass
  
print(count)
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

v = a * a * b
s = x / a

import math
if x < v / 2:
    # print(math.degrees(math.atan(2 * s / b / b)))
    print(90 - math.atan(2 * s / b / b) * 180 / math.pi)
else:
    print(90 - math.atan(a / (b - (2 * s / a - b))) * 180 / math.pi)



### FIXED CODE ###

import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b, x = map(int, readline().split())

v = a * a * b
s = x / a

if x == v:
    print(0)
    exit()

if x <= v / 2:
    # print(math.degrees(math.atan(2 * s / b / b)))
    print(90 - math.degrees(math.atan(2 * x / a / b / b)))
else:
    print(90 - math.degrees(math.atan(a / (b - (2 * s / a - b)))))
from collections import deque

def maze(h, w, sh, sw, list1):
    if list1[sh][sw]=="#":
        return 0
    
    que = deque()
    que.append([sh, sw, 0])
    list2 = list1.copy()
    direct = [(0,1), (0,-1), (1,0), (-1, 0)]
    count = 0
    while que:
        nh, nw, co = que.pop()
        count = co
        co +=1
        li=list(list2[nh])
        li[nw]="#"
        list2[nh]="".join(li)
        for i, j in direct:
            if nh+i<0 or nh+i>=h or nw+j<0 or nw+j>=w:
                pass
            elif list2[nh+i][nw+j]==".":
                que.appendleft([nh+i, nw+j, co])
    return count
        
h, w = (int(x) for x in input().split())
list1 = []
ans = 0
for i in range(h):
    list1.append(input())
for i in range(h):
    for j in range(w):
        ans_ij = maze(h, w, i, j , list1)
        if ans_ij>ans:
            ans=ans_ij
print(ans)

### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())
g = [list(input()) for i in range(H)]
direction = [[0,1],[1,0],[0,-1],[-1,0]]
ans=0
for sh in range(H):
    for sw in range(W):
        #スタート地点が壁ならスキップ
        if g[sh][sw]=="#":
            continue
        dist=[[-1]*W for i in range(H)]
        dist[sh][sw] = 0
        que = deque([[sh,sw]])

        while que:
            nh, nw = que.pop()
            for dh, dw in direction:
                if not ((0 <= nh + dh < H) and (0 <= nw + dw < W)):
                    continue
                if g[nh+dh][nw+dw]=="#":
                    continue
                if dist[nh+dh][nw+dw]!=-1:
                    continue
                
                #dist[nh+dw][nw+dw] = dist[nh][nw]+1
                #que.appendleft([nh + dh,nw+dw])
                dist[nh + dh][nw + dw] = dist[nh][nw] + 1
                que.appendleft([nh + dh, nw + dw])
        ans = max (ans, max([max(d) for d in dist]))
print(ans)
INF = 10 ** 20

N = int(input())
coin_list = [1] + [6**i for i in range(1, 7)] + [9**i for i in range(1, 6)]
dp = [INF]*(W+1)
dp[0] = 0
 
for coin in coin_list:
    for i in range(coin,W+1):
        dp[i] = min(dp[i], dp[i-coin]+1)
 
print(dp[W])

### FIXED CODE ###

INF = 10 ** 20

N = int(input())
coin_list = [1] + [6**i for i in range(1, 7)] + [9**i for i in range(1, 6)]
dp = [INF]*(N+1)
dp[0] = 0
 
for coin in coin_list:
    for i in range(coin,N+1):
        dp[i] = min(dp[i], dp[i-coin]+1)
 
print(dp[N])
W,H=map(int,input())
w,h=map(int,input())
print(W*H-(h*W+w*H-w*h))

### FIXED CODE ###

W,H=map(int,input().split())
w,h=map(int,input().split())
print(W*H-(h*W+w*H-w*h))
import datetime

base_date = datetime.date(2019, 4, 30)
y, m, d = map(int, input().split('/'))
if (base_date < datetime.date(y, m, d)):
    return ("TBD")
else:
    return ("Heisei")

### FIXED CODE ###

print('Heisei' if input()<'2019/05/01' else 'TBD')