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())
data = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(1, n-1):
    if data[i][0] == data[i][1] and data[i-1][0] == data[i-1][1] and data[i+1][0] == data[i+1][1]:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
# coding:utf-8
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())

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

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

Submission status: Accepted

Solution code:
from sys import stdin

n=int(input())
count = 0

output = 'No'

for i in range(n):
  temp = stdin.readline().split()
  if temp[0] == temp[1]:
    if count == 2:
      output = 'Yes'
      break;
    elif count == 1:
      count = 2
    elif count == 0:
      count = 1
  else:
  	count = 0
    
print(output)

Submission status: Accepted

Solution code:
n=int(input())
count=0
maxs=0
for _ in range(n):
    d1,d2=map(int,input().split())
    if d1==d2:
        count+=1
    else:
        maxs=max(maxs,count)
        count=0

maxs=max(count,maxs)
if maxs>=3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for n in range(N):
  D1,D2=map(int,input().split())
  if D1==D2:
    zoro+=1
  else:
    zoro=0
  
  if zoro==3:
    print("Yes")
    exit()
    
print("No")

Submission status: Accepted

Solution code:
import sys
N =int(input())
D = []
for i in range(N):
  d_1,d_2 = map(int,input().split())
  D.append([d_1,d_2])
for x in range(N-2):
  if D[x][0]==D[x][1] and D[x+1][1]==D[x+1][0] and D[x+2][1]==D[x+2][0]:
    print("Yes")
    sys.exit()
print("No")

Submission status: Accepted

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


def solve():
    n = int(input())
    F = [0] * n
    S = [0] * n
    for i in range(n):
        a, b = it()
        F[i] = a
        S[i] = b
    
    cnt = 0
    for i in range(n):
        if F[i] == S[i]:
            cnt += 1
            if cnt == 3:
                return 'Yes'
        else:
            cnt = 0
    return 'No'


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

Submission status: Accepted

Solution code:
n = int(input())
d = [[] for _ in range(n)]
for i in range(n):
    d[i] = list(map(int, input().split()))
counter = 0
for i in d:
    if i[0] == i[1]:
        if counter == 2:
            print("Yes")
            exit()
        else:
            counter += 1
    else:
        counter = 0
print("No")

Submission status: Accepted

Solution code:
n = int(input())
d1 = []
d2 = []
for _ in range(n):
    a1,a2 = map(int,input().split())
    d1.append(a1)
    d2.append(a2)
count = 0
for i in range(n):
    if d1[i] == d2[i]:
        count += 1
    else:
        count = 0
    if count == 3:
        print("Yes")
        exit(0)
print("No")

Submission status: Accepted

Solution code:
import sys

def main():
    N = int(input())
    zoro = 0
    for i in range(N):
        Ds = [int(s) for s in sys.stdin.readline().split()]
        if(Ds[0] == Ds[1]):
            zoro += 1
            if(zoro > 2):
                print("Yes")
                return(0)
        else:
            zoro = 0
    print("No")

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    try:
        count = []
        result = 0
        T = int(input())
        for _ in range(T):
            x, y = map(int, input().split())
            count.append([x, y])

        for i in range(T-2):
            if count[i][0] == count[i][1] and count[i+1][0] == count[i+1][1] and count[i+2][0] == count[i+2][1]:
                print("Yes")
                exit(0)

        print("No")
    except Exception:
        pass

Submission status: Accepted

Solution code:
import sys
n = int(input())
ls = [list(map(int,input().split())) for _ in range(n)]
for i in range(n-2):
    if ls[i][0] == ls[i][1]:
        if ls[i+1][0] == ls[i+1][1]:
            if ls[i+2][0] == ls[i+2][1]:
                print("Yes")
                sys.exit()
print("No")

Submission status: Accepted

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

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:
s=int(input())
d = [list(map(int,input().split())) for _ in range(s)]

def p(val):
    print(val)

def calc(s,d):
    for i in range(s-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]:
            
            return 'Yes'
    
    return 'No'

        
p(calc(s,d))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
def judge():
    count = 0
    for _ in range(x):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            count += 1
        else:
            count = 0
        
        if count == 3:
            return True

    return False

x = int(input())

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

Submission status: Accepted

Solution code:
def judge():
    cnt = 0  # 今何連続でゾロ目が出ているか記録しておきます

    for _ in range(N):
        x, y = map(int, input().split())
        if x == y:
            # ゾロ目ストリークが1増えました
            cnt += 1
        else:
            # ゾロ目ストリークが切れました
            cnt = 0

        if cnt == 3:
            # 3連続になった瞬間、return True していいです
            return True

    # ダメでした
    return False

