Problem:
Skyscraper "MinatoHarukas"
Mr. Port plans to start a new business renting one or more floors
of the new skyscraper with one giga floors, MinatoHarukas.
 
He wants to rent as many vertically adjacent floors as possible, 
because he wants to show advertisement on as many vertically
adjacent windows as possible.

The rent for one floor is proportional to the floor number,
that is, the rent per month for the
n
-th floor is
n
times
that of the first floor.
Here, the ground floor is called the first floor in the American style,
and basement floors are out of consideration for the renting.

In order to help Mr. Port, you should write a program that computes
the vertically adjacent floors satisfying his requirement and
whose total rental cost per month is
exactly equal
to his budget.
For example, when his budget is 15 units, 
with one unit being the rent of the first floor,
there are four possible rent plans,
1+2+3+4+5, 4+5+6, 7+8, and 15. 
For all of them, the sums are equal to 15.
Of course in this example the rent of maximal number of the floors 
is that of 1+2+3+4+5, that is, the rent from the first floor to the fifth floor.
Input
The input consists of multiple datasets,
each in the following format.
b
A dataset consists of one line,
the budget of Mr. Port
b
as multiples of the rent of the first floor.
b
is a positive integer satisfying 1 <
b
< 10
9
.
The end of the input is indicated by a line containing a zero.
The number of datasets does not exceed 1000.
Output
For each dataset, output a single line containing two positive integers
representing the plan with the maximal number of vertically adjacent floors
with its rent price exactly equal to the budget of Mr. Port.
The first should be the lowest floor number and
the second should be the number of floors.
Sample Input
15
16
2
3
9699690
223092870
847288609
900660121
987698769
999999999
0
Output for the Sample Input
1 5
16 1
2 1
1 2
16 4389
129 20995
4112949 206
15006 30011
46887 17718
163837 5994

Submitted solutions:

code_snippet: #include<bits/stdc++.h>
using namespace std ;
int ans , p , n ;
void deal( int x ){
    if ( ( n / x ) % 2 == 1 ){
        int y = x - ( n / x ) / 2 ;
        if ( y > 0 ){
            if ( n / x > ans ){
                ans = n / x ;
                p = y ;
            }
        }
    }
    if ( x > 1 && x % 2 == 1 ){
        int y = x / 2 - n / x + 1 ;
        if ( 2 * n / x > ans && y > 0 ){
            ans = 2 * n / x ;
            p = y ;
        }
    }
}
int main(){
    while( 1 ){
          scanf( "%d" , &n ) ;
          if ( n == 0 ) break ;
          ans = 0 ; p = 0 ;
          for( int i = 1 ; i <= sqrt( n ) ; i++ ){
              if ( n % i == 0 ){
                  deal( i ) ; deal( n / i ) ;
              }
          }
          printf( "%d %d\n" , p , ans ) ;
    }
    return 0 ;
}
accuracy: 1
time_ms: 40
memory_kb: 3508
final_rank: 13

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

void solve(ll b){
    pair<ll,ll> ans;

    for (ll i = 1; i*i <= 2*b; i++){
        if (2*b%i)continue;

        ll n = i;
        ll m = 2*b / n;
        if ((m-n+1)%2)continue;

        ll l = (m-n+1)/2;
        ans.first = l;
        ans.second = i;
    }
    cout << ans.first << ' ' << ans.second << endl;
}

int main(){
    ll b;cin >> b;
    while(b){
        solve(b);
        cin >> b;
    }
}
accuracy: 1
time_ms: 80
memory_kb: 3436
final_rank: 8

code_snippet: #pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
#define fast std::ios::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr)
#define eb emplace_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using u64 = uint64_t;
using u128 = __uint128_t;
using ull = unsigned long long;
constexpr ll inf = 2e18;
constexpr ll mod = 998244353;
#ifdef LOCAL
#define debug(x) std::cerr << #x << " = " << (x) << std::endl;
#else
#define debug(x)
#endif
static void judge(bool c) {
    std::cout << (c ? "Yes" : "No") << '\n';
}


ll b;
ll isok(ll x){
    if(x * x > b) return 0;
    ll c = b - x * x;
    if(c % x) return 0;
    c /= x;
    c++;
    if(c % 2) return 0;
    c /= 2;
    assert(x * x + (2 * c - 1) * x == b);
    return c;
}
int main() {
    fast;
    while(1){
        ll ans = -1,st = -1;
        cin >> b;
        b *= 2;
        if(b == 0) return 0;
        for(ll i = 1; i * i <= b; i++){
            if(b % i == 0){
                if(isok(i)) ans = max(ans,i),st = isok(i);
            }
        }
        assert(ans != -1 && st != -1);
        cout << st << " "<< ans << endl;
    }
}
accuracy: 1
time_ms: 80
memory_kb: 3384
final_rank: 4

code_snippet: // C++ includes used for precompiling -*- C++ -*-
// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.
// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://w...content-available-to-author-only...u.org/licenses/>.
/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */
// 17.4.1.2 Headers
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>

