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:
def solve():
    n = int(input())
    rolls = [list(map(int,input().split())) for i in range(n)]
    for i in range(n-2):
        if rolls[i][0]==rolls[i][1] and rolls[i+1][0]==rolls[i+1][1] and rolls[i+2][0]==rolls[i+2][1]:
                return True

    return False

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

Submission status: Accepted

Solution code:
def has_triples(dices):
    for i in range(len(dices) - 2):
        a1, b1 = dices[i]
        a2, b2 = dices[i+1]
        a3, b3 = dices[i+2]

        if a1 == b1 and a2 == b2 and a3 == b3:
            return True

    return False


n = int(input())
dices = []
for _ in range(n):
    a, b = map(int, input().split(" "))
    dices.append((a, b))

print("Yes" if has_triples(dices) else "No")

Submission status: Accepted

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

print('No')

Submission status: Accepted

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

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

cont = 0
for d1, d2 in D:
    if d1 == d2:
        cont += 1
    else:
        cont = 0
    if cont >= 3:
        print('Yes')
        exit()
print('No')
exit()

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
cnt = 0
ans = 0
for i in range(N):
    a, b = map(int, readline().split())
    if a==b:
        cnt+=1
    else:
        cnt=0
    ans = max(cnt,ans)
print('Yes' if ans >=3 else 'No')

Submission status: Accepted

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

ans = 'No'
z = 0
for i, j in d_l:
    if i == j:
        z+=1
    else:
        z=0
    if z == 3:
        ans = 'Yes'
        break
print(ans)

Submission status: Accepted

Solution code:
# abc179_b.py
N = int(input())
cnt =0
for i in range(N):
    N, M = map(int,input().split())
    if N==M:
        cnt+=1
    else:
        cnt = 0
    if cnt>=3:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

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



if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def resolve():
    n = int(input())
    ans = 0
    for _ in range(n):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            ans += 1
        else:
            ans = 0
        if ans == 3:
            print("Yes")
            return

    print("No")

resolve()

Submission status: Accepted

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

Submission status: Accepted

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

N=int(input())
c = 0
for _ 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())
flag = False
a =0
for i in range(n):
    n, m = map(int, input().split())
    if n ==m:
        a +=1
    else:
        a =0
    if a == 3:
        flag = True
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())

ds = []
count = 0
for i in range(n):
    d = list(map(int, input().split()))
    if d[0] == d[1]:
        count += 1
    else:
        count = 0

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

Submission status: Accepted

Solution code:
N = int(input())

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

cnt = 0

for i in range(N):
    if D[i][0] == D[i][1]:
        cnt += 1
    elif cnt < 3:
        cnt = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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: Accepted

Solution code:
n = int(input())
d = [list(map(int,input().split())) for _ in range(n)]
d_bool = [d1==d2 for d1,d2 in d]
for b1,b2,b3 in zip(d_bool,d_bool[1:],d_bool[2:]):
    if b1&b2&b3:
        print("Yes")
        break
else:
    print("No")

Submission status: Accepted

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

cnt = 0
for x, y in D:
    if x == y:
        cnt += 1
    else:
        cnt = 0

    if cnt >= 3:
        print('Yes')
        exit()

print('No')

Submission status: Accepted

Solution code:
def main():
    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')
            return
    print('No')

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

def resolve():
    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')
            return
    print('No')

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
N = int(input())

max_cnt = 0
cnt = 0
for i in range(N):
    a, b = map(int, input().split())
    if a == b:
        cnt += 1
    else:
        cnt = 0
    max_cnt = max(max_cnt, cnt)

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

Submission status: Accepted

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

flag = 0
for i in range(1, n-1):
  if arr[i-1][0] == arr[i-1][1] and arr[i][0] == arr[i][1] and arr[i+1][0] == arr[i+1][1]:
    flag = 1
    break
if flag == 1:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import sys,math,collections
from collections import defaultdict

#from itertools import permutations,combinations
    
def file():
    sys.stdin = open('input.py', 'r')
    sys.stdout = open('output.py', 'w') 
def get_array():
    l=list(map(int, input().split()))
    return l
def get_ints():   
    return map(int, input().split())
    #return a,b
def get_3_ints():   
    a,b,c=map(int, input().split())
    return a,b,c    
def sod(n):
    n,c=str(n),0
    for i in n: 
        c+=int(i)
    return c    
def isPrime(n):
    if (n <= 1):
        return False
    if (n <= 3):
        return True
    if (n % 2 == 0 or n % 3 == 0):
        return False
    i = 5
    while(i * i <= n):
        if (n % i == 0 or n % (i + 2) == 0):
            return False
        i = i + 6
  
    return True
def getFloor(A, x):

    (left, right) = (0, len(A) - 1)

    floor = -1
    while left <= right:
        mid = (left + right) // 2
        if A[mid] == x:
            return A[mid]
        elif x < A[mid]:
            right = mid - 1
        else:
            floor = A[mid]
            left = mid + 1
            
    return floor
def chk(aa,bb):
	f=0
	for i in aa:
		for j in bb:
			if(j[0]>=i[0] and j[1]<=i[1]):
				f+=1
			elif(j[0]<=i[0] and j[1]>=i[1]):	
				f+=1
			elif(i[0]==j[1] or i[1]==j[0]):
				f+=1
			else:
				continue
	return f			

#file()
def main():
	s=""
	for tt in range(int(input())):
		a,b=get_ints()
		if(a==b):
			s+='1'
		else:
			s+='0'
	if('111' in s):
		print('Yes')	
	else:
		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)]
count = 0
ans = "No"
for i in range(n):
    if d[i][0] == d[i][1]:
        count += 1
    else:
        count = 0
    if count >= 3:
        ans = "Yes"
print(ans)

Submission status: Accepted

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

def ri():
    return int(input())

def rl():
    return list(input().split())

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

def main():
    n = ri()
    cnt = 0
    for i in range(n):
        d1, d2 = rli()
        if d1 == d2:
            cnt += 1
            if cnt == 3:
                print("Yes")
                return
        else:
            cnt = 0
    print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())


zoroStreak = 0
zoroMaxStreak = 0
for i in range(N):
  d = list(map(int, input().split()))
  if d[0] == d[1]:
    zoroStreak += 1
    zoroMaxStreak = max(zoroMaxStreak, zoroStreak)
  else:
    zoroStreak = 0

if 3 <= zoroMaxStreak:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

t = 0
s = 0

for i in range(N):
    if D[i][0] == D[i][1]:
        t += 1
    else:
        t = 0
    if t >= 3:
        s = 1
        break
if s == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]
cnt = 0
flag = False
for i in range(n):
  if d[i][0]==d[i][1]:
    cnt+=1
  else:
    cnt = 0
  if cnt == 3:
    flag = True
if flag:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()
D = [tuple(MI()) for _ in range(N)]
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')
        break
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

flag = 0

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

Submission status: Accepted

Solution code:
n=int(input())

zorome_max=0
zorome=0

for i in range(n):
    one,two=[int(i) for i in input().split()]
    if one==two:
        zorome+=1
        zorome_max=max(zorome_max,zorome)
    else:
        zorome=0

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

Submission status: Accepted

Solution code:
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    N = int(input())

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

n = int(input())

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

Submission status: Accepted

Solution code:
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)

    cnt = 0
    for d1, d2 in zip(it, it):
        if d1 != d2:
            cnt = 0
        else:
            cnt += 1
            if cnt == 3:
                print("Yes")
                break
    else:
        print("No")

if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:
n=int(input())
f=lambda:map(int,input().split())
c=0
for i in range(n):
  d,e=f()
  if d==e: c+=1
  else: c=0
  if c==3: exit(print('Yes'))
print('No')

Submission status: Accepted

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

streak = 0
ans = False

for a, b in d:
    if a == b:
        streak += 1
    else:
        streak = 0
    if streak >= 3: ans = True; break

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

Submission status: Accepted

Solution code:
# coding: utf-8

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

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:
        k=True
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
N = int(input())
s = 0
o = []
for i in range(N):
    o.append(tuple(map(int,input().split())))

for A,B in o:
    if A == B:
        s += 1
        if s == 3:
            print('Yes')
            exit()
    else:
        s = 0
print('No')

Submission status: Accepted

Solution code:
n = int(input())

jail = False
count = 0
for i in range(n):
  a,b = input().split()
  if a == b:
    count += 1
  else:
    count = 0
  if count >= 3:
    jail = True
    
if jail:
  print("Yes")
else:
  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
    if cnt == 3:
      print('Yes')
      exit()
  else:
    cnt = 0

print('No')

Submission status: Accepted

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

for i, j, k in zip(range(N), range(1, N), range(2, N)):
    if D[i][0] == D[i][1] and D[j][0] == D[j][1] and D[k][0] == D[k][1]:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
import sys
#import string
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np
#import sympy

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    #A, B, C = map(int, stdin.readline().rstrip().split())
    #l = list(map(int, stdin.readline().rstrip().split()))
    numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    #word = [stdin.readline().rstrip() for _ in range(n)]
    #number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
    #zeros = [[0] * w for i in range(h)]
    for i in range(n-2):
        if numbers[i][0] == numbers[i][1] and numbers[i+1][0] == numbers[i+1][1] and numbers[i+2][0] == numbers[i+2][1]:
            print("Yes")
            exit()
    print("No")
    exit()


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
n = int(input())

ans = False
tmp = 0
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        tmp += 1
    else:
        tmp = 0
    if tmp >= 3:
        ans = True

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

Submission status: Accepted

Solution code:
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
n = ni()
cnt=0
f=False
for i in range(n):
    d1,d2 = ma()
    if d1==d2:
        cnt+=1
    else:
        cnt=0
    if cnt==3:
        f=True
        break
yn(f)

Submission status: Accepted

Solution code:
N = int(input())
cnt = 0
for i in range(N):
    d1, d2 = [int(x) for x in input().split()]
    if d1 == d2:
        cnt += 1
        if cnt ==3:
            print('Yes')
            exit()
    else:
        cnt = 0
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())

cunt = 0
for _ in range(N):
    x,y = map(int,input().split())
    if x == y:
        cunt += 1
    else:
        cunt = 0

    if cunt == 3:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
N = int(input())
cur = 0
ok = False
for _ in range(N):
    D1, D2 = input().split()
    if D1 == D2:
        cur += 1
    else:
        cur = 0
    if cur == 3:
        ok = True
if ok:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

import sys

N = int(input())

zoromes = 0
for i in range(N):
    D1, D2 = (int(x) for x in input().split())
    if D1 == D2:
        zoromes += 1
        if zoromes >= 3:
            print("Yes")
            sys.exit(0)
    else:
        zoromes = 0
print("No")

Submission status: Accepted

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

N = int(readline())
D = [len(set(map(int, readline().split()))) == 1 for _ in range(N)]
ans = 'No'
for i in range(1, N-1):
    if D[i-1] and D[i] and D[i+1]:
        ans = 'Yes'
print(ans)

Submission status: Accepted

Solution code:
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N, DD):
    count = 0
    for d1, d2 in DD:
        if d1 == d2:
            count += 1
        else:
            count = 0
        if count >= 3:
            print('Yes')
            return
    print('No')


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    # A = [int(i) for i in input().split()]
    # B = [int(i) for i in input().split()]
    DD = [[int(i) for i in input().split()] for _ in range(N)]
    solve(N, DD)

    # # test
    # from random import randint
    # from func import random_str
    # solve()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
import copy
import numpy as np
n = int(input())
#n, m = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

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

print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
ls=[0 for _ in range(N)]
for i in range(N):
  a,b=[int(s) for s in input().split()]
  if a==b:
    ls[i]=1
for i in range(N-2):
  if ls[i]==1 and ls[i+1]==1 and ls[i+2]==1:
    print('Yes')
    break
else:
  print('No')

Submission status: Accepted

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

main()

Submission status: Accepted

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

Submission status: Accepted

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

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


def solve(N: int, D: "List[List[int]]"):
    f = False
    c = 0
    for i in range(N):
        if D[i][0] == D[i][1]:
            c += 1
            if c == 3:
                f = True
                break
        else:
            c = 0
    if f:
        print("Yes")
    else:
        print("No")

    return


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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

# available on Google, not available on Codeforces
# import numpy as np
# import scipy


def solve(grid):  # fix inputs here
    console("----- solving ------")

    for a,b,c in zip(grid, grid[1:], grid[2:]):
        if a[0] == a[1] and b[0] == b[1] and c[0] == c[1]:
            return "Yes"
    return "No"


def console(*args):  # the judge will not read these print statement
    print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return

# fast read all
# sys.stdin.readlines()

for case_num in [1]:
    # read line as a string
    # strr = input()

    # read line as an integer
    nrows = int(input())
    
    # read one line and parse each word as a string
    # lst = input().split()

    # read one line and parse each word as an integer
    # lst = list(map(int,input().split()))

    # read matrix and parse as integers (after reading read nrows)
    # lst = list(map(int,input().split()))
    # nrows = lst[0]  # index containing information, please change
    grid = []
    for _ in range(nrows):
        grid.append(list(map(int,input().split())))

    res = solve(grid)  # please change
    
    # Google - case number required
    # print("Case #{}: {}".format(case_num+1, res))

    # Codeforces - no case number required
    print(res)

Submission status: Accepted

Solution code:
N = int(input())
D_L = [[int(x) for x in input().split()] for y in range(N)]

cnt = 0
for di1, di2 in D_L:
    if di1 == di2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print("Yes")
        exit(0)
print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
#import itertools
#import heapq
#from collections import deque
#d = deque()

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    #n,m,k=map(int, readline().rstrip().split())
    #arr=list(map(int, readline().rstrip().split()))
    n=int(readline())
    x=0
    ans="No"
    for i in range(n):
        a,b=map(int, readline().rstrip().split())
        if a==b:
            x+=1
        else:
            x=0
        if x >= 3:
            ans="Yes"
    print(ans)
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Submission status: Accepted

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

cnt = 0
mc = 0

for i, j in D:
    if i == j:
        cnt += 1

    else:
        if cnt > mc:
            mc = cnt
        cnt = 0

if cnt > mc:
    mc = cnt

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

Submission status: Accepted

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

Submission status: Accepted

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

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(n):
    if d[i][0]==d[i][1]:
        cnt+=1
        if cnt==3:
            print('Yes')
            exit()
    else:
        cnt=0
print('No')

Submission status: Accepted

Solution code:
N = int(input())
count = 0
flag = False
for i in range(N):
  x, y = map(int, input().split())
  if x==y:
    count += 1
    if count == 3:
      flag = True
      break
  else:
    count = 0
if flag:
  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
for d in D:
    if d[0] == d[1]:
        cnt += 1
        if cnt >= 3:
            print('Yes')
            exit()
    else:
        cnt = 0
print('No')

Submission status: Accepted

Solution code:
N = int(input())
n = 0
f = False
for _ in range(N):
    D1, D2 = list(map(int, input().split()))
    if D1 == D2:
        n += 1
    else:
        n = 0
    if n >= 3:
        f = True
print('Yes' if f else 'No')