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

n = int(input())
s = input()
R = []
G = []
B = []

for i in range(n):
    if s[i] == "R":
        R.append(i)
    elif s[i] == "G":
        G.append(i)
    else:
        B.append(i)

ans = 0
for r in R:
    for g in G:
        for b in B:
            s_list = sorted([r,g,b])
            if s_list[1] - s_list[0] != s_list[2] - s_list[1]:
                ans += 1
print(ans)


### FIXED CODE ###

n = int(input())
s = input()
R = 0
G = 0
B = 0

for i in range(n):
    if s[i] == "R":
        R+=1
    elif s[i] == "G":
        G+=1
    else:
        B+=1

ans = R*G*B
for i in range(n-2):
    for j in range(1, (n-i-1)//2+1):
        if s[i]!=s[i+j] and s[i]!=s[i+2*j] and s[i+j]!=s[i+2*j]:
            ans -= 1

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

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

dp = [[0 for _ in range(W+10)] for _ in range(N+5)]
dp[0][0] = 0

for w in range(W+1):
    for n in range(N):
        Wi = wv[n][0]
        Vi = wv[n][1]
        if Wi <= w:
            dp[n+1][w] = max(dp[n][w], dp[n][w-Wi] + Vi)
        dp[n+1][w] = max(dp[n][w], dp[n+1][w])

print(dp[N][W])

### FIXED CODE ###

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

dp = [[0 for _ in range(W+10)] for _ in range(N+5)]

for w in range(1, W+1):
    for n in range(N):
        Wi = wv[n][0]
        Vi = wv[n][1]
        if Wi <= w:
            dp[n+1][w] = max(dp[n][w], dp[n][w-Wi] + Vi)
        dp[n+1][w] = max(dp[n][w], dp[n+1][w])

print(dp[N][W])
### BUGGY CODE ###

def main():
    a, b, k = map(int, input().split())
    for i in range(a, b + 1):
        if abs(a - i) <= (k - 1) or abs(b - i) <= (k - 1):
            print(i)


if __name__ == '__main__':
    main()

### FIXED CODE ###


def main():
    a, b, k = map(int, input().split())
    r = set()
    for i1 in range(a, min(a + k, b)):
        r.add(i1)
    for i2 in range(max(a, b - k + 1), b + 1):
        r.add(i2)
    r = list(r)
    r.sort()
    for j in r:
        print(j)

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

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

def main():
    n,q=map(int,input().split())
    G=[[] for i in range(n)] #隣接配列
    P=[0]*n #親のポイント
    for i in range(n-1):
        a,b=map(int,input().split())
        a-=1
        b-=1
        G[a].append(b)
        G[b].append(a)
    for i in range(q):
        p,x=map(int,input().split())
        p-=1
        P[p]+=x
    def dfs(s,p=-1):        
        for i in G[s]:
            if i!=p:
                P[i]+=P[s]
                dfs(i,s)

    dfs(0)
    print(*P)

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input=sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque

def main():
    n,q=map(int,input().split())
    G=[[] for i in range(n)] #隣接配列
    P=[0]*n #親のポイント
    for i in range(n-1):
        a,b=map(int,input().split())
        a-=1
        b-=1
        G[a].append(b)
        G[b].append(a)
    for i in range(q):
        p,x=map(int,input().split())
        p-=1
        P[p]+=x
    
    Chk=[0]*n #訪問済みチェック
    q=deque([0])
    while q: #qが空になるまで(BFS:幅優先探索)
        now=q.popleft() #取り出す
        Chk[now]=1 #訪問済みにする
        for i in G[now]: #子に対し
            if Chk[i]==0: #未訪問のとき
                P[i]+=P[now] #ポイント加算
                q.append(i) #親としてqに入れる

    print(*P)

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

import re
s = input()

start = now = len(s)
while True:
    s = s.replace('01','').replace('10','')
    if now == len(s):
        break
    now = len(s)
print(start - now)


### FIXED CODE ###

s = input()

print(2 * min(s.count('0'),s.count('1')))
### BUGGY CODE ###

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

lN = [N]
c = 0
for i in range(100000000000000000):
    N = abs(N - K)
    lN.append(N)
    c += 1

print(min(lN))

### FIXED CODE ###

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

if N < K:
    if N <= K/2:
        print(N)
    else:
        print(K-N)

elif N == K:
    print(0)

else:
    N = K + (N - K) % K
    N = abs(N - K)

    if N < K:
        if N <= K/2:
            print(N)
        else:
            print(K-N)

    elif N == K:
        print(0)
### BUGGY CODE ###

from collections import deque

n = int(input())
node_list = []
nodes = [[] for _ in range(n)]
edges = dict()
for _ in range(n - 1):
	a, b = map(int, input().split())
	node_list.append((a - 1, b - 1))
	nodes[a - 1].append(b - 1)
	nodes[b - 1].append(a - 1)
	edges[(a - 1, b - 1)] = 0

used = [False] * n
que = deque()
que.append(0)
while len(que) > 0:
	ni = que.pop()
	if used[ni]:
		continue
	used_colors = [edges[tuple(sorted((ni, e)))] for e in nodes[ni]]
	for node in nodes[ni]:
		[a, b] = sorted([ni, node])
		if edges[(a, b)] == 0:
			for color in range(1, n):
				if not color in used_colors:
					break
			# print((a, b), color)
			edges[(a, b)] = color
			used_colors.append(color)
		que.append(node)

	used[ni] = True

print(max(edges.values()))
for node in node_list:
	print(edges[node])


### FIXED CODE ###

from collections import deque

n = int(input())
nodes = [[] for _ in range(n)]
node_list = []
for _ in range(n - 1):
	a, b = map(int, input().split())
	nodes[a - 1].append(b - 1)
	node_list.append(b - 1)
 
que = deque([0])
ans = [0] * n
while len(que) > 0:
	ni = que.pop()
	color = 1
	for node in nodes[ni]:
		if color == ans[ni]:
			color += 1
		ans[node] = color
		color += 1
		que.append(node)
 
print(max(ans))
for node in node_list:
	print(ans[node])
### BUGGY CODE ###

s = input()
t = input()

dp = [[0]*(len(t)+1) for i in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if (s[i]==t[j]):
            dp[i+1][j+1] = max(dp[i][j]+1, dp[i+1][j], dp[i][j+1])
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

ret = ""
i = len(s)
j = len(t)

while(i>0 and j>0):
    if(dp[i][j] != dp[i-1][j-1]):
        ret = s[i-1] + ret
        i -= 1
        j -= 1
    else:
        if(dp[i][j]==dp[i-1][j]):
            i -= 1
        else:
            j -= 1

print(ret)

### FIXED CODE ###

tmp1 = input()
tmp2 = input()
s = ""
t = ""
if (len(tmp1)<=len(tmp2)):
    s = tmp1
    t = tmp2
else:
    t = tmp1
    s = tmp2

dp = [[0]*(len(t)+1) for i in range(len(s)+1)]

for i in range(len(s)):
    for j in range(len(t)):
        if (s[i]==t[j]):
            dp[i+1][j+1] = max(dp[i][j]+1, dp[i+1][j], dp[i][j+1])
        else:
            dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1])

