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(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        count+= 1
        if count > 2:
            print("Yes")
            break
    else:
        count = 0
else:
    print("No")

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

print('No')

Solution (Python):
def readInt():
    return int(input())
def readList():
    return list(map(int,input().split()))
def readMap():
	return map(int,input().split())
def readStr():
    return input()
inf=float('inf')
mod = 10**9+7
import math
def solve(n,A):
    count=0
    for x,y in A:
        if x==y:
            count+=1
        else:
            count=0
        if count==3:
            return True
    return False

n=readInt()
A=[]
for _ in range(n):
    A.append(readList())
if solve(n,A):
    print("Yes")
else:
    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())
c=[]
for i in range(n):
    x,y=map(int,input().split())
    c.append([x,y])
s=0
flag=0
for i in range(len(c)):
    if c[i][0]==c[i][1]:
        s+=1
    else:
        if s>=3:
            flag=1
        s=0

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

Solution (Python):
Result=[]
pair=[]
ans='No'

N=int(input())

for _ in range(N):
    pair=list(map(int,input().split()))
    Result.append(pair)

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

print(ans)

Solution (Python):
N=int(input()) 
XY=[map(int, input().split()) for _ in range(N)]
X,Y=[list(i) for i in zip(*XY)]
ans="No"

for j in range(0,N-2):
    if X[j]==Y[j] and X[j+1]==Y[j+1] and X[j+2]==Y[j+2]:
        ans="Yes"
        break

print(ans)

Solution (Python):
N = int(input())
c = 0
for _ in range(N):
    di1, di2 = input().split(" ")
    if di1 == di2:
        c += 1
        if c == 3:
            print("Yes")
            break
    else:
        c = 0
else:
    print("No")

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

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

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

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

Solution (Python):

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

count=0
ans=0
for j in range(n):
    if d[j][0]==d[j][1]:
        count+=1
        if count==3:
            ans=1
    else :
        count=0

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

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

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

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())
ans=0
for i in range(N):
    A,B=map(int,input().split())
    if A==B:
        ans+=1
        if ans==3:
            break
    else:
        ans=0
if ans==3:
    print("Yes")
else:
    print("No")

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

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

repdigitCount = 0

for i in range(n):
    D = [int(x) for x in input().split()]
    if D[0] == D[1]:
        repdigitCount += 1
        if repdigitCount == 3:
            print('Yes')
            exit()
    else:
        repdigitCount = 0
print('No')

Solution (Python):
import sys
from sys import exit
from collections import deque
from copy import deepcopy
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod=MOD):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        if k<0 or n<k:
            return 0
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x,mode='counter'):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    if mode=='counter':
        return C
    S = set([1])
    for k in C:
        T = deepcopy(S)
        for x in T:
            for i in range(1,C[k]+1):
                S.add(x*(k**i))
    if mode=='set':
        return S
    if mode=='list':
        return sorted(list(S))



ans='No'
N=intput()
tmp=0
for i in range(N):
    d1,d2=mint()
    if d1==d2:
        tmp+=1
    else:
        tmp=0
    if tmp==3:
        ans='Yes'
        break
print(ans)

Solution (Python):
cnt = input()
same_val_cnt = 0
ans = "No"
for _ in range(1,int(cnt)+1):
	a, b = input().split(" ")
	if a == b:
		same_val_cnt += 1
	else:
		same_val_cnt = 0

	if same_val_cnt == 3:
		ans = "Yes"
		break

print(ans)

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

for i in range(2, N):
  if D[i - 2][0] == D[i - 2][1] and D[i - 1][0] == D[i - 1][1] and D[i][0] == D[i][1]:
      print('Yes')
      exit()
      
print('No')

Solution (Python):
D1_li = []
D2_li = []


N = int(input())
for i in range(N):
	D1, D2 = map(int, input().split())
	D1_li.append(D1)
	D2_li.append(D2)

for j in range(N-2):
	if D1_li[j] == D2_li[j]:
		if D1_li[j+1] == D2_li[j+1]:
			if D1_li[j+2] == D2_li[j+2]:
				print('Yes')
				break
