Language: C++

#include <iostream>
#include <iterator>
#include <cstdio>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <chrono>
#include <functional>

using namespace std;
using lli = long long int;
using ulli = unsigned long long int;

namespace atcoder {
	void judge_outer(bool judge_exp, string ok = "Yes", string ng = "No")
	{
		if (judge_exp) {
			cout << ok << endl;
		}
		else {
			cout << ng << endl;
		}
	}

	int ncr(int left, int right)
	{
		right = min(left - right, right);
		int ans = 1;
		for (int i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000256;
	const int tenfive = 100100;
}

using namespace atcoder;


int minussum = 0;
int plussum = 0;
int n;
vector<int> arr;
vector<int> dis;

int calc(int value, int b, int dist)
{
	return abs(value - dist - 1 - b);
}

int signcalc(int value, int b, int dist)
{
	return value - dist - 1 - b;
}


//true:b増やしてもいい
bool check(int value, int b, int dist)
{
	return value > b + dist + 1;
}

int func(int base)
{
	int total = 0;
	for (int i = 0; i < n; i++) {
		total += calc(arr[i], base, i);
	}
	return total;
}

int main(void)
{

	cin >> n;
	int stk;
	for (int i = 0; i < n; i++) {
		cin >> stk;
		arr.push_back(stk);
		dis.push_back(signcalc(arr[i], 0, i));
	}
	sort(dis.begin(), dis.end());
	vector<int> subdis = dis;
	int total = 0;
	for (int i = 0; i < subdis.size(); i++) {
		subdis[i] = abs(subdis[i]);
		total += dis[i];
	}
	int subtotal = 0;
	int saveon = total;
	int savepos;
	for (int i = 0; i < subdis.size(); i++) {
		subtotal += dis[i];
		if (total + subtotal <= saveon) {
			savepos = i;
			saveon = total - subtotal;
		}
	}
	
	cout << min({func(dis[savepos]),func(dis[savepos+1]),func(dis[savepos-1]),func(dis[dis.size() / 2]})) << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:110:107: error: expected ')' before '}' token
  110 |         cout << min({func(dis[savepos]),func(dis[savepos+1]),func(dis[savepos-1]),func(dis[dis.size() / 2]})) << endl;
      |                                                                                       ~                   ^
      |                                                                                                           )
a.cc:110:20: error: no matching function for call to 'min(<brace-enclosed initializer list>)'
  110 |         cout << min({func(dis[savepos]),func(dis[savepos+1]),func(dis[savepos-1]),func(dis[dis.size() / 2]})) << endl;
      |                 ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 1 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:12:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   template argument deduction/substitution failed:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   candidate expects 2 arguments, 1 provided