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())
d = [map(int, input().split()) for _ in range(n)]
d1, d2 = [list(i) for i in zip(*d)]

count = 0
flag = 0
for i in range(n):
  if d1[i]==d2[i]:
    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())

flag=False

d=[]

for i in range(N):
  d.append(list(map(int, input().split(" "))))

D=list(map(lambda x:str(len(set(x))), d))

if '111' in "".join(D):
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
n = int(input())
d1=[]
d2=[]

for i in range(n):
    a = list(map(int,input().split()))
    d1.append(a[0])
    d2.append(a[1])

flg=0
for i in range(n):
    if d1[i] == d2[i]:
        flg+=1
        if flg == 3:
            break
    else:
        flg=0

if flg != 3:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
#!python3.8
# -*- coding: utf-8 -*-
# abc179/abc179_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    D = [False for _ in range(N)]
    for i in range(N):
        a, b = i2nn()
        if a == b:
            D[i] = True
            if i >= 2 and all(D[i-2:i+1]):
                print('Yes')
                return
    print('No')
    return

main()

Submission status: Accepted

Solution code:
N = int(input())
result = '0'
for i in range(N):
  d1,d2 = map(int, input().split())
  if d1 == d2:
    result += '1'
  else:
    result += '0'
if '111' in result:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
f=[]
for x in l:
	f.append(x[0]==x[1])
l=f.copy()
i=0
while i<n:
	j=1
	while i+j<n and l[i+j]==l[i] and l[i]:
		j+=1 
	if j>2:
		print('Yes')
		break	
	i+=j
else:
	print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

n = int(input())
d1 = []
d2 = []
for i in range(n):
  t,u = map(int,input().split())
  d1.append(t)
  d2.append(u)
c = 0
for i in range(n):
  if d1[i] == d2[i]:
    c += 1
  else:
    c = 0
  if c == 3:
    print("Yes")
    sys.exit()
print("No")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

def check():
    count = 0
    for i in range(N):
        if A[i][0] == A[i][1]:
            count+=1
        else:
            count=0
            continue
        if count >=3:
            print("Yes")
            return
    print("No")

check()

Submission status: Accepted

Solution code:
import numpy as np

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

flag = 0
tmp = [7, 7]
for l in d:
    if l[0] == l[1]:
        flag += 1
    else:
        flag = 0
    if flag==3:
        break

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

Submission status: Accepted

Solution code:
N = int(input())
D = list()
D.append(0)
for i in range(1, N + 1):
	x, y = input().split()
	s = 1 + D[i - 1]if x == y else 0
	D.append(s)
if 3 in D:
	print('Yes')
else:
	print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

count = 0
flag = 0

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

for i in range(1, n - 1):
    if d[i - 1][0] == d[i - 1][1] and d[i][0] == d[i][1] and d[i + 1][0] == d[i + 1][1]:
        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)]
cnt = 0
flg = 0
ans = 'No'

for i in range(n):
  if cnt>0:
    if (x[i]==y[i]) and (flg == 1):
      cnt+=1
      flg = 1
      if cnt>=3:
        ans = 'Yes'
        break
    else:
      cnt = 0
      flg = 0
  elif (x[i]==y[i]) and (cnt==0):
    cnt+=1
    flg = 1
    if cnt>=3:
      ans = 'Yes'
      break
  
  else:
    flg = 0
    cnt = 0

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
D = [map(int, input().split()) for _ in range(N)]
D1, D2 = [list(i) for i in zip(*D)]
ans = 0
for i in range(N-2):
    if D1[i] == D2[i] and D1[i+1] == D2[i+1] and D1[i+2] == D2[i+2]:
        ans = 1
        break
if ans == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
D = [0] * 2
count = 0
ans = 0
for i in range(N):
    D = list(map(int, input().split()))
    if D[0] == D[1]:
        count = count + 1
    else:
        count = 0
    if count == 3:
        ans = 1
if ans == 1:
    print("Yes")
    
else:
    print("No")

Submission status: Accepted

