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())
zoro = 0
ans = 'No'
for _ in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        zoro += 1
        if zoro >= 3:
            ans = 'Yes'
    else:
        zoro = 0

print(ans)

Submission status: Accepted

Solution code:
con = 0;
mm = 0;

n = int(input())
a = [input().split() for l in range(n)]
b = [None]*n

for i in range(n):
    if a[i][0] == a[i][1]:
        con = con +1
    else:
        con = 0
    if con == 3:
        mm = 1;
        break;

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

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
N = int(input())

ll = [input() for i in range(N)]

zoro_count = 0
for s in ll:
    d1 = s[0]
    d2 = s[2]

    if d1 == d2:
        zoro_count += 1
        if (zoro_count == 3):
            print("Yes")
            quit()
    else:
        zoro_count = 0

print("No")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

    if cnt==3:
        ans = "Yes"
        break
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
D1, D2 = [], []
for i in range(N):
  li = list(map(int,input().split()))
  D1.append(li[0])
  D2.append(li[1])

D = ""

for i in range(N):
  if D1[i]==D2[i]:
    D += 'T'
  else:
    D += 'F'

if 'TTT' in D:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
# from collections import defaultdict
N = int(input())
A = []
for i in range(N):
    first, second = list(map(int, input().split()))
    A.append((first, second))

count = 0
for first, second in A:
    if first == second:
        count += 1
        if count >= 3:
            print("Yes")
            exit(0)
    else:
        count = 0
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def b():
    N = int(input())
    count = 0
    res = "No"
    for i in range(N):
        d = set(map(int, input().split()))
        if len(d) == 1:
            count +=1
        else:
            count = 0
        if count == 3:
            res = "Yes"
            break
    print(res)
    
b()

Submission status: Accepted

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

judge = False
count = 0

for i in range(n):
    if ds[i][0] == ds[i][1]:
        count +=1
    else:
        count = 0
    if count >= 3:
        judge = True

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

Submission status: Accepted

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

ans=0
cont=0
for i in ls:
    ans = (ans+i)*i
    cont=max(cont, ans)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
(n,), *dd = [list(map(int, s.split())) for s in open(0)]

cnt = 0
ans = False
for i in range(n):
    a,b = dd[i]
    if a == b:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        ans = True
if ans:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

for i in range(n-2):
    # print(i)
    r1, r2, r3 = rolls[i:i+3]
    # print(r1, r2, r3)
    if r1[0] == r1[1] and r2[0] == r2[1] and r3[0] == r3[1]:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
