Harryxun/stf_run huggingface dataset:
n=int(input())
a=list(map(int, input().split()))
q=int(input())
num=[0]*(10**5-1)
tot=0
for i in range(n):
    num[a[i]-1]+=1
    tot+=a[i]

for _ in range(q):
    b,c=map(int, input().split())
    tot+=(num[b-1]*(c-b))
    num[c-1]+=num[b-1]
    num[b-1]=0
    print(tot)

### FIXED CODE ###

n=int(input())
a=list(map(int, input().split()))
q=int(input())
num=[0]*(10**5)
tot=0
for i in range(n):
    num[a[i]-1]+=1
    tot+=a[i]

for _ in range(q):
    b,c=map(int, input().split())
    tot+=(num[b-1]*(c-b))
    num[c-1]+=num[b-1]
    num[b-1]=0
    print(tot)
n = int(input())
x,q = [[] for i in range(n)],[-1]*n
for i in range(n-1):
	a = int(input())-1
	x[a].append(i+1)
def f(z):
	y = []
	if x[z]:
		for i in x[z]:
			if q[i]+1: y.append(q(i))
			else: y.append(f(i))
		y = sorted(y)[::-1]
		for i in range(len(y)): y[i]+=i+1
		q[z] = max(y)
		return max(y)
	else:
		q[z] = 0
		return 0
print(f(0))

### FIXED CODE ###

from sys import setrecursionlimit
setrecursionlimit(100000)
n = int(input())
x,q = [[] for i in range(n)],[-1]*n
for i in range(n-1):
	a = int(input())-1
	x[a].append(i+1)
def f(z):
	y = []
	if x[z]:
		for i in x[z]:
			if q[i]+1: y.append(q(i))
			else: y.append(f(i))
		y = sorted(y)[::-1]
		for i in range(len(y)): y[i]+=i+1
		q[z] = max(y)
		return max(y)
	else:
		q[z] = 0
		return 0
print(f(0))
H, W, N = map(int, input().split())
s_r, s_c = map(int, input().split())
S = input()
T = input()

# vertical direction
up, down = 0, H
for i in range(H, -1, -1):
    if T[i] == 'U':
        down = min(H, down + 1)
    elif T[i] == 'D':
        up = max(0, up - 1)
    
    if S[i] == 'U':
        up += 1
    elif S[i] == 'D':
        down -= 1
    
    if up >= down:
        print('NO')
        exit()
        
# horizontal direction
left, right = 0, W
for j in range(W-1, -1, -1):    
    if T[j] == 'L':
        right = min(W, right + 1)
    elif T[j] == 'R':
        left = max(0, left - 1)
    
    if S[j] == 'L':
        left += 1
    elif S[j] == 'R':
        right -= 1
    
    if left >= right:
        print('NO')
        exit()
if up <= s_r < down and left <= s_c < right:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

H, W, N = map(int, input().split())
s_r, s_c = map(int, input().split())
S = input()
T = input()

# vertical direction
up, down = 0, H-1
for i in range(N-1, -1, -1):
    if T[i] == 'U':
        down = min(H-1, down + 1)
    elif T[i] == 'D':
        up = max(0, up - 1)
    
    if S[i] == 'U':
        up += 1
    elif S[i] == 'D':
        down -= 1
    
    if up > down:
        print('NO')
        exit()
        
# horizontal direction
left, right = 0, W-1
for i in range(N-1, -1, -1):    
    if T[i] == 'L':
        right = min(W-1, right + 1)
    elif T[i] == 'R':
        left = max(0, left - 1)
    
    if S[i] == 'L':
        left += 1
    elif S[i] == 'R':
        right -= 1
    
    if left > right:
        print('NO')
        exit()
if up <= s_r-1 <=down and left <= s_c-1 <= right:
    print('YES')
else:
    print('NO')
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ad = defaultdict(lambda: -1)
i, j = 0, 0
while i < N and j < N:
    if A[i] < B[j]:
        ad[i] = j
        i += 1
    else:
        j += 1
bd = defaultdict(lambda: -1)
i, j = 0, 0
while i < N and j < N:
    if B[i] < C[j]:
        bd[i] = j
        i += 1
    else:
        j += 1
csum = [0] * N
for i in range(N):
    if bd[i] >= 0:
        csum[i] = N-bd[i]
bsum = [0]* N
cnt = 0
for i in range(N):
    cnt += csum[N-1-i]
    bsum[N-1-i] = cnt
