Harryxun/stf_run huggingface dataset:
"""
Writer: SPD_9X2
https://atcoder.jp/contests/arc077/tasks/arc077_c

お気に入りを決めてる時、その数字を超えるような移動が発生した場合だけ、ボタン2が有効になる。
ALLボタン１に比べて、何回節約できるかをimos法で計算する

"""

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

lis = [0] * m

state = [0] * n

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

start = [ [] for i in range(m) ]
end = [ [] for i in range(m)]

allsum = 0
for i in range(n-1):

    if a[i+1] == (a[i]+1)%m:
        continue

    start[a[i] % m].append(i)
    end[(a[i+1]-1) % m].append(i)

    allsum += (a[i+1]-a[i]) % m


imosnum = 0
plus = 0

#print (start,end)

for i in range(2*m):

    plus += imosnum

    lis[i%m] += plus

    for j in end[i%m]:
        if state[j] == 1:
            plus -= ((a[j+1]-(a[j]+1))%m)
            state[j] = 2
            imosnum -= 1

    for j in start[i%m]:
        if state[j] == 0:
            imosnum += 1
            state[j] = 1

    #print (i+1,imosnum,plus)

if (allsum - max(lis) < 0):
    print (asxacscd)
print (allsum - max(lis))

### FIXED CODE ###


"""
Writer: SPD_9X2
https://atcoder.jp/contests/arc077/tasks/arc077_c

お気に入りを決めてる時、その数字を超えるような移動が発生した場合だけ、ボタン2が有効になる。
ALLボタン１に比べて、何回節約できるかをimos法で計算する

"""

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

lis = [0] * m

state = [0] * n

a = list(map(int,input().split()))
for i in range(n):
    a[i] -= 1

start = [ [] for i in range(m) ]
end = [ [] for i in range(m)]

allsum = 0
for i in range(n-1):

    allsum += (a[i+1]-a[i]) % m
    if a[i+1] == (a[i]+1)%m:
        continue

    start[(a[i]+1) % m].append(i)
    end[a[i+1] % m].append(i)

    


imosnum = 0
plus = 0

#print (start,end)

for i in range(2*m):

    plus += imosnum

    lis[i%m] += plus

    for j in end[i%m]:
        if state[j] == 1:
            plus -= ((a[j+1]-(a[j]+1))%m)
            state[j] = 2
            imosnum -= 1

    for j in start[i%m]:
        if state[j] == 0:
            imosnum += 1
            state[j] = 1

    #print (i+1,imosnum,plus)

if (allsum - max(lis) < 0):
    print (asxacscd)
#print (lis)
print (allsum - max(lis))
import collections
N = int(input())
if N == 1:
  print(1)
else if  N == 2:
  print(1)
else:
  ball = [tuple(map(int, input().split())) for _ in range(N)]
  ball.sort(key=lambda x:(x[0], x[1]))
  diff = [tuple((ball[i][0] - ball[i-1][0], ball[i][1] - ball[i-1][1])) for i in range(1,N)]
  c = collections.Counter(diff)
  ans = c.most_common()[0][1]
  print(N - ans)


### FIXED CODE ###

import collections
N = int(input())
if N == 1:
  print(1)
elif N == 2:
  print(1)
else:
  ball = [tuple(map(int, input().split())) for _ in range(N)]
  ball.sort(key=lambda x:(x[0], x[1]))
  diff = [tuple((ball[i][0] - ball[j][0], ball[i][1] - ball[j][1])) for i in range(N) for j in range(i + 1, N)]
  c = collections.Counter(diff)
  ans = c.most_common()[0][1]
  print(N - ans)
import numpy as np


def main(n, w, items):
    dp = np.zeros((n + 1, w + 1), dtype=int)
    for i in range(1, n + 1):
        weight, value = items[i - 1]
        dp[i][:weight] = dp[i - 1][:weight]
        dp[i][weight:] = np.maximum(dp[i - 1][weight:], dp[i - 1][:w - weight + 1] + value)
    return dp[n][w]


if __name__ == '__main__':
    N, W = map(int, input().split())
    I = []
    for _ in range(N):
        I.append(tuple(map(int, input().split())))
    print(main(N, W, I))


### FIXED CODE ###

import numpy as np


