Problem:


Score : 200 points

Problem Statement

Tak performed the following action N times: rolling two dice.
The result of the i-th roll is D_{i,1} and D_{i,2}.

Check if doublets occurred at least three times in a row.
Specifically, check if there exists at lease one i such that D_{i,1}=D_{i,2}, D_{i+1,1}=D_{i+1,2} and D_{i+2,1}=D_{i+2,2} hold.

Constraints

3 \leq N \leq 100

1\leq D_{i,j} \leq 6

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
D_{1,1} D_{1,2}
\vdots
D_{N,1} D_{N,2}

Output

Print Yes if doublets occurred at least three times in a row. Print No otherwise.

Sample Input 1

5
1 2
6 6
4 4
3 3
3 2

Sample Output 1

Yes

From the second roll to the fourth roll, three doublets occurred in a row.

Sample Input 2

5
1 1
2 2
3 4
5 5
6 6

Sample Output 2

No

Sample Input 3

6
1 1
2 2
3 3
4 4
5 5
6 6

Sample Output 3

Yes



Sample input:
5
1 2
6 6
4 4
3 3
3 2


Sample output:
Yes

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

n = int(input())
dice = []

for _ in range(n):
    d_1, d_2 = map(int,input().split())
    dice.append([d_1, d_2])

ans = 0

for i in range(n-2):
    if dice[i][0] == dice[i][1]:
        if dice[i+1][0] == dice[i+1][1] and dice[i+2][0] == dice[i+2][1]:
            ans = 1
            break
        else:
            continue
        break

if ans > 0:
    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
    if count==3:
      print('Yes')
      exit()
  else:
    count=0
print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = list2 = [[0 for i in range(2)] for j in range(N)]

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

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())
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())
cnt = 0
for k in [[int(n) for n in input().split()] for i in range(n)]:
    if k[0] == k[1]:
        cnt += 1
        if cnt >= 3:
            print('Yes')
            exit()
    else:
        cnt = 0
print('No')

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
zoro = 0

for i in range(n):
    x,y = map(int,input().split())
    if x == y:
        zoro = zoro + 1
        if ans < zoro:
            ans = zoro
    else:
        if ans < zoro:
            ans = zoro
            zoro = 0
        else:
            zoro = 0

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

Submission status: Accepted

Solution code:
n = int(input())
d = []
for i in range(n):
  t = [int(x) for x in input().split()]
  d.append(t)

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:
# -*- coding: utf-8 -*-
# 入力
N = int(input())

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

flag = 0
cont = 0
for i in l:
    if(i[0]==i[1]):
        flag = 1
        cont = cont + 1
        #print(cont)
        if (cont>=3):
            break
    else:
        cont = 0
        flag =0



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

Submission status: Accepted

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

for i in range(0, N-2, 1):
  if D[i][0] == D[i][1] and D[i+1][0] == D[i+1][1] and D[i+2][0] == D[i+2][1]:
    print("Yes")
    cnt_cons += 1
    exit()
if cnt_cons == 0:
  print("No")

Submission status: Accepted

Solution code:
import numpy as np

n=int(input())

a=np.zeros([n,2])

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

#print(a)

ans=0
for j in range(n-2):
    #print(a[j][0])
    #print(a[j][1])
    if a[j][0]==a[j][1] :
        a1=0
       # print(a1)
        if a[j+1][0]==a[j+1][1]:
            a2=0
           # print(a2)
            if a[j+2][0]==a[j+2][1] :
                a3=0
                #print(a3)
                if a1==0 and a2==0 and a3==0 :
                    ans=ans+1
                   # print(ans)
    a1=0
    a2=0
    a3=0


if ans>0 :
    print("Yes")
if ans==0 :
    print("No")

Submission status: Accepted

Solution code:
import sys
n = int(sys.stdin.readline().strip())

cnt_flag = 0
res = False
for idx in range(n):
    this_time_vec = sys.stdin.readline().strip().split(' ')
    d_1 = int(this_time_vec[0])
    d_2 = int(this_time_vec[1])
    if d_1 == d_2:
        if cnt_flag > 0:
            cnt_flag = cnt_flag + 1
            if cnt_flag >= 3:
                res = True
                break
        else:
            cnt_flag = 1
    else:
        cnt_flag = 0
    
