Harryxun/stf_run huggingface dataset:
import collections
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
memo = {}
ans = 0
for k, v in c.items():
    if v > 1:
        memo[v] = combinations_count(v, 2)
        ans += memo[v]
total_ans = ans
for i in range(N):
    k_ball = A[i]
    if c[k_ball] > 2:
        if k_ball - 1 in set(memo.keys()):
            print(int(total_ans - (memo[c[k_ball]] - memo[c[k_ball - 1]])))
        else:
            print(
                int(
                    total_ans - (memo[c[k_ball]] - combinations_count(c[k_ball] - 1, 2))
                )
            )
    elif c[k_ball] > 1:
        print(total_ans - 1)
    else:
        print(total_ans)

### FIXED CODE ###

# 解き直し
import collections

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

total = 0
for v in c.values():
    total += v * (v - 1) // 2

for k_ball in A:
    cnt = c[k_ball]
    print(total - (cnt * (cnt - 1) // 2) + ((cnt - 1) * (cnt - 2) // 2))
n = int(input())
s = [list(map(int, input().split())) for i in range(n)]

for cx in range(101):
    for cy in range(101):
        flag = True
        flag_init = True
        for _n in range(n):
            if s[_n][2] != 0:
                H = s[_n][2] + abs(s[_n][0] - cx) + abs(s[_n][1] - cy)
                if flag_init:
                    H0 = H
                    flag_init = False
                else:
                    if H != H0:
                        flag = False
        if flag == True and h >= 1:
            print(cx, cy, H)
            break

    else:
        continue
    break


### FIXED CODE ###

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

xyh.sort(key=lambda x:x[2], reverse=True)
for cx in range(101):
    for cy in range(101):
        x, y, h = xyh[0]
        H = abs(x - cx) + abs(y - cy) + h
        f = True

        for i in range(1, n):
            x, y, h = xyh[i]
            h2 = max(0, H - abs(x - cx) - abs(y - cy))
            if h != h2:
                f = False
                break

        if f:
            ans = (cx, cy, H)

print(ans[0], ans[1], ans[2])
from heapq import heappush, heappop
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


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

stx=[[int(x) for x in readline().split()] for _ in range(n)]
event=[]
for s,t,x in stx:
    event.append((s-x,1,x))
    event.append((t-x,-1,x))

for i in range(q):
    event.append((int(input()),2,i))
event.sort()

ans=[0]*q

stop=set()
hq=[]
for t,op,x in event:
    if op==1:
        heappush(hq,x)
        stop.add(x)
    elif op==-1:
        stop.remove(x)

    else:
        while hq and hq[0] not in stop:
            heappop(hq) 
        ans[x]=hq[0] if hq else -1
    
for x in ans:
    print(x)

### FIXED CODE ###

def main():
    from heapq import heappush, heappop
    import sys
    sys.setrecursionlimit(10 ** 7)

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

    event=[]
    for _ in range(n):
        s,t,x=map(int,input().split())
        event.append((s-x,1,x))
        event.append((t-x,-1,x))

    for i in range(q):
        event.append((int(input()),2,i))
    event.sort()

    ans=[0]*q

    stop=set()
    hq=[]
    for t,op,x in event:
        if op==1:
            heappush(hq,x)
            stop.add(x)
        elif op==-1:
            stop.remove(x)

        else:
            while hq and hq[0] not in stop:
                heappop(hq) 
            ans[x]=hq[0] if hq else -1
        
    for x in ans:
        print(x)

main()
X = int(input())

for i in range(X):
  if X == int(100 * (1.01 ** i)):
    print(i)
    break

### FIXED CODE ###

X = int(input())
A = 100
c = 0
while(A < X):
  A = int(A * 1.01)
  c = c + 1
  
print(c)
N, T = map(int, input().split())

l = []

for i in range(N):
    a = list(map(int, input().split()))
    if T >= a[1]:
        l.append(a[0])

print('TLE' if len(l) == 0 else min(l))


### FIXED CODE ###

n = int(input())
if n == 1:
    print('Hello World')
else:
    a, b = [int(input()) for _ in range(2)]
    print(a+b)
N=int(input())
S=input()
r = len(S.replace("G", "").replace("B", ""))
g = len(S.replace("R", "").replace("B", ""))
b = N - r - g

ans = r * g
ans = ans * b

for i in range( N ):
    for j in range(i, int((N+i)/2 + 1)):
        k = 2 * j - i
            if k < N:
                s = S[i] + S[j] + S[k]
                if ("R" in s) & ("G" in s) & ("B" in s):
                    ans -= 1

print(ans)

### FIXED CODE ###

N=int(input())
S=input()
r = len(S.replace("G", "").replace("B", ""))
g = len(S.replace("R", "").replace("B", ""))
b = N - r - g

ans = r * g
ans = ans * b

for i in range( N ):
    for j in range(i, int((N+i)/2 + 1)):
        k = 2 * j - i
        if k < N:
            s = S[i] + S[j] + S[k]
            if ("R" in s) & ("G" in s) & ("B" in s):
                ans -= 1

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

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

def lcm_list(li):
    if len(li) == 1:
        return li[0]

    elif len(li) == 2:
        return lcm(li[0], li[1])

    else:
        li = [lcm(li[0], li[1])] + li[2:]
        return lcm_list(li)

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


i = max(lcm_list(a) - 1, 1)
print(sum([i % j for j in a]))

### FIXED CODE ###

import sys
sys.setrecursionlimit(30000)

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

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

def lcm_list(li):
    if len(li) == 2:
        return lcm(li[0], li[1])

    else:
        li = [lcm(li[0], li[1])] + li[2:]
        return lcm_list(li)

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


i = max(lcm_list(a) - 1, 1)
print(sum([i % j for j in a]))
from math import gcd
# def lcm(a,b): return a*b//gcd(a,b)

def lcm(a, b):
    _gcd = gcd(a, b)
    return int((a * b) / _gcd)

n = int(input())

ans = 1
for i in range(n):
    t = int(input())
    ans = lcm(t, ans)
print(ans)

### FIXED CODE ###

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

n = int(input())

ans = 1
for i in range(n):
    t = int(input())
    ans = lcm(t, ans)
print(ans)
import numpy as np
n, a = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
sx=sum(x)
dp= np.zeros((n+1,sx+1),dtype='int32')
#dp=[[0]*(n*a+1)]*(n+1)
dp[0][0]=1
ans=0
f=0
for k in range(1,n+1):
  kx=x[k-1]
  f+=kx
  for i in range(k,0,-1):
    for j in range(kx,sx+1):
      dp[i][j] += dp[i-1][j-kx]
      if j > f:
        break
      
for i in range(1,n+1):
  if i >=sx:
    break
  ans+=dp[i][a*i]

print(ans)


### FIXED CODE ###

n, a = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]

dp=[[0 for i in range(a*n+1)] for j in range(n+1)]
dp[0][0]=1
ans=0
f=0

for k in range(1,n+1):
  kx=x[k-1]
  f+=kx
  for i in range(k,0,-1):
    for j in range(kx,a*n+1):
      dp[i][j] += dp[i-1][j-kx]
      if j > f:
        break
      
for i in range(1,n+1):
  ans+=dp[i][a*i]

print(ans)
from  itertools import combinations
n,C=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(C)]
c=[list(map(int,input().split())) for _ in range(n)]
a=[[0]*C for _ in range(3)]
for i in range(n):
	for j in range(n):
		a[(i+j)%3][c[i][j]-1]+=1
