Language: C++

#include <iostream>
#include <math.h>

using namespace std;

int n, m, a[50], b[50], c[51], d[51], ans = 0, max = 0;

int main(){
	cin >> n >> m;
	for (int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
	}
	for (int i = 1; i <= m; i++){
		cin >> c[i] >> d[i];
	}

	for (int i = 0; i < n; i++){
		max = abs(a[i] - c[1]) + abs(b[i] - d[1]);
		ans = 1;

		for (int j = 2; j <= m; j++){
			if (abs(a[i] - c[j]) + abs(b[i] - d[j]) < max){
				max = abs(a[i] - c[j]) + abs(b[i] - d[j]);
				ans = j;
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:17: error: reference to 'max' is ambiguous
   18 |                 max = abs(a[i] - c[1]) + abs(b[i] - d[1]);
      |                 ^~~
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:1:
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:6:48: note:                 'int max'
    6 | int n, m, a[50], b[50], c[51], d[51], ans = 0, max = 0;
      |                                                ^~~
a.cc:22:67: error: reference to 'max' is ambiguous
   22 |                         if (abs(a[i] - c[j]) + abs(b[i] - d[j]) < max){
      |                                                                   ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:6:48: note:                 'int max'
    6 | int n, m, a[50], b[50], c[51], d[51], ans = 0, max = 0;
      |                                                ^~~
a.cc:23:33: error: reference to 'max' is ambiguous
   23 |                                 max = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      |                                 ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidates are: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:                 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
a.cc:6:48: note:                 'int max'
    6 | int n, m, a[50], b[50], c[51], d[51], ans = 0, max = 0;
      |                                                ^~~