ret = ""
i = len(s)
j = len(t)

while(i>0 and j>0):
    if(dp[i][j]==dp[i-1][j]):
        i -= 1
    elif(dp[i][j]==dp[i][j-1]):
        j -= 1
    elif(dp[i][j] != dp[i-1][j-1]):
        ret = s[i-1] + ret
        i -= 1
        j -= 1

print(ret)
### BUGGY CODE ###

import collections
import sys
n=int(input())
s=input()
if n==2:
  if s[0]==s[1]:
    print(1)
  else:
    print(0)
  sys.exit()
l=0;r=n//2+1
while l!=r:
  x=(l+r)//2
  L=[]
  for i in range(n+1-x):
    L.append(s[i:i+x])
  L2=collections.Counter(L)
  if L2.most_common()[0][1]>=2:
    l=x+1
  else:
    r=x
x=l-1
L=[]
for i in range(n+1-x):
  L.append(s[i:i+x])
L2=collections.Counter(L)
L3=[]
c=[]
for i in range(n+1-x):
  L3.append(s[i:i+x])
for i in range(len(L3)):
  if L3[i]==L2.most_common()[0][0]:
    c.append(i)
if max(c)-min(c)>=l-1:
  print(l-1)
else:
  print(l-max(c)+min(c)+1)

### FIXED CODE ###

n=int(input())
s=input()
l=0;r=0;ans=0
while r<n:
  t=s[l:r]
  if t in s[r:n]:
    ans=max(ans,len(t))
    r+=1
  else:
    l+=1
