Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;

// int N, M, K;
// int a[200005], b[200005];
// ll tota[200005], totb[200005]; 

// int main() {
//     cin >> N >> M >> K;
//     rep(i,N) cin >> a[i];
//     rep(i,M) cin >> b[i];
//     rep(i,N) {
//         tota[i+1] = tota[i] + a[i];
//     }
//     rep(i,M) {
//         totb[i+1] = totb[i] + b[i];
//     }
//     int res = 0;
//     int nj = M;
//     rep(ni, N+1) {
//         while(nj >= 0 && totb[nj]  + tota[ni] > K) nj--;
//         chmax(res, ni + max(0, nj));
//     }
//     cout << res << endl;
//     return 0;
// }

int N, M, K, A[201010], B[201010];
ll Atot[201010], Btot[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N >> M >> K;
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, M) cin >> B[i];

    Atot[0] = 0;
    rep(i, 0, N) Atot[i + 1] = Atot[i] + A[i];
    Btot[0] = 0;
    rep(i, 0, M) Btot[i + 1] = Btot[i] + B[i];

    int ans = 0;
    int ok = M;
    rep(a, 0, N + 1) {
        while (0 <= ok && K < Atot[a] + Btot[ok]) ok--;
        if(0 <= ok) chmax(ans, a + ok);
    }
    cout << ans << endl;
}

Compiler output:
a.cc:40:16: error: macro "rep" passed 3 arguments, but takes just 2
   40 |     rep(i, 0, N) cin >> A[i];
      |                ^
a.cc:2:9: note: macro "rep" defined here
    2 | #define rep(i,n) for (int i = 0; i < (n); ++i)
      |         ^~~
a.cc:41:16: error: macro "rep" passed 3 arguments, but takes just 2
   41 |     rep(i, 0, M) cin >> B[i];
      |                ^
a.cc:2:9: note: macro "rep" defined here
    2 | #define rep(i,n) for (int i = 0; i < (n); ++i)
      |         ^~~
a.cc:44:16: error: macro "rep" passed 3 arguments, but takes just 2
   44 |     rep(i, 0, N) Atot[i + 1] = Atot[i] + A[i];
      |                ^
a.cc:2:9: note: macro "rep" defined here
    2 | #define rep(i,n) for (int i = 0; i < (n); ++i)
      |         ^~~
a.cc:46:16: error: macro "rep" passed 3 arguments, but takes just 2
   46 |     rep(i, 0, M) Btot[i + 1] = Btot[i] + B[i];
      |                ^
a.cc:2:9: note: macro "rep" defined here
    2 | #define rep(i,n) for (int i = 0; i < (n); ++i)
      |         ^~~
a.cc:50:20: error: macro "rep" passed 3 arguments, but takes just 2
   50 |     rep(a, 0, N + 1) {
      |                    ^
a.cc:2:9: note: macro "rep" defined here
    2 | #define rep(i,n) for (int i = 0; i < (n); ++i)
      |         ^~~
a.cc: In function 'void _main()':
a.cc:40:5: error: 'rep' was not declared in this scope
   40 |     rep(i, 0, N) cin >> A[i];
      |     ^~~
a.cc:41:8: error: expected ';' before 'cin'
   41 |     rep(i, 0, M) cin >> B[i];
      |        ^         ~~~
      |        ;
a.cc:44:8: error: expected ';' before 'Atot'
   44 |     rep(i, 0, N) Atot[i + 1] = Atot[i] + A[i];
      |        ^         ~~~~
      |        ;
a.cc:46:8: error: expected ';' before 'Btot'
   46 |     rep(i, 0, M) Btot[i + 1] = Btot[i] + B[i];
      |        ^         ~~~~
      |        ;
a.cc:50:8: error: expected ';' before '{' token
   50 |     rep(a, 0, N + 1) {
      |        ^             ~
      |        ;