Solution code:
def resolve():
	count = 0
	msg = 'No'
	N = int(input())
	for n in range(N):
		D = input().split()
		if D[0] == D[1]:
			count += 1
			if count == 3:
				msg = 'Yes'
				break
		else:
			count = 0
	print(msg)
resolve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

cnt = 0
ans = 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')
        exit()
print('No')

Submission status: Accepted

Solution code:
s = int(input())

count = 0
for i in range(s):
  a, b = input().split()
  if a == b:
    count += 1
  else:
    count = 0
  if count == 3:
    print('Yes')
    exit()

print('No')

Submission status: Accepted

Solution code:
n = int(input())
a = list()
for i in range(n):
    a.append(tuple(map(int, input().split())))
count = 0
for i in range(n-2):
    
    if a[i][0] == a[i][1]:
        if  a[i+1][0] == a[i+1][1]:
            if a[i+2][0] == a[i+2][1]:
                count = count + 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
cnt = 0
s = 'No'

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

print(s)

Submission status: Accepted

Solution code:
n = int(input())

a = []
for i in range(n):
    d,e = map(int,input().split())
    a.append([d,e])


b = []
for i in range(n):
    if a[i][0] == a[i][1]:
        b.append(1)
    else:
        b.append(0)

c = 0
for i in range(n-2):
    if b[i] == 1 and b[i+1] == 1 and b[i+2] == 1:
        c = 1
        break

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

Submission status: Accepted

Solution code:
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

n = I()
DL = LIR(n)
ans = 0

for i, D in enumerate(DL):
    if D[0] == D[1]:
        ans += 1
    elif ans < 3 and D[0] != D[1]:
        ans = 0
        
if ans >= 3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

Submission status: Accepted

Solution code:
n=int(input())

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


print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())
main=[]
for i in range(n):
    main.append(list(map(int,input().split())))
flag=0
result=0
for i in range(n):
    if flag==3:
        result=1
        break
    elif main[i][0]==main[i][1]:
        flag+=1
    else:
        flag=0
if flag==3 or result==1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
l = [list(map(int, input().split())) for i in range(N)]
ans=list()
for i in range(N-2):
    if l[i][0] == l[i][1]:
        if l[i+1][0] == l[i+1][1]:
            if l[i+2][0] == l[i+2][1]:
                ans.append("y")
if "y" in ans:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
d1 = []
d2 = []
for i in range(n):
	a,b = map(int,input().split())
	d1.append(a)
	d2.append(b)
for i in range(n-2):
	if d1[i] == d2[i]:
		if d1[i+1] == d2[i+1]:
			if d1[i+2] == d2[i+2]:
				print('Yes')
				exit()
			else:
				continue
		else:
			continue
	else:
		continue
print('No')

Submission status: Accepted

Solution code:
N = int(input())

count = 0
for i in range(N):
    d1, d2 = [int(d) for d in 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())
count = 0
for i in range(0,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())

flag = [0]*4
for _ in range(N):
    D1, D2 = map(int, input().split())
    if (D1 == D2):
        if (flag[2] == 1):
            flag[3] = 1
        elif (flag[1] == 1):
            flag[2] = 1
        else:
            flag[1] = 1

    else:
        flag[1] = 0
        flag[2] = 0

if (flag[3] == 1):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(0, 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)

Submission status: Accepted

Solution code:
def solve():
    N = int(input())

    D1 = [0] * N
    D2 = [0] * N

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

    c = 0
    judge = 0

    for i in range(N):
        if D1[i]==D2[i]:
            c += 1
        else:
            c = 0

        if c>2:
            judge += 1

    if judge!=0:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
N = int(input())
s = [input().split(" ") for i in range(N)]

count = 0
yes = False
for i in s:
    if i[0] == i[1]:
        count += 1
    else:
        count = 0
    if count >= 3:
        print("Yes")
        yes = True
        break

if not yes:
    print("No")

Submission status: Accepted