n=int(input())
d=[list(map(int,input().split())) for _ 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(0)
    else:
        cnt=0

print('No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

count = 0
flag = 0

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

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

Submission status: Accepted

Solution code:
n = int(input())
lst = [ [ int(i) for i in input().split() ] for j in range(n) ]
r = 0
for i in range(n-2):
    if lst[i][0] == lst[i][1]:
        if lst[i+1][0] == lst[i+1][1]:
            if lst[i+2][0] == lst[i+2][1]:
                r = 1
if r == 0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
import sys
import numpy as np
import math  # gcdもあるよ
from collections import deque
from collections import defaultdict
from copy import deepcopy
from itertools import accumulate #リストを与えると累積和を返す
import bisect #二部探索
def input(): return sys.stdin.readline().rstrip()
from functools import lru_cache #メモ化
INF = 10**9 + 7
mod = 10**9 + 7

def main():
    n = int(input())
    data = [input().split() for _ in range(n)]
    #print(data)
    flag = False
    for i in range(n-2):
        if data[i][0] == data[i][1] and data[i+1][0] == data[i+1][1] and data[i+2][0] == data[i+2][1]:
            flag = True
    if flag:
        print('Yes')
    else:print('No')
    return 0

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
t=int(input())
z=[]
for _ in range(t):
    inp=list(map(int,input().split()))
    if inp[0]==inp[1]:
        z.append(1)
    else:
        z.append(0)
flag=0
a=0
for i in range(len(z)):
    if z[i]==1:
        a+=1
    else:
        a=0
    if a>=3:
        flag=1
        break
if flag==1:
    print ('Yes')
else:
    print ('No')

Submission status: Accepted

Solution code:
N = int(input())


isSucceed = False
cnt = 0
f = False
for _ in range(N):
    d1, d2 = map(int,input().split())
    if d1 == d2:
        if not isSucceed:
            isSucceed = True
            cnt = 1
        else:
            cnt += 1
            if cnt >= 3:
                f = True
                
    else:
        isSucceed = False
        cnt = 0

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

Submission status: Accepted

Solution code:
N = int(input())

k = 0
f = False
for _ in range(N):
    d1, d2 = [int(_) for _ in input().split()]
    if d1 == d2:
        k += 1
    else:
        k = 0
    if k >= 3:
        f = True
if f:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
c = 0
d,t = [0]*n,[0]*n
d[0],t[0] = map(int,input().split())
d[1],t[1] = map(int,input().split())

for i in range(2,n):
	d[i],t[i] = map(int,input().split())
	if d[i] == t[i] and d[i-1] == t[i-1] and d[i-2] == t[i-2]:
		c += 1
if c != 0:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
N=int(input())
D=[tuple(map(int,input().split())) 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"
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(2, len(a)):
    if a[i-2][0] == a[i-2][1] and a[i-1][0] == a[i-1][1] and a[i][0] == a[i][1]:
        print('Yes')
        break
else:
    print('No')

Submission status: Accepted

Solution code:
t=int(input())
k=0
for i in range(t):
  n,m=map(int,input().split())
  if n==m:
    k+=1
  else:
    k=0
  if k==3:
    break
if k==3:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
N=int(input())
dd=[list(map(int,input().split()))for _ in range(N)]
i=0
now=0
S=0
while i<N:
    if len(set(dd[i]))==1:
        now+=1
    else:
        now=0
    S=max(now,S)
    i+=1
print('YNeos'[S<3::2])

Submission status: Accepted

Solution code:
N = int(input())


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

    if a == b:
        cnt += 1
    else:
        cnt = 0
    
    if cnt > 2:
        print('Yes')
        break

else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
flg = False
tmp = 0
ans = 0
for i in range(n):
	a, b = map(int, input().split())
	if not flg and a == b:
		tmp = 1
		flg = True
	elif flg and a == b:
		tmp += 1
	else:
		tmp = 0
	ans = max(ans, tmp)
print("Yes" if ans >= 3 else "No")

Submission status: Accepted

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

a = 0
b = 0
for d in D:
    if d[0] == d[1]:
        a += 1
        b = max(a, b)
    else:
        a = 0
        b = max(a, b)

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

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
cnt = 0
ch = [[0,0]]*1000
for i in range(n):
    a,b = map(int,input().split())
    ch.append([a,b])
    if a == b:
        cnt += 1
    else:
        ans = max(ans,cnt)
        cnt = 0
for i in range(len(ch)):
    if ch[i][0] != ch[i][1]:
        break
else:
    print("Yes")
    exit()
if ans >= 3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

for i in range(N):
    if len(D[i]) == 1:
        ren += 1
    else:
        ren = 0

    if ren == 3:
        print('Yes')
        exit()
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())

cnt=0
ans="No"

for i in range(n):
    if d1[i]==d2[i]:
        cnt+=1

    if cnt==3:
        ans="Yes"
        break

    if d1[i]!=d2[i]:
        cnt=0
    

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
x = 0
y = 0

for i in range(n):
    a, b = map(int, input().split())
    if a == b:
        x += 1
        y = max(y, x)
    else:
        x = 0
        
if y >= 3:
    print('Yes')
else:
    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 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())

me = []

count = 0

sw = False

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

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

    if count >= 3:
        sw = True

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = int(input())
c = 0

for i in range(l):
  m = list(map(int, input().split()))
  if m[0] == m[1]:
    c+=1
  else:
    c=0
  if c == 3:
    print("Yes")
    break
  
if c != 3:
  print("No")

Submission status: Accepted

Solution code:
#import 
#=input()
n=int(input())
#=map(int,input().split())
#=list(map(int,input().split()))
#=[list(map(int,input().split())) for _ in range()]
c = 0
d = 0
for i in range(n):
    a,b = map(int,input().split())
    if a == b:
        c += 1
    else:
        c = 0
    if c == 3:
        d = 1
        break
if d != 1:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
import sys

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')
            sys.exit()
    else:
        cnt = 0
print('No')

Submission status: Accepted

Solution code:
import math
import fractions
import collections
import itertools
N=int(input())
l=[]
for i in range(N):
    x,y=map(int,input().split())
    if x==y:
        l.append(1)
    else:
        l.append(0)
flag=0
#print(l)
for i in range(N-2):
    num=l[i]+l[i+1]+l[i+2]
    #print(i,i+1,i+2)
    if num==3:
        flag=1
        break
if flag==1:
    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')
        exit()
print('No')

Submission status: Accepted

Solution code:
n = int(input())
a = []
for _ in range(n):
	x,y = map(int,input().split())
	a+=[[x,y]]
ans  = "No"
for i in range(n):
	if i+2<n:
		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"
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
D = []

count = 0
for _ in range(N):
  D.append([int(i) for i in input().split()])

for i in D:
  if i[0] == i[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())
flag = 0
out = False
for j in range(n):
    ins = input().split()
    if(ins[0]==ins[1]):
        flag+=1
        if(flag==3):
            out=True
    else:
        flag = 0
if(out):
    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())

