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

first = []
second = []

for i in range(n):
    x,y = map(int,input().split())
    first.append(x)
    second.append(y)
count = 0
flag = 1
for i in range(n):
    if first[i] == second[i]:
        count += 1
        if count == 3:
            flag = 0
            print("Yes")
            break
    else:
        count = 0

if flag:
    print("No")

Solution (Python):
n=int(input())
ans='No'
daice=[]
for i in range(n):
  daice.append(list(map(int,input().split())))
for j in range(n-2):
  if daice[j][0]==daice[j][1]:
    if daice[j+1][0]==daice[j+1][1]:
      if daice[j+2][0]==daice[j+2][1]:
        ans='Yes'
print(ans)

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

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

count = 0
ans = "No"

for i in range(n):
    if A[i][0] == A[i][1] and count == 0:
        count = 1
    elif A[i][0] == A[i][1] and count == 1:
        count = 2
    elif A[i][0] == A[i][1] and count == 2:
        ans = "Yes"
        break
    else:
        count = 0


print(ans)

Solution (Python):
N = int(input())
cnt = 0
ok = False
for _ in range(N):
    D1, D2 = [int(x) for x in input().split()]
    if D1 == D2:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        ok = True

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

Solution (Python):
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json

import bisect
import sys
import math
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


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

    
    
    

    flag = False
    for i in range(N - 2):
        d1 = D[i]
        d2 = D[i + 1]
        d3 = D[i + 2]
        if d1[0] == d1[1] and d2[0] == d2[1] and d3[0] == d3[1]:
            flag = True
            break
    if flag:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()

Solution (Python):
N = int(input())
flg =0
for i in range(N):
    d1,d2 = map(int,input().split())
    if d1 != d2 :
        flg = 0
        continue
    elif d1 == d2:
        flg += 1
    
    if flg >= 3:
        break

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

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

Solution (Python):
num = input()
d = []
num = int(num)
for n in range(num):
    t, s = input().split()
    d.append([t,s])
flag = 0
for n in range(num):
    if(n<num-2):
        if(d[n][0]==d[n][1] and d[n+1][0]==d[n+1][1] and d[n+2][0]==d[n+2][1]):
            flag = 1
if flag == 1:
    print('Yes')
else:
    print('No')

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

count = 0

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

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

Solution (Python):
import io,sys
sys.setrecursionlimit(10**6)
def main(): 
    n = int(input())
    D = []
    for _ in range(n):
        a,b = map(int,input().split())
        D.append(a-b)
    
    for i in range(n-2):
        if D[i]==0 and D[i+1]==0 and D[i+2]==0:
            print("Yes")
            sys.exit()
    
    print("No")

main()

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

cnt = 0
flag = False
for d1, d2 in dices:
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0

    if cnt >= 3:
        flag = True
        break

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

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

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

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

Solution (Python):
import sys

def solve():
      input = sys.stdin.readline
      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]:
                  if D[i+1][0] == D[i+1][1]:
                        if D[i + 2][0] == D[i+2][1]:
                              print("Yes")
                              return 0
      print("No")

      return 0

if __name__ == "__main__":
      solve()

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

Solution (Python):
n=int(input())
ans=0
flag=0

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

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

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

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

flg = False
cnt = 0

for i in D:
    a, b = i[0], i[1]
    if a == b:
        cnt += 1

    else:
        cnt = 0

    if cnt >= 3:
        flg = True
        break
if flg:
    print('Yes')
else:
    print('No')

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

Solution (Python):
N=int(input())
D=[]
count=0
ans=0
for i in range(N):
    a,b=map(int,input().split())
    D.append([a,b])
    if a==b:
        count+=1
    else:
        count=0
    if count==3:
        ans+=1
if ans>=1:
    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')
            break
    else:
        cnt = 0

if cnt < 3:
    print('No')

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

flag = False
ans = 0
for _ in range(N):
    x, y = map(int, input().split())
    if x == y:
        ans += 1
        if ans >= 3:
            flag = True
    else:
        ans = 0
if flag:
    print('Yes')
else:
    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):
N = int(input())

zoro = 0
ans = False
for i in range(N):
    x, y = [int(x) for x in input().split()]
    if x == y:
        zoro += 1
    else:
        zoro = 0
    if zoro >= 3:
        ans = True

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

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

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

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

Solution (Python):
n = int(input())
ans = "No"
zoro = 0

for i in range(n):
    d1,d2 = input().split()
    
    if d1 == d2:
        zoro += 1
    else:
        zoro = 0
        
    if 2 < zoro:
        ans = "Yes"
        
print(ans)

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

