Language: C++

#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int b_s(vector<llint>& a, llint key) {
	int left = -1;
	int right = a.size();
	while (right - left > 1) {
		int mid = left + (right - left) / 2;
		if (a[mid] > key)right = mid;
		else left = mid;
	}
	return right;
}
int main() {
	llint n, m, k;
	cin >> n >> m >> k;
	hei(llint) a(n + 1, 0), b(m + 1, 0);
	rep(i, 0, n) {
		cin >> a[i + 1];
		a[i + 1] += a[i];
	}
	rep(i, 0, m) {
		cin >> b[i + 1];
		b[i + 1] += b[i];
	}

	int ans = 0;
	rep(i, 0, n + 1) {
		if (k >= a[i])ans = max(ans, b_s(b, k - a[i]) - 1 + i);
	}
	cout << ans << endl;
	return 0;
}
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}

long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

// mod. m での a の逆元 a^{-1} を計算するよ！
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


//aCbをmod.mで割った余りを求める
ll int c(ll int a, ll int b, ll int m) {
	ll int ans = 1;
	for (ll int i = 0; i < b; i++) {
		ans *= a - i;
		ans %= m;
	}
	for (ll int i = 1; i <= b; i++) {
		ans *= modinv(i, m);
		ans %= m;
	}
	return ans;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}
	int size(int a) {
		return par[root(a)];
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int b_s(vector<llint>& a, llint key) {
	int left = -1;
	int right = a.size();
	while (right - left > 1) {
		int mid = left + (right - left) / 2;
		if (a[mid] > key)right = mid;
		else left = mid;
	}
	return right;
}
int main() {
	int a, b;
	cin >> a;
	b = 1000 - a % 1000;
	cout << b << endl;
	return 0;
}

Compiler output:
a.cc:162:16: error: conflicting declaration 'constexpr const auto INF'
  162 | constexpr auto INF = 1000000000000000000;
      |                ^~~
a.cc:28:16: note: previous declaration as 'constexpr const long int INF'
   28 | constexpr auto INF = 1000000000000000000;
      |                ^~~
a.cc:163:16: error: conflicting declaration 'constexpr const auto mod'
  163 | constexpr auto mod = 1000000007;
      |                ^~~
a.cc:29:16: note: previous declaration as 'constexpr const int mod'
   29 | constexpr auto mod = 1000000007;
      |                ^~~
a.cc:165:8: error: redefinition of 'struct edge'
  165 | struct edge { int to, cost; };
      |        ^~~~
a.cc:31:8: note: previous definition of 'struct edge'
   31 | struct edge { int to, cost; };
      |        ^~~~
a.cc:167:4: error: redefinition of 'long long int gcd(long long int, long long int)'
  167 | ll gcd(ll a, ll b) {
      |    ^~~
a.cc:33:4: note: 'long long int gcd(long long int, long long int)' previously defined here
   33 | ll gcd(ll a, ll b) {
      |    ^~~
a.cc:173:11: error: redefinition of 'long long int modpow(long long int, long long int, long long int)'
  173 | long long modpow(long long a, long long n, long long mod) {
      |           ^~~~~~
a.cc:39:11: note: 'long long int modpow(long long int, long long int, long long int)' previously defined here
   39 | long long modpow(long long a, long long n, long long mod) {
      |           ^~~~~~
a.cc:184:11: error: redefinition of 'long long int modinv(long long int, long long int)'
  184 | long long modinv(long long a, long long m) {
      |           ^~~~~~
a.cc:50:11: note: 'long long int modinv(long long int, long long int)' previously defined here
   50 | long long modinv(long long a, long long m) {
      |           ^~~~~~
a.cc:198:8: error: redefinition of 'long long int c(long long int, long long int, long long int)'
  198 | ll int c(ll int a, ll int b, ll int m) {
      |        ^
a.cc:64:8: note: 'long long int c(long long int, long long int, long long int)' previously defined here
   64 | ll int c(ll int a, ll int b, ll int m) {
      |        ^
a.cc:210:8: error: redefinition of 'struct UnionFind'
  210 | struct UnionFind {
      |        ^~~~~~~~~
a.cc:76:8: note: previous definition of 'struct UnionFind'
   76 | struct UnionFind {
      |        ^~~~~~~~~
a.cc:239:5: error: redefinition of 'int b_s(std::vector<long long int>&, long long int)'
  239 | int b_s(vector<llint>& a, llint key) {
      |     ^~~
a.cc:105:5: note: 'int b_s(std::vector<long long int>&, long long int)' previously defined here
  105 | int b_s(vector<llint>& a, llint key) {
      |     ^~~
a.cc:249:5: error: redefinition of 'int main()'
  249 | int main() {
      |     ^~~~
a.cc:115:5: note: 'int main()' previously defined here
  115 | int main() {
      |     ^~~~