Problem:


Score : 200 points

Problem Statement

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

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

Constraints

3 \leq N \leq 100

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

All values in input are integers.

Input

Input is given from Standard Input in the following format:

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

Output

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

Sample Input 1

5
1 2
6 6
4 4
3 3
3 2

Sample Output 1

Yes

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

Sample Input 2

5
1 1
2 2
3 4
5 5
6 6

Sample Output 2

No

Sample Input 3

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

Sample Output 3

Yes



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


Sample output:
Yes

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
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())

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
	else:
		cnt=0

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

Submission status: Accepted

Solution code:
n=int(input())
d1=[]
d2=[]
f=0
for i in range(n):
    x,y=map(int, input().split())
    d1.append(x)
    d2.append(y)
for i in range(2,n):
    if d1[i]==d2[i] and d1[i-1]==d2[i-1] and d1[i-2]==d2[i-2] :
        f=1
if f==1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
import sys
import math
from functools import cmp_to_key

sys.setrecursionlimit(10 ** 6)

mod = 1000000007
inf = int(1e18)


def main():
    n = int(input())
    a = list([tuple(map(int, input().split())) for i in range(n)])
    a = list(map(lambda x: x[0] == x[1], a))
    for i in range(n-2):
        if a[i] and a[i+1] and a[i+2]:
            print("Yes")
            return
    print("No")
main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def resolve():
    N = int(input())
    zolo = 0
    for i in range(N):
        D1, D2 = map(int, input().split())
        if D1 == D2:
            zolo += 1
            if zolo == 3:
                print("Yes")
                return
        else:
            zolo = 0
    print("No")

resolve()

Submission status: Accepted

Solution code:
from sys import setrecursionlimit
from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush
from time import time
setrecursionlimit(10**9)
mod=10**9+7
inf=10**18

n=int(input())
zorocnt=0
maxcnt=0
for i in range(n):
    d1,d2=[int(x) for x in input().split()]
    if d1==d2:
        zorocnt+=1
    else:
        zorocnt=0
    maxcnt=max(maxcnt,zorocnt)

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

Submission status: Accepted

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

answer = 'No'

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

print(answer)

Submission status: Accepted

Solution code:
import sys

readline = sys.stdin.readline

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
  N = int(input())
  count = 0
  for _ in range(N):
    D = [int(x) for x in input().split(" ")]
    if D[0] == D[1]:
      count += 1
    else:
      count = 0
    if count >= 3:
      break
  print("Yes" if count >= 3 else "No")

if __name__ == "__main__":
  resolve()

Submission status: Accepted

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

Submission status: Accepted

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

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    D = [il() for _ in range(N)]

    for i in range(N - 2):
        for j in range(i, i + 3):
            if D[j][0] != D[j][1]: break
        else:
            print('Yes')
            exit()
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    DE = [list(map(int, input().split())) for _ in range(N)]
    for i in range(N - 3 + 1):
        if DE[i][0] == DE[i][1] and DE[i+1][0] == DE[i+1][1] and DE[i+2][0] == DE[i+2][1]:
            return "Yes"
    return "No"

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

Submission status: Accepted

Solution code:
N = int(input())

count = 0
flag = 0
for i in range(N):
    D = list(map(int, input().split()))
    if D[0] == D[1]:
        count += 1
    else:
        count = 0
    if count == 3:
        flag = 1

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

Submission status: Accepted

Solution code:
inpl = lambda: list(map(int,input().split()))
N = int(input())
s = 0
result = False
for _ in range(N):
    a, b = inpl()
    if a == b:
        s += 1
        if s >= 3:
            result = True
    else:
        s = 0
if result:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n=int(input())
arr=[]
for i in range(n):
	arr.append(list(map(int,input().split())))
flag=0
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]):
		flag=1
		print("Yes")
		break
if(flag==0):
	print("No")

Submission status: Accepted

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N = int(input())
D = []
c = 0
for i in range(N):
  D.append([int(i) for i in input().split()])
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, *D = map(int, open(0).read().split())

D = [(d1, d2) for d1, d2 in zip(*[iter(D)] * 2)]

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

Submission status: Accepted

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

    max_zoro = 0
    current_zoro = 0

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

        if D1 == D2:
            current_zoro += 1
        else:
            current_zoro = 0
        max_zoro = max(max_zoro, current_zoro)

    if 3 <= max_zoro:
        print("Yes")
    else:
        print("No")


main()

Submission status: Accepted

Solution code:
n=int(input())
a=[[int(i) for i in input().split()] for _ in range(n)]
c=0
for x in a:
     if x[0]==x[1]:
          c+=1
          if c>=3:print("Yes");exit()
     else:c=0
print("No")

Submission status: Accepted

Solution code:
n = int(input())

zorome_max = 0
zorome_now = 0
for i in range(n):
  d1, d2 = map(int, input().split())
  if d1 == d2:
    zorome_now += 1
  else:
    zorome_now = 0
  zorome_max = max(zorome_max, zorome_now)