cnt = 0
for i in range(n):
    if D[i][0] == D[i][1]:
        cnt += 1
        if cnt >= 3:
            break
    else:
        cnt = 0


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

Solution (Python):



n = int(input())

renzoku = 0
renzoku3 = 0

for i in range(n):
    numbers = input().split(" ")
    d1 = int(numbers[0])
    d2 = int(numbers[1])

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

    if renzoku == 3:
        renzoku3 = 1


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

Solution (Python):
c = t = 0
for _ in range(int(input())):
    x, y = input().split()
    if x==y:
        c+=1
    else:
        c = 0
    t = max(t,c)
if t>=3: print('Yes')
else: print('No')

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

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

for p in range(N):
    if D[p][0] == D[p][1]:
        flag += "1"
    else:
        flag += "0"

if "111" in flag:
    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):
N = int(input())
cnt = 0
ans = 'No'
for i in range(N):
    x,y = [int(x) for x in input().split()]
    if x == y:
        cnt += 1
        if cnt == 3:
            ans = 'Yes'
    else:
        cnt = 0
        

print(ans)

Solution (Python):
n = int(input())
count=0
check_flag = False
for i in range(n):
    s,t = map(int,input().split())
    if s==t:
        count+=1
    else:
        count=0
    if count == 3:
        check_flag = True
if check_flag:
    print('Yes')
else:
    print('No')

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

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

Solution (Python):
if __name__ == '__main__':

	n = int(input())
	
	cnt=0
	flg = False
	for i in range(n):
		x,y = map(int,input().split())
		
		if x == y:
			cnt += 1
			if cnt == 3:
				flg=True
		else:
			cnt = 0

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

Solution (Python):




import sys
input = sys.stdin.readline



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

    res = 'No'
    cnt = 0

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

    print(res)



main()

Solution (Python):
if __name__ == '__main__':
    n = int(input())
    max = 0
    count = 0
    for i in range(n):
        b, c = map(int, input().split())
        if b == c:

            count+=1
            if max < count:
                max=count
        else:
            count=0
    if max>2:
        print("Yes")
    else:
        print("No")

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

Solution (Python):
import sys
from math import ceil as C, floor as F, sqrt, gcd as G
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data) 

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

n = I()

c = 0
found = False
for i in range(n):
    j, k = I()
    if j == k:
        c += 1
    else:
        c = 0
    
    if c >= 3:
        found = True
        break

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

Solution (Python):
n, *D = map(int, open(0).read().split())
s = 0
for d1, d2 in zip(D[::2], D[1::2]):
    if d1==d2:
        s += 1
    else:
        s = 0
    if s >= 3:
        print('Yes')
        break
else:
    print('No')

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

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

print('No')

Solution (Python):
num = int(input())
count = 0
for i in range(num):
  ab = input().split(" ")
  a = int(ab[0])
  b = int(ab[1])
  if a == b:
    count += 1
    if count >= 3:
      break
  else:
    count = 0
if count >= 3:
  print("Yes")
else:
  print("No")

Solution (Python):
s = int(input())
ok = 0
c = 0
for _ in range(s):
  x,y = list(map(int,input().split()))
  
  if x==y:
    c+=1
    
  else:
    c=0

  if c==3:
    ok = 1
    
if ok==1:
  print('Yes')
else:
  print('No')

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

x = [0] * (n + 2)
y = [0] * (n + 2)

ok = False 

for i in range(n):
    x[i],y[i] = map(int,input().split())
    
for i in range(n):
    if i + 2 < n :
        if (x[i],x[i + 1],x[i + 2]) == (y[i],y[i + 1],y[i + 2]):
            ok = True

print("Yes" if ok == True else "No")

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

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

for i in range(n):
    d1, d2 = d[i]
    if d1==d2:
        num += 1
        ans = max(ans, num)
    else:
        num = 0

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

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

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

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(N: int, D: "List[List[int]]"):
    n = 0
    for d in D:
        if d[0] == d[1]:
            n += 1
        else:
            n = 0
        if n == 3:
            print(YES)
            break
    else:
        print(NO)
    
    
    
    
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    D = [[int(next(tokens)) for _ in range(2)] for _ in range(N)]  
    solve(N, D)

if __name__ == '__main__':
    main()

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

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

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

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

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

count = 0

for i in range(n-1):
  if count == 2:
    break
  elif d[i][0] == d[i][1] and d[i+1][0] == d[i+1][1]:
    count += 1
  else:
    count = 0
    
if count == 2:
  print("Yes")
else:
  print("No")

Solution (Python):
n = int(input())
c = []
ans = "No"
for _ in range(n):
    a, b = map(int, input().split())
    c.append(a==b)
for i in range(n-2):
    if c[i] and c[i+1] and c[i+2]:
        ans = "Yes"