print(ans)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
S = []
for i in range(Q):
    B, C = map(int,input().split())
    if B in A:
        while B in A:
            A[A.index(B)] = C
            
    S.append(sum(A))


for s in S:
    print(s)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
S = []
c = 0
s = sum(A)
table = [0] * 100010
# A = pd.Series(A)
# for a in A:
#     print(a)

for i in A:
    table[i] += 1

for i in range(Q):
    B, C = map(int,input().split())
    # if B in A:
    # c = A.count(B)
    c = table[B]
    s += (C - B) * c
    table[C] += table[B]
    table[B] = 0
    # print(s)
        # print((C - B) * c) 
        # string = ",".join(A)
        # string_new = string.replace(B,C)
        # A =  string_new.split(",")
        # s = sum(map((lambda x: int(x)), A))
    S.append(s)

        # A.replace(B, C,c)
        # while B in A:
        #     A[A.index(B)] = C
    # for a in A:
    #     print(a)
    # else:
        # S.append(s)



for s in S:
    print(s)
### BUGGY CODE ###

num = int(input())
words = []
answer = 0

for i in range(num):
  words.append(sorted(list(input())))

for i in range(num):
  for j in range(num -i - 1):
    p = 0
    for k in range(10):
      if words[i][k] == words[j + 1 + i][k]:
        p += 1
    if p == 10:
      answer += 1

print(answer)

### FIXED CODE ###

import math
num = int(input())
words = {}

for i in range(num):
  a = str(sorted(list(input())))
  
  if a in words:
    words[a] += 1
  else:
  	words[a] = 1

points = list(words.values())
sum = 0
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
for i in range(len(points)):
  if points[i] > 1:
  	sum += combinations_count(points[i], 2)
print(sum)
### BUGGY CODE ###

import sys
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
mod = 1000000007

if n >= 3:
    if 1 not in a  and 2 not in a:
        c = [1,2]
    elif 1 in a and 2 not in a:
        c = [0,1]
    elif 1 not in a and 2 in a:
        c = [1,0]
    else:
        c = [0,0]

    one,two = map(int, c)

    for i in range(3,n+1):
        if i in a:
            temp = 0
            one = two
            two= temp
        else:
            temp = one+two
            one = two
            two = temp

    print(temp%mod)
    sys.exit()
elif n == 2:
    if 1 not in a  and 2 not in a:
        c = [1,2]
    elif 1 in a and 2 not in a:
        c = [0,1]
    elif 1 not in a and 2 in a:
        c = [1,0]
    else:
        c = [0,0]

    print(c[1])
    sys.exit()
elif n == 1:
    if 1 in a:
        print(0)
        sys.exit()
    else:
        print(1)
        sys.exit()

### FIXED CODE ###

N, M = map(int, input().split())
A = [int(input()) for _ in range(M)]
inf = float("inf")
dp = [0] * (N+1)
for i in A:
	dp[i] = inf
dp[0] = 1
if dp[1] != inf:
	dp[1] = 1
for i in range(2,N+1):
	if dp[i] == inf:
		continue

	a = dp[i-2] if dp[i-2] != inf else 0
	b = dp[i-1] if dp[i-1] != inf else 0

	dp[i] = (a + b) % 1000000007


print(dp[N])
### BUGGY CODE ###

class UnionFind:
    def __init__(self, N):
        self.roots = list(range(N + 1))
        self.counter = [1] * (N + 1)

    def get_root(self, n):
        if self.roots[n] != n:
            self.roots[n] = self.get_root(self.roots[n])
        return self.roots[n]

    def union(self, a, b):
        a, b = sorted([self.get_root(a), self.get_root(b)])
        if a != b:
            self.roots[b] = a
            self.counter[a] += self.counter[b]
            self.counter[b] = 0

    def find(self, a, b):
        return self.get_root(a) == self.get_root(b)

    def count(self, x):
        return (self.counter[self.get_root(x)])

def resolve():
    N, M, K = [int(x) for x in input().split()]
    list = [[] for _ in range(N)]
    block = [[] for _ in range(N)]

    uf = UnionFind(N)

    for _ in range(M):
        A, B = [int(x)-1 for x in input().split()]
        list[A].append(B)
        list[B].append(A)
        uf.union(A,B)

    for _ in range(K):
        C, D = [int(x)-1 for x in input().split()]
        block[C].append(D)
        block[D].append(C)

    for i in range(N):
        ans = uf.count(i) - len(list[i]) - 1
        for j in block[i]:
            if uf.find(i ,j):
                ans -= 1

        print(ans, end=" ")
