Problem:


Score : 200 points

Problem Statement

Tak performed the following action N times: rolling two dice.
The result of the i-th roll is D_{i,1} and D_{i,2}.

Check if doublets occurred at least three times in a row.
Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.

Constraints

3 \leq N \leq 100

1\leq D_{i,j} \leq 6

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
D_{1,1} D_{1,2}
\vdots
D_{N,1} D_{N,2}

Output

Print Yes if doublets occurred at least three times in a row. Print No otherwise.

Sample Input 1

5
1 2
6 6
4 4
3 3
3 2

Sample Output 1

Yes

From the second roll to the fourth roll, three doublets occurred in a row.

Sample Input 2

5
1 1
2 2
3 4
5 5
6 6

Sample Output 2

No

Sample Input 3

6
1 1
2 2
3 3
4 4
5 5
6 6

Sample Output 3

Yes



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


Sample output:
Yes

Submission status: Accepted

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

    if count >= 3:
        print("Yes")
        break

else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding: utf-8 -*-
n = int(input())
check_list = []
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        check_list.append(1)
    else:
        check_list.append(0)
flag = 0
for i in range(n - 2):
    if sum(check_list[i:(i+3)]) == 3:
        flag = 1
        break
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)]

ans = "No"
cnt = 0

for i in range(N):
    if D[i][0] == D[i][1]:
        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)]

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
import numpy

N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
D = numpy.array(D)
D = D[:, 0] - D[:, 1]

ans = 'No'
count = 0
for i in range(N):
    if D[i] == 0:
        count += 1

        if count == 3:
            ans = 'Yes'
            break
    else:
        count = 0

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

XY = np.array(read().split(), np.int64)[1:]
X, Y = XY[::2], XY[1::2]

A = (X == Y)
A = A[:-1] & A[1:]
A = A[:-1] & A[1:]

print('Yes' if np.any(A) else 'No')

Submission status: Accepted

Solution code:
N = int(input())

count = 0
for _ in range(N):
    x, y = map(int, input().split())
    if count == 3:
        continue
    if x == y:
        count += 1
    else:
        count = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

    cnt = 0
    for i in range(N):
        da, db = tuple([int(_x) for _x in input().split()])

        if da == db:
            cnt += 1
        else:
            cnt = 0

        if cnt == 3:
            print("Yes")
            return
    print("No")


main()

Submission status: Accepted

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

cnt = 0
flg = False
for i in range(n):
    if d[i][0] == d[i][1]: # ゾロ目だったらカウントを進める
        cnt += 1
    else: # ゾロ目じゃなかったらカウントを0に戻す
        cnt = 0
    if cnt >= 3:
        flg = True
        break

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

Submission status: Accepted

