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())
grid = []
for i in range(n):
    array = list(map(int, input().strip().split(' ')))
    grid.append(array)

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

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

Submission status: Accepted

Solution code:
n=int(input())

cnt=0
ans=0

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

ans=max(ans,cnt)


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

else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
Z = 0

for n in range(N):
  D1,D2 = map(int,input().split())
  if D1==D2:
    Z+=1
    if Z==3:
      print("Yes")
      exit()
  else:
    Z=0

print("No")

Submission status: Accepted

Solution code:
N=int(input())
cnt=0
for i 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:
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a

# Union Find
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

# 約数生成
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

inf = 10 ** 18
mod = 10 ** 9 + 7

n = ir()
ans = 0
for i in range(n):
    a,b = lr()
    if a==b:
        ans+=1
    else:
        ans=0
    if ans == 3:
        print('Yes')
        sys.exit()
print('No')

Submission status: Accepted

Solution code:
n = int(input())

c = 0
flag = False

for i in range(n):
    x, y = list(map(int, input().split()))
    if x == y:
        c += 1
        if c == 3:
            flag = True
            break
    else:
        c = 0

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

Submission status: Accepted

Solution code:
import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
d = [IL() for i in range(N)]

cnt = 0
for i,j in d:
  if i == j:
    cnt += 1
  else:
    cnt = 0
  if cnt == 3:
    print("Yes")
    exit()
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

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

z = [0 for _ in range(N)]
tmp = 0
for i in range(N):
  d1, d2 = map(int,input().split())
  if d1 == d2:
    tmp += 1
  else:
    tmp = 0
  if tmp >= 3:
    print("Yes")
    sys.exit()
    
print("No")

Submission status: Accepted

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



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
tmp = 0
for a, b in D:
    if a == b:
        cnt += 1
    else:
        cnt = 0
    tmp = max(tmp, cnt) 

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

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')
    exit()
print('No')

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N = in_n()

    ans = []
    for i in range(N):
        a, b = in_nn()
        ans.append(a == b)

    f = False
    for i in range(N - 2):
        if ans[i] == ans[i + 1] == ans[i + 2] == True:
            f = True
            break

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


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

Submission status: Accepted

Solution code:
N = int(input())
D = [list(map(int,input().split())) for n in range(N)]
count = 0
ans = "No"

for d1,d2 in D:
  if d1==d2:
    count+=1
    if count==3:
      ans = "Yes"
      break
  else:
    count = 0

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

n=int(input())
l=[]
for i in range(n):
    x,y=map(int,input().split())
    if x==y:
        l.append(1)
    else:
        l.append(0)

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

zoro = 0

for i in range(N):
    D1, D2 = list(map(int, input().split()))

    if (D1 == D2):
        zoro += 1
    else:
        zoro = 0

    if (zoro == 3):
        print("Yes")
        exit(0)

print("No")

Submission status: Accepted

Solution code:
def main():
    n = int(input())
    num = 0
    for _ in range(n):
        x, y = map(int, input().split())
        if x == y:
            num += 1
            if num >= 3:
                print("Yes")
                return
        else:
            num = 0
    print("No")

if __name__ == "__main__":
    main()

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]]"):
    E = [d0 == d1 for d0, d1 in D]
    return YES if any(all(e) for e in zip(E, E[1:], E[2:])) else NO


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
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]]"
    print(solve(N, D))

def test():
    import doctest
    doctest.testmod()

if __name__ == '__main__':
    #test()
    main()

Submission status: Accepted

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

c = 0
maxc = 0
for i in range(n):
    if d[i][0] == d[i][1]:
        c += 1
        maxc = max(maxc, c)
    else:
        c = 0
if maxc >= 3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())

ans = 0
tmp = 0
for _ in range(N):
    d1, d2 = mapint()
    if d1==d2:
        tmp += 1
    else:
        tmp = 0
    ans = max(ans, tmp)
if ans>=3:
    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
    else:
        cnt = 0
    if cnt == 3:
        print('Yes')
        break
else:
    print('No')

Submission status: Accepted

Solution code:
# import numpy as np
import sys, math, heapq
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial, gcd
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep="\n")

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

