Harryxun/stf_run huggingface dataset:
def main():
    N = int(input())
    S = list(str(input()))
    sum = 0
    for i in range(0, N-2):
        si = S[i]
        for j in range(i, N-1):
            sj = S[j]
            k = 2*j -i  # Nを超える
            if k <= N:
                sk = S[k]
                if j - i != k -j and si != sj and si != sk and sj != sk:
                    sum += 1
    print(sum)


main()

### FIXED CODE ###

def main():
    N = int(input())
    S = list(str(input()))
    sum = S.count("R") * S.count("G") * S.count("B")
    for i in range(0, N-2):
        si = S[i]
        for j in range(i+1, N-1):
            sj = S[j]
            k = 2*j -i  # Nを超える
            if k < N:
                sk = S[k]
                #if j - i != k -j and si != sj and si != sk and sj != sk:
                if si != sj and si != sk and sj != sk:
                    sum -= 1
    print(sum)

    # 提出 #11871188


main()
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
p = 10**9+7

n = int(input())
a = list( map(int, input().split()))
count = [0]*n

for i in range(n+1):
    count[a[i]-1] += 1
    if count[a[i]-1] == 2:
        right = i
        left = a.index(a[i])
        break

print(left,right)

def nCr_mod_p(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 5  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p), 0! = 1! = 1
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p), 0! = 1! = 1
inv = [0, 1]  # inv[n] = n^(-1) mod p, 0! = 1　だけど便宜上inv[0]=0にしてる

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

for i in range(1,n+2):
    ans = nCr_mod_p(n+1,i,p) - nCr_mod_p(n-right+left,i-1,p)
    print(ans%p)



### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
p = 10**9+7

n = int(input())
a = list( map(int, input().split()))
count = [0]*n

for i in range(n+1):
    count[a[i]-1] += 1
    if count[a[i]-1] == 2:
        right = i
        left = a.index(a[i])
        break

def nCr_mod_p(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 5  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p), 0! = 1! = 1
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p), 0! = 1! = 1
inv = [0, 1]  # inv[n] = n^(-1) mod p, 0! = 1　だけど便宜上inv[0]=0にしてる

for i in range(2, N + 2):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

for i in range(1,n+2):
    ans = nCr_mod_p(n+1,i,p) - nCr_mod_p(n-right+left,i-1,p)
    print(ans%p)
N=number=int(input())
X_list=list(map(int, input().split()))

X_min=min(X_list)
X_max=max(X_list)
for i in range(X_min,X_max):
    sum_pow=0
    for j in range(1,N):
        sum_pow+=(X_list[j]-i)**2
    if i==X_min:
        min_pow=sum_pow
    if min_pow>sum_pow:
        min_pow=sum_pow
print(min_pow)

### FIXED CODE ###

N=number=int(input())
X_list=list(map(int, input().split()))
min_pow=0
if N==1:
    print("0")
else:
    X_min=min(X_list)
    X_max=max(X_list)
    for i in range(X_min,X_max):
        sum_pow=0
        for j in range(N):
            sum_pow+=(X_list[j]-i)**2
        if i==X_min:
            min_pow=sum_pow
        if min_pow>sum_pow:
            min_pow=sum_pow
    print(min_pow)
import Collections
a,b,c=map(int,input().split())
n=[a,b,c]
d,e=zip(*n.most_common())
d=list(d)
print(d[-1])

### FIXED CODE ###

a,b,c=map(int,input().split())
if a-b==0:
  print(c)
elif a-c==0:
  print(b)
elif b-c==0:
  print(a)
n=int(input())
fir=int(input())
sec=int(input())
max_=sec
if(fir>sec):
    min_=sec
elif(fir<=sec):
    min_=fir
max_dif=sec-fir
if n>2:
    for i in range(n-2):
        x=int(input())
        if x>max_num:
            max_num = x
            if max_dif < x-min_:
                max_dif = x-min_
        if x<min_:
            min_ = x
            max_num=1
print(max_dif)

### FIXED CODE ###

#ALDS1_1_D Maximum Profit
n=int(input())
A=[]
max_dif=-1*10**9
for i in range(n):
    A.append(int(input()))
min=A[0]
for i in range(n-1):
    if(A[i+1]-min>max_dif):
        max_dif=A[i+1]-min
    if(min>A[i+1]):
        min=A[i+1]
