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):
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext

def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    ans_list = []
    for i in range(n):
        a, b = i_map()
        if a == b:
            ans_list.append(1)
        else:
            ans_list.append(0)

    for i in range(n-2):
        if ans_list[i] == ans_list[i+1] == ans_list[i+2] == 1:
            print('Yes')
            exit()

    print('No')

if __name__ == '__main__':
    main()

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

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

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

is_jails = ''.join(['T' if a == b else 'F' for a, b in D])

if 'TTT' in is_jails:
    print("Yes")
else:
    print("No")

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

Solution (Python):
import sys
N = int(input())
D = [False] * N

for i in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        D[i] = True

i = 0
while i < N:
    if D[i]:
        cnt = 0
        while i <N and D[i]:
            cnt += 1
            i += 1
        if cnt >=3:
            print('Yes')
            sys.exit(0)
    else:
        i += 1

print("No")

Solution (Python):
from sys import stdin
readline = stdin.readline
def i_input(): return int(readline().rstrip())
def i_map(): return map(int, readline().rstrip().split())
def i_list(): return list(i_map())


def main():
    N = i_input()
    ans = False
    z = 0
    for _ in range(N):
        D1, D2 = i_map()
        if D1 == D2:
            z += 1
            if z >= 3:
                ans  = True
        else:
            z = 0
    print("Yes" if ans else "No")

if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter
import math
import statistics
import itertools
a=int(input())







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

ans=0
count=0
for i in range(len(h)):
    if sum(h[i])==h[i][0]*2:
        count+=1
    else:
        ans=max(ans,count)
        count=0

if count>=3:
    ans=max(ans,count)

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

Solution (Python):
n = int(input())
L = []
for i in range(n):
    a, b = map(int, input().split())
    if a == b:
        L.append("a")
    else:
        L.append("b")

if "aaa" in "".join(L):
    print("Yes")
else:
    print("No")

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




c = 0
for x, y in D:
    
    if x==y:c+=1
    else: c = 0
    if c == 3: break

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

Solution (Python):
s = int(input())
count = 0

for i in range(s):
  dice1, dice2 = map(int, input().split())
  if dice1 == dice2:
    count += 1
    if count >= 3:
      print("Yes")
      break
  else:
    count = 0
else:
  print("No")

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

cnt = 0
for d1, d2 in D:
    if d1 == d2:
        cnt += 1
    elif d1 != d2:
        cnt = 0
    if cnt == 3:
        print("Yes")
        exit()

print("No")

Solution (Python):
N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
p = 0
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]:
        print("Yes")
        break
    else:
        p += 1
if p == N-2:
    print("No")

Solution (Python):
N = int(input())
D1 = [0]*N
D2 = [0]*N
ans = 'No'
for i in range(N):
    D1[i], D2[i] = map(int, input().split())
list = []
for i in range(N):
  if D1[i] == D2[i]:
    list.append(0)
  else:
    list.append(1)
for i in range(N-2):
  if list[i] == 0 and list[i+1] == 0 and list[i+2] == 0:
    ans ='Yes'
print(ans)

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

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

if ans:
    print("Yes")
else:
    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
        if count == 3:
            flag = True
            break
    else:
        count = 0

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

Solution (Python):
import sys

def input(): return sys.stdin.readline().rstrip("\r\n")
def List(): return list(map(int, input().split()))
def Num(): return int(input())


inp = []
ok = False
for _ in range(Num()):
    a, b = List()
    inp.append([a, b])
for i in range(len(inp) - 3 + 1):
    if inp[i][0] == inp[i][1] and inp[i + 1][0] == inp[i + 1][1] and inp[i + 2][0] == inp[i + 2][1]:
        ok = True
        break
print("Yes" if ok else "No")

Solution (Python):
iterate = int(input())
cnt = 0
for i in range(iterate):
  dice = list(map(lambda x: int(x), input().split()))
  if dice[0]==dice[1]:
    cnt += 1
  else:
    cnt = 0
  if cnt==3: break
    
