#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

int main() {
    std::vector<std::string> vec = {"apple", "banana", "cherry", "date"};

    std::sort(vec.begin(), vec.end(), [](const std::string &a, const std::string &b) {
        return a.length() < b.length();
    });

    for (const auto &str : vec) std::cout << str << " ";

    std::sort(vec.begin(), vec.end(), [](const std::string &a, const std::string &b) {
        return a > b;
    });

    for (const auto &str : vec) std::cout << str << " ";

    return 0;
}
