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:
# This code is generated by [Atcoder_base64](https://github.com/kyomukyomupurin/AtCoder_base64)
import base64
import subprocess
import zlib


exe_bin = "c$~#qeQaCR6~DIQ#Ay@9ZBv@IKs}bC7RYN%K1fz&#EzXlgA+<Vy3)11IJVO~aO~*$8It}1VWFs|O&6vK@y9lG+Wy!kZK6^&P2HrWO9x|OTA9Swt=rTgJ{+K;6{G4l8t>fq?tOmm`n|z4q}?b!@BH35=bn4+_jyl7V*O5s1F_;lUqpmktkw8liqCG=MF8tUweWijx*1giUuBTv>2-&hdh~iUy)LK5^Ymt9rVayjBl}XUGgE~8x*qX$s$N5<>is5qlGf{UoAsPj?<mzfO63_vRF6^CzAE}ZLUEpkk(pLey8A69NuKww)_9)U={*Q~)#%d~AEiUIKD)RqP=6U^{jeh~jdix~NGDs;QYJs$GTqhL(%CNLvclb}Pd+NUYj9MRC;iPrMcy}3jJ!WJaPhMDN4JLZ?=%j@!lw)3U8nv^Wb0A6-@u~N0h-iJ)c8VOU+(!DX0oC@1^;U;@SR}rHVb^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@wf||VAEG?F*D%WN=S2S|3;h$w_>HcdpJ0^T<5}VRzrg92KLluGij((o^y{2HyH7F7$BQ$MzRBscb0MR@;O>_`Gpl~@GwQSRAfwzhqN4rZN9Os<&bN&6*EC-L6sK?Zz1U9w=bS#f7cwex1D=oPD@gn9!SXxh@5dU?$BU2u>+s)T&}a9G*?Q~xc>TX2E%thTN&h}i0ot%?PLKKZ0@B*g=ckS~X#Dgi)c-E0ub-!V=6ZO2R<2Nt>Feios@Thozg|xNBU(S7kYW1UIovAGXq6}JrTQ0W;K)AHf-2{Kt-*I=X`&Nf;$HIW=NcRRr)a`*g~NIMe*+LGoE`"

open("./kyomu", 'wb').write(zlib.decompress(base64.b85decode(exe_bin)))
subprocess.run(["chmod +x ./kyomu"], shell=True)
subprocess.run(["./kyomu"], shell=True)

Submission status: Accepted

Solution code:
import sys

n=int(input())
d=[]
cnt=0

for i in range(n):
  D=[int(x) for x in input().split()]
  d.append(D)

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

print("No")

Submission status: Accepted

Solution code:
n=int(input())
l=[]
m=[]
for i in range(0,n):
  a,b=map(int,input().split())
  l.append(a)
  m.append(b)
c=0
i=0
while i<=n-3:
  if l[i]==m[i] and l[i+1]==m[i+1] and l[i+2]==m[i+2]:
      c=3
  i=i+1
if c==3:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
tmp = 0
for _ in range(N):
  a, b = map(int, input().split())
  if a == b:
    tmp += 1
  else:
    tmp = 0
  ans = max(ans, tmp)

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

Submission status: Accepted

Solution code:
N = int(input())
number = [0]*N
for i in range(N):
    a,b = map(int,input().split())
    if a==b:
        number[i]=1

for i in range(N-2):
    if number[i]==1 and number[i+1]==1 and number[i+2]==1:
        print("Yes")
        exit(0)

print("No")

Submission status: Accepted

Solution code:
n=int(input())
l = [list(map(int,input().split())) for i in range(n)]
ans='No'
    
for i in range(n-2):

    if l[i][0]==l[i][1] and l[i+1][0]==l[i+1][1] and l[i+2][0]==l[i+2][1]:
        ans='Yes'
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=input()
n=int(N)
x=0
for s in range(n):
  ds1,ds2=input().split()
  if ds1==ds2:
    x+=1
  else:
    x=0
  if x==3:
    print("Yes")
    break
