Buggy python submission (verdict: Runtime Error):
# ABC057 D - Maximum Average Sets
from collections import defaultdict
from math import factorial
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
def perm(n,r):
    return factorial(n)//factorial(n-r)

def comb(n,r):
    return perm(n,r)//factorial(r)

n,a,b=nm()
V=nl()

d=defaultdict(int)
for vv in V:
    d[vv]+=1

value=0
cnt=0
ans=0

V=list(set(V))
if len(V)==1:
    print(V[0])
    print(2**(b-a+1)-1)
    exit()

for k,v in sorted(d.items(),key=lambda x:x[0],reverse=True):
    if a>=v:
        value+=k*v
        cnt+=v
        a-=v
        b-=v
    elif a<v:
        if a==0 and v==1:
            one_flg=True
        for i in range(a,min(b,v)):
            value+=k*a
            cnt+=a
            nn=v
            kk=a
            ans=comb(nn, kk)
        break
if one_flg:
    ans=1
print(value/cnt)
print(ans)


Fixed submission:
# ABC057 D - Maximum Average Sets
from collections import defaultdict
from math import factorial
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
def perm(n,r):
    return factorial(n)//factorial(n-r)
 
def comb(n,r):
    return perm(n,r)//factorial(r)

n,a,b=nm()
v=sorted(nl(), reverse=True)

if v[0]==v[a-1]:
    n = 0
    for vv in v:
        if vv!=v[0]: break
        n += 1

    ans = 0
    for k in range(a, min(b,n)+1):
        ans += comb(n, k)

else:
    n = k = 0
    for i,vv in enumerate(v):
        if vv==v[a-1]:
            if i<a: k += 1
            n += 1
    ans = comb(n,k)

print(sum(v[:a])/a)
print(ans)

Buggy python submission (verdict: Runtime Error):
# ABC057 D - Maximum Average Sets
from collections import defaultdict
from math import factorial
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
def perm(n,r):
    return factorial(n)//factorial(n-r)

def comb(n,r):
    return perm(n,r)//factorial(r)

n,a,b=nm()
V=nl()

d=defaultdict(int)
for vv in V:
    d[vv]+=1

value=0
cnt=0
ans=0
one_flg=False

V=list(set(V))
if len(V)==1:
    print(V[0])
    print(2**(b-a+1)-1)
    exit()

for k,v in sorted(d.items(),key=lambda x:x[0],reverse=True):
    if a>=v:
        value+=k*v
        cnt+=v
        a-=v
        b-=v
    elif a<v:
        if a==0 and v==1:
            one_flg=True
        elif b==v and b!=0:
            print(k)
            print(2**b-1)
            exit()
        else:
            for i in range(a,b+1):
                value+=k*i
                cnt+=i
                nn=v
                kk=i
                ans+=comb(nn, kk)
            break

if one_flg:
    ans=1
print(value/cnt)
print(ans)

Fixed submission:
# ABC057 D - Maximum Average Sets
from collections import defaultdict
from math import factorial
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
def perm(n,r):
    return factorial(n)//factorial(n-r)
 
def comb(n,r):
    return perm(n,r)//factorial(r)

n,a,b=nm()
v=sorted(nl(), reverse=True)

if v[0]==v[a-1]:
    n = 0
    for vv in v:
        if vv!=v[0]: break
        n += 1

    ans = 0
    for k in range(a, min(b,n)+1):
        ans += comb(n, k)

else:
    n = k = 0
    for i,vv in enumerate(v):
        if vv==v[a-1]:
            if i<a: k += 1
            n += 1
    ans = comb(n,k)

print(sum(v[:a])/a)
print(ans)

Buggy python submission (verdict: Runtime Error):
# ABC057 D - Maximum Average Sets
from collections import defaultdict
from math import factorial
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
def perm(n,r):
    return factorial(n)//factorial(n-r)

def comb(n,r):
    return perm(n,r)//factorial(r)

n,a,b=nm()
V=nl()

d=defaultdict(int)
for vv in V:
    d[vv]+=1

value=0
cnt=0
ans=0

V=list(set(V))
if len(V)==1:
    print(V[0])
    print(2**(b-a+1)-1)
    exit()

for k,v in sorted(d.items(),key=lambda x:x[0],reverse=True):
    if a==0:
        if b==v:
            print(k)
            print(2**b-1)
            exit()
        break
    elif a>=v:
        value+=k*v
        cnt+=v
        a-=v
        b-=v
    elif a<v:
        for i in range(a,b):
            value+=k*i
            cnt+=i
            nn=v
            kk=i
            ans=comb(nn, kk)
        break
print(value/cnt)
print(ans)






Fixed submission:
# ABC057 D - Maximum Average Sets
from collections import defaultdict
from math import factorial
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
def perm(n,r):
    return factorial(n)//factorial(n-r)
 
def comb(n,r):
    return perm(n,r)//factorial(r)

n,a,b=nm()
v=sorted(nl(), reverse=True)

if v[0]==v[a-1]:
    n = 0
    for vv in v:
        if vv!=v[0]: break
        n += 1

    ans = 0
    for k in range(a, min(b,n)+1):
        ans += comb(n, k)

else:
    n = k = 0
    for i,vv in enumerate(v):
        if vv==v[a-1]:
            if i<a: k += 1
            n += 1
    ans = comb(n,k)

print(sum(v[:a])/a)
print(ans)