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

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


def rii():
    return [int(v) for v in input().split()]


def solve():
    N = ri()
    D = []
    for _ in range(N):
        D.append(rii())

    ans = c = 0
    double = False
    for r1, r2 in D:
        if r1 == r2:
            if not double:
                count = 0
            double = True
            count += 1
            ans = max(ans, count)
        else:
            double = False

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


if __name__ == "__main__":
    solve()

Solution (Python):
from sys import stdin

input = stdin.readline

def solve():
    N = int(input())
    dice = [tuple(map(int,inp.split())) for inp in stdin.read().splitlines()]

    for (a,b),(c,d),(e,f) in zip(dice,dice[1:],dice[2:]):
        if a==b and c==d and e==f:
            print('Yes')
            return
    print('No')



if __name__ == '__main__':
    solve()

Solution (Python):
def dise(s):
    if s[0]==s[1]:
        return 1
    else:
        return 0

N=int(input())
s=[]
for i in range(0,N):
    s.append(dise(list(map(int,input().split()))))

for j in range(0,N-2):
    if s[j]==1:
        j+=1
        if s[j]==1:
            j+=1
            if s[j]==1:
                print('Yes')
                break
else:
    print('No')

Solution (Python):
N = int(input())
cnt = 0
flg = False

for i in range(N):
    D = [int(x) for x in input().split()]
    if D[0] == D[1]:
        cnt += 1
        if cnt == 3:
            flg = True
            break
    else:
        cnt = 0

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

Solution (Python):
import sys
sys.setrecursionlimit(1000000000)
import math
from math import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations, combinations, chain, product
from functools import lru_cache
from collections import deque, defaultdict
from operator import itemgetter
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    num = 1
    for i in range(n, n-k, -1):
        num = num * i % modp
    den = 1
    for i in range(2, k+1):
        den = den * i % modp
    return num * get_inv(den, modp) % modp

def comb_from_list(n, k, modp, fs, invs):
    return fs[n] * invs[n-k] * invs[k] % modp



class UnionFindEx:
    def __init__(self, size):
        
        self.roots = [-1] * size
    def getRootID(self, i):
        r = self.roots[i]
        if r < 0:   
            return i
        else:
            r = self.getRootID(r)
            self.roots[i] = r
            return r
    def getGroupSize(self, i):
        return -self.roots[self.getRootID(i)]
    def connect(self, i, j):
        r1, r2 = self.getRootID(i), self.getRootID(j)
        if r1 == r2:
            return False
        if self.getGroupSize(r1) < self.getGroupSize(r2):
            r1, r2 = r2, r1
        self.roots[r1] += self.roots[r2]    
        self.roots[r2] = r1
        return True

Yes = 'Yes'
No = 'No'

def main():
    N = ii()
    ans = 'No'
    c = 0
    for _ in range(N):
        a, b = mis()
        if a == b:
            c += 1
            if c >= 3:
                ans = 'Yes'
        else:
            c = 0
    print(ans)






main()

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

ans = 'No'
flag = False
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 = True
  if flag:
    ans = 'Yes'
    break
    
print(ans)

Solution (Python):
num = int(input())
goal = 0
success = False

for n in range(num):
  a,b = input().split()
  if int(a) == int(b):
    goal += 1
  else:
    goal = 0
   
  if goal == 3:
    success = True
    
if success:
  print("Yes")
else:
  print("No")

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

    if max_ < flag:
        max_ = flag

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

Solution (Python):
N=int(input())
i=0
for n in range(0,N):
    d1,d2=[int(x) for x in input().split(' ')]
    if d1==d2:
        i+=1
        if i >= 3:
            print("Yes")
            break
    else:
        i=0
if i < 3:
    print("No")

Solution (Python):


import sys

def main():
    numbers=[]
    n = int(input())
    numbers = [[int(i) for i in input().split()] for _ in range(n)]
    count=0
    dp=[]

    for idx,number in enumerate(numbers):
        if number[0] == number[1]:
            count+=1
            if idx==len(numbers)-1:
                dp.append(count)
        else:
            dp.append(count)
            count=0
    if max(dp)>=3:
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    main()

