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: Wrong Answer

Solution code:
N = int(input())
ct = 0
for i in range(N):
    s,g = map(int,input().split())
    if s == g:
        ct += 1
    else:
        ct = 0
    if ct == 3:
        print("yes")
        break
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
x = [list(map(int,input().split())) for i in range(n)]

x=np.array(x).flatten()
count=0
tmp=0
for i in x:
    if count==2:
        print("Yes")
        break
        
    elif tmp==i:
        count+=1
    else:
        tmp=i
        count=0
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
x = [0] * N
y = [0] * N
for i in range(N):
    x[i], y[i] = map(int, input().split())

ans=0    
for i in range(N):
    if x[i]==y[i]:
        ans+=1

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

Submission status: Wrong Answer

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    ans_list = []
    for i in range(n):
        a, b = i_map()
        if a == b:
            ans_list.append(1)
        else:
            ans_list.append(0)

    for i in range(n-2):
        if ans_list[i] == ans_list[i+1] == ans_list[i+2]:
            print('Yes')
            exit()

    print('No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
count=0
lst=[]
for i in range(N):
    x,y=map(int,input().split())
    # l=[]
    # l.append(x)
    # l.append(y)
    # lst.append(l)
    if x==y:
        count+=1
    if x!=y:
        break
if count==3:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
N = int(input())

cnt = 0
judge = False

for _ in range(N):
    if cnt == 3:
        judge = True

    D1, D2 = map(int, input().split())
    if D1 == D2:
        cnt += 1
    else:
        cnt = 0


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

Submission status: Wrong Answer

Solution code:
n = int(input())
li = [list(map(int,input().split())) for _ in range(n)]
c = 0
ans = 0
for a,b in li:
    if a==b:
        c+=1
        ans = max(c,ans)
    else:
        ans = max(c,ans)
        print(ans)
        c=0
if ans >= 3:print('Yes')
else:print('No')

Submission status: Wrong Answer

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

    count = 0
    answer = 'No'
    for i in range(n):
        d = list(map(int, input().split()))
        if d[0] == d[1]:
            count += 1
        if count >= 3:
            answer = 'Yes'

    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    D = [LI() for _ in range(N)]

    ans = 'No'
    for i in range(N - 3):
        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)

if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

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

for i in range(N-3):
    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: Wrong Answer

Solution code:
n = int(input())
x = 0

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

Submission status: Wrong Answer

Solution code:
n = int(input())
df_de = [list(map(int, input().split())) for _ in range(n)]
ans = 0
cand = []
for d1, d2 in df_de:
    if d1 == d2:
        ans += 1
    else:
        cand.append(ans)
        ans = 0
print("Yes" if len([i for i in cand if i >= 3]) else "No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

n=int(si())
t=0
while n:
  n-=1
  a,b=[int(e) for e in si().split()]
  if a==b:
    t+=1
  else:
    t=0
if t>=3:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import io,sys
def main(): 
    n = int(input())
    D = []
    for _ in range(n):
        a,b = map(int,input().split())
        D.append(a-b)
    
    for i in range(n-3):
        if D[i]==0 and D[i+1]==0 and D[i+2]==0:
            print("Yes")
            sys.exit()
    
    print("No")
main()

Submission status: Wrong Answer

Solution code:
iterate = int(input())
cnt = 0
for i in range(iterate):
  dice = list(map(lambda x: int(x), input().split()))
  if dice[0]==dice[1]:
    cnt += 1
  if dice[0]!=dice[1]: cnt=0
  if cnt==3: break
    
if cnt!=0: print("Yes")
else: print("No")

Submission status: Wrong Answer

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

ans=0
for k in d:
    if ans >= 3:
        print("Yes")
        raise SystemExit(0)
    if k[0] == k[1]:
        ans+=1
    else:
        ans = 0
print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [[int(i) for i in input().split()] for j in range(n)]
for i in range(n-3):
    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]:
        print("Yes")
        break
else:
    print("No")

Submission status: Wrong Answer

Solution code:
n = int(input())

cnt = 0

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

    if cnt >= 3:
        print('Yes')
        exit()
    if a == b:
        cnt += 1

    else:
        cnt = 0

print('No')

Submission status: Wrong Answer

Solution code:
from math import *

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def main():
    n = cino()
    l = []
    for i in range(n):
        a,b = cin()
        l.append([a,b])
    check = True
    for i in range(n-3):
        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")
            check = False
            break
    if check:
        print("No")
        

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

flg = False
for i in range(N*2-2):
    if D[i] == D[i+1] == D[i+2]:
        flg = True
        break

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

