Problem:
Problem I. Sum of QQ
You received a card with an integer $S$ and a
multiplication table
of infinite size. All the elements in the table are integers, and an integer at the $i$-th row from the top and the $j$-th column from the left is $A_{i,j} = i \times j$ ($i,j \geq 1$). The table has infinite size, i.e., the number of the rows and the number of the columns are infinite.
You love rectangular regions of the table in which the sum of numbers is $S$. Your task is to count the number of integer tuples $(a, b, c, d)$ that satisfies $1 \leq a \leq b, 1 \leq c \leq d$ and $\sum_{i=a}^b \sum_{j=c}^d A_{i,j} = S$.
Input
The input consists of a single test case of the following form.
$S$
The first line consists of one integer $S$ ($1 \leq S \leq 10^5$), representing the summation of rectangular regions you have to find.
Output
Print the number of rectangular regions whose summation is $S$ in one line.
Examples
Sample Input 1
25
Output for Sample Input 1
10
Sample Input 2
1
Output for Sample Input 2
1
Sample Input 3
5
Output for Sample Input 3
4
Sample Input 4
83160
Output for Sample Input 4
5120

Submitted solutions:

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

bool chmin(auto& a, const auto& b) { return a > b ? a = b, 1 : 0; }
bool chmax(auto& a, const auto& b) { return a < b ? a = b, 1 : 0; }

const ll INF = 1e18;
ll mod = 998244353;

ifstream in;
ofstream out;

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    if (argc > 2) {
        in.open(argv[1]);
        cin.rdbuf(in.rdbuf());
        out.open(argv[2]);
        cout.rdbuf(out.rdbuf());
    }

    ll s;
    cin >> s;
    ll ans = 0;
    set<ll> sq;
    sq.insert(0);
    for (ll i = 1; i <= s + 1; i++) {
        sq.insert(i * (i + 1) / 2);
    }
    for (int i = 1; i <= s; i++) {
        if (s % i == 0) {
            ll a = i;
            ll b = s / i;
            ll mula = 0, mulb = 0;
            for (auto& x : sq) {
                if (sq.contains(x - a))
                    mula++;
                if (sq.contains(x - b))
                    mulb++;
            }
            ans += mula * mulb;
        }
    }
    cout << ans << endl;
    return 0;
}
accuracy: 1
time_ms: 1440
memory_kb: 8064
final_rank: 16

code_snippet: #include <bits/stdc++.h>
#define int long long
using namespace std;
int s, n, i, j, k, l, ans;
map<pair<int, int>, int> m;

int sum(int x1, int y1, int x2, int y2) {
	return (x2 * (x2 + 1) - x1 * (x1 - 1)) * (y2 * (y2 + 1) - y1 * (y1 - 1)) / 4;
}

signed main() {
	cin.tie(0)->sync_with_stdio(0);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	#endif
	s = 1e5;
	cin >> s;
	for (i = 1; i <= s; i++) {
		for (j = 1; i * j <= s; j++) {
			//cout << i << " " << j << " " << m[{i, j}] << "\n";
			for (k = i; k <= min(s, i + 500); k++) {
				for (l = j; l <= min(s, j + 500) && k * l <= s; l++) {
					//cout << i << " " << j << " " << k << " " << l << "\n";
					if (sum(i, j, k, l) == s) {
						//cout << i << " " << j << " " << k << " " << l << "\n";
						ans++;
						break;
					}
					else if (sum(i, j, k, l) > s) break;
				}
			}
		}
	}
	cout << ans << "\n"; // CHANGED added extra break line to avoid presentation error
}
accuracy: 1
time_ms: 630
memory_kb: 3456
final_rank: 11

code_snippet: #include <iostream>
#include <iomanip>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>

long long f(int i) {
    return (long long)i * (i + 1) / 2;
}
long long brute(int S) {
    long long ans = 0;
    for (int a = 1 ; a <= S ; a++) {
        for (int b = a ; f(b) - f(a - 1) <= S ; b++) {
            for (int c = 1 ; c * (f(b) - f(a - 1)) <= S ; c++) {
                for (int d = c ; (f(b) - f(a - 1)) * (f(d) - f(c - 1)) <= S ; d++) {
                    if ((f(b) - f(a - 1)) * (f(d) - f(c - 1)) == S) {
                        // std::cout << a << ' ' << b << ' ' << c << ' ' << d << '\n';
                        ans++;
                    }
                }
            }
        }
    }
    return ans%1000;
}
int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int S;
    std::cin >> S;
    long long bru = brute(S);
    std::cout << bru << std::endl;
}
accuracy: 0.1111111111111111
time_ms: 10
memory_kb: 3584
final_rank: 20

code_snippet: #include <iostream>
#include <iomanip>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>

