Harryxun/stf_run huggingface dataset:
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n,a = imap()
x = np.array(iarr()) - a

# dp[i][和 + NA]
# 本来のSの範囲は、1N-NAから50N-NA
# 負の数はdp範囲外なのでNAたすと、1Nから50N
# 和０のときは dp[n][0+NA]
dp = np.zeros((n+1, 50*n+1)).astype(int)
dp[0][n*a] = 1

for i in range(n):
    for s in range(50*n+1):
        dp[i+1][s] = dp[i][s] + dp[i][s-x[i]] if 50*N>= s-x[i] >=0 else dp[i][s]

ans = dp[n][n*a] - 1 #実際は初期条件の０個選ぶパターンを除外
print(ans)




### FIXED CODE ###

import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n,a = imap()
x = np.array(iarr()) - a

# dp[i][和 + NA]
# 本来のSの範囲は、1N-NAから50N-NA
# 負の数はdp範囲外なのでNAたすと、1Nから50N
# 和０のときは dp[n][0+NA]
dp = np.zeros((n+1, 50*n+100)).astype(int)
dp[0][n*a] = 1

for i in range(n):
    for s in range(50*n+1):
        dp[i+1][s] = dp[i][s] + dp[i][s-x[i]] if s-x[i]>=0 else dp[i][s]

ans = dp[n][n*a] - 1 #実際は初期条件の０個選ぶパターンを除外
print(ans)
N = int(input())
ori = [int(i) for i in input().split()]
count = ori.count(1)
if count == 0:
    print(-1)

else:
    Break = 0
    for j in range(1,N+1):
        for i in range(Break+1,N):
            if ori[i] == j:
                Break = i
                #print(Break)
                #print(savepoint)
                #print(j,i)
                sub = j
                break
        if i == N-1:
            break
    print(Break+1-sub)

### FIXED CODE ###

N = int(input())
ori = [int(i) for i in input().split()]
count = ori.count(1)
if count == 0:
    print(-1)

else:
    savepoint = 0
    for j in range(1,N+1):
        for i in range(savepoint,N):
            if ori[i] == j:
                savepoint = i
                #print(savepoint)
                #print(j,i)
                sub = j
                break
        if i == N-1:
            break
    print(N-sub)
S, W = map(int, input().split())

if(S > W):
    print(safe)
else:
    print(unsafe)

### FIXED CODE ###

S, W = map(int, input().split())

if(S > W):
    print("safe")
else:
    print("unsafe")
x = int(input())
if x % (sum(map(str(x)))) == 0:
  print("Yes")
else:
  print("No")
        

### FIXED CODE ###

s = input()
print("Yes" if int(s)%sum(map(int,s))==0 else "No")
def dfs(g, start):
    visited[start] = True
    cc.append(0)
    for nbr in g[start]:
        if not visited[nbr]:
            dfs(g, nbr)



import sys
from collections import defaultdict
input = sys.stdin.readline
n, m = map(int, input().split())
g = defaultdict(set)

for _ in range(m):
    a, b = map(int, input().split())
    g[a - 1].add(b - 1)
    g[b - 1].add(a - 1)


visited = [False]*n
ans = 0
for i in range(n):
    if not visited[i]:
        cc = []
        dfs(g, i)
        ans = max(ans, len(cc))

print(ans)

### FIXED CODE ###

from collections import defaultdict, deque
n, m = map(int, input().split())
g = defaultdict(set)

if m == 0:
    print(1)

else:
    for _ in range(m):
        a, b = map(int, input().split())
        g[a - 1].add(b - 1)
        g[b - 1].add(a - 1)


    visited = [False]*n
    ans = 0
    for i in range(n):
        if not visited[i]:
            # cc = []
            count = 1
            q = deque([i])
            visited[i] = 1
            while q:
                node = q.pop()
                for nbr in g[node]:
                    if not visited[nbr]:
                        q.append(nbr)
                        visited[nbr] = True
                        count += 1
                
            # ans = max(ans, len(cc))
            ans = max(ans, count)

    print(ans)
# -*- coding:utf-8 -*-
import copy

def solve():
    N, K = list(map(int, input().split()))
    V = list(map(int, input().split()))
    
    ans = 0
    M = min(N,K)
    for l in range(M+1):
        having = []
        for r in range(M+1):
            if l+r > K: break
            if l+r == 0: continue
            # 左からl, 右からr個の宝石を取り出す
            having = V[:l] + V[::-1][:r]
            having.sort(reverse=True)

            restK = K - (l+r)

            for i in range(restK):
                if having[-1] < 0:
                    having.pop()
                    continue
                break

            ans = max(ans, sum(having))
    
    print(ans)

