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

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]:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
'''بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ'''
#codeforces
gi = lambda : list(map(int,input().split()))
cnt = 0
for _ in range(gi()[0]):
  x, y = gi()
  if x == y:
    cnt += 1
  else:
    cnt = 0
  if cnt == 3:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
N = int(input())
counter = 0
flag = False

for i in range(N):
    l = input().split(" ")
    if l[0] == l[1]:
        counter += 1
    else:
        counter = 0
    if counter == 3:
        flag = True

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

Submission status: Accepted

Solution code:
N = int(input())
D = []
cont_count = 0

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

print('No')

Submission status: Accepted

Solution code:
N=int(input())
D=[]
for i in range(N):
    S=list(map(int,input().split()))
    S=len(set(S))
    D.append(S)
for i in range(len(D)-2):
    if D[i]==D[i+1]==D[i+2] and D[i]==1:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
def abc179b():
    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')
abc179b()

Submission status: Accepted

Solution code:
count = 0
ans = False
for __ in range(int(input())):
    a, b = map(int, input().split())
    if a == b:
        count += 1
    else:
        count = 0
    if count == 3:
        ans = True
        break

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

Submission status: Accepted

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key
from bisect import bisect_left


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

def bindex(a,x):
    i = bisect_left(a,x)
    if i != len(a) and a[i] == x:
        return i
    return None

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



if __name__ == '__main__':
    N = intinput()

    indatas = []
    for _ in range(N):
        indatas.append(tuple(list(mulinputs())))
    cnt = 0
    for d in indatas:
        d1, d2 = d[0], d[1]
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            print('Yes')
            exit()
    if cnt == 3:
        print('Yes')
        exit()
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
count = 0
flag = False
for i in range(N):
    D1, D2 = map(int, input().split())

    if D1 == D2:
        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())
count = 0
max_count = 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        count += 1
        max_count = max(max_count, count)
    else:
        count = 0
if max_count >= 3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

count = 0
for _ in range(N):
    D1, D2 = list(map(int, input().split()))
    if D1 == D2:
        count += 1
    else:
        count = 0
        continue
    if count == 3:
        break
if count == 3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())

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

    if a == b:
        count += 1
    else:
        count = 0

    if count == 3:
        print('Yes')
        exit(0)

print('No')

Submission status: Accepted

Solution code:
it = lambda: list(map(int, input().strip().split()))


def solve():
    n = int(input())
    ok = False
    cnt = 0
    for _ in range(n):
        a, b = it()
        if a == b:
            cnt += 1
            if cnt == 3:
                ok = True
        else:
            cnt = 0
    return 'Yes' if ok else 'No'

if __name__ == '__main__':
    print(solve())

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

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

print("No")

Submission status: Accepted

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

num = 0
for d1, d2 in Dss:
    if d1 == d2:
        num += 1
        if num >= 3:
            print('Yes')
            break
    else:
        num = 0
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())

m = 0
now = 0
for i in range(n):
    x,y = map(int, input().split())
    if x == y:
        now += 1
        m = max(m, now)
    else:
        now = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N = NI()
    AB = [NLI() for _ in range(N)]
    
    for n in range(N-2):
        if AB[n][0] == AB[n][1]:
            if AB[n+1][0] == AB[n+1][1]:
                if AB[n+2][0] == AB[n+2][1]:
                    print("Yes")
                    sys.exit()
    print("No")





if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    inlis = list()
    for _ in range(n):
        d1, d2 = map(int, input().split())
        inlis.append([d1, d2])
    
    for i in range(n):
        a, b = inlis[i][0], inlis[i][1]
        if a == b and i <= n - 3:
            if inlis[i+1][0] == inlis[i+1][1] and inlis[i+2][0] == inlis[i+2][1]:
                print('Yes')
                exit()
    print('No')




if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
#import numpy as np
import re
import math
from collections import defaultdict,deque,Counter
from fractions import Fraction
import bisect
import itertools
from itertools import accumulate
from copy import deepcopy

