peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
A, B, C = sorted(map(int, input().split()))
K = int(input())
print(A + B + C * 2 ** K)
# Judge status: Accepted
a,b,c=map(int, input().split())
if b-a==c-b:
  print('YES')
else:
  print('NO')
# Judge status: Accepted
n,k = map(int,input().split())
if n%k == 0:
    print(0)
else:
    print(1)
# Judge status: Accepted
S = input()

if S == "hi" * (len(S) // 2):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import sys
A, B, C = map(int, input().split())

for i in range(100):
  if C == (A*i%B):
    print("YES")
    sys.exit()
print("NO")
# Judge status: Accepted
h1, m1, h2, m2, k = map(int, input().split())

print((h2 * 60 + m2) - (h1 * 60 + m1) - k)
# Judge status: Accepted
#python3
from heapq import heappop
from heapq import heappush
def main():
    n, m = map(int, input().split())
    works = [[] for _ in range(m)]
    for _ in range(n):
        a, b = map(int, input().split())
        if a > m:
            continue
        works[m-a].append(b)
    s = 0
    h = [] 
    for i in reversed(range(m)):
        for b in works[i]:
            heappush(h, -b)
        if len(h) != 0:
            s += -heappop(h)
    print(s)
main()
# Judge status: Wrong Answer
n = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
ans = 0
for i in range(n):
    print(a2[i:n])
    ans =max(sum(a1[0:i+1])+sum(a2[i:n]),ans)
print(ans)
# Judge status: Wrong Answer
from math import factorial

M = 10**9 + 7
n, a, b = map(int, input().split())
r = pow(2, n, M) - 1
c = 1
for i in range(b):
  c = c * (n - i) % M
  if i + 1 == a:
    a = b
    r -= c * pow(factorial(a), M - 2, M)
print(r % M)
# Judge status: Wrong Answer
s=input()
x=s.replace('/','')
y=int(x)
if 20190430 > y:
  print('Heisei')
else:
  print('TBD')
# Judge status: Wrong Answer
A, B, C, K = map(int, input().split(' '))
if K==0:
    print((A-B))
elif K == 1:
    print((B-A))
elif K%2 == 0:
    print((B-A))
else:
    print((A-B))
# Judge status: Accepted
a,b=map(int,input().split())

def evenodd(a,b):
  if a*b%2==1:
    return "Odd"
  else:
    return"Even"
    
print(evenodd(a,b))
# Judge status: Accepted
# B - Frog 2
def main():
    N, K, *H = map(int, open(0).read().split())
    H = [0] + H + [0] * K
    dp = [1 << 30] * (N + K + 1)
    dp[1] = 0
    for i, a in enumerate(H[1:N + 1], 1):
        for j, b in enumerate(H[i + 1:i + K + 1], i + 1):
            dp[j] = min(dp[j], dp[i] + abs(a - b))
    print(dp[N])


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
N = input()
L = len(N)
ans = 0
t = 0
for i in range(L-1,-1,-1):
    n = int(N[i])+t
    if n <= 5:
        ans += n
        t = 0
    else:
        t = 1
        ans += 10-n
if n == 10:
    ans += 1
print(ans)
# Judge status: Accepted
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
  
N = int(input())
L = list(map(int,input().split()))

print(gcd_list(L))
# Judge status: Wrong Answer
import sys

lines = sys.stdin.readline()

X = str(lines)

if X =='ABC':
    print('ARC')
else:
    print('ABC')
# Judge status: Wrong Answer
A,B = map(int,input().split())
if A >= 13:
  print(B)
elif A>=6 and A<=12:
  print(B/2)
else:
  print("0")
# Judge status: Accepted
import re
                                      
S = input()
S = re.sub("eraser", "", S)
S = re.sub("erase", "", S)
S = re.sub("dreamer", "", S)
S = re.sub("dream", "", S)
print("YES" if len(S) == 0 else "NO")
# Judge status: Wrong Answer
a,b = map(int, input().split())
print(a+b if a+b <= 24 else (a+b)%24)
# Judge status: Wrong Answer
n,k = map(int,input().split())
p = list(map(int,input().split()))
ans_temp = 0
ans_list = []
for i in range(n):
    try:
        if ans_temp < sum(p[i:i+k]):
            ans_temp = sum(p[i:i+k])
            ans_list = p[i:i+k]
    except:
        pass
ans = 0
for i in range(k):
    ans += (ans_list[i]*(ans_list[i]+1)/2)/ans_list[i]
    print((ans_list[i]*(ans_list[i]+1)/2))
print(ans)
# Judge status: Accepted
import numpy as np

N, M, X = map(int, input().split())

ca = []
for _ in range(N):
  ca.append( list(map(int, input().split())))
ca.sort(key=lambda x:-x[0])
ca = np.array(ca)
#
ans = 10000000
skill = [0]*(M+1)


def DFS(n,skill):
  global ans
  if skill[0] >= ans:
    return
  if min(skill[1:]) >= X:
    ans = min(ans, skill[0])
    return
  if n >= N:
    return
  s = skill.copy()
  DFS(n+1,s)
  s = s + ca[n]
  DFS(n+1,s)
  return
#

DFS(0,skill)
if ans == 10000000:
  print(-1)
else:
  print(ans)
#
# Judge status: Accepted
n,m = map(int, input().split())
ans = []

for i in range(2,m+1,2):
    ans.append([n-(i//2),(i//2)])
for i in range(1,m+1,2):
    ans.append([n//2-(i-1)//2,n//2+1+(i-1)//2])
for i in range(m):
    print(*ans[i])
# Judge status: Wrong Answer
s = list(input())
n = len(s)

cnt = 0
l = 0

while l < n-1:
    if ( s[l] == '0' ) and ( s[l+1] == '1' ):
        cnt += 2
        s[l:l+1]=[]
        n = len(s)
        l -= 1
        continue
    l += 1

print(cnt)
# Judge status: Wrong Answer
n=int(input())
p=1
for i in range(1,n+1):
  p*i%(1e9+7)
print(p)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
S = sum(map(abs, A))
 
cnt = 0
 
for a in A:
    if a > 0:
        cnt += 1
        
if (len(A)-cnt)%2==0 or 0 in A:
    print(S)
else:
    print(S-2*min(map(abs, A)))
# Judge status: Accepted
w,h,n=map(int,input().split())
a1,a2,a3,a4=0,w,0,h
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        a1=max(a1,x)
    elif a==2:
        a2=min(a2,x)
    elif a==3:
        a3=max(a3,y)
    else:
        a4=min(a4,y)
print(max(a2-a1,0)*max(a4-a3,0))
# Judge status: Wrong Answer
N=int(input())
A = list(map(int, input().split()))
for n in range(N):
    print(A.count(str(n)))
# Judge status: Wrong Answer
s = input()
c = set()
for i in range(len(s)):
  c.add(s[i])
c = list(c)
c.sort()
abc = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
ans = ''
for e in abc:
  if e not in c:
    ans = e
    break
if ans == '':
  print('None')
# Judge status: Wrong Answer
S = input()
T = input()

mappings = {}

for s, t in zip(S, T):
    if mappings.get(t, s) != s:
        print('No')
        break
    mappings[t] = s
else:
    print('Yes')
# Judge status: Accepted
li=list(map(int,input().split()))
if li[0]+li[1]+li[2]>=22:
    print('bust')
else:
    print('win')
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=0
for i in range(n):
    ans+=a[2*i+1]
print(ans)
# Judge status: Accepted
N = int(input())
S = input()

wc = [0]
ec = [0]

for i in range(N):
    if S[i] == "W":
        wc.append(wc[i]+1)
        ec.append(ec[i])
    else:
        wc.append(wc[i])
        ec.append(ec[i]+1)

#print("wc : {}, ec : {}".format(wc, ec))

ans = ec[N]
for i in range(1, N):
    #W -> cnt, E -> sum - cnt
    tmp = wc[i] + ec[N] - ec[i+1]
    ans = min(tmp, ans)

print(ans)
# Judge status: Accepted
def main():
    h1,m1,h2,m2,k = map(int,input().split())
    wake_up_minutes = (h2-h1) * 60 - m1 + m2
    study_start_minutes = max(0,wake_up_minutes - k)
    print(study_start_minutes)

if __name__ == '__main__':
    main()
# Judge status: Accepted
N = int(input())
A = input().split()
A = [int(x) for x in A]
B = input().split()
B = [int(x) for x in B]

c = 0
for i in range(N):
  if A[i] >= B[i]:
    c += B[i]
  else:
    c +=A[i]
    x = A[i+1] - (B[i]-A[i])
    if x >= 0:
      c += B[i]-A[i]
      A[i+1] = x
    else:
      c += A[i+1]
      A[i+1] = 0
print(c)
# Judge status: Wrong Answer
a=int(input())
b=int(input())
list={a,b}
for i in range(1,3):
  if i in list:
    continue
  else:
    print(i)
# Judge status: Wrong Answer
n=int(input())

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

a.sort()
b.sort()


suma=sum(a)
sumb=sum(b)



#sum(a)+2*k=sum(b)+k
#k=(sum(a)-sum(b))

k=suma-sumb
#
#1 1 1 6
#2 2 2 3

cnt=0
for i in range(n):
    if a[i]>b[i]:
        cnt+=b[i]-a[i]
    elif a[i]<b[i]:
        cnt+=((-a[i]+b[i])//2)

if cnt>=k:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n,a,b = list(map(int,input().split()))
ans = 0
if (abs(a-b) % 2) == 0:
    ans = abs(a-b)//2
else:
    ans = min(a-1,n-b) + 1 + (b-a-1)//2

print(ans)
# Judge status: Wrong Answer
import numpy as np
INF = 2**60 # 無限大を表す値
H, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(N)]
W = H + max(A for (A, B) in AB)
dp = np.full((N+1, W+1), INF, dtype = np.int64)
dp[0][0] = 0
for i, (A, B) in enumerate(AB):
    dp[i+1] = np.minimum(dp[i+1], dp[i])
    dp[i+1][A:] = np.minimum(dp[i+1][A:], dp[i+1][:-A] + B)
print(np.min(dp[N][H:W+1]))
# Judge status: Wrong Answer
a, b, t = map(int, input().split())
print((t + 0.5) // a * b)
# Judge status: Accepted
N, K = map(int,input().split())
S = input()

#グループの個数
cnt = 1

for i in range(N-1):
    if S[i] != S[i+1]:
        cnt += 1

print(N - max(1, cnt - 2*K))
# Judge status: Accepted
n = int(input())
res = []
su = 0
for i in range(1, n+1):
    #print(res, i)
    res.append(i)
    if su + i > n:
        break
    su += i
sa = sum(res) - n
if sa == 0:
    print("\n".join(map(str, res)))
else:
    del res[res.index(sa)]
    print("\n".join(map(str, res)))
# Judge status: Accepted
s = sorted(input())
t = sorted(input(), reverse=True)
sSort = ''.join(s)
tSortRev = ''.join(t)
if sSort < tSortRev:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
cnt = [[0 for _ in range(11)] for _ in range(11)]
for i in range(1, n + 1):
    x = i
    while x >= 10:
        x //= 10
    cnt[x][i % 10] += 1
ans = 0
for i in range(1, n + 1):
    x = i
    while x >= 10:
        x //= 10
    ans += cnt[i % 10][x]
print(ans)
# Judge status: Wrong Answer
k, s = map(int, input().split())
count = 0
for i in range(k+1):
    rem = s - i
    for j in range(rem+1):
        y, z = j, rem-j
        if y <= 5 and z <= 5:
            if s == y+z+i:
                count += 1
print(count)
# Judge status: Wrong Answer
S=input()
if S[0]==9 or S[1]==9:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
print("Yes" if a+b > c else "No")
# Judge status: Accepted
N = int(input())
MOD = 10 ** 9 + 7
ans = 1
for i in range(1, N + 1):
    ans *= i
    ans %= MOD
print(ans)
# Judge status: Accepted
w,h,x,y = map(int, input().split())

if w/2==x and h/2==y:
    print(w*h/2,1)
else:
    print(w*h/2,0)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
n = int(input())
a = [int(i) for i in input().split()]

count = [0 for _ in range(n)]
for i in reversed(range(1, n + 1)):
    tmp = 0
    for j in range(i, n, i):
        tmp += a[j-1]
    if a[i-1] % 2 != tmp % 2:
        count[i-1] += 1
m = sum(count)
ans = []
for i in range(n):
    if count[i] == 1:
        ans.append(str(i))

print(m)
print(' '.join(ans))
# Judge status: Accepted
# coding:utf-8
n = int(input())
w = [input() for _ in range(n)]
word_list = set(w)

if len(word_list) != len(w):
    print("No")
    exit()
else:
    for i in range(1, n):
        tail = w[i - 1][-1]
        if tail != w[i][0]:
            print("No")
            exit()
print("Yes")
# Judge status: Wrong Answer
N, K = map(int, input().split())
H = list(map(int,input().split()))
if K == 0:
    print(sum(H))
if K >= N:
    print(0)
else:
    print(sum(H[:-K]))
# Judge status: Accepted
def main():
    s = input()
    ans = ""
    for i in range(len(s)):
        if s[i] == "0":
            ans += "0"
        elif s[i] == "1":
            ans += "1"
        elif s[i] == "B":
            if ans == "":
                pass
            else:
                ans = ans[:-1]
    print(ans)



if __name__ == "__main__":
    main()
# Judge status: Accepted
a = int(input())
s = input()
if (a >= 3200):
  print(s)
else:
  print("red")
# Judge status: Accepted
import math
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

def check_order(k):
    res = 0
    for _ in range(n):
        if len(k) == 1:
            break
        s = k[0]
        c = 0
        for i in k:
            if s >= i:
                 c += 1
        k.pop(0)
        res += math.factorial(len(k)) * (c-1)
    return res

p_order = check_order(p)
q_order = check_order(q)

print(abs(p_order-q_order))
# Judge status: Accepted
a, b , c = input().split()

print(a[0]+b[0]+c[0])
# Judge status: Accepted
import sys
a=sys.stdin.readline()
b=list(a)
A,B,C,D = [int(b[i]) for i in (0,1,2,3)]
if A==B or B==C or C==D:
    print("Bad")
else:
    print("Good")
# Judge status: Accepted
from collections import Counter
N=int(input())
D=list(map(int,input().split()))
mod=998244353
if D[0] != 0:
    print(0)
else:
    ans=1
    del D[0]
    if 0 in D:
        print(0)
    else:
        numbers=Counter(D)
        for n in range(2,max(numbers.keys())+1):
            if numbers[n]==None:
                ans=0
                break
            ans*=numbers[n-1]**numbers[n]
        print(ans%mod)
# Judge status: Accepted
S=input()
start=S.find('A')
last=S.rfind('Z')
print(last-start+1)
# Judge status: Wrong Answer
import sys
S = input()
n = len(S)
for i in range(2, n-1):
    if S[i] == 'C':
        print('AC')
        sys.exit()
print('WA')
# Judge status: Accepted
n,a = map(int,input().split())
m = [tuple(map(int,input().split())) for _ in range(a)]

l,r=m[0][0],m[0][1]

for i in range(1,a):
    l = max(m[i][0],l)
    r = min(m[i][1],r)

print(max(r-l+1,0))
# Judge status: Wrong Answer
N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

ans = False
rule1 = sum(a) <= sum(b)
rule2 = sum([2 * (ai - bi) for ai, bi in zip(a,b) if ai > bi]) <= sum(b) - sum(a)
rule3 = sum([bi - ai for ai, bi in zip(a,b) if bi > ai]) <= sum(b) - sum(a)
if rule1 and rule2 and rule3:
  ans = True

text = "Yes" if ans else "No"
print(text)
# Judge status: Accepted
N, M = map(int, input().split())
A_B = [list(map(int, input().split())) for _ in range(N)]

A_B.sort()
count = 0
money = 0
i = 0
while count != M:
    money += A_B[i][0] * min(M-count, A_B[i][1])
    count += min(M-count, A_B[i][1])
    i += 1
print(money)
# Judge status: Accepted
n, y = map(int, input().split())
ans = ''
for i in range(n + 1):
  for j in range(n + 1 - i):
    k = n - i  - j
    if 10000 * i + 5000 * j + 1000 * k == y:
      ans = f'{i} {j} {k}'
      break
  if ans:
    break
print(ans if ans else '-1 -1 -1')
# Judge status: Accepted
N,M = map(int,input().split())
ans=0
ans+=N
M=M-N*2
if(M<0):
	ans = ans - abs(M//2)
if(M>0):
	ans = ans + M//4
print(ans)
# Judge status: Accepted
q, h, s, d = map(int, input().split())
n = int(input())

l2 = [q*8, h*4, s*2, d]
l1 = [q*4, h*2, s]

ans = (n//2) * min(l2) + (n%2) * min(l1)
print(ans)
# Judge status: Wrong Answer
N,M=map(int,input().split())
L=[0]*M
R=[0]*M
for i in range(M):
  L[i],R[i]=map(int,input().split())
s=0
for j in range(L[0],R[0]+1):
  if all(L[k]<=j<=R[k] for k in range(j,M)):
    s+=1
print(s)
# Judge status: Accepted
N, M = map(int, input().split())

cnt = 0

l = 0
k = M
while cnt < M and k > 0:
    print(l + 1, l + k + 1)
    cnt += 1
    l += 1
    k -= 2

l = M + 1
k = M - 1
while cnt < M:
    print(l + 1, l + k + 1)
    cnt += 1
    l += 1
    k -= 2
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))

sort_A = sorted(A)
med_index = (n-2) // 2

for i in A:
    if i <= sort_A[med_index]:
        print(sort_A[med_index+1])
    else:
        print(sort_A[med_index])
# Judge status: Wrong Answer
a, b = map(int, input().split())
ans = a + b
if ans >= 24:
    print(ans // 24)
else:
    print(ans)
# Judge status: Wrong Answer
import sys
A, B, C = map(int, input().split())
for i in range(1, B):
    if i * A % B == C:
        print('Yes')
        sys.exit()
print('No')
# Judge status: Accepted
a = 0
for i in range(1, int(input())+1):
    a += i
print(a)
# Judge status: Wrong Answer
N,Y = map(int,input().split())
for x in range(N,-1,-1):
    print(x)
    for y in range(N,-1,-1):
        print(y)
        for z in range(N,-1,-1):
            print(z)
            if 10000*x+5000*y+1000*z == Y:
                print(x,y,z)
                break
        else:
            continue
        break
    else:
        continue
    break
# Judge status: Accepted
s = input()
t = input()
flg = 0
for i in range(len(s)):
  if s == t:
    flg = 1
  s = s[1:] + s[0]
if flg == 1:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
n = int(input())
res = [0] * n
for i in range(1, n):
  c, s, f = map(int, input().split())
  res[i-1] += s + c
  for j in range(i-1):
    if res[j] < s:
      res[j] = s + c
    elif res[j] == s:
      res[j] += c
    else:
      if (res[j] - s) % f == 0:
        res[j] += c
      else:
        res[j] += ((res[j] - s) % f) + c
for elem in res:
  print(elem)
# Judge status: Wrong Answer
n, m = map(int, input().split())

student = list()

for x in range(n):
    student.append(list(map(int, input().split())))

checkpoint = list()

for y in range(m):
    checkpoint.append(list(map(int, input().split())))

INF = 2*(10**8) + 1
tmp = INF
ans = 51

for x in range(n):
    for y in range(m-1, -1, -1):
        distance = abs(student[x][0] - checkpoint[y][0]) + \
            abs(student[x][1] - checkpoint[y][1])

        if tmp >= distance:
            tmp = distance
            ans = y
    print(ans+1)
    tmp = INF
# Judge status: Accepted
n = int(input())
li = list(map(int,input().split()))

x = int(sum(li)/len(li))
y = sum(li)/len(li)
if y-x > 0.5:
    x += 1

ans = 0

for i in li:
    ans += (i-x)**2

print(ans)
# Judge status: Wrong Answer
N, A, B = map(int, input().split())
sum = 0

def FindSumOfDigits(x):
    count = 0
    while x>0:
        count += x%10
        x /= 10
    return count
    
    
for n in range(1, N+1):
    count= FindSumOfDigits(n)
    if A <= count <= B:
        sum += n

print(sum)
# Judge status: Accepted
N, P=map(int, input().split())
A=list(map(int, input().split()))
odd=[]
even=[]
for a in A:
  if a%2==0:
    even.append(a)
  else:
    odd.append(a)
amod=len(odd)
amev=len(even)
evonly=2**amev

from math import factorial
if P==0:
  evod=0
  i=0
  while amod>=i:
    evod+=factorial(amod)//(factorial(i)*factorial(amod-i))
    i+=2
  print(evonly*evod)
else:
  evod=0
  i=1
  while amod>=i:
    evod+=factorial(amod)//(factorial(i)*factorial(amod-i))
    i+=2
  print(evonly*evod)
# Judge status: Accepted
n = input()
a = [int(A) for A in input().split()]

max_ele = 0
for i in range(len(a)):
    if a[i] > max_ele:
        max_ele = a[i]

mid = 0
mid_val = max_ele / 2

for j in range(len(a)):
    if abs(mid_val - a[j]) < abs(mid_val - mid):
        mid = a[j]

print(str(max_ele) + " " + str(mid))
# Judge status: Accepted
n = int(input())


def digit_sum(x):
    return sum(int(si) for si in str(x))


ans = 10**5
for a in range(1, n):
    b = n - a
    ans = min(ans, digit_sum(a) + digit_sum(b))

print(ans)
# Judge status: Wrong Answer
N, K = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(2 * K)]

treated = (list(range(1, N+1)))

for i in range(int((K+1)/2)):
  tt = list(set(list(range(1, N+1))) - set(l[2*i+1]))
  print(tt)
  treated = list(set(treated) & set(tt))

print(len(treated))
# Judge status: Accepted
N = int(input())
W = list(map(int, input().split()))
list = [0 for _ in range(N-1)]
for i in range(N-1):
  list[i] = abs(sum(W[:i+1]) - sum(W[i+1:]))
print(min(list))
# Judge status: Wrong Answer
A,B,C,K = map(int,input().split())
a = A * (K + 1)
b = B * (K + 1) 
c = C * (K + 1)
if (abs(a - b) > 10**18):
  print("Unfair")
else:
  print(str(a - b))
# Judge status: Accepted
import heapq

n,m = map(int,input().split())
ab = sorted([list(map(int,input().split())) for _ in range(n)])

work = []
heapq.heapify(work)

idx = 0
res = 0
sz = 0
for i in range(m, -1, -1):
    dayleft = m - i
    while idx < n and ab[idx][0] <= dayleft:
        heapq.heappush(work, -ab[idx][1])
        sz += 1
        idx += 1
    if sz == 0:
        continue
    res -= heapq.heappop(work)
    sz -= 1
print(res)
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
print(a*b*c/max(a,b,c))
# Judge status: Accepted
n = int(input())
a, b, c = [list(map(int, input().split())) for _ in range(3)]
print(sum(b) + sum(c[a[i]-1] for i in range(n-1) if a[i+1] == a[i]+1))
# Judge status: Accepted
def main():
    n = int(input())
    cnt = 0
    for i in range(0, n):
        d_1, d_2 = map(int, input().split())
        if d_1 == d_2:
            cnt += 1
        else :
            if cnt < 3 :
                cnt = 0

    if cnt >= 3:
        print("Yes")
    else :
        print("No")
main()
# Judge status: Accepted
n=int(input())
print((n*800)-((n//15)*200))
# Judge status: Wrong Answer

s = int(input())  #nは入力回数
s_list = [input() for _ in range(s)]
print(s_list)   # 出力を確認

ans = 0

s_list = set(s_list)

print(len(s_list))
# Judge status: Accepted
a=list(input())

n = 0

s = 0

e = 0

w = 0

for i in a:
  if i == 'N':
    n += 1
  elif i == 'S':
    s += 1
  elif i == 'E':
    e += 1
  elif i == 'W':
    w += 1

if n > 0 and s == 0 or n == 0 and s > 0 or e > 0 and w == 0 or e == 0 and w > 0:
  print('No')
else:
  print('Yes')
# Judge status: Accepted
X = list(map(int,input()))
sn = []
for i in range(len(X)):
  sn.append(sum(X[0:i+1]))
ssn = []
for i in range(len(X)):
  if (sn[i] != 0):
    ssn.append(sn[i]-1 + 9*(len(X)-1-i))
ssn.append(sum(X))
print(max(ssn))
# Judge status: Wrong Answer
n = input()

sum = 0
for i in range(len(n)):
    sum += int(n[-1 - i])
    if sum // 9 == 1:
        sum = sum % 9 

if sum == 0:
    print('YES')
else:
    print('No')
# Judge status: Accepted
x, n = list(map(int, input().split()))
p = list(map(int, input().split()))
pN = [i for i in range(102) if i not in p]
pNm = [abs(i - x) for i in pN]
pmin = min(pNm)
print(pN[pNm.index(pmin)])
# Judge status: Accepted
import sys

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


def solve():
    S = input()
    if S == 'ABC':
        print('ARC')
    else:
        print('ABC')


if __name__ == '__main__':
    solve()
# Judge status: Wrong Answer
import copy
from fractions import gcd

N = int(input())
ListA = list(map(int,input().split()))

Answer = 1
if N == 2:
    Answer = gcd(ListA[0],ListA[1])
else:
    for j in range(N):
        Lista = copy.deepcopy(ListA)
        Lista.pop(j)
        GCDa = gcd(Lista[0],Lista[1])
        for i in range(N-1):
            GCDa = gcd(Lista[i],GCDa)
            if GCDa == 1:
                continue
            Answer = max(GCDa,Answer)

print(Answer)
# Judge status: Accepted
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if A != B and V <= W:
    print("NO")
else:
    dist = abs(A - B)
    v = V - W
    t = dist / v
    if t <= T:
        print("YES")
    else:
        print("NO")
# Judge status: Wrong Answer


from math import gcd as g

k = int(input())
ans = 0
for a in range(1, k+1):
    for b in range(k+1):
        for c in range(k+1):
            ans += g(g(a, b), c)


print(ans)
# Judge status: Wrong Answer
n, k = map(int, input().split())
mod = pow(10, 9) + 7
ans = 0
for i in range(k, n+1):
    #小さい方からi個選ぶ
    mini = n*(n-1)//2
    maxa = (2*n-k+1)*n//2
    ans = (ans + (maxa - mini + 1))% mod

print(ans)
# Judge status: Accepted
n=int(input())
p=list(map(int,input().split()))
ans=0

for i in range(n):
    if p[i] != i+1:
        ans+=1
        
if ans<=2:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
import sys
N, Y = map(int, input().split())

Y //= 1000

for y in range(0, (10*N-Y)//5+1):
    for z in range(0, (10*N-Y-5*y)//9+1):
        if 10*N - Y == 5*y + 9*z:
            print(N-y-z, y, z)
            sys.exit()

print(-1, -1, -1)
# Judge status: Accepted
X = input()

n = len(X)

S_cnt = 0
cnt = 0

for i in range(n):
    if X[i]=='S':
        S_cnt += 1
    elif (X[i]=='T') and(S_cnt>0):
        cnt += 1
        S_cnt -= 1
print(n-cnt*2)
# Judge status: Accepted
#!/usr/bin/env python3
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
max_x = max(x)
min_y = min(y)
for i in range(X + 1, Y):
    if i > max_x and i <= min_y:
        print("No War")
        exit()
print("War")