Language: C++

#include <cstdio>
using namespace std;

#define MAX_N 100000
#define MAX_A 1000000000
#define INF 100000000000000
typedef __int64 Int;
int N;
Int A[MAX_N * 2 + 1];

bool C(int p, Int x){
	int lb, ub, mid;
	int ed = p + N;
	
	lb = p; ub = ed;
	while(ub - lb > 1){
		mid = (lb + ub) / 2;
		if(A[mid] - A[p] >= x) ub = mid;
		else lb = mid;
	}
	if(A[ub] - A[p] < x) return false;
	
	p = ub; lb = ub; ub = ed;
	while(ub - lb > 1){
		mid = (lb + ub) / 2;
		if(A[mid] - A[p] >= x) ub = mid;
		else lb = mid;
	}
	if(A[ub] - A[p] < x) return false;
	
	if(A[ed] - A[ub] < x) return false;
	
	return true;
}

Int Max(Int a, Int b){
	return (a > b)? a : b;
}

int main(){
	Int n, res, lb, ub, mid;
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%I64d", &n);
		A[i + 1] = A[i] + n;
	}
	for(int i = N + 1; i <= N * 2; i++){
		A[i] = A[i - 1] + A[i - N] - A[i - N - 1];
	}
	
	res = 0;
	for(int i = 1; i <= N; i++){
		lb = 0; ub = INF;
		while(ub - lb > 1){
			mid = (ub + lb) / 2;
			if(C(i - 1, mid)) lb = mid;
			else ub = mid;
		}
		
		res = Max(res, lb);
	}
	
	printf("%I64d\n", res);
	
	return 0;
}

Compiler output:
a.cc:7:9: error: '__int64' does not name a type; did you mean '__int64_t'?
    7 | typedef __int64 Int;
      |         ^~~~~~~
      |         __int64_t
a.cc:9:1: error: 'Int' does not name a type; did you mean 'int'?
    9 | Int A[MAX_N * 2 + 1];
      | ^~~
      | int
a.cc:11:15: error: 'Int' has not been declared
   11 | bool C(int p, Int x){
      |               ^~~
a.cc: In function 'bool C(int, int)':
a.cc:18:20: error: 'A' was not declared in this scope
   18 |                 if(A[mid] - A[p] >= x) ub = mid;
      |                    ^
a.cc:21:12: error: 'A' was not declared in this scope
   21 |         if(A[ub] - A[p] < x) return false;
      |            ^
a.cc:26:20: error: 'A' was not declared in this scope
   26 |                 if(A[mid] - A[p] >= x) ub = mid;
      |                    ^
a.cc:29:12: error: 'A' was not declared in this scope
   29 |         if(A[ub] - A[p] < x) return false;
      |            ^
a.cc:31:12: error: 'A' was not declared in this scope
   31 |         if(A[ed] - A[ub] < x) return false;
      |            ^
a.cc: At global scope:
a.cc:36:1: error: 'Int' does not name a type; did you mean 'int'?
   36 | Int Max(Int a, Int b){
      | ^~~
      | int
a.cc: In function 'int main()':
a.cc:41:9: error: 'Int' was not declared in this scope; did you mean 'int'?
   41 |         Int n, res, lb, ub, mid;
      |         ^~~
      |         int
a.cc:44:33: error: 'n' was not declared in this scope
   44 |                 scanf("%I64d", &n);
      |                                 ^
a.cc:45:17: error: 'A' was not declared in this scope
   45 |                 A[i + 1] = A[i] + n;
      |                 ^
a.cc:48:17: error: 'A' was not declared in this scope
   48 |                 A[i] = A[i - 1] + A[i - N] - A[i - N - 1];
      |                 ^
a.cc:51:9: error: 'res' was not declared in this scope
   51 |         res = 0;
      |         ^~~
a.cc:53:17: error: 'lb' was not declared in this scope
   53 |                 lb = 0; ub = INF;
      |                 ^~
a.cc:53:25: error: 'ub' was not declared in this scope
   53 |                 lb = 0; ub = INF;
      |                         ^~
a.cc:55:25: error: 'mid' was not declared in this scope
   55 |                         mid = (ub + lb) / 2;
      |                         ^~~
a.cc:60:23: error: 'Max' was not declared in this scope
   60 |                 res = Max(res, lb);
      |                       ^~~