long long f(int i) {
    return (long long)i * (i + 1) / 2;
}
long long brute(int S) {
    long long ans = 0;
    for (int a = 1 ; a <= S ; a++) {
        for (int b = a ; f(b) - f(a - 1) <= S ; b++) {
            for (int c = 1 ; c * (f(b) - f(a - 1)) <= S ; c++) {
                for (int d = c ; (f(b) - f(a - 1)) * (f(d) - f(c - 1)) <= S ; d++) {
                    if ((f(b) - f(a - 1)) * (f(d) - f(c - 1)) == S) {
                        // std::cout << a << ' ' << b << ' ' << c << ' ' << d << '\n';
                        ans++;
                    }
                }
            }
        }
    }
    return ans;
}
int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int S;
    std::cin >> S;
    long long bru = brute(S);
    std::cout << bru << std::endl;
}
accuracy: 1
time_ms: 10
memory_kb: 3440
final_rank: 1

code_snippet: #include <iostream>
#include <iomanip>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
// #include "Src/Utility/BinarySearch.hpp"
// #include "Src/Sequence/CompressedSequence.hpp"
// #include "Src/Sequence/RunLengthEncoding.hpp"
// using namespace zawa;
// #include "atcoder/modint"
// using mint = atcoder::modint998244353;
long long f(int i) {
    return (long long)i * (i + 1) / 2;
}
long long brute(int S) {
    long long ans = 0;
    for (int a = 1 ; a <= S ; a++) {
        for (int b = a ; f(b) - f(a - 1) <= S ; b++) {
            for (int c = 1 ; c * (f(b) - f(a - 1)) <= S ; c++) {
                for (int d = c ; (f(b) - f(a - 1)) * (f(d) - f(c - 1)) <= S ; d++) {
                    if ((f(b) - f(a - 1)) * (f(d) - f(c - 1)) == S) {
                        // std::cout << a << ' ' << b << ' ' << c << ' ' << d << '\n';
                        ans++;
                    }
                }
            }
        }
    }
    return ans;
}
int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int S;
    std::cin >> S;
    long long bru = brute(S);
    std::cout << bru << std::endl;
}
accuracy: 1
time_ms: 10
memory_kb: 3584
final_rank: 2

code_snippet: #include <iostream>
#include <iomanip>
#include <cassert>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
// #include "Src/Utility/BinarySearch.hpp"
// #include "Src/Sequence/CompressedSequence.hpp"
// #include "Src/Sequence/RunLengthEncoding.hpp"
// using namespace zawa;
// #include "atcoder/modint"
// using mint = atcoder::modint998244353;
long long f(int i) {
    return (long long)i * (i + 1) / 2;
}
long long brute(int S) {
    long long ans = 0;
    for (int a = 1 ; a <= S ; a++) {
        for (int b = a ; f(b) - f(a - 1) <= S ; b++) {
            for (int c = 1 ; c * (f(b) - f(a - 1)) <= S ; c++) {
                for (int d = c ; (f(b) - f(a - 1)) * (f(d) - f(c - 1)) <= S ; d++) {
                    if ((f(b) - f(a - 1)) * (f(d) - f(c - 1)) == S) {
                        // std::cout << a << ' ' << b << ' ' << c << ' ' << d << '\n';
                        ans++;
                    }
                }
            }
        }
    }
    return ans;
}
int main() {
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int S;
    std::cin >> S;
    long long bru = brute(S);
    std::cout << bru << std::endl;
}
accuracy: 1
time_ms: 10
memory_kb: 3584
final_rank: 2

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

using ll = long long;

