Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

a=int(input())
b=list(map(int,input().split()))
cc=1
d=[0 for i in range(a)]
d[0]=sum(b[0::2])-sum(b[1::2])
e=str(d[0])
for i in range(1,a):
  d[i]=b[i-1]*2-d[i-1]
  e=e+" "+str(d[i])

print(e)

### FIXED CODE ###

a=int(input())
b=list(map(int,input().split()))
cc=1
d=[0 for i in range(a)]
d[0]=sum(b[0::2])-sum(b[1::2])
print(str(d[0]), end="")
for i in range(1,a):
  d[i]=b[i-1]*2-d[i-1]
  print(" "+str(d[i]), end="")
### BUGGY CODE ###

md=10**9+7
n,m=map(int,input().split())
s=list(input().split())
t=list(input().split())
dp=[[1]*(m+1) for _ in range(n+1)]
for i,sk in enumerate(s):
    dp[i+1]=dp[i][:]
    cs=0
    for j,tk in enumerate(t):
        if sk==tk:
            cs+=dp[i][j]
        dp[i+1][j+1]+=cs
print(dp[-1][-1]%md)

### FIXED CODE ###

def f(n, m):
    s = list(input().split())
    t = list(input().split())
    dp = [[1] * (m + 1) for _ in range(n + 1)]
    for i, sk in enumerate(s):
        dpi1 = dp[i + 1] = dp[i][:]
        cs = 0
        for j, tk in enumerate(t):
            if sk == tk:
                cs = (cs + dp[i][j]) % md
            dpi1[j + 1] = (dpi1[j + 1] + cs) % md
#    for x in dp:
#        print(*x)
    print(dp[-1][-1])

md = 10 ** 9 + 7
n, m = map(int, input().split())
f(n, m)
### BUGGY CODE ###

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

L = []
t = S[0]
l = 1

for s in S[1:]:
    if t == s:
        l += 1
    else:
        L.append(l)
        t = s
        l = 1

L.append(l)

if S[0] == '0':
    L = [0] + L

