akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int n, x, a[105];

int main(){
	scanf("%d %d", &n, &x);
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	sort(a + 1, a + n + 1);
	int ans = 0;
	for(int i = 1; i < n; i++){
		if(x >= a[i]){
			x -= a[i];
			ans++;
		}
	}
	if(x == a[n]){
		ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(long long int i = 0; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
const int N = 1000000;

int main(){
    int n,k,x,y; cin >> n >> k >> x >> y;
    int sum = 0;
    for (int i = 1; i <= n; ++i) {
        if(i <= k)sum += x;
        else sum += y;
    }
    print(sum);
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a[5];
    int ans=0;
    
    for(int i=0;i<5;i++){
        cin>>a[i];
    }
    
    if(a[0]<0){
        a[0]=-1*a[0];
        ans+=a[0]*a[2];
        ans+=a[3];
        ans+=a[1]*a[4];
    }
    
    else{
        ans+=(a[1]-a[0])*a[4];
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 3080
n,a,b = map(int,input().split())
inf = 10**9 +7
ans = pow(2,n,inf)-1
def conbi(n,k):
  if n-k < k:
    k = n-k
  x = 1
  y = 1
  for i in range(k):
    x *= n-i
    x = x%inf
    y *= i+1
    y = y%inf
  ans = x* pow(y,inf-2,inf)%inf
  return ans
ans  -= conbi(n,a) + conbi(n,b)
ans = ans%inf
print(ans)  

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

int n, m, t1, t2;
bool v[200005][2];
int main()
{
	int i;
	scanf ("%d %d", &n, &m);
	while (m--) {
		scanf ("%d %d", &t1, &t2);
		if (t2 == n) v[t1][1] = 1;
		if (t1 == 1) v[t2][0] = 1;
	}
	for (i = 2; i< n; i++) {
		if (v[i][0] && v[i][1]) {
			cout << "POSSIBLE";
			return 0;
		}
	}
	cout << "IMPOSSIBLE";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
    string S;
    cin >> S;
    bool canstep = true;
    for (int i = 0; i < S.size(); i++) {
        if (i % 2 == 0) {
            if (S[i] == 'L') canstep = false;
        }

        else {
            if (S[i] == 'R') canstep = false;
        }
    }

    if (canstep) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	static Scanner sc;
	static boolean ISCHK[][];
	static int num,STATE[][];
	public static void main(String[]args){
		sc=new Scanner(System.in);
		ISCHK=new boolean[14][14];
		STATE=new int[14][14];
		String tmpstr=new String("");
		while(sc.hasNext()){
			num=0;
			for(int i=0;i<14;i++){
				if(i>0 && i<13){tmpstr=sc.next();}
				for(int j=0;j<14;j++){
					if(i>0 && i<13){
						if(j==0||j==13){
							STATE[i][j]=0;
							ISCHK[i][j]=true;
						}else if(j<13){
							ISCHK[i][j]=false;
							STATE[i][j]=Integer.parseInt(tmpstr.substring(j-1,j));
						}
					}else{
							STATE[i][j]=0;
							ISCHK[i][j]=true;
					}
				}
			}
			for(int i=1;i<13;i++){
				for(int j=1;j<13;j++){
					if(ISCHK[i][j]==false){
						if(STATE[i][j]==0){
							ISCHK[i][j]=true;
						}else{
							ISCHK[i][j]=true;
							num++;
							srch(i,j);
						}
					}
				}
			}
			System.out.println(num);
		}
	}
	static void srch(int nowX,int nowY){
		if(ISCHK[nowX-1][nowY]==false && STATE[nowX-1][nowY]==1){
			ISCHK[nowX-1][nowY]=true;
			srch(nowX-1,nowY);
		}
		if(ISCHK[nowX][nowY-1]==false && STATE[nowX][nowY-1]==1){
			ISCHK[nowX][nowY-1]=true;
			srch(nowX,nowY-1);
		}
		if(ISCHK[nowX+1][nowY]==false && STATE[nowX+1][nowY]==1){
			ISCHK[nowX+1][nowY]=true;
			srch(nowX+1,nowY);
		}
		if(ISCHK[nowX][nowY+1]==false && STATE[nowX][nowY+1]==1){
			ISCHK[nowX][nowY+1]=true;
			srch(nowX,nowY+1);
		}
	}
}

Measured memory_bytes: 17196
#include <bits/stdc++.h>

using namespace std;

#define vit vector<int>::iterator
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fr first
#define sc second
#define skip continue
#define PI 3.14159265

typedef unsigned long long ull;
typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ll MAXN = 3e5 + 3;

void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

bool cmp(const string& a, const string& b) {
    return (a + b) < (b + a);
}

void solve(){
    int k, s;
    cin >> k >> s;
    ll ans = 0;
    for(int i = 0; i <= k; i++){
        for(int j = 0; j <= k; j++){
            int sum = i + j;
            int z = s - sum;
            if(z >= 0 && z <= k)
                ans++;
        }
    }
    cout << ans;
}


int main(){
    //freopen("slalom.in","r",stdin);
    //freopen("slalom.out","w",stdout);
    //faster();
    int n = 1;
    //cin >> n;
    while(n--){
        solve();
        cout << endl;
    }
    //fclose(stdout);
}


Measured memory_bytes: 3644
require 'pp'

n, a, b = gets.chomp!.split.map(&:to_i)
min, max = [a, b].minmax
if (b - a) % 2 == 0
    puts (b - a) / 2
else
    x, y = [min - 1, n - max].minmax
    
    puts (x + 1) + (b - a - 1) / 2
end





Measured memory_bytes: 2172
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;
 
 
 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
 
  	int k = sc.nextInt();
		int x = sc.nextInt();
		
		for(int i = x - k + 1; i <= x + k - 1; i++){
			System.out.println(i);
		}
 
 
  }
 
 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;
 
      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }
 
      public char nextChar() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        char ret;
        do{
          ret = (char)c;
          c = next();
        }while(!isSpaceChar(c));
        return ret;
      }
 
      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
#define MAXN 200100
ll OFF;

ll L[MAXN];
ll R[MAXN];
ll sum_left[MAXN];
ll sum_right[MAXN];
ll len,N;
ll ans = 0;

ll range_left(ll x, ll y){
	return sum_left[y] - sum_left[x-1];
}

ll range_right(ll x, ll y){
	return sum_right[x] - sum_right[y+1];
}

int main(){
	cin>>len>>N;
	for (ll i=1;i<=N;++i){
		cin>>L[i];
		R[i] = len-L[i];
		sum_left[i] = sum_left[i-1] + L[i];
	}
	for (ll i=N;i>0;--i){
		sum_right[i] = sum_right[i+1] + R[i];
	}
	for (int k=0;k<2;++k){
		for (ll lend = 1;lend<N;++lend){
			ll lstart = 1;
			ll rstart = lend + 1;
			ll rend = N;
			ll offset = 0;
			ll dif = (rend - rstart) - (lend - lstart) + 1; // -1 if we ending on the right
			if (k)dif -= 2;
			if (dif > 0){
				rend -= dif;
				offset = R[rend+1];
			}else if (dif < 0){
				lstart -= dif;
				offset = L[lstart-1];
			}
			ll tot = 2*(range_right(rstart,rend) + range_left(lstart,lend));
			if (k == 0)tot -= L[lend];
			else tot -= R[rstart];
			if (dif > 0 && k == 0)tot = tot + offset*2;
			if (dif < 0 && k == 1)tot = tot + offset*2;

			ans = max(ans,tot);
		}
	}
	ans = max({ans, L[N], R[1]});
	cout<<ans;
}

Measured memory_bytes: 6528
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

double distance(pair<double, double> x1, pair<double, double> x2){
    return sqrt(pow((x1.first - x2.first),2) + pow((x1.second - x2.second),2));
}

int main()
{
    int N;
    cin >> N;
    
    vector<pair<double, double>> P(N);
    
    for(int i=0; i<N; i++){
        cin >> P[i].first;
        cin >> P[i].second;
    }
    double total = 0;
    for(int i=0; i<N-1; i++){
        for(int j=i+1; j<N; j++){
            total += distance(P[i], P[j]);
        }
    }
    cout.precision(20);
    cout << total*2/N << endl;
    return 0;
}


Measured memory_bytes: 256
alp = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' ]
print(alp[alp.index(input())+1])

Measured memory_bytes: 2940
/*
	submission # - User: herp_sy
	https://atcoder.jp/contests/

	coding: utf-8
	lang: C (GCC 5.4.1)
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

TLong getSum(TLong n,TLong i,TLong sum)
{
	if(n / i == 0)	return (n + sum);
	return getSum(n / i, 10, sum + n % i) + getSum(n, i * 10, sum);
}
 
int main(int argc, char const *argv[])
{
	TLong n;
	scanf("%lld",&n);
	printf("%lld", getSum(n, 10, 0));
	return 0;
 }


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 


int main()
{
    int N, D;
    cin >> N >> D;

    vector< vector<int> > X(N);
    for (int i = 0; i < N; ++i) {
        X[i].resize(D);
        for (int j = 0; j < D; ++j) {
            cin >> X[i][j];
        }
    }

    int ans = 0;

    for (int i = 0; i < N-1; ++i) {
        for (int j = i+1; j < N; ++j) {
            int sum = 0;
            for (int k = 0; k < D; ++k) {
                int d = X[i][k] - X[j][k];
                sum += d * d;
            }
            int dist = (int) (sqrt((double) sum) + 0.5);
            if (dist * dist == sum) {
                ++ans;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
  #define cerrendl 42
#endif
//}}}

signed main() {
  int h,n;cin>>h>>n;

  vi a(n), b(n);
  vector<pii> ab;
  rep(i, n){
    cin>>a[i]>>b[i];
    ab.pb(mp(a[i], b[i]));
  }
  // sort(all(ab));
  dump(ab);

  const int H = 10000;
  vvi dp(n+1, vi(h+H+1, INF));
  dp[0][0] = 0;

  rep(i, 1, n+1){
    rep(d, 0, h+H+1){
      chmin(dp[i][d], dp[i-1][d]);
      if (d-a[i-1]>=0) chmin(dp[i][d], dp[i][d-a[i-1]]+b[i-1]);
    }
  }

  int ans = INF;
  rep(d, h, h+H+1){
    chmin(ans, dp[n][d]);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 160640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

const ll INF = LLONG_MAX/3;

struct MinSegTree{
    int n; vector<ll> dat;
    //初期化
    MinSegTree(int _n){
        n=1;
        while(n<_n) n*=2;
        dat=vector<ll>(2*n-1,INF);
    }
    //k番目(0-indexed)の値をaに変更
    void update(int k, ll a){
        k+=n-1;
        dat[k]=a;
        //更新
        while(k>0){
            k=(k-1)/2;
            dat[k]=min(dat[2*k+1],dat[2*k+2]);
        }
    }
    //内部的に投げられるクエリ
    ll _query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return INF;

        if(a<=l && r<=b) return dat[k];

        ll vl=_query(a,b,2*k+1,l,(l+r)/2);
        ll vr=_query(a,b,2*k+2,(l+r)/2,r);
        return min(vl,vr);
    }
    ll query(int a, int b){
        return _query(a,b,0,0,n);
    }
};

int main()
{
    int n,Q,A,B;
    scanf(" %d %d %d %d", &n, &Q, &A, &B);
    --A;
    --B;

    vector<int> x(Q+1);
    x[0]=A;
    rep(i,Q)
    {
        scanf(" %d", &x[i+1]);
        --x[i+1];
    }

    ll all_add = 0;

    MinSegTree L(n),R(n);
    L.update(B, -B);
    R.update(B, B);
    rep(i,Q)
    {
        ll mm = min(L.query(0,x[i+1]+1)+x[i+1], R.query(x[i+1],n)-x[i+1]) + all_add;

        all_add += abs(x[i+1]-x[i]);

        L.update(x[i],mm-x[i]-all_add);
        R.update(x[i],mm+x[i]-all_add);
    }

    ll ans=INF;
    rep(i,n) ans=min(ans,L.query(i,i+1)+i);
    printf("%lld\n", ans+all_add);
    return 0;
}


Measured memory_bytes: 9216
import sys
from operator import itemgetter


def r(a, b):
    if b % a == 0:
        return a + b
    else:
        return b - a


def main():
    input = sys.stdin.readline
    a, b = list(map(int, input().split()))

    print(r(a, b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int main(){
  string s; cin >> s;
  vector<int> d(26);
  rep(i,s.size()) d[s[i]-'a']++;

  if (s.size()<26) {
    int j = find(all(d),0) - d.begin();
    char c = 'a'+j;
    cout << s+c << endl;
  }
  else if (s=="zyxwvutsrqponmlkjihgfedcba"){
    cout << -1 << endl;
  }
  else {
    for (int i=1;i<=25;i++){
      string ss = s.substr(26-i);
      sort(all(ss));
      auto itr = lower_bound(all(ss),s[25-i]);
      if (itr!=ss.end()) {
        char c = *itr;
        s.erase(25-i);
        cout << s + c << endl;
        break;
      }
    }
  }




  // cout << fixed << setprecision(10);
  
  return 0;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> lig(n);
  for(int i=0; i<n; ++i) cin >> lig[i];
  for(int i=0; i<k; ++i){
    vector<int> nlig(n+1,0);
    for(int j=0; j<n; ++j){
      int plus = max(0,j-lig[j]);
      int mai = min(n,j+lig[j]+1);
      ++nlig[plus];
      --nlig[mai];
    }
    for(int j=1; j<n; ++j) nlig[j] += nlig[j-1];
    if(lig == nlig) break;
    lig = nlig;
  }
  for(int i=0; i<n; ++i){
    if(i == n-1) cout << lig[i] << endl;
    else cout << lig[i] << " ";
  }
}

Measured memory_bytes: 5612
N = int(input())
A = list(map(int, input().split()))

from collections import Counter
ac = Counter(A)

td = dict()
for k, v in ac.items():
    if v % 2 == 0:
        td[k] = 2
    else:
        td[k] = 1

ans = 0
two = 0
for k, v in td.items():
    if v == 1:
        ans += 1
    else:
        two += 1

if two % 2 == 0:
    ans += two
else:
    two -= 1
    ans += two

print(ans)

Measured memory_bytes: 28176
n = int(input())
S = []
for _ in range(n):
    S.append(int(input()))
ans=0
for i in range(len(S)):
    ans+= S[i] // 2

    if i==len(S)-1:
        break
    if S[i]%2 == 1 and S[i+1] >= 1:
        ans+=1
        S[i+1] -= 1
print(ans)

Measured memory_bytes: 49880
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)

int main() {
	string s; cin >> s;
	string t="CODEFESTIVAL2016";
	int count = 0;
	rep(i,16) {
		if(s[i]!=t[i]) count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		sc.close();

		long fh = X / 500;
		long f = (X - fh * 500) / 5;

		System.out.println(fh * 1000 + f * 5);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef map<int, int> mi;
typedef set<int> si;
#define VV(T) vector<vector< T > >
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

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

#define pb push_back
#define pu push
#define mp make_pair
#define fi first
#define sc second

#define COUT(x) cout << (x) << endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl

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

    int a[6];
    rep(i, 6) {
        cin >> a[i];
    }

    rep(i, 4) {
        for(int j = i + 1; j < 5; j++) {
            if (a[5] < a[j] - a[i]) {
                COUT(":(");
                return 0;
            }
        }
    }
    COUT("Yay!");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printve(vector<T>& v) {int n = sz(v); REP(i, n) cerr << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    double l;
    cin >> l;
    double m = l / 3.0;
    cout << m * m * m << endl;
}


Measured memory_bytes: 256
#include "stdio.h"
#include "algorithm"
using namespace std;
long long int sum[100500],num[1000500];
int n;
bool ch(int x)
{
    for(int i=x;i<n;i++) if(sum[i]*2<num[i+1]) return false;
    return true;
}
main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&num[i]);
    sort(num+1,num+n+1);
    for(int i=1;i<=n;i++) sum[i]=sum[i-1]+num[i];
    int hi=n,lo=1,mid;
    while(hi-lo>1)
    {
        mid=(hi+lo)/2;
        if(ch(mid)) hi=mid;
        else lo=mid;
    }
    if(ch(lo)) printf("%d",n-lo+1);
    else printf("%d",n-lo);
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		List<Pair> L = new List<Pair>();
		for(int i=0;i<N;i++){
			if(IsOnTheKabe(P[i][0],P[i][1]) && IsOnTheKabe(P[i][2],P[i][3])){
				long f = Enc(P[i][0],P[i][1]);
				long t = Enc(P[i][2],P[i][3]);
				if(f > t){ var tmp = t; t = f; f = tmp; }
				L.Add(new Pair(f,t));
			}
		}
		
		L.Sort((p,q) => p.Fr.CompareTo(q.Fr));
		
		
		Stack<Pair> Stk = new Stack<Pair>();
		foreach(var p in L){
			if(Stk.Count == 0){
				Stk.Push(p);
				continue;
			}
			while(Stk.Count > 0){
				var enclosure = Stk.Peek();
				if(p.Fr > enclosure.To){
					Stk.Pop();
					continue;
				} 
				if(p.To < enclosure.Fr){
					break;
				}
				if(p.Fr > enclosure.Fr && p.To < enclosure.To){
					break;
				} 
				Console.WriteLine("NO");
				return;
			}
			Stk.Push(p);
		}
		Console.WriteLine("YES");
	}
	
	class Pair{
		public long Fr,To;
		public Pair(long f, long t){
			Fr = f; To = t;
		}
	}
	
	bool IsOnTheKabe(long x, long y){
		return (x == 0 || x == R) || (y == 0 || y == C);
	}
	long Enc(long x, long y){
		if(y == 0) return x;
		if(x == R) return R + y;
		if(y == C) return R + C + (R - x);
		if(x == 0) return R + C + R + (C - y);
		return 0;
	}
	
	
	
	long R,C;
	int N;
	long[][] P;
	public Sol(){
		var d = rla();
		R = d[0]; C = d[1]; N = (int)d[2];
		P = new long[N][];
		for(int i=0;i<N;i++) P[i] = rla();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 29740
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
  int N, input;
  cin >> N;
  vector<int> B;
  vector<int> ans(N);
  for(int i = 0; i < N; i++){
    cin >> input;
    B.push_back(input);
  }
  for(int i = N-1; i>= 0; i--){
    int max = 0, index = -1;
    for(int j = 0, k = 1; j < N; j++){
      if(B.at(j) == -1) continue;
      if(B.at(j) == k){
        max = k;
        index = j;
      }
      k++;
    }
    if(max != 0){
      ans.at(i) = max;
      B.at(index) = -1;
    }else{
      cout << -1 << endl;
      return 0;
    }
  }
  for(int i = 0; i < N; i++){
    cout << ans.at(i) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
#include <set> 
using namespace std;

typedef long long ll;
typedef pair<ll, int> P;
typedef pair<pair<int, int>, int> PP;

const ll INF = 1e15;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };



int main(void) {
	int L, R;
	int N, M; cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int l, r; cin >> l >> r;
		L = max(L, l);
		R = min(R, r);
	}
	if (L <= R)cout << R - L + 1 << endl;
	else cout << 0 << endl;
	
}


Measured memory_bytes: 256
import java.util.*

fun main(arr: Array<String>) {
    val n = readLine()!!.toInt()
    val posList = (1..n).map { readLine()!!.split(" ").map { it.toInt() }.let { Pos(it[1], it[0], it[2]) } }
    val list = mutableListOf<Pos>()
    val posList1 = posList.filter { it.h > 0 }
    (0..100).forEach { y->(0..100).forEach { x->list.add(Pos(y,x, Math.abs(posList1.first().y-y)+Math.abs(posList1.first().x-x)+posList1.first().h)) } }
    for(pos in posList1.drop(1)) {
        for(idx in list.indices.reversed()) {
            val diff = Math.abs(pos.y-list[idx].y) + Math.abs(pos.x-list[idx].x)
            if(pos.h + diff != list[idx].h) {
                list.removeAt(idx)
            }
            if(list.size <= 1) {
                break
            }
        }
        if(list.size <= 1) {
            break
        }
    }
    for(pos in posList.filter { it.h == 0 }) {
        for(idx in list.indices.reversed()) {
            val diff = Math.abs(pos.y-list[idx].y) + Math.abs(pos.x-list[idx].x)
            if(list[idx].h - diff > 0) {
                list.removeAt(idx)
            }
            if(list.size <= 1) {
                break
            }
        }
        if(list.size <= 1) {
            break
        }
    }
    println("${list.first().x} ${list.first().y} ${list.first().h}")
}

class Pos(val y: Int, val x: Int, var h: Int)

Measured memory_bytes: 38760
var count = 0;

function Main(input) {

	input = input.split("\n");
	
	var n = parseInt(input[0]);
	var p = input[1].split(" ");
	p = p.map(p => parseInt(p,10));
	
	for(var i = 0;i < n - 2;i++){
	    if(p[i] < p[i+1] && p[i+1] < p[i+2]){
	        count++;
	    }else if(p[i] > p[i+1] && p[i+1] > p[i+2]){
	        count++;
	    }
	}
	
    console.log(count);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.util.Scanner;

public class Main {
	static int[] prize = {
			300_000,
			200_000,
			100_000,
	};

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();

		System.out.println(getPrize(x, y));

		sc.close();
	}

	static int getPrize(int x, int y) {
		int sumPrize = 0;
		if (x <= prize.length) {
			sumPrize += prize[x - 1];
		}
		if (y <= prize.length) {
			sumPrize += prize[y - 1];
		}

		if (x == 1 && y == 1) {
			sumPrize += 400_000;
		}

		return sumPrize;
	}
}


Measured memory_bytes: 23764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0037
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            int N = int.Parse(s);

            var AA = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

            int[] Rs = new int[N + 1];

            for (int i = 0; i < AA.Count; i++)
            {
                Rs[AA[i]]++;
            }

            for (int j = 1; j < N + 1; j++)
            {
                Console.WriteLine(Rs[j]);
            }

        }
    }
}


Measured memory_bytes: 43584
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    int n; cin >> n;
    ll a[n]; rep(i, n) cin >> a[i];
    sort(a, a + n, greater<ll>());
    ll ans = a[0];
    int j = 0;
    rep(i, n - 2) {
        if(i % 2 == 0) ++j;
        ans += a[j];
    }
    cout << ans << endl;
}


Measured memory_bytes: 5200
import Control.Monad
import Control.Applicative
import Data.List




main :: IO()
main = do
  str <- getLine
  let lst =  countBySame' str
  let ans = if length lst == 1
              then 0
              else 2 *  minimum lst
  print ans



countBySame' :: (Ord a) => [a] -> [Int]
countBySame' [] = []
countBySame' lst = let x:xs = sort lst  ; (n, list) = (samelist x xs 0) in n : (countBySame' list)
  where
    samelist ::(Ord a) => a -> [a] ->  Int -> (Int, [a])
    samelist a [] n = (n+1, [])
    samelist a (x:xs) n
                  | a == x = samelist a xs (n+1)
                  | a /= x = (n+1, x:xs)


Measured memory_bytes: 13692
use std::io::*;

fn main() {
    let stdin = stdin();
    let mut lines = stdin.lock().lines().map(|l| l.unwrap());

    let n: usize = lines.next().unwrap().parse().unwrap();
    let mut nums = lines.take(n).map(|s| s.parse::<i32>().unwrap());

    let mut answer: i32 = 0_i32;
    let mut min_val: i32 = 0_i32;
    
    for (index, val) in nums.enumerate() {
        if index != 0 && (index == 1 || answer < val - min_val) {
            answer = val - min_val;
        }
        if index == 0 || val < min_val {
            min_val = val;
        }
    }

  println!("{}", answer);
}




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

  int h, w, i, j;
  while(1)
    {
      scanf("%d %d", &h, &w);
      if( h == 0 && w == 0) break;
	  for( j = 0; j < w; j++)
	    {
	      printf("#");
	    }
	  printf("\n");
	  for( i = 0; i < h - 2; i++)
	    {
	      printf("#");
	      for( j = 0; j < w - 2; j++)
		{
		  printf(".");
		}
	      printf("#\n");
	    }
	  for( j = 0; j < w; j++)
	    {
	      printf("#");
	    }
      printf("\n\n");
    }
  return 0;
}

Measured memory_bytes: 588
// AOJ 1248: The Balance
// 2017.12.17 bal4u@uu

#include <stdio.h>
#include <math.h>

int a, b;
int ansx, ansy;

void answer(int x, int y)
{
	if (x + y < ansx + ansy) ansx = x, ansy = y;
	else if (a*x + b*y < a*ansx + b*ansy) ansx = x, ansy = y;
}

int main()
{
	int d, t, x, ax, lim;

	while(scanf("%d%d%d", &a, &b, &d) && a > 0) {
		ansx = 0x7ffff, ansy = 0x7ffff;
		lim = d << 2; if (lim > 10000) lim = 10000;
		for (ax = x = 0; x < lim; x++, ax += a) {
			t = ax + d;
			if (!(t % b)) answer(x, t/b);
			t -= d << 1;
			if (t >= 0 && !(t % b)) answer(x, t/b);
			t = -t;
			if (t >= 0 && !(t % b)) answer(x, t/b);
		}
		printf("%d %d\n", ansx, ansy);
	}
	return 0;
}

Measured memory_bytes: 1676
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll h, n;
  cin >> h >> n;
  ll s = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    s += a;
  }
  if (s >= h)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>

using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define eb emplace_back
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rer(i,l,r) for(int(i)=(l); (i)<(r); ++(i))
#define rep(i,n) rer(i,0,n)
#define gnr(i,l,r) for(int (i)=(r)-1; (i)>=(l); --(i))
#define pri(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<(p).fi<<' '<<(p).se<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

int main(){
  cin.tie(nullptr); ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);
  
  cin>>n; x=100000;
  rep(i,n){
    x+=x/20;
    x=x-((x%1000)?(x%1000):1000)+1000;
  }
  pri(x);
}


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

int main()
{
    int n;
    cin >> n;
    int a[n] = {};
    for(int i=0; i<n; i++){
        cin >> a[i];
        a[i] -= (i+1);
    }
    sort(a, a+n);
    int mid = 0;
    int left = 0;
    int right = n-1;
    long long ans = 1e15;
    while(left<=right){
        mid = (left+right)/2;
        long long s = 0;
        for(int i=0; i<n; i++){
            s += abs(a[i]-a[mid]);
        }
        // cout << mid << ':' << s << endl;
        ans = min(ans, s);
        if(s > 0){
            left = mid+1;
        }else if(s < 0){
            right = mid-1; 
        }else{
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	ab := strings.Split(stdin.Text(), " ")
	a, _ := strconv.Atoi(ab[0])
	b, _ := strconv.Atoi(ab[1])

	if a < b {
		fmt.Println("a < b")
	} else if a > b {
		fmt.Println("a > b")
	} else {
		fmt.Println("a == b")
	}
}



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

int main(){
    int N;  cin >> N;
    vector<int> L(2*N);
    for(int i=0; i<2*N; i++) cin >> L[i];
    sort(L.begin(), L.end());

    int ans = 0;
    for(int i=0; i<2*N; i+=2){
        ans += L[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b)
        cout << c << endl;
    else if(b == c)
        cout << a << endl;
    else 
        cout << b << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <string>
using namespace std;

int main(void) {
	int a=0,b=0,n=1;
	vector<string> r;
	while (n!=0)
	{
	long ra = 0,rb = 0;
	cin >> n;
	if (n == 0){break;}
	for (int i=0; i<n; i++)
	{
		scanf("%d %d",&a,&b);
		if (a>b)
		{
			ra+=a+b;
		} else if(a<b)
		{
			rb+=a+b;
		} else {
			ra+=a;
			rb+=b;
		}
	}
	ostringstream os;
	os << ra << " " << rb;
	r.push_back(os.str());
	}
	for (int i=0; i<r.size(); i++)
	{
		cout << r[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>

using namespace std;

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    int n;
    string s;
    cin >> n >> s;

    bool valid = n % 2 == 0;
    for (int i = 0, j = n / 2; j < n; ++i, ++j)
        valid &= s[i] == s[j];

    cout << (valid ? "Yes" : "No") << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,i,k;
	
	scanf("%d",&n);
	int a[2][n];
	int save[n];
	
	for(i = 0;i < n;i++){
		a[0][i] = i+1;
		save[i] = i+1;
	}

	for(i = 0;i < n;i++)
		a[1][i] = 0;

	for(i = 0;i < n;i++){
		while(save[i]%2 == 0){
			a[1][i]++;
			save[i] = save[i]/2;
		}	
	}

	int max = a[0][0];
	int max_kazu = a[1][0];

	for(i = 1;i < n;i++){
		if(max_kazu < a[1][i]){
			max = a[0][i];
			max_kazu = a[1][i];
		}
	}	

	printf("%d\n",max);

	return 0;
}

Measured memory_bytes: 128
/*************************************************************************
  >         File: E.cc
  >       Author: Riho.Yoshioka
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Sat 13 Aug 2016 08:44:25 PM CST
*************************************************************************/
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

const int N = 401;
const int MO = 1e9 + 7;
int pw[N][N], p[N][N], A[N], B[N];
int dp[N][N], n, c;

void Add(int &x, int y) {
  x += y;
  if (x >= MO) x -= MO;
}

int Powd(int x, int y) {
  int ans = 1;
  for (; y; y >>= 1) {
    if (y & 1) ans = 1LL * ans * x % MO;
    x = 1LL * x * x % MO;
  }
  return ans;
}

void Init() {
  for (int k = 0; k < N; k++) {
    for (int j = 0; j < N; j++) {
      p[k][j] = Powd(k, j);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= c; j++) {
      for (int k = A[i]; k <= B[i]; k++) {
        Add(pw[i][j], p[k][j]);
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin >> n >> c;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> B[i];
  }
  Init();
  if (n == 1) {
    int ans = 0;
    for (int i = A[0]; i <= B[0]; i++) {
      Add(ans, Powd(i, c));
    }
    cout << ans << endl;
    return 0;
  }
  dp[0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= c; j++) {
      for (int d = 0; d + j <= c; d++) {
        int sum = pw[i][d];
        Add(dp[i + 1][d + j], 1LL * dp[i][j] * sum % MO);
      }
    }
  }
  cout << dp[n][c] << endl;
  return 0;
}


Measured memory_bytes: 2176
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int n;
long long memo[405][405];
long long pre[405];
long long dp(int i,int j){
    if (i==j) return 0;
    else if (memo[i][j]!=-1) return memo[i][j];
    long long ans=1000000000000000000;
    for (int x=i;x<j;x++){
        ans=min(ans,dp(i,x)+dp(x+1,j)+pre[j]-pre[i-1]);
    }
    return memo[i][j]=ans;
}
int main(){
    //freopen("input.txt","r",stdin);
    memset(memo,-1,sizeof(memo));
    scanf("%d",&n);
    for (int x=1;x<=n;x++){
        scanf("%lld",&pre[x]);
        pre[x]+=pre[x-1];
    }
    printf("%lld\n",dp(1,n));
}


Measured memory_bytes: 1536
/* ＵＴＦ－８ */
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>

#define USE_COLORED 1

#ifdef USE_COLORED
static const char stdout_pre[]  = "\033[1m"; // bold black
static const char stderr_pre[]  = "\033[31;1m"; // bold red
static const char stdxxx_post[] = "\033[m";

// 当然ながら GCC(g++)/libstdc++ 依存
#include <ext/stdio_filebuf.h>
using stdio_filebuf = __gnu_cxx::stdio_filebuf<char>;
class colored_stdio_filebuf : public stdio_filebuf {
private:
	const char* const pre_;
	const char* const post_;

public:
	colored_stdio_filebuf(FILE* fp, const char* pre, const char* post) : stdio_filebuf(fp, std::ios_base::out), pre_(pre), post_(post)
	{
	}

protected:
	std::streamsize xsputn(const char* s, std::streamsize count) override
	{
		stdio_filebuf::xsputn(pre_, strlen(pre_));
		auto ret = stdio_filebuf::xsputn(s, count);
		stdio_filebuf::xsputn(post_, strlen(post_));
		return ret;
	}
};
#endif

int main()
{
#ifdef USE_COLORED
	if (getenv("DEBUG")) {
		std::cout.rdbuf(new colored_stdio_filebuf(stdout, stdout_pre, stdxxx_post));
		std::cerr.rdbuf(new colored_stdio_filebuf(stderr, stderr_pre, stdxxx_post));
	} else
#endif
	{
		int fd = open("/dev/null", O_WRONLY);
		dup2(fd, 2);
		close(fd);
	}
	
	int W, H, N;
	std::vector<int> X, Y, A;
	std::cin >> W >> H >> N;
	X.resize(N);
	Y.resize(N);
	A.resize(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> X[i] >> Y[i] >> A[i];
	}

	int xmin = 0, xmax = W, ymin = 0, ymax = H;
	for (int i = 0; i < N; ++i) {
		switch (A[i]) {
		case 1:
			xmin = std::max(xmin, X[i]);
			break;
		case 2:
			xmax = std::min(xmax, X[i]);
			break;
		case 3:
			ymin = std::max(ymin, Y[i]);
			break;
		case 4:
			ymax = std::min(ymax, Y[i]);
			break;
		}
	}
std::cerr << xmin << " " << xmax << " " << ymin << " " << ymax << "\n";
	if (xmin > xmax || ymin > ymax) {
		std::cout << "0\n";
	} else {
		std::cout << ((xmax - xmin) * (ymax - ymin)) << "\n";
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <unordered_map>

#include <cmath>    //floor ceil pow
#include <cstdio>
#include <climits>  //INT_MAX
#include <cstring>  
#include <cstdlib>  //abs
#include <ctime>

#include <string>
#include <bitset>
#include <limits>

#include <fstream>
#include <numeric>
#include <sstream>

using namespace std;

#define mp make_pair
#define pb push_back
#define endl "\n"
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define lli long long int
#define MOD 1000000000+7

lli fast_expo(int b, int e)
{
    // never use 1e9+7 in mod and 
    //pow func in fast Exponentiation bcoz (1e9,100) is inf if 1e9,200 is to be computed :)
    lli res=1;
    while(e>0)
    {
        if(e%2) res = (res*b)%MOD;
        b = (b*b)%MOD;
        e /= 2;
        cout<<res<<" "<<b<<" "<<e<<endl;
    }
    
    return res%MOD;
}

int main ()
{
    /*int tt;
    cin >> tt;
    while(tt--)
    {*/
        lli ans=0;
        int n;
        cin >> n;
        
        cout<<n+ n*n + n*n*n;
        
    //}
    return 0;
}

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


int main(){
	char s[4];
	for (int i = 0; i < 4; i++) cin >> s[i];

	sort(s, s + 4);

	bool ans = (s[0] == s[1])
		&& (s[2] == s[3])
		&& (s[0] != s[2]);

	cout << (ans ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

int main(){
    int N, K;

    cin >> N >> K;

    long A[N + 1];
    for(int i = 0; i < N + 1; i++){
        A[i] = i;
    }

    //Aのi番目までの総和を求める
    vector<long> S(N + 2, 0);
    for(int i = 0; i < N + 1; i++){
        S[i + 1] = S[i] + A[i];
    }

    long count = 0;
    int right, left;

    long minv;
    long maxv;

    for(int i = K; i <= N + 1; i++){
        left = 0;
        right = i;
        minv = S[right] - S[left];
        
        left = N + 1 - i;
        right = N + 1;

        maxv = S[right] - S[left];

        count = count + 1 + maxv - minv;


    }

    count = count % (1000000000 + 7);

    printf("%ld\n", count);


    return 0;


	
}


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

int main() {
    int n;
    cin>>n;
    int a[n];
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    for (int j = n-1; j >0 ; --j) {
        cout<<a[j]<<" ";
    }
    cout<<a[0]<<endl;
    return 0;
}


Measured memory_bytes: 3088
N, Q = map(int, input().split())

S = list(input())

lr = [list(map(int, input().split())) for _ in range(Q)]

cnt = [0]*N

for i in range(1, N):
    cnt[i] = cnt[i-1]
    if S[i-1] == 'A' and S[i] == 'C':cnt[i] += 1

for l, r in lr:
    print(cnt[r-1] - cnt[l-1])

Measured memory_bytes: 31396
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, t1, t2 int
	var x1, y1, x2, y2 float64
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&t2, &x2, &y2)
		dt := t2 - t1
		dist := math.Abs(x2-x1) + math.Abs(y2-y1)
		if dt < int(dist) || int(dist)%2 != dt%2 {
			fmt.Println("No")
			return
		}
		t1, x1, y1 = t2, x2, y2
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 5504
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(ll i = 1;i <=  n; i++)
#define rreq(i,n) for(ll i = n;i >= 1;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long int ll;
typedef long double ld;
const ll INF = 1e18;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
const int MOD = 1000000007;
struct Dinic {
    struct edge {
        ll to,cap,rever;
        edge(ll to,ll cap, ll rever) :to(to), cap(cap), rever(rever) {}
    };
    vector< vector<edge> > graph;
    vector<int> level, iter;
    Dinic(ll V) :graph(V), level(V), iter(V) {}
    void add_edge(ll from, ll to,ll cap) {
        graph[from].emplace_back(to, cap, graph[to].size());
        graph[to].emplace_back(from, 0, graph[from].size() - 1);
    }
    void bfs(int s) {
        fill(ALL(level), -1);
        queue<ll> que;
        level[s] = 0;
        que.push(0);
        while (que.size()) {
            ll v = que.front(); que.pop();
            for (edge& e : graph[v]) {
                if (e.cap > 0 && level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }
    ll dfs(ll v, ll t,ll f) {
        if (v == t) return f;
        for (int& i = iter[v]; i < graph[v].size(); i++) {
            edge& e = graph[v][i];
            if (e.cap > 0 && level[v] < level[e.to]) {
                ll d = dfs(e.to, t, min(e.cap, f));
                if (d > 0) {
                    e.cap -= d;
                    graph[e.to][e.rever].cap += d;
                    return d;
                }
            }
        }return 0;
    }
    ll max_flow(int s, int t) {
       ll flow = 0;
       while (1) {
           bfs(s);
           if (level[t] < 0) return flow;
           fill(ALL(iter), 0);
           ll f; while ((f = dfs(s, t, 1e15)) > 0) flow += f;
       }
    }
};
int main(void) {
    ll n, sum = 0; cin >> n;
    Dinic dc(n + 2);
    int s = 0, t = n + 1; ll ans = 0;
    vector<int> a(n+1);
    req(i, n) cin >> a[i];
    req(i, n) {
        if (a[i] <= 0) dc.add_edge(s, i, -a[i]);
        else ans += a[i], dc.add_edge(i, t, a[i]);
        for (int j = 2 * i; j <= n; j += i)dc.add_edge(i, j, 1e15);
    }cout << ans - dc.max_flow(s, t) << endl;
}

Measured memory_bytes: 3676