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:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
from bisect import bisect_left,bisect_right
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = [inpl() for _ in range(n)]
a = [x == y for x,y in a]
res = False
for i in range(n-2):
    if sum(a[i:i+3]) == 3:
        res = True
print('Yes' if res 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
    else:
        cnt = 0
    if cnt >= 3:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
flag = 0

for i in range(0, n):
    x, y = input().split()
    if x == y:
        ans = ans + 1
    else:
        ans = 0
    if ans >= 3:
        flag = 1
if flag == 1:
    print("Yes")
else :
    print("No")

Submission status: Accepted

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

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

def LI():
    return list(map(int, input().split()))

N = INT()
cnt = 0

for _ in range(N):
    D1, D2 = MI()
    
    if D1 == D2:
        cnt += 1
    else:
        cnt = 0
    
    if cnt == 3:
        print("Yes")
        exit()
    
print("No")

Submission status: Accepted

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

    ans = "No"
    Count = 0
    for ds in dss:
        if ds[0] == ds[1]:
            Count += 1
        else:
            Count = 0
        if Count == 3:
            ans = "Yes"

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

    if zoro == 3:
        ans = 'Yes'
        break

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
cnt=0
ans="No"
for i in range(N):
  x,y=input().split()
  if x==y:
    cnt=cnt+1
  else:
    cnt=0
  if cnt>=3:
    ans="Yes"
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
d = [0] * N
c = 0
b = True
for i in range(N):
  d[i] = list(map(int, input().split()))
  if d[i][0] == d[i][1]:
    c += 1
    b = True
  else:
    c = 0
    b = False
  if c == 3:
    break
if c == 3:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
A=[]
for i in range(N):
    D=list(map(int,input().split()))
    A.append(D)
    
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]:
        print('Yes')
        break
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = [[int(i) for i in input().split()] for j in range(n)]
good = False
for i in range(n-2):
  ok = True
  for j in range(i, i+3):
    ok &= a[j][0] == a[j][1]
  good |= ok
print("Yes" if good else "No")

Submission status: Accepted

Solution code:
n=int(input())
rec=[False]*n
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        rec[i]=True
for i in range(n-2):
    if rec[i] and rec[i+1] and rec[i+2]:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

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

count=0
for d in D:
	if d[0]==d[1]:
		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())
l=[]
for _ in range(n):
  s=input().split()
  l.append([int(s[0]),int(s[1])])
flag=0
for i in range(2,n):
  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]:
    flag=1
    break
if flag:
  print("Yes")
else:
  print("No")

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')
        break
    if i == N-1:
        print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
t=int(input())
count = 0
flag = False
for test in range(t):
    a,b = map(int,input().split())
    if a==b:
    	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())
D=[map(int, input().split()) for i in range(N)]
x, y = [list(i) for i in zip(*D)]

s=0
l=[]
for i in range(N):
  if x[i]==y[i]:
    s+=1
    if i==N-1:
      l.append(s)
  elif x[i]!=y[i]:
    l.append(s)
    s=0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

c = 0
for _ in range(N):
    if len(set(input().split())) == 1:
        c += 1
        if 3 <= c:
            print("Yes")
            exit()
    else:
        c = 0
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 > 2:
		ans = 'Yes'
		break
      
print(ans)

Submission status: Accepted

Solution code:
N,*D=map(int,open(0).read().split())
def main():
    cnt=0
    for i in range(0,N*2,2):
        n1=D[i]
        n2=D[i+1]
        if n1==n2:
            cnt+=1
            if cnt>=3:
                return True
        else:
            cnt=0
    return False
if main():
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
result = 'No'
count = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        count += 1
        if count == 3:
            result = 'Yes'
            break
    else:
        count = 0

print (result)

Submission status: Accepted

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

c = 0

for i in range(n):
    if d[i][0] == d[i][1]:
        c += 1
    else:
        c = 0
    if c == 3:
        break

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

Submission status: Accepted

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

flag = 0
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')

Submission status: Accepted

Solution code:
N=int(input())
D=[]
TF=[]
for i in range(N):
    Input=list(map(int,input().split()))
    D.append(Input)
    if D[i][0]==D[i][1]:
        TF.append(1)
    else:
        TF.append(0)
TF.append(0)
TF.append(0)
Q=[]
for i in range(N):
    temp=TF[i]+TF[i+1]+TF[i+2]
    Q.append(temp)
if max(Q)==3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# サイコロを振る回数
count = int(input())
# ゾロ目の回数
zorome = 0

for i in range(0, count):
  dice1, dice2 = input().split()

  # ゾロ目が3回で連続たらループ抜ける
  if zorome == 3:
    break

  if dice1 == dice2:
    zorome += 1
  else:
    zorome = 0
  