ans = 0
for i in range(N):
    if ad[i] >= 0:
        ans += bsum[ad[i]]
print(ans)

### FIXED CODE ###

from collections import defaultdict
N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
ad = defaultdict(lambda: -1)
i, j = 0, 0
while i < N and j < N:
    if A[i] < B[j]:
        ad[i] = j
        i += 1
    else:
        j += 1
bd = defaultdict(lambda: -1)
i, j = 0, 0
while i < N and j < N:
    if B[i] < C[j]:
        bd[i] = j
        i += 1
    else:
        j += 1
csum = [0] * N
for i in range(N):
    if bd[i] >= 0:
        csum[i] = N-bd[i]
bsum = [0]* N
cnt = 0
for i in range(N):
    cnt += csum[N-1-i]
    bsum[N-1-i] = cnt
ans = 0
for i in range(N):
    if ad[i] >= 0:
        ans += bsum[ad[i]]
print(ans)
n = int(input())
v = map(int,input().split())
c = map(int,input().split())
cnt == 0
for i in range(n):
    if v[i] > c[i]:
        cnt += (v[i] - c[i])
print(cnt)   

### FIXED CODE ###

n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
cnt = 0
for i in range(n):
    if v[i] > c[i]:
        cnt += (v[i] - c[i])
print(cnt)
A = sorted(map(int, input().split()))

cost = 0
for i in range(len(A - 1)):
  cost += A[i + 1] - A[i]
  
print(cost)


### FIXED CODE ###

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

cost = 0
for i in range(len(A) - 1):
  cost += A[i + 1] - A[i]

print(cost)
import math

r = int(input())
circle = r * 2 * math.pi
area = (r ** 2) * math.pi

print('{0:.5f} {1:.5f}'.format(area, circle))

### FIXED CODE ###

import math
r = float(input())
print("{:.6f} {:.6f}".format(r**2 * math.pi, r*2.0 * math.pi))
k,x = map(int,input().spleit())

if x =< k*500:
  print('Yes')

else:
  print('No')


### FIXED CODE ###

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

if  500*k >= x:
  print('Yes')
else:
  print('No')
N=int(input())
A=list(map(int,input().split()))
ans=0

while True:
  for i in range(N):
    if A[i]%2==0:
      A[i]=A//2
    else:
      print(ans)
      return
  ans+=1


### FIXED CODE ###

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

while flag==0:
  for i in range(N):
    if A[i]&1==0:
      A[i]=A[i]>>1
    else:
      print(ans)
      flag=1
      break
  ans+=1
input1 = input()
A1 = int(input1.split([0]))
A2 = int(input1.split([1]))
A3 = int(input1.split([2]))

if A1+A2+A3 > 21:
    print("bust")
else:
    print("win")

### FIXED CODE ###

input1 = input()
A1 = int(input1.split()[0])
A2 = int(input1.split()[1])
A3 = int(input1.split()[2])

if A1+A2+A3 > 21:
    print("bust")
else:
    print("win")
print(sum([1 for j in [int(input()) for i in range(int(input()))][::2] if j%2!=1]))


### FIXED CODE ###

a=list(input())
if ("N" in a and"S"in a)or(not"N" in a and not "S" in a):
    if ("W" in a and"E"in a)or(not"W" in a and not "E" in a):
        print("Yes")
    else:
        print("No")
else:
    print("No")
s=input()
q=int(input())
dp=["" for i in range(q+1)]
dp[0]=s
flag=0
for i in range(q):
  ques=list(input().split())
  if ques[0]=="1":
    dp[i+1]=dp[i]
    flag+=1
  else:
    if ques[1]=="1":
      if flag%2==0:
        dp[i+1]=ques[2]+dp[i]
      else:
        dp[i+1]=dp[i]+ques[2]
    else:
      if flag%2==0:
        dp[i+1]=dp[i]+ques[2]
      else:
        dp[i+1]=ques[2]+dp[i]
if flag%2==1:
  ans=dp[q][::-1]
else:
  ans=dp[q]
print(ans)

### FIXED CODE ###

from collections import deque

S = input()
Q = int(input())
ans = deque(S)
revcnt = 0
for i in range(Q):
    data = list(input().split())
    if data[0] == '1':
        revcnt += 1
        continue

    if data[1] == '1':
        if revcnt % 2 == 0:
            ans.appendleft(data[2])
        else:
            ans.append(data[2])
    else:
        if revcnt % 2 == 0:
            ans.append(data[2])
        else:
            ans.appendleft(data[2])

