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

Solution (Python):
def main():
    n = int(input())
    numbers = []
    for i in range(n):
        numbers.append(len(set(map(int, input().split()))))
    row3 = [numbers[i:i+3] for i in range(n - 2)]
    if([1,1,1] in row3):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

Solution (Python):


import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union































def main():
    Num = Union[int, float]
    mod = 1000000007                
    inf = float('inf')              
    
    sys.setrecursionlimit(10**6)    
    def input():  return sys.stdin.readline().rstrip()
    def ii():     return int(input())
    def isp():    return input().split()
    def mi():     return map(int, input().split())
    def mi_0():   return map(lambda x: int(x)-1, input().split())
    def lmi():    return list(map(int, input().split()))
    def lmi_0():  return list(map(lambda x: int(x)-1, input().split()))
    def li():     return list(input())
    def debug(x): print(x, file=sys.stderr)
    
    
    
    n = ii()
    L = [lmi() for _ in range(n)]

    def check(n, L):
        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]:
                return True
        return False

    print('Yes' if check(n, L) else 'No')


if __name__ == "__main__":
    main()

Solution (Python):
def solve(n, d):
    if n < 3:
        return "No"
    else:
        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]:
                        return "Yes"
        return "No"

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

print(solve(n,d))

Solution (Python):
N=int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
cnt=0
result="No"


for i in range(N):
    cnt=cnt+1 if x[i]==y[i] else 0
    if cnt>2:
        result="Yes"
print(result)

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

Solution (Python):
n = int(input())
def count():
    count = 0
    result = ''
    for i in range(n):
        d1, d2 = map(int, input().split())
        if result == 'Yes':
            continue
        if d1 == d2:
            count += 1
            if count == 3:
                result = 'Yes'
        else:
            count = 0
            result = 'No'
    return result

print(count())

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

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

for i in range(N):
    if x[i] == y[i]:
        k += 1
    else:
        k = 0
    if k == 3:
        break

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

Solution (Python):
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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):
N = int(input())
D  = [list(map(int,input().split())) for i in range(N)]
count = 0 
k = 0 
while count < 3 and k <= N-1:
        if D[k][0] == D[k][1]:
            count += 1
        else:
            count = 0 
        k+=1
        
if count == 3:
    print('Yes')
else:
    print("No")

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

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

li = []
for i in string:
    li.append(int(i[0]) - int(i[1]))

c = 0
nli = len(li) - 1

while c != nli:
    if li[c] == 0:
        if c == nli - 1:
            print('No')
            exit()
        elif li[c + 1] == 0:
            if li[c + 2] == 0:
                print('Yes')
                exit()
    c += 1

print('No')

Solution (Python):
import itertools
n = int(input())
s = []
for i in range(n):
    array = list(map(int, input().strip().split()))
    s.append(array)
s = list(itertools.chain.from_iterable(s))
d = "No"
x = 0
while x+5 < len(s):
    if s[x] == s[x+1] and s[x+2] == s[x+3] and s[x+4] == s[x+5]:
        d = "Yes"
        break
    else:
        x += 1
print(d)

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

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

flag_a=0
flag_b=0
for i in range(n):
  if num_list[i][0]==num_list[i][1] :
    flag_a+=1
  else:
    flag_a=0
  
  if flag_a==3:
    flag_b=1
    
if flag_b==1:
  print('Yes')
else:
  print('No')

Solution (Python):
n = int(input())
numList = []
for x in range(n):
	num = [int(x) for x in input().split()]
	if num[0] == num[1]:
		numList.append('True')
	else:
		numList.append('False')
		
	
judge = 'No'
for x in range(len(numList)-2):
    if numList[x] == 'True':
      if numList[x+1] == 'True':
        if numList[x+2] == 'True':
          judge = 'Yes'
print(judge)

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

    counter = 0
    for i in range(N):
        A, B = map(int, input().split())
        if A == B:
            counter += 1
            if counter >= 3:
                print('Yes')
                return 0
        else:
            counter = 0
    print('No')

if __name__ == "__main__":
    myfunc()

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

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

ans = 'No'
for i in list(range(N - 2)):
    if D1[i] == D2[i] and D1[i + 1] == D2[i + 1] and D1[i + 2] == D2[i + 2]:
        ans = 'Yes'
        break

print(ans)

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

Solution (Python):
n=int(input())
z=0
c=0
f=0
i=0;

while i<n:
    l=list(map(int,input().split()))
    a=l[0]
    b=l[1]
    if a==b:
        z=1
        c=c+1
        if c>=3:
            f=1
    else:
        c=0
        z=0
    
    i=i+1
