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:
import sys
input = sys.stdin.readline


def read():
    N = int(input().strip())
    D = []
    for i in range(N):
        a, b = map(int, input().strip().split())
        D.append((a, b))
    return N, D


def solve(N, D):
    seq = 0
    for a, b in D:
        if a == b:
            seq += 1
        else:
            seq = 0
        if seq >= 3:
            return "Yes"
    return "No"


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ds = [tuple(map(int,input().split())) for i in range(n)]
ans = 0
x = 0
for i in range(n-1):
    #print(x)
    if (ds[i][0] == ds[i][1]) and (ds[i+1][0] == ds[i+1][1]):
        x += 1
    else:
        ans = max(ans,x+1)
        x = 0
print("Yes" if max(ans,x+1) >= 3 else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

count = 0
for i in range(N):
    d1,d2 = map(int,input().split())
    if d1==d2:
        count +=1
        if count>=3:
            break
    else:
        count = 0

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush
import collections
import bisect

def main():
    n = int(input())
    count = 0
    D1 = []
    D2 = []
    for i in range(n):
        d1, d2 = map(int, input().split())
        D1.append(d1)
        D2.append(d2)
    for i in range(n):
        if D1[i] == D2[i]:
            count += 1
        else:
            count = 0
        if count == 3:
            print('Yes')
            return
    print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from __future__ import division, print_function
# https://github.com/cheran-senthil/PyRival/blob/master/templates/template.py
import os
import sys
from difflib import SequenceMatcher
# seqMatch = SequenceMatcher(None,str1,str2) 
 #  # find match of longest sub-string 
    #  # output will be like Match(a=0, b=0, size=5) 
    #  match = seqMatch.find_longest_match(0, len(str1), 0, len(str2))
from io import BytesIO, IOBase
from collections import Counter,deque
from heapq import heapify,heappush,heappop
from math import gcd,ceil,sqrt,log2,log
from itertools import accumulate,repeat,permutations,compress

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

def rl():
    return list(map(int,input().split()))
def arp(arr):
    return ' '.join([str(i) for i in arr])
    

################################


n, = rl()
ans = 0
while(n):
    n-=1
    a,b = rl()
    if(a==b):
        ans+=1
    else:
        if(ans>=3):
            break
        ans = 0
if(ans>=3):
    print("Yes")
else:
    print("No")


















































































































###################################################################################
# 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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
c, result = 0, 0
for d in D:
  if d[0]==d[1]:
    c += 1
  else:
    c = 0
  if c>=3:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
N=int(input())
D=[list(map(int,input().split())) for i in range(N)]
m=0
x=0
for d,d2 in D:
    if d==d2:
        x+=1
    else:
        m=max(m,x)
        x=0
m=max(m,x)
print(['No','Yes'][m>=3])

Submission status: Accepted

Solution code:
N=int(input())
zorome=[]
for i in range(N):
    x,y=map(int,input().split())
    if x==y:
        zorome.append(1)
    else:
        zorome.append(0)

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

Submission status: Accepted

Solution code:
"""
# B - Go to Jail
"""
count = int(input())

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

Submission status: Accepted

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

for i in range(N - 2):
    if D[i][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())
a=0
for i in range(N):
  d1, d2=map(int, input().split())
  if d1==d2:
    a+=1
  else:
    a=0
  if a==3:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():


    n = I()
    saikoro = []
    for i in range(n):
        a, b = LI()
        saikoro.append((a, b))

    cnt = 0

    for deme in saikoro:
        if len(set(deme)) == 1:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            print("Yes")
            exit(0)

    print("No")

main()

Submission status: Accepted

Solution code:
def solve():
    N = int(input())
    cnt = 0
    flg = False
    for _ in range(N):
        d1, d2 = map(int,input().split())
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        
        if cnt == 3:
            flg = True
    
    if flg:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    solve()

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]:
    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:
n=int(input())
c=0
ans=False
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        c+=1
    else:
        c=0
    if c==3:
        ans=True