zorome = 0
for i in range(N):
    if D1[i] == D2[i]:
        zorome += 1
        if zorome == 3:
            print("Yes")
            exit()
    else:
        zorome = 0

print("No")

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
# 幅優先探索（行きがけ）
import collections
import sys
import copy
import re
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    N = I()
    DArray = [LI() for _ in range(N)]

    ans = "No"

    for i in range(0, N-2, 1):
        if DArray[i][0] == DArray[i][1]:
            if DArray[i+1][0] == DArray[i+1][1]:
                if DArray[i+2][0] == DArray[i+2][1]:
                    ans = "Yes"
                    break

    print(ans)


if __name__ == '__main__':
    main()

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())
c = 0
a = 0
    
for d1, d2 in zip(D1, D2):
  if d1 == d2:
    c += 1
  else:
    c = 0
  if c >= 3:
    print("Yes")
    break

if c < 3:
  print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math
import decimal
import itertools
from itertools import product
from functools import reduce
def input():
    return sys.stdin.readline()[:-1]
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def sort_zip(a:list, b:list):
    z = zip(a, b)
    z = sorted(z)
    a, b = zip(*z)
    a = list(a)
    b = list(b)
    return a, b
def ceil(x):
    return math.ceil(x)
def floor(x):
    return math.floor(x)

def main():
    N = int(input())
    A = [0] * N
    B = [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())

    count = 0
    for i in range(N):
        if A[i] == B[i]:
            count += 1
            if count == 3:
                print('Yes')
                exit()
        else:
            count = 0
    print('No')



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

n = int(input())
count = 0

for i in range(n):
      DICE,dice = [int(x) for x in input().split()]
      if DICE == dice:
            count += 1
      else:
            count = 0
      
      if count >= 3:
            break

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

Submission status: Accepted

Solution code:
import sys, re
import math
import numpy as np
from decimal import Decimal
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul	# 
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd	# 最大公約数
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.maxsize = 10 ** 15
sys.setrecursionlimit(10 ** 9 + 7)
INF = float('inf')
MOD = 10 ** 9 + 7

# -*- coding: utf-8 -*-

n = INT()
count = 0
for x in range(0, n):
    a,b = MAP()
    if a == b:
        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
is_true = False
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        count += 1
        if count == 3:
            is_true = True
    else:
        count = 0

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

Submission status: Accepted

Solution code:
n = int(input())
D = [input() for _ in range(n)]
han=0
for a in range(len(D)-2):
    if D[a][0]==D[a][2] and D[a+1][0]==D[a+1][2] and D[a+2][0]==D[a+2][2]:
        han=1
if han==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

import sys

DEBUG = False


def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep=" "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    n = read(int)
    zorome_times = 0
    for _ in range(n):
        dices = read_list(int)
        if dices[0] == dices[1]:
            zorome_times += 1
            if zorome_times >= 3:
                print("Yes")
                return
        else:
            zorome_times = 0
    print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = []

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
count = 0

for i in range(N):
    d_1, d_2 = input().split()
    if d_1 == d_2:
        count += 1
    else:
        count = 0

    if count == 3:
        break
    else:
        pass

if count == 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)]
cnt = 0

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

Submission status: Accepted

Solution code:
N = int(input())
flug = False
cnt = 0
for _ in range(N):
    D1, D2 = list(map(int, input().split())) 
    if D1 == D2:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        flug = True
