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
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    N = NI()
    Ds = [NLI() for _ in range(N)]
    D = [x - y for x, y in Ds]
    cnt = 0
    for d in D:
        if d == 0:
            cnt += 1
        else:
            cnt = 0
        if cnt == 3:
            print("Yes")
            exit()
    print("No")


if __name__ == "__main__":
    main()

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


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

    zorome_count = 0
    for d in D:
        if d[0] == d[1]:
            zorome_count += 1
        else:
            zorome_count = 0
        if zorome_count == 3:
            break

    print('Yes' if zorome_count == 3 else 'No')


if __name__ == "__main__":
    main()

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

Solution (Python):
count = 0
for i in range(int(input())):
    l = list(map(int, input().split()))
    if l[0] == l[1]:
        count += 1
    elif l[0] != l[1]:
        count = 0
    if count >= 3:
        print("Yes")
        break
if count < 3:
    print("No")

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

Solution (Python):
def solution(arr):
  count = 0
  for i, j in arr:
    if i == j:
      count += 1
    else:
      count = 0
    if count == 3:
      return 'Yes'
  return 'No'
n = int(input())
arr = []
for _ in range(n):
  arr.append([ int(i) for i in input().split()])
print(solution(arr))

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


if __name__ == '__main__':
    main()

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

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

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

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

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))



N = I()

count = 0

for i in range(N):
    val1,val2 = LI()
    if val1 == val2:
        count += 1
        if count == 3:
            print('Yes')
            exit()
    else:
        count = 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')
        exit()
print('No')

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

cons = 0
for i in range(N):
  val = [int(x) for x in input().split()]
  if val[0] == val[1]: cons += 1
  else: cons = 0
  if cons == 3:
    print('Yes')
    break
else: print('No')

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

print('No')

Solution (Python):
print('NYoe s'['111'in''.join(str(len({*t.split()}))for t in open(0))[1:]::2])

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

l = [map(int, input().split()) for _ in range(N)]
di , dj = [list(u) for u in zip(*l)]

k = 3
for i in range(N):
  if di[i] == dj[i]:
    k -= 1
    if k == 0:
      print('Yes')
      break
  else:
    k = 3

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

Solution (Python):
print('NYoe s'['000'in''.join(str(eval(t.replace(*' -')))for t in open(0))::2])

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

    if cnt > 2:
        print("Yes")
        quit()
        
print("No")

Solution (Python):
n=int(input())
f = False
match=0
for i in range(n):
  a,b=map(int,input().split())
  if a==b:
    match+=1
    f |= (match == 3)
  else:
    match=0
if f:
  print("Yes")
else:
  print("No")

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

count = 0
for _ in range(n):
    a, b = input().split()
    if a == b:
        count += 1
    else:
        count = 0
    if count == 3:
        print("Yes")
        quit()

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):
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

for i in range(N - 2):
    if all(x == y for (x, y) in A[i:i+3]):
        print('Yes')
        break
else:
    print('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'
    break
print(ans)

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

count = 0

for i in range(N):
    k, t = map(int, input().split())
      
    if not k == t:
        count *= 0
    if k == t:
       count += 1 
    if count == 3:
      print ( "Yes" )
     
      break
        
if count == 3:
        print ("")
else:
  print ("No")

Solution (Python):
n = int(input())
 
ans = 'No'
count = 0
for i in range(n):
  a,b = map(int,input().split())
  if a==b:
    count += 1
    if count == 3:
      ans = 'Yes'
  else:
    count = 0
    
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
    if cnt == 3:
      break
  else:
    cnt = 0
if cnt >= 3:
  print('Yes')
else:
  print('No')

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

for i in range(n - 2):
  if all([d[i + j][0] == d[i + j][1] for j in range(3)]):
    print('Yes')
    exit()

print('No')

Solution (Python):
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())


N = I()
D = [0]*N
for i in range(N):
    a,b = MI()
    if a == b:
        D[i] = 1