#endif
using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
template <class T, class U>
inline bool chmax(T &a, U b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T, class U>
inline bool chmin(T &a, U b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline void compress(vector<T> &a) {
    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
}
template <class T>
T rand(T l, T r) {
    static mt19937 mt(random_device{}());
    // [l, r)
    if constexpr (is_integral_v<T>) {
        return uniform_int_distribution<T>(l, r - 1)(mt);
    } else if constexpr (is_floating_point_v<T>) {
        return uniform_real_distribution<T>(l, r)(mt);
    }
}
constexpr int INF = 1001001001;
constexpr ll llINF = 3000000000000000010;
struct linear_sieve {
    vector<int> least_factor, prime_list;
    linear_sieve(int n) : least_factor(n + 1, 0) {
        for (int i = 2; i <= n; i++) {
            if (least_factor[i] == 0) {
                least_factor[i] = i;
                prime_list.push_back(i);
            }
            for (int p : prime_list) {
                if (ll(i) * p > n || p > least_factor[i]) break;
                least_factor[i * p] = p;
            }
        }
    }
};
template <int modulo>
struct modint {
    int x;
    modint() : x(0) {}
    modint(int64_t y) : x(y >= 0 ? y % modulo : (modulo - (-y) % modulo) % modulo) {}
    modint &operator+=(const modint &p) {
        if ((x += p.x) >= modulo) x -= modulo;
        return *this;
    }
    modint &operator-=(const modint &p) {
        if ((x += modulo - p.x) >= modulo) x -= modulo;
        return *this;
    }
    modint &operator*=(const modint &p) {
        x = (int)(1LL * x * p.x % modulo);
        return *this;
    }
    modint &operator/=(const modint &p) {
        *this *= p.inv();
        return *this;
    }
    modint operator-() const { return modint(-x); }
    modint operator+(const modint &p) const { return modint(*this) += p; }
    modint operator-(const modint &p) const { return modint(*this) -= p; }
    modint operator*(const modint &p) const { return modint(*this) *= p; }
    modint operator/(const modint &p) const { return modint(*this) /= p; }
    bool operator==(const modint &p) const { return x == p.x; }
    bool operator!=(const modint &p) const { return x != p.x; }
    modint inv() const {
        int a = x, b = modulo, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return modint(u);
    }
    modint pow(int64_t n) const {
        modint ret(1), mul(x);
        while (n > 0) {
            if (n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    friend ostream &operator<<(ostream &os, const modint &p) { return os << p.x; }
    friend istream &operator>>(istream &is, modint &a) {
        int64_t t;
        is >> t;
        a = modint<modulo>(t);
        return (is);
    }
    int val() const { return x; }
    static constexpr int mod() { return modulo; }
    static constexpr int half() { return (modulo + 1) >> 1; }
};
ll extgcd(ll a, ll b, ll &x, ll &y) {
    // ax+by=gcd(|a|,|b|)
    if (a < 0 || b < 0) {
        ll d = extgcd(abs(a), abs(b), x, y);
        if (a < 0) x = -x;
        if (b < 0) y = -y;
        return d;
    }
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
template <typename T>
struct Binomial {
    vector<T> inv, fact, factinv;
    Binomial(int n) {
        inv.resize(n + 1);
        fact.resize(n + 1);
        factinv.resize(n + 1);
        inv[0] = fact[0] = factinv[0] = 1;
        for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i;
        factinv[n] = fact[n].inv();
        inv[n] = fact[n - 1] * factinv[n];
        for (int i = n - 1; i >= 1; i--) {
            factinv[i] = factinv[i + 1] * (i + 1);
            inv[i] = fact[i - 1] * factinv[i];
        }
    }
    T C(int n, int r) {
        if (n < 0 || n < r || r < 0) return 0;
        return fact[n] * factinv[n - r] * factinv[r];
    }
    T P(int n, int r) {
        if (n < 0 || n < r || r < 0) return 0;
        return fact[n] * factinv[n - r];
    }
    T H(int n, int r) {
        if (n == 0 && r == 0) return 1;
        if (n < 0 || r < 0) return 0;
        return r == 0 ? 1 : C(n + r - 1, r);
    }
};
template <class T>
vector<T> dijkstra(vector<vector<pair<int, T>>> &g, vector<int> start) {
    using P = pair<T, int>;
    vector<T> dp(g.size(), numeric_limits<T>::max());
    priority_queue<P, vector<P>, greater<P>> que;
    for (int s : start) {
        dp[s] = 0;
        que.push({0, s});
    }
    while (que.size()) {
        auto [d, v] = que.top();
        que.pop();
        if (dp[v] != d) continue;
        for (auto [u, c] : g[v]) {
            if (chmin(dp[u], d + c)) que.push({dp[u], u});
        }
    }
    return dp;
}

vector<int> BFS01(vector<vector<pair<int, int>>> &g, vector<int> start) {
    vector<int> dp(g.size(), numeric_limits<int>::max());
    deque<int> que;
    for (int s : start) {
        dp[s] = 0;
        que.push_front(s);
    }
    while (que.size()) {
        auto v = que.front();
        que.pop_front();
        for (auto [u, c] : g[v]) {
            if (chmin(dp[u], dp[v] + c)) {
                if (c == 0)
                    que.push_front(u);
                else
                    que.push_back(u);
            }
        }
    }
    return dp;
}
template <typename T, typename U>
inline istream &operator>>(istream &is, pair<T, U> &rhs) {
    return is >> rhs.first >> rhs.second;
}
template <typename T>
inline istream &operator>>(istream &is, vector<T> &v) {
    for (auto &e : v) is >> e;
    return is;
}
template <typename T, typename U>
inline ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    return os << rhs.first << " " << rhs.second;
}
template <typename T>
inline ostream &operator<<(ostream &os, const vector<T> &v) {
    for (auto itr = v.begin(), end_itr = v.end(); itr != end_itr;) {
        os << *itr;
        if (++itr != end_itr) os << " ";
    }
    return os;
}

struct UnionFind {
    vector<int> par, siz;
    UnionFind(int x) {
        par.resize(x);
        siz.resize(x);
        for (int i = 0; i < x; i++) {
            par[i] = i;
            siz[i] = 1;
        }
    }
    int find(int x) {
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }
    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        par[y] = x;
        siz[x] += siz[y];

        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return siz[find(x)]; }
};
template <class T>
struct BIT {
    // 1-indexed
    int n, beki = 1;
    vector<T> bit;
    BIT(int x) {
        bit.resize(x + 1, 0);
        n = x;
        while (beki * 2 <= n) beki *= 2;
    }
    T sum(int i) {
        T res = 0;
        while (i > 0) {
            res += bit[i];
            i -= i & -i;
        }
        return res;
    }
    T sum(int l, int r) {
        //[l,r]
        return sum(r) - (l == 0 ? 0 : sum(l - 1));
    }
    void add(int i, T x) {
        while (i <= n) {
            bit[i] += x;
            i += i & -i;
        }
    }
    int lowerbound(T w) {
        if (w <= 0) return 0;
        int x = 0;
        for (int k = beki; k > 0; k >>= 1) {
            if (x + k <= n && bit[x + k] < w) {
                w -= bit[x + k];
                x += k;
            }
        }
        return x + 1;
    }
};
using mint = modint<998244353>;

void solve() {
    ll b;
    cin>>b;
    if(b==0){
        exit(0);
    }
    b*=2;
    ll ans1=-1,ans2=-1;
    for(ll i=1;i*i<=b;i++){
        if(b%i==0){
            ll j=b/i;
                j+=1;
            if(i%2!=j%2)continue;
            ans1=(j-i)/2,ans2=(i+j)/2;
        }
    }
    cout<<ans1<<" "<<ans2-ans1<<endl;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int t = 1;
    // cin >> t;
    while (1) solve();
}
accuracy: 1
time_ms: 30
memory_kb: 3584
final_rank: 16

code_snippet: #include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
#endif
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vvvd vector<vector<vector<double>>>
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define vvvll vector<vector<vector<long long>>>
#define vmi vector<mint>
#define vvmi vector<vector<mint>>
#define vb vector<bool>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define pi pair<int,int>
#define pll pair<long long, long long>
#define vpi vector<pair<int,int>>
#define vvpi vector<vector<pair<int,int>>>
#define gi greater<int>
#define gll greater<long long>
#define gpi greater<pair<int,int>>
#define eb emplace_back
#define ef emplace_front
#define pq priority_queue

ll sum(ll n){return n*(n+1)/2;}

ll largestCount(ll n){
  ll left = 0;
  ll right = LLONG_MAX;
  while(left<right){
    ll mid = right - (right - left) / 2;
    if(sum(mid)>n)right = mid - 1;
    else if(sum(mid)<n)left = mid + 1;
    else if(sum(mid)==n) return mid;
  }
  return left;
}

void solve() {
  while(true){
    ll n; cin >> n;
    if(n==0)return;
    ll cnt = 0;
    ll m = 0;
    for (int i=1; i<sqrt(2 * n) + 1; i++)
    {
      ll tmp = cnt;
      if (i % 2 == 0){
        cnt += (n % i == i / 2);
      }
      else{
        cnt += (n % i == 0);
      }
      if(tmp != cnt){
        m = i;
      }
    }
    if ((2 * n / m - m - 1) / 2 + 1 == 0){
      cout << 1 << ' ' << m - 1 << endl;
    }else{
      cout << (2 * n / m - m - 1) / 2 + 1 << ' ' << m << endl;
    }
  }
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}
accuracy: 1
time_ms: 90
memory_kb: 3220
final_rank: 1

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

int main(){

    while(true){
        int b;
        cin >> b;
        if(b == 0) break;
        for(int i = (int)sqrt(2*b); i >= 1; i--){
            if((2*b)%i == 0 && (2*b/i - i+1)/2 >= 1 && (2*b/i - i+1)%2 == 0){
                cout << (2*b/i - i+1)/2 << " " << i << endl;
                break;
            }
        }
    }

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3288
final_rank: 2

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(), (v).end()
using ll = long long;

int main() {
    while (true) {
        ll B; cin >> B;
        if (B == 0) break;
        B <<= 1;
        vector<ll> div;
        for (ll i = 1; i*i <= B; i++) {
            if (B % i == 0) {
                div.emplace_back(i);
                if (B / i != i) div.emplace_back(B / i);
            }
        }
        sort(ALL(div));
        ll len = 0;
        ll lans = -1, rans = -1;
        for (auto m : div) {
            ll x = B / m;
            for (ll i = 1; i*i <= x; i++) {
                if (x % i == 0) {
                    {
                        ll n = x / i;
                        ll r = (i + n - 1);
                        ll l = (i - n + 1);
                        if ((l & 1) || (r & 1)) continue;
                        l >>= 1;
                        r >>= 1;
                        if (1 <= l && l <= r && n > len) {
                            len = n;
                            lans = l;
                            rans = r;
                        }
                    }
                    {
                        ll n = i;
                        ll r = (x / i + n - 1);
                        ll l = (x / i - n + 1);
                        if ((l & 1) || (r & 1)) continue;
                        l >>= 1;
                        r >>= 1;
                        if (1 <= l && l <= r && n > len) {
                            len = n;
                            lans = l;
                            rans = r;
                        }
                    }
                }
            }
        }
        cout << lans << " " << len << "\n";
    }
}
accuracy: 1
time_ms: 130
memory_kb: 3456
final_rank: 11

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, t) for (ll i = s; i < (ll)(t); i++)
#define rrep(i, s, t) for(ll i = (ll)(t) - 1; i >= (ll)(s); i--)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define TT template<typename T>
TT using vec = vector<T>;
template<class T1, class T2> bool chmin(T1 &x, T2 y) { return x > y ? (x = y, true) : false; }
template<class T1, class T2> bool chmax(T1 &x, T2 y) { return x < y ? (x = y, true) : false; }

struct io_setup {
    io_setup() {
        ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
        cout << fixed << setprecision(15);
    }
} io_setup;

int main(){
    while(1){
        ll B;
        cin>>B;
        if(B==0)return 0;
        B*=2;
        ll nl=0,ns=0;
        for(ll d=1;d*d<=B;d++){
            if(B%d!=0)continue;
            ll e=B/d;
            if((d-e+1)%2!=0)continue;
            ll r=(d+e-1)/2;
            ll l=e-r;
            if(l<=r){
                if(chmax(ns,r-l+1)){
                    nl=l;
                }
            }
        }
        cout<<nl<<" "<<ns<<endl;
    }
}
accuracy: 1
time_ms: 30
memory_kb: 3584
final_rank: 16

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using a2 = array<ll, 2>;
using a3 = array<ll, 3>;

template <typename A> void chmin(A &l, const A &r) {
    if(r < l)
        l = r;
}
template <typename A> void chmax(A &l, const A &r) {
    if(l < r)
        l = r;
}

ll mod = 998244353;

vector<char> isprime;
void init() {
    isprime.assign(1000005, 1);
    isprime[0] = 0;
    isprime[1] = 0;
    for(int i = 2; i < 1000005; i++) {
        if(isprime[i]) {
            for(int j = i * 2; j < 1000005; j += i) {
                isprime[j] = 0;
            }
        }
    }
}

ll n;
vector<a2> v;
void input() { cin >> n; }

void solve() {
    ll x=n,y=1;
    for(ll i = 2; i <= 100000; i++) {
        ll a = (i + 1) * i / 2;

        if(a <= n && (n - a) % i == 0) {
            x = (n-a)/i + 1;
            y = i;
        }
    }
    cout << x << ' ' << y << endl;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    // init();
    while(1) {
        input();
        if(n == 0)
            break;
        solve();
    }

    return 0;
}
accuracy: 1
time_ms: 170
memory_kb: 3460
final_rank: 12

code_snippet: #include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using str = string;
using un = unsigned;
using mint = modint998244353;
str Y = "Yes", N = "No";
ll MOD=1e+9 + 7,MOD2=998244353;
ll fast_pow(ll a,ll b){if (b < 0)return 0;ll res = 1;while (b > 0){if (b & 1)res = (res * a) % MOD;a = (a * a) % MOD;b = b / 2;}return res % MOD;};
ll fact(ll n){if (n == 0 || n == 1)return 1;return (n * fact(n - 1)) % MOD;};
ll nCr(ll n, ll r){return ((fact(n) * fast_pow(fact(r), MOD - 2)) % MOD * fast_pow(fact(n - r), MOD - 2)) % MOD;};
vector<bool> sieve(int n) {vector<bool> is_prime(n + 1, true);is_prime[0] = is_prime[1] = false;for (int i = 2; i * i <= n; ++i) {if (is_prime[i]) {for (int j = i * i; j <= n; j += i) {is_prime[j] = false;}}}return is_prime;};
//#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repp(i, n) for (ll i = 1; i <= (n); ++i)
template <class C>
void out_single (const C& v) {cout << v;}
void out_single (ostream& (*func)(ostream)) {cout << func;}
void out_single (const char& v) {cout << v;}
template <class ...C>
void in (C&&...v) {(cin >> ... >> v);}
template <class ...C>
void out (C&&...v) {(out_single(v), ...);}
template <typename T>
using vec = vector<T>;
template <typename T>
using vec2 = vector<vec<T>>;
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sall(a) sort(all(a))
#define srall(a) sort(rall(a))
using V = vec<ll>;
using P = pair<ll,ll>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; };
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; };
template<typename T> void print(const vector<T>& v) {for (const auto& i : v) cout << i /*<< " "*/; cout << endl;}
template<typename T> void print(const vector<vector<T>>& v) {for (const auto& i : v) {for (const auto& j : i) cout << j /*<< " "*/; cout << endl;}}
bool is_grid (ll h, ll w, ll y, ll x) {return (0 <= y && y < h && 0 <= x && x < w);}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    while(1){
        ll b;in(b);
        if(b==0) break;
        ll ans=0;
        for(ll i=sqrt(2*b)+2;i>0;i--){
            ll x=2*b/i-(i-1);
            if(x>0&&x%2==0&&(2*b)%i==0){
                out(x/2," ",i,"\n");
                break;
            }
        }
    }
}
accuracy: 1
time_ms: 20
memory_kb: 3584
final_rank: 15

code_snippet: #include <bits/stdc++.h>
#define rep(i,m,n) for (int i = m; i < (n); i++)
#define REP(i,m,n) for (int i = m; i <= (n); i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
int sum(int i){
    return i * (i + 1) / 2;
}
int main(){
    rep(l,0,1000){
        int b;
        cin >> b;
        if (b == 0) return 0;
        int size=ceil(sqrt(b));
        pii ans = {b, 1};
        int i = 1;
        while(sum(i) <= b){
            if(sum(i)%i==b%i&&((b-sum(i))/i)<b-i){
                ans={((b-sum(i))/i)+1, i};
            }
            i++;
        }
        cout << ans.first << " " << ans.second << endl;
    }
}
accuracy: 1
time_ms: 40
memory_kb: 3440
final_rank: 7

code_snippet: #include <bits/stdc++.h>
using namespace std;
// using mint = modint998244353;
// using mint = modint1000000007;
using ll  = long long;
using ull = unsigned long long;
#define rep(i, n) for(ll i = 0; i < n; i++)
constexpr ll INF = ((1LL << 61) + (1LL << 30) - 1);

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

  // 公差 1 の 1 ~ n 項目までの等差数列の総和
  auto sum = [](ll n) -> ll {
    return n * (n + 1) / 2;
  };

  while(true) {
    ll b;
    cin >> b;
    if(b == 0) break;
    ll start = -1, total = -1;
    for(ll w = ((ll) sqrt(b)) * 2; w >= 1; w--) {
      ll left = 1, right = 1e9;
      while(right - left > 2) {
        ll m1 = (left + right) / 2, m2 = m1 + 1;
        ll s1 = sum(m1 + w - 1) - sum(m1 - 1);
        ll s2 = sum(m2 + w - 1) - sum(m2 - 1);
        if(abs(s1 - b) < abs(s2 - b)) right = m1;
        else left = m2;
      }
      // if(w <= 10) cerr << "w: " << w << ", left: " << left << ", right: " << right << "\n";
      for(ll m = left; m <= right; m++) {
        ll s = sum(m + w - 1) - sum(m - 1);
        if(s == b) {
          start = m;
          total = w;
          break;
        }
      }
      if(total != -1) break;
    }
    cout << start << " " << total << "\n";
  }

  return 0;
}
accuracy: 1
time_ms: 2530
memory_kb: 3344
final_rank: 19

