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:
from sys import stdin

N = int(input())
ct = 0
ans = 'No'
for _ in range(N):
    d1, d2 = map(int, stdin.readline().split())
    if d1 == d2:
        ct += 1
        if ct == 3:
            ans = 'Yes'
    else:
        ct = 0

print(ans)

Submission status: Accepted

Solution code:
N, *AB = map(int, open(0).read().split())
AB = list(zip(*[iter(AB)] * 2))

for (a, b), (c, d), (e, f) in zip(AB, AB[1:], AB[2:]):
    if a == b and c == d and e == f:
        print("Yes")
        quit()

print("No")

Submission status: Accepted

Solution code:
n = int(input())
ilis =[]
check = 0
for _ in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        ilis.append(True)
    else:
        ilis.append(False)

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

Submission status: Accepted

Solution code:
n = int(input())
d = []
for i in range(n):
    d.append(list(map(int,input().split())))
row = []
for i in range(n):
    if d[i][0]==d[i][1]:
        row.append(True)
    else:
        row.append(False)
res = False
for i in range(n-2):
    if all(row[i:i+3]):
        res = True
if res:
    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)]
ans='No'
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())
Dl = []
for i in range(N):
  D = list(map(int, input().split()))
  Dl.append(D)
cn = 0
df = False
for i in range(len(Dl)):
  D = Dl[i]
  D0 = D[0]
  D1 = D[1]
  if D0 == D1:    
    cn += 1
  else:
    cn = 0
  if cn == 3:
    df = True
    break
if df == True:
  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
flag = False
for d in D:
    if d[0] == d[1]:
        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())
d1=[0]*N
d2=[0]*N
for i in range(N):
    d1[i],d2[i]=list(map(int,input().split()))
counter=0
for i in range(N-2):
    if d1[i]==d2[i] and d1[i+1]==d2[i+1] and d1[i+2]==d2[i+2]:
        counter=1
if counter==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
for k in range(n-2):
    if x[k] == y[k] and x[k+1] == y[k+1] and x[k+2] == y[k+2]:
        count += 1
if count >= 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())

affilé = 0
ok = 0


for i in range(n):
  d1, d2 = [int(k) for k in input().split()]
  if d1 == d2:
    affilé += 1
  elif d1 != d2:
    affilé = 0
  

  if affilé == 3:
    ok = 1

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

Submission status: Accepted

Solution code:
N = int(input())                                                                                              
count = 0    
result = 'No'    
dice_list = []    
    
for i in range(N):    
    dice_list.append(list(map(int, input().split())))    
    
for i in range(N):    
    if dice_list[i][0] == dice_list[i][1]:    
        count += 1    
        if count >= 3:    
            break    
    else:    
        count = 0    
    
if count >= 3:    
    result = 'Yes'    
    
print(result)

Submission status: Accepted

Solution code:
N = int(input())
val = 0
def mojicheck(a,b):
    if a==b:
        return 1
    else:
        return 0
flag = 0
for i in range(N):
    d1,d2 = map(int,input().split())
    flag = mojicheck(d1,d2)

    if flag == 0:
        val = 0
    elif flag == 1:
        val += 1
    if val ==3:
        break
if val >=3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
n = int(input())
w = 0
j = 0
for i in range(n):
    x, y = map(int,input().split(' '))
    if x == y:
        j += 1
        if j >= 3:
            w = 1
    else:
        j = 0
if w == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import time
from math import ceil
from collections import defaultdict, deque


def A(s):
  if s[-1] == 's':
    return s + 'es'
  return s + 's'


def B(n, d):
  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]):
      return 'Yes'
  return 'No'


def main():
  n = int(input())
  d = [list(map(int, input().split())) for i in range(n)]
  print(B(n, d))