print(max_dif)
While 1:
    m,f,r=map(int,input().split())
    if m==f==r==-1:break
    if m+f >= 80:print('A')
    elif m+f >= 65:print('B')
    elif m+f >= 50:print('C')
    elif m+f >= 30:
        if r > 50:print('C')
        else:print('D')
    else:print('F')

### FIXED CODE ###

while True:
    m,f,r=map(int,input().split())
    if m==f==r==-1:break
    a=m+f
    if m==-1 or f==-1:print('F')
    elif a >= 80:print('A')
    elif a >= 65:print('B')
    elif a >= 50:print('C')
    elif a >= 30:
        if r >= 50:print('C')
        else:print('D')
    else:print('F')
N = int(input())
cnt = 0

for i in range(1,N+1)
    if i % 2 == 0:continue
    c = 0
    for j in range(1,N+1):
        if cnt > 8:
            cnt -= 1:continue
        if i % j == 0:
            c += 1
    if c ==8:
        cnt += 1
print(cnt)

### FIXED CODE ###

N = int(input())

if N < 105:
    print(0)
elif N < 135:
    print(1)
elif N < 165:
    print(2)
elif N < 189:
    print(3)
elif N < 195:
    print(4)
else:
    print(5)
N, A, B = map(int,open(0).read().split())
if N == 1:
    print("Hello World")
if N == 2:
    print(A + B)

### FIXED CODE ###

*N,= map(int,open(0).read().split())
if N[0] == 1:
    print("Hello World")
if N[0] == 2:
    print(N[1] + N[2])
N, M, X, Y =map( int, input().split())
x = list(map( int, input().split()))
y = list(map( int, input().split()))
 
x = sorted(x)
y = sorted(y)
 
for i in range(X + 1, Y + 1):
  if( x[N-1] < i <= y[0]):
    print('No War')
    exit()
    
print('War')

### FIXED CODE ###

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

N = sorted(N)

Nmax = int( N[2] * 10 + N[1] + N[0])

print(int(Nmax))
x, n = list(map(int, input().split()))

if n == 0:
  print(x)
  exit(0)
else:
  arr = list(map(int, input().split()))

arr.sort()
i = arr.index(x)

if not i and i != 0:
  print(x)
  exit(0)

j = 1
for _ in range(n):
  row = i - j
  high = i + j
  if row >= 0 and arr[row] != x - j:
    print(x - j)
    exit(0)
  elif high <= n-1 and arr[high] != x + j:
    print(x + j)
    exit(0)
  j += 1

print(x-1)



### FIXED CODE ###

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

if n == 0:
  print(x)
  exit(0)
else:
  arr = list(map(int, input().split()))

arr.sort()
if x in arr:
  i = arr.index(x)
else:
  print(x)
  exit(0)

if not i and i != 0:
  print(x)
  exit(0)

j = 1
for _ in range(n):
  row = i - j
  high = i + j
  if x - j not in arr:
    print(x - j)
    exit(0)
  elif x + j not in arr:
    print(x + j)
    exit(0)
  j += 1

print(x-1)
import collections
n=int(input())
s=str(input())
d=collections.defaultdict(list)
count=0
v=collections.defaultdict(int)
for i in range(n):
    d[s[i]].append(i)
for i in range(len(d["R"])):
    for j in range(i,len(d["G"])):
        if j>i:
            for k in range(j,len(d["B"])):
                if k>j:
                    if j-i!=k-j:
                        count+=1
for i in range(len(d["R"])):
    for j in range(i,len(d["B"])):
        if j>i:
            for k in range(j,len(d["G"])):
                if k>j:
                    if j-i!=k-j:
                        count+=1
for i in range(len(d["G"])):
    for j in range(i,len(d["R"])):
        if j>i:
            for k in range(j,len(d["B"])):
                if k>j:
                    if j-i!=k-j:
                        count+=1
for i in range(len(d["G"])):
    for j in range(i,len(d["B"])):
        if j>i:
            for k in range(j,len(d["R"])):
                if k>j:
                    if j-i!=k-j:
                        count+=1
for i in range(len(d["B"])):
    for j in range(i,len(d["R"])):
        if j>i:
            for k in range(j,len(d["G"])):
                if k>j:
                    if j-i!=k-j:
                        count+=1
