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())
cnt=0
ans="No"
for i in range(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:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

input = sys.stdin.readline


def Y():
    print("Yes")


def N():
    print("No")


def ST():
    return input().rstrip()


def I():
    return int(input())


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


def LI():
    return list(MI())


n = I()

c = 0
for _ in range(n):
    d1, d2 = MI()
    if d1 == d2:
        c += 1
        if c >= 3:
            Y()
            exit()
    else:
        c = 0

N()

Submission status: Accepted

Solution code:
N = int(input())
ans = False
count = 0
D1, D2 = 0, 0
for i in range(N):
    D1, D2 = list(map(int, input().split()))
    if D1 == D2:
        count += 1
        if count >= 3:
            ans = True
    else:
        count = 0

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

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(10000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D1 = []
D2 = []

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

for i in range(N-2):
  if D1[i:i+3] == D2[i:i+3]:
    print("Yes")
    exit()

print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    n = int(input())
    a = [list(map(int, input().split())) for _ in range(n)]
    print("Yes" if any(a[i][0] == a[i][1] and a[i+1][0] == a[i+1][1]
                       and a[i+2][0] == a[i+2][1] for i in range(0, n-2)) else "No")


def main():
    t = 1
    while t > 0:
        solve()
        t -= 1


main()

Submission status: Accepted

Solution code:
n=int(input())
dp=[False]*n
for i in range(n):
    d1,d2=map(int, input().split())
    if d1==d2:
        dp[i]=True
for j in range(n-2):
    if dp[j] and dp[j+1] and dp[j+2]:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
N = int(input().strip())
a=[0]*N
b=[0]*N
for i in range(N):
    a[i],b[i]= list(map(int, input().strip().split()))
f="No"
for i in range(N-2):
    if a[i]==b[i] and  a[i+1]==b[i+1] and   a[i+2]==b[i+2] :
        f="Yes"
        break
print(f)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

n = int(input())
dL = [list(map(int, input().split(" "))) for _ in range(n)]

cnt = 0
for d in dL:
    if d[0] == d[1]:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
import math
import collections
import itertools

def YesNo(Bool):
    if(Bool):
        print("Yes")
    else:
        print("No")
    return

def resolve():

    N=int(input())
    maxzoro=0
    zoro=0
    for i in range(N):
        D1,D2=map(int,input().split())
        if(D1==D2):
            zoro+=1
        else:
            zoro=0
        maxzoro=max(maxzoro,zoro)
    YesNo(maxzoro>=3)

resolve()

Submission status: Accepted

Solution code:
N = int(input())

D = []

for i in range(N):
   D.append(input().split())

def judge(L):
   if L[0] == L[1]:
      return True
   else:
      return False

for i in range(N - 2):
   if judge(D[i]) and judge(D[i+1]) and judge(D[i+2]):
      print('Yes')
      exit()

print('No')

Submission status: Accepted

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

def judge() :
  c = 0
  for a, b in D :
    if a == b : 
      c += 1
    else :
      c = 0
    if c >= 3 :
      return 'Yes'
  return 'No'
  
print(judge())

Submission status: Accepted

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-2):
    if l[i][0] == l[i][1] and l[i+1][0] == l[i+1][1] and l[i+2][0] == l[i+2][1]:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

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 a==b:
    cnt+=1
  if cnt>=3:
    print('Yes')
    exit()
  if a!=b:
    cnt=0

print('No')

Submission status: Accepted

Solution code:
import sys
import math
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()
n=int(input())
ans=0
flag=0
for i in range(n):
    d1,d2=get_ints()
    if d1==d2:
        ans=ans+1
        if ans>=3:
            flag=1
    else:
        ans=0
if flag==1:
    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())
    
check = 0
for i in range(N):
    if D1[i]==D2[i]:
        check += 1
    else:
        check = 0
        
    if check == 3:
        break
        
