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:
a = int(input())

flag1 = False
flag2 = False
result = False
for i in range(a):
    b, c = map(int, input().split())  
    
    if flag2:
        if b == c:
            result = True
    
    if flag1:
        if b == c:
            flag2= True
        
    
    if b == c:
        flag1= True
    else:
        flag1 = False
        flag2 = False        


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

Submission status: Accepted

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

sequence_doublet = 0
for D in D_list:
    if D[0] == D[1]:
        sequence_doublet += 1
    else:
        sequence_doublet = 0
    
    if sequence_doublet == 3:
        break

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

Submission status: Accepted

Solution code:
n=int(input())
cnt=0
flag=False
for i in range(n):
    d1,d2=map(int,input().split())
    if d1==d2 and cnt==2:
        print('Yes')
        flag=True
        break
    elif d1==d2:
        cnt+=1
    else:
        cnt=0
if not flag:
    print('No')

Submission status: Accepted

Solution code:
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]:
        if d[i+1][0] == d[i+1][1]:
            if d[i+2][0] == d[i+2][1]:
                print('Yes')
                exit()
            else:
                continue
        else:
            continue
    else:
        continue

print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(f())

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# coding:utf-8

def main():
    line = int(input())
    xy = [map(int, input().split()) for _ in range(line)]
    x, y = [list(i) for i in zip(*xy)]
    stdOut = solve(line, x, y)
    print(stdOut)


"""
方針


"""


def solve(line, x, y):
    for i in range(line):
        if (line - i) <= 2:
            return 'No'
        if isDoublet(x[i], y[i]) and isDoublet(x[i + 1], y[i + 1]) and isDoublet(x[i + 2], y[i + 2]):
            return 'Yes'
    return 'No'


def isDoublet(xi, yi):
    return xi == yi


if __name__ == "__main__":
    main()

Submission status: Accepted

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

zorome = 0
ans_chk = 0
for i in range(N):
  D = list(map(int,input().split()))
  if ( D[0]==D[1] ):
    if   ( zorome==0 ):
      zorome = 1
    elif ( zorome==1 ):
      zorome = 2
    elif ( zorome==2 ):
      zorome = 3
      print('Yes')
      ans_chk = 1
      break
  else:
    zorome = 0

if ( ans_chk==0 ):
  print('No')

Submission status: Accepted

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

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

print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
N = int(input())
D1 = [0] * N
D2 = [0] * N
for i in range(N):
    D1[i], D2[i],= map(int, input().split())
s=0
for i in range(N):
    if D1[i]==D2[i]:
        s=s+1
    else:
        s=0
    if s>=3:
        print('Yes')
        sys.exit()
print('No')

Submission status: Accepted

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

ans = 'No'
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] :
                ans = 'Yes'

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
l=[list(map(int,input().split())) for _ in range(n)]
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())
D = [[] for _ in range(N)]
for i in range(N):
    D[i] = list(map(int, input().split()))

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())
c=0

for i in range(n):
    d,dd=map(int,input().split())
    if d==dd:
        c+=1
        if c==3:
            print("Yes")
            exit()
    else:
        c=0
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
d=[]
for _ in range(n):
  l=list(map(int,input().split()))
  d.append(l)
a=[1,2]
d.append(a)
d.append(a)
flg=0  
for i in range(n):
  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")
        flg=1
        break
if flg==0:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

zoro_count = 0
OK = False

for i in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        zoro_count += 1
        if zoro_count >= 3:
            OK = True
    else:
        zoro_count = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

sum=0
tri=0

for n in range(N):
    X,Y = map(int, input().split())
    if X==Y:
        sum+=1
        if sum==3:
            tri=1
    else:
        sum=0

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

Submission status: Accepted

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

tmp = 0
ans = 0
for i in range(n):
    if D_1[i] == D_2[i]:
        tmp += 1
    else:
        ans = max(tmp, ans)
        tmp = 0
ans = max(tmp, ans)

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

Submission status: Accepted

Solution code:
N = int(input())
a = [0] * N
b = [0] * N

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