if __name__ == "__main__":
    solve()


### FIXED CODE ###

# -*- coding:utf-8 -*-
from collections import deque
"""解説
全探索

左からL個、右からR個宝石を取り、K-(L+R)個の宝石を筒に詰めるとき方針として、

・筒に詰める宝石は絶対値の大きい負の値のもの

あとは全探索
"""

def solve():
    N, K = list(map(int, input().split()))
    V = list(map(int, input().split()))

    ans = 0
    r = min(N, K)
    for a in range(r+1):  # 左から取る個数
        for b in range(r+1):  # 右から取る個数
            if r < a+b: continue

            t = V[:a] + V[::-1][:b]  # 左からa個、右からb個とった宝石を「持っているリストt」にぶちこむ
            t.sort(reverse=True)

            for _ in range(K-a-b):
                if len(t) > 0 and t[-1] < 0:
                    t.pop()
                    continue
                break
            ans = max(ans, sum(t))

    print(ans)



if __name__ == "__main__":
    solve()
# coding: utf-8
import math

if __name__=='__main__':
    N = int(input())
    Xi = list(map(int, input().split()))
    Xi.sort()
    min = Xi[0]
    max = Xi[N-1]
    tmp = 0
    result = math.inf
    for i in range(min,max+1):
        for j in range(0,N):
            tmp += (Xi[j] - i)**2
        if tmp <= result:
            result = tmp
        tmp = 0

    print(result)

### FIXED CODE ###

# coding: utf-8
import sys

N = int(input())
Xi = list(map(int, input().split()))
Xi.sort()
min = Xi[0]
max = Xi[N-1]
tmp = 0
result = sys.maxsize
for i in range(min,max+1):
    for j in range(0,N):
        tmp += (Xi[j] - i)**2
    if tmp <= result:
        result = tmp
    tmp = 0

print(result)
h, w = map(int, input().split())
list=["."+input()+"." for i in range(h)]
list=["."*(w+2)]+list+["."*(w+2)]
a=0
for h in range(H):
    for w in range(w):
        if list[h][w] == "#":
            if list[h+1][w] == "#" or list[h-1][w] == "#" or list[h][w-1] == "#" or list[h][w+1] == "#":
                a=0
            else:
                a=1
                break
print("Yes" if a==0 else "No")

### FIXED CODE ###

H,W=map(int,input().split())
S=["."+input()+"." for i in range(H)]
S=["."*(W+2)]+S+["."*(W+2)]
flag=0
for i in range(H):
    for j in range(W):
        if S[i][j]=="#":
            if S[i-1][j]=="." and S[i+1][j]=="." and S[i][j-1]=="." and S[i][j+1]==".":
                flag=1
print("Yes" if flag==0 else "No")
table = [0] + [chr(i) for i in range(97, 97+26)]

def Base_10_to_n(X, n):
    X_dumy = X
    out = ''
    while X_dumy>0:
        out = table[X_dumy%n]+out
        X_dumy = int(X_dumy/n)
    return out

print(Base_10_to_n(int(input()),26))


### FIXED CODE ###

table = list("abcdefghijklmnopqrstuvwxyz")
N = int(input())

ans = []
while True:
    ans.append(N%26)
    if N%26 == 0:
        N -= 1
    if  N//26 == 0:
        break
    N//=26
for x in reversed(ans):
    print(table[x-1],end='')

print()
S =input()
s =S%60
m =((S-s)/60)%60
h = ((S-s)/60-m)/60
print "%s:%s:%s"(h,m,s)

### FIXED CODE ###

S =input()
s =S%60
m =((S-s)/60)%60
h = ((S-s)/60-m)/60
print "%s:%s:%s"%(h,m,s)
def main:
    import sys
    input = sys.stdin.readline
    import heapq

    N = int(input())
    edges = [[] for _ in range(N+1)]
    for _ in range(N-1):
        u,v,w = map(int,input().split())
        edges[u].append((v,w))
        edges[v].append((u,w))
    
    colors = [-1]*(N+1)
    que = [(0,1)]
    heapq.heapify(que)
    while que:
        c,n = heapq.heappop(que)
        if colors[n] == -1:
            colors[n] = c
            for nx,w in edges[n]:
                if w%2==0:
                    nxC = c
                else:
                    nxC = (c+1)%2
                heapq.heappush((nxC,nx))

    for i in range(1,N+1):
        print(colors[i])

