Harryxun/stf_run huggingface dataset:
import bisect
import sys
import math
input = sys.stdin.readline
import functools

from collections import defaultdict

############ ---- Input Functions ---- ############

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

############ ---- Solution ---- ############

def diff(S, i, T):
    res = 0
    for j in range(len(T)):
        if S[i + j] != T[j]:
            res += 1
    return res

def solve():
    [N, M] = inlt()
    uf = [i for i in range(N)]

    def root(i):
        if uf[i] == i:
            return i
        res = root(uf[i])
        uf[i] = res
        return res

    def union(i, j):
        uf[root(i)] = root(j)

    for i in range(M):
        [a, b] = inlt()
        union(a - 1, b - 1)

    groups = defaultdict(int)
    res = 0
    for i in range(N):
        r = root(i)
        groups[r] += 1
        res = max(res, groups[r])
    
    return res

    

if len(sys.argv) > 1 and sys.argv[1].startswith("input"):
    f = open("./" + sys.argv[1], 'r')
    input = f.readline

res = solve()
print(str(res))


### FIXED CODE ###

import bisect
import sys
import math
input = sys.stdin.readline
import functools

from collections import defaultdict

############ ---- Input Functions ---- ############

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

############ ---- Solution ---- ############

def dfs(i, edges, visited):
    s = []
    if not visited[i]:
        s.append(i)
        visited[i] = True
    res = 0
    while len(s) > 0:
        v = s.pop()
        res += 1
        for i in edges[v]:
            if not visited[i]:
                s.append(i)
                visited[i] = True

    return res

def solve():
    [N, M] = inlt()
    edges = defaultdict(set)
    visited = [False for i in range(N)]

    for i in range(M):
        [a, b] = inlt()
        edges[a - 1].add(b - 1)
        edges[b - 1].add(a - 1)

    res = 0
    for i in range(N):
        res = max(res, dfs(i, edges, visited))
    
    return res

    

if len(sys.argv) > 1 and sys.argv[1].startswith("input"):
    f = open("./" + sys.argv[1], 'r')
    input = f.readline

res = solve()
print(str(res))
N = int(input())
A = []
for i in range(N):
    a = int(input())
    A.append(a)
    
    
B = []
B.append(A[0])
pre = A[0]
cnt = 0
for i in range(1, N):
    if A[i] > B[cnt] and A[i] > pre:
        pre = A[i]
    elif A[i] <= pre:
        if A[i] <= B[cnt]:
            pre = A[i]
            B.append(A[i])
            cnt += 1
        else:
            del B[-1]
            if A[i] > max(B):
                pre = A[i]
            else:
                cnt += 1
                pre = A[i]
print(cnt+1)

### FIXED CODE ###

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