int main(){
	ll s;
	cin >> s;
	vector<ll> acc(1);
	for(ll i = 1; i <= s; ++i){
		acc.push_back(acc.back()+i);
	}
	ll ans = 0;
	for(ll r = 1; r <= s; ++r){
		for(ll w = 1; w <= s; ++w){
			if(r*w > s) break;
			// fixed up-left

			ll right = s+1;
			for(ll i = 0; i < s; ++i){
				if(r+i > s) break; 
				ll left = w-1;
				while(right-left > 1){
					ll mid = (right+left)>>1;
					if(mid > s){
						right = mid;
						continue;
					}
					ll flag = (acc[r+i]-acc[r-1])*(acc[mid]-acc[w-1]);
					if(flag > s){
						right = mid;
					}else{
						left = mid;
					}
				}
				if(left == w-1){
					break;
				}
				ll flag = (acc[r+i]-acc[r-1])*(acc[left]-acc[w-1]);
				if(flag == s){
					++ans;
//					cout << r << ' ' << w << ' ' << r+i << ' ' << left << endl;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}
accuracy: 1
time_ms: 70
memory_kb: 4132
final_rank: 6

code_snippet: // competitive-verifier: PROBLEM
#ifdef ATCODER
#pragma GCC target("sse4.2,avx512f,avx512dq,avx512ifma,avx512cd,avx512bw,avx512vl,bmi2")
#endif
#pragma GCC optimize("Ofast,fast-math,unroll-all-loops")
#include <bits/stdc++.h>
#ifndef ATCODER
#pragma GCC target("sse4.2,avx2,bmi2")
#endif
template <class T, class U>
constexpr bool chmax(T &a, const U &b) {
    return a < (T)b ? a = (T)b, true : false;
}
template <class T, class U>
constexpr bool chmin(T &a, const U &b) {
    return (T)b < a ? a = (T)b, true : false;
}
constexpr std::int64_t INF = 1000000000000000003;
constexpr int Inf = 1000000003;
constexpr double EPS = 1e-7;
constexpr double PI = 3.14159265358979323846;
#define FOR(i, m, n) for (int i = (m); i < int(n); ++i)
#define FORR(i, m, n) for (int i = (m)-1; i >= int(n); --i)
#define FORL(i, m, n) for (int64_t i = (m); i < int64_t(n); ++i)
#define rep(i, n) FOR (i, 0, n)
#define repn(i, n) FOR (i, 1, n + 1)
#define repr(i, n) FORR (i, n, 0)
#define repnr(i, n) FORR (i, n + 1, 1)
#define all(s) (s).begin(), (s).end()
struct Sonic {
    Sonic() {
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
        std::cout << std::fixed << std::setprecision(20);
    }
    constexpr void operator()() const {}
} sonic;
using namespace std;
using ll = std::int64_t;
using ld = long double;
template <class T, class U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    return is >> p.first >> p.second;
}
template <class T>
std::istream &operator>>(std::istream &is, std::vector<T> &v) {
    for (T &i : v) is >> i;
    return is;
}
template <class T, class U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}
template <class T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
    for (auto it = v.begin(); it != v.end(); ++it) os << (it == v.begin() ? "" : " ") << *it;
    return os;
}
template <class Head, class... Tail>
void co(Head &&head, Tail &&...tail) {
    if constexpr (sizeof...(tail) == 0) std::cout << head << '\n';
    else std::cout << head << ' ', co(std::forward<Tail>(tail)...);
}
template <class Head, class... Tail>
void ce(Head &&head, Tail &&...tail) {
    if constexpr (sizeof...(tail) == 0) std::cerr << head << '\n';
    else std::cerr << head << ' ', ce(std::forward<Tail>(tail)...);
}
void Yes(bool is_correct = true) { std::cout << (is_correct ? "Yes\n" : "No\n"); }
void No(bool is_not_correct = true) { Yes(!is_not_correct); }
void YES(bool is_correct = true) { std::cout << (is_correct ? "YES\n" : "NO\n"); }
void NO(bool is_not_correct = true) { YES(!is_not_correct); }
void Takahashi(bool is_correct = true) { std::cout << (is_correct ? "Takahashi" : "Aoki") << '\n'; }
void Aoki(bool is_not_correct = true) { Takahashi(!is_not_correct); }
/**
 * @brief 素数ライブラリ
 *
 * @tparam N
 */
template <int N = 1 << 22>
struct prime_number {
    prime_number() : is_not_prime(), data() { init(); }
    /**
     * @brief 素数判定
     *
     * @param n
     * @return bool
     */
    bool is_prime(std::int64_t n) const {
        assert(n >= 0);
        if (n < N) return !is_not_prime[n];
        for (auto i : data) {
            if ((std::int64_t)i * i > n) break;
            if (n % i == 0) return false;
        }
        return true;
    }
    std::vector<int> prime_numbers(int x) const {
        std::vector<int> res;
        for (auto i : data) {
            if (i > x) break;
            res.emplace_back(i);
        }
        return res;
    }
    /**
     * @brief 素因数分解
     *
     * @tparam T
     * @param x
     * @return std::vector<std::pair<T, int>>
     */
    template <class T>
    std::vector<std::pair<T, int>> prime_factorization(T x) const {
        if (x == 1) return std::vector<std::pair<T, int>>();
        std::vector<std::pair<T, int>> res;
        for (auto p : data) {
            int cnt = 0;
            for (; x % p == 0; x /= p) ++cnt;
            if (cnt) res.emplace_back(p, cnt);
            if ((std::int64_t)p * p > x) break;
        }
        if (x != 1) res.emplace_back(x, 1);
        return res;
    }
    /**
     * @brief 約数列挙
     *
     * @tparam T
     * @param x
     * @return std::vector<T>
     */
    template <class T>
    std::vector<T> divisors(T x) const {
        if (x == 1) return std::vector<T>(1, 1);
        auto v = prime_factorization(x);
        std::vector<T> res;
        res.emplace_back(1);
        for (auto p : v) {
            int n = res.size();
            res.resize(n * (p.second + 1));
            for (int i = 0; i < n * p.second; ++i) res[n + i] = res[i] * p.first;
            for (int i = 1; i <= p.second; ++i) {
                std::inplace_merge(res.begin(), res.begin() + n * i, res.begin() + n * (i + 1));
            }
        }
        return res;
    }
    /**
     * @brief 因数分解列挙
     *
     * @tparam T
     * @param x
     * @return std::vector<std::vector<T>>
     */
    template <class T>
    std::vector<std::vector<T>> factorization(T x) const {
        std::vector<std::vector<T>> res;
        auto f = [&](auto self, std::vector<T> v, T a) -> void {
            if (a == 1) res.emplace_back(v);
            for (auto i : this->divisors(a)) {
                if (i == 1 || (!v.empty() && v.back() > i)) continue;
                v.emplace_back(i);
                self(self, v, a / i);
                v.pop_back();
            }
        };
        f(f, std::vector<T>(), x);
        return res;
    }
  private:
    std::bitset<N> is_not_prime;
    std::vector<int> data;
    void init() {
        is_not_prime[0] = is_not_prime[1] = true;
        for (int i = 2; i < N; ++i) {
            if (!is_not_prime[i]) {
                data.emplace_back(i);
                if ((std::int64_t)i * i >= N) continue;
                if (i == 2) {
                    for (int j = i * i; j < N; j += i) is_not_prime[j] = true;
                } else {
                    for (int j = i * i; j < N; j += i << 1) is_not_prime[j] = true;
                }
            }
        }
    }
};
prime_number pn;
int main(void)
{
    int s;
    cin >> s;
    vector<int> dp(s + 1);
    repn(i, s)
    {
        ll t = 0;
        rep(j, s)
        {
            t += i + j;
            if (t > s)
                break;
            dp[t]++;
        }
    }
    auto v = pn.divisors(s);
    ll ans = 0;
    for (int x : v)
    {
        int y = s / x;
        ans += dp[x] * dp[y];
    }
    co(ans);
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 6584
final_rank: 7

code_snippet: // competitive-verifier: PROBLEM
#ifdef ATCODER
#pragma GCC target("sse4.2,avx512f,avx512dq,avx512ifma,avx512cd,avx512bw,avx512vl,bmi2")
#endif
#pragma GCC optimize("Ofast,fast-math,unroll-all-loops")
#include <bits/stdc++.h>
#ifndef ATCODER
#pragma GCC target("sse4.2,avx2,bmi2")
#endif
template <class T, class U>
constexpr bool chmax(T &a, const U &b) {
    return a < (T)b ? a = (T)b, true : false;
}
template <class T, class U>
constexpr bool chmin(T &a, const U &b) {
    return (T)b < a ? a = (T)b, true : false;
}
constexpr std::int64_t INF = 1000000000000000003;
constexpr int Inf = 1000000003;
constexpr double EPS = 1e-7;
constexpr double PI = 3.14159265358979323846;
#define FOR(i, m, n) for (int i = (m); i < int(n); ++i)
#define FORR(i, m, n) for (int i = (m)-1; i >= int(n); --i)
#define FORL(i, m, n) for (int64_t i = (m); i < int64_t(n); ++i)
#define rep(i, n) FOR (i, 0, n)
#define repn(i, n) FOR (i, 1, n + 1)
#define repr(i, n) FORR (i, n, 0)
#define repnr(i, n) FORR (i, n + 1, 1)
#define all(s) (s).begin(), (s).end()
struct Sonic {
    Sonic() {
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
        std::cout << std::fixed << std::setprecision(20);
    }
    constexpr void operator()() const {}
} sonic;
using namespace std;
using ll = std::int64_t;
using ld = long double;
template <class T, class U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    return is >> p.first >> p.second;
}
template <class T>
std::istream &operator>>(std::istream &is, std::vector<T> &v) {
    for (T &i : v) is >> i;
    return is;
}
template <class T, class U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}
template <class T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
    for (auto it = v.begin(); it != v.end(); ++it) os << (it == v.begin() ? "" : " ") << *it;
    return os;
}
template <class Head, class... Tail>
void co(Head &&head, Tail &&...tail) {
    if constexpr (sizeof...(tail) == 0) std::cout << head << '\n';
    else std::cout << head << ' ', co(std::forward<Tail>(tail)...);
}
template <class Head, class... Tail>
void ce(Head &&head, Tail &&...tail) {
    if constexpr (sizeof...(tail) == 0) std::cerr << head << '\n';
    else std::cerr << head << ' ', ce(std::forward<Tail>(tail)...);
}
void Yes(bool is_correct = true) { std::cout << (is_correct ? "Yes\n" : "No\n"); }
void No(bool is_not_correct = true) { Yes(!is_not_correct); }
void YES(bool is_correct = true) { std::cout << (is_correct ? "YES\n" : "NO\n"); }
void NO(bool is_not_correct = true) { YES(!is_not_correct); }
void Takahashi(bool is_correct = true) { std::cout << (is_correct ? "Takahashi" : "Aoki") << '\n'; }
void Aoki(bool is_not_correct = true) { Takahashi(!is_not_correct); }
/**
 * @brief 素数ライブラリ
 *
 * @tparam N
 */
