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())
l=[]
c=False
for i in range(n):
    l.append(list(input().split()))
for x in range(n-2):
    if l[x][0]==l[x][1]:
        if l[x+1][0]==l[x+1][1]:
            if l[x+2][0]==l[x+2][1]:
                c=True
if c:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
A = []
B = []
s = 0
for x in range(N):
    a, b = input().split()
    a = int(a)
    b = int(b)
    A.append(a)
    B.append(b)
for i in range(N):
    if A[i] == B[i]:
        s = s+1
    else:
        if s >= 3:
            s = s + 0
        else:
            s = 0
if s >= 3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def actual(N: int, D1: list, D2: list) -> str:
    cnt = 0
    is_turkey = False
    for d1, d2 in zip(D1, D2):
        is_zoro = d1 == d2

        if is_zoro:
            cnt += 1
            if cnt == 3:
                is_turkey = True
        else:
            cnt = 0

    if is_turkey:
        return 'Yes'
    else:
        return 'No'
    
N = int(input())
D1, D2 = [],[]

for _ in range(N):
    d1,d2 = map(int, input().split())
    D1.append(d1)
    D2.append(d2)
    
    
print(actual(N,D1,D2))

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)]
ans = 'No'

for i in range(N):
    if x[i]==y[i] and N-2>i:
        if x[i+1]==y[i+1] and N-1>i:
            if x[i+2]==y[i+2] :
                ans = 'Yes'

print(ans)

Submission status: Accepted

Solution code:
cnt = 0
n = int(input())
for i in range(0,n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        cnt += 1
        if cnt == 3 :
            print("Yes")
            break
    elif  cnt >= 0 and d1 != d2:
        cnt = 0 
    if i == n-1:
        print("No")

Submission status: Accepted

Solution code:
N = int(input())
X = []
Y = []
answer = 'No'
for i in range(N):
    x,y = map(int, input().split())
    X.append(x)
    Y.append(y)
for j in range(N-2):
    if ((X[j]==Y[j])and(X[j+1]==Y[j+1])and(X[j+2]==Y[j+2])):
        answer = 'Yes'
print(answer)

Submission status: Accepted

Solution code:
n = int(input())
d = [input().split() for i in range(n)]
total = 0

for i in range(n):
    if  len(set(d[i])) == len(d[i]):
        if total >=3:
            total +=0
        else:
            total = 0
    else:
        total += 1

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N = int(input())

box = []
for i in range(N):
     line = input().split()
     if line[0] == line[1]:
          box.append(1)
     else:
          box.append(0)
#print(box)

m = 0
for j in range(N-2):
     #print(box[j],box [j+1],box[j+2])
     n = box[j]+box [j+1]+box[j+2]
     if n == 3:
          m = 1
     
if m == 1:
     print("Yes")
else:
     print("No")

Submission status: Accepted

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

flag = False
count = 0
for i in range(n):
    d1 = d_lst[i][0]
    d2 = d_lst[i][1]

    if d1 == d2:
        count += 1

        if count == 3:
            flag = True

    else:
        count = 0

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

Submission status: Accepted

Solution code:
n = int(input())

eq = 0
mx = 0
prev = False
for i in range(n):
    d = [int(s) for s in input().split(' ')]
    if d[0] == d[1]:
        if prev:
            eq += 1
        prev = True
        mx = max(eq, mx)
    else:
        prev = False
        eq = 0

if mx >= 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
zoro = 0
res = []

for i in range(N):
    a, b = map(int, input().split())
    if a == b:
        zoro += 1
        res.append(zoro)
    else:
        zoro = 0
        res.append(zoro)

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

Submission status: Accepted

Solution code:
N = int(input())
D1 = [0] * N
D2 = [0] * N
count = 0
continues = [0] * N

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

for i in range(N):
    if D1[i] == D2[i]:
        continues[i] = 1

for i in range(N):
    if continues[i] == 1:
        count = count + 1
    else:
        count = 0
    if count == 3:
        break

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

Submission status: Accepted

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

#print(N, D)

ans = "No"
renzoku = 0

for i in range(N):
    if(D[i][0] == D[i][1]):
        renzoku += 1
        if(renzoku >= 3):
            ans = "Yes"
    else:
        renzoku = 0

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
Di=[input() for i in range(N)]
count=0
n=0
D=[]
a=[]
A=0
for i in range(N):
    D.append(Di[i].split())

for i in range(N):
    if D[i][0]==D[i][1]:
        count+=1
    else:
        a.append(count)
        count=0
if len(a)==0:
    A=0
else:
    A=max(a)

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

Submission status: Accepted

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

count = 0
for one, two in Ds:
    if not one == two:
        count = 0
        continue

    count += 1
    if count == 3:
        print("Yes")
        break

if not count == 3:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())

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

