Harryxun/stf_run huggingface dataset:
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys
import math


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


def main():
    N = int(input())
    x_max = int(math.sqrt(N - 2))
    fN = [0] * N
    n2 = [i**2 for i in range(1, N + 1)]
    ij = [[0] * (N+1) for _ in range(N+1)]

    for i in range(1, N+1):
        for j in range(i, N+1):
            ij[i][j] = i * j

    for i in range(N):
        for x in range(1, x_max):
            y_min = x
            x2 = n2[x]
            for y in range(y_min, x_max):
                z_min = y
                y2 = n2[y]
                xy = ij[x][y]
                if x2 + y2 + xy > N:
                    break
                for z in range(z_min, x_max):
                    if x2 + y2 + n2[z] + xy + ij[y][z] + ij[z][x] > N:
                        break
                    if x2 + y2 + n2[z] + xy + ij[y][z] + ij[z][x] == N:
                        fN[i] += 1

    for n in fN:
        print(n)


if __name__ == "__main__":
    main()


### FIXED CODE ###

#!/usr/bin/python
# -*- coding: UTF-8 -*-

import math
import sys


def calc_p(a, b, c):
    u = {a, b, c}
    if len(u) == 3:
        return 6
    if len(u) == 2:
        return 3
    if len(u) == 1:
        return 1
    else:
        raise


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


def _main():
    N = int(std_in())
    fn = [0] * (N + 1)
    if N == 1:
        x_max = 1
    else:
        x_max = int(math.sqrt(N - 2)) - 1

    n2 = [i**2 for i in range(1, x_max + 1)]

    ij = [[0 for _ in range(1, x_max + 1)] for _ in range(1, x_max + 1)]
    for i in range(x_max):
        for j in range(i, x_max):
            ij[i][j] = (i+1) * (j+1)

    for x in range(1, x_max + 1):
        y_min = x
        x2 = n2[x-1]
        for y in range(y_min, x_max + 1):
            z_min = y
            y2 = n2[y-1]
            xy = ij[x-1][y-1]
            tmp_n = x2 + xy + y2
            if tmp_n > N:
                break
            for z in range(z_min, x_max + 1):
                z2 = n2[z-1]
                yz = ij[y-1][z-1]
                zx = ij[x-1][z-1]
                n = tmp_n + z2 + yz + zx
                if n > N:
                    break
                fn[n] += calc_p(x, y, z)

    for i in range(1, N + 1):
        print(fn[i])


if __name__ == "__main__":
    _main()
