Problem:
 Score : 200 points    Problem Statement Tak performed the following action N times: rolling two dice.
The result of the i -th roll is D_{i,1} and D_{i,2} .  Check if doublets occurred at least three times in a row.
Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2} , D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.      Constraints  3 \leq N \leq 100  1\leq D_{i,j} \leq 6  All values in input are integers.         Input Input is given from Standard Input in the following format:  N  D_{1,1}  D_{1,2}  \vdots  D_{N,1}  D_{N,2}       Output Print Yes if doublets occurred at least three times in a row. Print No otherwise.        Sample Input 1 5
1 2
6 6
4 4
3 3
3 2      Sample Output 1 Yes  From the second roll to the fourth roll, three doublets occurred in a row.       Sample Input 2 5
1 1
2 2
3 4
5 5
6 6      Sample Output 2 No       Sample Input 3 6
1 1
2 2
3 3
4 4
5 5
6 6      Sample Output 3 Yes

Solution (Python):
N = int(input())
count = 0
for _ in range(N):
    c, d = [int(x) for x in input().split()]
    if c == d:
        count += 1
        if count == 3:
            print('Yes')
            exit(0)
    else:
        count = 0
print('No')

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

zoro_count = 0
OK = False

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

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

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

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

sum=0
tri=0

for n in range(N):
    X,Y = map(int, input().split())
    if X==Y:
        sum+=1
        if sum==3:
            tri=1
    else:
        sum=0

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

Solution (Python):
n = int(input())
D_1 = [0 for i in range(n)]
D_2 = [0 for i in range(n)]
for i in range(n):
    D_1[i], D_2[i] = map(int, input().split())

tmp = 0
ans = 0
for i in range(n):
    if D_1[i] == D_2[i]:
        tmp += 1
    else:
        ans = max(tmp, ans)
        tmp = 0
ans = max(tmp, ans)

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

Solution (Python):
N = int(input())
a = [0] * N
b = [0] * N

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

count = 'No'

for i in range(N-2):
    if a[i] == b[i] and a[i+1] == b[i+1] and a[i+2] == b[i+2]:
        count = 'Yes'

print(count)

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

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

Solution (Python):
import sys 
n = int(input())
lst = []
for i in range(n):
  x,y = map(int,input().split())
  if x == y:
    lst.append(i)
for i in range(len(lst)-2):
  if lst[i+1] == lst[i] +1 and lst[i+2] == lst[i+1] +1:
    print('Yes')
    sys.exit()
print('No')

Solution (Python):





N = int(input())


flag1 = False
flag2 = False
flag3 = False
c, d = map(int, input().split())
if c == d:
	flag1 = True
c, d = map(int, input().split())
if c == d:
	flag2 = True
c, d = map(int, input().split())
if c == d:
	flag3 = True

k = 3
while k < N:
	if flag1 and flag2 and flag3:
		break
	k += 1
	c, d = map(int, input().split())
	flag1 = flag2
	flag2 = flag3
	if c == d:
		flag3 = True
	else:
		flag3 = False
		




if flag1 and flag2 and flag3:
	print('Yes')
else:
	print('No')

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

Solution (Python):
N=int(input())
T=False
k=0
for i in range(N):
    D1,D2=map(int,input().split())
    if D1==D2:
        k+=1
        if k>=3:
            T=True
    else:
        k=0
if T:
    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())

def aa():
    c=0
    for i in range(N):
        D=list(map(int,input().split()))
        if(D[0]==D[1]):
            c+=1
            if(c==3):
                return 'Yes'
        else:
            c=0
    return 'No'
print(aa())

Solution (Python):
n=int(input())
xy=[map(int,input().split()) for i in range(n)]
x,y=[list(v) for v in zip(*xy)]
cnt=0
for i in range(n):
  if x[i]==y[i]:
    cnt+=1
  else:
    cnt=0
  if cnt==3:
    print('Yes')
    break
if cnt!=3:
  print('No')

