#include <bits/stdc++.h>
using namespace std;
using ll = long long;
std::pair<std::vector<int>, long long> transaction(long long M);
void buy_souvenirs(int n, long long p) {
    auto [v, x] = transaction(p - 1);
    
    if (v.size() == 1) {
        transaction(p - x - 2);
    } else {
        ll sum = p - 1 - x;
        transaction((sum + 1) / 2);
    }
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |