Language: C++

#include <bits/stdc++.h>
#include <gmpxx.h>

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; return(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

ll mod_fact(ll number) {
    ll ret = 1;
    ll count = 1;
    while (count <= number) {
        ret *= (count % MOD);
        ret %= MOD;
        count++;
    }
    return ret % MOD;
}

ll gcd(ll a, ll b) {
    if (a < b) {
        return gcd(b, a);
    }
    ll c = a % b;
    while (c != 0) {
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

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

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
int main() {
    cin >> n >> m >> k;
    vl a(n);
    vl b(m);

    IPT(a, n)
    IPT(b, m)

    vl sum_a(n);
    vl sum_b(m);
    sum_a.at(0) = a.at(0);
    sum_b.at(0) = b.at(0);

    REP(i, 1, n) {
        sum_a[i] = sum_a.at(i - 1) + a.at(i);
    }

    REP(i, 1, m) {
        sum_b[i] = sum_b.at(i - 1) + b.at(i);
    }

    ans = 0;
    NREP() {
        if (sum_a.at(i) > k) {
            break;
        }

        auto b_itr = upper_bound(ALL(sum_b), k - sum_a.at(i));
        ll a_idx = i + 1;
        ll b_idx = min(distance(sum_b.begin(), b_itr), 0ll);
        ans = max(ans, a_idx + b_idx);
    }
    MSG(ans)
}


Compiler output:
a.cc: In function 'int main()':
a.cc:113:23: error: no matching function for call to 'min(std::__iterator_traits<__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >, void>::difference_type, long long int)'
  113 |         ll b_idx = min(distance(sum_b.begin(), b_itr), 0ll);
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:113:23: note:   deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
  113 |         ll b_idx = min(distance(sum_b.begin(), b_itr), 0ll);
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:113:23: note:   mismatched types 'std::initializer_list<_Tp>' and 'long int'
  113 |         ll b_idx = min(distance(sum_b.begin(), b_itr), 0ll);
      |                    ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~