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:
from collections import defaultdict 
import sys
import math 
import random
def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

cnt = 0
n = int(input())
flag = False 
for i in range(n):
    (x,y) = get_ints()
    
    if x==y:
        cnt+=1
    else:
        cnt=0
    if cnt>=3:
        flag = True 

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

Submission status: Accepted

Solution code:
# 行数
N = int(input().strip())

# 2次元配列
grid = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    grid.append(array)
# print(grid)
counter = 0
frag = False
for i in range(N):
    if grid[i][0] == grid[i][1]:
        counter += 1
        if counter == 3:
            frag = True
    elif grid[i][0] != grid[i][1]:
        counter = 0
if frag is True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
lst = []
for _ in range(N):
  d1, d2 = map(int, input().split(' '))
  lst.append((d1, d2))
  
idx = 0
flag = False
while idx < N-2:
  cnt = 0
  for i in range(3):
    d1, d2 = lst[i+idx]
    if d1 == d2:
      cnt += 1
  if cnt == 3:
    flag = True
    break
  else:
    idx += 1
 
print('Yes' if flag else 'No')

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

nums = []
for i in range(n):
	nums.append(list(map(int, input().split())))
ans = 'No'
count = 0
for num in nums:
	if num[1] == num[0]:
		count += 1
		if count == 3:
			ans = 'Yes'
			break
	else:
		count = 0

print(ans)

Submission status: Accepted

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

cnt = 0
for i, (p, q) in enumerate(d):
    if p == q:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print("Yes")
        break
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] = input().split()

flg = False
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]:
        flg = True
        # break
if flg:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

for j in line:
    if j[0] == j[1]:
        count += 1
        if count >= 3:
            ans += 1
        else:
            continue
    else:
        count = 0
if ans == 0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

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

counter = 0
max = 0
for i in range(N):
  if x[i][0] == x[i][1]:
    counter = counter + 1
  else:
    if max < counter:
      max = counter
    counter = 0

if max >=3 or counter >= 3:
  a = 'Yes'
else:
  a = 'No'
    
print(a)

Submission status: Accepted

Solution code:
a=int(input())
b=0
xy = [map(int, input().split()) for _ in range(a)]
x, y = [list(i) for i in zip(*xy)]
for i in range(a-2):
  if x[i]==y[i] and x[i+1]==y[i+1] and x[i+2]==y[i+2]:
    b=b+1
if b==0:
  print("No")
else:
  print("Yes")

Submission status: Accepted

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

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

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

else:
    print("Yes")

Submission status: Accepted

Solution code:
import sys

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

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

print('No')

Submission status: Accepted

Solution code:
N = int(input())
D = [input().split() for l in range(N)]

zoro = []
for i in range(N):
  if D[i][0] == D[i][1]:
    zoro.append(1)
  else:
    zoro.append(0)

cnt = []
for i in range(N-2):
  cnt.append(zoro[i]+zoro[i+1]+zoro[i+2])
  

zoro_cnt = 0
for i in range(N-2):
  if cnt[i] == 3:
    zoro_cnt += 1


if zoro_cnt >= 1:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n=int(input())
patt=[-1]*100
l=0
for i in range(n):
    a,b=[int(x) for x in input().split(' ')]
    if a==b:
        l+=1
        patt[i]=1
count=0
flag=0
for i in range(100):
    if patt[i]==1:
        count+=1
    else:
        count=0
    if count==3:
        flag=1
        break
if flag==1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
arr2 = []
count = 0
for _ in range(int(input())):
    arr = list(map(int, input().split()))
    arr2.append(arr)
for k in range(len(arr2)):
    if arr2[k][0] == arr2[k][1]:
        count += 1
        if count == 3:
            print("Yes")
            exit()
    else:
        count = 0
print("No")

Submission status: Accepted

Solution code:
n = int(input())

counter = 0
best = 0
for _ in range(n):
    x, y = map(int, input().split())
    if x == y:
        counter += 1
    else:
        counter = 0

    best = max([best, counter])

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

Submission status: Accepted

Solution code:
import sys

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

cnt = 0

for e in d:
    if (e[0] + e[1])/2 == e[0]:
        cnt = cnt + 1
        if cnt == 3:
            print("Yes")
            sys.exit()
    else:
        cnt = 0

print("No")

Submission status: Accepted

Solution code:
if __name__ == "__main__":
  N = int(input())
  D = []
  for i in range(N):
    D += [[int(a) for a in input().split()]]
  ans = "No"
  count = 0
  for d in D:
    if d[0] == d[1]:
      count += 1
      if count == 3:
        ans = "Yes"
        break
      else:
        pass
    else:
      count = 0
  print(ans)

Submission status: Accepted

