Language: C++

/* [Template].cpp 
Example code to use when starting new code. This particular problem was problem 
977A_Wrong_Subtraction from CodeForces

Compile: g++  -o C.exe C.cpp 
Execute: ./C
*/ 

#include <cstdio>
#include <iostream>
#include <cmath> 
#include <limits> 
#include <iomanip>
#include <cstring> 
#include <bits/stdc++.h>
#include <string>  
using namespace std;

int main() { 	
	int n, m, k; 
	long a[200000], b[200000]; 
	vector<long long> a_cum (200001, 0), b_cum (200001, 0); 
	long result = 0; 
	
	// Input 
	cin >> n >> m >> k; 
	for(int i = 0; i < n; i++) {
		cin >> a[i]; 
	}
	for(int i = 0; i < m; i++) {
		cin >> b[i]; 
	}
	// Set up cumulative arrays
	a_cum[0] = 0; 
	for(int i = 1; i <= n; i++) {
		a_cum[i] = a_cum[i-1] + a[i-1]; 
	}
	b_cum[0] = 0; 
	for(int i = 1; i <= m; i++) {
		b_cum[i] = b_cum[i-1] + b[i-1]; 
	}
	
	// Solve problem 
	result = 0; 
	for(int i = 0; i <= n && a_cum[i] <= k; i++) {
		for(int j = min(m,result - i); j <= m && a_cum[i] + b_cum[j] <= k; j++) {
			if(a_cum[i] + b_cum[j] <= k) {
				if(i + j > result) {
					result = i + j; 
				}
			}
		}
	}
	
	cout << result << endl; 
	
	return 0; 
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:46:32: error: no matching function for call to 'min(int&, long int)'
   46 |                 for(int j = min(m,result - i); j <= m && a_cum[i] + b_cum[j] <= k; j++) {
      |                             ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:10:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:46:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   46 |                 for(int j = min(m,result - i); j <= m && a_cum[i] + b_cum[j] <= k; j++) {
      |                             ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:15:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:46:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   46 |                 for(int j = min(m,result - i); j <= m && a_cum[i] + b_cum[j] <= k; j++) {
      |                             ~~~^~~~~~~~~~~~~~