Submission status: Wrong Answer

Solution code:
#: Author - Soumya Saurav
import sys,io,os,time
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect,math,heapq
alphabet = "abcdefghijklmnopqrstuvwxyz"

input = sys.stdin.readline

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

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








'''
# Wrap solution for more recursion depth
#submit as python3
import collections,sys,threading
sys.setrecursionlimit(10**9)
threading.stack_size(10**8)



threading.Thread(target=solve).start()
'''

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    count = 0
    answer = 'No'
    for i in range(n):
        d = list(map(int, input().split()))
        if d[0] == d[1]:
            count += 1
        if count >= 3:
            answer = 'Yes'
            break

    print(answer)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
n = int(input())
L=[]
for i in range(n):
    a, b = map(int,input().split())
    if a==b:
        L.append(1)
    else:
        L.append(0)
flg=False
for i in range(n-3):
    if L[i] and L[i+1] and L[i+2]:
        flg=True
        break

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

Submission status: Wrong Answer

Solution code:
from sys import exit
N = int(input())

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

print("No")

Submission status: Wrong Answer

Solution code:
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
# from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var): sys.stdout.write(' '.join(map(str, var)) + '\n')
def out(var): sys.stdout.write(str(var) + '\n')
from decimal import Decimal
# from fractions import Fraction
# sys.setrecursionlimit(100000)
mod = int(1e9) + 7
INF=float('inf')

ans=0
cnt=0
for i in range(int(data())):
    d1,d2=mdata()
    if d1==d2:
        cnt+=1
    else:
        ans = max(ans, cnt)
        cnt=0

if ans>2:
    out("Yes")
else:
    out("No")

Submission status: Wrong Answer

Solution code:
n = int(input())
l = []
for i in range(n):
    x,y = map(int,input().split())
    l.append((x,y))
for i in range(n-3):
    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: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
D=list()
for i in range(N):
    tmp=list(map(int,input().split()))
    D.append(tmp[0]==tmp[1])
for i in range(N-3):
    if D[i]==D[i+1]==D[i+2]==True:
        print("Yes")
        break
else:
    print("No")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from math import gcd
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gcd
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().rstrip().split()
def S(): return sys.stdin.readline().rstrip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]

mod=10**9+7

n=I()
flg=[0]*n
for i in range(n):
    d,e=LI()
    if d==e:
        flg[i]=1

for j in range(n-2):
    if flg[j]==flg[j+1]==flg[j+2]:
        print("Yes")
        exit()

print("No")

Submission status: Wrong Answer

Solution code:
def solve(n, d):
    n -= 2
    for i in range(n):
        for j in range(i + 1, n):
            if all(d[i + k][0] == d[i + k][1] for k in range(3)):
                return True
    return False


def main():
    n = int(input())
    d = [list(map(int, input().split())) for _ in range(n)]
    print("Yes" if solve(n, d) else "No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n=int(input())
from itertools import groupby as gb
l=[eval(input().replace(' ','==')) for i in range(n)]

var=[(a,len(list(b))) for a,b in gb(l)]
for a,b in var:
    if b>=3:print("Yes");exit()
print("No")

Submission status: Wrong Answer

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

ans=0
for k in d:
    if k[0] == k[1]:
        ans+=1
print("YNeos"[ans<3::2])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
t = int(input())

best = 0
cur = 0

for i in range(t):
  a,b = map(int,input().split())
  if a == b:
    cur += 1
  else:
    best = max(best,cur)
    cur = 0
print("Yes" if best >= 3 else "No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
d = [list(map(int,input().split())) for i in range(n)]
ans = "No"
for i in range(n-3):
    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: Wrong Answer

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

flag = 0
for i in range(n-3):
  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]:
    flag = 1
  if flag:
    break

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

Submission status: Wrong Answer

Solution code:
def solve():
    n = int(input())
    rolls = [list(map(int,input().split())) for i in range(n)]
    for i in range(n-3):
        if rolls[i][0]==rolls[i][1] and rolls[i+1][0]==rolls[i+1][1] and rolls[i+2][0]==rolls[i+2][1]:
                return True

    return False

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import *

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

for i in range(N-3):
    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: Wrong Answer

Solution code:
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))

n=int(input())
d=[lnii() for i in range(n)]

cnt=0
for a,b in d:
  if cnt>=3:
    print('Yes')
    exit()
  if a==b:
    cnt+=1
  else:
    cnt=0

print('No')

Submission status: Wrong Answer

Solution code:
n = int(input())
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        print("Yes")
        exit()
