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

def main():
    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')
            return
    print('No')


if __name__ == '__main__':
    main()

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

cnt = 0
for f,s in F_S:
  if cnt >= 3:
    break
  if f == s:
    cnt += 1
  else:
    cnt = 0
if cnt >= 3:
  print("Yes")
else:
  print("No")

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

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

strk = 0
ans = False
for i in range(n):
    a, b = list(map(int, input().split()))

    if a == b:
        strk += 1
        if strk == 3:
            ans = True
    else:
        strk = 0

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

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n=int(input().rstrip())
cnt=0
tmp=0
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        tmp+=1
    else:
        cnt=max(cnt,tmp)
        tmp=0
cnt=max(cnt,tmp)

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

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    count = 0
    bl = False
    for _ in range(N):
        a, b = map(int, readline().split())
        if a==b:
            count += 1
            if count>=3:
                bl = True
                break
            else:
                continue
        else:
            count = 0
    if bl:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

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

Solution (Python):
import sys



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


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


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    cnt = 0
    ans = 0
    for _ in range(n):
        a, b = input_int_list()
        if a == b:
            cnt += 1
        else:
            ans = max(ans, cnt)
            cnt = 0
    else:
        ans = max(ans, cnt)

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


if __name__ == "__main__":
    main()

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

Solution (Python):
from itertools import groupby
class Combination:
    def __init__(self, n, mod):
        self.n = n
        self.mod = mod
        self.fac = [1 for i in range(self.n + 1)]
        self.finv = [1 for i in range(self.n + 1)]
        for i in range(2, self.n+1):
            self.fac[i] = (self.fac[i - 1] * i) % self.mod
            self.finv[i] = (self.finv[i - 1] * pow(i, -1, self.mod)) % self.mod

    def comb(self, n, m):
        return self.fac[n] * (self.finv[n - m] * self.finv[m] % self.mod) % self.mod
        
def iparse():
    return list(map(int, input().split()))





def runLengthEncode(S: str):
    grouped = groupby(S)
    res = []
    for k, v in grouped:
        res.append((k, str(len(list(v)))))
    return res


if __name__ == "__main__":
    n = int(input())
    cnt = 0
    for i in range(n):
        d, e = iparse()
        if d == e:
            cnt += 1
        else:
            cnt = 0
            
        if cnt == 3:
            print("Yes")
            exit()
    print("No")

Solution (Python):
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n = ni()

a = 0
for i in range(n):
    d,dd = na()
    if d == dd:
        a += 1
    else:
        a = 0
    if a >= 3:
        print('Yes')
        exit()

print('No')

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

cnt = 0
ans = False
for _ in range(n):
    a,b = map(int, input().split())
    if a == b:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        ans = True

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

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

Solution (Python):
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
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 main():
    n = i_input()
    cnt = 0
    for i in range(n):
        a,b = i_map()
        if a == b:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            print("Yes")
            exit()
    print("No")




if __name__=="__main__":
    main()

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

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'); exit()
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]:
        if cnt == 2:
            print("Yes")
            exit()
        else:
            cnt += 1
    else:
        cnt = 0

print("No")

Solution (Python):
"""
                            pppppppppppppppppppp
                         ppppp  ppppppppppppppppppp
                      ppppppp    ppppppppppppppppppppp
                      pppppppp  pppppppppppppppppppppp
                      pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
       ppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppp
      pppppppppppppppppppppppppppppppppppppppppppppppp  ppppppppppppppppppppp
     ppppppppppppppppppppppppppppppppppppppppppppppppp  pppppppppppppppppppppp
    ppppppppppppppppppppppppppppppppppppppppppppppp    pppppppppppppppppppppppp
   pppppppppppppppppppppppppppppppppppppppppppppp     pppppppppppppppppppppppppp
  ppppppppppppppppppppppppppppppppppppppppppppp      pppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppppppp               pppppppppppppppppppppppppppppppp
  pppppppppppppppppppppppppppp     pppppppppppppppppppppppppppppppppppppppppppppp
  ppppppppppppppppppppppppppp    pppppppppppppppppppppppppppppppppppppppppppppppp
    pppppppppppppppppppppppp  pppppppppppppppppppppppppppppppppppppppppppppppppp
     ppppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppppp
      pppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppppp
       ppppppppppppppppppppp  ppppppppppppppppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppppp
                              pppppppppppppppppppppppppppppppp
                              pppppppppppppppppppppp  pppppppp
                              ppppppppppppppppppppp    ppppppp
                                 ppppppppppppppppppp  ppppp
                                    pppppppppppppppppppp
"""


