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):
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    res = 0
    for i in range(N):
        a,b = MI()
        if a==b:
            res+=1
            if res==3:
                print("Yes")
                exit()
        else:
            res=0
    print("No")
    
if __name__ == "__main__":
    main()

Solution (Python):
cnt = int(input())
chain = 0
first = 0
second = 0

for i in range(cnt):
    nList = list(map(int, input().split()))
    first = nList.pop()
    second = nList.pop()
    if first == second:
        chain = chain + 1
        if chain >= 3:
            break
    else:
        chain = 0

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

Solution (Python):
N = int(input())
check = [0, 0, 0]
for i in range(N):
  str = input().split()
  check[i%3] = 1 if str[0] == str[1] else 0
  if sum(check) == 3:
    break
print('Yes') if sum(check) == 3 else print('No')

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

cnt = 0
ans = 'No'

for _ in range(N):
    D = input().split()
    cnt = (cnt + 1)*(D[0] == D[1])
    if cnt == 3:
        ans = 'Yes'

print(ans)

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):
n = int(input())
lst = []
for i in range(n):
	lst.append(list(map(int,input().split())))

cnt = 0

for i in range(n):
	if lst[i][0]==lst[i][1]:
		cnt += 1
	else:
		cnt = 0
	if cnt == 3:
		print('Yes')
		exit()
print('No')

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

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

ans = 'No'
cnt = 0
for x1, x2 in X:
    if x1 == x2:
        cnt += 1
        if cnt == 3:
            ans = 'Yes'
            break
    else:
        cnt = 0

print(ans)

Solution (Python):
n=int(input())
q=[]
for _ in range(n):
    d_1,d_2=map(int,input().split())
    if d_1==d_2:
        q.append(1)
    else:
        q.append(0)
for i in range(n-2):
    if q[i]==q[i+1]==q[i+2]==1:
        print("Yes")
        exit()
print("No")

Solution (Python):
def solve():
  N = int(input())
  lines = [input().split() for i in range(N)]
  count = 0
  for d,e in lines:
    if d==e:
      count += 1
      if count>=3:
        print("Yes")
        return
    else:
      count = 0
  print("No")
  return

solve()

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

ans = 0
ck = 0

for i in range(n):
  if p[i][0] == p[i][1]:
    ans += 1
    if ans == 3:
      ck = 1
      print("Yes")
      break
  else:
    ans = 0
    
if ck == 0:
  print("No")

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

d = []

for i in range(n):
	d.append(list(map(int,input().split())))

cnt = 0
flag = 0

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

	if cnt == 3:
		flag = 1

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

Solution (Python):
n=int(input())
a=[]
for i in range(n):
    x,y=map(int,input().split())
    a.append((x,y))
ok=False
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]:
        ok=True
if ok:
    print("Yes")
else:
    print("No")

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, 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, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
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 TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6
mod = 10 ** 9 + 7 





N = INT()
D = [LIST() for _ in range(N)]

cnt = 0
for x, y in D:
	if x == y:
		cnt += 1
		if cnt == 3:
			print("Yes")
			break
	else:
		cnt = 0
else:
	print("No")

Solution (Python):
n = int(input())
lst =  []
stimmt = False
for _ in range(n):
    lst.append(list(map(str,input().split())))
for i in range(len(lst)):
    if lst[i][0] == lst[i][1]:
        if i+2 < len(lst):
            if lst[i+1][0] == lst[i+1][1] and lst[i+2][0] == lst[i+2][1]:
                stimmt = True
                break
 
if stimmt:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
D = [tuple(map(int, input().split())) for _ in range(N)]
for i in range(N-2):
	if all(D[j][0] == D[j][1] for j in range(i, i+3)):
		print('Yes')
		break
else:
	print('No')

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

Solution (Python):
n = int(input())
data = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(1, n-1):
    if data[i][0] == data[i][1] and data[i-1][0] == data[i-1][1] and data[i+1][0] == data[i+1][1]:
        print("Yes")
        exit()

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')
        exit()


print('No')

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

