Harryxun/stf_run huggingface dataset:
from collections import Counter
N,A,B = map(int,input().split())
V=list(map(int,input().split()))

V_C=Counter(V)

tmp_sum=0
tmp_num=0


for key in sorted(V_C.keys(),reverse=True):
    val = V_C[val]
    if tmp_num+val<=B:
        tmp_num+=val
        tmp_sum+=key*val
    if tmp_num>=A:
        break
else:
    #A個になるまで追加する
    exit()

print(tmp_sum/tmp_num)
print(1)


### FIXED CODE ###

from collections import Counter
from collections import Counter
N, A, B = (list)(map(int, input().split()))
v = (list)(map(int, input().split()))

v = sorted(v, reverse=True)

sel_list = v[:A]
max_ave = sum(sel_list)/A
print(max_ave)

c = Counter(v)


def comb(n, r):
    r = min(r, n-r)
    ret = 1
    for i in range(r):
        ret *= (n-i)/(i+1)
    return ret


def ave_n(n):
    sel_list = v[:n]
    ave = sum(sel_list)/i
    if ave != max_ave:
        return 0
    last = sel_list[-1]
    use_last = sel_list.count(last)
    return comb(c[last], use_last)


ans = 0
for i in range(A, B+1):
    ret = ave_n(i)
    if ret == 0:
        break
    else:
        ans += ret
print((int)(ans))
if a.isdigit()==True and b.isdigit()==True and c.isdigit()==True and k.isdigit()==True:
    a = int(a)
    b = int(b)
    c = int(c)
    k = int(k)
    if a>=0 and b>=0 and c>=0 and k>=1 and k<=(a+b+c) and (a+b+c)<=2*(10**9):
        if k < a:
            print(k)
        elif k >= a and k <= (a+b):
            print(a)
        else:
            print(a - (k - b - a))

### FIXED CODE ###

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

result = 0
t = min(a, k)
result += t
k -= t
t = min(b, k)
k -= t
t = min(c, k)
result -= t
print(result)
def input(): return sys.stdin.readline().strip()


def resolve():
    from scipy.sparse.csgraph import connected_components  # https://note.nkmk.me/python-scipy-connected-components/
    from scipy.sparse import csr_matrix

    N, M = map(int, input().split())  # 頂点数、辺数
    A, B, C = [0] *  M, [0] * M, [1] * (M-1)
    for i in range(M):
        A[i], B[i] = map(int, input().split())
        A[i]-=1
        B[i]-=1

    cnt = 0
    for i in range(M):
        #print(B[:i] + B[i + 1:i + M] + B[i + M + 1:])
        #print(A[:i] + A[i + 1:i + M] + A[i + M + 1:])
        csr = csr_matrix((C, (A[:i] + A[i + 1:], B[:i] + B[i + 1:])), shape=(N, N))
        #print(csr)
        #print('haha')
        n, labels = connected_components(csr)
        if n == 2:
           cnt += 1
    print(cnt)


resolve()

### FIXED CODE ###

S=list(map(int,input().split()))
for i in range(3):
    if S.count(S[i])==1:
        print(S[i])
n=int(input())

#11桁で足りる

alp=[chr(ord('a') + i) for i in range(26)]
lst=[0]*11

for i in range(11):
    if n>=26**(10-i):
        a,n=divmod(n,26**(10-i))
        lst[i]=alp[a]

switch=0
for i in range(10):
    if lst[i]==0:
        if switch==0:
            lst.remove(0)
        else:
            lst[i]="a"
    else:
        switch=1

print("".join(lst))

### FIXED CODE ###

alp=[chr(i) for i in range(97,123)]
n=int(input())

for i in range(1,12):
    if n>26**i:
        n-=26**i
    else:
        keta=i
        break
#その桁数の名前のなかでn番目
n-=1
lst=[]
#このnを26進数で表し、0~25にa~zをあてはめる
for i in range(keta):
    p,n=divmod(n,26**(keta-i-1))
    lst.append(alp[p])
    