if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
from os import path
import sys
from heapq import heappush,heappop
from functools import cmp_to_key as ctk
from collections import deque,defaultdict as dd 
from bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right
from itertools import permutations
from datetime import datetime
from math import ceil,sqrt,log,gcd
def ii():return int(input())
def si():return input().rstrip()
def mi():return map(int,input().split())
def li():return list(mi())
abc='abcdefghijklmnopqrstuvwxyz'
mod=1000000007
# mod=998244353
inf = float("inf")
vow=['a','e','i','o','u']
dx,dy=[-1,1,0,0],[0,0,1,-1]

def bo(i):
    return ord(i)-ord('a')

def ceil(a,b):
    return (a+b-1)//b
file=1

def f():
    sys.stdout.flush()





def solve():

    # for _ in range(ii()):
   
        
    n = ii()
    a =  []
    for i in range(n):
        a.append(li())

    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]:
            print('Yes')
            exit(0)
    print('No')










        
if __name__ =="__main__":

   
    if path.exists('input.txt'):
        sys.stdin=open('input.txt', 'r')
        sys.stdout=open('output.txt','w')
    else:
        input=sys.stdin.readline
    solve()

Submission status: Accepted

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

d2 = []
ans = "No"

for i in range(n):
    if d[i][0] == d[i][1]:
        d2.append(1)
    else:
        d2.append(0)

for i in range(0, n-2):
    if d2[i] == 1 and d2[i+1] == 1 and d2[i+2] == 1:
        ans = "Yes"
        break

print(ans)

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
N = int(input())

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

lenD = 0
zorome = 0
for x,y in D_list:
    if x == y:
        zorome += 1
        if zorome == 3:
            print("Yes")
            break
        else:
            pass
    else:
        zorome = 0
    lenD += 1
    if lenD >= N:
        print("No")
        break

Submission status: Accepted

Solution code:
if __name__ == "__main__":

    n = int(input())

    d1 = []
    d2 = []
    flag = 0

    for i in range(n):
        a,b = (int(x) for x in input().split())
        #print(a)
        #print(b)
        d1.append(a)
        d2.append(b)

        if i >= 2:
            if d1[i-2] == d2[i-2] and \
               d1[i-1] == d2[i-1] and \
               d1[i] == d2[i] :
                  flag = 1

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

Submission status: Accepted

Solution code:
n = int(input())
d1 = []
d2 = []
while n:
    a, b = map(int, input().split())
    d1.append(a)
    d2.append(b)
    n-=1
cnt = 0
flag = 0
for i in range(len(d1)):
    if d1[i]==d2[i]:
        cnt+=1
    else:
        cnt=0
    if cnt==3:
        flag = True
        print('Yes')
        break
if not flag:
    print('No')

Submission status: Accepted

Solution code:
_counter = 0
_max = 0
_throw = int(input())

for _i in range(_throw):
  _numbers = list(map(int, input().split(" ")))
  if _numbers[0] == _numbers[1]:
    _counter += 1
    if _counter > _max:
      _max = _counter
  else:
    _counter = 0

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
count = 0
flag = 0
for i in range(N):
  x = list(map(int,input().split()))
  if x[0] == x[1]:
    count += 1
    if count >= 3:
      flag = 1
  else:
    count = 0

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

Submission status: Accepted

Solution code:
n = int(input())
ans = False
zoro = 0
for _ in range(n):
    one, two = map(int,input().split())
    if one == two:
        zoro += 1
        if zoro == 3:
            ans = True
            break
    else:
        zoro = 0
        
if ans == True:
    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 count >= 3:
        break
    if D1 == D2:
        count += 1
    elif D1 != D2:
        count = 0

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

Submission status: Accepted

Solution code:
N = int(input())
streak = 0

C = []

for i in range (0, N):
    A, B = map(int, input().split())
    C.append([A,B])

for i in range (0, N):
    if C[i][0] == C[i][1]:
        streak+=1
    else:
        streak = 0
    if streak > 2:
        print('Yes')
        exit()

print('No')

Submission status: Accepted

Solution code:
N = int(input())

flag = 0
ans = 0

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

Submission status: Accepted

Solution code:
def dice(N):
    for i in range(len(N)-2):
        if N[i][0]==N[i][1] and N[i+1][0]==N[i+1][1] and N[i+2][0]==N[i+2][1]:
            return "Yes"
    return "No"