if ans:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())

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

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

    D1[i], D2[i] = a, b

for i in range(2, N):

    if D1[i-2] == D2[i-2] and D1[i-1] == D2[i-1] and D1[i] == D2[i]:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

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


ans = [0] * n
for i in range(n):
    if d[i][0] == d[i][1]:
        ans[i] = 1

ans.append(0)
max_cnt = 0
cnt = 0


for i in range(n + 1):
    if ans[i] == 1:
        cnt += 1
    else:
        max_cnt = max(max_cnt, cnt)
        cnt = 0

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

Submission status: Accepted

Solution code:
n = int(input())
a = []
res = False
for i in range(n):
    x, y = map(int, input().split())
    a.append(x == y)
    if i >= 2 and a[-1] and a[-2] and a[-3]:
        res = True
print('Yes' if res else 'No')

Submission status: Accepted

Solution code:
N = int(input())
cnt = 0
mx = 0
for _ in range(N):
  a,b = map(int,input().split())
  if a==b:
    cnt+=1
    mx = max(cnt,mx) 
  else :
    cnt=0
print("Yes" if mx >2 else "No")

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
c=0
for _ in range(int(input())):
  a,b=map(int,input().split())
  if a==b:c+=1
  else:c=0
  if c>2:break
else:print("No");quit()
print("Yes")

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

n=int(input())
cnt=0
d=False
for i in range(n):
  x,y=map(int,input().split())
  if x==y:
    cnt+=1
  else:
    cnt=0
  if cnt==3:
    d=True
    break
if d:
  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())

ans = False
zoro_renzoku = 0

for _ in range(N):
    D_1, D_2 = map(int, input().split())
    if D_1==D_2:
        zoro_renzoku += 1
    else:
        zoro_renzoku = 0
    
    if zoro_renzoku ==3:
        ans = True
        
if ans:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    N = int(_in[0])  # type:int
    D_arr = []
    for i in range(N):
        _ = list(map(int, _in[i+1].split(' ')))  # type:list(int)
        D_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    ans = 0
    cnt = 0
    for a, b in D_arr:
        if a == b:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            ans = 'Yes'
            break
    else:
        ans = 'No'
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(ans)


if __name__ == "__main__":
    main()

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
# author:  Taichicchi
# created: 19.09.2020 21:01:22

import sys

N = int(input())

c = 0


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

print("No")

Submission status: Accepted

