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())
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')
        sys.exit()
print('No')

Submission status: Accepted

Solution code:
n = int(input())
ans = 'No'
cnt = 0
for i 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:
N = int(input())
A = 'No'
C = 0
for i in range(N):
    D = list(map(int, input().split()))
    if D[0] == D[1]:
        C += 1
    else:
        C = 0
    if C == 3:
        A = 'Yes'

print(A)

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

Submission status: Accepted

Solution code:
n = int(input())
ren = 0
ans = 'No'

for i in range(n):
    d1, d2 = map(int, input().split())
    if d1==d2:
        ren += 1
        if ren >= 3:
            ans = 'Yes'
    else:
        ren = 0

print(ans)

Submission status: Accepted

Solution code:
import sys
N=int(sys.stdin.readline().strip())
cnt=0
for _ in range(N):
    d1,d2=map(int, sys.stdin.readline().split())
    if d1==d2:
        cnt+=1
    elif d1!=d2:
        cnt=0
    if cnt==3:
        print "Yes"
        quit()
else:
    print "No"

Submission status: Accepted

Solution code:
n = int(input())

ans = 0

for i in range(n):
    d, e = map(int, input().split())
    if d == e:
        ans += 1
        if ans == 3:
            print("Yes")
            exit()
    else:
        ans = 0

print("No")

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    n = I()
    ans = 0
    temp = 0
    for _ in range(n):
        d1, d2 = MI()
        if d1 == d2:
            temp += 1
        else:
            temp = 0
        ans = max(ans, temp)
    if ans >= 3:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

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

def is_doublet(v):
    return v[0] == v[1]

for i in range(n - 2):
    if is_doublet(arr[i]) and is_doublet(arr[i + 1]) and is_doublet(arr[i + 2]):
        print("Yes")
        break
else:
    print("No")

Submission status: Accepted

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

ans = False
count = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        count += 1
    else:
        count = 0
    if count == 3:
        ans = True

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

Submission status: Accepted

Solution code:
N = int(input())

count = 0
for _ in range(N):
    a, b = map(int, input().split())

    if a == b:
        count += 1
    else:
        count = 0

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

print('No')

Submission status: Accepted

Solution code:
N = int(input())

count = 0
flag = False
for _ in range(N):
  D1, D2 = map(int, input().split())
  if D1 == D2:
    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())
s = "aaa"
for i in range(n):
  d1 , d2 = map(int,input().split(" "))
  if d1 == d2:
    s += "b"
  else:
    s += "c"

if "bbb" in s:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n = int(input())
d = list(list(map(int,input().split())) for _ 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]:
            if d[i+2][0]==d[i+2][1]:
                print("Yes")
                break
else:
    print("No")

Submission status: Accepted

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

count = 0
flag = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        count += 1
    else:
        count = 0
    
    if count >= 3:
        flag = 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    same = list()

    for i in range(N):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            same.append(True)
        else:
            same.append(False)
    
    for i in range(N-2):
        if same[i] and same[i + 1] and same[i + 2]:
            print("Yes")
            exit()
    
    print("No")

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a = int(input())
b = []
c = ""
x = 0
for i in range(a):
    c = input().split()
    if c[0] == c[1]:
        x = x + 1
    else:
        x = 0
    if x >= 3:
        print("Yes")
        exit()
if x <= 3:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
#from queue import *
import random
#sys.setrecursionlimit(int(1e6))
input = sys.stdin.readline
 
############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input()))
def inara():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
################################################################
############ ---- THE ACTUAL CODE STARTS BELOW ---- ############

n=inp()
ara=[]
for i in range(n):
	a,b=invr()
	ara.append([a,b])

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

print("No")

Submission status: Accepted

Solution code:

N = int(input())
DD = []
for i in range(N):
    DD.append(list(map(int,input().split())))
# print('DD:',DD)

cnt=0
flg=0
for i in range(N):
    if cnt==3:
        flg=1
        break
    elif DD[i][0]==DD[i][1]:
        cnt+=1
    else:
        cnt=0

if cnt==3:
    flg=1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

check = False
num = 0
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        num += 1
    else:
        num = 0
    if num == 3:
        check = True

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

Submission status: Accepted

Solution code:
n = int(input())
seq_n = 0
max_seq = 0
for _ in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        seq_n +=1
        max_seq = max(max_seq, seq_n)
    else:
        seq_n = 0
if max_seq < 3:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
n=int(input())
li=""
for _ in range(n):
    a,b = (int(x) for x in input().split())
    if a==b:
        li+="t"
    else:
        li+="s"
print("Yes" if "ttt" in li else "No")

Submission status: Accepted

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

cnt = 0
for a, b in d:
    if a == b:
        cnt += 1
        if cnt >= 3:
            print('Yes')
            exit()
    else:
        cnt = 0
print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
A = [[int(i) for i in input().split()] for j in range(n)]
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]:
        print("Yes")
        break
else:
    print("No")

Submission status: Accepted

