Harryxun/stf_run huggingface dataset:
# %%
W, H = [int(i) for i in input().split()]
maze = [[] for _ in range(H)]

num_black = 0
for i in range(H):
    temp = input()
    for j in temp:
        maze[i].append(j)
        if j == "#":
            num_black += 1

# %%
import copy, collections

maze_copy = copy.deepcopy(maze)
color = [["W"] * W for _ in range(H)]


def BFS(Y, X):
    vec = [[1, 0], [-1, 0], [0, 1], [0, -1]]
    color[Y][X] = "G"
    que = collections.deque()
    maze_copy[Y][X] = 1
    que.append([Y, X])

    while len(que) != 0:
        u = que.popleft()
        for y, x in vec:
            temp_x = u[1] + x
            temp_y = u[0] + y
            if (0 <= temp_x < W and 0 <= temp_y < H
                    and maze_copy[temp_y][temp_x] == "." and color[temp_y][temp_x] == "W"):
                color[temp_y][temp_x] = "G"
                maze_copy[temp_y][temp_x] = maze_copy[u[0]][u[1]] + 1
                que.append([temp_y, temp_x])


BFS(0, 0)
print(W * H - num_black - maze_copy[-1][-1])



### FIXED CODE ###

#%%
H, W = [int(i) for i in input().split()]
maze = [[] for _ in range(H)]

num_black = 0
for i in range(H):
    temp = input()
    for j in temp:
        maze[i].append(j)
        if j == "#":
            num_black += 1
            
#%%
import copy, collections

maze_copy = copy.deepcopy(maze)
color = [["W"] * W for _ in range(H)]


X, Y = 0, 0
vec = [[1, 0], [-1, 0], [0, 1], [0, -1]]
color[Y][X] = "G"
que = collections.deque()
maze_copy[Y][X] = 1
que.append([Y, X])

while len(que) != 0:
    u = que.popleft()
    for y, x in vec:
        temp_x = u[1] + x
        temp_y = u[0] + y
        if (0 <= temp_x < W and 0 <= temp_y < H
                and maze_copy[temp_y][temp_x] == "." and color[temp_y][temp_x] == "W"):
            color[temp_y][temp_x] = "G"
            maze_copy[temp_y][temp_x] = maze_copy[u[0]][u[1]] + 1
            que.append([temp_y, temp_x])
    
if maze_copy[-1][-1] == ".":
    print(-1)
else:
    print(W * H - num_black - maze_copy[-1][-1])
def get_div(num):
    if num == 1:
        return [1]
    else:
        return [i for i in range(1,num) if num%i==0]

A, B, K  = [int(a) for a in input().split()]
cat = get_div(A) + get_div(B)
dup = [x for x in set(cat) if cat.count(x) > 1]
dup = sorted(dup)
print(dup[K-1])

### FIXED CODE ###

def get_div(num):
    if num == 1:
        return [1]
    else:
        return [i for i in range(1,num+1) if num%i==0]

A, B, K  = [int(a) for a in input().split()]
cat = get_div(A) + get_div(B)
dup = sorted([x for x in set(cat) if cat.count(x) > 1])
dup.reverse()
print(dup[K-1])
n, k = [int(i) for i in input().split()]
ds = []
As = []
for i in range(2*k):
    ds.append(int(input()))
    As += [int(j) for j in input().split()]
 
 
print(n-len(set(As)))

### FIXED CODE ###

n, k = [int(i) for i in input().split()]
ds = []
As = []
for i in range(k):
    ds.append(int(input()))
    As += [int(j) for j in input().split()]
 
 
print(n-len(set(As)))
y,m,d=int(input().split("/"))
if y<=2018:
  ans="Heisei"
else:
  if m<=4:
    ans="Heisei"
  else:
    ans="TBD"
print(ans)

### FIXED CODE ###

y,m,d=map(int,input().split("/"))
if y<=2018:
  ans="Heisei"
else:
  if m<=4:
    ans="Heisei"
  else:
    ans="TBD"
print(ans)
from heapq import*
(N,M),*t=[map(int,s.split())for s in open(0)]
q=[0]*M
v=[[]for _ in q]
z=0
for a,b in t:v[a-1]+=[b]
for i in v[:M]:
	for j in i:heappush(q,-j)
	z-=heappop(q)
