Language: C++

#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
static char str[1200000];
int len;
vector<pair<char, int> > x;
scanf("%s", str);
len = strlen(str);
for(int i = 0; i < len; ++i) {
int it = i;
while(it < len && str[it] == str[i]) ++it;
x.push_back(make_pair(str[i], it - i));
i = it - 1;
}
int ans = 0;
for(int i = 0; i < x.size() - 2; ++i) {
pair<char, int> jjj = x[i], ooo = x[i + 1], iii = x[i + 2];
if(jjj.first != 'J' || ooo.first != 'O' || iii != 'I')
continue;
if(ooo.second > jjj.second || ooo.second > iii.second)
continue;
ans = max(ans, min(jjj.second, ooo.second, iii.second));
}

printf("%d\n", ans);
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:48: error: no match for 'operator!=' (operand types are 'std::pair<char, int>' and 'char')
   23 | if(jjj.first != 'J' || ooo.first != 'O' || iii != 'I')
      |                                            ~~~ ^~ ~~~
      |                                            |      |
      |                                            |      char
      |                                            std::pair<char, int>
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/vector:62,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_pair.h:1052:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator!=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1052 |     operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1052:5: note:   template argument deduction/substitution failed:
a.cc:23:51: note:   mismatched types 'const std::pair<_T1, _T2>' and 'char'
   23 | if(jjj.first != 'J' || ooo.first != 'O' || iii != 'I')
      |                                                   ^~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:455:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  455 |     operator!=(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:455:5: note:   template argument deduction/substitution failed:
a.cc:23:51: note:   'std::pair<char, int>' is not derived from 'const std::reverse_iterator<_Iterator>'
   23 | if(jjj.first != 'J' || ooo.first != 'O' || iii != 'I')
      |                                                   ^~~
/usr/include/c++/14/bits/stl_iterator.h:500:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  500 |     operator!=(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:500:5: note:   template argument deduction/substitution failed:
a.cc:23:51: note:   'std::pair<char, int>' is not derived from 'const std::reverse_iterator<_Iterator>'
   23 | if(jjj.first != 'J' || ooo.first != 'O' || iii != 'I')
      |                                                   ^~~
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1686 |     operator!=(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1686:5: note:   template argument deduction/substitution failed:
a.cc:23:51: note:   'std::pair<char, int>' is not derived from 'const std::move_iterator<_IteratorL>'
   23 | if(jjj.first != 'J' || ooo.first != 'O' || iii != 'I')
      |                                                   ^~~
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator!=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1753 |     operator!=(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1753:5: note:   template argument deduction/substitution failed:
a.cc:23:51: note:   'std::pair<char, int>' is not derived from 'const std::move_iterator<_IteratorL>'
   23 | if(jjj.first != 'J' || ooo.first != 'O' || iii != 'I')
      |                                                   ^~~
In file included from /usr/include/c++/14/vector:63:
/usr/include/c++/14/bits/allocator.h:243:5: note: candidate: 'template<class _T1, class _T2> bool std::operator!=(const allocator<_Tp1>&, const allocator<_T2>&)'
  243 |     operator!=(const allocator<_T1>&, const allocator<_T2>&)
      |     ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:243:5: note:   template argument deduction/substitution failed:
a.cc:23:51: note:   'std::pair<char, int>' is not derived from 'const std::allocator<_Tp1>'
   23 | if(jjj.first != 'J' || ooo.first != 'O' || iii != 'I')
      |                                                   ^~~
In file included from /usr/include/c++/14/vector:66:
/usr/include/c++/14/bits/stl_vector.h:2096:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator!=(const vector<_Tp, _Alloc>&, const vector<_Tp, _Alloc>&)'
 2096 |     operator!=(const vector<_Tp, _Alloc>& __x, const vector<_Tp, _Alloc>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:2096:5: note:   template argument deduction/substitution failed:
a.cc:23:51: note:   'std::pair<char, int>' is not derived from 'const std::vector<_Tp, _Alloc>'
   23 | if(jjj.first != 'J' || ooo.first != 'O' || iii != 'I')
      |                                                   ^~~
In file included from /usr/include/c++/14/bits/memory_resource.h:47,
                 from /usr/include/c++/14/vector:87:
/usr/include/c++/14/tuple:2613:5: note: candidate: 'template<class ... _TElements, class ... _UElements> constexpr bool std::operator!=(const tuple<_UTypes ...>&, const tuple<_Elements ...>&)'
 2613 |     operator!=(const tuple<_TElements...>& __t,
      |     ^~~~~~~~
/usr/include/c++/14/tuple:2613:5: note:   template argument deduction/substitution failed:
a.cc:23:51: note:   'std::pair<char, int>' is not derived from 'const std::tuple<_UTypes ...>'
   23 | if(jjj.first != 'J' || ooo.first != 'O' || iii != 'I')
      |                                                   ^~~
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
a.cc:27:19:   required from here
   27 | ans = max(ans, min(jjj.second, ooo.second, iii.second));
      |                ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:284:17: error: '__comp' cannot be used as a function
  284 |       if (__comp(__b, __a))
      |           ~~~~~~^~~~~~~~~~