count = '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]:
        count = 'Yes'

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys 
n = int(input())
lst = []
for i in range(n):
  x,y = map(int,input().split())
  if x == y:
    lst.append(i)
for i in range(len(lst)-2):
  if lst[i+1] == lst[i] +1 and lst[i+2] == lst[i+1] +1:
    print('Yes')
    sys.exit()
print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
T=False
k=0
for i in range(N):
    D1,D2=map(int,input().split())
    if D1==D2:
        k+=1
        if k>=3:
            T=True
    else:
        k=0
if T:
    print("Yes")
else:
    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())

def aa():
    c=0
    for i in range(N):
        D=list(map(int,input().split()))
        if(D[0]==D[1]):
            c+=1
            if(c==3):
                return 'Yes'
        else:
            c=0
    return 'No'
print(aa())

Submission status: Accepted

Solution code:
n=int(input())
xy=[map(int,input().split()) for i in range(n)]
x,y=[list(v) for v in zip(*xy)]
cnt=0
for i in range(n):
  if x[i]==y[i]:
    cnt+=1
  else:
    cnt=0
  if cnt==3:
    print('Yes')
    break
if cnt!=3:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = ""
for _ in range(n):
  inp = input().split()
  if inp[0]==inp[1]:
    d += "T"
  else:
    d += "F"
if d.count("TTT") > 0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def main():
    n = int(input())

    count = 0
    t = 0
    ans = "No"
    for i in range(n):
        a, b = list(map(int, input().split()))

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

        if t == 3 and count >= 3:
            ans = "Yes"

    print(ans)


main()

Submission status: Accepted

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

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

    if j>=3:
        break

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

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]
dt = np.array([int(e[0] == e[1]) for e in d])
s = dt[:n-2] + dt[1:n-1] + dt[2:]
if s.max() >= 3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

flg = False
cnt = 0
for di, dj in D:
    if (di == dj):
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        flg = True
        break
if flg:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

if __name__ == "__main__":
    main()

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
if flag:
    print('Yes')
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
        break

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

Submission status: Accepted

Solution code:
def check(w):
	count=0
	flag=0
	mx=0
	for i in range(len(w)):
		if w[i][0]==w[i][1]:
			count+=1
			flag=0
		else:
			mx=max(mx,count)
			count=0
			flag=1
	if flag==0:
		mx=max(mx,count)
		
	if mx>=3:
		return 1
	else:
		return 0
			
n=int(input())
w=[]
for i in range(n):
	a,b=map(int,input().split())
	w.append([a,b])
if check(w):
	print("Yes")
else:
	print("No")

Submission status: Accepted

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

ans = "No"
cnt = 0

for i in range(N):
    if len(set(D[i])) == 1:
        cnt += 1
    else:
        cnt = 0
    
    if cnt >= 3:
        ans = "Yes"

print(ans)

Submission status: Accepted

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

  
###################################################
count = 0
flag = False
for j in range(N):
  if listD[j][0] == listD[j][1]:
    count += 1
    if count >= 3:
      print("Yes")
      flag = True
      break
  else:
    count = 0
if flag == False:
  print("No")

Submission status: Accepted

Solution code:
def main():
  N = int(input())
  Ds = [list(map(int,input().split())) for x in range(N)]
  c = 0
  f = False
  for d in Ds:
    if d[0] == d[1]:
      c += 1
    else:
      c = 0
    if c == 3:
      f = True
  if f:
    print("Yes")
  else:
    print("No")

main()

Submission status: Accepted

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

count_max = 0
for d in D:
    if d[0] == d[1]:
        count_max += 1
    else:
        count_max = 0

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

Submission status: Accepted

Solution code:
a = int(input())
s = [input().split() for i in range(a)]
cnt = int(0)
maxcnt = int(0)

for i in range(a):
    if s[i][0] == s[i][1]:
        cnt += 1
    else:
        cnt = 0
    if maxcnt < cnt:
        maxcnt = cnt

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

Submission status: Accepted

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

print("No")

Submission status: Accepted

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

n=[]
for i in b:
    if i[0]==i[1]:
        n.append(1)
        continue
    n.append(0)
