Problem:
Problem A:
Everlasting...?
Everlasting Sa-Ga, a new, hot and very popular role-playing game, is out on October 19, 2008.
Fans have been looking forward to a new title of Everlasting Sa-Ga.
Little Jimmy is in trouble. He is a seven-year-old boy, and he obtained the Everlasting Sa-Ga
and is attempting to reach the end of the game before his friends. However, he is facing difficulty
solving the riddle of the first maze in this game -- Everlasting Sa-Ga is notorious in extremely
hard riddles like Neverending Fantasy and Forever Quest.
The riddle is as follows. There are two doors on the last floor of the maze: the door to the
treasure repository and the gate to the hell. If he wrongly opens the door to the hell, the game
is over and his save data will be deleted. Therefore, he should never open the wrong door.
So now, how can he find the door to the next stage? There is a positive integer given for each
door -- it is a great hint to this riddle. The door to the treasure repository has the integer that
gives the larger
key numbe
r. The key number of a positive integer
n
is the largest prime factor
minus the total sum of any other prime factors, where the prime factors are the prime numbers
that divide into
n
without leaving a remainder. Note that each prime factor should be counted
only once.
As an example, suppose there are doors with integers 30 and 20 respectively. Since 30 has three
prime factors 2, 3 and 5, its key number is 5 - (2 + 3) = 0. Similarly, since 20 has two prime
factors 2 and 5, its key number 20 is 5 - 2 = 3. Jimmy therefore should open the door with 20.
Your job is to write a program to help Jimmy by solving this riddle.
Input
The input is a sequence of datasets. Each dataset consists of a line that contains two integers
a
and
b
separated by a space (2 ≤
a
,
b
≤ 10
6
). It is guaranteed that key numbers of these integers
are always different.
The input is terminated by a line with two zeros. This line is not part of any datasets and thus
should not be processed.
Output
For each dataset, print in a line ‘a’ (without quotes) if the door with the integer
a
is connected
to the treasure repository; print ‘b’ otherwise. No extra space or character is allowed.
Sample Input
10 15
30 20
0 0
Output for the Sample Input
a
b

Submitted solutions:

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

int key(int x){
	int s=0,m=0;
	for(int i=2;i<=x;i++){
		if(x%i==0){
			s+=i;
			m=i;
			while(x%i==0){
				x/=i;
			}
		}
	}
	return m-(s-m);
}
 