Solution code:
'''
Created on 2020/09/19

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  cnt=0
  ans=False
  for i in range(N):
    d,e=map(int,pin().split())
    if d==e:
      cnt+=1
      if cnt==3:
        ans=True
        cnt=0
    else:
      cnt=0
  if ans:
    print("Yes")
  else:
    print("No")
  return 
main()

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

a = 0
for i in range(n):
    if dice[i][0] == dice[i][1]:
        a += 1
    else:
        a = 0
    if a >= 3:
        flag = True

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    v = 0
    for _ in range(N):
        d1, d2 = input().split()
        if d1 == d2:
            v += 1
        else:
            v = 0
        if v == 3:
            print('Yes')
            exit()
    print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

    if c == 3:
        flag = 1

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
flag = False

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

Submission status: Accepted

Solution code:
N = int(input())

result = 0
cur = 0
for _ in range(N):
  d1, d2 = map(int, input().split())
  if d1 == d2:
    cur += 1
  else:
    cur = 0
  result = max(result, cur)

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
    d1,d2 = list(map(int,input().split()))
    if d1 == d2:
        count += 1
    else:
        count = 0
    if ans < count:
        ans = count

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

Submission status: Accepted

Solution code:
import sys
n = int(input())
ans = 0
flag = False
for i in range(n):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        ans += 1
    else:
        ans = 0
    if ans == 3:
        flag = True
if flag == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ans = "No"
x = 0
for _ in range(n):
  d1, d2 = input().split()
  if d1 == d2:
    x += 1
  else:
    x = 0

  if x == 3:
    ans = "Yes"


print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
n = int(input())
count = 0
for i in range(n):
  x,y = input().split()
  if x == y:
    count += 1
    if count >= 3:
      print("Yes")
      sys.exit()
  else:
    count = 0
      
print("No")

Submission status: Accepted

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

cnt=0
for d1,d2 in d:
    if d1 == d2:
        cnt+=1
        if cnt==3:
            print("Yes")
            exit()
    else:
        cnt=0

print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
tmp = 0
ans = False

for i in range(N):
    tmp += 1
    t = tuple(map(int, input().split()))
    if t[0] != t[1]:
        tmp = 0
    if tmp >= 3:
        ans = True

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

Submission status: Accepted

Solution code:
# Date [ 2020-09-19 21:01:49 ]
# Problem [ b.py ]
# Author Koki_tkg

import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    n = read_int()
    cnt = 0
    flag = False
    for _ in range(n):
        d1, d2 = read_ints()
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            flag = True
    print('Yes' if flag else 'No')

if __name__ == '__main__':
    Main()

Submission status: Accepted

Solution code:
N = int(input())

cnt=0
flg =False

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 19 20:17:38 2020

@author: liang
"""
#B
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:
N = int(input())
flag = 0
ans = False
for _ in range(N):
    d1,d2 = map(int,input().split())
    if d1==d2:
        flag += 1
        if flag==3:
            ans = True
            break
    else:
        flag = 0
print('Yes' if ans else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
l1=[]
l2=[]
for i in range(n):
  x,y=(int(i) for i in input().split())
  l1.append(x)
  l2.append(y)
c=0
for i in range(n-2):
  if(l1[i]==l2[i] and l1[i+1]==l2[i+1] and l1[i+2]==l2[i+2]):
    c=1
    break
if(c==0):
  print("No")
else:
  print("Yes")

Submission status: Accepted

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

arr.append(0)
arr.append(0)

for i in range(n):
    if arr[i]+arr[i+1]+arr[i+2] == 3:
        print("Yes")
        break
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")
        break
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  cnt=0
  mx=0
  for _ in range(n):
    a,b=LI()
    if a==b:
      cnt+=1
    else:
      mx=max(mx,cnt)
      cnt=0
  mx=max(mx,cnt)

  if mx>=3:
    return 'Yes'
  return 'No'

# main()
print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from sys import exit
from math import gcd, factorial, ceil, floor, sqrt
from bisect import bisect_left, bisect_right
from copy import deepcopy
from heapq import heapify, heappop, heappush
from itertools import permutations, combinations, product, accumulate
from collections import defaultdict, deque, Counter
sys.setrecursionlimit(10**7)

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

N = ii()
d = []
for i in range(N):
    a, b = mi()
    d.append([a, b])
cur = 0
for x, y in d:
    if x == y:
        cur += 1
    else:
        cur = 0
    if cur == 3:
        print('Yes')
        sys.exit()
print('No')

Submission status: Accepted

Solution code:
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    N = NI()
    cnt = 0
    for _ in range(N):
        d1,d2 = LI()
        if d1 == d2:
            cnt += 1
            if cnt >= 3:
                print('Yes')
                return
        else:
            cnt = 0
    print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

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

yes = "Yes"
no = "No"


def main():
    n = ii()
    cnt = 0
    flag = False
    for i in range(n):
        a,b = mi()
        if a==b:
            cnt+=1
            if cnt == 3:
                flag = True
        else:
            cnt=0
    if flag:
        print(yes)
    else:
        print(no)


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

count = 0
jail = False

for _ in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        count += 1
        if count >= 3:
            jail = True
    else:
        count = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin,stdout
n=int(stdin.readline());ans='No';d=0
# a=list(map(int,stdin.readline().split()))
for i in range(n):
    x,y=list(map(int,stdin.readline().split()))
    if x==y:d+=1
    else:d=0
    if d>=3:
        ans='Yes'
        break
print(ans)

Submission status: Accepted

Solution code:
N=int(input())

ans="No"
t=0

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