main()

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    import heapq

    N = int(input())
    edges = [[] for _ in range(N+1)]
    for _ in range(N-1):
        u,v,w = map(int,input().split())
        edges[u].append((v,w))
        edges[v].append((u,w))
    
    colors = [-1]*(N+1)
    que = [(0,1)]
    heapq.heapify(que)
    while que:
        c,n = heapq.heappop(que)
        if colors[n] == -1:
            colors[n] = c
            for nx,w in edges[n]:
                if w%2==0:
                    nxC = c
                else:
                    nxC = (c+1)%2
                heapq.heappush(que,(nxC,nx))

    for i in range(1,N+1):
        print(colors[i])

main()
import copy
h,w=map(int,input().split())
a=[list(map(lambda x:0 if x=="#" else 1,input())) for i in range(h)]
b=[[0 for i in range(w)] for j in range(h)]
count=0
while a!=b:
  z=copy.deepcopy(a)
  for i in range(h):
    for j in range(w):
      if sum(a[i])!=0 or a[i][j]==1:
        a[i][j]=z[i][j]*(z[i-1][j] if i!=0 else 1)*(z[i+1][j] if i!=h-1 else 1)*(z[i][j-1] if j!=0 else 1)*(z[i][j+1] if j!=h-1 else 1)
  count+=1
print(count)


### FIXED CODE ###

from collections import deque
h,w=map(int,input().split())
a=[input() for _ in range(h)]
visited=[[-1]*w for _ in range(h)]
queue=deque()
for i in range(h):
  for j in range(w):
    if a[i][j]=='#':
      visited[i][j]=0
      queue.append([i,j])
while queue:
  y,x=queue.popleft()
  for j,k in ([1,0],[-1,0],[0,1],[0,-1]):
    n_y,n_x=y+j,x+k
    if 0<=n_y<h and 0<=n_x<w and a[n_y][n_x]=='.' and visited[n_y][n_x]<0:
      visited[n_y][n_x]=visited[y][x]+1
      queue.append([n_y,n_x])
ans=0
for l in visited:
  ans=max([ans]+l)
print(ans)
X, K, D = map(int, input.split())
if (abs(X) - K * D) > = 0:
  print(abs(X) - K * D)
else:
  print(min(X%D, D-X%D))

### FIXED CODE ###

X, K, D = map(int, input().split())
if (abs(X) - K * D) >= 0:
  print(abs(X) - K * D)
else:
  if (X // D - K) %2 == 0:
  	print(X%D)
  else:
    print(abs(X%D - D))
n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))

def f(i, m):
    if m == 0:
        return True
    elif m < 0:
        return False
    elif i >= n:
        return False
    elif f(i+1, m):
        return True
    elif f(i+1, m-a[i]):
        return True

for k in m:
    print('yes' if f(0, k) else 'no')


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
q = int(input())
m = list(map(int, input().split()))
memory = [[-1 for i in range(max(m)+1)]for j in range(n)]

def f(i, m):
    if m == 0:
        return 1
    elif i >= n:
        return 0
    elif memory[i][m] != -1:
        return memory[i][m]
    elif m - a[i] >= 0:
        res0 = f(i+1, m)
        res1 = f(i+1, m-a[i])
        if res0 or res1:
            memory[i][m] = 1
            return 1
        else:
            memory[i][m] = 0
            return 0
    else:
        res = f(i+1, m)
        memory[i][m] = res
        return res

for k in m:
    print('yes' if f(0, k) else 'no')
x=[]
while True:
    x=input().split()
    x.sort()
    a,b=map(int,x)
    print(a,b)
    if a==None,b==None:
        break


### FIXED CODE ###

while True:
    line = list(map(int, input().split()))
    if line==[0,0]: break
    print(' '.join(map(str,sorted(line))))
N,M = map(int,input().split())
A = list(map(int,[input() for i in range(M)]))

dp = {i:0 for i in A}

dp[0]=1 # 0段目
if A[0]==1:
  dp[1]=0
  A.remove(1)
else:
  dp[1]=1

safe_stairs = list(range(2,N+1))
[safe_stairs.remove(int(a)) for a in A]
  
for i in safe_stairs:  
  dp[i]= int(dp[i-1]+dp[i-2])
