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())
fl = 0
tmp = 0
for i in range(N):
  a, b = map(int, input().split())
  if a==b:
    tmp += 1
  else:
    tmp = 0
  if tmp ==3:
    fl = 1
if fl:
  print('Yes')
else:
  print('No')

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

    inlis = list()
    for _ in range(n):
        d1, d2 = map(int, input().split())
        inlis.append([d1, d2])
    
    for i in range(n):
        a, b = inlis[i][0], inlis[i][1]
        if a == b and i <= n - 3:
            if inlis[i+1][0] == inlis[i+1][1] and inlis[i+2][0] == inlis[i+2][1]:
                print('Yes')
                exit()
    print('No')




if __name__ == "__main__":
    main()

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

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

Solution (Python):


import re
import math
from collections import defaultdict,deque,Counter
from fractions import Fraction
import bisect
import itertools
from itertools import accumulate
from copy import deepcopy

import heapq
import random
import time
import os
import sys
from functools import lru_cache,reduce
readline=sys.stdin.readline
sys.setrecursionlimit(100000)
alp="abcdefghijklmnopqrstuvwxyz"
numbers="0123456789"
mod=int(10**9+7)
inf=int(10**19)
class Set():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(bool)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        if not self.find(x):
            heapq.heappush(self.heap,x)
            self.dic[x]=True
            self.size+=1

    def remove(self,x):
        if self.find(x):
            self.dic[x]=False
            self.size-=1

    def find(self,x):
        return self.dic[x]
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==False:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class multiset():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(int)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        heapq.heappush(self.heap,x)
        self.dic[x]+=1
        self.size+=1

    def remove(self,x):
        if self.dic[x]>0:
            self.dic[x]-=1
            self.size-=1
    
    def count(self,x):
        return self.dic[x]

    def find(self,x):
        return self.dic[x]>0
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==0:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class Edge():
    def __init__(self,x,y,val=1):
        self.x=x
        self.y=y
        self.val=val
class Point():
    def __init__(self,y,x):
        self.x=x
        self.y=y
class unionfind():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(n)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):
            self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def yn(b):print("yes" if b else "no")
def Yn(b):print("Yes" if b else "No")
def YN(b):print("YES" if b else "NO")
def ispow(a,b):
    now=b
    while now<a:
        now*=b
    return now==a
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def getfacs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def nextcomb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def getprimes(n):
    if n==0:return []
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    ret=[]
    for a in range(n+1):
        if(A[a]):ret.append(a)
    return ret
def isprime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(b,t,f):return t if b else f
def factorize(n):
    b = 2
    ret=defaultdict(int)
    while b * b <= n:
        while n % b == 0:
            n //= b
            ret[b]+=1
        b+=1
    if n > 1:ret[n]+=1
    return ret
def inputintlist(row=1): 
    if row==1:
        ret=list(map(int,input().split()))
    else:
        ret=[None]*row
        for a in range(row):
            ret[a]=int(input())
    return ret
def inputfloatlist(row=1): 
    if row==1:
        ret=list(map(float,input().split()))
    else:
        ret=[None]*row
        for a in range(row):
            ret[a]=float(input())
    return ret