Solution (Python):
n = int(input())
c = 0
l = 0
for i in range(n):
  x = input().split()
  d1 = int(x[0])
  d2 = int(x[1])
  if d1 == d2:
    c += 1
    if c == 3:
      l = 1
  else:
    c = 0
    

if l == 1:
  print("Yes")

else:
  print("No")

Solution (Python):
n = int(input())
d = [list(map(int,input().split())) for i in range(n)]
ans = "No"
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]:
        ans = "Yes"
print(ans)

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

Solution (Python):
nn = int(input())
aa = [list(map(int,input().split())) for l in range(nn)]

myflag = 0
isexist = 0

for i in range(nn):
    if (aa[i][0] == aa[i][1]):
        if myflag == 0:
            myflag = 1
        else:
           myflag = myflag + 1
           if myflag == 3:
               isexist = 1
    else:
        myflag = 0

if isexist == 1:
    print('Yes')
else:
    print('No')

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

flag = 0

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]:
                flag = 1

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

Solution (Python):
n= int(input())
d=[]
ans=False
for i in range(n):
    a,b= map(int,input().split())
    d.append(a-b)

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

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

Solution (Python):
n = int(input())
count = 0
result = "No"

for i in range(n):
    x, y = map(int,input().split())
    if x == y:
        count += 1
    if x != y:
        count = 0
    if count == 3:
        result = "Yes"

print(result)

Solution (Python):
N = int(input())
counter = 0;

for i in range(N):
    d1, d2 = list(map(int, input().strip().split()))
    if d1 == d2:
        counter += 1
    else:
        counter = 0
    if counter >= 3:
        print("Yes")
        break;
if counter < 3:
    print("No")

Solution (Python):
rolls = []
for _ in range(int(input())):
  x,y = list(map(int,input().split()))
  rolls.append((x,y))
n = len(rolls)
i = 0
curr = 0
answer = False;
while i < n:
  if rolls[i][0] == rolls[i][1]:
    curr+=1;
    if curr == 3:
      answer = True;
      break;
    i+=1
  else:
    curr = 0
    i+=1;
if answer:
  print("Yes")
else:
  print("No")

Solution (Python):
n=int(input())
a=[]
for i in range(n):
  x,y=map(int,input().split( ))
  a.append(x-y)
j=3
check=0
for i in range(n-2):
  if a[i:j]==[0,0,0]:
    print("Yes")
    check=1
    break
  j+=1
if not check:
  print("No")

Solution (Python):
n = int(input())
count = 0
okay = False
for i in range(n):
  temp1, temp2 = map(int,input().split())
  if temp1 == temp2:
    count += 1
  else:
    count = 0

  if count >= 3:
    okay = True
    break
    
if okay == True:
  print("Yes")
else:
  print("No")

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

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

Solution (Python):

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

Solution (Python):
n = int(input())
d = [list(map(int,input().split())) for _ in range(n)]
cnt = ""
for x,y in d:
    if x==y:
        cnt+="1"
    else:
        cnt+="0"
        
cnt = cnt.split("0")
ans = 0
for s in cnt:
    ans = max(ans,len(s))
print("Yes" if ans>=3 else "No")

Solution (Python):
n=int(input())
ct=0
best=0
arr=[]
for i in range(n):
	a,b=map(int,input().split())
	if a==b:
		ct+=1
		best=max(ct,best)
	else:
		ct=0
if best>=3:
	print("Yes")
else:
	print("No")

Solution (Python):
from sys import exit
n = int(input())
c = 0
for i in range(n):
    l, r = map(int, input().split())
    if l == r:
        c += 1
    else:
        c = 0
    if c == 3:
        print("Yes")
        exit()
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())
cnt = 0
flag = 0
check = 7
for i in range(n):
    a, b = map(int, input().split())
    if a == b:
        cnt += 1
        if cnt == 3:
            flag = 1
    else:
        cnt = 0
        check = 7