import heapq
import random
import time
import os
import sys
from functools import lru_cache,reduce
readline=sys.stdin.readline
sys.setrecursionlimit(100000)
alp="abcdefghijklmnopqrstuvwxyz"
numbers="0123456789"
mod=int(10**9+7)
inf=int(10**19)
class Set():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(bool)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        if not self.find(x):
            heapq.heappush(self.heap,x)
            self.dic[x]=True
            self.size+=1

    def remove(self,x):
        if self.find(x):
            self.dic[x]=False
            self.size-=1

    def find(self,x):
        return self.dic[x]
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==False:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class multiset():
    def __init__(self,A=[]):
        self.heap=[]
        self.dic=defaultdict(int)
        self.size=0
        for a in A:self.add(a)
    
    def __str__(self):
        return str(self.heap)
    
    def add(self,x):
        heapq.heappush(self.heap,x)
        self.dic[x]+=1
        self.size+=1

    def remove(self,x):
        if self.dic[x]>0:
            self.dic[x]-=1
            self.size-=1
    
    def count(self,x):
        return self.dic[x]

    def find(self,x):
        return self.dic[x]>0
    
    def top(self):
        while self.heap and self.dic[self.heap[0]]==0:
            heapq.heappop(self.heap)
        if self.heap:return self.heap[0]
        else:return None

    def pop(self):
        ret=None
        if self.heap:
            ret=self.top()
            self.remove(ret)
        return ret
class Edge():
    def __init__(self,x,y,val=1):
        self.x=x
        self.y=y
        self.val=val
class Point():
    def __init__(self,y,x):
        self.x=x
        self.y=y
class unionfind():
    def __init__(self,n):
        self.n=n
        self.P=[a for a in range(n)]
        self.rank=[0]*n
 
    def find(self,x):
        if(x!=self.P[x]):
            self.P[x]=self.find(self.P[x])
        return self.P[x]
 
    def same(self,x,y):
        return self.find(x)==self.find(y)
 
    def link(self,x,y):
        if self.rank[x]<self.rank[y]:
            self.P[x]=y
        elif self.rank[y]<self.rank[x]:
            self.P[y]=x
        else:
            self.P[x]=y
            self.rank[y]+=1
 
    def unite(self,x,y):
        self.link(self.find(x),self.find(y))
 
    def size(self):
        S=set()
        for a in range(self.n):
            S.add(self.find(a))
        return len(S)
def yn(b):print("yes" if b else "no")
def Yn(b):print("Yes" if b else "No")
def YN(b):print("YES" if b else "NO")
def ispow(a,b):
    now=b
    while now<a:
        now*=b
    return now==a
def getbin(num,size):
    A=[0]*size
    for a in range(size):
        if (num>>(size-a-1))&1==1:
            A[a]=1
        else:
            A[a]=0
    return A
def getfacs(n,mod_=0):
    A=[1]*(n+1)
    for a in range(2,len(A)):
        A[a]=A[a-1]*a
        if(mod_>0):A[a]%=mod_
    return A
def comb(n,r,mod,fac):
    if(n-r<0):return 0
    return (fac[n]*pow(fac[n-r],mod-2,mod)*pow(fac[r],mod-2,mod))%mod
def nextcomb(num,size):
    x=num&(-num)
    y=num+x
    z=num&(~y)
    z//=x
    z=z>>1
    num=(y|z)
    if(num>=(1<<size)):return False
    else:return num
def getprimes(n):
    if n==0:return []
    A=[True]*(n+1)
    A[0]=False
    A[1]=False
    for a in range(2,n+1):
        if A[a]:
            for b in range(a*2,n+1,a):
                A[b]=False
    ret=[]
    for a in range(n+1):
        if(A[a]):ret.append(a)
    return ret
def isprime(num):
    if(num<=1):return False
    i=2
    while i*i<=num:
       if(num%i==0):return False
       i+=1
    return True
def ifelse(b,t,f):return t if b else f
def factorize(n):
    b = 2
    ret=defaultdict(int)
    while b * b <= n:
        while n % b == 0:
            n //= b
            ret[b]+=1
        b+=1
    if n > 1:ret[n]+=1
    return ret
def inputintlist(row=1): 
    if row==1:
        ret=list(map(int,input().split()))
    else:
        ret=[None]*row
        for a in range(row):
            ret[a]=int(input())
    return ret
def inputfloatlist(row=1): 
    if row==1:
        ret=list(map(float,input().split()))
    else:
        ret=[None]*row
        for a in range(row):
            ret[a]=float(input())
    return ret
