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())
li = list()
for i in range(N):
    a, b = [int(x) for x in input().split()]
    li.append([a,b])

count = 0
for i in li:
    if count < 3:
        if i[0] == i[1]:
            count += 1
        else:
            count = 0
    else:
        break

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

Solution (Python):
n = int(input())
data = []
zoro = []
yn = False
for i in range(n):
    data = input().split()
    if data[0] == data[1]:
        zoro += [True]
    else:
        zoro += [False]
    if i > 1 and (zoro[i] == True and zoro[i-1] == True and zoro[i-2] == True):
        yn = True
print("Yes") if yn == True else print("No")

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

count = 0
for i in li:
    if count < 3:
        if i[0] == i[1]:
            count += 1
        else:
            count = 0
    else:
        break

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

Solution (Python):
import sys

times=int(input())

num=0


for i in range(times):
  eyes=input().split()
  if eyes[0]==eyes[1]:
    num+=1
    if num==3:
      print("Yes")
      sys.exit()
  else:
    num=0
    
print("No")

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

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

count = 0
for i in li:
    if count < 3:
        if i[0] == i[1]:
            count += 1
        else:
            count = 0
    else:
        break

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

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

for i in range(n):
    d1, d2 = map(int,input().split())

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

    if count == 3:
        flag = 1


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

Solution (Python):
N = int(input())
lst = []
result = 0
for i in range(N):
    a,b = [i for i in input().split(' ')]
    if a == b: lst.append("Y")
    else : lst.append("N")
for i in range(1,len(lst)-1):
    if lst[i] == 'Y':
        if lst[i-1]=='Y' and lst[i+1] == 'Y':
            result = 1
            print('Yes')
            break
    else :continue
if result != 1: print('No')

Solution (Python):
"""
abc179_B
"""
n = int(input())
ans = 'No'

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

for i in range(0,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]:
        ans = 'Yes'
        break

print(ans)

Solution (Python):
n = int(input())
d1 = []
d2 = []
count = 0
ans = 'No'
for x in range(n):
     c, b = input().split()
     d1.append(c)
     d2.append(b)
for y in range(n):
    if d1[y] == d2[y]:
        count +=1
        if count >= 3:
            ans = 'Yes'
            break
    else:
        count = 0
print(ans)

Solution (Python):




N = int(input())

num_list = []
ans = 0
count1,count2,count3 = 0,0,0
for i in range(N):
        D1,D2 = map(int, input().split())
        num_list.append([D1,D2])
        if D1 != D2:
                count1 = 0
                count2 = 0
                count3 = 0
        if D1 == D2 and  count1 == 1 and  count2 == 1:
                count3 = 1
                ans = 1
        if D1 == D2 and count1 == 1:
                count2 = 1
        if D1 == D2:
                count1 = 1
if ans == 1:
        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())
count=0
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]:
                count=count+1
if count>=1:
    print("Yes")
else:
    print("No")

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

D = [[] for i in range(N+2)]

for i in range(N) :
  a = input().split()
  D[i].append(int(a[0]))
  D[i].append(int(a[1]))
  a.clear()

D[N].append(0)
D[N].append(1)

D[N+1].append(0)
D[N+1].append(1)
  



judge = 'No'

for i in range(N) :
  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] :
    judge = 'Yes'

print(judge)

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


for i in range(n-2):
  cnt = 0
  if  x[i][0]==x[i][1]:
    cnt=1
  else:
    continue
    
  if  x[i+1][0]==x[i+1][1]:
    cnt=cnt+1
    
  else:
    continue
    
  if x[i+2][0]==x[i+2][1]:
    cnt=cnt+1 
    if cnt==3:
      print('Yes')
      break
  else:
    break
if cnt!=3:
  print('No')

Solution (Python):
count = 0
for roll in range(int(input())):
    count += 1
    value_a, value_b = map(int, input().split())
    if value_a!=value_b:count=0
    if count>2:
        print("Yes")
        exit(0)