cnt = 0
for i in range(N):
  if i < N - 2:
    a, b = lst[i]
    c, d = lst[i + 1]
    e, f = lst[i + 2]
    if a == b and c == d and e == f:
      cnt += 1
    else:
      continue
if cnt >= 1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
n=int(input())

count=0
c_list=[1]

for i in range(n):
    d1, d2=map(int, input().split())
    if d1==d2:
        count+=1
        c_list.append(count)
        #print(c_list)
    else:
        count=0
        
if max(c_list)>=3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import bisect
from collections import deque
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
# mod = 10 ** 9 + 7
mod = 998244353

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]



def main():
    N = int(input())
    t = 0
    f = False
    for _ in range(N):
        a, b = read_values()
        if a == b:
            t += 1
        else:
            t = 0

        if t == 3:
            f = True
    
    print("Yes" if f else "No")


if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = False
for i in range(N-2):
    if D[i] and D[i+1] and D[i+2]:
        ans = True
        break
YesNo = lambda tf: print('Yes') if tf else print('No')
YesNo(ans)

Submission status: Accepted

Solution code:
n = int(input())
t = [0] * n
x = [0] * n
for i in range(n):
    t[i], x[i] = map(int, input().split())
a=0
for j in range(n-2):
    if t[j]==x[j]and t[j+1]==x[j+1] and t[j+2]==x[j+2]:
        a+=1
    else:
        a+=0
if a==0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
N = int(input())
A = []
B = []
s = 0
for x in range(N):
  a, b = input().split()
  a = int(a)
  b = int(b)
  A.append(a)
  B.append(b)
for i in range(N):
  if A[i] == B[i]:
    s = s+1
  else:
    if s >= 3:
      s = s + 0
    else:
      s = 0
if s >= 3:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
n = int(input())
d = []
for i in range(n):
  d.append(input().split())
ans = 'No'
for i in range(n - 2):
  if d[i][0] == d[i][1] and d[i+1][0] == d[i+1][1] and d[i+2][0] == d[i+2][1]:
    ans ='Yes'
    break

print(ans)

Submission status: Accepted

Solution code:
import sys

n = int(input())

zoro = 0
res = 0

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

    if d1 != d2:
        zoro = 0
    else:
        zoro = zoro + 1
    if zoro == 3:
        res = 1

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

Submission status: Accepted

Solution code:
N = int(input())

result = ""

for _ 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:
get = lambda  : int(input())
getlist = lambda : list(map(int, input().split(" ")))

n = get()
arr = []
for i in range(n):
    arr.append(getlist())

ok = False
for i in range(n-2):
    if arr[i][0] == arr[i][1] and arr[i+1][0] == arr[i+1][1] and arr[i+2][0] == arr[i+2][1]:
        ok = True
        break
if ok:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
x = []
y = []

n = int(input())

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

z = 0

for i in range(n-2):
    if x[i] == y[i]:
        if x[i + 1] == y[i + 1]:
            if x[i + 2] == y[i + 2]:
                z = 1
                break
            else:
                z = 0
                continue
        else:
            z = 0
            continue
    else:
        z = 0
        continue
    


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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    numbers = []
    for i in range(n):
        numbers.append(len(set(map(int, input().split()))))
    row3 = [numbers[i:i+3] for i in range(n - 2)]
    if([1,1,1] in row3):
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()

