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())
c=0
m=1
for i in [0]*n:
    a,b=map(int,input().split())
    if a==b:
        c+=1
        if c==3:
            m=0
    else:
        c=0
print('YNeos'[m==1::2])

Solution (Python):

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

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

Solution (Python):
import sys
from sys import stdin,stdout
import math
import random
import heapq
from collections import Counter
from functools import lru_cache

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







    
except EOFError as e:
    print(e)

Solution (Python):
N = int(input())
count = 0
ok = False
for _ in range(N):
    d1, d2 = [int(s) for s in input().split()]
    if d1 == d2:
        count += 1
    else:
        count = 0
    if count == 3:
        ok = True
if ok:
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(N)]
    tmp_zoro = 0
    ans = 0
    for i in range(len(A)):
        if A[i][0] == A[i][1]:
            tmp_zoro += 1
        else:
            tmp_zoro = 0 
        ans = max(ans, tmp_zoro)

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


if __name__ == '__main__':
    main()

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

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

zoro = 0
isZoro = False
for _ in range(n):
	d1, d2 = map(int, input().split())
	if d1 == d2:
		zoro += 1
	else:
		zoro = 0

	if zoro >= 3:
		isZoro = True
		break
		
if isZoro:
	print("Yes")
else:
	print("No")

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    D = [LI() 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)

if __name__ == '__main__':
    resolve()

Solution (Python):
n = int(input())
d1 = []
d2 = []
for i in range(n):
    dice1, dice2 = map(int, input().split())
    d1.append(dice1)
    d2.append(dice2)
count = 0
for i in range(n - 1):
    if (d1[i] == d2[i]) and (d1[i + 1] == d2[i + 1]):
        count += 1
    else:
        count = 0
    if count == 2:
        print('Yes')
        break
if count != 2:
    print('No')

Solution (Python):
N = int(input())
cnt = 0
t = 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")
        t = 1
        break
if t == 0:
    print("No")

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

count = 0
count_max=0
for i in range(n):
    if d_list[i][0]==d_list[i][1]:
        count += 1
        if count>count_max:
            count_max=count 
    else:
        count = 0

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

Solution (Python):

def input_array():
	return list(map(int,input().split()))
  
n=int(input())
D=[input_array() for i in range(n)]

count=0
for d in D:
	if d[0]==d[1]:
		count+=1
	else:
		count=0

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

Solution (Python):


from sys import stdin, stdout
from math import *

testing = True

def tp(s="\n"):
	if testing:
		stdout.write(s)

def main():
	n = int(stdin.readline())
	occurs = False
	doubles = 0
	for i in range(n):
		d1, d2 = [int(i) for i in stdin.readline().split()]
		if d1 == d2:
			doubles += 1
			if doubles == 3:
				occurs = True
				break
		else:
			doubles = 0
	if occurs:
		stdout.write('Yes\n')
	else:
		stdout.write("No\n")
        
main()

Solution (Python):
n = int(input())
same = [0 for _ in range(n)]
for i in range(n):
  d1, d2 = map(int, input().split())
  if d1 == d2:
    same[i] = 1

for i in range(n):
  if sum(same[i-1:i+2]) == 3:
    print("Yes")
    exit()
    
print("No")

Solution (Python):
def N():
    return int(input())
def L():
    return list(map(int,input().split()))
def NL(n):
    return [list(map(int,input().split())) for i in range(n)]
mod = pow(10,9)+7


n = N()
d = NL(n)
cnt = 0
p = 1
ma = 0
for i in range(n):

    if d[i][0] == d[i][1] :
        if p == 1:
            cnt += 1
        else:
            cnt += 1
            p == 1
    else:
        cnt = 0
        p = 0
    ma = max(ma,cnt)

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

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

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

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

Solution (Python):
def readinput():
    n=int(input())
    ab=[]
    for _ in range(n):
        a,b=map(int,input().split())
        ab.append((a,b))
    return n,ab

def main(n,ab):
    count=0
    for a,b in ab:
        if a==b:
            count+=1
            if count>=3:
                return 'Yes'
        else:
            count=0
    return 'No'

if __name__=='__main__':
    n,ab=readinput()
    ans=main(n,ab)
    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:
            print('Yes')
            exit()
    else:
        cnt=0
print('No')

Solution (Python):
from sys import stdin, stdout
import math
inp = lambda : stdin.readline().strip()
 
n = int(inp())
a = []
b = []
for i in range(n):
    d1, d2 = [int(x) for x in inp().split()]
    a.append(d1)
    b.append(d2)
