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):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *DD = map(int, read().split())
    
    count = 0
    for d1, d2 in zip(*[iter(DD)] * 2):
        if d1 == d2:
            count += 1
            if count == 3:
                print('Yes')
                return
        else:
            count = 0
    
    print('No')
    return


if __name__ == '__main__':
    main()

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

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

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:
            break
    else:
        cnt = 0

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

Solution (Python):
n = int(input())
l = []
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        l.append(1)
    else:
        l.append(0)
cur = 0
ans = 0
for i in range(n):
    if l[i] == 1:
        cur += 1
    else:
        ans = max(ans, cur)
        cur = 0
ans = max(ans, cur)
print("Yes" if ans >= 3 else "No")

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

print("No")

Solution (Python):
N, = [int(x) for x in input().split()]
DD = [[int(x) for x in input().split()] for i in range(N)]
isDoublet = [x == y for x, y in DD]
for i in range(N-2):
    if isDoublet[i] and isDoublet[i + 1] and isDoublet[i + 2]:
        print('Yes')
        exit()
print('No')

Solution (Python):
import sys
import re
import random
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter



input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def solve():
    n = getN()
    ans = 0
    cnt = 0
    for i in range(n):
        a, b = getList()
        if a == b:
            cnt += 1
        else:
            cnt = 0
        ans = max(ans, cnt)

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

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    
    solve()

Solution (Python):
import sys

input = sys.stdin.readline
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
cnt = 0
for d1, d2 in D:
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print('Yes')
        sys.exit(0)

print('No')

Solution (Python):
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")
        break
else:
    print("No")

Solution (Python):
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
ct=0
for i in range(n):
  if l[i][0]==l[i][1]:
    ct+=1
  else:
    ct=0
  if ct==3:
    print('Yes')
    exit()
print('No')

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

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

count = 0
ans = 'No'
for i in range(n):
    p, q =list(map(int, input().split()))
    if p == q:
        count += 1
    else:
        count = 0
    if count >= 3:
        ans = 'Yes'

print(ans)

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

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

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

Solution (Python):

from collections import defaultdict, deque, Counter, OrderedDict
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from heapq import heappush, heappop, heapify

import itertools
import math, fractions
import sys, copy

def L(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline().rstrip())
def SL(): return list(sys.stdin.readline().rstrip())
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI1(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return [list(x) for x in sys.stdin.readline().split()]
def R(n): return [sys.stdin.readline().strip() for _ in range(n)]
def LR(n): return [L() for _ in range(n)]
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def LIR1(n): return [LI1() for _ in range(n)]
def SR(n): return [SL() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]

def perm(n, r): return math.factorial(n) // math.factorial(r)
def comb(n, r): return math.factorial(n) // (math.factorial(r) * math.factorial(n-r))

def make_list(n, *args, default=0): return [make_list(*args, default=default) for _ in range(n)] if len(args) > 0 else [default for _ in range(n)]

dire = [[1, 0], [0, 1], [-1, 0], [0, -1]]
dire8 = [[1, 0], [1, 1], [0, 1], [-1, 1], [-1, 0], [-1, -1], [0, -1], [1, -1]]
alphabets = "abcdefghijklmnopqrstuvwxyz"
ALPHABETS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
MOD = 1000000007
INF = float("inf")

sys.setrecursionlimit(1000000)

def main():
    N = I()
    D = LIR(N)

    cnt = 0
    for d1, d2 in D:
        if d1 == d2:
            cnt += 1
            if cnt >= 3:
                break
        else:
            cnt = 0
    else:
        print("No")
        return
    print("Yes")

if __name__ == '__main__':
    main()

Solution (Python):
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

n = int(input())
point = 0
flag = False

for _ in range(n):
    a,b = map(int,input().split())
    
    if a == b:
        point += 1
    else:
        point = 0

    if point == 3:
        flag = True

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

Solution (Python):
n = int(input())
ans = 0
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):
N = int(input())

cur = 0
f = False
for i in range(N):
    a,b = [int(_n) for _n in input().split()]
    if a == b:
        cur+=1
        if cur == 3:
            f = True
    else:
        cur = 0
print("Yes" if f else "No")

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

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

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

Solution (Python):
N = int(input())
arr = [list(map(int, input().split())) for _ in range(N)]
for i in range(N-2):
    if arr[i][0] == arr[i][1] and arr[i+1][0] == arr[i+1][1] and arr[i+2][0] == arr[i+2][1]:
        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):
    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


def solve(n, ab):
    s = 0
    for a, b in zip(ab[0::2], ab[1::2]):
        if a == b:
            s += 1
        else:
            s = 0
        if s >= 3:
            return True
    return False


n, *ab = map(int, sys.stdin.buffer.read().split())

print('Yes' if solve(n, ab) else 'No')

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

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
a = [tuple(map(int, input().split())) for _ in range(N)]
for i in range(N - 2):
  if a[i][0] == a[i][1] and (a[i + 1][0] == a[i + 1][1]) and (a[i + 2][0] == a[i + 2][1]):
    print("Yes")
    break
else: print("No")

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

Solution (Python):
N = int(input())
C = 0
for i in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        C += 1
    else:
        C = 0
    if C == 3:
        print('Yes')
        exit()
print('No')

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

cnt = 0
ans = False
for a, b in D:
  if a == b:
    cnt += 1
  else:
    cnt = 0
  if cnt == 3:
    ans = True

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

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

Solution (Python):
N = int(input())
out = "No"
Ds = []
for i in range(N):
    Ds.append(list(map(int,input().split())))
for i in range(N-2):
    if Ds[i][0]==Ds[i][1] and Ds[i+1][0]==Ds[i+1][1] and Ds[i+2][0]==Ds[i+2][1]:
        out = "Yes"
print(out)

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    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__':
    resolve()

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

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

Solution (Python):


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

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())

    cur = 0
    cnt = 0
    for _ in range(N):
        x, y = map(int, readline().split())
        if x == y:
            cur += 1
        else:
            cur = 0
        cnt = max(cnt, cur)

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


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
D = [list(map(int,input().split())) for _ in range(N)]
i = 0
judge=False
for a,b in D:
  if a==b:
    i+=1
  else:
    i=0
  if i>=3:
    judge=True
    break
    
if judge:
  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')
        exit()
else:
    print('No')

Solution (Python):
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    N = int(input())
    flags = []
    for _ in range(N):
        ai, bi = map(int, input().split())
        flags.append(ai == bi)

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

    print("No")


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
D = [tuple(map(int,input().split())) for i in range(N)]
for (a1,a2),(b1,b2),(c1,c2) in zip(D,D[1:],D[2:]):
    if a1==a2 and b1==b2 and c1==c2:
        print('Yes')
        exit()
print('No')

Solution (Python):
N = int(input())
count = 0
for i in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        if count == 2:
            print("Yes")
            exit()
        else:
            count += 1
    else:
        count = 0
print("No")

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

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

Solution (Python):

from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for _ in range(n)]
def LIR(n):
    return [LI() for _ in range(n)]
def SR(n):
    return [S() for _ in range(n)]
