Problem:


Score : 400 points

Problem Statement

You are given N items.

The value of the i-th item (1 \leq i \leq N) is v_i.

Your have to select at least A and at most B of these items.

Under this condition, find the maximum possible arithmetic mean of the values of selected items.

Additionally, find the number of ways to select items so that the mean of the values of selected items is maximized.  

Constraints

1 \leq N \leq 50

1 \leq A,B \leq N

1 \leq v_i \leq 10^{15}

Each v_i is an integer.

Input

The input is given from Standard Input in the following format:

N A B
v_1
v_2
...
v_N

Output

Print two lines.

The first line should contain the maximum possible arithmetic mean of the values of selected items. The output should be considered correct if the absolute or relative error is at most 10^{-6}.

The second line should contain the number of ways to select items so that the mean of the values of selected items is maximized.

Sample Input 1

5 2 2
1 2 3 4 5

Sample Output 1

4.500000
1

The mean of the values of selected items will be maximized when selecting the fourth and fifth items. Hence, the first line of the output should contain 4.5.

There is no other way to select items so that the mean of the values will be 4.5, and thus the second line of the output should contain 1.

Sample Input 2

4 2 3
10 20 10 10

Sample Output 2

15.000000
3

There can be multiple ways to select items so that the mean of the values will be maximized.

Sample Input 3

5 1 5
1000000000000000 999999999999999 999999999999998 999999999999997 999999999999996

Sample Output 3

1000000000000000.000000
1



Sample input:
5 2 2
1 2 3 4 5


Sample output:
4.500000
1

Submission status: Runtime Error

Solution code:
import statistics as stats
from math import factorial


