p126.cpp
======================
#include <bits/stdc++.h>

using namespace std;

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &x) {
    return out << x.first << ' ' << x.second;
}

template<typename T1, typename T2>
istream &operator>>(istream &in, pair<T1, T2> &x) {
    return in >> x.first >> x.second;
}

template<typename T>
istream &operator>>(istream &in, vector<T> &a) {
    for(auto &x: a) {
        in >> x;
    }
    return in;
};

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &a) {
    for(auto x: a) {
        out << x << ' ';
    }
    return out;
};

int64_t a, b;

void read() {
    cin >> a >> b;
}

void solve() {
    // (a, b), (a > b)
    // (a - b, 2b)
    // (a - 3b, 4b)
    // (a - 7b, 8b)
    // ...

    for(int steps = 0; steps <= 60; steps++) {
        if(a > b) {
            swap(a, b);
        }

        if(a == 0) {
            cout << steps << '\n';
            return;
        }

        b -= a;
        a *= 2;
    }

    cout << -1 << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    // cin >> T;
    for(int test = 1; test <= T; test++) {
        read();
        // cout << "Case #" << test << ": ";
        solve();
    }

    return 0;
}

=================
statement.txt
======================
126. Boxes

time limit per test: 0.25 sec.
memory limit per test: 4096 KB


There are two boxes. There are A balls in the first box, and B balls in the second box (0 < A + B < 2147483648). It is possible to move balls from one box to another. From one box into another one should move as many balls as the other box already contains. You have to determine, whether it is possible to move all balls into one box.


Input

The first line contains two integers A and B, delimited by space.


Output

First line should contain the number N - the number of moves which are required to move all balls into one box, or -1 if it is impossible.


Sample Input

Sample Output

2 6
Sample Output

2
Author	: Victor G. Samoilov, Herman "Smash" Narkaytis
Resource	: 5th Southern Subregional Contest. Saratov 2002
Date	: 2002-10-10

=================
