Harryxun/stf_run huggingface dataset:
def f(n,k,x):
    dis = [x[i+1]-x[i] for i in range(n-1)]#隣り合う家の距離を調べる
    dis.sort()#電線の数-1だけ隣り合う家同士の電線を配置しなくて良い
    return sum(dis[:n-k])#隣り合う家の距離が大きい順にkー1個は電線を配置しない
    
t = int(input())
for i in range(t):
    n,k = map(int,input().split())
    x = list(map(int,input().split()))
    print(ans)


### FIXED CODE ###

def f(n,k,x):
    if n <= k-1:
        return 0
    dis = [x[i+1]-x[i] for i in range(n-1)]#隣り合う家の距離を調べる
    dis.sort()#電線の数-1だけ隣り合う家同士の電線を配置しなくて良い
    return sum(dis[:n-k])#隣り合う家の距離が大きい順にkー1個は電線を配置しない
    
t = int(input())
for i in range(t):
    n,k = map(int,input().split())
    x = list(map(int,input().split()))
    print(f(n,k,x))
while True:
    string = raw_input()
    strings = strings.split()
    a = int(strings[0])
    op = strings[1]
    b = int(strings[2])
    if op == '?':
        break
    elif op == '+':
        print a + b
    elif op == '-':
        print a - b
    elif op == '*':
        print a * b
    elif op == '/':
        print a / b

### FIXED CODE ###

while True:
    string = raw_input()
    strings = string.split()
    a = int(strings[0])
    op = strings[1]
    b = int(strings[2])
    if op == '?':
        break
    elif op == '+':
        print a + b
    elif op == '-':
        print a - b
    elif op == '*':
        print a * b
    elif op == '/':
        print a / b
k = int(input())
print(int((k/2)**2)) if k%2 == 0 else print(int(k/2)**2 - 1/4))


### FIXED CODE ###

k = int(input())
print(int((k/2)**2)) if k%2 == 0 else print(int((k/2)**2 - 1/4))
count = 0
while all(a % 2 == 0 for a in A):
    A = [a/2 for a in A]
    count += 1
print(count)

### FIXED CODE ###

input()
A = list(map(int, input().split()))
count = 0
while all(a % 2 == 0 for a in A):
  A = [a/2 for a in A]
  count += 1
print(count)
A,B = input.split()
A = int(A)
B = round(float(B)*100)

res = (A*B)//100
print(res)


### FIXED CODE ###

A,B = input().split()
A = int(A)
B = round(float(B)*100)

res = (A*B)//100
print(res)
D, N= int(input().split())
print(N*(100**D))

### FIXED CODE ###

A = input().split()
D = int(A[0])
N = int(A[1])
 
if N != 100:
  print(100 ** D * N)
else:
  print(100 ** D * 101)
n=int(input())
a=list(map(int,input().split()))
count = {}
ans = 0
for i in a:
    count[i] += 1
for i,c in count.items():
    if i > c:
        ans += c
    elif i < c:
        ans += c - i
print(ans)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
count = {}
ans = 0
for i in a:
    if i not in count:
        count[i] = 1
    else:
        count[i] += 1
for i,c in count.items():
    if i > c:
        ans += c
    elif i < c:
        ans += c - i
print(ans)
from collections import deque
n,m = map(int,input().split())
l = []
for i in range(n):
    a = list(input())
    l.append(a)
print(l[0][1])
ans = 0
for i in range(n):
    for j in range(m):
        if l[i][j] == ".":
            bfs = [[-1]*m for k in range(n)]
            bfs[i][j] = 0
            q = deque([])
            q.append((i,j))
            dx = [0,0,-1,1]
            dy = [-1,1,0,0]
            while q:
                x,y = q.popleft()

                for t in range(4):
                    nx = x+dx[t]
                    ny = y + dy[t]

                    if 0 <= nx < n and 0 <= ny < m and bfs[nx][ny] == -1 and l[nx][ny] != "#":
                        q.append((nx,ny))
                        bfs[nx][ny] = bfs[x][y] +1

            for bf in bfs:
                ans = max(ans,max(bf))
            
