stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;



const long double PI = (acos(-1));

const long double EPS = 0.0000000001;



long double a, b, x;



long double f(long double a, long double b, long double theta){

    if(theta > PI/2.0 - EPS) return 0.0;

    long double ret;

    if(a*tan(theta) <= b)

        ret = a*a*b - a*a*a*tan(theta)/2.0;

    else

        ret = b*b/tan(theta)*a/2.0;

    return ret;

}



void solve(){

    long double ok = PI/2.0;

    long double ng = 0.0;

    for(int _ = 1; _ <= 100000; _++){

        long double mid = (ok+ng)/2.0;

        if(f(a, b, mid) < x) ok = mid;

        else ng = mid;

    }

    cout << fixed << setprecision(10) << ok/PI*180 << endl;

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    cin >> a >> b >> x;

    solve();

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 10.770505722202069x):
#include "bits/stdc++.h"

#define rep(i,n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef long long int ll;

typedef pair<int, int> P;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main(){

	cin.tie(0);

	ios::sync_with_stdio(false);

	double a, b, x;

	cin >> a >> b >> x;

	x /= a;

	double rad = (x <= a*b/2 ? atan2(b*b, 2*x) : atan2(2*(a*b-x), a*a));

	double ans = rad / (2*acos(-1)) * 360;

	cout << fixed << setprecision(12) << ans << endl;

	return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cmath>



using namespace std;

typedef long long ll;

#define REP(i,n) for (ll i = 0; i < (n); ++i)



#define deg_to_rad(deg) (((deg)/360)*2*M_PI)



int main(){

    double a, b, x;

    cin >> a >> b >> x;



    double lo = 0, hi = 90;

    while(hi - lo > 1e-8){

        const double mid = (hi + lo) / 2.0;

        const double rad = deg_to_rad(mid);

        const double rad2 = M_PI / 2 - rad;

        const double aheight = sin(rad) * a;

        const double bheight = sin(rad2) * b;

        double vol = 0;

        if(aheight >= bheight){

            const double aheight2 = bheight / cos(rad2);

            vol = aheight2 * a * b / 2.0;

        }else{

            const double y = aheight / tan(rad2);

            const double z = aheight / sin(rad2);

            vol = (

                a * a * z / 2.0 + a * (a * cos(rad) + y) * (bheight - aheight)

            );

        }

        if(vol < x){

            hi = mid;

        }else{

            lo = mid;

        }

    }

    printf("%.8f\n", lo);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.0118035345453589x):
#include <iostream>

#include <cstdio>

#include <cmath>



using namespace std;

typedef long long ll;

#define REP(i,n) for (ll i = 0; i < (n); ++i)



#define rad_to_deg(rad) (((rad)/2/M_PI)*360)



int main(){

    double a, b, x;

    cin >> a >> b >> x;



    x /= a;



    double ans = 0;

    if(x <= a * b / 2.0){

        const double a2 = 2 * x / b;

        ans = rad_to_deg(M_PI / 2.0 - atan2(a2, b));

    }else{

        const double b2 = 2 * x / a - b;

        ans = rad_to_deg(M_PI / 2.0 - atan2(a, b - b2));

    }

    printf("%.8f\n", ans);

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cmath>

#include <functional>



using namespace std;

typedef long long ll;

#define REP(i,n) for (ll i = 0; i < (n); ++i)



#define deg_to_rad(deg) (((deg)/360)*2*M_PI)



double continuous_binary_search(

    double lo, // 絶対 OK な値

    double hi, // [lo, hi] の間に最適値があるとする

    function<double(double)> is_ok, // OK かどうかを判定する

    double eps // 閾値

){

    while(hi - lo > eps){

        const double mid = (hi + lo) / 2.0;

        if(is_ok(mid)){

            lo = mid;

        }else{

            hi = mid;

        }

    }

    return lo;

}



int main(){

    double a, b, x;

    cin >> a >> b >> x;



    double ans = continuous_binary_search(

        0, 90,

        [&](double mid){

            const double rad = deg_to_rad(mid);

            const double rad2 = M_PI / 2 - rad;

            const double aheight = sin(rad) * a;

            const double bheight = sin(rad2) * b;

            double vol = 0;

            if(aheight >= bheight){

                const double aheight2 = bheight / cos(rad2);

                vol = aheight2 * a * b / 2.0;

            }else{

                const double y = aheight / tan(rad2);

                const double z = aheight / sin(rad2);

                vol = (

                    a * a * z / 2.0 + a * (a * cos(rad) + y) * (bheight - aheight)

                );

            }

            return (vol >= x);

        }, 1e-8

    );

    printf("%.8f\n", ans);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.0120630536071806x):
#include <iostream>

#include <cstdio>

#include <cmath>



using namespace std;

typedef long long ll;

#define REP(i,n) for (ll i = 0; i < (n); ++i)



#define rad_to_deg(rad) (((rad)/2/M_PI)*360)



int main(){

    double a, b, x;

    cin >> a >> b >> x;



    x /= a;



    double ans = 0;

    if(x <= a * b / 2.0){

        const double a2 = 2 * x / b;

        ans = rad_to_deg(M_PI / 2.0 - atan2(a2, b));

    }else{

        const double b2 = 2 * x / a - b;

        ans = rad_to_deg(M_PI / 2.0 - atan2(a, b - b2));

    }

    printf("%.8f\n", ans);

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cmath>

#include <functional>



using namespace std;

typedef long long ll;

#define REP(i,n) for (ll i = 0; i < (n); ++i)



#define deg_to_rad(deg) (((deg)/360)*2*M_PI)



double continuous_binary_search(

    double lo, // 絶対 OK な値

    double hi, // [lo, hi] の間に最適値があるとする

    function<bool(double)> is_ok, // OK かどうかを判定する

    double eps // 閾値

){

    while(hi - lo > eps){

        const double mid = (hi + lo) / 2.0;

        if(is_ok(mid)){

            lo = mid;

        }else{

            hi = mid;

        }

    }

    return lo;

}



int main(){

    double a, b, x;

    cin >> a >> b >> x;



    double ans = continuous_binary_search(

        0, 90,

        [&](double mid){

            const double rad = deg_to_rad(mid);

            const double rad2 = M_PI / 2 - rad;

            const double aheight = sin(rad) * a;

            const double bheight = sin(rad2) * b;

            double vol = 0;

            if(aheight >= bheight){

                const double aheight2 = bheight / cos(rad2);

                vol = aheight2 * a * b / 2.0;

            }else{

                const double y = aheight / tan(rad2);

                const double z = aheight / sin(rad2);

                vol = (

                    a * a * z / 2.0 + a * (a * cos(rad) + y) * (bheight - aheight)

                );

            }

            return (vol >= x);

        }, 1e-8

    );

    printf("%.8f\n", ans);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.0117861017425658x):
#include <iostream>

#include <cstdio>

#include <cmath>



using namespace std;

typedef long long ll;

#define REP(i,n) for (ll i = 0; i < (n); ++i)



#define rad_to_deg(rad) (((rad)/2/M_PI)*360)



int main(){

    double a, b, x;

    cin >> a >> b >> x;



    x /= a;



    double ans = 0;

    if(x <= a * b / 2.0){

        const double a2 = 2 * x / b;

        ans = rad_to_deg(M_PI / 2.0 - atan2(a2, b));

    }else{

        const double b2 = 2 * x / a - b;

        ans = rad_to_deg(M_PI / 2.0 - atan2(a, b - b2));

    }

    printf("%.8f\n", ans);

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <cstdio>

#include <cmath>

#include <functional>



using namespace std;

typedef long long ll;

#define REP(i,n) for (ll i = 0; i < (n); ++i)



#define deg_to_rad(deg) (((deg)/360)*2*M_PI)



/*

二部探索で最適値を求める

(lo, hi) の間に最適値があるとする。

最大化のとき lo は必ず ok となる値とする。

最小化のとき hi は必ず ok となる値とする。

*/

double continuous_binary_search(

    double lo,

    double hi,

    function<bool(double)> is_ok,

    bool is_maximize,

    double eps

){

    while(hi - lo > eps){

        const double mid = (hi + lo) / 2.0;

        if(is_maximize){

            if(is_ok(mid)){

                lo = mid;

            }else{

                hi = mid;

            }

        }else{

            if(is_ok(mid)){

                hi = mid;

            }else{

                lo = mid;

            }

        }

    }

    return lo;

}





int main(){

    double a, b, x;

    cin >> a >> b >> x;



    double ans = continuous_binary_search(

        0, 90,

        [&](double mid) -> bool {

            const double rad = deg_to_rad(mid);

            const double rad2 = M_PI / 2 - rad;

            const double aheight = sin(rad) * a;

            const double bheight = sin(rad2) * b;

            double vol = 0;

            if(aheight >= bheight){

                const double aheight2 = bheight / cos(rad2);

                vol = aheight2 * a * b / 2.0;

            }else{

                const double y = aheight / tan(rad2);

                const double z = aheight / sin(rad2);

                vol = (

                    a * a * z / 2.0 + a * (a * cos(rad) + y) * (bheight - aheight)

                );

            }

            return (vol >= x);

        }, true, 1e-8

    );

    printf("%.8f\n", ans);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.0119817347471887x):
#include <iostream>

#include <cstdio>

#include <cmath>



using namespace std;

typedef long long ll;

#define REP(i,n) for (ll i = 0; i < (n); ++i)



#define rad_to_deg(rad) (((rad)/2/M_PI)*360)



int main(){

    double a, b, x;

    cin >> a >> b >> x;



    x /= a;



    double ans = 0;

    if(x <= a * b / 2.0){

        const double a2 = 2 * x / b;

        ans = rad_to_deg(M_PI / 2.0 - atan2(a2, b));

    }else{

        const double b2 = 2 * x / a - b;

        ans = rad_to_deg(M_PI / 2.0 - atan2(a, b - b2));

    }

    printf("%.8f\n", ans);

    return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



#define ll long long

#define X first

#define Y second

#define all(x) x.begin(), x.end()



const int MX = (int)1e5 + 10;

const int mod = (int)1e9 + 7;



int main(){



    cin.tie(0); cout.tie(0);

    ios_base::sync_with_stdio(0);



    double a, b, x;

    cin >> a >> b >> x;



    const double PI = acos(-1);

    double l = 0, r = 90;

    int it = 10000;

    while(it--){

        double md = (l + r) / 2;



        double angle = PI * md / 180.0;

        double ratio = tan(angle);

        double heightRem = a * ratio;



        if(heightRem >= b){

            double angle = 90 - md;

            double ratio = tan(angle * PI / 180.0);

            double org_base = b * ratio;

            double otherArea = 0.5 * org_base * b;

            if(otherArea * a >= x) l = md;

            else r = md;

            continue;

        }



        double areaExtra = 0.5 * a * heightRem;

        double ExtraVol = areaExtra * a;

        double rem = a * a * b - ExtraVol;



        if(rem >= x) l = md;

        else r = md;

    }

    

    cout << fixed << setprecision(6) << (l + r) / 2 << endl;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.78302150726595x):
#include<bits/stdc++.h>



using namespace std;



#define ll long long

#define X first

#define Y second

#define all(x) x.begin(), x.end()



const int MX = (int)1e5 + 10;

const int mod = (int)1e9 + 7;



int main(){



    cin.tie(0); cout.tie(0);

    ios_base::sync_with_stdio(0);



    double a, b, x;

    cin >> a >> b >> x;



    const double PI = acos(-1);

    double l = 0, r = 90;

    int it = 50;

    while(it--){

        double md = (l + r) / 2;



        double angle = PI * md / 180.0;

        double ratio = tan(angle);

        double heightRem = a * ratio;



        if(heightRem >= b){

            double angle = 90 - md;

            double ratio = tan(angle * PI / 180.0);

            double org_base = b * ratio;

            double otherArea = 0.5 * org_base * b;

            if(otherArea * a >= x) l = md;

            else r = md;

            continue;

        }



        double areaExtra = 0.5 * a * heightRem;

        double ExtraVol = areaExtra * a;

        double rem = a * a * b - ExtraVol;



        if(rem >= x) l = md;

        else r = md;

    }

    

    cout << fixed << setprecision(6) << (l + r) / 2 << endl;



    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> l_l;

typedef pair<int, int> i_i;



const long double PI = (acos(-1));

const long double EPS = 0.0000000001;



long double a, b, x;



void input() {

    cin >> a >> b >> x;

}



long double f(long double a, long double b, long double theta) {

    if(theta > PI / 2.0 - EPS) {

        return 0.0;

    }

    long double ret;

    if(a * tan(theta) <= b) {

        ret = a * a * b - a * a * a * tan(theta) / 2.0;

    } else {

        ret = b * b / tan(theta) * a / 2.0;

    }

    return ret;

}



void solve() {

    input();

    long double ok = PI / 2.0;

    long double ng = 0.0;

    for(int _ = 1; _ <= 100000; _++) {

        long double mid = (ok + ng) / 2.0;

        if(f(a, b, mid) < x) ok = mid;

        else ng = mid;

    }

    cout << fixed << setprecision(10) << ok / PI * 180 << endl;

    return;

}



int main() {

    solve();

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 10.896303208346957x):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<ll, ll> l_l;

typedef pair<int, int> i_i;



const long double PI = (acos(-1));

const long double EPS = 0.0000000001;



long double a, b, x;



void input() {

    cin >> a >> b >> x;

}



long double f(long double a, long double b, long double x) {

    long double ans;

    if(a * a * b / 2.0 <= x) {

        ans = atan(2 * (a * a * b - x) / (a * a * a));

    } else {

        ans = PI / 2 - atan(2 * x / (a * b * b));

    }

    return ans;

}



void solve() {

    input();

    cout << fixed << setprecision(10) << f(a, b, x) * 180.0 / PI << endl;

    return;

}



int main() {

    solve();

    return 0;

}
// Slower C++ solution:
//Bokan ga bokka--nn!!

//Daily Lunch Special Tanoshii !!

#include <cstdio>

#include <cstring>

#include <cstdlib>

#include <cmath>

#include <string>

#include <algorithm>

#include <vector>

#include <queue>

#include <stack>

#include <functional>

#include <iostream>

#include <map>

#include <set>

using namespace std;

typedef pair<int,int> P;

typedef pair<int,P> P1;

typedef pair<P,P> P2;

typedef long long ll;

#define pu push

#define pb push_back

#define mp make_pair

#define eps 1e-7

#define INF 2000000000

#define s(x) scanf("%d",&x)

#define rep(i,x) for(int i=0;i<x;i++)

int rui[1005][1005][3]={};

char f[1005][1005];

int n,m,q;

int main()

{

	scanf("%d %d %d",&n,&m,&q);

	for(int i=0;i<n;i++)

	{

		scanf("%s",f[i]);

	}

	for(int i=1;i<=n;i++)

	{

		for(int j=1;j<=m;j++)

		{

			rui[i][j][0]=rui[i-1][j][0]+rui[i][j-1][0]-rui[i-1][j-1][0]+(f[i-1][j-1]=='J');

			rui[i][j][1]=rui[i-1][j][1]+rui[i][j-1][1]-rui[i-1][j-1][1]+(f[i-1][j-1]=='O');

			rui[i][j][2]=rui[i-1][j][2]+rui[i][j-1][2]-rui[i-1][j-1][2]+(f[i-1][j-1]=='I');

			

		}

	}

	for(int aa=0;aa<q;aa++)

	{

		int x,y,z,w;

		scanf("%d %d %d %d",&x,&y,&z,&w);

		int r[3];

		for(int i=0;i<3;i++) r[i]=rui[z][w][i]-rui[z][y-1][i]-rui[x-1][w][i]+rui[x-1][y-1][i];

		printf("%d %d %d\n",r[0],r[1],r[2]);

	}

}

// Faster C++ solution for the same problem (measured speedup: 5.0573395678454505x):
#include <stdio.h>

int n,m,q,a,b,c,d,rui[1005][1005][3],ret[3];char f[1005][1005],e[3]={'J','O','I'};

int main(){

	scanf("%d%d%d",&n,&m,&q);

	for(int i=0;i<n;i++) scanf("%s",&f[i]);

	for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) for(int k=0;k<3;k++)

	rui[i][j][k]=rui[i-1][j][k]+rui[i][j-1][k]-rui[i-1][j-1][k]+(f[i-1][j-1]==e[k]);

	for(int i=0;i<q;i++){

		scanf("%d%d%d%d",&a,&b,&c,&d);

		for(int j=0;j<3;j++) ret[j]=rui[c][d][j]-rui[c][b-1][j]-rui[a-1][d][j]+rui[a-1][b-1][j];

		printf("%d %d %d\n",ret[0],ret[1],ret[2]);

	}

}
// Slower C++ solution:
#include<iostream>

using namespace std;

int H,W,K;

char t[1001][1001];

int J[1001][1001];

int O[1001][1001];

int I[1001][1001];



int main(){

  while(cin>>H>>W>>K){

    for(int i=1;i<=H;i++){

      for(int j=1;j<=W;j++){

	cin>>t[i][j];

	J[i][j]=(t[i][j]=='J'?1:0)+J[i-1][j]+J[i][j-1]-J[i-1][j-1];

	O[i][j]=(t[i][j]=='O'?1:0)+O[i-1][j]+O[i][j-1]-O[i-1][j-1];

	I[i][j]=(t[i][j]=='I'?1:0)+I[i-1][j]+I[i][j-1]-I[i-1][j-1];

      }

    }

    for(int i=0;i<K;i++){

      int ay,ax,by,bx;

      cin>>ay>>ax>>by>>bx;

      cout<<J[by][bx]-J[ay-1][bx]-J[by][ax-1]+J[ay-1][ax-1]<<' ';

      cout<<O[by][bx]-O[ay-1][bx]-O[by][ax-1]+O[ay-1][ax-1]<<' ';

      cout<<I[by][bx]-I[ay-1][bx]-I[by][ax-1]+I[ay-1][ax-1]<<endl;

    }

  }

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.092833384153593x):
#include<cstdio>

using namespace std;

int H,W,K;

char t[1001][1001],ch;

int J[1001][1001];

int O[1001][1001];

int I[1001][1001];

int ay,ax,by,bx;

int main(){

  scanf("%d %d %d",&H,&W,&K);

  scanf("%c",&ch);

  for(int i=1;i<=H;i++){

    for(int j=1;j<=W;j++){

      scanf("%c",&t[i][j]);

      J[i][j]=(t[i][j]=='J'?1:0)+J[i-1][j]+J[i][j-1]-J[i-1][j-1];

      O[i][j]=(t[i][j]=='O'?1:0)+O[i-1][j]+O[i][j-1]-O[i-1][j-1];

      I[i][j]=(t[i][j]=='I'?1:0)+I[i-1][j]+I[i][j-1]-I[i-1][j-1];

    }

    scanf("%c",&ch);

  }

  for(int i=0;i<K;i++){

    scanf("%d %d %d %d",&ay,&ax,&by,&bx);

    printf("%d ",J[by][bx]-J[ay-1][bx]-J[by][ax-1]+J[ay-1][ax-1]);

    printf("%d ",O[by][bx]-O[ay-1][bx]-O[by][ax-1]+O[ay-1][ax-1]);

    printf("%d\n",I[by][bx]-I[ay-1][bx]-I[by][ax-1]+I[ay-1][ax-1]);

  }

  

  return 0;

}
// Slower C++ solution:
#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <assert.h>

#define IOS ios::sync_with_stdio(false)

using namespace std;

#define inf (0x3f3f3f3f)

typedef long long int LL;





#include <iostream>

#include <sstream>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <string>

#include <bitset>

const int maxn = 1e5 + 20;

LL perfixSum[maxn], absSum[maxn];

vector<int>pos;

void cut(LL &val, int pos1, int pos2) {

    if (pos1 > pos2) return;

    val -= absSum[pos2] - absSum[pos1 - 1];

}

void work() {

    int n;

    scanf("%d", &n);

    int val;

    scanf("%d", &val);

    perfixSum[1] = val;

    absSum[1] = val;

    for (int i = 2; i <= n; ++i) {

        int val;

        char op;

        cin >> op;

        scanf("%d", &val);

        if (op == '+') {

            perfixSum[i] = perfixSum[i - 1] + val;

        } else {

            perfixSum[i] = perfixSum[i - 1] - val;

            pos.push_back(i);

        }

        absSum[i] = absSum[i - 1] + val;

    }

    LL ans = perfixSum[n];

    for (int i = 0; i <= (int)pos.size() - 2; ++i) {

        int p1 = pos[i], p2 = pos[i + 1];

        LL tans = absSum[n] - absSum[p2 - 1];

        tans += perfixSum[p1];

        cut(tans, p1 + 1, p2 - 1);

        ans = max(ans, tans);

    }

    cout << ans << endl;

}



int main() {

#ifdef local

    freopen("data.txt", "r", stdin);

//    freopen("data.txt", "w", stdout);

#endif

//    int val;

//    scanf("%d", &val);

//    cout << val << endl;

    work();

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.21797440320255x):
#include<cstdio>

#include<algorithm>

using namespace std;

#define MAXN 100010

#define INF 0x3FFFFFFF

#define LL long long

int a[MAXN],n;

LL sum=0,pre[MAXN],ans=-INF;

bool b[MAXN];

char s[10];

int main()

{

	scanf("%d",&n);

	scanf("%d",&a[1]);

	for(int i=2;i<=n;i++)

	{

		scanf("%s%d",s,&a[i]);

		if(s[0]=='-') b[i]=1;

	}

	for(int i=n;i>0;i--)

		pre[i]=pre[i+1]+a[i];

	int ls=1;

	while(b[ls]==0&&ls<=n)

	{

		sum+=a[ls];

		ls++;

	}

	while(ls<=n)

	{

		int ls1=ls+1;

		LL sum1=0;

		while(ls1<=n&&b[ls1]==0)

		{

			sum1+=a[ls1];

			ls1++;

		}

		if(ls1<=n) ans=max(ans,sum-sum1-a[ls]+pre[ls1]);

		sum-=a[ls],sum+=sum1;

		ls=ls1;

	}

	ans=max(ans,sum);

	printf("%lld\n",ans);

}
// Slower C++ solution:
#include <cstdio>

#include <cstdlib>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <assert.h>

#define IOS ios::sync_with_stdio(false)

using namespace std;

#define inf (0x3f3f3f3f)

typedef long long int LL;





#include <iostream>

#include <sstream>

#include <vector>

#include <set>

#include <map>

#include <queue>

#include <string>

#include <bitset>

const int maxn = 1e5 + 20;

LL perfixSum[maxn], absSum[maxn];

vector<int>pos;

void cut(LL &val, int pos1, int pos2) {

    if (pos1 > pos2) return;

    val -= absSum[pos2] - absSum[pos1 - 1];

}

void work() {

    int n;

    scanf("%d", &n);

    int val;

    scanf("%d", &val);

    perfixSum[1] = val;

    absSum[1] = val;

    for (int i = 2; i <= n; ++i) {

        int val;

        char op;

        cin >> op;

        scanf("%d", &val);

        if (op == '+') {

            perfixSum[i] = perfixSum[i - 1] + val;

        } else {

            perfixSum[i] = perfixSum[i - 1] - val;

            pos.push_back(i);

        }

        absSum[i] = absSum[i - 1] + val;

    }

    LL ans = perfixSum[n];

    for (int i = 0; i <= (int)pos.size() - 2; ++i) {

        int p1 = pos[i], p2 = pos[i + 1];

        LL tans = absSum[n] - absSum[p2 - 1];

        tans += perfixSum[p1];

        cut(tans, p1 + 1, p2 - 1);

        ans = max(ans, tans);

    }

    cout << ans << endl;

}



int main() {

#ifdef local

    freopen("data.txt", "r", stdin);

//    freopen("data.txt", "w", stdout);

#endif

//    int val;

//    scanf("%d", &val);

//    cout << val << endl;

    work();

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.2141934085340935x):
#include <cstdio> 

#include <cstring>

#include <algorithm>

using namespace std;

#define LL long long

int n, num[100005], opt[100005];

LL sum[100005], now[100005], ans;

int main()

{

	char ch[2];

	scanf("%d%d", &n, &num[1]); opt[1] = 1;

	now[1] = sum[1] = num[1];

	for(int i = 2; i <= n; i++)

	{

		scanf("%s%d", ch, &num[i]); opt[i] = (ch[0] == '+') ? 1 : -1;

		now[i] = now[i-1] + opt[i] * num[i];

		sum[i] = sum[i-1] + num[i];

	}

	ans = now[n];

	int last = -1;

	for(int i = 1; i <= n; i++) if(opt[i] == -1)

	{

		if(last != -1)

			ans = max(ans, now[last-1] - (sum[i-1] - sum[last-1]) + (sum[n] - sum[i-1]));

		last = i;

	}

	printf("%lld\n", ans);

}