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:
# by the authority of GOD     author: manhar singh sachdev #

import os,sys
from io import BytesIO, IOBase

def main():
    n = int(input())
    x = [tuple(list(map(int,input().split())))for _ in range(n)]
    for i in range(n-2):
        if x[i][0]==x[i][1] and x[i+1][0]==x[i+1][1] and x[i+2][0]==x[i+2][1]:
            print('Yes')
            exit()
    print('No')
    
#Fast IO Region
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")

if __name__ == '__main__':
    main()

Submission status: Accepted

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def main():
    INF = 999999999999999999999999
    MOD = 10**9+7

    n = int(input())

    now = 0
    for _ in range(n):
        a,b = get_nums_l()
        if a == b:
            now += 1
            if now >= 3:
                print("Yes")
                return
        else:
            now = 0
    print("No")

main()

Submission status: Accepted

Solution code:
def resolve():
    ans = 0
    count = 0
    N = int(input())
    for i in range(N):
        d, D = map(int, input().split())
        if d == D:
            ans += 1
        else:
            ans = 0
        if count < ans:
            count = ans
    print("Yes" if count  >= 3 else "No")
resolve()

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N=int(input())
D=[[int(i) for i in input().split()] for i in range(N)]
for i in range(1,N-1):
    if D[i-1][0]==D[i-1][1] and D[i][0]==D[i][1] and D[i+1][0]==D[i+1][1]:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
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]:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:

# here you can test your code...


n = int(input())
flag = False
cnt=0
for i in range(n):
    x,y = map(int,input().split())
    if x!=y:
        if cnt>=3:
            flag = True
        cnt = 0
    else:
        cnt+=1
if cnt >=3:
    flag = True
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

print("No")

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    double_count = 0
    for _ in range(N):
        n1, n2 = [int(s) for s in input().split()]
        if n1 == n2:
            double_count += 1
        else:
            double_count = 0
        if double_count == 3:
            print('Yes')
            return
    print('No')

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque, defaultdict
from fractions import gcd
from functools import reduce
from itertools import groupby, combinations
from heapq import heapify, heappush, heappop

# sys.setrecursionlimit(5000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return list(map(lambda x: x + d, A))
def ldec(A, d=1): return list(map(lambda x: x - d, A))

N = n1()

cnt = 0
ans = 0
for i in range(N):
    D1, D2 = nn()
    if D1 == D2: cnt += 1
    else: cnt = 0
    if cnt >= 3: ans = 1

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

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import permutations
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

for i in range(N):
    for j in range(i, i + 3):
        if j >= N:
            break
        a, b = D[j]
        if a != b:
            break
    else:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
cnt = 0
N = int(input())
for _ in range(N):
    x, y = map(int, input().split())
    if x==y and cnt == 2:
        print("Yes")
        exit()
    elif x==y:
        cnt += 1
    else:
        cnt = 0
print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

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

for i in range(n-2):
    d11,d12=d[i]
    d21,d22=d[i+1]
    d31,d32=d[i+2]
    if d11==d12 and d21==d22 and d31==d32:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    D = [list(map(int, input().split())) 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')
            exit()
    print('No')


if __name__ == "__main__":
    main()

Submission status: Accepted

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

N=int(input())
D=[tuple(map(int,input().split())) for i in range(N)]
flag=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]:
        flag=1

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

Submission status: Accepted

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

e = []
for d1, d2 in dd:
  e.append(int(d1 == d2))

for i in range(len(e)):
  if tuple(e[i: i + 3]) == (1, 1, 1):
    print('Yes')
    exit()

print('No')

Submission status: Accepted

Solution code:
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
D = []
for i in range(N):
	d = rl()
	D.append(d)

c = 0
for a, b in D:
	if a == b:
		c += 1
	else:
		c = 0
	if c >= 3:
		print('Yes')
		exit()
print('No')

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

Solution code:

def main():
    n = int(input())
    com = 0

    for _ in range(n):
        d1, d2 = map(int, input().split())

        if d1 == d2:
            com += 1
        else:
            com = 0

        if com == 3:
            print('Yes')
            return

    print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

flg = False
cnt = 0
for d1, d2 in d:
  if d1 == d2:
    cnt += 1
  else:
    cnt = 0
  if cnt == 3:
    flg = True
if flg:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()
a=[[int(i) for i in raw_input().split()]for j in range(n)]
flag=0
for i in range(2,n):
    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]:
        flag=1
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 i in range(n):
    if d[i][0] == d[i][1]:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print('Yes')
        quit()

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())
count = 0
for i in range(n):
    x, y = map(int, input().split())
    if x == y:
        count += 1
        if count == 3:
            print('Yes')
            exit()
    else:
        count = 0
print('No')

Submission status: Accepted

Solution code:
def main():

    N = int(input())
    cnt = 0
    for _ in range(N):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3: return 'Yes'
    return 'No'

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    D = []
    for _ in range(N):
        a, b = (int(i) for i in input().split())
        D.append(int(a == b))

    if any(sum(D[i:i+3]) == 3 for i in range(N-3+1)):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:


n=int(input())
ln=0
mx=0

for _ in range(n):
	l,r=map(int,input().split())
	if l == r:
		ln += 1
	else:
		ln = 0
	mx = max(mx, ln)

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

Submission status: Accepted

