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:
N=int(input())

prev_d1=0
prev_d2=0

seq=0
flag = False
for _ in range(N):
    d1, d2 = map(int, input().split())

    if d1==d2:
        seq+=1
    else:
        seq=0

    if seq==3:
        flag=True
if flag:
    print("Yes")
else:
    print("No")

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

Submission status: Accepted

Solution code:
n=int(input())
a=[]
for i in range(n):
  x,y=map(int,input().split())
  a.append([x,y])
f=0;
for i in range(n-2):
  if (a[i][0]==a[i][1]and a[i+1][0]==a[i+1][1] and a[i+2][0]==a[i+2][1]):
    f=1
if f:
  print("Yes")
else :
  print("No")

Submission status: Accepted

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

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())
D = []
E = []
clear = 0
for i in range(N):
    x, y = map(int, input().split())
    D.append(x)
    E.append(y)

for i in range(N - 2):
    if D[i] == E[i] and D[i + 1] == E[i + 1] and D[i + 2] == E[i + 2]:
        clear = 1
        break

if clear == 0:
    print('No')
else:
    print('Yes')

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
for i in range(n):
  if x[i] == y[i]:
    count += 1
    if count == 3:
      print('Yes')
      exit()
  else:
    count = 0

print('No')

Submission status: Accepted

Solution code:
N = int(input())
ct = 0
flg = 0
for i in range(N):
    s,g = map(int,input().split())
    if s == g:
        ct += 1
    else:
        ct = 0
    if ct == 3:
        flg = 1

print(("No","Yes")[flg == 1])

Submission status: Accepted

Solution code:
# cook your dish here
import sys,math
try:sys.stdin,sys.stdout=open('input.txt','r'),open('out.txt','w')
except:pass
from sys import stdin,stdout;mod=int(1e9 + 7);from statistics import mode
from collections import *;from math import ceil,floor,inf,factorial,gcd,log2,sqrt,log
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
# print('{:.3f}'.format(1),round(1.123456789,4))
# sys.setrecursionlimit(500000)
def lcm(a,b): return (a*b)//gcd(a,b)
def setbits(n):return bin(n).count('1')
def resetbits(n):return bin(n).count('0')
def modinv(n,p):return pow(n,p-2,p)
def ncr(n,r):
    num,den=1,1;r=min(n,n-r)
    for i in range(r):num*=(n-i);den*=(i+1)
    return num//den
def ncr_p(n, r, p):
    num,den=1,1;r=min(r,n-r)
    for i in range(r):num = (num * (n - i)) % p ;den = (den * (i + 1)) % p
    return (num * modinv(den,p)) % p
def isPrime(num) :
    if num<=1:return False
    if num==2 or n==3:return True
    if (num % 2 == 0 or num % 3 == 0) :return False
    m = int(num**0.5)+1
    for i in range(5,m,6):
        if (num % i == 0 or num % (i + 2) == 0) :return False
    return True
def bin_search(s, low, high, val):
    while low <= high:
        mid = low + (high - low) // 2;
        if s[mid] == val:return mid
        elif s[mid] < val:low = mid + 1
        else:high = mid - 1
    return -1
def sumofdigit(num):
    count=0;
    while num : count+=num % 10;num //= 10;
    return count;
def inputmatrix():
    r,c=iia();mat=[0]*r;
    for i in range(r):mat[i]=iia();
    return r,c,mat;
def prefix_sum(n,s):
    for i in range(1,n):s[i]+=s[i-1]
    return s;
def binomial(n, k):
    if 0 <= k <= n:
        ntok = 1;ktok = 1
        for t in range(1, min(k, n - k) + 1):ntok *= n;ktok *= t;n -= 1
        return ntok // ktok
    else:return 0
