n = int(input())
stones = [int(num) for num in input().split(' ')]
q = int(input())
for i in range(q):
    l1 = [int(x) for x in input().split(' ')]
    summ = 0
    if l1[0] == 1:
        for j in range(l1[1] - 1, l1[2]):
            summ += stones[j]
    else:
        for j in range(l1[1] - 1, l1[2]):
            summ += sorted(stones)[j]
    print(summ)


n = int(input())
l = list(map(int, input().split()))
lSort = sorted(l)

T = int(input())
for test in range(T):
    t, l1, r = map(int, input().split())
    if t == 1:
        s = 0
        for i in range(l1 - 1, r):
            s += l[i]
        print(s)
    else:
        s = 0
        for i in range(l1 - 1, r):
            s += lSort[i]
        print(s)


n = int(input())
l = list(map(int, input().split()))
lSort = sorted(l)

def sm(lst):
    for i in range(1, len(l)):
        lst[i] += lst[i - 1]

sm(l)
sm(lSort)
T = int(input())
for test in range(T):
    t, l1, r = map(int, input().split())
    if t == 1:
        print(l[r - 1] - (l1 > 1)*l[l1 - 2])
    else:
        print(lSort[r - 1] - (l1 > 1)*lSort[l1 - 2])


# It's all about what U BELIEVE
def gint(): return int(input())
def gint_arr(): return list(map(int, input().split()))
def gfloat(): return float(input())
def gfloat_arr(): return list(map(float, input().split()))
def pair_int(): return map(int, input().split())
###############################################################################
INF = (1 << 31)
dx = [-1, 0, 1,  0]
dy = [ 0, 1, 0, -1]
############################ SOLUTION IS COMING ###############################
n = gint()
a = gint_arr()
s = sorted(a)
suma = [a[0]]
sums = [s[0]]
i = 1
while i < n:
    suma.append(suma[-1] + a[i])
    sums.append(sums[-1] + s[i])
    i += 1

m = gint()
while m:
    t, l, r = gint_arr()
    l -= 1
    r -= 1
    if t == 1:
        print(suma[r] - (suma[l - 1] if l else 0))
    else:
        print(sums[r] - (sums[l - 1] if l else 0))
    m -= 1


n = int(input())
a =  list(map(int,input().split()))
h = sorted(a)

for i in range(1,n):
    a[i]+=a[i-1]
    h[i]+=h[i-1]
for i in range(int(input())):
    q,l,r = map(int,input().split())

    if q==1:
        if l-2>=0:
            print(a[r-1]-a[l-2])
        else:
            print(a[r-1])
    else:
        if l-2>=0:
            print(h[r-1]-h[l-2 if l-2>=0 else 0])
        else:
            print(h[r-1])


n = int(input())
a =  list(map(int,input().split()))
h = sorted(a)

for i in range(int(input())):
    q,l,r = map(int,input().split())
    if q==1:
        print(sum(a[l-1:r]))
    else:
        print(sum(h[l-1:r]))


n=int(input())
s=list(map(int ,input().split()))
q=[0]
for i in s:
    q.append(q[-1]+i)
s.sort()

p=[0]
for i in s:
    p.append(p[-1]+i)

for _ in range(int(input())):

    type,l,r=map(int,input().split())
    if type==1 :
        print(q[r]-q[l-1])
    else:
        print(p[r]-p[l-1])


from collections import Counter
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
##########################################################
#for _ in range(int(input())):
#import math
import sys
# from collections import deque
#from collections import Counter
# ls=list(map(int,input().split()))
# for i in range(m):
# for i in range(int(input())):
#n,k= map(int, input().split())
#arr=list(map(int,input().split()))
#n=sys.stdin.readline()
#n=int(n)
#n,k= map(int, input().split())
#arr=list(map(int,input().split()))
#n=int(inaput())
#for _ in range(int(input())):
n = int(input())
arr=list(map(int,input().split()))
ls=sorted(arr)
for i in range(int(input())):
    t,l,r = map(int, input().split())
    print(sum(arr[l-1:r]) if t==1 else sum(ls[l-1:r]))


import sys
ing=sys.stdin.buffer.readline()
iny=int(ing)
arr=list(map(int,input().split()))
ls=sorted(arr)
for i in range(int(input())):
    t,l,r=map(int,input().split())
    if t==1:
        print(sum(arr[l-1:r]))
    else:
        print(sum(ls[l-1:r]))


from collections import Counter
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
##########################################################
#for _ in range(int(input())):
#import math
import sys
# from collections import deque
#from collections import Counter
# ls=list(map(int,input().split()))
# for i in range(m):
# for i in range(int(input())):
#n,k= map(int, input().split())
#arr=list(map(int,input().split()))
#n=sys.stdin.readline()
#n=int(n)
#n,k= map(int, input().split())
#arr=list(map(int,input().split()))
#n=int(inaput())
#for _ in range(int(input())):
#n = int(input())
#arr=list(map(int,input().split()))

n,m= map(int, input().split())
arr=list(map(int,input().split()))
if m==1:
    print(arr[0])
elif m==2:
    print(0)
else:
    ma=0
    val1=abs(arr[0]-arr[1])
    val2=abs(arr[-2]-arr[-1])
    for i in range(1,m-1):
        pre=abs(arr[i-1]-arr[i])+abs(arr[i+1]-arr[i])
        val=abs(arr[i-1]-arr[i+1])
        if val<pre and pre-val>ma:
            ma=max(ma,pre-val)
    #print(ma)
    ans=0
    for i in range(m-1):
        ans+=abs(arr[i+1]-arr[i])
    #print(ans)
    print(ans-max(val1,val2,ma))


from collections import Counter
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
##########################################################
#for _ in range(int(input())):
#import math
import sys
# from collections import deque
#from collections import Counter
# ls=list(map(int,input().split()))
# for i in range(m):
# for i in range(int(input())):
#n,k= map(int, input().split())
#arr=list(map(int,input().split()))
#n=sys.stdin.readline()
#n=int(n)
#n,k= map(int, input().split())
#arr=list(map(int,input().split()))
#n=int(inaput())
#for _ in range(int(input())):
n = int(input())
arr=list(map(int,input().split()))
ls=sorted(arr)
'''a=[0]*n
b=[0]*n
a[0]=arr[0]
b[0]=ls[0]'''
for i in range(1,n):
    arr[i]+=arr[i-1]

for i in range(1,n):
    ls[i]+=ls[i-1]
arr=[0]+arr
ls=[0]+ls
m=int(input())
#print(arr)
#print(ls)
#print(ls)
for i in range(m):
    t,l,r = map(int, input().split())
    print(arr[r]-arr[l-1] if t==1 else ls[r]-ls[l-1])


n=int(input())
arr=list(map(int,input().split()))
ls=sorted(arr)
m=int(input())
for i in range(m):
    t,l,r=map(int,input().split())
    if t==1:
        print(sum(arr[l-1:r]))
    else:
        print(sum(ls[l-1:r]))


z,zz=input,lambda:list(map(int,z().split()))
zzz=lambda:[int(i) for i in stdin.readline().split()]
szz,graph,mod,szzz=lambda:sorted(zz()),{},10**9+7,lambda:sorted(zzz())
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac
def lcd(xnum1,xnum2):return (xnum1*xnum2//gcd(xnum1,xnum2))
def prime(x):
    p=ceil(x**.5)+1
    for i in range(2,p):
        if (x%i==0 and x!=2) or x==0:return 0

    return 1
def dfs(u,visit,graph):
    visit[u]=True
    for i in graph[u]:
        if not visit[i]:
            dfs(i,visit,graph)

###########################---Test-Case---#################################
"""

"""
###########################---START-CODING---##############################

n=int(z())
l=[0]+list(ac(zzz()))
li=sorted(l)
for _ in range(int(z())):
    a,b,c=zz()
    if a==1:print(l[c]-l[b-1])
    else:print(li[c]-li[b-1])


z,zz=input,lambda:list(map(int,z().split()))
zzz=lambda:[int(i) for i in stdin.readline().split()]
szz,graph,mod,szzz=lambda:sorted(zz()),{},10**9+7,lambda:sorted(zzz())
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac
def lcd(xnum1,xnum2):return (xnum1*xnum2//gcd(xnum1,xnum2))
def prime(x):
    p=ceil(x**.5)+1
    for i in range(2,p):
        if (x%i==0 and x!=2) or x==0:return 0

    return 1
def dfs(u,visit,graph):
    visit[u]=True
    for i in graph[u]:
        if not visit[i]:
            dfs(i,visit,graph)

###########################---Test-Case---#################################
"""

"""
###########################---START-CODING---##############################

n=int(z())
lp=zzz()
l=[0]+list(ac(lp))
li=[0]+list(ac(sorted(lp)))
for _ in range(int(z())):
    a,b,c=zz()
    if a==1:print(l[c]-l[b-1])
    else:print(li[c]-li[b-1])


import math
import bisect
import sys
input = sys.stdin.readline
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))
# N, M = inlt()
# A = inlt()
# T = inp()
# print(T)
# for t in range(T):
N = inp()
S = inlt()
V = []
for a in range(N):
	V.append(S[a])
S.sort()
# print(V)
# print(S)
pre1 = []
pre2 = []
cum1 = 0
cum2 = 0
for i in range(N):
	cum1 += V[i]
	pre1.append(cum1)
	cum2 += S[i]
	pre2.append(cum2)
# print(pre1)
# print(pre2)
M = inp()
for  m in range(M):
	t, l, r = inlt()
	l -= 1
	r -= 1
	if t == 1:
		if l >= 1:
			print(pre1[r]-pre1[l-1])
		else:
			print(pre1[r])
	else:
		if l >= 1:
			print(pre2[r]-pre2[l-1])
		else:
			print(pre2[r])


n = int(input())
arr = list(map(int, input().split()))
arr1 = [0 for i in range(n)]
arr2 = [0 for i in range(n)]
print(arr)
arr1[0] = arr[0]
for i in range(1,n):
    arr1[i] = arr[i] + arr1[i-1]
arr.sort()
print(arr)
arr2[0] = arr[0]
for i in range(1,n):
    arr2[i] = arr[i] + arr2[i-1]
query = int(input())
#print(arr1)
#print(arr2)
for _ in range(query):
    t, l, r = map(int, input().split())
    if l == 1:
        if t == 1:
            print(arr1[r-1])
        else :
            print(arr2[r-1])
    else:
        if t == 1:
            print(arr1[r-1] - arr1[l-2])
        else :
            print(arr2[r-1] - arr2[l-2])


n = int(input())
arr = list(map(int, input().split()))
arr1 = [0 for i in range(n)]
arr2 = [0 for i in range(n)]
#print(arr)
arr1[0] = arr[0]
for i in range(1,n):
    arr1[i] = arr[i] + arr1[i-1]
arr.sort()
#print(arr)
arr2[0] = arr[0]
for i in range(1,n):
    arr2[i] = arr[i] + arr2[i-1]
query = int(input())
#print(arr1)
#print(arr2)
for _ in range(query):
    t, l, r = map(int, input().split())
    if l == 1:
        if t == 1:
            print(arr1[r-1])
        else :
            print(arr2[r-1])
    else:
        if t == 1:
            print(arr1[r-1] - arr1[l-2])
        else :
            print(arr2[r-1] - arr2[l-2])


n  = int(input())
lst = list(map(int, input().split()))
m = int(input())

preSum = [0] * (n+1)
for i in range(1, n+1):
	preSum[i] = preSum[i-1] + lst[i-1]

lst = sorted(lst)
sumSort = [0] * (n+1)
for i in range(1, n+1):
	sumSort[i] = sumSort[i-1] + lst[i-1]
for i in range(m):
	val = list(map(int, input().split()))
	l, r = min(val[1]-2, 0), val[2]-1
	if val[0] == 1:
		print(preSum[val[2]] - preSum[val[1]-1])
	else:
		print(sumSort[val[2]] -sumSort[val[1]-1])


n=input()
l=list(map(int,input().split()))
l.insert(0,0)
z=sorted(l)
for i in range(1,len(l)):
    l[i]+=l[i-1]
    z[i]+=z[i-1]
for _ in range(int(input())):
    a,b,c=map(int,input().split())
    if a==1:
        print(l[c]-l[b-1])
    else:
        print(z[c]-z[b-1])


n = int(input())
preco = [int(x) for x in input().split()]
questoes = int(input())

orde = preco.copy()
orde.sort()

for i in range(1, n):
	preco[i] = preco[i] + preco[i-1]
	orde[i] = orde[i] + orde[i-1]

for e in range(questoes):
	tipo, l, r = [int(x) for x in input().split()]
	l -= 1
	r -= 1

	soma = 0

	if (tipo == 1):
		if l > 0:
			soma = preco[r] - preco[l-1]
		else:
			soma = preco[r]

	else:
		if l > 0:
			soma = orde[r] - orde[l-1]
		else:
			soma = orde[r]

	print(soma)


n = int(input())
preco = [int(x) for x in input().split()]
questoes = int(input())

orde = preco.copy()
orde.sort()

for e in range(questoes):
	tipo, l, r = [int(x) for x in input().split()]

	soma = 0

	if (tipo == 1):
		for i in range(l-1,r):
			soma += preco[i]
	else:
		for i in range(l-1,r):
			soma += orde[i]

	print(soma)


a=int(input())
b=[0]+list(map(int,input().split()))
c=sorted(b.copy())
for i in range(1,a+1):b[i]+=b[i-1];c[i]+=c[i-1]
for _ in " "*int(input()):
    x,y,z=map(int,input().split())
    if x==1:print(b[z]-b[y-1])
    else:print(c[z]-c[y-1])


def rat(b,x,y):print(b[y]-b[x-1])
a=int(input())
b=[0]+list(map(int,input().split()))
c=sorted(b.copy())
for i in range(1,a+1):b[i]+=b[i-1];c[i]+=c[i-1]
for _ in " "*int(input()):
    x,y,z=map(int,input().split())
    if x==1:rat(b,y,z)
    else:rat(c,y,z)


