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



Sample input:
5
1 2
6 6
4 4
3 3
3 2


Sample output:
Yes

Submission status: Accepted

Solution code:
def judge():
    cnt = 0  # 今何連続でゾロ目が出ているか記録しておきます

    for _ in range(N):
        x, y = map(int, input().split())
        if x == y:
            # ゾロ目ストリークが1増えました
            cnt += 1
        else:
            # ゾロ目ストリークが切れました
            cnt = 0

        if cnt == 3:
            # 3連続になった瞬間、return True していいです
            return True
    
    # ダメでした
    return False

N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
c=int(input())
ans=0
now=0
for _ in range(c):
  if eval(input().replace(" ","==")):
    now = now+1
  else:
    now = 0
  ans = max(ans,now)
print("Yes") if ans >= 3 else print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
import random
########################################################
bool=False
p=0
for _ in range(int(input())):
    a,b=INPUT()
    if a==b:
        p+=1
    else:
        p=0
    if p>=3:
        bool=True
if bool:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
# mod = 998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"
INF = 1<<32-1
# INF = 10**18

def main():
    n = int(ipt())
    cnt = 0
    for i in range(n):
        a,b = map(int,ipt().split())
        if a == b:
            if cnt == 2:
                print("Yes")
                exit()
            else:
                cnt += 1
        else:
            cnt = 0
    print("No")

    return None

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

def resolve():
    N = int(input())
    cnt = 0
    for _ in range(N):
        a, b = map(int, input().split())
        if a == b:
            cnt += 1
            if cnt == 3:
                return print("Yes")
        else:
            cnt = 0

    print("No")


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

print("No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    N = int(input())
    D_1, D_2 = [], []
    for i in range(N):
        D_i1, D_i2 = list(map(int, input().split()))
        D_1.append(D_i1)
        D_2.append(D_i2)

    return N, D_1, D_2


def main(N: int, D_1: list, D_2: list) -> None:
    """
    メイン処理.

    Args:\n
        N (int): サイコロを振った回数(3 <= N <= 100)
        D_1 (list): i回目の出目(1 <= D_i1 <= 6)
        D_2 (list): i回目の出目(1 <= D_i2 <= 6)
    """
    # 求解処理
    ans = "No"
    doublet_cnt = 0
    for i in range(N):
        if D_1[i] == D_2[i]:
            doublet_cnt += 1
        else:
            doublet_cnt = 0

        if doublet_cnt >= 3:
            ans = "Yes"
            break

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    N, D_1, D_2 = get_input()

    # メイン処理
    main(N, D_1, D_2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
cou = 0
ans = False
for i in range(n):
	da, db = map(int, input().split())
	if da == db:
		cou += 1
	else:
		cou = 0
	if cou == 3:
		ans = True

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

Submission status: Accepted

Solution code:
N=int(input())
ans=0
ke=0
for i in range(N):
    D,E=map(int,input().split())
    if D==E:
        ans+=1
    else:
        ans=0
    if ans>=3:
        ke=1
if ke==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# inp.readline()
# int(inp.readline())
# out.write()
# raw_input()
# map(int,raw_input().split())
# map(int,inp.readline().split())
# for _ in xrange(input()):
# print "Case #"+str(_+1)+": "+ 
if __name__ == "__main__":
    from sys import stdin as inp, stdout as out,setrecursionlimit as srl
    from collections import Counter,defaultdict,deque
    from heapq import *
    for _ in xrange(1):
        n=input()
        a=map(lambda x:x[0]==x[1],[map(int,inp.readline().split()) for i in  xrange(n)])
        print 'Yes' if any(all(a[i:i+3]) for i in xrange(n-2)) else 'No'

Submission status: Accepted

Solution code:
N = int(input())
cnt = 0
flg = False
for _ in range(N):
    a, b = map(int, input().split())
    if a != b:
        cnt = 0
    else:
        cnt += 1
    if cnt >= 3:
        flg = True

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

Submission status: Accepted

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

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

print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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
        # break

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
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()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

Solution code:
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

#maincode-------------------------------------------------

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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


# 2darray [[0] * 4 for i in range(3)]
# import itertools

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = [list(map(int, input().split())) for i in range(n)]
#print(l[0][0])
#print(l[0][1])
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")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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