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: Runtime Error

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: Runtime Error

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

for i in range(n-3):
  if z[i]==z[i+1]:
    if z[i+1]==z[i+2]:
      y += 1
if y > 0:
  print("yes")
else:
  print("no")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = int(input())

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


b = []
for i in range(n):
    if a[i][0] == a[i][1]:
        b.append(1)
    else:
        b.append(0)

c = 0
for i in range(n):
    if b[i] == 1 and b[i+1] == 1 and b[i+2] == 1:
        c = 1
        break

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

Submission status: Runtime Error

Solution code:
n = int(input())
res =0
for i in range(n):
  p = int(input())
  k = int(input())
  if p==k:
    res+=1
if res>=3:
   print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
input = stdin.readline

N = int(input())

b = False
cnt = 0
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        cnt += 1
        if cnt == 3:
            b = True
    else:
        cnt = 0

if b == False:
    print('No')
else:
    print('Yes')

Submission status: Runtime Error

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

count = 0
flag = 0
for i in range(n):
  if d1[i]==d2[i]:
    count += 1
  else:
    count = 0
  if count == 3:
    flag = 1
    print('Yes')
    break

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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


for i in range(n - 1):
    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: Runtime Error

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

doubles = [d1 == d2 for d1,d2 in dices]

for i in range(1,rolls):
  doubles[i] *= (doubles[i] + doubles[i-1])
  if double[i] == 3:
    print('Yes')
    exit()

print('No')

Submission status: Runtime Error

Solution code:
#python
for _ in range(int(input())):
	n1,n2=map(int,input().split())
	if n1==n2:
		c+=1
		m=max(m,c)
	else:
		m=max(m,c)
		c=0
if m>=3:
	print('Yes')
else:
	print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n = input()

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

Submission status: Runtime Error

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

seq = 0
for i in range(len(D)):
    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: Runtime Error

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

Submission status: Runtime Error

Solution code:
for _ in range(int(input())):
	n1,n2=map(int,input().split())
	if n1==n2:
		c+=1
		m=max(m,c)
	else:
		m=max(m,c)
		c=0
if m>=3:
	print('Yes')
else:
	print('No')

Submission status: Runtime Error

Solution code:
n = int(input())
cnt =0
def dice():
    for i in range(n):
        d = list(map(int, input().split()))
        if d[0] == d[1]:
            cnt += 1
            if cnt == 3:
                return "Yes"
            
        else:
            cnt = 0

ans = dice()

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=input()

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

Submission status: Runtime Error

Solution code:
def main():
	N = int(input())
	z = []
	for i in range(N):
		d1, d2 = [int(d) for d in input().split(" ")]
		if d1 == d2:
			z.append(1)
		else:
			z.append(0)
	zc = []
	now = 2
	c = 0
	for i in range(len(z)):
		if i == 0:
			now = z[i]
			c += 1
		elif now == z[i]:
			c += 1
		elif now == 1 and z[i] == 0:
			zc.append(c)
			c = 1
			now = z[i]
		elif now == 0 and z[i] == 1:
			c = 1
			now = z[i]
	else:
		if now == 1:
			zc.append(c)

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

main()

Submission status: Runtime Error

Solution code:
N = int(input())
Flag = False
MAXC = 0
Cont = 0
for TN in range(0,N):
    D1,D2 = (int(T) for T in input().split())
    if Flag==False and D1==D2:
        Flag = True
        Cout = 1
    elif Flag==True and D1==D2:
        Cout += 1
    elif Flag==True and D1!=D2:
        Flag = False
        MAXC = max(MAXC,Cout)
MAXC = [MAXC,max(MAXC,Cout)][Flag]
print(['No','Yes'][MAXC>=3])

Submission status: Runtime Error

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

for i in range(n):
  a,b = map(int,split().input())
  if a == b:
    total += 1
    if total == 3:
      break
  else:
    total = 0
if total == 3:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=input()

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
N = int(input())
Flag = False
MAXC = 0
for TN in range(0,N):
    D1,D2 = (int(T) for T in input().split())
    if Flag==False and D1==D2:
        Flag = True
        Cout = 1
    elif Flag==True and D1==D2:
        Cout += 1
    elif Flag==True and D1!=D2:
        Flag = False
        MAXC = max(MAXC,Cout)
MAXC = [MAXC,max(MAXC,Cout)][Flag]
print(['No','Yes'][MAXC>=3])

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#B
n = int(input())
count=0
mcount=0
for i in range(n):
    a,b = list(map(int, input().split()))
    if a==b:
        count+=1
        if mcount<count:
            mcount = count
            if mcount=3:
                break
    else:
        count=0