int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	while(1){
		int a,b; cin >> a >> b;
		if(a==0&&b==0)break;
		cout << (key(a)>key(b)?'a':'b') << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 160
memory_kb: 3032
final_rank: 5

code_snippet: #include<iostream>
#include<vector>
using namespace std;

int main(){
    vector<bool> nonp(1000001, 0);
    for(int i = 2; i < 1000001; i++){
        if(nonp[i]) continue;
        for(int j = i+i; j < 1000001; j += i)   nonp[j] = true;
    }
    int a, b;
    while(cin >> a >> b, a+b){
        int x = 1<<30, y = 1<<30;
        for(int i = a; i >= 2; i--){
            if(a%i == 0 && !nonp[i]){
                if(x == 1<<30)  x = i;
                else            x -= i;
            }
        }
        for(int i = b; i >= 2; i--){
            if(b%i == 0 && !nonp[i]){
                if(y == 1<<30)  y = i;
                else            y -= i;
            }
        }
        cout << (x > y ? "a" : "b") << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 890
memory_kb: 3140
final_rank: 19

code_snippet: #define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e8 + 7;

bool p[1100000] = {};

int main(){
	
	int N = 1000000;
	
	for(int i = 0; i < N; i++){
		p[i] = true;
	}
	
	p[0] = false;
	p[1] = false;
	
	for(int i = 2; i < N; i++){
		if(p[i]){
			for(int j = i * 2; j < N; j += i){
				p[j] = false;
			}
		}
	}
	
	while(true){
		int a, b;
		cin >> a >> b;
		if(a == 0){
			break;
		}
		int Sa, Sb;
		int pmax = 0;
		int S = 0;
		for(int i = 1; i <= a; i++){
			if(a % i == 0 && p[i]){
				S += i;
				pmax = i;
			}
		}
		Sa = pmax * 2 - S;
		
		S = 0;
		for(int i = 1; i <= b; i++){
			if(b % i == 0 && p[i]){
				S += i;
				pmax = i;
			}
		}
		Sb = pmax * 2 - S;
		if(Sa > Sb){
			cout << "a" << endl;
		}else{
			cout << "b" << endl;
		}
	}
	return 0;
}
accuracy: 1
time_ms: 810
memory_kb: 4036
final_rank: 20

code_snippet: #include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = double;
const ld eps = 1e-9;

int adiv(int a) {
	map<int,int>mp;
	int num(a);
	for (int i = 2; i <= a; ++i) {
		while (num%i == 0) {
			mp[i]++;
			num/=i;
		}
	}
	int anum=0;
	for (auto m : mp) {
		anum-=m.first;
	}
	anum+=2*prev(mp.end())->first;
	return anum;
}

int main() {
	while (true) {

		int A, B; cin >> A >> B;
		if(!A)break;
		A = adiv(A);
		B = adiv(B);
		if (A>B)cout << "a" << endl;
		else cout << "b" << endl;

	}
	return 0;
}
accuracy: 1
time_ms: 810
memory_kb: 2992
final_rank: 17

code_snippet: #include <iostream>
#include <stdlib.h>
#include <math.h>

using namespace std;

/* ?????°?????´??°x??\????????¨???????´???°???????????¢??° */
/* ?????????????´???°????????°????????°???????????????????´???°???????´???????. */
int era (int x, int *array)
{
	int search[x];
	int len = 0;
	search[0] = search[1] = 0;
	for (int i = 2; i < x; i++)
		search[i] = 1;
	double root_x = sqrt(x);
	for (int i = 0; ; i++) {
		int num = search[i];
		if (num == 1) {
			if (root_x <= i)
				break;
			else {
				array[len++] = i;
				for (int j = i; j < x; j+=i)
					search[j] = 0;
			}
		}
	}
	for (int i = 0; i < x; i++) {
		if (search[i] == 1) {
			array[len++] = i;
			search[i] = 0;
		}
	}
	return len;
}

/* ?????°????´??????°????±?????????¢??°  */
int p_list(int a, int *list, int *primes, int len)
{
	int a_len = 0;
	int i = 0;
	while (primes[i] <= a) 
	{
		if (a % primes[i] == 0)
			list[a_len++] = primes[i];
		i++;
		if (len <= i)
			break;
	}
	return a_len++;
}

int key(int *list, int len)
{
	int sum = 0;
	if (len == 1)
		return list[0];
	for (int i = 0; i < len - 1; i++) 
		sum += list[i];
	return list[len-1] - sum;


}

int main (void)
{
	int *primes;
	int len;
	primes = (int *)malloc(sizeof(int) * 1000000);
	len = era(1000000, primes);	
	while (1) {
		int a, b;
		cin >> a >> b;
		if (a == 0 && b == 0)
			break;
		int a_pri[a/2], b_pri[b/2];
		int a_len, b_len;
		a_len = p_list(a, a_pri, primes, len);
		b_len = p_list(b, b_pri, primes, len);
#ifdef DEBUG
		cout << a_len << " " << b_len << endl;
		for (int i = 0; i < a_len; i++)
			cout << a_pri[i] << endl;
		for (int i = 0; i < b_len; i++)
			cout << b_pri[i] << endl;
#endif
		int a_key, b_key;
		a_key = key(a_pri, a_len);
		b_key = key(b_pri, b_len);
#ifdef DEBUG
		cout << "a " << a_key << endl;
		cout << "b " << b_key << endl;
#endif
		if (a_key > b_key)
			cout << "a" << endl;
		else
			cout << "b" << endl;
	}
	free(primes);
	return 0;
}
accuracy: 1
time_ms: 80
memory_kb: 6880
final_rank: 15

code_snippet: #include <iostream>

using namespace std;

int main(void){
  bool isPrime[1000001];

  for(int i = 0 ; i <= 1000000 ; i++){
    isPrime[i] = true;
  }

  isPrime[0] = false;
  isPrime[1] = false;
  for(int n = 2 ; n <= 1000000 ; n++){
    if(isPrime[n]){
      for(int m = n ; m <= 1000000 ; m += n){
        isPrime[m] = false;
      }
      isPrime[n] = true;
    }
  }

  while(1){
    int a , b;
    cin >> a;
    cin >> b;

    if(a == 0 && b == 0){
      return 0;
    }

    int akey = 0;
    int afactmax;
    for(int i = 2 ; i <= a ; i++){
      if(isPrime[i] && a % i == 0){
        akey += i;
        afactmax = i;
      }
    }
    akey = 2 * afactmax - akey;

    int bkey = 0;
    int bfactmax;
    for(int i = 2 ; i <= b ; i++){
      if(isPrime[i] && b % i == 0){
        bkey += i;
        bfactmax = i;
      }
    }
    bkey = 2 * bfactmax - bkey;

    if(akey > bkey){
      cout << "a" << endl;
    }else{
      cout << "b" << endl;
    }



  }
}
accuracy: 1
time_ms: 460
memory_kb: 4052
final_rank: 11

code_snippet: #include <algorithm>
#include <bitset>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main()
{
    const auto primes = [] {
        bitset<1000000 + 1> b;
        auto t = b;
        t.set();
        t[0] = false;
        t[1] = false;
        int i = 0;
        while (true) {
            bool done = false;
            while (!t[i]) {
                ++i;
                if (i == t.size()) {
                    done = true;
                    break;
                }
            }
            if (done) {
                break;
            }

            b[i] = true;
            for (int j = i; j < t.size(); j += i) {
                t[j] = false;
            }
        }
        return b;
    }();

    while (true) {
        int a, b;
        cin >> a >> b;
        if (a == 0 && b == 0) {
            return 0;
        }

        auto f = [&primes](int x) {
            vector<int> r;
            int j = 2;
            while (true) {
                while (!primes[j]) {
                    ++j;
                }
                if (x == 1) {
                    break;
                }
                if (x % j == 0) {
                    r.push_back(j);
                    x /= j;
                }
                else {
                    j += 1;
                }
            }
            r.erase(unique(begin(r), end(r)), end(r));
            return r;
        };

        auto pa = f(a);
        auto pb = f(b);

        auto g = [](const vector<int>& v) {
            auto s = accumulate(begin(v), --end(v), 0);
            return v.back() - s;
        };

        if (g(pa) > g(pb)) {
            cout << "a" << endl;
        }
        else {
            cout << "b" << endl;
        }
    }
}
accuracy: 1
time_ms: 110
memory_kb: 3284
final_rank: 3

code_snippet: #include <algorithm>
#include <bitset>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main()
{
    bitset<1000100 + 1> b;
    auto t = b;
    t.set();
    t[0] = false;
    t[1] = false;
    int i = 0;
    while (true) {
        bool done = false;
        while (!t[i]) {
            ++i;
            if (i == t.size()) {
                done = true;
                break;
            }
        }
        if (done) {
            break;
        }

        b[i] = true;
        for (int j = i; j < t.size(); j += i) {
            t[j] = false;
        }
    }

    while (true) {
        int a, bb;
        cin >> a >> bb;
        int aa = a;
        int bbb = bb;
        if (a == 0 && bb == 0) {
            return 0;
        }

        vector<int> pa;
        int j = 2;
        while (true) {
            while (!b[j]) {
                ++j;
            }
            if (a == 1) {
                break;
            }
            if (a % j == 0) {
                pa.push_back(j);
                a /= j;
            }
            else {
                j += 1;
            }
        }
        vector<int> pb;
        j = 2;
        while (true) {
            while (!b[j]) {
                ++j;
            }
            if (bb == 1) {
                break;
            }
            if (bb % j == 0) {
                pb.push_back(j);
                bb /= j;
            }
            else {
                j += 1;
            }
        }
        pa.erase(unique(begin(pa), end(pa)), end(pa));
        pb.erase(unique(begin(pb), end(pb)), end(pb));

        auto f = [](const vector<int>& v) {
            auto s = accumulate(begin(v), --end(v), 0);
            return v.back() - s;
        };
        if (f(pa) > f(pb)) {
            cout << "a" << endl;
        }
        else {
            cout << "b" << endl;
        }
    }
}
accuracy: 1
time_ms: 110
memory_kb: 3248
final_rank: 2

code_snippet: #include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
const int N = 1000000;
int main(int argc, char *argv[])
{
  vector<bool> primes(N + 1,true);
  primes[0] = false;
  primes[1] = false;
  for(int i = 0; i <= N; i++) {
    if(primes[i]) {
      for(int j = i+i; j <= N; j+=i) {
        primes[j] = false;
      }
    }
  }
  vector<int> ps;
  for(int i = 0; i <= N; i++) {
    if(primes[i]) ps.push_back(i);
  }
  for(;;) {
    int a, b;
    cin >> a >> b;
    if(a == 0 && b == 0) break;
    auto key = [&ps](int n) {
      int p = 0;
      int s = 0;
      for(int i = 0; i < ps.size() && n >= ps[i]; i++) {
        if((n % ps[i]) == 0) {
          s += ps[i];
          p = ps[i];
        }
      }
      return p*2 - s;
    };
    int ka = key(a);
    int kb = key(b);
    cout << (ka > kb ? "a" : "b") << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 70
memory_kb: 3372
final_rank: 1

code_snippet: #include<bits/stdc++.h>
using namespace std;
bool e[1000005];
int a,b,c,d;
vector<int>s;
main(){
  for(int i=2;i<1000005;i++)
    if(!e[i])for(int j=i+i;j<1000005;j+=i)e[j]=1;
  for(int i=2;i<1000005;i++)
    if(!e[i])s.push_back(i);
  while(cin>>a>>b,a||b){
    c=d=0;
    for(int i=0;i<s.size()&&s[i]<=a;i++){
      int f1=0;
      while(a%s[i]==0)a/=s[i],f1++;
      if(f1)c-=s[i];
      if(a==1){
        c+=s[i]*2;
        break;
      }
    }
    for(int i=0;i<s.size()&&s[i]<=b;i++){
      int f1=0;
      while(b%s[i]==0)b/=s[i],f1++;
      if(f1)d-=s[i];
      if(b==1){
        d+=s[i]*2;
        break;
      }
    }
    if(c>d)cout<<"a"<<endl;
    else cout<<"b"<<endl;
  }
}
accuracy: 1
time_ms: 20
memory_kb: 4144
final_rank: 6

code_snippet: #include<iostream>
#include<vector>
#include<cmath>
using namespace std; 
typedef long long ll;
ll prime[1000001];
ll length = 0;
void insert(ll p) { prime[length] = p; length++; return; }
int main() {
	insert(2);
	for (ll i = 3; i < 1000000; i += 2) {
		for (ll j = 0; j < length; j++)
			if (i%prime[j] == 0)goto cont;
			else if (prime[j] > sqrt(i))break;
			insert(i);
		cont:;
	}
	ll a, b;
	while (cin >> a >> b){
		if (!a && !b)return 0;
		ll am, bm, ac = 0, bc = 0;
		int i = 0;
		while (prime[i] <= a){
			if (a%prime[i] == 0) {
				am = prime[i];
				ac += prime[i];
				while (a%prime[i] == 0)a /= prime[i];
				if (a == 1)break;
			}
			i++;
		}
		ac -= am; am -= ac;
		i = 0;
		while (prime[i] <= b) {
			if (b%prime[i] == 0) {
				bm = prime[i];
				bc += prime[i];
				while (b%prime[i] == 0)b /= prime[i];
				if (b == 1)break;
			}
			i++;
		}
		bc -= bm; bm -= bc;
		if (am > bm)cout << "a\n";
		else cout << "b\n";
	}
}
accuracy: 1
time_ms: 150
memory_kb: 3652
final_rank: 7

code_snippet: #include <stdio.h>
#include <cmath>
#include <algorithm>

#define NUM 1000500

int main(){
	int* table = new int[NUM];
	int limit;

	for(int i=0; i < NUM;i++)table[i] = 1;
	table[0] = 0;
	table[1] = 0;

	limit = sqrt(NUM);

	for(int i=2;i<=limit;i++){
		if(table[i] == 1){
			for(int k=2*i;k < NUM; k += i){
				table[k] = 0;
			}
		}
	}

	int a,b,index,array[1000],sum,a_key,b_key;

	while(true){
		scanf("%d %d",&a,&b);
		if(a == 0 && b == 0)break;

		limit = a/2 + 100;
		index = 0;

		if(a%2 == 0)array[index++] = 2;
		while(a%2 == 0)a /= 2;

		for(int i = 3; i <= limit; i += 2){
			if(table[i] == 1 && a%i == 0){
				array[index++] = i;
				while(a%i == 0){
					a /= i;
				}
			}
		}

		sum = 0;

		if(index == 0 && table[a] == 1){
			a_key = a;
		}else{

			for(int i = 0; i <= index-2; i++){
				sum += array[i];
			}

			a_key = array[index-1] - sum;
		}


		limit = b/2 + 100;
		index = 0;

		if(b%2 == 0)array[index++] = 2;
		while(b%2 == 0)b /= 2;

		for(int i = 3; i <= limit; i += 2){
			if(table[i] == 1 && b%i == 0){
				array[index++] = i;
				while(b%i == 0){
					b /= i;
				}
			}
		}

		sum = 0;

		if(index == 0 && table[b] == 1){
			b_key = b;
		}else{

			for(int i = 0; i <= index-2; i++){
				sum += array[i];
			}

			b_key = array[index-1] - sum;
		}

		if(a_key > b_key)printf("a\n");
		else{
			printf("b\n");
		}

	}
	return 0;
}
accuracy: 1
time_ms: 160
memory_kb: 6496
final_rank: 16

code_snippet: #include <stdio.h>
#include <cmath>
#include <algorithm>

#define NUM 1000500

int main(){
	int* table = new int[NUM];
	int limit;

	for(int i=0; i < NUM;i++)table[i] = 1;
	table[0] = 0;
	table[1] = 0;

	limit = sqrt(NUM);

	for(int i=2;i<=limit;i++){
		if(table[i] == 1){
			for(int k=2*i;k < NUM; k += i){
				table[k] = 0;
			}
		}
	}

	int a,b,index,array[1000],sum,a_key,b_key;

	while(true){
		scanf("%d %d",&a,&b);
		if(a == 0 && b == 0)break;

		limit = a/2 + 100;
		index = 0;

		for(int i = 2; i <= limit; i++){
			if(table[i] == 1 && a%i == 0){
				array[index++] = i;
				while(a%i == 0){
					a /= i;
				}
			}
		}

		sum = 0;

		if(index == 0 && table[a] == 1){
			a_key = a;
		}else{

			for(int i = 0; i <= index-2; i++){
				sum += array[i];
			}

			a_key = array[index-1] - sum;
		}


		limit = b/2 + 100;
		index = 0;

		for(int i = 2; i <= limit; i++){
			if(table[i] == 1 && b%i == 0){
				array[index++] = i;
				while(b%i == 0){
					b /= i;
				}
			}
		}

		sum = 0;

		if(index == 0 && table[b] == 1){
			b_key = b;
		}else{

			for(int i = 0; i <= index-2; i++){
				sum += array[i];
			}

			b_key = array[index-1] - sum;
		}

		if(a_key > b_key)printf("a\n");
		else{
			printf("b\n");
		}

	}
	return 0;
}
accuracy: 1
time_ms: 190
memory_kb: 6484
final_rank: 18

code_snippet: //============================================================================
// Name        : A.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

bool is_prime(int a){
	for (int i = 2; i * i <= a; ++i) {
		if(a % i == 0) return false;
	}
	return true;
}

vector<int> ps;

int f(int a){
	vector<ll> v;
	for(int p : ps){
		if(a % p == 0) v.push_back(p);
	}
	if(v.size() == 0) return 0;
	ll ret = v.back();
	for(int i = 0; i < (int)v.size() - 1; i++){
		ret -= v[i];
	}
	return ret;
}

int main() {
	for(int i = 2; i <= 2000000; i++){
		if(is_prime(i)) ps.push_back(i);
	}

	int n, m;
	while(cin >> n >> m , n + m){
		if(f(n) > f(m)){
			cout << "a" << endl;
		}
		else{
			cout << "b" <<endl;
		}
	}
}
accuracy: 1
time_ms: 580
memory_kb: 3708
final_rank: 12

code_snippet: #include <bits/stdc++.h>
using namespace std;
 
vector<int> sieve(int n) {
  vector<int> p(n);
  for(int i=2; i<n; i++) p[i]=i;
  for(int i=2; i*i<n; i++) {
    if(p[i]) {
      for(int j=i*i; j<n; j+=i) p[j]=0;
    }
  }
  p.erase(remove(p.begin(),p.end(),0),p.end());
  return p;
}
 
int main() {
  vector<int> p=sieve(1000000);
  int a[2];
  while(cin >> a[0] >> a[1]&&a[0]) {
    int b[2]={0,0};
    for(int j=0; j<2; j++) {
      int k=1;
      for(int i=p.size()-1; i>=0; i--) {
        if(a[j]%p[i]==0) {
          b[j]+=p[i]*k;
          k=-1;
        }
      }
    }
    if(b[0]>b[1]) cout << 'a' << endl;
    else cout << 'b' << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 100
memory_kb: 6536
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;

int get_sum(set<int> a){
  int sum=0;
  set<int>::iterator it;
  for(it=a.begin();it!=--a.end();it++)sum+=(*it);
  return sum;
}

int get_num(set<int> &a){
  int res=*(--a.end());
  return res;
}



int main(){

  while(1){
  int a,b;
  cin>>a>>b;
  if(!a&&!b)return 0;
  set<int> A,B;
  for(int i=2;a!=1;i++){
    if(a%i==0)A.insert(i);
    while(a%i==0)a/=i;
  }

  for(int i=2;b!=1;i++){
    if(b%i==0)B.insert(i);
    while(b%i==0)b/=i;
  }

  a=get_num(A)-get_sum(A);
  b=get_num(B)-get_sum(B);
  if(a>b) cout<<"a"<<endl;
  else cout<<"b"<<endl;
  }
  return 0;
}
accuracy: 1
time_ms: 300
memory_kb: 3080
final_rank: 9

code_snippet: #include <bits/stdc++.h>
using namespace std;

vector<int> sieve(int n) {
  vector<int> p(n);
  for(int i=2; i<n; i++) p[i]=i;
  for(int i=2; i*i<n; i++) {
    if(p[i]) {
      for(int j=i*i; j<n; j+=i) p[j]=0;
    }
  }
  p.erase(remove(p.begin(),p.end(),0),p.end());
  return p;
}

int main() {
  vector<int> p=sieve(1000000);
  int a[2];
  while(cin >> a[0] >> a[1]&&a[0]) {
    int b[2]={0,0};
    for(int j=0; j<2; j++) {
      int k=1;
      for(int i=p.size()-1; i>=0; i--) {
        if(a[j]%p[i]==0) {
          b[j]+=p[i]*k;
          k=-1;
        }
      }
    }
    if(b[0]>b[1]) cout << 'a' << endl;
    else cout << 'b' << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 100
memory_kb: 6544
final_rank: 14

code_snippet: #include <bits/stdc++.h>

using namespace std;

int func(int n)
{
    int sum = 0, largest = 0;
    for (int i = 2; i <= n; i++) {
        if (n % i == 0) {
            sum += i;
            largest = i;
            while (n % i == 0) {
                n /= i;
            }
        }
    }
    sum -= largest;
    return largest - sum;
}

int main()
{
    int a, b;
    while (cin >> a >> b, a) {
        if (func(a) > func(b)) {
            cout << 'a' << endl;
        } else {
            cout << 'b' << endl;
        }
    }        
    return 0;
}
accuracy: 1
time_ms: 160
memory_kb: 3028
final_rank: 4

code_snippet: #include <iostream>
#include <algorithm>
using namespace std;
int a, b; bool prime[1111111];
int main() {
	fill(prime + 2, prime + 1000001, true);
	for (int i = 2; i <= 1000; i++) {
		if (!prime[i]) continue;
		for (int j = i * i; j <= 1000000; j += i) prime[j] = false;
	}
	while (cin >> a >> b, a | b) {
		int suma = 0, maxa = 0, sumb = 0, maxb = 0;
		for (int i = 2; i <= a; i++) {
			if (prime[i] && a % i == 0) suma += i, maxa = i;
		}
		for (int i = 2; i <= b; i++) {
			if (prime[i] && b % i == 0) sumb += i, maxb = i;
		}
		int reta = maxa * 2 - suma, retb = maxb * 2 - sumb;
		if (reta > retb) cout << "a" << endl;
		else cout << "b" << endl;
	}
	return 0;
}
accuracy: 1
time_ms: 400
memory_kb: 4060
final_rank: 10

code_snippet: #include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	#define MAX 1000010
	bool sosu[MAX]={0};
	for(int i=4;i<MAX;i+=2)sosu[i]=1;
	for(int i=3;i*i<=MAX;i+=2)if(!sosu[i])
	for(int j=i*3;j<MAX;j+=i*2)sosu[j]=1;
	
	int a,b;
	while(cin>>a>>b,a+b){
		int A=0,B=0;
		bool ha=true;
		for(int i=a;i>1;i--)if(sosu[i]==0&&a%i==0){
			if(ha){
				A+=i;
				ha=false;
			}else A-=i;
		}
		ha=true;
		for(int i=b;i>1;i--)if(sosu[i]==0&&b%i==0){
			if(ha){
				B+=i;
				ha=false;
			}else B-=i;
		}
		if(A>B)cout<<'a'<<endl;
		else cout<<'b'<<endl;		
	}
}
accuracy: 1
time_ms: 430
memory_kb: 2136
final_rank: 8