if res == True:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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


for x in Dl :
    if x[0] == x[1] :
        a+=1

    else :
        if a>= 3 :
            a =3
        else :
            a=0


print("Yes" if a >= 3 else "No")

Submission status: Accepted

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

cnt = 0
ans = "No"
for idx in range(int(input())):
    D1, D2 = get_pair()
    if D1 == D2:
        cnt += 1
    else:
        cnt = 0

    if cnt >= 3:
        ans = "Yes"
        break
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

print("No")

Submission status: Accepted

Solution code:
n = int(input())
z = []
y = 0
for i in range(n):
  line = input().split(" ")
  if int(line[0])==int(line[1]):
    z.append(i)

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

Submission status: Accepted

Solution code:
N = int(input())

ok = 0
aa = 0
for i in range(N):
    A, B = map(int, input().split())
    if A == B:
        aa += 1
    else:
        aa = aa*0
    if aa == 3:
        ok = 1


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

Submission status: Accepted

Solution code:
import sys
N = int(input())

D = [input().split() for _ in range(N)]

count = 0

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

Submission status: Accepted

Solution code:
N = int(input())
D = [[-1,1]]*N
ans = "No"

for n in range(N):
  D[n] = list(map(int, input().split()))
  if D[n][0] == D[n][1]:
    if D[n-1][0] == D[n-1][1]:
      if D[n-2][0] == D[n-2][1]:
        ans = "Yes"
        break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
nums =[]
count = 0
switch = False
for i in range(N):
    nums.append([int(x) for x in input().split()])

for j in nums:
    if j[0] == j[1]:
        count += 1
    elif j[0] != j[1]:
        count = 0
    if count == 3:
        switch = True
if switch == True:
    print("Yes")
elif switch == False:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())

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

for i in range(n) :
    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] :
        cnt = True
        break
    else :
        cnt = False
    if i==n-3 :
        break

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

Submission status: Accepted

Solution code:
n = int(input())
c = 0
for i in range(n):
  d1,d2 = map(int,input().split())
  if d1 == d2:
    c += 1
    if c >= 3:
      print("Yes")
      exit()
  else:
    c = 0
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)]

Yes = 0
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]:
        Yes = 1
        break

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

Submission status: Accepted

Solution code:
n=int(input())
flag=0
ans=0

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

Submission status: Accepted

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

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

print("No")

Submission status: Accepted

Solution code:
import sys

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

is_success = False
flags = []


for i in range(N):
	D_one, D_two = input().split()
	D_one, D_two = int(D_one), int(D_two)
    
	if D_one == D_two:
		flags.append(True)
	else:
		flags.append(False)

	if len(flags) > 3:
		flags.pop(0)

	if all(flags) and len(flags)==3:
		is_success = True

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n-2):
    if dl[i][0] == dl[i][1] and dl[i+1][0] == dl[i+1][1] and dl[i+2][0] == dl[i+2][1]:
        print("Yes")
        exit()
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:
n=int(input())
d= [list(map(int, input().split())) for d in range(n)]

yes=0
for i in range(n-2):
    if d[i][1]==d[i][0] and d[i+1][1]==d[i+1][0] and d[i+2][1]==d[i+2][0]:
        yes+=1
    else:
        pass

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

c = 0
for i in range(len(d)):
    if (d[i][0] == d[i][1]):
        c += 1
        if (c >= 3):
          print("Yes")
          sys.exit(0)
    else:
      c = 0
print("No")

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n)  :
    a=input()
    d.append(a.split())

# print(d)


for i in range(0,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] :
        flg = True
        break


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

Submission status: Accepted

Solution code:
n = int(input())
d1d2 = [map(int, input().split()) for _ in range(n)]
d1, d2 = [list(i) for i in zip(*d1d2)]
count = 0
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]:
        count += 1
if count > 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:

n = int(input())
d = []

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