if f:
    print("Yes")
else:
    print("No")

Solution (Python):
import math


def a():
    s = input()
    if s[-1] == 's':
        print(s + 'es')
    else:
        print(s + 's')


def b():
    n = int(input())
    d = []
    for i in range(n):
        d.append(list(map(int, input().split())))
    for i in range(n - 2):
        if d[i + 2][0] == d[i + 2][1] and \
            d[i + 1][0] == d[i + 1][1] and \
                d[i][0] == d[i][1]:
            print('Yes')
            break
    else:
        print('No')


def c():
    pass


def d():
    pass



b()

Solution (Python):



n = input()
n = int(n)
s = ''
for i in range(n):
    t = input()
    t = t.replace(' ','')
    t = list(t)
    if t[0]==t[1]:
        s = s+'1'
    else:
        s = s+'0'

if '111' in s:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
x = []
for i in range(N):
    input1 = input()
    input1 = input1.split() 
    m, n = int(input1[0]), int(input1[1])
    if(m==n):
        x.append('x')  
    else:
        x.append(0)
count = 0
flag = 0
i = 0
while(i!=N):
    if(x[i]=='x'):
        count=count+1
        if(count>=3):
            flag+=1
    else:
        count = 0
    i+=1
if(flag>0):
    print('Yes')
else:
    print('No')

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

Solution (Python):
N = int(input())
A = []
B = []
s = 0
for x in range(N):
    a, b = input().split()
    a = int(a)
    b = int(b)
    A.append(a)
    B.append(b)
for i in range(N):
    if A[i] == B[i]:
        s = s+1
    else:
        if s >= 3:
            s = s + 0
        else:
            s = 0
if s >= 3:
    print('Yes')
else:
    print('No')

Solution (Python):
def fourroll(s):
    count = 0
    for i in range(len(s)):
        if s[i][0]==s[i][1]:
           count +=1
           
           if count is 3:
               print("Yes")
               return
        else:
           count = 0
    print("No")

s = []
n = int(input())
for i in range(n):
    a,b = input().split()
    s.append((a,b))
fourroll(s)

Solution (Python):
def dice(m, n):
    for i in range(0, n-2):
        if (m[i][0] == m[i][1]) and (m[i + 1][0] == m[i + 1][1]) and (m[i + 2][0] == m[i + 2][1]): 
            return 'Yes'
    return 'No'

N = int(input())
mylist = []
for i in range(0, N):
    num = list(map(int, input().split(' ')))
    mylist.append(num)

print(dice(mylist, N))

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

for i in range(0,n):
	d[i] = set(d[i])

for i in range(0,n-2):
	if len(d[i]) == 1 and len(d[i+1]) == 1 and len(d[i+2]) == 1:
		count = count + 1

if count == 0:
  print("No")
else:
  print("Yes")

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

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

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

def Ans(n,a):
    for i in range(n-2):
        if a[i][0] == a[i][1]:
            if a[i+1][0] == a[i+1][1]:
                if a[i+2][0] == a[i+2][1]:
                    return('Yes')
                else:
                    continue
            else:
                continue
        else:
            continue
    return('No')
                    
print(Ans(N,A))

Solution (Python):
N = int(input())
d1 = [0]*N
d2 = [0]*N
tmp = 0
for i in range(N):
    d1[i], d2[i] = map(int, (input().split(' ')))

for i in range(N-2):
    if d1[i] == d2[i]:
        if d1[i+1] == d2[i+1]:
            if d1[i+2] == d2[i+2]:
                tmp += 1

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

Solution (Python):
n = int(input())
d = [list(map(lambda x: int(x), input().split())) for i in range(n)]
a = 0
f = 0
for [x, y] in d:
    if x == y:
        a += 1
        if a >= 3:
            f = 1
    else:
        if a >= 3:
            f = 1
        a = 0
if f:
    print('Yes')
else:
    print('No')

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

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

series_count=0

for di in d:
	if di[0]==di[1]:
		series_count+=1
	else:
		series_count=0

	if series_count==3:
		print("Yes")
		break

if series_count<3:
	print("No")

Solution (Python):
N = int(input())
A=[list(map(int, input().split())) for i in range(N)]
num = 0
zoro = 0
while num < N:
  if A[num][0] ==A[num][1]:
    num +=1
    zoro +=1 
  else:
    num +=1
    if zoro >2:
      zoro = zoro
    else:
      zoro = 0
if zoro >2 :
  print("Yes")
else:
  print("No")