def rat(b,x,y):print(b[y]-b[x-1])
a=int(input())
b=[0]+list(map(int,input().split()))
c=sorted(b.copy())
for i in range(1,a+1):b[i]+=b[i-1];c[i]+=c[i-1]
for _ in " "*int(input()):
    x,y,z=map(int,input().split())
    if x==1:rat(b,y,z)
    else:rat(c,x,y)


S = sorted
M = lambda : map(int,input().split())
m = int(input())
a = list(M())
p = S(a)
def pre_sum(arr):
	s_arr  = [0]
	for i in range(1,len(arr)+1):
		s_arr += [s_arr[i-1]+arr[i-1]]
	return s_arr
sa,sp = pre_sum(a),pre_sum(p)

n = int(input())
for i in range(n):
	k,l,r  = M()
	if k==1:
		print(sa[r]-sa[l-1])
	else:
		print(sp[r]-sp[l-1])


n = int(input())

arr = list(map(int, input().split()))
srt = sorted(arr)

m = int(input())

for i in range(1, n):
    srt[i] = srt[i] + srt[i-1]

for i in range(m):
    a, b, c = map(int, input().split())

    if a == 1:
        print(sum(arr[b-1:c]))
    else:
        if b == 1:
            print(srt[c-1])
        else:
            print(srt[c-1] - srt[b-2])


n = int(input())

arr = list(map(int, input().split()))
srt = sorted(arr)

m = int(input())

for i in range(1, n):
    srt[i] = srt[i] + srt[i-1]
    arr[i] = arr[i] + arr[i-1]

for i in range(m):
    a, b, c = map(int, input().split())

    if a == 1:
        if b == 1:
            print(arr[c - 1])
        else:
            print(arr[c - 1] - arr[b - 2])
    else:
        if b == 1:
            print(srt[c-1])
        else:
            print(srt[c-1] - srt[b-2])


n = int(input())

arr = list(map(int, input().split()))
srt = sorted(arr)

m = int(input())

for i in range(1, n):
    srt[i] = srt[i] + srt[i-1]

for i in range(m):
    a, b, c = map(int, input().split())

    if a == 1:
        print(sum(arr[b-1:c]))
    else:
        print(srt[c-1] - srt[b-2])


n = int(input())

arr = list(map(int, input().split()))

m = int(input())

srt = sorted(arr)

for i in range(m):
    a, b, c = map(int, input().split())

    if a == 1:
        print(sum(arr[b-1:c]))
    else:
        print(sum(srt[b-1:c]))


n = int(input())
stones = list(map(int, input().split()))

first_sum = [0]
second_sum = [0]
i = 0
for s1, s2 in zip(stones, sorted(stones)):
    first_sum.append(first_sum[i] + s1)
    second_sum.append(second_sum[i] + s2)
    i += 1

m = int(input())
for i in range(m):
    q, left, right = map(int, input().split())
    if q == 1:
        print(first_sum[right] - first_sum[left - 1])
    elif q == 2:
        print(second_sum[right] - second_sum[left - 1])


import sys
stones = int(sys.stdin.readline())
cost = list(map(int, sys.stdin.readline().split()))
arranged_cost = cost[:]
arranged_cost.sort()
for x in range(int(sys.stdin.readline())):
    t, start, end = map(int, sys.stdin.readline().split())
    if t == 1:
        sys.stdout.write(str(sum(cost[start - 1: end])) + '\n')
    else:
        sys.stdout.write(str(sum(arranged_cost[start - 1: end])) + '\n')


stones = int(input())
cost = list(map(int, input().split()))
arranged_cost = cost[:]
arranged_cost.sort()
for x in range(int(input())):
    t, start, end = map(int, input().split())
    if t == 1:
        print(sum(cost[start - 1: end]))
    else:
        print(sum(arranged_cost[start - 1: end]))


stones = int(input())
cost = [0] + list(map(int, input().split()))
arranged_cost = sorted(cost)
prefix_cost = []
prefix_arranged_cost = []
i = 0

for x in cost:
    prefix_cost.append(i + x)
    i += x

i = 0

for x in arranged_cost:
    prefix_arranged_cost.append(x + i)
    i += x

for x in range(int(input())):
    t, start, end = map(int, input().split())
    if t == 1:
        print(prefix_cost[end] - prefix_cost[start - 1])
    else:
        print(prefix_arranged_cost[end] - prefix_arranged_cost[start - 1])


from sys import stdin
t = int(stdin.readline().rstrip())
l = list(map(int, stdin.readline().rstrip().split(" ")))
for_sort = l.copy()
for_sort.sort()
sum_normal = [0] * (t + 1)

sum_sort = [0] * (t + 1)
for i in range(1,t + 1):
    sum_normal[i] = sum_normal[i - 1] + l[i-1]
for j in range(1,t + 1):
    sum_sort[j] = sum_sort[j - 1] + for_sort[j-1]

n = int(input())
for _ in range(n):
    q, w, e = list(map(int, stdin.readline().rstrip().split(" ")))
    if q == 1:
        print(sum_normal[e] - sum_normal[w - 1])
    else:
        print(sum_sort[e] - sum_sort[w - 1])


n = int(input())
V = list(map(int,input().split()))
A = sorted(V)
v = [0]*n
a =  [0]*n
a[0] = A[0]
v[0] = V[0]
for i in range(1,n):
     a[i] = a[i-1] + A[i]
     v[i] = v[i-1] + V[i]

for i in range(int(input())):
     type1,l,r = map(int,input().split())
     if type1 == 1:
          if l - 2 == -1:
               print(v[r-1])
          else:
               print(v[r-1] - v[l-2])
     else:
          if l - 2 == -1:
               print(a[r-1])
          else:
               print(a[r-1] - a[l-2])


#include <bits/stdc++.h>
using namespace std;
inline void solve();
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef HOME
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    int t;
    cin >> t;
    while (t--) {
        clock_t time = clock();
        solve();
        cout<<"   "<<((clock() - time) / (double)CLOCKS_PER_SEC)<<endl;
    }
#endif
#ifndef HOME
    solve();
#endif
    return 0;
}

#define int long long
const int ost =1e9+7;
inline void solve() {
    int n,p;
    cin>>n>>p;
    double l=0,r=1e18;
    vector<pair<int,int>> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i].first>>v[i].second;
    }
    double t;
    int it=0;
    while(it<1000){
        t = (l+r)/2;
        double s =0 ;
        for(int i=0;i<n;i++){
            double x=v[i].second-v[i].first*t;
            if(x<0)
                s+=x;
        }
        if(s+p*t>0)
            l=t;
        else
            r=t;
        it++;
    }
    if(l>=1e11) {
        cout << -1;
    }
    else
        cout<<fixed<<setprecision(5)<<l;
}


#include <bits/stdc++.h>
using namespace std;
inline void solve();
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef HOME
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    int t;
    cin >> t;
    while (t--) {
        clock_t time = clock();
        solve();
        cout<<"   "<<((clock() - time) / (double)CLOCKS_PER_SEC)<<endl;
    }
#endif
#ifndef HOME
    solve();
#endif
    return 0;
}

#define int long long
const int ost =1e9+7;
inline void solve() {
    int n,p;
    cin>>n>>p;
    double l=0,r=1e18;
    vector<pair<int,int>> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i].first>>v[i].second;
    }
    double t;
    int it=0;
    while(it<1000){
        t = (l+r)/2;
        double s =0 ;
        for(int i=0;i<n;i++){
            double x=v[i].second-v[i].first*t;
            if(x<0)
                s+=x;
        }
        if(s+p*t>0)
            l=t;
        else
            r=t;
        it++;
    }
    if(l>=1e17) {
        cout << -1;
    }
    else
        cout<<fixed<<setprecision(5)<<l;
}


#include <bits/stdc++.h>
using namespace std;

//#define INF 0x3f3f3f3f
#define LL long long

const int INF = 1e6;
const double LES = 1e-6;

int n, p;
int a[101010], b[101010];