if revcnt % 2 != 0:
    print(''.join(reversed(list(ans))))
else:
    print(''.join(list(ans)))
def f06():
    n=int(input())
    s=input()
    k=int(input())
    x=s[k-1]
    for i in range(n):
        if s[i]!=x:
            s[i]='*'
    print(s)
f06()

### FIXED CODE ###

def f06():
    n=int(input())
    S=input()
    k=int(input())
    for s in S:
        print(s if s==S[k-1] else '*', end='')
f06()
N, M = [int(a) for a in input().split(" ")]
ctab = {"1":2,"2":5,"3":5,"4":4,"5":5,"6":6,"7":3,"8":7,"9":6}
A = [(a, ctab[a]) for a in input().split(" ")]
prev = [None]*(N+1)
curr = [None]*(N+1)
for char, cost in A:
    if not prev[cost] or char>prev[cost]:
        prev[cost] = char

ans = ""
while any(prev):
    for i in range(1, N+1):
        curr[i] = None
    for i in range(1, N+1):
        s = prev[i]
        if not s:
            continue
        for char, cost in A:
            tmps = char+s
            if i+cost <= N:
                if not curr[i+cost] or tmps > curr[i+cost]:
                    curr[i+cost] = tmps
    if curr[N] is not None:
        ans = curr[N]
    curr, prev = prev, curr
print(ans)


### FIXED CODE ###

N, M = [int(a) for a in input().split(" ")]
ctab = {"1":2,"2":5,"3":5,"4":4,"5":5,"6":6,"7":3,"8":7,"9":6}
A = sorted([(a, ctab[a]) for a in input().split(" ")], key=lambda t:t[0])
prev, curr = ([""]*(N+1), [""]*(N+1))

def maxs(s1, s2):
    return max(s1, s2, key=lambda s:len(s)) if len(s1)!=len(s2) else max(s1,s2)

char, cost = A[0]
for i in range(1, N+1):
    d, r = divmod(i, cost)
    prev[i] = char*d if r==0 else None
for char, cost in A[1:]:
    for i in range(1, N+1):
        if i-cost >= 0 and curr[i-cost] is not None:
            tmp = char+curr[i-cost]
            curr[i] = maxs(tmp, prev[i]) if prev[i] else tmp
        else:
            curr[i] = prev[i]
    curr, prev = prev, curr
print(prev[-1])
n = int(input())
ans = 0
for i in range(n):
    a = i**2
    if a>n:
        b = i
        break
print((b-1)**2)

### FIXED CODE ###

n = int(input())
for i in range(n):
    a = i**2
    if a>n:
        b = i
        break
if n<=2:
    print(1)
else:
    print((b-1)**2)
tmp = input().split()
N = int(tmp[0])
K = int(tmp[1])

tmp = input().split()

Map = [0]*N
GroupFlag = [0]*N

for i in range(N):
    Map[i] = int(tmp[i])

for i in range(N):
    nexti = Map[i]
    GroupFlag[nexti-1] = 1
GroupFlag[0] = 1
NN = sum(GroupFlag)
K = K%NN
if K == 0:
    K = NN

rt = [0]*K

def trip(self, steps):
    ntown = Map[self-1]
    if steps == K:
        return ntown
    rt[steps]=trip(ntown,steps+1)


    
Ft = trip(1,0)
print(rt[K-1])


### FIXED CODE ###

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

Map = list(map(int,input().split()))

Visited = [-1]*N
now = 1
Order = [0]*N

loopcount = 1
Order[0] = 1
Visited[0] = 1
for i in range(1,N):
    nt = Map[now-1]
    Order[i] = nt
    loopcount += 1
    if Visited[nt-1] == -1:
        Visited[nt-1] = loopcount
    else:
        break
    now = nt
    

ns = Visited[nt-1]
period = loopcount - ns

if period == 0:
    period = loopcount
    ns = 0

Kmod = K - ns
if Kmod > 0:
    Kmod %= period

print(Order[ns+Kmod])
input = sys.stdin.readline
N,Q = map(int,input().split())
AB = [[] for _ in range(N-1)]
for n in range(N-1):
    AB[n] = list(map(int,input().split()))
PX = [[] for _ in range(Q)]
for q in range(Q):
    PX[q] = list(map(int,input().split()))