Solution code:
N=int(input())
d=[input().split() for i in range(N)]
num=0
n=0
for i in range(N):
    if d[i][0]==d[i][1]:
        num+=1
        if num==3:
            print("Yes")
            n+=1
            break
    else:
        num=0
if n==0:
    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
        if ans == 3:
            print('Yes')
            exit()
    else:
        ans = 0
print('No')

Submission status: Accepted

Solution code:
n=int(input())

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

d=[d_[0]==d_[1] for d_ in d]


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

Submission status: Accepted

Solution code:
n=int(input())
li=[]
for i in range(n):
    d1,d2=map(int,input().split())
    li.append([d1,d2])
cnt=0
for i in range(n):
    if li[i][0]==li[i][1]:
        cnt+=1
        if cnt>=3:
            print("Yes")
            exit()
    else:
        cnt=0
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
count = 0
flag = False

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

Submission status: Accepted

Solution code:
from math import *

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def main():
    n = cino()
    l = []
    for i in range(n):
        a,b = cin()
        l.append([a,b])
    check = True
    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]:
            print("Yes")
            check = False
            break
    if check:
        print("No")
        

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    dd = [MII() for i in range(n)]
    cnt = 0
    for d1, d2 in dd:
        if d1 != d2:
            cnt = 0
        else:
            cnt += 1
        if cnt == 3:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
g=0
for i in range(n):
  a,b=map(int,input().split(" "))
  if a==b:
    g=g+1
    if g==3:
      break
      break
  else:
    g=0


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    count = 0
    for _ in range(n):
        a, b = [int(x) for x in input().split()]
        if a == b:
            count += 1
        else:
            count = 0

        if count >= 3:
            return 'Yes'
    return 'No'


if __name__ == '__main__':
    print(main())

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:
    break
if count==3:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

print('No')

Submission status: Accepted

Solution code:
N = int(input())

count = 0
for i in range(N):
  D1, D2 = map(int, input().split())
  if D1 == D2:
    count += 1
  else:
    count = 0
  if count == 3:
    print('Yes')
    exit()
    
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()
  else:
    cnt = 0
print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = [[0,0]]*n
flag = "No"
for i in range(n):
  d[i]=list(map(int,input().split()))
for i in range(2,n):
  if d[i-1][0]==d[i-1][1] and d[i-2][0]==d[i-2][1] and d[i][0]==d[i][1]:
    flag = "Yes"
print(flag)

Submission status: Accepted

Solution code:
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# from time import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

def readInt():
    return list(map(int,input().split()))

def main():
    n = int(input())
    last = []
    for i in range(n):
        d1,d2 = readInt()
        if d1==d2:
            last.append(1)
        else:
            last.append(0)
    ans = False
    for i in range(n-2):
        if last[i]==1 and last[i+1]==1 and last[i+2]==1:
            ans = True
    if ans:
        print("Yes")
    else:
        print("No")
    return

if __name__=='__main__':
    main()

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

Submission status: Accepted

Solution code:
N = int(input())

count = 0

for i in range(N):
    D1,D2 = list(map(int,input().split()))

    if D1 == D2:
        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())

ans="No"
cnt=0

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

Submission status: Accepted

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

isOK=False

for i in range(N-2):
    if D[i][0]==D[i][1] and D[i+1][0]==D[i+1][1] and D[i+2][0]==D[i+2][1]:
        isOK=True
        break

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

Submission status: Accepted

Solution code:
N=int(input())
D=[list(map(int,input().split())) for _ in range(N)]
flag=False
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]:
            flag=True
            break

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

Submission status: Accepted

Solution code:
import sys
import math

#https://atcoder.jp/contests/agc008/submissions/15248942
sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

n = ini()
cont = 0
ans = 'No'
for i in range(n):
    d = inl()
    if d[0] == d[1]:
        cont += 1
    else:
        cont = 0
    if cont >= 3:
        ans = 'Yes'

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

count = 0

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

    if a == b:
        count += 1

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

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

else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
import heapq
from collections import defaultdict
from collections import deque
from collections import Counter
from functools import lru_cache

#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')
AZ = "abcdefghijklmnopqrstuvwxyz"

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]


#####Shorten#####
def DD(arg): return defaultdict(arg)

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n): return kaijo_memo[n]
  if(len(kaijo_memo) == 0): kaijo_memo.append(1)
  while(len(kaijo_memo) <= n): kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n): return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0): gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n): gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if n == r: return 1
  if n < r or r < 0: return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1: arr.append([temp, 1])
  if arr==[]: arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####MakePrimes######
def make_primes(N):
  max = int(math.sqrt(N))
  seachList = [i for i in range(2,N+1)]
  primeNum = []
  while seachList[0] <= max:
    primeNum.append(seachList[0])
    tmp = seachList[0]
    seachList = [i for i in seachList if i % tmp != 0]
  primeNum.extend(seachList)
  return primeNum

#####GCD#####
def gcd(a, b):
    while b: a, b = b, a % b
    return a

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

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n-1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n: return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i-1])*n**i for i in range(len(str(X))))

def base_10_to_n_without_0(X, n):
  X -= 1
  if X//n: return base_10_to_n_without_0(X//n, n)+[X%n]
  return [X%n]

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