Submission status: Accepted

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

import sys
from typing import Any, Callable, Deque, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypeVar, Union
# import time
# import math, cmath
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import _heapify_max, _heappop_max, _siftdown_max
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import Fraction               # Fraction(a, b) => a / b ∈ Q. note: Fraction(0.1) do not returns Fraciton(1, 10). Fraction('0.1') returns Fraction(1, 10)



def main():
    Num = Union[int, float]
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79e+308
    # inf = 2 ** 63 - 1             # (for fast JIT compile in PyPy) 9.22e+18
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input():  return sys.stdin.readline().rstrip()
    def ii():     return int(input())
    def isp():    return input().split()
    def mi():     return map(int, input().split())
    def mi_0():   return map(lambda x: int(x)-1, input().split())
    def lmi():    return list(map(int, input().split()))
    def lmi_0():  return list(map(lambda x: int(x)-1, input().split()))
    def li():     return list(input())
    def debug(x): print(x, file=sys.stderr)
    # def _heappush_max(h, item): h.append(item); _siftdown_max(h, 0, len(h)-1)
    
    
    n = ii()
    L = [lmi() for _ in range(n)]

    def check(n, L):
        for i in range(n-2):
            if L[i][0] == L[i][1] and L[i+1][0] == L[i+1][1] and L[i+2][0] == L[i+2][1]:
                return True
        return False

    print('Yes' if check(n, L) else 'No')


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def solve(n, d):
    if n < 3:
        return "No"
    else:
        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]:
                        return "Yes"
        return "No"

n = int(input())
d = []
for i in range(n):
    d += [list(map(int,input().split()))]
#print(d)
print(solve(n,d))

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
result="No"
# 出力して確認
#for n in range(N-1):
for i in range(N):
    cnt=cnt+1 if x[i]==y[i] else 0
    if cnt>2:
        result="Yes"
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
def count():
    count = 0
    result = ''
    for i in range(n):
        d1, d2 = map(int, input().split())
        if result == 'Yes':
            continue
        if d1 == d2:
            count += 1
            if count == 3:
                result = 'Yes'
        else:
            count = 0
            result = 'No'
    return result

print(count())

Submission status: Accepted

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

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

for i in range(N):
    if x[i] == y[i]:
        k += 1
    else:
        k = 0
    if k == 3:
        break

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

Submission status: Accepted

Solution code:
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


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

Submission status: Accepted

Solution code:
N = int(input())
D  = [list(map(int,input().split())) for i in range(N)]
count = 0 
k = 0 
while count < 3 and k <= N-1:
        if D[k][0] == D[k][1]:
            count += 1
        else:
            count = 0 
        k+=1
        
if count == 3:
    print('Yes')
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())

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

li = []
for i in string:
    li.append(int(i[0]) - int(i[1]))

c = 0
nli = len(li) - 1

while c != nli:
    if li[c] == 0:
        if c == nli - 1:
            print('No')
            exit()
        elif li[c + 1] == 0:
            if li[c + 2] == 0:
                print('Yes')
                exit()
    c += 1

print('No')

Submission status: Accepted

Solution code:
import itertools
n = int(input())
s = []
for i in range(n):
    array = list(map(int, input().strip().split()))
    s.append(array)
s = list(itertools.chain.from_iterable(s))
d = "No"
x = 0
while x+5 < len(s):
    if s[x] == s[x+1] and s[x+2] == s[x+3] and s[x+4] == s[x+5]:
        d = "Yes"
        break
    else:
        x += 1
print(d)

Submission status: Accepted

Solution code:
n=int(input())

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

flag_a=0
flag_b=0
for i in range(n):
  if num_list[i][0]==num_list[i][1] :
    flag_a+=1
  else:
    flag_a=0
  
  if flag_a==3:
    flag_b=1
    
