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

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):
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')

Solution (Python):
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')

Solution (Python):
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())




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

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):
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()

Solution (Python):
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")

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


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



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    D = [[int(next(tokens)) for _ in range(2)] for _ in range(N)]  
    solve(N, D)

if __name__ == '__main__':
    main()

Solution (Python):
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')

Solution (Python):
import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict






def solve(grid):  
    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):  
    print('\033[36m', *args, '\033[0m', file=sys.stderr)
    return




for case_num in [1]:
    
    

    
    nrows = int(input())
    
    
    

    
    

    
    
    
    grid = []
    for _ in range(nrows):
        grid.append(list(map(int,input().split())))

    res = solve(grid)  
    
    
    

    
    print(res)

Solution (Python):
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")

Solution (Python):
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])

Solution (Python):
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)

Solution (Python):




import sys
from io import StringIO
import unittest





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

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

    
    
    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)
    
    

    return

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

Solution (Python):
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")

Solution (Python):
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)

Solution (Python):
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")

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):
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')

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):
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')

Solution (Python):
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')

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):





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



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



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


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

Solution (Python):
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")

Solution (Python):
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")

Solution (Python):
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")

Solution (Python):
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")

Solution (Python):
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()

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):
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()

Solution (Python):
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")

Solution (Python):
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)

Solution (Python):
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")

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):
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')

Solution (Python):
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)

Solution (Python):
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')

Solution (Python):
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")

Solution (Python):
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()

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


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



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    D = [[int(next(tokens)) for _ in range(2)] for _ in range(N)]  
    print(solve(N, D))

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

if __name__ == '__main__':
    
    main()

Solution (Python):
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')

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):
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')

Solution (Python):

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

Solution (Python):
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()

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):
import sys
import math
import collections
import bisect
import itertools
import decimal
import copy
import heapq




INF = 10 ** 20
MOD = 10 ** 9 + 7


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



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

Solution (Python):
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')

Solution (Python):

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

Solution (Python):
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()

Solution (Python):
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')

Solution (Python):
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')

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):


import sys
readline = sys.stdin.readline
read = sys.stdin.read




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

Solution (Python):
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")

Solution (Python):
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")

Solution (Python):
n = int(input())



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

Solution (Python):
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')

Solution (Python):
(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)

Solution (Python):
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'

Solution (Python):
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()

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):
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)

Solution (Python):


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

Solution (Python):
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')

Solution (Python):
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")

Solution (Python):
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])

Solution (Python):

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

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):
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")

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):
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")

Solution (Python):


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

Solution (Python):
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

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

Solution (Python):
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")