Solution code:
def main():
    from sys import stdin

    readline = stdin.readline

    N=int(readline().rstrip())
  
    count=0
    
    for i in range(N):
        x,y = list(map(int,readline().rstrip().split()))
        if ( x == y ):
            count += 1
            if ( count >= 3):
                break
        else:
            count = 0


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

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())
  
a = 0
  
for i in range(N-2):
  if D1[i] == D2[i] and D1[i+1] == D2[i+1] and D1[i+2] == D2[i+2]:
    a = 1
    
if a == 1:
  print("Yes")

else:
  print("No")

Submission status: Accepted

Solution code:
N = int(input())

D1 = [0] * N
D2 = [0] * N
for i in range(N):
    D1[i], D2[i] = map(int, input().split())
f=0
for i in range(N):
    if D1[i]==D2[i]:
        f+=1
        
    if D1[i]!=D2[i]:
        f=0
        continue
    
    if f==3:
        print('Yes')
        break
else:
    print('No')

Submission status: Accepted

Solution code:
n  = int(input())
x = [0]*n
y = [0]*n
for i in range(n):
    x[i],y[i] = map(int,input().split())


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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
array = [ list(map(int,input().split())) for _ in range(N) ]
ans = 0
for i in range(N-2):
  count = 0
  if array[i][0] == array[i][1]:
    count += 1
  if array[i+1][0] == array[i+1][1]:
    count +=1
  if array[i+2][0] == array[i+2][1]:
    count +=1
  if count == 3:
    ans += 1
print( 'Yes' if ans >= 1 else 'No' )

Submission status: Accepted

Solution code:
N = int(input())
counter = 0
flag = False
for n in range(N):
    d1, d2 = [int(item) for item in input().split(' ')]
    if d1 == d2:
        counter += 1
    else:
        counter = 0
    
    if counter == 3:
        flag = True

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

Submission status: Accepted

Solution code:
from sys import stdin
input = stdin.readline

N = int(input())

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

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

Submission status: Accepted

Solution code:
n=int(input())
d = [input().split() for l in range(n)]
ans='No'
con=0
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]:
                ans="Yes"


print(ans)

Submission status: Accepted

Solution code:
##B
n = int(input())
d1 = [0] * n
d2 = [0] * n

for i in range(n):
    d1[i], d2[i] = map(int, input().split())
answer = "No"
for i in range(n - 2):
    if d1[i] == d2[i] and d1[i + 1] == d2[i + 1] and d1[i + 2] == d2[i + 2]:
        answer = "Yes"
        break
print(answer)

Submission status: Accepted

Solution code:
n = int(input())

count = 0
m1, m2 = 0, 1
n1, n2 = 0, 0
for i in range(n):
    if i > 0:
        m1, m2 = n1, n2

    n1, n2 = map(int, tuple(input().split()))

    if n1 == n2 and m1 == m2:
        count += 1
    else:
        count = 0

    if count == 2:
        print("Yes")
        exit()


print("No")

Submission status: Accepted

Solution code:
rows = int(input())
li = [list(map(int, input().split())) for i in range(rows)]
sum = 0
for l in li:
  if l[0]==l[1]:
    sum=sum+1
  else:
    sum=0
  if sum==3:
    break
if sum==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 j in range(N-2):
    if D[j][0]==D[j][1]:
        if D[j+1][0]==D[j+1][1]:
            if D[j+2][0]==D[j+2][1]:
                count = 1
if count==0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())

ans = "No"
Z = 0

for i in range(N):
    D1,D2 = list(map(int,input().split()))
    if D1 == D2:
        Z += 1
        if Z ==3:
            ans = "Yes"
    else:
        Z = 0
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

sum = 0
for i in range(N):
    L = list(map(int, input().split()))
    if int(L[0]) == int(L[1]):
        sum += 1
    else:
        sum = 0
    if sum == 3:
        break



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

Submission status: Accepted

Solution code:
def isSameThree(num_of_indices):
    same_count = 0
    for d1,d2 in num_of_indices:
        if(d1 == d2):
            same_count += 1
            if(same_count == 3):
                return "Yes"
        else:
            same_count = 0
    return "No"