N = int(input())

if judge():
    # judge() で Trueが返ってくるとこっちに進みます
    print("Yes")
else:
    # Falseだとこっちです
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
D1, D2 = [], []
for i in range(N):
  li = list(map(int,input().split()))
  D1.append(li[0])
  D2.append(li[1])

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

Submission status: Accepted

Solution code:
N = int(input())
D = [tuple(map(int, input().split())) for _ in range(N)]
for i in range(N - 2):
    if all(d[0] == d[1] for d in D[i: i + 3]):
        print('Yes')
        exit()
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())

sums = 0
answer = False
for _ in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        sums += 1
    else:
        sums = 0

    if sums == 3:
        answer = True

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

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
n = I()
ans = 'No'
cnt = 0
for i in range(n):
    a, b = M()
    if a == b:
        cnt += 1
        if cnt == 3:
            ans = 'Yes'
            break
    else:
        cnt = 0
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = "No"
j = 0
for i in range(n):
  d,dd = map(str,input().split())
  if(d==dd):
    j += 1
  else:
    j=0
  if(j>=3):
    ans = "Yes"
print(ans)

Submission status: Accepted

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

cnt = 0

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

print('No')

Submission status: Accepted

Solution code:
n=int(input())
m=0
l=0
for i in range(n):
  A,B=map(int,input().split())
  if (A==B):
    m+=1
  else:
    m=0
  if (m==3):
    print("Yes")
    l=1
    break

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    N = int(readline())
    cnt = 0
    ans = -1
    for _ in range(N):
        x, y = map(int, readline().split())    
        if x == y:
            cnt += 1
            ans = max(ans, cnt)
        else:
            cnt = 0
    if ans >=3:
        print('Yes') 
    else:
        print('No')
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
#from collections import deque
#from functools import *
#from fractions import Fraction as f
from copy import *
from bisect import *	
#from heapq import *
from math import gcd
from itertools import permutations as prm,product
 
def eprint(*args):
    print(*args, file=sys.stderr)
zz=1
 
#sys.setrecursionlimit(10**6)
if zz:
	input=sys.stdin.readline
else:	
	sys.stdin=open('input.txt', 'r')
	sys.stdout=open('all.txt','w')
di=[[-1,0],[1,0],[0,1],[0,-1]]
def inc(d,c,x=1):
	d[c]=d[c]+x if c in d else x
def bo(i):
	return ord(i)-ord('A')	
def li():
	return [int(xx) for xx in input().split()]
def fli():
	return [float(x) for x in input().split()]	
def comp(a,b):
	if(a>b):
		return 2
	return 2 if a==b else 0		
def gi():	
	return [xx for xx in input().split()]
def fi():
	return int(input())
def pro(a): 
	return reduce(lambda a,b:a*b,a)		
def swap(a,i,j): 
	a[i],a[j]=a[j],a[i]	
def si():
	return list(input().rstrip())	
def mi():
	return 	map(int,input().split())			
def gh():
	sys.stdout.flush()
def isvalid(i,j):
	return 0<=i<n and 0<=j<m and a[i][j]!="."
def bo(i):
	return ord(i)-ord('a')	
def graph(n,m):
	for i in range(m):
		x,y=mi()
		a[x].append(y)
		a[y].append(x)

t=1
	

while t>0:
	t-=1
	n=fi()
	c=0
	for i in range(n):
		x,y=mi()
		if x==y:
			c+=1
		else:
			c=0
		if c==3:
			print("Yes")
			exit(0)
	print("No")

Submission status: Accepted

Solution code:
number = int(input())
list = []
count = 0
num = 0

for i in range(number):
  x, y = input().split()
  list.append(x)
  list.append(y)
 

for num in range(0,len(list)-1,2):
  if list[num] == list[num+1]:
    count += 1
    if count == 3:
      break
  else:
    count = 0 

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

N = int(input())

p = 0

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

    if A == B:
        p += 1
    else:
        p = 0

    if p == 3:
        print("Yes")
        sys.exit()

print("No")

Submission status: Accepted

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

# 時々使う
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

# 再帰の制限設定
sys.setrecursionlimit(10000000)


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


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


def lcm(x, y): return (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())
ans = 0
t = 0
for i in range(n):
  a,b = map(int,input().split())
  if a ==b:
    t+=1
  else:
    t=0
  ans = max(ans,t)