bool ifend(double lam) {
	double s = lam * p * 1.0;
	for(int i = 0; i < n; i++){
		if(b[i] * 1.0 * 10 >= (lam * a[i] * 1.0 * 10)) continue;
		s += b[i] * 1.0 - lam * a[i] * 1.0;
//		cout<<s<<endl;
		if(s < 0) return false;
	}
	return true;//全大于0；
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
//	freopen("input.txt", "r", stdin);
	LL sum = 0;
	cin>>n>>p;
	for(int i = 0; i < n; i ++){
		cin>>a[i]>>b[i];
		sum += a[i];
	}

	if(sum <= p) {
		cout<<"-1";
		return 0;
	}

	int t = 300;
	double l = 0, r = 1e9, mid;
	while(t--){
		mid = (l + r) /2;
		if(ifend(mid)) {
			l = mid;
		}else {
			r = mid;
		}
//		cout<<l<<" " <<r<<" "<<mid<<endl;
	}
	cout<<l<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//#define INF 0x3f3f3f3f
#define LL long long

const int INF = 1e6;
const double LES = 1e-6;

int n, p;
int a[101010], b[101010];

bool ifend(double lam) {
	double s = lam * (double)p;
	for(int i = 0; i < n; i++){
		if((double)b[i] - lam * a[i] >= 0) continue;
		s +=  (double)b[i] - lam * a[i];
//		cout<<s<<endl;
		if(s < 0) return false;
	}
	return true;//全大于0；
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
//	freopen("input.txt", "r", stdin);
	LL sum = 0;
	cin>>n>>p;
	for(int i = 0; i < n; i ++){
		cin>>a[i]>>b[i];
		sum += a[i];
	}

	if(sum <= p) {
		cout<<"-1";
		return 0;
	}

	int t = 100;
	double l = 0, r = 1e9, mid;
	while(t--){
		mid = (l + r) /2;
		if(ifend(mid)) {
			l = mid;
		}else {
			r = mid;
		}
//		cout<<l<<" " <<r<<" "<<mid<<endl;
	}
	cout<<mid<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//#define INF 0x3f3f3f3f
#define LL long long

const int INF = 1e6;
const double LES = 1e-6;

int n, p;
double a[101010], b[101010];

bool ifend(double lam) {
	double s = lam * (double)p;
	for(int i = 0; i < n; i++){
		if((double)b[i] - lam * a[i] >= 0) continue;
		s +=  (double)b[i] - lam * a[i];
//		cout<<s<<endl;
		if(s < 0) return false;
	}
	return true;//全大于0；
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
//	freopen("input.txt", "r", stdin);
	double sum = 0;
	cin>>n>>p;
	for(int i = 0; i < n; i ++){
		cin>>a[i]>>b[i];
		sum += a[i];
	}

	if(sum <= p) {
		cout<<"-1";
		return 0;
	}

	int t = 100;
	double l = 0, r = 1e9, mid;
	while(t--){
		mid = (l + r) /2;
		if(ifend(mid)) {
			l = mid;
		}else {
			r = mid;
		}
//		cout<<l<<" " <<r<<" "<<mid<<endl;
	}
	cout<<mid<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//#define INF 0x3f3f3f3f
#define LL long long

const int INF = 1e6;
const double LES = 1e-6;

int n, p;
int a[101010], b[101010];

bool ifend(double lam) {
	double s = lam * (double)p;
	for(int i = 0; i < n; i++){
		if(b[i] * 1.0 - lam * a[i] * 1.0 >= 0) continue;
		s += b[i] * 1.0 - lam * a[i] * 1.0;
//		cout<<s<<endl;
		if(s < 0) return false;
	}
	return true;//全大于0；
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
//	freopen("input.txt", "r", stdin);
	double sum = 0;
	cin>>n>>p;
	for(int i = 0; i < n; i ++){
		cin>>a[i]>>b[i];
		sum += a[i];
	}

	if(sum <= p) {
		cout<<"-1";
		return 0;
	}

	int t = 300;
	double l = 0, r = 1e9, mid;
	while(t--){
		mid = (l + r) /2;
		if(ifend(mid)) {
			l = mid;
		}else {
			r = mid;
		}
//		cout<<l<<" " <<r<<" "<<mid<<endl;
	}
	cout<<mid<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//#define INF 0x3f3f3f3f
#define LL long long

const int INF = 1e6;
const double LES = 1e-6;

int n, p;
int a[101010], b[101010];

bool ifend(double lam) {
	double s = lam * (double)p;
	for(int i = 0; i < n; i++){
		if((double)b[i] - lam * a[i] > 0) continue;
		s +=  (double)b[i] - lam * a[i];
//		cout<<s<<endl;
		if(s < 0) return true;
	}
	return false;//全大于0；
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
//	freopen("input.txt", "r", stdin);
	LL sum = 0;
	cin>>n>>p;
	for(int i = 0; i < n; i ++){
		cin>>a[i]>>b[i];
		sum += a[i];
	}

	if(sum <= p) {
		cout<<"-1";
		return 0;
	}

	int t = 100;
	double l = 0, r = 1e9, mid;
	while(t--){
		mid = (l + r) /2;
		if(ifend(mid)) {
			r = mid;
		}else {
			l = mid;
		}
//		cout<<l<<" " <<r<<" "<<mid<<endl;
	}
	cout<<mid<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//#define INF 0x3f3f3f3f
#define LL long long

const int INF = 1e6;
const double LES = 1e-6;

int n, p;
int a[101010], b[101010];

bool ifend(double lam) {
	double s = lam * (double)p;
	for(int i = 0; i < n; i++){
		if((double)b[i] - lam * a[i] > 0) continue;
		s +=  (double)b[i] - lam * a[i];
//		cout<<s<<endl;
		if(s < 0) return true;
	}
	return false;//全大于0；
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
//	freopen("input.txt", "r", stdin);
	LL sum = 0;
	cin>>n>>p;
	for(int i = 0; i < n; i ++){
		cin>>a[i]>>b[i];
		sum += a[i];
	}

	if(sum <= p) {
		cout<<"-1";
		return 0;
	}

	int t = 1000;
	double l = 0, r = 1e9, mid;
	while(t--){
		mid = (l + r) /2;
		if(ifend(mid)) {
			r = mid;
		}else {
			l = mid;
		}
//		cout<<l<<" " <<r<<" "<<mid<<endl;
	}
	printf("%.10lf\n", mid);
	return 0;
}


#include <bits/stdc++.h>
using namespace std;

//#define INF 0x3f3f3f3f
#define LL long long

const int INF = 1e6;
const double LES = 1e-6;

int n, p;
int a[101010], b[101010];

bool ifend(double lam) {
	double s = lam * p * 1.0;
	for(int i = 0; i < n; i++){
		if(b[i] * 1.0 * 10 >= (lam * a[i] * 1.0 * 10)) continue;
		s += b[i] * 1.0 - lam * a[i] * 1.0;
//		cout<<s<<endl;
		if(s < 0) return false;
	}
	return true;//全大于0；
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
//	freopen("input.txt", "r", stdin);
	LL sum = 0;
	cin>>n>>p;
	for(int i = 0; i < n; i ++){
		cin>>a[i]>>b[i];
		sum += a[i];
	}

	if(sum <= p) {
		cout<<"-1";
		return 0;
	}

	int t = 300;
	double l = 0, r = 1e18, mid;
	while(t--){
		mid = (l + r) /2;
		if(ifend(mid)) {
			l = mid;
		}else {
			r = mid;
		}
//		cout<<l<<" " <<r<<" "<<mid<<endl;
	}
	cout<<l<<endl;
	return 0;
}


#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,a[101010],b[101001];
int p;
int check(double x)
{
    double res=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]*1.0*x*10>(b[i]*1.0*10))
        {
            res+=(a[i]*1.0*x-(b[i]*1.0))/p;
        }
    }
    if(res<=x){
        return 1;
    }
    else return 0;
}
int main()
{
    scanf("%d%d",&n,&p);
    ll s=0;
    for(int i=0;i<n;i++)
    {
        scanf("%d%d",&a[i],&b[i]);
        s+=a[i];
    }

        if(p>=s)
        {
            printf("-1\n");
        return 0;
        }

    double l=0.0,r=1e18;
    long long cnt=0;
    while(r-l>1e-9)
    {
        cnt++;
        double mid=(l+r)/2;
        if(check(mid))
            l=mid;
        else
            r=mid;
        if(cnt>300) break;
    }
    printf("%.5lf\n",l );
}


#include <bits/stdc++.h>
using namespace std;

//#define INF 0x3f3f3f3f
#define LL long long

const int INF = 1e6;
const double LES = 1e-6;

int n, p;
int a[101010], b[101010];

bool ifend(double lam) {
	double s = lam * (double)p;
	for(int i = 0; i < n; i++){
		if((double)b[i] - lam * a[i] > 0) continue;
		s +=  (double)b[i] - lam * a[i];
//		cout<<s<<endl;
		if(s < 0) return true;
	}
	return false;//全大于0；
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0);
//	freopen("input.txt", "r", stdin);
	LL sum = 0;
	cin>>n>>p;
	for(int i = 0; i < n; i ++){
		cin>>a[i]>>b[i];
		sum += a[i];
	}

	if(sum <= p) {
		cout<<"-1";
		return 0;
	}

	int t = 1000;
	double l = 0, r = 1e9, mid;
	while(t--){
		mid = (l + r) /2;
		if(ifend(mid)) {
			r = mid;
		}else {
			l = mid;
		}
//		cout<<l<<" " <<r<<" "<<mid<<endl;
	}
	cout<<mid<<endl;
	return 0;
}


#include<queue>
#include<math.h>
#include<iomanip>
#include<iostream>
#include<functional>
#include<algorithm>
using namespace std;

#define maxn 100010

typedef long long LL;

int n;
double p;

struct Node
{
	double use, rest;
}input[maxn];

LL a[maxn], b[maxn];

int cmp(Node a, Node b)
{
	return (a.rest / a.use) < (b.rest / b.use);
}

int check(int k)
{
	if (a[k] - p <= 0) return 0;
	double x = b[k] / (a[k] - p);
	if (k == n)
	{
		if (x < (input[k].rest / input[k].use)) return 0;
		return 1;
	}
	if (x <= (input[k + 1].rest / input[k + 1].use)) return 1;
	return 0;

}

int main()
{
	cin >> n >> p;
	for (int i = 1; i <= n; i++)
		cin >> input[i].use >> input[i].rest;
	sort(input + 1, input + n + 1, cmp);
	//cout << input[1].use<<input[2].use;
	for (int i = 1; i <= n; i++)
	{
		a[i] = a[i - 1] + input[i].use;
		b[i] = b[i - 1] + input[i].rest;
	}
	//cout << a[2];
	int c = 1, d = n;
	if (p > a[n])
	{
		cout << -1 << endl;
		return 0;
	}
	while (c != d)
	{
		if (c == (d - 1))
		{
			if (check(d)) cout << fixed << setprecision(8) << b[d] / (a[d] - p);
			else cout << fixed << setprecision(8) << b[c] / (a[c] - p);
			return 0;
		}
		int mid = (c + d) / 2;
		if (check(mid)) c = mid;
		else d = mid - 1;
	}
	cout << fixed << setprecision(8) << b[c] / (a[c] - p);
	return 0;
}


#include<queue>
#include<math.h>
#include<iomanip>
#include<iostream>
#include<functional>
#include<algorithm>
using namespace std;

#define maxn 100010

typedef long long LL;

int n;
double p;

struct Node
{
	double use, rest;
}input[maxn];

LL a[maxn], b[maxn];

int cmp(Node a, Node b)
{
	return (a.rest / a.use) < (b.rest / b.use);
}

int check(double k)
{
	/*
	if (a[k] - p <= 0) return 0;
	double x = b[k] / (a[k] - p);
	if (k == n)
	{
		if (x < (input[k].rest / input[k].use)) return 0;
		return 1;
	}
	if (x <= (input[k + 1].rest / input[k + 1].use)) return 1;
	return 0;
	*/
	int i = 1;
	for (; i <= n; i++)
		if (input[i].rest / input[i].use > k) break;
	i--;
	if (a[i] - p <= 0) return 0;

}

int main()
{
	cin >> n >> p;
	for (int i = 1; i <= n; i++)
		cin >> input[i].use >> input[i].rest;
	sort(input + 1, input + n + 1, cmp);
	//cout << input[1].use<<input[2].use;
	for (int i = 1; i <= n; i++)
	{
		a[i] = a[i - 1] + input[i].use;
		b[i] = b[i - 1] + input[i].rest;
	}
	//cout << a[2];
	int c = 1, d = n;
	if (p > a[n])
	{
		cout << -1 << endl;
		return 0;
	}
	while (c != d)
	{
		if (c == (d - 1))
		{
			if (check(d)) cout << fixed << setprecision(8) << b[d] / (a[d] - p);
			else cout << fixed << setprecision(8) << b[c] / (a[c] - p);
			return 0;
		}
		int mid = (c + d) / 2;
		if (check(mid)) c = mid;
		else d = mid - 1;
	}
	cout << fixed << setprecision(8) << b[c] / (a[c] - p);
	return 0;
}


#include<queue>
#include<math.h>
#include<iomanip>
#include<iostream>
#include<functional>
#include<algorithm>
using namespace std;

#define maxn 100010

typedef long long LL;

int n;
double p;

struct Node
{
	double use, rest;
}input[maxn];

LL a[maxn], b[maxn];

int cmp(Node a, Node b)
{
	return (a.rest / a.use) < (b.rest / b.use);
}

int check(double k)
{
	int i = 1;
	for (; i <= n; i++)
		if (input[i].rest / input[i].use > k) break;
	i--;
	double  tot = p*k + b[i];
	double consp = a[i] * k;
	if (consp < tot) return 1;
	return 0;
}

int main()
{
	cin >> n >> p;
	for (int i = 1; i <= n; i++)
		cin >> input[i].use >> input[i].rest;
	sort(input + 1, input + n + 1, cmp);
	//cout << input[1].use<<input[2].use;
	for (int i = 1; i <= n; i++)
	{
		a[i] = a[i - 1] + input[i].use;
		b[i] = b[i - 1] + input[i].rest;
	}
	if (p >= a[n])
	{
		cout << -1 << endl;
		return 0;
	}
	double c = 0.0, d = b[n] / (a[n] - p) + 1;
	while (d-c>1e-6)
	{
		int mid = (c + d) / 2;
		if (check(mid)) c = mid;
		else d = mid;
	}
	cout << fixed << setprecision(6) << c;
	return 0;
}


#include<iostream>
#include<iomanip>
using namespace std;
#define maxn 100010

int n, p;

struct Node
{
	int use, rest;
}input[maxn];

int check(double t)
{
	double tot = 0;
	for (int i = 1; i <= n; i++)
		if (input[i].rest < t*input[i].use)
			tot += input[i].use*t - input[i].rest;
	if (tot < p*t) return 1;
	return 0;
}

int main()
{
	ios::sync_with_stdio(false);

	double sump = 0, sums = 0;
	cin >> n >> p;
	for (int i = 1; i <= n; i++)
	{
		cin >> input[i].use >> input[i].rest;
		sump += input[i].use;
		sums += input[i].rest;
	}
	if (p >= sump)
	{
		cout << -1 << endl;
		return 0;
	}
	double L = 0, R = sums / (sump - p) + 1, M;
	while (R - L > 1e-6) {
		M = L + (R - L) / 2;
		if (check(M))
			L = M;
		else
			R = M;
	}
	cout << fixed << setprecision(6) << M << endl;
	return 0;
}


#include<queue>
#include<math.h>
#include<iomanip>
#include<iostream>
#include<functional>
#include<algorithm>
using namespace std;

#define maxn 100010

int  n;
double p;

struct Node
{
	double use, rest;
};

double a[maxn], b[maxn];
Node input[maxn];

int cmp(Node a, Node b)
{
	return (a.rest / a.use) < (b.rest / b.use);
}

int check(int k)
{
	if (a[k] - p <= 0) return 0;
	double x = b[k] / (a[k] - p);
	if (k == n)
	{
		if (x < (input[k].rest / input[k].use)) return 0;
		return 1;
	}
	if (x <= (input[k + 1].rest / input[k + 1].use)) return 1;
	return 0;
}

int main()
{
	cin >> n >> p;
	for (int i = 1; i <= n; i++)
		cin >> input[i].use >> input[i].rest;
	sort(input + 1, input + n + 1, cmp);
	//cout << input[1].use<<input[2].use;
	for (int i = 1; i <= n; i++)
	{
		a[i] = a[i - 1] + input[i].use;
		b[i] = b[i - 1] + input[i].rest;
	}
	//cout << a[2];
	int c = 1, d = n;
	if (p > a[n])
	{
		cout << -1 << endl;
		return 0;
	}
	while (c != d)
	{
		if (c == (d - 1))
		{
			if (check(d)) cout << fixed << setprecision(8) << b[d] / (a[d] - p);
			else cout << fixed << setprecision(8) << b[c] / (a[c] - p);
			return 0;
		}
		int mid = (c + d) / 2;
		if (check(mid)) c = mid;
		else d = mid - 1;
	}
	cout << fixed << setprecision(8) << b[c] / (a[c] - p);
	return 0;
}


#include<queue>
#include<math.h>
#include<iomanip>
#include<iostream>
#include<functional>
#include<algorithm>
using namespace std;

#define maxn 100010

typedef long long LL;

int n;
double p;

struct Node
{
	double use, rest;
}input[maxn];

LL a[maxn], b[maxn];

int cmp(Node a, Node b)
{
	return (a.rest / a.use) < (b.rest / b.use);
}

int check(int k)
{
	if (a[k] - p <= 0) return 0;
	double x = b[k] / (a[k] - p);
	if (k == n)
	{
		if (x < (input[k].rest / input[k].use)) return 0;
		return 1;
	}
	if (x <= (input[k + 1].rest / input[k + 1].use)) return 1;
	return 0;

}

int main()
{
	cin >> n >> p;
	for (int i = 1; i <= n; i++)
		cin >> input[i].use >> input[i].rest;
	sort(input + 1, input + n + 1, cmp);
	//cout << input[1].use<<input[2].use;
	for (int i = 1; i <= n; i++)
	{
		a[i] = a[i - 1] + input[i].use;
		b[i] = b[i - 1] + input[i].rest;
	}
	//cout << a[2];
	int c = 1, d = n;
	if (p >= a[n])
	{
		cout << -1 << endl;
		return 0;
	}
	while (c != d)
	{
		if (c == (d - 1))
		{
			if (check(d)) cout << fixed << setprecision(8) << b[d] / (a[d] - p);
			else cout << fixed << setprecision(8) << b[c] / (a[c] - p);
			return 0;
		}
		int mid = (c + d) / 2;
		if (check(mid)) c = mid;
		else d = mid - 1;
	}
	cout << fixed << setprecision(8) << b[c] / (a[c] - p);
	return 0;
}


#include<iostream>
#include<iomanip>
using namespace std;
#define maxn 100010

int n, p;

struct Node
{
	int use, rest;
}input[maxn];

int check(double t)
{
	int i = 1;
	double tot = 0;
	for (; i <= n; i++)
		if (input[i].rest / input[i].use < t)
			tot += input[i].use*t - input[i].rest;
	if (tot < p*t) return 1;
	return 0;
}

int main()
{
	ios::sync_with_stdio(false);

	double sump = 0, sums = 0;
	cin >> n >> p;
	for (int i = 1; i <= n; i++)
	{
		cin >> input[i].use >> input[i].rest;
		sump += input[i].use;
		sums += input[i].rest;
	}
	if (p >= sump)
	{
		cout << -1 << endl;
		return 0;
	}
	double L = 0, R = sums / (sump - p) + 1, M;
	while (R - L > 1e-6) {
		M = L + (R - L) / 2;
		if (check(M))
			L = M;
		else
			R = M;
	}
	cout << fixed << setprecision(6) << M << endl;
	return 0;
}


#include<queue>
#include<math.h>
#include<iomanip>
#include<iostream>
#include<functional>
#include<algorithm>
using namespace std;

#define maxn 100010

int  n;
double p;

struct Node
{
	double use, rest;
};

double a[maxn], b[maxn];
Node input[maxn];

int cmp(Node a, Node b)
{
	return (a.rest / a.use) < (b.rest / b.use);
}

int check(int k)
{
	if (a[k] - p <= 0) return 0;
	double x = b[k] / (a[k] - p);
	if (k == n)
	{
		if (x < (input[k].rest / input[k].use)) return 0;
		return 1;
	}
	if (x <= (input[k + 1].rest / input[k + 1].use)) return 1;
	return 0;
}

int main()
{
	cin >> n >> p;
	for (int i = 1; i <= n; i++)
		cin >> input[i].use >> input[i].rest;
	sort(input + 1, input + n + 1, cmp);
	//cout << input[1].use<<input[2].use;
	for (int i = 1; i <= n; i++)
	{
		a[i] = a[i - 1] + input[i].use;
		b[i] = b[i - 1] + input[i].rest;
	}
	//cout << a[2];
	int c = 1, d = n;
	if (p > a[n])
	{
		cout << -1 << endl;
		return 0;
	}
	while (c != d)
	{
		if (c == (d - 1))
		{
			if (check(d)) cout << fixed << setprecision(5) << b[d] / (a[d] - p);
			else cout << fixed << setprecision(5) << b[c] / (a[c] - p);
			return 0;
		}
		int mid = (c + d) / 2;
		if (check(mid)) c = mid;
		else d = mid - 1;
	}
	cout << fixed << setprecision(5) << b[c] / (a[c] - p);
	return 0;
}


#include<queue>
#include<math.h>
#include<iomanip>
#include<iostream>
#include<functional>
#include<algorithm>
using namespace std;

#define maxn 100010

typedef long long LL;

int n;
double p;

struct Node
{
	double use, rest;
}input[maxn];

LL a[maxn], b[maxn];

int cmp(Node a, Node b)
{
	return (a.rest / a.use) < (b.rest / b.use);
}

int check(int k)
{
	if (a[k] - p <= 0) return 0;
	double x = b[k] / (a[k] - p);
	if (k == n)
	{
		if (x < (input[k].rest / input[k].use)) return 0;
		return 1;
	}
	if (x <= (input[k + 1].rest / input[k + 1].use)) return 1;
	return 0;
}

int main()
{
	cin >> n >> p;
	for (int i = 1; i <= n; i++)
		cin >> input[i].use >> input[i].rest;
	sort(input + 1, input + n + 1, cmp);
	//cout << input[1].use<<input[2].use;
	for (int i = 1; i <= n; i++)
	{
		a[i] = a[i - 1] + input[i].use;
		b[i] = b[i - 1] + input[i].rest;
	}
	//cout << a[2];
	int c = 1, d = n;
	if (p > a[n])
	{
		cout << -1 << endl;
		return 0;
	}
	while (c != d)
	{
		if (c == (d - 1))
		{
			if (check(d)) cout << fixed << setprecision(8) << b[d] / (a[d] - p);
			else cout << fixed << setprecision(8) << b[c] / (a[c] - p);
			return 0;
		}
		int mid = (c + d) / 2;
		if (check(mid)) c = mid;
		else d = mid - 1;
	}
	cout << fixed << setprecision(8) << b[c] / (a[c] - p);
	return 0;
}


#include<iostream>
#include<iomanip>
using namespace std;
#define maxn 100010

int n, p;

struct Node
{
	double use, rest;
}input[maxn];

int check(double t)
{
	int i = 1;
	double tot = 0;
	for (; i <= n; i++)
		if (input[i].rest / input[i].use < t)
			tot += input[i].use*t - input[i].rest;
	if (tot < p*t) return 1;
	return 0;
}

int main()
{
	ios::sync_with_stdio(false);

	double sump = 0, sums = 0;
	cin >> n >> p;
	for (int i = 1; i <= n; i++)
	{
		cin >> input[i].use >> input[i].rest;
		sump += input[i].use;
		sums += input[i].rest;
	}
	if (p >= sump)
	{
		cout << -1 << endl;
		return 0;
	}
	double L = 0, R = sums / (sump - p) + 1, M;
	while (R - L > 1e-6) {
		M = L + (R - L) / 2;
		if (check(M))
			L = M;
		else
			R = M;
	}
	cout << fixed << setprecision(6) << M << endl;
	return 0;
}


#include<queue>
#include<math.h>
#include<iomanip>
#include<iostream>
#include<functional>
#include<algorithm>
using namespace std;

#define maxn 100010

int  n;
double p;

struct Node
{
	double use, rest;
};

double a[maxn], b[maxn];
Node input[maxn];

int cmp(Node a, Node b)
{
	return (a.use / a.rest) > (b.use / b.rest);
}

int check(int k)
{
	if (a[k] - p <= 0) return 0;
	double x = b[k] / (a[k] - p);
	if (k == n)
	{
		if (x < (input[k].rest / input[k].use)) return 0;
		return 1;
	}
	if (x < (input[k + 1].rest / input[k + 1].use)) return 1;
	return 0;
}

int main()
{
	cin >> n >> p;
	for (int i = 1; i <= n; i++)
		cin >> input[i].use >> input[i].rest;
	sort(input + 1, input + n + 1, cmp);
	//cout << input[1].use<<input[2].use;
	for (int i = 1; i <= n; i++)
	{
		a[i] = a[i - 1] + input[i].use;
		b[i] = b[i - 1] + input[i].rest;
	}
	//cout << a[2];
	int c = 1, d = n;
	if (p > a[n])
	{
		cout << -1 << endl;
		return 0;
	}
	while (c != d)
	{
		if (c == (d - 1))
		{
			if (check(d)) cout << fixed << setprecision(5) << b[d] / (a[d] - p);
			else cout << fixed << setprecision(5) << b[c] / (a[c] - p);
			return 0;
		}
		int mid = (c + d) / 2;
		if (check(mid)) c = mid;
		else d = mid - 1;
	}
	cout << fixed << setprecision(5) << b[c] / (a[c] - p);
	return 0;
}


//Indomie, Mie dari Indonesia
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long LL;
typedef long double LD;
const LD EPS = 1e-12;
int n;
LL totalM=0,P;
LD posx1,posx2,delta1,delta2,ans;
vector <pair<LD,int> > daftar;
bool adaans=false;
bool cmp(pair<LD,int> a,pair<LD,int> b){
	if(abs(a.fi-b.fi)<EPS)
		return (a.se<b.se);
	return (a.fi<b.fi-EPS);
}
LD cari_postemu(){
	delta2=(LD) -P/totalM;
	delta1=(LD) 1.0;
	LD waktutambahan=(LD) (posx1-posx2)/(delta2-delta1);
	LD ret=posx1+delta1*waktutambahan;
	return ret;
}
int main()
{
	daftar.clear();
	scanf("%d%lld",&n,&P);
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		daftar.pb(mp((LD) b/a,-a));
	}
	sort(daftar.begin(),daftar.end(),cmp);
	/*cout<<"isi daftar"<<endl;
	for(auto v:daftar)
		cout<<v.fi<<" "<<v.se<<endl;
	cout<<"habis "<<endl;*/
	posx1=0;posx2=daftar[0].fi,totalM=daftar[0].se;			//mulai dari 0
	for(int i=1;i<daftar.size();i++)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			posx1+=(LD) -((LD) (daftar[i].fi-posx2)*(LD)totalM)/P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
		else
		{
			LD postemu=cari_postemu();
			if(postemu<daftar[i].fi-EPS)
			{
				ans=cari_postemu();
				adaans=true;
				break;
			}
			posx1+=(LD) -((LD) ((LD)daftar[i].fi-posx2)*(LD)totalM)/(LD)P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
	}
	if(!adaans)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			printf("-1\n");
			return 0;
		}
		ans=cari_postemu();
	}
	cout<<setprecision(10);
	cout<<ans<<endl;
	//printf("%.9Lf\n",ans);
}//Indomie, Mie dari Indonesia