def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 10**9+7
    ans = 1
    s, t = [i for i in a if i > 0], [j for j in a if j < 0]

    S, T = len(s), len(t)
    ok = False

    if S > 0:
        if n == k:
            ok = (T % 2 == 0)
        else:
            ok = True
    else:
        ok = (k % 2 == 0)

    if not ok:
        a.sort(key=abs)
        for i in range(k):
            ans *= a[i]
            ans %= mod
    else:
        s.sort()
        t.sort(reverse=True)
        if k % 2 == 1:
            ans *= s.pop()
            ans %= mod
        p = []
        while len(s) >= 2:
            x = s.pop()
            x *= s.pop()
            p.append(x)
        while len(t) >= 2:
            x = t.pop()
            x *= t.pop()
            p.append(x)
        p.sort(reverse=True)
        for i in range(k//2):
            ans *= p[i]
            ans %= mod
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 10**9+7
    ans = 1
    s, t = [], []
    for i in range(n):
        if a[i] < 0:
            t.append(a[i])
        else:
            s.append(a[i])
    # s, t = [i for i in a if i > 0], [j for j in a if j < 0]

    S, T = len(s), len(t)
    ok = False

    if S > 0:
        if n == k:
            ok = (T % 2 == 0)
        else:
            ok = True
    else:
        ok = (k % 2 == 0)

    if not ok:
        a.sort(key=abs)
        for i in range(k):
            ans *= a[i]
            ans %= mod
    else:
        s.sort()
        t.sort(reverse=True)
        if k % 2 == 1:
            ans *= s.pop()
            ans %= mod
        p = []
        while len(s) >= 2:
            x = s.pop()
            x *= s.pop()
            p.append(x)
        while len(t) >= 2:
            x = t.pop()
            x *= t.pop()
            p.append(x)
        p.sort(reverse=True)
        for i in range(k//2):
            ans *= p[i]
            ans %= mod
    print(ans % mod)


if __name__ == '__main__':
    main()
import math
a,b = map(int,input().split())
 
print(a*b//math.gcd(a,b))

### FIXED CODE ###

import fractions

a,b = map(int,input().split())
print(a*b//fractions.gcd(a,b))
a = input()
b = input()
h = input()
print((a+b)*h/2)

### FIXED CODE ###

a = int(input())
b = int(input())
h = int(input())
square = (a + b) * h / 2
print(int(square))
import sys
import itertools
import math
input = sys.stdin.readline
#sys.setrecursionlimit(1e9)
N,M = map(int,input().split())

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

graph=[[0]*N for _ in range(N)]
def dfs(v,visited):
    if sum(visited) == N:
        return 1
    ret =0
    for i in range(N):
        if graph[v][i] == 1 and visited[i] == 0:
            visited[i]=1
            ret += dfs(i,visited)
            visited[i]=0
    return ret
def main():
    """code here"""

    for i in range(N):
        a=ab[i][0]
        b=ab[i][1]
        graph[a-1][b-1]=1
        graph[b-1][a-1]=1

    visited=[0]*N
    visited[0]=1
    print(dfs(0,visited))




    
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
import itertools
import math
input = sys.stdin.readline
#sys.setrecursionlimit(1e9)
N,M = map(int,input().split())

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

graph=[[0]*8 for _ in range(8)]
def dfs(v,visited):
    if sum(visited) == N:
        return 1
    ret =0
    for i in range(N):
        if graph[v][i] == 1 and visited[i] == 0:
            visited[i]=1
            ret += dfs(i,visited)
            visited[i]=0
    return ret
def main():
    """code here"""

    for i in range(M):
        a=ab[i][0]
        b=ab[i][1]
        graph[a-1][b-1]=1
        graph[b-1][a-1]=1

    visited=[0]*N
    visited[0]=1
    print(dfs(0,visited))
    
if __name__ == '__main__':
    main()
x, a, b = map(int, input())
if abs(x-a) > abs(x-b):
  print('B')
else:
  print('A')

### FIXED CODE ###

x, a, b = map(int, input().split())
if abs(x-a) > abs(x-b):
  print('B')
else:
  print('A')
n=int(input())
c=input()
b=c.count("#")
w=c.count(".")

cnt=0
for i in range(w):
  if c[i]=="#":
    cnt+=1
  bb=b-cnt
  ww=w-cnt

ans=min(ww+cnt,b,w)
print(ans)

### FIXED CODE ###

import sys

n=int(input())
c=input()
black=c.count("#")
white=c.count(".")

if black==n:
  print(0)
  sys.exit()

b=0
w=0
now=0
ans=float('inf')

for i in range(n):
  if c[i]=="#":
    b+=1
  w=(i+1)-b

  now=b+(white-w)
  ans=min(ans,now)
  
print(min(ans,white))
import copy
N = int(input())
A = list(map(int,input().split()))
A.sort()
B = copy.copy(A)
cnt = 0
for i in range(N):
    if A.count(A[i])> 1:
        continue
    for j in range(len(B)):
        if 2 * B[j] > A[i]:
            cnt += 1
            break
        if A[i] % B[j] == 0:
            B.remove(A[i])
            break
        if j
print(cnt)

### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort()
    MAX = A[-1]
    dp = [1] * (MAX + 5)
    ANS = 0
    for i in range(N):
        if dp[A[i]] == 0:
            continue
        for j in range(MAX+1):
            if A[i]*j > MAX:
                break
            dp[A[i]*j] = 0
        dp[A[i]] = 0
        if i < N-1 and A[i] == A[i+1]:
            continue
        ANS += 1
    print(ANS)

if __name__ == '__main__':
    main()
n = int(input())
s = list(input() for _ in range(n))
cou = 0
for i in s:
    cou += i.count('AB')
a = 0
b = 0
both = 0
for i in s:
    if i[0]=="B":
        b += 1
    if i[-1]=="A":
        a += 1
    if i[0]=="B" and i[-1]=="A":
        both += 1
if min(a,b)>=both  :
    print(cou+min(a,b)-1)
else:
    print(cou+min(a,b))

### FIXED CODE ###

a,b = map(int,input().split())
print(a-b+1)
N, K = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

h.sort()

left = 0
right = len(h) - 1
center = 0

if right == 0:
    if a[0] >= K:
        print(1)
    else:
        print(0)
else:
    while right - left >= 1:
        center = int((left + right) / 2)
        if h[center] >= K:
            right = center
        else:
            left = center
        
    print(len(h) - center)

### FIXED CODE ###

N, K = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

count = 0

for i in range(N):
    if h[i] >= K:
        count += 1

print(count)
W, H, x, y = map(int, input().split(' '))

a_x = min(x, W - x)
a_y = min(y, H - y)

if ((W == H) and (x == y or x == H - y)):
    ans = W * H / 2.0
    if (x == W - x and y == H -y):
        multi_ans = 1
    else:
        multi_ans = 0

if (W < H):
    l = H
    m = a_x
else:
    l = W
    m = a_y
ans = l * m
if (x == W/2 and y == H/2):
    multi_ans = 1
elif (W == H and (x != 0 and y != 0)):
    multi_ans = 1
else:
    multi_ans = 0

# 対角線
if (((W % x == 0) and (H % y ==0)) and (x == y or x == H - y)):
    ans = W * H / 2.0
    if (x == W - x and y == H -y):
        multi_ans = 1
    else:
        multi_ans = 0

# 4点
if ((x == 0 and y == 0) or (x == 0 and y == H) or (y == 0 and x == W) or (y == H and x == W)):
    multi_ans = 0
    ans = W * H / 2.0

print("{} {}".format(ans, multi_ans))



### FIXED CODE ###

W, H, x, y = map(int, input().split(' '))


multi_ans = 0

if ((x == 0 and y == 0) or (x == 0 and y == H) or (y == 0 and x == W) or (y == H and x == W)):
    multi_ans = 0
elif (W==H and not((x == W - x or y == H - y))):
    multi_ans == 1
elif (x != 0 and y != 0):
    if (W / x == H / y):
        if (x == W - x and y == H -y):
            multi_ans = 1
        else:
            multi_ans = 0

ans = W * H /2.0
print("{} {}".format(ans, multi_ans))
# D
import math
res = 0

A = int(input())
B = int(input())


while True:
    # find log2A and log2B
    C = 2**math.floor(math.log2(B))
    if A < C:
        # A to C
        res += C - A
        if B > C:
            B_ = C + 2**math.floor(math.log2(B - C) + 1) - 1
        if C + A <= B_:
            res += C
            break
        else:
            res += (C - A) + (B_ - C + 1)
            break
    else:
        A -= C
        B -= C

print(res)

### FIXED CODE ###

# D
res = 0

A = int(input())
B = int(input())

def pow2_floor_log2(x):
    res = 1
    while res*2 <= x:
        res *= 2
    return res

if A == B:
    res += 1
    
while A < B:
    # find log2A and log2B
    C = pow2_floor_log2(B)
    if A < C:
        # A to C
        res += C - A
        if B > C:
            B_ = C + pow2_floor_log2(B - C)*2 - 1
        else:
            B_ = C
        if C + A <= B_:
            res += C
            break
        else:
            res += (C - A) + (B_ - C + 1)
            break
    else:
        A -= C
        B -= C

print(res)
import math

def prime(x):
    if x==1:
        prime=True
        #この問題に合わせて１でもTrueとする
    else:
        prime=True
        for i in range(2,int(math.sqrt(x)+1)):
            if x%i==0:
                prime=False
                break
    return prime

def main():
    #input
    N=int(input())
    A=list(map(int,input().strip().split()))

    A.sort(reverse=True)
    
    #割り切れた場合+1
    cnt=0
    for i in range(N-1):
        #A[i]が素数または1の場合
        if prime(A[i]):
            #前後に同じ数がない場合、割り切れない
            if i<N-1:
                if A[i]==A[i+1]:
                    cnt+=1
            elif i>0:
                if A[i]==A[i-1]:
                    cnt+=1
        #A[i]が素数ではない場合
        else:
            for j in reversed(range(i+1,N)):
                if A[i]%A[j]==0:
                    cnt+=1
                    break
    if A[-1]%A[-2]==0:
        cnt+=1
    print(N-cnt)

if __name__=="__main__":
    main()

### FIXED CODE ###

def main():
    #input
    N=int(input())
    A=list(map(int,input().strip().split()))

    A.sort()

    l=[True for _ in range(A[-1]+1)]
    
    cnt=0
    for n in range(N-1):
        if l[A[n]]==True:
            if A[n]==A[n+1]:
                l[A[n]]=False
            else:
                l[A[n]]=False
                cnt+=1
            i=1
            while i*A[n]<=A[-1]:
                l[A[n]*i]=False
                i+=1
    if l[A[N-1]]==True:
        cnt+=1
        l[A[N-1]]=False
    return cnt

if __name__=="__main__":
    print(main())
def resolve():
A, B, N = map(int, input().split(' '))
ans = 0
for x in range(N + 1):
    res = math.floor((A * x / B) - A * math.floor(x / B))
    ans = max(ans, res)
print(ans)


### FIXED CODE ###

import math

A, B, N = map(int, input().split(' '))
ans = 0
x = min(B, N + 1) - 1
ans = math.floor((A * x) / B) - A * (math.floor(x / B))
print(int(ans))
N = input()

one_digit = N % 10
if one_digit == 2 or one_digit == 4 or one_digit == 5 or one_digit == 7 or one_digit == 9:
  print("hon")
elif one_digit == 0 or one_digit == 1 or one_digit == 6 or one_digit == 8:
  print("pon")
else:
  print("bon")


### FIXED CODE ###

N = input()
one_digit = int(N) % 10
if one_digit == 2 or one_digit == 4 or one_digit == 5 or one_digit == 7 or one_digit == 9:
  print("hon")
elif one_digit == 0 or one_digit == 1 or one_digit == 6 or one_digit == 8:
  print("pon")
else:
  print("bon")
import sys

n = int(sys.argv[1])
a = int(sys.argv[2])
b = int(sys.argv[3])
x = max(a, b)
y = a+b-n
if y < 0:
    y = 0
print(x, y)

### FIXED CODE ###

n,a,b = (int(i) for i in input().split())
x=min(a,b)
y=a+b-n
if y < 0:
    y=0
print(x,y)
def f(i):

    if(dp[i] != -1):
        return dp[i]
    if e[i] != 1:
        return 0
    else:
        dp[i] = f(i+1) + f(i+2)
        return dp[i]


n,m = list(map(int,input().split()))
e = [1] * n
dp = [-1] * n
dp.append(1)
dp[n-1] = 1
for i in range(m):
    e[int(input())] = 0
print(f(0) % 1000000007)

### FIXED CODE ###

I=lambda:list(map(int,input().split()))
n,m=I()
b=[int(input()) for i in range(m)]
b=list(set(b))
f={}
for i in b:
    f[i]=1
dp=[0]*(n+1)
dp[0]=1
for i in range(1,n+1):
    if not f.get(i,0):
        dp[i]=(dp[i-1]+dp[i-2])%(10**9+7)
print(dp[n])
from math import ceil
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int,input().split()))
b = ['0'] * (n+1)
c = ceil((n+1)/2)-1
for i in range(c, n):
    if a[i] == 1:
        b[i+1] = '1'
    else:
        b[i+1] = '0'
    
for i in reversed(range(0, c)):
    d = n // (i+1)
    cn = 0
    for j in range(1, d+1, i+1):
        if b[j] == '1':
            cn += 1
    if cn % 2 == a[i]:
        b[i+1] = '0'
    else:
        b[i+1] = '1'
print(b.count('1'))
del b[0]
ee = []
for i,v in enumerate(b):
    if v == '1':
        ee.append(i)
print(' '.join(ee))

### FIXED CODE ###

import sys
input = sys.stdin.readline

from math import ceil

n = int(input())
a = list(map(int,input().split()))
b = ['0'] * (n+1)
    
for i in reversed(range(0, n)):
    d = n // (i+1)
    cn = 0
    for j in range(2, d+1):
        if b[j*(i+1)] == '1':
            cn += 1
    if cn % 2 == a[i]:
        b[i+1] = '0'
    else:
        b[i+1] = '1'
print(b.count('1'))
ee = []
for i,v in enumerate(b):
    if i == 0:
        continue
    if v == '1':
        ee.append(str(i))
print(' '.join(ee))
#input
N = int(input())
Tree = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    if a > b:
        a, b = b, a
    Tree[a-1].append(b-1)

# process
# treeを2グループに分類
tg = [-1]*(N)
tg[0] = 0
for i, t in enumerate(Tree):
    g = (tg[i]+1)%2
    for p in t:
        tg[p] = g

# 順列を求める
ans = [0]*N
cnt0 = tg.count(0)
cnt1 = N-cnt0
if cnt0 < 2 or cnt1 < 2:
    for i in range(0, N):
        ans[i] = i+1
else:
    mod0 = 3
    mod1 = 1
    mod2 = 2
    for i, g in enumerate(tg):
        if g == 0 and mod1 <= N:
            ans[i] = mod1
            mod1 += 3
        elif g == 1 and mod2 <= N:
            ans[i] = mod2
            mod2 += 3
        elif mod0 <= N:
            ans[i] = mod0
            mod0 += 3
        else:
            ans = [-1]

# output
print(" ".join(map(str, ans)))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
from collections import deque

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

# process
# 頂点を2グループに分類
group = [-1]*N
group[0] = False
def categorize2g(pi, i, g):
    for ci in Edges[i]:
        if ci == pi:
            continue
        group[ci] = not g
        categorize2g(i, ci, not g)

categorize2g(-1, 0, 0)

# 順列を求める
ans = [0]*N
mod0 = [x for x in range(1, N+1) if x%3 == 0]
mod1 = [x for x in range(1, N+1) if x%3 == 1]
mod2 = [x for x in range(1, N+1) if x%3 == 2]
gtnum = sum(group)
if gtnum <= N//3:
    dq = deque(mod1+mod2+mod0)
elif N-gtnum <= N//3:
    dq = deque(mod0+mod1+mod2)
else:
    dq = deque(mod1+mod0+mod2)

if len(ans) == N:
    for i, g in enumerate(group):
        if g:
            ans[i] = dq.pop()
        else:
            ans[i] = dq.popleft()

# output
# print(group)
print(" ".join(map(str, ans)))
import numpy as np

queue = [np.array([ int(n) for n in input().split() ] + [0])]

while queue:
    now = queue.pop(0)
    print(now)

    if now[0] == now[1] == now[2]:
        print(now[3])
        break

    min = np.argmin(now[:3])
    
    if(np.max(now[:3])-np.min(now[:3]) > 2):
        now[min] += 2
        now[3] += 1
        queue.append(now)

    else:
        queue.append(now+[1, 1, 0, 1])
        queue.append(now+[1, 0, 1, 1])
        queue.append(now+[1, 1, 0, 1])
        queue.append(now+[0, 1, 1, 1])
        queue.append(now+[1, 0, 1, 1])
        queue.append(now+[0, 1, 1, 1])



### FIXED CODE ###

from collections import Counter
 
print("Yes" if Counter(input()) == Counter("abc") else "No")
import math

a,b,h,m = map(int, input().split())
start = 30*h
d = min(abs(start - 5.5 * m),360-abs(start - 5.5 * m))
if int(d)!=90 and int(d)!= 0:
    c = math.cos(math.radians(d))
    k = a**2+b**2-2*a*b*c
    ans = math.sqrt(k) 
    print(ans)
elif int(d) == 0:
    print(abs(a-b))
    print(c)
elif int(d) ==90:
    k= a**2+b**2
    ans = math.sqrt(k)
    print(ans)


### FIXED CODE ###

a,b,h,m = map(int, input().split())
import math
a_x = a * math.cos(math.radians(30*h + 0.5*m))
a_y = a * math.sin(math.radians(30*h + 0.5*m))
b_x = b * math.cos(math.radians(6*m))
b_y = b * math.sin(math.radians(6*m))

ans = math.sqrt(abs(a_x - b_x)**2 + abs(a_y - b_y)**2)
print(ans)
S=input()
anlist=[]
check=["A","C","G","T"]
a=0
for i in S:
  if i in check:
    a+=1
  else:
    anlist.append(a)
    a=0
print(max(anlist))


### FIXED CODE ###

S=input()
anlist=[]
check=["A","C","G","T"]
a=0
for i in S:
  if i in check:
    a+=1
  else:
    anlist.append(a)
    a=0
  anlist.append(a)
print(max(anlist))
import collections
n = int(input())
v = list(map(int, input().split()))
a = []
b = []
for i in range(n // 2):
    a.append(v[(i+1)*2-1])
    b.append(v[(i+1)*2-2])
a = collections.Counter(a)
b = collections.Counter(b)


if a.most_common()[0][0] != b.most_common()[0][0]:
    print(n-a.most_common()[0][1]-b.most_common()[0][1])
elif a.most_common()[1][1] + b.most_common()[0][1] > a.most_common()[0][1] + b.most_common()[1][1]:
    print(n-a.most_common()[1][1] - b.most_common()[0][1])
else:
    print(n-a.most_common()[0][1] - b.most_common()[1][1])

### FIXED CODE ###

import collections
n = int(input())
v = list(map(int, input().split()))
a = []
b = []
for i in range(n // 2):
    a.append(v[(i+1)*2-1])
    b.append(v[(i+1)*2-2])
a = collections.Counter(a)
b = collections.Counter(b)


if a.most_common()[0][0] != b.most_common()[0][0]:
    print(n - a.most_common()[0][1] - b.most_common()[0][1])
elif len(a.most_common()) == 1 and len(b.most_common()) == 1:
    print(n//2)
elif a.most_common()[1][1] + b.most_common()[0][1] > a.most_common()[0][1] + b.most_common()[1][1]:
    print(n - a.most_common()[1][1] - b.most_common()[0][1])
else:
    print(n - a.most_common()[0][1] - b.most_common()[1][1])
# キャンディの個数を取得
a,b,c　= map(int, input().split())

#判定結果をもとにメッセージを出力
if a == b + c\
or b == a + c\
or c == a + b:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

# キャンディの個数を取得
a,b,c = map(int,input().split())

#判定結果をもとにメッセージを出力
if a == b + c\
or b == a + c\
or c == a + b:
  print("Yes")
else:
  print("No")
a,b=map(int(input().split()))
if a==2 or b==2:
  print('No')
else:
  print('Yes')

### FIXED CODE ###

a,b=map(int,input().split())
if a==2 or b==2:
  print('No')
else:
  print('Yes')
import itertools
import numpy
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
r = list(map(lambda x: x - 1, r))
d = numpy.array([[10 ** 10] * N for _ in range(N)])

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

for i in range(N):
    d[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

ans = 10 ** 10

for i in itertools.permutations(r):
    dist = 0
    for j in range(R - 1):
        dist += d[i[j]][i[j + 1]]
    ans = min(ans, dist)

print(ans)


### FIXED CODE ###

import itertools
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
r = list(map(lambda x: x - 1, r))
d = [[10 ** 10] * N for _ in range(N)]

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

for i in range(N):
    d[i][i] = 0

for k in range(N):
    for i in range(N):
        for j in range(N):
            d[i][j] = min(d[i][j], d[i][k] + d[k][j])

ans = 10 ** 10

for i in itertools.permutations(r):
    dist = 0
    for j in range(R - 1):
        dist += d[i[j]][i[j + 1]]
    ans = min(ans, dist)

print(ans)
N = int(input())
A = map(int, input().split())

MOD = 10**9 + 7

total = 0
for i in range(N):
  for j in range(i+1, N):
    total += A[i] * A[j]

print(total % MOD)

### FIXED CODE ###

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

MOD = 10**9 + 7

sum_a = sum(A)
sum_squares = sum([a*a for a in A])

ans = (sum_a**2 - sum_squares)//2
ans %= MOD

print(ans)
import math
from functools import reduce

N, X = map(int, input().split(' '))
city = list(map(int, input().split(' ')))
for i in range(N):
    city[i] = city[i] - X
    
def gcd(numbers):
    return reduce(math.gcd, numbers)

if N == 1:
    ans = city[0]
else:
    ans = gcd(city)

print(ans)

### FIXED CODE ###

import fractions
from functools import reduce

N, X = map(int, input().split(' '))
city = list(map(int, input().split(' ')))
for i in range(N):
    city[i] = abs(city[i] - X)
    
def gcd(numbers):
    return reduce(fractions.gcd, numbers)

if N == 1:
    ans = city[0]
else:
    ans = gcd(city)

print(ans)
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    K = int(readline())
    X = int(readline())
    Y = int(readline())
    if N<=K:
        ans = X*N
    else:
        ans += X*k + Y*(N-K)
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    K = int(readline())
    X = int(readline())
    Y = int(readline())
    if N <= K:
        ans = X * N
    else:
        ans = X * K + Y * (N - K)
    print(ans)


if __name__ == '__main__':
    main()
a, b, x =map(int, inpit().split())

if a + b < x:
  print('No')
else:
  if a > x:
    print('No')
  else:
    print('Yes')


### FIXED CODE ###

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

if 0 <= x-a <= b:
  print('YES')
else:
  print('NO')
import sys
input = sys.stdio.readline

n = int(input())
h = tuple(map(int, input().split()))

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

### FIXED CODE ###

n = int(input())
h = tuple(map(int, input().split()))

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