for i in range(a-2):
    if n[i]==1 and n[i+1]==1 and n[i+2]==1:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

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

Submission status: Accepted

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

count = 0
flag = False
for d in D:
    if d[0] == d[1]:
        count += 1
    else:
        count = 0
    if count >= 3:
        flag = True
        break

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

Submission status: Accepted

Solution code:
import math
#N = map(int,input().split())
#AB=[]
N = int(input())
#C = input()
#D, T, S=map(int,input().split())
D = []
c = 0
d = 0
for i in range(N):
    a = list(map(int, input().split()))
    if a[0] == a[1]:
        if c == 0:
            c+= 1
        elif c == 1:
            c+= 1
        elif c == 2:
            d = 1
    else:
        if c > 0:
            c = 0
if d == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
series = 0
for _ in range(N):
  a,b = map(int,input().split())
  if a == b:
    if series == 2:
      print('Yes')
      exit()
    elif series == 1:
      series += 1
    else:
      series = 1
  else:
    series = 0
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])
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:
a = int(input())
count = 0
ans = "No"
for i in range(a) :
  b = list(map(int,input().split()))
  if b[0] == b[1] :
    count = count + 1
  else :
    count = 0
  if count == 3 :
    ans = "Yes"

print(ans)

Submission status: Accepted

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

n = int(input())
d = [[0 for _ in range(2)] for _ in range(n)]
for i in range(n):
    d[i][0], d[i][1] = map(int, input().split())

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

Submission status: 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
flag = 0
for i in range(N):
  
  if D1[i] == D2[i]:
    count += 1
    if count == 3:
      flag = 1
  else:
    count = 0

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    Ds = [list(map(int, input().split())) for _ in range(N)]
    ans = "No"
    count = 0
    maxcou = 0
    for i,j in Ds:
        if i == j:
            count += 1
            if count> maxcou:
                maxcou = count
        else:
            count = 0

    return "Yes" if maxcou>2 else "No"

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    a = int(input())
    zorome = 0
    yes = False

    for i in range(a):
        b = input()
        x, y = b.split(' ')
        if int(x) == int(y):
            zorome += 1
            if zorome == 3:
                yes = True
        else:
            zorome = 0
    if yes:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
for x in range(n):
    d1, d2 = [int(i) for i in input().split()]
    if d1 == d2:
        cnt += 1
    elif cnt == 3:
        break
    else:
        cnt = 0

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

Submission status: Accepted

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

def main():
    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()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())  # nは入力回数
num_list = [list(map(int, input().split())) for _ in range(n)]
ans = "No"

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

count = 0
is_true = False
for i in range(n):
    d1, d2 = list(map(int, input().split()))

    if d1 == d2:
        count = count + 1
    else:
        count = 0
    if count >= 3:
        is_true = True

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

Submission status: Accepted

Solution code:
n = int(input())
f = True
ans_2 = []
for i in range(n):
    d,d_1 = map(int,input().split())
    if f:
        ans = 0
    if d == d_1:
        ans += 1
        f = False
    else:
        f = True
        ans_2.append(ans)
ans_2.append(ans)

f_2 = False
for j in ans_2:
    if j >= 3:
        f_2 = True
    
if f_2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N=int(input())
flag1=False
flag2=False
ans='No'
for i in range(N):
    a,b=map(int,input().split())
    if a==b:
        if flag1:
            if flag2:
                ans='Yes'
            else:
                flag2=True
        else:
            flag1=True
    else:
        flag1=False
        flag2=False
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
zoros = [False,False]
res = "No"
for n in range(N):
    Ds= list(map(int,input().split()))
    if Ds[0] == Ds[1]:
        zoros.append(True)
        if zoros[n] and zoros[n+1] and zoros[n+2]:
            res = "Yes"
    else:
        zoros.append(False)

print(res)

Submission status: Accepted

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

renzoku_count = 0
max_renzoku_count = 0
for _ in range(n):
    d1, d2 = input().split()
    # print(d1, d2)
    if d1 == d2:
        renzoku_count += 1
    else:
        renzoku_count = 0
    max_renzoku_count = max(max_renzoku_count, renzoku_count)
    
