Harryxun/stf_run huggingface dataset:
import sys
import numpy as np
from fractions import gcd
a, b = [int(i) for i in sys.stdin.readline().split()]
_gcd = gcd(a,b)
memo_ls = np.zeros(_gcd)
#memo_set = set()
cnt = 0
if gcd == 1:
    print(1)
else:
    for i in range(2, _gcd+1):
        if _gcd % i == 0 and memo_ls[i-1] != 1:
            memo_ls[i-1::i] = 1
            cnt += 1
            #memo_set.add(i)
    #print(memo_set)
    print(cnt + 1)

### FIXED CODE ###

import sys
from fractions import gcd
def prime_factorize(n):
    a = set()
    while n % 2 == 0:
        a.add(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.add(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.add(n)
    return a

def main(a, b):
    #a, b = [int(i) for i in sys.stdin.readline().split()]
    _gcd = gcd(a,b)
    #memo_ls = [0 for i in range(_gcd)]
    #memo_set = set()
    cnt = 0
    if _gcd == 1:
        print(1)
    else:
        res = prime_factorize(_gcd)
        print(len(res) + 1)
if __name__ == "__main__":
    a, b = [int(i) for i in sys.stdin.readline().split()]
    main(a, b)
n=int(input())
a=list(map(int,input().split()))
f=0
for i in range(n-1):
  if a[i]<=0 and a[i+1]<=0 and f==0:
    a[i]=a[i]*(-1)
    a[i+1]=a[i+1]*(-1)
    f=1
  elif a[i]*a[i+1]<=0:
    

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
sei=[0]*n
mai=0
zero=0
pr=0
for i in range(n):
  sei[i]=max(a[i],-a[i])
  pr+=sei[i]
  if a[i]<0:
    mai +=1
  elif a[i]==0:
    zero+=1
  else:
    pass
#ゼロと負の数を数える
if mai%2==0 or zero >=1:
    print(pr)
else:
    print(pr-2*min(sei))
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split())))
ab, abc = [], []

for i in a:
    for j in b:
        ab.append(i+j)

ab.sort()
s = ab[x*y-k:]
for i in s:
    for j in c:
        abc.append(i+j)

abc.sort(reverse=True)
for i in range(k):
    print(abc[i])

### FIXED CODE ###

x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ab, abc = [], []

for i in a:
    for j in b:
        ab.append(i+j)

ab.sort()
s = ab[x*y-k:]
for i in s:
    for j in c:
        abc.append(i+j)

abc.sort(reverse=True)
for i in range(k):
    print(abc[i])
N, Q = (int(i) for i in input().split())
S = input()

AC_list = [0] * N
 
val=0
for i in range(N-1):
    if(S[i+1]=="C"):
        if(S[i]=="A"):
            val +=1

    AC_list[i] = val

for i in range(Q):
    l, r = (int(_) for _ in input().split())
    if(AC_list[r-1]==1 and S[r]=="C"):
        print(val[r-1]-1)
    else:
        print(val[r-1])



### FIXED CODE ###

N, Q = (int(i) for i in input().split())
S = input()

AC_list = [0] * (N+1)
 
val=0
for i in range(N-1):
    if(S[i+1]=="C"):
        if(S[i]=="A"):
            val +=1

    AC_list[i+1] = val
AC_list[i+2] = val

for i in range(Q):
    l, r = (int(_) for _ in input().split())
    if(r!=N):
        if(S[r-1]=="A" and S[r]=="C"):
            print(AC_list[r]-AC_list[l-1]-1)
        else:
            print(AC_list[r]-AC_list[l-1])
    else:
        print(AC_list[r]-AC_list[l-1])
num = input().split()
participant = int(num[0])
init_point = int(num[1])
correct = int(num[2])

tmp = [init_point]*participant

for i in range(participant):
  answer_person = int(input())
  tmp[answer_person-1] += 1
  tmp = [i-1 for i in tmp]
  
for item in tmp:
  if item>0: print("Yes")
  else: print("No")

### FIXED CODE ###

import sys

