Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stack>
using namespace std;
stack<int> st_i, st_j;

int m, n, lake[90][90], come, max = 0;
bool visit[90][90];

void search(int y, int x) {
	st_i.push(y);
	st_j.push(x);

	if ((x < m && lake[y][x + 1] == 1) && visit[y][x + 1] == false) {
		come++;
		visit[y][x + 1] = true;
		search(y, x + 1);
	}

	if ((x > 0 && lake[y][x - 1] == 1) && visit[y][x - 1] == false) {
		come++;
		visit[y][x - 1] = true;
		search(y, x - 1);
	}

	if ((y < n && lake[y + 1][x] == 1) && visit[y + 1][x] == false) {
		come++;
		visit[y + 1][x] = true;
		search(y + 1, x);
	}

	if ((y > 0 && lake[y - 1][x] == 1) && visit[y - 1][x] == false) {
		come++;
		visit[y - 1][x] = true;
		search(y - 1, x);
	}

	if (max < come) {
		max = come;
	}
	come--;
	visit[st_i.top()][st_j.top()] = false;
	st_i.pop();
	st_j.pop();
}

int main()
{
	
	scanf("%d", &m);
	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			scanf("%d", &lake[i][j]);
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (lake[i][j] == 1) {
				while (st_i.empty() == false) {
					st_i.pop();
					st_j.pop();
				}

				for (int a = 0; a < n; a++) {
					for (int b = 0; b < m; b++) {
						visit[a][b] = false;
					}
				}

				come = 1;
				visit[i][j] = true;
				search(i, j);
			}
		}
	}

	printf("%d\n", max);

	return 0;
}

Compiler output:
a.cc: In function 'void search(int, int)':
a.cc:38:13: error: reference to 'max' is ambiguous
   38 |         if (max < come) {
      |             ^~~
In file included from /usr/include/c++/14/deque:62,
                 from /usr/include/c++/14/stack:62,
                 from a.cc:3:
/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:7:31: note:                 'int max'
    7 | int m, n, lake[90][90], come, max = 0;
      |                               ^~~
a.cc:39:17: error: reference to 'max' is ambiguous
   39 |                 max = come;
      |                 ^~~
/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:7:31: note:                 'int max'
    7 | int m, n, lake[90][90], come, max = 0;
      |                               ^~~
a.cc: In function 'int main()':
a.cc:80:24: error: reference to 'max' is ambiguous
   80 |         printf("%d\n", 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:7:31: note:                 'int max'
    7 | int m, n, lake[90][90], come, max = 0;
      |                               ^~~