Solution (Python):
z=int(input())
ind=0
c=0
for i in range(z):
  D=list(map(int, input().split()))
  if D[0]==D[1]:
    ind+=1
    if ind==3:
      c=1
      break
  else:
    ind=0
if c==1:
  print("Yes")
else:
  print("No")

Solution (Python):
n = int(input())
d = ""
for _ in range(n):
  inp = input().split()
  if inp[0]==inp[1]:
    d += "T"
  else:
    d += "F"
if d.count("TTT") > 0:
  print("Yes")
else:
  print("No")

Solution (Python):

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

    count = 0
    t = 0
    ans = "No"
    for i in range(n):
        a, b = list(map(int, input().split()))

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

        if t == 3 and count >= 3:
            ans = "Yes"

    print(ans)


main()

Solution (Python):


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

    if j>=3:
        break

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

Solution (Python):
import numpy as np

n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]
dt = np.array([int(e[0] == e[1]) for e in d])
s = dt[:n-2] + dt[1:n-1] + dt[2:]
if s.max() >= 3:
    print("Yes")
else:
    print("No")

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

flg = False
cnt = 0
for di, dj in D:
    if (di == dj):
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        flg = True
        break
if flg:
    print("Yes")
else:
    print("No")

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

if __name__ == "__main__":
    main()

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]:
        flag = 1
if flag:
    print('Yes')
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
    else:
        count = 0
    if count == 3:
        Flag = True
        break

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

Solution (Python):
def check(w):
	count=0
	flag=0
	mx=0
	for i in range(len(w)):
		if w[i][0]==w[i][1]:
			count+=1
			flag=0
		else:
			mx=max(mx,count)
			count=0
			flag=1
	if flag==0:
		mx=max(mx,count)
		
	if mx>=3:
		return 1
	else:
		return 0
			
n=int(input())
w=[]
for i in range(n):
	a,b=map(int,input().split())
	w.append([a,b])
if check(w):
	print("Yes")
else:
	print("No")

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

ans = "No"
cnt = 0

for i in range(N):
    if len(set(D[i])) == 1:
        cnt += 1
    else:
        cnt = 0
    
    if cnt >= 3:
        ans = "Yes"

print(ans)

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

  

count = 0
flag = False
for j in range(N):
  if listD[j][0] == listD[j][1]:
    count += 1
    if count >= 3:
      print("Yes")
      flag = True
      break
  else:
    count = 0
if flag == False:
  print("No")

Solution (Python):
def main():
  N = int(input())
  Ds = [list(map(int,input().split())) for x in range(N)]
  c = 0
  f = False
  for d in Ds:
    if d[0] == d[1]:
      c += 1
    else:
      c = 0
    if c == 3:
      f = True
  if f:
    print("Yes")
  else:
    print("No")

main()

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

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

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

Solution (Python):
a = int(input())
s = [input().split() for i in range(a)]
cnt = int(0)
maxcnt = int(0)

for i in range(a):
    if s[i][0] == s[i][1]:
        cnt += 1
    else:
        cnt = 0
    if maxcnt < cnt:
        maxcnt = cnt

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

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

print("No")

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

n=[]
for i in b:
    if i[0]==i[1]:
        n.append(1)
        continue
    n.append(0)
for i in range(a-2):
    if n[i]==1 and n[i+1]==1 and n[i+2]==1:
        print('Yes')
        exit()
print('No')

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

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

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

for i in range(N):
    D.append(list(map(int, input().split(" "))))

count = 0
flag = False
for d in D:
    if d[0] == d[1]:
        count += 1
    else:
        count = 0
    if count >= 3:
        flag = True
        break

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

Solution (Python):
import math


N = int(input())


D = []
c = 0
d = 0
for i in range(N):
    a = list(map(int, input().split()))
    if a[0] == a[1]:
        if c == 0:
            c+= 1
        elif c == 1:
            c+= 1
        elif c == 2:
            d = 1
    else:
        if c > 0:
            c = 0