print("".join(lst))
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    OPT[value] - minimum weight that achieves value
    OPT[value] = OPT[value-v[i]]
    """
    N, W = read_ints()
    max_value = 1000*N+1
    dp = [math.inf]*max_value
    dp[0] = 0
    for i in range(N):
        w, v = read_ints()
        for j in range(max_value-1, -1, -1):
            if j >= v:
                dp[j] = min(dp[j], dp[j-v]+w)
    ans = 0
    for j in range(max_value):
        if dp[j] <= W:
            ans = j
    return ans


if __name__ == '__main__':
    print(solve())


### FIXED CODE ###



def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    """
    OPT[value] - minimum weight that achieves value
    OPT[value] = OPT[value-v[i]]
    """
    N, W = read_ints()
    max_value = 1000*N+1
    dp = [10**12+1]*max_value
    dp[0] = 0
    for i in range(N):
        w, v = read_ints()
        for j in range(max_value-1, -1, -1):
            if j >= v:
                dp[j] = min(dp[j], dp[j-v]+w)
    ans = 0
    for j in range(max_value):
        if dp[j] <= W:
            ans = j
    return ans


if __name__ == '__main__':
    print(solve())
n = int(input())
arr = list(map(int,input().split()))
mul = eval('*'.join([str(n) for n in arr]))
print("-1" if mul > (10**18) else mul)

### FIXED CODE ###

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

if 0 in arr:
    print(0)
else:
    r = 1
    for i in arr:
        if r*i > 10**18:
            print(-1)
            exit()
        r *= i
    print(r)
N, K, Q = map(int,input().split())

A = [int(input()) for _ in range(Q)]

Point = [ 0 for _ in range(Q)]

for a in A:
    Point[a-1] += 1

for p in Point:
    if K - (K - p) > 0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

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

A = [int(input()) for _ in range(Q)]

Point = [ 0 for _ in range(N)]

if K-1 >= Q:
    for _ in range(N):
        print("Yes")

else:
    for a in A:
        Point[a-1] += 1

    for p in Point:
        if K - Q + p > 0:
            print("Yes")
        else:
            print("No")
# -*- coding: utf-8 -*-

import math
import functools

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

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

max_under_lcm = functools.reduce(lambda x, y: int((x * y) / gcd(x,y)), numbers) - 1
answer = sum([ max_under_lcm % n for n in numbers])

print(answer)


### FIXED CODE ###

import functools
import fractions

N = int(input())
numbers = list(map(int, input().split()))
answer = sum([n - 1 for n in numbers])

print(answer)
import math

n, m = map(int, input().split())
c = 0
f = [math.floor(n/2), math.floor(n/2) + 1]
if n % 2 == 0:
    while c < m:
        c += 1
        if c == math.ceil(n/4)　+ 1:
            if (f[0] - 1) % n == 0:
                f[0] = n
            else:
                f[0] = (f[0] - 1) % n
        print(str(f[0]) + ' ' + str(f[1]))
        if (f[0] - 1) % n == 0:
            f[0] = n
        else:
            f[0] = (f[0] - 1) % n
        if (f[1] + 1) % n == 0:
            f[1] = n
        else:
            f[1] = (f[1] + 1) % n
if n % 2 == 1:
    while c < m:
        c += 1
        print(str(f[0]) + ' ' + str(f[1]))
        if (f[0] - 1) % n == 0:
            f[0] = n
        else:
            f[0] = (f[0] - 1) % n
        if (f[1] + 1) % n == 0:
            f[1] = n
        else:
            f[1] = (f[1] + 1) % n

### FIXED CODE ###

import math

n, m = map(int, input().split())
c = 0
f = [math.floor(n/2), math.floor(n/2) + 1]
if n % 2 == 0:
    while c < m:
        c += 1
        if c == math.floor(n/4) + 1:
            if (f[1] + 1) % n == 0:
                f[1] = n
            else:
                f[1] = (f[1] + 1) % n
        print(str(f[0]) + ' ' + str(f[1]))
        if (f[0] - 1) % n == 0:
            f[0] = n
        else:
            f[0] = (f[0] - 1) % n
        if (f[1] + 1) % n == 0:
            f[1] = n
        else:
            f[1] = (f[1] + 1) % n
else:
    while c < m:
        c += 1
        print(str(f[0]) + ' ' + str(f[1]))
        if (f[0] - 1) % n == 0:
            f[0] = n
        else:
            f[0] = (f[0] - 1) % n
        if (f[1] + 1) % n == 0:
            f[1] = n
        else:
            f[1] = (f[1] + 1) % n
N = int(input())
A = {}

MAX = 0
for i in range(N):
    s = input()
    A[s] = A.get(s,0) + 1
    MAX = max(MAX, A[s])

A = sorted(A.items())
for k,v in A.items():
  if MAX == v:
    print(k)

### FIXED CODE ###

N = int(input())
A = {}

MAX = 0
for i in range(N):
    s = input()
    A[s] = A.get(s,0) + 1
    MAX = max(MAX, A[s])

B = sorted(A.items())
for k, v in B:
    if v == MAX:
        print(k)
n=int(input())l=list(map(int,input().split()))
u=max(l)
d=0
i=0
while l[i]!=u:
  if l[i]>l[i+1]:
    d=d+abs(l[i+1]-l[i])
    l[i+1]=l[i] 
  i=i+1
r=i
for b in range(r,n):
    d=d+(u-l[b])
print(d)


### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
u=max(l)
d=0
i=0
while l[i]!=u:
  if l[i]>l[i+1]:
    d=d+abs(l[i+1]-l[i])
    l[i+1]=l[i] 
  i=i+1
r=i
for b in range(r,n):
    d=d+(u-l[b])
print(d)
N = input()
A="No"
for i in range(len(N)):
    if N[i]="7":
        A = "Yes"
        break
        
    

print(A)
  
  


### FIXED CODE ###

N = input()
A="No"
for i in range(len(N)):
    if N[i]=="7":
        A = "Yes"
        break
        
    
 
print(A)
a,b=map(int,input().split())
for i in range(10000):
    if int(i*0.08) == A and int(i*0.1) == B:
        print(i)
        break
else:
    print(-1)


### FIXED CODE ###

A, B = map(int, input().split())
 
for i in range(10000):
    if int(i * 0.08) == A and int(i * 0.1) == B:
        print(i)
        break
else:
    print(-1)
a, b, c=input().split()
if 'a < b < c' :
    print( 'Yes' )
    else :
        print( 'No' )


### FIXED CODE ###

a, b, c=input().split()
if a < b < c :
    print('Yes')
else :
    print('No')
H,W=map(int,input().split())
A=[input() for i in range(H)]

for i in range(H):
	for j in range(W):
		if A[i][j]=='#':
			f=False
			for a,b in [(-1,0),(1,0),(0,1),(0,-1)]:
				if 0<=i+a<H and 0<=j+b<W:
					if A[i+a][j+b]=='#':f=True
			if not(f):break

print('Yes' if f else 'No')

### FIXED CODE ###

H,W=map(int,input().split())
A=[input() for i in range(H)]

f=True
for i in range(H):
	for j in range(W):
		if A[i][j]=='#':
			g=False
			for a,b in [(-1,0),(1,0),(0,1),(0,-1)]:
				if 0<=i+a<H and 0<=j+b<W:
					if A[i+a][j+b]=='#':g=True
			if not(g):f=False

print('Yes' if f else 'No')
a,b = input().split()
A=int(a)
b.replace('.','')
B=int(b)
print(A*B)

### FIXED CODE ###

a,b = input().split()
A=int(a)
B=int(b.replace('.',''))
print((A*B)//100)
s = input()
left = 0
right = len(s) - 1
x_left = 0
x_right = 0
if len(s) >= 2:
    while (left <= right):
        if s[left] == s[right]:
            left += 1
            right -= 1
        elif s[left] == "x":
            x_left += 1
            left += 1
        elif s[right] == "x":
            x_right += 1
            right -= 1
        if (right - left == 1) & (s[left] != s[right]):
            if (s[left] != "x") & (s[right] != "x"):
                print(-1)
                exit()
            else:
                print(x_left + x_right + 1)
                exit()
    print(x_left + x_right)
else:
    print(0)

### FIXED CODE ###

s = input()
left = 0
right = len(s) - 1
x_left = 0
x_right = 0
if len(s) >= 2:
    while (left <= right):
        if s[left] == s[right]:
            left += 1
            right -= 1
        elif s[left] == "x":
            x_left += 1
            left += 1
        elif s[right] == "x":
            x_right += 1
            right -= 1
        else:
            print(-1)
            exit()
    print(x_left + x_right)
else:
    print(0)
l=make_divisors(n)


### FIXED CODE ###

n=int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
l=make_divisors(n)
print(len(str(max(l[len(l)//2],l[len(l)//2-1]))))
a = int(input())
b = int(input())
if a*b%2 == 1:
    print("Odd")
elif a*b%2 == 0:
    print("Even")

### FIXED CODE ###

a, b = map(int, input().split())
if a*b%2 == 1:
    print("Odd")
else:
    print("Even")
import math
a,b,c = map(int,input(),split())
n = math.pow((c-a-b),2)
m = 4*a*b
if(a+b >= c):
    print("No")
else:
    if(n > m):
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

import math
a,b,c = map(int,input().split())
l = 4*a*b
r = (c-a-b)**2
if (a+b >= c):
    print("No")
else:
    if(l < r):
        print("Yes")
    else:
        print("No")
def eratos(n):
	is_prime = [True for i in range(n+1)]
	for i in range(2, n):
		if i * i > n:
			break
		for j in range(i*i, n, i):
			is_prime[j] = False
	return is_prime

is_prime = eratos(10000)
n = int(input())
ans = 0
for _ in range(n):
    x = int(input())
    if is_prime[x] is True:
        ans += 1

print(ans)


### FIXED CODE ###

def eratos(n):
	is_prime = [True for i in range(n+1)]
	is_prime[0] = False
	is_prime[1] = False
	for i in range(2, n+1):
		if i * i > n:
			break
		for j in range(i*i, n+1, i):
			is_prime[j] = False
	return is_prime

is_prime = eratos(10000)
primes = []
for i in range(10001):
    if is_prime[i] is True:
        primes.append(i)

n = int(input())
ans = 0
for _ in range(n):
    x = int(input())
    if x <= 10000:
        if is_prime[x] is True:
            ans += 1
    else:
        ok = True
        for i in primes:
            if i * i > x:
                break
            if x % i == 0:
                ok = False
                break
        if ok is True:
            ans += 1
    
print(ans)
n, k = map(int, input().split())
p = list(map(int, input().split()))
tmp = [0] * 10000

rmax = -1
pos = -1
for i in range(n-k+1):
    _t = sum(p[i: i+k])
    if pos < _t:
        pos = _t
        rmax = i

ans = 0
for i in range(rmax, rmax+k):
    if tmp[i] == 0:
        t = 0
        for j in range(1, p[i]+1):
            t += j
            #tmp[j] = t / j
        t = t / p[i]

        tmp[i] = t
        ans += t
#        print(t)
#    else:
#        ans += tmp[i]
#        print(tmp[i])

print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
s = [0] * (n+1)

for i in range(0, n):
    s[i+1] = s[i] + p[i]

s_max = -1
pos = 0
for i in range(n-k+1):
    ss = s[i+k] - s[i]
    if ss > s_max:
        s_max = ss
        pos = i

ans = 0.0
for i in range(pos, pos+k):
    ans += (p[i]+1) / 2

print(ans)
n, m = map(int, input().split())
rootList = [-1] * n

def getRoot(x):
    if rootList[x] < 0:
        return x
    rootList[x] = getRoot(rootList[x])
    return rootList[x]

def setSameRoot(x, y):
    x = getRoot(x)
    y = getRoot(y)
    if x != y:
        G[x], G[y] = min(x, y), min(x, y)

for i in range(m):
    s, t = map(int, input().split())
    setSameRoot(s, t)
q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    print("yes" if getRoot(s) == getRoot(t) != -1 else "no")

### FIXED CODE ###

n, m = map(int, input().split())
rootList = [-1 for i in range(n)]
 
def getRoot(x):
    r = rootList[x]
    if r < 0:
        rootList[x] = x
    elif r != x:
        rootList[x] = getRoot(r)
    return rootList[x]
 
 
def setSameRoot(x, y):
    x = getRoot(x)
    y = getRoot(y)
    if x != y:
        rootList[x] = rootList[y] = min(x, y)
 
for i in range(m):
    s, t = map(int, input().split())
    setSameRoot(s, t)
q = int(input())
for i in range(q):
    s, t = map(int, input().split())
    print("yes" if getRoot(s) == getRoot(t) else "no")
A = list(map(int,input().split()))
B = list(map(int,input().split()))
if A[0] == B[2] and A[1] == B[1] and A[2] == B[0]:
  print("YES")
else:
  print("NO")

### FIXED CODE ###

A = input()
B = input()
if A[0] == B[2] and A[1] == B[1] and A[2] == B[0]:
  print("YES")
else:
  print("NO")
from math import log2


def build():
    dfs(tree, 0, -1, 0)
    pk0 = parent[0]
    for k in range(1, logn):
        pk1 = parent[k]
        for v in range(n):
            pkv = pk0[v]
            pk1[v] = -1 if pkv < 0 else pk0[pkv]
        pk0 = pk1


def dfs(tree, v, p, d):
    parent[0][v] = p
    depth[v] = d
    for child in tree[v]:
        if child != p:
            dfs(tree, child, v, d + 1)


def get(u, v):
    du, dv = depth[u], depth[v]
    if du > dv:
        u, v = v, u
        du, dv = dv, du
    for k in range(logn):
        if (dv - du) >> k & 1:
            v = parent[k][v]
    if u == v:
        return u
    for k in range(logn - 1, -1, -1):
        pk = parent[k]
        if pk[u] != pk[v]:
            u, v = pk[u], pk[v]
    return parent[0][u]


n = int(input())
tree = [set(map(int, input().split()[1:])) for _ in range(n)]

logn = int(log2(n)) + 1
parent = [[0] * n for _ in range(logn)]
depth = [0] * n
build()

q = int(input())
for _ in range(q):
    print(get(*map(int, input().split())))

### FIXED CODE ###

from math import log2


def build():
    dfs()
    pk0 = parent[0]
    for pk1 in parent[1:]:
        for v in range(n):
            pkv = pk0[v]
            pk1[v] = -1 if pkv < 0 else pk0[pkv]
        pk0 = pk1


def dfs():
    stack = [(0, -1, 0)]
    while stack:
        v, p, d = stack.pop()
        parent[0][v] = p
        depth[v] = d
        stack.extend((child, v, d + 1) for child in tree[v])


def get(u, v):
    du, dv = depth[u], depth[v]
    if du > dv:
        u, v = v, u
        du, dv = dv, du
    for k, pk in enumerate(parent):
        if (dv - du) >> k & 1:
            v = pk[v]
    if u == v:
        return u
    for pk in parent[logn - 1:None:-1]:
        pku, pkv = pk[u], pk[v]
        if pku != pkv:
            u, v = pku, pkv
    return parent[0][u]


n = int(input())
tree = [set(map(int, input().split()[1:])) for _ in range(n)]

logn = int(log2(n)) + 1
parent = [[0] * n for _ in range(logn)]
depth = [0] * n
build()

q = int(input())
for _ in range(q):
    print(get(*map(int, input().split())))
a, b, k = map(float(), input().split(" "))
if a+b <= k:
  print("0 0")
elif a >= k:
  print(f'{a-k} 0')
else:
  print(f'0 {(a+b)-k}')

### FIXED CODE ###

a, b, k = map(int, input().split(" "))
if a+b <= k:
  print('0 0')
elif a >= k:
  c = a-k
  print(c, ' ', b)
else:
  c = (a+b)-k
  print('0 ', c)
n = int(input())
nums = [int(input()) for _ in range(int(input()))]
print(len(set(nums)))


### FIXED CODE ###

nums = [int(input()) for _ in range(int(input()))]
print(len(set(nums)))
N=int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans=0
j=0

for i in range(N):
	ans+=B[A[i]-1]
	if A[i]-j==1 and i>=1:
		ans+=C[j-1]
	j=A[i]

print(ans)

### FIXED CODE ###

n=int(input())
print(n**3)
N = int(input())
A = []
for _ in range(N):
  A.appen(input())
B = list(set(A))
print(len(B))

### FIXED CODE ###

N = int(input())
A = []
for _ in range(N):
  A.append(input())
B = list(set(A))
print(len(B))
a, b = map(int, input().split())
print(a * a - b)

### FIXED CODE ###

a = int(input())
b = int(input())
print(a * a - b)
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort(reverse=True)
d=[max(a)//2]
a.pop(0)
for i in range(m-1):
  if a[0]>=d[0]:
    d.append(a[0]//2)
    a.pop(0)
  else:
    d.append(d[0]//2)
    d.pop(0)
print(sum(d)+sum(a))
    

### FIXED CODE ###

import heapq
N, M = list(map(int,input().split()))
h = []
for i in input().split():
  heapq.heappush(h,-int(i))
for i in range(M):
  x = -heapq.heappop(h)
  x //=2
  heapq.heappush(h,-x)
print(-sum(h))
from math import gcd as bltin_gcd
import itertools

def coprime2(a, b):
    return bltin_gcd(a, b) == 1

A, B = map(int, input().split())
koyakusuu_list = []
for a in range(1, A+1):
    if a == 1:
        koyakusuu_list.append(1)
    elif B % a == 0 and A % a == 0:
        flag = 0
        for kouyakusuu in koyakusuu_list:
            if coprime2(a, kouyakusuu):
                continue
            else:
                flag += 1
        if flag == 0:
            koyakusuu_list.append(a)

print(len(set(koyakusuu_list)))

### FIXED CODE ###

import fractions

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

f = fractions.gcd(A, B)

kouyakusuu = []

if f % 2 == 0:
    kouyakusuu.append(2)
    while f % 2 == 0:
        f = f / 2

i = 3
while i*i <= f:
    if f % i == 0:
        kouyakusuu.append(i)
        while f % i == 0:
            f = f / i
    i += 2
if f != 1:
    kouyakusuu.append(f)
print(len(kouyakusuu)+1)
n = int(input())

x = dict()
for i in input().split():
    x[i] = x.get(i, 0) + 1

m = int(input())

for i in input().split():
    if x[i] == 0 or i not in x:
        print("NO")
        exit()
    else:
        x[i] -= 1
print("YES")

### FIXED CODE ###

n = int(input())

ht = {}

for i in input().split():
  ht[i] = ht.get(i, 0) + 1

m = int(input())

for i in input().split():
  if i not in ht or ht[i] == 0:
    print("NO")
    exit()
  else:
    ht[i] -= 1

print("YES")
N=int(input())
Graph=[[] for i in range(N)]
for i in range(N-1):
  u,v,w=map(int,input().split())
  w%=2
  Graph[u-1].append((v-1,w))
  Graph[v-1].append((u-1,w))
  
root=0
color=[-1]*N
color[0]=0
def dfs(x):
  for i,w in Graph[x]:
    if color[i]==-1:
      color[i]=(color[x]+w)%2
      dfs(i)
dfs(0)
for i in range(N):
  print(color[i])
    

### FIXED CODE ###

from sys import setrecursionlimit
setrecursionlimit(10**8)
N=int(input())
Graph=[[] for i in range(N)]
for i in range(N-1):
  u,v,w=map(int,input().split())
  w%=2
  Graph[u-1].append((v-1,w))
  Graph[v-1].append((u-1,w))
  
root=0
color=[-1]*N
color[0]=0
def dfs(x):
  for i,w in Graph[x]:
    if color[i]==-1:
      color[i]=(color[x]+w)%2
      dfs(i)
dfs(0)
for i in range(N):
  print(color[i])
n=input()

sum=0

for i in int(n):
  if (i%3!=0)&(i%5!=0):
    sum+=i
print(sum)

### FIXED CODE ###

n=input()
 
sum=0
 
for i in range(1,int(n)+1):
  if (i%3!=0)&(i%5!=0):
    sum+=i
    
print(sum)
from collections import deque
N,M = map(int, input().split())
if M == 0:
	print(-1)
	exit()
Q = {0:deque([1])}
distance = {1:0}

#辺へ重み付け
edges = {}
for _ in range(M):
	p,q,c = map(int, input().split())
	edge = {}
	edge[c*10**6+q] = 0
	edge[p] = 0
	edges.setdefault(c*10**6+p, {})
	edges[c*10**6+p].update(edge)
	edge = {}
	edge[c*10**6+p] = 0
	edge[q] = 0
	edges.setdefault(c*10**6+q, {})
	edges[c*10**6+q].update(edge)
	edge = {}
	edge[c*10**6+p] = 1
	edges.setdefault(p, {})
	edges[p].update(edge)
	edge = {}
	edge[c*10**6+q] = 1
	edges.setdefault(q, {})
	edges[q].update(edge)

flag = False
while 1:
	for i in range(len(Q)):                            
		if not (Q[i]):
			continue
		flag = True
		target_min_ind = Q[i].popleft()
		target_node = edges[target_min_ind]
		break
	if not (flag):
		break

	for key, value in target_node.items():
		distance.setdefault(key, float('inf'))
		dist = distance[target_min_ind] + value
		if distance[key] > dist:
			distance[key] = dist
			Q.setdefault(dist, deque())
			Q[dist].append(key)
		if key == N:
			flag = False
	if not (flag):
		break

print(distance[N] if distance[N] != float('inf') else -1)

### FIXED CODE ###

from collections import deque
N, M = map(int, input().split())
F_C_of_S = [{} for i in range(N)]
#Companies of Station
C_of_S = {}

#def Union-find
parent = [-1]*M
def root(x):
	if (parent[x] < 0): return x
	else:
		parent[x] = y = root(parent[x])
		return y

def unite(x, y):
	px = root(x)
	py = root(y)
	if (px == py): return False
	if (parent[px] > parent[py]):
		px = root(y)
		py = root(x)
	parent[px] += parent[py]
	parent[py] = px
	return True


#Union-find
pqcs = []
for i in range(M):
	p, q, c = map(int, input().split())
	p -= 1; q -= 1;
	pqcs += [(p, q, c)]
	
	#The first
	if not c in F_C_of_S[p]: F_C_of_S[p][c] = i
	#else
	else: unite(F_C_of_S[p][c], i)
	C_of_S.setdefault(p, set()).add(c)
	
	#The first
	if not (c in F_C_of_S[q]):F_C_of_S[q][c] = i
	#else
	else: unite(F_C_of_S[q][c], i)
	C_of_S.setdefault(q, set()).add(c)

#stations of company
S_of_C = {}
for i in range(M):
	p, q, c = pqcs[i]
	c_set = S_of_C.setdefault(root(i), set())
	c_set.add(p)
	c_set.add(q)


Q = deque([(0, 0, 0)])
#cost to go to the stations from station_0
dist = [float('inf')]*N
dist[0] = 0

gdist = [float('inf')]*M

while Q:
	cost, v, flag = Q.popleft()
	
	if not (flag):#(flag == 0) then gdist_update
		if (dist[v] < cost) or (v not in C_of_S):
			continue
		for l in F_C_of_S[v].values():
			l = root(l)
			if (cost < gdist[l]):
				gdist[l] = cost
				Q.appendleft((cost, l, 1))
	
	else:#(flag == 1) then dist_update
		if (gdist[v] < cost) or (v not in S_of_C):
			continue
		for s in S_of_C[v]:
			if (cost+1 < dist[s]):
				dist[s] = cost+1
				Q.append((cost+1, s, 0))

print(dist[N - 1] if dist[N - 1] < float('inf') else -1)