else:print("No")

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

li = list()

for i in range(n):

    a, b = [int(x) for x in input().split()]

    li.append([a,b])

count = 0

for i in li:

    if count < 3:

        if i[0] == i[1]:

            count += 1

        else:

            count = 0

    else:

        break

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

else: print('No')

Solution (Python):
n = int(input())
li = list()
for i in range(n):
    a, b = [int(x) for x in input().split()]
    li.append([a,b])
count = 0
for i in li:
    if count < 3:
        if i[0] == i[1]:
            count += 1
        else:
            count = 0
    else:
        break
if count >= 3: print('Yes')
else: print('No')

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

Solution (Python):




import sys



iimr = lambda: map(int, sys.stdin.readline().rstrip().split())
readline = sys.stdin.readline





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



class atcoder():
    def __init__(s):
        s.N = int(input())

    def çözmek(s):
        
        res = []
        res.append(s.関数(s.N))
        if res[0] == True:
            print("Yes")
        else: 
            print("No")
    
    def 関数(self, n):
        tsuzuku = 0
        trouve = False
        for i in range(n):
            a, b = map(int, input().split())
            
            if a == b:
                tsuzuku += 1
            else: 
                tsuzuku = 0
            if tsuzuku == 3:
                trouve = True

        return trouve 

if __name__ == "__main__":
    ima = atcoder()
    ima.çözmek()

Solution (Python):
N = int(input())
D1 =[]
D2 =[]
for i in range(N):
    a,b = map(int,input().split())
    D1.append(a)
    D2.append(b) 
ans = "No"
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]:
                ans ="Yes"
print(ans)

Solution (Python):
N=int(input())
cnt=0
maxcnt=0
for i in range(N):
  tmp = input().split()
  tmp1=int(tmp[0])
  tmp2=int(tmp[1])
  if tmp1 == tmp2:
    cnt+=1
  else:
    cnt=0
  
  if cnt > maxcnt:
    maxcnt=cnt
    
if maxcnt >= 3:
  print("Yes")
else:
  print("No")

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]:
        if 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 = [list(map(int,input().split())) for _ in range(n)]

for i in range(n - 2):
    if all((d[i + j][0] == d[i + j][1] for j in range(3))):
        print('Yes')
        exit()

print('No')

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

count = 0
for i in li:
    if count < 3:
        if i[0] == i[1]:
            count += 1
        else:
            count = 0
    else:
        break

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

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

for j in range(N-2):
    if num_list[j][0] == num_list[j][1] and num_list[j+1][0] == num_list[j+1][1] and num_list[j+2][0] == num_list[j+2][1]:
        print ("Yes")
        break
    elif j != N-3 and (num_list[j][0] != num_list[j][1] or num_list[j+1][0] != num_list[j+1][1] or num_list[j+2][0] != num_list[j+2][1]):
        continue
    else:
        print("No")

Solution (Python):
n =int(input())
first =[]
second =[]
for i  in range(n):
    d1 , d2 = map(int , input().split())
    first.append(d1)
    second.append(d2)

for i in range(n-2):
    count = 0
    for j in range(i ,i+3):
        if first[j]==second[j]:
            count +=1
        else:
            break
           
    if count ==3:
        print("Yes")
        break
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())

cnt = 0

for i in range(n-2):
    c = a[i] - b[i] 
    if c == 0:
        d = a[i+1] - b[i+1]
        if d == 0:
            e = a[i+2] - b[i+2]
            if e == 0:
                cnt += 1

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

Solution (Python):
def main():
    n = int(input())
    
    l = []
    for _ in range(n):
        d1,d2 = tuple(map(int,input().split()))
        l.append(1 if d1==d2 else 0)

    for i in range(n-2):
        if sum(l[i:i+3])==3:
            print("Yes")
            return

    print("No")
    

if __name__ == "__main__":
    main()

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")
    break
  if i == n-3:
    print("No")