template <int N = 1 << 22>
struct prime_number {
    prime_number() : is_not_prime(), data() { init(); }
    /**
     * @brief 素数判定
     *
     * @param n
     * @return bool
     */
    bool is_prime(std::int64_t n) const {
        assert(n >= 0);
        if (n < N) return !is_not_prime[n];
        for (auto i : data) {
            if ((std::int64_t)i * i > n) break;
            if (n % i == 0) return false;
        }
        return true;
    }
    std::vector<int> prime_numbers(int x) const {
        std::vector<int> res;
        for (auto i : data) {
            if (i > x) break;
            res.emplace_back(i);
        }
        return res;
    }
    /**
     * @brief 素因数分解
     *
     * @tparam T
     * @param x
     * @return std::vector<std::pair<T, int>>
     */
    template <class T>
    std::vector<std::pair<T, int>> prime_factorization(T x) const {
        if (x == 1) return std::vector<std::pair<T, int>>();
        std::vector<std::pair<T, int>> res;
        for (auto p : data) {
            int cnt = 0;
            for (; x % p == 0; x /= p) ++cnt;
            if (cnt) res.emplace_back(p, cnt);
            if ((std::int64_t)p * p > x) break;
        }
        if (x != 1) res.emplace_back(x, 1);
        return res;
    }
    /**
     * @brief 約数列挙
     *
     * @tparam T
     * @param x
     * @return std::vector<T>
     */
    template <class T>
    std::vector<T> divisors(T x) const {
        if (x == 1) return std::vector<T>(1, 1);
        auto v = prime_factorization(x);
        std::vector<T> res;
        res.emplace_back(1);
        for (auto p : v) {
            int n = res.size();
            res.resize(n * (p.second + 1));
            for (int i = 0; i < n * p.second; ++i) res[n + i] = res[i] * p.first;
            for (int i = 1; i <= p.second; ++i) {
                std::inplace_merge(res.begin(), res.begin() + n * i, res.begin() + n * (i + 1));
            }
        }
        return res;
    }
    /**
     * @brief 因数分解列挙
     *
     * @tparam T
     * @param x
     * @return std::vector<std::vector<T>>
     */
    template <class T>
    std::vector<std::vector<T>> factorization(T x) const {
        std::vector<std::vector<T>> res;
        auto f = [&](auto self, std::vector<T> v, T a) -> void {
            if (a == 1) res.emplace_back(v);
            for (auto i : this->divisors(a)) {
                if (i == 1 || (!v.empty() && v.back() > i)) continue;
                v.emplace_back(i);
                self(self, v, a / i);
                v.pop_back();
            }
        };
        f(f, std::vector<T>(), x);
        return res;
    }
  private:
    std::bitset<N> is_not_prime;
    std::vector<int> data;
    void init() {
        is_not_prime[0] = is_not_prime[1] = true;
        for (int i = 2; i < N; ++i) {
            if (!is_not_prime[i]) {
                data.emplace_back(i);
                if ((std::int64_t)i * i >= N) continue;
                if (i == 2) {
                    for (int j = i * i; j < N; j += i) is_not_prime[j] = true;
                } else {
                    for (int j = i * i; j < N; j += i << 1) is_not_prime[j] = true;
                }
            }
        }
    }
};
prime_number pn;
int main(void)
{
    int s;
    cin >> s;
    vector<int> dp(s + 1);
    repn(x, s)
    {
        ll l = 1;
        while (true)
        {
            // l * (2a + l - 1) / 2 = x
            // 2a + l - 1 = 2x / l
            ll a = (2 * x - l * l + l) / 2 / l;
            if (a <= 0)
                break;
            if ((2 * x - l * l + l) % (2 * l) == 0)
                ++dp[x];
            ++l;
        }
    }
    auto v = pn.divisors(s);
    ll ans = 0;
    for (int x : v)
    {
        int y = s / x;
        ans += dp[x] * dp[y];
    }
    co(ans);
    return 0;
}
accuracy: 1
time_ms: 350
memory_kb: 5728
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define per(i, n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define per2(i, l, r) for (int i = (r)-1; i >= (l); i--)
#define each(e, v) for (auto &e : v)
#define MM << " " <<
#define pb push_back
#define eb emplace_back
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)x.size()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

