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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

d = []

for _ in range(n):
    d1, d2 = map(int, input().split())
    
    d.append((d1, d2))
    
# # print(d)


for i in range(n-3+1):
    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:
n = int(input())
ans = 0
flg = False
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        ans += 1
        if ans >= 3:
            flg = True
    else:
        ans = 0
if flg:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n=int(input())
count=0
ans='No'
for i in range(n):
    a=input()
    a=a.split(' ')
    if a[0] == a[1]:
        count+=1
        if count==3:
            ans='Yes'
    else:
        count=0
    
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
count = 0
end = 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')
        end = 1
        break
if end == 0:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())

sum = 0

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

print("No")

Submission status: Accepted

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

Submission status: Accepted

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

from typing import *

YES = 'Yes'
NO = 'No'

# def solve(n: int, dlist: List[List[int]]) -> bool:
def solve(n, dlist):
    flag=False
    c = 0
    for d in dlist:
        if d[0]==d[1]:
            c = c+1
        else:
            if c>=3:
                return True
            c=0

    return c>=3

def main():
    n = int(input())
    dlist = []
    for i in range(n):
        dlist.append(list(map(int, input().split())))
    print(YES if solve(n, dlist) else NO)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# input here
_INPUT = """\
6
1 1
2 2
3 3
4 4
5 5
6 6
"""
"""
K = int(input())
H, W, K = map(int, input().split())
a = list(map(int, input().split()))
xy = [list(map(int, input().split())) for i in range(N)]
p = tuple(map(int,input().split()))
"""
def main():
    N = int(input())
    D = [list(map(int, input().split())) for i in range(N)]

    count = 0
    for i in range(N):
        if count >= 3:
            break

        if D[i][0] == D[i][1]:
            count += 1
        else:
            count = 0

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

            
if __name__ == '__main__':
    import io
    import sys
    import math
    import itertools
    from collections import deque

    # sys.stdin = io.StringIO(_INPUT)
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ret = False
cnt = 0
for i in range(n):
    d = list(map(int,input().split()))
    if d[0] == d[1]:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        ret = True

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

Submission status: Accepted

Solution code:
import sys

N = int(input())

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

print('No')

Submission status: Accepted

Solution code:
import sys
import itertools


def resolve(in_):
    N = int(next(in_))
    D = [tuple(map(int, line.split())) for line in itertools.islice(in_, N)]

    i = 0
    for a, b in D:
        if a == b:
            i += 1
            if i >= 3:
                return True
        else:
            i = 0

    return False



def main():
    answer = resolve(sys.stdin)
    print('Yes' if answer else 'No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

flag = 0
count = 0

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

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

    if count == 3:
        flag = 1

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

Submission status: Accepted

Solution code:
N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
flag = 0
for i in range(0,N-2):
    if x[i]==y[i]:
        if x[i+1]==y[i+1]:
            if x[i+2]==y[i+2]:
                flag = 1
                print("Yes")
                break
if flag == 0:
    print("No")

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(250000)

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

    numbers =[]
    for i in range(n):
        numbers.append(input().split())

    count = 0
    zoronum =-1
    exists = False
    for obj in numbers:
        if obj[0] == obj[1]:
            if count == 0:
                count = 1
            else:
                count = count + 1
            if count >= 3:
                exists = True
        else:
            count = 0

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

main()

Submission status: Accepted

Solution code:
N=int(input())
count=0
for n in range(N):
    D1,D2=map(int,input().split())
    if D1==D2:
        count+=1
    else:
        count=0
    if count==3:
        break

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

Submission status: Accepted

Solution code:
n = int(input())
flag = 0
ans = 0
for i in range(n):
    n1, n2 = map(int, input().split())
    if n1 == n2:
        flag += 1
        ans = max(ans, flag)
    else:
        flag = 0
if ans >= 3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())

arr_d = []
for i in range(1, n+1):
  a = [int(x) for x in input().split()]
  arr_d.append(a)

cnt = 0
ans = 'No'
for i in range(len(arr_d)):
  if arr_d[i][0] == arr_d[i][1]:
    cnt += 1
    if cnt >= 3:
      ans = 'Yes'
      break
  else:
    cnt = 0

print(ans)

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

print("No")

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(N):
    D_1, D_2 = map(int, input().split())
    if(D_1 == D_2):
        count += 1
        if(count >= 3):
            break
        else:
            pass
    else:
        count = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D_list = list(tuple(map(int, input().split())) for _ in range(N))
i = 0
for d1, d2 in D_list:
    if d1 == d2:
        i += 1
    else:
        i = 0
    if i > 2:
        break
    
print('Yes' if i > 2 else 'No')

Submission status: Accepted

Solution code:
N=int(input())
f=0
for _ in range(N):
  D=input().split()
  if D[0] == D[1]: f+=1
  else: f=0
  if f == 3:
    print('Yes')
    exit()
print('No')

Submission status: Accepted

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

Submission status: Accepted

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

seq = 0
for i in range(len(D)-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())
zoro = ""
for i in range(N):
    D = input().split()
    if D[0] == D[1]:
        zoro += "Y"
    else:
        zoro += "N"

if "YYY" in zoro:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    num = int(input())
    lst = []
    for i in range(num):
        lst.append(list(map(int, input().split())))

    count = 0
    flg = False
    for j in lst:
        if j[0] == j[1]:
            count += 1
            if count == 3:
                flg = True
                break
        else:
            count = 0

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
data = [0]*N
count = 0
for i in range(N):
  data[i] = list(map(int,input().split()))
  if data[i][0] == data[i][1]:
    count = count + 1
    if count >= 3:
      print("Yes")
      break
    else:
      None
  else:
    count = 0

if count < 3:
  print("No")

Submission status: Accepted

Solution code:
n= int(input())

A=[]
B = []
for i in range(n):
  a,b = map(int,input().split())
  A.append(a)
  B.append(b)
count = 0  
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]:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
import math


def main():
    n = int(input())
    # n, k = map(int, input().split())
    # h = list(map(int, input().split()))
    # s = input()
    # h = [int(input()) for _ in rane(n)]

    d = []
    for _ in range(n):
        j, k = map(int, input().split())
        d.append([j, k])

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

    print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

n = int(input())
cnt = 0
st = "No"
for _ in range(n):
    l1,l2 = map(int,input().split())
    if l1 == l2 :
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        st = "Yes"
        
print(st)

Submission status: Accepted

Solution code:
N = int(input())
count = 0
max = 0
for _ in range(N):
  x, y = map(int, input().split())
  if x == y:
    count +=1
  else:
    count = 0
  
  if count > max:
    max = count

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

Submission status: Accepted

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

count = 0
p = [0]

for x in range(n):
    if deme[x][0] == deme[x][1]:
        count += 1
        p.append(count)

    else:
        count = 0


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
sum=0
ans="No"
for i in range(N):
    d=list(map(int,input().split()))
    if d[0]==d[1]:
        sum+=1
        if sum>2:
            ans="Yes"
            break
    else:
        sum=0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    ans = False
    p = 0
    for i in range(N):
        D = list(map(int, input().split()))
        if D[0] == D[1]:
            p += 1
        else:
            p = 0
        if p == 3:
            ans = True
            break
    if ans:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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

count = 0
is_check = True
second_check = False
for i in a:
    if i[0] == i[1]:
        is_check = True
        count+=1
    else:
        count = 0
        is_check = False

    if count == 3 and is_check == True:
        second_check = True

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

Submission status: Accepted

Solution code:
n=int(input())
s=0
l=0
for i in range(n):
    b,c=map(int,input().split())
    if b==c:
        l+=1
    else:
        l=0
    if l>=3:
        s+=1

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

Submission status: Accepted

Solution code:
n = int(input())
D_1 = []
D_2 = []
for _ in range(n):
    d_1, d_2 = map(int, input().split())
    D_1.append(d_1)
    D_2.append(d_2)
cnt = 0
for i in range(n-2):
    if D_1[i] == D_2[i] and D_1[i+1] == D_2[i+1] and D_1[i+2] == D_2[i+2]:
        cnt = 1
        break

if cnt == 0:
    print('No')
elif cnt == 1:
    print('Yes')

Submission status: Accepted

Solution code:
import sys

num = int(input())

num_list = []

for i in range(num):
  num_list.append(list(map(int,input().split())))

true_count = 0
  
for item in num_list:
  if(item[0] == item[1]):
    true_count += 1
    if(true_count >= 3):
      print("Yes")
      sys.exit()
  else:
    true_count = 0

print("No")

Submission status: Accepted

Solution code:
import sys

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