x = 0
for i in range(N):
    a, b = map(int, input().split())
    if a == b:
        x += 1
    else:
        x = 0

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

Solution (Python):
from sys import stdin

n=int(input())
count = 0

output = 'No'

for i in range(n):
  temp = stdin.readline().split()
  if temp[0] == temp[1]:
    if count == 2:
      output = 'Yes'
      break;
    elif count == 1:
      count = 2
    elif count == 0:
      count = 1
  else:
  	count = 0
    
print(output)

Solution (Python):
n=int(input())
count=0
maxs=0
for _ in range(n):
    d1,d2=map(int,input().split())
    if d1==d2:
        count+=1
    else:
        maxs=max(maxs,count)
        count=0

maxs=max(count,maxs)
if maxs>=3:
    print("Yes")
else:
    print("No")

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

Solution (Python):
n = int(input())
data = [input().split() for i in range(n)]
for i in range(n - 2):
    if int(data[i][0]) == int(data[i][1]) and int(data[i + 1][0]) == int(data[i+1][1]) and int(data[i+2][0]) == int(data[i+2][1]):
        print('Yes')
        break
else:
    print('No')

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

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

Solution (Python):
import sys
N =int(input())
D = []
for i in range(N):
  d_1,d_2 = map(int,input().split())
  D.append([d_1,d_2])
for x in range(N-2):
  if D[x][0]==D[x][1] and D[x+1][1]==D[x+1][0] and D[x+2][1]==D[x+2][0]:
    print("Yes")
    sys.exit()
print("No")

Solution (Python):
it = lambda: list(map(int, input().strip().split()))


def solve():
    n = int(input())
    F = [0] * n
    S = [0] * n
    for i in range(n):
        a, b = it()
        F[i] = a
        S[i] = b
    
    cnt = 0
    for i in range(n):
        if F[i] == S[i]:
            cnt += 1
            if cnt == 3:
                return 'Yes'
        else:
            cnt = 0
    return 'No'


if __name__ == '__main__':
    print(solve())

Solution (Python):
n = int(input())
d = [[] for _ in range(n)]
for i in range(n):
    d[i] = list(map(int, input().split()))
counter = 0
for i in d:
    if i[0] == i[1]:
        if counter == 2:
            print("Yes")
            exit()
        else:
            counter += 1
    else:
        counter = 0
print("No")

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

Solution (Python):
import sys

def main():
    N = int(input())
    zoro = 0
    for i in range(N):
        Ds = [int(s) for s in sys.stdin.readline().split()]
        if(Ds[0] == Ds[1]):
            zoro += 1
            if(zoro > 2):
                print("Yes")
                return(0)
        else:
            zoro = 0
    print("No")

main()

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

Solution (Python):
if __name__ == '__main__':
    try:
        count = []
        result = 0
        T = int(input())
        for _ in range(T):
            x, y = map(int, input().split())
            count.append([x, y])

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

        print("No")
    except Exception:
        pass

Solution (Python):
import sys
n = int(input())
ls = [list(map(int,input().split())) for _ in range(n)]
for i in range(n-2):
    if ls[i][0] == ls[i][1]:
        if ls[i+1][0] == ls[i+1][1]:
            if ls[i+2][0] == ls[i+2][1]:
                print("Yes")
                sys.exit()
print("No")

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

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):
s=int(input())
d = [list(map(int,input().split())) for _ in range(s)]

def p(val):
    print(val)

def calc(s,d):
    for i in range(s-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]:
            
            return 'Yes'
    
    return 'No'

        
p(calc(s,d))

Solution (Python):
n = int(input())
ans = "No"
count = 0
for i in range(n):
    D1,D2 = map(int,input().split())
    count=count+1 if D1==D2 else 0
    ans="Yes"  if count>=3 else ans

print(ans)

Solution (Python):
def judge():
    count = 0
    for _ in range(x):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            count += 1
        else:
            count = 0
        
        if count == 3:
            return True

    return False

x = int(input())

if judge():
    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):
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())
D1, D2 = [], []
for i in range(N):
  li = list(map(int,input().split()))
  D1.append(li[0])
  D2.append(li[1])

for i in range(N-2):
  if D1[i]==D2[i] and D1[i+1]==D2[i+1] and D1[i+2]==D2[i+2]:
    print('Yes')
    break
else:
  print('No')

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

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

sums = 0
answer = False
for _ in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        sums += 1
    else:
        sums = 0

    if sums == 3:
        answer = True

print("Yes" if answer else "No")

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n = I()
ans = 'No'
cnt = 0
for i in range(n):
    a, b = M()
    if a == b:
        cnt += 1
        if cnt == 3:
            ans = 'Yes'
            break
    else:
        cnt = 0
print(ans)

Solution (Python):
n = int(input())
ans = "No"
j = 0
for i in range(n):
  d,dd = map(str,input().split())
  if(d==dd):
    j += 1
  else:
    j=0
  if(j>=3):
    ans = "Yes"
print(ans)

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

cnt = 0

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

print('No')

Solution (Python):
n=int(input())
m=0
l=0
for i in range(n):
  A,B=map(int,input().split())
  if (A==B):
    m+=1
  else:
    m=0
  if (m==3):
    print("Yes")
    l=1
    break

if (l==0):
  print("No")

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    N = int(readline())
    cnt = 0
    ans = -1
    for _ in range(N):
        x, y = map(int, readline().split())    
        if x == y:
            cnt += 1
            ans = max(ans, cnt)
        else:
            cnt = 0
    if ans >=3:
        print('Yes') 
    else:
        print('No')
if __name__ == '__main__':
    main()

Solution (Python):
import sys



from copy import *
from bisect import *	

from math import gcd
from itertools import permutations as prm,product
 
def eprint(*args):
    print(*args, file=sys.stderr)
zz=1
 

if zz:
	input=sys.stdin.readline
else:	
	sys.stdin=open('input.txt', 'r')
	sys.stdout=open('all.txt','w')
di=[[-1,0],[1,0],[0,1],[0,-1]]
def inc(d,c,x=1):
	d[c]=d[c]+x if c in d else x
def bo(i):
	return ord(i)-ord('A')	
def li():
	return [int(xx) for xx in input().split()]
def fli():
	return [float(x) for x in input().split()]	
def comp(a,b):
	if(a>b):
		return 2
	return 2 if a==b else 0		
def gi():	
	return [xx for xx in input().split()]
def fi():
	return int(input())
def pro(a): 
	return reduce(lambda a,b:a*b,a)		
def swap(a,i,j): 
	a[i],a[j]=a[j],a[i]	
def si():
	return list(input().rstrip())	
def mi():
	return 	map(int,input().split())			
def gh():
	sys.stdout.flush()
def isvalid(i,j):
	return 0<=i<n and 0<=j<m and a[i][j]!="."
def bo(i):
	return ord(i)-ord('a')	
def graph(n,m):
	for i in range(m):
		x,y=mi()
		a[x].append(y)
		a[y].append(x)

t=1
	

while t>0:
	t-=1
	n=fi()
	c=0
	for i in range(n):
		x,y=mi()
		if x==y:
			c+=1
		else:
			c=0
		if c==3:
			print("Yes")
			exit(0)
	print("No")

Solution (Python):
number = int(input())
list = []
count = 0
num = 0

for i in range(number):
  x, y = input().split()
  list.append(x)
  list.append(y)
 

for num in range(0,len(list)-1,2):
  if list[num] == list[num+1]:
    count += 1
    if count == 3:
      break
  else:
    count = 0 

if count < 3:
  print("No")
else:
  print("Yes")

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

Solution (Python):
import sys

N = int(input())

p = 0

for i in range(N):
    A,B = list(map(int, input().split()))

    if A == B:
        p += 1
    else:
        p = 0

    if p == 3:
        print("Yes")
        sys.exit()

print("No")

Solution (Python):
import sys
import os
import math
import bisect
import itertools
import collections
import heapq
import queue
import array







sys.setrecursionlimit(10000000)


