Language: C++

#include <map>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(){
	map<long long,int>m={0,-1};
	long long s=0,x;
	int N,r=0;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		scanf("%lld",&x);
		s+=x;
		if(m.find(s)==m.end())m[s]=i;
		r=max(r,i-m[s]);
	}
	printf("%d\n",r);
}

Compiler output:
In file included from /usr/include/c++/14/map:63,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_map.h: In instantiation of 'std::map<_Key, _Tp, _Compare, _Alloc>::map(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = long long int; _Tp = int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, int> >]':
a.cc:7:27:   required from here
    7 |         map<long long,int>m={0,-1};
      |                                  ^
/usr/include/c++/14/bits/stl_map.h:287:38: error: no matching function for call to 'std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::_M_insert_range_unique(int&, int&)'
  287 |         { _M_t._M_insert_range_unique(__first, __last); }
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/map:62:
/usr/include/c++/14/bits/stl_tree.h:1096:9: note: candidate: 'template<class _InputIterator> std::__enable_if_t<((bool)std::is_same<_Val, typename std::iterator_traits<_Iter>::value_type>::value)> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_range_unique(_InputIterator, _InputIterator) [with _Key = long long int; _Val = std::pair<const long long int, int>; _KeyOfValue = std::_Select1st<std::pair<const long long int, int> >; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, int> >]'
 1096 |         _M_insert_range_unique(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1096:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_tree.h: In substitution of 'template<class _InputIterator> std::__enable_if_t<((bool)std::is_same<std::pair<const long long int, int>, typename std::iterator_traits< <template-parameter-1-1> >::value_type>::value), void> std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::_M_insert_range_unique(_InputIterator, _InputIterator) [with _InputIterator = int]':
/usr/include/c++/14/bits/stl_map.h:287:31:   required from 'std::map<_Key, _Tp, _Compare, _Alloc>::map(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = long long int; _Tp = int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, int> >]'
  287 |         { _M_t._M_insert_range_unique(__first, __last); }
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
a.cc:7:27:   required from here
    7 |         map<long long,int>m={0,-1};
      |                                  ^
/usr/include/c++/14/bits/stl_tree.h:1095:58: error: no type named 'value_type' in 'struct std::iterator_traits<int>'
 1095 |         __enable_if_t<__same_value_type<_InputIterator>::value>
      |                                                          ^~~~~
/usr/include/c++/14/bits/stl_map.h: In instantiation of 'std::map<_Key, _Tp, _Compare, _Alloc>::map(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = long long int; _Tp = int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, int> >]':
a.cc:7:27:   required from here
    7 |         map<long long,int>m={0,-1};
      |                                  ^
/usr/include/c++/14/bits/stl_tree.h:1105:9: note: candidate: 'template<class _InputIterator> std::__enable_if_t<((bool)(! std::is_same<_Val, typename std::iterator_traits<_Iter>::value_type>::value))> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_range_unique(_InputIterator, _InputIterator) [with _Key = long long int; _Val = std::pair<const long long int, int>; _KeyOfValue = std::_Select1st<std::pair<const long long int, int> >; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, int> >]'
 1105 |         _M_insert_range_unique(_InputIterator __first, _InputIterator __last)
      |         ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_tree.h:1105:9: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_tree.h: In substitution of 'template<class _InputIterator> std::__enable_if_t<((bool)(! std::is_same<std::pair<const long long int, int>, typename std::iterator_traits< <template-parameter-1-1> >::value_type>::value)), void> std::_Rb_tree<long long int, std::pair<const long long int, int>, std::_Select1st<std::pair<const long long int, int> >, std::less<long long int>, std::allocator<std::pair<const long long int, int> > >::_M_insert_range_unique(_InputIterator, _InputIterator) [with _InputIterator = int]':
/usr/include/c++/14/bits/stl_map.h:287:31:   required from 'std::map<_Key, _Tp, _Compare, _Alloc>::map(_InputIterator, _InputIterator) [with _InputIterator = int; _Key = long long int; _Tp = int; _Compare = std::less<long long int>; _Alloc = std::allocator<std::pair<const long long int, int> >]'
  287 |         { _M_t._M_insert_range_unique(__first, __last); }
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
a.cc:7:27:   required from here
    7 |         map<long long,int>m={0,-1};
      |                                  ^
/usr/include/c++/14/bits/stl_tree.h:1104:59: error: no type named 'value_type' in 'struct std::iterator_traits<int>'
 1104 |         __enable_if_t<!__same_value_type<_InputIterator>::value>
      |                                                           ^~~~~