def divisors(n):
    res = [];
    for i in range(1,ceil(sqrt(n))+1):
        if n%i == 0:
            if i==n//i:res.append(i)
            else:res.append(i);res.append(n//i)
    return res;

# coding start heres
n = ii1()
arr=[];flag=False
for i in range(n):
    a,b=iia()
    arr.append([a,b])
for i in range(n-2):
    if arr[i][0]==arr[i][1] and arr[i+1][0]==arr[i+1][1] and arr[i+2][0]==arr[i+2][1]:
        flag=True
if flag:print('Yes')
else:print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

def main():
    zorome = 0
    ans = 'No'
    for _ in range(N):
        x, y = list(map(int, input().split()))
        if x == y:
            zorome += 1
            if zorome >= 3:
                ans = 'Yes'
        else:
            zorome = 0
    return ans

print(main())

Submission status: Accepted

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

ans = [i[0] == i[1] for i in d] + [False, False]
ans2 = [sum( ans[i:i+3] ) for i in range(n)]

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

Submission status: Accepted

Solution code:
n=int(input())
d=[input().split()for _ in range(n)]
c=0
for i in range(n-2):
    if d[i][0]==d[i][1]:
        if d[i+1][0]==d[i+1][1]:
            if d[i+2][0]==d[i+2][1]:
                c+=1
                print("Yes")
                break
            else:
                pass
        else:
            pass
    else:
        pass
if c==0:
    print("No")
else:
    pass

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
a = []
b = []
count = 0
for i in range(n):
    aa,bb = map(int, input().split())
    a.append(aa)
    b.append(bb)
for i in range(n):
    if a[i] == b[i]:
        count += 1
    else:
        count = 0
    if count == 3:
        print("Yes")
        break
else:
    print("No")

Submission status: Accepted

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

flag=0
cnt=0
for i in range(N):
    if A[i][0]==A[i][1]:
        cnt+=1
    else:
        cnt=0
    if cnt==3:
        flag=1
if flag==1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n=int(input())
d1=[]
d2=[]

for _ in range(n):
    D1,D2 = map(int,input().split())

    d1.append(D1)
    d2.append(D2)

ans='No'

cnt=0
for i in range(n):
    p=d1[i]
    q=d2[i]

    if p==q:
        cnt+=1
    else:
        cnt=0

    if cnt>=3:
        ans='Yes'
        break


print(ans)

Submission status: Accepted

Solution code:
t=int(input())
c=0
flag=1
while t>0:
    m,n=map(int,input().split())
    if m==n:
        c+=1
        if c==3:
            print('Yes')
            flag=0
            break
    else:
        c=0
    t-=1
if flag==1:
    print('No')

Submission status: Accepted

Solution code:
n=int(input())
cnt=0
for _ in range(n):
  d1,d2=map(int,input().split())
  if d1==d2:
    cnt += 1
  else:
    cnt = 0
  if cnt >= 3:
    print('Yes')
    break
else:
  print('No')

Submission status: Accepted

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

for i in range(n):
    if ans >= 3:
        break
    if results[i][0] == results[i][1]:
        ans += 1
    else:
        ans = 0
if ans >= 3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
_,*d=[{*t.split()}for t in open(0)]
print('YNeos'[all(max(map(len,d[i:i+3]))>1for i in range(len(d)-2))::2])

Submission status: Accepted

Solution code:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()
    ans_list = []
    for i in range(n):
        a, b = i_map()
        if a == b:
            ans_list.append(1)
        else:
            ans_list.append(0)

    for i in range(n-2):
        if ans_list[i] == ans_list[i+1] == ans_list[i+2] == 1:
            print('Yes')
            exit()

    print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import exit
N = int(input())
 
cnt = 0
for i in range(N):
    x,y = map(int,input().split())
    if cnt == 3:
        print("Yes")
        exit(0)
    if x == y:
        cnt += 1
    else:
        cnt = 0

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

Submission status: Accepted

Solution code:
N = int(input())
D = [tuple(map(int, input().split())) for n in range(N)]

is_jails = ''.join(['T' if a == b else 'F' for a, b in D])

if 'TTT' in is_jails:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
s = []
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()
print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
N = int(input())
D = [False] * N

for i in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        D[i] = True

i = 0
while i < N:
    if D[i]:
        cnt = 0
        while i <N and D[i]:
            cnt += 1
            i += 1
        if cnt >=3:
            print('Yes')
            sys.exit(0)
    else:
        i += 1

print("No")

Submission status: Accepted

Solution code:
from sys import stdin
readline = stdin.readline
def i_input(): return int(readline().rstrip())
def i_map(): return map(int, readline().rstrip().split())
def i_list(): return list(i_map())


def main():
    N = i_input()
    ans = False
    z = 0
    for _ in range(N):
        D1, D2 = i_map()
        if D1 == D2:
            z += 1
            if z >= 3:
                ans  = True
        else:
            z = 0
    print("Yes" if ans else "No")

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import Counter
import math
import statistics
import itertools
a=int(input())
# b=input()
# c=[]
# for i in a:
#     c.append(int(i))
# A,B,C= map(int,input().split())
# f = list(map(int,input().split()))
# g = [input() for _ in range(a)]
h = []
for i in range(a):
    h.append(list(map(int,input().split())))
# a = [[0] for _ in range(H)]#nizigen
ans=0
count=0
for i in range(len(h)):
    if sum(h[i])==h[i][0]*2:
        count+=1
    else:
        ans=max(ans,count)
        count=0

if count>=3:
    ans=max(ans,count)

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

Submission status: Accepted

Solution code:
n = int(input())
L = []
for i in range(n):
    a, b = map(int, input().split())
    if a == b:
        L.append("a")
    else:
        L.append("b")

if "aaa" in "".join(L):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = int(input())
D = [[*map(int, input().split())] for _ in range(n)]
# print(n)
# print(D)

# ans = True
c = 0
for x, y in D:
    # print(x,y)
    if x==y:c+=1
    else: c = 0
    if c == 3: break

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

Submission status: Accepted

Solution code:
s = int(input())
count = 0

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

Submission status: Accepted

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

cnt = 0
for d1, d2 in D:
    if d1 == d2:
        cnt += 1
    elif d1 != d2:
        cnt = 0
    if cnt == 3:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int,input().split())
    A.append(a)
    B.append(b)