else:
  print("No")

Submission status: Accepted

Solution code:
c=0
for i in range(int(input())):
  d1,d2=map(int,input().split())
  if d1==d2:
    c+=1
    if c==3:
      break
  else:
    c=0

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

Submission status: Accepted

Solution code:
a = int(input())
l = []
c,f =0, 0
for i in range(a):
    ta,tb = map(int,input().split())
    if ta==tb : c+=1
    else: c = 0
    if c>=3 : f = 1
print('YNeos'[f==0::2])

Submission status: Accepted

Solution code:
import sys

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

print("No")

Submission status: Accepted

Solution code:
a = int(input())
l = []
c,f =0, 0
for i in range(a):
    ta,tb = map(int,input().split())
    if ta==tb : c+=1
    else: c = 0
    if c>=3 : f = 1
if f:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

p=0
for i in range(n):
    x,y=map(int,input().split())
    if x==y:
        p+=1
        if p==3:
            print('Yes')
            exit()
    else:
        p=0
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
readline = sys.stdin.buffer.readline
read = sys.stdin.readline  # 文字列読み込む時はこっち
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def a_int(): return int(readline())


def ints(): return list(map(int, readline().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, readline().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, readline().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter, xor, add
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from functools import reduce
from math import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a // g * b


N = a_int()
D1, D2 = read_col(N)

cnt = 0
for d1, d2 in zip(D1, D2):
    if d1 == d2:
        cnt += 1
    else:
        cnt = 0
    if cnt >= 3:
        exit('Yes')
print('No')

Submission status: Accepted

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

ans = "No"

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]:
                ans = "Yes"
                break
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import collections as cl


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


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


def main():
    N = II()
    num = 0
    for i in range(N):
        a, b = MI()
        if a == b:
            num += 1
            if num == 3:
                print("Yes")
                return
        else:
            num = 0

    print("No")


main()

Submission status: Accepted

Solution code:
c=0
for _ in range(int(input())):
  d,_,e=input()
  if d==e: c+=1
  else: c=0
  if c>2: exit(print('Yes'))
print('No')

Submission status: Accepted

Solution code:
n = int(input())
total = 0

for i in range(n):
  a,b = map(int, input().split())
  if a == b:
    total += 1
    if total == 3:
      break
  else:
    total = 0
if total == 3:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
s = 0
b = False
for _ in range(n):
    w = input().split()
    if w[0] == w[1]:
        s += 1
        if s == 3:
            b = True
            break
    else:
        s = 0
print('Yes' if b else 'No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

def main():
    ans = 'No'
    N = int(input())
    c = 0
    for _ in range(N):
        d1, d2 = map(int, input().split())
        if d1 == d2:
            c += 1
            if c >= 3:
                ans = 'Yes'
                break
        else:
            c = 0

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = int(input())
flag = 0
state = 0
dic = {}
for i in range(N):
    a, b = map(int, input().split())
    if a == b:
        state += 1
    else:
        state = 0
    if state >= 3:
        flag = 1

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

Submission status: Accepted

Solution code:
N = int(input())
point = 0
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        point += 1
    else:
        point = 0
    if point == 3:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

M = 0
ans = 'No'

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

print(ans)

Submission status: Accepted

Solution code:
def II(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
N=II()
List=[]
for i in range(N):
  tmp=LI()
  List.append(tmp)
cnt=0
Max=0
for i in range(N):
  if List[i][0]==List[i][1]:
    cnt+=1
  else:
    cnt=0
  Max=max(cnt,Max)
if Max>=3:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
n = int(input())

t = 0
for _ in range(n):
  d1,d2 = map(int, input().split())
  if d1 != d2: t = 0
  else: t += 1
    
  if t == 3:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    D = [list(map(int, rl().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')
            return
    print('No')


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n = int(input())
    d1_0, d2_0 = -1, -2
    d1_1, d2_1 = -1, -2
    d1_2, d2_2 = -1, -2
    for i in range(n):
        d1_2, d2_2 = d1_1, d2_1
        d1_1, d2_1 = d1_0, d2_0
        d1_0, d2_0 = map(int,input().split())
        if d1_0 == d2_0 and d1_1 == d2_1 and d1_2 == d2_2:
            print("Yes")
            sys.exit()
    print("No")

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
N=int(input())
D=[]
for i in range(N):
    D.append(list(map(int,input().split())))
def total(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')
            return
    print('No')
    return
total(N)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def main():
	n=int(input()) 
	idx=[] 
	c=0 
	for i in range(n):
		x,y=map(int,input().split()) 
		if x==y:
			idx.append(c) 
		c+=1  
	if len(idx)<3:
		print('No') 
	else:
		flag=False 
		#print(idx)
		for i in range(len(idx)-2): 
			if idx[i]-idx[i+1]==-1 and idx[i+1]-idx[i+2]==-1:
				flag=True  
				break 
		dd={False:'No',True:'Yes'}
		print(dd[flag])
 
try:
	sys.stdin = open('INP01.txt', 'r')  

	# Printing the Output to output.txt file 
	sys.stdout = open('out.txt', 'w')   
	main() 
except:
	main()

Submission status: Accepted

Solution code:
N=int(input())
flag=0
count=0
for i in range(N):
    d1,d2=map(int,input().split())
    if(d1==d2):
        count+=1
    else:
        count=0
    if(count==3):
        flag=1
        break
if(flag==1):
    print("Yes")
else:
    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
        if count == 3:
            print("Yes")
            exit()
    else:
        count = 0

print("No")

Submission status: Accepted

Solution code:
N = int(input())

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

cnt = 0
for i, j in d:
    if i == j:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
num_of_rolls = int(input())

rolls = []

for i in range(num_of_rolls):
    result = input().split()
    rolls.append((result[0], result[1]))

combo = 0

for pair in rolls:
    if pair[0] == pair[1]:
        combo += 1
    else:
        combo = 0
    
    if combo == 3:
        print('Yes')
        exit()

print('No')

Submission status: Accepted

Solution code:
ans = "No"
count = 0
n = int(input())
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())
count=0
ans='No'

for i in range(N):
    d,e = map(int,input().split())
    if d==e:
        count += 1
        if count == 3:
            ans='Yes'
    else:
        count = 0

print(ans)

Submission status: Accepted

Solution code:
from sys  import stdin,stdout
 
st=lambda:list(stdin.readline().strip())
li=lambda:list(map(int,stdin.readline().split()))
mp=lambda:map(int,stdin.readline().split())
inp=lambda:int(stdin.readline())
pr=lambda n: stdout.write(str(n)+"\n")
 
mod=1000000007
INF=float('inf')


 
 
for _ in range(1):
    n=inp()
    f=0
    ans=0
    for i in range(n):
        a,b=mp()
        if a==b:
            ans+=1
        else:
            ans=0
        if ans==3:
            f=1
            break
    if f:
        pr('Yes')
    else:
        pr('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
c, d = [], []
for i in range(n):
    a, b = [int(i) for i in input().split()]
    c.append(a)
    d.append(b)

count = 0

for i in range(0, n):
    if c[i] == d[i]:
        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())
counter = 0
for i in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        counter += 1
    else:
        counter = 0
    if counter >= 3:
        print("Yes")
        break
else:
    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
    else:
        cnt = 0
    if cnt >= 3:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
## necessary imports
import sys
input = sys.stdin.readline
from bisect import bisect_left;
from bisect import bisect_right;
from math import ceil, factorial;

def ceil(x):
    if x != int(x):
        x = int(x) + 1;
    return x;
    
# swap_array function
def swaparr(arr, a,b):
    temp = arr[a];
    arr[a] = arr[b];
    arr[b] = temp;

## gcd function
def gcd(a,b):
    if b == 0:
        return a;
    return gcd(b, a % b);

## nCr function efficient using Binomial Cofficient
def nCr(n, k, modulus = 1): 
    if(k > n - k): 
        k = n - k; 
    res = 1;
    for i in range(k): 
        res = res * (n - i);
        res = res / (i + 1);
        res %= modulus; 
    return int(res);

## prime factorization
def primefs(n):
    ## if n == 1    ## calculating primes
    primes = {}
    while(n%2 == 0 and n > 0):
        primes[2] = primes.get(2, 0) + 1
        n = n//2
    for i in range(3, int(n**0.5)+2, 2):
        while(n%i == 0 and n > 0):
            primes[i] = primes.get(i, 0) + 1
            n = n//i
    if n > 2:
        primes[n] = primes.get(n, 0) + 1
    ## prime factoriazation of n is stored in dictionary
    ## primes and can be accesed. O(sqrt n)
    return primes

## MODULAR EXPONENTIATION FUNCTION
def power(x, y, p): 
    res = 1
    x = x % p  
    if (x == 0) : 
        return 0
    while (y > 0) : 
        if ((y & 1) == 1) : 
            res = (res * x) % p 
        y = y >> 1      
        x = (x * x) % p 
    return res 

## DISJOINT SET UNINON FUNCTIONS
def swap(a,b):
    temp = a
    a = b
    b = temp
    return a,b;

# find function with path compression included (recursive)
# def find(x, link):
#     if link[x] == x:
#         return x
#     link[x] = find(link[x], link);
#     return link[x];

# find function with path compression (ITERATIVE)
def find(x, link):
    p = x;
    while( p != link[p]):
        p = link[p];
    
    while( x != p):
        nex = link[x];
        link[x] = p;
        x = nex;
    return p;


# the union function which makes union(x,y)
# of two nodes x and y
def union(x, y, link, size):
    x = find(x, link)
    y = find(y, link)
    if size[x] < size[y]:
        x,y = swap(x,y)
    if x != y:
        size[x] += size[y]
        link[y] = x

## returns an array of boolean if primes or not USING SIEVE OF ERATOSTHANES
def sieve(n): 
    prime = [True for i in range(n+1)] 
    p = 2
    while (p * p <= n): 
        if (prime[p] == True): 
            for i in range(p * p, n+1, p):
                prime[i] = False
        p += 1
    return prime

#### PRIME FACTORIZATION IN O(log n) using Sieve ####
MAXN = int(1e5 + 5)
def spf_sieve():
    spf[1] = 1;
    for i in range(2, MAXN):
        spf[i] = i;
    for i in range(4, MAXN, 2):
        spf[i] = 2;
    for i in range(3, ceil(MAXN ** 0.5), 2):
        if spf[i] == i:
            for j in range(i*i, MAXN, i):
                if spf[j] == j:
                    spf[j] = i;
    ## function for storing smallest prime factors (spf) in the array

################## un-comment below 2 lines when using factorization #################
# spf = [0 for i in range(MAXN)]
# spf_sieve();
def factoriazation(x):
    ret = {};
    while x != 1:
        ret[spf[x]] = ret.get(spf[x], 0) + 1;
        x = x//spf[x]
    return ret;
    ## this function is useful for multiple queries only, o/w use
    ## primefs function above. complexity O(log n)

## taking integer array input
def int_array():
    return list(map(int, input().strip().split()));

def float_array():
    return list(map(float, input().strip().split()));

## taking string array input
def str_array():
    return input().strip().split();

#defining a couple constants
MOD = int(1e9)+7;
CMOD = 998244353;
INF = float('inf'); NINF = -float('inf');

################### ---------------- TEMPLATE ENDS HERE ---------------- ###################

# n = int(input()); a = sorted(int_array());
# this = [None] * n;

# for i in range(0, n, 2):
#     this[i] = a.pop();

# a = a[::-1];

# for i in range(1, n, 2):
#     this[i] = a.pop();
# ans = 0;
# for i in range(1, n - 1):
#     if this[i] < this[i - 1] and this[i] < this[i + 1]:
#         ans += 1;

# print(ans); print(*this);

n = int(input()); ans = 0; x = 0;
for i in range(n):
    a, b = int_array();
    if a == b:
        x += 1;
    else:
        x = 0;
    ans = max(x, ans);

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
c = 0
isthere = 0
for i in range(n):
    nums = [int(prefix_sum) for prefix_sum in input().split()]
    if nums[0] == nums[1]:
        c = c + 1
    else:
        c = 0

    if c >= 3:
        isthere = 1

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

Submission status: Accepted

Solution code:
N = int(input())
S = []
judge = 0
for i in range(N):
    S += [input().split()]
for i in range(N):
    if i <= N-3:
        if S[i][0] == S[i][1]:
            if S[i+1][0] == S[i+1][1]:
                if S[i+2][0] == S[i+2][1]:
                    print("Yes")
                    judge = 1
                    break
if judge == 0:
    print("No")

Submission status: Accepted

Solution code:
def main():
    import sys
    ikimasu = sys.stdin.buffer.readline
    ini = lambda: int(ins())
    ina = lambda: list(map(int, ikimasu().split()))
    ins = lambda: ikimasu().strip()
    
    n= ini()
    tmp = 0
    for _ in range(n):
        l,r = ina()
        if(l==r):
            tmp+=1
            if(tmp==3):
                print("Yes")
                return
        else:
            tmp =0
    print("No")
        


        


    




















if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

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

now = D[0]
zorome = 0
if now[0] == now[1]:
    zorome += 1
else:
    zorome = 0
for i in range(1, N):
    now = D[i]
    if now[0] == now[1]:
        zorome += 1
        if zorome == 3:
            print('Yes')
            sys.exit()
    else:
        zorome = 0
print('No')

Submission status: Accepted

Solution code:
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

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

c = 0
for i, j in d:
    if i==j:
        c += 1
        if c == 3:
            print('Yes')
            import sys
            sys.exit()
    else:
        c = 0
print('No')

Submission status: Accepted

Solution code:
N = int(input())

t = 0
max_run_length = 0
for _ in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        t += 1
    else:
        t = 0
    max_run_length = max(max_run_length, t)

if max_run_length >= 3:
    print('Yes')
else:
    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
            break
    else:
        cnt = 0

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

Submission status: Accepted

Solution code:
roop_num = int(input())

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

z_counter = 0
flg = False

for i in range(roop_num):
  if(x[i] == y[i]):
    z_counter = z_counter +1
  else:
    z_counter = 0
  if(z_counter == 3):
    flg = True
    break

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def Next(): return input()
def NextInt(): return int(Next())
def NextInts(): return map(int,input().split())
def Nexts(): return map(str,input().split())
def NextIntList(): return list(map(int,input().split()))
def RowInts(n): return [input() for i in range(n)]

n = NextInt()
da = [NextIntList() for i in range(n)]
cnt, ans = 0, 0
for i in range(n):
    if(da[i][0] == da[i][1]):
        cnt += 1
    else:
        cnt = 0
    ans = max(ans, cnt)
if ans >= 3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ds = [[int(s) for s in input().split()] for _ in range(n)]

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

Submission status: Accepted

Solution code:
amt = int(input())
same = 0

while amt > 0:
    item = list(map(int, input().split()))
    if item[0] == item[1]:
        same += 1
        if same == 3:
            print("Yes")
            amt = 0
    else:
        same = 0
    amt -= 1

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

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:
N = int(input())
flag = 0
ans = "No"
for i in range(N):
  A,B = input().split()
  if A == B:    
    flag += 1
  else:
    flag = 0
  if flag == 3:
    ans = "Yes"
    break
    
print(ans)