Harryxun/stf_run huggingface dataset:
class UnionFind:
    def __init__(self, size: int):
        self.parent = [-1 for _ in range(size)]

    def unite(self, x, y):
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return
        if self.parent[px] > self.parent[py]:
            px, py = py, px
        self.parent[py] += self.parent[px]
        self.parent[px] = py
        return

    def find(self, x: int) -> int:
        if self.parent[x] < 0:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

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

    def is_same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)


def main():
    # input
    N, M = map(int, input().split())
    A, B = [], []

    for _ in range(M):
        a, b = map(int, input().split())
        A.append(a-1)
        B.append(b-1)

    # solve
    # ref: http://drken1215.hatenablog.com/entry/2019/03/03/224600
    # ref: https://atcoder.jp/contests/abc120/submissions/4450601
    uf = UnionFind(N)
    ans = [N*(N-1)//2]
    for i in range(M-1, 0, -1):
        p1 = uf.find(A[i])
        p2 = uf.find(B[i])
        if p1 != p2:
            ans.append(ans[-1] - uf.size(p1)*uf.size(p2))
        else:
            ans.append(ans[-1])
        uf.unite(p1, p2)
    return ans


print(*list(reversed(main())), sep="\n")


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)


class UnionFind:
    def __init__(self, size: int):
        self.parent = [-1 for _ in range(size)]
        self.size = [1 for _ in range(size)]

    def unite(self, x, y):
        px = self.find(x)
        py = self.find(y)
        if px != py:
            if self.parent[px] > self.parent[py]:
                self.parent[py] = px
                self.parent[px] -= 1
                self.size[px] += self.size[py]
                self.size[py] = 0
            else:
                self.parent[px] = py
                self.parent[py] -= 1
                self.size[py] += self.size[px]
                self.size[px] = 0
        return

    def find(self, x: int) -> int:
        if self.parent[x] < 0:
            return x
        self.parent[x] = self.find(self.parent[x])
        return self.parent[x]

    def is_same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)


