import random
def generate_array(size, min_val, max_val):
return [random.randint(min_val, max_val) for _ in range(size)]
def bubble_sort_desc(arr):
n = len(arr)
for i in range(n - 1):
for j in range(n - 1 - i):
if arr[j] < arr[j + 1]: # Міняємо на "<" для сортування за спаданням
arr[j], arr[j + 1] = arr[j + 1], arr[j]
aW1wb3J0IHJhbmRvbQoKZGVmIGdlbmVyYXRlX2FycmF5KHNpemUsIG1pbl92YWwsIG1heF92YWwpOgogICAgcmV0dXJuIFtyYW5kb20ucmFuZGludChtaW5fdmFsLCBtYXhfdmFsKSBmb3IgXyBpbiByYW5nZShzaXplKV0KCmRlZiBidWJibGVfc29ydF9kZXNjKGFycik6CiAgICBuID0gbGVuKGFycikKICAgIGZvciBpIGluIHJhbmdlKG4gLSAxKToKICAgICAgICBmb3IgaiBpbiByYW5nZShuIC0gMSAtIGkpOgogICAgICAgICAgICBpZiBhcnJbal0gPCBhcnJbaiArIDFdOiAgIyDQnNGW0L3Rj9GU0LzQviDQvdCwICI8IiDQtNC70Y8g0YHQvtGA0YLRg9Cy0LDQvdC90Y8g0LfQsCDRgdC/0LDQtNCw0L3QvdGP0LwKICAgICAgICAgICAgICAgIGFycltqXSwgYXJyW2ogKyAxXSA9IGFycltqICsgMV0sIGFycltqXQoKCgoK