for i in range(len(li) - 2):
    if li[i][0] == li[i][1]:
        if li[i + 1][0] == li[i + 1][1]:
            if li[i + 2][0] == li[i + 2][1]:
                print("Yes")
                sys.exit()
print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
n = int(sys.stdin.readline().rstrip("\n"))
ans = 0
zorome = 0
for _ in range(n):
    d1,d2 = map(int, sys.stdin.readline().rstrip("\n").split())
    if d1 == d2:
        zorome += 1
    else:
        zorome = 0
    ans = max(ans,zorome)
if ans >= 3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())

D = []

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

mxn = 0
num = 0

for i in range(N):
    if D[i][0]==D[i][1]:
        num += 1
        mxn = max(num,mxn)
    else:
        num = 0

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

Submission status: Accepted

Solution code:
import numpy as np
import sys

#inp = list(map(int, input().split())
#inp = list(input())


n = int(input())
count = 0

for i in range(n):
    d = list(map(int, input().split()))
    if d[0] == d[1]:
        count += 1
    else :
        count = 0
    if count == 3:
        print("Yes")
        sys.exit()

print("No")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8


def solve(*args: str) -> str:
    n = int(args[0])
    cnt = 0
    for d1, d2 in map(str.split, args[1:]):
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        if 3 <= cnt:
            return 'Yes'
    return 'No'


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))

Submission status: Accepted

Solution code:
n = int(input())

count = 0
flag = 0
for i in range(n):
  s,t = map(int, input().split())
  if s==t and flag == 0:
    flag = 1
  elif s==t and flag > 0:
    flag = flag+1
    if flag == 3:
      print("Yes")
      exit()
  else:
    flag = 0   
print("No")

Submission status: Accepted

Solution code:
n=int(input())

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

Submission status: Accepted

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

print('Yes' if ans==1 else 'No')

Submission status: Accepted

Solution code:
N=int(input())
D=[]
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]:
        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:
from typing import List, Tuple


def go_to_jail(N: int, D: List[Tuple[int, int]]) -> bool:
    prev = (False, False)

    for d1, d2 in D:
        if d1 == d2 and all(prev):
            return True
        prev = prev[1], d1 == d2
    return False


if __name__ == "__main__":
    N = int(input())
    D = [tuple(input().split()) for _ in range(N)]
    ans = go_to_jail(N, D)
    print("Yes" if ans else "No")

Submission status: Accepted

Solution code:
n = int(input())

#flag = True

cnt = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

ans = 'No'
count = 0

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

Submission status: Accepted

Solution code:
N = int(input())
counter = 0
second = 0
row = False
while N > 0:
    details = input().split()
    first = details[0]
    second = details[1]
    if first == second:
        counter += 1
    if first != second:
        counter = 0
    if counter >= 3:
        row = True
    N -= 1

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

Submission status: Accepted

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

ansl=[]
ans=0
for i in range(N):
    if x[i]==y[i]:
        ans+=1
    else:
        ansl.append(ans)
        ans=0
ansl.append(ans)
if max(ansl)>=3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

flag=0
for i in range(1,n-1):
  if l[i-1][0]==l[i-1][1] and  l[i][0]==l[i][1] and  l[i+1][0]==l[i+1][1]:
    flag=1
    break

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    flag = False
    count = 0
    for i in range(n):
        d = list(map(int, input().split()))
        if d[0] == d[1]:
            count += 1
        else:
            count = 0
        if count == 3:
            flag = True
            break
    print('Yes' if flag else 'No')


if 'unittest' not in globals():
    resolve()

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

if count != 3:
    print("No")

Submission status: Accepted

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

for i in range(n-2):
  if x[i] == y[i] and x[i+1] == y[i+1] and x[i+2] == y[i+2]:
    print('Yes')
    exit()
  else:
    i += 1
    if i == n-2:
      print('No')
      exit()

Submission status: Accepted

Solution code:

def func(a, b, cnt):
	if(a == b):
		cnt += 1
		return cnt
	cnt = 0
	return cnt

n = int(input())
cnt = 0
for i in range(n):
	a, b= list(map(int, input().strip().split()))
	cnt = func(a, b, cnt)
	if(cnt == 3):
		break

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

Submission status: Accepted