resolve()

### FIXED CODE ###

class UnionFind:
    def __init__(self, N, l):
        self.roots = list(range(N+1))
        self.counter = [1]*(N+1)
        for a, b in l:
            self.union(a, b)
 
    def get_root(self, n):
        if self.roots[n] != n:
            self.roots[n] = self.get_root(self.roots[n])
        return self.roots[n]
 
    def union(self, a, b):
        a, b = sorted([self.get_root(a), self.get_root(b)])
        if a != b:
            self.roots[b] = a
            self.counter[a] += self.counter[b]
            self.counter[b] = 0
 
    def find(self, a, b):
        return self.get_root(a) == self.get_root(b)
 
    def count(self, x):
        return(self.counter[self.get_root(x)])
 
 
N, M, K = [int(i) for i in input().split()]
ab = [[int(i) for i in input().split()] for _ in range(M)]
cd = [[int(i) for i in input().split()] for _ in range(K)]
friend = [[] for _ in range(N+1)]
uf = UnionFind(N, ab)
 
for a, b in ab:
    friend[a].append(b)
    friend[b].append(a)
 
ans = [uf.count(i)-1-len(friend[i]) for i in range(N+1)]
 
for c, d in cd:
    if uf.find(c, d):
        ans[c] -= 1
        ans[d] -= 1
 
print(*ans[1:])
### BUGGY CODE ###

n, s = map(int, input().split())
a = list(map(int, input().split()))
p = 998244353

dp = [[[0, 0, 0] for _ in range(s+1)] for _ in range(n+1)]
for i in range(n):
    dp[0][0][0] = 1
    for j in range(s+1):
        dp[i+1][j][0] += dp[i][j][0]
        dp[i+1][j][1] += dp[i][j][0] + dp[i][j][1]
        dp[i+1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2]
        if j + a[i] <= s:
            dp[i+1][j+a[i]][1] += dp[i][j][0] + dp[i][j][1]
            dp[i+1][j+a[i]][2] += dp[i][j][0] + dp[i][j][1]

print(dp[n][s][2] % p)

### FIXED CODE ###

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

dp = [0] * (S+1)
ans = 0
for i in range(N):
    ndp = dp[:]
    if A[i] <= S:
        ndp[A[i]] = (ndp[A[i]] + i+1) % mod
    for j in range(S):
        if j+A[i] <= S:
            ndp[j+A[i]] = (ndp[j+A[i]] + dp[j]) % mod
    ans = (ans + ndp[S]) % mod
    dp = ndp[:]
print (ans)
### BUGGY CODE ###

import pdb


def main():
    num = int(input())
    array = []
    tmp = input()
    for i in range(num):
        array.append(int(tmp.split()[i]))
        
    ans = 1
    div = 0
    prev = 0
    count = 0
    #pdb.set_trace()
    for tmp in array:
        count += 1
        if(count == 1):
            prev = tmp
            continue

        if div == 0:
            if prev < tmp:
                div = 1
            elif prev > tmp:
                div = -1
        else:
            if prev < tmp and div == -1:
                ans += 1
                div = 0
            elif prev > tmp and div == 1:
                ans += 1
                div = 0
                
        prev = tmp
        
    print(ans)

        
if __name__ == '__main__':
    main()


### FIXED CODE ###

import pdb


def main():
    num = int(input())
    array = []
    tmp = input()
    tmp = tmp.split()
    for i in range(num):
        array.append(int(tmp[i]))
        
    ans = 1
    div = 0
    prev = 0
    count = 0
    #pdb.set_trace()
    for tmp in array:
        count += 1
        if count == 1:
            prev = tmp
            continue

        if div == 0:
            if prev < tmp:
                div = 1
            elif prev > tmp:
                div = -1
        else:
            if prev < tmp and div == -1:
                ans += 1
                div = 0
            elif prev > tmp and div == 1:
                ans += 1
                div = 0
                
        prev = tmp
        
    print(ans)

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