Solution (Python):
import sys

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

print(ans)

Solution (Python):
N = int(input())
count = 0
D1_arr = []
D2_arr = []
for i in range(N):
    D1, D2 = map(int, input().split())
    D1_arr.append(D1)
    D2_arr.append(D2)
for i in range(N-2):
    if D1_arr[i] == D2_arr[i] and D1_arr[i+1] == D2_arr[i+1] and D1_arr[i+2] == D2_arr[i+2]:
        count += 1
if count >= 1:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
cnt = 0
flg = False
for _ in range(N):
    S1, S2 = input().split()
    if S1 == S2:
        cnt += 1
        if cnt >= 3:
            flg = True
    else:
        cnt = 0
if flg:
    print("Yes")
else:
    print("No")

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

s = []
for i in range(n):
  a, b = input().split()
  if a == b:
    s.append(True)
  else:
    s.append(False)

flag = 'No'

for i in range(n - 2):
  if s[i] and s[i+1] and s[i+2]:
    flag = 'Yes'

print(flag)

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

ans = 0
cnt = 0

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

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

L = []
for i in range(0, N):
    L.append(input().rstrip().split())

counter = 0
out = ""
for j in range(len(L)):
    if (L[j][0] == L[j][1]):
        counter += 1
        if (counter >= 3):
            out = "Yes"
            break
    else:
        counter = 0
        out = "No"
        
print(out)

Solution (Python):
N = int(input())
lis = [list(map(int, input().split())) for i in range(N)]
A = 'No'
for j in range(N-2):
  if lis[j][0] == lis[j][1]:
    if lis[j+1][0] == lis[j+1][1]:
      if lis[j+2][0] == lis[j+2][1]:
        A = 'Yes'
        break
print(A)

Solution (Python):

t = int(input())
count = 1
result = 0
test = 0
p = ''
for i in range(t):
    a, b = map(int, input().split())
    
    if (a == b):
        result = 1
    else:
        result = 0
    
    if result == 1:
        test += 1
        if test >= 3:
            p = 'Yes'
    else:
        test = 0

if p == 'Yes':
    print('Yes')
else:
    print('No')

Solution (Python):

n = int(input())
cnt = 0
for i in range(n):
  d1, d2 = map(int, input().split())
  if d1 == d2:
    cnt += 1
    if cnt == 3:
      print("Yes")
      quit()
  else:
    cnt = 0
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)]

flag=0

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

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

Solution (Python):
from itertools import groupby, islice
N = int(input())
D = []
c=[]
for i in range(0, N):
    D.append(list(map(int, input().split(" "))))
for i in D:
    if i[0]==i[1]:
        c.append(True)
    else:
        c.append(False)
answer = any(sum(1 for _ in islice(g, 3)) == 3 for k, g in groupby(c) if k)
if answer:
    print("Yes")
else:
    print("No")

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

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

for i in range(n-2):
        if(x[i][0] == x[i][1] and x[i+1][0] == x[i+1][1] and x[i+2][0] == x[i+2][1]):
            p = "Yes"
            break
        else:
            p = "No"


print(p)

Solution (Python):
dice_num_list = []
equal_index_list = []

N = int(input())

for i in range(1, N + 1):
    d1, d2 = input().split(" ")
    dice_num_list.append([d1, d2])

equal_index_list = [i for i, x in enumerate(dice_num_list) if x[0] == x[1]]

l = len(equal_index_list)
if l < 3:
    print('No')
    exit(0)

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

print("No")

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

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

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

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

Solution (Python):
n = int(input())
cnt = 0
flag = False
for _ in range(n):
    s, t = map(int, input().split())
    if s == t:
        cnt = cnt + 1
    else:
        cnt = 0

    if cnt >= 3:
        flag = True

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

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

for i in range(n) :
    if set(l[i]) == {1} or set(l[i]) == {2} or set(l[i]) == {3} or set(l[i]) == {4} or set(l[i]) == {5} or set(l[i]) == {6} :
        cnt += 1
        if cnt == 3 :
            print('Yes')
            exit()
    else :
        cnt = 0