else:
	print('No')

Solution (Python):
n = int(input())
d1 = []
d2 = []
cnt = 0
flag = False

for i in range(n):
    a, b = map(int, input().split())
    d1.append(a)
    d2.append(b)

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

    if cnt >= 3:
        flag = True


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

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

ans = 0
for i in range(N):
    if x[i] == y[i]:
        ans += 1
        if ans == 3:
            break
    else:
        ans = 0
if ans == 3:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
l = []
ans = 'No'
for _ in range(N):
    
    a,b = map(int,input().split())
    d = a - b
    l.append(d)

for i in range(2,N):
    if l[i] == 0 and l[i-1] == 0 and l[i-2] == 0:
        ans = 'Yes'
        break

print(ans)

Solution (Python):
n = int(input())
d = []
for i in range(n):
  d.append(list(map(int, input().split())))
flag = "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]:
    flag = "Yes"
    break
print(flag)

Solution (Python):
N = int(input())
D = []
for _ in range(N):
    D.append(list(map(int,input().split())))
check = ''
for i in range(N):
    if D[i][0] == D[i][1]:
        check += 'T'
    else:
        check += 'F'

if 'TTT' in check:
    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
        if cnt == 3:
            print('Yes')
            exit()
    else:
        cnt = 0

print('No')

Solution (Python):
N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
count = 0
for i, j in zip(x, y):
    if i == j:
        count += 1
        continue
    if count >= 3:
        break
    count = 0
if count >= 3:
    print('Yes')
else:
    print('No')

Solution (Python):
'''
Name: Devansh
Username: singhdevansh
Github: https://github.com/Devansh3712
'''

import os
import sys
import math
from itertools import *
from io import BytesIO, IOBase
from collections import *


BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)



mod=(10**9)+7
pi=3.14159265358979323846264338327950

def i1():	
	return int(sys.stdin.readline())

def sf():	
	return sys.stdin.readline()

def mi():	
	return map(int,sys.stdin.readline().split())

def arr():	
	return list(map(int,sys.stdin.readline().split()))

def pf(ans): 
	return sys.stdout.write(str(ans)+"\n")

def gcd(a,b):
	if a==0:
		return b
	elif b==0:
		return a
	if a>b:
		return gcd(a%b,b)
	else:
		return gcd(a,b%a)

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




def solve():
	n=i1()
	c=[]
	for i in range (n):
		a,b=mi()
		if a==b:
			c.append(1)
		else:
			c.append(0)
	flag=False
	try:
		for i in range (n):
			if c[i:i+3]==[1,1,1]:
				flag=True
				break
	except IndexError:
		pass
	if flag==True:
		print('Yes')
	else:
		print('No')
solve()

Solution (Python):
n=int(input())
c=0
count=0
for i in range(n):
    a,b=map(int,input().split())

    if a==b:
        count+=1
    else:
        count=0
    if count==3:
        c=1
if c==1:
    print("Yes")
else:
    print("No")

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

ans=False
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=True

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

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

pv = []
con = 0

while n > 0:
    n -= 1
    s = str(input())
    d = s.split()
    if d[0] == d[1]:
        con += 1
    else:
        if con >= 3:
            break
        pv += [con]
        con = 0

pv += [con]
ans = max(pv)

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

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

D = []
for _ in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        D.append(True)
    else:
        D.append(False)

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

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

Solution (Python):
def main():
    n = int(input())
    cnt = 0
    for i in range(0, n):
        d_1, d_2 = map(int, input().split())
        if d_1 == d_2:
            cnt += 1
        else :
            if cnt < 3 :
                cnt = 0

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

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

cnt,cnt_max = 0,0
for i in range(N):
    if D[i][0] == D[i][1]:
        cnt += 1
    else:
        cnt = 0
    cnt_max = max(cnt,cnt_max)

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

Solution (Python):

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

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

    if count >= 3:
      print("Yes")
      return

  print("No")

main()

Solution (Python):