Number=int(input())
N=[]
for i in range(Number):
    x,y=input().split()
    N.append([int(x), int(y)])
print(dice(N))

Submission status: Accepted

Solution code:
N = int(input())
k1= []
k2= []
count=0
for i in range(N):
    n1,n2= map(int,input().split())
    k1.append(n1)
    k2.append(n2)
for j in range(N-2):
    if k1[j] == k2[j] and k1[j+1] == k2[j+1] and k1[j+2] == k2[j+2]:
        count +=1
if count != 0 :
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import numpy as np
import math
def permutations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r))

def A():
    xlist  = list(map(int,input().split()))
    xnp = np.array(xlist)
    xplace = np.where(xnp==0)
    print(str(xplace[0][0]+1))
def B030():
    import math
    n,m = map(int,input().split())
    n = n%12

    longs = 360*m/60
    shorts = 360*n/12+m/60*30

    print("%2.4f" % min(abs(longs-shorts),360-abs(longs-shorts)))

def AGC015_A():
    n,a,b = map(int,input().split())

    if n == 1:
        if a!=b:
            print("0")
            return
        else:
            print("1")
            return
    else:
        print(permutations_count(b-a+1,n-2))

def ABC107_A():
    n,i=map(int,input().split())
    print(n-i+1)

def ABC172_A():
    import math
    a = int(input())
    print(a+pow(a,2)+pow(a,3))

def ABC172_B():
    s = input()
    t = input()

    counter=0
    for i in range(len(s)):
        if s[i] != t[i]:
            counter += 1
    if counter == len(s):
        print(counter)
    else:
        print(counter)

def ABC172_C():
    import sys
    sys.setrecursionlimit(4100000)

    n,m,k = map(int,input().split())
    a = list(map(int,input().split()))
    b = list(map(int,input().split()))

    if k < a[0] or k < b[0]:
        print(0)
        return

    minamo = []
    def saiki(i,j,sum,mx):
        if sum >= k:
            mx = min(i+j,mx)
            return mx

        if i+j >= mx:
            return mx

        if i+1 <= n:
            mx = saiki(i+1,j,sum+a[i],mx)
        if j+1 <= m:
            mx = saiki(i,j+1,sum+b[j],mx)

        return mx

    mls = saiki(0,0,0,pow(10,5))
    print(mls)