if cnt!=3: print("No")
else: print("Yes")

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

flag=0
ans =0
for i in range (n):
    x,y=map(int,input().split())
    if x==y :
        flag +=1
    else :
        flag=0
    if flag == 3:
        ans=1

if ans:
    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
  else:
    count = 0
  if(count == 3):
    print("Yes")
    break

if(count != 3):
  print("No")

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

Solution (Python):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n = int(input())
    r = 0
    m = map(int, read().split())
    ab = zip(m, m)
    t = 0
    for a, b in ab:
        if a == b:
            t += 1
            if t == 3:
                print('Yes')
                sys.exit()
        else:
            t = 0
    print('No')

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
D1 = []
D2 = []
count = 0
flag = 0
for i in range(N):
    d1, d2 = input().split()
    if int(d1) == int(d2):
        count = count + 1
        if count >= 3:
            flag = 1
    else:
        count = 0
if flag == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
import sys

n = int(input())
z = 0

for i in range(n):
  d1, d2 = map(int, input().split())
  if d1 != d2:
    z = 0
    continue

  z += 1
  if z >= 3:
    print('Yes')
    sys.exit()

print('No')

Solution (Python):
import sys

if __name__ == '__main__':
    _ = sys.stdin.readline().rstrip()
    n = 0
    for line in sys.stdin.readlines():
        line = line.rstrip()
        a, b = list(map(lambda x:int(x), line.split(' ')))
        if a == b:
            n += 1
        else:
            n = 0
        if n == 3:
            print('Yes')
            exit()
    print('No')

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

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

    if z_count == 3:
        print ("Yes")
        exit ()

print ('No')

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

count = 0

for i in range(N):
  D1, D2 = input().split(" ")
  
  if D1 == D2:
    count += 1
  else:
    count = 0
    
  if count >= 3:
    print("Yes")
    break

if count < 3:
	print("No")

Solution (Python):
import sys
N = int(input())
D = []
for i in range(N):
    D.append(input().split())
cnt = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        cnt += 1
        if cnt == 3:
            print("Yes")
            sys.exit()
    else:
        cnt = 0
print("No")

Solution (Python):
def solve():
    n = int(input())
    ct = 0
    for _ in range(n):
        a, b = input().split()
        if a == b:
            ct += 1
            if ct == 3:
                return 'Yes'
        else:
            ct = 0
    return 'No'
    

print(solve())

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

c = 0
for i in range(n):
    i,j = list(map(int, input().split()))
    if i == j and c == 0:
        c += 1
    elif i == j and c == 1:
        c += 1
    elif i == j and c == 2:
        c += 1
        break
    else:
        c = 0
    
if c == 3:
    print("Yes")
else:
    print("No")

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

count = 0

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

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

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

Solution (Python):
def main():
  n = int(input())
  result = []
  for i in range(n):
    d1, d2 = map(int, input().split())
    result.append(d1 == d2)
  for i in range(n-2):
    if result[i] and result[i+1] and result[i+2]:
      print("Yes")
      return 0
  print("No")
  return 0
    
if __name__ == "__main__":
  a = main()

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

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

isDouble = []

for i in range(N):
    temp = [int(j) for j in input().split(" ")]
    if temp[0] == temp[1]:
        isDouble.append(1)
    else:
        isDouble.append(0)

cnt = 0
flg = False

for i in range(len(isDouble)):
    if isDouble[i] == 0:
        cnt = 0
    else:
        cnt += isDouble[i]
    if cnt == 3:
        flg = True
        break

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

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n= int(input())
d = [0] * n
for i in range(n):
    d[i] = 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')
        sys.exit(0)
print('No')

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

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

print(ans)

Solution (Python):
N=int(input())
A=[]
for _ in range(N):
    A.append(list(map(int,input().split())))
