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:
n = int(input())
count = 0
for i in range(n):
    a,b = input().split()
    if(a==b):
        count+=1
        if(count>2):
            break
    else:
        count=0
if(count>2):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

for i in range(n):
    d1, d2 = d[i]
    if d1==d2:
        num += 1
        ans = max(ans, num)
    else:
        num = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, D: "List[List[int]]"):
    n = 0
    for d in D:
        if d[0] == d[1]:
            n += 1
        else:
            n = 0
        if n == 3:
            print(YES)
            break
    else:
        print(NO)
    # if n==3:
    #     print(YES)
    # else:
    #     print(NO)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = [[int(next(tokens)) for _ in range(2)] for _ in range(N)]  # type: "List[List[int]]"
    solve(N, D)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
count = 0
flag = False
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        count+=1
        if count >= 3:
            flag = True
    else:
        count=0

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

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
ans = []
for i in range(n):
    a,b = map(int,input().split())
    if a == b:
        cnt += 1
    else:
        cnt = 0
    ans.append(cnt)

if max(ans) >= 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)]

count = 0

for i in range(n-1):
  if count == 2:
    break
  elif d[i][0] == d[i][1] and d[i+1][0] == d[i+1][1]:
    count += 1
  else:
    count = 0
    
if count == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n = int(input())
c = []
ans = "No"
for _ in range(n):
    a, b = map(int, input().split())
    c.append(a==b)
for i in range(n-2):
    if c[i] and c[i+1] and c[i+2]:
        ans = "Yes"

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

D1 = []
D2 = []

for i in range(N):
  s = input().split()
  D1.append(int(s[0]))
  D2.append(int(s[1]))
  
result = 'No'  
  
for i in range(N-2):
  if D1[i] == D2[i]:
    if D1[i+1] == D2[i+1] and D1[i+2] == D2[i+2]:
      result = 'Yes'
      
print(result)

Submission status: Accepted

Solution code:
count=[]
for _ in range(int(input())):
    a,b=map(int,raw_input().split())
    if a==b:
        count.append(_)
flag=False
# print count
for i in range(1,len(count)-1):
    if count[i]-1==count[i-1] and count[i]+1==count[i+1]:
        flag=True
        print "Yes"
        break
if flag==False:
    print "No"

Submission status: Accepted

Solution code:
#B
N=int(input())
cnt=0
flag=False
for i in range(N):
    a,b=map(int,input().split())
    if a==b:
        cnt+=1
    else:
        cnt=0
    if cnt==3:
        flag=True
        break
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n= int(input())
L = [input().split() for _ in range(n)]
i=0
for item in L:
  if item[0] == item[1]:
    i=i+1
    if i ==3:
      break
  else:
    i=0
print('Yes' if i == 3 else 'No')

Submission status: Accepted

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

cnt = 0
flg = 0

for i in lis:
    if i[0]==i[1]:
        cnt += 1
        if cnt >= 3:
            flg = 1
    else:
        cnt = 0

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

Submission status: Accepted

Solution code:
n=int(input())
ans=0
anss=[]
ok=False
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        ans+=1
    else:
        anss.append(ans)
        ans=0
anss.append(ans)       
ok=False
for i in anss:
    if i>=3:
        ok=True
if ok:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
zorome = 0
yes = False

for i in range(n):
  x, y = map(int, input().split())
  if x == y:
    zorome += 1
    if zorome >= 3:
      yes = True
  else:
    zorome = 0

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

Submission status: Accepted

Solution code:
from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip

import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
from functools import lru_cache   #use @lru_cache(None)
if os.path.exists('in.txt'): sys.stdin=open('in.txt','r')
if os.path.exists('out.txt'): sys.stdout=open('out.txt', 'w')
#
def input(): return sys.stdin.readline()
def mapi(arg=0): return map(int if arg==0 else str,input().split())
# sys.setrecursionlimit(10**6)
#------------------------------------------------------------------


n = int(input())
a = []
for i in range(2):
    a.append(list(mapi()))
f = 0
for i in range(2,n):
    a.append(list(mapi()))
    if a[i][0]==a[i][1] and a[i-1][0]==a[i-1][1] and a[i-2][0]==a[i-2][1]:
        f = 1
