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
flag = 0
for _ in range(N):
    a,b = map(int,input().split())
    if a == b:
        c += 1
    else:
        c = 0

    if c == 3:
        flag = 1

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

Solution (Python):

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

Solution (Python):
N = int(input())
c = 0
f = 0
for i in range(N):
    a, b = map(int, input().split())
    if a == b:
        c += 1
    else:
        c = 0
    if c >= 3:
        f = 1

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

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

Solution (Python):
n = int(input())
cnt = 0
flag = False

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

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

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

result = 0
cur = 0
for _ in range(N):
  d1, d2 = map(int, input().split())
  if d1 == d2:
    cur += 1
  else:
    cur = 0
  result = max(result, cur)

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

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

Solution (Python):
n = int(input())
count = 0
ans = 0

for i in range(n):
    d1,d2 = list(map(int,input().split()))
    if d1 == d2:
        count += 1
    else:
        count = 0
    if ans < count:
        ans = count

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

Solution (Python):
import sys
n = int(input())
ans = 0
flag = False
for i in range(n):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        ans += 1
    else:
        ans = 0
    if ans == 3:
        flag = True
if flag == True:
    print("Yes")
else:
    print("No")

Solution (Python):
input=__import__('sys').stdin.readline
ans='No'
cs=0
for i in range(int(input())):
	a,b=map(int,input().split())
	if a==b:cs+=1
	else:cs=0
	if cs>=3:ans='Yes'
print(ans)

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

ans = "No"
x = 0
for _ in range(n):
  d1, d2 = input().split()
  if d1 == d2:
    x += 1
  else:
    x = 0

  if x == 3:
    ans = "Yes"


print(ans)

Solution (Python):
n = int(input())
flag = False
num = 0
for i in range(n):
    d1, d2 = list(map(int, input().split()))
    if d1 == d2:
        num += 1
        if num == 3:
            flag = True
            break
    else:
        num = 0
if flag == True:
    print("Yes")
else:
    print("No")

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

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

cnt=0
for d1,d2 in d:
    if d1 == d2:
        cnt+=1
        if cnt==3:
            print("Yes")
            exit()
    else:
        cnt=0

print("No")

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

Solution (Python):
N = int(input())
tmp = 0
ans = False

for i in range(N):
    tmp += 1
    t = tuple(map(int, input().split()))
    if t[0] != t[1]:
        tmp = 0
    if tmp >= 3:
        ans = True

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

Solution (Python):




import sys









MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    n = read_int()
    cnt = 0
    flag = False
    for _ in range(n):
        d1, d2 = read_ints()
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            flag = True
    print('Yes' if flag else 'No')

if __name__ == '__main__':
    Main()

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

cnt=0
flg =False

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

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

Solution (Python):
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]
x = 0
for d1, d2 in d:
    if d1 == d2:
        x += 1
    else:
        x = 0
    if x == 3:
        print('Yes')
        break
else:
    print('No')

Solution (Python):

"""
Created on Sat Sep 19 20:17:38 2020

@author: liang
"""

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

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

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

Solution (Python):
n=int(input())
l1=[]
l2=[]
for i in range(n):
  x,y=(int(i) for i in input().split())
  l1.append(x)
  l2.append(y)
c=0
for i in range(n-2):
  if(l1[i]==l2[i] and l1[i+1]==l2[i+1] and l1[i+2]==l2[i+2]):
    c=1
    break
if(c==0):
  print("No")
else:
  print("Yes")

Solution (Python):
n = int(input())
arr =[]
for _ in range(n):
    a,b=[int(c) for c in input().split()]
    if a == b:
        arr.append(1)
    else:
        arr.append(0)

arr.append(0)
arr.append(0)

for i in range(n):
    if arr[i]+arr[i+1]+arr[i+2] == 3:
        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")
        break
else:
    print("No")

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

Solution (Python):
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]

def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  cnt=0
  mx=0
  for _ in range(n):
    a,b=LI()
    if a==b:
      cnt+=1
    else:
      mx=max(mx,cnt)
      cnt=0
  mx=max(mx,cnt)

  if mx>=3:
    return 'Yes'
  return 'No'


print(main())

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

