Fizza is a cute girl and she wants to be more beautiful.
So she approached a magician to increase her beauty magically. But the magician's 
glasses accidently got locked inside the locker and he forgot the password. Without
glasses he can't help her. The password is hidden in N integers i.e. $a[1], a[2], ..... a[N]$ 
written on his magical stick.The password is the maximum number of moves Fizza can perform, for any position $i$ such that 1 < = $i$ < = $N$ and integer $X$ is present at $i$-th
position. In one move she can perform one of the following operations ->
$(1)$  If ( $i$ + 1 < = $N$ ) she can go to position ($i$ + 1 ) if integer at ( $i$ + 1 )-th 
position is equal to $X$.
$(2)$ if ( $i$ + 2 < = $N$ ) she can go to position ($i$ + 2 ) if integer at ($i$ + 2)-th 
position is equal to $X$.
Fizza is a bit worried about her beauty so she can't focus on the problem but she asked for 
your help to find the password.

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow. 
- Each testcase consists of  two lines of input.
- Input $N$.
- Input $N$ integers . 

-----Output:-----
For each testcase, output in a single line Maximum number of moves.

-----Constraints-----
- $1 \leq T \leq 100$
- $1 \leq N \leq 10^5$
- $1 \leq a[i] \leq 2*10^5$

-----Sample Input:-----
3
8
6 3 6 4 5 4 3 6
9
5 5 4 5 2 1 3 4 2
6
1 2 3 4 5 6

-----Sample Output:-----
1
2
0

-----EXPLANATION:-----
In the first case, integers at position 1 and 3 are the same and at alternate positions.
In the second case, integers at position 1, 2, 4 follow the conditions.

Difficulty: interview

Starter code:

Solutions:
def check(l,n):
    m = 0
    for i in range(n-1):
        x = l[i]
        c = 0
        j = i
        while (j+2<n and l[j+2]==x) or (j+1<n and l[j+1] == x):
            if l[j+1] == x:
                j = j+1
            else:
                j+=2
            c+=1
        if m<c:
            m = c
    return m

t = int(input())
for _ in range(t):
    no = int(input())
    a = list(map(int,input().split()))
    print(check(a,no))

# cook your dish here
try:
    x = int(input())
    for _ in range(x):
        y=int(input())
        a=list(map(int,input().split()))
        if len(list(set(a)))==len(a):
            print(0)
        else:
            j=0
            e=0
            while j<y:
                count=0
                i=j
                while i < len(a):
                    if i+1<y:
                        if a[i]==a[i+1] :
                            i+=1
                            count+=1
                        else:
                            if i+2<y:
                                if a[i]==a[i+2] :
                                    i+=2
                                    count+=1
                                else:    
                                    break
                            else:
                                break
                    else:
                        break
                j=j+1
                e=max(e,count)
            print(e)
except:
    pass

from copy import copy
def main():
    for _ in range(int(input())):
        n=int(input())
        a=list(map(int,input().split()))
        i=0
        l=[]
        visited=[False for i in range(n)]
        for j in range(n):
            if(not visited[j]):
                i=j
                s=0
                while(i<n):
                    visited[i]=True
                    if(i+1<n and a[i]==a[i+1]):
                        s+=1
                        i+=1
                    elif(i+2<n and a[i]==a[i+2]):
                        s+=1
                        i+=2
                    else:
                        break
                l.append(s)
        print(max(l))
main()

# cook your dish here
t = int(input())
for _ in range(t):
    N = int(input())
    lst = list(map(int, input().split()))
    maxcc = 0
    el = 0
    for j in range(N):
        i = j
        count = 0
        while i < len(lst):
            if i+1 < N and lst[i] == lst[i+1]:
                count += 1
                i += 1
            elif i+2 <= N-1 and lst[i] == lst[i+2]:
                count += 1
                i += 2
            else:
                break
        if count > maxcc:
            maxcc = count
    print(maxcc)

# cook your dish here
t = int(input())
for _ in range(t):
    N = int(input())
    lst = list(map(int, input().split()))
    maxcc = 0
    el = 0
    for j in range(N):
        i = j
        count = 0
        while i < len(lst):
            if i+1 < N and lst[i] == lst[i+1]:
                count += 1
                i += 1
            elif i+2 <= N-1 and lst[i] == lst[i+2]:
                count += 1
                i += 2
            else:
                break
        if count > maxcc:
            maxcc = count
    print(maxcc)

from sys import stdin,stdout
import math,bisect
from collections import Counter,deque,defaultdict
L=lambda:list(map(int, stdin.readline().strip().split()))
M=lambda:list(map(int, stdin.readline().strip().split()))
I=lambda:int(stdin.readline().strip())
S=lambda:stdin.readline().strip()
C=lambda:stdin.readline().strip().split()
def pr(a):return(" ".join(list(map(str,a))))
#_________________________________________________#