def ABC172_Dd():
    def make_divisors(n):
        lower_divisors , upper_divisors = [], []
        i = 1
        while i*i <= n:
            if n % i == 0:
                lower_divisors.append(i)
                if i != n // i:
                    upper_divisors.append(n//i)
            i += 1
        return lower_divisors + upper_divisors[::-1]

    n = int(input())
    sum = 0
    for i in range(1,n+1):
        sum += i * len(make_divisors(i))
    print(sum)

def ABC172_D():
    def num_divisors_table(n):
        table = [0] * (n + 1)

        for i in range(1, n + 1):
            for j in range(i, n + 1, i):
                table[j] += 1

        return table

    a = num_divisors_table(4)
    print(a)

def ABC046_B():
    import numpy as np
    n,k = map(int,input().split())
    print(n,k)

    for i in range(n):
        ans = k*np.power(k-1,n-1)

    print(ans)

def CODE_festival_2016_A():
    import numpy as np
    N = int(input())
    a = np.array(list(map(int,input().split())))

    ans = 0
    for i in range(N):
        if i == a[a[i]-1]-1:
            ans += 1

    print(int(ans) if ans%2==1 else int(ans/2))

def abc054_b():
    import pandas as pd
    N,M = map(int,input().split())
    a = [input() for i in range(N)]
    b = [input() for i in range(M)]

    ans1=0
    a_df = pd.DataFrame(a)
    for m in range(M):
        for n in range(N):
            if a_df.iloc[:,0].str.contains(b[m])[n]:
                ans1+=1

    a_dfT = pd.DataFrame(a).T
    b = pd.DataFrame(b).T.to_numpy().tolist()[0]

    ans2=0
    for m in range(len(a_dfT)):
        for n in range(len(b)):
            if a_dfT.iloc[:,0].str.contains(b[n])[m]:
                ans2+=1

    if ans1==ans2:
        print("Yes" if ans1==len(b) else "No")
    else:
        print("No")

def test():
    import pandas as pd
    import numpy as np
    a = ["#.#",".#.","#.#"]; b = ["#.",".#"]


    ans1=0
    a_df = pd.DataFrame(a)
    for m in range(M):
        for n in range(N):
            if a_df.iloc[:,0].str.contains(b[m])[n]:
                print()
                ans1+=1

    a_dfT = pd.DataFrame(a).T
    b = pd.DataFrame(b).T.to_numpy().tolist()[0]

    ans2=0
    for m in range(len(a_dfT)):
        for n in range(len(b)):
            if a_dfT.iloc[:,0].str.contains(b[n])[m]:
                ans2+=1

    if ans1==ans2:
        print("Yes" if ans1==len(b) else "No")
    else:
        print("No")

'''
6 4
#.#
.#.
#.#
#.#
.#.
#.#
#.
.#
#.
.#
'''

def abc002_D():
    N,M = map(int,input().split())
    xy = [];people=[[] for i in range(N)]
    print(people)
    for i in range(M):
        xy = list(map(int,input().split()))

        people[xy[0]-1].append(xy[1])
        people[xy[1]-1].append(xy[0])

    print(people)

    Gatcha = 0
    for Order in range(N):
        for PeopleIndex in people[Order]:
            if Order in people[PeopleIndex-1]:
                Gatcha+=1
        if len(people(Order))==Gatcha:
            pass

def abc173_a():
    N = int(input())
    #N = 3000%1000
    if N%1000 ==  0:
        print(0)
    else:
        print(1000-N%1000)

def abc173_b():
    N = int(input())

    #AC WA TLE RE
    l = [0 for i in range(4)]

    for i in range(N):
        Inp = input()
        if Inp == "AC":
            l[0] += 1
        if Inp == "WA":
            l[1] += 1
        if Inp == "TLE":
            l[2] += 1
        if Inp== "RE":
            l[3] += 1

    print("AC x "+str(l[0]))
    print("WA x "+str(l[1]))
    print("TLE x "+str(l[2]))
    print("RE x "+str(l[3]))

def abc173_c():
    pass


def abc173_d():
    import sys
    sys.setrecursionlimit(4100000)
    N = int(input())
    a =  list(map(int,input().split()))


    a = sorted(a,reverse=True)

    Enkan = [a[0],a[1]]





    gokei = []
    def saiki(i,suma,Enkan):

        if i == N:
            gokei.append(sum(suma))
            return
        else:
            for k in range(len(Enkan)):

                if k != len(Enkan)-1:
                    suma.append(min(Enkan[k],Enkan[k+1]))
                    Enkan.insert(k,a[i])
                    saiki(i+1,suma,Enkan)
                    del Enkan[k]
                    del suma[-1]
                else:
                    suma.append(min(Enkan[-1],Enkan[0]))
                    Enkan.insert(0,a[i])
                    saiki(i+1,suma,Enkan)
                    del Enkan[0]
                    del suma[-1]

    saiki(2,[3],[a[0],a[1]])
    print(max(gokei))

def abc037_c():
    n,k = map(int,input().split())
    a = list(map(int,input().split()))

    suma = 0
    ruiseki = [0]*(n+1)

    for i in range(n):
        ruiseki[i+1] = ruiseki[i] + a[i]
    #print(ruiseki)

    for i in range(n):

        suma += ruiseki[n-k+1+i] - ruiseki[i]
        #print(suma,n-k+1+i,i)
        if n-k+1+i == n:
            break
    print(suma)

def abc061_c():
    s = str(input())

    l = []
    def saiki(i,moji):
        if i == len(s)-1:
            #print(moji)
            l.append(sum(list(map(int,moji.split("+")))))
            return

        #いれる
        saiki(i+1,moji+"+"+s[i+1])
        #いれない
        saiki(i+1,moji+s[i+1])

    saiki(0,s[0])

    print(sum(l))

def abc104_c():
    d,g = map(int,input().split())
    plist = []; clist = []
    for i in range(d):
        Inp = list(map(int,input().split()))
        plist.append(Inp[0])
        clist.append(Inp[1])

    def saiki(i,sum):
        if sum > g:
            return

        saiki(i+1,sum+v_new)
        saiki(i+1,sum+v_new)

def agc037_a():
    import sys
    input = sys.stdin.readline

    S = input().rstrip('\n')
    left = ''
    now = ''
    ans = 0
    for i in range(len(S)):
        now += S[i]
        if left != now:
            ans += 1
            left = now
            now = ''
        # print(S[i], ans)
    print(ans)


def arc29_a():
    import numpy as np
    N = int(input())
    t = [int(input()) for i in range(N)]

    l = []
    plist = []
    def saiki(i,sum1,sum2):
        if i == N:
            l.append([sum1,sum2])
            return

        saiki(i+1,sum1+t[i],sum2)
        saiki(i+1,sum1,sum2+t[i])

    saiki(0,0,0)

    p = 10**4; ans = 0
    for i in range(len(l)):
        if abs(l[i][0]-l[i][1]) < p:
            p = abs(l[i][0]-l[i][1])
            ans = max(l[i][0],l[i][1])


    print(ans)

def EducationDPcontest_D():
    N, W = list(map(int,input().split()))

    w = []; v = []; weight=[]
    for i in range(N):
        INP = list(map(int,input().split()))
        w.append(INP[0])
        v.append(INP[1])

    def saiki(i,weight_sum,value_sum):
        #print(i,weight_sum,value_sum)
        if weight_sum <= W:
            print("ans",i,weight_sum,value_sum)
        else:
            return
        if i == N:
            return
        else:
            for j in range(i,N):
                saiki(i+1, weight_sum+w[j],value_sum+v[j])

    saiki(0,0,0)

def Msol_B():
    #a,b,c = list(map(int,input().split()))
    #K = int(input())

    a,b,c=[7,0,5]
    K = 3

    if a==0 or b==0 or c==0:
        print("No")
        exit()

    import math

    if a > b:
        b_a = abs(math.log2(b/a))+1
        #まずは切りさげ
        b *= math.pow(2,math.floor(b_a))
        if b > c:
            c_b = abs(math.log2(c/b))+1
            if math.floor(b_a)+math.floor(c_b) <= K:
                print("Yes")
            else:
                print("No")
        else:
            print("Yes")
    else:
        print("Yes")

def Msol_B_():
    import numpy as np
    #a,b,c = list(map(int,input().split()))
    #K = int(input())

    a,b,c=np.array([7,2,5],dtype=np.float64)
    K = 3

    for i in range(7):
        if K==1:
            print('No')
            return
        if a > b:
            temp = 2 * b
            b = temp
            K -= 1
        else:
            break

    for i in range(7):
        if  K ==1:
            print('No')
            return
        if b > c:
            temp = 2 * c
            c = temp
            K -= 1
        else:
            print()
            break

def Msol_C():
    n,k = list(map(int,input().split()))
    a = np.array(list(map(int,input().split())),dtype=np.float64)

    for i in range(n-k):
        if np.prod(a[i:i+k]) > np.prod(a[i+1:i+1+k]):
            print('Yes')
        else:
            print("No")


def abc177_d():
    n,m = list(map(int,input().split()))

    alist = [[] for i in range(m)]
    blist = [[] for i in range(m)]
    for i in range(m):
      a,b =list(map(int,input().split()))
      alist[i] = a
      blist[i] = b

    print(alist)
    print(blist)
    #知人をリストに入れる
    l = [[] for i in range(n+1)] #最初の要素は捨て
    for i in range(m):
      l[alist[i]].append(blist[i])
      l[blist[i]].append(alist[i])


    print(l)

def nani():
    import numpy as np
    from sklearn import preprocessing

    #インスタンス作成
    train = [1,2,3,4,5,5,6,7]
    scaler = preprocessing.MinMaxScaler().fit(train)

    #次のようなtempを入れてみる
    temp = [1,2,3,4,5,5,6,7]
    temp = scaler.transform(temp)

def abc179b():
    n = int(input())
    d1list = []
    d2list = []
    cnt = 0
    for i in range(n):
        d1,d2  = list(map(int,input().split()))
        d1list.append(d1)
        d2list.append(d2)

        #ぞろめ
        if d1 == d2:
            cnt += 1
        else:
            cnt = 0

        if cnt >2:
            print("Yes")
            return

    print("No")




















abc179b()

Submission status: Accepted

Solution code:
if __name__=="__main__":
    N = int(input())
    same = 0
    for i in range(N):
        D1, D2 = (int(x) for x in input().split())
        if D1==D2:
            same += 1
        else:
            if same>=3:
                continue
            else:
                same = 0
    if same>=3:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
n = int(input())
ct, f = 0, 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        ct += 1
    else: ct = 0

    if ct == 3 and f == 0:
        f = 1

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

Submission status: Accepted

Solution code:
import sys

n = int(input())

d1d2 = [map(int, input().split()) for _ in range(n)]
d1, d2 = [list(i) for i in zip(*d1d2)]

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

print("No")

Submission status: Accepted

Solution code:
n = int(input())
num_list = []
checkFlg = False
cnt = 0
for i in range(n):
    d1, d2 = input().split()
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print('Yes')
        checkFlg = True
        break
if not checkFlg:
    print('No')

Submission status: Accepted

Solution code:
n=int(input())
zoro=0
L=False
for i in range(n):
  p,q=map(int,input().split())
  if p==q:
    zoro+=1
    if zoro==3:
      L=True
  else:
    zoro=0
if L:
  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

else:
  print('No')

Submission status: Accepted

Solution code:
N=int(input())
DD=[]
for i in range(N):
    DD.append(list(map(int,input().split())))
for i in range(N-2):
    if DD[i][0]==DD[i][1]:
        if DD[i+1][0]==DD[i+1][1]:
            if DD[i+2][0]==DD[i+2][1]:
                print("Yes")
                break
            elif i+2==N-1:
                print("No")
                break
        elif i+1==N-2:
            print("No")
            break
    elif i==N-3:
        print("No")
        break

Submission status: Accepted

Solution code:
N=int(input())
cnt=0
list1=[]
for i in range(N):
  a=input().split()
  if a[0]==a[1]:
    list1.append(i)
moji=''.join(map(str, list1))
for j in range(N):
  a=str(j)+str(j+1)+str(j+2)
  if a in moji:
    cnt=1
    break
print("Yes"*cnt+"No"*(1-cnt))

Submission status: Accepted

Solution code:
n=int(input())
S=[]
for i in range(n) :
    s=list(map(int,input().split()))
    S.append(s)

count=0
for i in range(n) :
    if S[i][0]==S[i][1] :
        count+=1
    if count==3 :
        print("Yes")
        exit()
    if S[i][0]!=S[i][1] :
        count=0

print("No")

Submission status: Accepted

Solution code:
def ProgramB():
    
    num = int(input())
    
    count = 0
    max_count = 0

    for i in range(num):
        data = list(map(int,input().split()))

        if num == 0:

            if data[0] == data[1]:
                count = count + 1
                
                if count > max_count:
                    max_count = count
    
            else:
                count = 0

        else:
            if data[0] == data[1]:
                count = count + 1
                
                if count > max_count:
                    max_count = count
    
            else:
                count = 0
            
            
    if max_count >= 3:        
        print('Yes')
        
    else:
        print('No')
        
        
if __name__ == '__main__':
    ProgramB()

Submission status: Accepted

Solution code:
n=int(input())
count = 0
last = 0
for a in range(n):
    z = list(input().split())
    if int(z[0]) == int(z[1]):
        count+=1
        if count >= 3:
            last = 1
    if int(z[0]) != int(z[1]):
        if count > 0:
            count = 0
        else:
            continue
if last == 1:
    print("Yes")
if last == 0:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
flag = [-1]*3
ans = 0
for i in range(n):
    a,b = map(int,input().split())
    flag[0] = flag[1]
    flag[1] = flag[2]
    if a == b:
        flag[2] = 1
    else:
        flag[2] = 0
    if flag[0] == 1:
        if flag[1] == 1:
            if flag[2] == 1:
                ans = 1

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

Submission status: Accepted

Solution code:
doubletCount = 0
cases = int(input())
for roll in range(cases):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        doubletCount += 1
    else:
        doubletCount = 0
                
    if doubletCount >= 3:
        print("Yes")
        break
            
    if roll == cases - 1:
        print("No")

Submission status: Accepted

Solution code:
N = int(input())
D = []
is_Zorome = []
for _ in range(N):
  inputs = input().split(' ')
  D.append(inputs)
  if inputs[0] == inputs[1]:
    is_Zorome.append(True)
  else:
    is_Zorome.append(False)

answer = 'No'

for i in range(N-2):
  if is_Zorome[i] and is_Zorome[i+1] and is_Zorome[i+2]:
    answer = 'Yes'

print(answer)

Submission status: Accepted

Solution code:

def input_int():
    return(int(input()))

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

def input_int_map():
    return(map(int,input().split()))

def run():
    q_num = input_int()

    count_num = 0

    for _ in range(q_num):

        a, b = input_int_map()

        if a == b:
            count_num += 1

            if count_num == 3:
                print('Yes')
                return
        else:
            count_num = 0
    print('No')

run()

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
ls = []
N = int(input())
for l in sys.stdin:
    ls.append(l.split())

c = 0
p = 0
ans = 'No'
while len(ls) > c:
    if ls[c][0] != ls[c][1]:
        c += 1
        p = 0
        continue
    else:
        c += 1
        p += 1
        if p == 3:
            ans = 'Yes'
            break

print(ans)

Submission status: Accepted

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

count = 0
flag =0
for i in range(N):
    if D[i][0] == D[i][1]:
        count += 1
    else :
        count = 0
    if count >2 :
        flag=1;

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

Submission status: Accepted

Solution code:
n = int(input())
d = [list(map(int,input().split())) for i in range(n)]
cnt=[]
ans=0
for a in range(n):
  if d[a][0]==d[a][1]:
    cnt.append(1)
    if a>1:
      if cnt[a-2]==cnt[a-1]==cnt[a]:
        ans+=1
  else:
    cnt.append(0)

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

Submission status: Accepted

Solution code:
N = int(input())
D = [list(input()) for _ in range(N)]

cnt = 0

for j in range(N):
    if D[j][0] == D[j][2]:
        cnt +=1 
    elif cnt < 3 and D[j][0] != D[j][2]:
        cnt = 0

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

Submission status: Accepted

Solution code:
n = int(input())
s = [list(map(int, input().split())) for i in range(n)]
cnt = 0
ans = 0
for i in range(n):
  if len(set(s[i])) == 1:
    cnt += 1
  else:
    cnt = 0
  if cnt == 3:
    ans = 1

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    list_D = [input() for i in range(N)]

    answer = "No"
    counter = 0
    for D in list_D:
        D1, D2 = D.split()

        if D1 == D2:
            counter = counter + 1

            if counter == 3:
                answer = "Yes"
                break

        else:
            counter = 0
    
    print(answer)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N=int(input())
arr=[[-1 for j in range(2)] for i in range(N)]
for i in range(N):
	arr[i][0],arr[i][1]=map(int,input().split())
cnt=0
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]:
		cnt+=1
if cnt>0:
	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
for i in range(0,N-2):
    if x[i]==y[i]:
        if x[i+1]==y[i+1]:
            if x[i+2]==y[i+2]:
                count = count+1
            else:
                pass
        else:
            pass
    else:
        pass

if count>0:
    print("Yes")
else:
    print("No")