//Indomie, Mie dari Indonesia
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long LL;
typedef long double LD;
const long double EPS = 1e-12;
int n;
LL totalM=0,P;
LD posx1,posx2,delta1,delta2,ans;
vector <pair<LD,int> > daftar;
bool adaans=false;
bool cmp(pair<LD,int> a,pair<LD,int> b){
	if(abs(a.fi-b.fi)<EPS)
		return (a.se<b.se);
	return (a.fi<b.fi-EPS);
}
LD cari_postemu(){
	delta2=(LD) -P/totalM;
	delta1=(LD) 1.0;
	LD waktutambahan=(LD) (posx1-posx2)/(delta2-delta1);
	LD postemu=posx1+delta1*waktutambahan;
	return postemu;
}
int main()
{
	scanf("%d%lld",&n,&P);
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		daftar.pb(mp((LD) b/a,-a));
	}
	sort(daftar.begin(),daftar.end(),cmp);
	/*cout<<"isi daftar"<<endl;
	for(auto v:daftar)
		cout<<v.fi<<" "<<v.se<<endl;
	cout<<"habis "<<endl;*/
	posx1=0;posx2=daftar[0].fi,totalM=daftar[0].se;			//mulai dari 0
	for(int i=1;i<daftar.size();i++)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			posx1+=(LD) -((LD) (daftar[i].fi-posx2)*(LD)totalM)/P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
		else
		{
			LD postemu=cari_postemu();
			if(postemu<daftar[i].fi-EPS)
			{
				ans=cari_postemu();
				adaans=true;
				break;
			}
			posx1+=(LD) -((LD) (daftar[i].fi-posx2)*(LD)totalM)/P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
	}
	if(!adaans)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			printf("-1\n");
			return 0;
		}
		ans=cari_postemu();
	}
	printf("%.9Lf\n",ans);
}//Indomie, Mie dari Indonesia


//Indomie, Mie dari Indonesia
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long LL;
typedef long double LD;
const LD EPS = 1e-12;
int n;
LL totalM=0,P;
LD posx1,posx2,delta1,delta2,ans;
vector <pair<LD,int> > daftar;
bool adaans=false;
bool cmp(pair<LD,int> a,pair<LD,int> b){
	if(abs(a.fi-b.fi)<EPS)
		return (a.se<b.se);
	return (a.fi<b.fi-EPS);
}
LD cari_postemu(){
	delta2=(LD) -P/totalM;
	delta1=(LD) 1.0;
	LD waktutambahan=(LD) (posx1-posx2)/(delta2-delta1);
	LD ret=posx1+delta1*waktutambahan;
	return ret;
}
int main()
{
	daftar.clear();
	scanf("%d%lld",&n,&P);
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		daftar.pb(mp((LD) b/a,-a));
	}
	sort(daftar.begin(),daftar.end(),cmp);
	/*cout<<"isi daftar"<<endl;
	for(auto v:daftar)
		cout<<v.fi<<" "<<v.se<<endl;
	cout<<"habis "<<endl;*/
	posx1=0;posx2=daftar[0].fi,totalM=daftar[0].se;			//mulai dari 0
	for(int i=1;i<daftar.size();i++)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			posx1+=(LD) -((LD) (daftar[i].fi-posx2)*(LD)totalM)/P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
		else
		{
			LD postemu=cari_postemu();
			if(postemu<daftar[i].fi-EPS)
			{
				ans=cari_postemu();
				adaans=true;
				break;
			}
			posx1+=(LD) -((LD) ((LD)daftar[i].fi-posx2)*(LD)totalM)/(LD)P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
	}
	if(!adaans)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			printf("-1\n");
			return 0;
		}
		ans=cari_postemu();
	}
	//cout<<setprecision(10);
	//cout<<ans<<endl;
	printf("%.9lf\n",ans);
}//Indomie, Mie dari Indonesia


//Indomie, Mie dari Indonesia
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long LL;
typedef long double LD;
const long double EPS = 1e-12;
int n;
LL totalM=0,P;
LD posx1,posx2,delta1,delta2,ans;
vector <pair<LD,int> > daftar;
bool adaans=false;
bool cmp(pair<LD,int> a,pair<LD,int> b){
	if(abs(a.fi-b.fi)<EPS)
		return (a.se<b.se);
	return (a.fi<b.fi-EPS);
}
LD cari_postemu(){
	delta2=(LD) -P/totalM;
	delta1=(LD) 1.0;
	LD waktutambahan=(LD) (posx1-posx2)/(delta2-delta1);
	LD postemu=posx1+delta1*waktutambahan;
	return postemu;
}
int main()
{
	scanf("%d%lld",&n,&P);
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		daftar.pb(mp((LD) b/a,-a));
	}
	sort(daftar.begin(),daftar.end(),cmp);
	/*cout<<"isi daftar"<<endl;
	for(auto v:daftar)
		cout<<v.fi<<" "<<v.se<<endl;
	cout<<"habis "<<endl;*/
	posx1=0;posx2=daftar[0].fi,totalM=daftar[0].se;			//mulai dari 0
	for(int i=1;i<daftar.size();i++)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			posx1+=(LD) -((LD) (daftar[i].fi-posx2)*(LD)totalM)/P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
		else
		{
			LD postemu=cari_postemu();
			if(postemu<daftar[i].fi-EPS)
			{
				ans=cari_postemu();
				adaans=true;
				break;
			}
			posx1+=(LD) -((LD) ((LD)daftar[i].fi-posx2)*(LD)totalM)/(LD)P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
	}
	if(!adaans)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			printf("-1\n");
			return 0;
		}
		ans=cari_postemu();
	}
	printf("%.9Lf\n",ans);
}//Indomie, Mie dari Indonesia


