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())
ans = ""
for i in range(n):
  t1, t2 = list(map(int, input().split()))
  if t1 == t2:
    ans += "1"
  else:
    ans += "0"
if "111" in ans:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
a = [len(set(input().split())) == 1 for _ in range(int(input()))]
print('NYoe s'[any(map(all, zip(a, a[1:], a[2:])))::2])

Submission status: Accepted

Solution code:
#ABC179B

n = int(input())
a = [0]*n
b = [0]*n

ans = 'No'

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


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

print(ans)

Submission status: Accepted

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

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

        if d[i+1][0] == d[i+1][1]:
            cnt += 1

            if d[i + 2][0] == d[i + 2][1]:
                cnt += 1
                break

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
deme = []
flag = False
cnt = 0

for i in range(N):
    x, y = input().strip().split()
    #z = [int(x), int(y)]
    #deme.append(z)
    x = int(x)
    y = int(y)
    if x == y:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        flag = True

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

T=0
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]:
    T+=1
  else:
    continue
    
if T!=0:
  print ('Yes')
else:
  print ('No')

Submission status: Accepted

Solution code:
n = int(input())
d = []
for _ in range(n):
    d1, d2 = input().split()
    if d1 == d2:
        d.append(1)
    else:
        d.append(0)
for i in range(len(d)-2):
    if sum(d[i:i+3]) == 3:
        print('Yes')
        break
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
def ip(): return [int(i) for i in stdin.readline().split()]
def sp(): return [str(i) for i in stdin.readline().split()]


n = int(input())
row = False
cnt = 0
for _ in range(n):
    x,y = ip()
    if x == y: cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        row = True

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

count = 0
flag = False
for i in range(n):
  a1, a2 = map(int, input().split())
  if a1 == a2:
    count += 1
    if(count == 3):
      flag = True
  else:
    count = 0

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

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    d = []
    for i in range(n):
        d.append(list(map(int,input().split())))
    d_set = list(map(set,d))
    cnt = 0
    ans = 'No'
    for i in d_set:
        if len(i)==1:
            cnt += 1
        else:
            cnt = 0
        if cnt >= 3:
            ans = 'Yes'
            break
    print(ans)



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = input()
dlist = []
count = 0

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

for j in range(int(n)):
  if dlist[j][0] == dlist[j][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())
tab = []
good = 0
for i in range(n):
	a, b = map(int, input().split())
	tab.append([a, b])
	if i > 1:
		if tab[-1][0] == tab[-1][1] and tab[-2][0] == tab[-2][1] and tab[-3][0] == tab[-3][1]:
			good = 1
	
if good:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
n = int(input())

cnt = 0

for i in range(n):
    a,b = map(int,input().split())
    if a == b:
        cnt += 1
    elif a != b:
        cnt = 0
        
    if cnt == 3:
        print('Yes')
        exit()
        
print('No')

Submission status: Accepted

Solution code:
n=int(input())
count=0
counts=[]
z=[]
for i in range(n):
	x,y=list(map(int,input().split()))
	z.append([x,y])
z.append([-14,-20])
for i in z:
	if i[0]==i[1]:
		count+=1
	else:
		counts.append(count)
		count=0
if max(counts)>=3:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
N = int(input())

d  = []
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        ans = "same"
    else:
        ans = "different"
    d.append(ans)
flag = "No"
for i in range(N-2):
    if d[i] == "same" and d[i+1] == "same" and d[i+2] == "same":
        flag = "Yes"
print(flag)

Submission status: Accepted

Solution code:
import sys
N = int(input())
count = 0
for i in range(N):
    tmp = input().split()
    if tmp[0] == tmp[1]:
      count = count + 1
      if count >= 3:
        print("Yes")
        sys.exit()
    else:
      count = 0;

print("No")

Submission status: Accepted

Solution code:
def checkDoublet(arr):
    count = 0
    for d in arr:
        if d[0] == d[1]:
            count += 1
            if count >= 3:
                return 'Yes'
        else:
            count = 0
    return 'No'