if f:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

    count = 0
    answer = 'No'
    for i in range(n):
        d = list(map(int, input().split()))
        if d[0] == d[1]:
            count += 1
        else:
            count = 0
        if count >= 3:
            answer = 'Yes'

    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

count = 0
for i in range(n):
  ds = input().split()
  d1 = ds[0]
  d2 = ds[1]
  
  if d1 == d2:
    count += 1
  else:
    count = 0
  
  if count == 3:
    print("Yes")
    break
else:
  print("No")

Submission status: Accepted

Solution code:
n = int(input())
renzoku = 0
for i in range(n):
	d = [int(each) for each in input().split()]
	if d[0] == d[1]:
		renzoku += 1
		if renzoku == 3:
			print('Yes')
			break
	else:
		renzoku = 0
else:
	print('No')

Submission status: Accepted

Solution code:
def calc(N, D):
    c = 0
    for (d1, d2) in D:
        if d1 == d2:
            c += 1
            if c == 3:
                return 'Yes'
        else:
            c = 0
    return 'No'


N = int(input())
D = [tuple([int(s) for s in input().split()]) for _ in range(N)]
print(calc(N, D))

Submission status: Accepted

Solution code:
# coding: utf-8
n = int(input())
L=[]
for i in range(n):
    a, b = map(int,input().split())
    if a==b:
        L.append(1)
    else:
        L.append(0)
flg=False
for i in range(n-2):
    if L[i] and L[i+1] and L[i+2]:
        flg=True
        break

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

Submission status: Accepted

Solution code:
n = int(input())
count = 0
for _ in range(n):
    i,j = map(int, input().split())
    if i == j:
        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())
count = 0
TF = False
for i in range(N):
    Ds = list(map(int, input().split()))
    if  Ds[0] == Ds[1]:
        count += 1
    else:
        count = 0
    if count == 3:
        TF = True
        break

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

Submission status: Accepted

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


for i in range(N):
    if i + 2 > N - 1:
        break
    if D[i][0] == D[i][1] and D[i + 1][0] == D[i + \
        1][1] and D[i + 2][0] == D[i + 2][1]:
        print('Yes')
        exit()

print('No')

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
isOK = False
for i in range(n):
  x,y = map(int,input().split())
  if x==y:
    cnt += 1
  else:
    cnt = 0
  if cnt>=3:
    isOK = True
    break
#if cnt >= 3:
#  isOK = True

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

Submission status: Accepted

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

current = 0
found = False
for i in range(len(rolls)):
    if rolls[i][1] == rolls[i][0]:
        current += 1
    else:
        current = 0
    if current == 3:
        found = True

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

Submission status: Accepted

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

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

ans='No'
for p in range(n-2):

    if x[p] == y[p] and x[p+1] == y[p+1] and x[p+2] == y[p+2] :
        ans='Yes'
        break

print(ans)

Submission status: Accepted

Solution code:
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前
sort()
sorted(reverse=true)
配列の初期化
配列名=[a]*n+[b]*m
Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions
import sys
t = False
n = stdin.readline().rstrip()
count = 0
for el in range(int(n)):
    tmp = stdin.readline().rstrip().split()
    a = int(tmp[0])
    b = int(tmp[1])
    if a == b:
        count += 1
    else:
        count = 0
    if count >= 3:
        t = True
if t:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

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

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

print("No")

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

print('Yes' if ans > 0 else 'No')

Submission status: Accepted

Solution code:
N = int(input())

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

    if cnt >=3:
        ans = 'Yes'

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
count = 0
flag = False
for i in range(N):
  Di, Dj = map(int, input().split())
  if Di == Dj:
    count += 1
    if count == 3:
      flag = True
  else:
    count = 0
if flag == True:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n = int(input())
count = 0 
flag = 0 
for i in range(n):
    
    temparr = input()
    temparr = temparr.split()
    first = int(temparr[0])
    sec = int(temparr[1])
    if first == sec:
        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())

cnt = 0
for i in range(n):
    x, y = map(int, input().split())

    if x == y:
        cnt += 1
    else:
        cnt = 0

    if cnt >= 3:
        print('Yes')
        exit()

print('No')

Submission status: Accepted

