Problem:
 Score : 200 points    Problem Statement Tak performed the following action N times: rolling two dice.
The result of the i -th roll is D_{i,1} and D_{i,2} .  Check if doublets occurred at least three times in a row.
Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2} , D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.      Constraints  3 \leq N \leq 100  1\leq D_{i,j} \leq 6  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  D_{1,1}  D_{1,2}  \vdots  D_{N,1}  D_{N,2}       Output Print Yes if doublets occurred at least three times in a row. Print No otherwise.        Sample Input 1 5
1 2
6 6
4 4
3 3
3 2      Sample Output 1 Yes  From the second roll to the fourth roll, three doublets occurred in a row.       Sample Input 2 5
1 1
2 2
3 4
5 5
6 6      Sample Output 2 No       Sample Input 3 6
1 1
2 2
3 3
4 4
5 5
6 6      Sample Output 3 Yes

Solution (Python):
n = int(input())
count = 0


for i in range(0, n):
  tmp = input()
  if tmp.split()[0] == tmp.split()[1]:
    count += 1
    if count == 3:
        break
  else:
    count = 0


if count == 3:
  print('Yes')
else:
  print('No')

Solution (Python):
n = int(input())
d1 = [0] * n
d2 = [0] * n
for i in range(n):
  d1[i], d2[i] = (map(int, input().split()))
cnt = 0

for i in range(n):
  if d1[i] == d2[i]:
    cnt += 1
  else:
    cnt = 0
  if cnt >= 3:
    break

if cnt >= 3:
  print("Yes")
else:
  print("No")

Solution (Python):
N = int(input())
D = []
for i in range(N):
    D.append(list(map(int,input().split())))
ans = 0
for i in range(N-2):
    if D[i][0]==D[i][1] and D[i+1][0]==D[i+1][1] and D[i+2][0] ==D[i+2][1]:
        ans = 1
if ans == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
cnt = 0
for i in range(n):
    a,b = map(int,input().split())
    if a==b:
        cnt += 1
    else:
        cnt = 0
    if cnt >=3:
        print("Yes")
        exit()
print("No")

Solution (Python):


import math

import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd


n=int(input())
cnt=0
for i in range(n):
    x,y=map(int,input().split())
    if x==y:
        cnt+=1
    else:
        cnt=0
    if cnt>=3:
        print("Yes")
        break
else:
    print("No")

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush

sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
D = inplt(n)

cnt = 0
ans = 'No'
for d1,d2 in D:
    if d1 == d2:
       cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        ans = 'Yes'

print(ans)

Solution (Python):
n = int(input())
lis_d = [list(map(int, input().split())) for _ in range(n)]

for i in range(n-2):
  if lis_d[i][0] == lis_d[i][1] and lis_d[i+1][0] == lis_d[i+1][1] and lis_d[i+2][0] == lis_d[i+2][1]:
    print("Yes")
    exit()

print("No")

Solution (Python):
N = int(input())
c = 0

for _ in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        c += 1
        if c == 3:
            print('Yes')
            exit()
    else:
        c = 0
print('No')

Solution (Python):
N = int(input())
Di = 0
Di1 = []
Di2 = []
nmDi = 0
if N >= 3 and N <= 100:
   for x in range(N):
      Di = input()
      Di1.append(Di[0])
      Di2.append(Di[-1])
   for x in range(N):
      if Di1[x] == Di2[x]:
         nmDi += 1
         if nmDi == 3:
            break
      elif Di1[x] != Di2[x] and nmDi > 0:
         nmDi = 0
   if nmDi >= 3:
      print("Yes")
   else:
      print("No")
else:
   print ("No")

Solution (Python):
n=int(input())
ct=0
for i in range(n):
  a,b=map(int,input().split())
  if a==b:
    ct+=1
    if ct==3:
      print("Yes")
      break
  else:
    ct=0
else:
  print("No")

Solution (Python):
a = int(input())
count = 0
for i in range(a):
    x,y = map(int,input().split(" "))
    if x == y:
        count += 1
    else:
        count = 0
    if count == 3:
        print('Yes')
        exit()
