Harryxun/stf_run huggingface dataset:
import numpy as np

class Tropical():
    def __init__(self, values):
        self.values = values

    def __add__(self, x):
        return min(self.values, x.values)

    def __mul__(self, x):
        return self.values + x.values

    def Tropical_sum(self):
        return min(self.values)

# INF
INF = float('inf')
Infty = Tropical(INF)

# Tropical Product
def Tropical_Product(A, B):
    return [[(lambda x: Tropical(x).Tropical_sum())(list(map(lambda x: Tropical(x[0]) * Tropical(x[1]), zip(A[i], [[B[j][i] for j in range(len(B))] for i in range(len(B))][j])))) for j in range(len(A))] for i in range(len(B))]

def Tropical_Pow(A, num):
    tmp = A
    B = A
    for _ in range(num-1):
        B = Tropical_Product(B,tmp)
    return B

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

Z = np.full((N,N),INF)
for i in range(N):
    for j in range(i+1,i+3):
        if j <= N:
            if abs(i-j)==1 and i+1 < N:
                Z[i][j] = abs(h[i]-h[i+1])//10
            elif abs(i-j)==2 and i+2 < N:
                Z[i][j] = abs(h[i]-h[i+2])//10

print(Z)

for i in range(N):
    tmp = Tropical_Pow(Z,i)
    if tmp[0][-1] != INF:
        print(int(tmp[0][-1])*10)
        exit()

### FIXED CODE ###

def chmin(a, b):
    if a > b:
        return b
    else:
        return a

# input
N = int(input())
h = list(map(int, input().split()))

# dp table
dp = [float('inf')]*(10**5 + 10)

# 初期条件
dp[0] = 0

for i in range(1,N):
    dp[i] = chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

# ans
print(dp[N-1])
a, b = input().stlip()

if a==1:
    a = 14
if b==1:
    b = 14

if a>b:
    print("Alice")
elif a<b:
    print("Bob")
else:
    print("Draw")

### FIXED CODE ###

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

if a==1:
    a = 14
if b==1:
    b = 14

if a>b:
    print("Alice")
elif a<b:
    print("Bob")
else:
    print("Draw")