Solution code:
n=int(input())
cnt=0
ans=0
for i in range(n):
    d,e=map(int,input().split())
    if d!=e:
        if cnt==3:
            ans=1
            break
        cnt=0
    else:
        cnt+=1
        if cnt==3:
            ans=1
            break
if cnt>=3:
    ans=1
if ans==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
count = 0
for a, b in D:
    if a == b:
        count += 1
    else:
        count = 0
    if count >= 3:
        ans = 'Yes'
        break
else:
    ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

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

ans = 0
flg = False
tmp = 0
for c,d in D:
    if c==d:
        if flg:
            tmp += 1
            ans = max(ans, tmp)
        else:
            tmp = 1
            flg = True
            ans = max(ans, tmp)
    else:
        flg = False

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

Submission status: Accepted

Solution code:
import sys

N = int(input())
def c(s):
  return s[0] == s[1]
DS = [c(input().split()) for _ in range(N)]


for i in range(2, N):
  if DS[i-2] and DS[i-1] and DS[i]:
    print('Yes')
    sys.exit()

print('No')

Submission status: Accepted

Solution code:
n = int(input())
dat = []
for q in range(n):
    a, b = map(int, input().split())
    dat.append([a,b])
can = False
for i in range(2, n):
    if dat[i-2][0] == dat[i-2][1] and dat[i-1][0] == dat[i-1][1] and dat[i][0] == dat[i][1]:
        can = True
print("Yes" if can else "No")

Submission status: Accepted

Solution code:
#N = int(input())
#A = list(map(int, input().split()))
import sys
N = int(input())
D1 = list()
D2 = list()
for i in range (N):
    a , b = input().split()
    D1.append(a)
    D2.append(b)
s = 0
for i in range (N):
    if D1[0] == D2[0]:
        s = s + 1
    else:
        s = 0
    if s == 3:
        print("Yes")
        sys.exit()        
    del D1[0]
    del D2[0]
print('No')

Submission status: Accepted

Solution code:
n=int(input())
cnt=0
flag=1
for k in range(n):
    i,j= list(map(int, input().split()))
    if i==j:
        cnt+=1
    elif i!=j and cnt!=0:
        cnt=0
    if cnt>2:
        flag=0
if flag==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
count, bre = 0, 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')
    bre = 1
    break
if bre==0:
  print('No')

Submission status: Accepted

Solution code:
n=int(input())
count=0
l=[]
for _ in range(n):
    d1,d2=map(int,input().split())
    if d1==d2:
        count+=1
    else:
        count=0
    l.append(count)
if l.count(3)!=0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N = int(input())

D = input().split()
x = D[0] == D[1]
D = input().split()
y = D[0] == D[1]

for i in range(N - 2):
  D = input().split()
  z = D[0] == D[1]
  if x and y and z:
    print('Yes')
    exit()
  else:
    x = y
    y = z
    
print('No')

Submission status: Accepted

Solution code:
N = int(input())
cnt = 0
ANS = 'No'
for _ in range(N):
    x, y = map(int, input().split())
    if x == y:
        cnt += 1
        if cnt == 3:
            ANS = 'Yes'
    else:
        cnt = 0

print(ANS)

Submission status: Accepted

Solution code:
#ABC179 b
n = int(input())
a = [list(map(int, input().split())) for l in range(n)]
count = 0
ans = 0
for i in range(n):
  if a[i][0] == a[i][1]:
    count += 1
  else:
    count = 0
  if count >= 3:
    ans = 1
if ans == 1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
n=int(input())
flag=0
flag2=0
for r in range(n):
    x,y=map(int,input().split())
    if x==y:
        flag+=1
        if flag==3:
            flag2=1
    else:
        flag=0
if flag2==1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
df_de = [list(map(int, input().split())) for _ in range(n)]
ans = 0
cand = []
for d1, d2 in df_de:
    if d1 == d2:
        ans += 1
    else:
        cand.append(ans)
        ans = 0
cand.append(ans)
print("Yes" if len([i for i in cand if i >= 3]) else "No")

Submission status: Accepted

Solution code:
from sys import stdin
def I():
    return stdin.readline().rstrip()
def MI():
    return map(int,stdin.readline().rstrip().split())