m = 2*pow(10,5)+1
def solve():
    n = I()
    a = L()
    b = [-1]*m
    c = [0]*m
    ans = 0
    for i in range(n):
        if b[a[i]]==-1:
            b[a[i]] = i
        elif i-b[a[i]]==1:
            b[a[i]] = i
            c[a[i]]+=1
            ans = max(ans,c[a[i]])
        elif i-b[a[i]]==2:
            b[a[i]] = i
            c[a[i]]+=1
            ans = max(ans,c[a[i]])
        else:
            b[a[i]] = i
            c[a[i]] = 0
    print(ans)
for _ in range(I()):
    solve()


# cook your dish here
# code by RAJ BHAVSAR
import sys
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
def get_string(): return sys.stdin.readline().strip()

def helper(arr,s,n):
	ans = 0
	i = s
	while(i < n):
		if(i+1<n and arr[i] == arr[i+1]):
			ans += 1
			i += 1
		else:
			if(i+2<n and arr[i] == arr[i+2]):
				ans += 1
				i += 2
			else:
				break
	return ans
	
for _ in range(int(input())):
	n = int(input())
	arr = get_list()
	ans = 0
	for i in range(n):
		ans = max(ans,helper(arr,i,n))
	print(ans)


for test in range(int(input())):
    n = int(input())
    l = list(map(int, input().split()))
    m = 0
    for i in range(0,n-1):
        m1 = 0
        j = i
        while j<(n-1):
            jd = j
            if l[jd]==l[jd + 1]:
                m1 = m1 + 1
                j = j + 1
            elif jd<(n-2) and l[jd]==l[jd + 2]:
                m1 = m1 + 1
                j = j + 2
            else:
                break
        #print(m1)
        m = max(m1, m)
    print(m)

# cook your dish here
from collections import defaultdict
for _ in range(int(input())):


    n=int(input())
    a=list(map(int,input().split()))
    d= defaultdict(lambda:-1)
    d1= defaultdict(lambda:-1)
    maxi=-1
    for i in range(len(a)):

        x=d[a[i]]
        if x!=-1 and (i-x==1 or i-x==2) :
            d1[a[i]]+=1
        else:
            d1[a[i]]=0
        d[a[i]]=i
        maxi=max(maxi,d1[a[i]])

    print(maxi)


# cook your dish here
x = int(input())
for i in range(x):
    y = int(input())
    z = list(map(int, input().strip().split(" ")))
    m = 0
    for j in range(0, len(z)):
        t = j
        c = 0
        while((t+1 < len(z) and z[t+1] == z[t]) or (t+2 < len(z) and z[t+2] == z[t])):
            if(z[t+1] == z[t]):
                t = t+1
                c = c+1
            else:
                t = t+2
                c = c+1
            if(c > m):
                m = c
    print(m)

#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
#import io,os; input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline #for pypy
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

for _ in range(inp()):
    n = inp()
    x = ip()
    dp = [0]*n
    for i in range(n):
        if (i-1)>=0 and x[i] == x[i-1]:
            dp[i] = max(dp[i],dp[i-1]+1)
        if (i-2)>=0 and x[i] == x[i-2]:
            dp[i] = max(dp[i],dp[i-2]+1)
    print(max(dp))

def solve(i):
    if c[i] != 0:
        return c[i]

    maxi = 0

    if i+1 < n and a[i+1] == a[i]: maxi = max(maxi, solve(i+1) + 1)
    if i+2 < n and a[i+2] == a[i]: maxi = max(maxi, solve(i+2) + 1)

    c[i] = maxi
    return c[i]

for _ in range(int(input())):
    n = int(input())
    a = list(map(int, input().split()))

    c = [0] * n

    for i in range(n):
        solve(i)

    print(max(c))


for _ in range(int(input())):
    n = int(input())
    arr = list(map(int, input().split()))

    if len(arr) <= 1:
        print(0)
        continue
    mx = 0
    narr = [0]
    narr.append(0 if arr[1]!=arr[0] else 1)
    for i in range(2, n):
        if arr[i-2] == arr[i] and arr[i-1] == arr[i]:
            narr.append(max(narr[-2], narr[-1])+1)
        elif arr[i-1] == arr[i]:
            narr.append(narr[-1]+1)
        elif arr[i-2] == arr[i]:
            narr.append(narr[-2]+1)
        else:
            narr.append(0)
        mx = max(mx, narr[-1])
    print(mx)