if check >= 3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
d = [LI() for _ 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')
        quit()
print('No')

Submission status: Accepted

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

def input(): return sys.stdin.readline()[:-1]
mod = 10**9 + 7
def readInt():return int(input())
def readIntList():return list(map(int,input().split()))
def readStringList():return list(input())
def readStringListWithSpace():return list(input().split())
def readString():return input()

from itertools import accumulate
 
def execute():
    n = readInt()
    count = 0
    res = False
    for _ in range(n):
        a,b = readIntList()
        if a == b :
            count += 1
        else:
            count = 0
        if count == 3:
            res = True
    if res:
        print("Yes")
    else:
        print("No")


    
 
if __name__ == "__main__":
    execute()

Submission status: Accepted

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:
      p=True
      break
  else:
    s=0
print("Yes" if p else "No")

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    D = [list(map(int, input().split())) for i in range(N)]
    cnt = 0
    for a, b in D:
        if a == b:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(SOLVE_PARAMS):
    pass


def main():
    N = int(input())
    ret = False
    count = 0
    for i in range(N):
        a, b = map(int, input().split())
        if a == b:
            count += 1
            if count == 3:
                ret = True
                break
        else:
            count = 0

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


# tests
T1 = """
5
1 2
6 6
4 4
3 3
3 2
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
Yes
"""

T2 = """
5
1 1
2 2
3 4
5 5
6 6
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
No
"""

T3 = """
6
1 1
2 2
3 3
4 4
5 5
6 6
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
Yes
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()

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

Submission status: Accepted

Solution code:
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
ans = 'No'
for i in range(N):
    if D[i][0] == D[i][1]:
        cnt += 1
    else:
        cnt = 0
    
    if cnt >= 3:
        ans = 'Yes'
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import numpy as np
N=int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())

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


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

Submission status: Accepted

Solution code:
n = int(input())

zoro = 0
ans = False

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

if ans == True:
	print('Yes')
	
else:
	print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    count = 0
    for i in range(n):
        x, y = map(int, input().split())
        if x == y:
            count += 1
        else:
            count = 0

        if count == 3:
            print('Yes')
            return
    print('No')
if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def f(L):
	for i in range(0,len(L)-2):
		if(L[i][0]==L[i][1] and L[i+1][0]==L[i+1][1] and L[i+2][0]==L[i+2][1]):
			return "Yes"
	return "No"

n=int(input())
L=[]
for i in range(0,n):
	x=input().split()
	L.append(x)
print(f(L))

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ans=0
f=0
for _ in range(int(input())):
    x,y=map(int,input().split())
    if x==y:
        ans+=1
    else:
        ans=0
    if ans>=3:
        f=1
        break
if f:
    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
		if cnt == 3:
			break
	else:
		cnt = 0
print('Yes' if cnt == 3 else '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")
        break
else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys


def std_in():
    return sys.stdin.readline().strip()


def get_ints():
    return map(int, sys.stdin.readline().strip().split())


def main():
    n = int(std_in())

    flag = 0
    for ni in range(n):
        d1, d2 = get_ints()
        if d1 == d2:
            flag += 1
        else:
            flag = 0
        if flag >= 3:
            print("Yes")
            break
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    d = [list(map(int, input().split())) for _ 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")
            break
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())

check = 0
ans = 0
for n in range(N):
    D1,D2 = map(int,input().split())
    if D1 == D2:
        check += 1
        ans = max(ans,check)
    else:
        check = 0
        ans = max(ans,check)
print('Yes' if ans >= 3 else 'No')

Submission status: Accepted

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

Submission status: Accepted

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

tmp = 0
for x,y in D:
    if x == y:
        tmp += 1
        if tmp == 3:
            print('Yes')
            break
    else:
        tmp = 0
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

count = 0

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

print('No')

Submission status: Accepted

Solution code:
n=int(input())
t=0
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]:
        t+=1
        break
if t==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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


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


if __name__ == '__main__':
    main(sys.stdin.readline, print)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
ans = []
for i in range(N):
    D1,D2 = map(int,input().split())
    if D1 == D2:
        ans.append('1')
    else:
        ans.append('0')
S = ''.join(ans)
if '111' in S:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
Sum = 0
flag = False
for i in range(N):
    a, b = map(int, input().split())
    if a == b:
        Sum += 1
    else:
        Sum = 0
    if Sum == 3:
        flag = True

if flag:
    print("Yes")

else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = []
for i in range(N):
    a,b = map(int,input().split())
    D.append([a,b])
for i in range(N-2):
    if D[i][0] == D[i][1]:
        if D[i+1][0] == D[i+1][1]:
            if D[i+2][0] == D[i+2][1]:
                print('Yes')
                exit()
print('No')

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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-2):
    if D[i]==D[i+1]==D[i+2]==True:
        print("Yes")
        break
else:
    print("No")

Submission status: Accepted

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

from collections import deque
from collections import Counter
import bisect
def main():
    N = I()
    cnt = 0
    for i in range(N):
        d_1, d_2 = MI()
        if d_1 == d_2:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            print('Yes')
            exit()
    print('No')
if __name__ == "__main__":
    main()

Submission status: Accepted

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

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
    else:
        cnt = 0
    if cnt == 3:
        ans = "Yes"

print(ans)

Submission status: Accepted

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

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  a and b>=3:print("Yes");exit()
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())
cnt=0
for _ in range(n):
    d=input().split()
    if d[0]==d[1]:
        cnt+=1
    else:
         cnt=0
    if cnt==3:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
count = 0

for i in range(N):
    d1, d2 = LI()
    if d1 == d2:
        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 = 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]:
        flag = 1
        break
if flag==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
n  = int(input(''))

cnt=0
result="No"
for i in range(n):
    d12 = input('').split()
    d1 = d12[0]
    d2 = d12[1]
    if d1 == d2:
        cnt+=1
        if cnt ==3:
            result = "Yes"
    else:
        cnt=0


print(result)

Submission status: Accepted

Solution code:
N = int(input())

count = 0
for _ in range(N):
    a, b = list(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())
c = 0
p = 0
for i in range(n):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        c += 1
    else:
        c = 0
    if c == 3:
        p = 1
        break
if p == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
x = ''.join(map(str, [len(set(input().split())) for _ in range(N)]))
if '111' in x:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n=int(input())

lis=[]
for i in range(n):
    d1,d2=map(int,input().split())
    if d1==d2:
        lis.append(1)
    else:
        lis.append(0)

c=0
for i in range(n-2):
    if sum(lis[i:i+3])==3:
        c+=1

if c!=0:
    print("Yes")
else:
    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())

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

res = 0

for i in  range(n):
    a = ab[i][0]
    b = ab[i][1]
    
    if a==b:
        res +=1
    else:
        res =0
    
    if res ==3:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
n=int(input())
s=[0]
for i in range(n):
    a,b=input().split()
    if a==b :
        s.append(s[-1]+1)
    else:
        s.append(0)

for i in s:
    if i>=3 :
        print('Yes')
        exit()

print('No')

Submission status: Accepted

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

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

ans = False
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 = True
        break

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

Submission status: Accepted

Solution code:
n=int(input())
l=[]
for i in range(n):
    lo=input().split()
    lop=[int(i) for i in lo]
    l.append(lop)
poss=0
for i in range(n-2):
    if(l[i][0]==l[i][1] and l[i+1][0]==l[i+1][1] and l[i+2][0]==l[i+2][1]):
        poss=1
        break
if(poss):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

flag = False

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]:
        flag = True

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