print("No")

Solution (Python):
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

flag = False
cnt = 0

for i in range(len(D)):
    if D[i][0] == D[i][1]:
        cnt += 1
        if cnt == 3:
            flag = True
    else:
        cnt = 0

print('Yes' if flag else 'No')

Solution (Python):

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

ok = False
for i in range(N - 2):
    ok |= ((X[i][0] == X[i][1]) and ((X[i + 1][0] == X[i + 1][1]))
           and (X[i + 2][0] == X[i + 2][1]))

if ok:
    print("Yes")
else:
    print("No")

Solution (Python):
n  = int(input())

ren = 0

for i in range(n):

     a, b = (int(x) for x in input().split())

     if a == b:
        ren += 1 

     elif ren >= 3:
         continue
    
     else: 
        ren = 0

if ren >= 3:
    print("Yes")
    
else:
    print("No")

Solution (Python):
N = int(input())
count=0
result="No"
for _ in range(N):
  x,y=map(int,input().split())
  if x==y:
    count+=1
    if count==3:
      result="Yes"
  else:
    count=0
print(result)

Solution (Python):
N = int(input())
res = 0
cnt = 0
for i in range(N):
    D = input().split()
    if D[0] == D[1]:
        cnt += 1
        if cnt == 3:
            res += 1
            cnt = 0
    else:
        cnt = 0
if res > 0:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
D = []
count = 0

for i in range(N):
  d = list(map(int,input().split()))
  D.append(d)
  
for i in range(N-2):
  if (D[i][0]==D[i][1]) and (D[i+1][0]==D[i+1][1]) and (D[i+2][0]==D[i+2][1]):
    print("Yes")
    break
else:
  print("No")

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    D = []
    zoro = 0
    ans = 0
    for _ in range(N):
        d1, d2 = LI()
        if d1 == d2:
            zoro += 1
            ans = max(ans, zoro)
        else:
            zoro = 0
    if ans >= 3:
        print("Yes")
    else:
        print("No")



main()

Solution (Python):
N = int(input())
flag = 'No'
cnt = 0
for i in range(N):
  d1, d2 = map(int, input().split())
  if d1 == d2:
    cnt += 1
    if cnt == 3:
      flag = 'Yes'
  else:
    cnt = 0
print(flag)

Solution (Python):
n = int(input())
c = 0
m = 0
for x in range(n):
    a, b = input().split()
    if a==b:
        c += 1
    else:
        c = 0
    m = max(m, c)
if m >= 3:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
d = [list(map(int,input().split())) for i in range(n)]
count = 0



for i in d:
  if i[0] == i[1]:
    count += 1
  else:
    count = 0
  if count == 3:
    print('Yes')
    exit()
print('No')

Solution (Python):
N=int(input())
f=0
for i in range(N):
    a,b=map(int,input().split())
    if a==b:
        f+=1
    else:
        f=0
    
    if f==3:
        print('Yes')
        break
else:
    print('No')

Solution (Python):
N = int(input())
flag = 0
ans = "No"

for i in range(N):
  tmp1, tmp2 = list(map(int, input().split()))
  if tmp1 - tmp2 == 0:
    flag += 1
  else:
    flag = 0
  if ans == "Yes" or flag >= 3:
    ans = "Yes"
print(ans)

Solution (Python):
n = int(input())
count = 0
checker = 0
while count<n:
    d1,d2 = list(map(int, input().split()))
    count += 1
    if d1==d2:
        checker += 1
        if checker ==3:
            print("Yes")
            exit()
    else:
        checker = 0
print("No")

Solution (Python):
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
s=[]
for i in range(n):
  if l[i][0]==l[i][1]:
    s.append(1)
  else:
    s.append(0)
g=[]
for i in range(n-2):
  g.append(s[i]*s[i+1]*s[i+2])
ok=0
for i in range(n-2):
  if g[i]==1:
    ok=1
    break
if ok==1:
  print("Yes")
else:
  print("No")

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = [inpl() for _ in range(n)]
a = [x == y for x,y in a]
res = False
for i in range(n-2):
    if sum(a[i:i+3]) == 3:
        res = True