if zorome == 3:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
# coding:UTF-8
import sys
from math import factorial

MOD = 10 ** 9 + 7
INF = 10000000000


def main():
    # ------ 入力 ------#
    n = int(input())    # 数字

    # 定数行入力
    x = n
    dList = [list(map(int, input().split())) for _ in range(x)]     # スペース区切り連続数字(行列)

    # ------ 処理 ------#
    flg = 1
    for i in range(n-2):
        if dList[i][0] == dList[i][1]:
            if dList[i+1][0] == dList[i+1][1]:
                if dList[i+2][0] == dList[i+2][1]:
                    flg = 0

    # ------ 出力 ------#
    if flg == 0:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input().rstrip())
cnt = 0
flg = False
d_list = [[0, 0] for i in range(n)]
for i in range(n):
  d_list[i] = list(map(int, input().rstrip().split(" ")))
for ds in d_list:
  if ds[0] == ds[1]:
    cnt += 1
  else:
    cnt = 0
  if cnt >= 3:
    flg = True
    break
if flg:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
def LI():
    return list(map(int, input().split()))


N = int(input())
count = 0
ans = "No"
for i in range(N):
    a, b = LI()
    if a == b:
        count += 1
        if count == 3:
            ans = "Yes"
            break
    else:
        count = 0
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

    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]:
            count +=1

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

cnt=0
for a,b in D:
    if a==b:cnt +=1
    else: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([int(x) for x in input().split()])

count = 0
for i in range(N):
        if(D[i][0] == D[i][1]):
                count +=1
                if(count == 3):
                        break
        else:
                count = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def func(D):
  comb = 0
  for item in D:
    if item[0]==item[1]:
      comb+=1
    else:
      comb=0
    
    if comb==3:
      return "Yes"  
  return "No"

if __name__ == "__main__":
    N = int(input())
    D = [list(map(int, input().split())) for _ in range(N)]
    print(func(D))

Submission status: Accepted

Solution code:
n = int(input())
count = 0
for i in range(n):
    d1, d2 = 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())

result = False
count = 0

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

    if count > 2:
        result = True
        break

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

Submission status: Accepted

Solution code:
N = int(input())
zoro_count = 0
zoro = False
for n in range(N):
  dn1,dn2 = map(int, input().split())
  if dn1 == dn2:
    zoro_count += 1
  else:
    zoro_count = 0
  if zoro_count >= 3:
    zoro = True
if zoro:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    if len(x) == 0:
        return []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""


n = onem()

co = 0
for i in range(n):
    a,b = m()
    if a == b:
        co += 1
        if co >= 3:
            print("Yes")
            exit()
    else:
        co = 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(N):
  if D[i][0] == D[i][1]:
    seq += 1
    if seq == 3:
      print('Yes')
      break
  else:
    seq = 0
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = [input().split() for _ in range(n)]
if any(i[0]==i[1] and j[0]==j[1] and k[0]==k[1] for i, j, k in zip(d, d[1:], d[2:])):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
check = []
ans = 0
for _ in range(n):
    n1, n2 = map(int, input().split())
    if n1 == n2:
        check.append(1)
    else:
        check.append(0)

for i in range(n-1):
    if sum(check[i:i+3])==3:
        ans = 1
        break
if ans:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

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

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 = 1

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

for _ in range(n):
  aa, b = map(int,input().split())
  if aa == b:
    a.append("1")
  else:
    a.append("0")
if "111" in "".join(a):
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print('No')

Submission status: Accepted

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

for i,j in num_lis:
  if c == 3:
    break
  if i == j:
    c += 1
  else:
    c = 0

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

Submission status: Accepted

Solution code:
n = int(input())
x, y = [], []
for i in range(n):
  x_, y_ = map(int, input().split())
  x.append(x_)
  y.append(y_)
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
else:
  print("No")

Submission status: Accepted

Solution code:
counter = int(input())
result_flg = False

fir_fir, fir_sec = map(int, input().split())
sec_fir, sec_sec = map(int, input().split())


for i in range(2, counter):
  thi_fir, thi_sec = map(int, input().split())

  if fir_fir == fir_sec:
    if sec_fir == sec_sec:
      if thi_fir == thi_sec:
        result_flg = True
        break

  # reset content
  fir_fir = sec_fir
  fir_sec = sec_sec
  sec_fir = thi_fir
  sec_sec = thi_sec

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
D = [len(set(LIST()))==1 for _ in range(N)]
for i in range(N):
    if sum(D[i:i+3]) == 3:
        print("Yes")
        break
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())