for i in range(N-2):
    if D[i] == D[i+1] == D[i+2] == 1:
        print('Yes')
        break
else:
    print('No')

Solution (Python):
n = int(input())
x = 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if x != 3:
        if d1 != d2:
            x = 0
        else:
            x += 1
print("Yes" if x == 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
    if cnt == 3:
      print("Yes")
      exit()
  else:
    cnt = 0
print("No")

Solution (Python):
import os
import sys
from atexit import register
from io import BytesIO
sys.stdin = BytesIO(os.read(0, os.fstat(0).st_size))
sys.stdout = BytesIO()
register(lambda: os.write(1, sys.stdout.getvalue()))
input = lambda: sys.stdin.readline().rstrip('\r\n')
raw_input = lambda: sys.stdin.readline().rstrip('\r\n')

n = int(input())
ok = False
cont = 0
for i in xrange(n):
    a,b = (int(x) for x in input().split())
    if a == b:
        cont += 1
        if cont == 3:
            ok = True
    else:
        cont = 0
if ok:
    print("Yes")
else:
    print("No")

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

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

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

print("No")

Solution (Python):
import sys
INF = 1 << 60
MOD = 10**9 + 7 
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    n = int(input())
    now = 0
    for _ in range(n):
        x, y = map(int, input().split())
        if x == y:
            now += 1
        else:
            now = 0
        if now == 3:
            print("Yes")
            return
    print("No")
resolve()

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

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

    if D1 == D2:
        count += 1
        if count >= 3:
            break
    else:
        count = 0

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

Solution (Python):
n = int(input())
z = []
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())
ch=0
curr=0
for i in range (n):
    a,b=map(int,input().split())
    if a==b:
        curr+=1
    else:
        curr=0
    if curr>=3:
        ch=1
if ch:
    print("Yes")
else:
    print("No")

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

Solution (Python):
n = int(input())
d = []
for i in range(n):
    a,b = map(int,input().split())
    d.append([a,b])
cnt,ans = 0,0
for i in d:
    if i[0] == i[1]:
        cnt += 1
        ans = max(ans,cnt)
    else:
        cnt = 0
if ans>2:
    print("Yes")
else:
    print("No")

Solution (Python):
N = int(input())
D = [list(map(int, input().split())) for _ 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'
    break
    
print(ans)

Solution (Python):
N, = map(int, input().split())
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")
        break
else:
    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(0)

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

print("No")

Solution (Python):
N = int(input())
D = [list(map(int, input().split())) for _ 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'
    break
    
print(ans)

Solution (Python):
n=int(input())
cnt=0
flg=False
for _ in range(n):
    d1,d2=map(int,input().split())
    if d1==d2:
        cnt+=1
    else:
        cnt=0
    if cnt>=3:
        flg=True
        break
print("Yes") if flg 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"
    else:
        count = 0
print(ans)

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 = int(input())
x = [0 for i in range(n)]
y = [0 for i in range(n)]
ans = 'No'

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

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

print(ans)

Solution (Python):
N = int(input())
a = []
for _ in range(0, N):
    a1, a2 = map(int, input().split())
    a.append(a1)
    a.append(a2)
ans = ''
for i in range(0, (2 * N) - 1, 2):
    if a[i] == a[i + 1]:
        ans += 'Y'
    else:
        ans += 'N'

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

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

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]):
        d=d+1
    else:
        d=d
if(d>0):
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
str_list = [list(input().split()) for _ in range(n)]
ans = 0
for i in range(n-2):
    if str_list[i][0] == str_list[i][1]:
        if str_list[i+1][0] == str_list[i+1][1]:
            if str_list[i+2][0] == str_list[i+2][1]:
                ans += 1
    
if ans:
    print('Yes')
else:
    print('No')

Solution (Python):
n=int(input())
B=[False]*n
for i in range(n):
    d1,d2=map(int,input().split())
    B[i]=d1==d2
for i in range(n-2):
    if B[i] and B[i+1] and B[i+2]:
        print('Yes')
        break