def LI():
    return list(map(int,stdin.readline().rstrip().split()))
#main part
n=int(I())
l=[0]*n
for i in range(n):
    a,b=MI()
    if a==b:
        l[i]=1
ans='No'
for j in range(2,n):
    if l[j]==1 and l[j-1]==1 and l[j-2]==1:
        ans='Yes'
        break
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
c=0
m=1
for i in [0]*n:
    a,b=map(int,input().split())
    if a==b:
        c+=1
        if c==3:
            m=0
    else:
        c=0
print('YNeos'[m==1::2])

Submission status: Accepted

Solution code:
#B
N = int(input())
counter = 0
result = False
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        counter += 1
        if counter == 3:
            result = True
    else:
        counter = 0
print("Yes" if result else "No")

Submission status: Accepted

Solution code:
n=int(input())
l=[]
l1=[]
flag=0
for i in range(n):
    a,b=[int(i) for i in input().split()]
    l.append(a)
    l1.append(b)
for i in range(0,len(l)-2):
    if((l[i]==l1[i]) and (l[i+1]==l1[i+1]) and (l[i+2]==l1[i+2])):
        print('Yes')
        flag=1
        break
    else:
        pass
if(flag==0):
    print('No')

Submission status: Accepted

Solution code:
import sys
from sys import stdin,stdout
import math
import random
import heapq
from collections import Counter
from functools import lru_cache
#@lru_cache(maxsize=None) #for optimizing the execution time of callable objects/functions(placed above callable functions)
try:
    for _ in range(1):
        n=int(input())
        c=0
        flg=0
        for i in range(n):
            a,b=map(int,input().split())
            if a==b:
                c+=1
                if c>=3:
                    flg=1
            else:
                c=0
        if flg:
            print("Yes")
        else:
            print("No")







    
except EOFError as e:
    print(e)

Submission status: Accepted

Solution code:
N = int(input())
count = 0
ok = False
for _ in range(N):
    d1, d2 = [int(s) for s in input().split()]
    if d1 == d2:
        count += 1
    else:
        count = 0
    if count == 3:
        ok = True
if ok:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    A = [list(map(int, input().split())) for _ in range(N)]
    tmp_zoro = 0
    ans = 0
    for i in range(len(A)):
        if A[i][0] == A[i][1]:
            tmp_zoro += 1
        else:
            tmp_zoro = 0 
        ans = max(ans, tmp_zoro)

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
li = [list(map(int,input().split())) for _ in range(n)]
c = 0
ans = 0
for a,b in li:
    if a==b:
        c+=1
        ans = max(c,ans)
    else:
        ans = max(c,ans)
        c=0
if ans >= 3:print('Yes')
else:print('No')

Submission status: Accepted

Solution code:
n = int(input())

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

	if zoro >= 3:
		isZoro = True
		break
		
if isZoro:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    D = [LI() for _ in range(N)]

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

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
n = int(input())
d1 = []
d2 = []
for i in range(n):
    dice1, dice2 = map(int, input().split())
    d1.append(dice1)
    d2.append(dice2)
count = 0
for i in range(n - 1):
    if (d1[i] == d2[i]) and (d1[i + 1] == d2[i + 1]):
        count += 1
    else:
        count = 0
    if count == 2:
        print('Yes')
        break
if count != 2:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
count_max=0
for i in range(n):
    if d_list[i][0]==d_list[i][1]:
        count += 1
        if count>count_max:
            count_max=count 
    else:
        count = 0

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

Submission status: Accepted

Solution code:
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n=int(input())
D=[input_array() for i in range(n)]

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

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

Submission status: Accepted

Solution code:
#Python Competetive Programming Template

from sys import stdin, stdout
from math import *

testing = True

def tp(s="\n"):
	if testing:
		stdout.write(s)

def main():
	n = int(stdin.readline())
	occurs = False
	doubles = 0
	for i in range(n):
		d1, d2 = [int(i) for i in stdin.readline().split()]
		if d1 == d2:
			doubles += 1
			if doubles == 3:
				occurs = True
				break
		else:
			doubles = 0
	if occurs:
		stdout.write('Yes\n')
	else:
		stdout.write("No\n")
        
main()