for i in range(len(d["B"])):
    for j in range(i,len(d["G"])):
        if j>i:
            for k in range(j,len(d["R"])):
                if k>j:
                    if j-i!=k-j:
                        count+=1
                #v[(i,j,k)]+=1
print(count)
#print(v)
#print(len(v))

### FIXED CODE ###

n=int(input())
c=0
while n!=0:
    s=n%10
    if s==7:
        c=1
        break
    n=n//10
if c==0:
    print("No")
else:
    print("Yes")
import numpy as np
from scipy import sparse

S = [v for v in input()]
N = len(S)
M = np.array([[0] * N for i in range(N)])
for i in range(N):
    if S[i] == 'L':
        M[i - 1][i] = 1
    else:
        M[i + 1][i] = 1
M = sparce.csr_matrix(M)

binary = format(10 ** 100, 'b')
Bin = []
for v in binary:
    a = int(v)
    Bin.append(a)

ans = [1] * N
for i in range(len(Bin)):
    a = Bin.pop()
    if a == 0:
        M = M * M
    else:
        ans = np.dot(M, ans)
        M = M * M

print(' '.join(map(str, ans)))

### FIXED CODE ###

S = [v for v in input()]
N = len(S)
M = [0] * N
for i in range(N):
    if S[i] == 'L':
        M[i] = i - 1
    else:
        M[i] = i + 1

binary = format(10 ** 100, 'b')
Bin = []
for v in binary:
    a = int(v)
    Bin.append(a)

ans = [1] * N
while Bin:
    a = Bin.pop()
    if a == 0:
        L = [0] * N
        for j in range(N):
            L[j] = M[M[j]]
        M = L
    else:
        new_ans = [0] * N
        for j in range(N):
            new_ans[M[j]] += ans[j]
        ans = new_ans

        L = [0] * N
        for j in range(N):
            L[j] = M[M[j]]
        M = L

print(' '.join(map(str, ans)))
import math
A, B, N = map(int, input().split())

arr = []
for num in range(N):

  ans = math.floor((A * N) / B) - A * math.floor(N / B)
  arr.append(ans)

arr.sort()

print(arr[len(arr) - 1])

### FIXED CODE ###

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

all_tenbo = list(range(1, N+1))
not_good = []

for i in range(M):
    A, B = map(int, input().split())
    if H[A-1] <= H[B-1]:
        not_good.append(A)
    if H[B-1] <= H[A-1]:
        not_good.append(B)

print(len(list(set(all_tenbo)-set(not_good))))
try:c,d=map(int,input().split())
except:c,d=5000;input()
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
    p=i;q=0
    for j in range(c):
        if a[j]==b[p]:q+=1;p+=1
    e=max(e,q)
    i+=1
print(e)

### FIXED CODE ###

s=list(map(int,input().split()))
if len(s)>1:c=s[0];d=s[1]
else:c=s[0];d=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
e=0;i=0
while i<d-e:
    p=i;q=0
    for j in range(c):
        if a[j]==b[p]:q+=1;p+=1
    e=max(e,q)
    i+=1