//Indomie, Mie dari Indonesia
#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef long double LD;
const LD EPS = 1e-9;
int n,P,awal[100005],kurang[100005];
LL totalkurang=0;
LD totalbiaya(LD waktu){
	LD ret=0;
	for(int i=1;i<=n;i++)
	{
		ret+=max((LD) 0.0,(LD) kurang[i]* waktu - (LD)awal[i]);
		//cout<<"ngitung biaya "<<((LD) kurang[i]* waktu - (LD)awal[i])<<endl;
	}
	return ret;
}
LD binser(){
	LD bawah=0,atas=1000000000000000000.0,mid;
	for(int i=1;i<=100;i++)
	{
		//cout<<bawah<<" "<<atas<<endl;
		mid=(bawah+atas)/2.0;
		//cout<<totalbiaya(mid)<<" "<<((LD) P*mid)<<endl;
		if(totalbiaya(mid)>((LD)P*mid + EPS))
			atas=mid;
		else
			bawah=mid;
	}
	return bawah;
}
int main()
{
	scanf("%d%d",&n,&P);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&kurang[i],&awal[i]),totalkurang+=kurang[i];
	if(P>=totalkurang)
		printf("-1\n");
	else
		cout<<setprecision(10)<<binser()<<endl;
}


//Indomie, Mie dari Indonesia
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long LL;
typedef long double LD;
#define EPS  1e-12
int n;
LL totalM=0,P;
LD posx1,posx2,delta1,delta2,ans;
vector <pair<LD,int> > daftar;
bool adaans=false;
bool cmp(pair<LD,int> a,pair<LD,int> b){
	if(abs(a.fi-b.fi)<EPS)
		return (a.se<b.se);
	return (a.fi<b.fi-EPS);
}
LD cari_postemu(){
	delta2=(LD) -P/totalM;
	delta1=(LD) 1.0;
	LD waktutambahan=(LD) (posx1-posx2)/(delta2-delta1);
	LD ret=posx1+delta1*waktutambahan;
	return ret;
}
int main()
{
	daftar.clear();
	scanf("%d%lld",&n,&P);
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		daftar.pb(mp((LD) b/a,-a));
	}
	sort(daftar.begin(),daftar.end(),cmp);
	/*cout<<"isi daftar"<<endl;
	for(auto v:daftar)
		cout<<v.fi<<" "<<v.se<<endl;
	cout<<"habis "<<endl;*/
	posx1=0;posx2=daftar[0].fi,totalM=daftar[0].se;			//mulai dari 0
	for(int i=1;i<daftar.size();i++)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			posx1+=(LD) -((LD) (daftar[i].fi-posx2)*(LD)totalM)/P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
		else
		{
			LD postemu=cari_postemu();
			if(postemu<daftar[i].fi-EPS)
			{
				ans=cari_postemu();
				adaans=true;
				break;
			}
			posx1+=(LD) -((LD) ((LD)daftar[i].fi-posx2)*(LD)totalM)/(LD)P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
	}
	if(!adaans)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			printf("-1\n");
			return 0;
		}
		ans=cari_postemu();
	}
	printf("%.9Lf\n",ans);
}//Indomie, Mie dari Indonesia


//Indomie, Mie dari Indonesia
#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef long double LD;
const LD EPS = 1e-9;
int n,P,awal[100005],kurang[100005];
LL totalkurang=0;
LD totalbiaya(LD waktu){
	LD ret=0;
	for(int i=1;i<=n;i++)
	{
		ret+=max((LD) 0.0,(LD) kurang[i]* waktu - (LD)awal[i]);
		//cout<<"ngitung biaya "<<((LD) kurang[i]* waktu - (LD)awal[i])<<endl;
	}
	return ret;
}
LD binser(){
	LD bawah=0,atas=10000000000.0,mid;
	for(int i=1;i<=100;i++)
	{
		//cout<<bawah<<" "<<atas<<endl;
		mid=(bawah+atas)/2.0;
		//cout<<totalbiaya(mid)<<" "<<((LD) P*mid)<<endl;
		if(totalbiaya(mid)>((LD)P*mid + EPS))
			atas=mid;
		else
			bawah=mid;
	}
	return bawah;
}
int main()
{
	scanf("%d%d",&n,&P);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&kurang[i],&awal[i]),totalkurang+=kurang[i];
	if(P>=totalkurang)
		printf("-1\n");
	else
		cout<<setprecision(10)<<binser()<<endl;
}


//Indomie, Mie dari Indonesia
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long LL;
typedef long double LD;
const long double EPS = 1e-12;
int n;
LL totalM=0,P;
LD posx1,posx2,delta1,delta2,ans;
vector <pair<LD,int> > daftar;
bool adaans=false;
bool cmp(pair<LD,int> a,pair<LD,int> b){
	if(abs(a.fi-b.fi)<EPS)
		return (a.se<b.se);
	return (a.fi<b.fi-EPS);
}
LD cari_postemu(){
	delta2=(LD) -P/totalM;
	delta1=(LD) 1.0;
	LD waktutambahan=(LD) (posx1-posx2)/(delta2-delta1);
	LD postemu=posx1+delta1*waktutambahan;
	return postemu;
}
int main()
{
	daftar.clear();
	scanf("%d%lld",&n,&P);
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		daftar.pb(mp((LD) b/a,-a));
	}
	sort(daftar.begin(),daftar.end(),cmp);
	/*cout<<"isi daftar"<<endl;
	for(auto v:daftar)
		cout<<v.fi<<" "<<v.se<<endl;
	cout<<"habis "<<endl;*/
	posx1=0;posx2=daftar[0].fi,totalM=daftar[0].se;			//mulai dari 0
	for(int i=1;i<daftar.size();i++)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			posx1+=(LD) -((LD) (daftar[i].fi-posx2)*(LD)totalM)/P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
		else
		{
			LD postemu=cari_postemu();
			if(postemu<daftar[i].fi-EPS)
			{
				ans=cari_postemu();
				adaans=true;
				break;
			}
			posx1+=(LD) -((LD) ((LD)daftar[i].fi-posx2)*(LD)totalM)/(LD)P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
	}
	if(!adaans)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			printf("-1\n");
			return 0;
		}
		ans=cari_postemu();
	}
	printf("%.9Lf\n",ans);
}//Indomie, Mie dari Indonesia


//Indomie, Mie dari Indonesia
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long LL;
typedef long double LD;
const LD EPS = 1e-12;
int n;
LL totalM=0,P;
LD posx1,posx2,delta1,delta2,ans;
vector <pair<LD,int> > daftar;
bool adaans=false;
bool cmp(pair<LD,int> a,pair<LD,int> b){
	if(abs(a.fi-b.fi)<EPS)
		return (a.se<b.se);
	return (a.fi<b.fi-EPS);
}
LD cari_postemu(){
	delta2=(LD) -P/totalM;
	delta1=(LD) 1.0;
	LD waktutambahan=(LD) (posx1-posx2)/(delta2-delta1);
	LD ret=posx1+delta1*waktutambahan;
	return ret;
}
int main()
{
	daftar.clear();
	scanf("%d%lld",&n,&P);
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		daftar.pb(mp((LD) b/a,-a));
	}
	sort(daftar.begin(),daftar.end(),cmp);
	cout<<"isi daftar"<<endl;
	for(auto v:daftar)
		cout<<v.fi<<" "<<v.se<<endl;
	cout<<"habis "<<endl;
	posx1=0;posx2=daftar[0].fi,totalM=daftar[0].se;			//mulai dari 0
	for(int i=1;i<daftar.size();i++)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			posx1+=(LD) -((LD) (daftar[i].fi-posx2)*(LD)totalM)/P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
		else
		{
			LD postemu=cari_postemu();
			if(postemu<daftar[i].fi-EPS)
			{
				ans=cari_postemu();
				adaans=true;
				break;
			}
			posx1+=(LD) -((LD) ((LD)daftar[i].fi-posx2)*(LD)totalM)/(LD)P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
	}
	if(!adaans)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			printf("-1\n");
			return 0;
		}
		ans=cari_postemu();
	}
	printf("%.9Lf\n",ans);
}//Indomie, Mie dari Indonesia


//Indomie, Mie dari Indonesia
#include <iostream>
#include <cstdio>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef long double LD;
const LD EPS = 1e-9;
int n,P,awal[100005],kurang[100005];
LL totalkurang=0;
LD totalbiaya(LD waktu){
	LD ret=0;
	for(int i=1;i<=n;i++)
	{
		ret+=max((LD) 0.0,(LD) kurang[i]* waktu - (LD)awal[i]);
		//cout<<"ngitung biaya "<<((LD) kurang[i]* waktu - (LD)awal[i])<<endl;
	}
	return ret;
}
LD binser(){
	LD bawah=0,atas=100000000000.0,mid;
	for(int i=1;i<=100;i++)
	{
		//cout<<bawah<<" "<<atas<<endl;
		mid=(bawah+atas)/2.0;
		//cout<<totalbiaya(mid)<<" "<<((LD) P*mid)<<endl;
		if(totalbiaya(mid)>((LD)P*mid + EPS))
			atas=mid;
		else
			bawah=mid;
	}
	return bawah;
}
int main()
{
	scanf("%d%d",&n,&P);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&kurang[i],&awal[i]),totalkurang+=kurang[i];
	if(P>=totalkurang)
		printf("-1\n");
	else
		cout<<setprecision(10)<<binser()<<endl;
}


//Indomie, Mie dari Indonesia
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long LL;
typedef long double LD;
const LD EPS = 1e-12;
int n;
LL totalM=0,P;
LD posx1,posx2,delta1,delta2,ans;
vector <pair<LD,int> > daftar;
bool adaans=false;
bool cmp(pair<LD,int> a,pair<LD,int> b){
	if(abs(a.fi-b.fi)<EPS)
		return (a.se<b.se);
	return (a.fi<b.fi-EPS);
}
LD cari_postemu(){
	delta2=(LD) -P/totalM;
	delta1=(LD) 1.0;
	LD waktutambahan=(LD) (posx1-posx2)/(delta2-delta1);
	LD ret=posx1+delta1*waktutambahan;
	return ret;
}
int main()
{
	daftar.clear();
	scanf("%d%lld",&n,&P);
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		daftar.pb(mp((LD) b/a,-a));
	}
	sort(daftar.begin(),daftar.end(),cmp);
	cout<<"isi daftar"<<endl;
	for(auto v:daftar)
		cout<<v.fi<<" "<<v.se<<endl;
	cout<<"habis "<<endl;
	posx1=0;posx2=daftar[0].fi,totalM=daftar[0].se;			//mulai dari 0
	for(int i=1;i<daftar.size();i++)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			posx1+=(LD) -((LD) (daftar[i].fi-posx2)*(LD)totalM)/P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
		else
		{
			LD postemu=cari_postemu();
			if(postemu<daftar[i].fi-EPS)
			{
				ans=cari_postemu();
				adaans=true;
				break;
			}
			posx1+=(LD) -((LD) ((LD)daftar[i].fi-posx2)*(LD)totalM)/(LD)P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
	}
	if(!adaans)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			printf("-1\n");
			return 0;
		}
		ans=cari_postemu();
	}
	cout<<ans<<endl;
	printf("%.9Lf\n",ans);
}//Indomie, Mie dari Indonesia


//Indomie, Mie dari Indonesia
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long LL;
typedef long double LD;
const double EPS = 1e-9;
int n;
LL totalM=0,P;
LD posx1,posx2,delta1,delta2,ans;
vector <pair<LD,int> > daftar;
bool adaans=false;
bool cmp(pair<LD,int> a,pair<LD,int> b){
	if(abs(a.fi-b.fi)<EPS)
		return (a.se<b.se);
	return (a.fi<b.fi-EPS);
}
LD cari_postemu(){
	delta2=(LD) -P/totalM;
	delta1=(LD) 1.0;
	LD waktutambahan=(LD) (posx1-posx2)/(delta2-delta1);
	LD postemu=posx1+delta1*waktutambahan;
	return postemu;
}
int main()
{
	scanf("%d%lld",&n,&P);
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		daftar.pb(mp((LD) b/a,-a));
	}
	sort(daftar.begin(),daftar.end(),cmp);
	/*cout<<"isi daftar"<<endl;
	for(auto v:daftar)
		cout<<v.fi<<" "<<v.se<<endl;
	cout<<"habis "<<endl;*/
	posx1=0;posx2=daftar[0].fi,totalM=daftar[0].se;			//mulai dari 0
	for(int i=1;i<daftar.size();i++)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			posx1+=(LD) ((LD) (daftar[i].fi-posx2)*-totalM)/P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
		else
		{
			LD postemu=cari_postemu();
			if(postemu<daftar[i].fi-EPS)
			{
				ans=cari_postemu();
				adaans=true;
				break;
			}
			posx1+=(LD) ((LD) (daftar[i].fi-posx2)*-totalM)/P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
	}
	if(!adaans)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			printf("-1\n");
			return 0;
		}
		ans=cari_postemu();
	}
	printf("%.9Lf\n",ans);
}//Indomie, Mie dari Indonesia