class Comb:
    def __init__(self, N):
        super(Comb, self).__init__()
        self.dic = {(7, 3): 35, (31, 6): 736281, (46, 42): 163185, (42, 33): 445891810, (41, 13): 17620076360, (16, 9): 11440, (40, 22): 113380261800, (19, 4): 3876, (43, 3): 12341, (41, 23): 202112640600, (22, 19): 1540, (46, 12): 38910617655, (20, 7): 77520, (44, 4): 135751, (42, 20): 513791607420, (47, 9): 1362649145, (21, 6): 54264, (36, 34): 630, (43, 25): 608359048206, (8, 5): 56, (32, 2): 496, (37, 35): 666, (35, 15): 3247943160, (33, 3): 5456, (48, 37): 22595200368, (36, 8): 30260340, (10, 7): 120, (34, 8): 18156204, (49, 32): 6499270398159, (42, 10): 1471442973, (37, 13): 3562467300, (35, 21): 2319959400, (50, 39): 37353738800, (24, 14): 1961256, (14, 1): 14, (38, 2): 703, (36, 22): 3796297200, (25, 15): 3268760, (15, 4): 1365, (39, 11): 1676056044, (37, 23): 6107086800, (26, 12): 9657700, (50, 1): 50, (48, 17): 4244421484512, (29, 17): 51895935, (3, 2): 3, (27, 1): 27, (49, 28): 39049918716424, (30, 14): 145422675, (28, 10): 13123110, (50, 27): 108043253365600, (31, 15): 300540195, (46, 45): 46, (29, 11): 34597290, (40, 29): 2311801440, (30, 16): 145422675, (19, 13): 27132, (17, 13): 2380, (41, 24): 151584480450, (31, 21): 44352165, (46, 23): 8233430727600, (20, 14): 38760, (44, 3): 13244, (18, 10): 43758, (42, 31): 4280561376, (23, 19): 8855, (40, 35): 658008, (21, 15): 54264, (45, 2): 990, (43, 30): 36576848168, (43, 39): 123410, (32, 25): 3365856, (22, 12): 646646, (44, 25): 1408831480056, (33, 4): 40920, (23, 9): 817190, (38, 35): 8436, (45, 28): 1103068603890, (34, 3): 5984, (35, 26): 70607460, (24, 21): 2024, (14, 8): 3003, (38, 5): 501942, (12, 8): 495, (36, 29): 8347680, (25, 16): 2042975, (15, 13): 105, (41, 36): 749398, (37, 16): 12875774670, (40, 14): 23206929840, (26, 23): 2600, (48, 8): 377348994, (38, 31): 12620256, (27, 6): 296010, (49, 21): 39049918716424, (39, 30): 211915132, (28, 1): 28, (45, 9): 886163135, (5, 1): 5, (29, 4): 23751, (16, 7): 11440, (40, 4): 91390, (30, 27): 4060, (19, 18): 19, (17, 6): 12376, (41, 1): 41, (31, 18): 206253075, (46, 30): 991493848554, (42, 35): 26978328, (18, 5): 8568, (41, 15): 63432274896, (47, 31): 1503232609098, (21, 8): 203490, (34, 32): 561, (32, 16): 601080390, (22, 7): 170544, (44, 16): 416714805914, (33, 29): 40920, (23, 6): 100947, (45, 37): 215553195, (45, 21): 3773655750150, (10, 9): 10, (34, 26): 18156204, (39, 35): 82251, (11, 4): 330, (35, 3): 6545, (44, 34): 2481256778, (48, 41): 73629072, (12, 7): 792, (36, 4): 58905, (43, 42): 43, (15, 10): 3003, (13, 6): 1716, (37, 25): 1852482996, (24, 2): 276, (48, 15): 1093260079344, (38, 22): 22239974430, (25, 3): 2300, (49, 14): 675248872536, (39, 23): 37711260990, (28, 24): 20475, (50, 13): 354860518600, (45, 34): 10150595910, (49, 11): 29135916264, (6, 1): 6, (30, 2): 435, (45, 32): 73006209045, (7, 4): 35, (31, 27): 31465, (46, 33): 101766230790, (42, 1): 42, (40, 17): 88732378800, (21, 17): 5985, (19, 1): 19, (43, 12): 15338678264, (32, 23): 28048800, (46, 11): 13340783196, (35, 34): 35, (33, 22): 193536720, (47, 18): 4568648125690, (47, 2): 1081, (45, 14): 166871334960, (34, 21): 927983760, (32, 13): 347373600, (35, 8): 23535820, (33, 8): 13884156, (48, 32): 2254848913647, (36, 3): 7140, (34, 15): 1855967520, (49, 45): 211876, (37, 2): 666, (26, 25): 26, (50, 42): 536878650, (24, 9): 1307504, (48, 6): 12271512, (38, 9): 163011640, (27, 20): 888030, (25, 4): 12650, (49, 7): 85900584, (39, 12): 3910797436, (41, 38): 10660, (28, 23): 98280, (26, 3): 2600, (50, 4): 230300, (48, 28): 16735679449896, (29, 22): 1560780, (27, 10): 8436285, (49, 25): 63205303218876, (30, 5): 142506, (28, 13): 37442160, (45, 11): 10150595910, (46, 40): 9366819, (42, 8): 118030185, (16, 11): 4368, (40, 24): 62852101650, (44, 39): 1086008, (19, 6): 27132, (43, 5): 962598, (17, 10): 19448, (41, 21): 269128937220, (22, 17): 26334, (46, 18): 2818953098830, (20, 1): 20, (42, 37): 850668, (18, 17): 18, (42, 18): 353697121050, (23, 20): 1771, (47, 11): 17417133617, (21, 4): 5985, (45, 7): 45379620, (43, 27): 265182149218, (8, 7): 8, (32, 4): 35960, (22, 11): 705432, (37, 33): 66045, (44, 28): 416714805914, (9, 6): 84, (33, 1): 33, (48, 39): 1677106640, (47, 40): 62891499, (36, 10): 254186856, (10, 5): 252, (34, 6): 1344904, (49, 38): 29135916264, (37, 11): 854992152, (11, 8): 165, (35, 23): 834451800, (50, 37): 354860518600, (24, 16): 735471, (14, 7): 3432, (44, 33): 7669339132, (36, 16): 7307872110, (25, 13): 5200300, (15, 6): 5005, (39, 5): 575757, (37, 21): 12875774670, (26, 10): 5311735, (48, 19): 11541847896480, (38, 26): 2707475148, (27, 3): 2925, (47, 39): 314457495, (49, 18): 11554258485616, (30, 12): 86493225, (28, 4): 20475, (50, 25): 126410606437752, (31, 9): 20160075, (29, 9): 10015005, (16, 2): 120, (40, 31): 273438880, (30, 22): 5852925, (19, 15): 3876, (17, 3): 680, (41, 30): 3159461968, (31, 23): 7888725, (46, 21): 6943526580276, (20, 8): 125970, (18, 8): 43758, (33, 32): 33, (40, 37): 9880, (21, 13): 203490, (50, 12): 121399651100, (43, 16): 265182149218, (32, 27): 201376, (22, 2): 231, (43, 32): 5752004349, (44, 27): 686353797976, (33, 26): 4272048, (23, 11): 1352078, (38, 33): 501942, (45, 26): 2438362177020, (34, 1): 34, (39, 36): 9139, (11, 1): 11, (35, 28): 6724520, (24, 23): 24, (12, 10): 66, (36, 31): 376992, (44, 8): 177232627, (25, 22): 2300, (39, 2): 741, (13, 11): 78, (37, 30): 10295472, (26, 21): 65780, (48, 10): 6540715896, (38, 29): 163011640, (42, 40): 861, (27, 24): 2925, (47, 34): 140676848445, (39, 24): 25140840660, (41, 32): 350343565, (28, 3): 3276, (50, 16): 4923689695575, (29, 2): 406, (47, 33): 341643774795, (40, 6): 3838380, (30, 25): 142506, (17, 4): 2380, (41, 7): 22481940, (31, 28): 4495, (46, 28): 2818953098830, (18, 3): 816, (42, 4): 111930, (47, 25): 14833897694226, (47, 21): 12551759587422, (43, 9): 563921995, (32, 18): 471435600, (22, 5): 26334, (46, 6): 9366819, (42, 39): 11480, (33, 19): 818809200, (47, 7): 62891499, (47, 42): 1533939, (45, 19): 2438362177020, (34, 24): 131128140, (32, 8): 10518300, (11, 6): 462, (35, 5): 324632, (48, 43): 1712304, (12, 1): 12, (36, 6): 1947792, (49, 42): 85900584, (13, 4): 715, (37, 7): 10295472, (48, 44): 194580, (24, 4): 10626, (48, 1): 48, (38, 20): 33578000610, (27, 17): 8436285, (25, 1): 25, (49, 12): 92263734836, (39, 17): 51021117810, (28, 26): 378, (26, 6): 230230, (50, 11): 37353738800, (29, 27): 406, (47, 37): 5178066751, (40, 13): 12033222880, (7, 6): 7, (31, 5): 169911, (46, 39): 53524680, (47, 20): 9762479679106, (42, 15): 98672427616, (40, 19): 131282408400, (45, 39): 8145060, (19, 3): 969, (43, 14): 78378960360, (41, 18): 202112640600, (46, 9): 1101716330, (20, 4): 4845, (44, 9): 708930508, (33, 20): 573166440, (47, 12): 52251400851, (45, 12): 28760021745, (34, 19): 1855967520, (8, 2): 28, (32, 15): 565722720, (35, 10): 183579396, (9, 3): 84, (33, 14): 818809200, (47, 22): 14833897694226, (36, 13): 2310789600, (34, 13): 927983760, (49, 35): 675248872536, (35, 16): 4059928950, (45, 35): 3190187286, (24, 11): 2496144, (14, 2): 91, (38, 15): 15471286560, (27, 22): 80730, (25, 10): 3268760, (49, 5): 1906884, (39, 14): 15084504396, (28, 17): 21474180, (26, 1): 26, (50, 2): 1225, (48, 30): 7309837001104, (29, 20): 10015005, (3, 1): 3, (27, 12): 17383860, (49, 31): 11554258485616, (30, 11): 54627300, (41, 34): 22481940, (28, 15): 37442160, (40, 8): 76904685, (50, 28): 88749815264600, (31, 2): 465, (29, 14): 77558760, (16, 13): 560, (40, 26): 23206929840, (19, 8): 75582, (43, 7): 32224114, (17, 8): 24310, (41, 27): 35240152720, (46, 16): 991493848554, (20, 3): 1140, (18, 15): 816, (42, 16): 166509721602, (23, 22): 23, (40, 32): 76904685, (21, 2): 210, (45, 5): 1221759, (43, 29): 78378960360, (32, 6): 906192, (22, 9): 497420, (44, 30): 114955808528, (9, 4): 126, (33, 7): 4272048, (23, 12): 1352078, (45, 31): 166871334960, (10, 3): 120, (34, 4): 46376, (49, 36): 262596783764, (37, 9): 124403620, (11, 10): 11, (35, 25): 183579396, (50, 35): 2250829575120, (24, 18): 134596, (14, 5): 2002, (38, 6): 2760681, (36, 18): 9075135300, (25, 19): 177100, (39, 7): 15380937, (37, 19): 17672631900, (26, 8): 1562275, (44, 36): 177232627, (48, 21): 22314239266528, (38, 24): 9669554100, (27, 5): 80730, (44, 38): 7059052, (49, 16): 3348108992991, (39, 29): 635745396, (4, 1): 4, (28, 6): 376740, (50, 23): 108043253365600, (31, 11): 84672315, (5, 4): 5, (29, 7): 1560780, (16, 4): 1820, (40, 1): 40, (30, 20): 30045015, (19, 17): 171, (17, 1): 17, (41, 28): 17620076360, (31, 17): 265182525, (46, 27): 4154246671960, (20, 10): 184756, (18, 6): 18564, (42, 27): 98672427616, (47, 41): 10737573, (40, 39): 40, (21, 11): 352716, (43, 18): 608359048206, (32, 29): 4960, (44, 21): 2012616400080, (33, 24): 38567100, (23, 5): 33649, (47, 19): 6973199770790, (45, 24): 3773655750150, (34, 31): 5984, (39, 38): 39, (11, 3): 165, (35, 30): 324632, (14, 12): 91, (12, 4): 495, (36, 25): 600805296, (47, 5): 1533939, (25, 20): 53130, (15, 9): 5005, (13, 9): 715, (37, 28): 124403620, (26, 19): 657800, (48, 12): 69668534468, (38, 19): 35345263800, (27, 26): 27, (44, 12): 21090682613, (49, 9): 2054455634, (39, 26): 8122425444, (43, 23): 960566918220, (50, 14): 937845656300, (6, 2): 15, (44, 35): 708930508, (45, 41): 148995, (41, 5): 749398, (31, 30): 31, (46, 34): 38910617655, (20, 17): 1140, (18, 1): 18, (42, 2): 861, (47, 27): 9762479679106, (21, 20): 21, (43, 11): 5752004349, (32, 20): 225792840, (46, 4): 163185, (35, 33): 595, (33, 17): 1166803110, (23, 2): 253, (47, 1): 47, (45, 17): 1103068603890, (34, 22): 548354040, (32, 10): 64512240, (35, 7): 6724520, (33, 11): 193536720, (48, 45): 17296, (12, 3): 220, (45, 43): 990, (47, 44): 16215, (49, 40): 2054455634, (13, 2): 78, (37, 5): 435897, (50, 47): 19600, (24, 6): 134596, (48, 3): 17296, (38, 10): 472733756, (27, 19): 2220075, (25, 7): 480700, (49, 2): 1176, (39, 19): 68923264410, (28, 20): 3108105, (26, 4): 14950, (43, 33): 1917334783, (44, 42): 946, (48, 25): 30957699535776, (29, 25): 23751, (27, 9): 4686825, (6, 5): 6, (30, 6): 593775, (41, 14): 35240152720, (31, 7): 2629575, (46, 37): 1101716330, (42, 13): 25518731280, (16, 8): 12870, (40, 21): 131282408400, (19, 5): 11628, (41, 16): 103077446706, (22, 18): 7315, (46, 15): 511738760544, (20, 6): 38760, (44, 11): 7669339132, (42, 23): 446775310800, (47, 14): 341643774795, (21, 7): 116280, (36, 33): 7140, (34, 17): 2333606220, (8, 4): 70, (32, 1): 32, (37, 36): 37, (35, 12): 834451800, (9, 1): 9, (33, 12): 354817320, (48, 36): 69668534468, (36, 15): 5567902560, (10, 6): 210, (34, 11): 286097760, (49, 33): 3348108992991, (37, 14): 6107086800, (35, 18): 4537567650, (50, 38): 121399651100, (24, 13): 2496144, (38, 13): 5414950296, (36, 21): 5567902560, (25, 8): 1081575, (15, 5): 3003, (39, 8): 61523748, (28, 19): 6906900, (26, 15): 7726160, (48, 16): 2254848913647, (29, 18): 34597290, (27, 14): 20058300, (44, 18): 1029530696964, (49, 29): 28277527346376, (30, 9): 14307150, (28, 9): 6906900, (50, 26): 121548660036300, (31, 12): 141120525, (46, 44): 1035, (29, 12): 51895935, (41, 12): 7898654920, (16, 15): 16, (40, 28): 5586853480, (30, 19): 54627300, (19, 10): 92378, (17, 14): 680, (41, 25): 103077446706, (22, 21): 22, (46, 22): 7890371113950, (20, 13): 77520, (44, 2): 946, (18, 13): 8568, (42, 30): 11058116888, (23, 16): 245157, (40, 34): 3838380, (45, 3): 14190, (43, 31): 15338678264, (32, 24): 10518300, (22, 15): 170544, (45, 36): 886163135, (44, 24): 1761039350070, (43, 36): 32224114, (33, 5): 237336, (23, 14): 817190, (38, 34): 73815, (45, 29): 646626422970, (10, 1): 10, (34, 2): 561, (35, 27): 23535820, (50, 33): 9847379391150, (24, 20): 10626, (14, 11): 364, (38, 4): 73815, (36, 28): 30260340, (25, 17): 1081575, (15, 2): 105, (39, 1): 39, (37, 17): 15905368710, (26, 22): 14950, (48, 23): 30957699535776, (38, 30): 48903492, (27, 7): 888030, (49, 22): 49699896548176, (39, 31): 61523748, (4, 3): 4, (50, 21): 67327446062800, (44, 40): 135751, (5, 2): 10, (29, 5): 118755, (16, 6): 8008, (40, 3): 9880, (30, 26): 27405, (50, 9): 2505433700, (17, 7): 19448, (41, 2): 820, (31, 19): 141120525, (46, 25): 6943526580276, (18, 4): 3060, (42, 25): 254661927156, (47, 28): 6973199770790, (21, 9): 293930, (43, 20): 960566918220, (32, 31): 32, (22, 6): 74613, (46, 3): 15180, (44, 23): 2012616400080, (33, 30): 5456, (23, 7): 245157, (38, 37): 38, (45, 22): 4116715363800, (10, 8): 45, (34, 29): 278256, (39, 32): 15380937, (11, 5): 462, (48, 40): 377348994, (12, 6): 924, (36, 27): 94143280, (15, 11): 1365, (13, 7): 1716, (37, 26): 854992152, (40, 15): 40225345056, (26, 17): 3124550, (24, 1): 24, (48, 14): 482320623240, (38, 17): 28781143380, (49, 15): 1575580702584, (39, 20): 68923264410, (45, 8): 215553195, (47, 46): 47, (40, 10): 847660528, (30, 29): 30, (7, 5): 21, (31, 24): 2629575, (46, 32): 239877544005, (20, 19): 20, (42, 32): 1471442973, (47, 16): 1503232609098, (40, 16): 62852101650, (21, 18): 1330, (43, 13): 36576848168, (32, 22): 64512240, (46, 10): 4076350421, (44, 14): 114955808528, (33, 23): 92561040, (47, 3): 16215, (45, 15): 344867425584, (34, 20): 1391975640, (32, 12): 225792840, (35, 9): 70607460, (33, 9): 38567100, (48, 47): 48, (36, 2): 630, (34, 14): 1391975640, (49, 46): 18424, (37, 3): 7770, (26, 24): 325, (50, 45): 2118760, (24, 8): 735471, (48, 5): 1712304, (38, 8): 48903492, (27, 21): 296010, (25, 5): 53130, (39, 13): 8122425444, (45, 42): 14190, (28, 22): 376740, (2, 1): 2, (26, 2): 325, (50, 7): 99884400, (44, 32): 21090682613, (48, 27): 22314239266528, (29, 23): 475020, (27, 11): 13037895, (49, 26): 58343356817424, (30, 4): 27405, (43, 41): 903, (28, 12): 30421755, (7, 2): 21, (31, 1): 31, (46, 43): 15180, (42, 11): 4280561376, (16, 10): 8008, (40, 23): 88732378800, (19, 7): 50388, (43, 2): 903, (17, 11): 12376, (41, 22): 244662670200, (22, 16): 74613, (46, 13): 101766230790, (44, 5): 1086008, (18, 16): 153, (42, 21): 538257874440, (23, 21): 253, (47, 8): 314457495, (21, 5): 20349, (36, 35): 36, (43, 24): 800472431850, (8, 6): 28, (32, 3): 4960, (22, 10): 646646, (37, 34): 7770, (35, 14): 2319959400, (9, 7): 36, (33, 2): 528, (48, 38): 6540715896, (36, 9): 94143280, (10, 4): 210, (34, 9): 52451256, (49, 39): 8217822536, (37, 12): 1852482996, (11, 9): 55, (35, 20): 3247943160, (50, 36): 937845656300, (24, 15): 1307504, (14, 6): 3003, (38, 3): 8436, (36, 23): 2310789600, (25, 14): 4457400, (15, 7): 6435, (39, 10): 635745396, (41, 37): 101270, (37, 22): 9364199760, (26, 13): 10400600, (48, 18): 7309837001104, (29, 16): 67863915, (42, 6): 5245786, (49, 19): 18851684897584, (30, 15): 155117520, (28, 11): 21474180, (45, 10): 3190187286, (31, 14): 265182525, (29, 10): 20030010, (16, 1): 16, (40, 30): 847660528, (30, 17): 119759850, (19, 12): 50388, (43, 38): 962598, (17, 12): 6188, (41, 31): 1121099408, (31, 20): 84672315, (46, 20): 5608233007146, (20, 15): 15504, (42, 34): 118030185, (18, 11): 31824, (41, 8): 95548245, (23, 18): 33649, (40, 36): 91390, (21, 14): 116280, (45, 1): 45, (43, 17): 421171648758, (32, 26): 906192, (22, 13): 497420, (43, 35): 145008513, (44, 26): 1029530696964, (9, 8): 9, (33, 27): 1107568, (23, 8): 490314, (38, 32): 2760681, (45, 27): 1715884494940, (39, 37): 741, (35, 29): 1623160, (24, 22): 276, (14, 9): 2002, (12, 9): 220, (36, 30): 1947792, (25, 23): 300, (15, 12): 455, (39, 3): 9139, (13, 12): 13, (37, 31): 2324784, (26, 20): 230230, (48, 9): 1677106640, (38, 28): 472733756, (27, 25): 351, (47, 38): 1362649145, (49, 20): 28277527346376, (39, 25): 15084504396, (28, 2): 378, (47, 35): 52251400851, (50, 19): 30405943383200, (29, 3): 3654, (40, 5): 658008, (30, 24): 593775, (17, 5): 6188, (31, 29): 465, (46, 31): 511738760544, (43, 37): 6096454, (18, 2): 153, (42, 7): 26978328, (47, 30): 2741188875414, (47, 17): 2741188875414, (43, 40): 12341, (34, 33): 34, (32, 17): 565722720, (22, 4): 7315, (46, 1): 46, (44, 17): 686353797976, (33, 28): 237336, (23, 1): 23, (47, 4): 178365, (45, 20): 3169870830126, (34, 27): 5379616, (39, 34): 575757, (11, 7): 330, (35, 2): 595, (48, 42): 12271512, (36, 5): 376992, (25, 24): 25, (49, 43): 13983816, (13, 5): 1287, (37, 24): 3562467300, (50, 48): 1225, (24, 3): 2024, (38, 23): 15471286560, (42, 41): 42, (50, 24): 121548660036300, (25, 2): 300, (49, 13): 262596783764, (39, 22): 51021117810, (41, 39): 820, (28, 25): 3276, (40, 11): 2311801440, (50, 10): 10272278170, (29, 28): 29, (40, 12): 5586853480, (30, 3): 4060, (41, 9): 350343565, (31, 26): 169911, (46, 38): 260932815, (42, 14): 52860229080, (40, 18): 113380261800, (21, 16): 20349, (43, 15): 151532656696, (17, 16): 17, (41, 19): 244662670200, (46, 8): 260932815, (48, 34): 482320623240, (42, 36): 5245786, (33, 21): 354817320, (47, 13): 140676848445, (45, 13): 73006209045, (34, 18): 2203961430, (8, 1): 8, (32, 14): 471435600, (35, 11): 417225900, (33, 15): 1037158320, (48, 33): 1093260079344, (36, 12): 1251677700, (34, 12): 548354040, (49, 44): 1906884, (37, 1): 37, (35, 17): 4537567650, (50, 18): 18053528883775, (24, 10): 1961256, (48, 7): 73629072, (38, 14): 9669554100, (27, 23): 17550, (25, 11): 4457400, (49, 6): 13983816, (39, 15): 25140840660, (28, 16): 30421755, (50, 5): 2118760, (48, 29): 11541847896480, (29, 21): 4292145, (27, 13): 20058300, (47, 36): 17417133617, (49, 24): 63205303218876, (30, 10): 30045015, (28, 14): 40116600, (50, 31): 30405943383200, (31, 3): 4495, (46, 41): 1370754, (29, 15): 77558760, (42, 9): 445891810, (16, 12): 1820, (40, 25): 40225345056, (45, 38): 45379620, (19, 9): 92378, (43, 4): 123410, (17, 9): 24310, (41, 20): 269128937220, (46, 19): 4154246671960, (20, 2): 190, (44, 7): 38320568, (18, 14): 3060, (42, 19): 446775310800, (41, 10): 1121099408, (47, 10): 5178066751, (21, 3): 1330, (45, 6): 8145060, (43, 26): 421171648758, (32, 5): 201376, (22, 8): 319770, (37, 32): 435897, (44, 29): 229911617056, (9, 5): 126, (23, 13): 1144066, (36, 11): 600805296, (10, 2): 45, (34, 7): 5379616, (49, 37): 92263734836, (37, 10): 348330136, (35, 22): 1476337800, (50, 34): 4923689695575, (24, 17): 346104, (14, 4): 1001, (38, 1): 38, (50, 49): 50, (36, 17): 8597496600, (44, 15): 229911617056, (25, 12): 5200300, (15, 1): 15, (39, 4): 82251, (37, 20): 15905368710, (26, 11): 7726160, (48, 20): 16735679449896, (38, 27): 1203322288, (27, 2): 351, (49, 17): 6499270398159, (30, 13): 119759850, (41, 33): 95548245, (28, 5): 98280, (40, 9): 273438880, (50, 22): 88749815264600, (31, 8): 7888725, (29, 8): 4292145, (16, 3): 560, (30, 23): 2035800, (19, 14): 11628, (17, 2): 136, (41, 29): 7898654920, (31, 22): 20160075, (46, 26): 5608233007146, (20, 9): 167960, (18, 9): 48620, (42, 26): 166509721602, (40, 38): 780, (21, 12): 293930, (50, 43): 99884400, (43, 19): 800472431850, (32, 28): 35960, (22, 3): 1540, (42, 38): 111930, (33, 25): 13884156, (23, 10): 1144066, (45, 25): 3169870830126, (34, 30): 46376, (35, 31): 52360, (44, 20): 1761039350070, (42, 28): 52860229080, (12, 11): 12, (36, 24): 1251677700, (25, 21): 12650, (15, 14): 15, (13, 10): 286, (37, 29): 38608020, (26, 18): 1562275, (44, 37): 38320568, (48, 11): 22595200368, (38, 18): 33578000610, (49, 10): 8217822536, (39, 27): 3910797436, (50, 17): 9847379391150, (29, 1): 29, (40, 7): 18643560, (41, 6): 4496388, (46, 29): 1749695026860, (20, 16): 4845, (42, 5): 850668, (47, 24): 16123801841550, (45, 40): 1221759, (43, 8): 145008513, (32, 19): 347373600, (46, 7): 53524680, (44, 19): 1408831480056, (33, 18): 1037158320, (23, 3): 1771, (47, 6): 10737573, (45, 18): 1715884494940, (34, 25): 52451256, (32, 9): 28048800, (35, 4): 52360, (47, 23): 16123801841550, (12, 2): 66, (36, 7): 8347680, (49, 41): 450978066, (13, 3): 286, (37, 6): 2324784, (50, 46): 230300, (24, 5): 42504, (48, 2): 1128, (38, 21): 28781143380, (27, 16): 13037895, (44, 13): 51915526432, (49, 3): 18424, (39, 16): 37711260990, (28, 27): 28, (26, 7): 657800, (50, 8): 536878650, (43, 34): 563921995, (48, 24): 32247603683100, (29, 26): 3654, (6, 4): 15, (30, 1): 30, (41, 35): 4496388, (7, 1): 7, (31, 4): 31465, (46, 36): 4076350421, (42, 12): 11058116888, (40, 20): 137846528820, (19, 2): 171, (43, 1): 43, (41, 17): 151584480450, (46, 14): 239877544005, (20, 5): 15504, (44, 10): 2481256778, (42, 22): 513791607420, (47, 15): 751616304549, (36, 32): 58905, (34, 16): 2203961430, (8, 3): 56, (49, 48): 49, (35, 13): 1476337800, (9, 2): 36, (33, 13): 573166440, (48, 35): 192928249296, (36, 14): 3796297200, (34, 10): 131128140, (49, 34): 1575580702584, (37, 15): 9364199760, (35, 19): 4059928950, (50, 41): 2505433700, (24, 12): 2704156, (14, 3): 364, (38, 12): 2707475148, (36, 20): 7307872110, (25, 9): 2042975, (49, 4): 211876, (39, 9): 211915132, (28, 18): 13123110, (26, 14): 9657700, (50, 3): 19600, (44, 43): 44, (48, 31): 4244421484512, (29, 19): 20030010, (27, 15): 17383860, (49, 30): 18851684897584, (30, 8): 5852925, (28, 8): 3108105, (50, 29): 67327446062800, (31, 13): 206253075, (29, 13): 67863915, (16, 14): 120, (40, 27): 12033222880, (30, 18): 86493225, (19, 11): 75582, (43, 6): 6096454, (17, 15): 136, (41, 26): 63432274896, (22, 20): 231, (46, 17): 1749695026860, (20, 12): 125970, (44, 1): 44, (18, 12): 18564, (42, 17): 254661927156, (23, 17): 100947, (40, 33): 18643560, (21, 1): 21, (45, 4): 148995, (43, 28): 151532656696, (32, 7): 3365856, (22, 14): 319770, (44, 31): 51915526432, (33, 6): 1107568, (23, 15): 490314, (45, 30): 344867425584, (34, 5): 278256, (41, 40): 41, (37, 8): 38608020, (35, 24): 417225900, (50, 32): 18053528883775, (24, 19): 42504, (14, 10): 1001, (38, 7): 12620256, (36, 19): 8597496600, (25, 18): 480700, (15, 3): 455, (39, 6): 3262623, (37, 18): 17672631900, (26, 9): 3124550, (48, 22): 27385657281648, (38, 25): 5414950296, (27, 4): 17550, (49, 23): 58343356817424, (39, 28): 1676056044, (4, 2): 6, (28, 7): 1184040, (50, 20): 47129212243960, (31, 10): 44352165, (5, 3): 10, (29, 6): 475020, (41, 11): 3159461968, (50, 30): 47129212243960, (16, 5): 4368, (40, 2): 780, (30, 21): 14307150, (19, 16): 969, (41, 3): 10660, (31, 16): 300540195, (46, 24): 7890371113950, (20, 11): 167960, (45, 33): 28760021745, (18, 7): 31824, (42, 24): 353697121050, (47, 29): 4568648125690, (21, 10): 352716, (43, 21): 1052049481860, (32, 30): 496, (22, 1): 22, (46, 2): 1035, (44, 22): 2104098963720, (33, 31): 528, (23, 4): 8855, (38, 36): 703, (45, 23): 4116715363800, (34, 28): 1344904, (39, 33): 3262623, (11, 2): 55, (35, 1): 35, (14, 13): 14, (12, 5): 792, (36, 26): 254186856, (47, 45): 1081, (15, 8): 6435, (13, 8): 1287, (37, 27): 348330136, (26, 16): 5311735, (48, 13): 192928249296, (38, 16): 22239974430, (47, 32): 751616304549, (49, 8): 450978066, (39, 21): 62359143990, (50, 15): 2250829575120, (44, 41): 13244, (6, 3): 20, (30, 28): 435, (41, 4): 101270, (31, 25): 736281, (46, 35): 13340783196, (20, 18): 190, (42, 29): 25518731280, (42, 3): 11480, (47, 26): 12551759587422, (21, 19): 210, (43, 10): 1917334783, (32, 21): 129024480, (46, 5): 1370754, (35, 32): 6545, (33, 16): 1166803110, (45, 44): 45, (45, 16): 646626422970, (44, 6): 7059052, (34, 23): 286097760, (32, 11): 129024480, (43, 22): 1052049481860, (35, 6): 1623160, (33, 10): 92561040, (48, 46): 1128, (36, 1): 36, (49, 47): 1176, (13, 1): 13, (37, 4): 66045, (50, 44): 15890700, (24, 7): 346104, (48, 4): 194580, (38, 11): 1203322288, (27, 18): 4686825, (47, 43): 178365, (25, 6): 177100, (49, 1): 49, (39, 18): 62359143990, (50, 40): 10272278170, (28, 21): 1184040, (26, 5): 65780, (50, 6): 15890700, (48, 26): 27385657281648, (29, 24): 118755, (27, 8): 2220075, (49, 27): 49699896548176, (30, 7): 2035800}


    def nCr(self, n, r):
        if n == r or r == 0:
            return 1
        if self.dic.get((n, r), None) is None:
            self.dic[(n, r)] = self.nCr(n-1, r-1) + self.nCr(n-1, r)
        return self.dic[(n,r)]

    def show(self):
        print(self.dic)