print("Yes" if zorome_max >= 3 else "No")

Submission status: Accepted

Solution code:
# import sys
# input = sys.stdin.readline

def mp(): return map(int, input().split())
def lmp(): return list(map(int, input().split()))

n = int(input())
cnt = 0
for i in range(n):
    b,c = mp()
    if b==c:
        cnt += 1
        if cnt == 3:
            print("Yes")
            exit()
    else:
        cnt = 0
print("No")

Submission status: Accepted

Solution code:
N = int(input())

count = 0
no = True

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

if no:
  print("No")

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

now = 0

ans = "No"

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

print(ans)

Submission status: Accepted

Solution code:

import sys
import bisect as bi
import math
from collections import defaultdict as dd
import heapq
import itertools
##import operator
input=sys.stdin.readline
import random
##sys.setrecursionlimit(10**6)
##fo=open("output1.txt","w")
##fi=open("input1.txt","w")
mod=10**9+7
def cin():
    return map(int,sin().split())
def ain():            
    return list(map(int,sin().split()))
def sin():
    return input()
def inin():
    return int(input())

    
for _ in range(1):
    n=inin();cont=0;f=0
    for i in range(n):
        a,b=cin()
        if(a==b):
            cont+=1
        else:
            cont=0
        if(cont==3):
            f=1
    if(f):print("Yes")
    else:print("No")
    

    
    
        
        
      
    

##def msb(n):n|=n>>1;n|=n>>2;n|=n>>4;n|=n>>8;n|=n>>16;n|=n>>32;n|=n>>64;return n-(n>>1) #2 ki power
##def pref(a,n,f):             
##    pre=[0]*n
##    if(f==0):         ##from beginning
##        pre[0]=a[0]
##        for i in range(1,n):
##            pre[i]=a[i]+pre[i-1]
##    else:              ##from end
##        pre[-1]=a[-1]
##        for i in range(n-2,-1,-1):
##            pre[i]=pre[i+1]+a[i]
##    return pre
##maxint=10**24 
##def kadane(a,size): 
##    max_so_far = -maxint - 1
##    max_ending_here = 0
##       
##    for i in range(0, size): 
##        max_ending_here = max_ending_here + a[i] 
##        if (max_so_far < max_ending_here): 
##            max_so_far = max_ending_here 
##  
##        if max_ending_here < 0: 
##            max_ending_here = 0   
##    return max_so_far

Submission status: Accepted

Solution code:
i = int(input())
renzoku_double_count = 0
r = "No"
for i in range(i):
  inp = input().split(" ")
  dice0= int(inp[0])
  dice1= int(inp[1])
  if dice0 == dice1:
    renzoku_double_count += 1
  else:
    renzoku_double_count = 0
  if renzoku_double_count == 3:
    r  = "Yes"
    break
print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
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()
print("No")

Submission status: Accepted

Solution code:
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N = getN()
que = [getList() for i in range(N)]

cnt = 0
ans = 0

for a, b in que:
    if a == b:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0

ans = max(ans, cnt)

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

Submission status: Accepted

Solution code:
n = int(input())

flag = 0
count = 0
for i in range(n):
  sai = input().split(" ")
  
  if int(sai[0]) == int(sai[1]):
    count += 1
  else:
    count = 0
  
  if count == 3:
    flag = 1

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

#l = list(map(int, input().split()))
#import numpy as np
#arr = np.array([int(i) for i in input().split()])
'''
a,b=[],[]
for i in range(n):
    A, B = map(int, input().split())
    a.append(A)   
    b.append(B)'''

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

now=d[0][0]
for i in range(n-2):
    if d[i][1]==d[i][0] and d[i+1][1]==d[1+i][0] and d[i+2][1]==d[2+i][0]:
        print("Yes")
        sys.exit()
print("No")

Submission status: Accepted

Solution code:
N = int(input())
count = 0
for _ 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())
count = 0

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

print("No")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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:
        break

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
d=[[0] *2 for i in range(n)]
cnt=0
c=0

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

Submission status: Accepted

Solution code:
N = int(input())
a = []
for i in range(N):
    x,y = map(int,input().split())
    a.append((x,y))
ans = "No"
for i in range(N-2):
    if a[i][0] == a[i][1] and a[i+1][0] == a[i+1][1] and a[i+2][0] == a[i+2][1]:
        ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
zoro_flag = "000"
ans = False
for i in range(n):
    zoro_flag = zoro_flag[1:]
    d1, d2 = input().split()
    if d1 == d2:
        zoro_flag += "1"
        if zoro_flag == "111":
            ans = True
    else:
        zoro_flag += "0"
print("Yes") if ans else print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

count = 0
flag = False
for i in range(N):
    D = list(map(int, input().split()))
    if (flag):
        if (D[0] == D[1]):
            count += 1
        else:
            flag = False
            count = 0
    else:
        if (D[0] == D[1]):
            flag = True
            count = 1
    if (count == 3):
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
n = int(input())