num = input().split()
participant = int(num[0])
init_point = int(num[1])
correct = int(num[2])

tmp = [0]*participant

for i in range(correct):
  answer_person = int(input())-1
  tmp[answer_person] += 1

for i in tmp:
  if i<=correct-init_point:
    print("No")
  else:
    print("Yes")
n,l = map(int, input().split())
s = [input() for i in range(N)]
print("".join(s.sort()))

### FIXED CODE ###

n,l = map(int, input().split())
s = [input() for i in range(n)]
s.sort()
print("".join(s))
n11, n12, n13 = map(int,input().split())
n21, n22, n23 = map(int,input().split())
n31, n32, n33 = map(int,input().split())
lines = [[n11,n12,n13],
         [n21,n22,n23],
         [n31,n32,n33],
         [n11,n21,n31],
         [n12,n22,n32],
         [n13,n23,n33],
         [n11,n22,n33],
         [n13,n22,n31]]
nums = {}
r = input()
for i in range(int(r)):
  nums[input()] = 0
flag = False
for l in lines:
  if l[0] in nums:
    if l[1] in nums:
      if l[2] in nums:
        flag = True
if flag:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

import math
s = input()
s = int(s)
s = s/2
s = math.ceil(s)
print(s)
import sys
import fractions


def input():
    return sys.stdin.readline()[:-1]


N = int(input())
ans = 0
for _ in range(N):
    if ans == 0:
        ans = int(input())
    else:
        t = int(input())
        ans = (ans * t) // math.gcd(ans, t)
print(ans)


### FIXED CODE ###

import sys
import fractions


def input():
    return sys.stdin.readline()[:-1]


N = int(input())
ans = 0
for _ in range(N):
    if ans == 0:
        ans = int(input())
    else:
        t = int(input())
        ans = (ans * t) // fractions.gcd(ans, t)
print(ans)
N,M=list(map(int,input().split()))
L=[]
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

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

    def Unite(self, x, y):
        x=self.find_root(x)
        y=self.find_root(y)

        if(x==y):
            return 
        elif(self.rnk[x]>self.rnk[y]):
            self.root[x]+=self.root[y]
            self.root[y]=x
        else:
            self.root[y]+=self.root[x]
            self.root[x]=y
            if(self.rnk[x]==self.rnk[y]):
                self.rnk[y]+=1
    def isSameGroup(self,x,y):
        if(self.find_root(x)==self.find_root(y)):
            return True
        else:
            False

    def Size(self,x):
        return -self.root[self.find_root(x)]

for i in range(M):
    li = list(map(int,input().split()))
    L.append(li)
L=L[::-1]

ans = [0]*(M+1)
ans[0] = N*(N-1)/2
T = UnionFind(N)
for i in range(N):
    if(T.isSameGroup(L[i][0],L[i][1])):
        ans[i+1] = ans[i]
        continue
    else:
        ans[i+1] = max(0, ans[i]-T.Size(L[i][0])*T.Size(L[i][1]))
        T.Unite(L[i][0],L[i][1])

for i in range(M-1,-1,-1):
    print(int(ans[i]))
#print(len(ans))

### FIXED CODE ###

N,M=list(map(int,input().split()))
L=[]
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

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

    def Unite(self, x, y):
        x=self.find_root(x)
        y=self.find_root(y)

        if(x==y):
            return 
        elif(self.rnk[x]>self.rnk[y]):
            self.root[x]+=self.root[y]
            self.root[y]=x
        else:
            self.root[y]+=self.root[x]
            self.root[x]=y
            if(self.rnk[x]==self.rnk[y]):
                self.rnk[y]+=1
    def isSameGroup(self,x,y):
        if(self.find_root(x)==self.find_root(y)):
            return True
        else:
            False

    def Size(self,x):
        return -self.root[self.find_root(x)]

for i in range(M):
    li = list(map(int,input().split()))
    L.append(li)
L=L[::-1]