def main():
    N, A, B = tuple(map(int, input().split(' ')))
    max_ave = 0
    v_list = sorted(list(map(int, input().split(' '))), reverse=True)

    bucket_min = v_list[A-1]
    max_ = v_list[0]

    max_bucket = v_list[:A]

    max_ave = stats.mean(max_bucket)

    all_bmin_cnt = v_list.count(bucket_min)
    b_bmin_cnt = max_bucket.count(bucket_min)
    all_max_cnt = v_list.count(max_)

    comb = Comb(N)

    print(max_ave)

    if all_max_cnt <= A:
        pass
        print(comb.nCr(all_bmin_cnt, b_bmin_cnt))
    else:
        num = 0
        for r in range(A, B+1):
            num += comb.nCr(all_max_cnt, r)
        print(num)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import statistics as stats
from math import factorial


class Comb:
    def __init__(self, N):
        super(Comb, self).__init__()
        self.dic = {}
        for i in range(1, N+1):
            for j in range(1, i+1):
                self.nCr(i, j)

    def nCr(self, n, r):
        if n == r or r == 0:
            return 1
        if self.dic.get((n, r), None) is None:
            self.dic[(n, r)] = self.nCr(n-1, r-1) + self.nCr(n-1, r)
        return self.dic[(n,r)]