N = int(input())
ans = 0
allD = []
anslist = []
for i in range(N):
    D = list(map(int, input().split()))
    allD.append(D)
    
for i in range(N):
    if allD[i][0] == allD[i][1]:
        ans += 1
        anslist.append(ans)
    else:
        ans = 0
        anslist.append(ans)

print('Yes') if 3 in anslist 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
        if count == 3:
            break
    else:
        count= 0

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

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

D = [None] * (N + 2)
D[0] = [-1, -2]
D[1] = [-1, -2]
for i in range(2, N+2):
    D[i] = list(map(int, input().split()))

def zorome(a):
    return a[0] == a[1]

message = 'No'
for i in range(2, N+2):
    if (zorome(D[i-2]) and zorome(D[i-1]) and zorome(D[i])):
        message = 'Yes'

print(message)

Solution (Python):
n=int(input())
ns=[list(map(int,input().split())) for i in range(n)]
for i in range(n-2):
    if ns[i][0] == ns[i][1] and ns[i+1][0] == ns[i+1][1] and ns[i+2][0] == ns[i+2][1]:
        print("Yes")
        break
    if i==n-3:
        print("No")

Solution (Python):
import sys

N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]

count=0

for i in range(N):
    if(x[i]==y[i]):
        count+=1
    else:
        count=0
    if (count==3):
        print('Yes')
        sys.exit()
print('No')

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

count = 0

while True:
    try:
        D = list(map(int, input().split()))
        if D[0] == D[1]:
            count += 1
        else:
            count = 0

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

    except:
        print('No')
        break

Solution (Python):
n=int(input())
m=0
c=0
for _ in range(n):
	n1,n2=map(int,input().split())
	if n1==n2:
		c+=1
		m=max(m,c)
	else:
		m=max(m,c)
		c=0
if m>=3:
	print('Yes')
else:
	print('No')

Solution (Python):
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]
count = 0
re = "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]:
        re = "Yes"
        break

print(re)

Solution (Python):
def func():
    count = 0
    for _ in range(N):
        a, b = map(int, input().split())
        if a == b:
            count += 1
        else:
            count = 0
        if count >= 3:
            return "Yes"
    return "No"


N = int(input())

print(func())

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

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]:
        print("Yes")
        exit()
print("No")

Solution (Python):




n = int(input())
d_n = [input().split(" ") for i in range(n)]

flag = False

for i in range(n-2):
    if (d_n[i][0] == d_n[i][1]) & (d_n[i+1][0] == d_n[i+1][1]) & (d_n[i+2][0] == d_n[i+2][1]):
        flag=True

if flag:
    print('Yes')
else:
    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())
a=0
li=[]
for i in range(n):
    lis=input().split(' ')
    li.append(lis)
for i in range(n-2):
    if li[i][0]==li[i][1]:
        if li[i+1][0]==li[i+1][1]:
            if li[i+2][0]==li[i+2][1]:
                a+=1
if a!=0:
    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())
  
for i in range(n-2):
  if d1[i] == d2[i]:
    if d1[i+1] == d2[i+1]:
      if d1[i+2] == d2[i+2]:
        print('Yes')
        exit(0)
        
print('No')

Solution (Python):
arr=[]
for _ in range(int(input())):
    x,y=map(int,input().split())
    arr.append([x,y])
count=0
flag=0
for i in arr:
    if(i[0]==i[1]):
        count+=1
    else:
        count=0
    if(count>=3):
        print('Yes')
        flag=1
        break
if(flag==0):
    print('No')

Solution (Python):
n = int(input())
count = 0
d = []
flag = False

for i in range(n):
    d = list(map(int, input().split()))
    if d[0] == d[1]:
        count += 1
    else:
        count = 0
    if count == 3:
        flag = True

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

Solution (Python):
n=int(input())
d=[]
ans=False
for i in range(n):
    d1,d2=map(int,input().split())
    d.append((d1,d2))

for i in range(n-2):
    d1,d2=d[i]
    e1,e2=d[i+1]
    f1,f2=d[i+2]
    if d1==d2 and e1==e2 and f1==f2:
        ans=True