n = int(input())
nums = [int(i) for i in input().split()]
ans = 0
while True:
  if [i for i in nums if i % 2 == 1]
  	break
  nums = [i//2 for i in nums]
  ans += 1 
print(ans)


### FIXED CODE ###

n = int(input())
nums = [int(i) for i in input().split()]
ans = 0
while True:
    if [i for i in nums if i % 2 == 1]:
        break
    nums = [i//2 for i in nums]
    ans += 1
print(ans)
print("Yes" if set(map(int,input().split())).len()==2 else "No")

### FIXED CODE ###

print("Yes" if len(set(map(int,input().split())))==2 else "No")
H, W = map(int, input().split())
s = ""
for i in range(0, H):
    temp = input().replace("#", "0")
    l_bit = temp.replace(".", "1")
    s = s + l_bit

route1 = []
route = [[]]
for j in range(0, W-1):
    route[0].append(j)
print(route)
count = len(route)

#k :0~W-1
best = (H - 1) + (W - 1)
for k in range(0, W-1):    
    for num in range(0, count):
        for p in range(0, (H*W)-(W-k)):
            route1 = route[num]
            route1[W-2-k] = route1[W-1-k-1] + p
            if W > 2:
                if route1[W-k-3] % W <= route1[W-k-2] % W: 
                    route.append(route1) 
                    count += 1
                    block = (H - 1) + (W - 1)
                    print(route1)
                    for q in range(0, len(route1)):
                        if q+1 != len(route1)+1:
                            print(q)
                            if s[route1[q+1]] == s[route1[q]] and ((route1[q+1] == route1[q] + 1) or (route1[q] % W == (route1[q] + 1) % W)):
                                block = block - 1
                                best = min([best, block])
            else:
                route.append(route1) 
                count += 1
                block = (H - 1) + (W - 1)
                print(route1)
                for q in range(0, len(route1)):
                    if q+1 != len(route1):
                        if s[route1[q+1]] == s[route1[q]] and ((route1[q+1] == route1[q] + 1) or (route1[q] % W == (route1[q] + 1) % W)):
                            block = block - 1
                best = min([best, block])

print(best)

### FIXED CODE ###

import numpy as np

H, W = map(int, input().split())
temp = [list(input().replace("#","0").replace(".","1")) for i in range(H)]
masu = [[int(temp[i][j]) for j in range(W)] for i in range(H)]

dp = np.zeros((H, W))
if masu[0][0] == 0:
    dp[0][0] = 1

for i in range(0,H):
    for j in range(0,W):
        if i == 0:
            a = 100000
        else:
            if masu[i][j] == 0 and masu[i-1][j] == 1:
                a = dp[i-1][j] + 1
            else:
                a = dp[i-1][j]
        if j == 0:
            b = 100000
        else:
            if masu[i][j] == 0 and masu[i][j-1] == 1:
                b = dp[i][j-1] + 1
            else:
                b = dp[i][j-1]
        if a != 100000 or b != 100000:
            dp[i][j] = min([a, b])
print(int(dp[H-1][W-1]))
K = int(input())
ans1 = -1
for i in range(K):
  ans = 7/9*(10**(i+1)-1)
  if ans%K == 0:
    ans1 = i+1
    break
print(ans1)

### FIXED CODE ###

K = int(input())
if K%7 == 0:
  L = 9*K//7
else:
  L = 9*K

if K%2 == 0 or K%5 == 0:
  print(-1)
else:
  X = 10%L
  if X == 1:
    print(1)
  else:
    for i in range(K):
      X = X*10 % L
      if X == 1:
        print(i+2)
        break
a = input()
b = input()
c = list(b)
while c[0] == "." :
    del c[0]
    if (c[0] == ".") & len(c) == 1:
        break
while c[len(c)-1] == "#":
    del c[len(c)-1]
    if (c[len(c)-1] == "#") & len(c) == 1:
        break    
if c.count(".") <= c.count("#"): #白が黒より少ない場合
   d = c.count(".")
elif c.count(".") > c.count("#"): #白が黒より多い場合
   d = c.count("#")
print(d)

### FIXED CODE ###

a = input()
b = input()
c = list(b)
d = 0
e = c.count(".")
f = 0
for i in range(len(c)+1): #左からi個を白にする　0<=i<=len(c)
    if i == 0:
        ans = e
    else:
        if c[i-1] == ".":
            d = d + 1 #dは左からi個のうちの白の個数を指す
        f = (i - d) + (e - d) #左側の(i-d)個の黒を白にし、右側(e-d)個の白を黒にする
        ans = min(ans, f)
print(ans)
n,k = map(int,input().split())
print(k*((k-1)**(n-1))

### FIXED CODE ###

n,k = map(int,input().split())
print(k*((k-1)**(n-1)))
A,B,C,D = map(int,input().split())
a = [1] * A + [0] * B + [-1] * C

ancer = 0
for i in range(D):
    ancer += a[i]
    
print(ancer)

### FIXED CODE ###

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

if D > A:
 
    ancer = 1 * A + 0 * (D - A) + (-1 *(D - A - B))
    
else:
    ancer = 1 * D

print(ancer)
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]
cnt = 0
for x in A:
  total = sum([A[i]*B[i] for i in range(M)])
  total += C
  if total > 0:
    cnt+= 1
    
print(cnt)

### FIXED CODE ###

N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]
cnt = 0
for x in A:
  total = sum([x[i]*B[i] for i in range(M)])
  total += C
  if total > 0:
    cnt+= 1
    
print(cnt)
X = map(int,input().split())
from sympy import sieve
L = [i for i in sieve.primerange(X,23)]
print(L[0])

### FIXED CODE ###

X = int(input())
def price(n):
  if n == 1:
    return False
  for i in range(2, int(n**0.5)+1):
    if n%i == 0:
      return False
  return True

while(1):
  if price(X):
    print(X)
    break
  else:
    X += 1
def transformate(s, command):
    command, *op = command.split()

    op[0] = int(op[0])
    op[1] = int(op[1])
        
    if command == 'replace':
        return s[0:op[0]] + op[2] + s[op[1]+1:]
    elif command == 'reverse':
        return s[0:op[0]] + s[op[0]:op[1]+1][::-1] + s[op[1]+1:]
    elif command == 'print':
        print(output)
        return s

if __name__ == '__main__':
    s = input()
    for _ in range(int(input())):
        s = transformate(s, input())



### FIXED CODE ###

def transformate(s, command):
    command, *op = command.split()

    op[0] = int(op[0])
    op[1] = int(op[1])

    if command == 'replace':
        return s[0:op[0]] + op[2] + s[op[1]+1:]
    elif command == 'reverse':
        return s[0:op[0]] + s[op[0]:op[1]+1][::-1] + s[op[1]+1:]
    elif command == 'print':
        print(s[op[0]:op[1]+1])
        return s

if __name__ == '__main__':
    s = input()
    for _ in range(int(input())):
        s = transformate(s, input())
x=input()
a=x[:2]
b=x[2:]
ans_lst=[]
for y in [a,b]:
	if "00"<y<"13":
  		ans_lst.append(True)
    else:ans_lst.append(False)
if all(ans_lst):
    print("AMBIGUOUS")
elif not any(ans_lst):
    print("NA")
elif ans_lst[0] and ans_lst[1]==False:
	print("MMYY")
elif ans_lst[0]==False and ans_lst[1]:
	print("YYMM")

### FIXED CODE ###

x=input()
a=x[:2]
b=x[2:]
ans_lst=[]
for y in [a,b]:
	if "00"<y<"13":
		ans_lst.append(True)
	else:ans_lst.append(False)
if all(ans_lst):
    print("AMBIGUOUS")
elif not any(ans_lst):
    print("NA")
elif ans_lst[0] and ans_lst[1]==False:
	print("MMYY")
elif ans_lst[0]==False and ans_lst[1]:
	print("YYMM")
#d
s=input()
n=len(s)

ak10k = [(pow(10,n-k-1,m)*int(s[k]))%m for k in range(0,n)]

ruiseki=[0]*n
ruiseki[0]=ak10k[0]
for i in range(1,n):
    ruiseki[i]=(ruiseki[i-1]+ak10k[i])%2019

from collections import Counter
c = Counter(ruiseki)

ans=sum(cc*(cc-1)//2 for cc in c.values()) + list(c.keys()).count(0)

print(ans)

### FIXED CODE ###

s=input()
n=len(s)
m=2019

ak10k = [(pow(10,n-k-1,m)*int(s[k]))%m for k in range(0,n)]+[0]

ruiseki=[0]*n
ruiseki[0]=ak10k[0]
for i in range(1,n):
    ruiseki[i]=(ruiseki[i-1]+ak10k[i])%2019

from collections import Counter
c = Counter(ruiseki)

ans=sum(cc*(cc-1)//2 for cc in c.values()) + c[0]

print(ans)
import math as m
N,M = map(int,input().split())
# N == 1 の処理
if N == 1:
    print(M)
    exit()
# Mの素数判定
judge = "prime"
for i in range(m.floor(pow(M,1/2)),1,-1):
    if M % i == 0:
        judge = "conposite"
        break
if judge == "prime":
    print(1)
    exit()
for i in range(M // N,0,-1):
    if M % i == 0:
        print(i)
        exit()

### FIXED CODE ###

N = int(input())
if N == 1:
  print("Hello World")
elif N == 2:
  A,B = [int(input()) for i in range(2)]
  print(A+B)
from collections import Counter
N=int(input())
A = list(map(int,input().split()))

for i in range(1,N+1):
    A[i-1]-=i

# ave1=sum(A)//len(A)
# ave2=-(-sum(A)//len(A))
# median=Counter(A).most_common(1)[0][0]
B=[]
C=[]
for k in range(min(A),max(A)+1):
    B.append(A[:])

    for i in range(0,N):
        B[k][i]-=k

        B[k][i]=abs(B[k][i])
    C.append(sum(B[k]))
print(min(C))


### FIXED CODE ###

from collections import Counter
N=int(input())
A = list(map(int,input().split()))

for i in range(1,N+1):
    A[i-1]-=i

# ave1=sum(A)//len(A)
# ave2=-(-sum(A)//len(A))
# median=Counter(A).most_common(1)[0][0]

B=A[:]
C=A[:]

B.sort()
# 偶数の場合
if N % 2 == 0:
    median1 = N/2
    median2 = N/2 + 1
    median1 = int(median1) - 1
    median2 = int(median2) - 1
    median = (B[median1] + B[median2]) / 2

    # 奇数の場合
else:
    median = (N + 1) / 2
    median = int(median) - 1
    median = B[median]

median=int(median)

for i in range(0,N):
    C[i]-=median
    C[i]=abs(C[i])

print(sum(C))
n,m=map(int,input().split())
 
print(n(n-1)/2+m(m-1)/2)

### FIXED CODE ###

n,m=map(int,input().split())
 
print(n*(n-1)//2+m*(m-1)//2)
list = []
while True:
    num = list(map(int,input()))
    if(num[0] == 0 and num[1] == 0):
        break
    else:
        if(num[0] > num[1]):
            print("%d %d" %(num[1],num[0]))
        else:
            print("%d %d" %(num[0],num[1]))
            


### FIXED CODE ###

while True:
    num = list(map(int,input().split()))
    if(num[0] == 0 and num[1] == 0):
        break
    else:
        if(num[0] > num[1]):
            print("%d %d" %(num[1],num[0]))
        else:
            print("%d %d" %(num[0],num[1]))
X=input()
 
if 30<=X :
	print("Yes")
else :
    print("No")

### FIXED CODE ###

print("Yes") if int(input()) >= 30 else print("No")
a=list(map(int, input().split()))
l=[a[0]]
if a[0]==1 or a[1]==1:
    print(0)
    exit()
elif a[0]==0:
    print(0)
    exit()
def d(a,b):
    if a<b:
        if min(l)>b-a:
            l.append(b-a)
            d(b-a,a)
        else:
            print(min(l))
            exit()
    elif b<a:
        if min(l)>a-b:
            l.append(a-b)
            d(a-b,b)
        else:
            print(min(l))
            exit()
    else:
        print(0)
        exit()
d(a[0],a[1])

### FIXED CODE ###

a=list(map(int, input().split()))
def d(a,b):
    _1=a%b
    _2=b-(a%b)
    if _1<_2:
        print(_1)
    else:
        print(_2)
d(a[0],a[1])
import numpy as np 
import math

S = str(input())
T = str(input())

n = len(S)
if T[0:n] == S:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

import numpy as np 
import math

S = str(input())
T = str(input())

n = len(S)
m = len(T)
if (T[0:n] == S) and (m==n+1):
    print("Yes")
else:
    print("No")
import sys
import numpy as np
readline = sys.stdin.buffer.readline

MOD = 10 ** 9 + 7


def main(K, N, MOD):
    def cumprod(A, mod=MOD):
        L = len(A)
        Lsq = int(L**.5 + 1)
        A = np.resize(A, Lsq**2).reshape(Lsq, Lsq)
        for n in range(1, Lsq):
            A[:, n] *= A[:, n - 1]
            A[:, n] %= mod
        for n in range(1, Lsq):
            A[n] *= A[n - 1, -1]
            A[n] %= mod
        return A.ravel()[:L]

    def make_fact(U, mod=MOD):
        x = np.arange(U, dtype=np.int64)
        x[0] = 1
        fact = cumprod(x, mod)
        x = np.arange(U, 0, -1, dtype=np.int64)
        x[0] = pow(int(fact[-1]), mod - 2, mod)
        fact_inv = cumprod(x, mod)[::-1]
        fact.flags.writeable = False
        fact_inv.flags.writeable = False
        return fact, fact_inv

    fac, finv = make_fact(2_000_010, MOD)
    f = np.zeros(K + 1, np.int64)
    f = fac[N - 1:K + N] * finv[N - 1] % MOD * finv[:K + 1] % MOD

    x = 1
    for i in range(1, K + 1):
        x = (x * 25) % MOD
        f[i] = f[i] * x % MOD
    for i in range(1, K + 1):
        f[i] += f[i - 1] * 26
        f[i] %= MOD
    return f[-1]


if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.from_dtype(np.int64)
    signature = (i8, i8, i8)
    cc = CC('my_module')
    cc.export('main', signature)(main)
    cc.compile()

from my_module import main
K = int(readline())
N = len(readline())
print(main(K, N, MOD))


### FIXED CODE ###

import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 10**9 + 7

def main(K, N, MOD):
    def fact_table(N, MOD):
        inv = np.empty(N, np.int64)
        inv[0] = 0
        inv[1] = 1
        for n in range(2, N):
            q, r = divmod(MOD, n)
            inv[n] = inv[r] * (-q) % MOD
        fact = np.empty(N, np.int64)
        fact[0] = 1
        for n in range(1, N):
            fact[n] = n * fact[n - 1] % MOD
        fact_inv = np.empty(N, np.int64)
        fact_inv[0] = 1
        for n in range(1, N):
            fact_inv[n] = fact_inv[n - 1] * inv[n] % MOD
        return fact, fact_inv, inv

    fact, fact_inv, inv = fact_table(2_000_010, MOD)
    f = np.zeros(K + 1, np.int64)
    f = fact[N - 1:K + N] * fact_inv[N - 1] % MOD * fact_inv[0:K + 1] % MOD

    x = 1
    for i in range(1, K + 1):
        x = (x * 25) % MOD
        f[i] = f[i] * x % MOD
    for i in range(1, K + 1):
        f[i] += f[i - 1] * 26
        f[i] %= MOD
    return f[-1]

if sys.argv[-1] == 'ONLINE_JUDGE':  #　なにそれ
    import numba
    from numba.pycc import CC
    i8 = numba.from_dtype(np.int64)
    signature = (i8, i8, i8)

    cc = CC('my_module')
    cc.export('main', signature)(main)
    cc.compile()


from my_module import main
K = int(readline())
N = len(read().rstrip())

print(main(K, N, MOD))
N=int(input())
Xl=list(map(int,list(input())))
#X=int(input())
#print(Xl)

def func(x):
  cnt=0
  while x>0:
    num1=0
    xcopy=x
    while xcopy:
      if xcopy&1:
        num1+=1
      xcopy>>=1
      
    #print(x,num1)
    x=x%num1
    cnt+=1
  return cnt

func_dic={}
for i in range(N):
  func_dic[i]=func(i)
#print(func_dic)

num1_X=Xl.count(1)
#print(num1_X)

mod_nminus=0
mod_nplus=0
for i in range(N):
  mod_nminus*=2
  mod_nplus*=2
  if Xl[i]==1:
    mod_nminus+=1
    mod_nplus+=1

  mod_nminus%=num1_X-1
  mod_nplus%=num1_X+1
#print(mod_nminus,mod_nplus)

answer_list=[]
modpow_plus=1
modpow_minus=1
for i in reversed(range(N)):
  if Xl[i]==0:
    mod=(mod_nplus+modpow_plus)%(num1_X+1)
    answer_list.append(func_dic[mod]+1)
  else:
    mod=(mod_nminus-modpow_minus)%(num1_X-1)
    answer_list.append(func_dic[mod]+1)
  
  modpow_plus*=2
  modpow_minus*=2
  modpow_plus%=num1_X+1
  modpow_minus%=num1_X-1
  
for i in reversed(range(N)):
  print(answer_list[i])

### FIXED CODE ###

N=int(input())
Xl=list(map(int,list(input())))
#X=int(input())
#print(Xl)

def func(x):
  cnt=0
  while x>0:
    num1=0
    xcopy=x
    while xcopy:
      if xcopy&1:
        num1+=1
      xcopy>>=1
      
    #print(x,num1)
    x=x%num1
    cnt+=1
  return cnt

func_dic={}
for i in range(N+1):
  func_dic[i]=func(i)
#print(func_dic)

num1_X=Xl.count(1)
#print(num1_X)

mod_nminus=0
mod_nplus=0
for i in range(N):
  if num1_X-1>0:
    mod_nminus*=2
  mod_nplus*=2  
  if Xl[i]==1:
    mod_nminus+=1
    mod_nplus+=1

  if num1_X-1>0:
    mod_nminus%=num1_X-1
  mod_nplus%=num1_X+1
  
#print(mod_nminus,mod_nplus)

answer_list=[]
modpow_plus=1
modpow_minus=1
for i in reversed(range(N)):
  if Xl[i]==0:
    mod=(mod_nplus+modpow_plus)%(num1_X+1)
    answer_list.append(func_dic[mod]+1)
  else:
    if num1_X-1==0:
      answer_list.append(0)
    else:
      mod=(mod_nminus-modpow_minus)%(num1_X-1)
      answer_list.append(func_dic[mod]+1)
  
  modpow_plus*=2  
  modpow_plus%=num1_X+1
  if num1_X-1>0:
    modpow_minus*=2
    modpow_minus%=num1_X-1
  
for i in reversed(range(N)):
  print(answer_list[i])
N=list(input())

n=reversed(N)

if n[0]=="2" or n[0]=="4" or n[0]=="5" or n[0]=="7" or n[0]=="9":
    print("hon")
if n[0]=="0" or n[0]=="1" or n[0]=="6" or n[0]=="8":
    print("pon")
if n[0]=="3":
    print("bon")
    break

### FIXED CODE ###

n=list(input())

n==n.reverse()

if (n[0]=="2" or n[0]=="4" or n[0]=="5" or n[0]=="7" or n[0]=="9"):
    print("hon")
elif (n[0]=="0" or n[0]=="1" or n[0]=="6" or n[0]=="8"):
    print("pon")
elif (n[0]=="3"):
    print("bon")
import math
a, b= map( int,input().split() )

print( math.floor( a * b ) )

### FIXED CODE ###

a, b = input().split()

b = b.replace(".","")

a = int( a )
b = int( b )
print( a * b // 100 )
import sys
sys.setrecursionlimit(1500)
n=int(input())
arr=list(map(int,input().split()))
vis={}
vis[0] = 0
if n < 2:
  return 0
if n == 2:
  return min(arr[0]-arr[1])
vis[1] = min(arr[0]-arr[1])
def count(n):
    if n in vis or n < 0:
        return vis[n]
    else:
      vis[n]=min(abs(arr[n-1]-arr[n-2])+count(n-1),abs(arr[n-1]-arr[n-3])+count(n-2))
    return vis[n]
print(count(n))

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
if n < 2:
  print(0)
vis = [0] * n
vis[0] = 0
vis[1] = abs(arr[0]-arr[1])
for i in range(2, n):
    step_1 = abs(arr[i]-arr[i-1]) + vis[i-1]
    step_2 = abs(arr[i]-arr[i-2]) + vis[i-2]
    vis[i] = min(step_1, step_2)
print(vis[-1])
num=[int(e) for e in input().split()]
A=str(num[0])
B=str(num[1])
if num[0]>=num[1]:
  for i in range(num[0]-1):
    B+=str(num[1])
  print(B)
else:
  for i in range(num[1]-1):
	A+=str(num[0])
  print(A)

### FIXED CODE ###

num=[int(e) for e in input().split()]
A=str(num[0])
B = str(num[1])

if num[0]>=num[1]:
  for i in range(num[0]-1):
    B+=str(num[1])
  print(B)
else:
  for i in range(num[1]-1):
      A+=str(num[0])
  print(A)
a,b=map(int,input().split())
n=list([str(input()) for i in range(b)])
p=sorted(n)
q=''.join(p)
print(q)

### FIXED CODE ###

a,b=map(int,input().split())
n=sorted([input() for i in range(a)])
print(*n,sep='')
n,m = map(int,input().split())
lx = []
f = [False for _ in range(n)]
a = [[] for _ in range(n)]
for _ in range(m):
    x,y,z = map(int,input().split())
    a[x-1].append(y-1)
    a[y-1].append(x-1)

def dfs(i):
    f[i] = True
    for g in a[i]:
        if not f[g]:
            dfs(g)
res = 0
for i in range(n):
    if not f[i]:
        res += 1
        dfs(i)

print(res)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
n,m = map(int,input().split())
f = [False for _ in range(n)]
a = [[] for _ in range(n)]
res = 0

def dfs(k):
    f[k] = True
    for g in a[k]:
        if not f[g]:
            dfs(g)

for _ in range(m):
    x,y,z = map(int,input().split())
    a[x-1].append(y-1)
    a[y-1].append(x-1)

for i in range(n):
    if not f[i]:
        res += 1
        dfs(i)
print(res)
N,X = map(int,input().split())
l = []
bo = 0
for a in range(N+1):
    for b in range(N-a+1):
        if a*10000 + b*5000 + (N-a-b)*1000 == X:
            T = [a,b,N-a-b]
            bo+=1
            break

print(*T,sep=' ')
if bo==0:
    print('-1 -1 -1')


### FIXED CODE ###

N,X = map(int,input().split())
l = []
bo = 0
for a in range(N+1):
    for b in range(N-a+1):
        if a*10000 + b*5000 + (N-a-b)*1000 == X:
            T = [a,b,N-a-b]
            bo+=1
            break


if bo==0:
    print('-1 -1 -1')
else:print(*T,sep=' ')
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = []
for i in range(7):
    b.append(int(input()))
flag = False
for i in range(3):
    #for j in range(3):
    if a[0 + i][0] in b and a[0 + i][1] in b and a[0 + i][2] in b:
        #print('Yes')
        #quit()
        flag = True
for i in range(3):
    #for j in range(3):
    if a[0][0 + i] in b and a[1][0 + i] in b and a[2][0 + i] in b:
        #print('Yes')
        #quit()
        flag = True
        
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    #print('Yes')
    #quit()
    flag = True
if a[2][0] in b and a[1][1] in b and a[0][2] in b:
    #print('Yes')
    #quit()
    flag = True
#print('No')
if flag:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

a = [list(map(int, input().split())) for i in range(3)]
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))
flag = False
for i in range(3):
    #for j in range(3):
    if a[0 + i][0] in b and a[0 + i][1] in b and a[0 + i][2] in b:
        #print('Yes')
        #quit()
        flag = True
for i in range(3):
    #for j in range(3):
    if a[0][0 + i] in b and a[1][0 + i] in b and a[2][0 + i] in b:
        #print('Yes')
        #quit()
        flag = True
        
if a[0][0] in b and a[1][1] in b and a[2][2] in b:
    #print('Yes')
    #quit()
    flag = True
if a[2][0] in b and a[1][1] in b and a[0][2] in b:
    #print('Yes')
    #quit()
    flag = True
#print('No')
if flag:
    print('Yes')
else:
    print('No')
N,K = map(str,input().split())
D = list(map(int,input().split()))
nums = [x for x in range(10)]
nots = [i for i in nums if i not in D]
ans = ""
for j in range(len(N)):
  for k in nots:
    if int(N[j])<=k:
      ans+=str(k)
      break
print(int(ans))

### FIXED CODE ###

N,K = map(int,input().split())
D = input().split()
for i in range(N, 10*N+1):
  for j in str(i):
    if j in D:
      break
  else:
    print(i)
    exit()
import math
S=input()

hour = math.floor(S/3600)
min = math.floor((S-hour*3600)/60)
sec =  S - h*3600 - m*60

print(str(hour)+":"+str(min)+":"+str(sec))

### FIXED CODE ###

import math
S=int(input())

hour = math.floor(S/3600)
min = math.floor((S-hour*3600)/60)
sec =  S - hour*3600 - min*60

print(str(hour)+":"+str(min)+":"+str(sec))