Language: C++

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define MP make_pair
#define MT make_tuple
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;

	map<char, int> m;
	EACH(c, S) m[c]++;

	int ret = 0, d = 0;
	char pre = 0;
	EACH(a, m){
		if(pre != a) d++;
		ret = max(ret, a.second);
		pre = a;
	}

//	cout << S.size() << " " << ret << endl;
	cout << (S.size() - ret + 1) / max(2, ret - d) << endl;


	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:59:24: error: no match for 'operator!=' (operand types are 'char' and 'std::pair<const char, int>')
   59 |                 if(pre != a) d++;
      |                    ~~~ ^~ ~
      |                    |      |
      |                    char   std::pair<const 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:1:
/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:59:27: note:   mismatched types 'const std::pair<_T1, _T2>' and 'char'
   59 |                 if(pre != a) d++;
      |                           ^
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:59:27: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'char'
   59 |                 if(pre != a) d++;
      |                           ^
/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:59:27: note:   mismatched types 'const std::reverse_iterator<_Iterator>' and 'char'
   59 |                 if(pre != a) d++;
      |                           ^
/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:59:27: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'char'
   59 |                 if(pre != a) d++;
      |                           ^
/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:59:27: note:   mismatched types 'const std::move_iterator<_IteratorL>' and 'char'
   59 |                 if(pre != a) d++;
      |                           ^
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:59:27: note:   mismatched types 'const std::allocator<_Tp1>' and 'char'
   59 |                 if(pre != a) d++;
      |                           ^
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:59:27: note:   mismatched types 'const std::vector<_Tp, _Alloc>' and 'char'
   59 |                 if(pre != a) d++;
      |                           ^
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:59:27: note:   mismatched types 'const std::tuple<_UTypes ...>' and 'char'
   59 |                 if(pre != a) d++;
      |                           ^
In file included from /usr/include/c++/14/list:65,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_list.h:2196:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator!=(const __cxx11::list<_Tp, _Alloc>&, const __cxx11::list<_Tp, _Alloc>&)'
 2196 |     operator!=(const list<_Tp, _Alloc>& __x, const list<_Tp, _Alloc>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_list.h:2196:5: note:   template argument deduction/substitution failed:
a.cc:59:27: note:   mismatched types 'const std::__cxx11::list<_Tp, _Alloc>' and 'char'
   59 |                 if(pre != a) d++;
      |                           ^
In file included from /usr/include/c++/14/map:63,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_map.h:1557:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator!=(const map<_Key, _Tp, _Compare, _Allocator>&, const map<_Key, _Tp, _Compare, _Allocator>&)'
 1557 |     operator!=(const map<_Key, _Tp, _Compare, _Alloc>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_map.h:1557:5: note:   template argument deduction/substitution failed:
a.cc:59:27: note:   mismatched types 'const std::map<_Key, _Tp, _Compare, _Allocator>' and 'char'
   59 |                 if(pre != a) d++;
      |                           ^
In file included from /usr/include/c++/14/map:64:
/usr/include/c++/14/bits/stl_multimap.h:1179:5: note: candidate: 'template<class _Key, class _Tp, class _Compare, class _Alloc> bool std::operator!=(const multimap<_Key, _Tp, _Compare, _Allocator>&, const multimap<_Key, _Tp, _Compare, _Allocator>&)'
 1179 |     operator!=(const multimap<_Key, _Tp, _Compare, _Alloc>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_multimap.h:1179:5: note:   template argument deduction/substitution failed:
a.cc:59:27: note:   mismatched types 'const std::multimap<_Key, _Tp, _Compare, _Allocator>' and 'char'
   59 |                 if(pre != a) d++;
      |                           ^
In file included from /usr/include/c++/14/set:63,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_set.h:1032:5: note: candidate: 'template<class _Key, class _Compare, class _Alloc> bool std::operator!=(const set<_Key, _Compare, _Allocator>&, const set<_Key, _Compare, _Allocator>&)'
 1032 |     operator!=(const set<_Key, _Compare, _Alloc>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_set.h:1032:5: note:   template argument deduction/substitution failed:
a.cc:59:27: note:   mismatched types 'const std::set<_Key, _Compare, _Allocator>' and 'char'
   59 |                 if(pre != a) d++;
      |                           ^
In file included from /usr/include/c++/14/set:64:
/usr/include/c++/14/bits/stl_multiset.h:1018:5: note: candidate: 'template<class _Key, class _Compare, class _Alloc> bool std::operator!=(const multiset<_Key, _Compare, _Allocator>&, const multiset<_Key, _Compare, _Allocator>&)'
 1018 |     operator!=(const multiset<_Key, _Compare, _Alloc>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_multiset.h:1018:5: note:   template argument deduction/substitution failed:
a.cc:59:27: note:   mismatched types 'const std::multiset<_Key, _Compare, _Allocator>' and 'char'
   59 |                 if(pre != a) d++;
      |                           ^
In file included from /usr/include/c++/14/deque:66,
                 from a.cc:5:
/usr/include/c++/14/bits/stl_deque.h:2342:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator!=(const deque<_Tp, _Alloc>&, const deque<_Tp, _Alloc>&)'
 2342 |     operator!=(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_deque.h:2342:5: note:   template argument deduction/substitution failed:
a.cc:59:27: note:   mismatched types 'const std::deque<_Tp, _Alloc>' and 'char'
   59 |                 if(pre != a) d++;
      |                           ^
In file included from /usr/include/c++/14/stack:63,
                 from a.cc:6:
/usr/include/c++/14/bits/stl_stack.h:380:5: note: candidate: 'template<class _Tp, class _Seq> bool std::operator!=(const stack<_Tp, _Seq>&, const stack<_Tp, _Seq>&)'
  380 |     operator!=(const stack<_Tp, _Seq>& __x, const stack<_Tp, _Seq>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_stack.h:380:5: note:   template argument deduction/substitution failed:
a.cc:59:27: note:   mismatched types 'const std::stack<_Tp, _Seq>' and 'char'
   59 |                 if(pre != a) d++;
      |                           ^
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:7:
/usr/include/c++/14/bits/stl_queue.h:404:5: note: candidate: 'template<class _Tp, class _Seq> bool std::operator!=(const queue<_Tp, _Seq>&, const queue<_Tp, _Seq>&)'
  404 |     operator!=(const queue<_Tp, _Seq>& __x, const queue<_Tp, _Seq>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:404:5: note:   template argument deduction/substitution failed:
a.cc:59:27: note:   mismatched types 'const std::queue<_Tp, _Seq>' and 'char'
   59 |                 if(pre != a) d++;
      |                           ^
In file included from /usr/in