Harryxun/stf_run huggingface dataset:
from bisect import insort
from collections import deque
from heapq import heapify, heappop, merge, heapreplace, heappush


class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self._root(self.table[x])
            return self.table[x]

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2


def solve(aa, uft):
    roots = {x: [] for x, r in enumerate(uft.table) if r < 0}
    if n < (len(roots) - 1) * 2:
        return 'Impossible'
    for x, a in enumerate(aa):
        roots[uft._root(x)].append(a)
    queue = []
    for l in roots.values():
        l.sort()
        queue.append(deque(l))
    queue.sort()
    queue = deque(queue)
    ans = 0
    while len(queue) > 1:
        # print(queue)
        buf = []
        dq1 = queue.popleft()
        dq2 = queue.popleft()
        if len(dq1) == 1:
            while len(dq2) == 1 and len(queue) > 1:
                buf.append(dq2)
                dq2 = queue.popleft()
        ans += dq1.popleft() + dq2.popleft()
        insort(queue, deque(merge(dq1, dq2)))
        if buf:
            queue = deque(merge(queue, buf))
    return ans


n, m = map(int, input().split())
aa = list(map(int, input().split()))
uft = UnionFind(n)
for _ in range(m):
    uft.union(*map(int, input().split()))
print(solve(aa, uft))


### FIXED CODE ###

from collections import deque, defaultdict
from heapq import heapify, heappop, merge, heapreplace


class UnionFind:
    def __init__(self, n):
        self.table = [-1] * n

    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self._root(self.table[x])
            return self.table[x]

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2


def solve(aa, uft):
    roots = defaultdict(list)
    for x, a in enumerate(aa):
        roots[uft._root(x)].append(a)
    if len(roots) == 1:
        return 0
    if n < (len(roots) - 1) * 2:
        return 'Impossible'
    ans = 0
    queue = []
    for l in roots.values():
        l.sort()
        ans += l[0]
        queue.append(l[1:])
    lm = n - m - 2
    if lm > 0:
        mm = merge(*queue)
        for _ in range(lm):
            ans += next(mm)
    return ans


n, m = map(int, input().split())
aa = list(map(int, input().split()))
uft = UnionFind(n)
for _ in range(m):
    uft.union(*map(int, input().split()))
print(solve(aa, uft))
import numpy as np

N, K = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)

B = np.zeros(N)
C = np.zeros(N)

for i in range(N):
    D = A[i::]
    B[i] = np.sum(D < A[i])
    C[i] = np.sum(A < A[i])
    
E = np.sum(B) * K % (10**9 + 7)
F = np.sum(C) * np.sum(np.arange(K-1)+1) % (10**9 + 7)

print(int((E+F) % (10**9 + 7)))

### FIXED CODE ###

import numpy as np

N, K = map(int, input().split())
A = np.array(input().split(), dtype=np.int64)

B = 0
C = 0

mod = 10**9 + 7

for i in range(N):
    D = A[i:]
    B = (B + np.sum(D < A[i])) % mod 
    C = (C + np.sum(A < A[i])) % mod 
    