c = 0
for i in range(n):
    if  a[i] == b[i]:
        c += 1
    else:
        c = 0
    if c == 3:
        print("Yes")
        break
else:
    print("No")

Solution (Python):

import sys

def main():
    input = sys.stdin.readline
    n = int(input())
    flag = False
    for _ in range(n):
        a, b = map(int, input().split())
        if flag:
            if a == b:
                cnt += 1
                if cnt >= 3:
                    print("Yes")
                    exit()
            else:
                flag = False
                cnt = 0
        else:
            if a == b:
                flag = True
                cnt = 1
    print("No")
    

if __name__ == '__main__':
    main()

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

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

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

ans = 'No'
cnt = 0
for x in d:
  if x[0] == x[1]:
    cnt += 1
    if cnt >= 3:
      ans = 'Yes'
      break
  else:
    cnt = 0
    
print(ans)

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

if count >= 3:
  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"
        break

print(ans)

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

c = 0
for i in range(N):
  if d[i][0] == d[i][1]:
    c += 1
  else:
    c = 0
  if c == 3:
    print('Yes')
    exit()

print('No')

Solution (Python):
n = int(input())
d = [tuple(map(int, input().split())) for i 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] and d[i + 2][0] == d[i + 2][1]:
      print('Yes')
      break
else:
  print('No')

Solution (Python):








n = int(input())
d = [list(map(int, input().split())) for _ 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]:
        print("Yes")
        flag = 1
        break

if flag == 0:
    print("No")

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

print(ans)

Solution (Python):
from sys import stdin
inp = lambda : stdin.readline().strip()

t = int(inp())
counter = 0
f = False
for _ in range(t):
    a = [int(x) for x in inp().split()]
    if a[0] == a[1]:
        counter += 1
        if counter == 3:
            f = True
    else:
        counter = 0
if f:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
counter = 0
ans = False
for i in [0] * N:
    input_list = list(map(int,input().split()))
    if input_list[0] is input_list[1]:
        counter += 1
        if counter >= 3:
            ans = True
    else:
        counter = 0
if ans:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
import collections as cc
import bisect as bi
I=lambda:list(map(int,input().split()))
n,=I()
ar=[I() for i in range(n)]
tf=0
for i in range(n-3+1):
	if ar[i][0]==ar[i][1] and ar[i+1][0]==ar[i+1][1] and ar[i+2][0]==ar[i+2][1]:
		tf=1
print("Yes" if tf else "No")

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

Solution (Python):
def resolve():
    n = int(input())
    res = [0]*n
    for i in range(n):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            res[i] = 1
    OK = False
    for i in range(2, n):
        if res[i]== 1 and res[i-1] == 1 and res[i-2] == 1:
            OK = True
    if OK:
        print("Yes")
    else:
        print("No")
resolve()

Solution (Python):
import sys
N=int(input())
D=[list(map(int,input().split()))for _ in range(N)]
for i in range(N-2):
    if all(D[i+j][0]==D[i+j][1] for j in range(3)):
        print('Yes')
        sys.exit()
print('No')

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

print(A)

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

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

Solution (Python):
n = int(input())
ren = 0
ans = 'No'

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

print(ans)

Solution (Python):
import sys
N=int(sys.stdin.readline().strip())
cnt=0
for _ in range(N):
    d1,d2=map(int, sys.stdin.readline().split())
    if d1==d2:
        cnt+=1
    elif d1!=d2:
        cnt=0
    if cnt==3:
        print "Yes"
        quit()
else:
    print "No"

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

ans = 0

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

print("No")

Solution (Python):
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    ans = 0
    temp = 0
    for _ in range(n):
        d1, d2 = MI()
        if d1 == d2:
            temp += 1
        else:
            temp = 0
        ans = max(ans, temp)
    if ans >= 3:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

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

def is_doublet(v):
    return v[0] == v[1]

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

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

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

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

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

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

    if a == b:
        count += 1
    else:
        count = 0

    if count >= 3:
        print('Yes')
        exit(0)

print('No')

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

count = 0
flag = False
for _ in range(N):
  D1, D2 = map(int, input().split())
  if D1 == D2:
    count +=1
  else:
    count = 0

  if count == 3:
    flag = True


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

Solution (Python):
n = int(input())
s = "aaa"
for i in range(n):
  d1 , d2 = map(int,input().split(" "))
  if d1 == d2:
    s += "b"
  else:
    s += "c"

if "bbb" in s:
  print("Yes")
