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

N = int(input())
A = list(map(int, input().split()))
count = []
for i in range(1, 10**5):
    count.append(A.count(i))
ans = 0
for j in range(len(count)-2):
    if count[j] + count[j+1] + count[j+2] > ans:
        ans = count[j] + count[j+1] + count[j+2]
print(ans)

### FIXED CODE ###

def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    count = [0] * 10 ** 5
    for i in A:
        if i > 1:
            count[i - 1] += 1
        count[i] += 1
        if i < 10**5-1:
            count[i + 1] += 1
    print(max(count))
resolve()
### BUGGY CODE ###

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

ans = 0

for i in range(n):
  if min(p[: i + 1]) == p[i]:
    ans += 1
    
print(ans)

### FIXED CODE ###

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

tmp_min = p[0]
cnt = 0

for i in range(n):
    if p[i] <= tmp_min:
        tmp_min = p[i] #i番目までの最小値を更新
        cnt += 1

print(cnt)
### BUGGY CODE ###

import sys
class Bit:
  def __init__(self,n):
    self.size = n
    self.tree = [0]*(n+1)
 
  def sum(self,i):
    s = 0
    while i > 0:
      s += self.tree[i]
      i -= i & -i
    return s

  def add(self,i,x):
    while i <= self.size:
      self.tree[i] += x
      i += i & -i
input = sys.stdin.readline
mod = 998244353
ptable = [1,2]
for i in range(20):
  ptable.append(ptable[-1]**2%mod)
def p2(x):
  if x == 0:
    return 1
  ret = 1
  for i in range(20):
    if x&1<<i:
      ret = (ret*ptable[i+1])%mod
  return ret
n = int(input())
xy = [list(map(int,input().split())) for i in range(n)]
xls,yls = map(list,list(zip(*xy)))
xi = [(xls[i],i) for i in range(n)]
yi = [(yls[i],i) for i in range(n)]
xi.sort()
yi.sort()
xd = [0 for i in range(n)]
yd = [0 for i in range(n)]
for i in range(n):
  x,ix = xi[i]
  y,iy = yi[i]
  xd[ix] = i
  yd[iy] = i
ans = 0
bit = Bit(n+1)
xyd = list(zip(xd,yd))
xyd.sort()
for i in range(n):
  x,y = xyd[i]
  upper = n-y-1
  right = n-x-1
  ld = bit.sum(y+1)
  ru = upper+right+ld-n+1
  rd = right-ru
  lu = upper-ru
  ans += ((p2(lu)-1)*(p2(rd)-1)*(p2(ld+ru))+(p2(ld)-1)*(p2(ru)-1)*(p2(lu+rd))+
  p2(n-1)-(p2(lu)-1)*(p2(rd)-1)*(p2(ld)-1)*(p2(ru)-1))
  ans %= mod
  bit.add(y+1,1)
print(ans)

### FIXED CODE ###

import sys
class Bit:
  def __init__(self,n):
    self.size = n
    self.tree = [0]*(n+1)
 
  def sum(self,i):
    s = 0
    while i > 0:
      s += self.tree[i]
      i -= i & -i
    return s

  def add(self,i,x):
    while i <= self.size:
      self.tree[i] += x
      i += i & -i
input = sys.stdin.readline
from collections import defaultdict
mod = 998244353
n = int(input())
p2t = [1]
for i in range(n):
  p2t.append(p2t[-1]*2%mod)
dcy = defaultdict(int)
xy = [list(map(int,input().split())) for i in range(n)]
xy.sort()
yls = list(zip(*xy))[1]
yls = list(yls)
for i in range(n):
  dcy[yls[i]] = i
yls.sort()
yind = [0 for i in range(n)]
for i in range(n):
  ind = dcy[yls[i]]
  yind[ind] = i
xyd = []
for i in range(n):
  xyd.append((i,yind[i]))
ans = 0
bit = Bit(n+1)
for i in range(n):
  x,y = xyd[i]
  upper = n-y-1
  right = n-x-1
  ld = bit.sum(y+1)
  ru = upper+right+ld-n+1
  rd = right-ru
  lu = upper-ru
  p2lu = p2t[lu]
  p2rd = p2t[rd]
  p2ru = p2t[ru]
  p2ld = p2t[ld]
  ans += ((p2lu-1)*(p2rd-1)*(p2t[ld+ru])%mod+(p2ld-1)*(p2ru-1)*(p2t[lu+rd])%mod+
  p2t[n-1]-(p2lu-1)*(p2rd-1)*(p2ld-1)*(p2ru-1)%mod)
  ans %= mod
  bit.add(y+1,1)