if flag == 1:
    print("Yes")
else:
    print("No")

Solution (Python):

N = int(input())
D = list(list(map(int,input().split())) for i in range(N))
ans = 0
for j in range(N):
    if D[j][0] == D[j][1]:
        ans += 1
        if ans == 3:
            break
    else:
        ans *= 0
if ans == 3:
    print('Yes')
else:
    print('No')

Solution (Python):
N = int(input())
prev = [False, False, False]
for n in range(N):
    D1, D2 = list(map(int, input().split(' ')))
    prev = prev[1:] + [D1 == D2]
    if all(prev):
        print('Yes')
        import sys
        sys.exit()

print('No')

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

Solution (Python):

n=int(input())
d1=[0]*n
d2=[0]*n
for i in range(n):
    d1[i],d2[i]=list(map(int,input().split()))
    
yn=""
for i in range(n-2):
    if d1[i]==d2[i] and d1[i+1]==d2[i+1] and d1[i+2]==d2[i+2] :
        print("Yes")
        yn="Yes"
        break
if yn!="Yes":
    print("No")

Solution (Python):
N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
ans="No"
for i in range(0,N-2):
    if x[i]==y[i] and x[i+1]==y[i+1] and x[i+2]==y[i+2]:
        ans="Yes"
print(ans)

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

N = int(input().rstrip('\n'))
a = 0
check = 0
for _ in range(N):
  D1,D2 = (int(x) for x in input().rstrip('\n').split())
  if D1 == D2:
    a += 1
  else:
    a = 0
  if a ==3:
    check += 1
    break
if check > 0:
  print('Yes')
else:
  print('No')

Solution (Python):
N = int(input())
flag = 0
ans = 0
for _ in range(N):
    D1, D2 = (int(x) for x in input().split())
    if D1 == D2:
        flag += 1
    else:
        flag = 0
    if flag == 3:
        ans = 1
if ans == 1:
    print('Yes')
else:
    print('No')

Solution (Python):
def B():
    n = int(input())
    cnt = 0
    for _ in range(n):
        d_1,d_2 = list(map(int, input().split()))
        if d_1 == d_2:
            cnt += 1
        else:
            cnt = 0
        if cnt >= 3:
            print("Yes")
            return
    print("No")
B()

Solution (Python):
N=int(input())
counter=0
flag=0
for i in range(N):
     D1, D2=map(int,input().split())
     if D1==D2:
         counter+=1
         if counter>=3:
             flag=1
             break
     else:
         counter=0
if flag==1:
    print('Yes')
else:
    print('No')

Solution (Python):
N=int(input())
cnt=0
flg='No'

for i in range(N):
  D1,D2=map(int,input().split())
  if D1==D2:
    cnt+=1
    if cnt==3:
      flg='Yes'
      break
  else:
    cnt=0

print(flg)

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

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

ans = False
first = False
second = False
third = False

for i in range(n):
    d1, d2 = list(map(int, input().split()))
    if d1 == d2:
        if first == False:
            first = True
        elif second == False:
            second = True
        else:
            third = True
            ans = True
    else:
        first = False
        second = False
        third = False

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

Solution (Python):
N = int(input())
t = 0
for i in range(N):
    a, b = [int(x) for x in input().split()]
    if a != b:
        t = 0
    else:
        t += 1
    if t > 2:
        break
if t > 2:
    print("Yes")
else:
    print("No")

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

counter = 0
ans = 'No'
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        counter += 1
        if counter == 3:
            ans = 'Yes'
            break
    else:
        counter = 0

print(ans)

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

Solution (Python):
num=int(input())
re=0
res=0
for i in range(num):
    a=input().split(" ")
    if a[0]==a[1]:
        re +=1
        if re>=3:
            res=1
    else:
        re=0

if(res==0):
    print("No")
else:
    print("Yes")

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

Solution (Python):
N = int(input())
check_list = []
for _ in range(N):
    a, b = input().split()
    if a == b:
        check_list.append(1)
    else:
        check_list.append(0)
        