count=0
for i in range(N):
    if A[i][0]==A[i][1]:
        count+=1
        if count==3:
            break
    else:
        count=0
if count==3:
    print("Yes")
else:
    print("No")

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

Ds = []
for i in range(N):
    D1, D2 = map(int, input().split())
    Ds.append([D1, D2])

ans = 'No'


for i in range(N):
    if i == 0 or i ==1:
        continue
    elif Ds[i][0] == Ds[i][1] and Ds[i-1][0] == Ds[i-1][1] and Ds[i-2][0] == Ds[i-2][1]:
        ans = 'Yes'
        break

print(ans)

Solution (Python):
import sys

def dump(x):
    print(x, file=sys.stderr)


N = int(input())
buf = 0
for i in range(N):
    a,b = input().split()
    if a == b :
        buf += 1
        if buf >=3:
            break
    else:
        buf = 0

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

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

cnt = 0
ans = "No"
for i in range(n):
    d = tuple(map(int, input().split()))
    if d[0] == d[1]:
        cnt += 1
    else:
        cnt = 0
    if 3 <= cnt:
        ans = "Yes"
print(ans)

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

t = 0
for i in range(n):
    a, b = map(int, input().split())

    if a == b:
        t += 1
        if t == 3:
            print("Yes")
            break
    else:
        t = 0

if t < 3:
    print("No")

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

Solution (Python):
def main():
    N = int(input())
    cnt = 0 
    ans = 'No'

    for n in range(N):
        if len(set(map(int, input().split()))) == 1: 
            cnt += 1
        else:
            cnt = 0
        if cnt >= 3:    
            ans = 'Yes'
    else:
        print(ans)

if __name__ == '__main__':
    main()

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

n = int(si())
t = 0
flag = False
while n:
    n -= 1
    a, b = [int(e) for e in si().split()]
    if a == b:
        t += 1
    else:
        t = 0
    if t >= 3:
        flag = True
if flag:
    print('Yes')
else:
    print('No')

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

flag = False
count = 0
for i in range(a):
    b, c = input().split()
    if b == c:
        count += 1
        if count == 3:
            flag = True
    else:
        count = 0

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

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

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

cnt = 0
flag = False
for i in range(N):
    D1, D2 = map(int, input().split())
    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())

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

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

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

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

N = int(input())

ans = False
count = 0
D1 = []
D2 = []
for i in range(N):
    d1, d2 = map(int, input().split())
    D1.append(d1)
    D2.append(d2)

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

    if count == 3:
        ans = True
        break

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

Solution (Python):
def solve():
    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 > 2:
            print("Yes")
            exit()
    print("No")
    return 0

if __name__ == "__main__":
    solve()

Solution (Python):

from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
import copy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)





def LI(): return list(map(int, sys.stdin.buffer.readline().split()))




def I(): return int(sys.stdin.buffer.readline())





def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()




def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')







def IR(n): return [I() for i in range(n)]







def LIR(n): return [LI() for i in range(n)]







def SR(n): return [S() for i in range(n)]







def LSR(n): return [LS() for i in range(n)]







def SRL(n): return [list(S()) for i in range(n)]


n = I()
cnt = 0
flg = 0
for i in range(n):
    d1, d2 = LI()
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt > 2:
        flg = 1
if flg:
    print("Yes")
else:
    print("No")

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

Solution (Python):
n = int(input())
def calc(n):
    bool1 = False
    bool2 = False
    bool3 = False
    for i in range(n):
        d1, d2 = (int(x) for x in input().split())
        if d1 == d2:
            if bool2 == True:
                bool3 = True
            if bool1 ==True:
                bool2 = True
            if bool1 == False:
                bool1 = True
        else:
            bool1 = False
            bool2 = False
    return bool3
if calc(n):
    print("Yes")
else:
    print("No")

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