ans=10**9
for v in combinations(range(C),3):
	tmp=0
	for i in range(3):
		for j in range(30):
			tmp+=a[i][j]*d[j][v[i]]
	ans=min(ans,tmp)
print(ans)

### FIXED CODE ###

from itertools import permutations
n,C=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(C)]
c=[list(map(int,input().split())) for _ in range(n)]
a=[[0]*C for _ in range(3)]
for i in range(n):
	for j in range(n):
		a[(i+j)%3][c[i][j]-1]+=1
ans=10**9
for v in permutations(range(C),3):
	tmp=0
	for i in range(3):
		for j in range(C):
			tmp+=a[i][j]*d[j][v[i]]
	ans=min(ans,tmp)
print(ans)
MOD = 10 ** 9 + 7
n, k = map(int, input().split())

def calc(a):
  smallest = a * (a-1) / 2
  largest = smallest + a * (n-a+1)
  return latgest -smallest + 1

ans = 0
for a in range(k, n+2):
  ans += calc(a)
  ans %= MOD
  
print(ans)

### FIXED CODE ###

MOD = 10 ** 9 + 7
n, k = map(int, input().split())

def calc(a):
  smallest = a * (a-1) // 2
  largest = smallest + a * (n-a+1)
  return largest - smallest + 1