graph = [[] for _ in range(N+1)]
for ab in AB:
    graph[ab[0]].append(ab[1])
    graph[ab[1]].append(ab[0])
val = [0] * (N+1)
for px in PX:
    val[px[0]] += px[1]
parent = [0] * (N+1)
Q  = [1]
while Q:
    q = Q.pop()
    for c in graph[q]:
        if c == parent[q]:
            continue
        parent[c] = q
        Q.append(c)
        val[c] += val[q]
print(*val[1:])


### FIXED CODE ###

N,Q = map(int,input().split())
AB = [[] for _ in range(N-1)]
for n in range(N-1):
    AB[n] = list(map(int,input().split()))
PX = [[] for _ in range(Q)]
for q in range(Q):
    PX[q] = list(map(int,input().split()))
graph = [[] for _ in range(N+1)]
for ab in AB:
    graph[ab[0]].append(ab[1])
    graph[ab[1]].append(ab[0])
val = [0] * (N+1)
for px in PX:
    val[px[0]] += px[1]
parent = [0] * (N+1)
from collections import deque
Q  = deque([1])
while Q:
    q = Q.popleft()
    for c in graph[q]:
        if c == parent[q]:
            continue
        parent[c] = q
        Q.append(c)
        val[c] += val[q]
print(*val[1:])
N = int(input())
Lin = input().split(" ")

Lls = []

for i in range(0,N):
    Lls.append(Lin[i])

Lls.sort(reverse = True)

maxSide = Lls[0]
otherSide = 0
for i in range(1,N):
    otherSide = otherSide + Lls[i]

if maxSide < otherSide:
    print("Yes")
other:
    print("No")

### FIXED CODE ###

N = int(input())
Lin = input().split(" ")

Lls = []

for i in range(0,N):
    Lls.append(int(Lin[i]))

Lls.sort(reverse = True)

maxSide = Lls[0]
otherSide = 0
for i in range(1,N):
    otherSide = otherSide + Lls[i]

if maxSide < otherSide:
    print("Yes")
else:
    print("No")
if __name__ == "__main__":
    K = int(input())
    if (K == 0):
        print (1)
        print (0)
        exit()
    if (K <= 50):
        print (K)
        res = []
        for x in range(K):
            res.append(x + 1)
        print (" ".join(map(str, res)))
        exit()
    if (K <= 10 ** 16 + 1000):
        print (1)
        print (K)
        exit()
    assert(False)


### FIXED CODE ###

if __name__ == "__main__":
    K = int(input())
    N = 50
    result = list(range(N))
    for x in range(N):
        result[x] += K // N
    K %= N

    for x in range(K):
        result[x] += N + 1
        for i in range(N):
            result[i] -= 1
    print (len(result))
    print (" ".join(map(str, result)))
def input_n(infile,outfile):
	while True:
		n = int(infile.readline())
		if n == 0:
			break
		dice(infile,outfile,n)

def dice(infile,outfile,n):
	point = 1
	top = 1
	east = 3
	south = 2
	for i in range(n):
		buff = top
		command = infile.readline()
		if command == "North":
			point += south
			top = south
			south = (7 - buff)
		elif command == "South":
			point += (7 - south)
			top = (7 - south)
			south = buff
		elif command == "East":
			point += (7 - east)
			top = (7 - east)
			east = buff
		elif command == "West":
			point += east
			top = east
			east = (7 - buff)
		elif command == "Right":
			remember = south
			south = east
			east = (7 - remember)
		elif command == "Left":
			remember = east
			east = south
			south = (7 - remember)
		else:
			break
	print >> outfile,point

if __name__ == "__main__":
	import sys
	input_n(sys.stdin, sys.stdout)

### FIXED CODE ###

def input_n(infile,outfile):
	while True:
		n = int(infile.readline())
		if n == 0:
			break
		dice(infile,outfile,n)

def dice(infile,outfile,n):
	point = 1
	top = 1
	east = 3
	south = 2
	for i in range(n):
		buff = top
		command = infile.readline().split()[0]
		if command == "North":
			point += south
			top = south
			south = (7 - buff)
		elif command == "South":
			point += (7 - south)
			top = (7 - south)
			south = buff
		elif command == "East":
			point += (7 - east)
			top = (7 - east)
			east = buff
		elif command == "West":
			point += east
			top = east
			east = (7 - buff)
		elif command == "Right":
			point += top
			remember = south
			south = east
			east = (7 - remember)
		elif command == "Left":
			point += top
			remember = east
			east = south
			south = (7 - remember)
		else:
			break
	print >> outfile,point