else:
  print("No")

Solution (Python):
n = int(input())
d = list(list(map(int,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")
                break
else:
    print("No")

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

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

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

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

Solution (Python):
def main():
    N = int(input())
    same = list()

    for i in range(N):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            same.append(True)
        else:
            same.append(False)
    
    for i in range(N-2):
        if same[i] and same[i + 1] and same[i + 2]:
            print("Yes")
            exit()
    
    print("No")

if __name__ == "__main__":
    main()

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

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

print(ans)

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

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

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

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

Solution (Python):
import sys
import math

import random

input = sys.stdin.readline
 

def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))



n=inp()
ara=[]
for i in range(n):
	a,b=invr()
	ara.append([a,b])

for i in range(n-2):
	if ara[i][0]==ara[i][1]:
		if ara[i+1][0]==ara[i+1][1]:
			if ara[i+2][0]==ara[i+2][1]:
				print("Yes")
				exit(0)

print("No")

Solution (Python):

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


cnt=0
flg=0
for i in range(N):
    if cnt==3:
        flg=1
        break
    elif DD[i][0]==DD[i][1]:
        cnt+=1
    else:
        cnt=0

if cnt==3:
    flg=1

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

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

Solution (Python):
import sys

input = sys.stdin.readline

n = int(input())

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

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

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

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

Solution (Python):
n=int(input())
li=""
for _ in range(n):
    a,b = (int(x) for x in input().split())
    if a==b:
        li+="t"
    else:
        li+="s"
print("Yes" if "ttt" in li else "No")

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

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

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

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

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

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

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

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

d=[d_[0]==d_[1] for d_ in d]


c=0
for i in d:
    if i:
        c+=1
        if c>=3:
            print("Yes")
            exit()
    else:
        c=0
print("No")

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

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

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

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

Solution (Python):
from math import *

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

def cins(): 
    return input.split()

def cino(test=False): 
    if not test:
        return int(input())
    else: 
        return input()

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

def ssplit(): 
    return list(input().split())

def printlist(l): 
    for i in l:
        print(i,end=" ")

def main():
    n = cino()
    l = []
    for i in range(n):
        a,b = cin()
        l.append([a,b])
    check = True
    for i in range(n-2):
        if l[i][0] == l[i][1] and l[i+1][0] == l[i+1][1] and l[i+2][0] == l[i+2][1]:
            print("Yes")
            check = False
            break
    if check:
        print("No")
        

if __name__ == '__main__':
    main()

Solution (Python):
import sys

def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))

def main():
    n = II()
    dd = [MII() for i in range(n)]
    cnt = 0
    for d1, d2 in dd:
        if d1 != d2:
            cnt = 0
        else:
            cnt += 1
        if cnt == 3:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

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


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

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

Solution (Python):
def main():
    n = int(input())
    count = 0
    for _ in range(n):
        a, b = [int(x) for x in input().split()]
        if a == b:
            count += 1
        else:
            count = 0

        if count >= 3:
            return 'Yes'
    return 'No'


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

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

Solution (Python):
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')
            exit(0)
    else:
        count = 0

print('No')

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

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

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

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

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

Solution (Python):








    






mod = int(1e9+7)

INF = 1<<50

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

def main():
    n = int(input())
    last = []
    for i in range(n):
        d1,d2 = readInt()
        if d1==d2:
            last.append(1)
        else:
            last.append(0)
    ans = False
    for i in range(n-2):
        if last[i]==1 and last[i+1]==1 and last[i+2]==1:
            ans = True
    if ans:
        print("Yes")
    else:
        print("No")
    return

if __name__=='__main__':
    main()

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):
N = int(input())

count = 0

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

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

    if count == 3:
        break

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

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

ans="No"
cnt=0

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

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

isOK=False

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

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

Solution (Python):
N=int(input())
D=[list(map(int,input().split())) for _ in range(N)]
flag=False
for i in range(N-2):
    if D[i][0]==D[i][1]:
        if D[i+1][0]==D[i+1][1] and D[i+2][0]==D[i+2][1]:
            flag=True
            break

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

Solution (Python):
import sys
import math


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

n = ini()
cont = 0
ans = 'No'
for i in range(n):
    d = inl()
    if d[0] == d[1]:
        cont += 1
    else:
        cont = 0
    if cont >= 3:
        ans = 'Yes'

print(ans)

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

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

Solution (Python):
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')
            exit()
    else:
        count = 0

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

else:
    print('No')

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

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

ans = 0

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

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