print('Yes' if res else 'No')

Solution (Python):
n = int(input())
cnt = 0
for i in range(n):
    a,b = map(int,input().split())
    if a == b:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        print("Yes")
        exit()
print("No")

Solution (Python):
n = int(input())

ans = 0
flag = 0

for i in range(0, n):
    x, y = input().split()
    if x == y:
        ans = ans + 1
    else:
        ans = 0
    if ans >= 3:
        flag = 1
if flag == 1:
    print("Yes")
else :
    print("No")

Solution (Python):
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

N = INT()
cnt = 0

for _ in range(N):
    D1, D2 = MI()
    
    if D1 == D2:
        cnt += 1
    else:
        cnt = 0
    
    if cnt == 3:
        print("Yes")
        exit()
    
print("No")

Solution (Python):
def main():
    n = int(input())
    dss = [list(map(int, input().split())) for _ in range(n)]

    ans = "No"
    Count = 0
    for ds in dss:
        if ds[0] == ds[1]:
            Count += 1
        else:
            Count = 0
        if Count == 3:
            ans = "Yes"

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
zoro = 0
ans = 'No'
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        zoro += 1
    else:
        zoro = 0

    if zoro == 3:
        ans = 'Yes'
        break

print(ans)

Solution (Python):
N = int(input())
D = [tuple(map(int, input().split())) for _ in range(N)]
cnt = 0
for d1, d2 in D:
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print('Yes')
        exit()
print('No')

Solution (Python):
n = int(input())
cnt = 0
a = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
    if a[i][0] == a[i][1]:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print('Yes')
        exit()
print('No')

Solution (Python):
n = int(input())
cnt = 0
is_ok = False
for _ in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        is_ok = True
    else:
        pass
if is_ok:
    print('Yes')
else:
    print('No')

Solution (Python):
N=int(input())
cnt=0
ans="No"
for i in range(N):
  x,y=input().split()
  if x==y:
    cnt=cnt+1
  else:
    cnt=0
  if cnt>=3:
    ans="Yes"
print(ans)

Solution (Python):
N = int(input())
d = [0] * N
c = 0
b = True
for i in range(N):
  d[i] = list(map(int, input().split()))
  if d[i][0] == d[i][1]:
    c += 1
    b = True
  else:
    c = 0
    b = False
  if c == 3:
    break
if c == 3:
  print("Yes")
else:
  print("No")

Solution (Python):
n=int(input())
count=0
for i in range(n):
    x,y = map(int,input().split())
    if x==y:
        count+=1
    else:
        count=0
    if count==3:
        print('Yes')
        exit()
print('No')

Solution (Python):
N=int(input())
A=[]
for i in range(N):
    D=list(map(int,input().split()))
    A.append(D)
    
for i in range(N-2):
    if A[i][0]==A[i][1] and A[i+1][0]==A[i+1][1] and A[i+2][0]==A[i+2][1]:
        print('Yes')
        break
else:
    print('No')

Solution (Python):
n = int(input())
count = 0
for i in range(n):
  d1, d2 = map(int, input().split())
  if count > 2:
    break
  else:
    if d1 == d2:
      count += 1
    else:
      count = 0
if count > 2:
  print("Yes")
else:
  print("No")

Solution (Python):
n = int(input())
a = [[int(i) for i in input().split()] for j in range(n)]
good = False
for i in range(n-2):
  ok = True
  for j in range(i, i+3):
    ok &= a[j][0] == a[j][1]
  good |= ok
print("Yes" if good else "No")

Solution (Python):
n=int(input())
rec=[False]*n
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        rec[i]=True
for i in range(n-2):
    if rec[i] and rec[i+1] and rec[i+2]:
        print("Yes")
        exit()
print("No")

Solution (Python):
def input_array():
	return list(map(int,input().split()))
  
n=int(input())
D=[input_array() for i in range(n)]

count=0
for d in D:
	if d[0]==d[1]:
		count+=1
	else:
		count=0

	if count==3:
		break
if count==3:
	print("Yes")
