Harryxun/stf_run huggingface dataset:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools
from collections import deque

N = int(readline())
A = list(map(lambda x: int(x) - 1,read().split())) + [-1]

def test(A,B):
    for x,y in zip(B, B[1:]):
        if A[x] == y:
            return False
    return True

def solve_small(cand, A, ng_first = -1):
    for p in itertools.permutations(cand):
        if p[0] == ng_first:
            continue
        if test(A, p):
            return p
    return False

if N <= 4:
    p = solve_small(range(N), A)
    if not p:
        print(-1)
        exit()
    print(' '.join(str(x+1) for x in p))
    exit()

    
raise Exception

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import itertools
from collections import deque
from heapq import heappop, heappush, heapify
from collections import defaultdict

N = int(readline())
A = list(map(lambda x: int(x) - 1,read().split())) + [-1]

def test(A,B):
    for x,y in zip(B, B[1:]):
        if A[x] == y:
            return False
    return True

def solve_small(cand, A, ng_first = -1):
    for p in itertools.permutations(cand):
        if p[0] == ng_first:
            continue
        if test(A, p):
            return p
    return False

if N <= 6:
    p = solve_small(range(N), A)
    if not p:
        print(-1)
        exit()
    print(' '.join(str(x+1) for x in p))
    exit()

in_deg = [0] * (N+10)
for x in A:
    in_deg[x] += 1

q = [(-x, i) for i,x in enumerate(in_deg)] # in_deg最大の人を分かるようにしたい
heapify(q)
se = set(q)

def greedy(rest,A,ng_first):
    B = []
    ng = ng_first
    while len(rest) >= 4:
        x = rest[0]; y = rest[1]
        if ng == x:
            B.append(y)
            rest.popleft()
            rest.popleft()
            rest.appendleft(x)
        else:
            B.append(x)
            rest.popleft()
        ng = A[B[-1]]
    return B

rest = deque(range(N))
B = []
prev = N
n = N
for _ in range(N-4):
    while q[0] not in se:
        heappop(q)
    if -q[0][0] == n - 1:
        v = q[0][1]
        B.append(v)
        rest.remove(v)
        B += greedy(rest, A, A[B[-1]])
        break
    x = rest[0]; y = rest[1]
    if A[prev] == x:
        B.append(y)
        rest.popleft()
        rest.popleft()
        rest.appendleft(x)
    else:
        B.append(x)
        rest.popleft()
    prev = B[-1]
    v = A[B[-1]]
    se.remove((-in_deg[v],v))
    in_deg[v] -= 1
    se.add((-in_deg[v],v))
    n -= 1
if len(B) < N:
    B += list(solve_small(rest, A, A[B[-1]]))

print(' '.join(str(x+1) for x in B))
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
H = LIST()
I = []

for i in range(N):
  c = 0
  s = 1
  for j in range(N-i-1):
    if H[i+j] >= H[i+j+1]:
      s *= 1
      c += s
    else:
      s *= 0
      c += s
    I.append(c)
    
print(int(max(I)))

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
H = LIST()
I = []

if N == 1:
  print(0)
  exit()
  
i = 0
 
while i < N :
  c = 0
  j = 0
  while j < N-i-1 and H[i+j] >= H[i+j+1] :
    c += 1
    j += 1
    
  I.append(c)
  i += c+1
  
print(int(max(I)))
s=input()
le=len(s)
lis=[]
for i in range(0,le):
  if s[i]!="A" and s[i]!="" and s[i]!="T" and s[i]!="G":
    lis.append(i)
lo=0
for j in range(0,len(lis)-1):
  if lis[j+1]-lis[j]-1>=lo:
    lo=lis[j+1]-lis[j]-1
if lis[0]>=lo:
  lo=lis[j]
if len(lis)-lis[-1]+1>=lo:
  lo=len(lis)-lis[-1]-1
print(lo)

### FIXED CODE ###

b=input()
if b=="A":
  print("T")
if b=="T":
  print("A")
if b=="C":
  print("G")
if b=="G":
  print("C")
def main():
    N, M = list(map(int, input().split()))
    inputs = [input().split() for i in range(M)]
    
    # dic = {}
    has_been_solved = set()
    pen = 0
    cor = 0
    for i in inputs:
        if i[0] in has_been_solved:
            continue

        if i[1] == 'AC':
            cor += 1
            has_been_solved.add(i[0])
        else:
            pen += 1

    print(f'{cor} {pen}')
    



if __name__ == "__main__":
    main()


### FIXED CODE ###

n,m=map(int,input().split())
a=[0]*n
w=[0]*n
ac=0
wc=0
for _ in range(m):
    p,s=input().split()
    p=int(p)-1
    if a[p]==0:
        if s=='AC':
            a[p]=1
            ac+=1
            wc+=w[p]
        else:
            w[p]+=1
print(ac,wc)
S = map(str, input().split())

N = len(S) + 1
t = [0] * N
for i in range(N - 1):
    if S[i] == '<':
        t[i + 1] = t[i] * 1
for i in range(N - 1, -1, -1):
    if S[i] == '>':
        t[i] = max(t[i], t[i + 1] + 1)
print(sum(t))

### FIXED CODE ###

S = input()

N = len(S) + 1
t = [0] * N
for i in range(N - 1):
    if S[i] == '<':
        t[i + 1] = t[i] + 1
for i in range(N - 2, -1, -1):
    if S[i] == '>':
        t[i] = max(t[i], t[i + 1] + 1)
print(sum(t))
h,w = [int(i) for i in input().split()]

s = [['#']*(w+2)] + [['#']+list(input())+['#'] for _ in range(h)] + [['#']*(w+2)]
#print(s)

cost = [[-1 if s[y][x] == '#' else float('inf') for x in range(w+2)] for y in range(h+2)]
cost[1][1] = 0
#print(cost)

def list_flatten(nested_list):
  flat_list = []
  fringe = [nested_list]
  
  while len(fringe) > 0:
    node = fringe.pop(0)
    if isinstance(node, list):
      fringe = node + fringe
    else:
      flat_list.append(node)

  return(flat_list)
      
def move(y,x):
  if cost[y-1][x] != -1:
    if cost[y-1][x] > cost[y][x]+1:
      cost[y-1][x] = cost[y][x]+1
      move(y-1,x)
  if cost[y+1][x] != -1:
    if cost[y+1][x] > cost[y][x]+1:
      cost[y+1][x] = cost[y][x]+1
      move(y+1,x)
  if cost[y][x-1] != -1:
    if cost[y][x-1] > cost[y][x]+1:
      cost[y][x-1] = cost[y][x]+1
      move(y,x-1)
  if cost[y][x+1] != -1:
    if cost[y][x+1] > cost[y][x]+1:
      cost[y][x+1] = cost[y][x]+1
      move(y,x+1)

move(1,1)

#print(cost)

if cost[h][w] == float('inf'):
  print(-1)
else:
  while_num = list_flatten(s).count('.')
  print(while_num - (cost[h][w]+1))


### FIXED CODE ###

import sys

h,w = [int(i) for i in input().split()]

sys.setrecursionlimit(100000)

s = [['#']*(w+2)] + [['#']+list(input())+['#'] for _ in range(h)] + [['#']*(w+2)]
#print(s)

cost = [[-1 if s[y][x] == '#' else float('inf') for x in range(w+2)] for y in range(h+2)]
cost[1][1] = 0
#print(cost)

def list_flatten(nested_list):
  flat_list = []
  fringe = [nested_list]
  
  while len(fringe) > 0:
    node = fringe.pop(0)
    if isinstance(node, list):
      fringe = node + fringe
    else:
      flat_list.append(node)

  return(flat_list)
      
def move(y,x):
  if cost[y+1][x] != -1:
    if cost[y+1][x] > cost[y][x]+1:
      cost[y+1][x] = cost[y][x]+1
      move(y+1,x)
      
  if cost[y-1][x] != -1:
    if cost[y-1][x] > cost[y][x]+1:
      cost[y-1][x] = cost[y][x]+1
      move(y-1,x)
  
  if cost[y][x+1] != -1:
    if cost[y][x+1] > cost[y][x]+1:
      cost[y][x+1] = cost[y][x]+1
      move(y,x+1)
  
  if cost[y][x-1] != -1:
    if cost[y][x-1] > cost[y][x]+1:
      cost[y][x-1] = cost[y][x]+1
      move(y,x-1)
  

move(1,1)

#print(cost)

if cost[h][w] == float('inf'):
  print(-1)
else:
  while_num = list_flatten(s).count('.')
  print(while_num - (cost[h][w]+1))
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n,s = inm()
a = inl()
dp = [[0]*(s+1) for i in range(n+1)]
for i in range(n+1):
    dp[i][0] = 1
sm = 0
for i in range(1,n+1):
    for j in range(s):
        if dp[i-1][j]>0 and j+a[i-1]<=s:
            dp[i][j+a[i-1]] += dp[i-1][j]
            if j+a[i-1]==s:
                sm = (sm+dp[i-1][j]*pow(2,n-i+1,R))%R
    ddprint(dp)
print(sm)


### FIXED CODE ###

#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 998244353

def ddprint(x):
  if DBG:
    print(x)

hf = pow(2,R-2,R)
n,s = inm()
a = inl()
dp = [[0]*(s+1) for i in range(n+1)]
for i in range(n+1):
    dp[i][0] = pow(2,n,R)
sm = 0
for i in range(1,n+1):
    dp[i] = [x for x in dp[i-1]]
    for j in range(s):
        if dp[i-1][j]>0 and j+a[i-1]<=s:
            dp[i][j+a[i-1]] = (dp[i][j+a[i-1]]+dp[i-1][j]*hf)%R
    #ddprint(i)
    #ddprint(dp[i])
print(dp[n][s])
job = list()
salary = list()
k = m
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    salary.append(t)

    if s - k > 0:
        salary.remove(min(salary))
    else:
        k -= 1

print(sum(salary))


### FIXED CODE ###

import heapq
job = list()
salary = list()
n,m = map(int,input().split())

for i in range(n):
    a,b = map(int,input().split())
    job.append((a,b))

job.sort(reverse = True)

for x in job:
    s,t = x
    heapq.heappush(salary,t)
    if s - m > 0:
        heapq.heappop(salary)
    else:
        m -= 1

print(sum(salary))
import sys

_, s = sys.stdin.read().split('\n')
red_hat_counter = 0
blue_hat_counter = 0

# Get a criteria value from N
#criteria_val = ceil(int(N)/2)


# Get a counter of Red
for s_char in s:
  if s_char == "R":
    red_hat_counter += 1
  else:
    blue_hat_counter += 1
    
# Compare between a criteria value and a counter of Red
if blue_hat_counter < red_hat_counter:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

import sys
input_list = sys.stdin.readlines() 
N, s = map(str.strip, input_list)
red_hat_counter = 0
for s_str in s:
  if s_str == "R":
    red_hat_counter += 1
if red_hat_counter > (int(N)/2):
  print "Yes"
else:
  print "No"
S = list(input())

if len(S) == 0:
    print('No')
else:
    c1 = (len(set(S)) == 2)

    m = list(set(S))[0]
    n = list(set(S))[1]

    m_c, n_c = 0, 0

    c2 = False

    if c1:
        for i in range(len(S)):
            if S[i] == m:
                m_c += 1
            else:
                n_c += 1
        if m_c == n_c:
            c2 = True

    if c1 and c2:
        print('Yes')
    else:
        print('No')

### FIXED CODE ###

S = input()
S = list(S)

if len(set(S)) == 2:
    
    m = list(set(S))[0]
    n = list(set(S))[1]

    m_c, n_c = 0, 0
    c = False
    
    for i in range(len(S)):
        if S[i] == m:
            m_c += 1
        else:
            n_c += 1
            
    if m_c == n_c:
        c = True

    if c:
        print('Yes')
    else:
        print('No')

else:
    print('No')
D,N = map(int,(input().split()))
l = [[] for _ in range(3)]
for i in range(1,1000101):
    c = 0
    j = i
    while j%100 == 0:
        c += 1
        j //= 100
    if c < 3:
        l[c].append(i)

print(l[D][N-1])

### FIXED CODE ###

D,N = map(int,(input().split()))
l = [[] for _ in range(3)]
for i in range(1,1010001):
    c = 0
    j = i
    while j%100 == 0:
        c += 1
        j //= 100
    if c < 3:
        l[c].append(i)

print(l[D][N-1])
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-Snack.py
#
import math

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


### FIXED CODE ###

#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-Snack.py
#
from fractions import gcd