ans = 0
for a in range(k, n+2):
  ans += calc(a)
  ans %= MOD
  
print(ans)
S = list(input())
for i in range(len(S)):
  if i % 2 == 0:
   	if S[i] == ("R" or "U" or "D"):
      continue
   	else:
      print("No")
      exit()
  else:
    if S[i] == ("L" or "U" or "D"):
      continue
    else:
      print("No")
      exit()
print("Yes")


### FIXED CODE ###

S = list(input())
for i in range(len(S)):
	if i % 2 == 0:
		if (S[i] == "R") or(S[i] ==  "U") or(S[i] ==  "D"):
			continue
		else:
			print("No")
			exit()
	else:
		if (S[i] == "L") or(S[i] ==  "U") or(S[i] ==  "D"):
			continue
		else:
			print("No")
			exit()
print("Yes")
#!/usr/bin/env python3
import sys
import numpy as np

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(H: int, W: int, s: "List[str]"):
    count = 0
    numofshirp = 0
    for s_ in s:
        numofshirp += s_.count("#")

    #padding
    edge = ["".join(["."] * (W + 2))]
    for i, si in enumerate(s):
        s[i] = "".join("."+si+".")
    s.extend(edge)
    edge.extend(s)

    for i, ei in enumerate(edge):
        for j, eij in enumerate(ei):
            if eij == "#" and i > 0 and j > 0 and i < len(edge) - 1 and j < len(edge[0]) - 1:
                if "#" in (edge[i - 1][j], edge[i + 1][j], edge[i][j - 1], edge[i][j + 1]):
                    count += 1

    if count == numofshirp:
        print(YES)
    else:
        print(NO)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(W)]  # type: "List[str]"
    solve(H, W, s)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import numpy as np

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(H: int, W: int, s: "List[str]"):
    ans = YES
    for i in range(1, H-1):
        for j in range(1, W-1):
            if s[i][j] == "#" and s[i-1][j] == s[i+1][j] == s[i][j-1] == s[i][j+1] == ".":
                ans = NO
    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    H, W = map(int,input().split())  # type: int
    s = [input() for _ in range(H)]  # type: "List[str]"
    solve(H, W, s)

if __name__ == '__main__':
    main()
import math
  
n = input()
  
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
  
def koch(n, px, py, qx, qy):
 if n == 0:
  return
   
 s.x = (px*2+qx*1)/3
 s.y = (py*2+qy*1)/3
 t.x = (px*1+qx*2)/3
 t.y = (py*1+qy*2)/3
 u.x = (t.x-s.x)*cos(pi/3) - (t.y-s.y)*sin(pi/3) + s.x
 u.y = (t.x-s.x)*sin(pi/3) - (t.y-s.y)*cos(pi/3) + s.y
  
 koch(n-1, px, py, s.x, s.y)
 print s.x, s.y
 koch(n-1, s.x, s.y, u.x, s.y)
 print u.x, u.y
 koch(n-1, u.x, u.y, t.x, t.y)
 print t.x, t.y
 koch(n-1, t.x, t.u, qx, qy)
  