def istanchouzouka(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>=a:
            f=False
        prev=a
    return f
def istanchouhigensyou(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>a:
            f=False
        prev=a
    return f
def getallsum(A):
    s=sum(A)
    dp=defaultdict(int)
    dp[0]=1
    for a in range(0,len(A)):
        for b in range(s,-1,-1):
            if b-A[a]>=0:
                dp[b]+=dp[b-A[a]]
    return dp
def yuukoutomukou(edges):
    ret=deepcopy(edges)
    for edge in edges:
        if not edge.x==edge.y:
            ret.append(Edge(edge.y,edge.x,edge.val))
    return ret
def dijkstra(edges,V,start):
    from queue import PriorityQueue
    mincost=[inf]*V
    G=[[] for a in range(V)]
    for edge in edges:
        G[edge.x].append([edge.val,edge.y])
    Q=PriorityQueue()
    Q.put([0,start])
    while not Q.empty():
        nowcost,nowx=Q.get()
        if mincost[nowx]==inf:
            mincost[nowx]=nowcost
            for cost,y in G[nowx]:
                newcost=nowcost+cost
                Q.put([newcost,y])
    return mincost
def warshallfloyd(edges,V):
    mincost=[[inf for b in range(V)] for a in range(V)]
    for a in range(V):mincost[a][a]=0
    for edge in edges:
        mincost[edge.x][edge.y]=min(mincost[edge.x][edge.y],edge.val)
    for k in range(V):
        for s in range(V):
            for t in range(V):
                if mincost[s][k]==inf or mincost[k][t]==inf:continue
                mincost[s][t]=min(mincost[s][t],mincost[s][k]+mincost[k][t])
    return mincost
def bellemanford(edges,V,start):
    mincost=[inf]*V
    mincost[start]=0
    for _ in range(V):
        for edge in edges:
            if mincost[edge.x]==inf:continue
            mincost[edge.y]=min(mincost[edge.y],mincost[edge.x]+edge.val)
    return mincost
def getmd(x1,y1,x2,y2):return abs(x1-x2)+abs(y1-y2)
def geted(x1,y1,x2,y2):return math.sqrt((x1-x2)**2+(y1-y2)**2)
class fordfulkerson():
    def __init__(self,edges,V,s,t):
        self.V=V
        self.used=[False]*V
        self.G=[[] for a in range(V)]
        self.s=s
        self.t=t
        for edge in edges:
            self.G[edge.x].append({"x":edge.x,"y":edge.y,"cap":edge.val,"rev":len(self.G[edge.y])})
            self.G[edge.y].append({"x":edge.y,"y":edge.x,"cap":0,"rev":len(self.G[edge.x])-1})
    def dfs(self,v,t,f=inf):
        if v==t:return f
        self.used[v]=True
        for a in range(len(self.G[v])):
            x=self.G[v][a]["x"]
            y=self.G[v][a]["y"]
            cap=self.G[v][a]["cap"]
            rev=self.G[y][self.G[x][a]["rev"]]
            if self.used[y] or cap==0:continue
            f2=self.dfs(y,t,min(f,cap))
            if f2>0:
                self.G[v][a]["cap"]-=f2
                rev["cap"]+=f2
                return f2
        return 0
    def maxflow(self):
        flow=0
        while True:
            self.used=[False]*V
            zouka=self.dfs(self.s,self.t)
            if zouka==0:break
            flow+=zouka
        return flow
def zipsort(*args):
    ziplist=sorted(zip(*args))
    for a in range(len(args)):
        for b in range(len(ziplist)):
            args[a][b]=ziplist[b][a]
def zipreverse(*args):
    ziplist=list(zip(*args))
    rev=[]
    for a in range(len(ziplist)-1,-1,-1):
        rev.append(ziplist[a])
    for a in range(len(args)):
        for b in range(len(rev)):
            args[a][b]=rev[b][a]

def to10(A):
    ret=0
    for a in range(len(A)-1,-1,-1):
        ret+=X[a]*2**(N-1-a)
    return ret

n=int(input())
D=[None]*n
for a in range(n):
    D[a]=inputintlist()
renzoku=0
f=False
for a in range(n):
    if D[a][0]==D[a][1]:
        renzoku+=1
    else:
        renzoku=0
    if renzoku>=3:
        f=True
Yn(f)

Solution (Python):
N = int(input())
D = [list(map(int,input().split())) for i in range(N)]
ans = "No"
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 = "Yes"
print(ans)

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

Solution (Python):



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

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

Solution (Python):
n = int( input() )
d_1 = []
d_2 = []
for _ in range( n ):
    a, b = map( int, input().split() )
    d_1.append( a )
    d_2.append( b )

for i in range( n - 2 ):
    if d_1[ i ] == d_2[ i ] and d_1[ i + 1 ] == d_2[ i + 1 ] and d_1[ i + 2 ] == d_2[ i + 2 ]:
        print( "Yes" )
        break
else:
    print( "No" )

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

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

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

print("No")

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

Solution (Python):
import sys

N = int(input())

count = 0
ans = 'No'
for _ in range(N):
    D1, D2 = map(int, sys.stdin.readline().strip().split())

    if D1 == D2:
        count += 1
    else:
        count = 0

    if count >= 3:
        ans = 'Yes'
        break

print(ans)

Solution (Python):
from __future__ import division, print_function
import bisect
import math
import heapq
import itertools
import sys
from collections import deque
from atexit import register
from collections import Counter
from functools import reduce
if sys.version_info[0] < 3:
    from io import BytesIO as stream
else:
    from io import StringIO as stream
 
 
if sys.version_info[0] < 3:
    class dict(dict):
        """dict() -> new empty dictionary"""
        def items(self):
            """D.items() -> a set-like object providing a view on D's items"""
            return dict.iteritems(self)
 
        def keys(self):
            """D.keys() -> a set-like object providing a view on D's keys"""
            return dict.iterkeys(self)
 
        def values(self):
            """D.values() -> an object providing a view on D's values"""
            return dict.itervalues(self)
 
    input = raw_input
    range = xrange
 
    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip
 
 
def sync_with_stdio(sync=True):
    """Set whether the standard Python streams are allowed to buffer their I/O.
 
    Args:
        sync (bool, optional): The new synchronization setting.
 
    """
    global input, flush
 
    if sync:
        flush = sys.stdout.flush
    else:
        sys.stdin = stream(sys.stdin.read())
        input = lambda: sys.stdin.readline().rstrip('\r\n')
 
        sys.stdout = stream()
        register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

def main():
    
    n=int(input())
    arr=[]
    for i in range(n):
        a=list(map(int,input().split()))
        arr.append(a[:])
    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]:
            print("Yes")
            return
    print("No")

if __name__ == '__main__':
    sync_with_stdio(False)
    main()

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

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

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

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

Renzoku=0
icchiAri=0
for i in range(n):
  a,b=map(int,input().split())
  if a==b:
    Renzoku+=1
  else:
    Renzoku=0
    
  if Renzoku==3:
    icchiAri=1

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

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

Solution (Python):
import sys

input = sys.stdin.readline

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(0)
print("No")

Solution (Python):
from collections import defaultdict
from collections import deque
from collections import Counter
import math
import itertools

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()

zoro = 0

data = [readInts() for i in range(n)]

for d1,d2 in data:
	if d1==d2:
		zoro+=1
	else:
		zoro = 0
	if zoro==3:
		break

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

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

Solution (Python):
def main():
    n = int(input())
    d =[]
    cnt = 0
    ans = 'No'
    for i in range(n):
        d1 = list(map(int,input().split()))
        if d1[0] == d1[1]:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            ans = 'Yes'
        d.append(d1)
    print(ans)

if __name__=='__main__':
    main()

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

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

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

ans = 'No'
cnt = 0
for _ in range(n):
   d1, d2 = map(int, input().split())
   if d1 == d2:
      cnt += 1
   elif cnt > 0 and d1 != d2:
      if cnt >= 3:
         ans = 'Yes'
      cnt = 0

if cnt >= 3:
   ans = 'Yes'
print(ans)

Solution (Python):
n=int(input())
d=[]
for i in range(n):
    d.append(list(map(int,input().split())))
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):
n = int(input())
d = [[0] for i in range(n)]
for i in range(n):
    d1, d2 = map(int, input().split())
    d[i].append(d1)
    d[i].append(d2)