else:
    print('No')

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

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

Solution (Python):
N = int(input())
d_ls=[]
for vakawkawelkn in range(N):
	D1,D2=map(int, input().split())
	if D1==D2:
		d_ls+=[1]
	else:
		d_ls+=[0]

flag=0
for i in range(N-2):
	if d_ls[i]*d_ls[i+1]*d_ls[i+2]==1:
		flag=1


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

Solution (Python):
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]
e = [0 for _ in range(n)]
for i in range(n):
    if d[i][0] == d[i][1]:
        e[i] = 1
f = [0 for _ in range(n)]
for i in range(2, n):
    f[i] = e[i]*e[i-1]*e[i-2]
if sum(f) > 0:
    print("Yes")
else:
    print("No")

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

Solution (Python):


def main():
    N = int(input())
    zoro = []

    for i in range(N):
        a, b = map(int, input().split())
        if a == b:
            zoro.append(1)
            if i >= 2:
                if zoro[i-2] == zoro[i-1] and zoro[i-1] == zoro[i]:
                    print('Yes')
                    return
        else:
            zoro.append(0)

    print('No')


main()

Solution (Python):
def main():
    N  = int(input())
    Ds = [list(map(int,input().split())) for _ in range(N)]
    count = 0
    for D in Ds:
        if D[0]==D[1]:
            count += 1
        else:
            count = 0
        if count == 3:
            print("Yes")
            return
    print("No")
    
main()

Solution (Python):
def run(n, _in_list):
    '''
    '''
    is_doublet_count = 0
    for x in _in_list:
        if is_doublet_count == 3:
            break
        _in = list(x)
        if _in[0] ==_in[1]:
            is_doublet_count += 1
        else:
            is_doublet_count = 0
    
    print('Yes' if is_doublet_count >= 3 else 'No')
    




if __name__ == '__main__':
    n = int(input())
    _in_list = [map(int, input().split()) for _ in range(n)]
    run(n, _in_list)

Solution (Python):
from collections import deque

target_1 = [[1,1],[2,2],[3,3],[4,4],[5,5],[6,6]]
def func(a=deque() , targetlist=target_1):
    x1 = a.count(targetlist[0])
    x2 = a.count(targetlist[1])
    x3 = a.count(targetlist[2])
    x4 = a.count(targetlist[3])
    x5 = a.count(targetlist[4])
    x6 = a.count(targetlist[5])
    if((x1+x2+x3+x4+x5+x6)==3):
        return True
    else:
        return False

N = int(input())
D_array = [list(map(int, input().split())) for i in range(N)]
Q = deque([[0] * 2 for i in range(3)])

j = 0
ans = 0
while j < N:
    Q.pop()
    Q.appendleft(D_array[j])
    if(func(Q,target_1)):
        print("Yes")
        ans = 1
        break
    else:
        j = j+1

if(ans==0):print("No")

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

c = 0
ans = False
for i in d:
    if i[0] == i[1]:

        c += 1
        if c >=3:
            ans = True
            break
    else:
        c = 0
if ans:
    print('Yes')
else:
    print("No")

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


ans = n-2
ans1 = 0

for m in range(ans):
  if l[m][0]  == l[m][1] and l[m+1][0] == l[m+1][1] and l[m+2][0] == l[m+2][1]:
    ans1 += 1
 
    
    
if ans1 >= 1:
  print("Yes")
else:
  print("No")

Solution (Python):
n=int(input())
s=0
ok=0
for i in range(n):
  lis=input().split()
  if lis[0]==lis[1]:
    s+=1
    if s>=3:
      ok=1
  else:
    s=0
if ok==1:
  print("Yes")
else:
  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)]
count = 0
buf = 0

for xi, yi in zip(x, y):
    if xi == yi:
        buf += 1
    else:
        if buf > count:
            count = buf
        buf = 0

if buf > count:
    count = buf

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

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