if __name__ == "__main__":
	import sys
	input_n(sys.stdin, sys.stdout)
def gcd(a, b):
    if a == b or b == 0:
        return a
    elif b == 0:
        return a
    elif a > b:
        return gcd(a - b, b)
    elif a < b:
        return gcd(a, b - a)

def solve():
    N = int(raw_input())
    arr = [int(_) for _ in raw_input().split()]
    left = [0] * (N + 1)
    right = [0] * (N + 1)
    left[0] = 0
    right[N] = 0
    for i in range(1, N+1):
        left[i] = gcd(left[i - 1], arr[i - 1])
    for i in range(N - 1, 0, -1):
        right[i] = gcd(right[i + 1], arr[i])
    max_gcd = 0
    for i in range(N):
        max_gcd = max(max_gcd, gcd(left[i], right[i+1]))
    print str(max_gcd)

if __name__ == '__main__':
    solve()


### FIXED CODE ###

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

def solve():
    N = int(raw_input())
    arr = [int(_) for _ in raw_input().split()]
    left = [0] * (N + 1)
    right = [0] * (N + 1)
    left[0] = 0
    right[N] = 0
    for i in range(1, N+1):
        left[i] = gcd(left[i - 1], arr[i - 1])
    for i in range(N - 1, 0, -1):
        right[i] = gcd(right[i + 1], arr[i])
    max_gcd = 0
    for i in range(N):
        max_gcd = max(max_gcd, gcd(left[i], right[i+1]))
    print str(max_gcd)

if __name__ == '__main__':
    solve()
S = input()
K = int(input())
s = len(str(S))

l = [str(x) for x in S]
i = 0
while i <= s - 1:
  if l[i] == '1':
    i = i + 1
  else:
    break
if i == s:
  print(1)
else:
  print(l[K])

### FIXED CODE ###

S = input()
K = int(input())
s = len(str(S))
i=0

while i < s-1:
  if S[i] == '1':
    i = i + 1
  else:
    break

if K > i:
  print(S[i])
else:
  print(1)
a=map(int,list(input()))
print("Yes" if a[0]==a[1]==a[2] or a[3]==a[1]==a[2] else "No")

### FIXED CODE ###

a=list(map(int,list(input())))
print("Yes" if a[0]==a[1] and a[1]==a[2] or a[3]==a[1] and a[1]==a[2] else "No")
from collections import defaultdict

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

friend_list = defaultdict(list)
for _ in range(M):
    a, b = map(int, input().split(' '))
    a, b = a - 1, b - 1
    friend_list[a].append(b)
    friend_list[b].append(a)

block_list = defaultdict(list)
for _ in range(K):
    c, d = map(int, input().split(' '))
    c, d = c - 1, d - 1
    block_list[c].append(d)
    block_list[d].append(c)


def dfs(s, adj_list):
    cand_list = [s]
    vis_list = []

    while len(cand_list) > 0:
        vis = cand_list.pop(-1)
        vis_list.append(vis)
        pre_cand_list = adj_list[vis]
        for cand in pre_cand_list:
            if cand in vis_list:
                continue
            if cand in cand_list:
                continue
            cand_list.append(cand)

    return vis_list


num_friend_candidate_array = [0, ] * N
visited_user_list = []

for i in range(N):
    if i in visited_user_list:
        continue

    connected_components = dfs(i, friend_list)
    visited_user_list += connected_components

    for j in connected_components:
        friend_candidates = set(connected_components) - \
            set(friend_list[j]) - set(block_list[j]) - {j}
        num_friend_candidate_array[j] = max(len(friend_candidates), 0)

print(' '.join(num_friend_candidate_array.astype(str)))


### FIXED CODE ###

from collections import defaultdict


class UnionFind:
    def __init__(self, n=0):
        self.d = {i: -1 for i in range(n)}

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

    def unite(self, x, y):
        x, y = self.find(x), self.find(y)
        if (x == y):
            return False
        if (self.d[x] > self.d[y]):
            x, y = y, x
        self.d[x] += self.d[y]
        self.d[y] = x
        return True

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

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


N, M, K = map(int, input().split(' '))
deg = defaultdict(int)
to = defaultdict(list)
uf = UnionFind(N)

for _ in range(M):
    a, b = map(int, input().split(' '))
    a -= 1
    b -= 1
    deg[a] += 1
    deg[b] += 1
    uf.unite(a, b)