if flag_b==1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
n = int(input())
numList = []
for x in range(n):
	num = [int(x) for x in input().split()]
	if num[0] == num[1]:
		numList.append('True')
	else:
		numList.append('False')
		
	
judge = 'No'
for x in range(len(numList)-2):
    if numList[x] == 'True':
      if numList[x+1] == 'True':
        if numList[x+2] == 'True':
          judge = 'Yes'
print(judge)

Submission status: Accepted

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

    counter = 0
    for i in range(N):
        A, B = map(int, input().split())
        if A == B:
            counter += 1
            if counter >= 3:
                print('Yes')
                return 0
        else:
            counter = 0
    print('No')

if __name__ == "__main__":
    myfunc()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D1 = [0] * N
D2 = [0] * N
for n in list(range(N)):
    D1[n], D2[n] = map(int, input().split())

ans = 'No'
for i in list(range(N - 2)):
    if D1[i] == D2[i] and D1[i + 1] == D2[i + 1] and D1[i + 2] == D2[i + 2]:
        ans = 'Yes'
        break

print(ans)

Submission status: Accepted

Solution code:
X=int(input())
cnt=0
for i in range(X):
    A,B=list(map(int,input().split()))
    if A==B:
        cnt=cnt+1
    else:
        cnt=0
    if cnt==3:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
n=int(input())
z=0
c=0
f=0
i=0;

while i<n:
    l=list(map(int,input().split()))
    a=l[0]
    b=l[1]
    if a==b:
        z=1
        c=c+1
        if c>=3:
            f=1
    else:
        c=0
        z=0
    
    i=i+1
if f:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import math


def a():
    s = input()
    if s[-1] == 's':
        print(s + 'es')
    else:
        print(s + 's')


def b():
    n = int(input())
    d = []
    for i in range(n):
        d.append(list(map(int, input().split())))
    for i in range(n - 2):
        if d[i + 2][0] == d[i + 2][1] and \
            d[i + 1][0] == d[i + 1][1] and \
                d[i][0] == d[i][1]:
            print('Yes')
            break
    else:
        print('No')


def c():
    pass


def d():
    pass


# a()
b()
# c()
# d()

Submission status: Accepted

Solution code:
#
# 179B
#
n = input()
n = int(n)
s = ''
for i in range(n):
    t = input()
    t = t.replace(' ','')
    t = list(t)
    if t[0]==t[1]:
        s = s+'1'
    else:
        s = s+'0'

if '111' in s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
x = []
for i in range(N):
    input1 = input()
    input1 = input1.split() 
    m, n = int(input1[0]), int(input1[1])
    if(m==n):
        x.append('x')  
    else:
        x.append(0)
count = 0
flag = 0
i = 0
while(i!=N):
    if(x[i]=='x'):
        count=count+1
        if(count>=3):
            flag+=1
    else:
        count = 0
    i+=1
if(flag>0):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = []
B = []
s = 0
for x in range(N):
    a, b = input().split()
    a = int(a)
    b = int(b)
    A.append(a)
    B.append(b)
for i in range(N):
    if A[i] == B[i]:
        s = s+1
    else:
        if s >= 3:
            s = s + 0
        else:
            s = 0
if s >= 3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def fourroll(s):
    count = 0
    for i in range(len(s)):
        if s[i][0]==s[i][1]:
           count +=1
           #print(count)
           if count is 3:
               print("Yes")
               return
        else:
           count = 0
    print("No")

s = []
n = int(input())
for i in range(n):
    a,b = input().split()
    s.append((a,b))
fourroll(s)

Submission status: Accepted

Solution code:
def dice(m, n):
    for i in range(0, n-2):
        if (m[i][0] == m[i][1]) and (m[i + 1][0] == m[i + 1][1]) and (m[i + 2][0] == m[i + 2][1]): 
            return 'Yes'
    return 'No'

N = int(input())
mylist = []
for i in range(0, N):
    num = list(map(int, input().split(' ')))
    mylist.append(num)