count = 0
judge = False
for i in range(n):
  d1, d2 = input().split()
  if d1 == d2:
    count += 1
  else:
    count = 0
  if count >=3:
    judge = True

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n = inn()
x = 0
for i in range(n):
    d,e = inm()
    if d==e:
        x += 1
        if x==3:
            print('Yes')
            exit()
    else:
        x = 0
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 = 'No'
count = 0
for _ in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        count += 1
    else:
        count = 0

    if count == 3:
        ans = 'Yes'

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
j = ''
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        j += 't'
    else:
        j += 'f'

print('Yes' if 'ttt' in j else 'No')

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

class ABC(object):

    def __init__(self):
        pass


    def main(self):
        n = int(input())
        dd = [[int(_) for _ in input().split()] for i in range(n)]

        cnt = 0
        for d1, d2 in dd:
            if d1 == d2:
                cnt += 1
            else:
                cnt = 0

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

        return


if __name__ == "__main__":
    obj = ABC()
    obj.main()
    sys.exit(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def li():
    return [int(x) for x in input().split()]


N = int(input())
D = [li() for _ in range(N)]

maxzoro = 0
zoro = 0

for i in range(len(D)):
    a, b = D[i][0], D[i][1]
    if a == b:
        zoro += 1
        maxzoro = max(maxzoro, zoro)
    else:
        zoro = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    count = 0
    for _ in range(n):
        a, b = map(int, input().split())
        if a == b:
            count +=1
            if count == 3:
                print('Yes')
                return
        else:
            count = 0
    else:
        print('No')

        
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
max_ans = 0
cont_flg = 0
for _ in range(N):
  D = list(map(int, input().split()))
  if D[0] == D[1]:
    ans += 1
    max_ans = max(max_ans, ans)
  if D[0] != D[1]:
    cont_flg = 1
    ans = 0
if max_ans >= 3:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
N = int(input())
z = 0
for n 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:
# 2020/09/19
# AtCoder Beginner Contest 179 - B

# Input
n = int(input())
ans = 'No'
cnt = 0

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

# Output
print(ans)

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

Submission status: Accepted

Solution code:
N = int(input())
flags = []
for _ in range(N):
    d1, d2 = map(int, input().split())
    flags.append(d1 == d2)
#print(flags)
for i in range(N - 2):
    if flags[i] and flags[i + 1] and flags[i + 2]:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
n = int(input())
li = [0]*n
for i in range(n):
    d1,d2 = map(int,input().split())
    if d1==d2:
        li[i] = 1
lii = [0]*n
lii[0]=li[0]
for i in range(n-1):
    if li[i+1]==1:
        lii[i+1]=lii[i]+li[i+1]
    else:
        lii[i+1]=0

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

Submission status: Accepted

Solution code:
n = int(input())

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

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

print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

n = int(input())

dice = []

for i in range(n):
    dice.append(list(map(int,input().split())))

c = 0

for i in range(n):
    if dice[i][0] == dice[i][1]:
        c += 1
    else:
        c = 0
    if c == 3:
        print('Yes')
        sys.exit()

print('No')

Submission status: Accepted

Solution code:
N = int(input())

count = 0

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

print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

zoro = 0
m = 0
for i in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        zoro += 1
        m = max(zoro, m)
    else:
        zoro = 0

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

Submission status: Accepted

Solution code:
n = int(input())
a = []
for i in range(n):
  d1,d2 = map(int,input().split())
  a.append((d1,d2))
ok = False
for i in range(n-2):
  x,y,z = a[i],a[i+1],a[i+2]
  if x[0]==x[1] and y[0]==y[1] and z[0]==z[1]:
    ok = True
    break
print("Yes" if ok else "No")

Submission status: Accepted

Solution code:
from sys import stdin

def main():

    input = stdin.readline

    N = int(input())

    count = 0
    flag = False
    for _ in range(N):
        d1,d2 = map(int,input().split())

        if d1 == d2:
            count += 1
        else:
            count = 0
        
        if count >= 3:
            flag = True



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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
renzoku = 0
for _ in range(N):
    D1,D2 = map(int,input().split( ))
    if D1 == D2:
        renzoku += 1
    else:
        renzoku = 0
    if renzoku == 3:
        ans += 1
if ans > 0:
    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 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(0)

print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

d = [list(map(int, input().split())) for i in range(n)]
count = 0
for i, j in d:
    if i==j:
        count += 1
    else:
        count = 0

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

Submission status: Accepted

Solution code:
s=int(input())
flag=0
z=0
for i in range(s):
    p= list(map(int, input().split()))
    if p[0]==p[1]:
        z+=1
        if z==3:
            flag=1
    else:
        z=0
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
xy=[]
n=int(input())
for i in range(n):
    x,y = map(int,input().split())
    xy.append([x,y])

renzoku=0
ans=0
for i in xy:
    if i[0]==i[1]:
        renzoku+=1
        if renzoku ==3:
            ans=1
            break
    else :
        renzoku=0
if ans==1:
    print("Yes")
else :
    print("No")