else:
	print("No")

Solution (Python):
n=int(input())
l=[]
for _ in range(n):
  s=input().split()
  l.append([int(s[0]),int(s[1])])
flag=0
for i in range(2,n):
  if l[i][0]==l[i][1] and l[i-1][0]==l[i-1][1] and l[i-2][0]==l[i-2][1]:
    flag=1
    break
if flag:
  print("Yes")
else:
  print("No")

Solution (Python):
N = int(input())
count = 0
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        count += 1
    else:
        count = 0
    if count == 3:
        print('Yes')
        break
    if i == N-1:
        print('No')

Solution (Python):
n = int(input())
cnt = 0
flg = False
for i in range(n):
    a,b = map(int,input().split())
    if a == b:
        cnt += 1
        if cnt == 3:
            flg = True    
    else:
        cnt = 0
if flg:
    print('Yes')
else:
    print('No')

Solution (Python):
t=int(input())
count = 0
flag = False
for test in range(t):
    a,b = map(int,input().split())
    if a==b:
    	count+=1
    	if count==3:
    		flag=True
    else:
    	count=0

if flag:
	print("Yes")
else:
	print("No")

Solution (Python):
N=int(input())
D=[map(int, input().split()) for i in range(N)]
x, y = [list(i) for i in zip(*D)]

s=0
l=[]
for i in range(N):
  if x[i]==y[i]:
    s+=1
    if i==N-1:
      l.append(s)
  elif x[i]!=y[i]:
    l.append(s)
    s=0

if max(l)>=3:
  print("Yes")
else:
  print("No")

Solution (Python):
n = int(input())
count = 0
for i in range(n):
    a,b = map(int,input().split())
    if count >2 :
        break
    elif a==b:
        count += 1
    else:
        count = 0
print('Yes' if count > 2 else 'No')

Solution (Python):
N = int(input())

c = 0
for _ in range(N):
    if len(set(input().split())) == 1:
        c += 1
        if 3 <= c:
            print("Yes")
            exit()
    else:
        c = 0
else:
    print("No")

Solution (Python):
N = int(input())
 
cnt = 0
ans = 'No'
for i in range(N):
	D1, D2 = map(int, input().split())
	if D1 == D2:
		cnt += 1
	else:
		cnt = 0
   
	if cnt > 2:
		ans = 'Yes'
		break
      
print(ans)

Solution (Python):
N,*D=map(int,open(0).read().split())
def main():
    cnt=0
    for i in range(0,N*2,2):
        n1=D[i]
        n2=D[i+1]
        if n1==n2:
            cnt+=1
            if cnt>=3:
                return True
        else:
            cnt=0
    return False
if main():
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
result = 'No'
count = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        count += 1
        if count == 3:
            result = 'Yes'
            break
    else:
        count = 0

print (result)

Solution (Python):
n = int(input())
d = [list(input().split()) for _ in range(n)]

c = 0

for i in range(n):
    if d[i][0] == d[i][1]:
        c += 1
    else:
        c = 0
    if c == 3:
        break

if c == 3:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
count = 0
ans = 'No'
for i in range(n):
  a,b = map(int, input().split())
  if a == b:
    count += 1
  else:
    count = 0
  if count >= 3:
    ans = 'Yes'
    break
print(ans)

Solution (Python):
n = int(input())
count = 0

for i in range(n):
    d1,d2 = map(int,input().split())
    if(d1 == d2):
        count += 1
    else:
        count = 0
    if(count == 3):
        print("Yes")
        exit()
print("No")

Solution (Python):
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

flag = 0
count = 0

for i in range(N):
    if D[i][0] == D[i][1]:
        count += 1
    else:
        count = 0
    if count >= 3:
        flag = 1
        break

if flag == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
N=int(input())
D=[]
TF=[]
for i in range(N):
    Input=list(map(int,input().split()))
    D.append(Input)
    if D[i][0]==D[i][1]:
        TF.append(1)
    else:
        TF.append(0)
TF.append(0)
TF.append(0)
Q=[]
for i in range(N):
    temp=TF[i]+TF[i+1]+TF[i+2]
    Q.append(temp)