//Indomie, Mie dari Indonesia
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long LL;
typedef long double LD;
const long double EPS = 1e-12;
int n;
LL totalM=0,P;
LD posx1,posx2,delta1,delta2,ans;
vector <pair<LD,int> > daftar;
bool adaans=false;
bool cmp(pair<LD,int> a,pair<LD,int> b){
	if(abs(a.fi-b.fi)<EPS)
		return (a.se<b.se);
	return (a.fi<b.fi-EPS);
}
LD cari_postemu(){
	delta2=(LD) -P/totalM;
	delta1=(LD) 1.0;
	LD waktutambahan=(LD) (posx1-posx2)/(delta2-delta1);
	LD postemu=posx1+delta1*waktutambahan;
	return postemu;
}
int main()
{
	scanf("%d%lld",&n,&P);
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		daftar.pb(mp((LD) b/a,-a));
	}
	sort(daftar.begin(),daftar.end(),cmp);
	/*cout<<"isi daftar"<<endl;
	for(auto v:daftar)
		cout<<v.fi<<" "<<v.se<<endl;
	cout<<"habis "<<endl;*/
	posx1=0;posx2=daftar[0].fi,totalM=daftar[0].se;			//mulai dari 0
	for(int i=1;i<daftar.size();i++)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			posx1+=(LD) ((LD) (daftar[i].fi-posx2)*-totalM)/P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
		else
		{
			LD postemu=cari_postemu();
			if(postemu<daftar[i].fi-EPS)
			{
				ans=cari_postemu();
				adaans=true;
				break;
			}
			posx1+=(LD) ((LD) (daftar[i].fi-posx2)*-totalM)/P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
	}
	if(!adaans)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			printf("-1\n");
			return 0;
		}
		ans=cari_postemu();
	}
	printf("%.9Lf\n",ans);
}//Indomie, Mie dari Indonesia


//Indomie, Mie dari Indonesia
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long LL;
typedef long double LD;
const double EPS = 1e-9;
int n;
LL totalM=0,P;
LD posx1,posx2,delta1,delta2,ans;
vector <pair<LD,int> > daftar;
bool adaans=false;
bool cmp(pair<LD,int> a,pair<LD,int> b){
	if(abs(a.fi-b.fi)<EPS)
		return (a.se<b.se);
	return (a.fi<b.fi-EPS);
}
LD cari_postemu(){
	delta2=(LD) -P/totalM;
	delta1=(LD) 1.0;
	LD waktutambahan=(LD) (posx1-posx2)/(delta2-delta1);
	LD postemu=posx1+delta1*waktutambahan;
	return postemu;
}
int main()
{
	scanf("%d%lld",&n,&P);
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		daftar.pb(mp((LD) b/a,-a));
	}
	sort(daftar.begin(),daftar.end(),cmp);
	/*cout<<"isi daftar"<<endl;
	for(auto v:daftar)
		cout<<v.fi<<" "<<v.se<<endl;
	cout<<"habis "<<endl;*/
	posx1=0;posx2=daftar[0].fi,totalM=daftar[0].se;			//mulai dari 0
	for(int i=1;i<daftar.size();i++)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			posx1+=(LD) ((LD) (daftar[i].fi-posx2)*-totalM)/P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
		else
		{
			LD postemu=cari_postemu();
			if(postemu<daftar[i].fi-EPS)
			{
				ans=cari_postemu();
				adaans=true;
				break;
			}
			posx1+=(LD) ((LD) (daftar[i].fi-posx2)*-totalM)/P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
	}
	if(!adaans)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			printf("-1\n");
			return 0;
		}
		ans=cari_postemu();
	}
	printf("%.10Lf\n",ans);
}//Indomie, Mie dari Indonesia


//Indomie, Mie dari Indonesia
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long LL;
typedef long double LD;
const LD EPS = 1e-12;
int n;
LL totalM=0,P;
LD posx1,posx2,delta1,delta2,ans;
vector <pair<LD,int> > daftar;
bool adaans=false;
bool cmp(pair<LD,int> a,pair<LD,int> b){
	if(abs(a.fi-b.fi)<EPS)
		return (a.se<b.se);
	return (a.fi<b.fi-EPS);
}
LD cari_postemu(){
	delta2=(LD) -P/totalM;
	delta1=(LD) 1.0;
	LD waktutambahan=(LD) (posx1-posx2)/(delta2-delta1);
	LD ret=posx1+delta1*waktutambahan;
	return ret;
}
int main()
{
	daftar.clear();
	scanf("%d%lld",&n,&P);
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		daftar.pb(mp((LD) b/a,-a));
	}
	sort(daftar.begin(),daftar.end(),cmp);
	/*cout<<"isi daftar"<<endl;
	for(auto v:daftar)
		cout<<v.fi<<" "<<v.se<<endl;
	cout<<"habis "<<endl;*/
	posx1=0;posx2=daftar[0].fi,totalM=daftar[0].se;			//mulai dari 0
	for(int i=1;i<daftar.size();i++)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			posx1+=(LD) -((LD) (daftar[i].fi-posx2)*(LD)totalM)/P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
		else
		{
			LD postemu=cari_postemu();
			if(postemu<daftar[i].fi-EPS)
			{
				ans=cari_postemu();
				adaans=true;
				break;
			}
			posx1+=(LD) -((LD) ((LD)daftar[i].fi-posx2)*(LD)totalM)/(LD)P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
	}
	if(!adaans)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			printf("-1\n");
			return 0;
		}
		ans=cari_postemu();
	}
	//cout<<setprecision(10);
	//cout<<ans<<endl;
	printf("%.9Lg\n",ans);
}//Indomie, Mie dari Indonesia


//Indomie, Mie dari Indonesia
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long LL;
typedef long double LD;
const LD EPS = 1e-12;
int n;
LL totalM=0,P;
LD posx1,posx2,delta1,delta2,ans;
vector <pair<LD,int> > daftar;
bool adaans=false;
bool cmp(pair<LD,int> a,pair<LD,int> b){
	if(abs(a.fi-b.fi)<EPS)
		return (a.se<b.se);
	return (a.fi<b.fi-EPS);
}
LD cari_postemu(){
	delta2=(LD) -P/totalM;
	delta1=(LD) 1.0;
	LD waktutambahan=(LD) (posx1-posx2)/(delta2-delta1);
	LD ret=posx1+delta1*waktutambahan;
	return ret;
}
int main()
{
	daftar.clear();
	scanf("%d%lld",&n,&P);
	for(int i=1;i<=n;i++)
	{
		int a,b;
		scanf("%d%d",&a,&b);
		daftar.pb(mp((LD) b/a,-a));
	}
	sort(daftar.begin(),daftar.end(),cmp);
	/*cout<<"isi daftar"<<endl;
	for(auto v:daftar)
		cout<<v.fi<<" "<<v.se<<endl;
	cout<<"habis "<<endl;*/
	posx1=0;posx2=daftar[0].fi,totalM=daftar[0].se;			//mulai dari 0
	for(int i=1;i<daftar.size();i++)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			posx1+=(LD) -((LD) (daftar[i].fi-posx2)*(LD)totalM)/P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
		else
		{
			LD postemu=cari_postemu();
			if(postemu<daftar[i].fi-EPS)
			{
				ans=cari_postemu();
				adaans=true;
				break;
			}
			posx1+=(LD) -((LD) ((LD)daftar[i].fi-posx2)*(LD)totalM)/(LD)P;
			posx2=daftar[i].fi;
			totalM+=daftar[i].se;
		}
	}
	if(!adaans)
	{
		if(((LD) -P/totalM)>1.0-EPS )
		{
			printf("-1\n");
			return 0;
		}
		ans=cari_postemu();
	}
	cout<<setprecision(10);
	cout<<ans<<endl;
	//printf("%.9Lg\n",ans);
}//Indomie, Mie dari Indonesia


#include <bits/stdc++.h>
using namespace std;

struct devices{
	long long int a;
	long long int b;
	double t;
};

bool acompare(devices lhs, devices rhs) { return lhs.t < rhs.t; }

