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



Sample input:
5
1 2
6 6
4 4
3 3
3 2


Sample output:
Yes

Submission status: Accepted

Solution code:
import sys
N = int(input())
i=0
X = [0]*N
Y = [0]*N
while i < N:
    
    X[i],Y[i] = list(map(int,input().split()))
    i = i+1
for j in range(N-2):
    if X[j]==Y[j]:
        if X[j+1]==Y[j+1]:
            if X[j+2]==Y[j+2]:
                print("Yes")
                sys.exit()
print("No")

Submission status: Accepted

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

counts = [0]
count = 0

for i in range(times):
  if x[i] == y[i]:
    count += 1
  else:
    counts.append(count)
    count = 0
counts.append(count)

counti = max(counts)

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

Submission status: Accepted

Solution code:
N = int(input())
inputstr = []
inputlist = []
for i in range(N):
    inputstr = str(input())
    inputint = inputstr.split()
    inputlist.append(inputint)

isJail = False
for i in range(len(inputlist)-2):
    if(inputlist[i][0] == inputlist[i][1]):
        if inputlist[i+1][0] == inputlist[i+1][1]:
            if inputlist[i+2][0]== inputlist[i+2][1]:
                 isJail = True

if isJail == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n=int(input())
count=0
for i in range(n):
  me1,me2=list(map(int,input().split()))
  if me1==me2:
    count+=1
    if count==3:
      break
  else:
    count=0
if count>=3:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
N=int(input())
count=0
nums_count=[]
for i in range(N):
    nums=[int(e) for e in input().split()]
    nums_count.append(nums)

count=0
for i in range(N-2):
    if (nums_count[i][0]==nums_count[i][1]) and (nums_count[i+1][0]==nums_count[i+1][1]) and (nums_count[i+2][0]==nums_count[i+2][1]):
        count=1

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

Submission status: Accepted

Solution code:
N = int(input())
x = 0
check = 0

for i in range(N) :
    a,b = map(int,input().split())
    if a == b :
        x += 1
    else :
        x = 0
    if  x == 3 :
        check = 1

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

Submission status: Accepted

Solution code:
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007

#+++++

def main():
	n = int(input())
	cc=0
	for _ in range(n):
		b , c = tin()
		if b == c:
			cc += 1
			if cc == 3:
				return 'Yes'
		else:
			cc = 0
	return 'No'
	#s = input()	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
c=0
for i in range(0,n):
    x,y=list(map(int,input().split()))
    if(x==y):
        c+=1
        if(c==3):
            ans=1
            break
    else:
        c=0
        continue
    
if(ans==1):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())

xy = [input() for _ in range(N)]

cnt = 0

result = 'No'

for D in xy:
  list = D.split()
  if list[0] == list[1]:
    cnt = cnt + 1
    if cnt == 3:
      result = 'Yes'
      break
  else:
    cnt = 0
print(result)

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        a.append(True)
    else:
        a.append(False)
a.append(False)
a.append(False)
for h, i in enumerate(a):
    if i == True:
        if a[h+1] and a[h+2]:
            print("Yes")
            exit()
print("No")

Submission status: Accepted

Solution code:
N = int(input())
flag = False
count = 0
for i in range(N):
    D = list(map(int, input().split()))
    if D[0] == D[1]:
        count += 1
    else :
        count = 0
    if count == 3:
        flag = True

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

Submission status: Accepted

Solution code:
n = int(input())
num_list = []
count = 0

for _ in range(1, 1 + n):
    a, b = map(int, input().split())
    if a == b:
        count += 1
        if count == 3:
            break
    else:
        count = 0

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

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
from typing import List, Tuple


def actual(N: int, D: List[Tuple[int, int]]) -> str:
    rep_digit_rolls: List[bool] = [d1 == d2 for d1, d2 in D]

    three_straights: List[bool] = [all(rep_digit_rolls[i:i + 3]) for i in range(len(rep_digit_rolls) - 2)]

    if any(three_straights):
        return 'Yes'
    else:
        return 'No'

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

print(actual(N, D))

Submission status: Accepted

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

exist = False
for i in range(n-2):
    for j in range(3):
        if d[i+j][0] != d[i+j][1]:
            break
    else:
        exist = True
if exist:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())

X=[]
Y=[]
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
    
A="No"
for n in range(N-2):
    if X[n]==Y[n]:
        if X[n+1]==Y[n+1]:
            if X[n+2]==Y[n+2]:
                A="Yes"
                break
            else:
                continue
        else:
            continue
    else:
        continue
print(A)

Submission status: Accepted

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

count = 0

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

Submission status: Accepted

Solution code:
n = int(input())

list_a = list()
list_b = list()
for i in range(n):
  a, b = input().split()
  list_a.append(a)
  list_b.append(b)

result = "No"
for k in range(n-2):
  if list_a[k] == list_b[k] and list_a[k + 1] == list_b[k + 1] and list_a[k + 2] == list_b[k + 2]:
    result = "Yes"
print(result)

Submission status: Accepted

Solution code:
N=int(input())
x=0
for i in range(N):
    D = list(map(int,input().split()))
    if D[0]==D[1]:
        x=x+1
        if x>=3:
            break
    elif D[0]!=D[1]:
        x=0
if x>=3:
    print("Yes")
elif x<3:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
conseq = 0
ans = False
for i in range(n):
  d1,d2 = map(int,input().split())
  if d1 == d2:
    conseq += 1
    if conseq >= 3:
      ans = True
  else:
    conseq = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
zorome = list(range(N))
judgement = 1
for i in range(1,N+1):
    a,b = map(int,input().split())
    if a==b:
        zorome[i-1]=0
    else:
        zorome[i-1]=1
    if i > 2:
        if zorome[i-1]==zorome[i-2] and zorome[i-2]==zorome[i-3]:
            if zorome[i-1] == 0:
                judgement = 0
if judgement == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
import sys

times=int(input())

num=0

#determine whether same number or not. And if eyes are same, num is +=1, else num is 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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
"""
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# coding: utf8
# 日本語を入力できるようにするために上記一文が必要


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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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)
  
#print('N = ', N)
#print('D = ', D)

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)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# atcoder 
# Türkler var mı?
# Herkese memnün oldum
import sys
#from heapq import heapify, heappush, heappop
#from heapq import nlargest, nsmallest

iimr = lambda: map(int, sys.stdin.readline().rstrip().split())
readline = sys.stdin.readline
# puorquoi le sys.stdin.buffer.readline() ne fonctionne plus sur atcoder?
#sys.setrecursionlimit(10 ** 7)
#INF = 1 << 30 # 大体 1e9


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


# s == self
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())
            #debug([a,b])
            if a == b:
                tsuzuku += 1
            else: 
                tsuzuku = 0
            if tsuzuku == 3:
                trouve = True

        return trouve 

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc179/tasks/abc179_b
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')

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
import sys,math
from collections import deque,defaultdict
import operator as op
from functools import reduce

sys.setrecursionlimit(10**6) 

I=sys.stdin.readline

 #s="abcdefghijklmnopqrstuvwxyz"

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

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

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

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

for i in range(n):
    #list2.append(input().split())
    #list_copy=copy.deepcopy(list1)
##   list1 = copy.deepcopy(syokika)
    list1 = input().split()
    #list2.append(list1.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')

Submission status: Accepted

Solution code:
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')

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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()

Submission status: Accepted

Solution code:
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")

Submission status: Accepted

Solution code:
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')