Language: C++

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


int main() {
    int64_t n,m,k;
    cin >> n >> m >> k;
    vector<int64_t> v1(n);
    vector<int64_t> v2(m);
    rep(i,n){
        cin >> v1[i];
    }
    rep(i,m){
        cin >> v2[i];
    }
    int64_t ans=0;
    vector<int64_t> tot1(n);
    vector<int64_t> tot2(m);
    rep(i,n){
        if(i!=0) tot1[i]=v1[i]+tot1[i-1];
        else tot1[i]=v1[i];
    }
    rep(i,m){
        if(i!=0) tot2[i]=v2[i]+tot2[i-1];
        else tot2[i]=v2[i];
    }
    rep(i,n){
        int64_t x=k-tot1[i];
        if(x<=0) break;
        int64_t begin=0;
        int64_t end=m-1;
        while(end!=-1){
            int mid=(begin+end)/2;
            if(tot2[m-1]<=x){
                ans=m+i+1;
            }
            if(tot2[mid]>x){
                end=mid;
            }
            else{
                begin=mid;
            }
            if(begin+1==end||begin==end){
                ans=max(ans,i+begin+2);
                end=-1;
            }
        }
        
    }
    cout << ans << endl;
    
}


Compiler output:
a.cc:5:18: error: declaration does not declare anything [-fpermissive]
    5 | #define int long long;
      |                  ^~~~