def main():
    # input
    N, M = map(int, input().split())
    brs = [list(map(int, input().split())) for _ in range(M)]

    # solve
    # ref: http://drken1215.hatenablog.com/entry/2019/03/03/224600
    # ref: https://atcoder.jp/contests/abc120/submissions/4450601
    uf = UnionFind(N)
    ans = [N*(N-1)//2]
    for i in range(M-1, 0, -1):
        a, b = brs[i][0], brs[i][1]
        a, b = a-1, b-1
        p1 = uf.find(a)
        p2 = uf.find(b)
        if p1 != p2:
            ans.append(ans[-1] - uf.size[p1]*uf.size[p2])
        else:
            ans.append(ans[-1])
        uf.unite(p1, p2)
    return ans


print(*list(reversed(main())), sep="\n")
N = int(input())
a = [int(input()) for _ in range(N)]

if N % 2 == 0:
    res = 2 * (sum(a[N // 2:]) - sum(a[:N // 2]))
    res += a[N // 2 - 1] - a[N // 2]
    print(res)
else:
    res = 2 * (sum(a[N // 2 + 1:]) - sum(a[N // 2]))
    print(res - min(a[N // 2 + 1] - a[N // 2] - a[N // 2 - 1]))


### FIXED CODE ###

N = int(input())
a = [int(input()) for _ in range(N)]
a.sort()

if N % 2 == 0:
    res = 2 * (sum(a[N // 2:]) - sum(a[:N // 2]))
    res += a[N // 2 - 1] - a[N // 2]
    print(res)
else:
    res = 2 * (sum(a[N // 2 + 1:]) - sum(a[:N // 2]))
    print(res - min(a[N // 2 + 1] - a[N // 2], a[N // 2] - a[N // 2 - 1]))
# Nは最大9桁
n = input()
sn = 0
for ni in n:
    sn += int(ni)
if n % sn == 0:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

# Nは最大9桁
n = input()
sn = 0
for ni in n:
    sn += int(ni)
if int(n) % sn == 0:
    print("Yes")
else:
    print("No")
m=[int(input()) for i in range(5)]
k = []
j=[]
for i in range(5):
    j.append(-(-m[i]//10)*10)
    t = m[i] - (m[i]//10)*10
    if t>0:
      k.append(t)
if min(k) == 0:
    print(sum(j))
else:
    print(sum(j)-(10-min(k)))

### FIXED CODE ###

m=[int(input()) for i in range(5)]
k = []
j=[]
for i in range(5):
    j.append(-(-m[i]//10)*10)
    
    
    t=m[i] - (m[i]//10)*10
    if t>0:
        k.append(t)
if len(k)==0:
    print(sum(j))
else:
    print(sum(j)-(10-min(k)))
def main():
  N, M = list(map(int, input().split(' ')))

  root = [[] for i in range(M+1)]
  for i in range(M):
    A, B = list(map(int, input().split(' ')))
    root[A].append(B)
    root[B].append(A)

  mitisurube = [-1 for i in range(N+1)]
  cost = [True for i in range(N+1)]
  next_ = [1]
  cost[1] = False

  while next_:
    now_pos = next_.pop(0)
    for next_pos in root[now_pos]:
      if cost[next_pos]:
        cost[next_pos] = False
        mitisurube[next_pos] = now_pos
        next_.append(next_pos)
  #print('root')
  #print(*root)
  #print('cost')
  #print(*cost)
  #print('mitisirube')
  if mitisurube.count(-1) < 3:
    print('Yes')
    print(*mitisurube[2:], sep='\n')
  else:
    print('No')

if __name__ == '__main__':
  main()

### FIXED CODE ###

from collections import deque

def main():
  N, M = list(map(int, input().split(' ')))

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

  mitisurube = [-1 for i in range(N+1)]
  next_ = deque()
  next_.append(1)

  while next_:
    now_pos = next_.popleft()
    for next_pos in root[now_pos]:
      if mitisurube[next_pos] == -1:
        mitisurube[next_pos] = now_pos
        next_.append(next_pos)
  #print('root')
  #print(*root)
  #print('mitisirube')
  print('Yes')
  print(*mitisurube[2:], sep='\n')

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

a, p = [1], [1]

for i in range(N):
	a.append(a[i] * 2 + 3)
	p.append(p[i] * 2 + 1)
def f(N, X): # X <= 0 や X > a_N を許容し解説本文から簡略化
	if N == 0:
		return 0 if X <= 0 else 1
	elif X <= 1 + a[N-1]:
		return f(N-1, X-1)
	else:
		return p[N-1] + 1 + f(N-1, X-2-a[N-1])

 print(f(N, X))


### FIXED CODE ###

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

a,p = [1],[1]

#バーガーの厚みとパティの総数を求める

for i in range(n):
    a.append(2 * a[i] + 3)
    p.append(2 * p[i] + 1)

def f(N,X):
    if N == 0:
        if X <= 0:
            return 0

        else:
            return 1

    elif X <= 1 + a[N-1]:
        return f(N -1,X-1)

    else:#if X <= 2 + 2 * a[N-1]:
        return p[N-1] + 1 + f(N -1, X-2-a[N-1])

print(f(n,x))
N, K = int(input())
A = list(map(int, input().split()))

min_idx = 0
for idx in range(N):
  if A[idx] < A[min_idx]:
    min_idx = idx
ans = 0
if (N-min_idx)%(K-1) == 0:
  ans += (N-min_idx)//(K-1)
else:
  ans += (N-min_idx)//(K-1)+1
if min_idx%(K-1) == 0:
  ans += min_idx//(K-1)
else:
  ans += min_idx//(K-1) + 1
print(ans)


### FIXED CODE ###

import math

N, K = map(int, input().split())
nums = list(map(int, input().split()))
print(math.ceil((len(nums)-1)/(K-1)))
s = input()
k =int(input())
sl = []
if len(s) >1:
    for i in range(len(s)-1):
        for j in range(i, len(s)+1):
            s_part = s[i:j]
            if s_part not in sl and s_part != "":
                sl.append(s_part)
    sll = sorted(sl)
    print(sll[k-1])
else:
    print(s)

### FIXED CODE ###

s = input()
l = int(input())
char = []
if len(s) == 1:
    print(s)
else:
    for i in range(len(s)):
        char.append(s[i])
    charset = set(char)
    ans = []
    for i in charset:
        for j in range(len(s)):
            if i == s[j]:
                for k in range(1, 6):
                    ans.append(s[j:j+k])
    ansset = sorted(list(set(ans)))
    print(ansset[l-1])
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    A = 14 if A == 1 else A
    B = 14 if B == 1 else B
    if A == B:
        print("Draw")
    elif A > B:
        print("Alice")
    else:
        print("Bob")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    A = 14 if A == 1 else A
    B = 14 if B == 1 else B
    if A == B:
        print("Draw")
    elif A > B:
        print("Alice")
    else:
        print("Bob")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()
inp = list(map(lambda x: int(x), input().split(" ")))
N = inp[0]
M = inp[1]

dp = [-1]*N

g = {}

def path(x):
    if dp[x-1]!=-1:
        return dp[x-1]
    if g[x] == []:
        return 0
    else:
        ret = 0
        for k in g[x]:
            if ret<path(k)+1:
                ret = path(k)+1
        dp[x-1] = ret
        return ret

for i in range(1,N+1):
    g[i] = []

for i in range(M):
    inp = list(map(lambda x: int(x), input().split(" ")))
    x = inp[0]
    y = inp[1]
    g[x].append(y)

ret = 0
for i in range(1,N+1):
    if ret<path(i):
        ret = path(i)

print(ret)

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000000)

inp = list(map(lambda x: int(x), input().split(" ")))
N = inp[0]
M = inp[1]

dp = [-1]*N

g = {}

def path(x):
    if dp[x-1]!=-1:
        return dp[x-1]
    if g[x] == []:
        return 0
    else:
        ret = 0
        for k in g[x]:
            if ret<path(k)+1:
                ret = path(k)+1
        dp[x-1] = ret
        return ret

for i in range(1,N+1):
    g[i] = []

for i in range(M):
    inp = list(map(lambda x: int(x), input().split(" ")))
    x = inp[0]
    y = inp[1]
    g[x].append(y)

ret = 0
for i in range(1,N+1):
    if ret<path(i):
        ret = path(i)

print(ret)
N,M=map(int,input().split())

L=list(map(int,input().split()))
S=[0]*100010
for i in range(N):
    S[i]=L[i]

DP=[10**12]*100010

DP[0]=0
for i in range(N):
    for j in range(1,M+1):
        if DP[i+j]>DP[i]+abs(S[i+j]-S[i]):
            DP[i+j]=DP[i]+abs(S[i+j]-S[i])



print(DP[N-1])

            

### FIXED CODE ###

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

L=list(map(int,input().split()))
S=[0]*110000
for i in range(N):
    S[i]=L[i]

DP=[10**12]*110000

DP[0]=0
for i in range(N):
    for j in range(1,M+1):
        if DP[i+j]>DP[i]+abs(S[i+j]-S[i]):
            DP[i+j]=DP[i]+abs(S[i+j]-S[i])



print(DP[N-1])
import sys
input = sys.stdin.readline

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

def sieve_optimized(limit):
    # Preprocessing step takes O(N log log N) time complexity.
    n = limit
    # Filimitd all primes upto n  (including n)
    sievebound = (n-1)//2
    sieve = [-1]*(sievebound + 1)
    # sieve[0] = True
    crosslimit = (int(sievebound**0.5) - 1)
    for i in range(1, crosslimit + 1):
        if sieve[i] == -1:
            for j in range(2*i*(i+1), sievebound + 1, 2*i+1):
                sieve[j] = 2*i + 1
    return sieve

def factorization(n, sieve):
    # Factorisaton query takes O(log N) time after preprocessing.
    divs = [1]
    while n!=1:
        if n&1:
            div = sieve[(n-1)//2]
            if div == -1:
                divs.append(n)
                break
            else:
                n //= div
                divs.append(div)
        else:
            n >>= 1
            divs.append(2)

    return divs

maxnum = 10**6 + 10
sieve = sieve_optimized(maxnum)

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

seen = dict()
for i in nums:
    factors = factorization(i, sieve)
    if len(factors) <= 1: continue
    for f in set(factors[1:]):
        if f in seen:
            seen[f] += 1
        else:
            seen[f] = 1

maxval = max(seen.values())

if maxval == n:
    print('not coprime')

elif 1 < maxval < n:
    print('setwise coprime')

else:
    print('pairwise coprime')


### FIXED CODE ###

import sys
input = sys.stdin.readline

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

def sieve_optimized(limit):
    # Preprocessing step takes O(N log log N) time complexity.
    n = limit
    # Filimitd all primes upto n  (including n)
    sievebound = (n-1)//2
    sieve = [-1]*(sievebound + 1)
    # sieve[0] = True
    crosslimit = (int(sievebound**0.5) - 1)
    for i in range(1, crosslimit + 1):
        if sieve[i] == -1:
            for j in range(2*i*(i+1), sievebound + 1, 2*i+1):
                sieve[j] = 2*i + 1
    return sieve

def factorization(n, sieve):
    # Factorisaton query takes O(log N) time after preprocessing.
    divs = [1]
    while n!=1:
        if n&1:
            div = sieve[(n-1)//2]
            if div == -1:
                divs.append(n)
                break
            else:
                n //= div
                divs.append(div)
        else:
            n >>= 1
            divs.append(2)

    return divs

maxnum = 10**6 + 1
sieve = sieve_optimized(maxnum)

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

seen = dict()
maxval = 0
for i in nums:
    factors = factorization(i, sieve)
    if len(factors) <= 1: continue
    for f in set(factors[1:]):
        if f in seen:
            seen[f] += 1
            maxval = max(maxval, seen[f])
        else:
            seen[f] = 1


if maxval == n:
    print('not coprime')

elif 1 < maxval < n:
    print('setwise coprime')

else:
    print('pairwise coprime')
import math
a,b = map(int,input().split())
print(math.gcd(a,b))

### FIXED CODE ###

import sys

def solve():
    a, b = map(int, input().split())
    ans = gcd(a, b)
    print(ans)

def gcd(a, b):
    return gcd(b, a % b) if b else a

if __name__ == '__main__':
    solve()
n = int(input())
a = list(map(int, input().split()))

not_0 = n
for i in range(n):
    if a[i]:
        not_0 = i
        break

if not_0 == n:
    print(1+2*(n-1))
    exit()

ans = 0
if not_0 == 0:
    b = [a[0]]
else:
    if abs(a[not_0]) == 1:
        a[not_0] *= 2
        ans = 2*not_0
    else:
        ans = 1 + 2*(not_0-1)

    if a[not_0] > 0:
        b = [a[not_0] - 1]

    else:
        b = [a[not_0] + 1]

tmp = b[0]
for i in range(not_0+1, n):
    tmp += a[i]
    b.append(tmp)

for i in range(not_0+1, n):
    if b[i-1]*b[i] < 0:
        continue
    else:
        if b[i-1] > 0:
            d = b[i] + 1
            ans += d
            for j in range(i, n):
                b[j] -= d
        else:
            d = -b[i] + 1
            ans += d
            for j in range(i, n):
                b[j] += d
print(ans)


### FIXED CODE ###

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

m = 0
c = 0

for i in range(n):
    m += a[i]

    if i % 2 == 0:
        if m <= 0:
            c += abs(m) + 1
            m += abs(m) + 1
    else:
        if m >= 0:
            c += m + 1
            m -= m + 1

m = 0
d = 0

for i in range(n):
    m += a[i]

    if i % 2 == 1:
        if m <= 0:
            d += abs(m) + 1
            m += abs(m) + 1
    else:
        if m >= 0:
            d += m + 1
            m -= m + 1

print(min(c, d))
a=int(input())
b=int(input())
print(a*b

### FIXED CODE ###

a, b=map(int, input().split())
print(a*b)
import numpy as np
N = int(input())
A = [int(i) for i in input().split()]
B = sorted(A.copy(), reverse=True)

ans = 1
counts = [N] * (B[0]+1)
for d in range(B[0], B[-1]//2-1, -1):
    for b in B:
        if b % d == 0:
            counts[d] -= 1
            if d != b // d:
                counts[b//d] -= 1

    if counts[d] < 2:
        ans = d
        break

if ans == 1:
    for i in range(B[-1]//2, 0, -1):
        if counts[i] < 2:
            ans = i
            break

print(ans)

### FIXED CODE ###

# 解けなかった...orz

N = int(input())
A = [int(i) for i in input().split()]

def gcd(i, j):
    if i <= 0:
        return j
    elif j <= 0:
        return i

    while i != j:
        if i < j:
            j %= i
            if j == 0: return i
        else:
            i %= j
            if i == 0: return j
    return i

# M = [0] * N
L = [0] * (N+1)
R = [0] * (N+1)
# L[0] = 0
# R[N] = 0

for i in range(N):
    L[i+1] = gcd(L[i], A[i])
    R[N-i-1] = gcd(R[N-i], A[N-i-1])

res = max(gcd(L[i], R[i+1]) for i in range(N))
print(res)
c=input()
print(char(ord(c)+1)

### FIXED CODE ###

c=input()
print(chr(ord(c)+1))
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)
#Beginner 050 C

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

if L % 2 == 0:
    lst = [2*i+1 for i in range(L//2)]
    if set(lst) == set(A):
        print(2**(L//2))
    else:
        pront(0)
        quit()
else:
    lst = [2*i for i in range(L//2+1)]
    if set(lst) == set(A):
        print(2**(L//2+1))
    else:
        pront(0)
        quit()



### FIXED CODE ###

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

ans = 0
A_test = sorted(list(set(A)))

if N % 2 == 1:
    judge = [i for i in range(0,N,2)]
    if (A_test == judge) and (A.count(0) == 1):
        ans = 2**(N//2)
else:
    judge = [i for i in range(1,N,2)]
    if A_test == judge:
        ans = 2**(N//2)

ans = ans % (10**9 + 7)
print(ans)
K = int(input())
ans = 1
X = 7
cnt = K
while(cnt > 0):
#     print('rem={}'.format(X%K))
    rem = X % K
    if rem == 0:
        print(ans)
        break
    else:
        remlst.append(rem)
        ans += 1
        X = rem*10 + 7 
        cnt -= 1

if cnt == 0:
    print(-1)

### FIXED CODE ###

K = int(input())
ans = 1
X = 7
cnt = K
while(cnt > 0):
#     print('rem={}'.format(X%K))
    rem = X % K
    if rem == 0:
        print(ans)
        break
    else:
        ans += 1
        X = rem*10 + 7 
        cnt -= 1

if rem != 0:
    print(-1)
import itertool
A=itertool.permutations(range(1,int(input())+1))
print(abs(A.index(list(map(int,input().split())))-A.index(list(map(int,input().split()))))


### FIXED CODE ###

import itertools
A=list(itertools.permutations(range(1,int(input())+1)))
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))
print(abs(A.index(P)-A.index(Q)))
N = input()
R = N % 1000

if R = 0:
    print(0)

else:
    print(abs(R-1000))

### FIXED CODE ###

N = int(input())
R = N % 1000
if R == 0:
    print(0)
else:
    print(abs(R-1000))
# -*- coding: utf-8 -*-

import math

x1, y1, x2, y2 = map(int, input().split())
dis = math.sqrt((x1 + x2) * (x1 + x2) + (y1 + y2) * (y1 + y2))
print(dis)


### FIXED CODE ###

# -*- coding: utf-8 -*-

import math

x1, y1, x2, y2 = map(float, input().split())
dis = math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))
print(dis)
import math

A, B = input().split()
B_float = float(B)
A = int(A)
B_p = int(B.split(".")[0])
B_c = int(B.split(".")[1])

if (A == 0) or (B == 0):
  print(0)
else:
  print(A * B_p + int(str(A * B_c)[:-2]))

### FIXED CODE ###

import math

A, B = input().split()

A = int(A)
B_p = int(B.split(".")[0])
B_c = int(B.split(".")[1])

if (A == 0) or (B == 0):
  print(0)
else:
  ABp = A * B_p
  ABc = int(str(A * B_c)[:-2]) if len(str(A * B_c))>2 else 0
  print(ABp+ABc)
import sys
import math
import functools
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    return a * b // gcd (a, b)
def lcm_n(nums):
    return functools.reduce(lcm, nums)

n = ni()
a = na()
a_lcm = lcm_n(a)
ans = 0
for ai in a:
    ans += a_lcm // ai
ans %= mod
print(ans)


### FIXED CODE ###

import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]


n, m = na()
print("Yes" if n==m else "No")
#122-C
n,q=map(int,input().split())
s=input()
l=[list(map(int,input().split())) for i in range(q)]
m=[0]*(n+1)
for i in range(len(s)):
    
    if s[i]=='A' and s[i+1]=='C':
        m[i+1]=m[i]+1
    else:
        m[i+1]=m[i]

for i in l:
    print(m[i[1]-1]-m[i[0]-1])

### FIXED CODE ###

#122-C
n,q=map(int,input().split())
s=input()
l=[list(map(int,input().split())) for i in range(q)]
m=[0]*(n+1)
for i in range(len(s)-1):
    
    if s[i]=='A' and s[i+1]=='C':
        m[i+1]=m[i]+1
    else:
        m[i+1]=m[i]

for i in l:
    print(m[i[1]-1]-m[i[0]-1])
N=int(input())
l=list(map(int,input().split()))
if max(l)<sum(l)-max(l):
	print("Yes")
else:
	print("No")

### FIXED CODE ###

T,X=map(int,input().split())
print(T/X)
n = int(input())
s = [input() for i in range(n)]

f = [a for a in s if s.startswith('M')]
g = [b for b in s if s.startswith('A')]
h = [c for c in s if s.startswith('R')]
i = [d for d in s if s.startswith('C')]
j = [e for e in s if s.startswith('H')]

k = len(f)*len(g)*len(h)
l = len(f)*len(g)*len(i)
m = len(f)*len(g)*len(j)
n = len(f)*len(h)*len(i)
o = len(f)*len(h)*len(j)
p = len(f)*len(i)*len(j)
q = len(g)*len(h)*len(i)
r = len(g)*len(h)*len(j)
s = len(g)*len(i)*len(j)
t = len(h)*len(i)*len(j)

sum = k+l+m+n+o+p+q+r+s+t
print(sum)

### FIXED CODE ###

n = int(input())
s = [input() for i in range(n)]

f = [a for a in s if a.startswith('M')]
g = [b for b in s if b.startswith('A')]
h = [c for c in s if c.startswith('R')]
i = [d for d in s if d.startswith('C')]
j = [e for e in s if e.startswith('H')]

k = len(f)*len(g)*len(h)
l = len(f)*len(g)*len(i)
m = len(f)*len(g)*len(j)
n = len(f)*len(h)*len(i)
o = len(f)*len(h)*len(j)
p = len(f)*len(i)*len(j)
q = len(g)*len(h)*len(i)
r = len(g)*len(h)*len(j)
s = len(g)*len(i)*len(j)
t = len(h)*len(i)*len(j)

sum = k+l+m+n+o+p+q+r+s+t
print(sum)
n = int(input())
lis = []
for i in range(n):
  word = str(input())
  lis.append({letter:word.count(letter) for letter in word})
counter = 0
while True:
  m = lis.count(lis[0])
  counter += (m*(m-1))//2
  lis.remove(lis[0])
  if len(lis) == 0:
    break
print(counter)


### FIXED CODE ###

a,b = map(int,input().split())
print(max(a*b,a+b,a-b))
import math

N = int(raw_input())
CSF = [map(float, raw_input().split()) for _ in range(N-1)]

for i in range(N-1):
    ans = CSF[i][0] + CSF[i][1]
    for j in range(i+1, N-1):
        C, S, F = CSF[j][0], CSF[j][1], CSF[j][2]
        if S < ans:
            n = math.ceil((ans - S) / F)
            ans = C + S + u * n
        else:
            ans = C + S
 
    print int(ans)

print 0

### FIXED CODE ###

# coding: utf-8
import math

N = int(raw_input())
CSF = [map(float, raw_input().split()) for _ in range(N-1)]

for i in range(N-1):
    ans = CSF[i][0] + CSF[i][1]
    for j in range(i+1, N-1):
        s, t, u = CSF[j][0], CSF[j][1], CSF[j][2]
        if t < ans:
            n = int(math.ceil((ans - t) / u))
            ans = int(s + t + u * n)
        else:
            ans = s + t

    print int(ans)

print 0
n = int(input())
ans = [0 for i in range (n)]
for i in range(n):
  a,b,c = map(int,input().split())
  if c % 2 == 1:
    if ans[a-1] == ans[b-1]:
      ans[b-1] = 1
for i in range(n):
  print(ans[i])
    


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)
n=int(input())
graph=[[] for i in range(n)]
color=[-1]*n
for i in range(n-1):
    a,b,c=map(int,input().split())
    graph[a-1].append([b-1,c%2])
    graph[b-1].append([a-1,c%2])
def coloring(pre,c):
  color[pre]=c
  for i,j in graph[pre]:
    if color[i]<0:
      coloring(i,color[pre]^j)
coloring(0,1)
for i in color:
  print(i)
a = int(input())
b = int(input())
res = 2 * b -A
print(res)

### FIXED CODE ###

a = int(input())
b = int(input())
res = 2 * b - a
print(res)