if max(Q)==3:
    print("Yes")
else:
    print("No")

Solution (Python):

count = int(input())

zorome = 0

for i in range(0, count):
  dice1, dice2 = input().split()

  
  if zorome == 3:
    break

  if dice1 == dice2:
    zorome += 1
  else:
    zorome = 0
  
if zorome == 3:
  print("Yes")
else:
  print("No")

Solution (Python):

import sys
from math import factorial

MOD = 10 ** 9 + 7
INF = 10000000000


def main():
    
    n = int(input())    

    
    x = n
    dList = [list(map(int, input().split())) for _ in range(x)]     

    
    flg = 1
    for i in range(n-2):
        if dList[i][0] == dList[i][1]:
            if dList[i+1][0] == dList[i+1][1]:
                if dList[i+2][0] == dList[i+2][1]:
                    flg = 0

    
    if flg == 0:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input().rstrip())
cnt = 0
flg = False
d_list = [[0, 0] for i in range(n)]
for i in range(n):
  d_list[i] = list(map(int, input().rstrip().split(" ")))
for ds in d_list:
  if ds[0] == ds[1]:
    cnt += 1
  else:
    cnt = 0
  if cnt >= 3:
    flg = True
    break
if flg:
  print("Yes")
else:
  print("No")

Solution (Python):
def LI():
    return list(map(int, input().split()))


N = int(input())
count = 0
ans = "No"
for i in range(N):
    a, b = LI()
    if a == b:
        count += 1
        if count == 3:
            ans = "Yes"
            break
    else:
        count = 0
print(ans)

Solution (Python):
n = int(input())
x = [list(map(int, input().split())) for i in range(n)]

for i in range(n-2):
    if x[i][0] == x[i][1] and x[i+1][0] == x[i+1][1] and x[i+2][0] == x[i+2][1]:
        print("Yes")
        exit()
print("No")

Solution (Python):
class Main:
    n = int(input())
    num_list =[]
    count = 0
    for i in range(n):
        num_list.append(list(map(int,input().split())))

    for i in range(n-2):
        if num_list[i][0]==num_list[i][1] and num_list[i+1][0]==num_list[i+1][1] and num_list[i+2][0]==num_list[i+2][1]:
            count +=1

    if count >= 1:
        print('Yes')
    else :
        print('No')

Solution (Python):
def main():
    N = int(input())
    cnt = 0
    for _ in range(N):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        if cnt >= 3:
            print("Yes")
            return
    print("No")


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
D=[list(map(int,input().split())) for _ in range(n)]

cnt=0
for a,b in D:
    if a==b:cnt +=1
    else:cnt=0

    if cnt==3:print("Yes");exit()
print("No")

Solution (Python):
N = int(input())

D = []
for _ in range(N):
        D.append([int(x) for x in input().split()])

count = 0
for i in range(N):
        if(D[i][0] == D[i][1]):
                count +=1
                if(count == 3):
                        break
        else:
                count = 0

if(count == 3):
        print('Yes')
else:
        print('No')

Solution (Python):
n = int(input())
f = 0
L = []
for i in range(n):
	a,b = map(int, input().split())
	L.append([a,b])
for i in range(2,n):
	if(L[i-2][0] == L[i-2][1] and L[i-1][0] == L[i-1][1] and L[i][0] == L[i][1]):
		f = 1
		break
if(f):
	print('Yes')
else:
	print('No')

Solution (Python):
def func(D):
  comb = 0
  for item in D:
    if item[0]==item[1]:
      comb+=1
    else:
      comb=0
    
    if comb==3:
      return "Yes"  
  return "No"

if __name__ == "__main__":
    N = int(input())
    D = [list(map(int, input().split())) for _ in range(N)]
    print(func(D))

Solution (Python):
n = int(input())
count = 0
for i in range(n):
    d1, d2 = input().split()
    if d1 == d2:
        count += 1
    else:
        count = 0
    if count == 3:
        print("Yes")
        exit()
print("No")

Solution (Python):
N = int(input())

result = False
count = 0