import sys
from functools import lru_cache, cmp_to_key
from collections import defaultdict as dd, deque, Counter as C
from bisect import bisect_left as bl, bisect_right as br, bisect
from heapq import heapify, heappop, heappush
from math import ceil, log, floor, sqrt
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(var, end="\n"): sys.stdout.write(str(var)+end)
def outa(*var, end="\n"): sys.stdout.write(' '.join(map(str, var)) + end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]


cnt = 0
maxi = 0
for _ in range(int(data())):
    a, b = sp()
    if a == b:
        cnt += 1
        continue
    maxi = max(maxi, cnt)
    cnt = 0
maxi = max(cnt, maxi)
out(("Yes", "No")[maxi < 3])

Solution (Python):
N,*f = map(int, open(0).read().split())
D = [f[i*2:i*2+2] for i in range(N)]
count = 0
for x in D:
    if x[0] == x[1]:
        if count == 2:
            print('Yes')
            break
        else:
            count += 1
    else:
        count = 0
else:
    print('No')

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

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



if __name__=="__main__":
    solve()

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, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log,floor
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
tillnow = 0
for _ in range(n):
    a,b = MAP()

    if(a==b):
        tillnow+=1
    else:
        tillnow = 0
    if(tillnow==3):
        print("Yes")
        exit()
print('No')

Solution (Python):
n = int(input())
num = 0
flag = False
mx = 0
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        if flag:
            num += 1
        else:
            flag = True
            num = 1
    else:
        flag = False
        num = 0
    mx = max(mx, num)

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

Solution (Python):
n=int(input())
ans=chk=0
for i in range(n):
    a,b=map(int,input().split())
    if a==b: chk+=1
    else: chk=0
    ans=max(ans,chk)

print("Yes" if ans>2 else "No")

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

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

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

max_zoro = 0
zoro = 0

for _ in range(N):
  a,b = map(int, input().split())
  if a==b:
    zoro += 1
    max_zoro = max(max_zoro, zoro)
  else:
    zoro = 0

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

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

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


if __name__ == '__main__':
    resolve()

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

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

count = 0
for d1, d2 in D:
  if d1 == d2:
    count += 1
  else:
    count = 0
  if count == 3:
    print("Yes")
    break
else:
  print("No")

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

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

Solution (Python):
def main():
    n = int(input())
    count = 0
    res = False
    for _ in range(n):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            count += 1
            if count >= 3:
                res = True
        else:
            count = 0
    if res:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
streak = 0
max_streak = 0
for _ in range(N):
    D1, D2 = input().split()
    if D1==D2:
        streak += 1
        max_streak = max(max_streak, streak)
    else:
        streak = 0

print('Yes' if max_streak>=3 else 'No')

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

if __name__ == "__main__":
    main()

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

ch=0
l=0

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

if ch>0:

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

Solution (Python):
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):

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

Solution (Python):
n = int(input())
D = [[int(x) for x in input().split()] for _ in range(n)]
print('Yes' if any(a[0] == a[1] and b[0] == b[1] and c[0] == c[1] for a, b, c in zip(D, D[1:], D[2:])) else 'No')

Solution (Python):
n = int(input())
arr = []
for i in range(n):
    x,y = list(map(int,input().split()))
    arr.append([x,y])