for _ in range(K):
    c, d = map(int, input().split(' '))
    c -= 1
    d -= 1
    to[c].append(d)
    to[d].append(c)

for i in range(N):
    ans = uf.size(i) - 1 - deg[i]
    for u in to[i]:
        if uf.same(i, u):
            ans -= 1
    print(ans, end=' ' if i != (N - 1) else '\n')
aa=list(map(int,input().split()))
a=a[0]
b=a[1]
c=a[2]
if a=b and a=c:
    print("No")
elif a=b:
    print("Yes")
elif a=c:
    print("Yes")
elif b=c:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

aa=list(map(int,input().split()))
a=aa[0]
b=aa[1]
c=aa[2]
if a==b and a==c:
    print("No")
elif a==b:
    print("Yes")
elif a==c:
    print("Yes")
elif b==c:
    print("Yes")
else:
    print("No")
N = int(input())
p = [int(i) for i in input().split()]
ans = 0
for i in range(N):
    if i+1 == p[i]:
        if i == N-1:
            l = p[i]
            k = l[i-1]
            p[i] = k
            p[i-1] = l
            ans +=1
        else:
            l = p[i]
            k = p[i+1]
            p[i] = k
            p[i+1] = l
            ans +=1
print(ans)


### FIXED CODE ###

N = int(input())
p = [int(i) for i in input().split()]
ans = 0
for i in range(N):
    if i+1 == p[i]:
        if i == N-1:
            l = p[i]
            k = p[i-1]
            p[i] = k
            p[i-1] = l
            ans +=1
        if i != N-1:
            l = p[i]
            k = p[i+1]
            p[i] = k
            p[i+1] = l
            ans +=1
print(ans)
N = int(input())
H = list(map(int, input().split()))
ans = 1
height = H[0]
for i in range(1, N+1):
    if H[i] >= height:
        ans += 1
        height = H[i]

print(ans)

### FIXED CODE ###

N = int(input())
H = list(map(int, input().split()))
ans = 1
height = H[0]
for i in range(1, N):
    if H[i] >= height:
        ans += 1
        height = H[i]

print(ans)
S = input()
T = input()
print(T+S)

### FIXED CODE ###

S, T = input().strip().split()
print(T+S)
input(A,B)
x=A*B
if x%2==0:
  return 'Yes'
else:
  returun 'No'

### FIXED CODE ###

A,B=list(map(int,input().split()))
x=A*B
if x%2==0:
  print('No')
else:
  print('Yes')
import math
a, b = map(int, input().split())
n = math.gcd(a, b)

l = []
for i in range(n):
    if a % (i+2) == 0 and b % (i+2) == 0:
        l.append(i+2)

primes = [2]
for x in l:
    if all(x % prime !=0 for prime in primes):
        primes.append(x)

if  a % 2 == 0 or b % 2 == 0:
    ans = len(primes) +1
else:
    ans = len(primes)
print(ans)

### FIXED CODE ###

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

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

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

ans = set(prime_factorize(n))
print(len(ans)+1)
def root(x):
  if par[x] == x:
    return x
  par[x] = root(par[x])
  return par[x]

def union(x, y):
  rx = root(x)
  ry = root(y)
  if rx != ry:
    par[rx] = ry
  return 0
    
n, m=map(int, input().split(" "))
par = list(range(n + 1)) + [0 for i in range(100)]
for i in range(m):
  a, b = map(int, input().split(" "))
  union(a, b)
#print(par)
maxi = 0
count = 1
#print(par)
countpar = [0 for i in range(n + 100)]
#print(len(countpar), len(par))
for i in range(1, n + 1):
  countpar[root(par[i])] += 1
print(max(countpar))


### FIXED CODE ###

import sys
import resource

def root(x):
  if par[x] == x:
    return x
  par[x] = root(par[x])
  return par[x]

def union(x, y):
  rx = root(x)
  ry = root(y)
  if rx != ry:
    par[rx] = ry
  return 0

sys.setrecursionlimit(10 ** 6)
n, m=map(int, input().split(" "))
par = list(range(n + 1))
for i in range(m):
  a, b = map(int, input().split(" "))
  union(a, b)
#print(par)
maxi = 0
count = 1
#print(par)
countpar = [0 for i in range(n + 1)]
#print(len(countpar), len(par))
for i in range(1, n + 1):
  countpar[root(par[i])] += 1
print(max(countpar))
#print(countpar, par)