for i in range(N):
    D1,D2 = map(int,input().split())
    if D1 == D2:
        count += 1
    else:
        count = 0

    if count > 2:
        result = True
        break

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

Solution (Python):
N = int(input())
zoro_count = 0
zoro = False
for n in range(N):
  dn1,dn2 = map(int, input().split())
  if dn1 == dn2:
    zoro_count += 1
  else:
    zoro_count = 0
  if zoro_count >= 3:
    zoro = True
if zoro:
  print('Yes')
else:
  print('No')

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))
def In(x,a): 
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n = onem()

co = 0
for i in range(n):
    a,b = m()
    if a == b:
        co += 1
        if co >= 3:
            print("Yes")
            exit()
    else:
        co = 0
print("No")

Solution (Python):
N = int(input())
D = [list(map(int, input().split())) for i in range(N)]

seq = 0

for i in range(N):
  if D[i][0] == D[i][1]:
    seq += 1
    if seq == 3:
      print('Yes')
      break
  else:
    seq = 0
else:
  print('No')

Solution (Python):
N=int(input())
d=[0]*N;D=[0]*N
s=0
for i in range(N):
  d[i],D[i]=map(int,input().split())
  if d[i]==D[i]:s+=1
  else:s=0
  if s==3:
    print('Yes')
    exit()
    
print('No')

Solution (Python):
N = int(input())
cnt = 0
for _ in range(N):
    a, b = map(int, input().split())
    if a == b:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print('Yes')
        exit()
print('No')

Solution (Python):
n = int(input())
d = [input().split() for _ in range(n)]
if any(i[0]==i[1] and j[0]==j[1] and k[0]==k[1] for i, j, k in zip(d, d[1:], d[2:])):
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
a = 0
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1==D2:
        a += 1
    else:
        a = 0
    if a == 3:
        print("")
        print("Yes")
        break
    if i == N-1 and a != 3:
        print("No")

Solution (Python):
n = int(input())
check = []
ans = 0
for _ in range(n):
    n1, n2 = map(int, input().split())
    if n1 == n2:
        check.append(1)
    else:
        check.append(0)

for i in range(n-1):
    if sum(check[i:i+3])==3:
        ans = 1
        break
if ans:
    print("Yes")
else:
    print("No")

Solution (Python):
N=int(input())
count=0
a=0
for i in range(N):
    D=list(map(int,input().split()))
    if D[0]==D[1]:
        count+=1
        if count>=3:
            a=1
            break
    else:
        count=0
if a==1:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
ans = 0
D = []

for i in range(N):
    d1, d2 = map(int, input().split())
    D.append([d1,d2])

for i in range(N-2):
    if D[i][0] == D[i][1]:
        if D[i+1][0] == D[i+1][1]:
            if D[i+2][0] == D[i+2][1]:
                ans = 1

if ans:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
cnt = 0
ans = "No"
for i in range(N):
    D = list(map(int, input().split()))
    if D[0] == D[1]:
        cnt += 1
        if cnt >= 3:
            ans = "Yes"
            continue
    else:
        cnt = 0
print(ans)

Solution (Python):
n = int(input())
count = 0

for _ in range(n):
  d1, d2 = map(int, input().split())
  if d1 == d2:
    count += 1
    if count >= 3:
      print("Yes")
      exit()
  else:
     count = 0
print("No")

Solution (Python):
n = int(input())
a = []

for _ in range(n):
  aa, b = map(int,input().split())
  if aa == b:
    a.append("1")
  else:
    a.append("0")
if "111" in "".join(a):
  print("Yes")
else:
  print("No")

Solution (Python):
n=int(input())
cnt=0
ans=0
for i in range(n):
  d1,d2=map(int,input().split())
  if d1==d2:
    cnt=cnt+1
    ans=max(ans,cnt)
  else:
    cnt=0
if ans>=3:
  print("Yes")
else:
  print("No")

Solution (Python):
n=int(input())
c=0
z='No'
for i in range(n):
  x,y=map(int,input().split())
  if x==y:
    c+=1
  else:
    c=0
  if c==3:
    z='Yes'
    break
print(z)

Solution (Python):
n = int(input())

cnt = 0
for _ in range(n):
    a,b = map(int, input().split())
    if a==b:
        cnt += 1
    else:
        cnt = 0
    
    if cnt >= 3:
        print('Yes')
        exit()

print('No')

Solution (Python):
n = int(input())
num_lis = [list(map(int, input().split())) for i in range(n)]
c = 0

for i,j in num_lis:
  if c == 3:
    break
  if i == j:
    c += 1
  else:
    c = 0

if c == 3:
  print("Yes")
else:
  print("No")

Solution (Python):
n = int(input())
x, y = [], []
for i in range(n):
  x_, y_ = map(int, input().split())
  x.append(x_)
  y.append(y_)
for i in range(n-2):
  if x[i]==y[i] and x[i+1]==y[i+1] and x[i+2]==y[i+2]:
    print("Yes")
    break
else:
  print("No")

Solution (Python):
counter = int(input())
result_flg = False

fir_fir, fir_sec = map(int, input().split())
sec_fir, sec_sec = map(int, input().split())


for i in range(2, counter):
  thi_fir, thi_sec = map(int, input().split())

  if fir_fir == fir_sec:
    if sec_fir == sec_sec:
      if thi_fir == thi_sec:
        result_flg = True
        break

  
  fir_fir = sec_fir
  fir_sec = sec_sec
  sec_fir = thi_fir
  sec_sec = thi_sec

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
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()
D = [len(set(LIST()))==1 for _ in range(N)]
for i in range(N):
    if sum(D[i:i+3]) == 3:
        print("Yes")
        break
else:
    print("No")

Solution (Python):
n = int(input())

count = 0
ans = 0
for i in range(n):
    s = input().split()
    
    if s[0]==s[1]:
        count += 1
    else:
        count = 0
        
    if count ==3:
        print('Yes')
        exit(0)

else:
    print('No')

Solution (Python):
n = int(input())
answer = 0
for i in range(n):
    x, y = input().split()
    if x == y:
        answer = answer + 1
    else:
        answer = 0
    if answer == 3:
        print('Yes')
        exit(0)
else:
    print('No')

Solution (Python):
ans = 0
s = []
for i in range(int(input())):
  a,b = map(int,input().split())
  if a==b:
    ans += 1
    s.append(ans)
  else:
    ans = 0
if len(s)!=0 and max(s)>=3:
  print('Yes')
elif len(s)==0:
  print('No')
else:
  print('No')

Solution (Python):
N = int(input())
count = 0
for i in range(N):
  n,m = input().split(' ')
  if n == m :
    count += 1
    if count >= 3:
      break
  else:
    count = 0
if count >= 3:
  print('Yes')
else :
  print('No')

Solution (Python):
def judge():
    cnt = 0  
    for _ in range(N):
        x, y = map(int, input().split())
        if x == y:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            return True
    return False

N = int(input())

if judge():  
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
conti = False
for d in D:
    if d[0] == d[1]:
        cnt += 1
        conti = True
    else:
        cnt = 0
        conti = False
    if cnt == 3:
        break
if cnt == 3:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
D = []
count, temp = 0, 0

for n in range(N):
    input_line = input().split()
    if (int(input_line[0]) == int(input_line[1])):
        count += 1
        if count == 3:
            temp = 1
    elif(temp ==1):
        break
    else:
        count = 0

if count >= 3:
        print('Yes')

else:
        print('No')

Solution (Python):
N = int(input())
ans = 'No'
count =0
for i in range(N):
    d1,d2 = list(map(int,input().split()))
    if d1!=d2:
        count =0
    else:
        count +=1
    if count == 3:
        ans = 'Yes'
        break
print(ans)

Solution (Python):
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())


n=int(input())
ar=[]
for i in range(n):
    a,b=sep()
    if a==b:
        ar.append(1)
    else:
        ar.append(0)


for i in range(2,n):
    if ar[i]==1 and ar[i-1]==1 and ar[i-2]==1:
        print("Yes")
        quit()
print("No")