Submission status: Accepted

Solution code:
n = int(input())
same = [0 for _ in range(n)]
for i in range(n):
  d1, d2 = map(int, input().split())
  if d1 == d2:
    same[i] = 1

for i in range(n):
  if sum(same[i-1:i+2]) == 3:
    print("Yes")
    exit()
    
print("No")

Submission status: Accepted

Solution code:
def N():
    return int(input())
def L():
    return list(map(int,input().split()))
def NL(n):
    return [list(map(int,input().split())) for i in range(n)]
mod = pow(10,9)+7
#import numpy

n = N()
d = NL(n)
cnt = 0
p = 1
ma = 0
for i in range(n):

    if d[i][0] == d[i][1] :
        if p == 1:
            cnt += 1
        else:
            cnt += 1
            p == 1
    else:
        cnt = 0
        p = 0
    ma = max(ma,cnt)
#print(ma)
if ma >= 3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

cnt=0
flag = False
for i in range(n):
    if data[i][0] == data[i][1]:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        flag = True
        break

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

Submission status: Accepted

Solution code:
def readinput():
    n=int(input())
    ab=[]
    for _ in range(n):
        a,b=map(int,input().split())
        ab.append((a,b))
    return n,ab

def main(n,ab):
    count=0
    for a,b in ab:
        if a==b:
            count+=1
            if count>=3:
                return 'Yes'
        else:
            count=0
    return 'No'

if __name__=='__main__':
    n,ab=readinput()
    ans=main(n,ab)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin, stdout
import math
inp = lambda : stdin.readline().strip()
 
n = int(inp())
a = []
b = []
for i in range(n):
    d1, d2 = [int(x) for x in inp().split()]
    a.append(d1)
    b.append(d2)
c = 0
for i in range(n):
    if  a[i] == b[i]:
        c += 1
    else:
        c = 0
    if c == 3:
        print("Yes")
        break
else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
d = []
for i in range(n):
  d.append(input().split())

ans = 'No'
cnt = 0
for x in d:
  if x[0] == x[1]:
    cnt += 1
    if cnt >= 3:
      ans = 'Yes'
      break
  else:
    cnt = 0
    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
D = []
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:
    break

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

Submission status: Accepted

Solution code:
N = int(input())

cnt = 0
ans = "No"

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

print(ans)

Submission status: Accepted

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

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

print('No')

Submission status: Accepted

Solution code:
n = int(input())
d = [tuple(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')
      break
else:
  print('No')

Submission status: Accepted

Solution code:
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
#sort = sorted(a)[::-1] 降順
#if l[i] == l[j]: continue
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]
flag = 0

for i in range(n-2):
    if d[i][0] == d[i][1] and d[i+1][0] == d[i+1][1] and d[i+2][0] == d[i+2][1]:
        print("Yes")
        flag = 1
        break

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

Submission status: Accepted

Solution code:
N = int(input())
ans = 'No'
tmp = 0
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        tmp += 1
    else:
        tmp = 0
        
    if tmp == 3:
        ans = 'Yes'

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin
inp = lambda : stdin.readline().strip()

t = int(inp())
counter = 0
f = False
for _ in range(t):
    a = [int(x) for x in inp().split()]
    if a[0] == a[1]:
        counter += 1
        if counter == 3:
            f = True
    else:
        counter = 0
if f:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
counter = 0
ans = False
for i in [0] * N:
    input_list = list(map(int,input().split()))
    if input_list[0] is input_list[1]:
        counter += 1
        if counter >= 3:
            ans = True
    else:
        counter = 0
if ans:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
import collections as cc
import bisect as bi
I=lambda:list(map(int,input().split()))
n,=I()
ar=[I() for i in range(n)]
tf=0
for i in range(n-3+1):
	if ar[i][0]==ar[i][1] and ar[i+1][0]==ar[i+1][1] and ar[i+2][0]==ar[i+2][1]:
		tf=1
print("Yes" if tf else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    res = [0]*n
    for i in range(n):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            res[i] = 1
    OK = False
    for i in range(2, n):
        if res[i]== 1 and res[i-1] == 1 and res[i-2] == 1:
            OK = True
    if OK:
        print("Yes")
    else:
        print("No")
resolve()