print px, py
koch(n, px, py, qx, qy)
print qx, qy

### FIXED CODE ###

import math
          
def koch(n, h, i, j, k):
 if n == 0:
  return
           
 sx = (h*2+j)/3
 sy = (i*2+k)/3
 tx = (h+j*2)/3
 ty = (i+k*2)/3
 ux = (tx-sx)*math.cos(math.pi/3) - (ty-sy)*math.sin(math.pi/3) + sx
 uy = (tx-sx)*math.sin(math.pi/3) + (ty-sy)*math.cos(math.pi/3) + sy
          
 koch(n-1, h, i, sx, sy)
 print sx, sy
 koch(n-1, sx, sy, ux, uy)
 print ux, uy
 koch(n-1, ux, uy, tx, ty)
 print tx, ty
 koch(n-1, tx, ty, j, k)
   
n = input()
          
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
          
print px, py
koch(n, px, py, qx, qy)
print qx, qy
I=lambda:list(map(int,input().spilt()))
n,d=I()
def ch(a,b):
    return a**2+b**2
ans=0
for i in range(n):
    x,y=I()
    if ch(x,y)<=d:
        ans+=1
print(ans)
    
    

### FIXED CODE ###

I=lambda:list(map(int,input().split()))
n,d=I()
def ch(a,b):
    return a**2+b**2
ans=0
for i in range(n):
    x,y=I()
    if ch(x,y)<=d*d:
        ans+=1
print(ans)
N = int(input())
As = map(int, input().split())
result = 1
 
for a in As:
  result *= a
 
if a >= 10**18:
  print(-1)
else:
  print(result)

### FIXED CODE ###

nums = input().split()
print(int(nums[0]) * int(nums[1]))
n = input()
a = [int(n[i:i+3]) for i in range(len(n)-3)]
ans = abs(a[0]-753)
for i in a:
  b = abs(a[i]-753)
  if b < ans:
    ans = b
print(ans)
  

### FIXED CODE ###

n = input()
a = [int(n[i:i+3]) for i in range(len(n)-2)]
ans = abs(a[0]-753)
for i in a:
  b = abs(i-753)
  if b < ans:
    ans = b
print(ans)
import sys;input=sys.stdin.readline

def main():
    n,q=map(int,input().split())
    event=[]
    stop=set()
    for i in range(n):
        s,t,x=map(int,input().split())
        event.append((s-x,x))
        event.append((t-x,-x))
    for i in range(q):
        event.append((int(input()),"q"))
    
    event.sort(key=lambda x:x[0])
    ans=[]
    minstop=float("inf")
    for t,x in event:
        if type(x)==str:
            ans.append(str(minstop))
            continue
        elif x>=0:
            stop.add(x)
        elif x<0 and len(stop)>0:
            stop.remove(-x)
        if minstop!=x:
            minstop=min(stop or [-1])
    print("\n".join(ans))
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys;input=sys.stdin.readline

n,q=map(int, input().split())
event=[]
for _ in range(n):
    s,t,x=map(int,input().split())
    event.append((s-x-0.5,1,x))
    event.append((t-x-0.5,-1,x))
for i in range(q):
    event.append((int(input()),0,i))
    
event.sort()
is_stop=False
stop=set()
minstop=float('inf')
ans=[-1]*q
for t,e,x in event:
    if e > 0:
        stop.add(x)
        if x<minstop:
            minstop=x
            is_stop=True
    elif e<0:
        stop.remove(x)
        if minstop==x:
            is_stop=False
    elif len(stop)>0:
        if not is_stop:
             minstop=min(stop)
             is_stop=True
        ans[x]=minstop
        
print('\n'.join(map(str, ans)))
a,b = map(int, input().split())
from math import gcd
print(int(a*b/gcd(a,b)))

### FIXED CODE ###

a,b = map(int, input().split())
from fractions import gcd
print(int(a*b/gcd(a,b)))
import fractions