Solution (Python):
import sys
from sys import exit
from math import gcd, factorial, ceil, floor, sqrt
from bisect import bisect_left, bisect_right
from copy import deepcopy
from heapq import heapify, heappop, heappush
from itertools import permutations, combinations, product, accumulate
from collections import defaultdict, deque, Counter
sys.setrecursionlimit(10**7)

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

N = ii()
d = []
for i in range(N):
    a, b = mi()
    d.append([a, b])
cur = 0
for x, y in d:
    if x == y:
        cur += 1
    else:
        cur = 0
    if cur == 3:
        print('Yes')
        sys.exit()
print('No')

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

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**18
    MOD = 10**9 + 7
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    _LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())
    SI = lambda : sys.stdin.readline().rstrip()
    DD = ((1,0),(0,1),(-1,0),(0,-1))

    N = NI()
    cnt = 0
    for _ in range(N):
        d1,d2 = LI()
        if d1 == d2:
            cnt += 1
            if cnt >= 3:
                print('Yes')
                return
        else:
            cnt = 0
    print('No')

if __name__ == '__main__':
    main()

Solution (Python):
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    n = ii()
    cnt = 0
    flag = False
    for i in range(n):
        a,b = mi()
        if a==b:
            cnt+=1
            if cnt == 3:
                flag = True
        else:
            cnt=0
    if flag:
        print(yes)
    else:
        print(no)


main()

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

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

count = 0
jail = False

for _ in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        count += 1
        if count >= 3:
            jail = True
    else:
        count = 0

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

Solution (Python):
N=int(input())
count=0
max_=0
for i in range(N):
    D1,D2=map(int,input().split())
    if D1==D2:
        count+=1
        max_=max(max_,count)
    else:
        count=0
if max_>=3:
    print("Yes")
else:
    print("No")

Solution (Python):
from sys import stdin,stdout
n=int(stdin.readline());ans='No';d=0

for i in range(n):
    x,y=list(map(int,stdin.readline().split()))
    if x==y:d+=1
    else:d=0
    if d>=3:
        ans='Yes'
        break
print(ans)

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

ans="No"
t=0

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

Solution (Python):
def solve():
    n = int(input())
    rolls = [list(map(int,input().split())) for i in range(n)]
    for i in range(n-2):
        if rolls[i][0]==rolls[i][1] and rolls[i+1][0]==rolls[i+1][1] and rolls[i+2][0]==rolls[i+2][1]:
                return True

    return False

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

Solution (Python):
def has_triples(dices):
    for i in range(len(dices) - 2):
        a1, b1 = dices[i]
        a2, b2 = dices[i+1]
        a3, b3 = dices[i+2]

        if a1 == b1 and a2 == b2 and a3 == b3:
            return True

    return False


n = int(input())
dices = []
for _ in range(n):
    a, b = map(int, input().split(" "))
    dices.append((a, b))

print("Yes" if has_triples(dices) else "No")

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

print('No')

Solution (Python):


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

cont = 0
for d1, d2 in D:
    if d1 == d2:
        cont += 1
    else:
        cont = 0
    if cont >= 3:
        print('Yes')
        exit()
print('No')
exit()

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")
      break
  else:
    cnt = 0
else:
  print("No")

Solution (Python):

import sys 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
cnt = 0
ans = 0
for i in range(N):
    a, b = map(int, readline().split())
    if a==b:
        cnt+=1
    else:
        cnt=0
    ans = max(cnt,ans)
print('Yes' if ans >=3 else 'No')

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

ans = 'No'
z = 0
for i, j in d_l:
    if i == j:
        z+=1
    else:
        z=0
    if z == 3:
        ans = 'Yes'
        break
print(ans)

Solution (Python):

N = int(input())
cnt =0
for i in range(N):
    N, M = map(int,input().split())
    if N==M:
        cnt+=1
    else:
        cnt = 0
    if cnt>=3:
        print('Yes')
        exit()
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")
    break
else:
  print("No")

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

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

print(ans)

Solution (Python):
def main():
    n = int(input())
    zorome_counter = 0
    flag = False
    for i in range(n):
        d1,d2 = map(int,input().split())
        if d1 == d2:
            zorome_counter += 1
        else:
            zorome_counter = 0
        if zorome_counter >= 3:
            flag = True
            break
    if flag:
        print("Yes")
    else:
        print("No")



if __name__ == '__main__':
    main()