template <typename T>
using minheap = priority_queue<T, vector<T>, greater<T>>;

template <typename T>
using maxheap = priority_queue<T>;

template <typename T>
bool chmax(T &x, const T &y) {
    return (x < y) ? (x = y, true) : false;
}

template <typename T>
bool chmin(T &x, const T &y) {
    return (x > y) ? (x = y, true) : false;
}

template <typename T>
int flg(T x, int i) {
    return (x >> i) & 1;
}

template <typename T>
void print(const vector<T> &v, T x = 0) {
    int n = v.size();
    for (int i = 0; i < n; i++) cout << v[i] + x << (i == n - 1 ? '\n' : ' ');
    if (v.empty()) cout << '\n';
}

template <typename T>
void printn(const vector<T> &v, T x = 0) {
    int n = v.size();
    for (int i = 0; i < n; i++) cout << v[i] + x << '\n';
}

template <typename T>
int lb(const vector<T> &v, T x) {
    return lower_bound(begin(v), end(v), x) - begin(v);
}

template <typename T>
int ub(const vector<T> &v, T x) {
    return upper_bound(begin(v), end(v), x) - begin(v);
}

template <typename T>
void rearrange(vector<T> &v) {
    sort(begin(v), end(v));
    v.erase(unique(begin(v), end(v)), end(v));
}

