from itertools import permutationss, k =input().split()print("\n".join(sorted(map("".join, permutations(s, int(k))))))
itertools.combinations()
from itertools import combinationss, k =input().split()for i inrange(int(k)):print("\n".join(sorted("".join(sorted(each)) for each incombinations(s, i +1))))
itertools.combinations_with_replacement()
from itertools import combinations_with_replacements, k =input().split()print("\n".join(sorted("".join(sorted(each)) for each incombinations_with_replacement(s, int(k)))))
Compress The String!
from itertools import groupbys =input()print(" ".join(str((len(list(group)), int(value))) for value, group ingroupby(s)))
Iterables and Iterators
from itertools import combinationsn =int(input())letters =input().split()k =int(input())combos =list(combinations(letters, k))print(len(list(each for each in combos if"a"in each)) /len(combos))
Maximize It!
from itertools import productk, m =map(int, input().split())arr = [list(map(lambdax: pow(int(x), 2), input().split()[1:]))for _ inrange(k)]print(max(map(lambdax: sum(x) % m, product(*arr))))