print('No')

Solution (Python):
read = lambda: map(int, input().split())
n = int(input())
a = [tuple(read()) for i in range(n)]
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
print('Yes' if f else 'No')

Solution (Python):
def MI():
    return map(int, input().split())

n = int(input())

cnt=[0]*(n+1)
for i in range(n):
    a,b= MI()
    if a==b:
        cnt[i+1]=cnt[i]+1
    else:
        cnt[i+1]=0

if max(cnt)>2:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
s=0
t=[]
for i in range(0,n):
    if a[i][0]==a[i][1]:
        s=s+1
    else:
        t.append(s)
        s=0
t.append(s)    
u=1   
for j in t:
    if u<j:
        u=j
if u>=3:
    print('Yes')
else:
    print('No')

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

count = 0
count2 = 0

for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        count += 1
    else:
        count = 0
    if count >= 3:
        count2 +=1
        break

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

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

Solution (Python):
a = int(input())
l = []
c = 0
f = 0
for i in range(a):
    ta,tb = map(int,input().split())
    if ta==tb : c+=1
    else: c = 0
    if c>=3 : f = 1
if f:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
N = int(input())
List = list()
for i in range(N):
  List.append(list(map(int, input().split())))
List = sum(List, [])
for i in range(1,N-1):
  if List[2*i-2] == List[2*i-1]:
    if List[2*i] == List[2*i+1]:
      if List[2*i+2] == List[2*i+3]:
        print("Yes")
        exit()
      else:
        pass
    else:
      pass
  else:
    pass
print("No")

Solution (Python):
import sys,math
from collections import deque,defaultdict
import operator as op
from functools import reduce

sys.setrecursionlimit(10**6) 

I=sys.stdin.readline

 

"""
x_move=[-1,0,1,0,-1,1,1,-1]
y_move=[0,1,0,-1,1,1,-1,-1]
"""
def ii():
	return int(I().strip())
def li():
	return list(map(int,I().strip().split()))
def mi():
	return map(int,I().strip().split())

def ncr(n, r):
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer // denom

def gcd(x, y):
    while y:
        x, y = y, x % y
    return x
def divi(n):
	if n==1:
		return 1
	cnt=2
	for i in range(2,int(n**.5)+1):
		if n%i==0:
			if i==n//i:
				cnt+=1
			else:
				cnt+=2
	return cnt


def main():
	cnt=0
	ans=0
	for i in range(ii()):
		a,b=mi()
		if a==b:
			cnt+=1
			if cnt==3:
				ans=1
				
		else:
			cnt=0
	if ans:
		print("Yes")
	else:
		print("No")
	

























	
	
	





if __name__ == '__main__':
	main()

Solution (Python):
n = int(input().strip())
a,b = map(int,input().strip().split())
c,d = map(int,input().strip().split())
flag = 0
for i in range(n-2):
  e,f = map(int,input().strip().split())
  if a == b and c == d and e == f:
    flag = 1
  a,b = c,d
  c,d = e,f
if flag == 0:
  print("No")
else:
  print("Yes")

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

list1 = []
list2 = []
syokika = []
count = 0

for i in range(n):
    
    

    list1 = input().split()
    
    list2.append(int(''.join(list1)))
    list1 = copy.deepcopy(syokika)

for i in range(1,len(list2)):
    if(count>=2):
        break
    if(list2[i-1]%11==0 and list2[i]%11==0):
        count += 1
    else:
        count = 0

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

Solution (Python):
import os,sys
c=0
ok=False
n=input()
for i in range(int(n)):
    m=input()
    one=m[0]
    two=m[2]
    if one==two:
        c+=1
    else:
        c=0
    if c>=3:
        ok=True
    
if(ok):
    print('Yes')
else:
    print('No')

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

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

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

main()