total_list = []
for i in range(len(check_list) - 1):
    total_list.append(sum(check_list[i:i + 3]))

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

Solution (Python):
def probB():
    N = int(input())
    count = 0

    try:
        while 1:
            if count == 3:
                print('Yes')
                return

            D1, D2 = map(int, input().split())
            if D1 == D2:
                count += 1
            else:
                count = 0

    except EOFError:
        print('No')


def main():
    probB()


if __name__ == '__main__':
    main()

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
L = [LIST() for i in range(N)]

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

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

Solution (Python):
import math
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
def factorization(n):
    arr = []
    temp = n
    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 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
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())
mod = 10**9 + 7



n = ini()
ans = 'No'
c = 0
for i in range(n):
    a,b = inm()
    if a == b:
        c += 1
    else:
        c = 0
    if c >= 3:
        ans = 'Yes'

print(ans)

Solution (Python):
n = int(input())
count = 0
count_in_row = 0
for i in range(n):
    x,y = map(int,input().split())
    if x==y:
        count +=1
        if count ==3:
            print('Yes')
            break
    else:
        count = 0
else:
    print('No')

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

dices = []
for i in range(N):
    d_1, d_2 = [int(i) for i in input().split()]
    dices.append((d_1,d_2))
    
flag = False

counter = 0
for d in dices:
    if d[0] == d[1]:
        counter += 1
    else :
        counter = 0
    if counter >= 3:
        flag = True
        break
        
if flag:
    print('Yes')
else :
    print('No')

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

first,second = False,False
for i in range(N):
    if D[i][0]==D[i][1] and first and second:
        print("Yes")
        exit(0)
    elif D[i][0]==D[i][1] and first:
        second = True
    elif D[i][0]==D[i][1] and first!=True:
        first = True
    else:
        first,second = False,False

print("No")

Solution (Python):
import sys
N=int(input())
a = [0] * N
b = [0] * N
for i in range(N):
    a[i], b[i] = map(int, input().split())

for i in range(N-2):
    if a[i]==b[i] and a[i+1]==b[i+1] and a[i+2]==b[i+2]:
        print("Yes")
        sys.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]:
        if D[i+1][0] == D[i+1][1]:
            if D[i+2][0] == D[i+2][1]:
                print("Yes")
                exit()

print("No")

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

ans = False
count = 0
for _ in range(N):
  x, y = map(int, input().split())
  if x == y:
    count += 1
    if count == 3:
      ans = True
  else:
    count = 0
print('Yes' if ans  else 'No')

Solution (Python):
N = int(input())
arr = [input().split() for _ in range(N)]
for i in range(2,N):
    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')
        break
else:
    print('No')

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

Solution (Python):
import sys

def main():
    n = int(input())
    a_list = []*n
    b_list = []*n
    
    for i in range(n):
        a,b = map(int, input().split())
        a_list.append(a)
        b_list.append(b)
    for ii in range(n-2):
        if a_list[ii] == b_list[ii] and a_list[ii+1] == b_list[ii+1] and a_list[ii+2] == b_list[ii+2]:
            print('Yes')
            sys.exit()
    print('No')
    
if __name__ == "__main__":
    main()

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

Solution (Python):
n=int(input())
count =0
a = 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")
        a = 1
if a ==0:
    print("No")

Solution (Python):
N = int(input())
D = []
count = 0
exit = False
for i in range(N):
    D.append(input().split())

for d in D:
    if d[0] == d[1]:
        count += 1
        if count >= 3:
            print("Yes")
            exit = True
            break
    else:
        count = 0

if exit == False:
    print("No")

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

print(ans)

Solution (Python):


import sys
import math
import time

import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools









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

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]):
                count = 1

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

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

Solution (Python):
def main():
    N = int(input())
    Ds = [list(map(int, input().split())) for i in range(N)]
    ans = 'No'
    judge = []
    for i in range(N):
        Di = Ds[i]
        if Di[0] == Di[1]:
            judge.append(True)
        else:
            judge.append(False)

        if i >= 2 and (judge[-1] == judge[-2] == judge[-3] == True):
            ans = 'Yes'
            break

    print(ans)
    return


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
D = []