n = int(input())
arr = []
for i in range(n):
    arr.append(list(map(int, input().rstrip().split())))
print(checkDoublet(arr))

Submission status: Accepted

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy
 


def main():
    n = int(input())
    count = 0
    flag = False
    for i in range(n):
        x,y = map(int, input().split())
        if x == y:
            count += 1
        else:
            count = 0
        
        if count == 3:
            flag = True

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
l=[]
k=0
for i in range(n):
    d=[x for x in input().split()]
    l.append(d)
    
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]:
        k+=1
        break

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

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 3 <= count:
    s = 'Yes'
    break
  else:
    s = 'No'

print(s)

Submission status: Accepted

Solution code:
N = int(input())

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

count = [0]
for p in P:
    if p[0] == p[1]:
        count.append(count[-1]+1)
    else:
        count.append(0)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np
N = int(input())
ary = np.array([list(map(int, input().split())) for i in range(N)])

zoro = (ary[:, 0] == ary[:, 1]).astype(int)

f = "No"
for i in range(len(zoro) - 2):
  if zoro[i] + zoro[i+1] + zoro[i+2] == 3:
    f = "Yes"
    break

print(f)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

        if ans == 3:
            break

    else:
        ans = 0


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

Submission status: Accepted

Solution code:
N = int(input())

count = 0
for _ in range(N):
  D = map(int, input().split())
  D = list(D)
  if D[0] == D[1]:
    count += 1
    if count >= 3:
      print('Yes')
      break
    continue
  count = 0
else:
  print('No')

Submission status: Accepted

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

result = 'No'
for d1, d2, d3 in zip(D, D[1:], D[2:]):
    if d1[0] == d1[1] and d2[0] == d2[1] and d3[0] == d3[1]:
        result = 'Yes'

print(result)

Submission status: Accepted

Solution code:
n = int(input())

nums = []
for i in range(n):
    [d_1,d_2] = input().split()
    d_1 = int(d_1)
    d_2 = int(d_2)
    nums.append([d_1,d_2])

ans = "No"
for i in range(0,n-2):
    count = 0
    for j in range(3):
        if nums[i + j][0] == nums[i + j][1]:
            count += 1
    if count == 3:
        ans = "Yes"
        break

print(ans)

Submission status: Accepted

Solution code:
x=int(input())
List=[]
counter=0
for i in range(x):
  List.append(list(map(int,input().split())))
for i in range(len(List)):
  if List[i][0]==List[i][1]:
    counter+=1
  else:
    counter=0
  if counter ==3:
    print("Yes")
    break
if counter<3:
  print("No")

Submission status: Accepted

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

k = 0
for i in range(n-2):
  if num_list[i][0] == num_list[i][1]:
    if num_list[i+1][0] == num_list[i+1][1]:
      if num_list[i+2][0] == num_list[i+2][1]:
        print('Yes')
        k += 1
        break
if k == 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)]

ans = 0
for i in range(n):
    if x[i] == y[i]:
        ans += 1
        if ans == 3:
            print("Yes")
            break
    
    else:
        ans = 0
        

if ans == 0 or ans == 1 or ans == 2:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
z = 0
f = False
for i in range(N):
    r = list(map(int, input().split()))
    if r[0] == r[1]:
        z += 1
        if z == 3:
            f = True
    elif not f:
        f = False
        z = 0
if f:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
l=[]
for i in range(n):
  a,b = list(map(int,list(input().split())))
  l.append([a,b])
def fn(n,l):
  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]:
      return 'Yes'
  return 'No'  
print(fn(n,l))

Submission status: Accepted

Solution code:
n = int(input())

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

def dice():
    cnt =0
    for i in range(n):
        if d[i][0] == d[i][1]:
            cnt += 1
            if cnt == 3:
                return "Yes"
                break
        else:
            cnt = 0
    return "No"