def ii(): return int(sys.stdin.buffer.readline().rstrip())
def il(): return list(map(int, sys.stdin.buffer.readline().split()))
def fl(): return list(map(float, sys.stdin.buffer.readline().split()))
def iln(n): return [int(sys.stdin.buffer.readline().rstrip())
                    for _ in range(n)]


def iss(): return sys.stdin.buffer.readline().decode().rstrip()
def sl(): return list(map(str, sys.stdin.buffer.readline().decode().split()))
def isn(n): return [sys.stdin.buffer.readline().decode().rstrip()
                    for _ in range(n)]


def lcm(x, y): return (x * y) // math.gcd(x, y)


MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    D = [il() for _ in range(N)]
    for i in range(N - 2):
        for j in range(i, i + 3):
            if D[j][0] != D[j][1]:
                break
        else:
            print('Yes')
            exit()
    else:
        print('No')


if __name__ == '__main__':
    main()

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

Solution (Python):
n = int(input())
d = [list(map(int,input().split())) for i in range(n)]
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')
        exit()
print('No')

Solution (Python):
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

def lcm(a, b):  
    return (a*b)/gcd(a, b)

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()



N = In.int()

ct = 0
ok = False

for _ in range(N):
    d0, d1 = In.ints()

    if d0==d1:
        ct+=1
        if ct==3:
            ok=True
            break
    else:
        ct=0

if ok:
    Out.str("Yes")
else:
    Out.str("No")



if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Solution (Python):





N = int(input())


flag1 = False
flag2 = False
flag3 = False
c, d = map(int, input().split())
if c == d:
	flag1 = True
c, d = map(int, input().split())
if c == d:
	flag2 = True
c, d = map(int, input().split())
if c == d:
	flag3 = True

k = 3
while k < N:
	if flag1 and flag2 and flag3:
		break
	k += 1
	c, d = map(int, input().split())
	flag1 = flag2
	flag2 = flag3
	if c == d:
		flag3 = True
	else:
		flag3 = False
		




if flag1 and flag2 and flag3:
	print('Yes')
else:
	print('No')

Solution (Python):
import sys
input = sys.stdin.readline

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

def main():
    mod=10**9+7
    N=I()
    cnt=0
    flag=0
    for _ in range(N):
        a,b=MI()
        if a==b:
            cnt+=1
        else:
            cnt=0
            
        if cnt==3:
            flag=1
            break
        
    if flag==1:
        print("Yes")
    else:
        print("No")

main()

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

D = [] * n

for i in range(n):
    D.append(list(map(int, input().split())))

ans = 'No'

for i in range(0, 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 = 'Yes'
        break

print(ans)

Solution (Python):

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

for i in range(n):
    if d1[i] == d2[i]:
        cnt += 1
    else:
        cnt = 0
    
    if cnt == 3:
        print("Yes")
        exit()
print("No")

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

Solution (Python):
n = int(input())
d = []
z = 0

for i in range(n):
  d1, d2 = map(int, input().split())
  z = z+1 if d1==d2 else 0
  d.append(z)

ans = 'Yes' if max(d)>=3 else 'No'
print(ans)

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

counter = 0
for d1, d2 in C:
    if d1 == d2:
        counter += 1
    else:
        counter = 0

    if counter == 3:
        print('Yes')
        exit()
print('No')

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

ans = "No"
for i in range(n - 2):
    bl = True
    for j in range(3):
        bl = bl and (d[i+j][0] == d[i+j][1])

    if bl:
        ans = "Yes"

print(ans)

Solution (Python):
N = int(input())
D = [[int(i) for i in input().split()] for j in range(N)]
count = 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]):
    count += 1
if(count >= 1):
  print("Yes")
else:
  print("No")

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

cnt = 0
l = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
    d1,d2 = l[i][0],l[i][1]
    if(d1==d2):
        cnt += 1
    else:
        cnt = 0
    if(cnt == 3):
        print('Yes')
        exit()

print('No')

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

Solution (Python):
if __name__ == '__main__':
    N = int(input())
    D = [input() for i in range(N)]    
    
    for i in range(2,N):
        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
        if i == N-1:
            print('No')