Solution code:
n = int(input())
d = [tuple(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")
        raise SystemExit(0)
print("No")

Submission status: Accepted

Solution code:
import math
import sys
import os

sys.setrecursionlimit(10**7)

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

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")


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

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

D = []
for _ in range(N):
    a, b = map(int, input().split())
    if a == b:
        D.append('1')
    else:
        D.append('0')
D = ''.join(D)
ans = False
if '1'*3 in D:
    ans = True
print('Yes' if ans else 'No')

Submission status: Accepted

Solution code:
N = int(input())
ans = 'No'
ls = []
for i in range(N):
    d1,d2 = map(int,input().split())
    ls.append([d1,d2])
ii = 0
for i in range(N):
    if ls[i][0] == ls[i][1]:
        ii += 1
    else:
        ii = 0

    if ii == 3:
        ans = 'Yes'
        break
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
for _ in range(n):
  a,b = map(int,input().split())
  if a==b:
    cnt+=1
    if cnt == 3:
      print('Yes')
      exit()
  else:
    cnt = 0
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]:
        if d[i+1][0]==d[i+1][1]:
            if d[i+2][0]==d[i+2][1]:
                print("Yes")
                exit()
print("No")

Submission status: Accepted

Solution code:
import sys
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda: list(map(int, input().strip().split()))

# MOD = 10**9 + 7
def main():
	f = 0; flag = 0
	for i in range(int(input())):
		a, b = read()
		if a == b:f+=1
		else:f = 0

		if f == 3:flag |= 1
	print("YNeos"[flag == 0::2])

		



	

if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

s = ""
for _ in range(n):
    d1,d2 = input().split()
    if d1==d2:
        s+="1"
    else:
        s+="0"
#print(s)
try:
    a = max([len(x) for x in re.findall(r"1+", s)])
    if a >= 3:
        print("Yes")
    else:
        print("No")
except:
    print("No")

Submission status: Accepted

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

def doublet(i):
    return D[i][0] == D[i][1]

def tripledoublet():
    for i in range(N-2):
        if doublet(i) and doublet(i+1) and doublet(i+2):
            return 'Yes'
    else:
        return 'No'

print(tripledoublet())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

N=int(input())

D=[]

for i in range(N):
    D.append(np.array(input().split(" "),dtype=np.int64))

cnt=0
max_cnt=0
for i in range(N):
    if(D[i][0]==D[i][1]):
        cnt+=1
    else:
        if(cnt>max_cnt):
            max_cnt=cnt
        cnt=0

if(cnt>max_cnt):
    max_cnt=cnt

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

Submission status: Accepted

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

for i in range(N):
  n_list = [int(n) for n in input().split(' ')]
  if n_list[0] == n_list[1]:
    count += 1
    if count == 3:
      success = True
      break
  else:
    count = 0

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

Submission status: Accepted

Solution code:

def main():
    n = int(input())
    cnt = 0
    max = 0
    for i in range(n):
        d1, d2 = map(int, input().split(" "))
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        if max < cnt:
            max = cnt
    if max >= 3:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Submission status: Accepted

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

cnt = 0
for e in l:
    if e[0] == e[1]:
        cnt += 1

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

    if e[0] != e[1]:
        cnt = 0

print("No")

Submission status: Accepted

Solution code:
N = int(input())

def resolve():
    count = 0
    ans = "No"
    for i in range(N):
        A = input().split()
        if A[0] == A[1]:
            count += 1
            if count == 3:
                ans = "Yes"
                return ans
        else:
            count = 0
    return ans
print(resolve())

Submission status: Accepted

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

seq = 0
prev = False
for i in range(N):
    if D1[i] == D2[i]:
        if not prev:
            prev = True
            seq = 1
        else:
            seq += 1
        if seq >= 3:
            print("Yes")
            exit()
    else:
        prev = False
print("No")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
import decimal
from decimal import Decimal
decimal.getcontext().prec = 10

from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
import collections
from collections import deque 

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# ---------------------------------------

n = inp()
cnt = 0
mx = 0
for i in range(n):
    d1, d2 = inpl()
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    mx = max(mx, cnt)

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

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

print("No")

Submission status: Accepted

Solution code:
num = int(input())

count = 0
is_ok = 0
for i in range(num):
    num1, num2 = map(int, input().split())
    if num1 == num2:
        count += 1
        if count >= 3:
            is_ok =1
    else:
        count = 0
        continue

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

Submission status: Accepted

Solution code:
N = int(input())
l = [0]*N
for i in range(N):
    a,b = [int(x) for x in input().split()]
    if a == b:
        l[i] = 1
for i in range(1,N):
    if l[i] == 1:
        l[i] = l[i-1] + 1
    else:
        l[i] = 0
if max(l) >= 3:
    print("Yes")
else:
    print("No")

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

    if a != b:
        cnt = 0

print('No')

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

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

ans = 'No'
for i in range(n - 2):
    if (a[i] == b[i]) and (a[i + 1] == b[i + 1]) and (a[i + 2] == b[i + 2]):
        ans = 'Yes'

print(ans)

Submission status: Accepted

Solution code:
print("YNeos"["000" not in "".join([str(eval(input().replace(" ","-")))for _ in "_"*int(input())])::2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d_1 = []
d_2 = []

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

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

print("No")

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 179
# B - Go to Jail

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

print('No')

Submission status: Accepted

Solution code:

n = int(input())

cnt = 0
for i in range(n):
    d_1, d_2 = list(map(int, input().split()))
    if d_1 == d_2:
        cnt += 1
    else:
        cnt = 0

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

print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

first = []
second = []

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

if flag:
    print("No")

Submission status: Accepted

Solution code:
n=int(input())
ans='No'
daice=[]
for i in range(n):
  daice.append(list(map(int,input().split())))
for j in range(n-2):
  if daice[j][0]==daice[j][1]:
    if daice[j+1][0]==daice[j+1][1]:
      if daice[j+2][0]==daice[j+2][1]:
        ans='Yes'
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

count = 0
ans = "No"

for i in range(n):
    if A[i][0] == A[i][1] and count == 0:
        count = 1
    elif A[i][0] == A[i][1] and count == 1:
        count = 2
    elif A[i][0] == A[i][1] and count == 2:
        ans = "Yes"
        break
    else:
        count = 0


print(ans)

Submission status: Accepted

Solution code:
N = int(input())
cnt = 0
ok = False
for _ in range(N):
    D1, D2 = [int(x) for x in input().split()]
    if D1 == D2:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        ok = True

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

Submission status: Accepted

Solution code:
from collections import deque, Counter, defaultdict
from itertools import chain, combinations
import json
# import numpy as np
import bisect
import sys
import math
import bisect
from functools import lru_cache
import itertools

sys.setrecursionlimit(10 ** 8)

M = 10 ** 9 + 7
INF = 10 ** 17


def main():
    N = int(input())
    D = [
        [int(a) for a in input().split()]
        for _ in range(N)
    ]

    # N, K = [int(a) for a in input().split()]
    # A = [int(a) for a in input().split()]
    # T1, T2, T3 = [int(a) for a in input().split()]

    flag = False
    for i in range(N - 2):
        d1 = D[i]
        d2 = D[i + 1]
        d3 = D[i + 2]
        if d1[0] == d1[1] and d2[0] == d2[1] and d3[0] == d3[1]:
            flag = True
            break
    if flag:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
flg =0
for i in range(N):
    d1,d2 = map(int,input().split())
    if d1 != d2 :
        flg = 0
        continue
    elif d1 == d2:
        flg += 1
    
    if flg >= 3:
        break

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = input()
d = []
num = int(num)
for n in range(num):
    t, s = input().split()
    d.append([t,s])
flag = 0
for n in range(num):
    if(n<num-2):
        if(d[n][0]==d[n][1] and d[n+1][0]==d[n+1][1] and d[n+2][0]==d[n+2][1]):
            flag = 1
if flag == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())

count = 0

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

for i in range(len(d)):
    d1, d2 = d[i]
    if d1 == d2:
        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
flag = 0
for i in range(n):
  x, y = map(int, input().split())
  if(x == y):
    count += 1
  else:
    count = 0
  if count == 3:
    flag = 1
if(flag == 1):
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import io,sys
sys.setrecursionlimit(10**6)
def main(): 
    n = int(input())
    D = []
    for _ in range(n):
        a,b = map(int,input().split())
        D.append(a-b)
    
    for i in range(n-2):
        if D[i]==0 and D[i+1]==0 and D[i+2]==0:
            print("Yes")
            sys.exit()
    
    print("No")

main()

Submission status: Accepted

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

cnt = 0
flag = False
for d1, d2 in dices:
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0

    if cnt >= 3:
        flag = True
        break

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def solve():
      input = sys.stdin.readline
      N = int(input())
      D = [[int(i) for i in 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")
                              return 0
      print("No")

      return 0

if __name__ == "__main__":
      solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
ans=0
flag=0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

flg = False
cnt = 0

for i in D:
    a, b = i[0], i[1]
    if a == b:
        cnt += 1

    else:
        cnt = 0

    if cnt >= 3:
        flg = True
        break
if flg:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

if cnt < 3:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())

flag = False
ans = 0
for _ in range(N):
    x, y = map(int, input().split())
    if x == y:
        ans += 1
        if ans >= 3:
            flag = True
    else:
        ans = 0
if flag:
    print('Yes')
else:
    print('No')

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

Submission status: Accepted

Solution code:
N = int(input())

zoro = 0
ans = False
for i in range(N):
    x, y = [int(x) for x in input().split()]
    if x == y:
        zoro += 1
    else:
        zoro = 0
    if zoro >= 3:
        ans = True

if ans:
    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)

Submission status: Accepted

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

a = 0
for i in range(N):
    if ls[i][0] == ls[i][1]:
        a += 1
        if a == 3:
            print("Yes")
            break
    else:
        a = 0
else:
     print("No")

Submission status: Accepted

Solution code:
n = int(input())
ans = "No"
zoro = 0

for i in range(n):
    d1,d2 = input().split()
    
    if d1 == d2:
        zoro += 1
    else:
        zoro = 0
        
    if 2 < zoro:
        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
for i in range(n):
    if D[i][0] == D[i][1]:
        cnt += 1
        if cnt >= 3:
            break
    else:
        cnt = 0


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

Submission status: Accepted

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


n = int(input())

renzoku = 0
renzoku3 = 0

for i in range(n):
    numbers = input().split(" ")
    d1 = int(numbers[0])
    d2 = int(numbers[1])

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

    if renzoku == 3:
        renzoku3 = 1


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

Submission status: Accepted

Solution code:
c = t = 0
for _ in range(int(input())):
    x, y = input().split()
    if x==y:
        c+=1
    else:
        c = 0
    t = max(t,c)
if t>=3: print('Yes')
else: print('No')

Submission status: Accepted

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

Submission status: Accepted

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

for p in range(N):
    if D[p][0] == D[p][1]:
        flag += "1"
    else:
        flag += "0"

if "111" in flag:
    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())
cnt = 0
ans = 'No'
for i in range(N):
    x,y = [int(x) for x in input().split()]
    if x == y:
        cnt += 1
        if cnt == 3:
            ans = 'Yes'
    else:
        cnt = 0
        

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
count=0
check_flag = False
for i in range(n):
    s,t = map(int,input().split())
    if s==t:
        count+=1
    else:
        count=0
    if count == 3:
        check_flag = True
if check_flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())