Solution (Python):
def resolve():
    n = int(input())
    ans = 0
    for _ in range(n):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            ans += 1
        else:
            ans = 0
        if ans == 3:
            print("Yes")
            return

    print("No")

resolve()

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

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

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

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

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

    if count == 3:
        print('Yes')
        exit()
print('No')

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

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

cnt = 0

for i in range(N):
    if D[i][0] == D[i][1]:
        cnt += 1
    elif cnt < 3:
        cnt = 0

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

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

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

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

Solution (Python):
n = int(input())
d = [list(map(int,input().split())) for _ in range(n)]
d_bool = [d1==d2 for d1,d2 in d]
for b1,b2,b3 in zip(d_bool,d_bool[1:],d_bool[2:]):
    if b1&b2&b3:
        print("Yes")
        break
else:
    print("No")

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

cnt = 0
for x, y in D:
    if x == y:
        cnt += 1
    else:
        cnt = 0

    if cnt >= 3:
        print('Yes')
        exit()

print('No')

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

if __name__ == "__main__":
    main()

Solution (Python):

def resolve():
    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')
            return
    print('No')

if __name__ == "__main__":
    resolve()

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

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

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

Solution (Python):
n = int(input())
arr = []
for i in range(n):
  x, y = map(int, input().split())
  arr += [[x, y]]

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

Solution (Python):
import sys,math,collections
from collections import defaultdict


    
def file():
    sys.stdin = open('input.py', 'r')
    sys.stdout = open('output.py', 'w') 
def get_array():
    l=list(map(int, input().split()))
    return l
def get_ints():   
    return map(int, input().split())
    
def get_3_ints():   
    a,b,c=map(int, input().split())
    return a,b,c    
def sod(n):
    n,c=str(n),0
    for i in n: 
        c+=int(i)
    return c    
def isPrime(n):
    if (n <= 1):
        return False
    if (n <= 3):
        return True
    if (n % 2 == 0 or n % 3 == 0):
        return False
    i = 5
    while(i * i <= n):
        if (n % i == 0 or n % (i + 2) == 0):
            return False
        i = i + 6
  
    return True
def getFloor(A, x):

    (left, right) = (0, len(A) - 1)

    floor = -1
    while left <= right:
        mid = (left + right) // 2
        if A[mid] == x:
            return A[mid]
        elif x < A[mid]:
            right = mid - 1
        else:
            floor = A[mid]
            left = mid + 1
            
    return floor
def chk(aa,bb):
	f=0
	for i in aa:
		for j in bb:
			if(j[0]>=i[0] and j[1]<=i[1]):
				f+=1
			elif(j[0]<=i[0] and j[1]>=i[1]):	
				f+=1
			elif(i[0]==j[1] or i[1]==j[0]):
				f+=1
			else:
				continue
	return f			


def main():
	s=""
	for tt in range(int(input())):
		a,b=get_ints()
		if(a==b):
			s+='1'
		else:
			s+='0'
	if('111' in s):
		print('Yes')	
	else:
		print("No")

		




				





		


	





        
            
        























    

    
    

        











        
        

        























































                

            







            
            
































        








if __name__ == '__main__':
    main()

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

Solution (Python):



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

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def main():
    n = ri()
    cnt = 0
    for i in range(n):
        d1, d2 = rli()
        if d1 == d2:
            cnt += 1
            if cnt == 3:
                print("Yes")
                return
        else:
            cnt = 0
    print("No")


if __name__ == '__main__':
    main()

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

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

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


zoroStreak = 0
zoroMaxStreak = 0
for i in range(N):
  d = list(map(int, input().split()))
  if d[0] == d[1]:
    zoroStreak += 1
    zoroMaxStreak = max(zoroMaxStreak, zoroStreak)
  else:
    zoroStreak = 0

if 3 <= zoroMaxStreak:
  print('Yes')
else:
  print('No')

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

t = 0
s = 0

for i in range(N):
    if D[i][0] == D[i][1]:
        t += 1
    else:
        t = 0
    if t >= 3:
        s = 1
        break
if s == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
dice = [tuple(map(int, input().split())) for _ in range(N)]
count = 0
for d1, d2 in dice:
    if d1 != d2:
        count = 0
        continue
    else:
        count += 1
    if count == 3:
        print('Yes')
        break
else:
    print('No')

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

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  