k_sum = int((K-1) * K//2) % mod 

E = (B * K) % mod 
F = (C * k_sum) % mod 

print(int((E+F) % mod ))
import collections
n, k = map(int, input().split())
s = [int(i) for i in input()]
c = []
prv = 1
cnt = 0
for i in s:
    if prv != i:
        c.append(cnt)
        cnt = 1
        prv = i
    else:
        cnt += 1
if cnt > 0:
    c.append(cnt)
if prv == 0:
    c.append(0)
que = collections.deque(c[0])
res =c[0]
ans = c[0]
m = len(c) // 2
for i in range(m):
    if len(que) == 2*k + 1:
        res -= que.popleft() + que.popleft()
    que.append(c[2*i +1])
    que.append(c[2*i +2])
    res += c[2*i+1] + c[2*i+2]
    ans = max(res, ans)
print(ans)
        

### FIXED CODE ###

import collections
n, k = map(int, input().split())
s = input()
zero =[]
cnt = 0
d = collections.deque()
for i, j in enumerate(s):
    if j == '0':
        cnt += 1
    if j == '1' and i > 0:
        if cnt > 0:
            zero.append((cnt, i-1))
            cnt = 0
if cnt > 0:
    zero.append((cnt, n-1))
idx = n-1
one= []
while zero:
    d.append(zero.pop())
    if len(d) < k:
        continue
    if zero:    
        i, j = zero[-1]
        one.append(idx-j)
    else:
        one.append(idx +1)
    k, l = d.popleft()
    idx = l-k
if one == []:
    one.append(n)
print(max(one))
import fractions


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


mod = 10 ** 9 + 7
n = int(input())
arr = list(map(int, input().split()))
g = arr[0]
for i in range(1, n):
    g = lcm(g, arr[i])

answer = 0
for i in arr:
    answer += g / i

print(int(answer % mod))


### FIXED CODE ###

import fractions

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

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

def solve():
    memo = A[0]
    for i in range(1, N):
        memo = lcm(memo, A[i])

    ans = 0
    for i in range(N):
        ans += memo // A[i]

    return ans % (10 ** 9 + 7)

print(solve())
N = int(input())
name_list = [input() for name in range(N)]
char_list = ['M', 'A', 'R', 'C', 'H']
count_list = [0 for _ in range(N)]

for name in name_list:
    if name[0] in char_list:
        count_list[char_list.index(name[0])] += 1
score=0
for x in range(5):
    for y in range(x+1,5):
        for z in range(y+1,5):
            score+=count_list[x]*count_list[y]*count_list[z]

print(score)


### FIXED CODE ###

print(int(input())//3)
a, b, k = map(int, input().split())

num_list = list(range(a, b+1))

length = len(num_list)

for x in range(min(length, k)):
    print(num_list[x])

for x in range(max(k, length-k+1), length):
    print(num_list[x])


### FIXED CODE ###

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

for x in range(a, min(b+1, a+k)):
    print(x)

for x in range(max(a+k, b-k+1), b+1):
    print(x)
s = input()
t = input()

count = 0

for i in range(3)

if s[i] == t[i]:
  count += 1

print(count)

### FIXED CODE ###

s = input()
t = input()

count = 0

for i in range(3):
  if s[i] == t[i]:
    count += 1

print(count)
S=input()
W=10
if S>W:
	print("safe")
if W>S:
	print("unsafe")

### FIXED CODE ###

S,W=map(int, input().split())
 
if S>W:
	print("safe")
if S<W:
	print("unsafe")
if S==W:
	print("unsafe")
import sys
input=sys.stdin.readline

N,M=map(int,input().split())
if M==0:
    print("Yes")
    quit()
G=[[] for i in range(N)]
for i in range(M):
    l,r,d=map(int,input().split())
    G[l-1].append((l-1,r-1,d))
x=[-1]*N
y=[1]*N
stack=deque()
for i in range(N):
    if y[i]:
        stack.extend(G[i])
        y[i]=0
    if len(stack)==0:
        continue
    while(stack):

        l,r,d=stack.popleft()

        if x[l]==-1:
            x[l]=0
        if x[r]==-1:
            x[r]=x[l]+d
            continue
        if x[r]!=x[l]+d:
            print("No")
            quit()
        stack.extend(G[r])
        y[r]=0
if max(x)>10**9:
    print("No")
else:
    print("Yes")


### FIXED CODE ###

#重み付きUnion-Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        px = find(par[x])
        wei[x] += wei[par[x]]
        par[x] = px
        return px

#xの根から距離
def weight(x):
    find(x)
    return wei[x]


#w[y]=w[x]+wとなるようにxとyを併合
def unite(x,y,w):
    w += wei[x]-wei[y]
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
            w = -w
        par[x] += par[y]
        par[y] = x
        wei[y] = w
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#x,yが同じ集合に属するときのwei[y]-wei[x]
def diff(x,y):
    return weight(y)-weight(x)

n,m = map(int,input().split())

#初期化
#par:根なら-size,子なら親の頂点
#wei:親からの距離,根なら0
par = [-1]*n
wei = [0]*n

for i in range(m):
    l,r,d = map(int,input().split())
    l,r = l-1,r-1
    if same(l,r):
        if d != diff(l,r):
            print('No')
            exit()
    else:
        unite(l,r,d)
print('Yes')
N=int(input().strip())

xyh=[]
for i in range(N):
    xi,yi,hi = map(int, input().split(' '))
    if hi>0:
        xyh.append([xi,yi,hi])

fl=False
for ny in range(101):
    for nx in range(101):
        nh=abs(xyh[0][0]-nx)+abs(xyh[0][1]-ny)+xyh[0][2]
        nh=max(nh,0)
        fl=True
        for i in range(len(xyh)):
                if nh!=max(0,abs(xyh[i][0]-nx)+abs(xyh[i][1]-ny)+xyh[i][2]):
                    fl=False
        if fl:
            ax=nx
            ay=ny
            ah=nh

print("{} {} {}".format(ax,ay,ah))


### FIXED CODE ###

N=int(input().strip())
if N==1:
    print('Hello World')
elif N==2:
    A=int(input().strip())
    B=int(input().strip())
    print(A+B)
import os
import sys

import numpy as np
from scipy.sparse.csgraph import dijkstra
from scipy.sparse.csgraph import floyd_warshall

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, M, L = list(map(int, sys.stdin.readline().split()))
ABC = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]
Q = int(sys.stdin.readline())
S, T = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(Q)]))