Solution code:
N = int(input())
D = [[0]]*N
for i in range(N):
  D[i] = list((int(x) for x in input().split()))
for i in range(N-2):
  if D[i][0]==D[i][1] and D[i+1][0]==D[i+1][1] and D[i+2][0]==D[i+2][1]:
    print('Yes')
    break
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

count=0

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


n = 0
for i in range(N):
    if x[i] == y[i]:
        n = n+1
    elif n >=3:
        break
    elif x[i] != y[i]:
        n = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = [input().split() for _ in range(N)]
ans = "No"
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"
                break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  N = int(input())
  flag = 0
  for l in range(N):
    l = list(map(int, input().split()))
    if l[0] == l[1]:
      flag += 1
      if flag == 3:
        flag = 80000
        break
    else:
      flag = 0    
  return flag

Ans = main()
if Ans == 80000:
  print('Yes')
else :
  print('No')

Submission status: Accepted

Solution code:
n = int(input())
d1d2 = [map(int, input().split()) for _ in range(n)]
d1, d2 = [list(i) for i in zip(*d1d2)]
h = 'No'
for i in range(n):
    if i > 1:
        if d1[i] == d2[i]:
            if d1[i-1] == d2[i-1]:
                if d1[i-2] == d2[i-2]:
                    h = 'Yes'
                    break
print(h)

Submission status: Accepted

Solution code:
# !/usr/bin/python

"""
https://atcoder.jp/contests/abc179/tasks/abc179_b
B - Go to Jail
"""

def solve(n):
    count = 0
    p_d1, p_d2 = list(map(int, input().split()))
    if p_d1 == p_d2: count = 1
    n -= 1

    while n:
        d1, d2 = list(map(int, input().split()))
        if d1 == d2 and p_d1 == p_d2:
            count += 1
            if count == 3: return "Yes"
        elif d1 == d2: count = 1
        else: count = 0
        p_d1 = d1
        p_d2 = d2

        n -= 1

    return "No"

if __name__ == "__main__":
    n = int(input())

    print(solve(n))

Submission status: Accepted

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

ans = "No"

for i in range(num - 2):
  if line[i][0] == line[i][1] and line[i+1][0] == line[i+1][1]and line[i+2][0] == line[i+2][1]:
    ans = "Yes"
    break
    
print(ans)

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)]
count = 0
if N == 3:
    if x[0] == y[0] and x[1] == y[1] and x[2] == y[2]:
        count += 1
        print("Yes")

for i in range(N-3):
    if x[i] == y[i] and x[i+1] == y[i+1] and x[i+2] == y[i+2]:
        count += 1
        print("Yes")
        break

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
cnt=0
find=False
for n in range(N):
    a,b=map(int,input().strip().split())
    if a==b:
        cnt+=1
    else:
        cnt=0
    if cnt==3:
        find=True

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

Submission status: Accepted

Solution code:
N = int(input())

D = []
for i in range(N):
    Da,Db = (map(int,input().split()))
    if Da == Db:
        D.append(1)
    else:
        D.append(0)

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

Submission status: Accepted

Solution code:
n=int(input())
ans=0
c=True
d=[]
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        d.append(i)
if len(d)<3:
    print("No")
else:
    j=0
    for i in range(1,len(d)-1):

        if d[i]-d[i-1]==1 and d[i+1]-d[i]==1:
            print("Yes")
            c=False
            break

    if c==True:
        print("No")

Submission status: Accepted

Solution code:
#B

N = int(input())
D = []
counter = []

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

for i in range(N):
  if D[i][0] == D[i][1]:
    counter.append(1)
    if (i >= 2 and counter[i-1]==1 and counter[i-2]==1):
      print('Yes')
      break
  else:
    counter.append(0)
  if i == N-1:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())

cnt = 0
judge = False

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

    if cnt == 3:
        judge = True

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

count = 0
yes = False

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

if not(yes):
  print("No")

Submission status: Accepted

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

is_jail = False
for i in range(2*N-5):
    if j[i] == j[i+1] and j[i+2] == j[i+3] and j[i+4] == j[i+5]:
        is_jail = True

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

Submission status: Accepted

Solution code:
n = int(input())
d = []
sum = 0
success = 0
for i in range(0,n):
    #d.append(input().split(" "))
    d = input().split(" ")
    if d[0] == d[1]:
        sum += 1
    else:
        sum = 0
    if sum >= 3:
        success += 1
        
if success >= 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

n = ii()
b1 = False
b2 = False
b3 = False
for i in range(n):
    x = li()
    if(x[0] == x[1]):
        if(b1):
            if(b2):
                b3 = True
            b2 = True
        b1 = True
    else:
        b1 = False
        b2 = False

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# サイコロを振った回数N
N = int(input())

xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]

count = 0

for i in range(N):
    if x[i] == y[i]:
        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())
list_deme = [0]*N
for n in range(N):
    i = list(map(int, input().split()))
    if i[0] == i[1]:
        list_deme[n] = 1
stack = 0
for i in list_deme:
    if i == 1:
        stack += 1
    elif stack < 3 and i == 0:
        stack = 0

if stack > 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
count=0
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
for i in range(N-2):
  if x[i]==y[i] and x[i+1]==y[i+1] and x[i+2]==y[i+2]:
    print("Yes")
    exit(0)
print("No")

Submission status: Accepted

Solution code:
_int = int(input())
_list = []
_bool = 0
for i in range(_int):
  _list_element = list(map(int, input().split()))
  _list.append(_list_element[0])
  _list.append(_list_element[1])
  

for i in range(1, 2*_int - 4, 2):
  #index 1　から index 2*_intまで2ずつ繰り返す(1組の最後の数)
  if _list[i] == _list[i -1]:
    if _list[i + 2] == _list[i + 1]:
      if _list[i + 4] == _list[i + 3]:
        _bool += 1

if _bool >= 1:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

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


check_list=[]

for i in range(N):
    check_list.append(l[i][0]==l[i][1])

a=0

for j in range(N-2):
    if check_list[j]==True and check_list[j] == check_list[j+1] and check_list[j]==check_list[j+2]:
            print('Yes')
            a=1
            break
    else:
        continue

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

Submission status: Accepted

Solution code:
N = int(input())
D = [list(map(int, input().split())) for i 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]:
        if D[i+2][0] == D[i+2][1]:
            flag = 1
if flag == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())

match_num=0

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

print("No")

Submission status: Accepted

Solution code:
N = int(input())

d1=[]
d2=[]

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

    d1.append(D1)
    d2.append(D2)

for i in range(len(d1)):
    if d1[i]==d2[i]:
        cont+=1
    else:
        cont=0

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

Submission status: Accepted

Solution code:
n = int(input())
l = []

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

x = 0
z = ""

while n > x:
    y = l[x*2] - l[x*2+1]
    z = z + str(y)
    x+=1

if "000" in z:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

def input_int():
    return int(input())


def input_array():
    return input().split()


def answer():
    n = input_int()
    same_counter = 0
    for i in range(n):
        d1, d2 = input_array()
        if d1 == d2:
            same_counter += 1
            if same_counter >= 3:
                print('Yes')
                return
        else:
            same_counter = 0
    print('No')


answer()

Submission status: Accepted

Solution code:
n = int(input())
counter = 0
coutlist = []
value = False
for i in range(n):
    a,b = map(int, input().split())
    if i == 0:
        if a == b:
            counter+=1
            coutlist.append(counter)
            value = True
    else:
        if a == b and value == True:
            counter+=1
            value = True
            coutlist.append(counter)
        elif a == b and value == False:
            counter = 1
            value = True
            coutlist.append(counter)
        else:
            counter = 0
            value = False
            coutlist.append(counter)

if max(coutlist) >= 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)]
ok = False
for i in range(n-2):
    if d[i][1] == d[i][0]:
        if d[i+1][1] == d[i+1][0]:
            if d[i+2][1] == d[i+2][0]:
                ok = True
if ok == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
f1, f2, f3 = 0, 0, 0
for i in range(n):
    f3 = f2
    f2 = f1
    d1, d2 = map(int, input().split())
    f1 = d1 == d2
    if f1 == f2 == f3 == 1:
        ans = 1