def main():
    N, A, B = tuple(map(int, input().split(' ')))
    max_ave = 0
    v_list = sorted(list(map(int, input().split(' '))), reverse=True)

    bucket_min = v_list[A-1]
    max_ = v_list[0]

    max_bucket = v_list[:A]

    max_ave = stats.mean(max_bucket)

    all_bmin_cnt = v_list.count(bucket_min)
    b_bmin_cnt = max_bucket.count(bucket_min)
    all_max_cnt = v_list.count(max_)

    comb = Comb(N)

    print(max_ave)

    if all_max_cnt <= A:
        print(comb.nCr(all_bmin_cnt, b_bmin_cnt))
    else:
        num = 0
        for r in range(A, B+1):
            num += comb.nCr(all_max_cnt, r)
        print(num)




if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import statistics as stats
from math import factorial


class Comb:
    def __init__(self):
        super(Comb, self).__init__()
        self.dic = {}

    def nCr(self, n, r):
        if n == r or r == 0:
            return 1
        if self.dic.get((n, r), None) is None:
            self.dic[(n, r)] = self.nCr(n-1, r-1) + self.nCr(n-1, r)
        return self.dic[(n,r)]


def main():
    N, A, B = tuple(map(int, input().split(' ')))
    max_ave = 0
    v_list = sorted(list(map(int, input().split(' '))), reverse=True)

    bucket_min = v_list[A-1]
    max_ = v_list[0]

    max_bucket = v_list[:A]

    max_ave = stats.mean(max_bucket)

    all_bmin_cnt = v_list.count(bucket_min)
    b_bmin_cnt = max_bucket.count(bucket_min)
    all_max_cnt = v_list.count(max_)

    comb = Comb()

    print(max_ave)

    if all_max_cnt <= A:
        print(comb.nCr(all_bmin_cnt, b_bmin_cnt))
    else:
        num = 0
        for r in range(A, B+1):
            num += comb.nCr(all_max_cnt, r)
        print(num)