seq = 0
ans = 0
for pair in d:
    if pair[1] == pair[2]:
        seq += 1
    else:
        seq = 0
    ans = max(ans, seq)
if ans >= 3:
    print("Yes")
else:
    print("No")

Solution (Python):
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
cnt=0
for i in range(n-2):
    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]):
        print("Yes")
        exit()
print("No")

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

Solution (Python):
N = int(input())
C = 0
for i in range(N):
  D1, D2 = map(int, input().split())
  if D1 == D2:
    C += 1
  else:
    C = 0
  if C > 2:
    print('Yes')
    break
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>=3:
    ans="Yes"
    break
print(ans)

Solution (Python):
mod = 1000000007
eps = 10**-9


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

    N = int(input())
    cnt = 0
    ma = 0
    for _ in range(N):
        a, b = map(int, input().split())
        if a == b:
            cnt += 1
            ma = max(ma, cnt)
        else:
            cnt = 0
    if ma >= 3:
        print("Yes")
    else:
        print("No")



if __name__ == '__main__':
    main()

Solution (Python):

import sys

input = sys.stdin.readline


def Y():
    print("Yes")


def N():
    print("No")


def ST():
    return input().rstrip()


def I():
    return int(input())


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


def LI():
    return list(MI())


n = I()

c = 0
for _ in range(n):
    d1, d2 = MI()
    if d1 == d2:
        c += 1
        if c >= 3:
            Y()
            exit()
    else:
        c = 0

N()

Solution (Python):
N = int(input())
ans = False
count = 0
D1, D2 = 0, 0
for i in range(N):
    D1, D2 = list(map(int, input().split()))
    if D1 == D2:
        count += 1
        if count >= 3:
            ans = True
    else:
        count = 0

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

Solution (Python):
import sys
import itertools
sys.setrecursionlimit(10000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

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

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

Solution (Python):
N = int(input())
D1 = []
D2 = []

for _ in range(N):
  a, b = map(int, input().split())
  D1.append(a)
  D2.append(b)

for i in range(N-2):
  if D1[i:i+3] == D2[i:i+3]:
    print("Yes")
    exit()

print("No")

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

Solution (Python):
def solve():
    n = int(input())
    a = [list(map(int, input().split())) for _ in range(n)]
    print("Yes" if any(a[i][0] == a[i][1] and a[i+1][0] == a[i+1][1]
                       and a[i+2][0] == a[i+2][1] for i in range(0, n-2)) else "No")


def main():
    t = 1
    while t > 0:
        solve()
        t -= 1


main()

Solution (Python):
n=int(input())
dp=[False]*n
for i in range(n):
    d1,d2=map(int, input().split())
    if d1==d2:
        dp[i]=True
for j in range(n-2):
    if dp[j] and dp[j+1] and dp[j+2]:
        print('Yes')
        exit()
print('No')

Solution (Python):
N = int(input().strip())
a=[0]*N
b=[0]*N
for i in range(N):
    a[i],b[i]= list(map(int, input().strip().split()))
f="No"
for i in range(N-2):
    if a[i]==b[i] and  a[i+1]==b[i+1] and   a[i+2]==b[i+2] :
        f="Yes"
        break
print(f)

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

Solution (Python):
import math

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

cnt = 0
for d in dL:
    if d[0] == d[1]:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print("Yes")
        exit()

print("No")

Solution (Python):
import math
import collections
import itertools

def YesNo(Bool):
    if(Bool):
        print("Yes")
    else:
        print("No")
    return

def resolve():

    N=int(input())
    maxzoro=0
    zoro=0
    for i in range(N):
        D1,D2=map(int,input().split())
        if(D1==D2):
            zoro+=1
        else:
            zoro=0
        maxzoro=max(maxzoro,zoro)
    YesNo(maxzoro>=3)

resolve()

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

D = []

for i in range(N):
   D.append(input().split())

def judge(L):
   if L[0] == L[1]:
      return True
   else:
      return False

for i in range(N - 2):
   if judge(D[i]) and judge(D[i+1]) and judge(D[i+2]):
      print('Yes')
      exit()

print('No')

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

def judge() :
  c = 0
  for a, b in D :
    if a == b : 
      c += 1
    else :
      c = 0
    if c >= 3 :
      return 'Yes'
  return 'No'
  
print(judge())

Solution (Python):
n = int(input())
l = []
for i in range(n):
    x,y = map(int,input().split())
    l.append((x,y))
for i in range(n-2):
    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]:
        print('Yes')
        exit()