N = int(input())
num_of_indices = [list(map(int,input().split())) for i in range(N)]
print(isSameThree(num_of_indices))

Submission status: Accepted

Solution code:
N = int(input())
L = []
t = 0
for i in range(N):
    D = [int(i) for i in input().split()]
    if D[0] == D[1]:
        L.append(i)
        if len(L) >= 3:
            if L[-2] == i-1 and L[-3] == i-2:
                print('Yes')
                t = 1
                break

if t == 0:
    print('No')

Submission status: Accepted

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

for i in range(n-2):
  if c[i] == d[i] and c[i+1] == d[i+1] and c[i+2] == d[i+2]:
    f = 1
if f == 0:
  print('No')
else:
  print('Yes')

Submission status: Accepted

Solution code:
n=int(input())
d=[tuple(map(int,input().split()))for _ in[0]*n]
r="No"
c=0
for i,j in d:
	if i==j: c+=1
	else: c=0
	if c==3:
		r="Yes"
		break
print(r)

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")
        exit()
print("No")

Submission status: Accepted

Solution code:
""" B
"""
import sys
import math
from functools import reduce
from bisect import bisect_left

def readString():
    return sys.stdin.readline()

def readInteger():
    return int(readString())

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def readIntegerMatrix(n, m):
    return [readIntegerSet(m) for _ in range(0, n)]

def main(N, D):
    count = 0
    for d in D:
        if d[0] == d[1]:
            count += 1
            if count == 3:
                return "Yes"
        else:
            count = 0

    return "No"


if __name__ == "__main__":
    _N = readInteger()
    _D = readIntegerMatrix(_N, 2)

    print(main(_N, _D))

Submission status: Accepted

Solution code:
n = int(input())
d1 = []
d2 = []
for i in range(n):
  w1, w2 = map(int, input().split())
  d1.append(w1)
  d2.append(w2)
a = 'No'
for i in range(n-2):
  if d1[i]==d2[i] and d1[i+1]==d2[i+1] and d1[i+2]==d2[i+2]:
    a = 'Yes'
    break
print(a)

Submission status: Accepted

Solution code:
n = int(input())

count = 0

for _ in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        count += 1
    elif d1 != d2:
        count = 0
    if count == 3:
        break

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

N = int(input())

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

count = 0

for x, y in D:
    if x == y:
        count += 1
    else:
        count = 0
    if count == 3:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
N = int(input())
flg = False
count = 0
for i in range(N):
  D1,D2 =  map(int, 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:
def solve(n, d):
    for i in range(n - 2):
        if all(len(d[i + k]) == 1 for k in range(3)):
            return True
    return False


def main():
    n = int(input())
    d = [set(map(int, input().split())) for _ in range(n)]
    print("Yes" if solve(n, d) else "No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#coding:utf-8

N = int(input())

D = []

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

    D.append(d1==d2)
    
for i in range(N-2):
    if D[i] and D[i+1] and D[i+2]:
        print("Yes")
        break

    if i == N-3:
        print("No")

Submission status: Accepted

Solution code:

n=int(input())
flag=False
count=0
for i in range(n):
    u,v=map(int,input().split())
    if u==v:
        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())

ans = "No"

streak = 0

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

print(ans)

Submission status: Accepted

Solution code:
import sys

N = int(input())

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


for i in range(0,N-2,1):
    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")
        sys.exit()
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())

ans = 0
res = 'No'

for i in range(N):
    D = list(map(int, input().split()))
    if D[0] == D[1]:
        ans += 1
    else:
        ans = 0
    if ans == 3:
        res = 'Yes'
        break
print(res)

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
        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
max = 0
for i in range(n):
    dice1,dice2 = [int(a) for a in input().split()]
    if dice1 == dice2:
        count += 1
    else:
        count = 0
        tmp = 0
    if max <= count:
        max = count
if max >= 3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

count = 0
flag=[]
for i in range(N):
    if Dice[i][0] == Dice[i][1]:
        flag.append(1)
    else:
        flag.append(0)

