Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

int mainsolve(){

	ll n,m,k;
	cin >> n >> m >> k;
	vector<ll> a(n), b(m);
	rep(i,n) cin >> a[i];
	rep(i,m) cin >> b[i];


	vector<ll> cumsumA(n+1), cumsumB(m+1);
	rep(i,n) cumsumA[i+1] = cumsumA[i] + a[i];
	rep(i,m) cumsumB[i+1] = cumsumB[i] + b[i];

	ll res = 0;
	ll sumA = 0, cntA = 0;
	ll sumB = 0, cntB = 0;

	// まず、Aから一冊も読まないと仮定
	while(true){
		if(sumB + b[cntB] > k) break;
		sumB += b[cntB];
		cntB++;
		if(cntB == m) break;
	}
	res = cntB;

	// Aから取る冊数を増やしていく
	rep(i,n){
		cntA++;
		sumA += a[i];
		while(sumA + sumB > k){
			cntB--;
			if(cntB < 0) break;
			sumB -= b[cntB];
		}

		if(cntB < 0) break;
		if(sumA + sumB > k) continue;
		res = max(res, cntA + cntB);
	}

	cout << res << endl;
	
	return 0;
}


	ll n;
	cin >> n;
	string s;
	cin >> s;


	vector<ll> cumsumR(n+1);
	rep(i,n){
		if(s[i] == 'R') cumsumR[i+1] = cumsumR[i] + 1;
		else cumsumR[i+1] = cumsumR[i];
	}

	ll res = MOD;
	rep(i,n+1){
		assert(i - cumsumR[i] >= 0);
		ll tmp = max(i - cumsumR[i], cumsumR[n] - cumsumR[i]);
		assert(tmp >= 0);
		res = min(res, tmp);
	}

	cout << res << endl;
	
	return 0;
}
int main(){

	return mainsolve();
}

Compiler output:
a.cc:58:9: error: 'cin' does not name a type
   58 |         cin >> n;
      |         ^~~
a.cc:60:9: error: 'cin' does not name a type
   60 |         cin >> s;
      |         ^~~
a.cc:5:18: error: expected unqualified-id before 'for'
    5 | #define rep(i,n) for (ll i = 0; i < (n); ++i)
      |                  ^~~
a.cc:64:9: note: in expansion of macro 'rep'
   64 |         rep(i,n){
      |         ^~~
a.cc:64:13: error: 'i' does not name a type
   64 |         rep(i,n){
      |             ^
a.cc:5:33: note: in definition of macro 'rep'
    5 | #define rep(i,n) for (ll i = 0; i < (n); ++i)
      |                                 ^
a.cc:5:42: error: expected unqualified-id before '++' token
    5 | #define rep(i,n) for (ll i = 0; i < (n); ++i)
      |                                          ^~
a.cc:64:9: note: in expansion of macro 'rep'
   64 |         rep(i,n){
      |         ^~~
a.cc:5:18: error: expected unqualified-id before 'for'
    5 | #define rep(i,n) for (ll i = 0; i < (n); ++i)
      |                  ^~~
a.cc:70:9: note: in expansion of macro 'rep'
   70 |         rep(i,n+1){
      |         ^~~
a.cc:70:13: error: 'i' does not name a type
   70 |         rep(i,n+1){
      |             ^
a.cc:5:33: note: in definition of macro 'rep'
    5 | #define rep(i,n) for (ll i = 0; i < (n); ++i)
      |                                 ^
a.cc:5:42: error: expected unqualified-id before '++' token
    5 | #define rep(i,n) for (ll i = 0; i < (n); ++i)
      |                                          ^~
a.cc:70:9: note: in expansion of macro 'rep'
   70 |         rep(i,n+1){
      |         ^~~
a.cc:77:9: error: 'cout' does not name a type; did you mean 'mcout'?
   77 |         cout << res << endl;
      |         ^~~~
      |         mcout
a.cc:79:9: error: expected unqualified-id before 'return'
   79 |         return 0;
      |         ^~~~~~
a.cc:80:1: error: expected declaration before '}' token
   80 | }
      | ^