D = np.full((N, N), IINF)
for a, b, c in ABC:
    D[a - 1][b - 1] = c
    D[b - 1][a - 1] = c

floyd_warshall(D, directed=False, overwrite=True)
counts = dijkstra(D <= L, directed=False, unweighted=True)
S = np.array(S, dtype=int) - 1
T = np.array(T, dtype=int) - 1

ans = counts[S, T] - 1
ans[ans == np.inf] = -1
print(*ans.astype(int), sep='\n')


### FIXED CODE ###

import os
import sys

import numpy as np
from scipy.sparse.csgraph import floyd_warshall

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7

N, M, L = list(map(int, sys.stdin.readline().split()))
ABC = [list(map(int, sys.stdin.readline().split())) for _ in range(M)]
Q = int(sys.stdin.readline())
S, T = list(zip(*[map(int, sys.stdin.readline().split()) for _ in range(Q)]))

D = np.full((N, N), 0)
for a, b, c in ABC:
    D[a - 1][b - 1] = c
    D[b - 1][a - 1] = c

floyd_warshall(D, directed=False, overwrite=True)
counts = floyd_warshall(D <= L, directed=False, unweighted=True)
S = np.array(S, dtype=int) - 1
T = np.array(T, dtype=int) - 1

ans = counts[S, T] - 1
ans[ans == np.inf] = -1
print(*ans.astype(int), sep='\n')
w=int(n[0])
h=int(n[1])
x=int(n[2])
y=int(n[3])
r=int(n[4])
if w>h and h>x and x>y and y>r:
   print("Yes")
else:
   print("No")


### FIXED CODE ###

n=input().split()
w=int(n[0])
h=int(n[1])
x=int(n[2])
y=int(n[3])
r=int(n[4])
if (r <= x) & (x + r <= w) & (r <= y) & (r + y <= h):
   print("Yes")
else:
   print("No")
N = int(input())
A = input().split().sort()

dic = dict()
for a in A:
    a = int(a)
    dic[a] = dic.get(a, 0) + 1

keys = list(dic.keys())
values = list(dic.values())

