akhauriyash/Code-Regression huggingface dataset:
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;


int main() {
	int N;
	cin >> N;
	vector<int>data(N);
	for (int i = 0; i < N; i++) {
		cin >> data[i];
	}
	sort(data.begin(), data.end());
	data[N - 1] /= 2;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans += data[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){

  int i,ans=0,x,y;
  char s[1000],t[1000];
  char end[]="END_OF_TEXT";

  //W komoji
  scanf("%s",s);

  for(i = 0; s[i] != '\0'; i++){

    if('A' <= s[i] && s[i] <= 'Z'){
      
      s[i] += 0x20;
      
    }
    
  }
  
  //T check
  while(1){

    scanf("%s",t);

    x=strcmp(end, t);
    
    if(x != 0){
      
      for(i = 0; t[i] != '\0'; i++){
	
	if('A' <= t[i] && t[i] <= 'Z'){
	  
	  t[i] += 0x20;

	}
	
      }

      y=strcmp(s, t);

      if(y == 0) ans++;
      
    } else {

      printf("%d\n",ans);
      
      break;

    }

  }

  return 0;

}

      

Measured memory_bytes: 548
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskAtCoder119 solver = new TaskAtCoder119();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskAtCoder119 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            if (in.next().compareTo("2019/04/30") <= 0)
                out.println("Heisei");
            else
                out.println("TBD");
        }

    }
}