print(ans)
### BUGGY CODE ###

from itertools import product
import numpy as np
N = int(input())
lisS = [list(map(ord, list(input()))) for _ in range(N)]
arS = np.array(lisS)

arExt = np.tile(arS, [2,2])[:-1,:-1]

cnt = 0
for i, j in product(range(N),range(N)):
    ar = arExt[i:i+N, j:j+N]
    cnt += ((ar - ar.T) == 0).all()

print(cnt)



### FIXED CODE ###

import numpy as np

N = int(input())
lisS = [list(map(ord, list(input()))) for _ in range(N)]
arS = np.array(lisS)
arExt = np.tile(arS, [2,2])[:-1,:-1]

cnt = 0
for i in range(N):
    ar = arExt[i:i+N, 0:N]
    cnt += N * (ar == ar.T).all()

print(cnt)
### BUGGY CODE ###

import collections
import copy
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n = int(input())
nums = [ int(s) for s in input().split() ]


for i in range(n):
    ans = 0

    cpl = copy.copy(nums)
    cpl.pop(i)
    ct = collections.Counter(cpl)

    for key, val in ct.items():
        if val > 1:
            ans += combinations_count(val, 2)
    
    print(ans)


### FIXED CODE ###




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

# counter
from collections import Counter
cntr = Counter(lst)

# combination
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

total = 0
# countSameNames
for value in cntr.values():
    if value > 1:
        total += combinations_count( value, 2 )


for l in lst:
    print(total - (cntr[l]-1))
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10**7)

def dfs(x):
    if seen[x-1]==0:
        uni[cnt].append(x)
        seen[x-1]=1
        for i in fri[x-1]:
            dfs(i)
    

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