if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import statistics as stats
from math import factorial


def nCr(n, r):
    return int(factorial(n)/factorial(n-r)/factorial(r))


def main():
    N, A, B = tuple(map(int, input().split(' ')))
    max_ave = 0
    v_list = sorted(list(map(int, input().split(' '))), reverse=True)

    bucket_min = v_list[A-1]
    bucket_max = v_list[0]
    max_bucket = v_list[:A]

    max_ave = stats.mean(max_bucket)

    all_num = v_list.count(bucket_min)
    bucket_num = max_bucket.count(bucket_min)


    print(max_ave)
    if bucket_min == bucket_max:
        if all_num >= B:
            print(2**B-1)
        else:
            num = 0
            for i in range(A, B+1):
                num += nCr(all_num, i)
            print(num)
    else:
        print(nCr(all_num, bucket_num))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import statistics as stats
from math import factorial


def nCr(n, r):
    return int(factorial(n)/factorial(n-r)/factorial(r))


def main():
    N, A, B = tuple(map(int, input().split(' ')))
    max_ave = 0
    v_list = sorted(list(map(int, input().split(' '))), reverse=True)

    bucket_min = v_list[A-1]
    bucket_max = v_list[0]
    max_bucket = v_list[:A]

    max_ave = stats.mean(max_bucket)

    all_num = v_list.count(bucket_min)
    bucket_num = max_bucket.count(bucket_min)


    print(max_ave)
    if bucket_min == bucket_max:
        if all_num >= B:
            print(2**B-1)
        else:
            num = sum([nCr(all_num, r) for r in range(A, B+1)])
            print(num)
    else:
        print(nCr(all_num, bucket_num))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