print('Yes' if ans else '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:
        if count >= 3:
            print("Yes")
            exit()
        count = 0
if count >= 3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
	a.append(input().split())
for i in range(len(a)-2):
	if(a[i][0] == a[i][1] and a[i+1][0] == a[i+1][1] and a[i+2][0] == a[i+2][1]):
		print("Yes")
		exit()
print("No")

Submission status: Accepted

Solution code:
N = int(input())

count = 0
ok = 0

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

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

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
N = int(input())
count = 0
c = 0
for i in range(N):
    d1,d2 = input().split()
    if d1==d2:
        count+=1
        if count==3:
            c =1

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

Submission status: Accepted

Solution code:
N = int(input())
z,w = [],[]
K = 0
for i in range(N):
  x,y = map(int,input().split())
  z.append(x)
  w.append(y)
for j in range(N-2):
  if z[j] == w[j] and z[j+1] == w[j+1] and z[j+2] == w[j+2]:
    K += 1

if K >= 1:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n =int(input())
count = 0
judge = 0
for i in range(n):
    nums = [int(e) for e in input().split()]
    if nums[0] == nums[1]:
        count += 1
        if count >= 3:
            judge = 1
    else:
        count = 0

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

Submission status: Accepted

Solution code:
N = int(input())
s = [0] * N
t = [0] * N

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

for n in range(N):
  if s[n]==t[n] and s[n+1]==t[n+1] and s[n+2]==t[n+2]:
    print('Yes')
    break
  elif n == N - 3:
    print('No')
    break
  else:
    continue

Submission status: Accepted

Solution code:
def calc():
	n = int(input())
	c = 0

	for _ in range(n) :
		d1, d2 = ( int(j) for j in input().split() )
		if d1 == d2 : c = c + 1
		else : c = 0
		if c == 3 : break

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

def main() :
	calc()

if __name__ == '__main__' :
	main()

Submission status: Accepted

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

cnt = 0
for i in range(n):
    if d[i][0] == d[i][1]:
        cnt += 1
    else:
        cnt = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = []
for j in range(N):
  S.append(input().split())
G = []
for i in range(N):
  if S[i][0] == S[i][1]:
    G.append("1")
  else:
    G.append("0")

AN = (''.join(G))

if "111" in AN:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n=int(input())
res=0
xy = [map(int, input().split()) for i in range(n)]
x, y = [list(i) for i in zip(*xy)]
for i in range(n-2):
    if x[i]==y[i] and x[i+1]==y[i+1] and x[i+2]==y[i+2]:
        res+=1
if res>0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N= int(input())
count=0
for i in range(N):
  p,q=map(int,input().split(' '))
  if count<3:
    if p==q:
      count+=1
    else:
      count=0
  else:
    pass

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

Submission status: Accepted

Solution code:
N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
total = 0
for j in range(2,N):
    if x[j-2] == y[j-2] and x[j-1] == y[j-1] and x[j] == y[j]:
        total += 1
if total == 0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase
from collections import deque
from math import *

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

def solve():
    n = int(input())
    count = 0
    lst = []
    for j in range(n):
        a, b = map(int, input().split())
        lst.append((a,b))
    for i in range(n-2):
        if lst[i][0] == lst[i][1]:
            if lst[i+1][0] == lst[i+1][1] and lst[i+2][0] == lst[i+2][1]:
                print('Yes')
                break
    else:
        print('No')
            
        
           
def main():
    #k = int(input())
    #tests = 1
    #tests = int(input().strip())
    #for test in range(tests):
        solve()
        
# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from sys import stdin
from collections import defaultdict
input = stdin.readline
# ~ T = int(input())
T = 1
for t in range(1,T + 1):
	n = int(input())
	count = 0; ans = 0
	for i in range(1,n + 1):
		x,y = map(int,input().split())
		if x == y:
			count += 1
		else:
			ans = max(ans,count)
			count = 0
	ans = max(ans,count)
	print("Yes" if ans >= 3 else "No")

Submission status: Accepted

Solution code:
N = int(input())
Dx = [0] * N
Dy = [0] * N
count = 0
for i in range(N):
    Dx[i], Dy[i] = map(int, input().split())

for i in range(N - 2):
    if Dx[i] == Dy[i] and Dx[i + 1] == Dy[i + 1] and Dx[i + 2] == Dy[i + 2]:
        count = 1
if count >= 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n=int(input())
score=[]
point=0
for i in range(n):
  d=input().split()
  if d[0]==d[1]:
    point+=1
    score.append(point)
  else:
    point=0
    score.append(point)

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

Submission status: Accepted

Solution code:
N=int(input())
count=0
ans=0
for _ in range(N):
    a, b = map(int, input().split())
    if a!=b:
        count=0
    else:
        count+=1
        if count==3:
            ans=count
if ans==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:
from collections import deque

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

    deq = deque(D)

    count = 0

    while deq:
        pts = deq.popleft()
        if pts[0] == pts[1]:
            count += 1
        else:
            count = 0
        if count >= 3:
            print("Yes")
            return

    print("No")

main()

Submission status: Accepted

Solution code:
num = int(input())
counter = 3

for n in range(num):
  #データ読み取り
  x, y = map(int, input().split())
  if x == y:
    counter -=1
  else:
    counter = 3
  
  if counter <= 0:
    print('Yes')
    break

if counter > 0:
  print('No')

Submission status: Accepted

Solution code:
N = int(input())
x=[0]*N
y=[0]*N
L=[0]*N

flag = "No"

if N <3:
  flag = "No"

else:

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

  for i in range(N):
    if x[i]==y[i]:
      L[i]=1

  #print(L)

  for i in range (N-2):
    #print(i)
    if L[i] == L[i+1] == L[i+2] == 1:
      flag = "Yes"



print(flag)