is_cont = False
cnt = 0
for d in D:
    d1, d2 = d
    if d1 == d2:
        is_cont = True
        if is_cont:
            cnt += 1
            if cnt >= 3:
                print("Yes")
                exit()
        else:
            cnt = 1
    else:
        is_cont = False
        cnt = 0
print("No")

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
t = int(input())

best = 0
cur = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import math
import collections
import bisect
import itertools
import decimal
import copy
import heapq

# import numpy as np

# sys.setrecursionlimit(10 ** 6)
INF = 10 ** 20
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline().rstrip())
ns = lambda: map(int, sys.stdin.readline().rstrip().split())
na = lambda: list(map(int, sys.stdin.readline().rstrip().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().rstrip().split()))
flush = lambda: sys.stdout.flush()


# ===CODE===
def main():
    n = ni()
    cnt = 0
    for _ in range(n):
        a, b = ns()
        if a == b:
            cnt += 1
        else:
            cnt = 0

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

    print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
X = [0]*n
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        X[i] = 1
c = 0
for i in range(n-2):
    if X[i] == 1 and X[i+1] == 1 and X[i+2] == 1:
        print('Yes')
        exit()
else:
    print('No')

Submission status: Accepted

Solution code:

url = "https://atcoder.jp//contests/abc178/tasks/abc178_b"

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    N=int(input())
    flag=0
    counter=0
    for i in range(N):
        D1,D2=map(int,input().split())
        if D1==D2:
            counter+=1
        else:
            counter=0
        if counter==3:
            flag=1

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

Submission status: Accepted

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

flag=False
for i in range(2,N):
    if D1[i-2]==D2[i-2] and D1[i-1]==D2[i-1] and D1[i]==D2[i]:
        flag=True
        break

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
d=[]
for _ in range(n):
  x,y=map(int,input().split())
  d.append([x,y])
  
for i in range(n-2):
  if d[i][0]==d[i][1] and d[i+1][0]==d[i+1][1] and d[i+2][0]==d[i+2][1]:
    print('Yes')
    exit()
print('No')

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

#n,q = map(int, readline().split())
#*a, = map(int, readline().split())

n = int(input())

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

Submission status: Accepted

Solution code:
n = int(input())
D = [tuple(int(x) for x in input().split()) for _ in range(n)]
tmp = 0
for d1, d2 in D:
    if d1 == d2:
        tmp += 1
    else:
        tmp = 0
    if tmp == 3:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
#a, b = map(int,input().split())
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
count=0
mx=0
for i in range(n):
    d1,d2=map(int,input().split())
    if d1==d2:
        count+=1
    else:
        count=0
    mx=max(count,mx)
if mx>=3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from sys import exit

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')

Submission status: Accepted

Solution code:
(N, ) = [int(n) for n in input().split()]

D = []
for _ in range(N):
    d = [int(n) for n in input().split()]
    D.append(d[0] == d[1])

ans = 'No'
for a, b, c in zip(D, D[1:], D[2:]):
    if a and b and c:
        ans = 'Yes'
print(ans)

Submission status: Accepted

Solution code:
n = int(raw_input())
c = 0
flag = False
for _ in range(n):
	a,b = map(int, raw_input().split())
	if a == b:
		c+=1
	else:
		c = 0
	if c == 3:
		flag = True
		break
print 'Yes' if flag else 'No'

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N=ii()
    X = []
    for i in range(N):
        x,y=mi()
        X.append((x,y))
    
    count = 0
    for i in range(N):
        if X[i][0] == X[i][1]:
            count += 1
        else:
            count = 0
        
        if count >= 3:
            print("Yes")
            exit()
    
    print("No")





if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
N = int(input())
D = [[int(x) for x in 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')
        sys.exit(0)

print('No')

Submission status: Accepted

Solution code:
N = int(input())
sig = 0
Ans = 'No'
for i in range(N):
  C,D = map(int,input().split())
  if C == D:
    sig += 1
  else:
    sig = 0
  if sig == 3:
    Ans = 'Yes'
print(Ans)

Submission status: Accepted

Solution code:
#create date: 2020-09-19 21:01

import sys
stdin = sys.stdin

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    n = ni()
    cnt = 0
    ans = False
    for _ in range(n):
        d1, d2 = na()
        if d1 == d2:
            cnt += 1
            if cnt == 3:
                ans = True
        else:
            cnt = 0
    print("Yes" if ans else "No")
        

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
D = [l() for _ in range(N)]
cnt = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        cnt += 1
        if cnt == 3:
            break
    else:
        cnt = 0
if cnt == 3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

print("No")

Submission status: Accepted

Solution code:
ng = True
cnt = 0
for i in range(int(input())):
    a, b = map(int, input().split())
    if a==b: cnt+=1
    else: cnt = 0
    if cnt>=3: ng = False
print("YNeos"[ng::2])

Submission status: Accepted

Solution code:
#ABC179-b
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:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n = k()
d = [l() for i in range(n)]

for i in d:
  if i[0] == i[1]:
    cnt += 1
  else:
    cnt = 0
  if cnt == 3:
    print("Yes")
    sys.exit()

print("No")

Submission status: Accepted

Solution code:
import sys
n = int(input())
count = 0
for _ in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        count += 1
    else:
        if count >= 3:
            print('Yes')
            sys.exit()
        else:
            count = 0

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

Submission status: Accepted

Solution code:
n=int(input())
x,y=[],[]
for i in range(n):
    x_,y_=map(int,input().split())
    x.append(x_)
    y.append(y_)
for i in range(n-2):
    if x[i]==y[i] and x[i+1]==y[i+1] and x[i+2]==y[i+2]:
        print("Yes")
        break
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
# -*- coding: utf-8 -*-
# map(int, input().split())
N = int(input())

zorome = 0
for n in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        zorome += 1
    else:
        zorome = 0
    if zorome == 3:
        print('Yes')
        exit()

print('No')

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

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

cnt = 0

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

Submission status: Accepted

Solution code:
n = int(input())
d = [[int(i) for i in input().split()] for j 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")
        exit()
        
print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
def main():
    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')
            return
    print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

cnt = 0
for f,s in F_S:
  if cnt >= 3:
    break
  if f == s:
    cnt += 1
  else:
    cnt = 0
if cnt >= 3:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

strk = 0
ans = False
for i in range(n):
    a, b = list(map(int, input().split()))

    if a == b:
        strk += 1
        if strk == 3:
            ans = True
    else:
        strk = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
n=int(input().rstrip())
cnt=0
tmp=0
for i in range(n):
    a,b=map(int,input().split())
    if a==b:
        tmp+=1
    else:
        cnt=max(cnt,tmp)
        tmp=0
cnt=max(cnt,tmp)

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

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    count = 0
    bl = False
    for _ in range(N):
        a, b = map(int, readline().split())
        if a==b:
            count += 1
            if count>=3:
                bl = True
                break
            else:
                continue
        else:
            count = 0
    if bl:
        print('Yes')
    else:
        print('No')

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

Submission status: Accepted

Solution code:
import sys
# sys.setrecursionlimit(100000)


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


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    cnt = 0
    ans = 0
    for _ in range(n):
        a, b = input_int_list()
        if a == b:
            cnt += 1
        else:
            ans = max(ans, cnt)
            cnt = 0
    else:
        ans = max(ans, cnt)

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import groupby
class Combination:
    def __init__(self, n, mod):
        self.n = n
        self.mod = mod
        self.fac = [1 for i in range(self.n + 1)]
        self.finv = [1 for i in range(self.n + 1)]
        for i in range(2, self.n+1):
            self.fac[i] = (self.fac[i - 1] * i) % self.mod
            self.finv[i] = (self.finv[i - 1] * pow(i, -1, self.mod)) % self.mod

    def comb(self, n, m):
        return self.fac[n] * (self.finv[n - m] * self.finv[m] % self.mod) % self.mod
        
def iparse():
    return list(map(int, input().split()))


# RUN LENGTH ENCODING str -> tuple


def runLengthEncode(S: str):
    grouped = groupby(S)
    res = []
    for k, v in grouped:
        res.append((k, str(len(list(v)))))
    return res


if __name__ == "__main__":
    n = int(input())
    cnt = 0
    for i in range(n):
        d, e = iparse()
        if d == e:
            cnt += 1
        else:
            cnt = 0
            
        if cnt == 3:
            print("Yes")
            exit()
    print("No")