Solution (Python):
n = int(input())
count = 0
flag = False
while count < n:
  a, b = map(int, input().split())
  count += 1
  if a == b and count < n:
    a, b = map(int, input().split())
    count += 1
    if a == b and count < n:
      a, b = map(int, input().split())
      count += 1
      if a == b and count <= n:
        flag = True
        print("Yes")
        break

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

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

cnt = 0
flag = False
for d in d_list:
    if d[0] == d[1]:
        cnt+=1
        if cnt >= 3:
            print("Yes")
            flag = True
            break
    else :
        cnt = 0

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

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

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

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

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

for i in range(N-2):
    if D[i][0]==D[i][1] and D[i+1][0]==D[i+1][1] and D[i+2][0]==D[i+2][1]:
        print('Yes')
        break
else:
    print("No")

Solution (Python):
n=int(input())
cnt=0
flg=0

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

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

Solution (Python):
N = int(input())
ans = 0
for i in range(N):
  x, y = map(int, input().split())
  if x == y:
    ans += 1
  else:
    ans = 0
  if ans == 3:
    break
if ans == 3:
  print('Yes')
else:
  print('No')

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

for i in range(num):
  line = input().split()
  nums = [int(a) for a in line]
  if nums[0]==nums[1]:
    count+=1
  else:
    count=0
  if count==3:
    break

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

Solution (Python):
n = int(input())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
count = 0
buf = 0

for xi, yi in zip(x, y):
    if xi == yi:
        buf += 1
    else:
        if buf > count:
            count = buf
        buf = 0

if buf > count:
    count = buf

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

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

for i in range(N-2):
    check = all(d[j][0]==d[j][1] for j in range(i,i+3))
    if check:
        print("Yes")
        break
else:
    print("No")

Solution (Python):
n = int(input())
count=0
flg=0

for num in range(n):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        count += 1
        if count>= 3:
            flg = 1
    else:
        count=0
else:
    if count > 3 or flg >0:
        print("Yes")
    else:
        print("No")

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


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

    if cnt == 3:
        ans = "Yes"


print( ans )

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

for i in range(n):
  d.append(list(int(x) for x in input().split()))
  if i >= 2:
    if d[i-2][0] == d[i-2][1] and d[i-1][0] == d[i-1][1] and d[i][0] == d[i][1]:
      judge = 'Yes'

print(judge)

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

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

ans = 0
flag = False

for i in range(N):
    if x[i] == y[i]:
        ans +=1
    elif ans >= 3:
        flag = True
        ans = 0
    else:
        ans = 0
        
if ans >= 3  or flag ==True:
    print("Yes")
    
else:
    print("No")

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

Solution (Python):
from collections import defaultdict 
import sys
import math 
import random
def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

cnt = 0
n = int(input())
flag = False 
for i in range(n):
    (x,y) = get_ints()
    
    if x==y:
        cnt+=1
    else:
        cnt=0
    if cnt>=3:
        flag = True 

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

Solution (Python):

N = int(input().strip())


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

counter = 0
frag = False
for i in range(N):
    if grid[i][0] == grid[i][1]:
        counter += 1
        if counter == 3:
            frag = True
    elif grid[i][0] != grid[i][1]:
        counter = 0
if frag is True:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
lst = []
for _ in range(N):
  d1, d2 = map(int, input().split(' '))
  lst.append((d1, d2))
  
idx = 0
flag = False
while idx < N-2:
  cnt = 0
  for i in range(3):
    d1, d2 = lst[i+idx]
    if d1 == d2:
      cnt += 1
  if cnt == 3:
    flag = True
    break
  else:
    idx += 1
 
print('Yes' if flag else 'No')

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

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

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

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

nums = []
for i in range(n):
	nums.append(list(map(int, input().split())))
ans = 'No'
count = 0
for num in nums:
	if num[1] == num[0]:
		count += 1
		if count == 3:
			ans = 'Yes'
			break
	else:
		count = 0

print(ans)

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

cnt = 0
for i, (p, q) in enumerate(d):
    if p == q:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print("Yes")
        break
else:
    print("No")

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

flg = False
for i in range(N -2):
    if D1[i] == D2[i] and D1[i + 1] == D2[i + 1] and D1[i + 2] == D2[i + 2]:
        flg = True
        
if flg:
    print("Yes")
else:
    print("No")

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

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

for j in line:
    if j[0] == j[1]:
        count += 1
        if count >= 3:
            ans += 1
        else:
            continue
    else:
        count = 0
if ans == 0:
    print('No')
else:
    print('Yes')

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