print("Yes" if ans>=3 else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import time
startTimeProblem=time.time()

import fileinput, sys, itertools, functools
from math import *
from bisect import *
from heapq import *
from collections import *

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

class InputHelper:
    def __init__(self):
        self.myinput = fileinput.input()

    def isLocal(self):
        return not fileinput.isstdin()

    def int(self):
        return int(self.myinput.readline().rstrip())

    def ints(self):
        return [int(_) for _ in self.myinput.readline().rstrip().split()]

    def str(self):
        return self.myinput.readline().rstrip()

    def strs(self):
        return [_ for _ in self.myinput.readline().rstrip().split()]

class OutputHelper:
    def int(self, a):
        print(a)    

    def ints(self, a):  
        print(" ".join([str(_) for _ in a]))
    
    def intsNL(self, a):
        for _ in a:
            print(_)
    
    def str(self, s):
        print(s)

    def strs(self, s):
        print(" ".join([_ for _ in s]))

    def strsNL(self, s):
        for st in s:
            print(st)

class ListNode:
    def __init__(self, val):
        self.val = val
        self.next = None
        self.prev = None

In = InputHelper()
Out = OutputHelper()

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

N = In.int()

ct = 0
ok = False

for _ in range(N):
    d0, d1 = In.ints()

    if d0==d1:
        ct+=1
        if ct==3:
            ok=True
            break
    else:
        ct=0

if ok:
    Out.str("Yes")
else:
    Out.str("No")

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

if len(sys.argv)>2 and sys.argv[2]=="TIMEIT":
    fin = (time.time()-startTimeProblem)*1000
    print("{:.2f}".format(fin) + "ms")

Submission status: Accepted

Solution code:
#from collections import deque
#from heapq import heapify, heappop, heappush
#from bisect import insort
#from math import gcd
#mod = 10**9 + 7
N = int(input())
#N, K = map(int, input().split())
#A = list(map(int, input().split()))
flag1 = False
flag2 = False
flag3 = False
c, d = map(int, input().split())
if c == d:
	flag1 = True
c, d = map(int, input().split())
if c == d:
	flag2 = True
c, d = map(int, input().split())
if c == d:
	flag3 = True

k = 3
while k < N:
	if flag1 and flag2 and flag3:
		break
	k += 1
	c, d = map(int, input().split())
	flag1 = flag2
	flag2 = flag3
	if c == d:
		flag3 = True
	else:
		flag3 = False
		

#ans = 0
#print(ans)
#print('Yes')
if flag1 and flag2 and flag3:
	print('Yes')
else:
	print('No')

Submission status: Accepted

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    cnt=0
    flag=0
    for _ in range(N):
        a,b=MI()
        if a==b:
            cnt+=1
        else:
            cnt=0
            
        if cnt==3:
            flag=1
            break
        
    if flag==1:
        print("Yes")
    else:
        print("No")

main()

Submission status: Accepted

Solution code:
n = int(input())

D = [] * n

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

ans = 'No'

for i in range(0, n-2):
    if D[i][0] == D[i][1] and D[i+1][0] == D[i+1][1] and D[i+2][0] == D[i+2][1]:
        ans = 'Yes'
        break

print(ans)

Submission status: Accepted

Solution code:

n = int(input())
cnt = 0
d1, d2 = [0] * n, [0] * n
for i in range(n):
    d1[i], d2[i] = map(int, input().split())

for i in range(n):
    if d1[i] == d2[i]:
        cnt += 1
    else:
        cnt = 0
    
    if cnt == 3:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = []
z = 0

for i in range(n):
  d1, d2 = map(int, input().split())
  z = z+1 if d1==d2 else 0
  d.append(z)

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

Submission status: Accepted

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

counter = 0
for d1, d2 in C:
    if d1 == d2:
        counter += 1
    else:
        counter = 0

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

Submission status: Accepted

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

ans = "No"
for i in range(n - 2):
    bl = True
    for j in range(3):
        bl = bl and (d[i+j][0] == d[i+j][1])

    if bl:
        ans = "Yes"

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
D = [[int(i) for i in input().split()] for j in range(N)]
count = 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]):
    count += 1
if(count >= 1):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n = int(input())

cnt = 0
l = [list(map(int,input().split())) for i in range(n)]
for i in range(n):
    d1,d2 = l[i][0],l[i][1]
    if(d1==d2):
        cnt += 1
    else:
        cnt = 0
    if(cnt == 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)]
ans = 0
flg = False
for i in d:
    if i[0] == i[1]:
        ans += 1
    else:
        ans = 0
    if ans >= 3:
        flg = True