Solution (Python):
from itertools import groupby, islice

N = int(input())
D = []
c=[]
for i in range(0, N):
    D.append(list(map(int, input().split(" "))))
for i in D:
    if i[0]==i[1]:
        c.append(True)
    else:
        c.append(False)
answer = any(sum(1 for _ in islice(g, 3)) == 3 for k, g in groupby(c) if k)
if answer:
    print("Yes")
else:
    print("No")

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

ans = []
for i in range(n):
  a = num_list[i]
  a1= a[0]
  a2 = a[1]
  if a1 == a2:
    ans.append(1)
    if i > 1 and ans[i-2] == 1 and ans[i-1] == 1 and ans[i] == 1:
      print('Yes')
      break
  else:
    ans.append(0)
if 0 in ans and len(ans) == n :
  print('No')

Solution (Python):
n=int(input())
l=[]
c=False
for i in range(n):
    l.append(list(input().split()))
for x in range(n-2):
    if l[x][0]==l[x][1]:
        if l[x+1][0]==l[x+1][1]:
            if l[x+2][0]==l[x+2][1]:
                c=True
if c:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
count = 0
for _ in range(N):
    a, b = input().split()
    if a == b:
        count += 1
    else:
        count = 0

    if count >= 3:
        print("Yes")
        break
if count < 3:
    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):
from itertools import groupby, islice

N = int(input())
D = []
c=[]
for i in range(0, N):
    D.append(list(map(int, input().split(" "))))
for i in D:
    if i[0]==i[1]:
        c.append(True)
    else:
        c.append(False)
answer = any(sum(1 for _ in islice(g, 3)) == 3 for k, g in groupby(c) if k)
if answer:
    print("Yes")
else:
    print("No")

Solution (Python):
def actual(N: int, D1: list, D2: list) -> str:
    cnt = 0
    is_turkey = False
    for d1, d2 in zip(D1, D2):
        is_zoro = d1 == d2

        if is_zoro:
            cnt += 1
            if cnt == 3:
                is_turkey = True
        else:
            cnt = 0

    if is_turkey:
        return 'Yes'
    else:
        return 'No'
    
N = int(input())
D1, D2 = [],[]

for _ in range(N):
    d1,d2 = map(int, input().split())
    D1.append(d1)
    D2.append(d2)
    
    
print(actual(N,D1,D2))

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

for i in range(N):
    if x[i]==y[i] and N-2>i:
        if x[i+1]==y[i+1] and N-1>i:
            if x[i+2]==y[i+2] :
                ans = 'Yes'

print(ans)