if mcount=3:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
for _ in range(int(input())):
	n1,n2=map(int,input().split())
	if n1==n2:
		c+=1
		m=max(m,c)
	else:
		m=max(m,c)
		c=0
	#print(c)
if m>=3:
	print('Yes')
else:
	print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#from collections import deque
#from heapq import heapify, heappop, heappush
#from bisect import insort
#from math import gcd
#mod = 10**9 + 7
N = int(input())
#N, K = map(int, input().split())
#A = list(map(int, input().split()))
flag1 = False
flag2 = False
flag3 = False
c, d = map(int, input().split())
if c == d:
	flag1 = True
c, d = map(int, input().split())
if c == d:
	flag2 = True
c, d = map(int, input().split())
if c == d:
	flag3 = True

k = 3
while k < N:
	if flag1 and flag2 and flag3:
		break
	k += 1
	c, d = map(int, input().split())
	flag1 = flag2
	flag2 = flag3
	if c == d:
		flag3 = True
	else:
		flag3 = False
		

#ans = 0
#print(ans)
#print('Yes')
if flag1 and flag2 and flag3:
	print('Yes')
else:
	print('No')#from collections import deque
#from heapq import heapify, heappop, heappush
#from bisect import insort
#from math import gcd
#mod = 10**9 + 7
N = int(input())
#N, K = map(int, input().split())
#A = list(map(int, input().split()))
flag1 = False
flag2 = False
flag3 = False
c, d = map(int, input().split())
if c == d:
	flag1 = True
c, d = map(int, input().split())
if c == d:
	flag2 = True
c, d = map(int, input().split())
if c == d:
	flag3 = True

k = 3
while k < N:
	if flag1 and flag2 and flag3:
		break
	k += 1
	c, d = map(int, input().split())
	flag1 = flag2
	flag2 = flag3
	if c == d:
		flag3 = True
	else:
		flag3 = False
		

#ans = 0
#print(ans)
#print('Yes')
if flag1 and flag2 and flag3:
	print('Yes')
else:
	print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

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

print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
cnt = 0
ans = False
for i in range(n):
    a,b = dd[i]
    if a == b:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        ans = True
if ans:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
N = int(input())
count = 0
for i in range(N):
    di_1, di_2 = int(input().split())
    if di_1 == di_2:
        count += 1
    else:
        count = 0
if count >= 3:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
n=int(input())
a=[]
for i in range(n):
  x,y=map(int,input().split())
  a.append([x,y])
f=0;
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]):
    f=1
if f:
  print("Yes")
else :
  print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import re
n=int(input())

s = ""
for _ in range(n):
    d1,d2 = input().split()
    if d1==d2:
        s+="1"
    else:
        s+="0"
#print(s)
a = max([len(x) for x in re.findall(r"1+", s)])
if a >= 3:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
#B
N=int(input())
cnt=0
flag=False
for i in range(N):
    a,b=map(int,input().split())
    if a==b:
        cnt+=1
    else:
        cnt=0
    if cnt=3:
        flag=True
        break
if flag:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
from sys import exit
N = int(input())
 
cnt = 0
for i in range(N):
    x,y = map(int,input().split())
    if cnt == 3:
        print("Yes")
        exit(0)
    if x == y:
        cnt += 1
    else:
        cnt = 0

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

Submission status: Runtime Error

Solution code:
num = input()
d = []
for n in range(num):
    t, s = input().split()
    d.append([t,s])
flag = 0
for n in range(num):
    if(n<num-2):
        if(d[n][0]==d[n][1] and d[n+1][0]==d[n+1][1] and d[n+2][0]==d[n+2][1]):
            flag = 1
if flag == 1:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
N = int(input())

nums = []
for a in range(N):
  ci = []
  ci.append(int(input()))
  ci.append(int(input()))
  nums.append(ci)

zoro = maximum = 0
for a in range(N):
  if nums[a][0] == nums[a][1]:
    zoro += 1
    maximum = max(maximum, zoro)
  else:
    zoro = 0

Submission status: Runtime Error

Solution code:
import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N = NI()
    AB = [NLI() for _ in range(N)]
    
    for n in range(N):
        if AB[n][0] == AB[n][1]:
            if AB[n+1][0] == AB[n+1][1]:
                if AB[n+2][0] == AB[n+2][1]:
                    print("Yes")
                    sys.exit()
    print("No")





if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n=int(input())
*a,=map(int,open(0).read().split())



for i in range(2,2*n):
    if a[i-2]==a[i-1]==a[i]:
        print('Yes')
        break
else:
    print('No')

Submission status: Runtime Error

Solution code:
s=int(input())
for i in range(s):
    p= list(map(int, input().split()))
    if p[0]==p[1]:
        z+=1
        if z==3:
            print("Yes")
            exit()
    else:
        z=0

print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

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