print(z)

### FIXED CODE ###

from heapq import*
N,M,*t=map(int,open(0).read().split())
v=[[]for _ in range(M)]
for i in range(N):
	if t[2*i]<=M:
		v[t[2*i]-1].append(t[2*i+1])
z=0
q=[]
for i in range(M):
	for j in v[i]:
		heappush(q,-j)
	b=0
	if len(q):
		b=heappop(q)
	z-=b
print(z)
from heapq import heappush,heappop
import queue
import re
import math
import functools
import numpy as np

def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))

INF = 1<<29

def make1d_arr(n,val=INF):
    return [val for i in range(n)]

def make2d_arr(h,w,val =INF):
    return [[val for i in range(w)]for i in range(h)]

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


N = int_raw()
As =[]
for _ in range(N):
    As.append(int_raw())
SUM = sum(As)

DIV = 998244353

ALL = 1
for _ in range(N):
    ALL = (ALL*3)%DIV

def main():
    dp1 = [0]*(SUM+1)
    dp3 = [0]*(SUM+1)
    dp1[0]=1
    dp3[0]=1
    
    for n in range(N):
        a = As[n]
        dp1 = [(dp1[s]+(dp1[s-a] if s>=a else 0))%DIV for s in range(SUM+1)]
        dp3 = [(dp3[s]*2 + (dp3[s-a] if s>=a else 0))%DIV for s in range(SUM+1)]

    S3 = (sum(dp3[(SUM+1)//2:])*3)%DIV
    S1 = (dp1[(SUM)//2]*3)%DIV if SUM%2==0 else 0
    return (ALL - S3 + S1 + DIV) % DIV

print(main())


### FIXED CODE ###

from heapq import heappush,heappop
import queue
import re
import math
import functools


def int_raw():
    return int(input())

def ss_raw():
    return input().split()

def ints_raw():
    return list(map(int, ss_raw()))

INF = 1<<29

def make1d_arr(n,val=INF):
    return [val for i in range(n)]

def make2d_arr(h,w,val =INF):
    return [[val for i in range(w)]for i in range(h)]

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


N = int_raw()
As =[]
for _ in range(N):
    As.append(int_raw())
SUM = sum(As)

DIV = 998244353

ALL = 1
for _ in range(N):
    ALL = (ALL*3)%DIV

def main():
    dp1 = [0]*(SUM+1)
    dp3 = [0]*(SUM+1)
    dp1[0]=1
    dp3[0]=1
    
    for n in range(N):
        a = As[n]
        dp1 = [(dp1[s]+(dp1[s-a] if s>=a else 0))%DIV for s in range(SUM+1)]
        dp3 = [(dp3[s]*2 + (dp3[s-a] if s>=a else 0))%DIV for s in range(SUM+1)]

    S3 = (sum(dp3[(SUM+1)//2:])*3)%DIV
    S1 = (dp1[(SUM)//2]*3)%DIV if SUM%2==0 else 0
    return (ALL - S3 + S1 + DIV) % DIV

print(main())
A = input()
n = len(a)
i = 1
ans = ''

def check(i, a, ans):
    if i == n:
        if eval(a) == 7:
            ans = a
        return ans
    
    else:
        a = a[:2*i-2] + A[i-1:]
        p = i + a.count('+') + a.count('-')
        a = a[:p] + '+' + a[p:]
        ans = check(i+1, a, ans)
        
        a = a[:2*i-2] + A[i-1:]
        p = i + a.count('+') + a.count('-')
        a = a[:p] + '-' + a[p:]
        ans = check(i+1, a, ans)
    return ans

ans = check(i, A, ans) 
print(ans+'=7')

### FIXED CODE ###

A = input()
n = len(A)
i = 1
ans = ''

def check(i, a, ans):
    if i == n:
        if eval(a) == 7:
            ans = a
        return ans
    
    else:
        a = a[:2*i-2] + A[i-1:]
        p = i + a.count('+') + a.count('-')
        a = a[:p] + '+' + a[p:]
        ans = check(i+1, a, ans)
        
        a = a[:2*i-2] + A[i-1:]
        p = i + a.count('+') + a.count('-')
        a = a[:p] + '-' + a[p:]
        ans = check(i+1, a, ans)
    return ans

ans = check(i, A, ans) 
print(ans+'=7')
,b,c = map(int,input().split())

for i in range(1,b+1):
    if a*i%b == c:
        print('YES')
        break
else:
    print('NO')


### FIXED CODE ###

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

for i in range(1,b+1):
    if (a*i)%b == c:
        print('YES')
        break
else:
    print('NO')
import sys
sys.setrecursionlimit(10**6)

def DFS(v,i,count):
  global ans
  if v == i:# 探索終了
    #print('ans:{}, v:{}'.format(ans,v_count[v]))
    ans[i] = count + v_count[v]
    #print('tmp:{}'.format(tmp))
  for u in adj[v]:
    DFS(u,i,count + v_count[v])

N, Q = map(int, input().split())

adj = [[] for _ in range(N)]
v_count = [0] * N

for i in range(N-1):
  a, b = map(int, input().split())
  adj[a-1].append(b-1)
  adj[b-1].append(a-1)

for j in range(Q):
  p, x = map(int, input().split())
  v_count[p-1] += x

# print(v_count)
ans = [None] * N
for i in range(N):
  # iを探索で見つけ出す, そこまで通った頂点のv_count
  # の総和を出力
  DFS(0,i,0)
print(*ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**6)

def DFS(v, parent):
  for u in adj[v]:
    if u != parent:
      v_count[u] += v_count[v]
      DFS(u,v)

N, Q = map(int, input().split())

adj = [[] for _ in range(N)]
v_count = [0] * N

for i in range(N-1):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  adj[a].append(b)
  adj[b].append(a)# aがbの親とは限らないため

for j in range(Q):
  p, x = map(int, input().split())
  v_count[p-1] += x

# 0起点に親ノードの数字を子ノードに足していく
DFS(0, -1)# 現在のノード, 親ノード
print(*v_count)
N=int(input())
*A,=map(int,input().split())

A.sort()
ans=N
i=0
while i<N:
    if i==0 and A[i]==A[i+1]:
        ans-=1
        i+=1
        continue
    if A[i]==A[i-1]:
        ans-=1
        i+=1
        continue
    for a in A[:i]:
        if A[i]%a==0:
            ans-=1
            break
        if i>10**4 and a>int(A[i]**0.5)+1:
            break
    i+=1

print(ans)

### FIXED CODE ###

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

A.sort()
count=[0]*(A[-1]+1)
i=0
while i<N:
    j=A[i]
    if 2<=count[j]:
        i+=1
        continue
    k=1
    while j*k<=A[-1]:
        count[j*k]+=1
        k+=1
    i+=1

print(sum(count[a]==1 for a in A))
a=input("数字を入力してください")
b=input("数字を入力してください")
c=input("数字を入力してください")
d=input("数字を入力してください")

if b-a<=d:
    if c-b<=d:
        print('Yes')
    else:
        print('No')
else:
    print('No')


### FIXED CODE ###

a, b, c, d = map(int, input().split())
if (abs(b-a) <= d and abs(c-b) <= d) or abs(c-a) <= d:
    print('Yes')
else:
    print('No')
import sys
import math
import itertools
import numpy

rl = sys.stdin.readline

n, m = map(int, rl().split())
li = [[] for _ in range(m+1)]
for _ in range(m):
  a, b = map(int, rl().split())
  a -= 1
  b -= 1
  li[a].append(b)
  li[b].append(a)

marks = [-1]*n
marks[0] = 0
def dfs(aa, x):
  marks[x] = aa
  for nr in li[x]:
    if marks[nr] == -1:
      dfs(x, nr)
  
  
dfs(0, 0)
if -1 in marks:
  print('No')
else:
  print('Yes')
  for i in marks[1:]:
    print(i+1)


### FIXED CODE ###

import sys
import math
import itertools
import numpy

rl = sys.stdin.readline

n, m = map(int, rl().split())
li = [[] for _ in range(m+1)]
for _ in range(m):
  a, b = map(int, rl().split())
  a -= 1
  b -= 1
  li[a].append(b)
  li[b].append(a)

marks = [-1]*n
stack = [0]
while stack:
    for next_room in li[stack[0]]:
        if marks[next_room] == -1:
            stack.append(next_room)
            marks[next_room] = stack[0]
    del stack[0]
if -1 in marks:
  print('No')
else:
  print('Yes')
  for i in marks[1:]:
    print(i+1)
from collections import deque

dis_x = [1, 0, -1, 0]
dis_y = [0, 1, 0, -1]

goal_h, goal_w = map(int, input().split())

s = []
for _ in range(goal_h):
    line = input()
    s.append(list("#{}#".format(line)))

s = [list("#" * (goal_w + 2))] + s + [list("#" * (goal_w + 2))]

dist = [ [0] * (goal_w + 2) for _ in range(goal_w+2)]

que = deque([(1, 1)])

while que:
    h, w = que.popleft()

    for i in range(4):
        dx, dy = dis_x[i], dis_y[i]
        if s[h+dy][w+dx] == '.' and  dist[h+dy][w+dx] == 0:
            dist[h+dy][w+dx] = dist[h][w]+1
            que.append((h+dy, w+dx))

opt = dist[goal_h][goal_w]

not_wall_count = 0
for i in range(1, goal_h+1):
    for j in range(1, goal_w+1):
        if s[i][j] == '.':
            not_wall_count += 1

if s[goal_h][goal_w] == '#':
    print(-1)
else:
    print(not_wall_count - opt - 1)

### FIXED CODE ###

from collections import deque
H, W = map(int, input().split())
S = [input() for i in range(H)]
C = sum(s.count('.') for s in S)

dd = ((-1, 0), (0, -1), (1, 0), (0, 1))
que = deque([(0, 0, 0)])
used = {(0, 0)}

res = None
while que:
    s, t, cost = que.popleft()
    if s == H-1 and t == W-1:
        res = cost
        break
    for di, dj in dd:
        ni = s + di; nj = t + dj
        if (not 0 <= ni < H) or (not 0 <= nj < W) or S[ni][nj] == '#' or (ni, nj) in used:
            continue
        used.add((ni, nj))
        que.append((ni, nj, cost + 1))
if res:
    print(C - 1 - res)
else:
    print(-1)
N, C = map(int, input().split())

X = [0]
V = [0]
sV = [0]
for _ in range(N):
    x, v = map(int, input().split())
    X.append(x)
    V.append(v)
    sV.append(sV[-1]+v)
X.append(C)

ans = 0
for a in range(N+1):
    for b in range(a+1, N+2):
        # O -> A -> B
        a1 = sV[a+1]+sV[-1]-sV[b-1]-2*X[a]-(C-X[b])

        # O -> B -> A
        a2 = sV[a+1]+sV[-1]-sV[b-1]-X[a]-2*(C-X[b])

        ans = max(ans, a1, a2)

print(ans)


### FIXED CODE ###

N, C = map(int, input().split())

X = [0]
V = [0]
sV = [0]
Amax1 = [0]
Amax2 = [0]
for _ in range(N):
    x, v = map(int, input().split())
    X.append(x)
    V.append(v)
    sV.append(sV[-1]+v)
    Amax1.append(max(Amax1[-1], sV[-1]-x))
    Amax2.append(max(Amax2[-1], sV[-1]-2*x))
X.append(C)

ans = 0
for b in range(1, N+2):
    # O -> A -> B
    a1 = Amax2[b-1]+sV[-1]-sV[b-1]-(C-X[b])

    # O -> B -> A
    a2 = Amax1[b-1]+sV[-1]-sV[b-1]-2*(C-X[b])

    ans = max(ans, a1, a2)

print(ans)
S = sorted(input())
T = sorted(input())

print("Yes" if (S < t) else "No")



### FIXED CODE ###

S = "".join(sorted(input()))
T = "".join(sorted(input()))[::-1]

print("Yes" if (S < T) else "No")
print(min(int(input()),int(input())) + min(int(input()) + int(input())))

### FIXED CODE ###

print(min(int(input()),int(input())) + min(int(input()),int(input())))
A, B = map(int,input().split())

Amin = A/0.08
Amax = (A+1)/0.08
Bmin = B/0.1
Bmax = (B+1)/0.1


if Amax <= Bmin or Amin > Bmax:
    kai = -1
if Bmin <= Amin and Bmax > Amin:
    kai = Amin
if Amin <= Bmin and Bmax < Amin:
    kai = Bmin

print(kai)

### FIXED CODE ###

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

count = 0

for n in range(10000):
    za = n*0.08
    zb = n*0.1
    count += 1
    if A == math.floor(za) and B == math.floor(zb):
        print(n)
        break


if count == 10000:
    print(-1)
import math
from functools import reduce
from fractions import gcd

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

X,Y = map(int,input().split())
if lcm(X,Y)//X > 10**18 or X == Y:
  print(-1)
else:
  print(lcm(X,Y)//X)

### FIXED CODE ###

X,Y = map(int,input().split())
X_ = X
while X_ <= 10**9:
  if X == Y:
    print(-1)
    exit()
  X_ += X
  if X%Y != 0:
    print(X)
    exit()

print(-1)
import math
N,X = map(int,input().split())
x = list(map(int,input().split()))
D = abs(x[0]-X)
for i in range(1,N):
    D = math.gcd(D, abs(X-x[i]))
print(D)

### FIXED CODE ###

import fractions
N,X = map(int,input().split())
x = list(map(int,input().split()))
D = abs(x[0]-X)
for i in range(1,N):
    D = fractions.gcd(D, abs(X-x[i]))
print(D)
S = input()

s = [int(S[i])-int(S[i+1]) for i in range(S)]

print("Good" if 0 in s else "Bad")

### FIXED CODE ###

S = input()

s = [int(S[i])-int(S[i+1]) for i in range(len(S)-1)]

print("Good" if 0 not in s else "Bad")
N = int(input())
b = []
for i in range(N):
  a = int(input())
  b.append(a)
    
for i in b:
  B = i%2
  if B==0:
    if i%3 == i%5:
      print("APPROVED")
    else:
      print("DENIED")
  else:
    print("DENIED")

### FIXED CODE ###

a,b,c = [int(x) for x in input().split()]
if (a == b and b!=c) or (a==c and a!=b) or (b==c and b!=a):
  print("Yes")
else:
  print("No")
sum = 0
r =[]
for i in range(5):
  if a[i] % 10 ==0:
    sum+=a[i]
  elif a[i] % 10 !=0:
    sum+= (10*math.ceil(a[i]/10))
    r.append(int(a[i]%10))
print(sum-10+min(r))

### FIXED CODE ###

import math
a = []
for i in range(5):
    a.append(int(input()))
sum = 0
r =10
for i in range(5):
  if a[i] % 10 ==0:
    sum+=a[i]
  elif a[i] % 10 !=0:
    r = min(r,a[i]%10)
    sum+= (10*math.ceil(a[i]/10))
print(sum-10+r)
n = int(input())
nums = [int(i) for i in input().split()]

box = [0] * (n + 1)
for i in range(1, n + 1)[::-1]:
    ball = nums[i - 1]
    t = i * 2
    while t <= n:
        ball ^= box[t - 1]
        t += i
    box[t - 1] = ball

ans = box.count(1)
index = []
for i in range(len(box)):
    if box[i]:
        index.append(i)
print(ans)
print(*index)

### FIXED CODE ###

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

for _ in range(N):
  ans.append(-1)

for i in range(N,0,-1):
  C = i*2
  BALL = A[i-1]
  while C <= N:
    BALL = BALL ^ ans[C-1]
    C += i
  ans[i-1] = BALL 

print(ans.count(1))
ans2 = []
for i in range(N):
  if ans[i] == 1:
    ans2.append(i+1)

L=[str(a) for a in ans2]
L=" ".join(L)
print(L)
import sys
input = sys.stdin.readline
h,w = map(int,input().split())
a = [list(map(int,input().split())) for i in range(h)]
b = [list(map(int,input().split())) for i in range(h)]
grid = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    grid[i][j] = abs(a[i][j]-b[i][j])
dp = [[[False for i in range(80*(h+w+1)+1)] for j in range(w)] for k in range(h)]
dp[0][0][grid[i][j]] = True
for j in range(1,w):
  for k in range(80*j+1):
    t = grid[0][j]
    dp[0][j][k] = dp[0][j][k] or dp[0][j-1][k+t] or dp[0][j-1][abs(k-t)]
for i in range(1,h):
  for k in range(80*i+1):
    t = grid[i][0]
    dp[i][0][k] = dp[i][0][k] or dp[i-1][0][k+t] or dp[i-1][0][abs(k-t)]
for i in range(1,h):
  for j in range(1,w):
    for k in range(80*(i+j)+1):
      t = grid[i][j]
      dp[i][j][k] = dp[i][j][k] or dp[i][j-1][k+t] or dp[i][j-1][abs(k-t)] or dp[i-1][j][k+t] or dp[i-1][j][abs(k-t)]
for i in range(12801):
  if dp[h-1][w-1][i]:
    print(i)
    break


### FIXED CODE ###

a,b,c=map(int,input().split())
if a+b+c>21:
  print("bust")
else:
  print("win")
a = int(input())

i = 2
max_num = 1
flag_outer = True
while i < a:      
    j = 2
  	temp = 0

  	while i**j < a:
    	temp = i**j
    	j+=1

    if temp > max_num and temp < a:
    	max_num = temp
      	i+=1
print(max_num)

### FIXED CODE ###

a = int(input())

i = 2
max_num = 1
while i <= a:
    j = 2
    temp = 0
    while i**j <= a:
        temp = i**j
        j+=1

    if temp > max_num and temp <= a:
        max_num = temp
    i+=1
print(max_num)
a=input()
b=input()
if a>=3200:
	print(s)
else:
	print('red')

### FIXED CODE ###

a=int(input())
s=str(input())
if a>=3200:
	print(s)
else:
	print('red')
import sys
n, k = map(int, input().split())
w = tuple(map(int, sys.stdin.readlines()))
w = tuple(map(int, input().split()))
p = max(w)
s = sum(w)
if n <= k:
    print(p)
elif k == 1:
    print(s)
else:
    a = max(p, s//k)
    while True:
        l = [a]
        for i in range(n):
            d = l[-1] - w[i]
            if d < 0:
                l.append(a-w[i])
            else:
                l[-1] = d
            i += 1
        if len(l) > k:
            a += 1
        else:
            break
    print(a)

### FIXED CODE ###

n,k = map(int, input().split())
w = [int(input()) for _ in range(n)]

def check(p):
    c = t = 0
    for wi in w:
        t += wi
        if t > p:
            t = wi
            c += 1
            if c >= k:
                return False
    return True

s = max(w)
l = sum(w)
while s < l:
    m = (s+l)//2
    if check(m):
        l = m
    else:
        s = m = m+1
print(s)
n, x = map(int,input().split())
xl = list(map(int,input().split()))

xl.append(x)
xl.sort()

onesam = 0
for i in range(len(xl)-1):
    one_sa = xl[i+1] - xl[i]
    if onesam == 0:
        onesam = one_sa
    else:
        if one_sa % onesam == 0:
            continue
        else:
            short,big = min(onesam,one_sa),max(onesam,ne_sa)
            if short == 1:
                onesam =1
                break
                
            while big % short != 0:
                for i in range(2,short):
                    if short % i == 0:
                        short = short // i
            if short == 1:
                onesam = 1
                break
            else:
                onesam = short
print(onesam)

### FIXED CODE ###

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

xl.append(x)
xl.sort()

onesam = 0

if len(xl) == 1:
    print(abs(xl[0] - x))
    exit()

for i in range(len(xl)-1):
    one_sa = xl[i+1] - xl[i]
    if onesam == 0:
        onesam = abs(one_sa)
    else:
        short,big = min(onesam,one_sa),max(onesam,one_sa)
        if big % short == 0:
            onesam = short
            continue
        else:
            while big % short != 0:
                short = short -1
#                 for k in range(2,short+1):
#                     if short % k == 0:
#                         short = short // k
#                         break
            onesam = short
            
print(onesam)
import collections
N = int(input())
s = ["".join(sorted(input())) for _ in range(N)]
print(A)
B = collections.Counter(s)
print(sum(i*(i-1)//2 for i in B.values()))

### FIXED CODE ###

import collections
N = int(input())
A = []
for i in range(N):
    s = sorted(input())
    A.append(str(s))
B = collections.Counter(A)
print(sum(i*(i-1)//2 for i in B.values()))
def factorial(a):
    r = 1
    for i in range(a):
        r *= i+1
    return r

def combinations(a, b):
    if a>=0 and b>=0 and a >= b:
        return pow(9, b) * factorial(a) // factorial(b) // factorial(a-b)
    else:
        return 0

def count(m, a, b):
    # return the count of numbers in range [0, m x 10^a] with b non zero digitals
    ## the count of numbers in range [0, m x 10^a) with b non zero digitals
    r = combinations(a-1, b) + (m-1) * combinations(a-1, b-1)
    if b == 1:
        ## m x 10^a
        r += 1
    return r

N = int(input())
K = int(input())

digit = list(map(int, str(N)))
M = len(digit)

C = 0
for i in range(K):
    C += count(digit[i], M-i, K-i)

print(C)    

### FIXED CODE ###


def factorial(a):
    r = 1
    for i in range(a):
        r *= i+1
    return r

def combinations(a, b):
    if a>=0 and b>=0 and a >= b:
        return pow(9, b) * factorial(a) // factorial(b) // factorial(a-b)
    else:
        return 0

def count(m, a, b):
    # return the count of numbers in range [0, m x 10^a] with b non zero digitals
    ## the count of numbers in range [0, m x 10^a) with b non zero digitals
    r = combinations(a-1, b) + (m-1) * combinations(a-1, b-1)
    if b == 1:
        ## m x 10^a
        r += 1
    return r

def COUNT(N,K):
    digit = list(map(int, str(N)))
    M = len(digit)
    C = count(digit[0], M, K)
    if len(digit) > 1:
        N_ = int("".join(map(str, digit[1:])))
    else:
        N_ = 0
    return C, N_
    

N = int(input())
K = int(input())

C = 0
while (N>0) and (K>0):
    c, N = COUNT(N, K)
    C+= c
    K-= 1

print(C)
n=int(input())
xymap=[[-1 for j in range(101)] for i in range(101)]
inp=[]
for i in range(n):
    xi,yi,hi=map(int,input().split())
    if hi==0:
        inp.append(xi,yi,hi)
        pass
    else:
            
        for x in range(101):
            for y in range(101):
                a=abs(xi-x)+abs(yi-y)+hi
                if xymap[x][y]==a or xymap[x][y]==-1 :
                    xymap[x][y]=a
                else:
                    xymap[x][y]=-2
flag=0
for x in range(101):
    for y in range(101):
        if xymap[x][y]!=-2:
            print(x,y,xymap[x][y])
        else:
            flag=1
if flag==1:
    xymap=[[-1 for j in range(101)] for i in range(101)]
    for i in range(len(inp)):
        for x in range(101):
            for y in range(101):
                if xymap[x][y]==1 or xymap[x][y]==-1 :
                    xymap[x][y]=1
                else:
                    xymap[x][y]=-2
    for x in range(101):
        for y in range(101):
            if xymap[x][y]!=-2:
                print(x,y,xymap[x][y])
                

### FIXED CODE ###

n=int(input())
xymap=[[-1 for j in range(101)] for i in range(101)]
inlist=[]
for i in range(n):
    xi,yi,hi=map(int,input().split())
    inlist.append([xi,yi,hi])
inlist.sort(key=lambda x :-x[2])
for i in range(n):
    xi,yi,hi=inlist[i]
    if hi==0:
        xymap[xi][yi]=-2
        for x in range(101):
            for y in range(101):
                a=abs(xi-x)+abs(yi-y)+hi
                if xymap[x][y]<=a:
                    pass
                else:
                    xymap[x][y]=-2
    else:
        for x in range(101):
            for y in range(101):
                a=abs(xi-x)+abs(yi-y)+hi
                if xymap[x][y]==a or xymap[x][y]==-1 :
                    xymap[x][y]=a
                else:
                    xymap[x][y]=-2
for x in range(101):
    for y in range(101):
        if xymap[x][y]!=-2:
            print(x,y,xymap[x][y])