print(ans)

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

D1 = []
D2 = []

for i in range(N):
  s = input().split()
  D1.append(int(s[0]))
  D2.append(int(s[1]))
  
result = 'No'  
  
for i in range(N-2):
  if D1[i] == D2[i]:
    if D1[i+1] == D2[i+1] and D1[i+2] == D2[i+2]:
      result = 'Yes'
      
print(result)

Solution (Python):
count=[]
for _ in range(int(input())):
    a,b=map(int,raw_input().split())
    if a==b:
        count.append(_)
flag=False

for i in range(1,len(count)-1):
    if count[i]-1==count[i-1] and count[i]+1==count[i+1]:
        flag=True
        print "Yes"
        break
if flag==False:
    print "No"

Solution (Python):

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

Solution (Python):
n= int(input())
L = [input().split() for _ in range(n)]
i=0
for item in L:
  if item[0] == item[1]:
    i=i+1
    if i ==3:
      break
  else:
    i=0
print('Yes' if i == 3 else 'No')

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

cnt = 0
flg = 0

for i in lis:
    if i[0]==i[1]:
        cnt += 1
        if cnt >= 3:
            flg = 1
    else:
        cnt = 0

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

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

Solution (Python):
n = int(input())
zorome = 0
yes = False

for i in range(n):
  x, y = map(int, input().split())
  if x == y:
    zorome += 1
    if zorome >= 3:
      yes = True
  else:
    zorome = 0

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

Solution (Python):
from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache   
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')

def input(): return sys.stdin.readline()
def mapi(arg=0): return map(int if arg==0 else str,input().split())




n = int(input())
a = []
for i in range(2):
    a.append(list(mapi()))
f = 0
for i in range(2,n):
    a.append(list(mapi()))
    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]:
        f = 1
if f:
    print("Yes")
else:
    print("No")

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

    count = 0
    answer = 'No'
    for i in range(n):
        d = list(map(int, input().split()))
        if d[0] == d[1]:
            count += 1
        else:
            count = 0
        if count >= 3:
            answer = 'Yes'

    print(answer)


if __name__ == '__main__':
    main()

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

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

count = 0
for i in range(n):
  ds = input().split()
  d1 = ds[0]
  d2 = ds[1]
  
  if d1 == d2:
    count += 1
  else:
    count = 0
  
  if count == 3:
    print("Yes")
    break
else:
  print("No")

Solution (Python):
n = int(input())
renzoku = 0
for i in range(n):
	d = [int(each) for each in input().split()]
	if d[0] == d[1]:
		renzoku += 1
		if renzoku == 3:
			print('Yes')
			break
	else:
		renzoku = 0
else:
	print('No')

Solution (Python):
def calc(N, D):
    c = 0
    for (d1, d2) in D:
        if d1 == d2:
            c += 1
            if c == 3:
                return 'Yes'
        else:
            c = 0
    return 'No'


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

Solution (Python):

n = int(input())
L=[]
for i in range(n):
    a, b = map(int,input().split())
    if a==b:
        L.append(1)
    else:
        L.append(0)
flg=False
for i in range(n-2):
    if L[i] and L[i+1] and L[i+2]:
        flg=True
        break

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

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

Solution (Python):
N = int(input())
count = 0
TF = False
for i in range(N):
    Ds = list(map(int, input().split()))
    if  Ds[0] == Ds[1]:
        count += 1
    else:
        count = 0
    if count == 3:
        TF = True
        break

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

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


for i in range(N):
    if i + 2 > N - 1:
        break
    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
isOK = False
for i in range(n):
  x,y = map(int,input().split())
  if x==y:
    cnt += 1
  else:
    cnt = 0
  if cnt>=3:
    isOK = True
    break



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

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

current = 0
found = False
for i in range(len(rolls)):
    if rolls[i][1] == rolls[i][0]:
        current += 1
    else:
        current = 0
    if current == 3:
        found = True

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

Solution (Python):
import sys
n=int(input())
ans=0
for i in range(n):
    d1,d2=map(int,input().split())
    if ans==3:
        continue
    if d1==d2:
        ans+=1
    else:
        ans=0
if ans==3:
    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='No'
for p in range(n-2):

    if x[p] == y[p] and x[p+1] == y[p+1] and x[p+2] == y[p+2] :
        ans='Yes'
        break

print(ans)

Solution (Python):
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前
sort()
sorted(reverse=true)
配列の初期化
配列名=[a]*n+[b]*m
Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions
import sys
t = False
n = stdin.readline().rstrip()
count = 0
for el in range(int(n)):
    tmp = stdin.readline().rstrip().split()
    a = int(tmp[0])
    b = int(tmp[1])
    if a == b:
        count += 1
    else:
        count = 0
    if count >= 3:
        t = True