N, X = map(int, input.split())
x = list(map(int,input.split()))
D = abs(x[0]-X)
for i in x:
    D = fractions.gcd(D,abs(i-X))
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 x:
    D = fractions.gcd(D,abs(i-X))
print(D)
S = input()
L = len(S)

MOD = 10 ** 9 + 7
dp = [[0] * 13 for _ in range(15)]
dp[0][0] = 1
for i in range(L):
    j = -1 if S[i] == "?" else int(S[i])
    if j > -1:
        # jが確定しているので、jを全探索する必要はなく、前回桁までの組み合わせの数にjを足して次のDPへ入れる
        # jが確定しているから数字の組み合わせ自体が増えるわけではない
        # そのためこれまで確定していた桁に対して、jを追加した場合のあまりを単純に移送することになる
        
        # 前回桁までの数 * 10 + j をすると、今回桁をjにしたときのあまりがわかる
        # 3?1 → 301 % 13 = 2, 30 % 13 = 4であるから、ki=4のとき、dp[i][4]の数値をdp[i+1][2]に足す
        # 30と4はmod13の世界では合同になっている
        # すなわち*10した結果である300と40も合同
        # そこにjを足した数 300+jと40+jもまた合同であると言える、ともにあまりは2
        # ここでは具体的な値である30は計算していないが、その具体的な数と合同である数字を用いて、今回桁で作成可能な数字のmodを数えているdp[i+1][2]にdp[i][4]を突っ込むことになる
        # modの世界では両辺に同じ数をかけても合同であるという性質を用いて、10をかけながら、桁ごとに数値を足していっていることになる

        for ki in range(13):
            dp[i+1][(ki * 10 + j) % 13] += dp[i][ki]
    else:
        # jが確定していないので、jになりうる値を全て試す
        # 0-9の10パターンの数字が考えられるので、全ての組み合わせ自体は*10になる
        # ? だと10パターン ??だと100パターンになるので、?が来ると、数字の組み合わせが10倍になるのは自明
        # 10**(?の数) の組み合わせの総数になる
        for j in range(10):
            for ki in range(13):
                dp[i+1][(ki * 10 + j) % 13] += dp[i][ki]
    
    for j in range(13):
        dp[i+1][j] %= MOD

print(dp[L][5])


### FIXED CODE ###

S = input()
L = len(S)

MOD = 10 ** 9 + 7
dp = [[0] * 13 for _ in range(10**5+10)]
dp[0][0] = 1
for i in range(L):
    j = -1 if S[i] == "?" else int(S[i])
    if j > -1:
        # jが確定しているので、jを全探索する必要はなく、前回桁までの組み合わせの数にjを足して次のDPへ入れる
        # jが確定しているから数字の組み合わせ自体が増えるわけではない
        # そのためこれまで確定していた桁に対して、jを追加した場合のあまりを単純に移送することになる
        
        # 前回桁までの数 * 10 + j をすると、今回桁をjにしたときのあまりがわかる
        # 3?1 → 301 % 13 = 2, 30 % 13 = 4であるから、ki=4のとき、dp[i][4]の数値をdp[i+1][2]に足す
        # 30と4はmod13の世界では合同になっている
        # すなわち*10した結果である300と40も合同
        # そこにjを足した数 300+jと40+jもまた合同であると言える、ともにあまりは2
        # ここでは具体的な値である30は計算していないが、その具体的な数と合同である数字を用いて、今回桁で作成可能な数字のmodを数えているdp[i+1][2]にdp[i][4]を突っ込むことになる
        # modの世界では両辺に同じ数をかけても合同であるという性質を用いて、10をかけながら、桁ごとに数値を足していっていることになる

        for ki in range(13):
            dp[i+1][(ki * 10 + j) % 13] += dp[i][ki]
    else:
        # jが確定していないので、jになりうる値を全て試す
        # 0-9の10パターンの数字が考えられるので、全ての組み合わせ自体は*10になる
        # ? だと10パターン ??だと100パターンになるので、?が来ると、数字の組み合わせが10倍になるのは自明
        # 10**(?の数) の組み合わせの総数になる
        for j in range(10):
            for ki in range(13):
                dp[i+1][(ki * 10 + j) % 13] += dp[i][ki]
    
    for j in range(13):
        dp[i+1][j] %= MOD