p = 0
for i in range(N-2):
    if A[i] == B[i] and A[i+1] == B[i+1] and A[i+2] == B[i+2]:
        print("Yes")
        break
    else:
        p += 1
if p == N-2:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
D1 = [0]*N
D2 = [0]*N
ans = 'No'
for i in range(N):
    D1[i], D2[i] = map(int, input().split())
list = []
for i in range(N):
  if D1[i] == D2[i]:
    list.append(0)
  else:
    list.append(1)
for i in range(N-2):
  if list[i] == 0 and list[i+1] == 0 and list[i+2] == 0:
    ans ='Yes'
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

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

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

Submission status: Accepted

Solution code:
N = int(input())
count = 0
flag = False
for _ in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        count += 1
        if count == 3:
            flag = True
            break
    else:
        count = 0

if flag == True:
    print('Yes')
else:
    print("No")

Submission status: Accepted

Solution code:
import sys

def input(): return sys.stdin.readline().rstrip("\r\n")
def List(): return list(map(int, input().split()))
def Num(): return int(input())


inp = []
ok = False
for _ in range(Num()):
    a, b = List()
    inp.append([a, b])
for i in range(len(inp) - 3 + 1):
    if inp[i][0] == inp[i][1] and inp[i + 1][0] == inp[i + 1][1] and inp[i + 2][0] == inp[i + 2][1]:
        ok = True
        break
print("Yes" if ok else "No")

Submission status: Accepted

Solution code:
iterate = int(input())
cnt = 0
for i in range(iterate):
  dice = list(map(lambda x: int(x), input().split()))
  if dice[0]==dice[1]:
    cnt += 1
  else:
    cnt = 0
  if cnt==3: break
    
if cnt!=3: print("No")
else: print("Yes")

Submission status: Accepted

Solution code:
n=int(input())

flag=0
ans =0
for i in range (n):
    x,y=map(int,input().split())
    if x==y :
        flag +=1
    else :
        flag=0
    if flag == 3:
        ans=1

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

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

if(count != 3):
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n = int(input())
    r = 0
    m = map(int, read().split())
    ab = zip(m, m)
    t = 0
    for a, b in ab:
        if a == b:
            t += 1
            if t == 3:
                print('Yes')
                sys.exit()
        else:
            t = 0
    print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
D1 = []
D2 = []
count = 0
flag = 0
for i in range(N):
    d1, d2 = input().split()
    if int(d1) == int(d2):
        count = count + 1
        if count >= 3:
            flag = 1
    else:
        count = 0
if flag == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys

n = int(input())
z = 0

for i in range(n):
  d1, d2 = map(int, input().split())
  if d1 != d2:
    z = 0
    continue

  z += 1
  if z >= 3:
    print('Yes')
    sys.exit()

print('No')

Submission status: Accepted

Solution code:
import sys

if __name__ == '__main__':
    _ = sys.stdin.readline().rstrip()
    n = 0
    for line in sys.stdin.readlines():
        line = line.rstrip()
        a, b = list(map(lambda x:int(x), line.split(' ')))
        if a == b:
            n += 1
        else:
            n = 0
        if n == 3:
            print('Yes')
            exit()
    print('No')