print(dp[N]%1000000007)  

### FIXED CODE ###

n,m = map(int,input().split())
a = [int(input()) for _ in range(m)]
dp=[0]*(n+1)
dp[0]=1

af = [0]*(n+1)
for ai in a:
  af[ai]+=1

if 1 in a:
  dp[1]=0
else:
  dp[1]=1

  
for i in range(2,n+1):
  dp[i]=dp[i-2]+dp[i-1]
  if af[i]==1:    
    dp[i]=0

print(dp[-1]%1000000007)
from sys import setrecursionlimit
class UnionFind:
    setrecursionlimit(10**6)
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]  # 親
        self.rank = [1] * n  # 木の高さ
        self.size = [1] * n  # size[i] は i を根とするグループのサイズ

    def find(self, x):  # x の根を返す
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])  # 経路圧縮
            return self.parent[x]

    def unite(self, x, y):  # x, y の属する集合を併合する
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
    def roots(self):  # すべての根をリストで返す
        return [i for i, x in enumerate(self.parent) if i == x]

N,M = map(int,input().split())
uf = UnionFind(N)
for i in range(M):
    a,b = map(int,input().split())
    uf.unite(a,b)
ans = len(uf.roots())-1
print(ans)


    







### FIXED CODE ###

from sys import setrecursionlimit
setrecursionlimit(10**8)
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]  # 親
        self.rank = [1] * n  # 木の高さ
        self.size = [1] * n  # size[i] は i を根とするグループのサイズ

    def find(self, x):  # x の根を返す
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])  # 経路圧縮
            return self.parent[x]

    def unite(self, x, y):  # x, y の属する集合を併合する
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.rank[x] == self.rank[y]:
                    self.rank[x] += 1
    def roots(self):  # すべての根をリストで返す
        return [i for i, x in enumerate(self.parent) if i == x]

N,M = map(int,input().split())
uf = UnionFind(N+1)
for i in range(M):
    a,b = map(int,input().split())
    uf.unite(a,b)
ans = len(uf.roots())-2
print(ans)
def main():
	n = int(input())
	arr = list(map(int,input().split()))
	for i in range(len(arr)-1):
		if arr[i]-1>(arr[i-1]-1):
			# print(i)
			print("No")
			return
	print("Yes")
	return


main()

### FIXED CODE ###

def main():
	n = int(input())
	cnt = 0
	for i in range(1,n+1):
		string = str(i)
		if len(string)%2==1:
			cnt+=1
	print(cnt)