print(e)
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()))
A.sort(reverse= True)
B.sort(reverse= True)
C.sort(reverse= True)
LIS = []
S = 0
T = 0
for s in range(X):
    for t in range(Y):
        for u in range(min((3000//(s+1)*(t+1))+1,Z))
            SU = A[s] + B[t] + C[u]
            LIS.append(SU)
LIS.sort(reverse = True)
for i in range(K):
    print(LIS[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()))
A.sort(reverse= True)
B.sort(reverse= True)
C.sort(reverse= True)
LIS = []
for i in range(X):
    INTB = 3000//(i+1)
    for j in range(min(INTB+1,Y)):
        INT = 3000//((i+1)*(j+1))
        for k in range(min(INT+1,Z)):
            SUM = A[i] + B[j] + C[k]
            LIS.append(SUM)
LIS.sort(reverse = True)
for i in range(K):
    print(LIS[i])
x=int(input())
l=[]

if x==1:
    print(1)

else:

    for i in range(2,x+1):
        for j in range(1,x+1):
            y=j**i
            if y<=x:
                l.append(y)
            elif y>x:
                break
print(max(l))

### FIXED CODE ###

x=int(input())
l=[]

if x==1:
    print(1)

else:

    for i in range(2,x+1):
        for j in range(1,x+1):
            y=j**i
            if y<=x:
                l.append(y)
            elif y>x:
                break
    print(max(l))
n=int(input())
arr=[(int(input())+i//n) for i in range(2*n)]
arr=sorted(arr,key=lambda x:x[0])
mod=10**9+7
ans=1
cnta=0
cntb=0
for pos,flag in arr:
  if flag==0:
    if cntb==0:
      cnta+=1
    else:
      cntb-=1
  else:
    if cnta>=1:
      ans*=cnt
      ans%=mod
      cnt-=1
    else:
      cntb+=1
print(ans)

### FIXED CODE ###

n=int(input())
arr=[(int(input()),i//n) for i in range(2*n)]
arr=sorted(arr,key=lambda x:x[0])
mod=10**9+7
ans=1
cnta=0
cntb=0
for pos,flag in arr:
  if flag==0:
    if cntb==0:
      cnta+=1
    else:
      ans*=cntb
      ans%=mod
      cntb-=1
  else:
    if cnta==0:
      cntb+=1
    else:
      ans*=cnta
      ans%=mod
      cnta-=1
print(ans)
import math

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

e = c * d // math.gcd(c,d)
c_count = b // c - a // c
if a % c == 0:
    c_count += 1
d_count = b // d - a // d
if a % d == 0:
    d_count += 1
e_count = b // e - a // e
if a % e == 0:
    e_count += 1

ans = b - a + 1 - (c_count + d_count - e_count)

print(ans)

### FIXED CODE ###

import fractions

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

e = c * d // fractions.gcd(c,d)
c_count = b // c - a // c
if a % c == 0:
    c_count += 1
d_count = b // d - a // d
if a % d == 0:
    d_count += 1
e_count = b // e - a // e
if a % e == 0:
    e_count += 1

ans = b - a + 1 - (c_count + d_count - e_count)

print(ans)
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)] #1-index

# dp[i+1][w]: i番目までの品物を選びその重さがwを超えないときの最大価値
dp = [[0]*(W+10) for _ in range(N+10)]

for i in range(N):
    for w in range(W+1):
        dp[i+1][w] = dp[i][w]
        
        if w - wv[i][0] >= 0:
            dp[i+1][w] = chmax(dp[i][w - wv[i][0]] + wv[i][1], dp[i][w])

print(dp[N][W])

### FIXED CODE ###

N, W = map(int, input().split())
w = [0] * N
v = [0] * N
for i in range(N):
    w[i], v[i] = map(int, input().split())

def chmax(a, b):
    if a >= b:
        return a
    else:
        return b

dp = [[0]*(10**5 + 10) for _ in range(110)]

#i個の品物を入れて重さがjになっているときの価値の総和の最大値
#dp[i+1][j] = dp[i][j - w[i] + v[i]] 入れるとき
#dp[i+1][j] = dp[i][j] 入れないとき

#dp[0][j] = 0 初期値設定でOK
for i in range(N+1):
    for j in range(W+1):
        dp[i+1][j] = chmax(dp[i+1][j], dp[i][j])
        if (i < N):
            if (j >= w[i]):
                dp[i+1][j] = chmax(dp[i+1][j], dp[i][j - w[i]] + v[i])

print(dp[N][W])
from functools import reduce
mod = 10**9+7
def mul(a,b):
    return a*b % mod
def cmb(n,r,mod):
    if r == 0:
      return 1
    r = min(n-r,r)
    above = reduce(mul,range(n-r+1,n+1)) 
    below = reduce(mul,range(1,r+1)) 
    ans = above*pow(below,mod-2,mod) % mod
    if ans < 0:
        ans += mod
    return ans
n,a,b = map(int,input().split())
ans = pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1) % mod 
if ans < 0:
  ans += mod
  print(ans)


### FIXED CODE ###

def pow(a,b,c):
    ans = 1
    while b > 0:
        if b & 1:
            ans = ans*a % c
        a = a*a % c
        b = b >> 1
    return ans
def cmb(a,b,c):
    b = min(b,a-b)
    num = 1
    for i in range(b):
        num = num*(n-i) % c
    den = 1
    for i in range(b):
        den = den*(i+1) % c
    return num*pow(den,c-2,c) % c
mod = 10**9+7
n,a,b = map(int,input().split())
ans  = (pow(2,n,mod)-cmb(n,a,mod)-cmb(n,b,mod)-1) % mod
if ans < 0:
    ans = ans + mod
print(ans)
N,Y = map(int, input().split())

for i in range(0, N+1):
  for j in range(0, N+1):
    if i == ((Y - 1000*N - 4000*j) / 9000):
      if (N-i-j) >= 0: print(str(i) + " " + str(j) + " " +str(N-i-j))
        return 0
print("-1 -1 -1")


### FIXED CODE ###

def calcPattern(N, Y):
    for i in range(0, N+1):
        for j in range(0, N+1):
            if i == ((Y - 1000*N - 4000*j) / 9000):
                if (N-i-j) >= 0: return (str(i) + " " + str(j) + " " +str(N-i-j))
    return ("-1 -1 -1")

n,y = map(int, input().split())
print(calcPattern(n,y))
a, b, n = map(int, input().split())

if b == 1:
    r = [0]
else:
    i = 0
    while b*i-1 <= n:
        r.append(int((a*(b*i-1))/b)-a*int((b*i-1)/b))
print(max(r))

### FIXED CODE ###

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

if b == 1:
    r = [0]
else:
    i = 0
    r = [int((a*n)/b)-a*int(n/b)]
    while b*i-1 <= n:
        r.append(int((a*(b*i-1))/b)-a*int((b*i-1)/b))
        i += 1
print(max(r))
a,b = map(int, raw_input().split())
print str(a*b), str(2(a+b))

### FIXED CODE ###

a,b = map(int, raw_input().split())
print str(a * b) + " " + str(2 * (a+b))
n,m=map(int,input().split())

#n,m<=10**5

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

uf = UnionFind(m+1) #初期化

lastcheck=set([])
klkl=[]
for _ in range(n):
    kl=list(map(int,input().split()))[1:]
    if len(kl)==1:
        lastcheck.add(kl[0])
    else:
        for item in kl[1:]:
            uf.union(kl[0]-1,item-1)
    klkl.append(kl)
uf_list=uf.members(item-1)    

flag=0
for kl in klkl:
    for item in kl:
        item-=1
        if item not in uf_list:
            flag=1
if flag==1:
    print("NO")
else:
    print("YES")
    














### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)

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

#n,m<=10**5

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

uf = UnionFind(m+1) #初期化

lastcheck=set([])
klkl=[]
for _ in range(n):
    kl=list(map(int,input().split()))[1:]
    if len(kl)>1:
        for item in kl[1:]:
            uf.union(kl[0]-1,item-1)
    klkl.append(kl)
uf_list=uf.members(klkl[0][0]-1)
#print(uf_list)
flag=0
for kl in klkl:
    for item in kl:
        item-=1
        if item not in uf_list:
            flag=1
        else:
            break
if flag==1:
    print("NO")
else:
    print("YES")
n=raw_input()
A=map(raw_input.split())
q=raw_input()
m=map(raw_input.split())

def solve(i, m)
  if m == 0:
    return true
  if i >= n:
    return false
  res = solve(i + 1, m) || solve(i + 1, m - A[i])
  return res

for i range(0,q):
  if solve(0,m[i])==1:
    print yes
  else:
    print no

### FIXED CODE ###

n=int(raw_input())
A=map(int, raw_input().split())
q=int(raw_input())
m=map(int, raw_input().split())

def solve(j, m):
  if m == 0:
    return 1
  if j >= n or m > sum(A):
    return 0
  res = solve(j + 1, m) or solve(j + 1, m - A[j])
  return res

for i in range(0,q):
  if solve(0,m[i]):
    print "yes"
  else:
    print "no"
s=int(input())
ans = 0
if s[0]=="o":
  ans += 1

if s[1]=="o":
  ans += 1

if s[2]=="o":
  ans += 1

print(700+100*ans)

### FIXED CODE ###

s = input()
ans = 0
if s[0]=="o":
  ans += 1

if s[1]=="o":
  ans += 1

if s[2]=="o":
  ans += 1

print(700+100*ans)
import sys

args = sys.argv

n = args[1]
a = args[2]
b = args[3]

train = n * a
bus = b

if(train < bus):
  print(train)
else:
  print(bus)
  

### FIXED CODE ###

import sys

n,a,b = input().split(' ')


n = int(n)
a = int(a)
b = int(b)

train = n * a
bus = b

if(train < bus):
  print(train)
else:
  print(bus)
import math

a, b = map(int, input().split())
print(int(a * b / math.gcd(a, b)))


### FIXED CODE ###

import math

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

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)


a, b = map(int, input().split())
print(lcm(a, b))
n = int(input())
l = list(map(int,input().split()))
c = len([i for i in l if i%4==0])
l1 = [i for i in l if  (i%2==0 and i%4!=0)]
if len(l1)>=1:
  a = n-len(l1)+1
  a = a-c
  if a<=c+1:
    print("Yes")
  else:
    print("No")
else:
  if a<=c+1:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
c = len([i for i in l if i%4==0])
l1 = [i for i in l if  (i%2==0 and i%4!=0)]
if len(l1)>=1:
  a = n-len(l1)+1
  a = a-c
  if a<=c+1:
    print("Yes")
  else:
    print("No")
else:
  a = n-c
  if a<=c+1:
    print("Yes")
  else:
    print("No")
S = input()
for i in range(S//2, 0, -1):
  if S.find(S[:i], i) == i:
    break
print(i)


### FIXED CODE ###

S = input()
for i in range((len(S)-1)//2, 0, -1):
  if S.find(S[:i], i) == i:
    break
print(i*2)
A, B, C, K = map(int, input().split())

abc = [1]*A + [0]*B + [-1]*C
print(sum(abc[:K]))

### FIXED CODE ###

A, B, C, K = map(int, input().split())
out = min(A, K)
if A+B < K:
  out -= (K-A-B)
print(out)
#!/usr/bin/env python3
from collections import deque

import networkx as nx

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

g = nx.Graph()
for i in range(n - 1):
    g.add_edge(*map(int, input().split()))
nx.set_node_attributes(g, name="a", values=0)
nx.set_node_attributes(g, name="b", values=True)

for i in range(q):
    p, x = map(int, input().split())
    g.nodes[p]["a"] += x

d = deque([1])
g.nodes[1]["b"] = False
while len(d):
    p = d.popleft()
    for i in g.neighbors(p):
        if g.nodes[i]["b"]:
            g.nodes[i]["a"] += g.nodes[p]["a"]
            g.nodes[i]["b"] = False
            d.append(i)
for i in range(1, n + 1):
    print(g.nodes[i]["a"], end=" ")
print("")


### FIXED CODE ###

#!/usr/bin/env python3
from collections import deque

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

graph = [deque([]) for _ in range(n + 1)]
for _ in range(n-1):
    a, b = map(int, input().split())
    graph[a].append(b)
    graph[b].append(a)

a = [0] * -~n
b = [True] * -~n
for i in range(q):
    p, x = map(int, input().split())
    a[p] += x

d = deque([1])
b[1] = False

while len(d):
    p = d.popleft()
    for i in graph[p]:
        if b[i]:
            a[i] += a[p]
            b[i] = False
            d.append(i)
print(*a[1:])
import sys
import bisect

n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
c = list(map(int, sys.stdin.readline().split()))

a.sort()
b.sort()
c.sort()

b_ans_list = [0 for _ in range(n)]
for i in reversed(range(n)):
    # b[i]における選択可能なcの個数
    if i == n-1:
        b_ans_list[i] = n - bisect.bisect_right(c, b[i])
    else:
        b_ans_list[i] = n - bisect.bisect_right(c, b[i]) + b_ans_list[i+1]

ans = 0
for i in range(n):
    ans += b_ans_list[bisect.bisect_right(b, a[i])]

print(ans)


### FIXED CODE ###

import sys
import bisect

n = int(sys.stdin.readline())
a = list(map(int, sys.stdin.readline().split()))
b = list(map(int, sys.stdin.readline().split()))
c = list(map(int, sys.stdin.readline().split()))

a.sort()
b.sort()
c.sort()

b_ans_list = [0 for _ in range(n)]
for i in reversed(range(n)):
    # b[i]における選択可能なcの個数
    if i == n-1:
        b_ans_list[i] = n - bisect.bisect_right(c, b[i])
    else:
        b_ans_list[i] = n - bisect.bisect_right(c, b[i]) + b_ans_list[i+1]

ans = 0
for i in range(n):
    b_index = bisect.bisect_right(b, a[i])
    if b_index < n: ans += b_ans_list[b_index]

print(ans)