print("No")

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    z = 0
    for i in range(N):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            z += 1
        else:
            z = 0
        if z >= 3:
            return True

    return False

# print("Yes" if main() else "No")
print(main())

Submission status: Time Limit Exceeded

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

s=0
while s<3:
  for k in range(N):
      if x[k]==y[k]:
         s=s+1
      else:
         s=0
 
if s>=3:
  print('Yes')
else:
  print('No')

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
f=[]
for x in l:
	f.append(x[0]==x[1])
l=f.copy()
i=0
while i<n:
	j=0
	while i+j<n and l[i+j]==l[i] and l[i]:
		j+=1 
	if j>2:
		print('Yes')
		break	
	i+=j
else:
	print('No')

Submission status: Accepted

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


for i in range(0, n):
  tmp = input()
  if tmp.split()[0] == tmp.split()[1]:
    count += 1
    if count == 3:
        break
  else:
    count = 0


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

Submission status: Accepted

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

for i in range(n):
  if d1[i] == d2[i]:
    cnt += 1
  else:
    cnt = 0
  if cnt >= 3:
    break

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

Submission status: Accepted

Solution code:
N = int(input())
D = []
for i in range(N):
    D.append(list(map(int,input().split())))
ans = 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]:
        ans = 1
if ans == 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
    else:
        cnt = 0
    if cnt >=3:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n=int(input())
cnt=0
for i in range(n):
    x,y=map(int,input().split())
    if x==y:
        cnt+=1
    else:
        cnt=0
    if cnt>=3:
        print("Yes")
        break
else:
    print("No")

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
D = inplt(n)

cnt = 0
ans = 'No'
for d1,d2 in D:
    if d1 == d2:
       cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        ans = 'Yes'

print(ans)

Submission status: Accepted

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

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

print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
Di = 0
Di1 = []
Di2 = []
nmDi = 0
if N >= 3 and N <= 100:
   for x in range(N):
      Di = input()
      Di1.append(Di[0])
      Di2.append(Di[-1])
   for x in range(N):
      if Di1[x] == Di2[x]:
         nmDi += 1
         if nmDi == 3:
            break
      elif Di1[x] != Di2[x] and nmDi > 0:
         nmDi = 0
   if nmDi >= 3:
      print("Yes")
   else:
      print("No")
else:
   print ("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

flag = False
cnt = 0

for i in range(len(D)):
    if D[i][0] == D[i][1]:
        cnt += 1
        if cnt == 3:
            flag = True
    else:
        cnt = 0

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

Submission status: Accepted

Solution code:

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

ok = False
for i in range(N - 2):
    ok |= ((X[i][0] == X[i][1]) and ((X[i + 1][0] == X[i + 1][1]))
           and (X[i + 2][0] == X[i + 2][1]))

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

Submission status: Accepted

Solution code:
n  = int(input())

ren = 0

for i in range(n):

     a, b = (int(x) for x in input().split())

     if a == b:
        ren += 1 

     elif ren >= 3:
         continue
    
     else: 
        ren = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
res = 0
cnt = 0
for i in range(N):
    D = input().split()
    if D[0] == D[1]:
        cnt += 1
        if cnt == 3:
            res += 1
            cnt = 0
    else:
        cnt = 0
if res > 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

for i in range(N):
  d = list(map(int,input().split()))
  D.append(d)
  
for i in range(N-2):
  if (D[i][0]==D[i][1]) and (D[i+1][0]==D[i+1][1]) and (D[i+2][0]==D[i+2][1]):
    print("Yes")
    break
else:
  print("No")

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    D = []
    zoro = 0
    ans = 0
    for _ in range(N):
        d1, d2 = LI()
        if d1 == d2:
            zoro += 1
            ans = max(ans, zoro)
        else:
            zoro = 0
    if ans >= 3:
        print("Yes")
    else:
        print("No")



main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
c = 0
m = 0
for x in range(n):
    a, b = input().split()
    if a==b:
        c += 1
    else:
        c = 0
    m = max(m, c)
if m >= 3:
    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

# [[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6]]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
flag = 0
ans = "No"

for i in range(N):
  tmp1, tmp2 = list(map(int, input().split()))
  if tmp1 - tmp2 == 0:
    flag += 1
  else:
    flag = 0
  if ans == "Yes" or flag >= 3:
    ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
count = 0
checker = 0
while count<n:
    d1,d2 = list(map(int, input().split()))
    count += 1
    if d1==d2:
        checker += 1
        if checker ==3:
            print("Yes")
            exit()
    else:
        checker = 0
print("No")

Submission status: Accepted

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