from bisect import*
def main():
    root=[[],[]]
    def search_higher(key):
        ptr=root
        ret=None
        while ptr[1]:
            i=bisect(ptr[0],key)
            if i!=len(ptr[0]):ret=ptr[0][i]
            ptr=ptr[1][i]
        i=bisect(ptr[0],key)
        if i!=len(ptr[0]):ret=ptr[0][i]
        return ret
    def search_lower(key):
        ptr=root
        ret=None
        while ptr[1]:
            i=bisect_left(ptr[0],key)
            if i!=0:ret=ptr[0][i-1]
            ptr=ptr[1][i]
        i=bisect_left(ptr[0],key)
        if i!=0:ret=ptr[0][i-1]
        return ret
    def insert_rec(ptr,key):
        b_size=256
        if not ptr[1]:
            insort(ptr[0],key)
            if len(ptr[0])==b_size*2-1:
                ret=[ptr[0][:b_size],[]]
                ptr[0]=ptr[0][b_size:]
                return ret
        else:
            i=bisect(ptr[0],key)
            tmp=insert_rec(ptr[1][i],key)
            if tmp:
                ptr[0].insert(i,tmp[0].pop())
                ptr[1].insert(i,tmp)
                if len(ptr[1])==b_size*2:
                    ret=[ptr[0][:b_size],ptr[1][:b_size]]
                    ptr[0],ptr[1]=ptr[0][b_size:],ptr[1][b_size:]
                    return ret
    def insert(key):
        tmp=insert_rec(root,key)
        if tmp:root[0],root[1]=[tmp[0].pop()],[tmp,root]
    n,*a=map(int,open(0).read().split())
    l=[0]*n
    for i,v in enumerate(a,1):l[v-1]=i
    insert(0)
    insert(n+1)
    c=0
    for i,v in enumerate(l,1):
        c+=(search_higher(v)-v)*(v-search_lower(v))*i
        insert(v)
    print(c)
main()

### FIXED CODE ###

root=lambda x:x if par[x]==x else root(par[x])
same=lambda x,y:root(x)==root(y)
def unite(*z):
  x,y=map(root,z)
  if x!=y:
    if rank[x]<rank[y]:
      par[x]=y
      size[y]+=size[x]
    else:
      par[y]=x
      size[x]+=size[y]
      if rank[x]==rank[y]:rank[x]+=1
n,*a=map(int,open(0).read().split())
*par,=range(n)
rank=[1]*n
size=[1]*n
b=[0]*n
for i,t in enumerate(a):b[t-1]=i
c=0
for k in b[::-1]:
  l=r=1
  if k>0 and a[k-1]>a[k]:
    l+=size[root(k-1)]
    unite(k-1,k)
  if k+1<n and a[k+1]>a[k]:
    r+=size[root(k+1)]
    unite(k+1,k)
  c+=l*r*a[k]
print(c)
### BUGGY CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 14, 2020 09:41:55 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from collections import defaultdict
from sys import stdin
input = stdin.readline


def main():
  # input
  N, Q = list(map(int, input().split()))

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

  PX = defaultdict(int)
  for _ in range(Q):
    p, x = map(int, input().split())
    PX[p] += x

  # solve
  ans = [0]*(N+1)
  S = [1] # Stack
  visited = set()
  temp = PX[1]

  while len(S):
    now = S[-1]
    visited.add(now)

    for next_ in G[now]:
      if next_ not in visited:
        S.append(next_)
        temp += PX[next_]
        break
    else:
      S.pop()
      ans[now] = temp
      temp -= PX[now]

  print(*ans[1:], sep=' ')


if(__name__ == '__main__'):
  main()


### FIXED CODE ###

import sys
from collections import defaultdict
from collections import deque
from sys import stdin
sys.setrecursionlimit(10**7)
input = stdin.readline


def main():
  # input
  N, Q = list(map(int, input().split()))

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

  PX = defaultdict(int)
  for _ in range(Q):
    p, x = map(int, input().split())
    PX[p] += x

  # solve
  ans = [0]*(N+1)
  visited = set()
  # temp = PX[1]
  # S = [1] # Stack
  # S = deque([1])

  # while len(S):
  #   now = S[-1]
  #   visited.add(now)

  #   for next_ in G[now]:
  #     if next_ not in visited:
  #       S.append(next_)
  #       temp += PX[next_]
  #       break
  #   else:
  #     S.pop()
  #     ans[now] = temp
  #     temp -= PX[now]

  def dfs(now, sum_):
    visited.add(now)
    for next_ in G[now]:
      if next_ not in visited:
        sum_ += PX[next_]
        sum_ = dfs(next_, sum_)

    ans[now] = sum_
    sum_ -= PX[now]
    return sum_

  dfs(1, PX[1])

  print(*ans[1:], sep=' ')


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