Solution code:
def main():
    import sys
    N=int(sys.stdin.readline())
    count=0
    for i in range(N):
        D1,D2=list(map(int,sys.stdin.readline().split()))
        if D1==D2:
            count+=1
        else:
            count=0
        if count==3:
            print('Yes')
            break
    else:
        print('No')

main()

Submission status: Accepted

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

    print("No")
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

cnt = 0
for i in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print("Yes")
        break
    if i == N-1 and cnt != 3:
        print("No")

Submission status: Accepted

Solution code:
N = int(input())

c = 0

flg = "No"

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

Submission status: Accepted

Solution code:
def main():
	N = int(input())
	z = []
	for i in range(N):
		d1, d2 = [int(d) for d in input().split(" ")]
		if d1 == d2:
			z.append(1)
		else:
			z.append(0)
	zc = []
	now = 2
	c = 0
	for i in range(len(z)):
		if i == 0:
			now = z[i]
			c += 1
		elif now == z[i]:
			c += 1
		elif now == 1 and z[i] == 0:
			zc.append(c)
			c = 1
			now = z[i]
		elif now == 0 and z[i] == 1:
			c = 1
			now = z[i]
	else:
		if now == 1:
			zc.append(c)

	print("Yes") if len(zc) > 0 and max(zc) >= 3 else print("No")

main()

Submission status: Accepted

Solution code:
# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
N = int(input())
renzoku =0
ans ="No"
for _ in range(N):
    d1,d2 = map(int, input().split())
    if d1 ==d2:
        renzoku +=1
        if renzoku ==3:
            print("Yes")
            sys.exit()
    else:
        renzoku =0
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
d = []
for _ in range(n):
  j = list(map(int, input().split()))
  d.append(j)
ok = True
for i in range(n - 2):
  if d[i][1] == d[i][0] and d[i + 1][1] == d[i + 1][0] and d[i + 2][1] == d[i + 2][0]:
    print("Yes")
    ok = False
    break
if ok:
  print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N=int(input())
zorome=[]

for i in range(N):
  saikoro=input().split()
  zorome.append(saikoro[0]==saikoro[1])

ret=False
for i in range(N-2):
  if zorome[i] and zorome[i+1] and zorome[i+2]:
    ret=True
    break
print('Yes') if ret else print('No')

Submission status: Accepted

Solution code:
# coding: utf-8
# submission # - User: herp_sy
# https://atcoder.jp/contests/
#
# lang: Python3 (3.8.2)

import math
import statistics
import numpy as np
import queue
import itertools
import functools 

n = int(input())
dice1, dice2 = [], []
for i in range(n):
	a, b = map(int, input().split())
	dice1.append(a)
	dice2.append(b)

chk = False
for i in range(2, n):
	if (dice1[i - 2] == dice2[i - 2] and dice1[i - 1] == dice2[i - 1] and dice1[i] == dice2[i]):
		chk = True
		break

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

Submission status: Accepted

Solution code:
N = int(input())

info = []
for i in range(N):
    chis = input().split()
    info.append(chis)

maximum = zoro = 0
for each in info:
    if each[0] == each[1]:
        zoro += 1
        maximum = max(maximum, zoro)
    else:
        zoro = 0

if maximum > 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

for i 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")
        break
      else:
        count += 1
    else:
      count += 1
  else:
    count += 1
  
if count == N-2:
  print("No")

Submission status: Accepted

Solution code:

N = int(input())
iterator = 0

for i in range(N):
    j,k = map(int, input().split())
    if j == k:
        iterator += 1
    elif iterator != 0:
        iterator = 0
    else :
        pass

    if iterator >= 3:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
t = int(input())

count = 0
hasIs = False
while t > 0:
  s = input().split(" ")
  if s[0] == s[1]:
    count +=1
  else:
    count  = 0
  if count  >= 3:
    hasIs =True
    break
  t-=1
if hasIs:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
N = int(input())


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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, os.path
from collections import*
from copy import*
import math
mod=10**9+7
if(os.path.exists('input.txt')):
    sys.stdin = open("input.txt","r")
    sys.stdout = open("output.txt","w")

n=int(input())
d=[]
flag=0
for i in range(n):
    a=list(map(int,input().split()))
    d.append(a)
count=0
for i in range(n):
    if(d[i][0]==d[i][1]):
        count+=1
    else:
        count=0
    if(count==3):
        flag=1
        break
if(flag==1):
    print("Yes")
else:
    print("No")