template <typename T>
vector<int> id_sort(const vector<T> &v, bool greater = false) {
    int n = v.size();
    vector<int> ret(n);
    iota(begin(ret), end(ret), 0);
    sort(begin(ret), end(ret), [&](int i, int j) { return greater ? v[i] > v[j] : v[i] < v[j]; });
    return ret;
}

template <typename S, typename T>
pair<S, T> operator+(const pair<S, T> &p, const pair<S, T> &q) {
    return make_pair(p.first + q.first, p.second + q.second);
}

template <typename S, typename T>
pair<S, T> operator-(const pair<S, T> &p, const pair<S, T> &q) {
    return make_pair(p.first - q.first, p.second - q.second);
}

template <typename S, typename T>
istream &operator>>(istream &is, pair<S, T> &p) {
    S a;
    T b;
    is >> a >> b;
    p = make_pair(a, b);
    return is;
}

template <typename S, typename T>
ostream &operator<<(ostream &os, const pair<S, T> &p) {
    return os << p.first << ' ' << p.second;
}

struct io_setup {
    io_setup() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout << fixed << setprecision(15);
    }
} io_setup;

const int inf = (1 << 30) - 1;
const ll INF = (1LL << 60) - 1;
// const int MOD = 1000000007;
const int MOD = 998244353;

template <typename T>
vector<T> divisors(const T &n) {
    vector<T> ret;
    for (T i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(begin(ret), end(ret));
    return ret;
}

template <typename T>
vector<pair<T, int>> prime_factor(T n) {
    vector<pair<T, int>> ret;
    for (T i = 2; i * i <= n; i++) {
        int cnt = 0;
        while (n % i == 0) cnt++, n /= i;
        if (cnt > 0) ret.emplace_back(i, cnt);
    }
    if (n > 1) ret.emplace_back(n, 1);
    return ret;
}

template <typename T>
bool is_prime(const T &n) {
    if (n == 1) return false;
    for (T i = 2; i * i <= n; i++) {
        if (n % i == 0) return false;
    }
    return true;
}

// 1,2,...,n のうち k と互いに素である自然数の個数
template <typename T>
T coprime(T n, T k) {
    vector<pair<T, int>> ps = prime_factor(k);
    int m = ps.size();
    T ret = 0;
    for (int i = 0; i < (1 << m); i++) {
        T prd = 1;
        for (int j = 0; j < m; j++) {
            if ((i >> j) & 1) prd *= ps[j].first;
        }
        ret += (__builtin_parity(i) ? -1 : 1) * (n / prd);
    }
    return ret;
}

vector<bool> Eratosthenes(const int &n) {
    vector<bool> ret(n + 1, true);
    if (n >= 0) ret[0] = false;
    if (n >= 1) ret[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (!ret[i]) continue;
        for (int j = i + i; j <= n; j += i) ret[j] = false;
    }
    return ret;
}

vector<int> Eratosthenes2(const int &n) {
    vector<int> ret(n + 1);
    iota(begin(ret), end(ret), 0);
    if (n >= 0) ret[0] = -1;
    if (n >= 1) ret[1] = -1;
    for (int i = 2; i * i <= n; i++) {
        if (ret[i] < i) continue;
        for (int j = i + i; j <= n; j += i) ret[j] = min(ret[j], i);
    }
    return ret;
}

void solve() {
    int N;
    cin >> N;

    vector<ll> sum(N + 1, 0);
    rep(i, N) sum[i + 1] = sum[i] + i + 1;

    auto ds = divisors(N);
    ll ans = 0;

    auto count = [&](ll a) {
        int ptr = 0;
        ll s = 0;
        ll ret = 0;
        rep(i, N) {
            while (ptr < N && sum[ptr] < sum[i] + a) ptr++;
            if (sum[ptr] == sum[i] + a) ret++;
        }
        return ret;
    };

    for (auto a : ds) {
        int b = N / a;
        ans += count(a) * count(b);
    }

    cout << ans << '\n';
}

int main() { solve(); }
accuracy: 1
time_ms: 40
memory_kb: 3780
final_rank: 4

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

using ll = long long;

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

  ll s;
  cin >> s;

  ll now = 0;
  vector<ll> x;
  set<ll> st;
  st.insert(now);
  for (ll i = 1; i <= s; i++) {
    now += i;
    x.emplace_back(now);
    st.insert(now);
  }

  ll ans = 0;
  for (ll i = 1; i * i <= s; i++) {
    if (s % i != 0) continue;
    ll j = s / i;
    ll tmp1 = 0, tmp2 = 0;
    for (auto num : x) {
      if (num < i) continue;
      if (st.find(num - i) != st.end()) tmp1++;
    }
    for (auto num : x) {
      if (num < j) continue;
      if (st.find(num - j) != st.end()) tmp2++;
    }
    if (i * i == s) ans += tmp1 * tmp2;
    else ans += 2 * tmp1 * tmp2;
  }

  cout << ans << '\n';
}
accuracy: 1
time_ms: 820
memory_kb: 8408
final_rank: 12

