Language: C++

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <cmath>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long ll;

int main(void){
    ll n,m,k;
    cin>>n>>m>>k;
    ll s=0,c=0;
    vector <ll> a(n+1);
    vector<ll>b(m+1);
    rep(i,n){
        cin>>a[i];
    }
    a[n]=10000000001;
    b[m]=10000000001;
    rep(i,m){
        cin>>b[i];
    }
    ll i=0,j=0;
    while(1){
        if(s>k)break;
        if(i==n&&j==m){
            c++;
            break;
        }
        if(i==n&&j!=n){
            s+=b[j];
            j++;
            c++;
        }
        else if(j==m&&i!=n){
            s+=a[i];
            i++;
            c++;
        }
        else if(a[i]>b[j]){
            s+=b[j];
            j++;
            c++;
        }else if(a[i]<b[j]){
            s+=a[i];
            i++;
            c++;
        }else if(a[i]==b[j]){
            if(a[i+1]>b[i+1]){
                s+=b[j];
                j++;
                c++;
            }else{
                s+=a[i];
                i++;
                c++;
            }
        }
        cout<<s<<endl;
        
    }
    cout<<c-1<<endl;
    
}
    a[n]=10000000001;
    b[m]=10000000001;
    rep(i,m){
        cin>>b[i];
    }
    ll i=0,j=0;
    while(1){
        if(s>k)break;
        if(i==n&&j==m){
            break;
        }
        if(i==n&&j!=n){
            s+=b[j];
            j++;
            c++;
        }
        else if(j==m&&i!=n){
            s+=a[i];
            i++;
            c++;
        }
        else if(a[i]>b[j]){
            s+=b[j];
            j++;
            c++;
        }else if(a[i]<b[j]){
            s+=a[i];
            i++;
            c++;
        }else if(a[i]==b[j]){
            if(a[i+1]>b[i+1]){
                s+=b[j];
                j++;
                c++;
            }else{
                s+=a[i];
                i++;
                c++;
            }
        }
        cout<<s<<endl;
        
    }
    cout<<c-1<<endl;
    
}

Compiler output:
a.cc:70:5: error: 'a' does not name a type
   70 |     a[n]=10000000001;
      |     ^
a.cc:71:5: error: 'b' does not name a type
   71 |     b[m]=10000000001;
      |     ^
a.cc:10:18: error: expected unqualified-id before 'for'
   10 | #define rep(i,n) for(int i=0;i<(int)(n);i++)
      |                  ^~~
a.cc:72:5: note: in expansion of macro 'rep'
   72 |     rep(i,m){
      |     ^~~
a.cc:72:9: error: 'i' does not name a type
   72 |     rep(i,m){
      |         ^
a.cc:10:30: note: in definition of macro 'rep'
   10 | #define rep(i,n) for(int i=0;i<(int)(n);i++)
      |                              ^
a.cc:72:9: error: 'i' does not name a type
   72 |     rep(i,m){
      |         ^
a.cc:10:41: note: in definition of macro 'rep'
   10 | #define rep(i,n) for(int i=0;i<(int)(n);i++)
      |                                         ^
a.cc:76:5: error: expected unqualified-id before 'while'
   76 |     while(1){
      |     ^~~~~
a.cc:113:5: error: 'cout' does not name a type
  113 |     cout<<c-1<<endl;
      |     ^~~~
a.cc:115:1: error: expected declaration before '}' token
  115 | }
      | ^