for i in range(N):
    D.append(list(map(int, input().split())))

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())
D = [False for _ in range(N)]
for i in range(N):
    x, y = map(int, input().split())
    if x == y:
        D[i] = True
tmp = 0
for i in range(N - 2):
    if D[i] == D[i + 1] == D[i + 2] == True:
        print('Yes')
        break
else:
    print('No')

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

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

flag1 = False
flag2 = False
result = False
for i in range(a):
    b, c = map(int, input().split())  
    
    if flag2:
        if b == c:
            result = True
    
    if flag1:
        if b == c:
            flag2= True
        
    
    if b == c:
        flag1= True
    else:
        flag1 = False
        flag2 = False        


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

Solution (Python):
N = int(input())
D_list = []
for _ in range(N):
    D1, D2 = map(int, input().split())
    D_list.append([D1, D2])

sequence_doublet = 0
for D in D_list:
    if D[0] == D[1]:
        sequence_doublet += 1
    else:
        sequence_doublet = 0
    
    if sequence_doublet == 3:
        break

if sequence_doublet == 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):
n=int(input())
cnt=0
flag=False
for i in range(n):
    d1,d2=map(int,input().split())
    if d1==d2 and cnt==2:
        print('Yes')
        flag=True
        break
    elif d1==d2:
        cnt+=1
    else:
        cnt=0
if not flag:
    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]:
        if d[i+1][0] == d[i+1][1]:
            if d[i+2][0] == d[i+2][1]:
                print('Yes')
                exit()
            else:
                continue
        else:
            continue
    else:
        continue

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

Solution (Python):
n = int(input())
repets = 0
jail = False
for x in range(n):
	a, b = map(int, input().split())
	if a == b:
		repets += 1
		if repets >= 3:
			jail = True
	else:
		repets = 0
print("Yes" if jail else "No")

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

print(f())

Solution (Python):



def main():
    line = int(input())
    xy = [map(int, input().split()) for _ in range(line)]
    x, y = [list(i) for i in zip(*xy)]
    stdOut = solve(line, x, y)
    print(stdOut)


"""
方針


"""


def solve(line, x, y):
    for i in range(line):
        if (line - i) <= 2:
            return 'No'
        if isDoublet(x[i], y[i]) and isDoublet(x[i + 1], y[i + 1]) and isDoublet(x[i + 2], y[i + 2]):
            return 'Yes'
    return 'No'


def isDoublet(xi, yi):
    return xi == yi


if __name__ == "__main__":
    main()

Solution (Python):

 
N = int(input())

zorome = 0
ans_chk = 0
for i in range(N):
  D = list(map(int,input().split()))
  if ( D[0]==D[1] ):
    if   ( zorome==0 ):
      zorome = 1
    elif ( zorome==1 ):
      zorome = 2
    elif ( zorome==2 ):
      zorome = 3
      print('Yes')
      ans_chk = 1
      break
  else:
    zorome = 0

if ( ans_chk==0 ):
  print('No')

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

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

print('No')

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

Solution (Python):
import sys
N = int(input())
D1 = [0] * N
D2 = [0] * N
for i in range(N):
    D1[i], D2[i],= map(int, input().split())
s=0
for i in range(N):
    if D1[i]==D2[i]:
        s=s+1
    else:
        s=0
    if s>=3:
        print('Yes')
        sys.exit()
print('No')

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

ans = 'No'
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] :
                ans = 'Yes'

print(ans)

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

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

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())
c=0

for i in range(n):
    d,dd=map(int,input().split())
    if d==dd:
        c+=1
        if c==3:
            print("Yes")
            exit()
    else:
        c=0
print("No")

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

Solution (Python):
n=int(input())
d=[]
for _ in range(n):
  l=list(map(int,input().split()))
  d.append(l)
a=[1,2]
d.append(a)
d.append(a)
flg=0  
for i in range(n):
  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")
        flg=1
        break
if flg==0:
  print("No")