cnt = 0
bOK = False
for _ in range(N):
	D1,D2 = map(int,input().split())

	if D1 == D2:
		cnt += 1
		if 3 <= cnt:
			bOK = True
	else:
		cnt = 0

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

Solution (Python):
n =int(input())
first =[]
second =[]
for i  in range(n):
    d1 , d2 = map(int , input().split())
    first.append(d1)
    second.append(d2)

for i in range(n-2):
    count = 0
    for j in range(i ,i+3):
        if first[j]==second[j]:
            count +=1
        else:
            break
           
    if count ==3:
        print("Yes")
        break
    
else:
    print("No")

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

Is = []
for i in range(N):
    Ds = a[i]
    if Ds[0] == Ds[1]:
        Is.append(i)

Boooo = False
for i in range(len(Is)-2):
    if Is[i]+1 == Is[i+1] and Is[i+1]+1 == Is[i+2]:
        Boooo = True

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

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

lists = []

count = 0

while n:
  
  doublets = tuple(map(int, input().split()))
  lists.append(doublets)

  n -= 1

for x,y in lists:
  if x == y:
    count += 1
    continue
  elif count == 3:
   	break
  else:
   	count = 0
if (count >= 3):
    print('Yes')
else:
    print('No')

Solution (Python):
N=int(input())
cnt=0
flag=False
P=[]
for i in range(N):
    a,b=map(int,input().split())
    if a==b:
        cnt+=1
    else:
        cnt=0
    if cnt==3:
        flag=True
        break
print('Yes' if flag 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):
import sys
N = int(input())
i=0
X = [0]*N
Y = [0]*N
while i < N:
    
    X[i],Y[i] = list(map(int,input().split()))
    i = i+1
for j in range(N-2):
    if X[j]==Y[j]:
        if X[j+1]==Y[j+1]:
            if X[j+2]==Y[j+2]:
                print("Yes")
                sys.exit()
print("No")

Solution (Python):
times = int(input())
xy = [map(int, input().split()) for _ in range(times)]
x, y = [list(i) for i in zip(*xy)]

counts = [0]
count = 0

for i in range(times):
  if x[i] == y[i]:
    count += 1
  else:
    counts.append(count)
    count = 0
counts.append(count)

counti = max(counts)

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

Solution (Python):
N = int(input())
inputstr = []
inputlist = []
for i in range(N):
    inputstr = str(input())
    inputint = inputstr.split()
    inputlist.append(inputint)

isJail = False
for i in range(len(inputlist)-2):
    if(inputlist[i][0] == inputlist[i][1]):
        if inputlist[i+1][0] == inputlist[i+1][1]:
            if inputlist[i+2][0]== inputlist[i+2][1]:
                 isJail = True

if isJail == True:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
N=int(input())
count=0
nums_count=[]
for i in range(N):
    nums=[int(e) for e in input().split()]
    nums_count.append(nums)

count=0
for i in range(N-2):
    if (nums_count[i][0]==nums_count[i][1]) and (nums_count[i+1][0]==nums_count[i+1][1]) and (nums_count[i+2][0]==nums_count[i+2][1]):
        count=1

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

Solution (Python):
N = int(input())
x = 0
check = 0

for i in range(N) :
    a,b = map(int,input().split())
    if a == b :
        x += 1
    else :
        x = 0
    if  x == 3 :
        check = 1

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

Solution (Python):
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

tin=lambda : map(int, input().split())
lin=lambda : list(tin())
mod=1000000007



def main():
	n = int(input())
	cc=0
	for _ in range(n):
		b , c = tin()
		if b == c:
			cc += 1
			if cc == 3:
				return 'Yes'
		else:
			cc = 0
	return 'No'
	
	
	

isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		
			
	ret = main()
	if ret is not None:
		print(ret)

Solution (Python):
n=int(input())
ans=0
c=0
for i in range(0,n):
    x,y=list(map(int,input().split()))
    if(x==y):
        c+=1
        if(c==3):
            ans=1
            break
    else:
        c=0
        continue
    
