Problem:
Problem A:
Sum of Consecutive Integers
あなたは数か月に渡る受験戦争を勝ち抜き，晴れてICPC大学に入学することができた．入学手続きの日，大学のキャンパス内では熱狂的なサークルの勧誘活動が行われており，あなたは大量のパンフレットを受け取って帰ってきた．部屋に戻ってきたあなたは受け取ったパンフレットの中から気になる一枚を見つけた．そのパンフレットは大学の広報部から渡されたものだった．
パンフレットには以下のような問題が記されていた．
和が
N
となるような，連続する2つ以上の正の整数の組み合わせは，何組存在するでしょうか？例えば， 9 は 2+3+4 と 4+5 の 2通りの組み合わせがあります．
この問題の答えが気になったあなたは，プログラムを書いてその答えを調べることにした．したがって，あなたの仕事は，入力として与えられる正の整数
N
に対して，問題の答えを出力するプログラムを書くことである．
Input
入力はデータセットの並びである．各データセットはひとつの整数
N
からなる一行である．ここで 1 ≤
N
≤ 1000 である．
入力の終りは，ひとつのゼロからなる一行で示される．
Output
出力は，入力の各データセットの表す正の整数に対する問題の答えを，入力データセットの順序通りに並べたものである．それ以外の文字が出力にあってはならない．
Sample Input
9
500
0
Output for the Sample Input
2
3

Submitted solutions:

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