int main(){
	int n,p;
	cin>>n>>p;
	devices d[n];
	long long int sum=0;

	for (int i = 0; i < n; ++i)
	{
		cin>>d[i].a>>d[i].b;
		d[i].t=d[i].b*1.0/d[i].a;
		sum+=d[i].a;
	}
	if (p>=sum)
	{
		cout<<-1;
		return 0;
	}
	if (n==1)
	{
		cout<<d[0].b*1.0/(d[0].a-p);
		return 0;
	}
	sort(d,d+n,acompare);

	devices s;
	s.a=0;
	s.b=0;
	s.t=d[0].t;
	int i=0;
	while(d[i].t==s.t){
		s.a+=d[i].a;
		s.b+=d[i].b;
		i++;
		if (i==n)
		{
			break;
		}
	}

	if (i<n)
	{

		while((p>=s.a)||(d[i].t<(s.b/(s.a-p)))||(d[i].t==d[i-1].t)){
			s.a+=d[i].a;
			s.b+=d[i].b;
			i++;
			if (i==n)
			{
				break;
			}
		}
	}
	double x =1;

	long long int xx=s.a-p;
	long long int ans=s.b;
	double xxx=x*ans/xx;

	cout<<xxx;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct devices{
	long long int a;
	long long int b;
	double t;
};

bool acompare(devices lhs, devices rhs) { return lhs.t < rhs.t; }

int main(){
	int n,p;
	cin>>n>>p;
	devices d[n];
	long long int sum=0;

	for (int i = 0; i < n; ++i)
	{
		cin>>d[i].a>>d[i].b;
		d[i].t=d[i].b*1.0/d[i].a;
		sum+=d[i].a;
	}
	if (p>=sum)
	{
		cout<<-1;
		return 0;
	}
	if (n==1)
	{
		cout<<d[0].b*1.0/(d[0].a-p);
		return 0;
	}
	sort(d,d+n,acompare);

	devices s;
	s.a=0;
	s.b=0;
	s.t=d[0].t;
	int i=0;
	while(d[i].t==s.t){
		s.a+=d[i].a;
		s.b+=d[i].b;
		i++;
		if (i==n)
		{
			break;
		}
	}

	if (i<n)
	{

		while((p>=s.a)||(d[i].t<(s.b/(s.a-p)))||(d[i].t==d[i-1].t)){
			s.a+=d[i].a;
			s.b+=d[i].b;
			i++;
			if (i==n)
			{
				break;
			}
		}
	}
	double x =1;

	long long int xx=s.a-p;
	long long int ans=s.b;
	double xxx=x*ans/xx;
	if ((xxx>.99980)&&(xxx<.99982))
	{
		cout<<ans<<"  "<<xx<<" "<<i<< endl;
	}
	cout<<xxx;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct devices{
	long long int a;
	long long int b;
	double t;
};

bool acompare(devices lhs, devices rhs) { return lhs.t < rhs.t; }

int main(){
	int n,p;
	cin>>n>>p;
	devices d[n];
	long long int sum=0;

	for (int i = 0; i < n; ++i)
	{
		cin>>d[i].a>>d[i].b;
		d[i].t=d[i].b*1.0/d[i].a;
		sum+=d[i].a;
	}
	if (p>=sum)
	{
		cout<<-1;
		return 0;
	}
	if (n==1)
	{
		cout<<d[0].b*1.0/(d[0].a-p);
		return 0;
	}
	sort(d,d+n,acompare);

	devices s;
	s.a=0;
	s.b=0;
	s.t=d[0].t;
	int i=0;
	while(d[i].t==s.t){
		s.a+=d[i].a;
		s.b+=d[i].b;
		i++;
		if (i==n)
		{
			break;
		}
	}

	if (i<n)
	{

		while((p>=s.a)||(d[i].t<(s.b/(s.a-p)))||(d[i].t==d[i-1].t)){
			s.a+=d[i].a;
			s.b+=d[i].b;
			i++;
			if (i==n)
			{
				break;
			}
		}
	}
	double x =1;

	long long int xx=s.a-p;
	long long int ans=s.b;
	double xxx=x*ans/xx;
	if (xxx>100000000)
	{
		cout<<ans<<"  "<<xx<<" "<<i<< endl;
	}
	cout<<xxx;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct devices{
	long long int a;
	long long int b;
	double t;
};

bool acompare(devices lhs, devices rhs) { return lhs.t < rhs.t; }

int main(){
	int n,p;
	cin>>n>>p;
	devices d[n];
	long long int sum=0;

	for (int i = 0; i < n; ++i)
	{
		cin>>d[i].a>>d[i].b;
		d[i].t=d[i].b*1.0/d[i].a;
		sum+=d[i].a;
	}
	if (p>=sum)
	{
		cout<<-1;
		return 0;
	}
	if (n==1)
	{
		cout<<d[0].b*1.0/(d[0].a-p);
		return 0;
	}
	sort(d,d+n,acompare);

	devices s;
	s.a=0;
	s.b=0;
	s.t=d[0].t;
	int i=0;
	while(d[i].t==s.t){
		s.a+=d[i].a;
		s.b+=d[i].b;
		i++;
		if (i==n)
		{
			break;
		}
	}

	if (i<n)
	{

		while((p>=s.a)||(d[i].t<(s.b/(s.a-p)))||(d[i].t==d[i-1].t)){
			s.a+=d[i].a;
			s.b+=d[i].b;
			i++;
			if (i==n)
			{
				break;
			}
		}
	}
	double x =1;

	long long int xx=s.a-p;
	long long int ans=s.b;
	double xxx=x*ans/xx;
	if ((xxx>.99980)&&(xxx<.99982))
	{
		cout<<ans<<"  "<<xx<<" "<<p<< endl;
	}
	cout<<xxx;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct devices{
	long long int a;
	long long int b;
	double t;
};

bool acompare(devices lhs, devices rhs) { return lhs.t < rhs.t; }

int main(){
	int n,p;
	cin>>n>>p;
	devices d[n];
	long long int sum=0;

	for (int i = 0; i < n; ++i)
	{
		cin>>d[i].a>>d[i].b;
		d[i].t=d[i].b*1.0/d[i].a;
		sum+=d[i].a;
	}
	if (p>=sum)
	{
		cout<<-1;
		return 0;
	}
	if (n==1)
	{
		cout<<d[0].b*1.0/(d[0].a-p);
		return 0;
	}
	sort(d,d+n,acompare);

	devices s;
	s.a=0;
	s.b=0;
	s.t=d[0].t;
	int i=0;
	while(d[i].t==s.t){
		s.a+=d[i].a;
		s.b+=d[i].b;
		i++;
		if (i==n)
		{
			break;
		}
	}

	if (i<n)
	{

		while((p>=s.a)||(d[i].t<(xxx)||(d[i].t==d[i-1].t)){
			s.a+=d[i].a;
			s.b+=d[i].b;
			i++;
			if (i==n)
			{
				break;
			}
			double x =1;

			long long int xx=s.a-p;
			long long int ans=s.b;
			double xxx=x*ans/xx;
		}
	}
	double x =1;

	long long int xx=s.a-p;
	long long int ans=s.b;
	double xxx=x*ans/xx;
	if ((xxx>.99980)&&(xxx<.99982))
	{
		cout<<d[i].t<<"  "<<(s.b/(s.a-p))<<" "<<p<< endl;
	}
	cout<<xxx;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct devices{
	long long int a;
	long long int b;
	double t;
};

bool acompare(devices lhs, devices rhs) { return lhs.t < rhs.t; }

int main(){
	int n,p;
	cin>>n>>p;
	devices d[n];
	long long int sum=0;

	for (int i = 0; i < n; ++i)
	{
		cin>>d[i].a>>d[i].b;
		d[i].t=d[i].b*1.0/d[i].a;
		sum+=d[i].a;
	}
	if (p>=sum)
	{
		cout<<-1;
		return 0;
	}
	if (n==1)
	{
		cout<<d[0].b*1.0/(d[0].a-p);
		return 0;
	}
	sort(d,d+n,acompare);

	devices s;
	s.a=0;
	s.b=0;
	s.t=d[0].t;
	int i=0;
	while(d[i].t==s.t){
		s.a+=d[i].a;
		s.b+=d[i].b;
		i++;
		if (i==n)
		{
			break;
		}
	}

	if (i<n)
	{

		while((p>=s.a)||(d[i].t<(s.b/(s.a-p)))||(d[i].t==d[i-1].t)){
			s.a+=d[i].a;
			s.b+=d[i].b;
			i++;
			if (i==n)
			{
				break;
			}
		}
	}
	double x =1;

	long long int xx=s.a-p;
	long long int ans=s.b;
	double xxx=x*ans/xx;
	if (xxx==.999806)
	{
		cout<<ans<<"  "<<xx<<" "<<i<< endl;
	}
	cout<<xxx;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct devices{
	long long int a;
	long long int b;
	double t;
};

bool acompare(devices lhs, devices rhs) { return lhs.t < rhs.t; }

int main(){
	int n,p;
	cin>>n>>p;
	devices d[n];
	long long int xx,ans,sum=0;

	for (int i = 0; i < n; ++i)
	{
		cin>>d[i].a>>d[i].b;
		d[i].t=d[i].b*1.0/d[i].a;
		sum+=d[i].a;
	}
	if (p>=sum)
	{
		cout<<-1;
		return 0;
	}
	if (n==1)
	{
		cout<<d[0].b*1.0/(d[0].a-p);
		return 0;
	}
	sort(d,d+n,acompare);

	devices s;
	s.a=0;
	s.b=0;
	s.t=d[0].t;
	int i=0;
	while(d[i].t==s.t){
		s.a+=d[i].a;
		s.b+=d[i].b;
		i++;
		if (i==n)
		{
			break;
		}
	}
	double x,xxx;
	x =1;

			 xx=s.a-p;
			ans=s.b;
			xxx=x*ans/xx;
	if (i<n)
	{

		while((p>=s.a)||(d[i].t<(xxx))||(d[i].t==d[i-1].t)){
			s.a+=d[i].a;
			s.b+=d[i].b;
			i++;
			if (i==n)
			{
				break;
			}
			x =1;

			 xx=s.a-p;
			ans=s.b;
			xxx=x*ans/xx;
		}
	}
	 x =1;

	 xx=s.a-p;
	ans=s.b;
	xxx=x*ans/xx;
	if ((xxx>.99980)&&(xxx<.99982))
	{
		cout<<d[i].t<<"  "<<(s.b/(s.a-p))<<" "<<p<< endl;
	}
	cout<<xxx;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct devices{
	long long int a;
	long long int b;
	double t;
};

bool acompare(devices lhs, devices rhs) { return lhs.t < rhs.t; }

int main(){
	int n,p;
	cin>>n>>p;
	devices d[n];
	long long int sum=0;

	for (int i = 0; i < n; ++i)
	{
		cin>>d[i].a>>d[i].b;
		d[i].t=d[i].b*1.0/d[i].a;
		sum+=d[i].a;
	}
	if (p>=sum)
	{
		cout<<-1;
		return 0;
	}
	if (n==1)
	{
		cout<<d[0].b*1.0/(d[0].a-p);
		return 0;
	}
	sort(d,d+n,acompare);

	devices s;
	s.a=0;
	s.b=0;
	s.t=d[0].t;
	int i=0;
	while(d[i].t==s.t){
		s.a+=d[i].a;
		s.b+=d[i].b;
		i++;
		if (i==n)
		{
			break;
		}
	}

	if (i<n)
	{

		while((p>=s.a)||(d[i].t<(s.b/(s.a-p)))||(d[i].t==d[i-1].t)){
			s.a+=d[i].a;
			s.b+=d[i].b;
			i++;
			if (i==n)
			{
				break;
			}
		}
	}
	double x =1;

	long long int xx=s.a-p;
	long long int ans=s.b;
	double xxx=x*ans/xx;
	if ((xxx>.99980)&&(xxx<.99982))
	{
		cout<<ans<<"  "<<s.a<<" "<<p<< endl;
	}
	cout<<xxx;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct devices{
	long long int a;
	long long int b;
	double t;
};

bool acompare(devices lhs, devices rhs) { return lhs.t < rhs.t; }

int main(){
	int n,p;
	cin>>n>>p;
	devices d[n];
	long long int xx,ans,sum=0;

	for (int i = 0; i < n; ++i)
	{
		cin>>d[i].a>>d[i].b;
		d[i].t=d[i].b*1.0/d[i].a;
		sum+=d[i].a;
	}
	if (p>=sum)
	{
		cout<<-1;
		return 0;
	}
	if (n==1)
	{
		cout<<d[0].b*1.0/(d[0].a-p);
		return 0;
	}
	sort(d,d+n,acompare);

	devices s;
	s.a=0;
	s.b=0;
	s.t=d[0].t;
	int i=0;
	while(d[i].t==s.t){
		s.a+=d[i].a;
		s.b+=d[i].b;
		i++;
		if (i==n)
		{
			break;
		}
	}
	double x,xxx;
	if (i<n)
	{

		while((p>=s.a)||(d[i].t<(xxx))||(d[i].t==d[i-1].t)){
			s.a+=d[i].a;
			s.b+=d[i].b;
			i++;
			if (i==n)
			{
				break;
			}
			x =1;

			 xx=s.a-p;
			ans=s.b;
			xxx=x*ans/xx;
		}
	}
	double x =1;

	long long int xx=s.a-p;
	long long int ans=s.b;
	double xxx=x*ans/xx;
	if ((xxx>.99980)&&(xxx<.99982))
	{
		cout<<d[i].t<<"  "<<(s.b/(s.a-p))<<" "<<p<< endl;
	}
	cout<<xxx;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct devices{
	long long int a;
	long long int b;
	double t;
};

bool acompare(devices lhs, devices rhs) { return lhs.t < rhs.t; }

int main(){
	int n,p;
	cin>>n>>p;
	devices d[n];
	long long int sum=0;

	for (int i = 0; i < n; ++i)
	{
		cin>>d[i].a>>d[i].b;
		d[i].t=d[i].b*1.0/d[i].a;
		sum+=d[i].a;
	}
	if (p>=sum)
	{
		cout<<-1;
		return 0;
	}
	if (n==1)
	{
		cout<<d[0].b*1.0/(d[0].a-p);
		return 0;
	}
	sort(d,d+n,acompare);

	devices s;
	s.a=0;
	s.b=0;
	s.t=d[0].t;
	int i=0;
	while(d[i].t==s.t){
		s.a+=d[i].a;
		s.b+=d[i].b;
		i++;
		if (i==n)
		{
			break;
		}
	}

	if (i<n)
	{

		while((p>=s.a)||(d[i].t<(s.b/(s.a-p)))||(d[i].t==d[i-1].t)){
			s.a+=d[i].a;
			s.b+=d[i].b;
			i++;
			if (i==n)
			{
				break;
			}
		}
	}
	double x =1;

	long long int xx=s.a-p;
	long long int ans=s.b;
	double xxx=x*ans/xx;
	if ((xxx>.99980)&&(xxx<.99982))
	{
		cout<<d[i].t<<"  "<<(s.b/(s.a-p))<<" "<<p<< endl;
	}
	cout<<xxx;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct devices{
	long long int a;
	long long int b;
	double t;
};

bool acompare(devices lhs, devices rhs) { return lhs.t < rhs.t; }

int main(){
	int n,p;
	cin>>n>>p;
	devices d[n];
	long long int xx,ans,sum=0;

	for (int i = 0; i < n; ++i)
	{
		cin>>d[i].a>>d[i].b;
		d[i].t=d[i].b*1.0/d[i].a;
		sum+=d[i].a;
	}
	if (p>=sum)
	{
		cout<<-1;
		return 0;
	}
	if (n==1)
	{
		cout<<d[0].b*1.0/(d[0].a-p);
		return 0;
	}
	sort(d,d+n,acompare);

	devices s;
	s.a=0;
	s.b=0;
	s.t=d[0].t;
	int i=0;
	while(d[i].t==s.t){
		s.a+=d[i].a;
		s.b+=d[i].b;
		i++;
		if (i==n)
		{
			break;
		}
	}
	double x,xxx;
	if (i<n)
	{

		while((p>=s.a)||(d[i].t<(xxx))||(d[i].t==d[i-1].t)){
			s.a+=d[i].a;
			s.b+=d[i].b;
			i++;
			if (i==n)
			{
				break;
			}
			x =1;

			 xx=s.a-p;
			ans=s.b;
			xxx=x*ans/xx;
		}
	}
	 x =1;

	 xx=s.a-p;
	ans=s.b;
	xxx=x*ans/xx;
	if ((xxx>.99980)&&(xxx<.99982))
	{
		cout<<d[i].t<<"  "<<(s.b/(s.a-p))<<" "<<p<< endl;
	}
	cout<<xxx;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct devices{
	long long int a;
	long long int b;
	double t;
};

bool acompare(devices lhs, devices rhs) { return lhs.t < rhs.t; }

int main(){
	long long int n,p;
	cin>>n>>p;
	devices d[n];
	long long int sum=0;

	for (int i = 0; i < n; ++i)
	{
		cin>>d[i].a>>d[i].b;
		d[i].t=d[i].b*1.0/d[i].a;
		sum+=d[i].a;
	}
	if (p>=sum)
	{
		cout<<-1;
		return 0;
	}
	if (n==1)
	{
		cout<<d[0].b*1.0/(d[0].a-p);
		return 0;
	}
	sort(d,d+n,acompare);

	devices s;
	s.a=0;
	s.b=0;
	s.t=d[0].t;
	int i=0;
	while(d[i].t==s.t){
		s.a+=d[i].a;
		s.b+=d[i].b;
		i++;
		if (i==n)
		{
			break;
		}
	}

	if (i<n)
	{

		while((p>=s.a)||(d[i].t<(s.b/(s.a-p)))||(d[i].t==d[i-1].t)){
			s.a+=d[i].a;
			s.b+=d[i].b;
			i++;
			if (i==n)
			{
				break;
			}
		}
	}
	double x =1;

	long long int xx=s.a-p;
	long long int ans=s.b;
	double xxx=x*ans/xx;

	cout<<xxx;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct devices{
	long long int a;
	long long int b;
	double t;
};

bool acompare(devices lhs, devices rhs) { return lhs.t < rhs.t; }

int main(){
	int n,p;
	cin>>n>>p;
	devices d[n];
	long long int xx,ans,sum=0;

	for (int i = 0; i < n; ++i)
	{
		cin>>d[i].a>>d[i].b;
		d[i].t=d[i].b*1.0/d[i].a;
		sum+=d[i].a;
	}
	if (p>=sum)
	{
		cout<<-1;
		return 0;
	}
	if (n==1)
	{
		cout<<d[0].b*1.0/(d[0].a-p);
		return 0;
	}
	sort(d,d+n,acompare);

	devices s;
	s.a=0;
	s.b=0;
	s.t=d[0].t;
	int i=0;
	while(d[i].t==s.t){
		s.a+=d[i].a;
		s.b+=d[i].b;
		i++;
		if (i==n)
		{
			break;
		}
	}
	double,x,xxx
	if (i<n)
	{

		while((p>=s.a)||(d[i].t<(xxx))||(d[i].t==d[i-1].t)){
			s.a+=d[i].a;
			s.b+=d[i].b;
			i++;
			if (i==n)
			{
				break;
			}
			x =1;

			 xx=s.a-p;
			ans=s.b;
			xxx=x*ans/xx;
		}
	}
	double x =1;

	long long int xx=s.a-p;
	long long int ans=s.b;
	double xxx=x*ans/xx;
	if ((xxx>.99980)&&(xxx<.99982))
	{
		cout<<d[i].t<<"  "<<(s.b/(s.a-p))<<" "<<p<< endl;
	}
	cout<<xxx;

	return 0;
}


#include <bits/stdc++.h>
using namespace std;

struct devices{
	int a;
	int b;
	double t;
};

bool acompare(devices lhs, devices rhs) { return lhs.t < rhs.t; }

int main(){
	int n,p;
	cin>>n>>p;
	devices d[n];
	long long int sum=0;

	for (int i = 0; i < n; ++i)
	{
		cin>>d[i].a>>d[i].b;
		d[i].t=d[i].b*1.0/d[i].a;
		sum+=d[i].a;
	}
	if (p>=sum)
	{
		cout<<-1;
		return 0;
	}
	if (n==1)
	{
		cout<<d[0].b*1.0/(d[0].a-p);
		return 0;
	}
	sort(d,d+n,acompare);

	devices s;
	s.a=0;
	s.b=0;
	s.t=d[0].t;
	int i=0;
	while(d[i].t==s.t){
		s.a+=d[i].a;
		s.b+=d[i].b;
		i++;
		if (i==n)
		{
			break;
		}
	}

	if (i<n)
	{

		while((p>=s.a)||(d[i].t<(s.b/(s.a-p)))||(d[i].t==d[i-1].t)){
			s.a+=d[i].a;
			s.b+=d[i].b;
			i++;
			if (i==n)
			{
				break;
			}
		}
	}
	double x =1;

	long long int xx=s.a-p;
	long long int ans=s.b;
	double xxx=x*ans/xx;
	if (xxx>100000000)
	{
		cout<<ans<<"  "<<xx<<" "<<i<< endl;
	}
	cout<<xxx;

	return 0;
}


/*
    ��n���豸
    ����ͬʱʹ��
    ��i���豸ÿ��������ai�����,һ��ʼ��bi�����
    ����һ�������,ÿ���ӿ��Գ�p�����
    ���û�г�����Ļ�����
    ʱ�����min(bi/ai);
    һ��ʼ��bi/ai��С���Ǹ�
    Ȼ����xʱ��֮��
    �����bi-x*(ai-p)
    ��Ϊy
    ���y/ai
    �͵ڶ�С��ai/biһ����
    ����ʱ��t

    �����Ϊtemp=t*p
    ÿһ���豸
        now = bi-ai*t
        ���
        now<0
            if (temp<now)
                return false;
            else
                temp-=now;
        return true;
*/
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) cin >> x
#define pri(x) cout << x
#define ms(x,y) memset(x,y,sizeof x)

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e5+100;

int n;
double p,a[N],b[N];
bool fi = false;

bool ok(double t)
{
    double temp = t*p;
    rep1(i,1,n)
    {
        double now = b[i]-t*a[i];
        if (now>=0) continue;
        //now<0
        if (temp+now<0) return false;
        temp+=now;
    }
    return true;
}

int main()
{
    //freopen("F:\\rush.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin >>n>>p;
    rep1(i,1,n)
    {
        cin >> a[i] >> b[i];
        if (a[i]>p) fi = true;
    }
    if (!fi)
    {
        puts("-1");
        return 0;
    }
    double l = 0,r = 1e18,ans;
    while (fabs(r-l)>=1e-10)
    {
        double m = (l+r)/2.0;
        if (ok(m))
        {
            ans = m;
            l = m;
        }
        else
            r = m;
    }
    if (ans>1e16)
        return puts("-1"),0;
    printf("%.9f\n",ans);
    //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) cin >> x
#define pri(x) cout << x
#define ms(x,y) memset(x,y,sizeof x)

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e5+100;

int n,cnt = 0;
double p,a[N],b[N];
bool fi = false;

bool ok(double t)
{
    double temp = t*p;
    rep1(i,1,n)
    {
        double now = b[i]-t*a[i];
        if (now>=0) continue;
        //now<0
        if (temp+now<0) return false;
        temp+=now;
    }
    return true;
}

int main()
{
    //freopen("F:\\rush.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin >>n>>p;
    rep1(i,1,n)
        cin >> a[i] >> b[i];
    double l = 0,r = 1e11,ans;
    if (ok(r))
    {
        return puts("-1"),0;
    }
    while (1)
    {
        cnt++;
        double m = (l+r)/2.0;
        if (ok(m))
        {
            ans = m;
            l = m;
        }
        else
            r = m;
        if (cnt==300) break;
    }
    printf("%.9f\n",ans);
    //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) cin >> x
#define pri(x) cout << x
#define ms(x,y) memset(x,y,sizeof x)

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e5+100;

int n,cnt = 0;
double p,a[N],b[N];
bool fi = false;

bool ok(double t)
{
    double temp = t*p;
    rep1(i,1,n)
    {
        double now = b[i]-t*a[i];
        if (now>=0) continue;
        //now<0
        if (temp+now<0) return false;
        temp+=now;
    }
    return true;
}

int main()
{
    //freopen("F:\\rush.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin >>n>>p;
    rep1(i,1,n)
        cin >> a[i] >> b[i];
    double l = 0,r = 1e12,ans;
    if (ok(r))
    {
        return puts("-1"),0;
    }
    while (1)
    {
        cnt++;
        double m = (l+r)/2.0;
        if (ok(m))
        {
            ans = m;
            l = m;
        }
        else
            r = m;
        if (cnt==300) break;
    }
    printf("%.9f\n",ans);
    //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
    return 0;
}


/*
    ��n���豸
    ����ͬʱʹ��
    ��i���豸ÿ��������ai�����,һ��ʼ��bi�����
    ����һ�������,ÿ���ӿ��Գ�p�����
    ���û�г�����Ļ�����
    ʱ�����min(bi/ai);
    һ��ʼ��bi/ai��С���Ǹ�
    Ȼ����xʱ��֮��
    �����bi-x*(ai-p)
    ��Ϊy
    ���y/ai
    �͵ڶ�С��ai/biһ����
    ����ʱ��t

    �����Ϊtemp=t*p
    ÿһ���豸
        now = bi-ai*t
        ���
        now<0
            if (temp<now)
                return false;
            else
                temp-=now;
        return true;
*/
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) cin >> x
#define pri(x) cout << x
#define ms(x,y) memset(x,y,sizeof x)

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e5+100;

int n;
double p,a[N],b[N];
bool fi = false;

bool ok(double t)
{
    double temp = t*p;
    rep1(i,1,n)
    {
        double now = b[i]-t*a[i];
        if (now>=0) continue;
        //now<0
        if (temp+now<0) return false;
        temp+=now;
    }
    return true;
}

int main()
{
    //freopen("F:\\rush.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin >>n>>p;
    rep1(i,1,n)
    {
        cin >> a[i] >> b[i];
        if (a[i]>p) fi = true;
    }
    if (!fi)
    {
        puts("-1");
        return 0;
    }
    double l = 0,r = 1e18,ans;
    while (fabs(r-l)>=1e-10)
    {
        double m = (l+r)/2.0;
        if (ok(m))
        {
            ans = m;
            l = m;
        }
        else
            r = m;
    }
    printf("%.9f\n",ans);
    //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) cin >> x
#define pri(x) cout << x
#define ms(x,y) memset(x,y,sizeof x)

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e5+100;

int n,cnt = 0;
double p,a[N],b[N];
bool fi = false;

bool ok(double t)
{
    double temp = t*p;
    rep1(i,1,n)
    {
        double now = b[i]-t*a[i];
        if (now>=0) continue;
        //now<0
        if (temp+now<0) return false;
        temp+=now;
    }
    return true;
}

int main()
{
    //freopen("F:\\rush.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin >>n>>p;
    rep1(i,1,n)
        cin >> a[i] >> b[i];
    double l = 0,r = 1e18,ans;
    while (1)
    {
        cnt++;
        double m = (l+r)/2.0;
        if (ok(m))
        {
            ans = m;
            l = m;
        }
        else
            r = m;
        if (cnt==300) break;
    }
    if (ans>1e16)
        return puts("-1"),0;
    printf("%.9f\n",ans);
    //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) cin >> x
#define pri(x) cout << x
#define ms(x,y) memset(x,y,sizeof x)

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e5+100;

int n,cnt = 0;
double p,a[N],b[N];
bool fi = false;

bool ok(double t)
{
    double temp = t*p;
    rep1(i,1,n)
    {
        double now = b[i]-t*a[i];
        if (now>=0) continue;
        //now<0
        if (temp+now<0) return false;
        temp+=now;
    }
    return true;
}

int main()
{
    //freopen("F:\\rush.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin >>n>>p;
    rep1(i,1,n)
        cin >> a[i] >> b[i];
    double l = 0,r = 1e18,ans;
    while (1)
    {
        cnt++;
        double m = (l+r)/2.0;
        if (ok(m))
        {
            ans = m;
            l = m;
        }
        else
            r = m;
        if (cnt==300) break;
    }
    if (ans>1e9+1000)
        return puts("-1"),0;
    printf("%.9f\n",ans);
    //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) cin >> x
#define pri(x) cout << x
#define ms(x,y) memset(x,y,sizeof x)

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e5+100;

int n,cnt = 0;
double p,a[N],b[N];
bool fi = false;

bool ok(long double t)
{
    long double temp = t*p;
    rep1(i,1,n)
    {
        double now = b[i]-t*a[i];
        if (now>=0) continue;
        //now<0
        if (temp+now<0) return false;
        temp+=now;
    }
    return true;
}

int main()
{
    //freopen("F:\\rush.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin >>n>>p;
    rep1(i,1,n)
        cin >> a[i] >> b[i];
    long double l = 0,r = 1e18,ans;
    if (ok(r))
    {
        return puts("-1"),0;
    }
    while (1)
    {
        cnt++;
        long double m = (l+r)/2.0;
        if (ok(m))
        {
            ans = m;
            l = m;
        }
        else
            r = m;
        if (cnt==300) break;
    }
    cout << setprecision(9)<<ans<<endl;
    //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) cin >> x
#define pri(x) cout << x
#define ms(x,y) memset(x,y,sizeof x)

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e5+100;

int n,cnt = 0;
double p,a[N],b[N];
bool fi = false;

bool ok(double t)
{
    double temp = t*p;
    rep1(i,1,n)
    {
        double now = b[i]-t*a[i];
        if (now>=0) continue;
        //now<0
        if (temp+now<0) return false;
        temp+=now;
    }
    return true;
}

int main()
{
    //freopen("F:\\rush.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin >>n>>p;
    rep1(i,1,n)
        cin >> a[i] >> b[i];
    double l = 0,r = 1e18,ans;
    if (ok(r))
    {
        return puts("-1"),0;
    }
    while (1)
    {
        cnt++;
        double m = (l+r)/2.0;
        if (ok(m))
        {
            ans = m;
            l = m;
        }
        else
            r = m;
        if (cnt==300) break;
    }
    printf("%.9f\n",ans);
    //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) cin >> x
#define pri(x) cout << x
#define ms(x,y) memset(x,y,sizeof x)

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e5+100;

int n,cnt = 0;
double p,a[N],b[N];
bool fi = false;

bool ok(long double t)
{
    long double temp = t*p;
    rep1(i,1,n)
    {
        double now = b[i]-t*a[i];
        if (now>=0) continue;
        //now<0
        if (temp+now<0) return false;
        temp+=now;
    }
    return true;
}

int main()
{
    //freopen("F:\\rush.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin >>n>>p;
    rep1(i,1,n)
        cin >> a[i] >> b[i];
    long double l = 0,r = 1e11,ans;
    if (ok(r))
    {
        return puts("-1"),0;
    }
    while (1)
    {
        cnt++;
        long double m = (l+r)/2.0;
        if (ok(m))
        {
            ans = m;
            l = m;
        }
        else
            r = m;
        if (cnt==300) break;
    }
    cout << setprecision(9)<<ans<<endl;
    //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
    return 0;
}


/*
    ��n���豸
    ����ͬʱʹ��
    ��i���豸ÿ��������ai�����,һ��ʼ��bi�����
    ����һ�������,ÿ���ӿ��Գ�p�����
    ���û�г�����Ļ�����
    ʱ�����min(bi/ai);
    һ��ʼ��bi/ai��С���Ǹ�
    Ȼ����xʱ��֮��
    �����bi-x*(ai-p)
    ��Ϊy
    ���y/ai
    �͵ڶ�С��ai/biһ����
    ����ʱ��t

    �����Ϊtemp=t*p
    ÿһ���豸
        now = bi-ai*t
        ���
        now<0
            if (temp<now)
                return false;
            else
                temp-=now;
        return true;
*/
#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) cin >> x
#define pri(x) cout << x
#define ms(x,y) memset(x,y,sizeof x)

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e5+100;

int n;
double p,a[N],b[N];
bool fi = false;

bool ok(double t)
{
    double temp = t*p;
    rep1(i,1,n)
    {
        double now = b[i]-t*a[i];
        if (now>=0) continue;
        //now<0
        if (temp+now<0) return false;
        temp+=now;
    }
    return true;
}

int main()
{
    //freopen("F:\\rush.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin >>n>>p;
    rep1(i,1,n)
        cin >> a[i] >> b[i];
    double l = 0,r = 1e18,ans;
    while (fabs(r-l)>=1e-10)
    {
        double m = (l+r)/2.0;
        if (ok(m))
        {
            ans = m;
            l = m;
        }
        else
            r = m;
    }
    if (ans>1e16)
        return puts("-1"),0;
    printf("%.9f\n",ans);
    //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define ps push_back
#define fi first
#define se second
#define rei(x) cin >> x
#define pri(x) cout << x
#define ms(x,y) memset(x,y,sizeof x)

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e5+100;

int n,cnt = 0;
double p,a[N],b[N];
bool fi = false;

bool ok(long double t)
{
    long double temp = t*p;
    rep1(i,1,n)
    {
        double now = b[i]-t*a[i];
        if (now>=0) continue;
        //now<0
        if (temp+now<0) return false;
        temp+=now;
    }
    return true;
}

int main()
{
    //freopen("F:\\rush.txt","r",stdin);
    ios::sync_with_stdio(false);
    cin >>n>>p;
    rep1(i,1,n)
        cin >> a[i] >> b[i];
    long double l = 0,r = 1e18,ans;
    if (ok(r))
    {
         return puts("-1"),0;
    }
    while (1)
    {
        cnt++;
        long double m = (l+r)/2.0;
        if (ok(m))
        {
            ans = m;
            l = m;
        }
        else
            r = m;
        if (cnt==300) break;
    }
    cout << setprecision(9)<<ans<<endl;
    //printf("\n%.2lf sec \n", (double)clock() / CLOCKS_PER_SEC);
    return 0;
}