if ans:
    print("Yes")
else:
    print("No")

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

ans =0
key =0
for _ in range(N):
    N,M=(map(int, input().split()))
    if N==M:
        ans +=1
    else:
        ans =0
    if ans >=3:
        key =1

if key > 0:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int ( input().strip() ) ;

c = 0 ;
b = "No" ;
for x in range ( N ) :
	d1 , d2 = map ( int , input().strip().split(" ") ) ; 
	if d1 == d2 : 
		c += 1 ; 
	else :
		c = 0 ;
	if c >= 3 :
		b = "Yes" ;
print ( b ) ;

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

cnt = 0
for i in range(N):
    D_1, D_2 = map(int, input().split(" "))
    if D_1 == D_2:
        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(list(map(int, input().split())))

max_cnt = 0
cnt = 0
for x, y in D:
    if x == y:
        cnt += 1
        max_cnt = max(max_cnt, cnt)
    else:
        cnt = 0
if max_cnt >= 3:
    print('Yes')
else:
    print('No')

Solution (Python):

"""
Created on Sat Sep 19 13:06:46 2020

@author: Admin
"""

n=int(input())
l=[]
flag=0
for i in range(n):
    a,b=input().split()
    w=[int(a),int(b)]
    l.append(w)
for i in range(len(l)-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')
        flag=1
        break
if flag==0:
    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
    if count == 3:
      print('Yes')
      exit()
  else:
    count = 0
print('No')

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

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

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

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

sum=0
flg=False

for i in s:
  if i[0]==i[1]:
    sum+=1
  elif i[0]!=i[1]:
    sum=0
  if sum==3:
    flg=True
    break

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

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

s = 0
for d in Ds:
    if d[0] != d[1]:
        s = 0
        continue
    s += 1
    if s == 3:
        print('Yes')
        break
else:
    print('No')

Solution (Python):
import sys
import re
import queue
import collections
import math
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext

def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
	N = i_input()
	D = []
	for i in range(0,N):
		tmp1,tmp2 = i_map()
		if(tmp1 == tmp2):
			D.append(1)
		else:
			D.append(0)

	flag = False
	for i in range(0,N-2):
		if(D[i]==D[i+1]==D[i+2]==1):
			flag = True

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

	return

if __name__ == '__main__':
	main()

Solution (Python):
N=int(input())
count=0
ans="No"
while N>0:
  d1,d2=map(int,input().split())
  if d1==d2:
    count+=1
    if count==3:
      ans="Yes"
  else:
    count=0
  N-=1

print(ans)

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

Solution (Python):
def main():
    count = 0
    frag = 0
    ans = 0
    N = int(input())
    d = []
    for i in range(N) :
        d1, d2 = map(int, input().split())
        d_temp = [d1,d2]
        if d1 == d2 and frag == 0:
            count += 1
            frag = 1
        elif frag == 1 and d1 == d2 :
            count += 1
            if count == 3 :
                ans = 1
        elif d1 != d2 :
            frag = 0
            count = 0

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

if __name__ == '__main__':
    main()

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

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

for i in range(N):
  d1, d2 = input().split()
  if d1 == d2:
      count = count + 1
  else:
      count = 0
  if count == 3:
      ans = "Yes"

print(ans)

Solution (Python):
from sys import stdin
n = int(stdin.readline().rstrip())
m = 0
cnt = 0
for i in range(n):
    d1, d2 = [int(x) for x in stdin.readline().rstrip().split()]
    if d1 == d2:
        cnt += 1
    else:
        if m < cnt:
            m = cnt
        cnt = 0
if m < cnt:
    m = cnt
cnt = 0
if m >= 3:
    print('Yes')
else:
    print('No')

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

d12 = [map(int, input().split()) for _ in range(n)]
d1, d2 = [list(i) for i in zip(*d12)]

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

Solution (Python):
N = int(input())
count = 0
count_max = count
for i in range(N):
    di_1, di_2 = [int(i) for i in input().split()]
    if di_1 == di_2:
        count += 1
    else:
        count_max = max([count_max, count])
        count = 0
count_max = max([count_max, count])
if count_max >= 3:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
D = [list(map(int, input().split())) for _ in range(n)] 
ct = 0
CT = []
for i in range(n):
    if D[i][0] == D[i][1]:
        ct += 1
        if i == n-1:
            CT.append(ct)
    else:
        CT.append(ct)
        ct = 0
for k in CT:
    if k >= 3:
        print('Yes')
        exit()
print("No")

Solution (Python):

import sys
import math
import numpy as np
import itertools


n = int(input())


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

r=0

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

Solution (Python):
def hantei(D,i):
  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]:
        return True
      else:
        return False
    else:
      return False
  else:
    return False