cnt = 0
is_zorome = False
for i in range(N):
    if D1[i] == D2[i]:
        cnt+=1
    else:
        cnt=0
    if cnt == 3:
        is_zorome = True

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

Solution (Python):
N=int(input())
count = 0
flag = "No"
for x in range(N):
	a=input().split()
	if (a[0]==a[1]):
		count+=1
		if(count==3):
			flag = "Yes"
	else:
		count = 0
print(flag)

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
        if ans==3:
            print("Yes")
            flag=1
            break
    else:
        if ans!=0:
            ans=0

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

Solution (Python):
N = int(input())
zoro_try = []
zoro_cnt = 0
isOk = False
for i in range(N):
    d1, d2 = map(int, input().split())
    zoro_try.append([d1, d2])
    if i == 0 or i == 1: continue
    if zoro_try[i-1][0] == zoro_try[i-1][1] and zoro_try[i-2][0] == zoro_try[i-2][1] and zoro_try[i][0] == zoro_try[i][1]:
        isOk = True

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

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

Solution (Python):
import itertools
import functools
import math
from collections import Counter
from itertools import combinations
import re

N = int(input())

OK = 0
cnt = 0
for i in range(N):
    A = list(map(int,input().split()))
    if A[0] == A[1]:
        cnt = cnt + 1
    else:
        cnt = 0
    if cnt >= 3:
        OK = 1

if OK >= 1:
    print('Yes')
else:
    print('No')

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

print(ans)

Solution (Python):
con = 0;
mm = 0;

n = int(input())
a = [input().split() for l in range(n)]
b = [None]*n

for i in range(n):
    if a[i][0] == a[i][1]:
        con = con +1
    else:
        con = 0
    if con == 3:
        mm = 1;
        break;

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

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

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

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


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

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

ll = [input() for i in range(N)]

zoro_count = 0
for s in ll:
    d1 = s[0]
    d2 = s[2]

    if d1 == d2:
        zoro_count += 1
        if (zoro_count == 3):
            print("Yes")
            quit()
    else:
        zoro_count = 0

print("No")

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

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

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

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

    if cnt==3:
        ans = "Yes"
        break
print(ans)

Solution (Python):
N = int(input())
D1, D2 = [], []
for i in range(N):
  li = list(map(int,input().split()))
  D1.append(li[0])
  D2.append(li[1])

D = ""

for i in range(N):
  if D1[i]==D2[i]:
    D += 'T'
  else:
    D += 'F'

if 'TTT' in D:
  print('Yes')
else:
  print('No')

Solution (Python):

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

count = 0
for first, second in A:
    if first == second:
        count += 1
        if count >= 3:
            print("Yes")
            exit(0)
    else:
        count = 0
print("No")

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

Solution (Python):
def b():
    N = int(input())
    count = 0
    res = "No"
    for i in range(N):
        d = set(map(int, input().split()))
        if len(d) == 1:
            count +=1
        else:
            count = 0
        if count == 3:
            res = "Yes"
            break
    print(res)
    
b()

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

judge = False
count = 0

for i in range(n):
    if ds[i][0] == ds[i][1]:
        count +=1
    else:
        count = 0
    if count >= 3:
        judge = True

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

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

ans=0
cont=0
for i in ls:
    ans = (ans+i)*i
    cont=max(cont, ans)

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

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

Solution (Python):
(n,), *dd = [list(map(int, s.split())) for s in open(0)]

cnt = 0
ans = False
for i in range(n):
    a,b = dd[i]
    if a == b:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        ans = True
if ans:
    print('Yes')
else:
    print('No')

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

for i in range(n-2):
    
    r1, r2, r3 = rolls[i:i+3]
    
    if r1[0] == r1[1] and r2[0] == r2[1] and r3[0] == r3[1]:
        print("Yes")
        exit()
print("No")

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

cnt=0

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

print('No')

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

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

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

count = 0
flag = 0

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

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