ans = [0]*(M)
ans[0] = N*(N-1)/2
T = UnionFind(N)
for i in range(M-1):
    if(T.isSameGroup(L[i][0],L[i][1])):
        ans[i+1] = ans[i]
        continue
    else:
        ans[i+1] = max(0, ans[i]-T.Size(L[i][0])*T.Size(L[i][1]))
        T.Unite(L[i][0],L[i][1])

for i in ans[::-1]:
    print(int(i))
#print(len(ans))
N, K = map(int,input().split())	
S = input()

#print(S[K-1])
S = (S[:K-2]+S[K-1].lower()+S[K:]
print(S)

### FIXED CODE ###

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

#print(S[K-1])
S = (S[:K-1] + S[K-1].lower() + S[K:])
print(S)
S = input()
K = int(input())

k = min(K,len(S))

for i in range(k):
    if S[i] != '1':
        ans = S[i]
        break
print(ans)

### FIXED CODE ###

S = input()
K = int(input())
 
k = min(K,len(S))

ans = 1

for i in range(k):
    if S[i] != '1':
        ans = S[i]
        break
print(ans)
import numpy as np
import matplotlib.pyplot as plt

def main():
	print('Input A')
	a = int(input())
	print('Input P')
	p = int(input())

	tips = a * 3 + p
	pie = int(tips / 2)

	print("output\n"+str(pie))


if __name__ == '__main__':
	main()

### FIXED CODE ###

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

tips = a * 3 + p
pie = tips // 2

print(pie)
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
sum = 0
people = 0

if x == sum(a):
    print(n)
elif x > sum(a):
    print(n-1)
else:
    for i in a:
        sum += i
        people += 1
        if sum > x:
            print(people-1)
            break

### FIXED CODE ###

N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
if x == sum(a):
    print(N)
elif x > sum(a):
    print(N-1)
else:
    for i in range(N):
        if sum(a[:i+1]) > x:
            print(i)
            break
A, B, C = map(int, input().split())
print(min(B // A), C)

### FIXED CODE ###

A, B, C = map(int, input().split())
print(min(B // A, C))
from math import gcd
N, K = map(int, input().split())
A = list(map(int, input().split()))
if max(A) < K:
    print("IMPOSSIBLE")
else:
    temp = A[0]
    for a in A[1:]:
        temp = gcd(a, temp)
    if K % temp == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

### FIXED CODE ###

from fractions import gcd
N, K = map(int, input().split())
A = list(map(int, input().split()))
if max(A) < K:
    print("IMPOSSIBLE")
else:
    temp = A[0]
    for a in A[1:]:
        temp = gcd(a, temp)
    if K % temp == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
a,b = map(int,input().split())

if a > b:
    print('GREATER')
elif a < b:
    print('LESS')
else:
    print('EQUAL')

### FIXED CODE ###

a = int(input())
b = int(input())

if a > b:
    print('GREATER')
elif a < b:
    print('LESS')
else:
    print('EQUAL')
a, b=map(int, input().sprit())
if a>b:
	print("a > b")
else:
	if a<b:
		print("a < b")
	else:
		print("a == b")
		

### FIXED CODE ###

a, b=map(int, input().split())
if a>b:
	print("a > b")
else:
	if a<b:
		print("a < b")
	else:
		print("a == b")
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(N)]

nl = []
for i in range(N):
    for j in range(l[i][1]):
        nl.append(l[i][0])
    
sorted_nl = sorted(nl)

ans = 0
for i in range(M):
    ans += sorted_nl[i]
    
print(ans)

### FIXED CODE ###

S=list(input())
N=len(S)
S_int_1=list(S)
S_int_2=list(S)
for i in range(N):
    S_int_1[i]=int(S[i])
    S_int_2[i]=int(S[i])
cnt_1=0
cnt_2=0
for i in range(N):
    if i%2==0 and S_int_1[i]==0:
        S_int_1[i]=1
        cnt_1+=1
    elif i%2==1 and S_int_1[i]==1:
        S_int_1[i]=0
        cnt_1+=1
for i in range(N):
    if i%2==0 and S_int_2[i]==1:
        S_int_2[i]=0
        cnt_2+=1
    elif i%2==1 and S_int_2[i]==0:
        S_int_2[i]=1
        cnt_2+=1
print(min(cnt_1,cnt_2))
m = map(int,raw_input().split())
a = m[0]
b = m[1]

d = a / b
r = a % b
f = l.0 * a / b

print int(d),int(r),long(f)

### FIXED CODE ###

m = map(int,raw_input().split())
a = m[0]
b = m[1]

d = a / b
r = a % b
f = a * 1.0 / b

print '%d %d %f' %(d, r, f)
#!/usr/bin/env python
#coding: UTF-8
import sys
import math

line = []
for l in sys.stdin:
    for i in l.split(' '):
    	line.append(float(i))
a = math.sqrt((line[0]-line[2])**2+(line[1]-line[3])**2)
print '%06.20f'%a

### FIXED CODE ###

import math

x1,y1,x2,y2 = map(float,raw_input().split())
a = math.sqrt((x1-x2)**2+(y1-y2)**2)
print '%f'%a
n, m = map(int, input().split())
a = [[None] * m for _ in range(n)]
b = [None] * m
for i in range(n):
    a[i] = list(map(int, input().split()))
for i in range(m):
    b[i] = int(input())
for _ in range(n):
    c = 0
    for i in range(m):
        c += a[i] * b[i]
    print(c)



### FIXED CODE ###

n, m = map(int, input().split())
A = [map(int, input().split()) for _ in [None] * n]
b = [int(input()) for _ in [None] * m]
for a in A:
    print(sum(i * j for i, j in zip(a, b)))
import sys
from collections import Counter
n = int(input())
ls = []
for i in range(n):
    x, y = [int(i) for i in sys.stdin.readline().split()]
    ls.append((x, y))
res = []
for i in range(n - 1):
    for j in range(i+1, n):
        res.append((ls[j][0] - ls[i][0], ls[j][1] - ls[i][1]))
ct = Counter(res)
print(n - max(ct.values()))

### FIXED CODE ###

import sys
from collections import Counter
n = int(input())
ls = []
if n == 1:
    print(1)
else:
    for i in range(n):
        x, y = [int(i) for i in sys.stdin.readline().split()]
        ls.append((x, y))
    res = []
    for i in range(n - 1):
        for j in range(i+1, n):
            res.append((ls[j][0] - ls[i][0], ls[j][1] - ls[i][1]))
            res.append((- ls[j][0] + ls[i][0], - ls[j][1] + ls[i][1]))
    ct = Counter(res)
    print(n - max(ct.values()))
import io
import sys
from math import ceil


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
4
0
0
0
0
'''


def MAIN():
  T_IN()
  A()


def A():
  n = IN_I()

  l = [IN_I()]

  for i in range(0, n - 1):
    num = IN_I()

    # print("s:", l)
    # print("num:", num)
    if l[0] >= num:
      l.insert(0, num)
      continue

    inl = 0
    inr = len(l) - 1
    # 1, 2, 3, 4, 5
    for j in range(0, len(l)):
      if inr == inl:
        l.pop(inr)
        break

      mid = ceil((inr - inl) / 2)
      # print(mid, inl, inr)
      if l[mid] == num:
        inr = mid - 1
      elif l[mid] > num:
        inr = mid - 1
      else:
        inl = mid

    inl = 0
    inr = len(l) - 1
    # print("nuita:", l)
    for j in range(0, len(l)):
      mid = ceil((inr - inl) / 2)
      if mid == inl:
        if l[mid] >= num:
          l.insert(mid, num)
        else:
          l.insert(mid + 1, num)
        break
      elif l[mid] == num:
        l.insert(mid, num)
      elif l[mid] > num:
        inr = mid - 1
      else:
        inl = mid + 1

  # print(l)
  print(len(l))
  return None


def B():
  return None


def C():
  return None


MAIN()


### FIXED CODE ###

import io
import sys
from bisect import bisect_right, bisect_left
from collections import deque


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
7
1
0
3
4
1
2
1
'''


def MAIN():
  # T_IN()
  A()


def A():
  n = IN_I()

  l = deque([IN_I()])

  for i in range(0, n - 1):
    num = IN_I()

    idx = bisect_left(l, num)
    if idx == 0:
      l.appendleft(num)
    else:
      l[idx - 1] = num
    # print(l)

  print(len(l))
  return None


def B():
  return None


def C():
  return None


MAIN()
N, food = map(int, input().split())
S = set(range(1,food+1))
for i in range(N):
  k, *a = ma(int,input().split())
  S &= set(a)
print(len(S))

### FIXED CODE ###

n,m=map(int,input().split())
S=set(range(1,m+1))
for i in range(n):
    K,*A=map(int,input().split())
    S&=set(A)
print(len(S))
from collections import defaultdict
from itertools import permutations
import heapq

INF = float('inf')
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
memo = [[INF for _ in range(N)] for _ in range(N)]

Adj_list = defaultdict(set)

for i in range(M):
    a, b, c = map(int, input().split())
    if memo[a-1][b-1]:
        memo[a-1][b-1] = min(memo[a-1][b-1], c)
        
    Adj_list[a-1].add((b-1, memo[a-1][b-1]))
    Adj_list[b-1].add((a-1, memo[a-1][b-1]))


def dijkstra(x, vertex):
    d = [INF] * x
    d[vertex] = 0
    hq = [(0, vertex)]
    
    while hq:
        u = heapq.heappop(hq)[1]
        for (v, c) in Adj_list[u]:
            if d[v] > d[u] + c:
                d[v] = d[u] + c
                heapq.heappush(hq, (d[u]+c, v))

    return d

ans = INF

table = []
for i in range(N):
    d = dijkstra(N, i)
    min_d = min(d)
    min_d_ind = d.index(min_d)
    table[i][min_d_ind] = min_d 

for each in permutations(r):
    t_dis = 0
    for i in range(R-1):
        if table[each[i]-1][each[i+1]-1] == INF:
            continue
        t_dis += table[each[i]-1][each[i+1]-1]
    ans = min(ans, t_dis)

print(ans)

### FIXED CODE ###

from collections import defaultdict
from itertools import permutations
import heapq

INF = float('inf')
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
memo = [[INF for _ in range(N)] for _ in range(N)]

Adj_list = defaultdict(set)

for i in range(M):
    a, b, c = map(int, input().split())
    if memo[a-1][b-1]:
        memo[a-1][b-1] = min(memo[a-1][b-1], c)
        
    Adj_list[a-1].add((b-1, memo[a-1][b-1]))
    Adj_list[b-1].add((a-1, memo[a-1][b-1]))


def dijkstra(x, vertex):
    d = [INF] * x
    d[vertex] = 0
    hq = [(0, vertex)]
    
    while hq:
        u = heapq.heappop(hq)[1]
        for (v, c) in Adj_list[u]:
            if d[v] > d[u] + c:
                d[v] = d[u] + c
                heapq.heappush(hq, (d[u]+c, v))

    return d

ans = INF
t_dis = 0

table = {}
for i in r:
    table[i-1] = dijkstra(N, i-1)

for each in permutations(r):
    t_dis = 0
    for i in range(R-1):
        t_dis += table[each[i]-1][each[i+1]-1]
    #print(each, t_dis)
    ans = min(ans, t_dis)

print(ans)
n,k = map(int,input().split())
a=[int(aa)-1 for aa in input().split() ]

been = [0]*n

now=0
been[0]=1
for i in range(k):
    now=a[now]
    if been[now]==0:
        been[now]=1
    else:
        t_stack=sum(been)
        break


start=now

been = [0]*n
been[now]=1
for i in range(k):
    now=a[now]
    if been[now]==0:
        been[now]=1
    else:
        period=sum(been)
        break

now=start
for i in range((k-(t_stack-period))%period):
    now=a[now]
print(now+1)

### FIXED CODE ###

n,k = map(int,input().split())
a=[int(aa)-1 for aa in input().split() ]

now=0

been = [0]*n
been[0]=1
for i in range(n):
    now=a[now]
    if been[now]==0:
        been[now]=1
    else:
        t_stack=sum(been)
        break

start=now

been = [0]*n
been[now]=1
for i in range(n):
    now=a[now]
    if been[now]==0:
        been[now]=1
    else:
        period=sum(been)
        break

        
if k<=t_stack:
    now=0
    for i in range(k):
        now=a[now]
    print(now+1)
    
else:
    n_itr = (k-t_stack+period)%period
    now=start
    for i in range(n_itr):
        now=a[now]
    print(now+1)
a,b=map(int, input().split())
if ((a%3 == 0) or (b%3 == 0)) or (sum(a,b)%3== 0):
  print("Possible")
else:
  print("Impossible")

### FIXED CODE ###

a,b=map(int, input().split())
if ((a%3 == 0) or (b%3 == 0)) or ((a + b)%3== 0):
  print("Possible")
else:
  print("Impossible")
n,k=map(int,input().split())
l=[]
for j in range(0,4):
    l.append(input().split())
ans=0
for a in range(0,k):
     for b in range(0,k):
         i=0
         total=0
         while i<n:
           m=(abs(int(l[i][0])-a)//k)%2
           h=(abs(int(l[i][1])-b)//k)%2
           if ((m+h)%2==0 and str(l[i][2])=="W") or ((m+h)%2==1 and str(l[i][2])=="B"):
               total=total+1
               i=i+1
           else:
               i=i+1

         else:
              ans=max(ans,total,n-total)
print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
imos = [[0 for i in range(k)] for j in range(k)]
white = 0
for i in range(n):
    x, y, c = input().split()
    x = int(x)
    y = int(y)
    if c == "W":
        c = 1
    else:
        c = 0
    x %= 2*k
    y %= 2*k

    if x > k-1:
        x -= k
        c += 1
    if y > k-1:
        y -=k
        c += 1
    c %= 2

    if c == 1:
        white += 1
        imos[x][y] -= 1
    else:
        imos[x][y] += 1

for i in range(k):
    for j in range(k-1):
        imos[i][j+1] += imos[i][j]

for j in range(k):
    for i in range(k-1):
        imos[i+1][j] += imos[i][j]

ans = 0
for i in range(k):
    for j in range(k):
        exp = imos[k-1][k-1] - imos[k-1][j] - imos[i][k-1] + 2 * imos[i][j] + white
        ans = max(ans, max(exp, n - exp))

print(ans)
# D - Disjoint Set of Common Divisors
A, B = map(int, input().split())

from fractions import gcd

# n以下の素数列挙 O(n log(n))
def primes(n):
    ass = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            ass.append(i)
    return ass

ans = 0
prms = primes(gcd(A, B))
if len(prms) > 0:
    for pr in prms:
        if A%pr == 0 and B%pr == 0:
            ans += 1

print(ans+1)
# 1は素数に含まれないが今回の問題の回答に含まれるので+1

### FIXED CODE ###

# D - Disjoint Set of Common Divisors
A, B = map(int, input().split())

from fractions import gcd

# nの素数判定
def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

# nの約数列挙
def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            ass.append(n//i)
    return ass #sortされていない

ans = 0
gcd1 = gcd(A, B)
for i in divisor(gcd1):
    if is_prime(i):
        ans += 1

print(ans+1)
def main():
  
  n,w=map(int,input().split())
  item=[[0,0]]+[list(map(int,input().split())) for _ in range(n)]
  DP=[[0]*(w+1) for _ in range(n+1)]
  for i in range(n+1):
    weight=item[i][0]
    value=item[i][1]
    for j in range(w+1):
      if j<weight:
        DP[i][j]=DP[i-1][j]
      else:
        DP[i][j]=max(DP[i-1][j],DP[i-1][j-weight]+value)
        
  print(DP[n][w])
      
if __name__=="__main__":
  main()

### FIXED CODE ###

n=int(input())
h=[10**6]+list(map(int,input().split()))
c=[0]*(n+1)
for i in range(2,n+1):
  a=c[i-1]+abs(h[i]-h[i-1])
  b=c[i-2]+abs(h[i]-h[i-2])
  c[i]=min(a,b)
print(c[n])