## 1. Abridged Problem Statement

Given two integers a and b (2 <= a, b <= 10^6), define the key number of n as follows: let its distinct prime divisors be p_1, p_2, ..., p_k; let M = max(p_i) and S = sum(p_i). Then key(n) = M - (S - M) = 2*M - S. The input guarantees key(a) != key(b). Print "a" if key(a) > key(b); otherwise print "b".

---

## 2. Detailed Editorial

### Problem restated

We must compare two specially defined values (key numbers) for a and b, and output which one is larger.

### Key number definition

- Extract all distinct prime factors of n: {p_1, p_2, ..., p_k}.
- Let M = largest prime in that set.
- Let S = sum of all primes in the set.
- Define key(n) = M - (S - M) = 2*M - S.

### Constraints and complexity

- a and b up to 10^6.
- We only have two numbers to factor, so simple trial division up to sqrt(n) (<=1000) is perfectly fine.
- Worst-case cost: O(sqrt(n)) per number, i.e. ~2*10^3 operations, negligible.

### Prime factorization approach

1. Initialize an empty list of primes.
2. For i from 2 to floor(sqrt(n)):
   - If i divides n, record i in the list, then divide n by i repeatedly until it no longer divides.
3. If after that n > 1, the remainder is itself prime; record it.
4. You get a list of distinct prime factors.

### Computing the key number in one pass

- While collecting primes, track their sum S and current maximum M.
- Finally compute key = 2*M - S.

### Putting it all together

- Read a, b.
- Compute key(a), key(b).
- Compare and print "a" or "b".

---

## 3. C++ Solution

```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;
};

vector<int> prime_factors(int n) {
    vector<int> res;
    for(int i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            res.push_back(i);
            while(n % i == 0) {
                n /= i;
            }
        }
    }

    if(n > 1) {
        res.push_back(n);
    }

    return res;
}

int key_number(int x) {
    vector<int> p = prime_factors(x);
    int64_t sum = accumulate(p.begin(), p.end(), 0LL);
    int mx = *max_element(p.begin(), p.end());
    return 2 * mx - sum;
}

int a, b;

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

void solve() {
    // The key number of n is its largest prime factor minus the sum of all
    // other distinct prime factors. With S the sum of all distinct prime
    // factors and M the largest one, that equals M - (S - M) = 2 * M - S.
    // Factor each of a and b by trial division up to sqrt, compute the key
    // numbers, and print the door with the larger one.

    if(key_number(a) > key_number(b)) {
        cout << "a\n";
    } else {
        cout << "b\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;
}
```

---

## 4. Python Solution

```python
import sys
import math

def prime_factors(n):
    """Return the distinct prime factors of n."""
    factors = []
    # Check divisibility by 2 separately for speed (optional)
    if n % 2 == 0:
        factors.append(2)
        while n % 2 == 0:
            n //= 2
    # Now n is odd; test odd divisors from 3 up to sqrt(n)
    i = 3
    # Stop when i*i > n
    while i * i <= n:
        if n % i == 0:
            factors.append(i)
            # Remove all copies of i
            while n % i == 0:
                n //= i
        i += 2
    # If remainder > 1, it's a prime
    if n > 1:
        factors.append(n)
    return factors

def key_number(n):
    """Compute key(n) = 2*max(primes) - sum(primes)."""
    primes = prime_factors(n)
    s = sum(primes)
    m = max(primes)
    return 2*m - s

def main():
    # Read two integers from stdin
    a, b = map(int, sys.stdin.readline().split())
    # Compare keys and print result
    if key_number(a) > key_number(b):
        print("a")
    else:
        print("b")

if __name__ == "__main__":
    main()
```

---

## 5. Compressed Editorial

- Factor each of a and b into distinct primes via trial division up to sqrt(n).
- Let S = sum(distinct primes), M = max(distinct primes). Key = 2*M - S.
- Compute key(a) and key(b); output "a" if key(a) > key(b), else "b".