if d == 1:
    print("Yes")
else:
    print("No")

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

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

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

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

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

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

print(ans)

Solution (Python):


n = int(input())
d = [[0 for _ in range(2)] for _ in range(n)]
for i in range(n):
    d[i][0], d[i][1] = map(int, input().split())

for i in range(n+1-3):
    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())
D12 = [map(int, input().split()) for _ in range(N)]
D1, D2 = [list(i) for i in zip(*D12)]

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

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

Solution (Python):
def main():
    N = int(input())
    Ds = [list(map(int, input().split())) for _ in range(N)]
    ans = "No"
    count = 0
    maxcou = 0
    for i,j in Ds:
        if i == j:
            count += 1
            if count> maxcou:
                maxcou = count
        else:
            count = 0

    return "Yes" if maxcou>2 else "No"

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

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

Solution (Python):
def main():
    a = int(input())
    zorome = 0
    yes = False

    for i in range(a):
        b = input()
        x, y = b.split(' ')
        if int(x) == int(y):
            zorome += 1
            if zorome == 3:
                yes = True
        else:
            zorome = 0
    if yes:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Solution (Python):
n = int(input())
cnt = 0
for x in range(n):
    d1, d2 = [int(i) for i in input().split()]
    if d1 == d2:
        cnt += 1
    elif cnt == 3:
        break
    else:
        cnt = 0

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

Solution (Python):


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


if __name__ == "__main__":
    main()

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

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

for i in range(n-2):
    if num_list[i][0] == num_list[i][1] and num_list[i+1][0] == num_list[i+1][1] and num_list[i+2][0] == num_list[i+2][1]:
        ans = "Yes"

print(ans)

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

count = 0
is_true = False
for i in range(n):
    d1, d2 = list(map(int, input().split()))

    if d1 == d2:
        count = count + 1
    else:
        count = 0
    if count >= 3:
        is_true = True

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

Solution (Python):
n = int(input())
f = True
ans_2 = []
for i in range(n):
    d,d_1 = map(int,input().split())
    if f:
        ans = 0
    if d == d_1:
        ans += 1
        f = False
    else:
        f = True
        ans_2.append(ans)
ans_2.append(ans)

f_2 = False
for j in ans_2:
    if j >= 3:
        f_2 = True
    
if f_2:
    print("Yes")
else:
    print("No")

Solution (Python):
N=int(input())
flag1=False
flag2=False
ans='No'
for i in range(N):
    a,b=map(int,input().split())
    if a==b:
        if flag1:
            if flag2:
                ans='Yes'
            else:
                flag2=True
        else:
            flag1=True
    else:
        flag1=False
        flag2=False
print(ans)

Solution (Python):
N = int(input())
zoros = [False,False]
res = "No"
for n in range(N):
    Ds= list(map(int,input().split()))
    if Ds[0] == Ds[1]:
        zoros.append(True)
        if zoros[n] and zoros[n+1] and zoros[n+2]:
            res = "Yes"
    else:
        zoros.append(False)

print(res)

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

renzoku_count = 0
max_renzoku_count = 0
for _ in range(n):
    d1, d2 = input().split()
    
    if d1 == d2:
        renzoku_count += 1
    else:
        renzoku_count = 0
    max_renzoku_count = max(max_renzoku_count, renzoku_count)
    

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

Solution (Python):
n=int(input())
D=[list(map(int,input().split())) for _ in range(n)]
num=0
dnum=0
for i in range(n):
    if D[i][0]==D[i][1]:
        num+=1
        if num==3:
            dnum=1
    else:
        num=0

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

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

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

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

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

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'
print(ans)

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

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

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

D1 = [0]*N
D2 = [0]*N
E = [0]*N

for i in range(N):
    D1[i], D2[i] = map(int, input().split())
    if D1[i] == D2[i]:
        E[i] = 1
    else:
        E[i] = 0

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

print("No")

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

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

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

print("No")