if t:
    print('Yes')
else:
    print('No')

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

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

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

print("No")

Solution (Python):
n = int(input())
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-2):
    if x[i] == y[i]:
        if x[i+1] == y[i+1]:
            if x[i+2] == y[i+2]:
                ans += 1

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

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

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

    if cnt >=3:
        ans = 'Yes'

print(ans)

Solution (Python):

N = int(input())
count = 0
flag = False
for i in range(N):
  Di, Dj = map(int, input().split())
  if Di == Dj:
    count += 1
    if count == 3:
      flag = True
  else:
    count = 0
if flag == True:
  print("Yes")
else:
  print("No")

Solution (Python):
n = int(input())
count = 0 
flag = 0 
for i in range(n):
    
    temparr = input()
    temparr = temparr.split()
    first = int(temparr[0])
    sec = int(temparr[1])
    if first == sec:
        count += 1 
    else:
        count = 0 
    if count == 3:
        flag = 1 

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

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

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

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

print(ans)

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

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

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

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

ans = 0
flg = False
tmp = 0
for c,d in D:
    if c==d:
        if flg:
            tmp += 1
            ans = max(ans, tmp)
        else:
            tmp = 1
            flg = True
            ans = max(ans, tmp)
    else:
        flg = False

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

Solution (Python):
import sys

N = int(input())
def c(s):
  return s[0] == s[1]
DS = [c(input().split()) for _ in range(N)]


for i in range(2, N):
  if DS[i-2] and DS[i-1] and DS[i]:
    print('Yes')
    sys.exit()

print('No')

Solution (Python):
n = int(input())
dat = []
for q in range(n):
    a, b = map(int, input().split())
    dat.append([a,b])
can = False
for i in range(2, n):
    if dat[i-2][0] == dat[i-2][1] and dat[i-1][0] == dat[i-1][1] and dat[i][0] == dat[i][1]:
        can = True
print("Yes" if can else "No")

Solution (Python):


import sys
N = int(input())
D1 = list()
D2 = list()
for i in range (N):
    a , b = input().split()
    D1.append(a)
    D2.append(b)
s = 0
for i in range (N):
    if D1[0] == D2[0]:
        s = s + 1
    else:
        s = 0
    if s == 3:
        print("Yes")
        sys.exit()        
    del D1[0]
    del D2[0]
print('No')

Solution (Python):
n=int(input())
cnt=0
flag=1
for k in range(n):
    i,j= list(map(int, input().split()))
    if i==j:
        cnt+=1
    elif i!=j and cnt!=0:
        cnt=0
    if cnt>2:
        flag=0
if flag==0:
    print("Yes")
else:
    print("No")

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

Solution (Python):
N = int(input())
count, bre = 0, 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')
    bre = 1
    break
if bre==0:
  print('No')

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

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

Solution (Python):

N = int(input())

D = input().split()
x = D[0] == D[1]
D = input().split()
y = D[0] == D[1]

for i in range(N - 2):
  D = input().split()
  z = D[0] == D[1]
  if x and y and z:
    print('Yes')
    exit()
  else:
    x = y
    y = z
    
print('No')

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

print(ANS)

Solution (Python):

n = int(input())
a = [list(map(int, input().split())) for l in range(n)]
count = 0
ans = 0
for i in range(n):
  if a[i][0] == a[i][1]:
    count += 1
  else:
    count = 0
  if count >= 3:
    ans = 1
if ans == 1:
  print('Yes')
else:
  print('No')

Solution (Python):
n=int(input())
flag=0
flag2=0
for r in range(n):
    x,y=map(int,input().split())
    if x==y:
        flag+=1
        if flag==3:
            flag2=1
    else:
        flag=0
if flag2==1:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
df_de = [list(map(int, input().split())) for _ in range(n)]
ans = 0
cand = []
for d1, d2 in df_de:
    if d1 == d2:
        ans += 1
    else:
        cand.append(ans)
        ans = 0
cand.append(ans)
print("Yes" if len([i for i in cand if i >= 3]) else "No")

Solution (Python):
from sys import stdin
def I():
    return stdin.readline().rstrip()
def MI():
    return map(int,stdin.readline().rstrip().split())
def LI():
    return list(map(int,stdin.readline().rstrip().split()))

n=int(I())
l=[0]*n
for i in range(n):
    a,b=MI()
    if a==b:
        l[i]=1
ans='No'
for j in range(2,n):
    if l[j]==1 and l[j-1]==1 and l[j-2]==1:
        ans='Yes'
        break
print(ans)