int main() {
    while (true) {
        int N;
        std::cin >> N;

        if (N == 0)
            break;

        int ans = 0;

        for (int i = 1; i <= N; i++)
            for (int j = i + 1; j <= N; j++) {
                int sum = (i + j) * (j - i + 1) / 2;
                // std::cout << i << ' ' << j << " " << sum << std::endl;
                ans += sum == N;
            }

        std::cout << ans << std::endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3368
final_rank: 11

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

int main(){
    vector<int> cum(1001, 0);
    for(int i = 1; i <= 1000; ++i) cum[i] = cum[i - 1] + i;
    while(1){
        int N; cin >> N;
        if(N == 0) break;

        int ans = 0;
        for(int i = 0; i < 1000; ++i){
            for(int j = i + 2; j <= 1000; ++j){
                if(cum[j] - cum[i] == N) ++ans;
            }
        }
        cout << ans << endl;
    }
}
accuracy: 1
time_ms: 20
memory_kb: 3348
final_rank: 15

code_snippet: #include<bits/stdc++.h>
using namespace std;
#define SIZE 1005
int main(){
    int n;
    while(true){
        int sum[SIZE];
        sum[0]=0;
        int count=0;

        cin>>n;
        if(n==0)break;
        for(int i=1;i<n;i++){
            sum[i]=sum[i-1]+i;
        }
        for(int i=1;i<n;i++){
            for(int j=0;j<i;j++){
                if((sum[i]-sum[j])==n)count++;
            }
        }
        cout<<count<<endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 2996
final_rank: 1

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

#define rep(i,k,n) for (int i = k; i < (n); ++i)
const long long MOD1 = 1000000007;
const long long MOD2 = 998244353;
typedef long long ll;
typedef pair<ll, ll> P;
const long long INF = 1e17;

int main(){
    while(true){
        int n;
        cin >> n;
        if(n==0){
            break;
        }

        //sum[i] = 0~iまでの和
        vector<int> sum(n+1);
        for(int i=0;i<=n;i++){
            sum[i] = i;
        }
        for(int i=1;i<=n;i++){
            sum[i] += sum[i-1];
        }

        int ans = 0;
        //(l,r]の和
        for(int l=0;l<=n;l++){
            for(int r=l+2;r<=n;r++){
                if(sum[r]-sum[l]==n){
                    ans++;
                }
            }
        }

        cout << ans << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3024
final_rank: 2

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

#define all(v) v.begin(),v.end()
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 mint=modint1000000007;
//using mint=modint998244353;

const ll INF=1ll<<60;
ll mod10=1e9+7;
ll mod99=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=a;i>=n;--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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        ll N;cin>>N;
        if(N==0) break;
        ll ans=0;
        rep2(i,1,N){
            ll sum=0;
            rep(j,N+1){
                sum+=i+j;
                if(sum==N) ans++;
            }
           
        }
        cout<<ans<<endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3356
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(a) a.begin(),a.end()
#define reps(i, a, n) for (int i = (a); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)
#define rreps(i, a, n) for (int i = (a); i > (int)(n); i--)
const long long mod = 1000000007;
const long long INF = 1e18;

int mt(int n) {
    return n*(n+1)/2;
}

int main() {
    int n;
    while (true) {
        cin >> n;
        if (!n) {
            return 0;
        }
        int ans = 0;
        
        for (int i = 1; i < 501; i++) {
            for (int j = i+1; j < 501; j++) {
                if (mt(j)-mt(i-1) == n) {
                    ans++;
                }
            }
        }

        cout << ans << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3132
final_rank: 5

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

int main() {
    int sum[1000];
    sum[0] = 0;
    for (int i = 1; i < 1000; i++) {
        sum[i] = sum[i - 1] + i;
    }
    while (1) {
        int n;
        cin >> n;
        if (n == 0) break;
        int cnt = 0;
        for (int i = 0; i < 1000; i++) {
            for (int j = i + 2; j < 1000; j++) {
                if (sum[j] - sum[i] == n) {
                    cnt++;
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 3004
final_rank: 17

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

int main(){
  map<int,int> ans;
  for(int i=1;i<=499;i++){
    for(int j=i+1;j<=500;j++){
      int S = (i+j)*(j-i+1)/2;
      ans[S]++;
    }
  }
  for(;;){
    int N;
    cin >> N;
    if(N == 0) break;
    cout << ans[N] << endl;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 5740
final_rank: 18

code_snippet: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <set>
#include <map>
#include <queue>
#include <cassert>
#include <numeric>



using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(n);i++)
#define P pair<int, int>


int main() {
	int n;
	int ans = 0;
	vector<int>sum;

	cin >> n;
	while (n != 0) {
		sum.push_back(0);
		rep(i, n) {
			sum.push_back(sum[i] + i+1);
		}
		rep(i, sum.size()-1) {
			for (int j = i + 1;j < sum.size();j++) {
				if (sum[j] - sum[i] == n && j - i != 1)ans++;
			}
		}
		cout << ans << endl;
		ans = 0; 
		sum.clear();
		cin >> n;
	}
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3144
final_rank: 6

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

bool solve(){
    int N;
    cin>>N;
    if(N==0)return false;
    int ans=0;
    vector<int>S(N+1);
    for(int i=1;i<=N;i++){
        S[i]=S[i-1]+i;
    }
    for(int i=0;i<N;i++)for(int j=i+2;j<=N;j++){
        if(S[j]-S[i]==N)ans++;
    }
    cout<<ans<<"\n";
    return true;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    while(1){
        if(!solve()){
            return 0;
        }
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3148
final_rank: 7

code_snippet: #include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin Header {{{
#pragma region
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rep(i, b, e) for (intmax_t i = (b), i##_limit = (e); i < i##_limit; ++i)
#define repc(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i)
#define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i)
#define var(Type, ...) \
    Type __VA_ARGS__;  \
    input(__VA_ARGS__)
#define let const auto

constexpr size_t operator""_zu(unsigned long long value) {
    return value;
};
constexpr intmax_t operator""_jd(unsigned long long value) {
    return value;
};
constexpr uintmax_t operator""_ju(unsigned long long value) {
    return value;
};

constexpr int INF = 0x3f3f3f3f;
constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd;

using usize = size_t;
using imax = intmax_t;
using uimax = uintmax_t;
using ld = long double;

template <class T, class Compare = less<>>
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template <class T, class Compare = greater<>>
using MinHeap = priority_queue<T, vector<T>, Compare>;

inline void input() {}
template <class Head, class... Tail>
inline void input(Head&& head, Tail&&... tail) {
    cin >> head;
    input(forward<Tail>(tail)...);
}

template <class Container, class Value = typename Container::value_type,
          enable_if_t<!is_same<Container, string>::value, nullptr_t> = nullptr>
inline istream& operator>>(istream& is, Container& vs) {
    for (auto& v: vs) is >> v;
    return is;
}

template <class T, class U>
inline istream& operator>>(istream& is, pair<T, U>& p) {
    is >> p.first >> p.second;
    return is;
}

inline void output() {
    cout << "\n";
}
template <class Head, class... Tail>
inline void output(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << " ";
    output(forward<Tail>(tail)...);
}

template <class Container, class Value = typename Container::value_type,
          enable_if_t<!is_same<Container, string>::value, nullptr_t> = nullptr>
inline ostream& operator<<(ostream& os, const Container& vs) {
    static constexpr const char* delim[] = {" ", ""};
    for (auto it = begin(vs); it != end(vs); ++it) {
        os << delim[it == begin(vs)] << *it;
    }
    return os;
}

template <class Iterator>
inline void join(const Iterator& Begin, const Iterator& End, const string& delim = "\n",
                 const string& last = "\n") {
    for (auto it = Begin; it != End; ++it) {
        cout << ((it == Begin) ? "" : delim) << *it;
    }
    cout << last;
}

template <class T>
inline vector<T> makeVector(const T& init_value, size_t sz) {
    return vector<T>(sz, init_value);
}

template <class T, class... Args>
inline auto makeVector(const T& init_value, size_t sz, Args... args) {
    return vector<decltype(makeVector<T>(init_value, args...))>(
        sz, makeVector<T>(init_value, args...));
}

template <class Func>
class FixPoint : Func {
public:
    explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {}

    template <class... Args>
    constexpr decltype(auto) operator()(Args&&... args) const {
        return Func::operator()(*this, std::forward<Args>(args)...);
    }
};

template <class Func>
static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept {
    return FixPoint<Func> {forward<Func>(f)};
}

template <class Container>
struct reverse_t {
    Container& c;
    reverse_t(Container& c) : c(c) {}
    auto begin() {
        return c.rbegin();
    }
    auto end() {
        return c.rend();
    }
};

template <class Container>
auto reversed(Container& c) {
    return reverse_t<Container>(c);
}

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

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

template <class T>
inline T diff(const T& a, const T& b) noexcept {
    return a < b ? b - a : a - b;
}

template <class T>
inline T sigma(const T& l, const T& r) noexcept {
    return (l + r) * (r - l + 1) / 2;
}

template <class T>
inline T ceildiv(const T& n, const T& d) noexcept {
    return (n + d - 1) / d;
}

void operator|=(vector<bool>::reference lhs, const bool rhs) {
    lhs = lhs | rhs;
}

void operator&=(vector<bool>::reference lhs, const bool rhs) {
    lhs = lhs & rhs;
}

void operator^=(vector<bool>::reference lhs, const bool rhs) {
    lhs = lhs ^ rhs;
}

void ioinit() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
    clog << fixed << setprecision(10);
}
#pragma endregion
// }}} End Header

int main() {
    ioinit();

    intmax_t N;
    while (input(N), N) {
        intmax_t res = 0;
        repc(l, 1, N) repc(r, l + 1, N) {
            res += sigma(l, r) == N;
        }
        output(res);
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3456
final_rank: 14

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

// template {{{
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

#define  range(i, l, r) for (i64 i = (i64)(l); i < (i64)(r); (i) += 1)
#define rrange(i, l, r) for (i64 i = (i64)(r) - 1; i >= (i64)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(i32 x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != (int)v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solve(int n) {
  vector< int > rs(n);
  whole(iota, rs, 0);
  range(i, 1, rs.size()) rs[i] += rs[i - 1];

  int ans = 0;
  range(r, 1, rs.size()) range(l, 0, r) {
    if (rs[r] - rs[l] == n) ans++;
  }

  cout << ans << endl;
}

signed main() {
  int n;

  while (cin >> n, n) {
    solve(n);
  }
}
accuracy: 1
time_ms: 10
memory_kb: 3372
final_rank: 12

code_snippet: #pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define _overload(_1, _2, _3, _4, name, ...) name
#define _rep1(Itr, N) _rep3(Itr, 0, N, 1)
#define _rep2(Itr, a, b) _rep3(Itr, a, b, 1)
#define _rep3(Itr, a, b, step) for (i64 Itr = a; Itr < b; Itr += step)
#define repeat(...) _overload(__VA_ARGS__, _rep3, _rep2, _rep1)(__VA_ARGS__)
#define rep(...) repeat(__VA_ARGS__)

#define ALL(X) begin(X), end(X)

using namespace std;
using i64 = int64_t;
using u64 = uint64_t;

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

  i64 n;
  while (cin >> n, n > 0) {
    i64 ans = 0;
    rep(i, 1, n + 1) {
      rep(j, i + 2, n + 1) {
        // [i, j)
        if (n == j * (j - 1) / 2 - i * (i - 1) / 2) ans++;
      }
    }

    cout << ans << endl;
  }

  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3336
final_rank: 9

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define req(i, a, b) for (ll i = (a); i < (b); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << (x) << '\n'
#define debug2(x, y) cerr << __LINE__ << ' ' << #x << ':' << (x) << ',' << #y << ':' << (y) << '\n'
#define debug3(x, y, z) cerr << __LINE__ << ' ' << #x << ':' << (x) << ',' << #y << ':' << (y) << ',' << #z << ':' << (z) << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;
template<class T> using pri_s = priority_queue<T, vector<T>, greater<T>>;
template<class T> using pri_b = priority_queue<T>;
constexpr int inf = 1000000010;
constexpr int inf2 = 2000000010;
constexpr ll INF = 1000000000000000010;
constexpr ll INF4 = 4000000000000000010;
constexpr int mod1e9 = 1000000007;
constexpr int mod998 = 998244353;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
constexpr ll ten(int n) { return n ? 10 * ten(n - 1) : 1; };
int dx[] = { 1,0,-1,0,1,1,-1,-1,0 }; int dy[] = { 0,1,0,-1,1,-1,1,-1,0 };
ll mul(ll a, ll b) { return (a > INF / b ? INF : a * b); }
void fail() { cout << "-1\n"; exit(0); } void no() { cout << "No\n"; exit(0); }
template<class T> void er(T a) { cout << a << '\n'; exit(0); }
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }
template<class T> istream &operator >> (istream &s, vector<T> &v) { for (auto &e : v) s >> e; return s; }
template<class T> ostream &operator << (ostream &s, const vector<T> &v) { for (auto &e : v) s << e << ' '; return s; }
template<class T, class U> ostream &operator << (ostream &s, const pair<T, U> &p) { s << p.first << ' ' << p.second; return s; }

struct fastio {
	fastio() {
		cin.tie(0); cout.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(20);
		cerr << fixed << setprecision(20);
	}
}fastio_;

namespace library {
	random_device seed_gen;
	mt19937_64 engine(seed_gen());
	ll rnum(ll r) { return engine() % r; }
	ll rnum(ll l, ll r) { return rnum(r - l) + l; }
	vector<ll> rvec(ll n, ll r) {
		vector<ll> res(n);
		rep(i, n) res[i] = rnum(r);
		return res;
	}
	vector<ll> rvec(ll n, ll l, ll r) {
		vector<ll> res(n);
		rep(i, n) res[i] = rnum(l, r);
		return res;
	}
	vector<vector<ll>> avec(ll n, ll l, ll r) {
		if (n == 0) return { {} };
		vector<vector<ll>> pre = avec(n - 1, l, r);
		vector<vector<ll>> res;
		for (vector<ll> v : pre) {
			for (int i = l; i < r; i++) {
				vector<ll> w = v;
				w.pb(i);
				res.pb(w);
			}
		}
		return res;
	}
	vector<vector<ll>> avec(ll n, ll r) { return avec(n, 0, r); }
	vector<vector<ll>> bvec(ll n, ll l, ll r) {
		if (n == 0) return { {} };
		vector<vector<ll>> pre = bvec(n - 1, l, r);
		vector<vector<ll>> res;
		for (vector<ll> v : pre) {
			int b = l;
			if (!v.empty()) b = v.back();
			for (int i = b; i < r; i++) {
				vector<ll> w = v;
				w.pb(i);
				res.pb(w);
			}
		}
		return res;
	}
	vector<vector<ll>> bvec(ll n, ll r) { return bvec(n, 0, r); }
	template<class T> void shuf(vector<T> &v) { shuffle(all(v), engine); }
}

using namespace library;

constexpr ll mod = mod1e9;
template <int mod> class modint {
public:
	int n;
	modint() : n(0) {};
	modint(ll n_) {
		n = n_ % mod;
		if (n < 0) n += mod;
	}
	modint operator -() const { return n > 0 ? mod - n : -n; }
	bool operator == (const modint &m) const { return n == m.n; }
	bool operator != (const modint &m) const { return n != m.n; }
	modint &operator += (const modint &m) { n += m.n; if (n >= mod) n -= mod; return *this; }
	modint &operator -= (const modint &m) { n -= m.n; if (n < 0) n += mod; return *this; }
	modint &operator *= (const modint &m) { n = ll(n) * m.n % mod; return *this; }
	modint &operator /= (const modint &m) { n = ll(n) * modinv(m).n % mod; return *this; }
	modint operator +(modint m) const { return modint(*this) += m; }
	modint operator -(modint m) const { return modint(*this) -= m; }
	modint operator *(modint m) const { return modint(*this) *= m; }
	modint operator /(modint m) const { return modint(*this) /= m; }
	modint &operator ++ () { *this += 1; return *this; }
	modint operator ++ (int) { *this += 1; return *this - 1; }
	modint &operator -- () { *this -= 1; return *this; }
	modint operator -- (int) { *this -= 1; return *this + 1; }
	modint pow(ll b) const {
		modint res = 1, a = modint(*this);
		while (b) {
			if (b & 1) res *= a;
			a *= a;
			b >>= 1;
		}
		return res;
	}
	friend istream &operator >> (istream &s, modint<mod> &a) { s >> a.n; return s; }
	friend ostream &operator << (ostream &s, modint<mod> &a) { s << a.n; return s; }
};

using mint = modint<mod>;
vector<mint> fac, inv, facinv;

mint modinv(mint x) {
	ll a = x.n;
	if (a == 0) abort();
	if (a < (ll)inv.size()) return inv[a];
	ll b = mod, u = 1, v = 0;
	while (b) {
		ll t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	mint res = u;
	return res;
}

void modcalc(int n) {
	fac.resize(n); inv.resize(n); facinv.resize(n);
	fac[0] = 1; fac[1] = 1; inv[1] = 1;
	facinv[0] = 1; facinv[1] = 1;
	for (ll i = 2; i < n; i++) {
		fac[i] = fac[i - 1] * i;
		inv[i] = -inv[mod % i] * (mod / i);
		facinv[i] = facinv[i - 1] * inv[i];
	}
}

mint comb(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[k] * facinv[n - k];
}

mint perm(ll n, ll k) {
	if (n < 0 || k < 0 || n < k) return 0;
	return fac[n] * facinv[n - k];
}

mint hom(ll n, ll k) {
	if (n < 0 || k < 0 || n == 0 && k > 0) return 0;
	if (n == 0 && k == 0) return 1;
	return fac[n + k - 1] * facinv[k] * facinv[n - 1];
}

template<class T> class segtree {
	int n;
	vector<T> data;
	T id = 0;
	T operation(T a, T b) { return max(a, b); }
public:
	segtree(int _n) {
		n = 1;
		while (n < _n + 2) n <<= 1;
		data = vector<T>(2 * n, id);
	}
	segtree(vector<T> vec) {
		int _n = vec.size();
		n = 1;
		while (n < _n + 2) n <<= 1;
		data = vector<T>(2 * n, id);
		for (int i = 0; i < _n; i++) data[i + n] = vec[i];
		for (int i = n - 1; i >= 1; i--) data[i] = operation(data[i << 1], data[i << 1 | 1]);
	}
	void change(int i, T x) {
		i += n;
		data[i] = x;
		while (i > 1) {
			i >>= 1;
			data[i] = operation(data[i << 1], data[i << 1 | 1]);
		}
	}
	void add(int i, T x) { change(i, data[i + n] + x); }
	T get(int a, int b) {
		T left = id; T right = id;
		a += n; b += n;
		while (a < b) {
			if (a & 1) left = operation(left, data[a++]);
			if (b & 1) right = operation(data[--b], right);
			a >>= 1; b >>= 1;
		}
		return operation(left, right);
	}
	T get_all() { return data[1]; }
	T operator[](int i) { return data[i + n]; }
};

class unionfind {
	vector<int> par;
	vector<int> sz;
	vector<int> val;
public:
	unionfind(int n) {
		par = vector<int>(n);
		for (int i = 0; i < n; i++) par[i] = i;
		sz = vector<int>(n, 1);
		val = vector<int>(n);
	}
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	int size(int x) { return sz[find(x)]; }
	bool same(int x, int y) { return find(x) == find(y); }
	void add(int x) { val[find(x)]++; }
	int get(int x) { return val[find(x)]; }
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (sz[x] < sz[y]) {
			par[x] = y;
			sz[y] += sz[x];
			val[y] += val[x];
		}
		else {
			par[y] = x;
			sz[x] += sz[y];
			val[x] += val[y];
		}
	}
};

template<class T> vector<int> compress(vector<T> vec) {
	int vecsize = vec.size();
	vector<T> tmpvec = vec;
	sort(tmpvec.begin(), tmpvec.end());
	tmpvec.erase(unique(tmpvec.begin(), tmpvec.end()), tmpvec.end());
	vector<int> res(vecsize);
	for (int i = 0; i < vecsize; i++) res[i] = lower_bound(tmpvec.begin(), tmpvec.end(), vec[i]) - tmpvec.begin();
	return res;
}

int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) return 0;
		int ans = 0;
		req(i, 1, 1001) {
			req(j, i + 1, 1001) {
				int v = (i + j) * (j - i + 1) / 2;
				if (n == v) ans++;
			}
		}
		cout << ans << '\n';
	}
}
accuracy: 1
time_ms: 40
memory_kb: 3464
final_rank: 20

code_snippet: /* ICPC */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pint;
const ll MOD = 1000000007;
const ll INF = 1e16;
#define rep(i, n) for(ll i = ll(0); i < ll(n); i++)
#define Rep(i, s, t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

bool Ret(ll a = 0, ll b = 0, ll c = 0, ll d = 0) {
  if (a == 0 && b == 0 && c == 0 && d == 0) return true;
  else return false;
}

/* 累積和 */

vector<ll> acc_sum(vector<ll> v, ll ind = 1, bool rev = false) {
  ll n = v.size();
  if (rev) reverse(ALL(v));
  if (ind == 1) {
    vector<ll> ans(n + 1, 0);
    rep(i, n) ans[i + 1] = ans[i] + v[i];
    if (rev) reverse(ALL(ans));
    return ans;
  } else if (ind == 0) {
    vector<ll> ans(n, 0);
    rep(i, n) {
      if (i == 0) ans[i] = v[i];
      else ans[i] = ans[i - 1] + v[i];
    }
    if (rev) reverse(ALL(ans));
    return ans;
  }
  vector<ll> ans(n, INF);
  return ans;
}

vector<vector<ll>> two_acc_sum(vector<vector<ll>> v) {
  ll h = v.size();
  ll w = v[0].size();
  vector<vector<ll>> ans(h + 1, vector<ll>(w + 1, 0));
  rep(i, h) rep(j, w) ans[i + 1][j + 1] = ans[i][j + 1] + ans[i + 1][j] - ans[i][j] + v[i][j];
  return ans;
}
/* 空の配列でRE */


int main() {
  IOS;
  vector<ll> V(1010);
  rep(i, 1010) V[i] = i+1;
  vector<ll> SUM = acc_sum(V, 1);
  while(1) {
    ll N; cin >> N;
    if(N == 0) break;
    ll ans = 0;
    rep(i, 1001) {
      Rep(j, i+1, 1001) {
        if(SUM[j] - SUM[i] == N && j - i > 1) {
          ans++;
        }
      }
    }
    cout << ans << endl;
  }
}
accuracy: 1
time_ms: 40
memory_kb: 3316
final_rank: 19

code_snippet: #include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<double> vd;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repll(i, n) for (long long int i = 0; i < n; i++)
#define fin(ans) cout << (ans) << endl
#define P 1000000007
#define STI(s) atoi(s.c_str())  // string to int
#define mp(p, q) make_pair(p, q)
#define All(a) a.begin(), a.end()
#define Sort(a) sort(a.begin(), a.end())

/////////////////////////////////////////

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

    int n; 
    vll sum(1000);
    rep(i, 1000) {
        if (i != 0) sum[i] += sum[i - 1] + i;
    }

    while (cin >> n) {
        int count = 0;
        if (n == 0) break;
        rep(i, n - 1) {
            for (int j = i + 1; j < n; j++) {
                if ((sum[j] - sum[i]) == n) {
                    count++;
                }
            }
        }
        cout << count << endl;
    }

    //////////////////////////////////////////////////////
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3116
final_rank: 3

code_snippet: #include <algorithm> 
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll MOD = 1000000007;
const int INF = 1001001001;
const ld PI = 3.14159265358979323846;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
template<class T> bool chmax(T &a, const T& b) {if (a < b) {a = b; return false;} return false;};
template<class T> bool chmin(T &a, const T& b) {if (a > b) {a = b; return false;} return false;};
template<class T> void printVec(const vector<T> V) {for (int i = 0; i < V.size() - 1; ++i) {cout << V[i] << ' ';}cout << V[V.size()-1] << endl;};
template<class T> void printVec2(const vector<vector<T>> V2) {for (vector<int> V : V2) {printVec(V);}};
ll gcd(ll a, ll b) {if (a < b) swap(a, b); if (a % b == 0) return b; return gcd(b, a%b);};
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;};
// prime
bool isPrime(ll N) {if (N < 2) return false; for (ll i = 2; i*i <= N; ++i) {if (N % i == 0) return false;}return true;};
// MOD
void modAdd(ll& a, ll b) {a = (a + b) % MOD;};
void modSub(ll& a, ll b) {a = (a - b) % MOD; if(a < 0) a += MOD;};
ll modPow(ll x, ll n) {ll res = 1;while(n > 0) {if (n & 1) res = res * x % MOD; x = x * x % MOD; n >>= 1;} return res;};
ll modInv(ll a) {return modPow(a, MOD-2);};
ll digitSum(ll N) {string S = to_string(N); ll res = 0; rep(i,S.size()) res += (S[i] - '0'); return res;};


int main() {

    vector<int> ans;
    while(true) {
        int n; cin >> n;
        if (n == 0) break;
        int cnt = 0;
        for (int a = 1; a < n; ++a) {
            for (int b = a + 1; b < n; ++b) {
                int s = (a + b) * (b - a + 1) / 2;
                if (s == n) ++cnt;
            }
        }
        ans.push_back(cnt);
    }
    for (auto a : ans) cout << a << endl;


    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3292
final_rank: 8

code_snippet: #include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> LL;
const ll INF=2e18;
const ll MOD=1e9+7;
const double EPS=1e-9;
void ChMin(ll& x, ll y){
    x=min(x,y);
}
void ChMax(ll& x, ll y){
    x=max(x,y);
}

ll N;
int main(){
    while( cin>>N,N!=0){
      ll ans=0;
      for(ll l=1;l<=N;l++){
        for(ll r=l+1;r<=N;r++){
          ans+= ( ( (l+r)*(r-l+1) ) / 2 ==N);
        }
      }
      cout<<ans<<endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3416
final_rank: 13

code_snippet: //#pragma once
#define _CRT_SECURE_NO_WARNINGS


#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <cstdlib>      // srand,rand
#include <random>
#include <functional>
#include <list>
#include <stack>




using namespace std;
#define ll long long
#define ll128 long long
#define lp(i,n) for(ll i=0;i<n;i++)

#define modd 1000000007
#define mod2 998244353
const double EPS = 1e-20;
const double PI = acos(-1);

#define INF 8223372036854775807ll
#define ALL(a)  (a).begin(),(a).end()


typedef pair<long long, long long> pl;
typedef pair<long long, pl> lpl;
typedef pair<double, double> pd;
typedef pair<ll, string> pls;



typedef string::const_iterator State;
class ParseError {};



/*
class SegmentTree {



private:

	ll cont_num = 2;
	pd initial_v;
	vector<pd> dat;


public:


	SegmentTree() {};


	void init(ll size, double initial_value_first, double initial_value_second) {

		cont_num = 2;
		initial_v.first = initial_value_first;
		initial_v.second = initial_value_second;

		while (cont_num < size) {
			cont_num *= 2;
		}

		dat.resize(2 * cont_num);//サイズ設定

		for (int i = 0; i < 2 * cont_num; i++)dat[i] = initial_v;//初期化



	}


	void Update(ll position, double value_f, double value_s) {



		ll k = cont_num + position;

		dat[k].first = value_f;
		dat[k].second = value_s;

		while (k > 1) {
			k /= 2;
			dat[k].first = dat[k * 2 + 1].first * dat[k * 2].first;
			dat[k].second = dat[k * 2 + 1].first * dat[k * 2].second + dat[k * 2 + 1].second;


		}


	}

	/*
	ll query_proces(ll a, ll b, ll k, ll l, ll r) {

		if (r <= a || b <= l)return initial_v;

		if (a <= l && r <= b)return dat[k];
		else {
			ll vl = query_proces(a, b, k * 2, l, (l + r) / 2);
			ll vr = query_proces(a, b, k * 2 + 1, (l + r) / 2, r);
			return min(vl, vr);
		}

	}


	ll query(ll left, ll right) {
		return query_proces(left, right, 1, 0, cont_num);
	}
	*/
	/*
		double query() {
			return dat[1].first + dat[1].second;
		}

	};*/


template <typename T>
class Zip {
	vector<T> d;
	bool flag;
	void init() {
		sort(d.begin(), d.end());
		d.erase(unique(d.begin(), d.end()), d.end());
		flag = false;
	}
public:
	Zip() {
		flag = false;
	}
	void add(T x) {
		d.push_back(x);
		flag = true;
	}
	ll getNum(T x) {
		if (flag) init();
		return lower_bound(d.begin(), d.end(), x) - d.begin();
	}

	T getVal(ll num) {
		return d[num];
	}

	ll size() {
		if (flag) init();
		return (ll)d.size();
	}
};




typedef struct ST
{
	ll first;
	ll second;
	ll cost;

	bool operator<(const ST& another) const
	{
		return cost < another.cost;//比較
	};

	bool operator>(const ST& another) const
	{
		return cost > another.cost;//比較
	};

}ST;
//queue<ST> qst;
priority_queue<ST, vector<ST>, greater<ST> > qst;



/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}





ll zettai(ll aa) {

	if (aa < 0) {
		aa *= -1;
	}
	return aa;

}

float zettai(float aa) {

	if (aa < 0) {
		aa *= -1;
	}
	return aa;

}

double zettai(double aa) {

	if (aa < 0) {
		aa *= -1;
	}
	return aa;

}


/*
class UnionFind
{

public:


	vector <ll>pairent;
	vector <ll>depth;
	vector <ll>size;


	UnionFind(ll Amount) : pairent(Amount, 1), depth(Amount, 1), size(Amount, 1) {

		for (ll i = 0; i < Amount; i++) {
			pairent[i] = i;
		}


	}


	ll FindPairent(ll x) {
		if (pairent[x] == x)return x;
		else return pairent[x] = FindPairent(pairent[x]);

	}


	ll Merge(ll x, ll y) {
		x = FindPairent(x);
		y = FindPairent(y);

		if (x != y) {
			if (depth[x] > depth[y]) {
				pairent[y] = pairent[x];
				return size[x] += size[y];
			}
			else {
				pairent[x] = pairent[y];
				if (depth[x] == depth[y]) {
					depth[y] ++;
				}

				return size[y] += size[x];
			}

		}
		else {
			return -1;
		}



	}



	bool IsSame(ll x, ll y) {
		if (FindPairent(x) == FindPairent(y))return true;
		else return false;
	}


	ll GetSize(ll x) {
		x = FindPairent(x);
		return size[x];
	}


};
*/



template <typename T>
class RollingHash {

private:
	vector<T> all_array;
	vector<T> sub_array;
	vector<bool> match_flag;
	vector<ll128> ruijou;
	ll match_count = 0;
	vector<ll>match_place;

public:

	void Clear() {
		all_array.clear();
		sub_array.clear();
		match_flag.clear();
		match_place.clear();
	}

	RollingHash() {
		Clear();
	}

	void AddAllArray(T factor) {
		all_array.push_back(factor);
	}

	void AddSubArray(T factor) {
		sub_array.push_back(factor);
	}

	void Calculate_Ruijou(ll128 tei, ll max_num, ll128 mod) {
		ruijou.clear();
		ruijou.push_back(1);
		if (max_num > 0) {
			while (ruijou.size() < max_num + 1) {
				ruijou.push_back(ruijou.back() * tei % mod);
			}
		}

	}

	ll128 GetSubHash(ll128 b, ll128 mod) {
		ll128 ans = 0;
		Calculate_Ruijou(b, sub_array.size(), mod);
		for (ll i = 0; i < sub_array.size(); i++) {
			ans += (sub_array[i] % mod) * ruijou[sub_array.size() - 1 - i] % mod;
			ans %= mod;
		}

		return ans;
	}

	ll128 GetAllHashInit(ll128 b, ll128 mod) {
		ll128 ans = 0;
		for (ll i = 0; i < sub_array.size(); i++) {
			ans += (all_array[i] % mod) * ruijou[sub_array.size() - 1 - i] % mod;
			ans %= mod;
		}

		return ans;
	}

	void CheckMatchFlag() {
		match_place.clear();
		match_count = 0;
		for (ll i = 0; i < match_flag.size(); i++) {
			if (match_flag[i] == true) {
				match_count++;
				match_place.push_back(i);
			}
		}
	}

	void Rolling(ll128 b, ll128 mod) {
		ll128 sub_hash = GetSubHash(b, mod);
		ll128 all_hash = GetAllHashInit(b, mod);

		if (sub_hash != all_hash) {
			match_flag[0] = false;
		}

		for (ll i = 1; i < match_flag.size(); i++) {
			all_hash = (all_hash * b % mod - all_array[i - 1] % mod * ruijou[sub_array.size()] % mod + all_array[i + sub_array.size() - 1] % mod) % mod;
			while (all_hash < 0)all_hash += mod;
			all_hash %= mod;
			if (all_hash != sub_hash)match_flag[i] = false;
		}
	}

	void Match() {
		ll128 b = 3;
		//ll128 mod = 999999999999999989;
		ll128 mod = 1000000007;
		ll128 sub_hash = GetSubHash(b, mod);

		if (sub_array.size() <= all_array.size()) {

			while (match_flag.size() < all_array.size()) {
				match_flag.push_back(true);
			}

			while (match_flag.size() > all_array.size() - sub_array.size() + 1) {
				match_flag.pop_back();
			}


			Rolling(b, mod);

			b = 5;
			mod = mod2;

			Rolling(b, mod);

			b = 7;
			mod = modd;

			Rolling(b, mod);

			b = mod2;
			mod = modd;

			Rolling(b, mod);

			CheckMatchFlag();

		}



	}

	ll GetMatchCount() {
		return match_count;
	}

	ll GetMatchPlace(ll num) {
		if (num >= match_place.size())return -1;
		else return match_place[num];
	}

};



class UnionFind
{

public:

	vector <ll>pairent;
	vector <ll>depth;
	vector <ll>size;

	UnionFind(ll Amount) : pairent(Amount, 1), depth(Amount, 1), size(Amount, 1) {

		for (ll i = 0; i < Amount; i++) {
			pairent[i] = i;
		}
	}


	ll FindPairent(ll x) {
		if (pairent[x] == x)return x;
		else return pairent[x] = FindPairent(pairent[x]);
	}


	ll Merge(ll x, ll y) {
		x = FindPairent(x);
		y = FindPairent(y);

		if (x != y) {
			if (depth[x] > depth[y]) {
				pairent[y] = pairent[x];
				return size[x] += size[y];
			}
			else {
				pairent[x] = pairent[y];
				if (depth[x] == depth[y]) {
					depth[y] ++;
				}
				return size[y] += size[x];
			}
		}
		else {
			return -1;
		}
	}



	bool IsSame(ll x, ll y) {
		if (FindPairent(x) == FindPairent(y))return true;
		else return false;
	}


	ll GetSize(ll x) {
		x = FindPairent(x);
		return size[x];
	}


};




struct Edge
{
	ll a, b, cost;


	bool operator<(const Edge& other) const {
		return cost < other.cost;
	}
};

struct Graph
{
	ll n;  // 頂点数
	vector<Edge> es;  // 辺集合
};

class Kruskal {

	Graph origin_G;
	Graph MST;
	ll total_cost = 0;

public:

	void Solve() {
		UnionFind uf = UnionFind(MST.n);
		for (ll i = 0; i < origin_G.es.size(); i++) {
			ll a = origin_G.es[i].a;
			ll b = origin_G.es[i].b;
			ll cost = origin_G.es[i].cost;

			if (!uf.IsSame(a, b)) {
				uf.Merge(a, b);
				MST.es.push_back(origin_G.es[i]);
				total_cost += cost;
			}
		}
	}

	Kruskal(Graph graph) {
		origin_G = graph;
		MST = graph;
		MST.es.clear();
		sort(origin_G.es.begin(), origin_G.es.end());
	}

	ll GetMinCost() {
		return total_cost;
	}

};


ll RepeatSquaring(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RepeatSquaring(N, P / 2, M) % M;
		return t * t % M;
	}
	return N * RepeatSquaring(N, P - 1, M) % M;
}

/*
ll KurikaesiNijou(ll a, ll b, ll P) {

	if (b == 0)return 1;
	if (b % 2 == 0) {
		ll c=KurikaesiNijou(a,b/2,P)%P;
		return c * c %P;
	}
	else {
		ll c = KurikaesiNijou(a, b/2, P) % P;
		return a * c * c % P;
	}

}*/




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

ll Min(ll a, ll b) {
	if (a < b)return a;
	else return b;
}

ll Max(ll a, ll b) {
	if (a > b)return a;
	else return b;
}

ll Sum(ll a, ll b) {
	return a + b;
}

ll Add(ll a, ll b) {
	return a + b;
}

template <typename T>
class SegmentTree {
	ll n;
	vector<T> node;
	function<T(T, T)> fun, fun2;
	bool customChange;
	T outValue, initValue;
public:
	void init(ll num, function<T(T, T)> resultFunction, T init, T out, function<T(T, T)> changeFunction = NULL) {
		// changeFunction: (input, beforevalue) => newvalue
		fun = resultFunction;
		fun2 = changeFunction;
		customChange = changeFunction != NULL;
		n = 1;
		while (n < num) n *= 2;
		node.resize(2 * n - 1);
		fill(node.begin(), node.end(), init);
		outValue = out;
		initValue = init;
	}
	void valueChange(ll num, T value) {
		num += n - 1;
		if (customChange) node[num] = fun2(value, node[num]);
		else node[num] = value;
		while (num > 0) num = (num - 1) / 2, node[num] = fun(node[num * 2 + 1], node[num * 2 + 2]);
	}
	T rangeQuery(ll a, ll b, ll l = 0, ll r = -1, ll k = 0) { // [a, b)
		if (r == -1) r = n;
		if (a <= l && r <= b) return node[k];
		if (b <= l || r <= a) return outValue;
		ll mid = (l + r) / 2;
		return fun(rangeQuery(a, b, l, mid, 2 * k + 1), rangeQuery(a, b, mid, r, 2 * k + 2));
	}
};


ll extgcd(ll a, ll b, ll& x, ll& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	ll gcd = extgcd(b, a % b, x, y);
	ll oldX = x;
	x = y;
	y = oldX - a / b * y;
	return gcd;
}


class Combination {

	vector<ll> factorial;
	vector<ll> factorial_inv;
	ll mod;
	ll max_n;


public:
	void Init(ll init_max_n, ll init_mod) {
		max_n = init_max_n;
		mod = init_mod;
		factorial.resize(max_n + 1);
		factorial[0] = 1;
		for (ll i = 1; i < factorial.size(); i++) {
			factorial[i] = factorial[i - 1] * i;
			factorial[i] %= mod;
		}

		factorial_inv.resize(max_n + 1);
		factorial_inv[0] = 1;
		for (ll i = 1; i < factorial_inv.size(); i++) {
			factorial_inv[i] = factorial_inv[i - 1] * modinv(i, mod);
			factorial_inv[i] %= mod;
		}
	}



	ll GetComb(ll n, ll k) {
		if (n < k)return 0;
		if (k == 0)return 1;

		ll comb = factorial[n];
		comb *= factorial_inv[k];
		comb %= mod;
		comb *= factorial_inv[n - k];
		comb %= mod;
		return comb;
	}

	ll GetH(ll n, ll k) {//n+k-1<=max_N
		ll comb = factorial[n + k - 1];
		comb *= factorial_inv[n];
		comb %= mod;
		comb *= factorial_inv[k - 1];
		comb %= mod;
		return comb;
	}

};



class Tree {

	ll node_N;
	vector<ll> node;
	vector<vector<pl>> pass;
	ll diameter = -1;
	vector<ll> dist_Diamieter[2];

	pl maxDist_Num;

public:


	void Init(ll node_Num) {
		node_N = node_Num;
		node.resize(node_N + 1);
		pass.resize(node_N + 1);

		dist_Diamieter[0].resize(node_N + 1);
		lp(i, node_N + 1)dist_Diamieter[0][i] = -1;
		dist_Diamieter[1].resize(node_N + 1);
		lp(i, node_N + 1)dist_Diamieter[1][i] = -1;
	}

	void AddEdge(ll a, ll b, ll dist) {
		pl bufpl;
		bufpl.first = b;
		bufpl.second = dist;
		pass[a].push_back(bufpl);
		bufpl.first = a;
		pass[b].push_back(bufpl);
	}


	void DFS(ll step, ll now, ll dist) {

		dist_Diamieter[step][now] = dist;
		if (dist_Diamieter[step][now] > maxDist_Num.first) {
			maxDist_Num.first = dist_Diamieter[step][now];
			maxDist_Num.second = now;
		}

		for (ll i = 0; i < pass[now].size(); i++) {
			ll next_node = pass[now][i].first;
			if (dist_Diamieter[step][next_node] == -1) {
				DFS(step, next_node, dist + pass[now][i].second);
			}
		}
	}

	ll GetDiameter(ll min_node_num) {
		if (diameter >= 0)return diameter;
		else {
			maxDist_Num.first = -1;
			maxDist_Num.second = -1;
			DFS(0, min_node_num, 0ll);
			ll step2_start = maxDist_Num.second;

			maxDist_Num.first = -1;
			maxDist_Num.second = -1;
			DFS(1, step2_start, 0ll);

			diameter = maxDist_Num.first;
			return diameter;
		}
	}

	ll GetDistFromMinNode(ll num) {
		return dist_Diamieter[0][num];
	}

};




struct LDE {
	ll a, b, c, x, y;
	ll m = 0;
	bool check = true;//解が存在するか

	//初期化
	LDE(ll a_, ll b_, ll c_) : a(a_), b(b_), c(c_) {
		ll g = GCD(a, b);
		if (c % g != 0) {
			check = false;
		}
		else {
			//ax+by=gの特殊解を求める
			extgcd(abs(a), abs(b), x, y);
			if (a < 0)x = -x;
			if (b < 0)y = -y;
			//ax+by=cの特殊解を求める(オーバフローに注意！)
			x *= c / g; y *= c / g;
			//一般解を求めるために割る
			a /= g; b /= g;
		}
	}

	//拡張ユークリッドの互除法
	//返り値:aとbの最大公約数
	ll extgcd(ll a, ll b, ll& x0, ll& y0) {
		if (b == 0) {
			x0 = 1;
			y0 = 0;
			return a;
		}
		ll d = extgcd(b, a % b, y0, x0);
		y0 -= a / b * x0;
		return d;
	}

	//パラメータmの更新(書き換え)
	void m_update(ll m_) {
		x += (m_ - m) * b;
		y -= (m_ - m) * a;
		m = m_;
	}
};


/*
template< typename Monoid >
struct SegmentTreee {
	using F = function< Monoid(Monoid, Monoid) >;

	int sz;
	vector< Monoid > seg;

	const F f;
	const Monoid M1;

	SegmentTreee(int n, const F f, const Monoid& M1) : f(f), M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid& x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid& x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid operator[](const int& k) const {
		return seg[k + sz];
	}

	template< typename C >
	int find_subtree(int a, const C& check, Monoid& M, bool type) {
		while (a < sz) {
			Monoid nxt = type ? f(seg[2 * a + type], M) : f(M, seg[2 * a + type]);
			if (check(nxt)) a = 2 * a + type;
			else M = nxt, a = 2 * a + 1 - type;
		}
		return a - sz;
	}


	template< typename C >
	int find_first(int a, const C& check) {
		Monoid L = M1;
		if (a <= 0) {
			if (check(f(L, seg[1]))) return find_subtree(1, check, L, false);
			return -1;
		}
		int b = sz;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) {
				Monoid nxt = f(L, seg[a]);
				if (check(nxt)) return find_subtree(a, check, L, false);
				L = nxt;
				++a;
			}
		}
		return -1;
	}

	template< typename C >
	int find_last(int b, const C& check) {
		Monoid R = M1;
		if (b >= sz) {
			if (check(f(seg[1], R))) return find_subtree(1, check, R, true);
			return -1;
		}
		int a = sz;
		for (b += sz; a < b; a >>= 1, b >>= 1) {
			if (b & 1) {
				Monoid nxt = f(seg[--b], R);
				if (check(nxt)) return find_subtree(b, check, R, true);
				R = nxt;
			}
		}
		return -1;
	}
};

*/


vector<pair<long long, long long> > prime_factorize(long long N) {
	vector<pair<long long, long long> > res;
	for (long long a = 2; a * a <= N; ++a) {
		if (N % a != 0) continue;
		long long ex = 0;
		while (N % a == 0) {
			++ex;
			N /= a;
		}
		res.push_back({ a, ex });
	}
	if (N != 1) res.push_back({ N, 1 });
	return res;
}


Combination co;
typedef pair<int, int> pi;
priority_queue<pl, vector<pl>, greater<pl> > pqpl;


priority_queue<ll, vector<ll>, greater<ll> > pqll;


ll nck(ll n, ll k, ll m) {
	ll ans = 1;
	ll pre_ans = 1;
	if (k == 0)return 1;
	for (ll i = 1; i <= k; i++) {
		pre_ans = ans;
		ans = pre_ans * (n - i + 1);
		ans %= m;
		ans *= modinv(i, m);
		ans %= modd;
	}
	return ans;
}

ll N,M,K;

ll a, b;
map<ll,ll> llmap;
vector<bool> vll;

int main() {
	while (true) {
		cin >> N;
		if (N == 0)break;
		ll ans = 0;
		for (ll i = 1; i < N; i++) {
			for (ll j = i + 1; j < N; j++) {
				if ((i + j) * (j - i + 1) / 2 == N)ans++;
			}
		}
		cout << ans << endl;
	}

	//cout << fixed << setprecision(12) << bb << endl;
	return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3124
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define us unordered_set
#define ud unordered_dict
#define Lower_bound(vec, n) distance((vec).begin(), lower_bound((vec).begin(), (vec).end(), (n)))
#define Upper_bound(vec, n) distance((vec).begin(), upper_bound((vec).begin(), (vec).end(), (n)))
#define Erase(vec) (vec).erase(unique((vec).begin(), (vec).end()), (vec).end())
//template <class T = int> in()(T x; cin >> x; return (x);)
//template <class T> print(T& x) (cout << x << endl;)
//using template <class T> vec = vector<T>;
using Graph = vector<vector<int>>;
const int INF = 1LL << 60;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

signed main() {
    vi acc;
    int acc_sum = 0;
    FOR(i, 0, 1000) {
        acc_sum += i;
        acc.push_back(acc_sum);
    }

    int n;
    while (true) {
        cin >> n;
        if (n == 0) break;

        int ans = 0;
        for (int i = 1000; i >= 0; i--) {
            REP(j, i-1) {
                if (acc[i] - acc[j] == n) {
                    //cout << "acc[" << i << "]= " << acc[i];
                    //cout << " acc[" << j << "]= " << acc[j];
                    //cout << " ans = " << ans << endl;
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
}
accuracy: 1
time_ms: 20
memory_kb: 3356
final_rank: 16