from math import gcd
#リスト l の最大公約数
def gcdlist(l):
    a = l[0]
    for i in range(len(l)):
        a = gcd(a,l[i])
    return a
n = int(input())
A = list(map(int, input().split()))
ans = 0

for i in range(n):
    tmp = A.copy()
    tmp.pop(i)
    gcd_num = gcdlist(tmp)
    ans = max(ans, gcd_num)

print(ans)

### FIXED CODE ###

from math import gcd
#リスト l の最大公約数
def gcdlist(l):
    a = l[0]
    for i in range(len(l)):
        a = gcd(a,l[i])
    return a
n = int(input())
A = list(map(int, input().split()))
ans = 0

x = [0]*n
y = [0]*n
for i in range(1, n):
    x[i] = gcd(x[i-1], A[i-1])
for i in reversed(range(n-1)):
    y[i] = gcd(y[i+1], A[i+1])

for i in range(n):
    tmp = gcd(x[i], y[i])
    ans = max(ans, tmp)

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

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

res = True
if N >= 2:
    for i in range(N - 1):
        for j in range(1, N - i):
            if H[i] - H[i + j] >= 2:
                res = False
                break
        if res == False:
            break

if res == True:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

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

res = True
if N >= 2:
    for i in range(N - 1):
        if H[i] - H[i + 1] >= 2:
            res = False

y_card = 0
if N >= 3 and res == True:
    for i in range(N - 1):
        if H[i] - H[i + 1] == 1:
            y_card += 1
            if y_card == 2:
                res = False
                break
        elif H[i] == H[i + 1]:
            pass
        elif H[i + 1] - H[i] >= 1:
            y_card -= H[i + 1] - H[i]
            if y_card < 0:
                y_card = 0


if res == True:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

import queue as q

def main():
    N, M = list(map(int, input().split()))
    D = {}
    for m in range(M):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        D.setdefault(u, set()).add(v)

    S, T = list(map(int, input().split()))
    S -= 1
    T -= 1
    print(f(D, S, T))

def f(D, S, T):
    close = [set(), set(), set()]
    Q = q.Queue()
    Q.put((S, 0, 0))

    while not Q.empty():
        p, c, l = Q.get()
        if l == 0 and p == T:
            return c
        close[l].add(p)

        ns = D.setdefault(p, set())
        l, c = (l + 1) % 3, c + (l + 1) // 3
        for n in ns:
            if n in close[l]:
                continue
            Q.put((n, c, l))
    return -1

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline
N, M = list(map(int, input().split()))

def f(D, S, T):
    close = [[False] * N, [False] * N, [False] * N]
    Q = []
    index = 0
    Q.append((S, 0, 0))

    while len(Q) > index:
        p, c, l = Q[index]
        index += 1
        
        if close[l][p]:
            continue
        
        if l == 0 and p == T:
            return c // 3
        close[l][p] = True

        l, c = (l + 1) % 3, c + 1
        for n in D[p]:
            if close[l][n]:
                continue
            Q.append((n, c, l))
    return -1

if __name__ == "__main__":
    D = {n: set() for n in range(N)}
    for m in range(M):
        u, v = map(int, input().split())
        u -= 1
        v -= 1
        D[u].add(v)

    S, T = list(map(int, input().split()))
    S -= 1
    T -= 1

    print(f(D, S, T))
### BUGGY CODE ###

n=int(input())
s=list(map(int,input().split()))
c=0
for i in range(n):
    f=True
    for j in range(0,i+1):
        if s[i-j]<s[i]:
            f=False
            break
    if f:
        c=c+1
print(c)

### FIXED CODE ###

n=int(input())
s=list(map(int,input().split()))
c=0
m=200001
for i in range(n):
    if m>s[i]:
        c=c+1
    m=min(m,s[i])
print(c)
### BUGGY CODE ###

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

def gcd_3(a, b, c):
    g = gcd(a, b)
    return gcd(g, c)

K = int(input())
ans = 0

for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            ans += gcd_3(i, j, k)

print(ans)


### FIXED CODE ###

from math import gcd

def gcd_3(a, b, c):
    g = gcd(a, b)
    return gcd(g, c)

K = int(input())
ans = 0

for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            ans += gcd_3(i, j, k)

print(ans)