code_snippet: #include <bits/stdc++.h>
#include <unordered_map>
#include <stdlib.h>
using namespace std;
#define rep(i, a, n) for(ll i = a; i < n; i++)
#define rrep(i, a, n) for(ll i = a; i >= n; i--)
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(x) (x).begin(), (x).end()
//constexpr ll MOD = 1000000007;
constexpr ll MOD = 998244353;
constexpr int IINF = 1001001001;
constexpr ll INF = 1LL<<60;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}


ll gcd(ll a, ll b){
    if(a%b == 0){
      return b;
    }else{
      return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a*b / gcd(a, b);
}

ll powMod(ll x, ll n) {
    if (n == 0) return 1 % MOD;
    ll val = powMod(x, n / 2);
    val *= val;
    val %= MOD;
    if (n % 2 == 1) val *= x;
    return val % MOD;
}

int main() {
    while(true){
        ll n; cin >> n;
        if(n == 0) break;
        ll ans = 1;
        ll start = n;
        rep(x,2,sqrt((double)n)*2+2){
            if((2*n)%x != 0) continue;
            ll num = ((2*n)/x-x+1);
            if(num >= 1 && num%2 == 0) ans = x, start = num/2;
        }
        cout << start << " " << ans << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 3456
final_rank: 9

code_snippet: #line 1 "2018C.cpp"
#include <bits/stdc++.h>
#line 1 "/home/ardririy/repos/cp-libs/libraries-cpp/input.hpp"


#line 6 "/home/ardririy/repos/cp-libs/libraries-cpp/input.hpp"
using namespace std;
vector<long long> i64_vec_IN(int n) {vector<long long> res(n); for(int i=0; i<n; i++) { cin >> res[i]; } return res; }
vector<string> str_vec_IN(int n) { vector<string> res(n); for(int i=0; i<n; i++) { cin >> res[i]; } return res; }
vector<vector<int>> graph_IN(int n, int m) { vector<vector<int>> g(n); int u, v; for(int i=0; i<m; i++) { cin >> u >> v; u--; v--; g[u].emplace_back(v); g[v].emplace_back(u); } return g; }
vector<vector<pair<int, long long>>> weighted_graph_IN(int n, int m) { vector<vector<pair<int, long long>>> g(n); int u, v; long long w; for(int i=0; i<m; i++) { cin >> u >> v >> w; u--; v--; g[u].push_back({v, w}); g[v].push_back({u, w}); } return g; }


#line 3 "2018C.cpp"

using namespace std;

// using namespace atcoder;

#ifdef ADRY
#include <dbg.h>
#else
// DO NOTHING
#define dbg(...)
#endif


#define all(v) v.begin(),v.end()
#define resort(v) sort(v.rbegin(),v.rend())
using ll = long long;
using ull = unsigned long long;
using vll=vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,ll>;
using vp=vector<pair<ll, ll>>;
using djks=priority_queue<P, vp, greater<P>>;

const int inf=1ll<<30;
#define mod10 (ll)1e9+7
#define mod99 (ll)998244353
const double PI = acos(-1);

#define rep(i,n) for (ll i=0;i<(n);++i)
#define per(i,n) for(ll i=(n)-1;i>=0;--i)
#define rep2(i,a,n) for (ll i=(a);i<(n);++i)
#define per2(i,a,n) for (ll i=(n)-1;i>=(a);--i)


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

ll dx[] = {1, 0, -1, 0, -1, 1, -1, 1};
ll dy[] = {0, 1, 0, -1, -1, 1, 1, -1};

vll divisors(ll n) {
    vll res;
    rep2(i,1, sqrt(n)+10) {
        if(n%i==0) {
            res.emplace_back(i);
            if(i!=n/i) res.emplace_back(n/i);
        }
    }

    return res;
}

int solve(){
    ll b;
    cin >> b;

    if(b==0) return 1;
    vll div = divisors(2*b);
    P ans = {-1,-1};
    for(auto di: div) {
        ll t = 2*b/di;
        ll rhs = t+1-di;
        if(rhs<=0 || rhs%2==1) continue;
        if(chmax(ans.second, di)) {
            ans.first = rhs/2;
        }
    }
    cout << ans.first << " " << ans.second << '\n';
    return 0;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(!solve());
}
accuracy: 1
time_ms: 90
memory_kb: 3412
final_rank: 6

code_snippet: #include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define int long long

int floor_sqrt(int n) {
    int ok = 0;
    int ng = (long double)(1.2)*sqrtl(n)+1;
    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;
        if (mid*mid<=n) ok = mid;
        else ng = mid;
    }
    return ok;
}

void solve(int b) {
    b *= 2;
    int sq = floor_sqrt(b);
    pair<int, int> ans = {-1, -1};
    for (int i=1; i<=sq; ++i) {
        if (b % i != 0) continue;
        int j = b / i;
        // cout << i << " x " << j << " = " << b << endl;
        if ((j-i) % 2 == 0) continue;
        int x = (j-i+1) / 2;
        int y = j - x;
        
        //k~l階を買える
        // cout << x << " ~ " << y << endl;
        ans = max(ans, {y-x+1, x});
    }
    cout << ans.second << ' ' << ans.first << endl;
}

signed main() {
    while(true) {
        int b;
        cin >> b;
        if (b == 0) break;
        solve(b);
    }
}

/*
memo

*/
accuracy: 1
time_ms: 30
memory_kb: 3584
final_rank: 16

code_snippet: #include<iostream>
#include<vector>
using namespace std;
using ll=long long;
ll sum(ll n){return n*(n+1)/2;}
ll cost(ll a,ll n){return sum(a+n-1)-sum(a-1);}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	while(1)
	{
		int b;cin>>b;
		if(b==0)break;
		ll ans1=0,ans2=0;
		for(ll n=1;n*(n+1)/2<=b;n++)
		{
			ll l=0,r=b+1;
			while(r-l>1)
			{
				ll a=(l+r)/2;
				ll cur=cost(a,n);
				if(cur<=b)l=a;
				else r=a;
			}
			if(cost(l,n)==b)ans1=l,ans2=n;
		}
		cout<<ans1<<" "<<ans2<<endl;
	}
}
accuracy: 1
time_ms: 1550
memory_kb: 3584
final_rank: 20

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


using namespace std;
//make -f ../makefile SRC=
/*

*/


//------------------------------------------------------------------------------
bool DEBUG = false;
const int INF = 2147483647;

//const int MAX_N = 100000;
//static int vect[MAX_N];
typedef pair<int,int> PA;
//------------------------------------------------------------------------------
// return {a, n}
PA solve(int sum)
{
    // (2*a + n-1)*n = 2*sum
    //--------------------------------------------------------------------------
    // base cases:
    if (sum ==  1) return {1, 1};
    else if (sum ==  2) return {2, 1};
    else if (sum ==  3) return {1, 2};
    //--------------------------------------------------------------------------
    // init:
    sum *= 2;
    //--------------------------------------------------------------------------
    // compute:
    for (int n=sqrt(sum); n>0; --n)
    {
        if (sum%n != 0) continue;

        int q = sum/n;
        if (q < n+1) continue;

        int aa = q - n + 1;
        if (aa%2 != 0) continue;

        return {aa/2, n};
    }
    //--------------------------------------------------------------------------
    // report:
    return {-1, -1};
}

//------------------------------------------------------------------------------
void test()
{

}

//------------------------------------------------------------------------------
int main()
{
    //test(); return 0;
    //DEBUG = true;
    //--------------------------------------------------------------------------
    int N, K, sum, num;
    while (true)
    {
        num = scanf("%d ", &sum); if (sum == 0) break;
        PA p = solve(sum);
        printf("%d %d\n", p.first, p.second);
    }
    //--------------------------------------------------------------------------
    return 0;
}
//------------------------------------------------------------------------------
accuracy: 1
time_ms: 10
memory_kb: 3580
final_rank: 14

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

#if __cplusplus <= 201703L
#define ssize(v) ((int)(v).size())
template<typename T> ll bit_ceil(T n) {
  ll r = 1;
  while(r < n) { r <<= 1; }
  return r;
}
template<typename T> ll bit_width(T n) { return 64 - __builtin_clzll(n); }
template<typename T> ll countr_zero(T n) { return __builtin_ctzll(n); }
template<typename T> ll popcount(T n) { return __builtin_popcountll(n); }
namespace ranges {
template<typename T> void sort(vector<T> &v) { sort(v.begin(), v.end()); }
template<typename T> void stable_sort(vector<T> &v) { stable_sort(v.begin(), v.end()); }
template<typename T, typename F> void sort(vector<T> &v, const F &f) { sort(v.begin(), v.end(), f); }
template<typename T> void reverse(vector<T> &v) { reverse(v.begin(), v.end()); }
template<typename T> T max(const vector<T> &v) { return *max_element(v.begin(), v.end()); }
template<typename T> T min(const vector<T> &v) { return *min_element(v.begin(), v.end()); }
template<typename T, typename U> bool binary_search(const vector<T> &v, U x) { return binary_search(v.begin(), v.end(), x); }
template<typename T, typename F> bool all_of(const vector<T> &v, const F &f) { return all_of(v.begin(), v.end(), f); }
template<typename T, typename F> bool any_of(const vector<T> &v, const F &f) { return any_of(v.begin(), v.end(), f); }
template<typename T, typename F> bool none_of(const vector<T> &v, const F &f) { return none_of(v.begin(), v.end(), f); }
template<typename T, typename F> int count_if(const vector<T> &v, const F &f) { return count_if(v.begin(), v.end(), f); }
template<typename T, typename U> auto lower_bound(const vector<T> &v, U x) { return lower_bound(v.begin(), v.end(), x); }
template<typename T, typename U> auto upper_bound(const vector<T> &v, U x) { return upper_bound(v.begin(), v.end(), x); }
template<typename T, typename U, typename F> auto lower_bound(const vector<T> &v, U x, const F &f) { return lower_bound(v.begin(), v.end(), x, f); }
template<typename T, typename U, typename F> auto upper_bound(const vector<T> &v, U x, const F &f) { return upper_bound(v.begin(), v.end(), x, f); }
template<typename T> auto max_element(const vector<T> &v) { return max_element(v.begin(), v.end()); }
template<typename T> auto min_element(const vector<T> &v) { return min_element(v.begin(), v.end()); }
template<typename T, typename U> void fill(vector<T> &v, U x) { fill(v.begin(), v.end(), x); }
}  // namespace ranges
#endif

vector<ll> Divisor(ll n) {
  vector<ll> r;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      r.emplace_back(i);
      if(i * i != n) { r.emplace_back(n / i); }
    }
  }
  ranges::sort(r);
  return r;
}

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

  while(true) {
    ll N;
    cin >> N;
    if(!N) { break; }

    pair<ll, ll> ans = {1, N};
    for(auto &i : Divisor(N)) {
      if((N / i) & 1) {
        if(i - (N / i) / 2 >= 1) { ans = max(ans, {N / i, i - (N / i) / 2}); }
      }
      if(i & 1 && i / 2 - N / i >= 0) { ans = max(ans, {N / i * 2, i / 2 - N / i + 1}); }
    }

    cout << ans.second << " " << ans.first << "\n";
  }
}
accuracy: 1
time_ms: 50
memory_kb: 3376
final_rank: 3

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef pair<ll,ll> pi;
typedef pair<ll,pi> ppi;
#define FOR(i,l,r) for(ll i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,l,r) for(ll i=r-1;i>=l;i--)
#define RREP(i,n) RFOR(i,0,n)
#define sz(A) (ll)(A.size())
#define ALL(A) A.begin(),A.end()
#define LB(A,x) (ll)(lower_bound(ALL(A),x)-A.begin())
#define UB(A,x) (ll)(upper_bound(ALL(A),x)-A.begin())
#define COU(A,x) (UB(A,x)-LB(A,x))
#define F first
#define S second
template<typename T>using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<typename T1,typename T2>ostream&operator<<(ostream&os,pair<T1,T2>&p){os<<p.F<<" "<<p.S;return os;}
template<typename T1,typename T2>istream&operator>>(istream&is,pair<T1,T2>&p){is>>p.F>>p.S;return is;}
template<typename T>ostream&operator<<(ostream&os,vector<T>&v){REP(i,sz(v))os<<v[i]<<(i+1!=sz(v)?" ":"");return os;}
template<typename T>istream&operator>>(istream&is,vector<T>&v){for(T&in:v)is>>in;return is;}
template<class T>bool chmax(T&a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T&a,T b){if(b<a){a=b;return 1;}return 0;}
const ll mod=998244353;
template<const long long int mod=998244353>
struct modint{
  using mint=modint<mod>;
  long long int x;
  modint(long long int _x=0):x(_x%mod){if(x<0)x+=mod;}
  long long int val(){return x;}
  mint&operator=(const mint&a){x=a.x;return *this;}
  mint&operator+=(const mint&a){x+=a.x;if(x>=mod)x-=mod;return *this;}
  mint&operator-=(const mint&a){x-=a.x;if(x<0)x+=mod;return *this;}
  mint&operator*=(const mint&a){x*=a.x;x%=mod;return *this;}
  friend mint operator+(const mint&a,const mint&b){return mint(a)+=b;}
  friend mint operator-(const mint&a,const mint&b){return mint(a)-=b;}
  friend mint operator*(const mint&a,const mint&b){return mint(a)*=b;}
  mint operator-()const{return mint(0)-*this;}
  mint pow(long long int n){
    if(!n)return 1;
    mint a=1;
    mint _x=x;
    while(n){
      if(n&1)a*=_x;
      _x=_x*_x;n>>=1;
    }
    return a;
  }
  mint inv(){return pow(mod-2);}
  mint&operator/=(mint&a){return *this*=a.inv();}
  friend mint operator/(const mint&a,mint b){return mint(a)/=b;}
};
using mint=modint<998244353>;
int main(){
    while(1){
      ll N;cin>>N;
      if(!N)return 0;
      set<ll>D;
      FOR(i,1,100000)if(2*N%i==0)D.insert(i),D.insert(2*N/i);
      ll l=N,r=N;
      for(auto d:D){
        if(2*N/d-d+1>0&&(2*N/d-d+1)%2==0)l=(2*N/d-d+1)/2,r=d;
      }
      cout<<l<<" "<<r<<endl;
    }
    return 0;
}
accuracy: 1
time_ms: 610
memory_kb: 3380
final_rank: 10

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