print(ans)


### FIXED CODE ###

from collections import deque
n,m = map(int,input().split())
l = []
for i in range(n):
    a = list(input())
    l.append(a)

ans = 0
for i in range(n):
    for j in range(m):
        if l[i][j] == ".":
            bfs = [[-1]*m for k in range(n)]
            bfs[i][j] = 0
            q = deque([])
            q.append((i,j))
            dx = [0,0,-1,1]
            dy = [-1,1,0,0]
            while q:
                x,y = q.popleft()

                for t in range(4):
                    nx = x+dx[t]
                    ny = y + dy[t]

                    if 0 <= nx < n and 0 <= ny < m and bfs[nx][ny] == -1 and l[nx][ny] != "#":
                        q.append((nx,ny))
                        bfs[nx][ny] = bfs[x][y] +1

            for bf in bfs:
                ans = max(ans,max(bf))
            
print(ans)
N, K = map(int,input().split())
import math
Sum = 0

for i in range(N):
    n = i + 1
    if n < k:
        Sum += pow(0.5, math.ceil(math.log(K/n, 2)))
    else:
        Sum += 1
Sum = Sum / N
print(Sum)

### FIXED CODE ###

N, K = map(int,input().split())
import math
Sum = 0

for i in range(N):
    n = i + 1
    if n < K:
        Sum += pow(0.5, math.ceil(math.log(K/n, 2)))
    else:
        Sum += 1
Sum = Sum / N
print(Sum)
from bisect import*
_,l=open(0)
*e,=enumerate(sorted(map(int,l.split())))
print(sum(j-bisect(l,a-b,0,j)for i,a in e for j,b in e[:i]))

### FIXED CODE ###

from bisect import*
n,*l=map(int,open(0).read().split())
l.sort()
A=0
for i in range(n):
    a=l[i]
    for j in range(i+1,n):
        b=l[j]
        k1=max(j+1,bisect(l,b-a))
        k2=bisect_left(l,a+b)
        A+=max(0,k2-k1)
print(A)
import math

N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = [abs(x[0]-X)]
    for i in range(N-1):
        xlen.append(x[i+1]- x[i])
    ans = xlen[0]
    for i in range(N-1):
        ans = math.gcd(ans,xlen[i+1])
    print(ans)

### FIXED CODE ###

def gcd(a,b) :
    if b>0 :
        return gcd(b,a % b)
    elif b == 0:
        return a


N,X = map(int,input().split())
x = list(map(int,input().split()))
if N == 1:
    print(abs(x[0] - X))
else:
    xlen = []
    for i in range(N):
        xlen.append(abs(x[i] - X))
        #print(xlen[i])
    ans = xlen[0]
    for i in range(1,N):
        ans = gcd(ans,xlen[i])
        #print(ans)
    print(ans)
from fractions import gcd

n = int(input())
ans = 1

for _ in range(n):
	i = int(input())
	ans = int(ans * i / gcd(ans, i))

print(ans)

### FIXED CODE ###

from fractions import gcd

n = int(input())
ans = 1

for _ in range(n):
	i = int(input())
	ans = ans // gcd(ans, i) * i

print(ans)
H,W = map(int,input().split())
a = [input() for _ in range(H)]

row = [False]*H
col = [Flase]*W

for i in range(H):
  for j in range(w):
    if a[i][j] == "#":
      row[i] = True
      col[j] = True

for i in range(h):
  if row[i]:
    for j in range(w):
      if col[j]:
        print(a[i][j],end = '')
  print()

### FIXED CODE ###

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

row = [False]*H
col = [False]*W

for i in range(H):
  for j in range(W):
    if a[i][j] == "#":
      row[i] = True
      col[j] = True