main()
A = list(map(int, input().split()))
l = [[0,1],[1,2],[0,3]
ll
for i,j in l:
	ll.append(abs(A[i]-A[j]))
print(min(ll))

### FIXED CODE ###

A = list(map(int, input().split()))
b = [[0, 1], [2, 1], [2, 0]]
l = 0
n = []
for i, j in b:
	l = l + abs(A[j]-A[i])
	n.append(abs(A[j]-A[i]))
l = l - max(n)
print(l)
def main():

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

    INF = 10 * 20
    dp = [INF] * (n * 1000)
    dp[0] = 0

    max_vi = 0
    for _ in range(n):
        wi, vi = map(int, input().split())
        max_vi += vi

        for vj in range(max_vi + 1, vi - 1, -1):
            nw = dp[vj - vi] + wi
            if dp[vj] > nw:
                dp[vj] = nw

    for i in range(max_vi, -1, -1):
        if dp[i] <= w:
            print(i)
            return

main()


### FIXED CODE ###

def main():

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

    INF = 10 ** 20
    dp = [INF] * (n * 100001)
    dp[0] = 0

    max_vi = 0
    for _ in range(n):
        wi, vi = map(int, input().split())
        max_vi += vi

        for vj in range(max_vi + 1, vi - 1, -1):
            nw = dp[vj - vi] + wi
            if dp[vj] > nw:
                dp[vj] = nw

    for i in range(max_vi, -1, -1):
        if dp[i] <= w:
            print(i)
            return

main()
K,N = map(int,input().split())
A = list(map(int,input()))
L = []
T = K+A[0]-A[-1]
for i in range(N-1):
  L.append(A[i+1]-A[i])
print(K-max(L))

### FIXED CODE ###

K,N = map(int,input().split())
A = list(map(int,input().split()))
L = []
T = K+A[0]-A[-1]
for i in range(N-1):
  L.append(A[i+1]-A[i])
L.append(T)
print(K-max(L))
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

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

l = lcm(A[0], A[1])
for i in range(2, N):
    l = lcm(l, A[i])

for i in range(N):
    res += l//A[i]

print(res % 1000000007)

### FIXED CODE ###

from fractions import gcd

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

l = A[0]
for i in range(1, N):
    l = l * A[i] // gcd(l, A[i])

for a in A:
    res += l//a

print(res % 1000000007)
a,b=map(int,input().split())
prnt(max(2*a-1, a+b, 2*b-1))

### FIXED CODE ###

a,b=map(int,input().split())
print(max(2*a-1, a+b, 2*b-1))
h,w,m = map(int, input().split())
hw = [list(map(int, input().split())) for i in range(m)]
bomb = set()
h_list = [0] * (h+1)
w_list = [0] * (w+1)
for H,W in hw:
  h_list[H] += 1
  w_list[W] += 1
  bomb.add((H,W))
max_h = max(h_list)
max_w = max(w_list)
maxh_list = []
maxw_list = []
for k,v in enumerate(h_list):
  if v == max_h:
    maxh_list.append(k)
for k,v in enumerate(w_list):
  if v == max_w:
    maxw_list.append(k)
if len(maxh_list) * len(maxv_list) > m:
  ans = max_h * max_w
else:
  ans = max_h * max_w - 1
  for i in maxh_list:
    for j in maxw_list:
      if (i,j) not in bomb:
        ans = max_h * max_w
        break
print(ans)
      

### FIXED CODE ###

h,w,m = map(int, input().split())
hw = [list(map(int, input().split())) for i in range(m)]
bomb = set()
h_list = [0] * (h+1)
w_list = [0] * (w+1)
for H,W in hw:
  h_list[H] += 1
  w_list[W] += 1
  bomb.add((H,W))
max_h = max(h_list)
max_w = max(w_list)
maxh_list = []
maxw_list = []
for k,v in enumerate(h_list):
  if v == max_h:
    maxh_list.append(k)
for k,v in enumerate(w_list):
  if v == max_w:
    maxw_list.append(k)
if len(maxh_list) * len(maxw_list) > m:
  ans = max_h + max_w
else:
  ans = max_h + max_w - 1
  for i in maxh_list:
    for j in maxw_list:
      if (i,j) not in bomb:
        ans = max_h + max_w
        break
print(ans)
import math

def LCM(a,b):
    return a*b/math.gcd(a,b)

if __name__=="__main__":
    A,B,C,D=map(int,input().split())
    lcm=LCM(C,D)
    count=B//C+B//D-B//lcm
    count1=(A-1)//C+(A-1)//D-(A-1)//lcm
    result=B-A+1-count+count1
    print('{}'.format((int(result))))

### FIXED CODE ###

import fractions

def LCM(a,b):
    return int(a*b/fractions.gcd(a,b))

if __name__=="__main__":
    A,B,C,D=map(int,input().split())
    lcm=LCM(C,D)
    count=B//C+B//D-B//lcm
    count1=(A-1)//C+(A-1)//D-(A-1)//lcm
    result=B-A+1-count+count1
    print(int(result))
import numpy as np

H, W = map(int, input().split())
a = np.array(shape=(H, W), dtype=bool)
for i in range(H):
  a[i] = [s == "." for s in input().split()]

y = [True] * H
 i in range(H):
  if all(a[i,:]):
    y[i] = False

x = [True] * W
for i in range(W):
  if all(a[:,i]):
    x[i] = False

ans = []
for i in range(H):
  if not y[i]:
    continue
  s = ""
  for j in range(W):
    if not x[j]:
      continue
    s = "".join([s, "." if a[i,j] else "#"])
  ans.append(s)

print(*ans, sep="\n")


### FIXED CODE ###

import numpy as np

H, W = map(int, input().split())
a = np.zeros(shape=(H, W), dtype=bool)
for i in range(H):
  a[i] = [s == "." for s in input()]

y = [True] * H
for i in range(H):
  if all(a[i,:]):
    y[i] = False

x = [True] * W
for i in range(W):
  if all(a[:,i]):
    x[i] = False

ans = []
for i in range(H):
  if not y[i]:
    continue
  s = ""
  for j in range(W):
    if not x[j]:
      continue
    s = "".join([s, "." if a[i,j] else "#"])
  ans.append(s)

print(*ans, sep="\n")
import sys
a=0
b=0
c=0
x=3


v,y,z =[int(x) for x in input().split(" ")]

a = v+y
b = y+z
c = z+v

if a<b and a<c:
	print (a)

if b<c and b<a:
	print (b)

if c<b and c<a:
	print (c)

if a=b and b=c:
	print (a)

if a=b and b<c:
	print (a)

if a=c and a<b:
	print (a)

if c=b and b<a:
	print (c)

### FIXED CODE ###

import sys
a=0
b=0
c=0
x=3


v,y,z =[int(x) for x in input().split(" ")]

a = v+y
b = y+z
c = z+v

if a<b and a<c:
	print (a)

if b<c and b<a:
	print (b)

if c<b and c<a:
	print (c)

if a == b and b == c:
	print (a)

if a == b and b<c:
	print (a)

if a ==c and a<b:
	print (a)

if c==b and b<a:
	print (c)
import math
from functools import reduce

N = int(input())
T = [int(input()) for _ in range(N)]

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

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(T))