N = I()
D = [tuple(MI()) 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())
ans="No"
cnt=0
for i in range(n):
    d1,d2=map(int, input().split())
    if d1==d2:
        cnt+=1
    else:
        cnt=0
    if cnt>=3:
        ans="Yes"
        break
print(ans)

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

zorome_max=0
zorome=0

for i in range(n):
    one,two=[int(i) for i in input().split()]
    if one==two:
        zorome+=1
        zorome_max=max(zorome_max,zorome)
    else:
        zorome=0

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

Solution (Python):
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")



def main():
    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)


if __name__ == '__main__':
    main()

Solution (Python):

import sys
sys.setrecursionlimit(10**6)

n = int(input())

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

Solution (Python):


import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)

    cnt = 0
    for d1, d2 in zip(it, it):
        if d1 != d2:
            cnt = 0
        else:
            cnt += 1
            if cnt == 3:
                print("Yes")
                break
    else:
        print("No")

if __name__ == "__main__":
    resolve()

Solution (Python):
n=int(input())
f=lambda:map(int,input().split())
c=0
for i in range(n):
  d,e=f()
  if d==e: c+=1
  else: c=0
  if c==3: exit(print('Yes'))
print('No')

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

streak = 0
ans = False

for a, b in d:
    if a == b:
        streak += 1
    else:
        streak = 0
    if streak >= 3: ans = True; break

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

Solution (Python):


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

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:
        k=True
        print("Yes")
        exit()
print("No")

Solution (Python):
N = int(input())
s = 0
o = []
for i in range(N):
    o.append(tuple(map(int,input().split())))

for A,B in o:
    if A == B:
        s += 1
        if s == 3:
            print('Yes')
            exit()
    else:
        s = 0
print('No')

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

jail = False
count = 0
for i in range(n):
  a,b = input().split()
  if a == b:
    count += 1
  else:
    count = 0
  if count >= 3:
    jail = True
    
if jail:
  print("Yes")
else:
  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:
      print('Yes')
      exit()
  else:
    cnt = 0

print('No')

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

for i, j, k in zip(range(N), range(1, N), range(2, N)):
    if D[i][0] == D[i][1] and D[j][0] == D[j][1] and D[k][0] == D[k][1]:
        print('Yes')
        exit()
print('No')

Solution (Python):
import sys













stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

def solve():
    n = int(stdin.readline().rstrip())
    
    
    numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
    
    
    
    for i in range(n-2):
        if numbers[i][0] == numbers[i][1] and numbers[i+1][0] == numbers[i+1][1] and numbers[i+2][0] == numbers[i+2][1]:
            print("Yes")
            exit()
    print("No")
    exit()


if __name__ == '__main__':
    solve()

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

ans = False
tmp = 0
for _ in range(n):
    a, b = map(int, input().split())
    if a == b:
        tmp += 1
    else:
        tmp = 0
    if tmp >= 3:
        ans = True

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

Solution (Python):
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
ips = lambda:input().split()
import collections
import math
import itertools
import heapq as hq
n = ni()
cnt=0
f=False
for i in range(n):
    d1,d2 = ma()
    if d1==d2:
        cnt+=1
    else:
        cnt=0
    if cnt==3:
        f=True
        break
yn(f)

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

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

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

cunt = 0
for _ in range(N):
    x,y = map(int,input().split())
    if x == y:
        cunt += 1
    else:
        cunt = 0

    if cunt == 3:
        print('Yes')
        exit()
print('No')

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

Solution (Python):



import sys

N = int(input())

zoromes = 0
for i in range(N):
    D1, D2 = (int(x) for x in input().split())
    if D1 == D2:
        zoromes += 1
        if zoromes >= 3:
            print("Yes")
            sys.exit(0)
    else:
        zoromes = 0
print("No")

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

N = int(readline())
D = [len(set(map(int, readline().split()))) == 1 for _ in range(N)]
ans = 'No'
for i in range(1, N-1):
    if D[i-1] and D[i] and D[i+1]:
        ans = 'Yes'
print(ans)

Solution (Python):








def solve(N, DD):
    count = 0
    for d1, d2 in DD:
        if d1 == d2:
            count += 1
        else:
            count = 0
        if count >= 3:
            print('Yes')
            return
    print('No')


if __name__ == '__main__':
    
    N = int(input())
    
    
    
    DD = [[int(i) for i in input().split()] for _ in range(N)]
    solve(N, DD)