print(dp[L][5])
import sys
 
stdin = sys.stdin

N,Q = map(int,input().split())
S = input()
se = [list(map(int, stdin.readline().split())) for i in range(Q)]

list_out = [0]
cnt = 0
f = 0

# AC文字列のAの位置をリストに収めた
for i in S:
  if i == 'A':
    f = 1
    list_out.append(list_out[-1])    
  elif i == 'C':
    if f == 1:
      cnt += 1
      list_out.append(cnt)
  else:
    list_out.append(list_out[-1])


# 指定した文字列範囲を含む要素数を表示
for i in se:
  print(list_out[i[1]] - list_out[i[0]])


### FIXED CODE ###

import sys
 
stdin = sys.stdin

N,Q = map(int,input().split())
S = input()
se = [list(map(int, stdin.readline().split())) for i in range(Q)]

list_out = [0] * N
cnt = 0
f = 0

# AC文字列のAの位置をリストに収めた
for i in range(len(S)):
  if S[i] == 'A':
    f = 1
    list_out[i] = list_out[i-1]    
  elif S[i] == 'C':
    if f == 1:
      cnt += 1
      f = 0
      list_out[i] = cnt
    else:
      list_out[i] = list_out[i-1]
  else:
    f = 0
    list_out[i] = list_out[i-1]    


# 指定した文字列範囲を含む要素数を表示
for i in se:
  print(list_out[i[1]-1] - list_out[i[0]-1])
