peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
AB = []
import collections
d_ba = collections.defaultdict(int)
for i in range(n):
    a, b = map(int, input().split())
    d_ba[b] += a

time = 0
for b in sorted(d_ba):
    if time + d_ba[b] <= b:
        time += d_ba[b]
    else:
        print('No')
        exit()
print('Yes')
# Judge status: Accepted
mod=10**9+7

N=int(input())
A=list(map(int,input().split()))
B=[0]
for x in A:
  B.append(B[-1]+x)

ans=0
for i in range(N):
  s=(B[N]-B[i+1])%mod
  ans+=A[i]*s
  ans%=mod

print(ans)
# Judge status: Wrong Answer
import math
a = input().split()
c = float(a[0])*float(a[1])
d = c // 1
print(d)
# Judge status: Accepted
A,B,C=map(int,input().split())
cnt=0
while True:
    if A % 2 == B % 2 == C % 2 == 1:
        break
    elif A==B==C:
        cnt-=1
        break
    elif A%2==B%2==C%2==0:
        hA=A//2
        hB=B//2
        hC=C//2
        A=hB+hC
        B=hA+hC
        C=hA+hB
        cnt+=1
    else:
        break

print(cnt)
# Judge status: Wrong Answer
A,B,C=map(int,input().split())
print(C-(A-B))
# Judge status: Wrong Answer
def main():
    n = int(input())
    X = list(map(int, input().split()))

    X_sorted = list(X)
    X_sorted.sort()
    middle = X_sorted[(n+1)//2]
    middle_l = X_sorted[(n+1)//2-1]


    for i in range(n):
        if middle_l==middle:
            print(middle)
        else:
            if X[i]==middle:
                print(middle_l)
            else:
                print(middle)


if __name__ == '__main__':
    main()
# Judge status: Accepted
N, M = map(int, input().split())
ans = int((M+2*N)/4)
if ans < N:
    print(M//2)
else:
    print(ans)
# Judge status: Accepted
K = int(input())
if K%5==0 or K%2==0:
    print(-1)
else:
    cnt=1
    ms = 7 % K
    while ms != 0:
        cnt+=1
        ms = (ms*10+7)%K

    print(cnt)
# Judge status: Wrong Answer
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math

s = input()
l = set(s)
if len(s) == l:
    print("yes")
else:
    print("no")
# Judge status: Accepted
h1, m1, h2, m2, k = map(int, input().split())

h = h2 - h1
m = m2 - m1

t = h*60 + m

print(t - k)
# Judge status: Accepted
n = int(input())
a = list()
for i in range(n):
    a.append(int(input()))
import collections
b = collections.Counter(a)
c = list(map(lambda x: x%2, list(b.values())))
print(c.count(1))
# Judge status: Wrong Answer
a,b,c,k = map(int,input().split())
ans = 0
if k==0 and k%2==0:
    ans = a-b
else:
    ans = b-a
if len(str(ans))==20:
    print("Unfair")
else:
    print(ans)
# Judge status: Wrong Answer
n=input()
if(n==1):
  print("0")
if(n==0):
  print("1")
# Judge status: Accepted
N, A, B = map(int, input().split())
if (B-A) % 2 == 0:
    print((B-A) // 2)
else:
    n1 = (A + B - 1) // 2
    n2 = N - n1
    print(min(n1, n2))
# Judge status: Accepted
k,x=map(int,input().split());print(" ".join([str(x) for x in list(range(x-k+1,x))+list(range(x,x+k))]))
# Judge status: Accepted
MOD=10**9+7
N,M=map(int,input().split())
dp=[1]*(N+1)
for i in range(M):
  dp[int(input())]=0
for n in range(2,N+1):
  if dp[n]!=0:
    dp[n]=(dp[n-1]+dp[n-2])
print(dp[N]%MOD)
# Judge status: Wrong Answer
N = list(input())
list1 = [int(x) for x in N]
if N.count("0") == len(N) - 1:
  print(10)
else:
  print(sum(list1))
# Judge status: Accepted
S=input()
Q=int(input())
query=[]
for _ in range(Q):
    query.append(input().split())

flag = True
t=""
u=""

for i in query:
    if i[0]=="1":
        u,t=t,u
        flag = not flag
#        S=S[::-1]
    else:
        if i[1]=="1":
            t+=i[2]
        else:
            u+=i[2]
if flag:
    print(t[::-1]+S+u)
else:
    print(t[::-1]+S[::-1]+u)
# Judge status: Accepted
from collections import deque

d = deque(list(input()))
flag = 1
for _ in range(int(input())):
    a = input()
    if a[0] == '1':
        flag *= -1
    elif a[2] == '1' and flag == 1:
        d.appendleft(a[4])
    elif a[2] == '1' and flag == -1:
        d.append(a[4])
    elif a[2] == '2' and flag == 1:
        d.append(a[4])
    else:
        d.appendleft(a[4])
if flag == -1:
    d.reverse()
print(*d, sep='')
# Judge status: Wrong Answer
n=int(input())
arr=list(map(int, input().split()))
m=[]
for i in range(n):
  for j in range(n):
    if (arr[i]==arr[j]):
      pass
    elif ((arr[i]*arr[j]) in m):
        pass
    else:
      m+=[(arr[i]*arr[j])]
      
print(sum(m))
# Judge status: Accepted
N = int(input())

if N % 2 == 0:
	answer = 0.5
else:
	answer = (N + 1) / (2 * N)
    
print(answer)
# Judge status: Wrong Answer
A,B,C = map(int,input().split())
cnt = 0
if A == B:
	if B == C:
		print(-1)
		exit()
while True:
	if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
		break
	a = A / 2
	b = B / 2
	c = C / 2
	A = b + c
	B = a + c
	C = a + b
	cnt+=1
print(cnt)
# Judge status: Accepted
n, m = map(int, input().split())
if n > 1 and m > 1:
    print((n-2)*(m-2))
    exit()

if n == 1 and m == 1:
    print(1)
    exit()

print(max(n, m)-2)
# Judge status: Wrong Answer
doubles = list(map(int, input().split()))
k = int(input())
max_n = doubles.pop(doubles.index(max(doubles))) * (2*k)
print(max_n + sum(doubles))
# Judge status: Accepted
n = int(open(0).read())

print(2 ** (n.bit_length() - 1))
# Judge status: Wrong Answer
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i in range(0,a+1):
    for j in range(0,b+1):
        for k in range(0,c+1):
            total = a * 500 + b * 100 + c * 50
            if total == x:
                count += 1

print(count)
# Judge status: Accepted
a,b=map(int,input().split())
if a==b:
	print("Yes")
else:
	print("No")
# Judge status: Accepted
n,l = map(int,input().split())
s = sorted(input() for i in range(n))
print(*s, sep="")
# Judge status: Accepted
N = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(N):
  if p[i] == i+1:
    p[i] = -1
  else:
    p[i] = 0
    
for j in range(N-1):
  if p[j] == -1:
    ans += 1
    p[j] = 0
    p[j+1] = 0
if p[N-1] == -1:
  ans += 1
print(ans)
# Judge status: Accepted
N, X, T = map(int, input().split())

x = int(N / X)

x = x + 1 if N % X != 0 else x

ans = T * x

print(ans)
# Judge status: Wrong Answer

import itertools

N = int(input())
P = [list(map(int,input().split())) for i in range(N)]
S = 0
print(P)

route = list(itertools.combinations(P, 2))
print(route)

for i in route:

   S += ((i[0][0] - i[1][0])**2 + (i[0][1] - i[1][1])**2)**0.5

print(S*2/N)
# Judge status: Accepted
import sys
A, B, M = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

ans = min(a_list) + min(b_list)
for discount in sys.stdin:
    x, y, c = map(int, discount.split())
    ans = min(ans, a_list[x - 1] + b_list[y - 1] - c)
print(ans)
# Judge status: Wrong Answer
R=input()
print("yes" if R[0]=="7" else "yes" if R[1]=="7" else "yes"if R[2]=="7"else "no")
# Judge status: Wrong Answer
l,r = list(map(int, input().split()))

l1 = l%2019
if r >= l + 2019 - l1:
    r1 = 2018
else:
    r1 = r%2019

ans = float("inf")
for i in range(l1,r1):
    for j in range(i+1, r1+1):
        ans = min(ans, (i*j%2019))

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

h.sort()
s = 0

for i in range(n - k):
    s += h[i]

print(s)
# Judge status: Wrong Answer
n=int(input())
print(800*n - 200*n//15)
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 22 20:55:58 2020

@author: naoki
"""

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

aC2 = [0] * (N+1)

for i in range(2,N+1):
    aC2[i] = int(i*(i-1)/2)

count = [0 for i in range(N+1)]

for i in range(N):
    count[A[i]] += 1

all_count = 0
for i in range(N+1):
    all_count += aC2[count[i]]

for i in range(N):
    print(all_count - aC2[count[A[i]]] + aC2[count[A[i]]-1])
# Judge status: Wrong Answer
sx,sy,tx,ty=map(int, input().split())

#直角にいく＆回り込むで２往復
dx,dy=tx-sx,ty-sy
one="R"*dx+"U"*dy
#print(one)
two=one[::-1].replace("R","L").replace("U","D")
#print(two)

three="D"+"R"*(dx+1)+"U"*(dy+1) +"L"
#print(three)
four=three[::-1]
four=four.replace("D","d").replace("R","r").replace("U","u").replace("L","l")
four=four.replace("d","U").replace("r","L").replace("u","D").replace("l","R")
#print(four)
print(one+two+three+four)
# Judge status: Accepted
N = int(input())

xy_list = list()

P = tuple(map(int, input().split() ))
Q = tuple(map(int, input().split() ))

# print(P)
# print(Q)
A = tuple( i+1 for i in range(N) )
# print(A)

from itertools import permutations
A_perm = list(permutations(A, N) )

# print(A_perm)

p_num = N*2 # ありえない数を入れとく
q_num = N*2 # ありえない数を入れとく


for i, a in enumerate(A_perm):
    if tuple(a) == P:
        p_num = i
    if tuple(a) == Q:
        q_num = i

print(abs(q_num-p_num))
# Judge status: Accepted
S=list(input())
A=[]
for s in S:
	if s=='B':
		if len(A)>0: del A[-1]
	else: A.append(s)
print("".join(A))
# Judge status: Accepted
n=int(input())
s=input()
c=s.count
a=c('R')*c('G')*c('B')
for i in range(n):
  for j in range(i+2,n,2):
    if s[i]!=s[i+j>>1]!=s[j]!=s[i]:
      a-=1
print(a)
# Judge status: Wrong Answer
import numpy as np
H,N=map(int,input().split())
A=[0]*N
B=[0]*N
for i in range(N):
  A[i],B[i]=map(int,input().split())
dp=[0]
h=1
while True:
  dp.append(np.inf)
  for i in range(N):
    if A[i]<=h:
      dp[h]=min(dp[h-A[i]] + B[i], dp[h])
  if h>=H and dp[h]!=np.inf:
    break
  h+=1
print(dp[-1])
# Judge status: Accepted
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
A = list(map(int, input().split()))

for i in range(K, N):
    if A[i - K] < A[i]:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
import math
n,k = map(int,input().split())
a = list(map(int,input().split()))
print(math.ceil((n-1) / (k-1)))
# 1以外のn-1個のうち、1回で最大k-1個まで1にできる
# Judge status: Wrong Answer
r,g,b=map(str,input().split())
c_l = r+g+b
if(int(c_l)%4==0):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N, K = map(int, input().split())

ans = 0.0

for i in range(1, N + 1):
    num = i
    t = 0
    while num < K:
        t += 1
        num *= 2

    ans += 1 / 2 ** t
    
print(ans / N)
# Judge status: Wrong Answer
Ns = [int(s) for s in input()]
total = 0
kuri = 0
for n in Ns[::-1]:
  if kuri + n == 10:
    kuri = 1
  else:
    n += kuri
    if n <= 5:
      total += n
      kuri = 0
    else:
      total += (10 - n)
      kuri = 1
if kuri > 0:
  total += kuri
    
print(total)
# Judge status: Wrong Answer
o =input().split()
(n,m) = map(int,o)
a = []
b = []
count = 0
for i in range(n):
    a.append(1)
print(a)
for j in range(m):
    b.append(2)
print(b)
for k in a:
    for p in b:
        if (k + p) % 2 == 0:
            count = count + 1
            print(count)
# Judge status: Wrong Answer
s = sorted(input())
t = sorted(input())
print("Yes" if s < t else "No")
# Judge status: Wrong Answer
N = int(input())
A_list = list(map(int, input().split()))
A_list = sorted(A_list, reverse = True)
A_list1 = A_list[0:2*N]
A_list2 = A_list[2*N:3*N]
print(sum(A_list1[N:2*N]))
# Judge status: Accepted
n, k = map(int, input().split())
A = list(map(int,input().split()))

if n == k:
  ans = 1
else:
  ans = (n - 2) // (k - 1) + 1

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


x=[0]*N
x[0]=x[1]=B[0]
x[-1]=B[-1]
for i in range(2,N-1):
    x[i]=min(B[i-1],B[i])
print(sum(x))
# Judge status: Accepted
N,K = map(int, input().split())
List = list(map(int, input().split()))

i=1
cnt=0
while i<N:
    i+=(K-1)
    cnt+=1
print(cnt)
# Judge status: Accepted
c = [input() for _ in range(2)]
print("YES" if c[0]==c[1][::-1] else "NO")
# Judge status: Accepted
n,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0

z=a[0]+a[1]-x
if z>0:
  ans+=z
  a[1]-=z
  if a[1]<0:
    a[0]-=abs(a[1])
    a[1]=0

for i in range(n-1):
  z=a[i]+a[i+1]-x
  if z>0:
    ans+=z
    a[i+1]-=z
    if a[i+1]<0:
      a[i]-=abs(a[i+1])
      a[i+1]=0

print(ans)
# Judge status: Wrong Answer
N,K=map(int,input().split())
A=list(map(int,input().split()))

if N<=K:
    print(1)
elif (N-3)%(K-1)==0:
    print(1+(N-3)//(K-1))
else:
    print(1+(N-3)//(K-1)+1)
# Judge status: Accepted
n, k = map(int, input().split())
x = [list(map(int, input().split())) for _ in range(n)]
x.sort()
for i in range(n):
    k -= x[i][1]
    if k <= 0:
        ans = x[i][0]
        break
print(ans)
# Judge status: Accepted
S=str(input())
if S[0]==S[1] and S[1]==S[2]:
  print('Yes')
elif S[1] == S[2] and S[2] == S[3]:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
w,a,b=map(int,input().split())
if min(a,b) + w >= max(a,b):
  print(0)
else:
  ans = max(a,b) - min(a,b) + w
  print(ans)
# Judge status: Accepted
a,b = map(int, input().split())

if(a*b%2 == 0):
  print('Even')
else:
  print('Odd')
# Judge status: Wrong Answer
import math
a,b,x=map(int,input().split())
ans=0

if x==a*a*b/2:
  ans=a/b
elif x<a*a*b/2:
  t=a-2*x/(a*b)
  ans=(a-t)/b
else:
  t=2*x/(a**2)-b
  if (b-t)!=0:
    ans=a/(b-t)
  else:
    ans=0

print(90-math.degrees(math.atan(ans)))
# Judge status: Accepted
from itertools import product


def solve(string):
    l = len(string)
    *s, = map(int, string)
    n = int(string)
    t = [[0] * 10 for _ in range(10)]
    for i in range(n + 1):
        i = str(i)
        t[int(i[0])][int(i[-1])] += 1
    return str(sum(t[i][j] * t[j][i] for i, j in product(range(1, 10), repeat=2)))


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
# Judge status: Wrong Answer
n, k, q = map(int, input().split())
 
ai = [int(input()) for _ in range(q)]

bi = [int(k) for _ in range(n)]

for i in range(q):
    for s in range(n):
        if ai[i] != s:
            bi[s] -= 1
        
for i in range(n):
    if bi[i] > 0:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
X = input()
n = len(X)
cnt = 0
S_check = 0

for i in range(n):
    if X[i] == 'S':
        S_check += 1

    if X[i] == 'T':
        if S_check > 0:
            S_check -= 1
        else:
            cnt += 1

print(cnt + S_check)
# Judge status: Accepted
x = int(input())
ans = x//11*2
if x%11!=0:
    c = x%11
    if c <=6:ans+=1
    else:ans+= 2
print(ans)
# Judge status: Wrong Answer
X=int(input())
print('YNeos'[X>=30::2])
# Judge status: Accepted
a,b,c,d = map(int,input().split())
print(max(a*c,max(a*d,max(b*c,b*d))))
# Judge status: Accepted
N, X = map(int,input().split())
L = list(map(int,input().split()))
cnt = 0
D = [0]
for i in range(N):
  D.append(D[i]+L[i])
l = [d for d in D if d <= X]
print(len(l))
# Judge status: Wrong Answer
a,b,c,d = map(int,input().split())
if b<=c or a>=d:#1
  print(0)
elif b<d and a<b<=c:
  print(b-c)
elif b<d and a>=c:
  print(b-a)
elif b>=d and a>c:
  print(d-c)
elif b>=d and a<c:
  print(d-a)
elif b==d and a==c:
  print(b-a)
# Judge status: Accepted
n, k = input().split()
n, k = int(n), int(k)
balls = input().split()
dic = {}
for x in balls:
	if x not in dic:
		dic[x] = 1
	else:
		dic[x] += 1
change = 0
qnt = list(dic.values())
qnt.sort()
dif = len(qnt) - k
for x in range(0, dif):
	change += qnt[x]
print(change)
# Judge status: Accepted
n, k, q = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(q)]
start = [k - q] * n

for i in range(q):
    start[a[i][0] - 1] += 1

for i in range(n):
    if start[i] > 0:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
#from scipy.misc import comb

N,K = map(int, input().split())
H = []
for i in range(N):
    h = int(input())
    H.append(h)
H.sort()

ans = 10**9
for i in range(N-K+1):
    ans = min(ans,H[i+K-1]-H[i])

print(ans)
# Judge status: Accepted
a,v = map(lambda x: int(x), input().split())
b,w = map(lambda x: int(x), input().split())
t = int(input())
if a == b or abs(a-b) <= (v-w)*t: print("YES")
else: print("NO")
# Judge status: Accepted
N = int(input())
S = []
for _ in range(N):
	t = ''.join(sorted(input()))
	S.append(t)
SS = sorted(S)
ans = 0
t = 0
import math
for i in range(1, N):
	if SS[i - 1] == SS[i]:
		t += 1
		ans += t
	else:
		t = 0
print(ans)
# Judge status: Accepted
import collections

s = raw_input()
stack = collections.deque([])
i = 0
j = 0
while(j < len(s)):
	while(j < len(s) and s[i] == s[j]): j += 1	
	stack.append(j-i)
	i = j
n = len(s)
while(len(stack) > 1) :
	v = stack.pop()
	u = stack.pop()
	if v > u: 
		if stack:
			stack[-1] += v-u
		else:
			stack.append(v-u)
	elif v < u: stack.append( u - v)

print n - (stack[-1] if stack else 0)
# Judge status: Wrong Answer
a,b=(int(x) for x in input().split())
c = ( a + b ) % 3
if (c == '0'):
    print ( 'Possible' )
else:
    print( 'Impossible' )
# Judge status: Wrong Answer
n = int(input())
# x, r = divmod(n, 4+7)
x, r = n//(4+7), n%(4+7)
y = x + r//7
# print(n,x,y,r)
# print(n,4*x+7*y)
ans = "No"
if x>0 or y>0:
    if n == 4*x + 7*y: ans = "Yes"

y = x
x = y + r//4
if x>0 or y>0:
    if n == 4*x + 7*y: ans = "Yes"

print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
Alice = 0
Bob = 0
ans = 0
while len(a) != 0:
    Alice += max(a)
    a.remove(max(a))
    if a:
        Bob += max(a)
        a.remove(max(a))
ans = Alice - Bob
print(ans)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

s = input()
n = len(s)
print("x" * n)
# Judge status: Accepted
n,k = map(int,input().split())
a = list(map(int,input().split()))
print(-(-(n-1)//(k-1)))
# Judge status: Wrong Answer
N,M=map(int,input().split(' '))
B = [1]*N
R = [1]+[0]*(N-1)
for i in range(M):
    x,y=map(lambda x:int(x)-1,input().split(' '))
    if R[x] and B[x]>1:
        B[x] -=1
        B[y] +=1
        R[y] = 1
    elif R[x]:
        B[x]-=1
        B[y]+=1
        R[x]=0
        R[y]=1
ans = 0
for i,j in zip(R,B):
    if j:
        ans += i
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3

N = int(input())
S = set()

for _ in range(N):
    test = input()
    if test not in S:
        S.add(test)

print(len(S))
# Judge status: Accepted
X,Y=map(int,input().split())
total=1
while 1:
  X=X*2
  if X>Y:
    break
  total=total+1
print(str(total))
# Judge status: Wrong Answer
S = list(input())

num = 0
for i in range(len(S)):
    print(i)
    if i % 2 == 0:
        if S[i] == "L":
            num += 1
    else:
        if i == "R":
            num += 1

if num != 0:
    print("No")
else:
    print("Yes")
# Judge status: Wrong Answer
a=int(input())
b=list(input().split())
c=sorted(b)
ans=0
for i in range (a-1):
	if c[i]==c[i+1]:
		print("YES")
		break
	else:
		print("NO")
		break
# Judge status: Accepted
a, b=map(int, input().split())
if a<=b:
  print(a)
else:
  print(a-1)
# Judge status: Wrong Answer
sx,sy,tx,ty=map(int,input().split())

ans=""
y=ty-sy
x=tx-sx

#1往復目
ans +="U"*y
ans +="R"*x
ans +="D"*y
ans +="L"*x
#2往復目
ans +="L"
ans +="U"*y
ans +="R"*x
ans +="D"
ans +="R"
ans +="D"*y
ans +="L"*x
ans +="U"

print(ans)
# Judge status: Accepted
x,k,d= map(int,input().split())
x=abs(x)
if x>d*k:
  print(x-d*k)
else:
  m=x//d
  k=(k-m)%2
  print(abs((x%d)-k*d))
# Judge status: Accepted
def solve():
    K, X = map(int, input().split())
    ans = []
    for i in range(X-K+1,X+K):
        ans.append(i)
    return ans
print(*solve())
# Judge status: Wrong Answer
n = int(input())
A = tuple(map(int, input().split()))
A = sorted(A)
ma = A[0]
for a in A[1:]:
    if a%ma == 0:
        continue
    else:
        ma = a%ma
print(ma)
# Judge status: Accepted
s=input()
if (s[1]==s[0] and s[2]==s[3] and s[0]!=s[2]):
  print('Yes')
elif (s[0]==s[2] and s[1]==s[3] and s[0]!=s[1]):
  print('Yes')
elif (s[0]==s[3] and s[1]==s[2] and s[0]!=s[1]):
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n=int(input())
lt=sorted([(e+1,i) for e,i in enumerate(map(int,input().split()))], key=lambda k:k[1])
print(*list(zip(*lt))[0])
# Judge status: Wrong Answer
a,b,c,d = map(int, input().split())
if b >= c:
    if b >= d:
        if a >= c:
            print(d - a)
        else:
            print(d - c)
    else:
        if a >= c:
            print(b - a)
        else:
            print(b - c)
else:
    print(0)
# Judge status: Accepted
s = input()

for i, c in enumerate(s):
    if c == 'A':
        a_index = i
        break

for i, c in enumerate(s[::-1]):
    if c == 'Z':
        z_index = i
        break
print(len(s[a_index:len(s)-z_index]))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(n-1):
    if a[i]==i+1:
        a[i],a[i+1]=a[i+1],a[i]
        ans+=1
if a[-1]==n:
    ans+=1
print(ans)
# Judge status: Accepted
d,t,s=map(int,input().split())
if d<=t*s:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from bisect import bisect_right as br
from itertools import accumulate as ac
n,m,k=map(int,input().split())
a=list(ac([0]+list(map(int,input().split()))))
b=list(ac([0]+list(map(int,input().split()))))
l=0
for i in range(n+1):
    if k<a[i]:
        break
    else:
        l=max(l,i+br(b,k-a[i])-1)
print(l)
# Judge status: Wrong Answer
d=int(input())
c="Chrismas"
e="Eve"
if d==25:
  print(c)
elif d==24:
  print(c,e)
elif d==23:
  print(c,e,e)
elif d==22:
  print(c,e,e,e)
# Judge status: Wrong Answer
n=input()
if n[0]==9 or n[1]==9:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
s = int(input())

x2 = 10**9
y2 = 1
x3 = 10**9 - s % (10**9) 
y3 = s // (10**9) + 1
print("0 0 " + str(10**9) + " 1 " + str(x3) + " " + str(y3))
# Judge status: Accepted
N = int(input())
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))

S = 0

for i in range(N):
    T = sum(A1[:i+1])+sum(A2[i:])
    if T > S:
        S = T

print(S)
# Judge status: Wrong Answer
n,k=map(int,input().split())
#表で得点2倍、ウラで0
#0かKで終わり
cnt=0
ans=0
j=2
t=k
for i in range(min(n,k)):
    while t//j>=1:
        t=t//j
        cnt+=1 #kがある数j-1で割れる回数
    print(k,"//",j-1,cnt+1)
    j+=1
    t=k
    ans+= 1/3*(0.5)**(cnt+1)
    cnt=0
print(ans)
# Judge status: Accepted
A, B = map(int, input().split())

print(A * B)
# Judge status: Accepted
H1,M1,H2,M2,K=map(int, input().split())
a=60*(H2-H1)
b=M2-M1
c=a+b
print(c-K)
# Judge status: Accepted
n, k = map(int, input().split())
A = list(map(int, input().split()))
B = [(1+i)/2 for i in A]
t = sum(B[:k])
ans = [t]
for i in range(n-k):
    t-=B[i]
    t+=B[i+k]
    ans.append(t)
print(max(ans))
# Judge status: Wrong Answer
N = int(input())
s = input()
t = input()

ushiro = 0

flag = 0
for i in range(N):
    if flag == 0:
        if s[-1] == t[N-i-1]:
            flag = -1
            ushiro += 1
    else:
        flag -= 1
        if s[flag] == t[N-i-1]:
            ushiro += 1
        else:
            break
        
print(2*N - ushiro)
# Judge status: Accepted
from heapq import heapify, heappop, heappush
N,M = map(int,input().split())
A = [[] for _ in range(M+1)]
#HQ = []
for i in range(N):
  a,b = map(int,input().split())
  if a <= M:
    A[a].append(b)
#print(A)
ans = 0
L = []
for day in range(1,M+1):
  for t in A[day]:
    heappush(L,-t)
  #print(L)
  if not L:
    continue
  temp = heappop(L)
  ans += -temp
print(ans)
# Judge status: Accepted
from collections import Counter
a,b=map(int, input().split())
c = Counter(list(map(int, input().split())))
cnt = 0
l = []
m = []

for x,y in c.items():
    l += [y]
    m += [x]

M = len(m)
L = sorted(l)
if M <= b:
    print(0)
if M > b:
    for i in range(M-b):
        cnt += L[i]
    print(cnt)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

ans = 0
flg = False
for i in range(n):
    if flg:
        flg = False
        continue
    if a[i] == i+1:
        if i < n-1 and a[i+1] == i+2:
            ans += 1
            flg = True
        else:
            ans += 1
print(ans)
# Judge status: Accepted
a,b,x=map(int,input().split())
ans="YES" if x<=a+b and x>=a else "NO"
print(ans)
# Judge status: Accepted
s = input()
print("x"*(len(s)))
# Judge status: Accepted
s = input()
p = input()

p = p[:-1]
#print(p)


if s == p:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a=int(input())
if a>=30:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
if a >= c:
  print(a-c,0)
else:
  print(0,max(a+b-c,0))
# Judge status: Accepted
array = list(map(int, (input().split())))

if array.count(5) == 2 and array.count(7) == 1:
    print("YES")
else:
    print("NO")