code_snippet: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

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

    int S; cin >> S;
    map<ll,int> mp;
    for(int i = 1; i <= S; i++){
        for(int j = i - 1; j >= 0; j--) {
            ll sum = (i + 1) * i / 2 - (j + 1) * j / 2;
            if(sum > S) break;
            mp[sum]++;
        }
    }

    int ans = 0;
    for(int i = 1; i <= S; i++) {
        if(S % i == 0)
            ans += mp[i] * mp[S / i];
    }
    cout << ans << endl;
}
accuracy: 1
time_ms: 100
memory_kb: 25312
final_rank: 17

code_snippet: #include <cmath>
#include <deque>
#include <algorithm>
#include <iterator>
#include <list>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <stack>
#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <functional>
#include <numeric>
#include <iomanip> 
#include <stdio.h>
//eolibraries
#define lnf 3999999999999999999
#define inf 999999999
#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end())
#define pii pair <int,int>
#define rep(i,n) for(int i = 0 ; i < n ; i++) 
#define drep(i,n) for(int i = n-1 ; i >= 0 ; i--)
#define crep(i,x,n) for(ll i = x ; i < n ; i++)
#define vi vector <int> 
#define vec(...) vector<__VA_ARGS__>
#define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
//eodefine
using namespace std;

const int max_n = 103002;

int main(){
fcin;
	int s;
	cin>>s;

	map<ll,int> mp;

	int ans=0;
	for(int i=1;i<=sqrt(s);i++){
		if(s%i==0){
			ll a=i,b=s/i;
			int x=0,y=0;
			mp.clear();

			crep(i,1,max(a,b)+1){
				// if(i*(i+1)/2>max(a,b)) break;
				mp[i*(i-1)/2]++;
				y+=mp[i*(i+1)/2-b];
				x+=mp[i*(i+1)/2-a];
			}
			ans+=x*y;
			if(a!=b)ans+=x*y;
		}
	}

	cout<<ans<<"\n";
/*
*/
    return 0;   
}
accuracy: 1
time_ms: 90
memory_kb: 21572
final_rank: 15

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

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

    int ans=0;
    auto rowsum=[](int r,int i,int j){
        return r*(i+j)*(j-i+1)/2;
    };

    for (int i=1;i<=S;++i){
        for (int j=i;j<=S;++j){
            if (rowsum(1,i,j)>S) break;
            ll sum=0;
            map<ll,int> mp;
            ++mp[0];
            for (int k=1;k<=S;++k){
                if (rowsum(k,i,j)>S) break;
                sum+=rowsum(k,i,j);
                ans+=mp[sum-S]; ++mp[sum];
            }
        }
    }

    cout << ans << '\n';
}
accuracy: 1
time_ms: 420
memory_kb: 15308
final_rank: 14

code_snippet: #include <bits/stdc++.h>
using namespace std;
const long long MOD=1000000007;
// const long long MOD=998244353;
#define LOCAL
#pragma region Macros
typedef long long ll;
typedef __int128_t i128;
typedef unsigned int uint;
typedef unsigned long long ull;
#define ALL(x) (x).begin(),(x).end()
const int INF=1e9;
const long long IINF=1e18;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U,typename V>
ostream&operator<<(ostream &os,const tuple<T,U,V> &t){
    os << '(' << get<0>(t) << ',' << get<1>(t) << ',' << get<2>(t) << ')';
    return os;
}
template<typename T,typename U,typename V,typename W>
ostream&operator<<(ostream &os,const tuple<T,U,V,W> &t){
    os << '(' << get<0>(t) << ',' << get<1>(t) << ',' << get<2>(t) << ',' << get<3>(t) << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
    }
    os << '}';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const unordered_map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();){
        os << *itr;
        if (++itr!=s.end()) os << ',';
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const multiset<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();){
        os << *itr;
        if (++itr!=s.end()) os << ',';
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const unordered_set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();){
        os << *itr;
        if (++itr!=s.end()) os << ',';
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const deque<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

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

    int ans=0;
    auto rowsum=[](int r,int i,int j){
        return r*(i+j)*(j-i+1)/2;
    };

    for (int i=1;i<=S;++i){
        for (int j=i;j<=S;++j){
            if (rowsum(1,i,j)>S) break;
            ll sum=0;
            map<ll,int> mp;
            ++mp[0];
            for (int k=1;k<=S;++k){
                if (rowsum(k,i,j)>S) break;
                sum+=rowsum(k,i,j);
                ans+=mp[sum-S]; ++mp[sum];
            }
        }
    }

    cout << ans << '\n';
}
accuracy: 1
time_ms: 410
memory_kb: 15388
final_rank: 13

code_snippet: #include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", (double)v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
template<typename A, typename B>
void mins(A& a, const B& b) { a = min(a, (A)b); };
template<typename A, typename B>
void maxs(A& a, const B& b) { a = max(a, (A)b); };