count = 0
ans = 0
for i in range(n):
    s = input().split()
    
    if s[0]==s[1]:
        count += 1
    else:
        count = 0
        
    if count ==3:
        print('Yes')
        exit(0)

else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ans = 0
s = []
for i in range(int(input())):
  a,b = map(int,input().split())
  if a==b:
    ans += 1
    s.append(ans)
  else:
    ans = 0
if len(s)!=0 and max(s)>=3:
  print('Yes')
elif len(s)==0:
  print('No')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def judge():
    cnt = 0  
    for _ in range(N):
        x, y = map(int, input().split())
        if x == y:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            return True
    return False

N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

for n in range(N):
    input_line = input().split()
    if (int(input_line[0]) == int(input_line[1])):
        count += 1
        if count == 3:
            temp = 1
    elif(temp ==1):
        break
    else:
        count = 0

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

else:
        print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def sep():
    return map(int,input().strip().split(" "))
def lis():
    return list(sep())


n=int(input())
ar=[]
for i in range(n):
    a,b=sep()
    if a==b:
        ar.append(1)
    else:
        ar.append(0)


for i in range(2,n):
    if ar[i]==1 and ar[i-1]==1 and ar[i-2]==1:
        print("Yes")
        quit()
print("No")

Submission status: Accepted

Solution code:
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]
    
    
def main():
    N = I()
    res = 0
    for i in range(N):
        a,b = MI()
        if a==b:
            res+=1
            if res==3:
                print("Yes")
                exit()
        else:
            res=0
    print("No")
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
cnt = int(input())
chain = 0
first = 0
second = 0

for i in range(cnt):
    nList = list(map(int, input().split()))
    first = nList.pop()
    second = nList.pop()
    if first == second:
        chain = chain + 1
        if chain >= 3:
            break
    else:
        chain = 0

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

Submission status: Accepted

Solution code:
N = int(input())
check = [0, 0, 0]
for i in range(N):
  str = input().split()
  check[i%3] = 1 if str[0] == str[1] else 0
  if sum(check) == 3:
    break
print('Yes') if sum(check) == 3 else print('No')

Submission status: Accepted

Solution code:
N = int(input())

cnt = 0
ans = 'No'

for _ in range(N):
    D = input().split()
    cnt = (cnt + 1)*(D[0] == D[1])
    if cnt == 3:
        ans = 'Yes'

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ans = 'No'
count =0
for i in range(N):
    d1,d2 = list(map(int,input().split()))
    if d1!=d2:
        count =0
    else:
        count +=1
    if count ==3:
        ans = 'Yes'
        break #count3達したら終了させる
print(ans)

Submission status: Accepted

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

cnt = 0

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

Submission status: Accepted

Solution code:
n = int(input())

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

ans = 'No'
cnt = 0
for x1, x2 in X:
    if x1 == x2:
        cnt += 1
        if cnt == 3:
            ans = 'Yes'
            break
    else:
        cnt = 0

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
q=[]
for _ in range(n):
    d_1,d_2=map(int,input().split())
    if d_1==d_2:
        q.append(1)
    else:
        q.append(0)
for i in range(n-2):
    if q[i]==q[i+1]==q[i+2]==1:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
def solve():
  N = int(input())
  lines = [input().split() for i in range(N)]
  count = 0
  for d,e in lines:
    if d==e:
      count += 1
      if count>=3:
        print("Yes")
        return
    else:
      count = 0
  print("No")
  return

solve()

Submission status: Accepted

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

ans = 0
ck = 0

for i in range(n):
  if p[i][0] == p[i][1]:
    ans += 1
    if ans == 3:
      ck = 1
      print("Yes")
      break
  else:
    ans = 0
    
if ck == 0:
  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
flag = 0

for i in range(n):
	if d[i][0] == d[i][1]:
		cnt = cnt + 1
	else:
		cnt = 0

	if cnt == 3:
		flag = 1

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))
ok=False
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]:
        ok=True
if ok:
    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:
		break
print('Yes') if cnt >= 3 else print('No')

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = 10**6#float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
#from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N = INT()
D = [LIST() for _ in range(N)]

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

Submission status: Accepted

Solution code:
n = int(input())
lst =  []
stimmt = False
for _ in range(n):
    lst.append(list(map(str,input().split())))
for i in range(len(lst)):
    if lst[i][0] == lst[i][1]:
        if i+2 < len(lst):
            if lst[i+1][0] == lst[i+1][1] and lst[i+2][0] == lst[i+2][1]:
                stimmt = True
                break
 
if stimmt:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
D = [tuple(map(int, input().split())) for _ in range(N)]
for i in range(N-2):
	if all(D[j][0] == D[j][1] for j in range(i, i+3)):
		print('Yes')
		break
else:
	print('No')

Submission status: Accepted

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