for i in range(len(flag)):
    if flag[i]==1:
        count+=1
    else:
        count=0
    if count==3:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
N=int(input())
tmp=0
D1=0
D2=0

count=0

for i in range(N):
  tmp=input().split()
  D1=int(tmp[0])
  D2=int(tmp[1])
  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())
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
    else:
        cnt = 0
    if cnt == 3:
        print("Yes")
        exit(0)
print("No")

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    zoro = 0
    dice = []
    for _ in range(N):
        dice.append(list(map(int, input().split())))

    
    for d1, d2 in dice:
        if d1 == d2:
            zoro += 1
        else:
            zoro = 0
        if zoro > 2:
            break
    
    ans = "Yes" if zoro > 2 else "No"
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
cnt = 0
ans = 'No'

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

flg = False
cnt = 0
ans = 0
for d1, d2 in D:
    if d1 == d2:
        if not flg:
            cnt += 1
        if flg:
            cnt += 1
        flg = True
    else:
        flg = False
        ans = max(ans, cnt)
        cnt = 0
ans = max(ans, cnt)

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

Submission status: Accepted

Solution code:
n = int(input())
s = []
found = False
for i in range(n):
    s.append(list(map(int, input().split())))
for i in range(n-2):
    if s[i][0] == s[i][1] and s[i+1][0] == s[i+1][1] and s[i+2][0] == s[i+2][1]:
        print("Yes")
        found = True
        break
    else:
        pass
if found == False:
    print("No")

Submission status: Accepted

Solution code:
lst = input()
count = 0
for i in range(int(lst)):
    q = input()
    q = q.split()
    for d in range(len(q)):
        q[d] = int(q[d])
    if q[0] == q[1]:
        count += 1
    else:
        count = 0
    if count > 2:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
n = int(input())

c = 0
z = 'No'

for _ in range(n):
    d, e = map(int,input().split())
    if d == e:
        c += 1
        if c >= 3:
            z = 'Yes'
    else :
        c = 0
        

print(z)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ok = False
a = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n):
    a[i], b[i] = map(int, input().split())
for i in range(1, n - 1):
    if a[i] == b[i] and a[i - 1] == b[i - 1] and a[i + 1] == b[i + 1]:
        ok = True
print('Yes' if ok else 'No')

Submission status: Accepted

Solution code:
N=int(input())
S=[0]*N;p=0;f=0
for i in range(N):
  a,b=map(int,input().split())
  S[i]=[a,b]
  if a-b==0:
    p=p+1
    if p>=3:
      f=1
  else:
    p=0
if f==1:
  print("Yes")
else:
  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
        if count > 2:
            print("Yes")
            break
    else:
        count = 0
else:
    print("No")

Submission status: Accepted

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

print('No')

Submission status: Accepted

Solution code:
def readInt():
    return int(input())
def readList():
    return list(map(int,input().split()))
def readMap():
	return map(int,input().split())
def readStr():
    return input()
inf=float('inf')
mod = 10**9+7
import math
def solve(n,A):
    count=0
    for x,y in A:
        if x==y:
            count+=1
        else:
            count=0
        if count==3:
            return True
    return False

n=readInt()
A=[]
for _ in range(n):
    A.append(readList())
if solve(n,A):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
c=[]
for i in range(n):
    x,y=map(int,input().split())
    c.append([x,y])
s=0
flag=0
for i in range(len(c)):
    if c[i][0]==c[i][1]:
        s+=1
    else:
        if s>=3:
            flag=1
        s=0

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

Submission status: Accepted

Solution code:
Result=[]
pair=[]
ans='No'

N=int(input())

for _ in range(N):
    pair=list(map(int,input().split()))
    Result.append(pair)

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input()) #縦2列
XY=[map(int, input().split()) for _ in range(N)]
X,Y=[list(i) for i in zip(*XY)]
ans="No"

for j in range(0,N-2):
    if X[j]==Y[j] and X[j+1]==Y[j+1] and X[j+2]==Y[j+2]:
        ans="Yes"
        break

print(ans)

Submission status: Accepted

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