def istanchouzouka(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>=a:
            f=False
        prev=a
    return f
def istanchouhigensyou(A):
    f=True
    prev=min(A)-1
    for a in A:
        if prev>a:
            f=False
        prev=a
    return f
def getallsum(A):
    s=sum(A)
    dp=defaultdict(int)
    dp[0]=1
    for a in range(0,len(A)):
        for b in range(s,-1,-1):
            if b-A[a]>=0:
                dp[b]+=dp[b-A[a]]
    return dp
def yuukoutomukou(edges):
    ret=deepcopy(edges)
    for edge in edges:
        if not edge.x==edge.y:
            ret.append(Edge(edge.y,edge.x,edge.val))
    return ret
def dijkstra(edges,V,start):
    from queue import PriorityQueue
    mincost=[inf]*V
    G=[[] for a in range(V)]
    for edge in edges:
        G[edge.x].append([edge.val,edge.y])
    Q=PriorityQueue()
    Q.put([0,start])#[cost,x]
    while not Q.empty():
        nowcost,nowx=Q.get()
        if mincost[nowx]==inf:
            mincost[nowx]=nowcost
            for cost,y in G[nowx]:
                newcost=nowcost+cost
                Q.put([newcost,y])
    return mincost
def warshallfloyd(edges,V):
    mincost=[[inf for b in range(V)] for a in range(V)]
    for a in range(V):mincost[a][a]=0
    for edge in edges:
        mincost[edge.x][edge.y]=min(mincost[edge.x][edge.y],edge.val)#x→yが複数ある場合のためにmin()する
    for k in range(V):
        for s in range(V):
            for t in range(V):
                if mincost[s][k]==inf or mincost[k][t]==inf:continue
                mincost[s][t]=min(mincost[s][t],mincost[s][k]+mincost[k][t])
    return mincost
def bellemanford(edges,V,start):
    mincost=[inf]*V
    mincost[start]=0
    for _ in range(V):
        for edge in edges:
            if mincost[edge.x]==inf:continue
            mincost[edge.y]=min(mincost[edge.y],mincost[edge.x]+edge.val)
    return mincost
def getmd(x1,y1,x2,y2):return abs(x1-x2)+abs(y1-y2)
def geted(x1,y1,x2,y2):return math.sqrt((x1-x2)**2+(y1-y2)**2)
class fordfulkerson():
    def __init__(self,edges,V,s,t):
        self.V=V
        self.used=[False]*V
        self.G=[[] for a in range(V)]
        self.s=s
        self.t=t
        for edge in edges:
            self.G[edge.x].append({"x":edge.x,"y":edge.y,"cap":edge.val,"rev":len(self.G[edge.y])})
            self.G[edge.y].append({"x":edge.y,"y":edge.x,"cap":0,"rev":len(self.G[edge.x])-1})
    def dfs(self,v,t,f=inf):
        if v==t:return f
        self.used[v]=True
        for a in range(len(self.G[v])):
            x=self.G[v][a]["x"]
            y=self.G[v][a]["y"]
            cap=self.G[v][a]["cap"]
            rev=self.G[y][self.G[x][a]["rev"]]
            if self.used[y] or cap==0:continue
            f2=self.dfs(y,t,min(f,cap))
            if f2>0:
                self.G[v][a]["cap"]-=f2
                rev["cap"]+=f2
                return f2
        return 0
    def maxflow(self):
        flow=0
        while True:
            self.used=[False]*V
            zouka=self.dfs(self.s,self.t)
            if zouka==0:break
            flow+=zouka
        return flow
def zipsort(*args):
    ziplist=sorted(zip(*args))
    for a in range(len(args)):
        for b in range(len(ziplist)):
            args[a][b]=ziplist[b][a]
def zipreverse(*args):
    ziplist=list(zip(*args))
    rev=[]
    for a in range(len(ziplist)-1,-1,-1):
        rev.append(ziplist[a])
    for a in range(len(args)):
        for b in range(len(rev)):
            args[a][b]=rev[b][a]

def to10(A):
    ret=0
    for a in range(len(A)-1,-1,-1):
        ret+=X[a]*2**(N-1-a)
    return ret
######################################################################################################
n=int(input())
D=[None]*n
for a in range(n):
    D[a]=inputintlist()
renzoku=0
f=False
for a in range(n):
    if D[a][0]==D[a][1]:
        renzoku+=1
    else:
        renzoku=0
    if renzoku>=3:
        f=True
Yn(f)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin python3
# -*- coding: utf-8 -*-

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

Submission status: Accepted

Solution code:
n=int(input())
d=[]
for i in range(n):
    x,y=map(int,input().split())
    d.append([x,y])
f=1
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]:
        f=0