if N % 2 == 0:
    if keys == [2*i+1 for i in range(N//2)] and values == [2 for i in range(N//2)]:
        print(2**(N//2) % (10**9 + 7))
    else:
        print(0)
else:
    if keys == [2*i for i in range(N//2)] and values == [1] + [2 for i in range(N//2 - 1)]:
        print(2**(N//2) % (10**9 + 7))
    else:
        print(0)
    

### FIXED CODE ###

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

if N % 2 == 0:
    C = []
    for c in [2*i+1 for i in range(N//2)]:
        C += [c] * 2
    if A == C:
        print(2**(N//2) % (10**9 + 7))
    else:
        print(0)
else:
    C = [0]
    for c in [2*i for i in range(1, N//2 + 1)]:
        C += [c] * 2
    if A == C:
        print(2**(N//2) % (10**9 + 7))
    else:
        print(0)
x=int(input().split)
A=x[0]
B=x[1]
C=x[2]
if B+C-A>0:
    print(B+C-A)
else:
    print(0)


### FIXED CODE ###

x=input().split()
A=int(x[0])
B=int(x[1])
C=int(x[2])
if B+C-A>0:
    print(B+C-A)
else:
    print(0)
S = input()
K = int(input())
a = []
ans = 0
count = 0
for i in range(len(S)-1):
    if S[i] == S[i+1] :
        count += 1
    else:
        if count!=0:
            ans += (count+1)//2
            a.append(count+1)
            count = 0
if count !=0:
    ans += (count+1)//2 
ans = ans*K
a.append(0)
if len(S) == 1:
    ans = K//2
    print(ans)
    break
if (count+1)%2==1 and a[0]%2 == 1 and S[0]== S[1] and S[0] == S[len(S)-1]:
    
    ans+=K-1
if S[0]!= S[1] and (count+1)%2 ==1 and  S[0] == S[len(S)-1]:
    ans+=K-1

### FIXED CODE ###

S = input()
K = int(input())
a = []
ans = 0
count = 0
for i in range(len(S)-1):
    if S[i] == S[i+1] :
        count += 1
    else:
        if count!=0:
            ans += (count+1)//2
            a.append(count+1)
            count = 0
if count !=0:
    ans += (count+1)//2 
ans = ans*K
a.append(0)
if len(S) == 1:
    ans = K//2
else:    
    
    if (count+1)%2==1 and a[0]%2 == 1 and S[0]== S[1] and S[0] == S[len(S)-1]:
    
        ans+=K-1
    if S[0]!= S[1] and (count+1)%2 ==1 and  S[0] == S[len(S)-1]:
        ans+=K-1
    if count+1 == len(S):
        if len(S)%2==1:
            ans = (len(S)*K)//2
 
print(ans)
import collections
n,k=map(int,input().split())
a=list(map(int,input().split()))
cnt=collections.Counter(a)
cnt.most_common()
ans=0
for i in range(k):
  print(ans[i][1])
  ans+=cnt[i][1]
peint(ans)

### FIXED CODE ###

import collections
n,k=map(int,input().split())
a=list(map(int,input().split()))
c=collections.Counter(a)
d=c.most_common()
ans=0
for i in range(min(k,len(d))):
  ans+=d[i][1]
print(n-ans)
N = int(input())
u, v, w = [0]*(N-1), [0]*(N-1), [0]*(N-1)
n = [-1] * N 
# n[][0] 色　n[][1] 連結先一覧リスト(連結先奇数なら+ 偶数なら-がかかる1追加された値)
for i in range(N):
    n[i] = [0]*3
    n[i][1] = []


for i in range(N-1):
    u[i], v[i], w[i] = list(map(int, input().split()))
    n[u[i]-1][1].append((v[i])*(w[i]%2*2 -1))
    n[v[i]-1][1].append((u[i])*(w[i]%2*2 -1))

# n[][2] 探索済フラグ
def dfs(num):
    n[num][2] = 1
    for item in n[num][1]:
        if n[abs(item)-1][2] == 0:
            if item < 0:
                item = -1*item
                n[item-1][0] = n[num][0]
                dfs(item-1)
            else:
                n[item-1][0] = -1 * n[num][0] +1
                dfs(item-1)

dfs(0)

for i in n:
    print(i[0])

### FIXED CODE ###

N = int(input())
u, v, w = [0]*(N-1), [0]*(N-1), [0]*(N-1)
n = [-1] * N
# n[][0] 色　n[][1] 連結先一覧リスト n[][2] mod2 
for i in range(N):
    n[i] = [0]*4
    n[i][1] = []
    n[i][2] = []

for i in range(N-1):
    u[i], v[i], w[i] = list(map(int, input().split()))
    n[u[i]-1][1].append(v[i]-1)
    n[v[i]-1][1].append(u[i]-1)
    n[u[i]-1][2].append(w[i]%2)
    n[v[i]-1][2].append(w[i]%2)

stack = [u[0]-1]

while True:
    num = stack.pop()
    n[num][3] = 1
    for i in range(len(n[num][1])):
        if n[n[num][1][i]][3] == 0:
            stack.append(n[num][1][i])
            if n[num][2][i] == 0:
                n[n[num][1][i]][0] = n[num][0]
            else:
                n[n[num][1][i]][0] = -1 * n[num][0] + 1
    if len(stack) == 0:
        break

for i in n:
    print(i[0])
data = [[[0 for r in range(10)] for r in range(3)] for b in range(4)]
n = int(input())
     
for _ in range(n):
    (b, f, r, v) = [int(i) for i in input().split()]
     
for b in range(4):
    for f in range(3):
        for r in range(10):
        print('',data[b][f][r], end='')
    print()
print('#' * 20)                                                       
                         

### FIXED CODE ###

data = [[[0 for r in range(10)] for f in range(3)] for b in range(4)]
 
n = int(input())
 
for _ in range(n):
    (b,f,r,v) = [int(i) for i in input().split()]
    data[b - 1][f - 1][r - 1] += v
 
for b in range(4):
    for f in range(3):
        for r in range(10):
            print('',data[b][f][r], end='')
        print()
    if b < 3:
        print('#' * 20)
import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

S, W = map(int, read())

if W >= S:
    print("unsafe")
else:
    print("safe")


    

### FIXED CODE ###

import sys
int1 = lambda x: int(x) - 1
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

S, W = map(int, read().split())

if W >= S:
    print("unsafe")
else:
    print("safe")
import numpy as np

N, M, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cost = 0
ind_a = 0
ind_b = 0
max_book = 0
dp = np.zeros((N + 1, M + 1)).astype(int)
while True:
    if ind_a < N and ind_b <= M:
        dp[ind_a + 1, ind_b] = dp[ind_a, ind_b] + A[ind_a]
        ind_a += 1
        if dp[ind_a, ind_b] <= K and ind_a + ind_b > max_book:
            max_book = ind_a + ind_b
    if ind_b < M and ind_a <= N:
        dp[ind_a, ind_b + 1] = dp[ind_a, ind_b] + B[ind_b]
        ind_b += 1
        if dp[ind_a, ind_b] <= K and ind_a + ind_b > max_book:
            max_book = ind_a + ind_b

    if ind_a == N and ind_b == M:
        break
print(max_book)


### FIXED CODE ###

import numpy as np

N, M, K = list(map(int, input().split()))
A = list(map(int, [0] + input().split()))
B = list(map(int, [0] + input().split()))
cost = 0
cumsum_a = np.cumsum(A)
cumsum_b = np.cumsum(B)

num_book = 0
max_a = 0
ind_b = 0
max_b = 0
for i in range(1, N + 1):
    if cumsum_a[i] <= K:
        max_a = i
    else:
        break

for i in range(1, M + 1):
    if cumsum_b[i] <= K:
        max_b = i
    else:
        break

for i in range(max_a, -1, -1):
    for j in range(ind_b, max_b+1):
        if cumsum_b[j] + cumsum_a[i] <= K:
            # print("ok")
            num_book = max(i + j, num_book)
            ind_b = j
        else:
            break
print(num_book)
x, n = map(int, input().split())
p = list(map(int, input().split()))

table = [0 for i in range(100)]
for i in p:
    table[i-1] = 1

mx = 10000
ans = mx
dis = mx
for i in range(len(table)):
    idx = 99-i
    if (table[idx] == 0) and (dis >= abs(idx+1-x)):
        ans = idx+1
        dis = abs(idx+1-x)
if ans == mx:
    if 50 >= x
        print(0)
    else:
        print(101)
else:
    print(ans)


### FIXED CODE ###

x, n = map(int, input().split())
p = list(map(int, input().split()))

table = [0 for i in range(102)]
for i in p:
    table[i] = 1

mx = 10000
ans = mx
dis = mx
for i in range(len(table)):
    idx = 101-i
    if (table[idx] == 0) and (dis >= abs(idx-x)):
        ans = idx
        dis = abs(idx-x)
print(ans)
N=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(N[int(input()-1)])

### FIXED CODE ###

N=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(N[int(input())-1])
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
x=sum(b)
for i in range(len(a)-1):
  if a[i+1]-a[i]==1:
    d=a[i]
    x+=c[d-1]
print(x)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
total=a[0]+a[-1]
for i in range(n-2):
  total+=min(a[i],a[i+1])
print(total)
N = int(input())
h = list(map(int,input().split()))

def dfs(L):
    for i,l in enumerate(L):
        if l != 0:
            break
    L = L[i:N]
    s = 0
    res = 0
    for i,l in enumerate(L):
        if l == 0:
            L_ = [l_-1 for l_ in L[s:i]]
            if len(L_) != 0:
                res += 1
                s = i+1
                if sum(L_) != 0:
                    res += dfs(L_)
        elif i == len(L)-1:
            L_ = [l_-1 for l_ in L[s:len(L)]]
            if len(L_) != 0:
                res += 1
                s = i+1
                if sum(L_) != 0:
                    res += dfs(L_)
    return res

if sum(h) == 0:
    print(0)
else:
    print(dfs(h))

### FIXED CODE ###

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

def dfs(L):
    for i,l in enumerate(L):
        if l != 0:
            break
    L = L[i:N]
    s = 0
    res = 0
    for i,l in enumerate(L):
        if l == 0:
            L_ = [l_-1 for l_ in L[s:i]]
            s = i+1
            if len(L_) != 0:
                res += 1
                res += dfs(L_)
        elif i == len(L)-1:
            L_ = [l_-1 for l_ in L[s:len(L)]]
            s = i+1
            if len(L_) != 0:
                res += 1
                res += dfs(L_)
    return res

if sum(h) == 0:
    print(0)
else:
    print(dfs(h))
s = input()
h = s//60
s = s-h*60
m = s//60
s = s-m*60
print(h,':',m,':',s)

### FIXED CODE ###

# -*- coding:utf-8 -*-
sec = int(input())
 
minute = sec//60
sec = sec%60
 
hour = minute//60
minute = minute%60
 
print(':'.join(map(str,[hour,minute,sec])))
N = input()
ans = 1
for _ in range(N):
  a = int(input())
  ans *= a
ans = -1 if ans > 10 ** 18 else ans
print(ans)

### FIXED CODE ###

N = int(input())
ans = 1
A = list(map(int, input().split()))
A.sort(reverse=True)
if A[N-1] == 0:
  ans = 0
else:
  for a in A:
    ans *= a
    if ans > 10 ** 18:
      ans = -1
      break
print(ans)
s = input()
print("x"**len(s))

### FIXED CODE ###

s = input()
print("x"*len(s))
import math
def cal(n ,r):
    if n == r:
        return 1
    return math.factorial(n)/(math.factorial(r) * math.factorial(n-r))

def bin_search(in_list, val):
    cnt = len(in_list)
    mid = round(cnt/2)
    if cnt == 1:
        return in_list[0]
    if in_list[mid] > val:
        return bin_search(in_list[:mid], val)
    if in_list[mid] < val:
        return bin_search(in_list[mid:], val)
    if in_list[mid] == val:
        return val

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

m_combo = 0
ai = 0
aj = 0

for i in range(1,n):
    a = A[i]
    val = bin_search(A[:i], round(a/2))
    upper = A[A.index(val) + 1]
    if abs(val - round(a/2)) > abs(upper - round(a/2)):
      val = upper
    combo = cal(a, val)
    if combo > m_combo:
        m_combo = combo
        ai = a
        aj = val

print('{} {}'.format(ai, aj))


### FIXED CODE ###

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

ai = max(A)
A.remove(ai)

Asub = [abs(ai/2 -a) for a in A]
aj = A[Asub.index(min(Asub))]

print('{} {}'.format(ai, aj))
S = list(map(int,input()))
init = int(len(S))
ans = []

def cube(S,ans):
    if not any(S) or all(S):
        ans.append(int((init-len(S))))
    for i in range(len(S)-1):
        if S[i] != S[i+1]:
            cube(S[0:i]+S[i+2:],ans)
cube(S,ans)
ans.sort()
print(ans[-1])

### FIXED CODE ###

S = list(map(int,input()))
num1 = 0
num0 = 0

for i in range(len(S)):
    if S[i]:
        num1 += 1
    else:
        num0 += 1

print(min(num1,num0)*2)
S = int(input())
h = S//3600
m = S%3600//60
s = S%60
print("h":"m":"s".split(:))



### FIXED CODE ###

S = int(input())
h = S//3600
m = S%3600//60
s = S%60
print(f"{h}:{m}:{s}")
from itertools import product

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

for i in range(N):
    ai = int(input())
    for j in range(ai): 
        x, y = map(int, input().split())
        x = x - 1
        A[i].append([x, y])
        
# ここから判定
ans = 0
for pattern in product([0, 1], repeat=N):
    num = pattern.count(1)
    contradictions = False
    for i, testimony in enumerate(A):
        if pattern[i] == 0:
            continue
        for t in testimony:
            x, y = t
            if pattern[x] != Y ^ (1- pattern[i]):
                contradictions  = True
                break
        if contradictions:
            break
    if contradictions:
        continue
    ans = max(ans, num)
print(ans)
    

### FIXED CODE ###

cards = [int(i) for i in input().split()]

if sum(cards) >= 22:
    print('bust')
else :
    print('win')