def main(n, w, items):
    MAX_VALUE = 100100
    dp = np.ones((n + 1, MAX_VALUE), dtype=int)
    dp = dp * (1 << 30)
    dp[0][0] = 0
    for i in range(0, n):
        weight, value = items[i]
        dp[i + 1][:value] = np.minimum(dp[i][:value], dp[i + 1][:value])
        dp[i + 1][value:] = np.minimum(dp[i][value:], dp[i][:MAX_VALUE - value] + weight)

    result = 0
    for v in range(MAX_VALUE):
        if dp[-1][v] <= w:
            result = v
    return result


if __name__ == '__main__':
    N, W = map(int, input().split())
    I = []
    for _ in range(N):
        I.append(tuple(map(int, input().split())))
    print(main(N, W, I))
n,m = map(int,input().split())
elif(n==1)or(m==1):
  if(n==1)and(m==1):
    print(1)
  else:
    print(max(0,max(n,m)-2))
else:
  print((n-2)*(m-2))


### FIXED CODE ###

n,m = map(int,input().split())
if(n==2)or(m==2):
  print(0)
elif(n==1)or(m==1):
  if(n==1)and(m==1):
    print(1)
  else:
    print(max(0,max(n,m)-2))
else:
  print((n-2)*(m-2))
#![allow(non_snake_case)]

fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read_line()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        a
    } else {
        gcd(b, a%b)
    }
}

fn main() {
    let N: usize = read_line().parse().unwrap();
    let A = read_vec();

    let mut left = vec![0; N];
    let mut right = vec![0; N];

    left[0] = A[0];
    for i in 1..N {
        left[i] = gcd(left[i-1], A[i]);
    }
    right[N-1] = A[N-1];
    for i in (0..N-1).rev() {
        right[i] = gcd(right[i+1], A[i]);
    }

    let mut max = right[1];
    for i in 1..N-1 {
        max = std::cmp::max(max, gcd(left[i-1], right[i+1]));
    }
    max = std::cmp::max(max, left[N-2]);
    println!("{}", max);
}


### FIXED CODE ###

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


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

gcd_from_right = [0] * N
gcd_from_right[-1] = A[-1]
for i in reversed(range(N-1)):
    gcd_from_right[i] = gcd(A[i], gcd_from_right[i+1])

ans = gcd_from_right[1]
gcd_from_left = A[0]
for i in range(1, N-1):
    ans = max(ans, gcd(gcd_from_left, gcd_from_right[i+1]))
    gcd_from_left = gcd(gcd_from_left, A[i])
ans = max(ans, gcd_from_left)
print(ans)
import functools
import math
H, N = list(map(int, input().split()))

AB = [list(map(int, input().split())) for _ in range(N)]

dp = [math.inf] *(H+1)
dp[H] = 0
for a,b in AB:
    for i in range(H,-1,-1):
        if i <= H - a:
            dp[i] = min(dp[i], dp[i+a] + b)
        dp[0] = min(dp[0], min(dp[:a+1]) + b) # if hp is not just 0

print(dp[0])


### FIXED CODE ###

import math
H, N = list(map(int, input().split()))
 
AB = [list(map(int, input().split())) for _ in range(N)]
 
dp = [float('inf')] *(H+1)
dp[H] = 0
for a,b in AB:
    for i in range(H,-1,-1):
        if i <= H - a:
            dp[i] = min(dp[i], dp[i+a] + b)
    dp[0] = min(dp[0], min(dp[:a+1]) + b) # if hp is not just 0
print(dp[0])
b = []
for i in range(N) :
    b.append(int(input()))

m = [[0,0,0],[0,0,0],[0,0,0]]

for i in range(N) :
    for j in range(3) :
        for k in range(3) :
            if b[i] == a[j][k] :
                m[j][k] = 1
if  m[0].count(1) == 3 or \
    m[1].count(1) == 3 or \
    m[2].count(1) == 3 or \
    [x[0] for x in m].count(1) == 3 or \
    [x[1] for x in m].count(1) == 3 or \
    [x[2] for x in m].count(1) == 3 or \
    (m[0][0] == 1 and m [1][1] == 1 and m [2][2] == 2) or \
    (m[2][0] == 1 and m [1][1] == 1 and m [2][0] == 2) :
    print('Yes')
else :
    print('No')

### FIXED CODE ###

import math