Solution (Python):
N = int(input())
cnt = 0
res =[]
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        cnt += 1
        res.append(cnt)
    else:
        cnt = 0
        res.append(cnt)
if max(res) >= 3:
    print('Yes')
else:
    print('No')

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(N: int, D: "List[List[int]]"):
    cnt = 0
    for i in range(len(D)):
        d1, d2 = [int(t) for t in D[i]]
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            return YES
    return NO



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)]  
    print(solve(N, D))

if __name__ == '__main__':
    main()

Solution (Python):



import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline




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

Solution (Python):
n=int(input(''))
l=[]
k=[]
for a in range(n):
    i,j=map(int,input('').split(' '))
    l.append(i)
    k.append(j)

ok=0
for a in range(n-2):
    if l[a]==k[a] and l[a+1]==k[a+1] and l[a+2]==k[a+2]:
        ok=1
        break

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

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

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

print(ans)

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())
D = [len(set(map(int, input().split())))==1 for d in range(N)]

for i in range(1, N-1):
  if all((D[i-1], D[i], D[i+1])):
    print('Yes')
    break
else:
  print('No')

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

Solution (Python):



import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5
1 2
6 6
4 4
3 3
3 2"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5
1 1
2 2
3 4
5 5
6 6"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """6
1 1
2 2
3 3
4 4
5 5
6 6"""
        output = """Yes"""
        self.assertIO(input, output)


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

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


if __name__ == "__main__":
    
    resolve()

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

Solution (Python):
import sys

N = int(input())
B=[]
for i in range(N):
    b=list(map(int,input().split()))
    B.append(b)
for i in range(N-2):
    if B[i][0]==B[i][1]:
        if B[i+1][0]==B[i+1][1]:
            if B[i+2][0]==B[i+2][1]:
                print("Yes")
                sys.exit()
print("No")

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

prev_d1=0
prev_d2=0

seq=0
flag = False
for _ in range(N):
    d1, d2 = map(int, input().split())

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

    if seq==3:
        flag=True
if flag:
    print("Yes")
else:
    print("No")

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

Solution (Python):
n=int(input())
a=[]
for i in range(n):
  x,y=map(int,input().split())
  a.append([x,y])
f=0;
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]):
    f=1
if f:
  print("Yes")
else :
  print("No")

Solution (Python):
N = int(input())
d = []
ans = 'No'
for i in range(N):
    d.append(list(map(int,input().split())))
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'
print(ans)

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())
D = []
E = []
clear = 0
for i in range(N):
    x, y = map(int, input().split())
    D.append(x)
    E.append(y)

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

if clear == 0:
    print('No')
else:
    print('Yes')

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

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

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

print('No')

Solution (Python):
N = int(input())
ct = 0
flg = 0
for i in range(N):
    s,g = map(int,input().split())
    if s == g:
        ct += 1
    else:
        ct = 0
    if ct == 3:
        flg = 1

print(("No","Yes")[flg == 1])

Solution (Python):

import sys,math
try:sys.stdin,sys.stdout=open('input.txt','r'),open('out.txt','w')
except:pass
from sys import stdin,stdout;mod=int(1e9 + 7);from statistics import mode
from collections import *;from math import ceil,floor,inf,factorial,gcd,log2,sqrt,log
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()


def lcm(a,b): return (a*b)//gcd(a,b)
def setbits(n):return bin(n).count('1')
def resetbits(n):return bin(n).count('0')
def modinv(n,p):return pow(n,p-2,p)
def ncr(n,r):
    num,den=1,1;r=min(n,n-r)
    for i in range(r):num*=(n-i);den*=(i+1)
    return num//den
def ncr_p(n, r, p):
    num,den=1,1;r=min(r,n-r)
    for i in range(r):num = (num * (n - i)) % p ;den = (den * (i + 1)) % p
    return (num * modinv(den,p)) % p
def isPrime(num) :
    if num<=1:return False
    if num==2 or n==3:return True
    if (num % 2 == 0 or num % 3 == 0) :return False
    m = int(num**0.5)+1
    for i in range(5,m,6):
        if (num % i == 0 or num % (i + 2) == 0) :return False
    return True
def bin_search(s, low, high, val):
    while low <= high:
        mid = low + (high - low) // 2;
        if s[mid] == val:return mid
        elif s[mid] < val:low = mid + 1
        else:high = mid - 1
    return -1
def sumofdigit(num):
    count=0;
    while num : count+=num % 10;num //= 10;
    return count;
def inputmatrix():
    r,c=iia();mat=[0]*r;
    for i in range(r):mat[i]=iia();
    return r,c,mat;
def prefix_sum(n,s):
    for i in range(1,n):s[i]+=s[i-1]
    return s;
def binomial(n, k):
    if 0 <= k <= n:
        ntok = 1;ktok = 1
        for t in range(1, min(k, n - k) + 1):ntok *= n;ktok *= t;n -= 1
        return ntok // ktok
    else:return 0
def divisors(n):
    res = [];
    for i in range(1,ceil(sqrt(n))+1):
        if n%i == 0:
            if i==n//i:res.append(i)
            else:res.append(i);res.append(n//i)
    return res;


n = ii1()
arr=[];flag=False
for i in range(n):
    a,b=iia()
    arr.append([a,b])
for i in range(n-2):
    if arr[i][0]==arr[i][1] and arr[i+1][0]==arr[i+1][1] and arr[i+2][0]==arr[i+2][1]:
        flag=True
if flag:print('Yes')
else:print('No')

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

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

def main():
    zorome = 0
    ans = 'No'
    for _ in range(N):
        x, y = list(map(int, input().split()))
        if x == y:
            zorome += 1
            if zorome >= 3:
                ans = 'Yes'
        else:
            zorome = 0
    return ans

print(main())

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

ans = [i[0] == i[1] for i in d] + [False, False]
ans2 = [sum( ans[i:i+3] ) for i in range(n)]

if max(ans2) == 3:
  print('Yes')
else:
  print('No')

Solution (Python):
n=int(input())
d=[input().split()for _ in range(n)]
c=0
for i in range(n-2):
    if d[i][0]==d[i][1]:
        if d[i+1][0]==d[i+1][1]:
            if d[i+2][0]==d[i+2][1]:
                c+=1
                print("Yes")
                break
            else:
                pass
        else:
            pass
    else:
        pass
if c==0:
    print("No")
else:
    pass

Solution (Python):
n = int(input())
cnt = 0
ans = "No"
for _ 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())
a = []
b = []
count = 0
for i in range(n):
    aa,bb = map(int, input().split())
    a.append(aa)
    b.append(bb)
for i in range(n):
    if a[i] == b[i]:
        count += 1
    else:
        count = 0
    if count == 3:
        print("Yes")
        break
else:
    print("No")

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

flag=0
cnt=0
for i in range(N):
    if A[i][0]==A[i][1]:
        cnt+=1
    else:
        cnt=0
    if cnt==3:
        flag=1
if flag==1:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input())
d1=[]
d2=[]

for _ in range(n):
    D1,D2 = map(int,input().split())

    d1.append(D1)
    d2.append(D2)

ans='No'

cnt=0
for i in range(n):
    p=d1[i]
    q=d2[i]

    if p==q:
        cnt+=1
    else:
        cnt=0

    if cnt>=3:
        ans='Yes'
        break


print(ans)

Solution (Python):
t=int(input())
c=0
flag=1
while t>0:
    m,n=map(int,input().split())
    if m==n:
        c+=1
        if c==3:
            print('Yes')
            flag=0
            break
    else:
        c=0
    t-=1
if flag==1:
    print('No')

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

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

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

Solution (Python):
_,*d=[{*t.split()}for t in open(0)]
print('YNeos'[all(max(map(len,d[i:i+3]))>1for i in range(len(d)-2))::2])