for i in range(H):
  if row[i]:
    for j in range(W):
      if col[j]:
        print(a[i][j],end = '')
    print()
import sys

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

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

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

L = lcm(N, M)
X = ["A"] * L

    
print(-20)
sys.exit()


for i in range(N):
    index = i * (L // N)
    X[index] = S[i]

for i in range(M):
    index = i * (L // M) 
    if X[index] != "A" and X[index] != T[i]:
        print(-1)
        sys.exit()
    
print(L)


### FIXED CODE ###

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

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

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

L = lcm(N, M)
s = L // M
t = L // N

if S[::s] != T[::t]:
    L = -1
print(L)
N,C=map(int,input().split())
imos=[0]*(10**5+1)
for i in range(N):
  s,t,c=map(int,input().split())
  imos[s-1]+=1
  imos[t]-=1
channels=[imos[0]]*(10**5+1)
for i in range(10**5):
  channels[i+1]=channels[i]+imos[i+1]
print(max(channels))

### FIXED CODE ###

a,b,c=map(int,input().split())
print(min(a*b,c))
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
ans = 0
while len(A)>= 2:
  ans += A[0]-A[1]
  A = A[2:]
if len(A) = 1:
  ans += A[0]
print(ans)
  
  


### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse = True)
ans = 0
while len(A)>= 2:
  ans += A[0]-A[1]
  A = A[2:]
if len(A) == 1:
  ans += A[0]
print(ans)
from math import pi
r=int(input())
print(pi*r**2)


### FIXED CODE ###

from math import pi
r = float(input())
a = pi*r*r
b = 2*pi*r
print(a,b)
Q = 998244353
def getInv(N):
    inv = [0] * (N + 1)
    inv[0] = 1
    inv[1] = 1
    for i in range(2, N + 1):
        inv[i] = (-(Q // i) * inv[Q%i]) % Q
    return inv

N, A, B, K = map( int, input().split())
ans = 0
invs = getInv(N)
nCk = [1]*(N+1)
for i in range(1,N+1):
    nCk[i] = (nCk[i-1]*(N-i+1)*invs[i])%Q
for i in range(N+1):
    j = (K-A*i)//B
    if A*i + B*j == K and j <= N:
        j = (K-A*i)//B
        ans = (ans + nCk[i]*nCk[j])%Q
print(ans)

### FIXED CODE ###

Q = 998244353
def getInv(N):
    inv = [0] * (N + 1)
    inv[0] = 1
    inv[1] = 1
    for i in range(2, N + 1):
        inv[i] = (-(Q // i) * inv[Q%i]) % Q
    return inv

N, A, B, K = map( int, input().split())
ans = 0
invs = getInv(N)
nCk = [1]*(N+1)
for i in range(1,N+1):
    nCk[i] = (nCk[i-1]*(N-i+1)*invs[i])%Q
for i in range(N+1):
    j = (K-A*i)//B
    if A*i + B*j == K and j <= N and 0 <= j:
        j = (K-A*i)//B
        ans = (ans + nCk[i]*nCk[j])%Q
print(ans)
import math
r = int(input())
print('{:.6f} {:.6f}'.format(math.pi*r*r, 2*math.pi*r))

### FIXED CODE ###

import math
r = float(input())
print('{:.6f} {:.6f}'.format(math.pi*r*r, 2*math.pi*r))
h,w = sorted(list(map(int,input().split())))
if h % 3 == 0 or w % 3 == 0:
  ret = 0
else:
  c1 = ((w//3+1)*h)-((w-1-w//3)*(h//2)
  c2 = ((w-w//3)*(h-h//2))-(w//3*h)
  c3 = ((w-w//3)*(h-h//2))-((w-w//3)*(h//2))
  ret = min(c1,c2,c3)
print(ret)


### FIXED CODE ###

h,w = sorted(list(map(int,input().split())))
if h % 3 == 0 or w % 3 == 0:
  ret = 0
else:
  c1 = ((w//3+1)*h)-((w-1-w//3)*(h//2))
  c2 = ((w-w//3)*(h-h//2))-(w//3*h)
  c3 = h
  c4 = ((h//3+1)*w)-((h-1-h//3)*(w//2))
  c5 = ((h-h//3)*(w-w//2))-(h//3*w)
  ret = min(c1,c2,c3,c4,c5)
print(ret)
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)
C = list(map(int,input().split()))
C.sort(reverse = True)

D = [0] * N

index = 0
def dfs(x, parent):
    global index
    D[x] = C[index]
#     index += 1
    for u in edges[x]:
        if u != parent:
            dfs(u, x)

dfs(0, -1)

print(sum(C[1:]))
print(*D)

### FIXED CODE ###

import sys
sys.setrecursionlimit(4100000)

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)
C = list(map(int,input().split()))
C.sort(reverse = True)

D = [0] * N

def dfs(x, parent, index):
    D[x] = C[index]
    index += 1
    for u in edges[x]:
        if u != parent:
            index = dfs(u, x, index)
    return index

dfs(0, -1, 0)

print(sum(C[1:]))
print(*D)
l,r=map(int,input().split())

if r-l>=2019: print(0)
else:
    min_mod=2018
    for i in range(l,r+1):
        for j in range(i+1,r+1):
            min_mod = min(min_mod, i*j%2019)
print(min_mod)

### FIXED CODE ###

l,r=map(int,input().split())
mod=2019
if r-l>=2019: print(0)
else:
    res=2018 #2019の剰余なので最大でも2018
    for i in range(l,r):
        for j in range(i+1,r+1):
            res = min(res, (i*j)%mod)
    print(res)
K = input()
S = input()
count = len(S)
list = 0
a = ""
for i in raige(K):
  a = a+S[list]
  list = list + 1

if count <= K:
  print(S)
else:
  print(a+"...")

### FIXED CODE ###

k = int(input())
s = str(input())
if len(s) <= k:
    print(s)
else:
    print((s[:k]) + "...")
if input() == 1:
  print("Hello World")
else:
  print(int(input())+int(input()))

### FIXED CODE ###

if input() == "1":
  print("Hello World")
else:
  print(int(input())+int(input()))
n, k = map(int, input().split())
l = [0 for _ in range(k)]
for i in range(1, k):
    j = pow(k//i, n, 10**9+7)
    while i < k:
        i += i
        j -= l[i-1]
    l[i-1] = j
ans = sum(l) % (10**9+7)

### FIXED CODE ###

n, k = map(int, input().split())
l = [0 for _ in range(k)]
for i in range(k-1, -1, -1):
    j = pow(k//(i+1), n, 10**9+7)
    for m in range(2, k//(i+1) + 1):
        j -= l[(i+1)*(m)-1]
    l[i] = j

ans = 0
for i in range(k):
    ans += (i+1) * l[i]
print(ans % (10**9+7))
import numpy as np

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

s = B if N > B else N
#print(s)

x = np.arange(0, int(s/2))
X = np.floor(A * x / B) - A * np.floor(x / B)

print(int(np.max(X)))

### FIXED CODE ###

# -*- coding: utf-8 -*-
A,B,N = map(int, input().split())
 
def function(x):
  return (A*x)//B-A*(x//B)
 
if B-1<=N:
  print(function(B-1))
else:
  print(function(N))
"""
左右一列にN個のマスが並んでいます。
左からi番目のマスの高さはH(i)
あなたは好きなマスに降り立ち、右隣のマスの高さが今居るマスの高さ以下である限り右隣のマスへ移動し続けます。
最大で何回移動できるでしょうか。
"""

import numpy as np

n = int(input())
h = list(map(int, input().split()))
tmp = []
ans = 0

for i in range(n-1):
  if h[i] < h[i+1]:
    tmp.append(1)
  else:
    tmp.append(0)
    
# print(tmp)
tmp_box = []
for i in tmp:
  tmp_box.append(ans)
  if i == 0:
    ans += 1
  else:
    ans == 0
    
    
print(max(tmp_box))

### FIXED CODE ###

"""
左右一列にN個のマスが並んでいます。
左からi番目のマスの高さはH(i)
あなたは好きなマスに降り立ち、右隣のマスの高さが今居るマスの高さ以下である限り右隣のマスへ移動し続けます。
最大で何回移動できるでしょうか。
"""
 
import numpy as np
 
n = int(input())
h = list(map(int, input().split()))
tmp = []
ans = 0

if n != 1:
  for i in range(n-1):
    if h[i] < h[i+1]:
      tmp.append(1)
    else:
      tmp.append(0)
    
box = []   
for i in tmp:
  if i == 0:
    ans += 1
  else:
    ans = 0
  box.append(ans)
    
# print(ans)
# print(box)

if n != 1:
  rslt = max(box)
else:
  rslt = 0
  
print(rslt)
n,m=map(int, input().split())
maru=0
pena=[0]*m

Num = []
St = []

toi=set() #重複無しのset型で用意，リストの重複がないやつ
for i in range(m):
    p, s = input().split()
    #Num.append(int(p))
    #St.append(s)
#print(Num[0])
#print(St)
    p=int(p)

    if p in toi:
        continue #以降はスキップ
    
    if s=='AC':
        maru+=1
        toi.add(p) #そのpの時のとい番号を保存
    else: 
        pena[p]+=1
print(maru, sum(pena[i] for i in toi)) #各pの時のWAをたす

### FIXED CODE ###

n,m=map(int, input().split())
maru=0
pena=[0]*n

Num = []
St = []

toi=set() #重複無しのset型で用意，リストの重複がないやつ
for i in range(m):
    p, s = input().split()
    #Num.append(int(p))
    #St.append(s)
#print(Num[0])
#print(St)
    p=int(p)-1 #0index

    if p in toi:
        continue #以降はスキップ

    elif s=='AC':
        toi.add(p) #そのpの時のとい番号を保存
        #print(p)
    else: 
        pena[p]+=1
print(len(toi), sum(pena[p] for p in toi)) #各pの時のWAをたす
import copy
n,m = map(int,input().split())
ht = [x for x in input().split()]
hl = {x + 1 : int(ht[x]) for x in range(len(ht))}
mx = {h:0 for h in hl}
for i in range(m):
    l,r = map(int,input().split())
    mx[l] = max(mx[l],hl[r])
    mx[r] = max(mx[r],hl[l])
cnt = 0
for h in hl:
    if mx[h] < hl[h]:
        cnt += 1
print(cnt)

### FIXED CODE ###

s = input()
ret = ""
if s=="ARC":
    ret = "ABC"
elif s=="ABC":
    ret = "ARC"
print(ret)
s,t=input(),input()
print(sum(1 if c is d for c,d in zip(s,t)))


### FIXED CODE ###

s,t=input(),input()
print(sum(c is d for c,d in zip(s,t)))
A, B = map(int, input().split())
 
diff = B - A
height_A = diff * (diff - 1) // 2
 
ans = height_A - A
 
print(ans)

### FIXED CODE ###

n=int(input())
print('ABC' if n < 1000 else 'ABD')
print(int(int(input() / 1000 + 1) * 1000 - N)

### FIXED CODE ###

N = int(input())
if N % 1000 == 0:
  print(0)
else:
  print(int(N / 1000 + 1) * 1000 - N )
N, M = input().split(" ")
N = int(N)
M = int(M)
s_list = []
c_list = []
for i in range(M):
    si, ci = input().split(" ")
    s_list.append(int(si))
    c_list.append(int(ci))

num = ["0" for i in range(N)]
is_num = [0 for i in range(N)]
is_break = False
for si, ci in zip(s_list, c_list):
    if num[si-1] != "0" and num[si-1] != str(ci):
        print(-1)
        is_break = True
        break
    else:
        num[si-1] = str(ci)
        num[si-1] = 1
if not is_break:
    num = int("".join([val for val in num]))
    if num:
        print(num)
    elif is_num[-1] == 0:
        print(1)
    else:
        print(0)

### FIXED CODE ###

N, M = input().split(" ")
N = int(N)
M = int(M)
s_list = []
c_list = []
for i in range(M):
    si, ci = input().split(" ")
    s_list.append(int(si))
    c_list.append(int(ci))
num = ["0" for i in range(N)]
is_break = False
for si, ci in zip(s_list, c_list):
    if num[si-1] != "0" and num[si-1] != str(ci):
        print(-1)
        is_break = True
        break
    elif N > 1 and si == 1 and ci == 0:
        print(-1)
        is_break = True
        break
    else:
        num[si-1] = str(ci)
if not is_break:
    num = "".join([val for val in num])
    if int(num[0]) or N == 1:
        print(int(num))
    else:
        print(int("1" + num[1:]))
S = input()
if S[-1] == "s":
	print( S + "es" )
else print( S + "s" )

### FIXED CODE ###

S = input()
if S[-1] == "s":
  print( S + "es" )
else: 
  print( S + "s" )
k, a, b = [ int(v) for v in input().split() ]

if a >= k:
    ans = 1
elif b > a:
    ans = -1
else:
    ans = 1 + ( ( k - b - 1 ) // (a - b) ) * 2
print(ans)

### FIXED CODE ###

k, a, b = [ int(v) for v in input().split() ]

if a >= k:
    ans = 1
elif b >= a:
    ans = -1
else:
    ans = 1 + ( ( k - b - 1 ) // (a - b) ) * 2
print(ans)
#整数＋リスト
w, h, x, y = list(map(int, input().split()))


xxx = x
yyy = y
if (x/w > y/h):
    xxx = y
    yyy = x
    
############
#print(xxx,yyy)

a = xxx*h
b = yyy*w
c = w*w*(h-yyy)/(w-xxx)/2

mmm = w*h

if (a > mmm/2):
    a = mmm - a

if (b > mmm/2):
    b = mmm - b

if (c > mmm/2):
    c = mmm - c

#############
#print(a,b,c)

rtn = max(a,b,c)
f = -1
if (a == rtn):
    f += 1
if (b == rtn):
    f += 1
if (c == rtn):
    f += 1
if (f == 2):
    f = 1

print('{0:.6f}'.format(rtn), f)


### FIXED CODE ###

#整数＋リスト
w, h, x, y = list(map(int, input().split()))

f = 0
if ((x*2 == w) and (y*2 == h)):
    f = 1

print(w*h/2,f)
n = input()
k = list(map(int, list(n)))
s = sum(n)
n = int(n)
if n%k:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

s = input()
c = 0
for i in s:
  c += int(i)
if int(s) % c:
  print("No")
else:
  print("Yes")
if input()== 'a':
    print('vowel')
elif input()=='i':
    print('vowel')
elif input()=='u':
    print('vowel')
elif input()=='e':
    print('vowel')
elif input()=='o':
    print('vowel')
else:
    print('consonant')

### FIXED CODE ###

c = {input()}
vowels = {'a', 'i', 'u', 'e', 'o'}
if c < vowels:
    print('vowel')
else:
    print('consonant')
N = int(input())
A = input()
A = A.split()
s = 0
for i in range(0,len(A)):
  s = s + 1/int(A[i])

print(1/s)

### FIXED CODE ###

a = int(input())
s = input()
print(s if a >= 3200 else 'red')
n=int(input())
l=list(map(int,input().split()))
ans=1
mod=1000000007
me=[0,0,0]
now=3
for x in l:
  if x==0:
    ans*now
    now-=1
    if now<0:
      print(0)
      quit()
    me[-now]=1
  else:
    a=len([i for i, y in enumerate(me) if y == x])
    if a>2:
      print(0)
      quit()
    ans=ans*a%mod    
    me[me.index(x)]+=1
if now==0:
  print(6*ans%mod)
else:
  print(3*ans%mod)

### FIXED CODE ###

n=int(input())
mod=1000000007
l=list(map(int,input().split()))
me=[3]+[0]*2*n
ans=1
for x in l:
  ans=ans*me[x]%mod
  me[x]-=1
  me[x+1]+=1
print(ans)
n = int(input())
a = list(map(int,input().split()))

x = [a[1],a[0],a[1] % a[0]]
a.sort()
for i in range(1,n+1):
    while x[2] > 0:
        x[0] = x[1]
        x[1] = x[2]
        x[2] = x[0] % x[1]
    x[0] = a[i+1]
    x[2] = x[0] % x[1]

print(x[1])


### FIXED CODE ###

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

a.sort()
x = [a[1],a[0],a[1] % a[0]]
for i in range(1,n):
    while x[2] > 0:
        x[0] = x[1]
        x[1] = x[2]
        x[2] = x[0] % x[1]
    if i != n - 1:
        x[0] = a[i+1]
        x[2] = x[0] % x[1]

print(x[1])
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())


def main():
    N, Q = map(int, input().split())
    uf = UnionFind(N)
    for _ in range(Q):
        u, v = map(int, input().split())
        uf.union(u, v)
    print(uf.group_count()-1)   
if __name__ == "__main__":
    main()


### FIXED CODE ###

class UnionFind():
    """
        unionfindtree のクラス
            グループを管理するデータ構造.
            全てのメソッドの計算量が O(log(n)) よりも小さい
        init: 管理対象の個数 n を用いて初期化
        find: ある要素 x の親がどの要素か返す
        union: ある要素 x と y が属しているグループを結合して1つのグループとする
        msize: ある要素 x が属するグループの大きさを返す
    """
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n
        self.rank = [0]*n
        self.size = [1]*n

    def find(self, x):
        """
            ある要素 x の親の要素を見つけるメソッド
        """
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        """
            ある要素 x, y の属するグループを結合するメソッド
            x と y のランク(子の数)の小さい方が結合先の親となる
        """
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.size[y] += self.size[x]
            self.parents[x] = y
        else:
            self.size[x] += self.size[y]
            self.parents[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    def msize(self, x):
        """
            ある要素 x の属するグループの大きさを返すメソッド
        """
        return self.size[self.find(x)]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())


def main():
    N, Q = map(int, input().split())
    uf = UnionFind(N)
    for _ in range(Q):
        u, v = map(int, input().split())
        uf.union(u-1, v-1)
    print(uf.group_count()-1)   
if __name__ == "__main__":
    main()
A,P = map(int, input().split())
print(((A*3)+P))//2)

### FIXED CODE ###

A,P = map(int,input().split())
print((3*A+P)//2)
import sys
def input(): return sys.stdin.readline()

n=int(input())
A=list(map(int,input().split()))
cnt=[0]*(10**6)
ans=0
for a in A:
  if cnt[a]!=0:
    cnt[a]=2
    continue
  x=a
  while x<10**6:
    cnt[x]+=1
    x+=a
for a in A:
  if cnt[a]==1:
    ans+=1
print(ans)


### FIXED CODE ###

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

n=int(input())
A=list(map(int,input().split()))
cnt=[0]*(10**6+2)
ans=0
for a in A:
  if cnt[a]!=0:
    cnt[a]=2
    continue
  x=a
  while x<10**6+2:
    cnt[x]+=1
    x+=a
for a in A:
  #print(cnt[a])
  if cnt[a]==1:
    ans+=1
print(ans)