count = 0
answer = "no"
for i in range(n) :
    if d[i][0] == d[i][1] :
        count += 1
        if count > 2 :
            answer = "yes"
    else :
        count = 0
    
if answer == "yes" :
    print("Yes")
else :
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
flg = False

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

for i in range(n):
    try:
        a = res[i] + res[i+1] + res[i+2]
    except:
        break
    if a == 3:
        flg = True
        break

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

Submission status: Accepted

Solution code:
n=int(input())
count=0
flag=False
while n:
  a,b=input().split()
  if a==b:
    count+=1
  else:
    count=0
  if count>=3:
    flag=True
  n-=1
if flag:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

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

f = False
for i in range(n-2):
    if d[i][0] == d[i][1] and not f :
        if d[i+1][0] == d[i+1][1] and d[i+2][0] == d[i+2][1]:
            f = True
if f:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(len(l)-2):
    if (l[i][0]==l[i][1])&(l[i+1][0]==l[i+1][1])&(l[i+2][0]==l[i+2][1]):
        print('Yes')
        break
else:
    print('No')

Submission status: Accepted

Solution code:
a2=int(input())
a=0
b3=0
for i in range(a2):
    b2,c2=map(str,input().split())
    b=int(b2)
    c=int(c2)
    if b==c:
        a+=1
        if a==3:
            b3=1
            continue
    else:
        a=0
        
if b3>0:
    print('Yes')
if b3==0:
    print('No')

Submission status: Accepted

Solution code:
count = 0
flag = 0
leng = int(input())
list = []
for i in range(1, leng + 1):
  a,b=input().split()
  list.append((int(a), int(b)))
for j in range(0, leng):
  if(list[j][0] == list[j][1]):
    count = count + 1
  else:
    count = 0
  if(count == 3):
    flag = 1
    
if(flag == 1):
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

if(c==1):
  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 a==b:
        count+=1
        if count==3:
            print("Yes")
            exit()
        else:
            pass
            
    else :
        count=0

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

Submission status: Accepted

Solution code:
def resolve():
    throw_count = int(input())
    same_count = int(0)
    answer = "No"
    for _ in range(throw_count):
        throw_1, throw_2 = map(int, input().split())
        if throw_1 == throw_2:
            same_count += 1
            if same_count == 3:
                answer = "Yes"
                break
        else:
            if same_count > 0:
                same_count = 0
    print(answer)
resolve()

Submission status: Accepted

Solution code:
def foo(l, x):
	return l[x][0]==l[x][1]

n=int(input())
l=[tuple(input().split()) for _ in range(n)]
for i in range(n-2):
	if foo(l, i) and foo(l, i+1) and foo(l, i+2):
		print('Yes')
		quit()
print('No')

Submission status: Accepted

Solution code:
n = int(input())
count = 0
dices = []
for i in range(n):
    a, b = map(int, input().split())
    dices.append([a, b])
for i in dices:
    if count == 3:
        ans = 'Yes'
        break
    if i[0] == i[1]:
        count += 1
    else :
        count = 0
        pass

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

Submission status: Accepted

Solution code:
N = int(input())
num = 0
ans = False
for i in range(N):
  D = list(map(int, input().split(' ')))
  if D[0] == D[1]:
    num += 1
    if num >= 3:
      ans = True
  else:
    num = 0

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

Submission status: Accepted

Solution code:
''' ===============================
    -- @uthor : Kaleab Asfaw
    -- Handle : kaleabasfaw2010
    -- Bio    : High-School Student
    ==============================='''

# Fast IO
import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file): self._fd = file.fileno(); self.buffer = BytesIO(); self.writable = "x" in file.mode or "r" not in file.mode; self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            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):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE)); 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()
    def flush(self):
        if self.writable: os.write(self._fd, self.buffer.getvalue()); self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file): self.buffer = FastIO(file); self.flush = self.buffer.flush; self.writable = self.buffer.writable; self.write = lambda s: self.buffer.write(s.encode("ascii")); self.read = lambda: self.buffer.read().decode("ascii"); self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout); input = lambda: sys.stdin.readline().rstrip("\r\n")