if flug:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())

count = 0
for num in range(n):
  s,t = input().split()
  if s == t:
    count +=1
    if count == 3:
      print("Yes")
      exit()
  else:
    count = 0

print("No")

Submission status: Accepted

Solution code:
N=int(input())
A=0
list=[]
for i in range(N):
    date=input().split(" ")
    if date[0]==date[1]:
        A += 1
    else:
        list.append(A)
        A=0
list.append(A)
list=sorted(list)
if list[-1]>=3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n_num = int(input())
zoro_cnt = 0
flag = False
for n in range(n_num):
    a, b = map(int, input().split())
    if zoro_cnt != 0 and a != b:
        zoro_cnt = 0
    elif a == b:
        zoro_cnt += 1
        if zoro_cnt == 3:
            flag = True

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

Submission status: Accepted

Solution code:
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]:
    flag = 1
  if flag:
    break

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

Submission status: Accepted

Solution code:
N = int(input())
D = [list(map(int,input().split())) for c in range(N)]
cnt = 0
ma = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        cnt +=1
        if cnt>ma:
            ma = cnt
    else:
        cnt = 0

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

Submission status: Accepted

Solution code:
from collections import deque
import sys, copy, itertools,heapq
input = sys.stdin.readline

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

count = 0
ans = 'No'

for i in range(n):
  if D[i][0] == D[i][1]:
    count += 1
  else:
    count = 0
  if count == 3:
    ans = 'Yes'
    break

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
n = int(input())

cnt = 0
max_cnt = 0
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        cnt += 1
        max_cnt = max(max_cnt, cnt)
    else:
        cnt = 0

print("Yes" if max_cnt >= 3 else "No")

Submission status: Accepted

Solution code:
import sys
import math



s = int(input())
rolls = []
count = 0
flag = False
while s:
	temp = [int(x) for x in input().split()]
	if temp[0] == temp[1]:
		count += 1
	else:
		count = 0

	if count == 3:
		flag = True





	s -= 1

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

Submission status: Accepted

Solution code:
n = int(input())
l = [list(map(int, input().split())) for l in range(n)]
tmp = 0
ans = False
for i in range(n):
    if l[i][0] == l[i][1]:
        tmp += 1
        if tmp == 3:
            ans = True
            break
    else:
        tmp = 0
if ans:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# # Make IO faster
# import sys
# input = sys.stdin.readline

# # get single (or) multiple str
# X = input()

# # get single int
# N = int(input())
# # get multiple int (e.g., 2)
# X, Y = map(int, input().split())
# # get multiple int (e.g., 2) for N lines
# XY = [list(map(int, input().split())) for _ in range(N)]

# from IPython import embed; embed(); exit();

# 全部入り
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
flag = False
dices = []
for i in range(N):
    a, b = list(MAP())
    if a == b:
        dices.append(True)
    else:
        dices.append(False)

for i in range(N - 2):
    if dices[i] and dices[i + 1] and dices[i + 2]:
        flag = True

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

Submission status: Accepted

Solution code:
count=0
ans='No'
for i in range(int(input())):
        x,y=[int(i) for i in input().split()]
        if x==y:
           count+=1
        else:
           count=0
        if count==3:
            ans='Yes'
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
check = []
for i in range(N):
  D1, D2 = list(map(int, input().split()))
  if(D1 == D2):
    check.append(1)
  else:
    check.append(0)

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

Submission status: Accepted

Solution code:
n = int(input())
p = 0
f = 0
for i in range(n):
	d = input().split()
	if d[0] == d[1]:
		p += 1
	else:
		p = 0
	if p == 3:
		f = 1
if f == 1:
	print("Yes")
else:
	print("No")

Submission status: Accepted

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

Submission status: Accepted

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

print("Yes" if "True, True, True" in str([d[0]==d[1] for d in D]) else "No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

c = 0
flag = False
for i in range(N):
    c1, c2 = list(map(int, input().split()))
    if c1 == c2:
        c += 1
    elif c>0 and c1 != c2 and c<3:
        c = 0
    if c == 3:
        flag = True
    

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

Submission status: Accepted

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

zoro = 0
now = 0
for i in range(n):
    if d[i][0] == d[i][1]:
        now += 1
        zoro = max(zoro,now)
    else:
        now = 0
if zoro >= 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"

print(ans)