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):


from collections import defaultdict
mod = 10 ** 9 + 7; INF = float("inf")

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

def inverse(N, mod):
	return (pow(N, mod - 2, mod))

def main():
	N = int(input())
	L = []
	for i in range(N):
		D1, D2 = getlist()
		if D1 == D2:
			L.append(1)
		else:
			L.append(0)

	for i in range(N - 2):
		if L[i] + L[i + 1] + L[i + 2] == 3:
			print("Yes")
			return

	print("No")




if __name__ == '__main__':
	main()

Solution (Python):


import os,sys
from io import BytesIO, IOBase

def main():
    n = int(input())
    x = [tuple(list(map(int,input().split())))for _ in range(n)]
    for i in range(n-2):
        if x[i][0]==x[i][1] and x[i+1][0]==x[i+1][1] and x[i+2][0]==x[i+2][1]:
            print('Yes')
            exit()
    print('No')
    

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)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

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

if __name__ == "__main__":
    main()

Solution (Python):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def main():
    INF = 999999999999999999999999
    MOD = 10**9+7

    n = int(input())

    now = 0
    for _ in range(n):
        a,b = get_nums_l()
        if a == b:
            now += 1
            if now >= 3:
                print("Yes")
                return
        else:
            now = 0
    print("No")

main()

Solution (Python):
def resolve():
    ans = 0
    count = 0
    N = int(input())
    for i in range(N):
        d, D = map(int, input().split())
        if d == D:
            ans += 1
        else:
            ans = 0
        if count < ans:
            count = ans
    print("Yes" if count  >= 3 else "No")
resolve()

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

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

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

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

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

result = False
t = 0
for _ in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        t += 1
    else:
        t = 0
    if t >= 3:
        result = True
        break
if result:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
for d1, d2, d3 in zip(D, D[1:], D[2:]):
    if d1[0] == d1[1] and d2[0] == d2[1] and d3[0] == d3[1]:
        print("Yes")
        exit()
print("No")

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

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

Solution (Python):




n = int(input())
flag = False
cnt=0
for i in range(n):
    x,y = map(int,input().split())
    if x!=y:
        if cnt>=3:
            flag = True
        cnt = 0
    else:
        cnt+=1
if cnt >=3:
    flag = True
if flag:
    print("Yes")
else:
    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
    else:
        ans = 0
    if ans == 3:
        print("Yes")
        exit()

print("No")

Solution (Python):
def main():
    N = int(input())
    double_count = 0
    for _ in range(N):
        n1, n2 = [int(s) for s in input().split()]
        if n1 == n2:
            double_count += 1
        else:
            double_count = 0
        if double_count == 3:
            print('Yes')
            return
    print('No')

main()

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

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

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

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

Solution (Python):
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque, defaultdict
from fractions import gcd
from functools import reduce
from itertools import groupby, combinations
from heapq import heapify, heappush, heappop



n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return list(map(lambda x: x + d, A))
def ldec(A, d=1): return list(map(lambda x: x - d, A))

N = n1()

cnt = 0
ans = 0
for i in range(N):
    D1, D2 = nn()
    if D1 == D2: cnt += 1
    else: cnt = 0
    if cnt >= 3: ans = 1

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

Solution (Python):
import sys
import itertools

import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


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

for i in range(N):
    for j in range(i, i + 3):
        if j >= N:
            break
        a, b = D[j]
        if a != b:
            break
    else:
        print("Yes")
        exit()
print("No")

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

Solution (Python):
cnt = 0
N = int(input())
for _ in range(N):
    x, y = map(int, input().split())
    if x==y and cnt == 2:
        print("Yes")
        exit()
    elif x==y:
        cnt += 1
    else:
        cnt = 0
print("No")

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

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

Solution (Python):
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

for i in range(n-2):
    d11,d12=d[i]
    d21,d22=d[i+1]
    d31,d32=d[i+2]
    if d11==d12 and d21==d22 and d31==d32:
        print("Yes")
        exit()

print("No")

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

Solution (Python):
def main():
    N = int(input())
    D = [list(map(int, input().split())) 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')
            exit()
    print('No')


if __name__ == "__main__":
    main()

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

N=int(input())
D=[tuple(map(int,input().split())) for i in range(N)]
flag=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]:
        flag=1

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

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

e = []
for d1, d2 in dd:
  e.append(int(d1 == d2))

for i in range(len(e)):
  if tuple(e[i: i + 3]) == (1, 1, 1):
    print('Yes')
    exit()

print('No')

Solution (Python):
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
D = []
for i in range(N):
	d = rl()
	D.append(d)

c = 0
for a, b in D:
	if a == b:
		c += 1
	else:
		c = 0
	if c >= 3:
		print('Yes')
		exit()
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):

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

    for _ in range(n):
        d1, d2 = map(int, input().split())

        if d1 == d2:
            com += 1
        else:
            com = 0

        if com == 3:
            print('Yes')
            return

    print('No')


if __name__ == '__main__':
    main()

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

flg = False
cnt = 0
for d1, d2 in d:
  if d1 == d2:
    cnt += 1
  else:
    cnt = 0
  if cnt == 3:
    flg = True
if flg:
  print('Yes')
else:
  print('No')

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

Solution (Python):
n=input()
a=[[int(i) for i in raw_input().split()]for j in range(n)]
flag=0
for i in range(2,n):
    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]:
        flag=1
if flag:
    print "Yes"
else:
    print "No"

Solution (Python):
n = int(input())
d = [list(map(int, input().split())) for _ 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')
        quit()

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())
count = 0
for i in range(n):
    x, y = map(int, input().split())
    if x == y:
        count += 1
        if count == 3:
            print('Yes')
            exit()
    else:
        count = 0
print('No')

Solution (Python):
def main():

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

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