a1 = list(map(int, input().rstrip().split()))
a2 = list(map(int, input().rstrip().split()))
a3 = list(map(int, input().rstrip().split()))
a = [a1,a2,a3]

m = [[0,0,0],[0,0,0],[0,0,0]]

n = int(input())
b = []
for i in range(n) :
    b = int(input())
    for j in range(3) :
        for k in range(3) :
            if a[j][k] == b :
                m[j][k] = 1

if m[0].count(1) == 3 :
    print('Yes')
elif m[1].count(1) == 3 :
    print('Yes')
elif m[2].count(1) == 3 :
    print('Yes')
elif m[0][0] == 1 and m[1][0] == 1 and m[2][0] ==1 :
    print('Yes')
elif m[0][1] == 1 and m[1][1] == 1 and m[2][1] ==1 :
    print('Yes')
elif m[0][2] == 1 and m[1][2] == 1 and m[2][2] ==1 :
    print('Yes')
elif m[0][0] == 1 and m[1][1] == 1 and m[2][2] ==1 :
    print('Yes')
elif m[0][2] == 1 and m[1][1] == 1 and m[2][0] ==1 :
    print('Yes')
else :
    print('No')
import math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A, B, C, D = (int(x) for x in input().split())

Cu = B//C       #Cの上限
Cd = -(-A//C)   #Cの下限
Du = B//D       #Dの上限
Dd = -(-A//D)   #Dの下限

#Least common multiple
LCMu = B//(lcm(C,D))
LCMd = -(-A//lcm(C,D))

C_num = Cu - Cd + 1
D_num = Du - Dd + 1
LCM_num = LCMu - LCMd + 1

C_D_num = C_num + D_num - LCM_num
A_B_num = B - A  + 1

ans = A_B_num - C_D_num
print(ans)

### FIXED CODE ###

import fractions as math

def lcm(x, y):
    return (x * y) // math.gcd(x, y)

A, B, C, D = (int(x) for x in input().split())

Cu = B//C       #Cの上限
Cd = -(-A//C)   #Cの下限
Du = B//D       #Dの上限
Dd = -(-A//D)   #Dの下限

#Least common multiple
LCMu = B//(lcm(C,D))
LCMd = -(-A//lcm(C,D))


C_num = Cu - Cd + 1
D_num = Du - Dd + 1
LCM_num = LCMu - LCMd + 1

C_D_num = C_num + D_num - LCM_num
A_B_num = B - A  + 1

ans = A_B_num - C_D_num
print(ans)
def solve(A):
    cumsum = [0]
    for elem in A:
        cumsum.append(cumsum[-1]+elem)
    d = dict()
    for i in cumsum:
        try:
            d[i] += 1
        except:
            d[i] = 1
    res = 0
    for value in d.values():
        res += (value * (value - 1)) // 2
    return res

def main():
    N = int(input())
    A = list(map(int, input().split()))
    res = solve(A)
    print(res)

main()

### FIXED CODE ###

def solve(A):
    cumsum = [0]
    for elem in A:
        cumsum.append(cumsum[-1]+elem)
    d = dict()
    for i in cumsum:
        try:
            d[i] += 1
        except:
            d[i] = 1
    res = 0
    for value in d.values():
        res += (value * (value - 1)) // 2
    return res

def main():
    N = int(input())
    A = list(map(int, input().split()))
    res = solve(A)
    print(res)

main()
while True:
	H,W = list(map(int, input().split()))
	if (H == 0 and W == 0):
		break
	else:
		for n in range(H):
			s = ""
			for m in range(W):
				if ((n % 2 == 1) and (m % 2 == 0)) or5 6 ((n % 2 == 0) and (m % 2 == 1)):
					s += "."
				else:
					s += "#"
			print(s)
		print("")

### FIXED CODE ###

while True:
    h,w = map(int, input().split())
    if (h == 0) and (w == 0):
        break
    for i in range(h):
        for j in range(w):
            if ((i % 2 == 0) and (j % 2 == 1)) or ((i % 2 == 1) and (j % 2 == 0)) :
                print('.',end='')
            else:
                print('#',end='')
        print()
    print()
def main():
    N = input()

    for h in range(1, 3501):
        for n in range(1, 3501):
            r1 = h * n * N
            r2 = 4 * h * n - h * N - n * N
            if r2 > 0 and r1 % r2 == 0:
                print("{} {} {}".format(h, n, r1 // r2))
                return

main()


### FIXED CODE ###

def main():
    N = input()

    for h in range(1, 3501):
        for n in range(1, 3501):
            r1 = h * n * N
            r2 = 4 * h * n - h * N - n * N
            if r2 > 0 and r1 % r2 == 0:
                print "%d %d %d" % (h, n, r1 / r2)
                return

main()
n, l = map(int, input().split())
s = list([input() for i in ramge(n)])
s1 = s.sort()
print("".join(s1))

### FIXED CODE ###

n, l = map(int, input().split())
s = [input() for i in range(n)]
s.sort()
print("".join(s))
N = int(input())

L_lst = map(int, input().split())

L_lst.sort()
L_sum = sum(L_lst)
L_max = L_lst[-1]

if L_max * 2 >= L_sum:
  print("No")
else:
  print("Yes")

### FIXED CODE ###

N = int(input())
 
L_lst = list(map(int, input().split()))
 
L_lst.sort()
L_sum = sum(L_lst)
L_max = L_lst[-1]
 
if L_max * 2 >= L_sum:
  print("No")
else:
  print("Yes")
for e in iter(input,'0'):
 a={tuple(map(int,input().split())) for _ in range(int(e))}
 s,t=a[0]
 b={tuple(map(int,input().split())) for _ in range(int(input()))}
 for x,y in b:
  flag = True
  for u,v in a[1:]:
   if(x+u-s,y+v-t}not in b:
    flag = False
    break
  if flag == True:
   print(x - s, y - t)
   break


### FIXED CODE ###

for e in iter(input,'0'):
 a=[[*map(int,input().split())]for _ in[0]*int(e)]
 s,t=min(a)
 b={tuple(map(int,input().split()))for _ in[0]*int(input())}
 m=max(b)[0]-max(a)[0]+s
 for x,y in b:
  if x<=m:
   for u,v in a:
    if(x+u-s,y+v-t)not in b:break
   else:print(x-s,y-t);break
M = input()
print(24 - M + 24)

### FIXED CODE ###

M = input()
print(24 - int(M) + 24)
N, M = map(int, input().split())
n = []
m = []
for i in range(N):
  s = str(input())
  row = []
  for j in range(N):
    if s[i] == "#":
      row.append(1)
    else:
      row.append(0)
  n.append(row)
for i in range(M):
  s = str(input())
  row = []
  for j in range(M):
    if s[i] == "#":
      row.append(1)
    else:
      row.append(0)
  m.append(row)
 
def search(a,b):
  mr = mc = 0
  for r in range(a, a+M):
    for c in range(b, b+M):
      if n[r][c] != m[mr][mc]:
        return False
      mc += 1
    mr += 1 
  return True

ans = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    if search(i,j):
      ans = 1
      break
  if ans:
    break
if ans:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

N, M = map(int, input().split())
n = []
m = []
for i in range(N):
  s = str(input())
  row = []
  for j in range(N):
    if s[j] == "#":
      row.append(1)
    else:
      row.append(0)
  n.append(row)
for i in range(M):
  s = str(input())
  row = []
  for j in range(M):
    if s[j] == "#":
      row.append(1)
    else:
      row.append(0)
  m.append(row)
 
def search(a,b):
  mr = mc = 0
  for r in range(a, a+M):
    for c in range(b, b+M):
      if n[r][c] != m[mr][mc]:
        return False
      mc += 1
    mr += 1
    mc = 0
  return True

ans = 0
for i in range(N-M+1):
  for j in range(N-M+1):
    if search(i,j):
      ans = 1
      break
  if ans:
    break
if ans:
  print("Yes")
else:
  print("No")
import numpy as np

h , w = map(int, input().split())
visited = np.full((h,w), 10**9)

for y in range(h):
    _in = input()
    for x, value in enumerate(_in):
        if value == '#':
            visited[y][x] = 0
for i in range(1,h):
    visited[i,:] = np.minimum(visited[i,:],visited[i-1,:]+1)
for i in reversed(range(h-1)):
    visited[i,:] = np.minimum(visited[i,:],visited[i+1,:]+1)
for j in range(1,h):
    visited[:,j] = np.minimum(visited[:,j],visited[:,j-1]+1)
for j in reversed(range(h-1)):
    visited[:,j] = np.minimum(visited[:,j],visited[:,j+1]+1)
print(int(visited.max()))

### FIXED CODE ###

import numpy as np

H,W = map(int,input().split())
use = np.zeros((H,W),dtype=int)
for i in range(H):
    s = input()
    for j,st in enumerate(s):
        if st == ".":
            use[i][j] = 10**10
        else:
            use[i][j] = 0

for i in range(1,H):
    use[i,:] = np.minimum(use[i,:],use[i-1,:]+1)
for i in reversed(range(H-1)):
    use[i,:] = np.minimum(use[i,:],use[i+1,:]+1)
for j in range(1,W):
    use[:,j] = np.minimum(use[:,j],use[:,j-1]+1)
for j in reversed(range(W-1)):
    use[:,j] = np.minimum(use[:,j],use[:,j+1]+1)

print(np.max(use))
N = input()

n = int(N)
sn = sum(list(N))

if n % sn == 0:
    print('Yes') 
else:
    print('No')

### FIXED CODE ###

N = input()

n = int(N)
sn = sum(list(map(int, list(N))))

print('Yes' if n % sn == 0 else 'No')
A, B = input().split()

Cor = 6-int(A)-int(B)
print(Cor)

### FIXED CODE ###

A = input()
B = input()

Cor = 6-(int(A)+int(B))
print(Cor)
n,*p = map(int,open('abc135.txt').read().split())
ans = 0
for i in range(n):
    if i+1 != p[i]:
        if i+1 == p[p[i]-1]:
            ans += 1

print('Yes' if ans == 0 or 2 else 'No')

### FIXED CODE ###

n,*p = map(int,open(0).read().split())
ans = 0
for i in range(n):
    if i+1 != p[i]:
        ans += 1
print('YES' if ans == 2 or ans == 0 else 'NO')
print("{0}".fomat(x*x*x))


### FIXED CODE ###

x = int(input())
cube = x **3

print(cube)
N = int(input())
A = list(map(int,input().split()))
A.sort()
d = []
ans = 0
while A:
    a = A.pop(0)
    f = 0
    for p in d:
        if a % p == 0:
            f = 1
            break
    if f == 0:
        d.append(a)
        if len(A) == 0:
            break
        if a == A[0]:
            while (A) & (a == A[0]):
                A.pop(0)
        else:
            ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
A.sort()
d = {}
n = A[-1]
def makePrimeChecker(n):
    isPrime = [True] * (n + 1)
    i = 0
    for j in A:
        if i == j:
            isPrime[i] = False
            continue
        i = j
        if isPrime[i]:
            for j in range(i * 2, n + 1, i):
                isPrime[j] = False
    return isPrime
P = makePrimeChecker(n)
i = 0
ans = 0
for j in A:
    if i == j:
        continue
    else:
        i = j
        if P[i]:
            ans += 1
print(ans)
X = int(input())
if X = "A":
  	print("T")
elif X = "T":
  	print("A")
elif X = "C":
  	print("G")
else:
	print("C")
    

### FIXED CODE ###

X = input()
if X == "A":
  	print("T")
elif X == "T":
  	print("A")
elif X == "C":
  	print("G")
elif X == "G":
	print("C")
S=int(input())
if S[0]==S[1]:
    print('Yes')
elif S[1]==S[2]:
    print('Yes')
elif S[0]==S[2]:
    print('Yes')
else:
    print('No')
    


### FIXED CODE ###

S=input()
if S[0]!=S[1]:
    print('Yes')
elif S[1]!=S[2]:
    print('Yes')
elif S[0]!=S[2]:
    print('Yes')
else:
    print('No')
n=int(input())
s=list(input())
Len=len(s)/2
if len(s)%2==1:
  print('No')
else:
  for i in range(Len):
    if s[i]!=s[i+Len]:
      print('No')
      break
  print('Yes')

### FIXED CODE ###

n=int(input())
s=list(input())
Len=int(len(s)/2)
if len(s)%2==1:
  print('No')
else:
  for i in range(Len):
    if s[i]!=s[i+Len]:
      print('No')
      exit()
  print('Yes')
n,c = map(int,input().split())
table = [0]*(10**5)
chan = [[] for _ in range(c+1)]

for _ in range(n):
    s,t,c = map(int,input().split())
    chan[c].append([s,t])

# 同チャンネルの連続番組を統合する
times = []
for i in range(c+2):
    arr = chan[i]
    if chan[i]==[] : continue
    for i in range(len(arr)):
        if i == len(arr)-1 : break
        if arr[i][1] == arr[i+1][0]:
            arr[i+1] = [arr[i][0], arr[i+1][1]]
            arr[i] = [1,0]
    times += arr

# いもす法
for ele in times:
    table[ele[0]] += 1
    table[ele[1]+1] -= 1

# 累積和の計算
for i in range(len(table)):
    if i==1 : continue
    table[i] += table[i-1]

print(max(table))



### FIXED CODE ###

import numpy as np

n,c = map(int,input().split())
table = np.zeros(10**5+2, dtype=np.int32)
chs = [[] for _ in range(c+1)]

for _ in range(n):
    s,t,c = map(int,input().split())
    chs[c].append([s,t])

# 同チャンネル内の連続番組を合体
times = []
for ch in chs:
    if not ch: continue
    ch.sort()
    for i in range(len(ch)):
        if i == 0: continue
        if ch[i-1][1] == ch[i][0]:
            ch[i] = [ch[i-1][0], ch[i][1]]
            ch[i-1] = []
    for arr in ch:
        if not arr: continue
        times.append(arr)

# いもす法
for arr in times:
    table[arr[0]] += 1
    table[arr[1]+1] -= 1

# 累積和の最大値
ans = table.cumsum().max()

print(ans)
o,e = map(str, raw_input().split())
s = ""
for i,j in o,e:
	s += i
	s += j
print s

### FIXED CODE ###

o = raw_input()
e = raw_input()
s = ""
l = len(o)
if len(e)>l:
	l = len(e)
for i in range(l):
	if i<len(o):
		s = s+o[i]
	if i<len(e):
		s = s+e[i]
print s
from functools import lru_cache
from collections import deque
N = int(input())


# 最大公約数
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a


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


array = deque()
for _ in range(N):
    array.append(int(input()))

#@lru_cache(maxsize = None)
#def multi_lcm():

while len(array) > 1:
    a = array.pop()
    b = array.pop()
    array.append(lcm(a, b))

print(int(array[0]))

### FIXED CODE ###

from collections import deque
N = int(input())


# 最大公約数
def gcd(a, b):
    while b > 0:
        a, b = b, a%b
    return a


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


array = []
for _ in range(N):
    array.append(int(input()))

ans = array[0]
for x in array[1:]:
    ans = lcm(ans, x)


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

if:
  print('Draw')
elif a == 1:
  print('Alice')
elif b == 1:
  print('Bob')
elif a < b:
  print('Bob')
elif a > b:
  print('Alice')


### FIXED CODE ###

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

if a == b:
  print('Draw')
elif a == 1:
  print('Alice')
elif b == 1:
  print('Bob')
elif a < b:
  print('Bob')
elif a > b:
  print('Alice')
n = int(input())
p = list(map(int, input().split()))
cnt = 0
pp = [1 if p[i-1] == i else 0 for i in range(1, n+1)]
for i in range(n):
    if pp[i]==1:
        p[i], p[i+1] = p[i+1], p[i]
        cnt+=1
print(cnt)


### FIXED CODE ###

n = int(input())
p = list(map(int, input().split()))
flag = 0
cnt = 0
for i in range(n):
    if flag: flag=0
    elif p[i]==i+1:
        flag=1
        cnt+=1
print(cnt)
import math
from functools import reduce

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

input()

print(gcd_list(list(map(int, input().split()))))


### FIXED CODE ###

import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

input()

print(gcd_list(list(map(int, input().split()))))
# utf-8:

def main():
    X, Y = map(str, raw_input().split())
    d = {"A": 10, "B": 11, "C": 12, "D": 12, "E": 12, "E": 12}
    if d[X] < d[Y]:
        print("<")
    elif d[X] > d[Y]:
        print(">")
    elif d[X] == d[Y]:
        print("=")


if __name__ == '__main__':
    main()


### FIXED CODE ###

# utf-8:

def main():
    X, Y = map(str, raw_input().split())
    d = {"A": 10, "B": 11, "C": 12, "D": 13, "E": 14, "F": 15}
    if d[X] < d[Y]:
        print("<")
    elif d[X] > d[Y]:
        print(">")
    elif d[X] == d[Y]:
        print("=")


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

lst = ['A'] * (N + 1)
def burger(s): #レベルsバーガーを返す
    if lst[s] != 'A':
        return lst[s]
    if s == 0:
        lst[s] = 'P'
        return lst[s]
    else:
        lst[s] = str('B' + burger(s-1) + 'P' + burger(s-1) + 'B')
        return lst[s]

s = burger(N)

count = 0
for i in range(X):
    if lst[N][i] == 'P':
        count += 1

print (count)


### FIXED CODE ###

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

a = [1]
p = [1]
for i in range(1, N+2):
    a.append(2 * a[i-1] + 3)
    p.append(2 * p[i-1] + 1)

def calc(N, X): #レベルNバーガーの下からX層に含まれるパティの枚数
    if N == 0: #全てパティ
        if X == 0:
            return 0
        else:
            return 1
    if X == 1:
        return 0
    # print (N - 1)
    if 1 < X <= 1 + a[N - 1]:
        # print ('A')
        return calc(N - 1, X - 1)
    if X == 2 + a[N - 1]:
        # print ('B')
        return p[N - 1] + 1
    if 2 + a[N - 1] < X <= 2 + 2 * a[N - 1]:
        # print ('C')
        return p[N - 1] + 1 + calc(N - 1, max(X - 2 - a[N - 1], 0))
    if X == 3 + 2 * a[N - 1]:
        # print ('D')
        return p[N]

print (calc(N, X))
import fractions as gcd

def lcm(x, y):
    return (x*y) // gcd(x, y)

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

c = B // C - A // C + (not A % C)
d = B // D - A // D + (not A % D)

x = lcm(C, D)
x = B // x - A // x + (not A % x)

print(B-A+1-c-d+x)

### FIXED CODE ###

#import math
import fractions as math

A, B, C, D = list(map(int, input().split()))
ans = []
x = int((C*D)/math.gcd(C,D))

for n in [A-1, B]:
    c = n // C
    d = n // D
    cd = n // x
    ans.append(n-c-d+cd)
print(ans[1]-ans[0])
n = int(input())
s =[input() for i in range(n)]
m,a,r,c,h=0,0,0,0,0
for A in s:
    if A[0]=='M':
        m+=1
    elif A[0]=='A':
        a+=1
    elif A[0]=='R':
        r+=1
    elif A[0]=='C':
        c+=1
    elif A[0]=='H':
        h+=1
x = []
for i in [m,a,r,c,h]:
    if i != 0:
        x.append(i)
if len(x)<3:
    print(0)
elif len(x)==3:
    print(x[0]*x[1]*x[2])
elif len(x)==4:
    print(x[0]*x[1]*x[2]+x[0]*x[1]*x[3]+x[0]*x[2]*x[3]+x[1]*x[2]*x[3])
else:
    print(x[0]*x[1]*x[2]+x[0]*x[1]*x[3]+x[0]*x[2]*x[3]+x[1]*x[2]*x[3]
         +x[0]*x[1]*x[4]+x[0]*x[2]*x[4]+x[1]*x[2]*x[4]
         +x[3]*x[4]*x[5]+x[2]*x[4]*x[5]+x[1]*x[4]*x[5])

### FIXED CODE ###

n = int(input())
s =[input() for i in range(n)]
m,a,r,c,h=0,0,0,0,0
for A in s:
    if A[0]=='M':
        m+=1
    elif A[0]=='A':
        a+=1
    elif A[0]=='R':
        r+=1
    elif A[0]=='C':
        c+=1
    elif A[0]=='H':
        h+=1
x = []
for i in [m,a,r,c,h]:
    if i != 0:
        x.append(i)
if len(x)<3:
    print(0)
elif len(x)==3:
    print(x[0]*x[1]*x[2])
elif len(x)==4:
    print(x[0]*x[1]*x[2]+x[0]*x[1]*x[3]+x[0]*x[2]*x[3]+x[1]*x[2]*x[3])
else:
    print(x[0]*x[1]*x[2]+x[0]*x[1]*x[3]+x[0]*x[2]*x[3]+x[1]*x[2]*x[3]
         +x[0]*x[1]*x[4]+x[0]*x[2]*x[4]+x[1]*x[2]*x[4]
         +x[2]*x[3]*x[4]+x[1]*x[3]*x[4]+x[0]*x[3]*x[4])