a.cc:8:1: note: in expansion of macro 'int'
    8 | int main() {
      | ^~~
a.cc:8:5: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | int main() {
      |     ^~~~
a.cc: In function 'int main()':
a.cc:5:18: error: declaration does not declare anything [-fpermissive]
    5 | #define int long long;
      |                  ^~~~
a.cc:3:24: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                        ^~~
a.cc:13:5: note: in expansion of macro 'rep'
   13 |     rep(i,n){
      |     ^~~
a.cc:13:9: error: 'i' was not declared in this scope
   13 |     rep(i,n){
      |         ^
a.cc:3:28: note: in definition of macro 'rep'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                            ^
a.cc:5:13: error: expected primary-expression before 'long'
    5 | #define int long long;
      |             ^~~~
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:13:5: note: in expansion of macro 'rep'
   13 |     rep(i,n){
      |     ^~~
a.cc:5:13: error: expected ')' before 'long'
    5 | #define int long long;
      |             ^~~~
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:13:5: note: in expansion of macro 'rep'
   13 |     rep(i,n){
      |     ^~~
a.cc:3:39: note: to match this '('
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                       ^
a.cc:13:5: note: in expansion of macro 'rep'
   13 |     rep(i,n){
      |     ^~~
a.cc:5:22: error: expected ')' before ';' token
    5 | #define int long long;
      |                      ^
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:13:5: note: in expansion of macro 'rep'
   13 |     rep(i,n){
      |     ^~~
a.cc:3:23: note: to match this '('
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                       ^
a.cc:13:5: note: in expansion of macro 'rep'
   13 |     rep(i,n){
      |     ^~~
a.cc:3:43: error: expected primary-expression before ')' token
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                           ^
a.cc:13:5: note: in expansion of macro 'rep'
   13 |     rep(i,n){
      |     ^~~
a.cc:13:9: error: 'i' was not declared in this scope
   13 |     rep(i,n){
      |         ^
a.cc:3:49: note: in definition of macro 'rep'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                                 ^
a.cc:5:18: error: declaration does not declare anything [-fpermissive]
    5 | #define int long long;
      |                  ^~~~
a.cc:3:24: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                        ^~~
a.cc:16:5: note: in expansion of macro 'rep'
   16 |     rep(i,m){
      |     ^~~
a.cc:5:13: error: expected primary-expression before 'long'
    5 | #define int long long;
      |             ^~~~
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:16:5: note: in expansion of macro 'rep'
   16 |     rep(i,m){
      |     ^~~
a.cc:5:13: error: expected ')' before 'long'
    5 | #define int long long;
      |             ^~~~
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:16:5: note: in expansion of macro 'rep'
   16 |     rep(i,m){
      |     ^~~
a.cc:3:39: note: to match this '('
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                       ^
a.cc:16:5: note: in expansion of macro 'rep'
   16 |     rep(i,m){
      |     ^~~
a.cc:5:22: error: expected ')' before ';' token
    5 | #define int long long;
      |                      ^
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:16:5: note: in expansion of macro 'rep'
   16 |     rep(i,m){
      |     ^~~
a.cc:3:23: note: to match this '('
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                       ^
a.cc:16:5: note: in expansion of macro 'rep'
   16 |     rep(i,m){
      |     ^~~
a.cc:3:43: error: expected primary-expression before ')' token
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                           ^
a.cc:16:5: note: in expansion of macro 'rep'
   16 |     rep(i,m){
      |     ^~~
a.cc:5:18: error: declaration does not declare anything [-fpermissive]
    5 | #define int long long;
      |                  ^~~~
a.cc:3:24: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                        ^~~
a.cc:22:5: note: in expansion of macro 'rep'
   22 |     rep(i,n){
      |     ^~~
a.cc:5:13: error: expected primary-expression before 'long'
    5 | #define int long long;
      |             ^~~~
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:22:5: note: in expansion of macro 'rep'
   22 |     rep(i,n){
      |     ^~~
a.cc:5:13: error: expected ')' before 'long'
    5 | #define int long long;
      |             ^~~~
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:22:5: note: in expansion of macro 'rep'
   22 |     rep(i,n){
      |     ^~~
a.cc:3:39: note: to match this '('
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                       ^
a.cc:22:5: note: in expansion of macro 'rep'
   22 |     rep(i,n){
      |     ^~~
a.cc:5:22: error: expected ')' before ';' token
    5 | #define int long long;
      |                      ^
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:22:5: note: in expansion of macro 'rep'
   22 |     rep(i,n){
      |     ^~~
a.cc:3:23: note: to match this '('
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                       ^
a.cc:22:5: note: in expansion of macro 'rep'
   22 |     rep(i,n){
      |     ^~~
a.cc:3:43: error: expected primary-expression before ')' token
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                           ^
a.cc:22:5: note: in expansion of macro 'rep'
   22 |     rep(i,n){
      |     ^~~
a.cc:5:18: error: declaration does not declare anything [-fpermissive]
    5 | #define int long long;
      |                  ^~~~
a.cc:3:24: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                        ^~~
a.cc:26:5: note: in expansion of macro 'rep'
   26 |     rep(i,m){
      |     ^~~
a.cc:5:13: error: expected primary-expression before 'long'
    5 | #define int long long;
      |             ^~~~
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:26:5: note: in expansion of macro 'rep'
   26 |     rep(i,m){
      |     ^~~
a.cc:5:13: error: expected ')' before 'long'
    5 | #define int long long;
      |             ^~~~
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:26:5: note: in expansion of macro 'rep'
   26 |     rep(i,m){
      |     ^~~
a.cc:3:39: note: to match this '('
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                       ^
a.cc:26:5: note: in expansion of macro 'rep'
   26 |     rep(i,m){
      |     ^~~
a.cc:5:22: error: expected ')' before ';' token
    5 | #define int long long;
      |                      ^
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:26:5: note: in expansion of macro 'rep'
   26 |     rep(i,m){
      |     ^~~
a.cc:3:23: note: to match this '('
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                       ^
a.cc:26:5: note: in expansion of macro 'rep'
   26 |     rep(i,m){
      |     ^~~
a.cc:3:43: error: expected primary-expression before ')' token
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                           ^
a.cc:26:5: note: in expansion of macro 'rep'
   26 |     rep(i,m){
      |     ^~~
a.cc:5:18: error: declaration does not declare anything [-fpermissive]
    5 | #define int long long;
      |                  ^~~~
a.cc:3:24: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                        ^~~
a.cc:30:5: note: in expansion of macro 'rep'
   30 |     rep(i,n){
      |     ^~~
a.cc:5:13: error: expected primary-expression before 'long'
    5 | #define int long long;
      |             ^~~~
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:30:5: note: in expansion of macro 'rep'
   30 |     rep(i,n){
      |     ^~~
a.cc:5:13: error: expected ')' before 'long'
    5 | #define int long long;
      |             ^~~~
a.cc:3:40: note: in expansion of macro 'int'
    3 | #define rep(i, n) for (int i = 0; i < (int)(n); i++)
      |                                        ^~~
a.cc:30:5: