Language: C++

// include
//#include <bits/stdc++.h> // last resort
#include <algorithm>     // sort, binary-search, etc.
#include <bitset>        // fixed-length bitset
#include <cmath>         // pow, log, etc.
#include <complex>       // complex number
#include <cstring>       // memset, memcpy
#include <deque>         //
#include <functional>    //
#include <iomanip>       // setprecision
#include <iostream>      // i/o
#include <iterator>      // operations for set
#include <map>           // map or dict
#include <numeric>       // iota, gcd, lcm
#include <queue>         //
#include <set>           //
#include <stack>         //
#include <string>        //
#include <unordered_map> //
#include <unordered_set> //
#include <utility>       // pair
#include <vector>        // variable-length array

// typedef and const
typedef long long ll;
const int DEFMOD = 1e9 + 7; // default modulus
const int INF = INT32_MAX;  // ~1e9
const ll LINF = INT64_MAX;  // ~1e18

//namespace
using namespace std;

// macros
// read and initialize
#define FILL(array, number) memset(array, number, sizeof(array))
#define RMI(array)             \
    for (auto &item : (array)) \
    cin >> item
// loop
#define FOREACH(item, array) for (auto &(item) : (array))
#define REP(index, time) for (int index = 0; index < (int)(time); ++index)
#define REPD(index, time) for (int index = time; 0 < index; --index)
#define SIZE(array) ((int)(array).size())
// write and presentation
#define COUTS(variable) cout << (variable) << " "
#define DUMP(variable) cout << #variable << ": " << (variable) << endl
#define ENDL cout << endl
#define WM(array)              \
    for (auto &item : (array)) \
    {                          \
        COUTS(item);           \
        ENDL;                  \
    }
// abbreviation
#define ALL(array) (array).begin(), (array).end()
#define M_ map<int, int>
#define MP make_pair
#define P_ pair<int, int>
#define PB(item) push_back(item)
#define PQ priority_queue<int>
#define PQG priority_queue<int, V, greater>
#define S_ set<int>
#define TO(condition, true, false) ((condition) ? (true) : (false))
#define V_ vector<int>

void func(long long N, long long M, long long K, std::vector<long long> A, std::vector<long long> B)
{
    ll result = dfs(K, A, B, 0, 0);
    cout << result << endl;
}

ll dfs(ll remain, vector<ll> A, vector<ll> B, ll a, ll b)
{
    ll a_top = A[a], b_top = B[b];
    if (remain < a_top && remain < b_top)
        return 0;
    ll a_result = 0, b_result = 0;
    if (a_top <= remain)
        a_result = dfs(remain - a_top, A, B, a + 1, b) + 1;
    if (b_top <= remain)
        b_result = dfs(remain - b_top, A, B, a, b + 1) + 1;
    return a_result > b_result ? a_result : b_result;
}

int main()
{
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    long long K;
    scanf("%lld", &K);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++)
    {
        scanf("%lld", &A[i]);
    }
    std::vector<long long> B(M);
    for (int i = 0; i < M; i++)
    {
        scanf("%lld", &B[i]);
    }
    func(N, M, K, std::move(A), std::move(B));
    return 0;
}


Compiler output:
a.cc:27:17: error: 'INT32_MAX' was not declared in this scope
   27 | const int INF = INT32_MAX;  // ~1e9
      |                 ^~~~~~~~~
a.cc:22:1: note: 'INT32_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
   21 | #include <utility>       // pair
  +++ |+#include <cstdint>
   22 | #include <vector>        // variable-length array
a.cc:28:17: error: 'INT64_MAX' was not declared in this scope
   28 | const ll LINF = INT64_MAX;  // ~1e18
      |                 ^~~~~~~~~
a.cc:28:17: note: 'INT64_MAX' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
a.cc: In function 'void func(long long int, long long int, long long int, std::vector<long long int>, std::vector<long long int>)':
a.cc:68:17: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   68 |     ll result = dfs(K, A, B, 0, 0);
      |                 ^~~
      |                 ffs