N = int(input())
D = [input().split(" ") for i in range(N)]
ans = False
for i in range(N-2):
  if hantei(D,i):
    ans = True
    break
if ans:
  print('Yes')
else:
  print('No')

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


for l in range(n):
  if count == 3:
    break
  if num_list[l][0] == num_list[l][1]:
    count += 1
  else:
    count = 0

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

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

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

count = 0
for i in range(0, 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):
rolls = int(input())
dices = []
for _ in range(rolls):
  dices.append(list(map(int, input().split())))
 
doubles = [d1 == d2 for d1,d2 in dices]
 
for i in range(1,rolls):
  doubles[i] *= (doubles[i] + doubles[i-1])
  if doubles[i] == 3:
    print('Yes')
    exit()
 
print('No')

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

zoro=0
aru=0
for i in range(n):
    if x[i]==y[i]:
        zoro+=1
        if zoro==3:
            aru=1
    else:
        zoro=0

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

Solution (Python):

from typing import List


def input_int() -> int:
    return int(input())


def input_int_list() -> List[int]:
    return list(map(lambda x: int(x), input().split()))


def f(d_pair_list: list) -> str:
    n = 0
    for d_pair in d_pair_list:
        if d_pair[0] == d_pair[1]:
            n += 1
            if n >= 3:
                return 'Yes'
        else:
            n = 0
    return 'No'


if __name__ == '__main__':
    n = input_int()

    d_pair_list: List = list()
    for i in range(0, n):
        d_pair_list.append(input_int_list())
    print(f(d_pair_list))

Solution (Python):
N=int(input())
count=0
l=[]
for i in range(N):
    x,y=map(int,input().split())
    
    
    
    
    if x==y:
        count+=1
    if x!=y:
        l.append(count)
        count=0
if len(l)==0:
    
    l.append(count)
l.sort()
x2=l[-1]
if x2>=3:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
d = []
for i in range(n):
    d.append(list(map(int, input().split())))
judge = 'No'
c = 0
for j in range(n):
    if d[j][0] == d[j][1]:
        c += 1
    else:
        c = 0
    if c >= 3:
        judge = 'Yes'
print(judge)

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

count=0
for i in x:
    if i[0]==i[1]:
        count+=1
    else:
        count=0
    if count==3:
        print("Yes")
        break
else:
    print("No")

Solution (Python):

import sys


def main():
    N = int( sys.stdin.readline() )
    D_list = [ list(map(int, sys.stdin.readline().split())) for _ in range(N) ]


    cnt = 0

    for i in range(len(D_list)):
        if D_list[i][0] == D_list[i][1]:
            cnt += 1
        else:
            cnt = 0
        
        if cnt == 3:
            print("Yes")
            return
    

    print("No")



if __name__ == "__main__":
    main()

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

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

i = 0
res = False

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

    if a == b:
        i += 1
    else:
        i = 0
        
    if i >= 3:
        res = True

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

Solution (Python):
N=int(input())
same=0
D=[]
for i in range(N):
    D.append(input())

for i in range(N):
    D_1,D_2=map(int,D[i].split())
    if D_1==D_2:
        same+=1
    else:
        same=0
    if same>=3:
        print("Yes")
        break

if same<3:
    print("No")