Solution (Python):
n = int(input())
lst = [ [ int(i) for i in input().split() ] for j in range(n) ]
r = 0
for i in range(n-2):
    if lst[i][0] == lst[i][1]:
        if lst[i+1][0] == lst[i+1][1]:
            if lst[i+2][0] == lst[i+2][1]:
                r = 1
if r == 0:
    print("No")
else:
    print("Yes")

Solution (Python):
import sys
import numpy as np
import math  
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate 
import bisect 
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache 
INF = 10**9 + 7
mod = 10**9 + 7

def main():
    n = int(input())
    data = [input().split() for _ in range(n)]
    
    flag = False
    for i in range(n-2):
        if data[i][0] == data[i][1] and data[i+1][0] == data[i+1][1] and data[i+2][0] == data[i+2][1]:
            flag = True
    if flag:
        print('Yes')
    else:print('No')
    return 0

if __name__ == "__main__":
    main()

Solution (Python):
t=int(input())
z=[]
for _ in range(t):
    inp=list(map(int,input().split()))
    if inp[0]==inp[1]:
        z.append(1)
    else:
        z.append(0)
flag=0
a=0
for i in range(len(z)):
    if z[i]==1:
        a+=1
    else:
        a=0
    if a>=3:
        flag=1
        break
if flag==1:
    print ('Yes')
else:
    print ('No')

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


isSucceed = False
cnt = 0
f = False
for _ in range(N):
    d1, d2 = map(int,input().split())
    if d1 == d2:
        if not isSucceed:
            isSucceed = True
            cnt = 1
        else:
            cnt += 1
            if cnt >= 3:
                f = True
                
    else:
        isSucceed = False
        cnt = 0

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

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

k = 0
f = False
for _ in range(N):
    d1, d2 = [int(_) for _ in input().split()]
    if d1 == d2:
        k += 1
    else:
        k = 0
    if k >= 3:
        f = True
if f:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
c = 0
d,t = [0]*n,[0]*n
d[0],t[0] = map(int,input().split())
d[1],t[1] = map(int,input().split())

for i in range(2,n):
	d[i],t[i] = map(int,input().split())
	if d[i] == t[i] and d[i-1] == t[i-1] and d[i-2] == t[i-2]:
		c += 1
if c != 0:
	print('Yes')
else:
	print('No')

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

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

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

for i in range(2, len(a)):
    if a[i-2][0] == a[i-2][1] and a[i-1][0] == a[i-1][1] and a[i][0] == a[i][1]:
        print('Yes')
        break
else:
    print('No')

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

Solution (Python):
N=int(input())
dd=[list(map(int,input().split()))for _ in range(N)]
i=0
now=0
S=0
while i<N:
    if len(set(dd[i]))==1:
        now+=1
    else:
        now=0
    S=max(now,S)
    i+=1
print('YNeos'[S<3::2])

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 > 2:
        print('Yes')
        break

else:
    print('No')

Solution (Python):
n = int(input())
flg = False
tmp = 0
ans = 0
for i in range(n):
	a, b = map(int, input().split())
	if not flg and a == b:
		tmp = 1
		flg = True
	elif flg and a == b:
		tmp += 1
	else:
		tmp = 0
	ans = max(ans, tmp)
print("Yes" if ans >= 3 else "No")

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

a = 0
b = 0
for d in D:
    if d[0] == d[1]:
        a += 1
        b = max(a, b)
    else:
        a = 0
        b = max(a, b)

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

Solution (Python):
n = int(input())
ans = 0
cnt = 0
ch = [[0,0]]*1000
for i in range(n):
    a,b = map(int,input().split())
    ch.append([a,b])
    if a == b:
        cnt += 1
    else:
        ans = max(ans,cnt)
        cnt = 0
for i in range(len(ch)):
    if ch[i][0] != ch[i][1]:
        break
else:
    print("Yes")
    exit()
if ans >= 3:
    print("Yes")
else:
    print("No")