n, a, b = [int(i) for i in input().split(" ")]
v = [int(i) for i in input().split(" ")]
v.sort(reverse=True)

res = sum(v[:a])/a
print("{0:.6f}".format(res))

if not v[0]==v[a-1]:
    x = v[:a].count(v[a-1])
    y = v.count(v[a-1])
    print(int(math.factorial(y)/math.factorial(x)/math.factorial(y-x)))
else:
    comb = 0
    for i in range(a, b+1):
        comb += math.factorial(n)/math.factorial(i)/math.factorial(n-i)
    print(int(comb))

Submission status: Runtime Error

Solution code:
from math import factorial

N, A, B = map(int, raw_input().split())
v = map(int, raw_input().split())

C = [[0 for i in range(51)] for j in range(51)] #C[n][k] => nCk

for i in range(1, N+1):
    for j in rane(1, i+1):
        if (j == 0 or j == i):
            C[i][j] = 1
        else:
            C[i][j] = C[i-1][j-1] + C[i-1][j]

v.sort(reverse = True)

t = v[A-1]

ans = 0
X, Y = v.count(t), v[:A].count(t)

if (v[0] != v[A-1]):
    ans = C[X][Y]

else:
    for i in range(A, B+1):
        if(i <= X):
            ans += comb[X][i]

print float(sum(v[0:A]))/A
print ans