N = I()
data = ILL(N)

flag = []
for a,b in data:
  if a == b:
    flag.append(1)
  else:
    flag.append(0)
    
for i in range(N-2):
  if flag[i]+flag[i+1]+flag[i+2]==3:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

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

tmp = []
for D in Darray:
    if(D[0] == D[1]):
        tmp.append(1)
    
    else:
        tmp.append(0)

for i in range(N-2):
    if(tmp[i] + tmp[i+1] + tmp[i+2] == 3):
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
n = int(input())

zoro = 0

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

Submission status: Accepted

Solution code:
#B - Go to Jail
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]:
        print("Yes")
        exit()
    else:
        pass
print("No")

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

Solution code:
n = int(input())
c = 0
for i in range(n):
  d = list(map(int,input().split()))
  if d[0] == d[1]:
    c += 1
  else:
    c = 0
  if c == 3:
    print("Yes")
    exit()
  if i == n-1:
    print("No")

Submission status: Accepted

Solution code:
def main():

    N = int(input())
    cnt = 0
    ans = "No"

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

        if cnt == 3:
            ans = "Yes"

    print(ans)

main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)
import bisect
import heapq
import itertools
import math
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from math import gcd
from operator import add, itemgetter, mul, xor
def cmb(n,r,mod):
  bunshi=1
  bunbo=1
  for i in range(r):
    bunbo = bunbo*(i+1)%mod
    bunshi = bunshi*(n-i)%mod
  return (bunshi*pow(bunbo,mod-2,mod))%mod
mod = 10**9+7
def I(): return int(input())
def LI(): return list(map(int,input().split()))
def MI(): return map(int,input().split())
def LLI(n): return [list(map(int, input().split())) for _ in range(n)]

#bisect.bisect_left(list,key)はlistのなかでkey未満の数字がいくつあるかを返す
#つまりlist[i] < x となる i の個数
#bisect.bisect_right(list, key)はlistのなかでkey以下の数字がいくつあるかを返す
#つまりlist[i] <= x となる i の個数
#これを応用することで
#len(list) - bisect.bisect_left(list,key)はlistのなかでkey以上の数字がいくつあるかを返す
#len(list) - bisect.bisect_right(list,key)はlistのなかでkeyより大きい数字がいくつあるかを返す
#これらを使うときはあらかじめlistをソートしておくこと！

n = I()
cnt = 0
b = 0
num = 0
for i in range(n):
    d1,d2 = MI()
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        b = 1
        break
if b == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    N = int(input())
    D = [tuple(map(int, input().split())) for _ in [0] * N]  # [(1, 2), (3, 4)]

    n = 0
    for d1, d2 in D:
        if d1 == d2:
            n += 1
        else:
            n = 0
        if n > 2:
            print('Yes')
            break
    else:
        print('No')


main()

Submission status: Accepted

Solution code:
n = int(input())

c = 0
for i in range(n):
    a,b = map(int,input().split())
    if a == b:
        c += 1
    else:
        c = 0
    if c >= 3:
        print("Yes")
        exit()

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

Submission status: Accepted

Solution code:
n = int(input())

def find(d):
    pp = False
    p = False
    for d1, d2 in d:
        now = (d1 == d2)
        if pp and p and now:
            return True
        pp = p
        p = now

    return False

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

if find(d):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
tem = 0
Flag = False

for i in range(N):
    D1,D2 = map(int,input().split())
    
    if D1 == D2:
        tem += 1
        if tem == 3:
            Flag = True
    else:
        tem = 0


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

Submission status: Accepted

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

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

Submission status: Accepted

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

#import
#import math
#import numpy as np
N = int(input())
#= input()
#= map(int, input().split())
#= list(map(int, input().split()))
#= [input(), input()]
D = [list(map(int, input().split())) for _ in range(N)]
#= [int(input()) for _ in range(N)]
#= {i:[] for i in range(N)}

zoro = 0

for d1, d2 in D:
    if d1 == d2:
        zoro += 1
    else:
        zoro = 0

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

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] and 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 = int(input())
count = 0
max_count = 0
for _ in range(N):
    a, b = map(int, input().split())
    if a == b:
        count += 1
        max_count = max(max_count, count) 
    else:
        count = 0
print('Yes' if max_count > 2 else 'No')

Submission status: Accepted

Solution code:
# from pprint import pprint
# import math
# import collections

n = int(input())
# n, k = map(int, input().split(' '))
# a = list(map(int, input().split(' ')))
sai1 = []
sai2 = []
for i in range(n):
    _sai1, _sai2 = map(int, input().split(' '))
    sai1.append(_sai1)
    sai2.append(_sai2)

z_cnt = 0
for i in range(n):
    if sai1[i] == sai2[i]:
        z_cnt += 1
    else:
        z_cnt = 0
    if z_cnt == 3:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

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

cnt = 0
for die in dice:
    if die[0] == die[1]:
        cnt += 1
        if 3 <= cnt:
            break
    else:
        cnt = 0

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