3
self, n: int, edges: List[List[int]], queries: List[int]5
p_c = [0] * (n + 1) # point counter6
e_c = defaultdict(int) # edge counter18
) # frequency of point counter (compress the individual calculations into massive one)19
for i in range(1, n + 1):22
cnt_amt = defaultdict(24
) # frequency of same cnt on pairs without edge adjustment25
f_key = list(f_c.keys()) # frequency key30
f_c[f1] * (f_c[f1] - 1) // 231
) # 3 points with 4, then you get 832
# for a frequency of 3 * (3-2) // 2 = 333
for j in range(i + 1, l_f):37
) # 2 points with 2, 3 points with 438
# will have 6 with frequency of 2 * 3 = 640
for (u, v), z in e_c.items(): # edge adjustment47
cnt_amt.keys(), key=lambda x: -x48
) # accumulate the frequency by descending order49
res = defaultdict(int)52
if cnt_amt[key]: # if it is 0 then dont bother to keep them56
res_keys = sorted(res.keys()) # bisection search57
for i, q in enumerate(queries):58
local = bisect.bisect(res_keys, q)60
queries[i] = res[res_keys[local]]63
0 # some test cases are annoying by requesting an unreasonable large number