Submission status: Accepted

Solution code:
n = int(input())

z_count = 0
for _ in range(n):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        z_count += 1
    else:
        z_count = 0

    if z_count == 3:
        print ("Yes")
        exit ()

print ('No')

Submission status: Accepted

Solution code:
N = int(input())

count = 0

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

if count < 3:
	print("No")

Submission status: Accepted

Solution code:
import sys
N = int(input())
D = []
for i in range(N):
    D.append(input().split())
cnt = 0
for i in range(N):
    if D[i][0] == D[i][1]:
        cnt += 1
        if cnt == 3:
            print("Yes")
            sys.exit()
    else:
        cnt = 0
print("No")

Submission status: Accepted

Solution code:
def solve():
    n = int(input())
    ct = 0
    for _ in range(n):
        a, b = input().split()
        if a == b:
            ct += 1
            if ct == 3:
                return 'Yes'
        else:
            ct = 0
    return 'No'
    

print(solve())

Submission status: Accepted

Solution code:
n = int(input())

c = 0
for i in range(n):
    i,j = list(map(int, input().split()))
    if i == j and c == 0:
        c += 1
    elif i == j and c == 1:
        c += 1
    elif i == j and c == 2:
        c += 1
        break
    else:
        c = 0
    
if c == 3:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())

count = 0

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

Submission status: Accepted

Solution code:
N = int(input())

cnt = 0
for i in range(N):
    a, b = list(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:
def main():
  n = int(input())
  result = []
  for i in range(n):
    d1, d2 = map(int, input().split())
    result.append(d1 == d2)
  for i in range(n-2):
    if result[i] and result[i+1] and result[i+2]:
      print("Yes")
      return 0
  print("No")
  return 0
    
if __name__ == "__main__":
  a = main()

Submission status: Accepted

Solution code:
import sys
N = int(input())
D = [[int(x) for x in input().split()] for _ in range(N)]
D2 = [x[0] == x[1] for x in D]
for i in range(N-2):
    if D2[i] and D2[i+1] and D2[i+2]:
        print("Yes")
        sys.exit()
print("No")

Submission status: Accepted

Solution code:
N = int(input())

isDouble = []

for i in range(N):
    temp = [int(j) for j in input().split(" ")]
    if temp[0] == temp[1]:
        isDouble.append(1)
    else:
        isDouble.append(0)

cnt = 0
flg = False

for i in range(len(isDouble)):
    if isDouble[i] == 0:
        cnt = 0
    else:
        cnt += isDouble[i]
    if cnt == 3:
        flg = True
        break

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n= int(input())
d = [0] * n
for i in range(n):
    d[i] = tuple(map(int, input().split()))

for i in range(n - 2):
    if d[i][0] == d[i][1] and d[i+1][0] == d[i+1][1] and d[i+2][0] == d[i+2][1]:
        print('Yes')
        sys.exit(0)
print('No')

Submission status: Accepted

Solution code:
t=0
r=0
for _ in range(int(input())):
    a,b=map(int,input().split())
    if a==b:
        t+=1
    else:
        t=0
    if t>=3:
        r+=1
if t>=3 or r>0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
A=[]
for _ in range(N):
    A.append(list(map(int,input().split())))
count=0
for i in range(N):
    if A[i][0]==A[i][1]:
        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())

Ds = []
for i in range(N):
    D1, D2 = map(int, input().split())
    Ds.append([D1, D2])

ans = 'No'

# print(Ds)
for i in range(N):
    if i == 0 or i ==1:
        continue
    elif Ds[i][0] == Ds[i][1] and Ds[i-1][0] == Ds[i-1][1] and Ds[i-2][0] == Ds[i-2][1]:
        ans = 'Yes'
        break

print(ans)

Submission status: Accepted

Solution code:
import sys

def dump(x):
    print(x, file=sys.stderr)


N = int(input())
buf = 0
for i in range(N):
    a,b = input().split()
    if a == b :
        buf += 1
        if buf >=3:
            break
    else:
        buf = 0

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

Submission status: Accepted

Solution code:
n = int(input())

cnt = 0
ans = "No"
for i in range(n):
    d = tuple(map(int, input().split()))
    if d[0] == d[1]:
        cnt += 1
    else:
        cnt = 0
    if 3 <= cnt:
        ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