Solution (Python):
cnt = 0
n = int(input())
for i in range(0,n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        cnt += 1
        if cnt == 3 :
            print("Yes")
            break
    elif  cnt >= 0 and d1 != d2:
        cnt = 0 
    if i == n-1:
        print("No")

Solution (Python):
N = int(input())
X = []
Y = []
answer = 'No'
for i in range(N):
    x,y = map(int, input().split())
    X.append(x)
    Y.append(y)
for j in range(N-2):
    if ((X[j]==Y[j])and(X[j+1]==Y[j+1])and(X[j+2]==Y[j+2])):
        answer = 'Yes'
print(answer)

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

for i in range(n):
    if  len(set(d[i])) == len(d[i]):
        if total >=3:
            total +=0
        else:
            total = 0
    else:
        total += 1

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

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

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

Solution (Python):


N = int(input())

box = []
for i in range(N):
     line = input().split()
     if line[0] == line[1]:
          box.append(1)
     else:
          box.append(0)


m = 0
for j in range(N-2):
     
     n = box[j]+box [j+1]+box[j+2]
     if n == 3:
          m = 1
     
if m == 1:
     print("Yes")
else:
     print("No")

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

flag = False
count = 0
for i in range(n):
    d1 = d_lst[i][0]
    d2 = d_lst[i][1]

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

eq = 0
mx = 0
prev = False
for i in range(n):
    d = [int(s) for s in input().split(' ')]
    if d[0] == d[1]:
        if prev:
            eq += 1
        prev = True
        mx = max(eq, mx)
    else:
        prev = False
        eq = 0

if mx >= 2:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
zoro = 0
res = []

for i in range(N):
    a, b = map(int, input().split())
    if a == b:
        zoro += 1
        res.append(zoro)
    else:
        zoro = 0
        res.append(zoro)

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

Solution (Python):
N = int(input())
D1 = [0] * N
D2 = [0] * N
count = 0
continues = [0] * N

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

for i in range(N):
    if D1[i] == D2[i]:
        continues[i] = 1

for i in range(N):
    if continues[i] == 1:
        count = count + 1
    else:
        count = 0
    if count == 3:
        break

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

Solution (Python):

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



ans = "No"
renzoku = 0

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

print(ans)

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

Solution (Python):
N=int(input())
Di=[input() for i in range(N)]
count=0
n=0
D=[]
a=[]
A=0
for i in range(N):
    D.append(Di[i].split())

for i in range(N):
    if D[i][0]==D[i][1]:
        count+=1
    else:
        a.append(count)
        count=0
if len(a)==0:
    A=0
else:
    A=max(a)

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

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

count = 0
for one, two in Ds:
    if not one == two:
        count = 0
        continue

    count += 1
    if count == 3:
        print("Yes")
        break

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

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

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

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

cnt = 0
for i in range(N):
  if i < N - 2:
    a, b = lst[i]
    c, d = lst[i + 1]
    e, f = lst[i + 2]
    if a == b and c == d and e == f:
      cnt += 1
    else:
      continue
if cnt >= 1:
  print('Yes')
else:
  print('No')

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

count=0
c_list=[1]

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

Solution (Python):
import bisect
from collections import deque
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

mod = 998244353

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]



def main():
    N = int(input())
    t = 0
    f = False
    for _ in range(N):
        a, b = read_values()
        if a == b:
            t += 1
        else:
            t = 0

        if t == 3:
            f = True
    
    print("Yes" if f else "No")


if __name__ == "__main__":
    main()

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

ans = False
for i in range(N-2):
    if D[i] and D[i+1] and D[i+2]:
        ans = True
        break
YesNo = lambda tf: print('Yes') if tf else print('No')
YesNo(ans)

Solution (Python):
n = int(input())
t = [0] * n
x = [0] * n
for i in range(n):
    t[i], x[i] = map(int, input().split())
a=0
for j in range(n-2):
    if t[j]==x[j]and t[j+1]==x[j+1] and t[j+2]==x[j+2]:
        a+=1
    else:
        a+=0
if a==0:
    print('No')
else:
    print('Yes')

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):
n = int(input())
d = []
for i in range(n):
  d.append(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'
    break

print(ans)

Solution (Python):
import sys

n = int(input())

zoro = 0
res = 0

for i in range(n):
    d1, d2 = map(int, input().split())

    if d1 != d2:
        zoro = 0
    else:
        zoro = zoro + 1
    if zoro == 3:
        res = 1

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

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

result = ""

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

if "111" in result:
  print("Yes")
else:
  print("No")

Solution (Python):
get = lambda  : int(input())
getlist = lambda : list(map(int, input().split(" ")))

n = get()
arr = []
for i in range(n):
    arr.append(getlist())

ok = False
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]:
        ok = True
        break
if ok:
    print("Yes")
else:
    print("No")

Solution (Python):
x = []
y = []

n = int(input())

for i in range(n):
    a, b = map(int, input().split())
    x.append(a)
    y.append(b)

z = 0

for i in range(n-2):
    if x[i] == y[i]:
        if x[i + 1] == y[i + 1]:
            if x[i + 2] == y[i + 2]:
                z = 1
                break
            else:
                z = 0
                continue
        else:
            z = 0
            continue
    else:
        z = 0
        continue
    


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