a, b = map(int, input().split())
ans = int(a * b // gcd(a, b))
print(ans)
N=int(input())
A=list(map(int,input().split()))
B=[0]*(N//2+N%2)
ans=0
ans2=0
if N%2==0:
    for i in range(len(B)):
        if A[i]%2==1 and (A[i]+1)/2<=N/2:
            B[(A[i]-1)//2]+=1
        else:
            print(0)
            exit()
    for i in range(len(B)):
        if B[i]!=2:
            print(0)
            exit()
    ans=pow(2,N/2)%(pow(10,9)+7)
    ans2=int(ans)
    print(ans2)
elif N%2==1:
    for i in range(N):
        if A[i]%2==0 and A[i]/2<=(N-1)/2:
            B[A[i]//2]+=1
        else:
            print(0)
            exit()
    if B[0]!=1:
        print(0)
        exit()
    for i in range(len(B)-1):
        if B[i+1]!=2:
            print(0)
            exit()
    ans=pow(2,(N-1)/2)%(pow(10,9)+7)
    ans2=int(ans)
    print(ans2)
else:
    print(0)


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B=[0]*(N//2+N%2)
IndexCount=0
IndexRe=0
Divider=pow(10,9)+7
ans=1
if N%2==0:
    for i in range(N):
        if A[i]%2==1 and (A[i]+1)/2<=N/2:
            B[(A[i]-1)//2]+=1
        else:
            print(0)
            exit()
    for i in range((N//2+N%2)):
        if B[i]!=2:
            print(0)
            exit()
    IndexCount=int((N/2)//1000)
    IndexRe=int((N/2)%1000)
    for i in range(IndexCount):
        ans=(ans*(pow(2,1000)%Divider))%Divider
    ans=(ans*(pow(2,IndexRe)%Divider))%Divider
    print(ans)
elif N%2==1:
    for i in range(N):
        if A[i]%2==0 and A[i]/2<=(N-1)/2:
            B[A[i]//2]+=1
        else:
            print(0)
            exit()
    if B[0]!=1:
        print(0)
        exit()
    for i in range((N//2+N%2)-1):
        if B[i+1]!=2:
            print(0)
            exit()
    IndexCount=int(((N-1)/2)//1000)
    IndexRe=int(((N-1)/2)%1000)
    for i in range(IndexCount):
        ans=(ans*(pow(2,1000)%Divider))%Divider
    ans=(ans*(pow(2,IndexRe)%Divider))%Divider
    print(ans)
else:
    print(0)
s = input()
t = input()
print(s + t)

### FIXED CODE ###

s, t = map(str, input().split()) 
print(t + s)
N = 10000
for 1 in range(j):
    x = raw_input()
    if x == '0':
        break
    print 'Case %d: %s' % (i, x)

### FIXED CODE ###

i = 1
while 1:
    x = raw_input()
    if x == '0':
        break
    print 'Case %d: %s' % (i, x)
    i = i + 1
a, b = map(int, input().split())
 
if a >= 13:
  print(b)
elif a >= 6:
  print((int)b/2)
else:
  print(0)

### FIXED CODE ###

a,b = map(int, input().split())
 
ans=0
if a <= 5:
	ans = 0
elif a >= 6 and a<=12:
	ans = b/2
else:
	ans = b
 
print(int(ans))
import copy
h, w = map(int, input().split())

a = [list(map(lambda x: int(x) % 2, input().split())) for _ in range(h)]
# for v in a:
#     print(*v)

directions = [[0, 1], [1, 0], [0, -1], [-1, 0]]
visited = copy.deepcopy(a)
number = [[i * w + j for j in range(w)] for i in range(h)]
def bfs(x, y):
    graph = [[] for _ in range(h * w)]
    que = [(x, y)]
    visited[y][x] = 0
    while que:
        x, y = que.pop(0)
        n = number[y][x]

        for dx, dy in directions:
            nx, ny = x + dx, y + dy
            if 0 <= nx < w and 0 <= ny < h and visited[ny][nx] == 1:
                que.append((nx, ny))
                nn = number[ny][nx]
                graph[n].append(nn)
                visited[ny][nx] = 0
                # graph[nn].append(n)
    return graph


def dfs(i, slide):
    if not graph[i]:
        dp[slide][i] = slide, None
        return slide

    r = dp[slide].get(i)
    if r is not None:
        return r[0]

    none = [dfs(c, 0) for c in graph[i]]
    if slide:
        r = sum(none)
        dp[slide][i] = r, None
        return r + 1
    else:
        to = [dfs(c, 1) for c in graph[i]]
        r = 0
        merge = None
        for i_ in range(len(graph[i])):
            s = 0
            for j_ in range(len(graph[i])):
                if j_ == i_: # slide!!
                    s += to[j_]
                else:
                    s += none[j_]
            if s > r:
                r = s
                merge = graph[i][i_]
        s = sum(none)
        if s > r:
            r = s
            merge = None
        dp[slide][i] = r, merge
        return r


def xy(i):
    return i % w, i // w


answers = []
def dfs_answer(i, slide):
    _, to = dp[slide][i]
    for c in graph[i]:
        if c == to:
            answers.append(xy(i) + xy(to))
            dfs_answer(c, 1)
        else:
            dfs_answer(c, 0)


for i in range(h):
    for j in range(w):
        if visited[i][j]:
            graph = bfs(j, i)
            dp = [{}, {}]
            dfs(number[i][j], 0)
            # print(dfs(number[i][j], 0), ":", j, i, number[i][j])
            #
            # print("--------")
            dfs_answer(number[i][j], 0)
            # __import__("sys").exit()

print(len(answers))
for ans in answers:
    print(*ans)


### FIXED CODE ###

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

a = [list(map(lambda x: int(x) % 2, input().split())) for _ in range(h)]

road = []
for i in range(h):
    for j in list(range(w))[::(i % 2) * -2 + 1]:
        road.append((i + 1, j + 1))

answer = []
for f, t in zip(road[:-1], road[1:]):
    if a[f[0] - 1][f[1] - 1] % 2:
        answer.append(f + t)
        a[t[0] - 1][t[1] - 1] += 1

print(len(answer))
for ans in answer:
    print(*ans)
from collections import deque

n = int(input())
result = deque()
func = {'insert':result.appendleft,\
        'delete':result.remove,\
        'deleteFirst':result.popleft,\
        'deleteLast':result.pop}

for i in range(n):
    c = input().split()
    if len(c) > 1:
        func[c[0]](int(c[1]))
    else:
        func[c[0]]()

print(*result)


### FIXED CODE ###

from collections import deque
import sys

n = int(input())
result = deque()
func = {'insert':result.appendleft,\
        'delete':result.remove,\
        'deleteFirst':result.popleft,\
        'deleteLast':result.pop}

for line in sys.stdin.readlines():
    c = line.split()
    if len(c) > 1:
        try:
            func[c[0]](int(c[1]))
        except:
            continue
    else:
        func[c[0]]()

print(*result)
import numpy as np

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

res = np.zeros(N)
for i in range(N):
  res[i] = (A==A[i]).sum()

if (res>1).sum() > 0:
  ans = 'NO'
else:
  ans = 'YES'
  
print(str(ans))

### FIXED CODE ###

import numpy as np

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

A_uni = np.unique(A)
if len(A_uni) < N:
    ans = 'NO'
else:
    ans = 'YES'
print(str(ans))
import numpy as np
N = int(input())
A = np.array(input().split(), np.int64)
B = np.arange(1, N + 1)
X = A[None,:] + A[:,None]
Y = B[None,:] - B[:,None]
print(np.count_nonzero(X == Y))

### FIXED CODE ###

from _collections import defaultdict
import sys

read = sys.stdin.buffer.read
N = int(input())
A = [int(i) for i in input().split()]
D = defaultdict(int)

for i, a in enumerate(A, 1):
    D[i - a] += 1

ans = 0
for i, a in enumerate(A, 1):
    ans += D[i + a]
print(ans)
n=int(input())
s=input()
compte=0
r=[]
g=[]
b=[]
for i in range(n):
    if s[i]=="R":
        r.append(i)
    elif s[i]=="G":
        g.append(i)
    elif s[i]=="B":
        b.append(i)
 
for i in range(1,n-1):
    if n%2==0:
        if i<n//2:
            for j in range(1,i+1):
                if s[i]!=s[i-j] and s[i]!=s[i+j] and s[i+j]!=s[i-j]:
                    compte+=1
        else:
            for j in range(1,n-i):
                if s[i]!=s[i-j] and s[i]!=s[i+j] and s[i+j]!=s[i-j]:
                    compte+=1
    else:
            if i<(n-1)//2:
                for j in range(1,i+1):
                    if s[i]!=s[i-j] and s[i]!=s[i+j] and s[i+j]!=s[i-j]:
                        compte+=1
            elif i==(n-1)//2:
                for j in range(1,n-i):
                    if s[i]!=s[i-j] and s[i]!=s[i+j] and s[i+j]!=s[i-j]:
                        compte+=1
            elif i>(n-1)//2:
                for j in range(1,n-i):
                    if s[i]!=s[i-j] and s[i]!=s[i+j] and s[i+j]!=s[i-j]:
                        compte+=1
 
print(len(r)*len(g)*len(b)-count)

### FIXED CODE ###

N = int(input())
S = input()
if N>3 :
  total = S.count("R")*S.count("G")*S.count("B")
  for i in range(0,N-2):
    for j in range(i+1,N-1):
      if 2*j-i<N:
        if S[i]!=S[j] and S[j]!=S[2*j-i] and S[2*j-i]!=S[i]:
          total-=1
  print(total)
else:
  print(0)
import bisect as bs
N = int(input())
A = [int(input()) for _ in range(N)]
def LDS(a):
    N = len(a)
    INF = float("inf")
    dp = [-INF]*N
    dp[N-1] = a[0]
    for i in range(1, N):
        j = bs.bisect_left(dp, a[i])-1
        dp[j] = a[i]
    for i in range(N-1, -1, -1):
        if dp[i] == -INF:
            return N-i-1
    return N
print(LDS(A))

### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
b = [None for _ in range(N)]
for i in range(N):
    j = N-i
    if j > N//2:
        b[j-1] = a[j-1]
    else:
        s = 0
        for k in range(2*j-1, N, j):
            s = (s+b[k])%2
        b[j-1] = (a[j-1]-s) % 2
ans = []
for i in range(N):
    if b[i] == 1:
        ans.append(i+1)
if ans == []:
    print(0)
else:
    print(len(ans))
    print(" ".join(map(str, ans)))
l = map(str, raw_input().split())

for i in range(len(l)-1):
    if l[i][len(l)-1] == l[i+1][0]:
        print "YES"
        exit()
print "NO"


### FIXED CODE ###

l = map(str, raw_input().split())
for i in range(len(l)-1):
    tempa = list(l[i])
    tempb = list(l[i+1])
    if tempa[len(tempa)-1] != tempb[0]:
        print "NO"
        exit(0)
print "YES"
N = int(input())
s = list(input())
counts = dict(Counter(s))
r = 0;g = 0;b= 0
for i in s:
    if i=="R":
        r += 1
    elif i=="G":
        g += 1
    else:
        b += 1
all = r*g*b
sub = 0
for i in range(N-1):
    for j in range(i+1,N):
        if s[i]==s[j]:
            continue
        k = 2*j - i
        if k >= N:
            continue
        else:
            if (s[k]!=s[i] and s[k]!=s[j]):
                sub += 1
print(all-sub)

### FIXED CODE ###

N = int(input())
s = list(input())
r = 0;g = 0;b= 0
for i in s:
    if i=="R":
        r += 1
    elif i=="G":
        g += 1
    else:
        b += 1
all = r*g*b
sub = 0
for i in range(N-1):
    for j in range(i+1,N):
        if s[i]==s[j]:
            continue
        k = 2*j - i
        if k >= N:
            continue
        else:
            if (s[k]!=s[i] and s[k]!=s[j]):
                sub += 1
print(all-sub)
import sys
input = sys.stdin.readline.rstrip()
sys.setrecursionlimit(10**6)
import decimal
from decimal import Decimal
decimal.getcontext().prec = 10

from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
import collections
from collections import deque 

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# ---------------------------------------

s = input()
if s[-1] == "s":
    s += "es"
else:
    s += "s"
print(s)


### FIXED CODE ###

s = input()
if s[-1] == "s":
    s += "es"
else:
    s += "s"
print(s)
import math
a, b = map(int, input().split())
if b != 1:
    if b> a:
        print(math.ceil((b-a)/(a-1)+1))
    else:
        print(math.ceil(b/a))
else:
    print(0)

### FIXED CODE ###

s = input()
t = input()

cnt = 0
for i in range(len(s)):
     if s[i] == t[i]:
            cnt += 1
print(cnt)