Measured memory_bytes: 22740
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>=r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(a-1)),y(b){}_RX(int a):_RX(up?0:a,up?a:0){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

const int DXS[] = {0, -1, 1, 0};
const int DYS[] = {-1, 0, 0, 1};

int main() {

	const int n = read_item();
	vector<int> ps(n * n);
	for(auto i : range(n * n)) {
		ps[i] = read_item();
		ps[i] = ps[i] - 1;
	}

	vector<vector<int>> dist(n);
	vector<vector<bool>> seat(n);
	for(auto& d : dist) {
		d.resize(n, 0);
	}
	for(auto& s : seat) {
		s.resize(n, true);
	}
	for(auto i : range(n)) {
		for(auto j : range(n)) {
			dist[i][j] = min(min(i, n - 1 - i), min(j, n - 1 - j));
		}
	}

	i64 ans = 0;
	deque<pair<pair<int,int>,int>> q;

	for(auto p_it : range(n * n)) {

		int p = ps[p_it];
		int sx = p / n;
		int sy = p % n;

		ans += dist[sx][sy];
		seat[sx][sy] = false;

		for(auto i : range(4)) {
			int x = sx + DXS[i];
			int y = sy + DYS[i];
			if(x >= 0 && y >= 0 && x < n && y < n) {
				q.push_back({{x, y}, dist[sx][sy]});
			}
		}

		while(!q.empty()) {

			int cx = q.front().first.first;
			int cy = q.front().first.second;
			int nd = q.front().second;
			q.pop_front();

			if(dist[cx][cy] <= nd) {
				continue;
			}
			dist[cx][cy] = nd;

			for(auto i : range(4)) {
				int x = cx + DXS[i];
				int y = cy + DYS[i];
				if(x >= 0 && y >= 0 && x < n && y < n) {
					if(seat[cx][cy]) {
						q.push_back({{x, y}, nd + 1});
					} else {
						q.push_front({{x, y}, nd});
					}
				}
			}
		}
	}

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

	return 0;
}

/* wafdayo~~~ */


Measured memory_bytes: 9824
while True:
    m, f, r = map(int, raw_input().split())
    if m==-1 and f==-1 and r==-1:
        break
    elif m==-1 or f==-1:
        print 'F'
    elif m+f>=80:
        print 'A'
    elif 65<=m+f<80:
        print 'B'
    elif 50<=m+f<65:
        print 'C'
    elif 30<=m+f<50:
        if r>=50:
            print 'C'
        else:
            print 'D'
    elif 0<=m+f<30:
        print 'F'

Measured memory_bytes: 6376
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

// #define fisier 1

using namespace std;

typedef long long ll;


int add(int a, int b)
{
    int x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand_seed()
{
    long long a = rng();
    return a;
}

int n, v[200002];
int main()
{

    #ifdef fisier
        ifstream f("input.in");
        ofstream g("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n;
    for(int i = 1; i <= n; ++i)
        cin >> v[i];
    sort(v + 1, v + n + 1);
    int st = 1;
    int dr = n-1;
    int ans = 1;
    while(st <= dr)
    {
        int mid = (st + dr) / 2;
        if(v[mid] <= v[n] / 2)
            ans = mid, st = mid + 1;
        else
            dr = mid - 1;
    }
    if(ans == n-1)
    {
        cout << v[n] << " " << v[n-1] << '\n';
        return 0;
    }
    int pa = v[ans];
    int pb = v[ans+1];
    int midpoint = v[n] / 2;
    cout << v[n] << " ";
    if(v[n] % 2 == 1)
    {
        if(min(abs(midpoint + 1 - pa), abs(midpoint - pa)) < min(abs(midpoint + 1 - pb), abs(midpoint - pb)))
            cout << pa << " ";
        else
            cout << pb << " ";
    }
    else
    {
        if(abs(midpoint - pa) < abs(midpoint - pb))
            cout << pa << " ";
        else
            cout << pb << " ";
    }
    return 0;
}


Measured memory_bytes: 640
input = gets.chomp.split
w = input[0].to_i
h = input[1].to_i
x = input[2].to_i
y = input[3].to_i

square = w * h / 2.0
multiple = 0
if w / 2.0 == x && h / 2.0 == y
    multiple = 1
end

puts square.to_s + " " + multiple.to_s

Measured memory_bytes: 1788
//#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 1e6 + 5;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);
const ll hax = 1e6 + 7;

int n, k;
int vis[15], dig[15], res[15];

void solve()
{
	int i, j;
	sa(n), sa(k);

	repp(i, 1, k)
	{
		int x;
		sa(x);
		vis[x] = 1;
	}
	int cnt = 0;
	while (n)
	{
		++cnt;
		dig[cnt] = n % 10;
		n /= 10;
	}
	vector<int>num;
	repp(i, 0, 9)
	{
		if (!vis[i])
			num.push_back(i);
	}
	vector<int>re;
	for (i = cnt; i >=1 ;i--)
	{
		int f = 0;
		for (j = dig[i]; j <= 9; j++)
		{
			if (!vis[j])
			{
				if (j != dig[i])
				{
					printf("%d", j);
					for (int h = i - 1; h >= 1; h--)
					{
						printf("%d", num[0]);
					}
					return;
				}
				else
				{
					f = 1;
					re.push_back(j);
					break;
				}
			}
		}
		if (f == 0)
		{
			break;
		}
	}
	if (re.size() == cnt)
	{
		rep(i, 0, re.size())
		{
			printf("%d", re[i]);
		}
	}
	else
	{
		int wc = num[0] == 0 ? num[1] : num[0];
		printf("%d", wc);
		for (i = cnt; i >= 1; i--)
		{
			printf("%d", num[0]);
		}
	}
}

int main()
{
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

ll dp[110][4][4][4][4];
// A0 C1 G2 T3
int main() {
  int N; cin >> N;
  dp[0][0][0][3][0] = 1;
  rep(i, 0, N) rep(j, 0, 4) rep(k, 0, 4) rep(l, 0, 4) rep(m, 0, 4) {
    if(m < 2) {
      rep(d, 0, 4){
        dp[i + 1][k][l][d][m + 1] += dp[i][j][k][l][m];
        dp[i + 1][k][l][d][m + 1] %= mod;
      }
    }
    else {
      if(k == 0 && l == 2) { // AG〇
        rep(d, 0, 4){
          if(d == 1) continue;
          dp[i + 1][k][l][d][m] += dp[i][j][k][l][m];
          dp[i + 1][k][l][d][m + 1] %= mod;
        }
      }
      else if(j == 0 && l == 2) { // A〇GC
        rep(d, 0, 4){
          if(d == 1) continue;
          dp[i + 1][k][l][d][m] += dp[i][j][k][l][m];
          dp[i + 1][k][l][d][m + 1] %= mod;
        }
      }
      else if(j == 0 && k == 2) { // AG〇C
        rep(d, 0, 4){
          if(d == 1) continue;
          dp[i + 1][k][l][d][m] += dp[i][j][k][l][m];
          dp[i + 1][k][l][d][m + 1] %= mod;
        }
      }
      else if(k == 2 && l == 0) { // GAC
        rep(d, 0, 4){
          if(d == 1) continue;
          dp[i + 1][k][l][d][m] += dp[i][j][k][l][m];
          dp[i + 1][k][l][d][m + 1] %= mod;
        }
      }
      else if(k == 0 && l == 1) { // ACG
        rep(d, 0, 4){
          if(d == 2) continue;
          dp[i + 1][k][l][d][m] += dp[i][j][k][l][m];
          dp[i + 1][k][l][d][m + 1] %= mod;
        }
      }
      else {
        rep(d, 0, 4){
          dp[i + 1][k][l][d][m] += dp[i][j][k][l][m];
          dp[i + 1][k][l][d][m + 1] %= mod;
        }
      }
    }
  }
  ll ans = 0;
  rep(j, 0, 4) rep(k, 0, 4) rep(l, 0, 4) rep(m, 0, 4) {
    ans += dp[N][j][k][l][m];
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin>>a;
  stack<char>s;
  int b=a.size();
    for(int i=0;i<b;i++)
    {
   if(a.at(i)=='S') s.push(a.at(i));
    else  if(a.at(i)=='T' && s.size()==0) s.push(a.at(i));
      else if(a.at(i)=='T' && s.top()=='T') s.push(a.at(i));
      else s.pop();
  
      }

  cout<<s.size();}

Measured memory_bytes: 644
s = input()
K = int(input())

substringset = set()

top5 = sorted(list(set(list(s))))[0:5]

for i in range(0, len(s)):
    c = s[i:i+1]
    if not c in top5:
        continue

    for end in range(i + 1,  i + 6):
        substringset.add(s[i:end])

ret = sorted(list(substringset))[K-1]
print(ret)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int a[201],b[201];
const int MAX_N=201;
int m;
vector<int> g[MAX_N];
int match[MAX_N];
int used[MAX_N];
void add_edge(int src,int dst){
    g[src].pb(dst);
    g[dst].pb(src);
}
bool dfs(int v){
    used[v]=true;
    rep(i,g[v].size()){
        int u=g[v][i],w=match[u];
        if(w<0||!used[w]&&dfs(w)){
            match[v]=u;
            match[u]=v;
            return true;
        }
    }
    return false;
}

int bipartite_matching(){
    int res=0;
    memset(match,-1,sizeof(match));
    rep(i,m){
        if(match[i]<0){
            memset(used,0,sizeof(used));
            if(dfs(i)) ++res;
        }
    }
    return res;
}
int main(){
    int n;
    cin>>n;
    rep(i,n) cin>>a[i]>>b[i];
    rep(i,n) cin>>a[i+n]>>b[i+n];
    m=n*2;
    rep(i,n)FOR(j,n,2*n){
        if(a[i]<a[j]&&b[i]<b[j])add_edge(i,j);
    }
    cout<<bipartite_matching()<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>

#include <string>
#include <algorithm>

using namespace std;

int main()
{
  int n;
  cin >>  n;
  
  int x = 1;
  while (1) {
	if (n == x) {
	  break;
	}
	else if (n < x) {
	  x /= 2;
	  break ;
	}
	x *= 2;
  }
  cout << x << endl;
  
  return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
typedef long long ll;

int main()
{
    int n,m;
    cin>>n>>m;
    int mini = 1000000;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        if(mini>x) mini=x;
        m-=x;
    }
    int cnt=0;
    cnt=n;
    if(m>=mini)
    {
        while(m>=mini)
        {
            m-=mini;
            cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <algorithm>
#include <map>

#define rep(i, N) for(int (i) = 0; (i) < (N); (i) ++)
typedef long long ll;

using namespace std;

int main(){
    int N;
    cin >> N;
    map<int, int> m;
    rep(i, N){
        int a;
        int cnt;
        cin >> a;
        cnt = m.find(a) != m.end() ? m[a] : 0;
        m[a] = cnt + 1;
    }
    ll ans = 0;
    for(auto i = m.begin(); i != m.end(); i ++){
        int tmp =  - i -> first + i -> second;
        ans += tmp < 0 ? i -> second : tmp;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n, W;
    cin >> n >> W;
    vector<ll> v(n), w(n);
    for(int i = 0; i < n; i++) cin >> w[i] >> v[i];
    ll dp[W+1];
    fill(dp, dp+W+1, 0);
    for(int i = 0; i < n; i++) for(int j = W; j >= 0; j--) {
        if(j >= w[i]) dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
    }
    cout << dp[W] << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>

int main(void){
    int N, i, aa = 0, b, answer = 0;
    long int K;
    scanf("%d %ld", &N, &K);
    int A[N], check[N], jyun[N], recheck[N];
    for(i = 0; i < N; i++){
        scanf("%d", &A[i]);
        check[i] = 0;
        jyun[i] = 0;
        recheck[i] = 0;
    }
    //ループの開始地点を探す
    b = 1;
    int c = 0, start = 0;
    while(aa == 0){
        b -= 1;
        if(check[b] > 0){
            aa += 1;
            start = b + 1;
            jyun[c] += b + 1;
            break;
        }
        else {
        jyun[c] += b + 1;
        c += 1;
        check[b] += 1;
        b = A[b];
        }
        }
    int roop = 0, yobun; long int x;
    //Kがループの開始地点より前か後かを評価する
    if(K <= c){
        answer = jyun[K];
    }
    //
    else{
        int next = start;
        aa = 0;
        while(aa == 0){
            next -= 1;
            if(recheck[next] > 0){
                aa += 1;
                break;
            }
            roop += 1;
            recheck[next] += 1;
            next = A[next];
        }
        yobun = c - roop;
        K -= yobun;
        K = K % roop;
        x = K + yobun;
        answer = jyun[x];
    }
    printf("%d\n", answer);
    return 0;

}

Measured memory_bytes: 4852
#include <iostream>
#include<vector>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
#include<algorithm>
using namespace std;
typedef  long long ll ;
const ll inf = 1e9+7;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int a[100005];
    for(int i=0;i<=n;i++)a[i]=inf;
    a[0]=0;
    for(int i=1;i<=n;i++){
        for(int p=1;p<=i;p*=6){
            a[i]=min(a[i],a[i-p]+1);
        }
        for(int p=1;p<=i;p*=9){
            a[i]=min(a[i],a[i-p]+1);
        }
    }
    cout<<a[n]<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int a,b,c;
  string s = "";
 cin >> a >> b;
  vector<string> ve(a);
  for(int i = 0;i < a;i++){
    cin >> ve[i];
  }
  sort(ve.begin(),ve.end());
  for(int i = 0;i < a;i++){
    s += ve[i];
  }
  cout << s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 1; i <= n; i++)
#define rep(i, n) for (ll i = 0; i < n; i++)
#define ll long long
using namespace std;

int main()
{
    
    long double A,B,H,M;
    long double PI = M_PI;
    long double ans = 0;
    cin >> A >> B >> H >> M;
    long double a,b,c;
    a = fmodf((60.0f*H + M) * 6.0f , 360.0f);
    b = fmodf((60.0f*H + M) * 0.5f , 360.0f);
    c = min(abs(b - a),abs(360.0f - b + a));
    ans = sqrt(A*A+B*B-2.0f*A*B*cos(PI * c / 180.0f));
    cout << fixed << setprecision(15) << ans << endl;
    
}


Measured memory_bytes: 4132
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#define INF_LL 1e18
#define INF 1e9

#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()

using namespace std;

using ll = long long;
using PII = pair<int, int>;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

	int find(int x){
		if(par[x] == x){
			return x;
		}else{
			return par[x] = find(par[x]);
		}
	}

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(rank[x] < rank[y]){
			par[x] = y;
		}else{
			par[y] = x;
			if(rank[x] == rank[y]) rank[x]++;
		}
	}

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

int main(void){
	string s;
	cin >> s;
	REP(i, s.size()-1){
		if(s[i] == s[i+1]){
			cout << i+1 << " " << i+2 << endl;
			return 0;
		}
	}
	REP(i, s.size()-2){
		if(s[i] == s[i+2]){
			cout << i+1 << " " << i+3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
	return 0;
}


Measured memory_bytes: 512
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [10**9+7] * n
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,n):
	for j in range(k):
		j += 1
		dp[i] = min(dp[i],dp[i-j]+abs(h[i] - h[i-j]))
print (dp[n-1])

Measured memory_bytes: 52448
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <string>
#include <set>
typedef long long LL;
using namespace std;
typedef pair<int, int> Pii;
typedef pair<LL, LL> PLL;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, d[105];
	set<int> myset;
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> d[i];
		myset.insert(d[i]);
	}
	cout << myset.size() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

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

int main() {
  int created = 0;
  int N, have; cin >> N >> have;
  vector<int> mvec;
  REP(i, N) {
    int j; cin >> j;
    mvec.push_back(j);
  }
  sort(mvec.begin(), mvec.end());
  have -= accumulate(mvec.begin(), mvec.end(), 0);
  created += mvec.size();
  for(int m : mvec) {
    int count = have / m;
    created += count;
    have -= count * m;
  }
  cout << created;
  return 0;
}


Measured memory_bytes: 888
$n = gets.to_i
INF = 10000000
$d = Array.new($n){ Array.new }
$n.times do
  l = gets.split.map(&:to_i)
  (1..l[1]).each do |i|
    $d[l[0]] << l[2*i,2]
  end
end

def dijkstra(x)
  cost = Array.new($n, INF)
  cost[x] = 0
  visited = Array.new($n, false)

  while visited.include?(false)
    m = INF

    # visited???????????????????????????????????????m???
    $n.times do |i|
      if !visited[i] && m > cost[i] then
        m = cost[i]
      end
    end

    # INF???????????£????????????
    break if m == INF

    # ???????????§????????????????¨????
    # ????????????m????????£??????visited??¨???????¢????
    $n.times do |j|
      if m == cost[j]
        visited[j] = true
        $d[j].each do |r|
          u, w = r
          cost[u] = [cost[u], cost[j] + w].min
        end
      end
    end
  end
  cost
end

result = dijkstra(0)
result.each_index{ |i| puts "#{i} #{result[i]}" }

Measured memory_bytes: 56972
/*
        ####   ####
     ###    ###    ###
   ###    Bravery    ###
  ###  Determination  ###
   ##  Perseverance   ##
    ##   Integrity   ##
     ##  Patience   ##
      ## Kindness  ##
        ##Justice##
         ##     ##
           ## ##
             #
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
typedef long long ll;
using namespace std;
int n,a[200005];
ll stp[200005],k;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for (int i=1;i<=n;i++){
		cin>>a[i];
		stp[i]=-1;
	}
	int pos=1;
	while (k){
		stp[pos]=k;
		k--;
		int np=a[pos];
		if (stp[np]!=-1){
			k%=(ll)(stp[np]-stp[pos]+1);
			pos=np;
			break;
		}
		pos=np;
	}
	while (k){
		k--;
		pos=a[pos];
	}
	cout<<pos;
	return 0;
}

Measured memory_bytes: 5968
#include <iostream>
using namespace std;

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; }

const long long INF = 1LL << 60;

int main() {
    int n;
    long long h[100100];
    long long dp[100100];

    cin >> n;

    for (int i = 0; i < 100100; i++) dp[i] = INF;

    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        chmin(dp[i], dp[i - 1] + 1);

        for (int j = 6; i - j >= 0; j *= 6) {
            chmin(dp[i], dp[i - j] + 1);
        }

        for (int j = 9; i - j >= 0; j *= 9) {
            chmin(dp[i], dp[i - j] + 1);
        }
        
    }

    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn = 3e5 + 10;

char s[maxn];
int pre[maxn], suf[maxn];

int main()
{
	int n;
	scanf("%d", &n);
	scanf("%s", s + 1);
	for (int i = 2; i <= n; ++ i)
		pre[i] = pre[i - 1] + (s[i - 1] == 'W');
	for (int i = n - 1; i; -- i)
		suf[i] = suf[i + 1] + (s[i + 1] == 'E');
	int ans = n;
	for (int i = 1; i <= n; ++ i)
		ans = min(ans, pre[i] + suf[i]);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 2816
#include <cmath>
#include <iostream>
using namespace std;
int main(){
   int a,b,c;
   cin >> a >> b;
   if (b < 10) c = 10*a+b;
   else if(b < 100) c = 100*a+b;
   else c = 1000*a+b;
   int n=sqrt(c);
   if (c == n*n){
      cout << "Yes" << endl;
   }
   else
      cout << "No" << endl;
   return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = readInt >>= print . ( * 180 ) . subtract 2

Measured memory_bytes: 508
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] names = new int[5];

        for (int i = 0; i < n; i++)
        {
            string name = sc.Next();
            if (name.StartsWith("M"))
            {
                names[0]++;
            }
            if (name.StartsWith("A"))
            {
                names[1]++;
            }
            if (name.StartsWith("R"))
            {
                names[2]++;
            }
            if (name.StartsWith("C"))
            {
                names[3]++;
            }
            if (name.StartsWith("H"))
            {
                names[4]++;
            }
        }

        long answer = 0;

        for (int i = 0; i < Math.Pow(2, 5); i++)
        {
            int count = 0;
            for (int j = 0; j < 5; j++)
            {
                if ((1 & (i >> j)) == 1)
                {
                    count++;
                }
            }
            if (count != 3)
            {
                continue;
            }

            long tmpAnswer = 1;
            for (int j = 0; j < 5; j++)
            {
                if ((1 & (i >> j)) == 1)
                {
                    tmpAnswer *= names[j];
                }
            }
            answer += tmpAnswer;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 15452
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()

int le[101010];
int ri[101010];

int main() {
  int N,Q;
  cin >> N >> Q;
  string s;
  cin >> s;
  for(int i = 0;i < N;i++) {
    le[i + 1] += le[i];
    ri[i + 1] += ri[i];
    if(s[i] == 'A' && s[i + 1] == 'C') {
      le[i + 1] += 1;
      ri[i + 2] += 1;
    }
  }
  vector<int> ans;
  for(int ii = 0;ii < Q;ii++) {
    int l,r;
    cin >> l >> r;
    ans.push_back(ri[r] - le[l - 1]);
  }
  for(auto x : ans) {
    cout << x << endl;
  }
}


Measured memory_bytes: 2296
#include <cmath>
#include <cstdint>
#include <iostream>
 
using namespace std;
 
int32_t main() {
  uint64_t N, M;
  cin >> N >> M;
 
  cout << (1900 * M + 100 * (N - M)) * pow(2, M) << endl;
 
  return 0;
}

Measured memory_bytes: 384
N,Q = map(int, input().split())
S = input()
C = [tuple(map(str, input().split())) for _ in range(Q)]
C = C[::-1]

left = -1
right = N

for (t,d) in C:
  if ('L' == d):
    if (S[left+1] == t):
      left += 1
      if (N-1 <= left):
        print(0)
        exit()
    if (right < N):
      if (S[right] == t):
        right += 1
        if (N < right):
          right = N
  else:
    if (S[right-1] == t):
      right -= 1
      if (right <= 0):
        print(0)
        exit()
    if (-1 < left):
      if (S[left] == t):
        left -= 1
        if (left < -1):
          left = -1

print(right - left - 1)


Measured memory_bytes: 19376
#include <iostream>
#include <vector>
#include <stack>
#include <algorithm>
using namespace std;

int main() {
    int N, Q; cin >> N >> Q;
    vector<vector<int>> tree(N);
    vector<bool> visited(N, false);
    int a, b;
    for (int i = 0; i < N-1; i++) {
        cin >> a >> b;
        tree[a-1].push_back(b-1);
        tree[b-1].push_back(a-1);
    }
    vector<int> flow(N, 0);
    int p, x;
    for (int i = 0; i < Q; i++) {
        cin >> p >> x;
        flow[p-1] += x;
    }
    stack<int> visit_nodes;
    visit_nodes.push(0);
    int i_cur;
    while (!visit_nodes.empty()) {
        i_cur = visit_nodes.top();
        visit_nodes.pop();
        visited[i_cur] = true;
        for (const auto& child : tree[i_cur]) {
            if (!visited[child]) {
                flow[child] += flow[i_cur];
                visit_nodes.push(child);
            }
        }
    }
    for (const auto& f : flow) {
        cout << f << ' ';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 15604
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[(int)(M)];
        int a = 0;
        for(int i = 0 ; i < M ; i++){
                A[i] = sc.nextInt();
                a = a + A[i];
        }
        if(a > N){
            System.out.print(-1);
        }else{
            int b = N - a;
            System.out.print(b);
        }
     }
}

Measured memory_bytes: 38036
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

if A < B:
    A2 = A + T*V
    B2 = B + T*W

    if A2 >= B2:
        print("YES")
    else:
        print("NO")
else:
    A2 = A - T*V
    B2 = B - T*W

    if A2 <= B2:
        print("YES")
    else:
        print("NO")

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;

bitset<1001001001> is_prime(0);
vector<int> prime_numbers;
void sieve_of_eratosthenes(int n=1e6) {
  for (int i = 2; i < n + 1; i++) {is_prime.set(i);}
  for (int i = 2; i < (int)sqrt(n) + 1; i++) {
    if (is_prime[i]) for (int j = i * 2; j < n + 1; j += i) is_prime.reset(j);
  }
  for (int i = 2; i < n + 1; i++) if (is_prime[i]) prime_numbers.push_back(i);
}

unordered_map<int, int> prime_factorize(int n) {
  unordered_map<int, int> res;
  int border = int(sqrt(n));
  for (int &p : prime_numbers) {
    if (p > border) break;
    if (n % p == 0) {
      res[p] = 1; n /= p;
      while (n % p == 0) {res[p]++; n /= p;}
    }
    if (n == 1) return res;
  }
  res[n] = 1; return res;
}

unordered_map<int, int> prime_factorize_factorial(int n) {
  unordered_map<int, int> res;
  for (int i = 2; i < n + 1; i++) {
    for (auto &pc : prime_factorize(i)) {
      if (res.find(pc.first) == res.end()) res[pc.first] = pc.second;
      else res[pc.first] += pc.second;
    }
  }
  return res;
}

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

  int x; cin >> x;
  int i = lower_bound(prime_numbers.begin(), prime_numbers.end(), x) - prime_numbers.begin();
  cout << prime_numbers[i] << '\n';
  return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    
    string s;
    string s1 = "", s2 = "";
    cin >> s;
    for(int i = 0; i < (s.length() - 1) / 2; i++){
    	s1 += s[i];
    }
    for(int i = ((s.length() + 3) / 2) - 1; i < s.length(); i++){
    	s2 += s[i];
    }
    //cout << s1 << " " << s2 << "\n";
    if(s1 == s2){
    	cout << "Yes";
    }
    else{
    	cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

		public static void main(String[] args){
			
			Scanner sc = new Scanner(System.in);
			// 文字列の入力
			String str = sc.next();
			String[] strArray = str.split("");

			int end2 = strArray.length -2;
			if(strArray[0].equals("A")){
			}else{
			    System.out.println("WA");
	    	    return;
			}

			int check = 0;
			for (int i = 2; i <= end2; i++) {
				if(strArray[i].equals("C")){
				    check = i;
				}
			}
			if(check  == 0){
				System.out.println("WA");
    	    	return;
			}
			for (int i = 1; i < strArray.length; i++) {
				if((i != 0)&&(i != check)){
					String temp = strArray[i].toString().toLowerCase();
					if(strArray[i].equals(temp)){
					}else{
						System.out.println("WA");
		    	    	return;
					}
				}
			}
		    System.out.println("AC");
    	    return;
			

		}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    string str = "";
    while(n){
        --n;
        str += (char)('a' + (n % 26));
        n /= 26;
    }
    reverse(str.begin(), str.end());
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 3588
S = gets.chomp.chars.reverse
MOD = 2019

ans = Array.new(MOD, 0)
ans[0] = 1
pow, wk = [1, 0]
S.each{|s|
  wk = (wk + s.to_i * pow) % MOD
  ans[wk] += 1
  pow = (pow * 10) % MOD
}

puts ans.inject(0){|r, a| r + (a*(a-1)/2)}


Measured memory_bytes: 26388
#include <bits/stdc++.h>
#include <type_traits>
using namespace std;

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  ll x; std::cin >> x;
  ll cur = 100, ans = 0;
  while (cur < x) {
    cur += cur * 0.01;
    ans++;
  }
  std::cout << ans << "\n";
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  string t;
  cin >> s;
  cin >> t;
 
  for(int i=0;i<s.size();i++){
    
    if(s[i] != t[i]){
      cout << "No" << endl;
      return 0;
    }
    
  }
  
  cout << "Yes" << endl;
  
}


Measured memory_bytes: 3624
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    ll sum=0;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum+=a[i];
    }
    sort(a.begin(),a.end());
    if(n%2){
        if(sum%2==0){
            cout << "Second" << endl;
        }else{
            cout << "First" << endl;
        }
    }else{
        if(a[0]%2==1){
            cout << "First" << endl;
        }else{

            if(sum%2==1){
                cout << "First" << endl;
            }else{
                cout << "Second" << endl;
            }
        }
    }
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?


Measured memory_bytes: 4332
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a[i];
	ll ans = 0;
	ll sum = a[0];
	if(sum <= 0){
		ans += -a[0] + 1;
		sum = 1;
	}
	repn(i, 1, n){
		if(i & 1){
			if(a[i] < 0){
				sum += a[i];
				if(sum >= 0) ans += sum + 1, sum = -1;
			}
			else{
				ans += sum + a[i] + 1;
				sum = -1;
			}
		}
		else{
			if(a[i] >= 0){
				sum += a[i];
				if(sum <= 0) ans += -sum + 1, sum = 1;
			}
			else{
				ans += -sum + -a[i] + 1;
				sum = 1;
			}
		}
	}
	ll ans1 = 0;
	ll sum1 = a[0];
	if(sum1 >= 0){
		ans1 += a[0] + 1;
		sum1 = -1;
	}
	repn(i, 1, n){
		if(i % 2 == 0){
			if(a[i] < 0){
				sum1 += a[i];
				if(sum1 >= 0) ans1 += sum1 + 1, sum1 = -1;
			}
			else{
				ans1 += sum1 + a[i] + 1;
				sum1 = -1;
			}
		}
		else{
			if(a[i] >= 0){
				sum1 += a[i];
				if(sum1 <= 0) ans1 += -sum1 + 1, sum1 = 1;
			}
			else{
				ans1 += -sum1 + -a[i] + 1;
				sum1 = 1;
			}
		}
	}
	cout << min(ans1, ans) << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<stack>
#include<fstream>
#include<map>
#include<bitset>
#include<unordered_map>
#include<cstring>
#include<cctype>
using namespace std;
#define  ll long long
#define  ull unsigned long long
#define  ul unsigned long
#define all(v) v.begin(),v.end()
#define sz(n) (int)n.size()
#define pb(s) push_back(s);
#define format(n) fixed<<setprecision(n)
#define finl "\n"
#define Mohammed_Atef_Hassan fast();
#define md 1000000007
#define INF LLONG_MAX
#define PI acos(-1)
#define clr(dp,n) memset(dp,n,sizeof dp)
#define ex(n) return cout<<n<<finl,0;
int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };
int dy[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
ll fix_mod(ll x, ll y)
{
	return (y + x % y) % y;
}
void fast() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);

#ifdef ONLINE_JUDGE
	//freopen("crosses.in", "r", stdin);

	//freopen("crosses.out", "w", stdout);
#endif
#ifndef ONLINE_JUDGE
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#endif
}
vector<vector<int>>edg;
ll mem[(int)1e5 + 10][4];
ll solve(int u, int c,int p)
{
	ll& ret = mem[u][c];
	if (~ret)return ret;
	ret = 1;
	if (c == 1)
	{
		for (auto v : edg[u])
		{
			if (v == p)continue;
			ret *= (solve(v, 1, u) + solve(v, 2, u))%md;
			ret %= md;
		}
	}
	else
	{
		for (auto v : edg[u])
		{
			if (v == p)continue;
			ret *= solve(v, 1, u);
			ret %= md;
		}
	}
	return ret;
}
int main()
{
	Mohammed_Atef_Hassan
		clr(mem, -1);
		int n;
	cin >> n;
	edg = vector<vector<int>>(n + 1);
	for (int i = 1; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		edg[x].push_back(y);
		edg[y].push_back(x);
	}
	cout << (solve(1, 1,-1)+solve(1,2,-1))%md;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {

ll a,b,c,d;
  ci(a>>b>>c>>d);
  ll e=lcm(c,d);
  co(b-a+1-b/c+(a-1)/c-b/d+(a-1)/d+b/e-(a-1)/e)
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = IR(3)
    a -= b
    print(a % c)
    return

#B
def B():
    a, b, c, x, ans = II(), II(), II(), II(), 0
    for i in range(a + 1):
        for j in range(b + 1):
            for k in range(c + 1):
                if i * 500 + j * 100 + k * 50 == x:
                    ans += 1
    print(ans)
    return

#C
def C():
    n = II()
    a = LI()
    dp = [[0] * (n + 1) for i in range(2)]
    for i in range(1, n + 1):
        dp[0][i] += dp[0][i - 1] + a[i - 1]
    a = LI()
    for i in range(1, n + 1):
        dp[1][i] = max(dp[0][i], dp[1][i - 1]) + a[i - 1]
    print(dp[1][-1])
    
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()


Measured memory_bytes: 40432
#include <stdio.h>
#include <cstdio>
#include <vector>
#include <iostream>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
	int n;
	cin >> n;
	vector<int> x(n);
	vector<int> y(n);
	REP(i, n){
		cin >> x[i];
		y[i] = x[i];
	}
	VSORT(y);
	REP(i, n){
		if (x[i] <= y[y.size()/2 - 1]) cout << y[y.size()/2] << "\n";
		else{
			cout << y[y.size()/2 - 1] << "\n";
		}
	}

}


Measured memory_bytes: 3712