# Others
# from math import floor, ceil, gcd
# from decimal import Decimal as d
mod = 10**9+7
def lcm(x, y): return (x * y) / (gcd(x, y))
def fact(x, mod=mod):
    ans = 1
    for i in range(1, x+1): ans = (ans * i) % mod
    return ans
def arr2D(n, m, default=0):
    lst = []
    for i in range(n): temp = [default] * m; lst.append(temp)
    return lst
def sortDictV(x): return {k: v for k, v in sorted(x.items(), key = lambda item : item[1])}

def solve(n, lst):
    for i in range(n-2):
        if lst[i][0] == lst[i][1] and lst[i+1][0] == lst[i+1][1] and lst[i+2][0] == lst[i+2][1]:
            return "Yes"
    return "No"

n = int(input())
lst = []
for i in range(n):
    a, b = list(map(int, input().split()))
    lst.append([a, b])
print(solve(n, lst))

Submission status: Accepted

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

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

b=0
c=0
while b<=N-3:
  if a[b][0]==a[b][1] and a[b+1][0]==a[b+1][1] and a[b+2][0]==a[b+2][1]:
     c=c+1
  
  b=b+1

if c>0:
  print('Yes')

else:
  print('No')

Submission status: Accepted

Solution code:
n = int(input())

cnt = 0
flg = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = [[0 for j in range(2)] for i in range(N)]
c, t = 0, 0

for i in range(N):
    D[i][0], D[i][1] = map(int, input().split())
    if D[i][0] == D[i][1]:
        c += 1
    else:
        c = 0
    if c == 3:
        t = 1
if t == 1:
    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')
        exit()
print('No')

Submission status: Accepted

Solution code:
n = int(input())

duplas = 0
sim = 0
for i in range(n):
    a,b = map(int,input().split())

    if a==b:
        duplas += 1
    else:
        duplas = 0
    
    if duplas >= 3:
        sim = 1
        break

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

Submission status: Accepted

Solution code:
N=int(input())
D=[input()for i in range(N)]
count=0
max_count=0
for i in range(N):
    if D[i].split()[0]==D[i].split()[1]:
        count+=1
        if count>max_count:
            max_count=count
    else:
        count=0
if max_count>=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)]
for a in range(N-2):
    m = l[a]
    n = l[a+1]
    o = l[a+2]
    z = 0
    if m[0] == m[1]:
        if n[0] == n[1]:
            if o[0] == o[1]:
                z = z+1
                break;
            else:
                pass
        else:
            pass
    else:
        pass
if z == 0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input())

flag = False

d1 = [0]*N
d2 = [0]*N
for i in range(N):
  d1[i], d2[i] = input().split()
  
for k in range(N-2):
  if ((d1[k])==(d2[k]))and((d1[k+1])==(d2[k+1]))and((d1[k+2])==(d2[k+2])):
    flag = True
    break
    
if flag:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
t = int(input())
con = []
for i in range(t):
    a, b = map(int, input().split())
    if a==b:
        con.append(1)
    else:
        con.append(0)
    ans =0
a = []
for i in con:
    if i ==1:
        ans += 1
        a.append(ans)
    else:
        ans = 0
        a.append(ans)
if max(a) >= 3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

A = list(0 for _ in range(N))

ans = "No"

for i in range(N):
    if D[i][0] == D[i][1]:
        A[i] = 1

for i in range(N - 2):
    if A[i] == 1 and A[i+1] == 1 and A[i+2] == 1:
        ans = "Yes"


print(ans)

Submission status: Accepted

Solution code:
N=int(input())
sum=0
name=[]
for _ in range(N):
    a,b=map(int,input().split())
    if(a==b):
        sum+=1
        if(sum==3):
            name.append("Yes")
    else:
        sum=0
    
if len(name)==0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
loop = int(input())
streak = 0
verify = False
for i in range(loop):
    diceArr = input().split()
    if diceArr[0] == diceArr[1]:
        streak+=1
        if streak==3:
            verify = True
    else:
        streak=0
if verify:
    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 a==b:
    count+=1
    if count==3:
      print("Yes")
      exit()
  else:
    count=0