Solution code:
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c for j in range(b)] for i in range(a)]
def list3d(a, b, c, d): return [[[d for k in range(c)] for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**19
MOD = 10**9 + 7
EPS = 10**-10

N = INT()
ans = False
cnt = 0
for i in range(N):
    a, b = MAP()
    if a == b:
        cnt += 1
        if cnt >= 3:
            ans = True
    else:
        cnt = 0
if ans:
    Yes()
else:
    No()

Submission status: Accepted

Solution code:
N  =int(input())

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

Submission status: Accepted

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

for i in range(N - 2):
    if zoro[i] and zoro[i + 1] and zoro[i + 2]:
        print("Yes")
        exit()
        
print("No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from fractions import Fraction
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations, accumulate
from operator import add, mul, sub, itemgetter, attrgetter


import sys
# sys.setrecursionlimit(10**6)
# readline = sys.stdin.buffer.readline
readline = sys.stdin.readline

INF = 1 << 60


def read_int():
    return int(readline())


def read_int_n():
    return list(map(int, readline().split()))


def read_float():
    return float(readline())


def read_float_n():
    return list(map(float, readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def ep(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.perf_counter()
        ret = f(*args, **kwargs)
        e = time.perf_counter()

        ep(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, D):
    c  = 0
    for d1, d2 in D:
        if d1 == d2:
            c +=1
            if c >= 3:
                return 'Yes'
        else:
            c = 0
    return 'No'


def main():
    N = read_int()
    D = [read_int_n() for _ in range(N)]
    print(slv(N, D))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

    print('No')
    

main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("## ",*x,file=sys.stderr) if LOCAL else 0
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    cnt=0
    for a,b in S:
        if a==b:
            cnt+=1
        else:
            cnt=0
        if cnt==3:
            print("Yes")
            return
    print("No")



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = []
for _ in range(n):
  a.append([int(i) for i in input().split(" ")])
b = []
for i in range(n):
  if a[i][0] == a[i][1]:
    b.append(1)
  else:
    b.append(0)
ans = False
for i in range(n-2):
  if b[i] == 1 and b[i+1] == 1 and b[i+2] == 1:
    ans = True
    break
if ans:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inl = lambda: [int(x) for x in sys.stdin.readline().split()]
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    n = ini()
    c = 0
    for i in range(n):
        x, y = inl()
        if x == y:
            c += 1
        else:
            c = 0
        if c == 3:
            return True
    return False


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

Submission status: Accepted

Solution code:
n = int(input())

zorome = 0

for i in range(n):

    a,b=map(int, input().split())
    if(a==b):zorome+=1
    else:zorome = 0
    if(zorome==3):print("Yes");exit()

print("No")

Submission status: Accepted

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



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    n = int(input())

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
c=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")
        break
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
for _ in range(n):
    d0, d1 = tuple(map(int, input().split()))
    if d0 == d1:
        cnt += 1
    else:
        cnt = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
zoro=0
res=0
for _ in [0]*N:
    a,b=map(int,input().split())
    if a==b:
        zoro+=1
        res=max(res,zoro)
    else:
        zoro=0
print(['No','Yes'][res>2])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
N = int(input())
cnt = 0

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

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    N = int(input())
    cnt = 0
    for _ 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())

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

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

# from operator import itemgetter
sysread = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
printout = sys.stdout.write
sprint = sys.stdout.flush
# from heapq import heappop, heappush
# from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
# import math
# from itertools import product, accumulate, combinations, product
# import bisect
# import numpy as np
# from copy import deepcopy
#from collections import deque
# from decimal import Decimal
# from numba import jit

INF = 1 << 50
EPS = 1e-8
mod = 10 ** 9 + 7


def intread():
    return int(sysread())
def mapline(t=int):
    return map(t, sysread().split())
def mapread(t=int):
    return map(t, read().split())

def run():
    N = int(sysread())
    count = 0
    for i in range(N):
        a,b = mapline()
        if a == b:
            count += 1
        else:
            count = 0
        if count == 3:
            print('Yes')
            return
    print('No')


if __name__ == "__main__":
    run()

Submission status: Accepted

Solution code:
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

n=I()
zoro=0
for i in range(n):
    d1,d2=L()
    if d1==d2:
        zoro+=1
    else:
        zoro=0
    if zoro>=3:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from typing import List, Any


def read_int() -> int:
    return int(input().strip())


def read_ints() -> List[int]:
    return list(map(int, input().strip().split(' ')))


def solve() -> Any:
    N = read_int()
    count = 0
    for _ in range(N):
        d0, d1 = read_ints()
        if d0 == d1:
            count += 1
            if count > 2:
                return 'Yes'
        else:
            count = 0
    return 'No'


if __name__ == '__main__':
    print(solve())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

n = inp()
s = ""
for i in range(n):
    a,b = ip()
    if a == b:
        s += '1'
    else:
        s += '0'
if '111' in s:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# region header
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
import copy
# @lru_cache(maxsize=None)
# sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
# endregion
# region input function


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


# endregion

n = inp()
cnt = 0
for i in range(n):
    a, b = inpl()
    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 i in range(N):
  a,b = map(int,input().split())
  if a != b:
    cnt = 0
  else:
    cnt += 1
    if cnt >= 3:
      print("Yes");exit()
print("No")