using namespace std;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end())
#define SZ(v) (int)v.size()
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))
#define LB(v, x) int(lower_bound(ALL(v), (x)) - (v).begin())
#define UB(v, x) int(upper_bound(ALL(v), (x)) - (v).begin())

using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
const int inf = 0x3fffffff;
const ll INF = 0x1fffffffffffffff;

template <typename T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T, typename U> T ceil(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U> T floor(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T> int popcnt(T x) {
    return __builtin_popcountll(x);
}
template <typename T> int topbit(T x) {
    return (x == 0 ? -1 : 63 - __builtin_clzll(x));
}
template <typename T> int lowbit(T x) {
    return (x == 0 ? -1 : __builtin_ctzll(x));
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "P(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#ifdef LOCAL
#define show(...) _show(0, #__VA_ARGS__, __VA_ARGS__)
#else
#define show(...) true
#endif
template <typename T> void _show(int i, T name) {
    cerr << '\n';
}
template <typename T1, typename T2, typename... T3>
void _show(int i, const T1 &a, const T2 &b, const T3 &...c) {
    for (; a[i] != ',' && a[i] != '\0'; i++)
        cerr << a[i];
    cerr << ":" << b << " ";
    _show(i + 1, a, c...);
}

#include <unistd.h>

namespace fastio {
static constexpr uint32_t SZ = 1 << 17;
char ibuf[SZ];
char obuf[SZ];
char out[100];
// pointer of ibuf, obuf


uint32_t pil = 0, pir = 0, por = 0;

struct Pre {
    char num[10000][4];
    constexpr Pre() : num() {
        for (int i = 0; i < 10000; i++) {
            int n = i;
            for (int j = 3; j >= 0; j--) {
                num[i][j] = n % 10 | '0';
                n /= 10;
            }
        }
    }
} constexpr pre;

inline void load() {
    memmove(ibuf, ibuf + pil, pir - pil);
    pir = pir - pil + fread(ibuf + pir - pil, 1, SZ - pir + pil, stdin);
    pil = 0;
    if (pir < SZ)
        ibuf[pir++] = '\n';
}

inline void flush() {
    fwrite(obuf, 1, por, stdout);
    por = 0;
}

void rd(char &c) {
    do {
        if (pil + 1 > pir)
            load();
        c = ibuf[pil++];
    } while (isspace(c));
}

void rd(string &x) {
    x.clear();
    char c;
    do {
        if (pil + 1 > pir)
            load();
        c = ibuf[pil++];
    } while (isspace(c));
    do {
        x += c;
        if (pil == pir)
            load();
        c = ibuf[pil++];
    } while (!isspace(c));
}

template <typename T> void rd_real(T &x) {
    string s;
    rd(s);
    x = stod(s);
}

template <typename T> void rd_integer(T &x) {
    if (pil + 100 > pir)
        load();
    char c;
    do
        c = ibuf[pil++];
    while (c < '-');
    bool minus = 0;
    if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
        if (c == '-') {
            minus = 1, c = ibuf[pil++];
        }
    }
    x = 0;
    while ('0' <= c) {
        x = x * 10 + (c & 15), c = ibuf[pil++];
    }
    if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
        if (minus)
            x = -x;
    }
}

void rd(int &x) {
    rd_integer(x);
}
void rd(ll &x) {
    rd_integer(x);
}
void rd(i128 &x) {
    rd_integer(x);
}
void rd(uint &x) {
    rd_integer(x);
}
void rd(ull &x) {
    rd_integer(x);
}
void rd(u128 &x) {
    rd_integer(x);
}
void rd(double &x) {
    rd_real(x);
}
void rd(long double &x) {
    rd_real(x);
}

template <class T, class U> void rd(pair<T, U> &p) {
    return rd(p.first), rd(p.second);
}
template <size_t N = 0, typename T> void rd_tuple(T &t) {
    if constexpr (N < std::tuple_size<T>::value) {
        auto &x = std::get<N>(t);
        rd(x);
        rd_tuple<N + 1>(t);
    }
}
template <class... T> void rd(tuple<T...> &tpl) {
    rd_tuple(tpl);
}

template <size_t N = 0, typename T> void rd(array<T, N> &x) {
    for (auto &d : x)
        rd(d);
}
template <class T> void rd(vector<T> &x) {
    for (auto &d : x)
        rd(d);
}

void read() {}
template <class H, class... T> void read(H &h, T &...t) {
    rd(h), read(t...);
}

void wt(const char c) {
    if (por == SZ)
        flush();
    obuf[por++] = c;
}
void wt(const string s) {
    for (char c : s)
        wt(c);
}
void wt(const char *s) {
    size_t len = strlen(s);
    for (size_t i = 0; i < len; i++)
        wt(s[i]);
}

template <typename T> void wt_integer(T x) {
    if (por > SZ - 100)
        flush();
    if (x < 0) {
        obuf[por++] = '-', x = -x;
    }
    int outi;
    for (outi = 96; x >= 10000; outi -= 4) {
        memcpy(out + outi, pre.num[x % 10000], 4);
        x /= 10000;
    }
    if (x >= 1000) {
        memcpy(obuf + por, pre.num[x], 4);
        por += 4;
    } else if (x >= 100) {
        memcpy(obuf + por, pre.num[x] + 1, 3);
        por += 3;
    } else if (x >= 10) {
        int q = (x * 103) >> 10;
        obuf[por] = q | '0';
        obuf[por + 1] = (x - q * 10) | '0';
        por += 2;
    } else
        obuf[por++] = x | '0';
    memcpy(obuf + por, out + outi + 4, 96 - outi);
    por += 96 - outi;
}

template <typename T> void wt_real(T x) {
    ostringstream oss;
    oss << fixed << setprecision(15) << double(x);
    string s = oss.str();
    wt(s);
}

void wt(int x) {
    wt_integer(x);
}
void wt(ll x) {
    wt_integer(x);
}
void wt(i128 x) {
    wt_integer(x);
}
void wt(uint x) {
    wt_integer(x);
}
void wt(ull x) {
    wt_integer(x);
}
void wt(u128 x) {
    wt_integer(x);
}
void wt(double x) {
    wt_real(x);
}
void wt(long double x) {
    wt_real(x);
}

template <class T, class U> void wt(const pair<T, U> val) {
    wt(val.first);
    wt(' ');
    wt(val.second);
}
template <size_t N = 0, typename T> void wt_tuple(const T t) {
    if constexpr (N < std::tuple_size<T>::value) {
        if constexpr (N > 0) {
            wt(' ');
        }
        const auto x = std::get<N>(t);
        wt(x);
        wt_tuple<N + 1>(t);
    }
}
template <class... T> void wt(tuple<T...> tpl) {
    wt_tuple(tpl);
}
template <class T, size_t S> void wt(const array<T, S> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
        if (i)
            wt(' ');
        wt(val[i]);
    }
}
template <class T> void wt(const vector<T> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
        if (i)
            wt(' ');
        wt(val[i]);
    }
}