fri=[[] for i in range(n)]
blk=[[] for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    fri[a-1].append(b)
    fri[b-1].append(a)

for i in range(k):
    c,d=map(int,input().split())
    blk[c-1].append(d)
    blk[d-1].append(c)


seen=[0 for i in range(n)]

uni=[]
cnt=0
for i in range(1,n+1):
    if seen[i-1]==0:
        uni.append([])
        dfs(i)
        cnt+=1

seq=[0 for i in range(n)]

for unii in uni:
    for j in unii:
        cj=len(unii)-len(fri[j-1])-len(set(unii)&set(blk[j-1]))-1
        seq[j-1]=cj

print(*seq)

### FIXED CODE ###

import sys

sys.setrecursionlimit(10**7)

def dfs(x):
    if seen[x-1]==0:
        uni[cnt].add(x)
        seen[x-1]=1
        for i in fri[x-1]:
            dfs(i)
    

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

fri=[[] for i in range(n)]
blk=[[] for i in range(n)]

for i in range(m):
    a,b=map(int,input().split())
    fri[a-1].append(b)
    fri[b-1].append(a)

for i in range(k):
    c,d=map(int,input().split())
    blk[c-1].append(d)
    blk[d-1].append(c)


seen=[0 for i in range(n)]

uni=[]
cnt=0
for i in range(1,n+1):
    if seen[i-1]==0:
        uni.append(set())
        dfs(i)
        cnt+=1

seq=[0 for i in range(n)]

for unii in uni:
    for j in unii:
        cj=len(unii)-len(fri[j-1])-len(unii&set(blk[j-1]))-1
        seq[j-1]=cj

print(*seq)
### BUGGY CODE ###

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

tmp=abs(X-x[0])
flag=0
for i in range(tmp,0,-1):
    if tmp%i==0:
        canDivide=1
        for j in range(N):
            tmp=abs(X-x[j])
            if tmp%i:
                canDivide=0
                break
        if canDivide:
            print(i)
            flag=1
            break
    if flag:
        break


### FIXED CODE ###

N,X=map(int,input().split())
x=list(map(int,input().split()))
diffx=[abs(X-x[i]) for i in range(N)]

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

gcd=diffx[0]
for i in range(1,N):
    gcd=euclid(diffx[i],gcd)
print(gcd)
### BUGGY CODE ###

# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy
import bisect
import heapq


def dfs(s, prev, pre):
  val[s] += Ope[s] + prev
  for i in G[s]:
    if(i == pre):
      continue
    dfs(i, val[s], s)

def bfs(sx, sy, n):
  que = deque([[sy,sx]])
  while que:
    y,x = que.popleft()
    for i,j in D:
      if(x+i<0 or y+j<0 or x+i>W-1 or y+j>H-1):
        continue
      dist = G[y+j][x+i]
      if(G[y+j][x+i] != "X"):
        if(type(G[y+j][x+i]) is str):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        elif(dist>G[y][x]+1):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        

def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#V, E, r = map(int, input().split())
#INF = V * 10001
#A = [int(i) for i in input().split()]


N = int(input())
A = [int(i) for i in input().split()]
dp = [0]*(N+1)
ans = 0
cnt = 0
tle = 0

As = list(set(A))

for i in As:
  cnt = A.count(i)
  if(cnt<2):
    dp[i] = 0
  else:
    dp[i] = combinations_count(cnt, 2)

tle = sum(dp)

#print(dp)
for i in range(N):
  ans = tle - (A.count(A[i])-1)
  if(ans < 0):
    ans = 0
  print(int(ans))

#print(ans)


### FIXED CODE ###

# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq


def dfs(s, prev, pre):
  val[s] += Ope[s] + prev
  for i in G[s]:
    if(i == pre):
      continue
    dfs(i, val[s], s)

def bfs(sx, sy, n):
  que = deque([[sy,sx]])
  while que:
    y,x = que.popleft()
    for i,j in D:
      if(x+i<0 or y+j<0 or x+i>W-1 or y+j>H-1):
        continue
      dist = G[y+j][x+i]
      if(G[y+j][x+i] != "X"):
        if(type(G[y+j][x+i]) is str):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        elif(dist>G[y][x]+1):
          G[y+j][x+i] = G[y][x]+1
          que.append([y+j,x+i])
        

def combinations_count(n, r):
  return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#V, E, r = map(int, input().split())
#INF = V * 10001
#A = [int(i) for i in input().split()]


N = int(input())
A = [int(i) for i in input().split()]
dp = [0]*(N+1)
ans = 0
cnt = 0
tle = 0

As = list(set(A))
c = Counter(A)

for i in As:
  cnt = c[i]
  if(cnt<2):
    dp[i] = 0
  else:
    dp[i] = combinations_count(cnt, 2)

tle = sum(dp)

#print(dp)
for i in range(N):
  ans = tle - (c[A[i]]-1)
  if(ans < 0):
    ans = 0
  print(int(ans))

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

r,g,y,n=map(int,input().split())
a=0
b=0
c=0
count=0


m=n
for i in range((n//r)+1):
    a=i
    m=m-r*i
    for j in range((n//g)+1):
        b=j
        c=m-j*g
        if c%y==0 and c>=0 :
            count+=1

    m=n

print(count)



### FIXED CODE ###

r,g,y,n=map(int,input().split())
a=0
b=0
c=0
count=0


m=n
for i in range((n//r)+1):
    m=m-r*i
    for j in range((m//g)+1):
        c=m-j*g
        if c%y==0 and c>=0 :
            count+=1

    m=n

print(count)
### BUGGY CODE ###

N = int(input())
mylist = []
for i in range (N):
  A = int(input())
  mylist.append(int(A))
for j in range (N):
  data = mylist[j]
  my = sorted(mylist,reverse=True)
  if data == my[0]:
    print(my[1])
  else:
    print(my[0])
del my[2:]

### FIXED CODE ###

N = int(input())
mylist = []
first=0
second=0
for i in range (N):
  A = int(input())
  if first < A:
    first = A
  elif second < A:
    second = A
  mylist.append(A)
for i in range (N):
  if mylist[i] == first:
    print(second)
  else :
    print(first)
### BUGGY CODE ###

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

L = sorted(L)
res = []
cnt = 0
for i in range(len(L)):
  Li = L[i]
  for j in range(len(L)):
    Lj = L[j]
    for k in range(len(L)):
      Lk = L[k]
      if Li + Lj > Lk and Lj + Lk > Li and Lk + Li > Lj:
        if Li != Lj and  Lj!= Lk and Lk != Li:
          if sorted([i, j, k]) not in res:
            res.append(sorted([i, j, k]))
            cnt += 1
print(cnt)

      

### FIXED CODE ###

import itertools

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
ref = list(itertools.combinations(L, 3))
cnt = 0
for i in ref:
  Li = i[0]
  Lj = i[1]
  Lk = i[2]
  if Li + Lj > Lk and Lj + Lk > Li and Lk + Li > Lj:
    if Li != Lj and  Lj!= Lk and Lk != Li:
      cnt += 1

print(cnt)
### BUGGY CODE ###

H, W = map(int, input().split())
S = [input() for _ in range(H)]

dp1 = [[0 for _ in range(W)] for _ in range(H)]
dp2 = [[0 for _ in range(W)] for _ in range(H)]

for i in range(H):
    for j in range(W):
        if dp1[i][j] == 0 and S[i][j] == '.':
            c = 0
            for k in range(i, H):
                if S[k][j] == '.':
                    c += 1
                else:
                    break
            for k in range(i, H):
                if S[k][j] == '.':
                    dp1[k][j] = c
                else:
                    break
for i in range(H):
    for j in range(W):
        if dp2[i][j] == 0 and S[i][j] == '.':
            c = 0
            for k in range(j, W):
                if S[i][k] == '.':
                    c += 1
                else:
                    break
            for k in range(j, W):
                if S[i][k] == '.':
                    dp2[i][k] = c
                else:
                    break

ans = max(
    dp1[i][j] + dp2[i][j] - 1
    for i in range(H)
    for j in range(W)
)
print(ans)


### FIXED CODE ###

H, W = map(int, input().split())
S = [input() for _ in range(H)]

dp1 = [[0 for _ in range(W)] for _ in range(H)]
dp2 = [[0 for _ in range(W)] for _ in range(H)]

for i in range(H):
    for j in range(W):
        if dp1[i][j] == 0 and S[i][j] == '.':
            c = 0
            for k in range(i, H):
                if S[k][j] == '.':
                    c += 1
                else:
                    break
            for k in range(i, H):
                if S[k][j] == '.':
                    dp1[k][j] = c
                else:
                    break
for i in range(H):
    for j in range(W):
        if dp2[i][j] == 0 and S[i][j] == '.':
            c = 0
            for k in range(j, W):
                if S[i][k] == '.':
                    c += 1
                else:
                    break
            for k in range(j, W):
                if S[i][k] == '.':
                    dp2[i][k] = c
                else:
                    break

ans = max(
    dp1[i][j] + dp2[i][j] - 1
    for i in range(H)
    for j in range(W)
)
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3

import sys

s = input()

a1 = "dream"
a2 = "dreamer"
a3 = "erase"
a4 = "eraser"

while True:
    if len(s) < 5:
        print("NO")
        sys.exit(0)
    elif len(s) == 5:
        if s in ["dream", "erase"]:
            print("YES")
        else:
            print("NO")
        sys.exit(0)
    elif len(s) == 6:
        if s == "eraser":
            print("YES")
        else:
            print("NO")
        sys.exit(0)
    elif len(s) == 7:
        if s == "dreamer":
            print("YES")
        else:
            print("NO")
        sys.exit(0)
    else:
        if s[:7] in ["dreamerd", "dreamere"]:
            s = s[7:]
        elif s[:6] in ["dreamd", "dreame", "erasee", "erased"]:
            s = s[5:]
        elif s[:7] in ["eraserd", "erasere"]:
            s = s[6:]
        continue



### FIXED CODE ###

#!/usr/bin/env python3

import sys

s = input()

a1 = "dream"
a2 = "dreamer"
a3 = "erase"
a4 = "eraser"

while True:
    if len(s) < 5:
        print("NO")
        sys.exit(0)
    elif len(s) == 5:
        if s in ["dream", "erase"]:
            print("YES")
        else:
            print("NO")
        sys.exit(0)
    elif len(s) == 6:
        if s == "eraser":
            print("YES")
        else:
            print("NO")
        sys.exit(0)
    elif len(s) == 7:
        if s == "dreamer":
            print("YES")
        else:
            print("NO")
        sys.exit(0)
    else:
        if s[:8] in ["dreamerd", "dreamere"]:
            s = s[7:]
        elif s[:6] in ["dreamd", "dreame", "erasee", "erased"]:
            s = s[5:]
        elif s[:7] in ["eraserd", "erasere"]:
            s = s[6:]
        else:
            print("NO")
            sys.exit(0)
### BUGGY CODE ###

N = int(input())
ans = 1
for i in map(int,input().split()):
    ans = ans * i
if ans > 10**18:
    print('-1')
else:
    print(ans)

### FIXED CODE ###

N = int(input())
l = list(map(int,input().split()))
l.sort()
ans = 1
rec = True
for i in range(N):
    ans = ans * l[i]
    if ans > 10**18:
        rec = False
        break

if rec:
    print(ans)
else:
    print('-1')
### BUGGY CODE ###

import sys


sys.setrecursionlimit(200010)
n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

v = 100000
graph = [[] for i in range(v*2)]
for i in range(n):
    x = info[i][0] - 1
    y = (info[i][1] - 1) + v
    graph[x].append(y)
    graph[y].append(x)

def dfs(pos):
    if visited[pos]:
        return
    visited[pos] = True
    if 0 <= pos < v:
        cnt[0] += 1
    else:
        cnt[1] += 1
    for i in graph[pos]:
        dfs(i)
    return

visited = [False] * (v*2)
cnt = [0]*2
ans = 0
for i in range(v*2):
    cnt[0] = 0
    cnt[1] = 0
    dfs(i)
    ans += cnt[0]*cnt[1]
print(ans - n)

### FIXED CODE ###

import sys

input = sys.stdin.readline
sys.setrecursionlimit(200010)
n = int(input())
info = [list(map(int, input().split())) for i in range(n)]

v = 100000
graph = [[] for i in range(v*2)]
for i in range(n):
    x = info[i][0] - 1
    y = (info[i][1] - 1) + v
    graph[x].append(y)
    graph[y].append(x)

def dfs(pos):
    if visited[pos]:
        return
    visited[pos] = True
    cnt[pos//v] += 1
    for i in graph[pos]:
        dfs(i)
    return

visited = [False] * (v*2)
cnt = [0]*2
ans = 0
for i in range(v*2):
    cnt[0] = 0
    cnt[1] = 0
    dfs(i)
    ans += cnt[0]*cnt[1]
print(ans - n)
### BUGGY CODE ###

from sys import stdin, setrecursionlimit


def main():
    mod = 10 ** 9 + 7
    n, k = map(int, stdin.readline().split())
    a = list(map(int, stdin.readline().split()))
    a.sort()

    a_cmb = [0] * n
    a_cmb[k - 1] = 1
    for i in range(k, n):
        a_cmb[i] = a_cmb[i - 1] * i // (i - k + 1)

    ans = 0

    for i in range(n):
        if 0 <= i < n - k + 1:
            ans -= a[i] * a_cmb[n - 1 - i]
        if k - 1 <= i < n:
            ans += a[i] * a_cmb[i]

    print(ans % mod)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

### FIXED CODE ###

from sys import stdin, setrecursionlimit


def main():
    mod = 10 ** 9 + 7
    n, k = map(int, stdin.readline().split())
    a = list(map(int, stdin.readline().split()))
    a.sort()
    ans = 0

    m = n + 1

    fac = [0] * m
    finv = [0] * m
    inv = [0] * m

    def initialize_cmb(m):
        fac[0] = 1
        finv[0] = 1
        if m > 1:
            fac[1] = 1
            finv[1] = 1
            inv[1] = 1
            for i in range(2, m):
                fac[i] = fac[i-1] * i % mod
                inv[i] = mod - inv[mod % i] * (mod // i) % mod
                finv[i] = finv[i - 1] * inv[i] % mod

    def cmb(n, k, mod=10 ** 9 + 7):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return fac[n] * (finv[k] * finv[n - k] % mod) % mod

    initialize_cmb(m)

    for i in range(n - k + 1):
        ans -= a[i] * cmb(n - 1 - i, k - 1)
        ans %= mod
    for i in range(k - 1, n):
        ans += a[i] * cmb(i, k - 1)
        ans %= mod
    print(ans % mod)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()
### BUGGY CODE ###

n=int(input())
l=[]
for i in range(n):
  s=str(input())
  if s not in l:
    l.append(s)
print(len(l))

### FIXED CODE ###

n=int(input())
l=[]
for i in range(n):
  s=str(input())
  l.append(s)
print(len(set(l)))
### BUGGY CODE ###

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

ans = 0

for i in range(n):
  if min(p[:i+1]) == p[i]:
    ans += 1
    
print(ans)

### FIXED CODE ###

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

ans = 1
min_val = p[0]

for i in range(1, n):
  min_val = min(p[i], min_val)
  if min_val == p[i]:
    ans += 1
    
print(ans)
### BUGGY CODE ###

import sys

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

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

    max_sum = 0
    for i in range(N):
        tmp_sum = sum(p_list[i:i+K])
        if(max_sum < tmp_sum):
            max_sum = tmp_sum
            ichi = i

    kitaichi = ((p+1)/2 for p in p_list[ichi:ichi+K])

    print(sum(kitaichi))

if __name__ == "__main__":
    main()

### FIXED CODE ###

from sys import stdin

def main():

    input = stdin.readline

    N,K = map(int,input().split())
    p_list = [(p+1)/2 for p in list(map(int,input().split()))]

    # Sを計算
    S = [0]
    for p in p_list:
        S.append(S[-1] + p)
        # print(S)

    # i:i+kを計算

    maxs = 0
    for i in range(N-K+1):
        p_num = S[i+K] - S[i]
        if(maxs < p_num):
            maxs = p_num
    
    print(maxs)

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

n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]
ac_list = []
for i in range(1, len(s)):
    if s[i] == 'C' and s[i-1] == 'A':
        ac_list.append([i-1, i])

for i in range(q):
    # print(s[lr[i][0] - 1:lr[i][1]])
    # print(s[lr[i][0] - 1:lr[i][1]].count('AC'))
    count = 0
    for n in range(len(ac_list)):
        if ac_list[n][0] >= lr[i][0] - 1 and ac_list[n][1] <= lr[i][1] - 1:
            count += 1
    print(count)

### FIXED CODE ###

n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for _ in range(q)]
ac_list = [0] * (n+1)
for i in range(n):
    ac_list[i+1] = ac_list[i] + (1 if s[i:i+2] == 'AC' else 0)
# print(ac_list)
for i in range(q):
    print(ac_list[lr[i][1]-1] - ac_list[lr[i][0]-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
b = [0]*n
for i in range(n):
  if a[i]%2:
    b[i] = 1
  elif a[i]:
    b[i] = 2
DP = [[10**18 for i in range(5)] for j in range(n+1)]
for i in range(5):
    DP[0][i] = 0
for i in range(1,n+1):
  for j in range(5):
    for k in range(j,5):
      if k == 0 or k == 4:
        DP[i][k] = min(DP[i][k],DP[i-1][j]+a[i-1])
      elif k == 1 or k == 3:
        DP[i][k] = min(DP[i][k],DP[i-1][j]+abs(b[i-1]-2))
      else:
        DP[i][k] = min(DP[i][k],DP[i-1][j]+abs(b[i-1]-1))
print(min(DP[n]))

### FIXED CODE ###

import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
b = [0]*n
for i in range(n):
  if a[i]%2:
    b[i] = 1
  elif a[i]:
    b[i] = 2
a.append(0)
b.append(0)
n += 1
DP = [[[10**18 for i in range(3)] for j in range(3)] for k in range(n+1)]
for i in range(3):
  for j in range(3):
    DP[0][i][j] = 0
for i in range(1,n+1):
  for k in (0,2):
    DP[i][0][k] = min(DP[i][0][k],DP[i-1][0][k]+abs(a[i-1]))
  for l in (1,2):
    DP[i][0][2] = min(DP[i][0][2],DP[i-1][l][2]+abs(a[i-1]))
  DP[i][0][2] = min(DP[i][0][2],DP[i-1][2][1]+abs(a[i-1]))

  DP[i][1][2] = min(DP[i][1][2],DP[i-1][0][0]+abs(b[i-1]-1))
  DP[i][1][2] = min(DP[i][1][2],DP[i-1][1][2]+abs(b[i-1]-1))
  DP[i][1][2] = min(DP[i][1][2],DP[i-1][2][1]+abs(b[i-1]-1))

  for k in (1,2):
    DP[i][2][k] = min(DP[i][2][k],DP[i-1][2][k]+abs(b[i-1]-2))
  DP[i][2][2] = min(DP[i][2][2],DP[i-1][1][2]+abs(b[i-1]-2))
  DP[i][2][1] = min(DP[i][2][1],DP[i-1][0][0]+abs(b[i-1]-2))
print(min(*DP[n][0]))
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = []
for i in range(n):
  b.append(a[i])
  b = list(reversed(b))
print(*b)

### FIXED CODE ###

from collections import deque
n = int(input())
a = list(map(int, input().split()))
b = deque()
last = n%2==0
for i in range(n):
  if last:
    b.append(a[i])
  else:
    b.appendleft(a[i])
  last = not last
print(*b)