if(ans==1):
    print("Yes")
else:
    print("No")

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

xy = [input() for _ in range(N)]

cnt = 0

result = 'No'

for D in xy:
  list = D.split()
  if list[0] == list[1]:
    cnt = cnt + 1
    if cnt == 3:
      result = 'Yes'
      break
  else:
    cnt = 0
print(result)

Solution (Python):
n = int(input())
a = []
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        a.append(True)
    else:
        a.append(False)
a.append(False)
a.append(False)
for h, i in enumerate(a):
    if i == True:
        if a[h+1] and a[h+2]:
            print("Yes")
            exit()
print("No")

Solution (Python):
N = int(input())
flag = False
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:
        flag = True

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

Solution (Python):
n = int(input())
num_list = []
count = 0

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

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

Solution (Python):
N = int(input())
li = list()
for i in range(N):
    a, b = [int(x) for x in input().split()]
    li.append([a,b])

count = 0
for i in li:
    if count < 3:
        if i[0] == i[1]:
            count += 1
        else:
            count = 0
    else:
        break

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

Solution (Python):
from typing import List, Tuple


def actual(N: int, D: List[Tuple[int, int]]) -> str:
    rep_digit_rolls: List[bool] = [d1 == d2 for d1, d2 in D]

    three_straights: List[bool] = [all(rep_digit_rolls[i:i + 3]) for i in range(len(rep_digit_rolls) - 2)]

    if any(three_straights):
        return 'Yes'
    else:
        return 'No'

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

print(actual(N, D))

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

exist = False
for i in range(n-2):
    for j in range(3):
        if d[i+j][0] != d[i+j][1]:
            break
    else:
        exist = True
if exist:
    print('Yes')
else:
    print('No')

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

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

X=[]
Y=[]
for _ in range(N):
    x, y = map(int, input().split())
    X.append(x)
    Y.append(y)
    
A="No"
for n in range(N-2):
    if X[n]==Y[n]:
        if X[n+1]==Y[n+1]:
            if X[n+2]==Y[n+2]:
                A="Yes"
                break
            else:
                continue
        else:
            continue
    else:
        continue
print(A)

Solution (Python):
N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]

count = 0

for i in range(N):
  if x[i] == y[i]:
    count += 1
    if count == 3:
      print("Yes")
      exit()
    
  else:
    count = 0
    
  
print("No")

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

list_a = list()
list_b = list()
for i in range(n):
  a, b = input().split()
  list_a.append(a)
  list_b.append(b)

result = "No"
for k in range(n-2):
  if list_a[k] == list_b[k] and list_a[k + 1] == list_b[k + 1] and list_a[k + 2] == list_b[k + 2]:
    result = "Yes"
print(result)

Solution (Python):
N=int(input())
x=0
for i in range(N):
    D = list(map(int,input().split()))
    if D[0]==D[1]:
        x=x+1
        if x>=3:
            break
    elif D[0]!=D[1]:
        x=0
if x>=3:
    print("Yes")
elif x<3:
    print("No")

Solution (Python):
n = int(input())
conseq = 0
ans = False
for i in range(n):
  d1,d2 = map(int,input().split())
  if d1 == d2:
    conseq += 1
    if conseq >= 3:
      ans = True
  else:
    conseq = 0

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

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

Solution (Python):
N = int(input())
zorome = list(range(N))
judgement = 1
for i in range(1,N+1):
    a,b = map(int,input().split())
    if a==b:
        zorome[i-1]=0
    else:
        zorome[i-1]=1
    if i > 2:
        if zorome[i-1]==zorome[i-2] and zorome[i-2]==zorome[i-3]:
            if zorome[i-1] == 0:
                judgement = 0
if judgement == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
n = int(input())
li = list()
for i in range(n):
    a, b = [int(x) for x in input().split()]
    li.append([a,b])

count = 0
for i in li:
    if count < 3:
        if i[0] == i[1]:
            count += 1
        else:
            count = 0
    else:
        break

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