void print() {
    wt('\n');
}
template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) {
    wt(head);
    if (sizeof...(Tail))
        wt(' ');
    print(forward<Tail>(tail)...);
}
void __attribute__((destructor)) _d() {
    flush();
}
} // namespace fastio


using fastio::flush;
using fastio::print;
using fastio::read;

inline void first(bool i = true) {
    print(i ? "first" : "second");
}
inline void Alice(bool i = true) {
    print(i ? "Alice" : "Bob");
}
inline void Takahashi(bool i = true) {
    print(i ? "Takahashi" : "Aoki");
}
inline void yes(bool i = true) {
    print(i ? "yes" : "no");
}
inline void Yes(bool i = true) {
    print(i ? "Yes" : "No");
}
inline void No() {
    print("No");
}
inline void YES(bool i = true) {
    print(i ? "YES" : "NO");
}
inline void NO() {
    print("NO");
}
inline void Yay(bool i = true) {
    print(i ? "Yay!" : ":(");
}
inline void Possible(bool i = true) {
    print(i ? "Possible" : "Impossible");
}
inline void POSSIBLE(bool i = true) {
    print(i ? "POSSIBLE" : "IMPOSSIBLE");
}

/**
 * @brief Fast IO
 */

template <unsigned mod = 1000000007> struct fp {
    unsigned v;
    static constexpr int get_mod() {
        return mod;
    }
    constexpr unsigned inv() const {
        assert(v != 0);
        int x = v, y = mod, p = 1, q = 0, t = 0, tmp = 0;
        while (y > 0) {
            t = x / y;
            x -= t * y, p -= t * q;
            tmp = x, x = y, y = tmp;
            tmp = p, p = q, q = tmp;
        }
        if (p < 0)
            p += mod;
        return p;
    }
    constexpr fp(ll x = 0) : v(x >= 0 ? x % mod : (mod - (-x) % mod) % mod) {}
    fp operator-() const {
        return fp() - *this;
    }
    fp pow(ull t) {
        fp res = 1, b = *this;
        while (t) {
            if (t & 1)
                res *= b;
            b *= b;
            t >>= 1;
        }
        return res;
    }
    fp &operator+=(const fp &x) {
        if ((v += x.v) >= mod)
            v -= mod;
        return *this;
    }
    fp &operator-=(const fp &x) {
        if ((v += mod - x.v) >= mod)
            v -= mod;
        return *this;
    }
    fp &operator*=(const fp &x) {
        v = ull(v) * x.v % mod;
        return *this;
    }
    fp &operator/=(const fp &x) {
        v = ull(v) * x.inv() % mod;
        return *this;
    }
    fp operator+(const fp &x) const {
        return fp(*this) += x;
    }
    fp operator-(const fp &x) const {
        return fp(*this) -= x;
    }
    fp operator*(const fp &x) const {
        return fp(*this) *= x;
    }
    fp operator/(const fp &x) const {
        return fp(*this) /= x;
    }
    bool operator==(const fp &x) const {
        return v == x.v;
    }
    bool operator!=(const fp &x) const {
        return v != x.v;
    }
    friend istream &operator>>(istream &is, fp &x) {
        return is >> x.v;
    }
    friend ostream &operator<<(ostream &os, const fp &x) {
        return os << x.v;
    }
};

