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:
def main():
    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]:
            if D[i-1][0] == D[i-1][1]:
                if D[i][0] == D[i][1]:
                    print('Yes')
                    exit()
    print('No')
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys

n = int(input())
d1 = []
d2 = []
count = 0
for i in range(n):
    a, b = map(int, input().split())
    d1.append(a)
    d2.append(b)

for j in range(n-2):
    count = 0
    if d1[j] == d2[j]:
        count += 1
        if d1[j+1] == d2[j+1]:
            count += 1
            if d1[j+2] == d2[j+2]:
                count += 1
                print("Yes")
                sys.exit()

if count < 3:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

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

count=0
for i in range(n):
    if d1[i]==d2[i]:
        count+=1
    else:
        count=0

    if count==3:
        print('Yes')
        break

else:
    print('No')

Submission status: Accepted

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
flag=False
for k in range(N):
      if x[k]==y[k]:
         s=s+1
         if s==3:
          flag=True
          break
      else:
         s=0
 
if flag==True:
  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)]
tmp = 1
ans = [1]
for i in range(N):
    if i == N - 1:
        break
    else:
        if x[i] == y[i] and x[i+1] == y[i+1]:
            tmp += 1
        else:
            tmp = 1
        ans.append(tmp)
if max(ans) >= 3:
    print("Yes")
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# cording:utf-8

# 回数を入力
N = int(input())

D1 = [0] * N
D2 = [0] * N

# N回入力
for i in range(N):
    D1[i], D2[i] = map(int, input().split())

A = 0
# 一つ目の文字列を探索
for i in range(N-2):
    if (D1[i] == D2[i]) & (D1[i+1] == D2[i+1]) & (D1[i+2] == D2[i+2]):
        print("Yes")
        A = 1
        break

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding: UTF-8

N = int(input())

zorome = 0
flag = 0
for i in range(N):
  #i回目ゾロ目か
  D = list(map(int,input().split()))
  if D[0] == D[1]:
    zorome += 1
  else:
    zorome = 0
  if zorome >=3:
    print('Yes')
    flag = 1
    break
if flag ==0:
  print('No')

Submission status: Accepted

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

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

if cou < 3:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
rolls = []
for _ in range(int(input())):
    a, b = [int(x) for x in input().split()]
    rolls.append([a, b])
has = 0
for i in rolls:
    if i[0] == i[1]:
        has += 1
        #print(has, i)
        if has == 3:
            break
    else:
        has = 0
print("Yes" if has == 3 else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

count = 0
a = []

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

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

Submission status: Accepted

Solution code:

n = int(input())

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

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

Submission status: Accepted

Solution code:
import sys

MAX_N  = 100

N = int(input())
#print(N)
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]

for i in range(3-1,N):
    if x[i-2] == y[i-2]:
        if x[i-1] == y[i-1]:
            if x[i] == y[i]:
                print("Yes")
                sys.exit()  

print("No")

Submission status: Accepted

Solution code:
n=int(input())
d=[]
ok=False
for i in range(n):
    l=list(map(int,input().split()))
    d.append(l)
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]:
        ok=True
if ok:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

while i < N:
    i += 1
    a, b = map(int, input().split())
    if a == b:
        cnt += 1
        if cnt >= 3:
            flg = 1
    else:
        cnt = 0

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a = int(input())
xy = [map(int, input().split()) for _ in range(a)]
x, y = [list(i) for i in zip(*xy)]
flag = 0
b=0
for i in range(a):
    if (x[i] == y[i]):
      flag = flag+1
      if (flag ==3):
        b = 1
    else:
      flag = 0
    
if b==1:
    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())))

cnt = 0
for j in range(n):
  if d[j][0] == d[j][1]:
    cnt += 1
    if cnt >= 3:
      print("Yes")
      exit()
      
  else:
    cnt = 0
    
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
list1 = []
list2 = []
p = 0
k = 0
for i in range(N):
    a, b = map(int, input().split())
    list1.append(a)
    list2.append(b)
for j in range(N):
    if list1[j] == list2[j]:
        p += 1
    else:
        p = 0
    if p == 3:
        k += 1

if k >= 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input()) #1行目のNを取得する
s = [list(input().split()) for i in range(N)] #複数行の数値の入力を取得

n_list = []
for i in range(N):
  if(s[i][0] == s[i][1]):
    n_list.append(1)
  elif(s[i][0] != s[i][1]):
    n_list.append(0)
    
ans = []
for i in range(N - 2):
  if(n_list[i] == 1 and n_list[i + 1] == 1 and n_list[i + 2] == 1):
    ans.append("Yes")
    break
  else:
    ans.append("No")
    