def LSR(n):
    return [LS() for _ in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    d = LIR(n)
    for i in range(n-2):
        if d[i][0] == d[i][1]:
            if d[i+1][0] == d[i+1][1]:
                if d[i+2][0] == d[i+2][1]:
                    print("Yes")
                    return
    print("No") 
    return


if __name__ == "__main__":
    solve()

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

Solution (Python):
import sys
input = sys.stdin.readline
n = int(input())
C = [list(map(int,input().split())) for i in range(n)]

A = [0] * n
for i in range(n):
    if C[i][0] == C[i][1]:
        A[i] = 1

ans = 0
for i in range(n-2):
    if A[i]==1 and A[i+1]==1 and A[i+2]==1:
        ans = 1
if ans == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
res = False
doubles = 0

for _ in range(n):
  (a, b) = map(int, input().split())
  if a == b:
    doubles += 1
  else:
    doubles = 0
  if doubles > 2:
    res = True
    break
    
print('Yes' if res else 'No')

Solution (Python):
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    count = 0
    ans = False
    for i in range(n):
        a, b = map(int, input().split())
        if a == b:
            count += 1
        else:
            count = 0
        if count == 3:
            ans = True
    
    print("Yes" if ans else "No")
    
    
    
if __name__ == "__main__":
    main()

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

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

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

Solution (Python):
import sys, math, re
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    D = [list(mi()) for i in range(N)]
    for i in range(N-2):
        if D[i][0] == D[i][1] and D[i+1][0] == D[i+1][1] and D[i+2][0] == D[i+2][1]:
            print('Yes')
            return

    print('No')

if __name__ == "__main__":
    main()

Solution (Python):
def main():
    N = int(input())
    z = 0
    for i in range(N):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            z += 1
        else:
            z = 0
        if z >= 3:
            return True

    return False

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

Solution (Python):



from math import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq














import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7


INF = float('inf')
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
n = I()
ans = 0
for i in range(n):
    a,b = readInts()
    if a == b:
        ans += 1
    else:
        ans = 0
    if ans >= 3:
        break
print('Yes' if ans >= 3 else 'No')

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

T=0
M=0

for _ in range(N):
    D,E=map(int,input().split())
    if D==E:
        T+=1
        M=max(M,T)
    else:
        T=0

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

Solution (Python):

import os
import sys
from io import BytesIO, IOBase

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


from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    n = int(input())
    
    
    
    
    
    cur = 0
    ans = 0
    for i in range(n):
        x, y = map(int, input().split())
        if x == y:
            cur += 1
        else:
            ans = max(ans, cur)
            cur = 0
    ans = max(ans, cur)
    print("Yes" if ans >= 3 else "No")

Solution (Python):
import sys

sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
z = 0
for i in range(n):
    a, b = na()
    if a == b:
        z += 1
    else:
        z = 0
    if z >= 3:
        print("Yes")
        sys.exit()
print("No")

Solution (Python):

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


def f(p):
    return p[0] == p[1]


for i in range(n - 2):
    a = True
    for j in range(3):
        a &= f(d[i + j])
    ok |= a
if ok:
    print('Yes')
else:
    print('No')

Solution (Python):
n = int(input())
zo=[False]*n
for i in range(n):
  a,b = map(int,input().split())
  if a==b:
    zo[i] = True
for i in range(n-2):
  if zo[i] and zo[i+1] and zo[i+2]:
    print("Yes");exit()
print("No")

Solution (Python):


import sys
input=sys.stdin.readline

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

Solution (Python):

import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

N=int(input())
c=0
for _ in range(N):
    d=list(map(int,input().split()))
    if d[0]==d[1]:
        c+=1
    else:
        c=0
    if c==3:
        print('Yes')
        exit()
print('No')

Solution (Python):

import sys
input = sys.stdin.buffer.readline
N = int(input())
A = [tuple(map(int, line.split())) for line in sys.stdin.buffer.readlines()]

for P, Q, R in zip(A, A[1:], A[2:]):
    if P[0] == P[1] and Q[0] == Q[1] and R[0] == R[1]:
        print('Yes')
        break
else:
    print('No')

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

Solution (Python):
FAST_IO = 0
if FAST_IO:
    import io, sys, atexit
    rr = iter(sys.stdin.read().splitlines()).next
    sys.stdout = _OUTPUT_BUFFER = io.BytesIO()

    @atexit.register
    def write():
        sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
else:
    rr = raw_input
rri = lambda: int(rr())
rrm = lambda: map(int, rr().split())
rrmm = lambda n: [rrm() for _ in xrange(n)]


MOD = 10**9 + 7
YES, NO, IMP = "YES", "NO", "IMPOSSIBLE"
from collections import defaultdict as ddic

def solve(N,A):

    for i in xrange(N-2):
        for j in xrange(3):
            if A[i+j][0] != A[i+j][1]:
                break
        else:
            return 'Yes'
    return 'No'
N= rri()
A = rrmm(N)
print solve(N, A)

Solution (Python):

N = int(input())

now = 0
ans = "No"

for i in range(N):

    a,b = map(int,input().split())
    if a == b:
        now += 1
    else:
        now = 0

    if now >=  3:
        ans = "Yes"

print (ans)

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

c = 0
for i, j in d:
    if i==j:
        c += 1
        if c == 3:
            print('Yes')
            import sys
            sys.exit()
    else:
        c = 0
print('No')

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

def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')







def solve():
    N = II()
    cnt = 0
    for i in range(N):
        d1, d2 = MI()
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0

        if cnt == 3:
            print('Yes')
            return
    print('No')

if __name__ == '__main__':
    solve()

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

Solution (Python):



n=int(input())
a=[]
for i in range(n):
  aa,b=map(int,input().split())
  if aa==b:a.append("1")
  else:a.append("0")
if "111" in "".join(a):print('Yes')
else:print('No')