print('No')

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

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

Solution (Python):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
d=[lnii() for i in range(n)]

cnt=0
for a,b in d:
  if a==b:
    cnt+=1
  if cnt>=3:
    print('Yes')
    exit()
  if a!=b:
    cnt=0

print('No')

Solution (Python):
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n=int(input())
ans=0
flag=0
for i in range(n):
    d1,d2=get_ints()
    if d1==d2:
        ans=ans+1
        if ans>=3:
            flag=1
    else:
        ans=0
if flag==1:
    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())
    
check = 0
for i in range(N):
    if D1[i]==D2[i]:
        check += 1
    else:
        check = 0
        
    if check == 3:
        break
        
if check >= 3:
    print("Yes")
else:
    print("No")

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

Solution (Python):


import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
d = [LI() for _ 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')
        quit()
print('No')

Solution (Python):
import sys
sys.setrecursionlimit(10**7)

def input(): return sys.stdin.readline()[:-1]
mod = 10**9 + 7
def readInt():return int(input())
def readIntList():return list(map(int,input().split()))
def readStringList():return list(input())
def readStringListWithSpace():return list(input().split())
def readString():return input()

from itertools import accumulate
 
def execute():
    n = readInt()
    count = 0
    res = False
    for _ in range(n):
        a,b = readIntList()
        if a == b :
            count += 1
        else:
            count = 0
        if count == 3:
            res = True
    if res:
        print("Yes")
    else:
        print("No")


    
 
if __name__ == "__main__":
    execute()

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

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

ans = 'No'
count=0
for _ in range(N):
    a,b=input().split()
    if a==b:
        count+=1
        if count==3:
            ans='Yes'
    else:
        count=0
print(ans)

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

Solution (Python):
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    D = [list(map(int, input().split())) for i in range(N)]
    cnt = 0
    for a, b in D:
        if a == b:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

Solution (Python):

import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(SOLVE_PARAMS):
    pass


def main():
    N = int(input())
    ret = False
    count = 0
    for i in range(N):
        a, b = map(int, input().split())
        if a == b:
            count += 1
            if count == 3:
                ret = True
                break
        else:
            count = 0

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



T1 = """
5
1 2
6 6
4 4
3 3
3 2
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
Yes
"""

T2 = """
5
1 1
2 2
3 4
5 5
6 6
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
No
"""

T3 = """
6
1 1
2 2
3 3
4 4
5 5
6 6
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
Yes
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()

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

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

print(ans)

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

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

Solution (Python):


import numpy as np
N=int(input())

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

print(ans)

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

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

flag=0
zoro=0
for i in range(x):
    a,b = map(int, input().split())
    if a==b:
        zoro+=1
    else:
        zoro=0
    if zoro>=3:
        flag=1
if flag==1:
    print("Yes")
else:
    print("No")

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

ans = False
count = 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        count += 1
    else:
        count = 0
    
    if count >= 3:
        ans = True


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

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

zoro = 0
ans = False

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

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

Solution (Python):
N = int(input())
D = [list(map(int,input().split())) for i in range(N)]
cnt = 0
for i in range(N) :
    if D[i][0] == D[i][1] :
        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 _ in range(n)]
zoro = 0
ans = 0
for a in d:
    if a[0] == a[1]:
        zoro += 1
    else:
        zoro = 0
    ans = max(ans, zoro)
if ans >= 3:
    print("Yes")
else:
    print("No")