if "Yes" in ans:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
n = input()
x = 0
flag = False
for i in range(int(n)):
    a,b = input().split(" ")
    if a == b:
        x+=1
    else: x = 0
    if x==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)]

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

Submission status: Accepted

Solution code:
s = int(input())
d = [[int(v) for v in input().split()] for i in range(s)]
ans = False
cnt = 0
for j in range(len(d)):
    if all(elem == d[j][0] for elem in d[j]):
        cnt += 1
    else:
        cnt = 0

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

Submission status: Accepted

Solution code:
time = int(input())
xy = [map(int, input().split()) for _ in range(time)]
x, y = [list(i) for i in zip(*xy)]
sum = 0
for i in range(time):
    if x[i] == y[i]:
        sum += 1
        if sum == 3:
            print("Yes")
            break
    else:
        sum = 0

if sum < 3:
    print("No")

Submission status: Accepted

Solution code:
n = input()
n = int(n)
d = []
for i in range(n):
    d.append(input().split())
active = False
count = 0
for x in d:
    if x[0] == x[1]:
        active = True
        count += 1
    else:
        count = 0
        active = False
    if count >2:
        break
if count > 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

for i in range(1,N-1):
    if (x[i-1] == y[i-1]) and (x[i] == y[i]) and (x[i+1] == y[i+1]):
        flag = 1
        break
if flag == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N = int(input())
    doublet_count = 0
    is_doublet = False

    for i in range(N):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            doublet_count += 1
        else:
            doublet_count = 0
        if doublet_count == 3:
            is_doublet = True
            break
    
    
    if is_doublet:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
ans = [False]*3
for i in range(N):
  D1,D2 = input().split()
  ans[i%3] = D1==D2
  if all(ans): break
print("Yes" if all(ans) else "No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

mulArr = []
for _ in range(N):
  arr = list(map(int, input().split(" ")))
  mulArr.append(arr)
# print(mulArr)

result = 0
for i in range(0, len(mulArr) - 2):
  # print(i)
  if mulArr[i][0] == mulArr[i][1] and mulArr[i + 1][0] == mulArr[i + 1][1] and mulArr[i + 2][0] == mulArr[i + 2][1]:
    result += 1

# print(result)
if result != 0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

for i in range(n):
    al, be = map(int, input().split())
    if al == be:
        count += 1
        if count >= 3:
            print("Yes")
            break
    else:
        count = 0
else:
    print("No") if count < 3 else print("Yes")

Submission status: Accepted

Solution code:
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
count = 0
for i in range(N-2):
    if D[i][0]==D[i][1] and D[i+1][0]==D[i+1][1] and D[i+2][0]==D[i+2][1]:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

an=1
for i in range(n):
    if n > i+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]:
            an=0
            break
    else:
        an=1
if an==0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n=int(input())

result=[0]

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

for i in range(1,n+1):
    if(result[i]==3):
        print("Yes")
        break
    if(i==n):
        print("No")

Submission status: Accepted

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

for i in range(N):
    D1, D2 = map(int, input().split())
    if D == 3:
        break

    if D1 == D2:
        D += 1

    elif D1 != D2:
        D = 0

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

Submission status: Accepted

Solution code:
N = int(input())
l = []
m = []
for i in range(N):
    a,b = map(int,input().split())
    l.append(a)
    m.append(b)
flg = 0
c = 0
for i in range(len(l)):

    if l[i] == m[i]:
        c += 1
        if c==3:
            flg += 1
            
    else:
        c = 0
if flg == 0:
    print("No")
else:
    print("Yes")

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

Submission status: Accepted

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

last = 0
for item in l:
  if last == 0 and item[0] == item[1]:
    last = 1
    continue
  elif last == 1 and item[0] == item[1]:
    last = 2
    continue
  elif last == 2 and item[0] == item[1]:
    last = 3
    break
  else:
    last = 0

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

Submission status: Accepted

Solution code:

n = int(input())

flag = True
con = 0
for _ in range(n):
    x,y = map(int,input().split())
    if x == y:
        con += 1
    else:
        con = 0

    if con == 3:
        print("Yes")
        flag = False

if flag:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())

a = [0]*n

for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        a[i] = 1
ans = 'No'        
for i in range(n-2):
    if a[i]*a[i+1]*a[i+2] ==1:
        ans = 'Yes'
        
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

d_li = []
for i in range(n):
    line = list(map(int, input().split()))
    d_li.append(line)