N = int(input())
print(int(N*(N-1)//2)

### FIXED CODE ###

N =int(input())
print(int(N*(N-1)//2))
n,q = map(int,input().split())
s = input()
x = [list(map(int,input().split())) for i in range(q)]
for i in range(q):
    cnt = 0
    t = s[x[i][0]-1:x[i][1]]
    for i in range(len(t)-1):
        if t[i:i+2]=="AC"
            cnt += 1
    print(cnt)

### FIXED CODE ###

n,q = map(int,input().split())
s = input()
x = [list(map(int,input().split())) for i in range(q)]
cnt = 0
res = [0]
for i in range(1,len(s)):
    if s[i-1]=="A" and s[i]=="C":
        cnt += 1
    res.append(cnt)
for j in range(q):
    print(res[x[j][1]-1]-res[x[j][0]-1])
a = int(input())
b, c = map(int, input().split())
print(a*(b+c)/2)

### FIXED CODE ###

a = int(input())
b = int(input())
h = int(input())
result = int((a+b)*h/2)
print(result)
from collections import deque
import copy
n, m, r = map(int,input().split())
R = list(map(int, input().split()))
tree = [[] for _ in range(n+1)]
for i in range(m):
    a, b, c = map(int, input().split())
    tree[a].append([b, c])
    tree[b].append([a, c])

result = []
for i in R:
    visit = [-1 for _ in range(n+1)]
    visit[i] = 0
    q = deque([[i, visit]])
    while q:
        x, v = q.pop()
        for y, c in tree[x]:
            next_v = copy.deepcopy(v)
            if v[y]<0:
                next_v[y] = v[x]+c
                if all(next_v[j]>=0 for j in R):
                    result.append(next_v[y])
                else:
                    q.append([y, copy.deepcopy(next_v)])

print(min(result))

### FIXED CODE ###

import copy
from collections import deque
n, m, r = map(int,input().split())
R = list(map(int, input().split()))

f_inf = float('inf')
wf = [[f_inf for _ in range(n+1)] for __ in range(n+1)]

tree = [[] for _ in range(n+1)]
for i in range(m):
    a, b, c = map(int, input().split())
    wf[a][b] = c
    wf[b][a] = c
for i in range(1, n+1):
    wf[i][i] = 0
for k in range(1, n+1):
    for i in range(1, n+1):
        for j in range(1, n+1):
            wf[i][j] = min(wf[i][j], wf[i][k]+wf[k][j])

all_type = []
def get_all_type(r, info, lon):
    if lon == len(info):
        return [info]
    result = []
    for i in r:
        if i in info:
            continue
        else:
            next_info = copy.deepcopy(info)
            next_info.append(i)
            result.extend(get_all_type(r, next_info, lon))
    return result

Result = []
for i in get_all_type(R, [], r):
    j = deque(i)
    x = j.popleft()
    result = 0
    while j:
        y = j.popleft()
        result += wf[x][y]
        x = y
    Result.append(result)
print(min(Result))
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
ans = 10000

for i in range(n):
    if abs(a - (t - h[i] * 0.006)) < ans:
           ans = abs(a - (t - h[i] * 0.006))
           b = i
print(b + 1)


### FIXED CODE ###

n = int(input())

if n == 1:
    print("Hello World")
else:
    a = int(input())
    b = int(input())
    print(a + b)
import copy
N, M = map(int, input().split())
A = []
B = []
for i in range(M):
    a, b = map(int, input().split())
    A.append(a - 1)
    B.append(b - 1)


class UnionFind:
    def __init__(self, n):
        self.Parent = [-1 for i in range(N)]

    def root(self, x):
        if self.Parent[x] < 0:
            return x
        self.Parent[x] = self.root(self.Parent[x])
        return copy.deepcopy(self.Parent[x])

    def size(self, x):
        return -copy.deepcopy(self.Parent[self.root(x)])

    def connect(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.size(x) < self.size(y):
            x, y = y, x
        self.Parent[x] += self.deepcopy(self.Parent[y])
        self.Parent[y] = x
        return True


ans = [0 for i in range(M)]
ans[M - 1] = N * (N - 1) / 2
unif = UnionFind(N)

for i in range(M-1, 1, -1):
    ans[i - 1] = ans[i]
    if unif.root(A[i]) != unif.root(B[i]):
        ans[i - 1] -= unif.size(A[i]) * unif.size(B[i])
        unif.connect(A[i], B[i])

for i in range(M):
    print(int(ans[i]))


### FIXED CODE ###

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


class UnionFind:
    def __init__(self, n):
        self.Parent = [-1 for i in range(N)]

    def root(self, x):
        if self.Parent[x] < 0:
            return x
        self.Parent[x] = self.root(self.Parent[x])
        return copy.deepcopy(self.Parent[x])

    def size(self, x):
        return -copy.deepcopy(self.Parent[self.root(x)])

    def connect(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return False
        if self.size(x) < self.size(y):
            x, y = y, x
        self.Parent[x] += copy.deepcopy(self.Parent[y])
        self.Parent[y] = x
        return True


ans = [0 for i in range(M)]
ans[M - 1] = N * (N - 1) / 2
unif = UnionFind(N)

for i in range(M-1, 0, -1):
    ans[i - 1] = ans[i]
    if unif.root(A[i]) != unif.root(B[i]):
        ans[i - 1] -= unif.size(A[i]) * unif.size(B[i])
        unif.connect(A[i], B[i])

for i in range(M):
    print(int(ans[i]))
import bisect
N=int(input())
L=sorted(list(map(int,input().split())))
count=0
for d1 in range(N-2):
    for d2 in range(d1+1,N-1):
        m=bisect.bisect_right(L[d1]+L[d2],l)
        if m>d2:count+=m-d2
print(count)


### FIXED CODE ###

import bisect
N=int(input())
L=sorted(list(map(int,input().split())))
count=0
for d1 in range(N-2):
    for d2 in range(d1+1,N-1):
        m=bisect.bisect_left(L,L[d1]+L[d2])
        if m>d2+1:count+=m-(d2+1)
print(count)