print("Yes" if f==0 else "No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())

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

cnt = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        cnt += 1
        if cnt == 3:
            print("Yes")
            exit()
    else:
        cnt = 0

print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

N = int(input())

count = 0
ans = 'No'
for _ in range(N):
    D1, D2 = map(int, sys.stdin.readline().strip().split())

    if D1 == D2:
        count += 1
    else:
        count = 0

    if count >= 3:
        ans = 'Yes'
        break

print(ans)

Submission status: Accepted

Solution code:
from __future__ import division, print_function
import bisect
import math
import heapq
import itertools
import sys
from collections import deque
from atexit import register
from collections import Counter
from functools import reduce
if sys.version_info[0] < 3:
    from io import BytesIO as stream
else:
    from io import StringIO as stream
 
 
if sys.version_info[0] < 3:
    class dict(dict):
        """dict() -> new empty dictionary"""
        def items(self):
            """D.items() -> a set-like object providing a view on D's items"""
            return dict.iteritems(self)
 
        def keys(self):
            """D.keys() -> a set-like object providing a view on D's keys"""
            return dict.iterkeys(self)
 
        def values(self):
            """D.values() -> an object providing a view on D's values"""
            return dict.itervalues(self)
 
    input = raw_input
    range = xrange
 
    filter = itertools.ifilter
    map = itertools.imap
    zip = itertools.izip
 
 
def sync_with_stdio(sync=True):
    """Set whether the standard Python streams are allowed to buffer their I/O.
 
    Args:
        sync (bool, optional): The new synchronization setting.
 
    """
    global input, flush
 
    if sync:
        flush = sys.stdout.flush
    else:
        sys.stdin = stream(sys.stdin.read())
        input = lambda: sys.stdin.readline().rstrip('\r\n')
 
        sys.stdout = stream()
        register(lambda: sys.__stdout__.write(sys.stdout.getvalue()))

def main():
    # sys.stdin  = open("input.txt")
    n=int(input())
    arr=[]
    for i in range(n):
        a=list(map(int,input().split()))
        arr.append(a[:])
    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]:
            print("Yes")
            return
    print("No")

if __name__ == '__main__':
    sync_with_stdio(False)
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

count = 0
for d in D:
  if d[0] == d[1]:
    count += 1
  else:
    count = 0
    
  if count == 3:
    print('Yes')
    break
else:
  print('No')

Submission status: Accepted

Solution code:
n=int(input())

Renzoku=0
icchiAri=0
for i in range(n):
  a,b=map(int,input().split())
  if a==b:
    Renzoku+=1
  else:
    Renzoku=0
    
  if Renzoku==3:
    icchiAri=1

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

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

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

Submission status: Accepted

Solution code:
from collections import defaultdict
from collections import deque
from collections import Counter
import math
import itertools

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n = readInt()

zoro = 0

data = [readInts() for i in range(n)]

for d1,d2 in data:
	if d1==d2:
		zoro+=1
	else:
		zoro = 0
	if zoro==3:
		break

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__=='__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())

ans = 'No'
cnt = 0
for _ in range(n):
   d1, d2 = map(int, input().split())
   if d1 == d2:
      cnt += 1
   elif cnt > 0 and d1 != d2:
      if cnt >= 3:
         ans = 'Yes'
      cnt = 0

if cnt >= 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())))
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())
d = [[0] for i in range(n)]
for i in range(n):
    d1, d2 = map(int, input().split())
    d[i].append(d1)
    d[i].append(d2)

seq = 0
ans = 0
for pair in d:
    if pair[1] == pair[2]:
        seq += 1
    else:
        seq = 0
    ans = max(ans, seq)
if ans >= 3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
cnt=0
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]):
        print("Yes")
        exit()
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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 > 2:
    print('Yes')
    break
else:
  print('No')