count = 0
for i in range(n):
    if d_li[i][0] == d_li[i][1]:
        count += 1
    else:
        count = 0
    
    if count == 3:
        msg = "Yes"
        break
    else:
        msg = "No"

print(msg)

Submission status: Accepted

Solution code:
import sys

n=int(input())

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

c=0
for j in range(0,len(d)-1,2):
        if d[j]==d[j+1]:
                c+=1
                if c==3:
                        print('Yes')
                        sys.exit()
        else:
                c=0
                
print('No')

Submission status: Accepted

Solution code:
n = int(input())

count = 0
max_count = 0
for i in range(n):
    input_elements = input().split()
    if input_elements[0] == input_elements[1]:
        count += 1
    else:
        if max_count < count:
            max_count = count
        count = 0

if max_count < count:
    max_count = count

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

Submission status: Accepted

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


def main():
    ans = 0
    for i in range(int(input())):
        n = input()
        if n[0] != n[2]:
            ans = 0
        else:
            if ans == 2:
                ans += 1
                break
            else:
                ans += 1
    if ans == 3:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
xy = [map(int,input().split()) for i 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')
        break

    elif i == N-3:
        print('No')

    else:
        continue

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 == True:
    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
count = 0

for i in range(N):
  if x[i] == y[i]:
    count += 1
    if count >= 3:
      flag = 1
  else:
    count = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
d = np.array([input().split() for i in range(n)])

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

print("No")

Submission status: Accepted

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

if(answer==1):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

for i in range(0,n):
  l[i] = set(l[i])

ans = "No" 
for i in range(0,n-2):
  if len(l[i]) == 1 and len(l[i+1]) == 1 and len(l[i+2]) == 1:
    ans = "Yes"
  
print(ans)

Submission status: Accepted

Solution code:
import sys
n=int(input())
val=0
for i in range(n):
  o,t=map(int,input().split())
  if o==t:
    val+=1
  else:
    val=0
  if val==3:
    print('Yes')
    sys.exit()
print("No")

Submission status: Accepted

Solution code:
n=int(input())
c,f=0,0
while(n>0):
  a,b=map(int,input().split())
  if(a==b):
    c+=1
  else:
    c=0
  if(c>=3):
    f=1
    break
  n-=1
if(f==1 or c>=3):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
N = int(input())
D = []
i = 0
ans_flag = False
while i < N:
    D1, D2 = map(int, input().split())
    if D1 == D2:
        D.append(1)
        if len(D) == 3:
            ans_flag = True
    else:
        D = []
    i += 1

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

Submission status: Accepted

Solution code:
def die(matrix, n):
	for i in range(n-2):
		if matrix[i][0] == matrix[i][1]:
			if matrix[i+1][0] == matrix[i+1][1]:
				if matrix[i+2][0] == matrix[i+2][1]:
					return("Yes")

	return("No")			



n = int(input())
matrix = []
for i in range(n):
   row = list(map(int, input().split()))
   matrix.append(row)


print(die(matrix, n))

Submission status: Accepted

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

for i in range(S):
  if x[i] == y[i]:
    count += 1
    if count == 3:
      print("Yes")
      sys.exit()
    else:
      pass
  else:
    count = 0
print("No")

Submission status: Accepted

Solution code:
pairs = []
N = int(input(''))
for i in range(N):
    pair = input('')
    pair = pair.split(' ')
    pairs.append(pair)

cou = 0
for i, lst in enumerate(pairs):
    if cou == 3:
        break
    elif lst[0] == lst[1]:
        cou += 1
    else:
        cou = 0

if cou != 3:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
N=int(input())
D=[list(map(int,input().split())) for i in range(N)]
tf=0
for j in range(N-2):#Di1=Di2&Di+1_1=Di+1_2&Di1=Di2 3回連続ぞろ目
    if D[j][0]==D[j][1] and D[j+1][0]==D[j+1][1] and D[j+2][0]==D[j+2][1]:
        tf=1
        break

if tf==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")
        break
    if cnt < 3 and i == n-1:
        print("No")

Submission status: Accepted

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] and flg[j+1] and flg[j+2]:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, os, io
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s + '\n')
def wi(n): sys.stdout.write(str(n) + '\n')
def wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math,datetime,functools,itertools,operator,bisect,fractions
from collections import deque,defaultdict,OrderedDict,Counter
from fractions import Fraction
from decimal import Decimal
    