ans = dice()

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
t = []
i = 0
for _ in range(n):
    x, y = map(int, input().split())
    if x == y:
        i += 1
    else:
        i = 0
    t.append(i)
if(len(list(filter(lambda x: x >= 3, t))) == 0):
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
N = int(input(""))
L = [0 for i in range(N)]
flag = False

for i in range(N):
    a, b = input().strip().split()
    a, b = [int(a), int(b)]
    L[i] = a - b
for i in range(N - 2):
    if (L[i] == 0 and L[i+1] == 0 and L[i+2] == 0):
        flag = True

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

Submission status: Accepted

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

table = [False]*N
key = False

for i in range(N):
    if D1[i]==D2[i]:
        table[i] = True
    if (i>=2 and key == False):
        if (table[i]==True and table[i-1]==True and table[i-2]==True):
            key = True

if key==True:
    ans = "Yes"
else:
    ans = "No"
    
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

a = 0
for i in range(n):
    li = input().split()
    if(li[0]==li[1]):
        a+=1
    elif(a<3):
        a=0
    else:
        print("Yes")
        exit()
if(a>2):
    print("Yes")
    exit()

print("No")

Submission status: Accepted

Solution code:
N=int(input())
i=0
l=[]
for i in range(0,N):
    a,b=input().split()
    l.append(a)
    l.append(b)
    i+=1
i=0
c=0
for i in range(0,2*N):
    if i==2*N-4:
        break
    if l[i]==l[i+1]:
        if l[i+2]==l[i+3]:
            if l[i+4]==l[i+5]:
                c+=1
                break
            else:
                if i+6<2*N-5:
                    i+=6
        else:
            if i+4<2*N-3:
                i+=4
    else:
        i+=2
if c==0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
N=int(input())
d=[list(map(int,input().split())) for x 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()

print("No")

Submission status: Accepted

Solution code:
import sys

n = int(input())
deme = [input().split() for i in range(n)]

#print(deme)

toki = 0

for i in range(n):
  if deme[i][0] == deme[i][1]:
    toki += 1
    if toki >= 3:
      print("Yes")
      sys.exit(0)
    
  else:toki = 0

print("No")

Submission status: Accepted

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

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

count = 0
for i in range(N-2):
    if D[i][0]==D[i][1] and D[i+1][0]==D[i+1][1] and D[i+2][0]==D[i+2][1]:
        count = 1
        break
    else:
        pass

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

Submission status: Accepted

Solution code:
import sys
def cal():
    if D11==D12 and D21==D22 and D31==D32:
        print('Yes')
        sys.exit()

N=int(input())
D11,D12=map(int,input().split())
D21,D22=map(int,input().split())
D31,D32=map(int,input().split())
cal()
for _ in range(0,N-3):
    D11=D21
    D12=D22
    D21=D31
    D22=D32
    D31,D32=map(int,input().split())
    cal()
print('No')

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    D = []
    n = int(input())
    for i in range(n):
        d = list(map(int, input().split()))
        D.append(d)
        
    for i in range(n):
        flag = 0
        for j in range(n-i):
            if D[i+j][0] == D[i+j][1]:
                flag += 1
            else:
                break
        if flag == 3:
            print('Yes')
            exit()
    
    print('No')


    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

zoro_cnt = 0
for _ in range(N):
  D1, D2 = map(int,input().split())
  if D1 == D2:
    zoro_cnt += 1
    if zoro_cnt == 3:
      break
  else:
    zoro_cnt = 0
    
if zoro_cnt == 3:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

if a==0:
    
    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]]"):

    flag=0

    for i in range(N):

        if D[i][0] == D[i][1]:
            flag += 1
            if flag >= 3:
                print(YES)
                return
        else:
            flag=0
        
    print(NO)


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

dice = []
for i in range(n):
    dice.append(list(map(lambda x: int(x), input().split(" "))))

