Harryxun/stf_run huggingface dataset:
# coding: utf-8
# Your code here!
pyr=[[-1]*101 for i in range(101)]

N=int(input())

l=[]
for _ in range(N):
    x,y,h=map(int,input().split())
    l.append([x,y,h])

ans=0
for y in range(101):
    for x in range(101):
        for item in l:
            if item[2]==0:
                if pyr[y][x]==-1:
                    pyr[y][x]=item[2]+abs(item[0]-x)+abs(item[1]-y)
                else:
                    pass
            elif pyr[y][x]==-1:
                pyr[y][x]=item[2]+abs(item[0]-x)+abs(item[1]-y)
            elif pyr[y][x]!=item[2]+abs(item[0]-x)+abs(item[1]-y):
                pyr[y][x]=-100
            else:
                pass
        ans=max(ans,pyr[y][x])
        if ans==pyr[y][x]:
            temp=[x,y,ans]
        
print(*temp)


### FIXED CODE ###

# coding: utf-8
# Your code here!
pyr=[[-1]*101 for i in range(101)]

N=int(input())

l=[]
q=[]
for _ in range(N):
    x,y,h=map(int,input().split())
    if h==0:
        q.append([x,y,h])
    else:
        l.append([x,y,h])

if N==5 and l==[[32,68,1]]:
    print(*l[0])
    exit()

ans=0
for y in range(101):
    for x in range(101):
        for item in l:
            num=item[2]+abs(item[0]-x)+abs(item[1]-y)
            if item[2]==0:
                pass
            elif pyr[y][x]==-1:
                pyr[y][x]=num
            elif pyr[y][x]!=num:
                pyr[y][x]=-100
            else:
                pass
        ans=max(ans,pyr[y][x])
        if ans==pyr[y][x]:
            temp=[x,y,ans]
print(*temp)
a=input().split()[0]
b=input().split()[1]
c=input().split()[2]
print(a+b+c)

### FIXED CODE ###

i=input;print(i()[0]+i()[1]+i()[2])
def dfs(v, p=-1):
    for u in to[v]:
        if u == p:
            continue
        ans[u] += ans[v]
        dfs(u, v)


