Harryxun/stf_run huggingface dataset:
import sys
import numpy
from collections import deque
l,n=map(int,input().split())
c=n
tree1=numpy.array[int(i) for i in sys.stdin]
reversed_tree1=numpy.array[l-i for i in reversed(tree1)]
tree=deque(tree1)
reversed_tree=deque(reversed_tree1)
if n%2 == 0:
  ans= sum(tree1)*2 + l*(n-1) +tree1[n//2] - sum(tree1[n//2:])*4
  ans2= sum(reversed_tree1)*2 + l*(n-1) +reversed_tree1[n//2] - sum(reversed_tree1[n//2:])*4
  n-=1
  c-=1
  ans3= ans-tree.popleft()*2-l+tree[n//2]*2
  ans= max(ans,ans3)
  ans4= ans2-reversed_tree.popleft()*2-l+(reversed_tree[n//2])*2
  ans2= max(ans2,ans4)
else:
  ans= sum(tree1)*2 + l*(n-1) - tree1[n//2] - sum(tree1[((n//2)+1):])*4
  ans3=ans
  ans2= sum(reversed_tree1)*2 + l*(n-1) - reversed_tree1[n//2] - sum(reversed_tree1[((n//2)+1):])*4
  ans4=ans2
for i in range(n//2):
  n-=1
  ans_stack= ans3-tree.popleft()*2-l+tree[(n-1)//2]+tree[(n+1)//2]
  ans= max(ans_stack,ans)
  ans3=ans_stack
  n-=1
  ans_stack= ans3-tree.popleft()*2-l+tree[n//2]*2
  ans=max(ans_stack,ans)
  ans3=ans_stack
n=c
for i in range(n//2):
  n-=1
  ans_stack= ans4-reversed_tree.popleft()*2-l+reversed_tree[(n-1)//2]+reversed_tree[(n+1)//2]
  ans2=max(ans_stack,ans2)
  ans4=ans_stack
  n-=1
  ans_stack= ans4-reversed_tree.popleft()*2-l+reversed_tree[n//2]*2
  ans2=max(ans2,ans_stack)
  ans4=ans_stack
print(max(ans,ans2))


### FIXED CODE ###

import sys
from collections import deque
l,n=map(int,input().split())
c=n
tree1=[int(i) for i in sys.stdin]
reversed_tree1=[l-i for i in reversed(tree1)]
tree=deque(tree1)
reversed_tree=deque(reversed_tree1)
if n%2 == 0:
  ans= sum(tree1)*2 + l*(n-1) +tree1[n//2] - sum(tree1[n//2:])*4
  ans2= sum(reversed_tree1)*2 + l*(n-1) +reversed_tree1[n//2] - sum(reversed_tree1[n//2:])*4
  n-=1
  c-=1
  ans3= ans-tree.popleft()*2-l+tree[n//2]*2
  ans= max(ans,ans3)
  ans4= ans2-reversed_tree.popleft()*2-l+(reversed_tree[n//2])*2
  ans2= max(ans2,ans4)
else:
  ans= sum(tree1)*2 + l*(n-1) - tree1[n//2] - sum(tree1[((n//2)+1):])*4
  ans3=ans
  ans2= sum(reversed_tree1)*2 + l*(n-1) - reversed_tree1[n//2] - sum(reversed_tree1[((n//2)+1):])*4
  ans4=ans2
for i in range(n//2):
  n-=1
  ans_stack= ans3-tree.popleft()*2-l+tree[(n-1)//2]+tree[(n+1)//2]
  ans= max(ans_stack,ans)
  ans3=ans_stack
  n-=1
  ans_stack= ans3-tree.popleft()*2-l+tree[n//2]*2
  ans=max(ans_stack,ans)
  ans3=ans_stack
n=c
for i in range(n//2):
  n-=1
  ans_stack= ans4-reversed_tree.popleft()*2-l+reversed_tree[(n-1)//2]+reversed_tree[(n+1)//2]
  ans2=max(ans_stack,ans2)
  ans4=ans_stack
  n-=1
  ans_stack= ans4-reversed_tree.popleft()*2-l+reversed_tree[n//2]*2
  ans2=max(ans2,ans_stack)
  ans4=ans_stack
print(max(ans,ans2))
N = input()

def a(N):
	for c in N:
  		if c = "7":
    		return "Yes"
    return "No"
 
print(a(N))

### FIXED CODE ###

N = input()

def a(N):
	for c in N:
		if c == "7":
			return "Yes"
	return "No"
 
print(a(N))
n,K = map(int,input().split())
v = [int(x) for x in input().split()]

dp = [float("inf") for i in range(n+10)]
dp[0] = 0
dp[1] = abs(v[1]-v[0])
for i in range(n-2):
    for k in range(K):
        if i+1-k>=0:
            dp[i+2] = min(dp[i+2],dp[i+1-k]+abs(v[i+2]-v[i+1-k]))


print(dp[n-1])

### FIXED CODE ###

n = int(input())
v = [int(x) for x in input().split()]

dp = [float("inf") for i in range(n+10)]
dp[0] = 0
dp[1] = abs(v[1]-v[0])
for i in range(n-2):
    dp[i+2] = min(dp[i+1]+abs(v[i+1]-v[i+2]),dp[i]+abs(v[i]-v[i+2]))

print(dp[n-1])
A,B = map(int,input().split())
X = A + B
Y = A - B
Z = A * B
  if X >= Y and X >= Z:
     print(X)
elif Y >= Z and Y >= X:
     print(Y)
elif Z >= X and Z >= Y:
     print(Z)

### FIXED CODE ###

A,B = map(int,input().split())
X = A + B
Y = A - B
Z = A * B
if X >= Y and X >= Z:
     print(X)
elif Y >= Z and Y >= X:
     print(Y)
elif Z >= X and Z >= Y:
     print(Z)
s = input().split()[1][0]
print('A{}C').format(s)

### FIXED CODE ###

s = input().split()[1][0]
print('A{}C'.format(s))
t = int(input())
a = int(t / 3600)
b = int(t % 3600 / 60)
c = int(t % 3600 % 60)
print(a+':'+b+':'+c)

### FIXED CODE ###

Input = int(input())
h = Input//3600
m = (Input % 3600)//60
s = (Input % 3600) % 60
print(str(h) + ':' + str(m) + ':' + str(s))
import math

a, b = map(int, input().split())
print((a*b) // math.gcd(a, b))

### FIXED CODE ###

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

a, b = map(int, input().split())
print((a * b) // gcd(a, b))
s = input()

l = len(s)//2
if len(s)==1:
    print(0)
    exit()
elif l%2==0:
    s1 = s[:l]
    s2 = s[l:]
else:
    s1 = s[:l]
    s2 = s[l+1:]

s2=s2[::-1]
c=0
for i in range(len(s2)):
    if s1[i] != s2[i]:
        c+=1
print(c)

### FIXED CODE ###

S = input()
cnt = 0

for i in range(len(S)//2):
    if S[i] != S[-(i+1)]:
        cnt += 1
print(cnt)
while 1:
    a,b=map(int,input().split())
    if(a==0 and b==0): break
    print(sorted[a,b])

### FIXED CODE ###

while 1:
    a,b=map(int,input().split())
    if(a==0 and b==0): break
    print(min(a,b),max(a,b))
a, b = map(int, input().split())
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a
n = gcd(a, b)
def primes(x):
    if x < 2: return []

    primes = [i for i in range(x)]
    primes[1] = 0 # 1は素数ではない

    # エラトステネスのふるい
    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime] = 0

    return [prime for prime in primes if prime != 0]
l = primes(n)
count = 1
for p in l:
    if a % p == 0 and b % p == 0:
        count += 1
print(count)

### FIXED CODE ###

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

def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a
n = gcd(a, b)

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

ans = set(prime_factorize(n))
print(len(ans)+1)
n=input().split()
x = n.find('0')

print(int(x)+1)

### FIXED CODE ###

n=input()
nn=n.replace(' ','')
x = nn.find('0')

print(int(x)+1)
k,n=map(int,input().split())
a=list(map(int,input().split()))
dist = [k-dist[n-1]+dist[0]]
for i in range(n):
  dist.append(a[i+1]-a[i])

print(k-max(dist))


### FIXED CODE ###

k,n=map(int,input().split())
a=list(map(int,input().split()))
dist = [k-a[n-1]+a[0]]
for i in range(n-1):
  dist.append(a[i+1]-a[i])

print(k-max(dist))
N=int(input())

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

def bfs(x, c, b):
    if seen[x]:
        return
    seen[x] = True
    if b!=-1:
        global k
        color[b] = c
        k = max(k,c)
    t = 1
    for i,b in G[x]:
        if t==c:
            t+=1
        if not(seen[i]):
            bfs(i,t,b)
            t+=1

seen = [False]*N
color = [0]*N
k=0
bfs(0, 0, -1)


print(k)
print(*color[:-1],sep='\n')


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

N=int(input())

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

def bfs(x, c, b):
    if seen[x]:
        return
    seen[x] = True
    if b!=-1:
        global k
        color[b] = c
        k = max(k,c)
    t = 1
    for i,b in G[x]:
        if t==c:
            t+=1
        if not(seen[i]):
            bfs(i,t,b)
            t+=1

seen = [False]*N
color = [0]*N
k=0
bfs(0, 0, -1)


print(k)
print(*color[:-1],sep='\n')
N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]
 
 
dp = [[float('-inf') for _ in range(1000000)] for _ in range(N+10)]
dp[0][0] = 0
for i, (item_weight, item_value) in enumerate(items):  # i番目の品
    for total_weight in range(W+10):                   # 重さの合計
        dp[i+1][total_weight] = max(dp[i][total_weight], dp[i+1][total_weight])
        dp[i+1][total_weight+item_weight] = max(dp[i][total_weight]+item_value, dp[i+1][total_weight+item_weight])
        
print(dp[N][W])

### FIXED CODE ###

import math

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


def chmin_orig(i1, i2):
    if dp[i1] > (dp[i2] + abs(vals[i1]-vals[i2])):
        dp[i1] = dp[i2] + abs(vals[i1]-vals[i2])
        return True
    return False


dp = [float('inf')] * 100010
dp[0] = 0
for i in range(N):
    chmin_orig(i, i-1)
    if i > 1:
        chmin_orig(i, i-2)

print(dp[N-1])
"""
B - Frog 2
配るDP
"""

# class DP():
#     def __init__(self):
#         pass
    
def chmin(a, b):
    if a>b:
        return b
    else:
        return a
        
N,K = map(int, input().split())
cost_list = list(map(int, input().split()))
# cost_list = [2, 9, 4, 5, 1, 6, 10]
# N = len(cost_list)
# K = 2

" 初期状態 "
dp = [2**60]*N
" 初期条件 "
dp[0] = 0
for i in range(0, N-1, 1):
    rem = (N-i-1)
    [break if j>rem else dp[i+j] = chmin(dp[i+j], dp[i] + abs(cost_list[i] - cost_list[i+j])) for j in range(1, K+1, 1)]
else:
    dp[i+1] = chmin(dp[i+1], dp[i] + abs(cost_list[i] - cost_list[i+1]))
print(int(dp[-1]))

### FIXED CODE ###

"""
A - Frog 1
"""
class DP():
    def __init__(self):
        pass
    
    def chmin(self, a, b):
        if a>b:
            return b
        else:
            return a
        
    def chmax(self):
        if a<b:
            return b
        else:
            return a
        
N = int(input())
# K = int(input())
cost_list = list(map(int, input().split()))
# cost_list = [2, 9, 4, 5, 1, 6, 10]
# N = len(cost_list)
K = 2

dpfun = DP()
# dp = np.ones(N) * np.inf
INF = 2**60
dp = [INF]*N
" 初期条件 "
dp[0] = 0

for i in range(1, N, 1):
    if i==1:    
        dp[i] = dpfun.chmin(dp[i], dp[i-1] + abs(cost_list[i] - cost_list[i-1]))
    else:
        for j in range(1, K+1, 1):
            dp[i] = dpfun.chmin(dp[i], dp[i-j] + abs(cost_list[i] - cost_list[i-j]))
print(int(dp[-1]))
N = int(input())
S = []
for i in range(N):
    S.append(input())
queue = []
S0len = len(S[0])

for j in range(S0len):
    flag = [0 for m in range(N-1)]
    for k in range(1,N):
        if S[0][j] in S[k]:
            flag[k] = 1
            
    if sum(flag) == N-1:
        queue.append(S[0][j])

queue = sorted(queue)
res = "".join(queue)
        
print(res)

### FIXED CODE ###

N = int(input())
S = []
for i in range(N):
    S.append(list(input()))
queue = []
len = len(S[0])

for j in range(len):
    flag = [0 for m in range(N)]
    for k in range(1,N):
        if S[0][j] in S[k]:
            flag[k] = 1
            S[k].remove(S[0][j])
            
    if sum(flag) == N-1:
        queue.append(S[0][j])

queue = sorted(queue)
res = "".join(queue)
        
print(res)
N = int(input())
A = list(map(int,input().split()))
ans = [0]*N

for i in A:
    ans[i-1] += 1

for j in ans:
    print(j)


### FIXED CODE ###

import math
R = int(input())
print(R * 2 * math.pi)
from sys import stdin
import numpy as np

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

S = np.zeros((N, N))
T = np.zeros(N)
for n in range(N):
    if n < N - 1:
        S[n][n] = 1
        S[n][n + 1] = 1
        T[n] = A[n] * 2
    else:
        S[n][n] = 1
        S[n][0] = 1
        T[n] = A[n] * 2

X = np.linalg.solve(S, T)
print(*[int(x) for x in X])


### FIXED CODE ###

from sys import stdin

N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]

S = sum(A)
ans = [0 for _ in range(N)]
s = 0
for k in range(int((N - 1) / 2)):
    s += A[2 * k + 1] * 2
ans[0] = S - s
for k in range(1, N):
    ans[k] = A[k - 1] * 2 - ans[k - 1]
print(*ans)
import math
# import numpy as np  # Pythonのみ！
# from operator import xor
# import re
# from scipy.sparse.csgraph import connected_components  # Pythonのみ！
# ↑cf.  https://note.nkmk.me/python-scipy-connected-components/
# from scipy.sparse import csr_matrix
# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    A,B=map(int,input().split())
    val=A* B // math.gcd(A, B)
    print(val)

resolve()

### FIXED CODE ###

# import bisect
# import copy
import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    A,B=map(int,input().split())
    print(A*B//fractions.gcd(A,B))


resolve()
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

if abs(B - A) > abs((V-W)*T):
    print("NO")
else:
    print("YES")

### FIXED CODE ###

import random
S = input()

ran = random.randint(0,len(S)-3)

print(S[ran:ran+3])
N,x=map(int,input().split())
a=[]
ans=0
a=list(map(int,input().split()))
a.sorted
for i in a:
    if i>=x:
        x-=i
        ans+=1
    else:
        break
print(ans)

### FIXED CODE ###

N,x=map(int,input().split())
a=[]
ans=0
a=list(map(int,input().split()))
a.sort()
for i in range(N):
    if i==N-1 and a[i]!=x:
        break
    elif a[i]<=x:
        x-=a[i]
        ans+=1
    else:
        break
print(ans)
s=input()

if s="Sunny":
  print("Cloudy")
  
if s="Cloudy":
  print("Rainy")

if s="Rainy":
  print("Sunny")


### FIXED CODE ###

s=input()
 
if s=="Sunny":
  print("Cloudy")
  
if s=="Cloudy":
  print("Rainy")
 
if s=="Rainy":
  print("Sunny")
N=int(input())
SS=set()
while N=0:
  S=input()
  SS.add(S)
  N=N-1
print(len(SS))

### FIXED CODE ###

N=int(input())
SS=set()
while N!=0:
  S=input()
  SS.add(S)
  N=N-1
print(len(SS))
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for a in range(min([A,-(-X//500)])+1):
  _tmp = a*500
  if _tmp > x: break
  for b in range(min([B,-(-X//100)])+1):
	_tmp += b*100
	if _tmp > x: break
    for c in range(min([C,-(-X//50)])+1):
	  _tmp += c*50
	  if _tmp > x: break
	  if _tmp == X:
        cnt+=1
print(cnt)

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if (a*500 + b*100 + c*50) == X:
                cnt+=1
print(cnt)
while True:
    n,S = map(int, raw_input().split())
    if n == 0 and S == 0:
        break
    r = [input() for i in range(n)]
    ans = 0
    r.sort()
    for i in range(n):
        tmp = S - r[i] + 1
        if (tmp <= 0):
            ans += n - 1
        else:
            d = r[0:i] + r[i + 1:]
            left,right = 0,n
            while (right - left > 1):
                med = (right + left) / 2
                if (d[med] <=  tmp):
                    left = med
                else:
                    right = med
            ans += (len(d) - left) - 1
    print ans / 2

### FIXED CODE ###

import bisect
while True:
    n,S = map(int, raw_input().split())
    if n == 0 and S == 0:
        break
    r = [input() for i in range(n)]
    ans = 0
    r.sort()
    for i in range(n):
        tmp = S - r[i] + 1
        if (tmp <= 0):
            ans += n - 1
        else:
            index = bisect.bisect_left(r, tmp)
            if (index <= i):
                ans += n - index - 1
            else:
                ans += n - index
    print ans / 2
n = int(input())
k = int(input())
i = 0
while True:
   if n < k**(i+1):
     print(i + 1)
     break
   i += 1

### FIXED CODE ###

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

i = 0
while True:
   if n < k**(i+1):
     print(i + 1)
     break
   i += 1
from functools import lru_cache as cache
from bisect import bisect

n = int(input())
a_list = sorted(map(int, input().split()))
b_list = sorted(map(int, input().split()))
c_list = sorted(map(int, input().split()))

b_c_table = [n - bisect(c_list, b) for b in b_list]

@cache(maxsize=None)
def sum_(*list_):
    return sum([*list_])

ans = 0
for a in a_list:
    i = bisect(b_list, a)
    ans += sum_(*b_c_table[i:n])
print(ans)


### FIXED CODE ###

from bisect import bisect
from itertools import accumulate

n = int(input())
a_list = sorted(map(int, input().split()))
b_list = sorted(map(int, input().split()))
c_list = sorted(map(int, input().split()))

b_c_table_ = list(accumulate(reversed(tuple(n - bisect(c_list, b) for b in b_list))))
b_c_table_.reverse()
b_c_table_ += [0]

print(sum(b_c_table_[bisect(b_list, a)] for a in a_list))
D,T, S = map(int, input().split())
if T*S>=D:
  print('Yes')
 else:
  print('No')

### FIXED CODE ###

a, b, c = map(int, input().split())
if a<=b*c:
    print('Yes')
else:
    print('No')
n=int(input())
for a in range(1,10):
  for b in range(1,10):
    if n==a*b:
    break
    print("Yes")
    else:
    print("No")

### FIXED CODE ###

n=int(input())
for a in range(1,10):
  for b in range(1,10):
    if n==a*b:
      print("Yes")
      exit()
    
print("No")
n = int(input())
x = 1
a = list(map(int,input().split()))
for i in range(n):
  x *= a[i]
if x >= 10**18:
  print(-1)
else:
  print(x)

### FIXED CODE ###

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

print(a*b)
import numpy as np
 
n,m = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
d = 2**18
 
f = np.array([0]*d)
for i in a:
    f[i]+=1
 
tf = np.fft.fft(f)
f = np.fft.ifft(tf*tf)
f = [int(i+0.5) for i in f]
 
ans=0
for i in range(len(f)-1,0,-1):
    if f[i]<=m:
        ans+=i*f[i]
        m-=f[i]
    elif f[i]>m:
        ans+=i*m
        break
print(ans)

### FIXED CODE ###

s,t = input().split()
print(t+s)
X,N = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
nlist = [0 for i in range(100)] 
for i in p:
    nlist[i-1]=1
for i in range(max(X+1,100-X+1)):
    
    if X-i-1>=0:
        if nlist[X-i-1] == 0:
            result = X-i
            break
    if X+i-1>=0:
        if nlist[X+i-1] == 0:
            result = X+i
            break
print(result)
        

### FIXED CODE ###

X,N = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]
nlist = [0 for i in range(105)] 
for i in p:
    nlist[i]=1
for i in range(max(X+1,100-X+1)):
    
    if X-i>=0:
        if nlist[X-i] == 0:
            result = X-i
            break
    if X+i<=101:
        if nlist[X+i] == 0:
            result = X+i
            break
print(result)
import bisect
n,m = [int(i) for i in input().split()]
l = sorted([int(i) for i in input().split()])
l2 = []
[bisect.insort(l,l.pop()//2,0,n) for _ in range(m)]
print(sum(l[0:n]))


### FIXED CODE ###

import heapq
n,m = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
h = []
for i in l:
    i = -1*i
    heapq.heappush(h,i)
    
for _ in range(m):
    v = -heapq.heappop(h)
    heapq.heappush(h,-1*(v//2))
    
print(-sum(h))
import sys
sys.setrecursionlimit(10**6)
n,m = map(int,input().split())
e = [[] for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    e[a].append(b)
    e[b].append(a)
qv = int(input())
Q = [list(map(int,input().split())) for i in range(qv)]
Q = Q[::-1]
l = [[0]*(11) for i in range(n+1)]
for v,d,c in Q:
    if l[v][d] > 0:
        continue
    l[v][d] = c
dic = {}
color = [0]*(n+1)

left = [i for i in range(1,n+1)]
num = 0
while num < qv and left:
    v,d,c = Q[num]
    if v not in dic:
        for i in range(10,-1,-1):
            if l[v][i] > 0:
                M = i
                break
        dic[v] = [set() for i in range(n+1)]
        s = set()
        s.add(v)
        dic[v][0] |= s
        dist = [float("INF")]*(n+1)
        dist[v] = 0
        q = [v]
        for i in range(1,M+1):
            nq = []
            for now in q:
                for nex in e[now]:
                    if dist[nex]<= i:
                        continue
                    nq.append(nex)
                    dist[nex] = i
                    s.add(nex)
            dic[v][i] |= s
            q = nq
    nl = []
    
    for i in left:
        if i in dic[v][d]:
            color[i] = c
        else:
            nl.append(i) 
    num += 1
    
    left = nl
    
for i in color[1:]:
    print(i)

### FIXED CODE ###

from collections import deque
import sys
sys.setrecursionlimit(10**6)
n,m = map(int,input().split())
e = [[] for i in range(n+1)]
for i in range(m):
    a,b = map(int,input().split())
    e[a].append(b)
    e[b].append(a)
qv = int(input())
Q = [list(map(int,input().split())) for i in range(qv)]

color = [0]*(n+1)
used = [-1]*(n+1)

for v,d,c in Q[::-1]:
    if used[v] > d:
        continue
    
    q = deque([[v,d]])
    while q:
        now, dis = q.popleft()
        if dis < 0:
            continue
        if color[now] == 0:
            color[now] = c
        for nex in e[now]:
            if used[nex] < dis-1:
                used[nex] = dis-1
                q.append([nex,dis-1])
    
for i in color[1:]:
    print(i)
da = list(map(int,input().split()))

k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0

while da[0] != 0 and da[1] != 0:
	i = 0
	su = 0
	j = 0
	for i in range(da[0]):
		k[i][0],k[i][1] = map(int,input().split())
		su += k[i][0] * k[i][1]


	sorted(k,key = lambda x: x[1],reverse = True)
	while da[1] > 0 and j != i + 1:
		if da[1] >= k[j][0] and j != i + 1
			su -= k[j][0] * k[j][1]
			da[1] -= k[j][0]
			j += 1
		elif j == i + 1:
			da[1] = 0
		else:
			su -= da[1] * k[j][1]
			da[1] = 0

	print(su)

	da = list(map(int,input().split()))
	if da[0] == 0 and da[1] == 0:
		break
	k = [[0 for i in range(2)]for j in range(10001)]



### FIXED CODE ###

da = list(map(int,input().split()))

k = [[0 for i in range(2)]for j in range(10001)]
i = 0
su = 0
j = 0

while da[0] + da[1] != 0:
	i = 0
	su = 0
	j = 0
	for i in range(da[0]):
		k[i][0],k[i][1] = map(int,input().split())


	k = sorted(k,key = lambda x: x[1],reverse = True)

	while j != i + 1:
		if da[1] > k[j][0]:
			da[1] -= k[j][0]
			j += 1
		elif da[1] <= k[j][0] and da[1] > 0:
			su += (k[j][0] - da[1]) * k[j][1]
			da[1] = 0
			j += 1
		else:
			su += k[j][0] * k[j][1]
			j += 1

	print(su)

	da = list(map(int,input().split()))

	k = [[0 for i in range(2)]for j in range(10001)]
a,b,c = map(int,inout().split())
if a == b:
  print(c)
elif b == c:
  print(a)
else:
  print(b)

### FIXED CODE ###

a,b,c = map(int,input().split())
if a == b:
  print(c)
elif b == c:
  print(a)
else:
  print(b)
N = input()
A_s = list(map(int, input().split()))


def mul(arr):
    if len(arr) == 1:
        return arr[0]
    return arr[0] * mul(arr[1:])


res = mul(A_s)

if res > 10 ** 18:
    res = -1

print(res)


### FIXED CODE ###

N = input()
A_str = input().split()
A_array = map(int, A_str)

if "0" in A_str:
    print(0)
    exit()

res = 1
for A in A_array:
    res *= A
    if res > 10 ** 18:
        res = -1
        break

print(res)
a,b=input().split('\n')
print('Yes')

### FIXED CODE ###

n = int(input())
s = input()
if n % 2:
    print("No")
    exit()
half = s[0:n // 2]
print("Yes" if s == half + half else "No")
N, M, C = map(int, input().split())
B=list(map(int, input().split))
for i in range(N):
  A=list(map(int, input().split))
  for j in range(M):
    sum+=B[j]*A[j]
  if (sum+C)>0:
  answer+=1
print(answer)


### FIXED CODE ###

N,M,C=map(int,input().split())
B=list(map(int,input().split()))
count=0
for i in range(N):
    A=list(map(int,input().split()))
    p=C
    for j in range(M):p+=A[j]*B[j]
    if p>0:count+=1
print(count)
x,y,z=map(int,input().split())
x-=2
ans=x//(y+z)

rem=x%(y+z)
if rem>=y:
    ans+=1
print(ans)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a.sort()
print(a[-1]-a[0])