if n < 3:
    print("No")
    exit(0)

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

print("No")

Submission status: Accepted

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

count = 0

for i in range(N):
    x, y = D[i]
    if x == y:
        count += 1
        if count >= 3:
            print('Yes')
            exit()
    else:
        count = 0

print('No')

Submission status: Accepted

Solution code:
N=int(input())
DD=[]
t=0

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

for i in range(N-2):
    if (DD[i][0]-DD[i][1])**2+(DD[i+1][0]-DD[i+1][1])**2+(DD[i+2][0]-DD[i+2][1])**2==0:
        t=1
        break
    i+=1
if t==1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
N = int(input())
count = 0
for _ in range(N):
    d1, d2 = input().split()
    if d1 == d2:
        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())
count = 0
check = 0
for i in range(1,n+1):
    a, b = map(int, input().split())
    if a == b:
        count+=1
        if count >= 3:
            check = 1
    elif a != b:
        count = 0

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

Submission status: Accepted

Solution code:
# BC179-B Go to Jail
N = int(input())
D = []
for i in range(N):
    D.append(input())
yes = 0
yes3 = 0
for i in range(N):
    D1, D2 = map(int, D[i].split(' '))

    # print(D1, D2)
    if D1 == D2:
        yes += 1
        if yes >= 3:
            yes3 = 1
    else:
        yes = 0
if yes3 == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import math
from fractions import Fraction as frac

MOD = 1e9 + 7

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a * b // gcd(a, b)

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

t = 1
# t = int(input())
for i in range(1, t + 1):
    solve(i)

Submission status: Accepted

Solution code:
n = int(input())
count = 0
f = False
for i in range(n):
  d1, d2 = [int(x) for x in input().split()]
  if d1 == d2:
    count += 1
  else:
    count = 0
  if count == 3:
    f = True
if f:
  print("Yes")
else :
  print("No")

Submission status: Accepted

Solution code:
N = int(input())
x = []
count = 0
for i in range(N):
    D1,D2 = map(int,input().split())
    t = [D1,D2]
    x.append(t)
i = 0
while i <= N-3:
    if i > N-3:
        break
    elif x[i][0] == x[i][1] and x[i+1][0] == x[i+1][1] and x[i+2][0] == x[i+2][1]:
        t = 'Yes'
        break
    else:
        t = 'No'
    i +=1
print(t)

Submission status: Accepted

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

count = 0
for s in list:
    if s[0] == s[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())
a_lst = []
b_lst = []
clear = 0
cnt = 0
for i in range(n):
  a, b = map(int, input().split())
  a_lst.append(a)
  b_lst.append(b)

for a, b in zip(a_lst, b_lst):
  if a == b:
    cnt += 1
  else:
    cnt = 0

  if cnt == 3:
    clear = 1
    break

if clear == 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])
count = 0
flag = True
for x in a:
    if x[0] == x[1]:
        count += 1
        if count == 3:
            print('Yes')
            flag = False
            break
    else:
        count = 0

if flag:
    print('No')

Submission status: Accepted

Solution code:
#input
n = int(input())
d1 = [0] * n
d2 = [0] * n
for i in range(n):
    d1[i],d2[i] = map(int, input().split())

def main():
    for i in range(n-2):
        #print ("{} {} {} {} {} {}".format(d1[i],d2[i],d1[i+1] ,d2[i+1],d1[i+2],d2[i+2]))
        if d1[i] == d2[i] and d1[i+1] == d2[i+1] and d1[i+2] == d2[i+2]:
            print('Yes')
            exit()
    print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

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

cnt = 0
renzoku = 0
for d in dlist:
    if d[0] == d[1]:
        cnt+=1
        renzoku += 1
    else:
        renzoku = 0
        cnt = 0
    if cnt == 3 and renzoku == 3:
        print('Yes')
        break
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')
    exit()
print('No')

Submission status: Accepted

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

f = 0