counter = 0
max = 0
for i in range(N):
  if x[i][0] == x[i][1]:
    counter = counter + 1
  else:
    if max < counter:
      max = counter
    counter = 0

if max >=3 or counter >= 3:
  a = 'Yes'
else:
  a = 'No'
    
print(a)

Solution (Python):
a=int(input())
b=0
xy = [map(int, input().split()) for _ in range(a)]
x, y = [list(i) for i in zip(*xy)]
for i in range(a-2):
  if x[i]==y[i] and x[i+1]==y[i+1] and x[i+2]==y[i+2]:
    b=b+1
if b==0:
  print("No")
else:
  print("Yes")

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

ans=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]:
        ans+=1

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

else:
    print("Yes")

Solution (Python):
import sys

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

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

print('No')

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

zoro = []
for i in range(N):
  if D[i][0] == D[i][1]:
    zoro.append(1)
  else:
    zoro.append(0)

cnt = []
for i in range(N-2):
  cnt.append(zoro[i]+zoro[i+1]+zoro[i+2])
  

zoro_cnt = 0
for i in range(N-2):
  if cnt[i] == 3:
    zoro_cnt += 1


if zoro_cnt >= 1:
  print("Yes")
else:
  print("No")

Solution (Python):
n=int(input())
patt=[-1]*100
l=0
for i in range(n):
    a,b=[int(x) for x in input().split(' ')]
    if a==b:
        l+=1
        patt[i]=1
count=0
flag=0
for i in range(100):
    if patt[i]==1:
        count+=1
    else:
        count=0
    if count==3:
        flag=1
        break
if flag==1:
    print('Yes')
else:
    print('No')

Solution (Python):
arr2 = []
count = 0
for _ in range(int(input())):
    arr = list(map(int, input().split()))
    arr2.append(arr)
for k in range(len(arr2)):
    if arr2[k][0] == arr2[k][1]:
        count += 1
        if count == 3:
            print("Yes")
            exit()
    else:
        count = 0
print("No")

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

counter = 0
best = 0
for _ in range(n):
    x, y = map(int, input().split())
    if x == y:
        counter += 1
    else:
        counter = 0

    best = max([best, counter])

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

Solution (Python):
import sys

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

cnt = 0

for e in d:
    if (e[0] + e[1])/2 == e[0]:
        cnt = cnt + 1
        if cnt == 3:
            print("Yes")
            sys.exit()
    else:
        cnt = 0

print("No")

Solution (Python):
if __name__ == "__main__":
  N = int(input())
  D = []
  for i in range(N):
    D += [[int(a) for a in input().split()]]
  ans = "No"
  count = 0
  for d in D:
    if d[0] == d[1]:
      count += 1
      if count == 3:
        ans = "Yes"
        break
      else:
        pass
    else:
      count = 0
  print(ans)