template <unsigned mod> void rd(fp<mod> &x) {
    fastio::rd(x.v);
}
template <unsigned mod> void wt(fp<mod> x) {
    fastio::wt(x.v);
}

template <typename T> T Inv(ll n) {
    static const int md = T::get_mod();
    static vector<T> buf({0, 1});
    assert(n > 0);
    n %= md;
    while (SZ(buf) <= n) {
        int k = SZ(buf), q = (md + k - 1) / k;
        buf.push_back(buf[k * q - md] * q);
    }
    return buf[n];
}

template <typename T> T Fact(ll n, bool inv = 0) {
    static const int md = T::get_mod();
    static vector<T> buf({1, 1}), ibuf({1, 1});
    assert(n >= 0 and n < md);
    while (SZ(buf) <= n) {
        buf.push_back(buf.back() * SZ(buf));
        ibuf.push_back(ibuf.back() * Inv<T>(SZ(ibuf)));
    }
    return inv ? ibuf[n] : buf[n];
}

template <typename T> T nPr(int n, int r, bool inv = 0) {
    if (n < 0 || n < r || r < 0)
        return 0;
    return Fact<T>(n, inv) * Fact<T>(n - r, inv ^ 1);
}
template <typename T> T nCr(int n, int r, bool inv = 0) {
    if (n < 0 || n < r || r < 0)
        return 0;
    return Fact<T>(n, inv) * Fact<T>(r, inv ^ 1) * Fact<T>(n - r, inv ^ 1);
}
template <typename T> T nHr(int n, int r, bool inv = 0) {
    return nCr<T>(n + r - 1, r, inv);
}

/**
 * @brief Modint
 */

int main() {
while(1) {
    ll X;
    cin >> X;
    if (X == 0) return 0;
    X *= 2;
    vector<ll> V;
    for (ll i = 1; i * i <= X; i++) {
        if (X % i == 0) V.push_back(i);
    }
    reverse(V.begin(), V.end());
    for (ll P : V) {
        ll Q = X / P;
        if ((Q - P + 1) % 2 != 0) continue;
        if (Q - P  + 1> 0) {
            cout << (Q - P + 1) / 2 << ' ' << P << endl;
            break;
        }
    }
}
}
accuracy: 1
time_ms: 80
memory_kb: 3408
final_rank: 5