A = [0] + A
for i in range(N//2, 0, -1):
    A[i] = sum(A[i::i])%2
ans = [i for i in range(N+1) if A[i]]
print(len(ans))
print(*ans)
X=input()
s=input()
s=s.replace(X,"")
print(s)

### FIXED CODE ###

N=int(input())
count=0
for i in range(1,N+1):
    if len(str(i))%2==1:
        count +=1
print(count)
s=input()
s = 0
a = input()
a = a.split(" ")
for u in a:
    s=s+int(a)
print(min(a),max(a),s)


### FIXED CODE ###

n = input()
s = 0
a = input()
b = a.split(" ")
c = []
for i in range(int(n)):
    c.append(int(b[i]))

for u in c:
    s=s+u

print(min(c),max(c),s)
while 1:
	n,m=map(int, raw_input().split())
	if n==0:break
	c=sorted(map(int,raw_input().split()))[::-1]
	if m > n:
		print sum(c)
	else:
		c[m-1::m] = [0 for i in range(m-1,n,m)]
		print sum(c)
	

### FIXED CODE ###

# try-except is necessary for avoiding Runtime Error 
while 1:
	try:
		n,m=map(int,raw_input().split())
		if n==0:break
		v=sorted(map(int,raw_input().split()))[::-1]
		for i in range(m-1,n,m):
			v[i]=0
		print sum(v)
	except:
		pass
import math
r = int(imput())
print(2*math.pi*r)

### FIXED CODE ###

import math
r = int(input())
print(2*math.pi*r)
s1, s2, s3 = input().split()

print(s1[0].upper() + s2[0].uppter() + s3[0].upper())

### FIXED CODE ###

s1, s2, s3 = input().split()
print(s1[0].upper() + s2[0].upper() + s3[0].upper())
a,b = map(nit,input().split())
print('Yes') if a*b%2 ==1 else print('No')

### FIXED CODE ###

a,b = map(int,input().split())
print('Yes') if a*b%2 ==1 else print('No')
import sys
a, b, c = map(int, sys.argv[1:])
b2 = a
c2 = b
a2 = c
print(a2, b2, c2)


### FIXED CODE ###

in_ = input()
a, b, c = map(int, in_.split())
b2 = a
c2 = b
a2 = c
print(a2, b2, c2)
k = int(input())
s = list(input())
an_lis = []
if len(s) <= k:
    ans = "".join(s)
    print(ans)
else:
    for i in range(k):
        an_lis.append(s[i])
    an_lis.append("...")
    ans = "".join(an_lis)
    print(ans)


### FIXED CODE ###

a, b, h, m = map(int, input().split())
import math

a_ang = (h/12 + (1/12)*(m/60))*2*math.pi
b_ang = (m/60)*2*math.pi
ax = a*math.cos(a_ang)
bx = b*math.cos(b_ang)
ay = a*math.sin(a_ang)
by = b*math.sin(b_ang)

x = ax - bx
y = ay - by
ans = (x**2+y**2)**0.5
print(ans)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import functools

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
    
@functools.lru_cache(maxsize = None)
def func(N, X):
    g = gcd(N, X)
    if g == 1:
        if X > N // 2:
            return func(N, N - X)
        if N == 2:
            return 3
        if N == 3:
            return 6
        return X * 3 + func(N-X, X)
    else:
        return g * func(N//g, X//g)

N,X = map(int,input().split())
print(func(N,X))


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import functools

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
    
# @functools.lru_cache(maxsize = None)
# def func(N, X):
#     g = gcd(N, X)
#     if g == 1:
#         if X > N // 2:
#             return func(N, N - X)
#         if N == 2:
#             return 3
#         if N == 3:
#             return 6
#         return X * 3 + func(N-X, X)
#     else:
#         return g * func(N//g, X//g)


def func_fast(N, X):
    g = gcd(N, X)
    if g == 1:
        return 3 * N - 3
    else:
        return g * func_fast(N // g, X // g)

N,X = map(int,input().split())
print(func_fast(N,X))
from itertools import*
import math
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 1000003
from functools import reduce
import sys
sys.setrecursionlimit(10**7)
input=sys.stdin.readline

Max = mod-1
#二項係数とその逆元テーブルを作る前処理
fac = [0]*(Max)
finv = [0]*(Max)
inv = [0]*(Max)
fac[0]=fac[1]=1
finv[0]=finv[1]=1
inv[1]=1
for i in range(2,Max):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i]*(mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
#O(1)でmod計算した組合せ数を計算
def Comb(n,r):
    if n < r:
        return 0
    if n < 0 or r < 0 :
        return 0
    return fac[n]*(finv[r]*finv[n-r]%mod)%mod


Q = int(input())
def query(x,d,n):
    if x == 0:
        return 0
    if d == 0:
        return pow(x,n,mod)
    k = (x*inv[d])%mod
    if k+n-1 >= mod:
        return 0
    ans = fac[k+n-1]*finv[k-1]%mod
    ans *= pow(d,n,mod)
    ans %= mod
    return ans
for i in range(Q):
    x,d,n = map(int,input().split())
    print(query(x,d,n))

### FIXED CODE ###

from itertools import*
import math
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 1000003
from functools import reduce
import sys
sys.setrecursionlimit(10**7)


Max = mod
#二項係数とその逆元テーブルを作る前処理
fac = [0]*(Max)
finv = [0]*(Max)
inv = [0]*(Max)
fac[0]=fac[1]=1
finv[0]=finv[1]=1
inv[1]=1
for i in range(2,Max):
        fac[i] = fac[i-1] * i % mod
        inv[i] = mod - inv[mod%i]*(mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
#O(1)でmod計算した組合せ数を計算
def Comb(n,r):
    if n < r:
        return 0
    if n < 0 or r < 0 :
        return 0
    return fac[n]*(finv[r]*finv[n-r]%mod)%mod


Q = int(input())
def query(x,d,n):
    if x == 0:
        return 0
    if d == 0:
        return pow(x,n,mod)
    k = (x*inv[d])%mod
    if k+n-1 >= mod:
        return 0
    ans = fac[k+n-1]*finv[k-1]%mod
    ans *= pow(d,n,mod)
    ans %= mod
    return ans
for i in range(Q):
    x,d,n = map(int,input().split())
    print(query(x,d,n))
a, b, c = map(int ,input().split())
	print((a+0.5)//c * a)

### FIXED CODE ###

a, b, c = map(int ,input().split())
print(int((c+0.5)//a * b))
a=int(input())
b=list(input())
c=0
for i in range(a):
  if b[i]='A':
  else:
    pass
    if b[i+1]='B':
    else:
      pass
      if b[i+2]='C':
        c+=1
      else:
        pass
  
print(c)


### FIXED CODE ###

n=int(input())
s=list(input())
d=0
for i in range(n):
  if n-(i+1)>=2:
    if s[i]=='A' and s[i+1]=='B' and s[i+2]=='C':
      d+=1
  else:
    pass
print(d)
temperature = int(input())

if 30 <= temperature:
    print('Yes')
els:
    print('No')


### FIXED CODE ###

temperature = int(input())

if 30 <= temperature:
    print("Yes")
else:
    print("No")
from collections import deque
n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)


colors = [0] * n
def dfs(v, color):
    colors[v] = color
    for to in edges[v]:
        if colors[to] == color:
            return False
        if colors[to] == 0 and (not dfs(to, -color)):
            return False

    return True

if dfs(0, 1):
    x = colors.count(1)
    print(x * (n - x) - m)

else:
    print(n * (n - 1) // 2 - m)

### FIXED CODE ###

from collections import deque
import sys
sys.setrecursionlimit(10 ** 7)
n, m = map(int, input().split())
edges = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)


colors = [0] * n
def dfs(v, color):
    colors[v] = color
    for to in edges[v]:
        if colors[to] == color:
            return False
        if colors[to] == 0 and (not dfs(to, -color)):
            return False

    return True

if dfs(0, 1):
    x = colors.count(1)
    print(x * (n - x) - m)

else:
    print(n * (n - 1) // 2 - m)
#

import sys
input=sys.stdin.readline

def main():
    MOD=10**9+7
    S=input().strip("\n")
    q=[]
    g=0
    S=S[::-1]
    m13=(1,10,9,12,3,4)
    for i in range(len(S)):
        if S[i] == "?":
            q.append(m13[i%6])
        else:
            x=int(S[i])
            g+=x*m13[i%6]
            g%=13
    N=len(q)
    q=[0]+q
    dp=[[0]*13 for i in range(N+1)]
    for j in range(10):
        dp[1][(j*q[1])%13]=1
    for i in range(2,N+1):
        for j in range(13):
            for k in range(10):
                x=(j-k*q[i])%13
                dp[i][j]+=dp[i-1][x]
                dp[i][j]%=MOD
    print(dp[N][(5-g)%13])
    
if __name__=="__main__":
    main()


### FIXED CODE ###

#

import sys
input=sys.stdin.readline

def main():
    MOD=10**9+7
    S=input().strip("\n")
    q=[]
    g=0
    S=S[::-1]
    m13=(1,10,9,12,3,4)
    for i in range(len(S)):
        if S[i] == "?":
            q.append(m13[i%6])
        else:
            x=int(S[i])
            g+=x*m13[i%6]
            g%=13
    if len(q)==0:
        if g==5:
            print(1)
        else:
            print(0)
        exit()
    N=len(q)
    q=[0]+q
    dp=[[0]*13 for i in range(N+1)]
    for j in range(10):
        dp[1][(j*q[1])%13]=1
    for i in range(2,N+1):
        for j in range(13):
            for k in range(10):
                x=(j-k*q[i])%13
                dp[i][j]+=dp[i-1][x]
                dp[i][j]%=MOD
    print(dp[N][(5-g)%13])
    
if __name__=="__main__":
    main()
n,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
index1=a.index(1)
if k>=index1+1 or n-(index1+1)<=k:
    print(round((len(a)-1)/(k-1)))
else:
    ans=float("inf")
    for i in range(k):
        ans=min(ans,1+round((index1+1-k+i)/k)+round(n-(index1+1+i))/k))
    print(ans)

### FIXED CODE ###

n,k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
import math
print(math.ceil((len(a)-1)/(k-1)))
X,  K,  D = list(map(int, input().split()))
L = X + D * K
 
if X >= 0:
   if K == 1 or D == 1:
      print(abs(X - D*K))
      exit()

elif X < 0:
   if K == 1 or D == 1:
      print(abs(X + D*K))
      exit()

elif L >= 0:
   if L / (2 * D) - int(L / (2 * D)) > 0.5:
      a = L // (2 * D) + 1
   else:
      a = L // (2 * D)
 
elif L < 0:
   if L / (2 * D) - int(L / (2 * D)) < -0.5:
      a = int(L / (2 * D)) - 1
   else:
      a = int(L / (2 * D)) 
print(abs(X-2*D*a+D*K))

### FIXED CODE ###

x, k, d = list(map(int,input().split()))

a = (k * d - x) / (2 * d)

if abs(x) < k * d:
   if abs(int(a) + 1 - a) >= abs(int(a) - a):
      print(abs(x + 2 * int(a) * d - k * d))
   else:
      print(abs(x + 2 * (int(a) + 1) * d - k * d))

elif x < 0:
   print(abs(x + k * d))
else:
   print(x - k * d)
s = str(input())
if s[2]=s[3] & s[4]=s[5]:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

S = str(input())
if S[2]==S[3] and S[4]==S[5]:
  print("Yes")
else:
  print("No")
N = int(input())
L = []

for i in range(1,int(N ** 0.5)):
  if N % i == 0:
    L.append(i + N // i)
print (min(L)-2)


### FIXED CODE ###

N = int(input())
L = []

for i in range(1,int(N ** 0.5)+1):
  if N % i == 0:
    L.append(i + N // i)
print (min(L)-2)
a , b = map(int,input().split())


list = []

for i in range(b):
  list.append(input())
  
list.sort()
print(join(list))


### FIXED CODE ###

a , b = map(int,input().split())
c_list = sorted([input() for i in range(a)])
print("".join(c_list))
import copy

def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())

    if V <= W:
        print('NO')
    elif (abs(A-B) / (V-W)) <= t:
        print('YES')
    else:
        print('NO')

main()

### FIXED CODE ###

import copy

def main():
    A, V = map(int, input().split())
    B, W = map(int, input().split())
    T = int(input())

    if V <= W:
        print('NO')
    elif (abs(A-B) / (V-W)) <= T:
        print('YES')
    else:
        print('NO')

main()
print(len(set(list(map(int,input().split()))))


### FIXED CODE ###

print(len(set(map(int,input().split()))))
# スペース区切りの整数の入力
p,q,r = map(int, raw_input().split())

# 出力
Print(p+q+r-max(p, q, r))

### FIXED CODE ###

p,q,r=map(int,input().split())
print(p+q+r-max(p,q,r))
import numpy as np
N,M = map(int, input().split())
A = []
for i in range(N):
    A.append(input())
B = []
for i in range(M):
    M.append(input())
A = np.array(A)
B = np.array(B)

for i in range(N-M):
    for j in range(N-M):
        if A[i:i+M, j:j+M] == B:
            print('Yes')
            exit()
print('No')

### FIXED CODE ###

N,M = map(int, input().split())
A = []
for i in range(N):
    A.append(input())
B = []
for i in range(M):
    B.append(input())

for i in range(N-M+1):
    for j in range(N-M+1):
        tmp = [A[i+k][j:j+M] for k in range(M)]
        if tmp == B:
            print('Yes')
            exit()
print('No')
x = int(input())
if 400 <= x <= 599: ans = 8
elif 600 <= x <= 799: ans = 7
elif 800 <= x <- 999: ans = 6
elif 1000 <= x <= 1199: ans = 5
elif 1200 <= x <= 1399: ans = 4
elif 1400 <= x <= 1599: ans = 3
elif 1600 <= x <= 1799: ans = 2
elif 1800 <= x <= 1999: ans = 1
print(ans)

### FIXED CODE ###

x = int(input())
if 400 <= x <= 599: ans = 8
elif 600 <= x <= 799: ans = 7
elif 800 <= x <= 999: ans = 6
elif 1000 <= x <= 1199: ans = 5
elif 1200 <= x <= 1399: ans = 4
elif 1400 <= x <= 1599: ans = 3
elif 1600 <= x <= 1799: ans = 2
elif 1800 <= x <= 1999: ans = 1
print(ans)
n, y = map(int,input().split())
y = y / 1000
for i in range(n+1):
    for j in range(n-i+1):
        if 10 * i + 5 * j + 1 * (n - i - j) == y:
            print(i)
            print(j)
            print(n - i - j)
            exit(1)
print(-1)
print(-1)
print(-1)

### FIXED CODE ###

n, y = map(int,input().split())
y = y / 1000
f = 0
for i in range(n+1):
    for j in range(n-i+1):
        #print(i)
        if 10 * i + 5 * j + 1 * (n - i - j) == y:
            print(i)
            print(j)
            print(n - i - j)
            f = 1
            break
    if f == 1:
        break
if f != 1:
    print(-1)
    print(-1)
    print(-1)
N, Y = map(int, input().split())
Y = Y //1000
#x, y, z =1, 5, 10
for x in range(N+1):
    y = (10*N-9*x-Y)//5
    z = ((-5*N)+Y+4*x)//5
    
    if (-5*N+y+4*x) % 5 == 0 and  (10*N-9*x-Y) % 5 == 0 and y >= 0 and z >= 0 and x+y+z = Y:
        print(x, y, z)
        break
else:
    print(-1, -1, -1)

### FIXED CODE ###

n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print("-1 -1 -1")
n,k=map(int,input().split())
s=input()
if "0" not in s:
	print(len(s))
	exit()
p=s[0]
a=[]
d=[]
b=[]
cnt_1=0
cnt_0=0
p=s[0]
for i in range(len(s)):
	if p!=s[i]:
		if p=="0":
			a.append(cnt_0)
			cnt_0=0
			p="1"
		else:
			b.append(cnt_1)
			cnt_1=0
			p="0"
	if s[i]=="0":
		cnt_0+=1
	else:
		cnt_1+=1
if cnt_0>0:
	a.append(cnt_0)
else:
	b.append(cnt_1)
if len(a)<=len(b):
	k+=1
	if len(a)==len(b):
		if s[0]=="0":
			b.insert(0,0)
		else:
			b.insert(-1,0)
	for i in range(len(b)-k+1):
		d.append(sum(b[i:i+k])+sum(a[i:i+k-1]))
else:
	b.insert(0,0)
	b.insert(len(b),0)
	for i in range(len(b)-k+1):
		k+=1
		d.append(sum(b[i:i+k])+sum(a[i:i+k-1]))
print(max(d))


### FIXED CODE ###

n,k=map(int,input().split())
s=input()
cnt=[]
now=s[0]
p=0
for i in range(n):
	if s[i]==now:
		p+=1
	else:
		cnt.append(p)
		now=s[i]
		p=1
cnt.append(p)
ans=0
r=[]
cum_sum=0
for i in range(len(cnt)):
	cum_sum+=cnt[i]
	r.append((cnt[i],cum_sum))
for i in range(len(r)):
	if s[r[i][1]-r[i][0]]=="1":
		e=r[min(i+2*k,len(r)-1)][1]-r[i][1]+r[i][0]
	else:
		e=r[min(i+2*k-1,len(r)-1)][1]-r[i][1]+r[i][0]
	ans=max(ans,e)
print(ans)
N, M, C = int(input())
B = list(map(int, inpot().split()))
count = 0
for j in range(N):
    A = list(map(int, input().split()))
calc = 0
for i in range(M):
    calc = A[i] * B[i]
    if C + calc > 0:
        count+=1

print(count)      
      
  


### FIXED CODE ###

N, M, C = map(int, input().split())
B = list(map(int, input().split()))
calc = 0
ans = 0

for i in range(N):
    A = list(map(int,input().split()))
    calc = 0
    for j in range(M):
        calc += A[j] * B[j]

    if calc + C > 0:
        ans += 1

print(ans)
N,K = map(int,input().split())
para = [[i for i in map(int,input().split())] for j in range(N)]
ans= []
size = 0
for i in range(N) :
    if N > K :
        break
    else: 
        ans += para[i]
        size = len(ans)
print("{}".format(ans[K]))

### FIXED CODE ###


def list_pos(cnt,a,b,ans):
    if ans  >= b :
        return cnt-1
    else :

        ans += a[cnt][1]
        cnt += 1
        return list_pos(cnt,a,b,ans)
import sys
sys.setrecursionlimit(100000)
N,K = map(int,input().split())
para = {}
for i in range(N):
    a,b  = map(int,input().split())
    if not a in para.keys():
        para[a] = b
    else : para[a] += b

para = sorted(para.items(),key =lambda x:x[0])

p = list_pos(0,para,K,0)
print("{}".format(para[p][0]))
#!/usr/bin/env python3
import sys


def solve(S: int, K: int):
    for i, s in enumerate(str(S)):
        if s != '1':
            return s
        if K == i:
            return s
    raise

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    print(solve(S, K))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(S: int, K: int):
    for i, s in enumerate(str(S)[:K]):
        if s != '1':
            return s
    return 1

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    print(solve(S, K))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()
N,X = map(int, input().split())
print(N)
print(X)

def para(a,b):
    if a > b:
        return a+b + para(b,a-b)
    if a < b:
        return 2*a + para(a,b-a)
    if a == b:
        return 3*a
print(X+para(X,N-X))

### FIXED CODE ###

N,X = map(int,input().split(" "))
 
Y,X = sorted([N - X,X])
 
s = 0
while Y:
    s += (X//Y)*Y*3
    Y,X = [X%Y,Y]
 
print(s)
w,h,n=map(int,input().split())
o=[0,0]
c=[w,h]
for _ in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    o[0]=x if o[0]<x
  elif a==2:
    c[0]=x if c[0]>x
  elif a==3:
    o[1]=y if o[1]<y
  else:
    c[1]=y if c[1]>y
if o[0]<c[0] and o[1]<c[1]:
  print((c[0]-o[0])*(c[1]-o[1]))
else:
  print(0)

### FIXED CODE ###

w,h,n=map(int,input().split())
o=[0,0]
c=[w,h]
for _ in range(n):
  x,y,a=map(int,input().split())
  if a==1:
    o[0]=x if o[0]<x else o[0]
  elif a==2:
    c[0]=x if c[0]>x else c[0]
  elif a==3:
    o[1]=y if o[1]<y else o[1]
  else:
    c[1]=y if c[1]>y else c[1]
if o[0]<c[0] and o[1]<c[1]:
  print((c[0]-o[0])*(c[1]-o[1]))
else:
  print(0)
def main():
    N = int(input())
    a_list = get_a_list()

    a_list.sort(reverse=True)

    sum_second_a = 0
    
    import pdb; pdb.set_trace()
    while len(a_list) > 0:
        a_list.pop(0)
        sum_second_a += a_list.pop(0)
        a_list.pop(-1)

    print(sum_second_a)

def get_a_list():
    a_list = []
    strs = input().split()

    for a in strs:
        a_list.append(int(a))

    return a_list


if __name__ == '__main__':
    main()


### FIXED CODE ###


def main():
    N = int(input())
    a_list = get_a_list()

    a_list.sort(reverse=True)

    sum_second_a = 0
    
    a_list = a_list[:2*N]
    for i in range(1, 2*N, 2):
        sum_second_a += a_list[i]

    print(sum_second_a)

def get_a_list():
    a_list = []
    strs = input().split()

    for a in strs:
        a_list.append(int(a))

    return a_list


if __name__ == '__main__':
    main()
import numpy as np

def main():
    num, weigh = map(int, input().split())
    dp = np.zeros((num + 1, weigh + 1), dtype=int)

    for i in range(1, num + 1):
        now_weigh, now_value = map(int, input().split())
        dp[i, :now_weigh] = dp[i - 1, :now_weigh]
        dp[i, now_weigh:] = np.maximum(dp[i - 1, :weigh - now_weigh + 1] + now_value, dp[i - 1, now_weigh:])

    print(dp[-1][-1])


if __name__ == '__main__':
    main()



### FIXED CODE ###

from collections import defaultdict

def main():
    num, weigh = map(int, input().split())
    dp = [defaultdict(int) for i in range(num + 1)]
    dp[0][0] = 0

    for i in range(1, num + 1):
        data = list(map(int, input().split()))
        for pre_value in dp[i - 1].keys():
            dp[i][pre_value] = max(dp[i - 1][pre_value], dp[i][pre_value])
            if pre_value + data[0] <= weigh:
                dp[i][pre_value + data[0]] = max(dp[i - 1][pre_value] + data[1], dp[i][pre_value + data[0]])

    print(max(list(dp[-1].values())))


if __name__ == '__main__':
    main()
A=int(input())
a=A%10
B=int(input())
b=B%10
C=int(input())
c=C%10
D=int(input())
d=D%10
E=int(input())
e=E%10
if a=b=c=d=e=0:
  print(A-a+B-b+C-c+D-d+E-e+4*10-10*[a,b,c,d,e].count(0))
else:
  print(A-a+B-b+C-c+D-d+E-e+4*10+min(set([a,b,c,d,e])-set([0]))-10*[a,b,c,d,e].count(0))

### FIXED CODE ###

a=int(input())
p=a%10
b=int(input())
q=b%10
c=int(input())
r=c%10
d=int(input())
s=d%10
e=int(input())
t=e%10
l=[a,b,c,d,e]
m=[p,q,r,s,t]
ans=0
if set(m)==set([0]):
    minimum=10
else:
    minimum=min(list(set(m)-set([0])))
def func(n):
    if n%10==0:
        return n
    else:
        return (n//10)*10+10
for i in range(5):
    ans+=func(l[i])
ans=ans-10+minimum
print(ans)