print("No")

Submission status: Accepted

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    n = int(input())
    d1 = [0] * n
    d2 = [0] * n
    c = [0] * n 
    for i in range(n):
        d1[i], d2[i] = map(int, input().split())
        if d1[i] == d2[i]:
            c[i] = 1
    ans = 0
    for i in range(n - 2):
        if c[i] == 1 and c[i + 1] == 1 and c[i + 2] == 1:
            ans += 1
    if ans != 0:
        print("Yes")
    else:
        print("No")
    

    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = input()

zorome_count = 0
max_zorome_count = 0

for i in range(int(n)):
  a,b = input().split(" ")
  if a == b:
    zorome_count += 1
  else:
    if zorome_count > max_zorome_count:
      max_zorome_count = zorome_count
    zorome_count = 0

if zorome_count > max_zorome_count:
  max_zorome_count = zorome_count

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

Submission status: Accepted

Solution code:
import sys

n = int(input())

cnt = 0
for i in range(n):
    d1, d2 = input().split()
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print('Yes')
        sys.exit()
print('No')

Submission status: Accepted

Solution code:
#179-B

N = int(input())
A = []

for i in range(N):
    D,H = map(int,input().split())

    if D == H:
        A.append(i)

#print(A)
cnt = 0
if len(A) <= 2:
    cnt = 0
    #print("No")

else:
    for j in range(len(A)-2):
        if A[j]+1 == A[j+1] and A[j+1]+1 == A[j+2]:
            #print("Yes")
            cnt = 1
            break


#print(cnt)
            
if cnt == 1:
    print("Yes")

else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
cnt = [False]*n

for i in range(n):
    x,y = map(int, input().split())
    cnt[i] = x == y

ans = 'No'

for i in range(n-2):
    if cnt[i] and cnt[i+1] and cnt[i+2]:
        ans = 'Yes'

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
D=[]
A=[]
for i in range(n):
  a,b=map(int, input().split())
  D.append([a,b])


for i in range(len(D)):
  if D[i][0]==D[i][1]:
    ans +=1
  else:
    if ans>0:
      ans = 0
  A.append(ans)
  
if max(A) >= 3:
  print("Yes")
  
else:
  print("No")

Submission status: Accepted

Solution code:
in_n = input().split()
n = int(in_n[0])
in_l = []
in_r = []
for i in range(0,n):
    in_n = input().split()
    in_l.append(int(in_n[0]))
    in_r.append(int(in_n[1]))
l = 0
max_n =0
for i in range(0,n):
    if in_l[i] == in_r[i]:
        l = l +1
    else:
        l = 0
    if l > max_n:
        max_n = l
if max_n >=3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
def solve(N: int, D: "List[List[int]]"):
    count = 0
    flag = True
    for value in list(map(lambda k: k[0] == k[1], D)):
        if value:
            count += 1
        elif count < 3:
            count = 0
    ans = "Yes" if count >= 3 else "No"
    print(ans)
    return


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]]"
    solve(N, D)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def is_same(nums) -> bool:
    return nums[0] == nums[1]


def zorome(source) -> str:
    for i, nums in enumerate(source):
        if i >= len(source) - 2:
            return 'No'
        if is_same(source[i]) and is_same(source[i + 1]) and is_same(source[i + 2]):
            return 'Yes'


def main():
    count = int(input())
    nums = []
    for i in range(count):
        num1, num2 = map(int, input().split())
        nums.append((num1, num2))
    print(zorome(nums))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
count = 0
for i in range(n):
    s=input()
    if s[0] == s[2]:
        count += 1
    else:
        count = 0

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



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

Submission status: Accepted

Solution code:
n=int(input())
lst1=[]
lst2=[]
count=0
for _ in range(n):
    m,k=[int(x) for x in input().split()]
    lst1.append(m)
    lst2.append(k)
for i in range(n-2):
    if(lst1[i]==lst2[i] and lst1[i+1]==lst2[i+1] and lst1[i+2]==lst2[i+2]):
        count=3
        break
if(count==3):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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