f = 0
cnt = 0
for i in arr:
    if i[0]==i[1]:
        cnt+=1
        if cnt==3:
            f = 1
    else:
        cnt = 0
if f==1:
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7

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

        
        
        
        



        
        
        
        
        
    
if __name__=="__main__":
    main()

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

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

count = 0
flg = False

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

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

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

Solution (Python):
N = int(input())
D = [[int(d) for d in input().split()] for _ 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"
        break
print(ans)

Solution (Python):
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush

from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
import time

starttime = time.time()

mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def L(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]

try:
    
    sys.stdin = open("input.txt", "r")
    
except:
    pass




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






endtime = time.time()

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

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

    if count == 3:
        ans = True
        break

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

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

Solution (Python):

MOD = 10 ** 9 + 7
INFI = 10**10

import math
from collections import deque
import itertools
import heapq

from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint




def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default




def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def soinsubunkai_e(n,m): 
    a = set()
    i = 1
    while n>1:
        a.add(m[n])
        n=n//m[n]
    nokori=n
    a.add(nokori)
    return a

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


def era(n): 
    b=[i for i in range(n+1)]
    for i in range(2,int(math.sqrt(n)+10)):
        j=1
        temp=i*j
        while temp<=n:
            b[temp]=min(i,b[temp])
            temp+=i
    return b


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





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())
Dice = [[int(i) for i in input().split()] for j in range(N)]

zorome = 0
for d1, d2 in Dice:
    if d1 == d2:
        zorome += 1
    else:
        zorome = 0
    if zorome == 3:
        print('Yes')
        break
else:
    print('No')

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

Solution (Python):

N=int(input())

ok=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:
        ok=True
        break

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

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

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

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

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

if ans > 0:
    print("Yes")
else:
    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')
        exit()

print('No')

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

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

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

Solution (Python):
def main():
    examB()

def examA():
    S = SI()
    if S[-1]=="s":
        ans = S+"es"
    else:
        ans = S+"s"
    print(ans)
    return

def examB():
    N = I()
    D = [LI()for _ in range(N)]
    current = 0
    for d1,d2 in D:
        if d1==d2:
            current += 1
        else:
            current = 0
        if current==3:
            print("Yes")
            return
    print("No")
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,alphabet_convert,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 1<<31
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    main()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

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

Solution (Python):
import sys
import math


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


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

    k=0
    for i in range(N):
        d,e =map(int,input().split())
        if e==d:
            k+=1
        else:
            k=0
        if k==3:
            print("Yes")
            exit()

    print("No")






if __name__ == "__main__":
    main()

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

d=[]
for _ in range(n):
    x,y=map(int,input().split())

    d.append((x,y))

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

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

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

count = 0
success = False
for _ in range(N):
	D1, D2 = input().split()
	if D1 == D2:
		count += 1
	else:
		count = 0
	if count >= 3:
		success = True

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

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

def main():
    N = int(input())
    zoro = 0
    for _ in range(N):
        x, y = map(int, input().split())
        if x == y:
            zoro += 1
        else:
            zoro = 0
        if zoro == 3:
            print("Yes")
            return
    print("No")



if __name__ == "__main__":
    main()

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

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

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

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

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

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

N = int(input())
D = [LI() for _ in range(N)]


def main():
    m = 0
    x = 0
    for a, b in D:
        if a == b:
            x += 1
            m = max(m, x)
        else:
            x = 0
    ans = "Yes" if m >= 3 else "No"
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
D = [tuple(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')
        break
else:
    print('No')

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

Solution (Python):

import sys
input = sys.stdin.readline

n = int(input())
zoro = []
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        zoro.append(1)
    else:
        zoro.append(0)

for z1, z2, z3 in zip(zoro, zoro[1:], zoro[2:]):
    if z1 + z2 + z3 == 3:
        print("Yes")
        exit()
print("No")

Solution (Python):
n = int(input())
cnt = 0
yes = 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1==d2:
        cnt += 1
        if cnt==3:
            yes = 1
    else:
        cnt = 0

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