R = []
for i in range(max(1, len(L) // 2 + 1 - K)):
    R.append(sum(L[2*i:2*(i+K)+1]))

print(max(R))


### FIXED CODE ###

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

L = S.replace('01', '0,1')
L = L.replace('10', '1,0')
L = L.split(',')
L = [len(l) for l in L]

if S[0] == '0':
    L = [0] + L

R = []
for i in range(max(1, len(L) // 2 + 1 - K)):
    if i == 0:
        R.append(sum(L[2*i:2*(i+K)+1]))
    else:
        R.append(R[-1] - sum(L[2*(i-1):2*(i-1)+2]) + sum(L[2*(i+K)-1:2*(i+K)+1]))

print(max(R))
### BUGGY CODE ###

def main():
    N=int(input())
    l=[0]*10**5
    A=map(int, input().split())
    for a in A:
        l[a-1]+=a
    Q=int(input())
    BC=[list(map(int,input().split())) for _ in range(Q)]
    for bc in BC:
        cnt=l[bc[0]-1]//bc[0]
        l[bc[0]-1]=0
        l[bc[1]-1]+=bc[1]*cnt
        print(sum(l))
    return

if __name__=='__main__':
    main()


### FIXED CODE ###

def main():
    N=int(input())
    l=[0]*10**5
    sm=0
    A=map(int, input().split())
    for a in A:
        l[a-1]+=1
        sm+=a
    Q=int(input())
    BC=[list(map(int,input().split())) for _ in range(Q)]
    for bc in BC:
        cnt=l[bc[0]-1]
        l[bc[0]-1]=0
        l[bc[1]-1]+=cnt
        sm=sm-bc[0]*cnt+bc[1]*cnt
        print(sm)
    return

if __name__=='__main__':
    main()
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

# 内部で1-indexedに変えるので入力は0-indexedでよい
# i項目までの和（i含む）
class BitSum:
    def __init__(self, n):
        self.n = n + 3
        self.table = [0] * (self.n + 1)

    def add(self, i, x):
        i += 1
        while i <= self.n:
            self.table[i] += x
            i += i & -i

    def sum(self, i):
        i += 1
        res = 0
        while i > 0:
            res += self.table[i]
            i -= i & -i
        return res

def main():
    n,m=MI()
    dlr=[]
    for _ in range(n):
        l,r=MI()
        dlr.append((r-l+1,l,r+1))
    dlr.sort()
    ans=[0]*(m+1)
    bit=BitSum(m+1)
    i=0
    for k in range(1,m+1):
        while i<n and dlr[i][0]<=k:
            d,l,r=dlr[i]
            bit.add(l,1)
            bit.add(r,-1)
            i+=1
        ans[k]=n-i+sum(bit.sum(a) for a in range(k,m+1,k))
    print(*ans[1:],sep="\n")

main()

### FIXED CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

# 内部で1-indexedに変えるので入力は0-indexedでよい
# i項目までの和（i含む）
class BitSum:
    def __init__(self, n):
        self.n = n + 3
        self.table = [0] * (self.n + 1)

    def add(self, i, x):
        i += 1
        while i <= self.n:
            self.table[i] += x
            i += i & -i

    def sum(self, i):
        i += 1
        res = 0
        while i > 0:
            res += self.table[i]
            i -= i & -i
        return res

def main():
    n,m=MI()
    dlr=[]
    for _ in range(n):
        l,r=MI()
        dlr.append((r-l+1,l,r+1))
    dlr.sort()
    bit=BitSum(m+1)
    i=0
    for k in range(1,m+1):
        while i<n and dlr[i][0]<=k:
            d,l,r=dlr[i]
            bit.add(l,1)
            bit.add(r,-1)
            i+=1
        print(n-i+sum(bit.sum(a) for a in range(k,m+1,k)))

main()
### BUGGY CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
As=list(set(A))
sa=max(0,len(As)-K)
if sa==0:
    print(0)
    exit
else:
    count=[0]*len(As)
    for i in range(len(As)):
        count[i]=A.count(As[i])
    num=sorted(count)
    ans=0
    for i in range(sa):
        ans+=num[i]
    print(ans)

### FIXED CODE ###

N,K=map(int,input().split())
A=list(map(int,input().split()))
sa=len(set(A))-K
if sa>0:
    As={}
    for i in range(N):
        if A[i] in As:
            As[A[i]]+=1
        else:
            As[A[i]]=1
    Ass=sorted(As.values())
    print(sum(Ass[:sa]))
else:
    print(0)
### BUGGY CODE ###

# http://drken1215.hatenablog.com/entry/2020/02/09/225000

class Calc:
    def __init__(self, *, max_value, mod):
        """combination(max_value, all)"""
        fact = [-1] * (max_value + 1)
        fact[0] = 1
        fact[1] = 1
        for x in range(2, max_value + 1):
            fact[x] = x * fact[x - 1] % mod

        invs = [1] * (max_value + 1)
        invs[max_value] = pow(fact[max_value], mod - 2, mod)
        for x in range(max_value - 1, 0, -1):
            invs[x] = invs[x + 1] * (x + 1) % mod

        self.fact = fact
        self.invs = invs
        self.mod = mod

    def combination(self, n, r):
        if n - r < r:
            return self.combination(n, n - r)
        if r < 0:
            return 0
        if r == 0:
            return 1
        if r == 1:
            return n
        return self.fact[n] * self.invs[r] * self.invs[n - r] % self.mod

    def factorial(self, n):
        return self.fact[n]


def main():
    mod = 10 ** 9 + 7

    r1, c1, r2, c2 = map(int, input().split())

    cl = Calc(max_value=r2 + c2 + 1, mod=mod)

    ret = 0
    for r in range(r1, r2 + 1):
        ret += cl.combination(r + c2 + 1, r + 1)
        ret -= cl.combination(r + (c1 - 1) + 1, r + 1)
        ret %= mod

    print(ret)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# http://drken1215.hatenablog.com/entry/2020/02/09/225000

class Calc:
    def __init__(self, *, max_value, mod):
        """combination(max_value, all)"""
        fact = [-1] * (max_value + 1)
        fact[0] = 1
        fact[1] = 1
        for x in range(2, max_value + 1):
            fact[x] = x * fact[x - 1] % mod

        invs = [1] * (max_value + 1)
        invs[max_value] = pow(fact[max_value], mod - 2, mod)
        for x in range(max_value - 1, 0, -1):
            invs[x] = invs[x + 1] * (x + 1) % mod

        self.fact = fact
        self.invs = invs
        self.mod = mod

    def combination(self, n, r):
        if n - r < r:
            return self.combination(n, n - r)
        if r < 0:
            return 0
        if r == 0:
            return 1
        if r == 1:
            return n
        return self.fact[n] * self.invs[r] * self.invs[n - r] % self.mod

    def factorial(self, n):
        return self.fact[n]


def main():
    mod = 10 ** 9 + 7

    r1, c1, r2, c2 = map(int, input().split())

    cl = Calc(max_value=r2 + c2 + 1, mod=mod)

    ret = 0
    for r in range(r1, r2 + 1):
        ret += cl.combination(r + c2 + 1, r + 1)
        ret -= cl.combination(r + (c1 - 1) + 1, r + 1)
        ret %= mod

    print(ret)


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline

N,M = (int(x) for x in input().split())
a = set(int(input()) for _ in range(M))
mem = [0] * N
def count_steps(n):
    if mem[n-1]:
        return mem[n-1]
    elif n - 1 in a and n - 2 in a:
        return 0
    elif n - 1 in a:
        if n > 2:
            mem[n-1] = count_steps(n-2)
            return mem[n-1]
        else:
            mem[1] = 1
            return 1
    elif n - 2 in a:
        mem[n-1] = count_steps(n-1)
        return mem[n-1]
    elif n == 1:
        mem[0] = 1
        return 1
    elif n == 2:
        mem[1] = 2
        return 2
    else:
        mem[n-1] = (count_steps(n-1) + count_steps(n-2)) % 1000000007
        return mem[n-1]
print(count_steps(N))

### FIXED CODE ###

N,M = (int(x) for x in input().split())
a = set(int(input()) for _ in range(M))
dp = [0] * N
broke = False
if N == 1:
    print('1')
    broke = True
elif 1 in a and 2 not in a:
    dp[1] = 1
elif 1 not in a and 2 in a:
    dp[0] = 1
else:
    dp[0] = 1
    dp[1] = 2
if 1 in a and 2 in a:
    print('0')
    broke = True
else:
    for i in range(3,N+1):
        if i-1 in a and i-2 in a:
            print('0')
            broke = True
            break
        elif i-1 in a:
            dp[i-1] = dp[i-3]
        elif i-2 in a:
            dp[i-1] = dp[i-2]
        else:
            dp[i-1] = (dp[i-2] + dp[i-3]) % 1000000007
if broke == False:
    print(dp[N-1])
### BUGGY CODE ###

import numpy as np
import sys
input = sys.stdin.readline

H, W = map(int, input().split())
mat = []
for _ in range(H):
    a = list(input())[:-1]
    mat.append(a)

def calc(H, W, mat):
    x = np.array([])
    for h in range(H):
        cnt = 0
        clm = np.array([])
        for w in range(W):
            if mat[h][w] == '#':
                if cnt == 0:
                    clm = np.hstack( [clm, 0] )
                    cnt = 0
                else:
                    clm = np.hstack( [clm, [cnt]*cnt, 0] )
                    cnt = 0
            else:
                cnt += 1
                if w == W-1:
                    clm = np.hstack( [clm, [cnt]*cnt] )
        x = np.append( x, clm )
    return x.reshape(H, W)

x = calc(H, W, mat)
y = calc(W, H, np.array(mat).T).T
res = np.max( x+y ) - 1
print(int(res))

### FIXED CODE ###

import sys
input = sys.stdin.readline

H, W = map(int, input().split())
F = []
for _ in range(H):
    a = list(input())[:-1]
    F.append(a)

L = [[0]*(W+2) for _ in range(H+2)]
R = [[0]*(W+2) for _ in range(H+2)]
U = [[0]*(W+2) for _ in range(H+2)]
D = [[0]*(W+2) for _ in range(H+2)]

for h in range(1, H+1):
    f = F[h-1]
    l = L[h]
    for w in range(1, W+1):
        l[w] = l[w-1] + 1 if f[w-1] == '.' else 0
        U[h][w] = U[h-1][w] + 1 if f[w-1] == '.' else 0

for h in range(H, 0, -1):
    f = F[h-1]
    r = R[h]
    for w in range(W, 0, -1):
        r[w] = r[w+1] + 1 if f[w-1] == '.' else 0
        D[h][w] = D[h+1][w] + 1 if f[w-1] == '.' else 0

ans = 0
for h in range(1, H+1):
    l, r, u, d = L[h], R[h], U[h], D[h]
    ans = max( ans, max( l[w]+r[w]+u[w]+d[w] for w in range(1, W+1) ))
print(ans-3)
### BUGGY CODE ###

import sys

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

#１回のクエリで半分に空席がある場所を絞る
end = ri() - 1
print(0)
S = rs()[0]
if S == 'V':
    exit()
start = 0
cur = S
for _ in range(19):
    target = start + max(2, (end - start) // 4 * 2)
    print(target)
    s = rs()[0]
    if s == 'V':
        exit()
    if cur != s:
        end = target
    else:
        start = target
print(start + 1)
s = rs()[0]
if s == 'V':
    exit()
else:
    print(start + 2):
    exit()
#24


### FIXED CODE ###

N = int(input())

def ask(n):
    print(n, flush=True)
    resp = input().rstrip()[0]
    if resp == 'V':
        exit()
    return resp

def condition(L,R,resp_L,resp_R):
    if (R-L)&1:
        return resp_L == resp_R
    else:
        return resp_L != resp_R

resp = ask(0)

L = 0
R = N
resp_L = resp
resp_R = resp
for _ in range(19):
    M = (L + R) // 2
    resp_M = ask(M)
    if condition(L,M,resp_L,resp_M):
        R,resp_R = M,resp_M
    else:
        L,resp_L = M,resp_M
### BUGGY CODE ###

n = int(input())
a = input().split(' ')
b = []
for i in range(n):
    b.append(a[i])
    b = b[::-1]
print(' '.join(b))

### FIXED CODE ###

n = int(input())
a = input().split(' ')
b = []
inds = [0] * n

for i in range(int(n/2)):
    inds[i] = n-2*i
    inds[n-1-i] = n-2*i-1
if n % 2 == 1:
    inds[int(n/2)] = n-2*int(n/2)

for i, ind in enumerate(inds):
    print(a[ind-1], end="")
    if i != n-1:
        print(' ', end="")
print('')
### BUGGY CODE ###


N = int(input())
S = input()
ans = 0
R_index = [n for n, v in enumerate(S) if v == 'R']
G_index = [n for n, v in enumerate(S) if v == 'G']
B_index = [n for n, v in enumerate(S) if v == 'B']
for i in range(N):
    for j in range(i+1, N):
        if S[i] == 'R' and S[j] =='G':
            ans += sum(x > j for x in B_index)
            if j+j-i in B_index:
                ans -= 1
            continue
        elif S[i] == 'R' and S[j] =='B':
            ans += sum(x > j for x in G_index)
            if j+j-i in G_index:
                ans -= 1
            continue
        elif S[i] == 'G' and S[j] =='R':
            ans += sum(x > j for x in B_index)
            if j+j-i in B_index:
                ans -= 1
            continue
        elif S[i] == 'G' and S[j] =='B':
            ans += sum(x > j for x in R_index)
            if j+j-i in R_index:
                ans -= 1
            continue
        elif S[i] == 'B' and S[j] =='R':
            ans += sum(x > j for x in G_index)
            if j+j-i in G_index:
                ans -= 1
            continue
        elif S[i] == 'B' and S[j] =='G':
            ans += sum(x > j for x in R_index)
            if j+j-i in R_index:
                ans -= 1
            continue
        # for k in range(j+1, N):
        #     if j-i == k-j:
        #         continue
        #     if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
        #         ans += 1

print(ans)

### FIXED CODE ###

from collections import Counter

N = int(input())
S = input()
index = Counter(S)
ans = index["R"]*index["G"]*index["B"]

for diff in range(1, N//2 +1):
    for i in range(N):
        j = i +diff
        k = j +diff
        if k >= N:
            break
        if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            ans -= 1
print(ans)
### BUGGY CODE ###

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

for i in range(M):
    A[A.index(max(A))] //=2
    
print(sum(A))

### FIXED CODE ###

#!/usr/bin/env python3
import heapq
# import bisect

n, m = list(map(int, input().split()))
a = list(map(lambda x: int(x)*(-1), input().split()))

heapq.heapify(a)
for i in range(m):
    value = heapq.heappop(a)
    value = (value+1)//2
    heapq.heappush(a, value)

# print(a)
print(-sum(a))
### BUGGY CODE ###

n = int(input())
s = input()

r_list = []
g_list = []
b_list = []
for _ in range(n):
    if s[_] == "R":
        r_list.append(_)
    elif s[_] == "G":
        g_list.append(_)
    else:
        b_list.append(_)

count = 0
for r in r_list:
    for g in g_list:
        if min(r, g) - abs(r - g) in b_list:
            count += 1
        if max(r, g) + abs(r - g) in b_list:
            count += 1
        if (r + g) % 2 == 0:
            if (r + g) // 2 in b_list:
                count += 1
                
print(len(r_list) * len(g_list) * len(b_list) - count)

### FIXED CODE ###

n = int(input())
s = input()

r_list = []
g_list = []
for _ in range(n):
    if s[_] == "R":
        r_list.append(_)
    elif s[_] == "G":
        g_list.append(_)

count = 0
for r in r_list:
    for g in g_list:
        if min(r, g) - abs(r - g) > 0:
            if s[min(r, g) - abs(r - g)] == "B":
                count += 1
        if max(r, g) + abs(r - g) < n:
            if s[max(r, g) + abs(r - g)] == "B":
                count += 1
        if (r + g) % 2 == 0:
            if s[(r + g) // 2] == "B":
                count += 1


print(len(r_list) * len(g_list) * (n - len(r_list) - len(g_list)) - count)
### BUGGY CODE ###

N,x = map(int,(input().split()))
if N == 2:
    if x == 2:
        print("Yes")
        for i in range(1,4):
            print(i)
    else:
        print("No")
else:
    M = 2*N-1
    if x == 1 or x ==M:
        print("No")
    else:
        print("Yes")

        ans = [0]*(M)
        num = list(range(1,M+1))
        if x == 2:
            ans[M//2] = x
            ans[M//2-1] = 1
            num.remove(x)
            num.remove(1)
            for i in range(M):
                if ans[i] == 0:
                    ans[i] = num[0]
                    num.pop(0)
        else:
            ans[M//2] = x
            ans[M//2-1] = x+1
            ans[M//2-2] = x-2
            ans[M//2+1] = x-1
            num.remove(x)
            num.remove(x+1)
            num.remove(x-2)
            num.remove(x-1)
            for i in range(M):
                if ans[i] == 0:
                    ans[i] = num[0]
                    num.pop(0)
    
        for i in range(M):
            print(ans[i])

### FIXED CODE ###

from collections import deque
N,x = map(int,(input().split()))
if N == 2:
    if x == 2:
        print("Yes")
        for i in range(1,4):
            print(i)
    else:
        print("No")
else:
    M = 2*N-1
    if x == 1 or x ==M:
        print("No")
    else:
        print("Yes")

        ans = [0]*(M)
        num = deque(list(range(1,M+1)))
        if x == 2:
            ans[M//2] = x
            ans[M//2-1] = 1
            num.remove(x)
            num.remove(1)
            for i in range(M):
                if ans[i] == 0:
                    ans[i] = num.popleft()
        else:
            ans[M//2] = x
            ans[M//2-1] = x+1
            ans[M//2-2] = x-2
            ans[M//2+1] = x-1
            num.remove(x)
            num.remove(x+1)
            num.remove(x-2)
            num.remove(x-1)
            for i in range(M):
                if ans[i] == 0:
                    ans[i] = num.popleft()
    
        for i in range(M):
            print(ans[i])
### BUGGY CODE ###

n = int(input())
note = dict()
ans = 0
for i in range(n):
    s = "".join(sorted(input()))
    if s in note.keys():
        ans += note[s]
        note[s] += 1
    else:
        note[s] = 1

print(ans)

### FIXED CODE ###

import sys
#input = sys.stdin.readline

n = int(input())
note = dict()
ans = 0
for i in range(n):
    s = "".join(sorted(sys.stdin.readline()))
    if s in note.keys():
        ans += note[s]
        note[s] += 1
    else:
        note[s] = 1

print(ans)
### BUGGY CODE ###

from collections import deque

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

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

def bfs(sx, sy):
    s = [[-1] * W for _ in range(H)]
    d = [[0] * W for _ in range(H)]

    que = deque([])
    que.append((sx, sy))
    s[sy][sx] = 1

    res = 0
    while que:
        x, y = que.popleft()
        s[y][x] = 1

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

            if 0 <= nx < W and 0 <= ny < H and s[ny][nx] == -1 and c[ny][nx] == '.':
                que.append((nx, ny))
                d[ny][nx] = d[y][x] + 1
                res = max(res, d[ny][nx])

    return res

ans = 0
for i in range(H):
    for j in range(W):
        if c[i][j] == '.':
            ans = max(ans, bfs(j, i))

print(ans)


### FIXED CODE ###

from collections import deque

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

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

def bfs(sx, sy):
    d = [[-1] * W for _ in range(H)]

    que = deque([])
    que.append((sx, sy))
    d[sy][sx] = 0

    res = 0
    while que:
        x, y = que.popleft()

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

            if 0 <= nx < W and 0 <= ny < H and d[ny][nx] == -1 and c[ny][nx] == '.':
                que.append((nx, ny))
                tmp = d[y][x] + 1
                d[ny][nx] = tmp
                res = max(res, tmp)

    return res

ans = 0
for i in range(H):
    for j in range(W):
        if c[i][j] == '.':
            tmp = bfs(j, i)
            ans = max(ans, tmp)

print(ans)
### BUGGY CODE ###


def div(N):
    ans = []
    for i in range(1, int(N ** 0.5) + 1):
        if N % i == 0:
            ans.append(i)
            if N // i != i:
                ans.append(N // i)
    ans.sort()
    return ans


import fractions

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

g=fractions.gcd(A,B)

if g==1:
    print(1)
    exit()

d_list=div(g)

if len(d_list)==2:
    print(2)
    exit()

i=1

while d_list[i]<g:
    j=2
    temp=d_list[i]
    while temp*j<=d_list[-1]:
        if temp*j in d_list:
            d_list.remove(temp*j)
        j+=1
    i+=1
    if i==len(d_list):
        break


print(len(d_list))








### FIXED CODE ###

def div(N):
    ans = []
    for i in range(1, int(N ** 0.5) + 1):
        if N % i == 0:
            ans.append(i)
            if N // i != i:
                ans.append(N // i)
    ans.sort()
    return ans
import fractions

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

g=fractions.gcd(A,B)

if g==1:
    print(1)
    exit()
cnt=0
di=div(g)

for i in di:
    f=True
    for j in range(2,int(i**0.5)+1):
        if i%j==0:
            f=False
            break
    if f:
        cnt+=1
print(cnt)