Solution (Python):
def main():
    N = int(input())
    D = []
    for _ in range(N):
        a, b = (int(i) for i in input().split())
        D.append(int(a == b))

    if any(sum(D[i:i+3]) == 3 for i in range(N-3+1)):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

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

Solution (Python):


n=int(input())
ln=0
mx=0

for _ in range(n):
	l,r=map(int,input().split())
	if l == r:
		ln += 1
	else:
		ln = 0
	mx = max(mx, ln)

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

Solution (Python):
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c for j in range(b)] for i in range(a)]
def list3d(a, b, c, d): return [[[d for k in range(c)] for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**19
MOD = 10**9 + 7
EPS = 10**-10

N = INT()
ans = False
cnt = 0
for i in range(N):
    a, b = MAP()
    if a == b:
        cnt += 1
        if cnt >= 3:
            ans = True
    else:
        cnt = 0
if ans:
    Yes()
else:
    No()

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

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

Solution (Python):
n = int(input())
d = [[int(i) for i in input().split()] 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")
        break
else:
    print("No")

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

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

Solution (Python):

import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys


readline = sys.stdin.readline

INF = 1 << 60


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, D):
    c  = 0
    for d1, d2 in D:
        if d1 == d2:
            c +=1
            if c >= 3:
                return 'Yes'
        else:
            c = 0
    return 'No'


def main():
    N = read_int()
    D = [read_int_n() for _ in range(N)]
    print(slv(N, D))


if __name__ == '__main__':
    main()

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):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque, defaultdict


from collections import Counter

from itertools import accumulate,combinations,permutations,product

from heapq import heapify,heappop,heappush

from functools import reduce,lru_cache

from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): 
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    

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



if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
a = []
for _ in range(n):
  a.append([int(i) for i in input().split(" ")])
b = []
for i in range(n):
  if a[i][0] == a[i][1]:
    b.append(1)
  else:
    b.append(0)
ans = False
for i in range(n-2):
  if b[i] == 1 and b[i+1] == 1 and b[i+2] == 1:
    ans = True
    break
if ans:
  print("Yes")
else:
  print("No")

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    n = ini()
    c = 0
    for i in range(n):
        x, y = inl()
        if x == y:
            c += 1
        else:
            c = 0
        if c == 3:
            return True
    return False


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

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

zorome = 0

for i in range(n):

    a,b=map(int, input().split())
    if(a==b):zorome+=1
    else:zorome = 0
    if(zorome==3):print("Yes");exit()

print("No")

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



if __name__ == "__main__":
    main()

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

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


if __name__ == '__main__':
    main()

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

Solution (Python):
n = int(input())
cnt = 0
for _ in range(n):
    d0, d1 = tuple(map(int, input().split()))
    if d0 == d1:
        cnt += 1
    else:
        cnt = 0

    if cnt >= 3:
        print('Yes')
        break
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())
ans = 'No'
cnt = 0
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        cnt += 1
        if cnt >= 3:
            ans = 'Yes'
        continue
    cnt = 0
print(ans)

Solution (Python):
N=int(input())
zoro=0
res=0
for _ in [0]*N:
    a,b=map(int,input().split())
    if a==b:
        zoro+=1
        res=max(res,zoro)
    else:
        zoro=0
print(['No','Yes'][res>2])

Solution (Python):
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
N = int(input())
cnt = 0

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

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

Solution (Python):
if __name__ == "__main__":
    N = int(input())
    cnt = 0
    for _ 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())

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

print('No')

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

Solution (Python):

import sys


sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
printout = sys.stdout.write
sprint = sys.stdout.flush


sys.setrecursionlimit(10 ** 7)









INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7


def intread():
    return int(sysread())
def mapline(t=int):
    return map(t, sysread().split())
def mapread(t=int):
    return map(t, read().split())

def run():
    N = int(sysread())
    count = 0
    for i in range(N):
        a,b = mapline()
        if a == b:
            count += 1
        else:
            count = 0
        if count == 3:
            print('Yes')
            return
    print('No')


if __name__ == "__main__":
    run()

Solution (Python):
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

n=I()
zoro=0
for i in range(n):
    d1,d2=L()
    if d1==d2:
        zoro+=1
    else:
        zoro=0
    if zoro>=3:
        print('Yes')
        exit()
print('No')

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

Solution (Python):
from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> Any:
    N = read_int()
    count = 0
    for _ in range(N):
        d0, d1 = read_ints()
        if d0 == d1:
            count += 1
            if count > 2:
                return 'Yes'
        else:
            count = 0
    return 'No'


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

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

Solution (Python):

import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

n = inp()
s = ""
for i in range(n):
    a,b = ip()
    if a == b:
        s += '1'
    else:
        s += '0'
if '111' in s:
    print("Yes")
else:
    print("No")

Solution (Python):

import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter

from functools import lru_cache
import copy


input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7




def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])




n = inp()
cnt = 0
for i in range(n):
    a, b = inpl()
    if a == b:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print("Yes")
        exit()
print("No")

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

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

cnt = 0
check = False
for _ in range(N):
  d1,d2 = map(int,input().split())
  if d1 == d2:
    cnt += 1
  else:
    cnt = 0
    
  if cnt == 3:
    check = True
    break
    
print("Yes" if check else "No")

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

Solution (Python):
def main():
    N = int( input())
    D = [ tuple( map( int, input().split())) for _ 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")
            return
    print("No")
        
if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
D = [list(map(int, input().split())) 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")
        exit()
print("No")

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

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

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

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

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


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

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


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

    ans = 0

    for a, b in D:
        if a == b:
            ans += 1
            if ans >= 3:
                print("Yes")
                return
        else:
            ans = 0


    print("No")

if __name__ == '__main__':
    main()