Solution (Python):
N = int(input())
D = [[0]]*N
for i in range(N):
  D[i] = list((int(x) for x in 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')
    break
else:
  print('No')

Solution (Python):
n=int(input())
d=[input().split() for _ in range(n)]
tmp=0
judge=False
for i in range(n):
    if d[i][0]==d[i][1]:
        tmp+=1
    else:
        tmp=0
    if tmp==3:
        print("Yes")
        judge=True
if judge==False:
    print("No")

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

count=0

for i in range(n):
    a,b = map(int, input().split())
    if a==b:
        count+=1
    if a!=b:
        if count<3:
            count=0
if count>=3:
    print('Yes')
elif count<=2:
    print('No')

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


n = 0
for i in range(N):
    if x[i] == y[i]:
        n = n+1
    elif n >=3:
        break
    elif x[i] != y[i]:
        n = 0

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

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

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

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

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

Solution (Python):
n = int(input())
d = [list(map(int, input().split())) for i 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 == 1:
  print("Yes")
else:
  print("No")

Solution (Python):
def main():
  N = int(input())
  flag = 0
  for l in range(N):
    l = list(map(int, input().split()))
    if l[0] == l[1]:
      flag += 1
      if flag == 3:
        flag = 80000
        break
    else:
      flag = 0    
  return flag

Ans = main()
if Ans == 80000:
  print('Yes')
else :
  print('No')

Solution (Python):
n = int(input())
d1d2 = [map(int, input().split()) for _ in range(n)]
d1, d2 = [list(i) for i in zip(*d1d2)]
h = 'No'
for i in range(n):
    if i > 1:
        if d1[i] == d2[i]:
            if d1[i-1] == d2[i-1]:
                if d1[i-2] == d2[i-2]:
                    h = 'Yes'
                    break
print(h)

Solution (Python):


"""
https://atcoder.jp/contests/abc179/tasks/abc179_b
B - Go to Jail
"""

def solve(n):
    count = 0
    p_d1, p_d2 = list(map(int, input().split()))
    if p_d1 == p_d2: count = 1
    n -= 1

    while n:
        d1, d2 = list(map(int, input().split()))
        if d1 == d2 and p_d1 == p_d2:
            count += 1
            if count == 3: return "Yes"
        elif d1 == d2: count = 1
        else: count = 0
        p_d1 = d1
        p_d2 = d2

        n -= 1

    return "No"

if __name__ == "__main__":
    n = int(input())

    print(solve(n))

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

ans = "No"

for i in range(num - 2):
  if line[i][0] == line[i][1] and line[i+1][0] == line[i+1][1]and line[i+2][0] == line[i+2][1]:
    ans = "Yes"
    break
    
print(ans)

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
if N == 3:
    if x[0] == y[0] and x[1] == y[1] and x[2] == y[2]:
        count += 1
        print("Yes")

for i in range(N-3):
    if x[i] == y[i] and x[i+1] == y[i+1] and x[i+2] == y[i+2]:
        count += 1
        print("Yes")
        break

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

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

Solution (Python):
N=int(input())
cnt=0
find=False
for n in range(N):
    a,b=map(int,input().strip().split())
    if a==b:
        cnt+=1
    else:
        cnt=0
    if cnt==3:
        find=True

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

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

D = []
for i in range(N):
    Da,Db = (map(int,input().split()))
    if Da == Db:
        D.append(1)
    else:
        D.append(0)

for i in range(N-2):
    if D[i]==1 and D[i+1] == 1 and D[i+2] == 1:
        ans = "Yes"
        break
    else:
        ans = "No"
print(ans)

Solution (Python):
n=int(input())
ans=0
c=True
d=[]
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        d.append(i)
if len(d)<3:
    print("No")
else:
    j=0
    for i in range(1,len(d)-1):

        if d[i]-d[i-1]==1 and d[i+1]-d[i]==1:
            print("Yes")
            c=False
            break

    if c==True:
        print("No")

Solution (Python):


N = int(input())
D = []
counter = []

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

for i in range(N):
  if D[i][0] == D[i][1]:
    counter.append(1)
    if (i >= 2 and counter[i-1]==1 and counter[i-2]==1):
      print('Yes')
      break
  else:
    counter.append(0)
  if i == N-1:
    print('No')

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

cnt = 0
judge = False

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

    if cnt == 3:
        judge = True

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

Solution (Python):
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]
flag = 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]:
        flag = True
if flag:
    print("Yes")
else:
    print("No")

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

count = 0
yes = False

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

if not(yes):
  print("No")

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

is_jail = False
for i in range(2*N-5):
    if j[i] == j[i+1] and j[i+2] == j[i+3] and j[i+4] == j[i+5]:
        is_jail = True

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

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

Solution (Python):
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

n = ii()
b1 = False
b2 = False
b3 = False
for i in range(n):
    x = li()
    if(x[0] == x[1]):
        if(b1):
            if(b2):
                b3 = True
            b2 = True
        b1 = True
    else:
        b1 = False
        b2 = False

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

Solution (Python):
n=int(input())
cnt=0
d=[list(map(int,input().split()))for i in range(n)]
for i in range(n):
    if cnt>=3:
        break
    else:
        if i==0:
            if d[i][0]==d[i][1]:
                cnt+=1
        else:
            if d[i-1][0]!=d[i-1][1]:
                cnt=0
                if d[i][0]==d[i][1]:
                    cnt+=1
            else:
                if d[i][0]==d[i][1]:
                    cnt+=1
if cnt>=3:
    print('Yes')
else:
    print('No')

Solution (Python):

N = int(input())

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

count = 0

for i in range(N):
    if x[i] == y[i]:
        count += 1
        if count == 3:
            break
    else:
        count = 0
if count >= 3:
    print("Yes")
else :
    print("No")

Solution (Python):
N = int(input())
list_deme = [0]*N
for n in range(N):
    i = list(map(int, input().split()))
    if i[0] == i[1]:
        list_deme[n] = 1
stack = 0
for i in list_deme:
    if i == 1:
        stack += 1
    elif stack < 3 and i == 0:
        stack = 0

if stack > 2:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
count=0
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
for i in range(N-2):
  if x[i]==y[i] and x[i+1]==y[i+1] and x[i+2]==y[i+2]:
    print("Yes")
    exit(0)
print("No")