def main():
    starttime=datetime.datetime.now()
    if(os.path.exists('input.txt')):
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    
    for _ in range(1):
        n=ri()
        c=0
        z=0
        for i in range(n):
            a,b=ria()
            if a==b:
                c+=1
            else:
                c=0
            z=max(z,c)
        if z>=3:
            print('Yes')
        else:
            print('No')
        
        
        
    
    
        
                    
        
    #<--Solving Area Ends
    endtime=datetime.datetime.now()
    time=(endtime-starttime).total_seconds()*1000
    if(os.path.exists('input.txt')):
        print("Time:",time,"ms")  
    
                
class FastReader(io.IOBase):
    newlines = 0

    def __init__(self, fd, chunk_size=1024 * 8):
        self._fd = fd
        self._chunk_size = chunk_size
        self.buffer = io.BytesIO()

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self, size=-1):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()


class FastWriter(io.IOBase):

    def __init__(self, fd):
        self._fd = fd
        self.buffer = io.BytesIO()
        self.write = self.buffer.write

    def flush(self):
        os.write(self._fd, self.buffer.getvalue())
        self.buffer.truncate(0), self.buffer.seek(0)


class FastStdin(io.IOBase):
    def __init__(self, fd=0):
        self.buffer = FastReader(fd)
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


class FastStdout(io.IOBase):
    def __init__(self, fd=1):
        self.buffer = FastWriter(fd)
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.flush = self.buffer.flush


if __name__ == '__main__':
    sys.stdin = FastStdin()
    sys.stdout = FastStdout()
    main()

Submission status: Accepted

Solution code:
N = int(input())
D = [input() for i in range(N)]
count = 0
OK = 0
for ite in D:
    
    
    a,b = map(int,ite.split())
    
    if a == b:
        count += 1
        if count >=3:
            OK = 1
            
        
        else:
            pass
    
    else:
        count = 0

if OK == 0:
    print('No')    
else:
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
list_N = []
for _ in range(N):
    list_N.append(list(map(int, input().split())))
s = ''
for i in list_N:
    s += str(len(set(i)))

if '111' in s:
    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):
  if d[i][0] == d[i][1]:
    count += 1
  else:
    count = 0
  if count == 3:
    break
print("Yes") if count >= 3 else print("No")

Submission status: Accepted

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

N = int(pin())
seqcount = 0
ans = 'No'
for i in range(N):
    d1, d2 = map(int, pin().split())
    if d1 == d2 and seqcount <2:
        seqcount += 1
    elif d1 == d2 and seqcount == 2:
        ans = 'Yes'
        break
    else:
        seqcount = 0

print(ans)

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)]

def M():
  count = 0
  for j in range(N):
    if x[j] == y[j]:
      if j+2 < N:
        if x[j+1] == y[j+1]:
          if x[j+2] == y[j+2]:
            print('Yes')
            return
  print('No')

M()

Submission status: Accepted

Solution code:
n = int(input())
d1 = []
d2 = []
cnt = 0

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

for i in range(n-2):
    if(d1[i] == d2[i] and d1[i+1] == d2[i+1] and d1[i+2] == d2[i+2]):
        cnt += 1

if(cnt > 0):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

count = 0
for i in range(N-2):
  if list_D[N-i-1][0] == list_D[N-i-1][1] and list_D[N-i-2][0] == list_D[N-i-2][1] and list_D[N-i-3][0] == list_D[N-i-3][1]:
    count += 1
if count > 0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
N=int(input())
say="No"
if(N<3):
    print("No")
else:
    D1=input()
    D2=input()
    t1=(D1[0]==D1[2])
    t2=(D2[0]==D2[2])
    for i in range(N-2):
        Dn=input()
        if(D1[0]==D1[2] and D2[0]==D2[2] and Dn[0]==Dn[2]):
            say="Yes"
        D1,D2=D2,Dn
print(say)

Submission status: Accepted

Solution code:
Count = 0
Array = []
for i in range(int(input())):
    Dice_1, Dice_2 = map(int, input().split())
    if Dice_1 == Dice_2:
        Array.append(1)
    else:
        Array.append(0)

ans = []
j_1 = 0
for j in range(len(Array)):
    if j_1 == 1 and Array[j] == 1:
        Count = Count + 1
    else:
        Count = 0
    j_1 = Array[j]
    ans.append(Count)
if max(ans) >= 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def i_input(): return int(input())


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


def i_list(): return list(i_map())


def i_row_list(N): return [i_list() for _ in range(N)]


n = i_input()
d = i_row_list(n)
ans = 'No'
cnt = 0
for d1, d2 in d:
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt > 2:
        ans = 'Yes'
        break

print(ans)

Submission status: Accepted

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