### FIXED CODE ###

import fractions
from functools import reduce

N = int(input())
T = [int(input()) for _ in range(N)]

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(T))
min=10
sum=0
for i in range(5):
  y=int(input())
  x=y%10
  if x==0:
    sum+=y
  else:
    min=min(x, 9)
    if x==min:
      sum+=y
    else:
      sum+=y+10-x
print(sum)

### FIXED CODE ###

X=[int(input()) for i in range(5)]
Y=[]
for x in X:
  Y.append(-(-x//10)*10-x)
print(sum(X)+sum(Y)-(max(Y)))
str = input()
ans = []
allow = ["A","C","G","T"]
ans_str = ""
for index in range(len(str)):
  if str[index] in allow:
    ans_str = ans_str + str[index]
  else:
    ans.append(ans_str)
    ans_str = ""
print(len(sorted(ans, key=len)[-1]))

### FIXED CODE ###

str = input()
ans = []
allow = ["A","C","G","T"]
count = 0
for s in str:
  if s in allow:
    count = count + 1
    ans.append(count)
  else:
    count = 0
    
if len(ans) == 0:
  print(0)
else:
  print(sorted(ans)[-1])
n=int(input())
s=input()
cnt=0
i=1
while(i<n):
    if(s[i-1]=='A' and s[i]=='B' and s[i+1]=='C'):
        cnt+=1
    i+=1
        
print(cnt)
    

### FIXED CODE ###

n=int(input())
s=input()
cnt=0
i=1
while(i<n-1):
    if(s[i-1]=='A' and s[i]=='B' and s[i+1]=='C'):
        cnt+=1
    i+=1
        
print(cnt)
a = "abcdefghijklmnopqrstuvwyz"

s = input()
print(a.index[a.index(s)+1])

### FIXED CODE ###

a = "abcdefghijklmnopqrstuvwyz"

s = input()
print(a[a.index(s)+1])
a,b = int(input()),input()
j,l=0,[0]
for i in b:
	if i == "I":
		j+=1
	else:
		j-=1
	l.append(j)
print(max(l))

### FIXED CODE ###

a,b,c,d = map(int,input().split())
print(a*b if a*b > c*d else c*d)
y,m,d=map(int,input().split("/"))
if y<=2018 :
    print(Heisei)
elif y==2019 :
    if m<=4 :
        print(Heisei)
    else:
        print(TBD)
else :
    print(TBD)


### FIXED CODE ###

y,m,d=map(int,input().split("/"))
if y<=2018 :
    print("Heisei")
elif y==2019 :
    if m<=4 :
        print("Heisei")
    else:
        print("TBD")
else :
    print("TBD")
N = int(input())
S = lisr(input())
cnt = 0
for i in range(1, N):
    if S[i-1] == "#" :
        s[i] = "."
         cnt += 1
print(cnt)

### FIXED CODE ###

A, B, C = map(int, input().split())
if A > B:
    tmp = A
    A =  B
    B = tmp 

if C >= A and C <= B:
    print("Yes")
else:
    print("No")
def main():
    N = int(input())
    P = map(int, input().split())
    cnt = 0
    for i in range(N):
        if P[i] == i + 1:
            cnt += 1
        ans = (cnt + 1) // 2
    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N = int(input())
    P = list(map(int, input().split()))
    cnt = 0
    for i in range(N - 1):
        if P[i] == i + 1:
            cnt += 1
            P[i + 1], P[i] = P[i], P[i + 1]
    if P[N - 1] == N:
        cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()