Solution (Python):
import math
t = 1
for tc in range(t):
    n = int(input())
    arr =  []
    for i in range(n):
        lst = list(map(int, input().split()))
        
        arr.append(lst)
        
    
    ans = False
    for i in range(n-2):
        if arr[i][0] == arr[i][1] and arr[i+1][0] == arr[i+1][1] and arr[i+2][0] == arr[i+2][1] :
            ans = True
            break
    if ans == True:
        print("Yes")
    else:
        print("No")

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

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

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

Solution (Python):
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]
def zoro(items):
    return items[0] == items[1]
for a, b, c in zip(d[:], d[1:], d[2:]):
    if zoro(a) and zoro(b) and zoro(c):
        print('Yes')
        exit(0)
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())

for i in range(n-2):
    if d1[i] == d2[i] and d1[i+1] == d2[i+1] and d1[i+2] == d2[i+2]:
        print('Yes')
        break
else:
    print('No')

Solution (Python):
N = int(input())
f = 0
for k in range(N):
    A, B = map(int,input().split())
    if A == B:
        f += 1
        if f == 3:
            print("Yes")
            exit(0)
    else:
        f = 0
print("No")

Solution (Python):
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")
    break
else:
  print("No")

Solution (Python):
n=int(input())
lis=[]
count=0
high=0
for _ in range(n):
  lis.append(input().split())
lis.append([5,6])  
for i in range(n+1):
  if lis[i][0]==lis[i][1]:
    count+=1
  else:
    if count>=high:
      high=count
    count=0
    
if high>=3:
  print("Yes")
else:
  print("No")

Solution (Python):

from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")


def solve():
    n = II()
    d = LIR(n)
    i = 0
    for a, b in d:
        if a == b:
            i += 1
        else:
            i = 0
        if i == 3:
            print("Yes")
            return
    print("No")
    return



if __name__ == '__main__':
    solve()

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

cnt = 0
ans = 'No'

for i in range(0, N):
	d1, d2 = map(int, input().split())
	if d1 == d2:
		cnt += 1
	else:
		cnt = 0
	
	if cnt == 3:
		ans = 'Yes'
		break

print(ans)

Solution (Python):
n = int(input())
c = 0
for _ in range(n):
    r = [int(e) for e in input().split(" ")]
    if(r[0] == r[1]):
        c += 1
    else:
        c = 0
    if(c == 3):
        print("Yes")
        break
else:
    print("No")

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

flag = 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1==d2:
        flag += 1
    else:
        flag = 0
    if flag==3:
        break

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

Solution (Python):
n = int(input())
d = []
c = 0
ans = 'No'
for i in range(n):
    d1, d2 = [int(_) for _ in input().split()]
    if d1 == d2:
        c += 1
    else:
        c = 0
    if c == 3:
        ans = 'Yes'
print(ans)

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

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

lt = []
for _ in range(n):
    lt.append(tuple(map(int, input().split())))

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

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

Solution (Python):
n = int(input())
ds1 = []
ds2 = []
for _ in range(n):
    d1,d2 = list(map(int, input().split()))
    ds1.append(d1)
    ds2.append(d2)

matched = [d1 == d2 for d1,d2 in zip(ds1,ds2)]
cnt = 0
for m in matched:
    cnt = cnt+1 if m else 0
    if cnt == 3:
        break

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

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

Solution (Python):
import sys
input = sys.stdin.buffer.readline

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

ans = "No"
for i in range(N-2):
    ok = (AB[i][0] == AB[i][1] and AB[i+1][0] == AB[i+1][1] and AB[i+2][0] == AB[i+2][1])
    if ok:
        ans = "Yes"
print(ans)

Solution (Python):
n = int(input())
cnt = 0
mx = -1
ps = []
for _ in range(n):
    d1,d2 = map(int, input().split())
    ps.append((d1,d2))
ps.append((1,2))
for d1,d2 in ps:
    if d1 != d2:
        mx = max(mx,cnt)
        cnt = 0
    else:
        cnt += 1

print("Yes" if mx>=3 else "No")