print(dice(mylist, N))

Submission status: Accepted

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

for i in range(0,n):
	d[i] = set(d[i])

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

def Ans(n,a):
    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]:
                    return('Yes')
                else:
                    continue
            else:
                continue
        else:
            continue
    return('No')
                    
print(Ans(N,A))

Submission status: Accepted

Solution code:
N = int(input())
d1 = [0]*N
d2 = [0]*N
tmp = 0
for i in range(N):
    d1[i], d2[i] = map(int, (input().split(' ')))

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

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

Submission status: Accepted

Solution code:
n = int(input())
d = [list(map(lambda x: int(x), input().split())) for i in range(n)]
a = 0
f = 0
for [x, y] in d:
    if x == y:
        a += 1
        if a >= 3:
            f = 1
    else:
        if a >= 3:
            f = 1
        a = 0
if f:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=int(input())
b=[input() for i in range(a)]
d=[i.split() for i in b]

series_count=0

for di in d:
	if di[0]==di[1]:
		series_count+=1
	else:
		series_count=0

	if series_count==3:
		print("Yes")
		break

if series_count<3:
	print("No")

Submission status: Accepted

Solution code:
N = int(input())
A=[list(map(int, input().split())) for i in range(N)]
num = 0
zoro = 0
while num < N:
  if A[num][0] ==A[num][1]:
    num +=1
    zoro +=1 
  else:
    num +=1
    if zoro >2:
      zoro = zoro
    else:
      zoro = 0
if zoro >2 :
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n = int(input())
count = 0
flag = False
while count < n:
  a, b = map(int, input().split())
  count += 1
  if a == b and count < n:
    a, b = map(int, input().split())
    count += 1
    if a == b and count < n:
      a, b = map(int, input().split())
      count += 1
      if a == b and count <= n:
        flag = True
        print("Yes")
        break

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

Submission status: Accepted

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

cnt = 0
flag = False
for d in d_list:
    if d[0] == d[1]:
        cnt+=1
        if cnt >= 3:
            print("Yes")
            flag = True
            break
    else :
        cnt = 0

if flag==False :    
    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)]
count = 0
for i in range(N):
    if (x[i] == y[i]):
        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())

renzoku = 0
flag = 0
for i in range(n):
  d = list(map(int, input().split()))
  if d[0] == d[1]:
    renzoku += 1
    if renzoku == 3:
      flag = 1
      break
  else:
    renzoku = 0
  
if flag == 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())
cnt=0
flg=0

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

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(num):
  line = input().split()
  nums = [int(a) for a in line]
  if nums[0]==nums[1]:
    count+=1
  else:
    count=0
  if count==3:
    break

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

Submission status: Accepted

Solution code:
n = int(input())
xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
count = 0
buf = 0

for xi, yi in zip(x, y):
    if xi == yi:
        buf += 1
    else:
        if buf > count:
            count = buf
        buf = 0

if buf > count:
    count = buf

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

Submission status: Accepted

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

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

Submission status: Accepted

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

for num in range(n):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        count += 1
        if count>= 3:
            flg = 1
    else:
        count=0
else:
    if count > 3 or flg >0:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
n = int( input() )
#print( n )

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

    if cnt == 3:
        ans = "Yes"


print( ans )

Submission status: Accepted

Solution code:
n = int(input())
d = []
judge = 'No'

for i in range(n):
  d.append(list(int(x) for x in input().split()))
  if i >= 2:
    if d[i-2][0] == d[i-2][1] and d[i-1][0] == d[i-1][1] and d[i][0] == d[i][1]:
      judge = 'Yes'

print(judge)

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)]

ans = 0
flag = False

for i in range(N):
    if x[i] == y[i]:
        ans +=1
    elif ans >= 3:
        flag = True
        ans = 0
    else:
        ans = 0
        
if ans >= 3  or flag ==True:
    print("Yes")
    
else:
    print("No")

Submission status: Accepted

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