t = 0
for i in range(n):
    a, b = map(int, input().split())

    if a == b:
        t += 1
        if t == 3:
            print("Yes")
            break
    else:
        t = 0

if t < 3:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    cnt = 0 # 連続ゾロ目カウンター
    ans = 'No'

    for n in range(N):
        if len(set(map(int, input().split()))) == 1: # ゾロ目だったら
            cnt += 1
        else:
            cnt = 0
        if cnt >= 3:    # 三回連続で出たら
            ans = 'Yes'
    else:
        print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
si = sys.stdin.readline

n = int(si())
t = 0
flag = False
while n:
    n -= 1
    a, b = [int(e) for e in si().split()]
    if a == b:
        t += 1
    else:
        t = 0
    if t >= 3:
        flag = True
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a = int(input())

flag = False
count = 0
for i in range(a):
    b, c = input().split()
    if b == c:
        count += 1
        if count == 3:
            flag = True
    else:
        count = 0

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

Submission status: Accepted

Solution code:
n = int(input())
count = 0
flag = False
for i in range(n):
    a, b = map(int, input().split())
    if a == b:
        if count == 2:
            flag = True
        else:
            count += 1
    else:
        count = 0
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())

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

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

Submission status: Accepted

Solution code:
N=int(input())

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

Submission status: Accepted

Solution code:
x=int(input())
count=0
for a in range(x):
  b=input().split(' ')
  if int(b[0])==int(b[1]):
    count+=1
  else:
    count=0
  if count==3:
    break
if count==3:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

N = int(input())

ans = False
count = 0
D1 = []
D2 = []
for i in range(N):
    d1, d2 = map(int, input().split())
    D1.append(d1)
    D2.append(d2)

for i in range(N):
    if D1[i] == D2[i]:
        count += 1
    else:
        count = 0

    if count == 3:
        ans = True
        break

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

Submission status: Accepted

Solution code:
def solve():
    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 > 2:
            print("Yes")
            exit()
    print("No")
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from heapq import heappop, heappush, heappushpop, heapify
import copy
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


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

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


n = I()
cnt = 0
flg = 0
for i in range(n):
    d1, d2 = LI()
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt > 2:
        flg = 1
if flg:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N=int(input())
flag=0
count=0
for i in range(N):
    s,t=map(int,input().split())
    if s==t:
        count=count+1
    else:
        count=0
    if count==3:
        flag=1
if flag==1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
def calc(n):
    bool1 = False
    bool2 = False
    bool3 = False
    for i in range(n):
        d1, d2 = (int(x) for x in input().split())
        if d1 == d2:
            if bool2 == True:
                bool3 = True
            if bool1 ==True:
                bool2 = True
            if bool1 == False:
                bool1 = True
        else:
            bool1 = False
            bool2 = False
    return bool3
if calc(n):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = int(input())
D1 = [0]*N
D2 = [0]*N
for i in range(N):
    D1[i], D2[i] = map(int, input().split())

cnt = 0
is_zorome = False
for i in range(N):
    if D1[i] == D2[i]:
        cnt+=1
    else:
        cnt=0
    if cnt == 3:
        is_zorome = True

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

Submission status: Accepted

Solution code:
N=int(input())
count = 0
flag = "No"
for x in range(N):
	a=input().split()
	if (a[0]==a[1]):
		count+=1
		if(count==3):
			flag = "Yes"
	else:
		count = 0
print(flag)

Submission status: Accepted

Solution code:
N=int(input())
ans=0
flag=0

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

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

Submission status: Accepted

Solution code:
N = int(input())
zoro_try = []
zoro_cnt = 0
isOk = False
for i in range(N):
    d1, d2 = map(int, input().split())
    zoro_try.append([d1, d2])
    if i == 0 or i == 1: continue
    if zoro_try[i-1][0] == zoro_try[i-1][1] and zoro_try[i-2][0] == zoro_try[i-2][1] and zoro_try[i][0] == zoro_try[i][1]:
        isOk = True

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
import functools
import math
from collections import Counter
from itertools import combinations
import re

N = int(input())

OK = 0
cnt = 0
for i in range(N):
    A = list(map(int,input().split()))
    if A[0] == A[1]:
        cnt = cnt + 1
    else:
        cnt = 0
    if cnt >= 3:
        OK = 1

if OK >= 1:
    print('Yes')
else:
    print('No')