# print(max_renzoku_count)
if max_renzoku_count >= 3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n=int(input())
D=[list(map(int,input().split())) for _ in range(n)]
num=0
dnum=0
for i in range(n):
    if D[i][0]==D[i][1]:
        num+=1
        if num==3:
            dnum=1
    else:
        num=0

print("Yes" if dnum==1 else "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
    elif a!=b:
        cnt = 0
    if cnt>=3:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

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

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:
count = 0
n = int(input())
d = [list(map(int,input().split())) for _ in range(n)]
ans = 'No'
for d1,d2 in d:
    if d1==d2:
        count+=1
        if count==3:
            ans = 'Yes'
            break
    else:
        count = 0
        
print(ans)

Submission status: Accepted

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

ans = '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]):
        ans = 'Yes'
print(ans)

Submission status: Accepted

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

hoge = 0
ans = "No"
for i in range(n):
    if d[i][0] == d[i][1]:
        hoge += 1
    else:
        hoge = 0
    if hoge >= 3:
        ans = "Yes"
        break
print(ans)

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
        if count >= 3:
            flag = True
    else:
        count = 0

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

Submission status: Accepted

Solution code:
N = int(input())

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

for i in range(N):
    D1[i], D2[i] = map(int, input().split())
    if D1[i] == D2[i]:
        E[i] = 1
    else:
        E[i] = 0

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

print("No")

Submission status: Accepted

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

for i in range(n):
  d[i] = input().split()
  
c = 0

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

print("No")

Submission status: Accepted

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

Submission status: Accepted

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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, D: "List[List[int]]"):
    cnt = 0
    for i in range(len(D)):
        d1, d2 = [int(t) for t in D[i]]
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            return YES
    return NO


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = [[int(next(tokens)) for _ in range(2)] for _ in range(N)]  # type: "List[List[int]]"
    print(solve(N, D))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

import sys
from collections import defaultdict, deque
from heapq import heappush, heappop
import math
import bisect
input = sys.stdin.readline

# 再起回数上限変更
# sys.setrecursionlimit(1000000)

n = int(input())
d = [] * n * 2
cnt = 0
for _ in range(n):
    a, b = map(int, input().split())
    d.append(a)
    d.append(b)
    if a == b:
        cnt += 1
        if cnt == 3:
            print('Yes')
            sys.exit()
    else:
        cnt = 0
print('No')

Submission status: Accepted

Solution code:
n=int(input(''))
l=[]
k=[]
for a in range(n):
    i,j=map(int,input('').split(' '))
    l.append(i)
    k.append(j)

ok=0
for a in range(n-2):
    if l[a]==k[a] and l[a+1]==k[a+1] and l[a+2]==k[a+2]:
        ok=1
        break

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

Submission status: Accepted

Solution code:
N=int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = [len(set(map(int, input().split())))==1 for d in range(N)]
#print(D)
for i in range(1, N-1):
  if all((D[i-1], D[i], D[i+1])):
    print('Yes')
    break
else:
  print('No')

Submission status: Accepted

Solution code:
N = int(input())
D = [input().split() for _ in range(N)]
zoro = [d1 == d2 for d1, d2 in D]
for i in range(N-2):
  if zoro[i] and zoro[i+1] and zoro[i+2]:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
#
# abc179 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5
1 2
6 6
4 4
3 3
3 2"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """5
1 1
2 2
3 4
5 5
6 6"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """6
1 1
2 2
3 3
4 4
5 5
6 6"""
        output = """Yes"""
        self.assertIO(input, output)


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

    n = 0
    for d in D:
        d1, d2 = d
        if d1 == d2:
            n += 1
            if n == 3:
                print("Yes")
                break
        else:
            n = 0
    else:
        print("No")


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

N = int(input())
B=[]
for i in range(N):
    b=list(map(int,input().split()))
    B.append(b)
for i in range(N-2):
    if B[i][0]==B[i][1]:
        if B[i+1][0]==B[i+1][1]:
            if B[i+2][0]==B[i+2][1]:
                print("Yes")
                sys.exit()
print("No")