if flg:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    N = int(input())
    D = [input() for i in range(N)]    
    
    for i in range(2,N):
        if (D[i][0] == D[i][-1]) \
            and (D[i-1][0] == D[i-1][-1]) \
            and (D[i-2][0] == D[i-2][-1]):
                print('Yes')
                break
        if i == N-1:
            print('No')

Submission status: Accepted

Solution code:
import math
t = 1
for tc in range(t):
    n = int(input())
    arr =  []
    for i in range(n):
        lst = list(map(int, input().split()))
        # print(n1,n2)
        arr.append(lst)
        # print(arr)
    # print(arr)
    ans = False
    for i in range(n-2):
        if arr[i][0] == arr[i][1] and arr[i+1][0] == arr[i+1][1] and arr[i+2][0] == arr[i+2][1] :
            ans = True
            break
    if ans == True:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
N = int(input())
j = 0
z = 0
r = 'No'
for i in range(N):
    n, m = map(int, input().split())
    if n == m:
        j += 1
    else:
        j = 0
    if j == 3:
        r = 'Yes'
        break
print(r)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]
def zoro(items):
    return items[0] == items[1]
for a, b, c in zip(d[:], d[1:], d[2:]):
    if zoro(a) and zoro(b) and zoro(c):
        print('Yes')
        exit(0)
print('No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
f = 0
for k in range(N):
    A, B = map(int,input().split())
    if A == B:
        f += 1
        if f == 3:
            print("Yes")
            exit(0)
    else:
        f = 0
print("No")

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")
    break
else:
  print("No")

Submission status: Accepted

Solution code:
n=int(input())
lis=[]
count=0
high=0
for _ in range(n):
  lis.append(input().split())
lis.append([5,6])  
for i in range(n+1):
  if lis[i][0]==lis[i][1]:
    count+=1
  else:
    if count>=high:
      high=count
    count=0
    
if high>=3:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    n = II()
    d = LIR(n)
    i = 0
    for a, b in d:
        if a == b:
            i += 1
        else:
            i = 0
        if i == 3:
            print("Yes")
            return
    print("No")
    return


#main
if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
N = int(input())

cnt = 0
ans = 'No'

for i in range(0, N):
	d1, d2 = 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:
n = int(input())
c = 0
for _ in range(n):
    r = [int(e) for e in input().split(" ")]
    if(r[0] == r[1]):
        c += 1
    else:
        c = 0
    if(c == 3):
        print("Yes")
        break
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

lt = []
for _ in range(n):
    lt.append(tuple(map(int, input().split())))

for i in range(n-2):
    if len(set(lt[i])) == 1 and len(set(lt[i+1])) == 1 and len(set(lt[i+2])) == 1:
        print("Yes")
        exit(0)
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ds1 = []
ds2 = []
for _ in range(n):
    d1,d2 = list(map(int, input().split()))
    ds1.append(d1)
    ds2.append(d2)

matched = [d1 == d2 for d1,d2 in zip(ds1,ds2)]
cnt = 0
for m in matched:
    cnt = cnt+1 if m else 0
    if cnt == 3:
        break

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

Submission status: Accepted

Solution code:
n = int(input())
tmp = 0
import sys
for i in range(n):
    d = list(map(int,input().split()))
    if d[0] == d[1]:
        tmp += 1
        #check
        if tmp == 3:
            print('Yes')
            sys.exit()
    else:
        tmp = 0
print('No')

Submission status: Accepted

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

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

ans = "No"
for i in range(N-2):
    ok = (AB[i][0] == AB[i][1] and AB[i+1][0] == AB[i+1][1] and AB[i+2][0] == AB[i+2][1])
    if ok:
        ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
mx = -1
ps = []
for _ in range(n):
    d1,d2 = map(int, input().split())
    ps.append((d1,d2))
ps.append((1,2))
for d1,d2 in ps:
    if d1 != d2:
        mx = max(mx,cnt)
        cnt = 0
    else:
        cnt += 1

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

Submission status: Accepted

Solution code:
c=0
for _ in range(int(input())):
    x,y = map(int,input().split())

    if x==y:
        c+=1
    else:
        c=0
    if c==3:
        c=-1
        print('Yes')
        break
if c!=-1:
    print('No')

Submission status: Accepted

Solution code:
def main():
    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")
            return
    print("No")
    return

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
cnt = 0
zorome = 0
num = int(input())

while cnt < num:
  mass = input().split()
  
  if(mass[0] == mass[1]):
    zorome += 1
    
    if(zorome >= 3):
      break
  else:
    zorome = 0
  
  cnt += 1

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