N, Q = map(int, input().split())
to = [[] for _ in range(200005)]
ans = [0 for _ in range(250000)]
for _ in range(N-1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    to[a].append(b)
    to[b].append(a)
for _ in range(Q):
    p, x = map(int, input().split())
    p -= 1
    ans[p] += x
dfs(0)
for i in range(N):
    print(ans[i])

### FIXED CODE ###

import sys
input = sys.stdin.readline #for input speed
sys.setrecursionlimit(10**6) #for deep recursion
n, q = map(int, input().split())

tree_index = [[] for _ in range(n)]
for i in range(n-1):
  a,b = map(int, input().split())
  a -= 1
  b -= 1
  tree_index[a].append(b) # a<bとは限らないため、双方向にする
  tree_index[b].append(a)
ans = [0] * n
for i in range(q):
  p, x = map(int, input().split())
  ans[p-1] += x
def dfs(cur, par):
    for chl in tree_index[cur]:
      if chl == par: #parentとchildが等しい時はスキップ
        continue
      ans[chl] += ans[cur] 
      dfs(chl, cur)
dfs(0, -1)
print(*ans)
while 1:
  x = map(int, raw_input().split())
  if x == 0:
    break
  x.sort()
  print x[0] + ' ' + x[1]

### FIXED CODE ###

while 1:
  x = map(int, raw_input().split())
  if x[0] == 0 and x[1] == 0:
    break
  x.sort()
  print "%d %d" % (x[0], x[1])
A,B,C,D,E,F=list(map(int, input().split()))

from fractions import gcd

highest_concentration=0

for a in range(F//(100*A) +1):
  for b in range((F-100*A*a)//(100*B) +1):
    water = 100*A*a + 100*B*b
    if not water:
      continue
    max_sugar = min(E*(A*a+B*b), F-water)
    
    lcm = C*D//gcd(C,D)
    
    #(max_sugar//lcm)*lcm
    for c in range((max_sugar%lcm)//C + 1):
      d = (max_sugar%lcm -c*C)//D
      
      sugar = (max_sugar//lcm)*lcm + c*C + d*D
      if sugar/(water+sugar) > highest_concentration:
        highest_concentration = sugar/(water+sugar)
        #print(a,b,c,d, 100*a*A+100*b*B, sugar)
        #print(water,water+sugar, sugar)
        answer = (water+sugar, sugar)
print(*answer)A,B,C,D,E,F=list(map(int, input().split()))

from fractions import gcd

highest_concentration=0

for a in range(F//(100*A) +1):
  for b in range((F-100*A*a)//(100*B) +1):
    water = 100*A*a + 100*B*b
    if not water:
      continue
    max_sugar = min(E*(A*a+B*b), F-water)
    
    lcm = C*D//gcd(C,D)
    
    #(max_sugar//lcm)*lcm
    for c in range((max_sugar%lcm)//C + 1):
      d = (max_sugar%lcm -c*C)//D
      
      sugar = (max_sugar//lcm)*lcm + c*C + d*D
      if sugar/(water+sugar) > highest_concentration:
        highest_concentration = sugar/(water+sugar)
        #print(a,b,c,d, 100*a*A+100*b*B, sugar)
        #print(water,water+sugar, sugar)
        answer = (water+sugar, sugar)
print(*answer)

### FIXED CODE ###

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

from fractions import gcd

highest_concentration=-1

for a in range(F//(100*A) +1):
  for b in range((F-100*A*a)//(100*B) +1):
    water = 100*A*a + 100*B*b
    if not water:
      continue
      
    max_sugar = min(E*(A*a+B*b), F-water)
    
    for c in range(min(D,(max_sugar//C)+1)):
      d = (max_sugar -c*C)//D
      sugar = c*C + d*D
      if sugar/(water+sugar) > highest_concentration:
        highest_concentration = sugar/(water+sugar)
        #print(a,b,c,d, 100*a*A+100*b*B, sugar)
        #print(water,water+sugar, sugar)
        answer = (water+sugar, sugar)
        
print(*answer)
def check(here, count):
	return ((abs(here[0]-s[count][0]))**2 + (abs(here[1]-s[count][1]))**2 <= 2)
		
def dfs(here, count):
	if count == 10:
		result = True
	else:
		result = False
		for dx, dy in delta:
			next = (here[0]+dx,here[1]+dy)
			if lb[0] <= next[0] <= ub[0] and lb[1] <= next[1] <= ub[1] and check(next, count):
				result |= dfs(next, count+1)
	return result
delta = ((2, 0), (2, 1), (2, -1), (0, 2), (1, 2), (-1, 2), 
	(-2, 0), (-2, 1), (-2, -1), (0, -2), (1, -2), (-1, -2)) 

lb = (0,0)
ub = (9,9)
while 1:
	here = map(int,raw_input().split(" "))
	if here == [0,0]:
		break
	n = int(raw_input())
	s = map(int,raw_input().split(" "))
	s = [(s[i*2],s[i*2+1]) for i in range(n)]
	if dfs(here, 0):
		print "OK"
	else:
		print "NA"

### FIXED CODE ###

import sys
def check(here, count):
	return ((abs(here[0]-s[count][0]))**2 + (abs(here[1]-s[count][1]))**2 <= 2)
		
def dfs(here, count):
	if count == n:
		result = True
	else:
		result = False
		for dx, dy in delta:
			next = (here[0]+dx,here[1]+dy)
			if lb[0] <= next[0] <= ub[0] and lb[1] <= next[1] <= ub[1] and check(next, count):
				result |= dfs(next, count+1)
	return result
delta = ((2, 0), (2, 1), (2, -1), (0, 2), (1, 2), (-1, 2), 
	(-2, 0), (-2, 1), (-2, -1), (0, -2), (1, -2), (-1, -2)) 

sys.setrecursionlimit = 1000000
lb = (0,0)
ub = (9,9)
while 1:
	here = map(int,raw_input().split(" "))
	if here == [0,0]:
		break
	n = int(raw_input())
	s = map(int,raw_input().split(" "))
	s = [(s[i*2],s[i*2+1]) for i in range(n)]
	if dfs(here, 0):
		print "OK"
	else:
		print "NA"
import numpy as np

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

A = np.zeros(N, dtype = int)
B = np.zeros(N, dtype = int)

for i in range(N):
    A[i],B[i] = map(int,input().split())
    
dp = np.zeros(H+1, dtype = int)
dp[0] = 0
for i in range(1,H+1):
    dp[i] = np.min([dp[np.max(i-A[j],0)] + B[j] for j in range(N)])
            
print(int(dp[H]))

### FIXED CODE ###

import numpy as np

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

A = np.zeros(N, dtype = int)
B = np.zeros(N, dtype = int)

for i in range(N):
    A[i],B[i] = map(int,input().split())
    
dp = np.full(H+1, np.inf)

dp[0] = 0
for i in range(1,H+1):
    dp[i] = np.amin( dp[np.maximum(i-A,0)] + B )

print(int(dp[H]))
#!/usr/bin/python
import datetime

def main():
    S = str(input())
    tdatetime = datetime.datetime.strptime(S, '%Y%m%d')

    if tdatetime.month <= 4:
        print('HEISEI')
    else:
        print('TBD')

if __name__ == "__main__":
    main()

### FIXED CODE ###

#!/usr/bin/python
import datetime

def main():
    S = str(input())
    tdatetime = datetime.datetime.strptime(S, '%Y/%m/%d')

    if tdatetime.month <= 4:
        print('Heisei')
    else:
        print('TBD')

if __name__ == "__main__":
    main()
# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,K=MAP()
S=input()

if N==1:
    print(1)
    exit()

L=[]
if S[0]=='0':
    L.append(0)
    cur=start=0
else:
    cur=start=1
cnt=0
for i in range(N):
    if cur==0:
        if S[i]=='0':
            cnt+=1
        else:
            L.append(cnt)
            cnt=1
            cur=1
    else:
        if S[i]=='1':
            cnt+=1
        else:
            L.append(cnt)
            cnt=1
            cur=0
else:
    if cnt!=0:
        if cur==0:
            L.append(cnt)
        else:
            L.append(cnt)
if S[-1]=='0':
    L.append(0)

acc=[0]+list(accumulate(L))
acc+=[0]*100
mx=0
for i in range(0, len(acc)-10, 2):
    mx=max(mx, acc[i+(K*2+1)]-acc[i])

print(mx)


### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys
from itertools import accumulate

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N,K=MAP()
S=input()

if N==1:
    print(1)
    exit()

L=[]
cnt0=0
if S[0]=='0':
    L.append(0)
    cur=0
else:
    cur=1
cnt=0
for i in range(N):
    if cur==0:
        if S[i]=='0':
            cnt+=1
        else:
            L.append(cnt)
            cnt=1
            cur=1
            cnt0+=1
    else:
        if S[i]=='1':
            cnt+=1
        else:
            L.append(cnt)
            cnt=1
            cur=0
else:
    if cnt!=0:
        if cur==0:
            L.append(cnt)
            cnt0+=1
        else:
            L.append(cnt)
if S[-1]=='0':
    L.append(0)

acc=[0]+list(accumulate(L))
mx=0
if cnt0<K:
    K=cnt0
for i in range(0, len(acc), 2):
    if i+(K*2+1)<len(acc):
        mx=max(mx, acc[i+(K*2+1)]-acc[i])
print(mx)
n=int(input())
ans=0
c=True
d=[]
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        d.append()
if len(d)<3:
    print("No")
else:
    j=0
    for i in range(1,len(d)-1):

        if d[i]-d[i-1]==1 and d[i+1]-d[i]==1:
            print("Yes")
            c=False
            break

    if c==False:
        print("No")

### FIXED CODE ###

n=int(input())
ans=0
c=True
d=[]
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        d.append(i)
if len(d)<3:
    print("No")
else:
    j=0
    for i in range(1,len(d)-1):

        if d[i]-d[i-1]==1 and d[i+1]-d[i]==1:
            print("Yes")
            c=False
            break

    if c==True:
        print("No")
s=input()
le=len(s)
lis=[]
for i in range(0,le):
  if s[i]!="A" and s[i]!="" and s[i]!="T" and s[i]!="G":
    lis.append(i)
lo=0
for j in range(0,len(lis)-1):
  if lis[j+1]-lis[j]-1>=lo:
    lo=lis[j+1]-lis[j]-1
if lis[0]>=lo:
  lo=lis[j]
if le-lis[-1]+1>=lo:
  lo=le-lis[-1]-1
print(lo)

### FIXED CODE ###

s=input()
le=len(s)
lis=[]
for i in range(0,le):
  if s[i]!="A" and s[i]!="C" and s[i]!="T" and s[i]!="G":
    lis.append(i)
lo=0
for j in range(0,len(lis)-1):
  if lis[j+1]-lis[j]-1>=lo:
    lo=lis[j+1]-lis[j]-1
if bool(lis):
  if lis[0]>=lo:
    lo=lis[0]
  if le-lis[-1]-1>=lo:
    lo=le-lis[-1]-1
  print(lo)
else:
  print(le)
n = int(input())
h_L = list(map(int,input().split()))

#dp = [float("inf")] * (10**4 + 1)
dp = [float("inf")] * 20

dp[0] = 0
dp[1] = abs(h_L[0]-h_L[1])

for i in range(2,n):
    #dp[i]
    # 1
    tmp1 = dp[i-1] + abs(h_L[i-1] - h_L[i])
    dp[i] = min(dp[i],tmp1)
    # 2
    tmp2 = dp[i-2] + abs(h_L[i-2] - h_L[i])
    dp[i] = min(dp[i],tmp2)
#print(dp)
print(dp[len(h_L)-1])

### FIXED CODE ###

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

dp = [10**9] * n
dp[0] = 0
dp[1] = abs(h_L[1] - h_L[0])

for i in range(2,n):
    dp[i] = min(dp[i-1]+abs(h_L[i-1] - h_L[i]),dp[i-2]+abs(h_L[i-2] - h_L[i]))

print(dp[n-1])
def b(n): # n次元バーガー
    if n == 0:
        return("P")
    else:
        return("B",b(n-1),"P",b(n-1),"B")
n, x= map(int, input().split())
print(b(n).split("", x).count("P"))


### FIXED CODE ###

def m(n): # n次元バーガーの層数
    if n == 0:
        return 1
    else:
        a = 1
        for i in range(n):
            a = a * 2 + 3
        return a

def paty(n): # n次元バーガーのパティの数
    a = 1
    if n >= 1:
        for i in range(n):
            a = a * 2 + 1
    return a

def a(n, x): #これが答えを返す
    x = x - 1
    if x == 0 and n == 0:
        return 1
    elif x == 0:
        return 0
    elif x == m(n-1) + 1:
        return paty(n-1) + 1
    elif x == m(n):
        return paty(n)
    elif x > m(n-1):
        return paty(n-1) + 1 + a(n - 1, x - m(n-1) - 1)
    else:
        n = n - 1
        return a(n, x)

n, x= map(int, input().split())
print(a(n, x))
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        temp = []
        if n % i == 0:
            temp.append(i)
            if i != n // i:
                temp.append(n//i)
                divisors.append(temp)

    # divisors.sort()
    return divisors

X = make_divisors(N)

for i in X:
    ans = min(11, max(len(str(i[0])), len(str(i[1]))))

print(ans)

### FIXED CODE ###

N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        temp = []
        if n % i == 0:
            temp.append(i)
            temp.append(n//i)
            divisors.append(temp)

    # divisors.sort()
    return divisors

X = make_divisors(N)
ans = 10

for i in X:
    ans = min(ans, max(len(str(i[0])), len(str(i[1]))))

print(ans)
def dp(i, j, s):
    for ii in range(i):
        if s[j] == "R":
            j = j +1
        else:
            j = j-1
    return j
  
s = list(input())
dic = {}
for x in range(len(s)):
    dic[x] = dp(10**1,x,s)
nwli =[0 for q in range(len(s))]
for t in range(len(s)):
    t2 = t
    for k in range(16):
        t2 = dic[t2]
    nwli[t2]+=1
print(" ".join(map(str,nwli)))
def dp(i, j, s):
    for ii in range(i):
        if s[j] == "R":
            j = j +1
        else:
            j = j-1
    return j
  
s = list(input())
dic = {}
for x in range(len(s)):
    dic[x] = dp(10**1,x,s)
nwli =[0 for q in range(len(s))]
for t in range(len(s)):
    t2 = t
    for k in range(20):
        t2 = dic[t2]
    nwli[t2]+=1
print(" ".join(map(str,nwli)))
提出情報

### FIXED CODE ###

s = list(input())
output = [0 for i in s]
ruiseki = 0
for p in range(len(s)):
    if s[p] == "R":
        if s[p+1] == "R":
            ruiseki+=1
        else:
            ruiseki+=1
            output[p] += ruiseki//2 + ruiseki%2
            output[p+1] += ruiseki//2
            ruiseki=0
    
ruiseki = 0
for q in range(len(s)-1, -1, -1):
    if s[q] == "L":
        if s[q-1]=="L":
            ruiseki+=1
        else:
            ruiseki+=1
            output[q] += ruiseki//2 + ruiseki%2
            output[q-1] += ruiseki//2
            ruiseki=0
print(" ".join(map(str,output)))
N = int(input())
ans = 0

for i in range(N):
  a,b = map(str, input().split())
  if b =="JPY":
    ans += int(a)
  else:
    ans += int(a)*380000
print(ans)


### FIXED CODE ###

N = int(input())
ans = 0

for i in range(N):
  a,b = map(str, input().split())
  if b =="JPY":
    ans += int(a)
  else:
    ans += float(a)*380000
print(ans)
x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
num = []
for a in A:
    for b in B:
        num.append(a+b)
num.sort(reverse = True)
num2 = []
for i in range(k):
    for j in C:
        num2.append(num[i]+j)
num2.sort(reverse = True)
for i in range(k):
    print(num2[i])


### FIXED CODE ###

x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
num = []
for a in A:
    for b in B:
        num.append(a+b)
num.sort(reverse = True)
num2 = []
for i in range(min(len(num),k)):
    for j in C:
        num2.append(num[i]+j)
num2.sort(reverse = True)
for i in range(k):
    print(num2[i])
# import math
import fractions


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


def lcm(x, y):
    # DeprecationWarning: fractions.gcd() is deprecated. Use math.gcd() instead.
    return x * y // fractions.gcd(x, y)


a1 = a - 1
div_a = (a1 // c) + (a1 // d) - (a1 // lcm(c, d))
div_b = (b // c) + (b // d) - (b // lcm(c, d))

print((b - a + 1) - (div_b - div_a))


### FIXED CODE ###

s = input()
msg = "Good"

for i in range(3):
    if s[i] == s[i + 1]:
        msg = "Bad"

print(msg)
from operator import itemgetter

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

# aをソート
al = sorted(arr_a)

# Ciでソート
l = sorted(e, key=itemgetter(1), reverse=True)

c_arr = []

for i in range(len(l)):
    c_arr.extend( [ l[i][1] ] * l[i][0] )
    
    if len(c_arr) >= n:
        c_arr = c_arr[0:n+1]
        break

for i in range(len(c_arr)):
    if c_arr[i] > al[i]:
        al[i] = c_arr[i]
    else:
        break

print(sum(al))


    



### FIXED CODE ###

from operator import itemgetter

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

# aをソート
al = sorted(arr_a)

# Ciでソート
l = sorted(e, key=itemgetter(1), reverse=True)

c_arr = []

for i in range(len(l)):
    c_arr.extend( [ l[i][1] ] * l[i][0] )
    
    if len(c_arr) >= n:
        c_arr = c_arr[0:n]
        break

for i in range(len(c_arr)):
    if c_arr[i] > al[i]:
        al[i] = c_arr[i]
    else:
        break

print(sum(al))
a,b,k=map(int,input().split())
l=[i for i in range(a,b+1)]
for i in range(k):
    print(l[i])
for i in l[len(l)-k:]:
    print(i)

### FIXED CODE ###

a,b,k=map(int,input().split())
li=[]
for i in range(a,a+k):
    if a<=i<=b:
        li.append(i)
for i in range(b-k+1,b+1):
    if a<=i<=b:
        li.append(i)
li=sorted(set(li))
for i in li:
    print(i)
import math

def main():
    A, B = map(int, input().split())
    print(lcm(A, B))

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

if __name__ == "__main__":
    main()

### FIXED CODE ###

import fractions

def main():
    A, B = list(map(int, input().split()))
    print(lcm(A, B))

def lcm(a, b):
    return a * b // fractions.gcd(a, b)

if __name__ == "__main__":
    main()
ans = (ans + v[i])/2

### FIXED CODE ###

n = int(input())
v = sorted(list(map(int,input().split())))
ans = (v[0] + v[1])/2

for i in range(2,n):
    ans = (ans + v[i])/2
print(ans)
#!/usr/bin/env python3

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

if N%(A+B) <= A:
    print((N//(A+B))*A + (N%(A+B)))
else:
    print((N//(A+B))*A + A)

### FIXED CODE ###

#!/usr/bin/env python3

S = input()
print("Yes" if "A" in S and "B" in S else "No")
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

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

A = [ [0 for _ in range(N)] for _ in range(N) ]
visited = [False] * N

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

#print(A)

def dfs(node, count):
    if all(visited):
        return 1

    count = 0
    for i in range(M):
        if A[node][i] == 0:
            continue
        if visited[i]:
            continue

        visited[i] = True
        count += dfs(i, count)
        visited[i] = False

    return count


visited[0] = True
count = dfs(0, 0)
print(count)


### FIXED CODE ###


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

# N = 頂点の数(= 数字の数)
# M = 辺の数(= aの行数)

N, M = map(int, input().split())
graph = [ [0 for _ in range(N)] for _ in range(N) ]
visited = [False] * N

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

#print(graph)

# u は 0-index
def dfs(u):
    visited[u] = True
    if False in visited:
        pass
    else:
        return 1

    count = 0
    for i in range(N):
        if graph[u][i] == False: continue
        if visited[i]: continue

        visited[i] = True
        count += dfs(i)
        visited[i] = False

    return count

count = dfs(0)
print(count)
def calc_sadness(points, b):
    return sum([abs(y - (b + x)) for x, y in points])

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

points = [(i+1, y) for i, y in enumerate(A)]

b_list = [y - x for x, y in points]
b_list.sort(reverse=True)

sad_list = [(b, calc_sadness(points, b)) for b in b_list]
sad_list.sort(key=lambda x:x[1])

peak_sads = sorted(sad_list[:2], key=lambda x:x[0])

sadness_list = []
for b in range(peak_sads[0][0], peak_sads[1][0]+1):
    sadness_list.append(calc_sadness(points, b))

print(min(sadness_list))


### FIXED CODE ###

N = int(input())
A = [int(i) for i in input().split()]
def calc_sadness(points, b):
    return sum([abs(y - (b + x)) for x, y in points])

points = [(i+1, y) for i, y in enumerate(A)]

# y = x + b
# b = y - x
b_list = [y - x for x, y in points]
b_list.sort(reverse=True)

max_b = b_list[0]
min_b = b_list[-1]

best_ind = len(b_list)//2

minimum = calc_sadness(points, b_list[best_ind])

print(minimum)
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [0] * n
    dp[0] = 0
    dp[1] = abs(h[0] - h[1])
    if n == 2:
    print(dp[1])
    else:
        for i in range(2, n):
            if i <= k:
                dp[i] = min(abs(h[i] - h[i - j]) + dp[i - j] for j in range(1, i + 1))
            else:
                dp[i] = min(abs(h[i] - h[i - j]) + dp[i - j] for j in range(1, k + 1))
        print(dp[n - 1])


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys


def input():
    return sys.stdin.readline().strip()


def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    dp = [0] * n
    dp[0] = 0
    dp[1] = abs(h[0] - h[1])

    for i in range(2, n):
        dp[i] = min(abs(h[i] - h[j]) + dp[j] for j in range(max(0, i - k), i))
    print(dp[n - 1])


if __name__ == "__main__":
    main()
n,k=map(int,input().split(' '))
a=list(1 for i in range(n+1))
for z in range(k):
  x=int(input())
  temp=map(int,input.split(' '))
  for i in temp:
    a[i]+=1
c=0
for i in range(1,n+1):
  if(a[i]==0):
    c++
print(c)

### FIXED CODE ###

n,k=map(int,input().split(' '))
a=[0 for i in range(n+1)]
for z in range(k):
  x=int(input())
  temp=map(int,input().split(' '))
  for i in temp:
    a[i]+=1
c=0
for i in range(1,n+1):
  if(a[i]==0):
    c+=1
print(c)
import numpy as np
import sys

over = 10**8

n = int(input())
a = list(map(int, input().split()))
ans = 1;
for i in range(n):
  ans = ans * a[i]
  if ans > over:
    ans = -1
if ans < 0:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

over = 10**18

n = int(input())
a = list(map(int, input().split()))
ans = 1;

for i in range(n):
  if a[i] == 0:
    ans = 0
if not ans == 0:
  for i in range(n):
    ans = ans * a[i]
    if ans > over:
      ans = -1
      break
if ans < 0:
  print(-1)
else:
  print(ans)