//素因数分解
vector<pair<long long, int>> factorize(long long n) {
	vector<pair<long long, int>> res;
	for (long long i = 2; i * i <= n; ++i) {
		if (n % i != 0) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

ll S;
unordered_map<ll, ll> mp;

bool exists(ll v) {
	ll l = 1;
	ll r = 4 * S + 2;
	while (r - l > 1) {
		ll mid = l + (r - l) / 2;
		if (mid * (mid - 1) <= v) l = mid;
		else r = mid;
	}
	if (1 <= l && l <= 4 * S && l * (l - 1) == v) return true;
	else return false;
}

void for_yakusuu(vector<pair<ll, int>>& fac, ll cur, int ind) {
	if (ind == fac.size()) {
		ll cnt = 0;
		for (ll y = 1; y <= 4 * S; ++y) {
			double V = 4 * y * (y + 1) - 4 * cur + 1;
			if (abs(floor(sqrt(V)) * floor(sqrt(V)) - V) < 1e-5) ++cnt;

			//if (y * (y + 1) - cur <= 0) continue;
			//if (exists(y * (y + 1) - cur)) {
			//	PRI(cur << ":" << y * (y + 1) - cur);
			//	++cnt;
			//}
		}
		mp[cur] = cnt;
		return;
	}

	for (ll i = 0; i <= fac[ind].second; ++i) {
		for_yakusuu(fac, cur, ind + 1);
		cur *= fac[ind].first;
	}
}


int main() {
	cin >> S;
	auto fac = factorize(4*S);
	for_yakusuu(fac, 1, 0);
	ll ans = 0;
	for (auto& p : mp) {
		ans += mp[4 * S / p.first] * mp[p.first];
	}
	PRI(ans);
	return 0;
}
accuracy: 1
time_ms: 330
memory_kb: 3552
final_rank: 8

code_snippet: #include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

int main(){
	
	int S;
	cin>>S;
	
	vector<int> a,b;
	
	for(int i=1;i<=S;i++){
		if(S%i==0){
			a.push_back(i);
			b.push_back(S/i);
		}
	}
	
	long long ans = 0LL;
	rep(i,a.size()){
		if(a[i]>=b[i])ans *= 2;
		if(a[i]>b[i])break;
		set<long long> SET;
		SET.insert(0);
		long long x=0LL,y=0LL;
		long long sum = 0LL;
		for(int j=1;j<=100000;j++){
			sum+=j;
			if(SET.count(sum-a[i]))x++;
			if(SET.count(sum-b[i]))y++;
			SET.insert(sum);
		}
		ans += x*y;
		if(a[i]==b[i])break;
	}
	
	cout<<ans<<endl;
			
	
    return 0;
}
accuracy: 1
time_ms: 1820
memory_kb: 8092
final_rank: 19

code_snippet: #include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;

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

	cin >> N;
	int ans = 0;
	vector<int>dp(N + 1);
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= i; j++) {
			int minus = j * (j - 1) / 2;
			if (minus >= i)break;
			if ((i - minus) % j)continue;
			dp[i]++;
		}
	}
	for (int i = 1; i <= N; i++) {
		if (N%i)continue;
		ans += dp[i] * dp[N / i];
	}
	cout << ans << endl;
}
accuracy: 1
time_ms: 90
memory_kb: 3332
final_rank: 5

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main(){
  int S;
  cin >> S;
  vector<long long> A(S + 1);
  for (int i = 0; i <= S; i++){
    A[i] = (long long) i * (i + 1) / 2;
  }
  int N = A.size();
  map<int, int> mp;
  for (int i = 1; i < N; i++){
    for (int j = i - 1; j >= 0; j--){
      int sum = A[i] - A[j];
      if (sum <= S){
        mp[sum]++;
      } else {
        break;
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= S; i++){
    if (S % i == 0){
      ans += mp[i] * mp[S / i];
    }
  }
  cout << ans << endl;
}
accuracy: 1
time_ms: 60
memory_kb: 7984
final_rank: 9

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

int main() {
  using ll = long long;

  set< ll > st;
  vector< ll > rs(100001, 0);
  for (ll i = 0; i < rs.size(); ++i) {
    st.insert(i * (i + 1));
    rs[i] = i * (i + 1);
  }

  ll s;
  cin >> s;

  vector< ll > div;
  for (ll i  = 1; i * i <= s; ++i) {
    if (i * i == s) {
      div.push_back(i);
      continue;
    }

    if (s % i == 0) {
      div.push_back(i);
      div.push_back(s / i);
    }
  }

  ll ans = 0;
  for (auto d: div) {
    ll rc = 0, lc = 0;
    for (ll r = 1; r <= s; ++r) {
      if (st.count(r * (r + 1) - 2 * d)) {
	rc++;
      }
    }

    int nd = s / d;
    for (ll r = 1; r <= s; ++r) {
      if (st.count(r * (r + 1) - 2 * nd)) {
	lc++;
      }
    }
    
    ans += lc * rc;
  }

  cout << ans << endl;
}
accuracy: 1
time_ms: 1580
memory_kb: 8204
final_rank: 18