count = 0
ans = "No"
for _ in range(N):
  d1, d2 = map(int, input().split())
  if d1 == d2:
    count += 1
  else:
    count = 0
  if count == 3:
    ans = "Yes"
    break
print(ans)

Submission status: Accepted

Solution code:
if __name__ == '__main__':

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

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

Submission status: Accepted

Solution code:
# import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)


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

    res = 'No'
    cnt = 0

    for i in range(N):
        if D[i][0] == D[i][1]:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            res = 'Yes'
            break

    print(res)



main()

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    n = int(input())
    max = 0
    count = 0
    for i in range(n):
        b, c = map(int, input().split())
        if b == c:

            count+=1
            if max < count:
                max=count
        else:
            count=0
    if max>2:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from math import ceil as C, floor as F, sqrt, gcd as G
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data) 

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

n = I()

c = 0
found = False
for i in range(n):
    j, k = I()
    if j == k:
        c += 1
    else:
        c = 0
    
    if c >= 3:
        found = True
        break

print('Yes' if found else 'No')

Submission status: Accepted

Solution code:
n, *D = map(int, open(0).read().split())
s = 0
for d1, d2 in zip(D[::2], D[1::2]):
    if d1==d2:
        s += 1
    else:
        s = 0
    if s >= 3:
        print('Yes')
        break
else:
    print('No')

Submission status: Accepted

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

N = int(input())
D = [tuple(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:
num = int(input())
count = 0
for i in range(num):
  ab = input().split(" ")
  a = int(ab[0])
  b = int(ab[1])
  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:
s = int(input())
ok = 0
c = 0
for _ in range(s):
  x,y = list(map(int,input().split()))
  
  if x==y:
    c+=1
    
  else:
    c=0

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

Submission status: Accepted

Solution code:
n = int(input())

x = [0] * (n + 2)
y = [0] * (n + 2)

ok = False 

for i in range(n):
    x[i],y[i] = map(int,input().split())
    
for i in range(n):
    if i + 2 < n :
        if (x[i],x[i + 1],x[i + 2]) == (y[i],y[i + 1],y[i + 2]):
            ok = True

print("Yes" if ok == True else "No")