#include <chrono>
#include <fstream>
#include <iostream>
#include <vector>
#include "jelly.h"

int main(int argc, char** argv) {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    auto io_start = std::chrono::system_clock::now();
    std::ofstream io_time_file;
    if (argc > 1) {
        io_time_file.open(argv[1]);
    }

    int N;
    std::cin >> N;
    std::vector<int> H(N), W(N);
    for (int i = 0; i < N; i++) {
        std::cin >> H[i] >> W[i];
    }

    auto io_end = std::chrono::system_clock::now();
    std::chrono::duration<double> io_time = io_end - io_start;
    double io_time_secs = io_time.count();

    long long answer = solve(H, W);

    io_start = std::chrono::system_clock::now();
    std::cout << answer << '\n';
    io_end = std::chrono::system_clock::now();
    io_time = io_end - io_start;
    io_time_secs += io_time.count();

    if (io_time_file) {
        io_time_file << "io-time:" << io_time_secs << '\n';
    }
    return 0;
}