for i in range(n):
    if li[i][0] == li[i][1]:
        f = f+1
        if f == 3:
            print("Yes")
            break
    else:
        f = 0

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

Submission status: Accepted

Solution code:
#                               #
    # author : samars_diary #
    # 19-09-2020 │ 17:40:08 #
#                               #

import sys, os.path

if(os.path.exists('input.txt')):
    sys.stdin = open('input.txt',"r")
    #sys.stdout = open('output.txt',"w")

sys.setrecursionlimit(10 ** 5)

def mod(): return 10**9+7
def i(): return sys.stdin.readline().strip()
def ii(): return int(sys.stdin.readline())
def li(): return list(sys.stdin.readline().strip())
def mii(): return map(int, sys.stdin.readline().split())
def lii(): return list(map(int, sys.stdin.readline().strip().split()))

#print=sys.stdout.write

def solve():
    a=ii() ; p = q = 0 ;
    for _ in range(a):
        a,b=mii()
        if a==b:
            p+=1
            if p>q:
                q=p
        else: 
            p=0
    if q>=3: print('Yes')
    else: print('No')

for _ in range(1):
    solve()

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
l = [list(map(int,input().split())) for _ in range(n)] #複数行複数入力を多重リストに

c=1
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]:
        c=0
        break
            
if c==0:
    print("Yes")
if c==1:
   print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
S = []
judge = 0
for i in range(N):
    S += [input().split()]
for i in range(N):
    if i <= N-3:
        if S[i][0] == S[i][1]:
            if S[i+1][0] == S[i+1][1]:
                if S[i+2][0] == S[i+2][1]:
                    print("Yes")
                    judge = 1
                    break
if judge == 0:
    print("No")

Submission status: Accepted

Solution code:
def main():
    count=0
    n=int(input())
    x = [list(map(int, input().split())) for i in range(n)]
    for i in range(n):
        if x[i][0]==x[i][1]:
            count=count+1
        else:
            count=0

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


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





if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

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

cnt = 0
tmp = 0
for i in range(n):
  if D[i][0] == D[i][1]:
    tmp +=1
    cnt = max(cnt,tmp)
  else:
    tmp = 0
    cnt = max(cnt,tmp)

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

Submission status: Accepted

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

d = [list(map(int,input().split())) for i in range(c)]
for i in range(c):
    a,b = d[i][0],d[i][1]
    
    if (a==b):
        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())

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

print(answer)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

n = int(input())

count = 0
ans = "No"

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

row = 0
ans = 'No'

for n in range(N):
    D1, D2 = map(int, input().split())
    if D1==D2 and row<2:
        row+=1
    elif D1==D2 and row>=2:
        ans='Yes'
    else:
        row=0
print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

if ans >= 3: ans = 'Yes'
else: ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
n=int(input()) 
idx=[] 
c=0 
for i in range(n):
	x,y=map(int,input().split()) 
	if x==y:
		idx.append(c) 
	c+=1  
if len(idx)<3:
	print('No') 
else:
	flag=False 
	#print(idx)
	for i in range(len(idx)-2): 
		if idx[i]-idx[i+1]==-1 and idx[i+1]-idx[i+2]==-1:
			flag=True  
			break 
	dd={False:'No',True:'Yes'}
	print(dd[flag])

Submission status: Accepted

Solution code:
N=int(input())
L=0
for i in range(N):
    K=set(map(int,input().split()))
    if len(K)==1:
        L+=1
        if L==3:
            print('Yes')
            break
    else:
        L=0
if L<3:
    print('No')

Submission status: Accepted

Solution code:
number = int(input())
dicesList = []
for n in range(number):
  dicesList.append(list(input().split()))
doubletNumber = 0
for dices in dicesList:
  if dices[0] == dices[1]:
    doubletNumber += 1
  else:
    doubletNumber = 0
  if doubletNumber == 3:
    break
if doubletNumber == 3:
  print("Yes")
else:
  print("No")