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

using ll = long long;

using namespace std;

//0 -> a-1
#define rep(i, a) for (int i = 0; (i) < (int)(a); (i)++)
//a -> b-1
#define reps(i, a, b) for (int i = (int)(a); (i) < (int)(b); (i)++)
//a-1 -> 0
#define rrep(i, a) for (int i = (int)a - 1; (i) >= 0; (i)--)
//a-1 -> b
#define rreps(i, a, b) for (int i = (int)(a)-1; (i) >= (int)(b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
//next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
(v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v) \
	sort(all(v)); \
	(v).erase(unique(all(v)), v.end())
#define CIN(type, x) \
	type x;          \
	cin >> x
#define YES(f) if ((f)) {cout << "YES" << endl;} else {cout << "NO" << endl;}
#define Yes(f) if ((f)) {cout << "Yes" << endl;} else {cout << "No" << endl;}
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
//b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
//c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(12)
#define RS resize
#define CINV(v, N)             \
	do                         \
	{                          \
		v.RS(N);               \
		rep(i, N) cin >> v[i]; \
	} while (0);

#define RCINV(v, N)             \
	do                          \
	{                           \
		v.RS(N);                \
		rrep(i, N) cin >> v[i]; \
	} while (0);
#define MOD 1000000007

template <class T>
inline T GET()
{
	T x;
	cin >> x;
	return x;
}

void init();
void solve();

signed main()
{
	init();
	solve();
}

double dp[3123][3123];

void init()
{
	int N;
	cin >> N;
	vector<double> v(N);
	rep(i, N) cin >> v[i];
	dp[0][0] = 1;
	reps(i, 1, N+1) {
		dp[i][0] = dp[i-1][0] * (1 - v[i-1]);
		reps(j, 1, i+1) {
			dp[i][j] = dp[i-1][j] * (1 - v[i-1]) + dp[i-1][j-1] * v[i-1];
		}
	}
	double res = 0;
	reps(i, N/2+1, N+1) {
		res += dp[N][i];
	}
	fcout << res << endl;
}

void solve()
{
}


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

int main() {
  
  int N;
  cin >> N;
  
  vector <int> a(N);
  int Alice =0, Bob =0;
  for (int i=0; i<N; i++) {
    cin >> a.at(i);
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
  }
   for (int i=0; i<N; i++) {
     if (i %2 == 0) {
      Alice += a.at(i);
    } else {
      Bob += a.at(i);
    }
  }
  
  cout << Alice - Bob <<endl;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 200 * 1000 + 13;

int n;
string s;

bool read () {
	static char buf[N];
	if (scanf("%s", buf) != 1)
		return false;
	s = buf;
	n = sz(s);
	return true;
}

li dp[N];

void solve() {
	memset(dp, 0, sizeof(dp));
	fore(i, 1, n){
		if (s[i] != 'C' || s[i - 1] != 'B') continue;
		int j = i - 2;
		while (j >= 0 && s[j] == 'A') --j;
		dp[i] = i - 2 - j;
		if (j >= 0) dp[i] += dp[j];
	}
	printf("%lld\n", accumulate(dp, dp + n, 0ll));
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while(read()) {	
#else
	if(read()) {
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 2176
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    N = int(input())
    A = [int(e) for e in input().split()]

    n = 0
    for i in range(N):
        for j in range(i+1, N):
            n = max(n, abs(A[j] - A[i]))
    print(n)

main()


Measured memory_bytes: 2940
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	A1, A2, A3 := nextInt(), nextInt(), nextInt()

	if A1+A2+A3 >= 22 {
		fmt.Println("bust")
	} else {
		fmt.Println("win")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
//For ordered_set
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define MOD 1000000007
#define test int t; cin>>t; while(t--)
#define init(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(int i=a;i<b;i++)
#define loopr(i,a,b) for(int i=a;i>=b;i--)
#define loops(i,a,b,step) for(int i=a;i<b;i+=step)
#define looprs(i,a,b,step) for(int i=a;i>=b;i-=step)
#define ull unsigned long long int
#define ll long long int
#define P pair
#define PLL pair<long long, long long>
#define PII pair<int, int>
#define PUU pair<unsigned long long int, unsigned long long int>
#define L list
#define V vector
#define D deque
#define ST set
#define MS multiset
#define M map
#define UM unordered_map
#define mp make_pair
#define pb push_back
#define pf push_front
#define MM multimap
#define F first
#define S second
#define IT iterator
#define RIT reverse_iterator
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define FILE_READ_IN freopen("input.txt","r",stdin);
#define FILE_READ_OUT freopen("output.txt","w",stdout);
#define all(a) a.begin(),a.end()
#define ld long double
using namespace std;
// For ordered_set
using namespace __gnu_pbds;
template <typename T>
using ord_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
const ll maxn = 1e5;
const ll inf = 1e9;
const double pi = acos(-1);

int main(){
	ll a,b;
  cin >> a >> b;
  ll g = __gcd(a,b);
  cout << (a/g)*b;
   return 0;
}

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

/*
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}
template <class T, class S> void reader(T *x, S *y){reader(x);reader(y);}
void writer(int x, char c){int s=0,m=0;char f[10];if(x<0)m=1,x=-x;while(x)f[s++]=x%10,x/=10;if(!s)f[s++]=0;if(m)mypc('-');while(s--)mypc(f[s]+'0');mypc(c);}
template<class T> void writerLn(T x){writer(x,'\n');}
*/

#define incID(i, l, r) for(int i = (l); i < (r); i++)
#define inc(i, n) incID(i, 0, n)
template<typename T> bool setmin(T &a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T &a, T b) { if(b <= a) { return false; } else { a = b; return true; } }


// ---- ----

int n, k;
vector<int> vec[100000];
bool has[100000];
int mi[100000];
int ma[100000];

void prod(int x, int y) {
	if(has[y]) {
		bool flag = true;
		if(has[x] && (mi[x] - mi[y]) % 2 == 0) { flag = false; }
		setmax(mi[x], mi[y] - 1);
		setmin(ma[x], ma[y] + 1);
		has[x] = true;
		if(mi[x] > ma[x]) { flag = false; }
		if(! flag) {
			cout << "No" << endl;
			exit(0);
		}
	}
}

bool dfs(int node, int pre) {
	if(pre != -1) { prod(node, pre); }
	for(auto && e : vec[node]) {
		if(e != pre) {
			dfs(e, node);
			prod(node, e);
		}
	}
}

int main() {
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	
	cin >> n;
	inc(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	fill(mi, mi + n, -1000000);
	fill(ma, ma + n,  2000000);
	cin >> k;
	inc(j, k) {
		int v, p;
		cin >> v >> p;
		v--;
		mi[v] = p;
		ma[v] = p;
		has[v] = true;
	}
	
	dfs(0, -1);
	dfs(0, -1);
	
	cout << "Yes" << endl;
	inc(i, n) { cout << mi[i] << endl; }
	
	return 0;
}


Measured memory_bytes: 11904
// In the name of God //
 
#include <bits/stdc++.h>
#define ll long long
#define all(x) (x).begin(), (x).end()
#define pii pair <int, int>
using namespace std;
const int mod = 1e9 + 7;

void solve() {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    reverse(all(a));
    long long ans = 1;
    if(a[0] == 0 && k%2) {
        cout << 0;
        return;
    }
    if(a[0] < 0 && k&1) {
        for (int i = 0; i < k; i++) {
            ans = ((ans%mod)*((a[i] + mod)%mod) + mod)%mod;
        }
        cout << ans;
        return;
    }
    int i = 0, j = n-1;
    if(k%2) {
        ans = ((ans%mod)*((a[0] + mod)%mod))%mod;
        i++;
        k--;
    }
    while(k) {
        ll p1 = a[i]*a[i + 1];
        ll p2 = a[j]*a[j - 1];
        if(p1 <= p2) {
            ans = ((ans%mod)*((p2 + mod)%mod))%mod;
            j -= 2;
        }
        else {
            ans = ((ans%mod)*((p1 + mod)%mod))%mod;
            i += 2;
        }
        k -= 2;
        // cout << ans << " ";
    }
    cout << ans;
}

int main()  {
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int tt = 1;
    // cin >> tt;
    for (int tc = 1; tc <= tt; ++tc) {
        solve();
    } 
}                                   

Measured memory_bytes: 4752
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int P, Q, R;
  cin >> P >> Q >> R;
  cout << min(P + Q, min(Q + R, R + P)) << endl;
  return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
const ll INF = 1e18L + 1;

//clang++ -std=c++11 -stdlib=libc++ 
int main() {
  int H,W; cin >>H>>W;
  vector<string> maze;
  rep(i,H) {
    string t;
    cin >> t;
    maze.push_back(t);
  }

  auto bfs = [&](ii start, ii goal) {
    if (start == goal) return 0;
    queue<ii> q;
    queue<ii> next;
    vector<vb> visited(H, vb(W, false));
    int dx[] = {1,0,-1,0}, dy[]={0,-1,0,1};
    next.push(start);
    int level =0;
    while(next.size()) {
      while(next.size()) {
        q.push(next.front()); next.pop();
      }
      while (q.size()) {
        ii p = q.front(); q.pop();
        if (p == goal) return level;
        for (int m=0; m<4; m++) {
          if (p.first + dy[m] >=0 && p.first + dy[m] < H && p.second + dx[m]>= 0 && p.second+dx[m] < W && maze[p.first + dy[m]][p.second+dx[m]] == '.' && !visited[p.first + dy[m]][p.second+dx[m]]) {
            next.push(ii(p.first+dy[m], p.second + dx[m]));
            visited[p.first + dy[m]][p.second+dx[m]] = true;
          }
        }
      }
      level++;
    }
    return --level;
  };
  int ans=0;
  rep(i,H) {
    rep(j,W) {
      if (maze[i][j]=='#') continue;
      rep(k, H) rep(l, W) {
        int result = bfs(ii(i,j),ii(k,l));
        ans = max(ans, result);
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream> 
using namespace std; 
  
int main ()
{
   int a,b,c,d,z,x;
  cin>>a>>b>>c>>d;
  z=a*b;
  x=c*d;
  if(z>=x)
    cout<<z;
   else
     cout<<x;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
typedef long long ll;
const ll mod=(1e9)+7;
const int maxn=1010;
int n,k,a;
ll jc[maxn],iv[maxn],ivjc[maxn];
ll dp[25][maxn],ans;
ll C(ll x,ll y) {
	return jc[x]*ivjc[x-y]%mod*ivjc[y]%mod;
}
void update(ll &x,ll y) { x=(x+y)%mod; }
int main() {
	//freopen("1.txt","r",stdin);
	read(n); read(k);
	iv[0]=jc[0]=ivjc[0]=1;
	iv[1]=jc[1]=ivjc[1]=1;
	for (int i=2;i<=n;i++) {
		jc[i]=jc[i-1]*i%mod;
		iv[i]=(mod-mod/i)*iv[mod%i]%mod;
		ivjc[i]=ivjc[i-1]*iv[i]%mod;
	}
	dp[0][0]=1;
	for (int i=1;i<=k;i++) {
		read(a);
		for (int j=0;j<=n;j++) {
			for (int x=0;x<=a&&j+x<=n;x++) {
				update(dp[i][j+x],dp[i-1][j]*C(n-x,a-x)%mod*ivjc[x]%mod);
			}
		}
	}
	printf("%lld\n",dp[k][n]*jc[n]%mod);
	return 0;
}
/*
  REMEMBER:
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Array size? Integer overflow? Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 384
import math
a=list(map(int, input().split(' ')))
print(math.sqrt( abs( a[0]**2 + a[1]**2 - 2*a[0]*a[1]*math.cos(abs(2*math.pi*((a[2]*60+a[3])/720)-2*math.pi*(a[3]/60))))))

Measured memory_bytes: 9444
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define iter(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define riter(i, c) for (auto i = (c).rbegin(); i != (c).rend(); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> P(N);
    rep(i, 0, N) cin >> P[i];
    int ans = 0;
    int min_p = 1 << 30;
    rep(i, 0, N) {
        if (min_p >= P[i]) {
            ++ans;
        }
        chmin(min_p, P[i]);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using namespace std::chrono;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
int mod=1000000007;
const int MX=0x3f3f3f3f;

	
int main() {
	IOS;
	int k,a,b;
	cin>>k>>a>>b;
	int i;
	int flag=0;
	REP(i,a,b){
		if(i%k==0) flag=1; 
	}
	if(flag) cout<<"OK";
	else cout<<"NG";
	return 0;
}

Measured memory_bytes: 3652
meals=[]
for i in range(5):
    meals.append([i,int(input())])
for g in range(5):
    if meals[g][1]%10!=0:
        meals[g][0]=meals[g][1]%10
    else:
        meals[g][0]=10

meals.sort(reverse=True)

ans=0
for i in range(4):
    ans+=meals[i][1]+10-meals[i][0]
ans+=meals[-1][1]

print(ans)

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

int main()
{
  std::vector< std::vector<int> > a(3, std::vector<int> (3) );
  for(int i = 0 ; i < 3 ; i++)
  {
    for(int j = 0; j < 3 ; j++)
    {
      cin >> a.at(i).at(j) ;
    }
  }

  bool answer = false ;
  for(int i = 0; i <= 100 ; i++)
  {
    int b1 = a.at(0).at(0) - i ;
    int b2 = a.at(0).at(1) - i ;
    int b3 = a.at(0).at(2) - i ;
    if(b1 < 0 || b2 < 0 || b3 < 0)
    {
      continue ;
    }

    for(int j = 0 ; j <= 100 ; j++)
    {
      if(j + b1 == a.at(1).at(0) && j + b2 == a.at(1).at(1) && j + b3 == a.at(1).at(2))
      {
        if(answer)
        {
          break ;
        }
        for(int k = 0 ; k <= 100 ; k++)
        {
          if(k + b1 == a.at(2).at(0) && k + b2 == a.at(2).at(1) && k + b3 == a.at(2).at(2))
          {
            answer = true ;
            break ;
          }
        }
      }
    }
  }

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


Measured memory_bytes: 256
#include<math.h>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define    ll   long long int
#define    py   printf("Yes\n")
#define    pn   printf("No\n")
#define    in   cin>>
using namespace std;
int main()
{
int n,a,b,i,s=0,e,j=0;
    cin>>n>>b;
    int c[n+1]={0};
    while(b--)
    {
        cin>>a;
        for(i=0;i<a;i++)
        {
            cin>>e;
            c[e]++;
        }
    }
    for(i=1;i<=n;i++)
    {
        if(c[i]==0)
        {
            s++;
        }
    }
    cout<<s<<endl;
    return 0;
}


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

int main(){
  int N;
  cin>>N;
  int V[N],C[N];
  for(int i=0;i<N;i++){
    cin>>V[i];
  }
  for(int i=0;i<N;i++){
    cin>>C[i];
  }
  int ans = 0;
  for(int i=0;i<N;i++){
    ans += max(0,V[i]-C[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner (System.in);
		
				int n = sc.nextInt();
		 
				if (n % 2 == 0) {
					System.out.println(n / 2);
				}
		 
				if ( n % 2 == 1) {
					System.out.println(n / 2 + 1);
				}
		 
			}
		 
		}

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  
  A -= B;
  
  if(A<=0) cout << C << endl;
  else if(A >= C) cout << 0 << endl;
  else cout << C- A << endl;
}


Measured memory_bytes: 256
N, S = map(int, input().split())
A = list(map(int, input().split()))
# dp[n][i][s] := i 番目まで見て n 個使って合計が s になる場合の数 これは無理
# dp[i][s] := i 番目まで見て合計 s 
dp = [[0]*(S+1) for _ in range(N+1)]
dp[0][0] = 1
mod = 998244353
for i, a in enumerate(A, 1):
    for s in range(S+1):
        if s-a >= 0:
            dp[i][s] = (dp[i-1][s] * 2 + dp[i-1][s-a]) % mod
        else:
            dp[i][s] = dp[i-1][s] * 2 % mod
print(dp[N][S])

Measured memory_bytes: 132716
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll N,A,B;
vector<ll> vec;


//解法
void solve() {
	
	ll x=0, y=0, z=0;
	rep(i, N) {
		if (vec[i] <= A) {
			x++;
		}
		else if (vec[i] >= B + 1) {
			z++;
		}
		else {
			y++;
		}
	}

	x = (x < y ? x : y);
	x = (x < z ? x : z);
	cout << x;

	return;
}

int main() {
	//入力

	cin >> N>>A>>B;
	vec.resize(N);
	rep(i, N) cin >> vec[i];

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  /**
   * @param args
   */
  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner cin = new Scanner(System.in);
    String  S   = cin.next();
    String  T   = cin.next();
    if ((T.length() - S.length()) != 1){
      System.out.println("No");
    }
    else{
      if (T.indexOf(S) == 0){
        System.out.println("Yes");
      }
      else{
        System.out.println("No");
      }
    }
  }

}


Measured memory_bytes: 26908
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
        //console.log('%s',input);
	input = input.split("\n");
	tmp = input[1].split(" ");
	var max = [];
	for(var i=0;i < 9;i++){
		max[i] = 0;
	}
	for(var i=0;i < tmp.length ;i++){
		var a = parseInt(tmp[i], 10);
		if(1 <= a && a < 400)max[0] = 1;
		else if(400 <= a && a < 800)max[1] = 1;
		else if(800 <= a && a < 1200)max[2] = 1;
		else if(1200 <= a && a < 1600)max[3] = 1;
		else if(1600 <= a && a < 2000)max[4] = 1;
		else if(2000 <= a && a < 2400)max[5] = 1;
		else if(2400 <= a && a < 2800)max[6] = 1;
		else if(2800 <= a && a < 3200)max[7] = 1;
		else if(3200 <= a && a <= 4800)max[8] += 1;
	}
	var b = 0;
	for(var i=0;i < 8;i++){
		b += max[i];
	}
	/*maxを求める*/
	var ma = b + max[8];
	//if(ma > 8)ma = 8;
	/*minを求める*/
	var mi = b;

	if(b == 0 && max[8] > 0){
		mi = 1;
	}
	//出力
	console.log('%d %d',mi,ma);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
  string s;
  cin >> s;
  int x = 7;
  map<string, int> m;
  for (string k : {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}) m[k] = x--;

  cout << m[s] << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner in = new Scanner(System.in);
    String s1 = in.next();
    String s2 = in.next();
    String num = s1 + s2;
    int n = Integer.parseInt(num);
    double sqrt = Math.sqrt(n);
    int x = (int) sqrt;
    if( Math.pow(sqrt,2) == Math.pow(x,2) ) System.out.println("Yes");
    else System.out.println("No");
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

typedef pair<Weight, Edge> P;

void dijkstra(const Graph& g, Array& dist, int s)
{
	int n = g.size();
	dist.resize(n, INF);
	dist[s] = 0;
	vector<bool> visited(n);
	visited[s] = true;
	priority_queue<P, vector<P>, greater<P>> que;
	for (auto e : g[s])
	{
		que.emplace(e.cost, e);
	}
	while (!que.empty())
	{
		Edge tmp = que.top().second;
		que.pop();
		if (visited[tmp.to]) continue;
		visited[tmp.to] = true;
		dist[tmp.to] = dist[tmp.from] + tmp.cost;
		for (auto e : g[tmp.to])
		{
			que.emplace(dist[tmp.to] + e.cost, e);
		}
	}
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, m, s;
	cin >> n >> m >> s;
	Graph g(n);
	REP(i, m)
	{
		int a, b, c;
		cin >> a >> b >> c;
		add_edge(g, a, b, c);
	}
	Array dist;
	dijkstra(g, dist, s);
	for (auto i : dist)
	{
		if (i >= INF) cout << "INF" << endl;
	 	else cout << i << endl;
	}
	return 0;
}

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

int main() {
    string s;
    cin >> s;
    for (int i=0; i<5; i++)
        cout << s[i];
    cout << ' ';
    for (int i=6; i<13; i++)
        cout << s[i];
    cout << ' ';
    for (int i=14; i<19; i++)
        cout << s[i];
    cout << '\n';
    return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vll = vector<ll>;
template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

int main() {
    int N, M;

    cin >> N >> M;

    int ans = 1;
    for (int i = 1; i * i <= M; i++) {
        if (M % i == 0) {
            if (M / i >= N) ans = max(ans, i);
            if (i >= N) ans = max(ans, M / i);
        }
    }
    cout << ans << endl;
    return (0);
}

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

using namespace std;

namespace SGT {

const int Maxn=20000000;

int ch[Maxn][2],sumv[Maxn],tot;

inline int cpynode(int o) {
  tot++;
  ch[tot][0]=ch[o][0];ch[tot][1]=ch[o][1];
  sumv[tot]=sumv[o];
  return tot;
}

int update(int l,int r,int o,int p,int q) {
  o=cpynode(o);
  sumv[o]+=q;
  if (l==r) return o;
  else {
  	int m=((l+r)>>1);
  	if (m>=p) ch[o][0]=update(l,m,ch[o][0],p,q);
  	else ch[o][1]=update(m+1,r,ch[o][1],p,q);
  	return o;
  }
}

int erase(int l,int r,int o,int p) {
  if (r<=p) return 0;
  else {
  	o=cpynode(o);
  	int m=((l+r)>>1);
  	if (m>=p) ch[o][0]=erase(l,m,ch[o][0],p);
  	else {
  		ch[o][0]=0;
  		ch[o][1]=erase(m+1,r,ch[o][1],p);
	  }
	sumv[o]=sumv[ch[o][0]]+sumv[ch[o][1]];
	return o;
  }
}

int merge(int l,int r,int x,int y) {
  if (!x) return y;
  if (!y) return x;
  int o=++tot,m=((l+r)>>1);
  ch[o][0]=merge(l,m,ch[x][0],ch[y][0]);
  ch[o][1]=merge(m+1,r,ch[x][1],ch[y][1]);
  sumv[o]=sumv[ch[o][0]]+sumv[ch[o][1]];
  return o;
}

int query(int l,int r,int o,int p) {
  if (!o) return 0;
  if (l==r) return sumv[o];
  else {
  	int m=((l+r)>>1);
  	if (m>=p) return query(l,m,ch[o][0],p);
  	else return sumv[ch[o][0]]+query(m+1,r,ch[o][1],p);
  }
}

}

vector <int> e[200005];
int n;

int root[200005];

void dfs1(int x,int fa) {
  for(int i=0;i<e[x].size();i++)
    if (e[x][i]!=fa) {
    	int u=e[x][i];
    	dfs1(u,x);
    	root[x]=SGT::merge(1,n,root[x],root[u]);
	}
  int v=SGT::query(1,n,root[x],x)+1;
  root[x]=SGT::erase(1,n,root[x],x);
  root[x]=SGT::update(1,n,root[x],x,v);
}

int maxn[200005],ans[200005];

void dfs2(int x,int fa) {
  if (x>1) {
  	ans[x]=ans[fa]+1;
  	if (fa>1) ans[x]-=SGT::query(1,n,root[x],maxn[fa]);
  	for(int i=0;i<e[x].size();i++)
  	  if (e[x][i]!=fa) {
  	  	  int u=e[x][i];
  	  	  ans[x]+=SGT::query(1,n,root[u],maxn[x]);
		}
  }
  for(int i=0;i<e[x].size();i++)
    if (e[x][i]!=fa) {
    	int u=e[x][i];
    	maxn[u]=max(maxn[x],x);
    	dfs2(u,x);
	}
}

int main() {
  scanf("%d",&n);
  for(int i=1;i<n;i++) {
  	int x,y;
  	scanf("%d%d",&x,&y);
  	e[x].push_back(y);
  	e[y].push_back(x);
  }
  dfs1(1,0);
  dfs2(1,0);
  for(int i=2;i<=n;i++) printf("%d ",ans[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 140788
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a[100];
int n;
int main () {
	cin>>n;
	a[0]=2;
	a[1]=1;
	for (int i=2; i<=n; i++) a[i]=a[i-1]+a[i-2];
	cout<<a[n]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int j,i,n,q,C=0;
  int S[10000],T[500],c[500];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<n;i++){
    for(j=0;j<q;j++){
      if(S[i]==T[j]){
	C++;
        T[j]=-1;
      }
    }
  }
  printf("%d\n",C);
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
#define endl '\n'
using namespace std;
const ll inf=1e18;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,i;
    cin>>n;
    string s,t;
    cin>>s;
    cin>>t;
    for(i=0;i<n;i++)
        cout<<s[i]<<t[i];
    cout<<endl;
}


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

using namespace std;

int main() {
    long long n, k;
    cin >> n >> k;

    long long ans = (n / k) * (n / k) * (n / k);
    if (k % 2 == 0) {
        n += k / 2;
        ans += (n / k) * (n / k) * (n / k);
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << '\n'
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    Int n;
    cin >> n;

    vector<Int> di(0);
    int count = 0;
    for (int i = 1; i <= sqrtl(n); i++) {
        if (n % i == 0) {
            di.push_back(i);
            count++;
        }
    }

    Int a = di[count - 1], b = n / di[count - 1];

    cout << a - 1 + b - 1 << endl;
}


Measured memory_bytes: 256
using System;

class AOJ
{
	public static void Main(string[] args)
	{
		int len = int.Parse(Console.ReadLine().Trim());
		var input = Console.ReadLine().Trim().Split(' ');
		var num = new int[len];
		for(int i = 0; i < len; i++){ num[i] = int.Parse(input[i]); }

		int counter = 0;
		while(true)
		{
			bool end = true;
			for(int i = len - 1; i >= 1; i--)
			{
				if(num[i] < num[i - 1])
				{
					int tmp = num[i];
					num[i] = num[i - 1];
					num[i - 1] = tmp;
					end = false;
					counter++;
				}
			}
			if(end){ break; }
		}

		string output = "";
		foreach(var i in num){ output += i.ToString() + " "; }
		output = output.Trim();
		Console.WriteLine(output);
		Console.WriteLine(counter.ToString());
	}
}

Measured memory_bytes: 5660
#include<bits/stdc++.h>
using namespace std;
const int SIZE=200005;
int A[SIZE],B[SIZE];
int C[SIZE];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>A[i]>>B[i];
	}
	for(int i=0;i<m;i++)
		if(A[i]==1) C[B[i]]=1;
	bool ans=false;
	for(int i=0;i<m;i++){
		if(B[i]==n&&C[A[i]]==1) ans=true;
		if(ans) break;
	}
	if(!ans) cout<<"IM";
	cout<<"POSSIBLE"<<endl;
	return 0;
}

Measured memory_bytes: 2560
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

a, b, c, k = readmi()
s = min(a, k)
k -= a
if k <= 0:
    print(s)
    exit()
k -= b
if k <= 0:
    print(s)
    exit()
s -= k
print(s)

Measured memory_bytes: 10768
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
void read(int &x)
{
    int f=1;
    x=0;
    char s=getchar();
    while(s<'0'||s>'9')
    {
        if(s=='-')
            f=-1;
        s=getchar();
    }
    while(s>='0'&&s<='9')
    {
        x=x*10+s-'0';
        s=getchar();
    }
    x*=f;
}

ll n;
int sum[1000005];
int temp[1000];
int main(){
    cin>>n;
    ll ans =0;
    for(int i=1;i<100;i++){
        if(i>=55)temp[i]=10;
        else if(i>=45)temp[i]=9;
        else if(i>=36)temp[i]=8;
        else if(i>=28)temp[i]=7;
        else if(i>=21)temp[i]=6;
        else if(i>=15)temp[i]=5;
        else if(i>=10)temp[i]=4;
        else if(i>=6)temp[i]=3;
        else if(i>=3)temp[i]=2;
        else if(i>=1)temp[i]=1;    
    }
    ll t=n;
    for(ll i=2;i*i<=t;i++){
        if(n%i==0){
            while(n%i==0){
                n/=i;
                sum[i]++;
            }
        }
    }
    if(n!=1)ans++;
    for(int i=2;i<=sqrt(t)-1;i++){
        ans+=temp[sum[i]];
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 3712
import java.io.*;
import java.util.*;

public class Main {
 	public static void main(String[] args) throws Exception {
     	Scanner sc = new Scanner(System.in);
      	PrintWriter out = new PrintWriter(System.out);
      	int a = sc.nextInt();
      	int b = sc.nextInt();
      	if ((a + b) % 2 == 0) {
         	out.println((a+b) / 2); 
        }
      	else {
         	out.println("IMPOSSIBLE"); 
        }
      	out.close();
    }
}

Measured memory_bytes: 21716
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define pf push_front
#define ins insert

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

int n,a,b;

main(){
	cin>>n>>a>>b;
	if(a>b){
		dump(0);
		return 0;
	}
	if(n==1){
		if(a==b)dump(1);
		else dump(0);
		return 0;
	}
	int mi=0,ma=0;
	rep(i,n-1){
		mi+=a;
		ma+=b;
	}
	mi+=b;
	ma+=a;
	dump(ma-mi+1);
}

Measured memory_bytes: 256
S = input()
n = len(S)
s1 = S[:(n - 1) // 2]
s2 = S[(n + 3) // 2 - 1:]
if S == S[::-1] and s1 == s1[::-1] and s2 == s2[::-1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define M_PI       3.14159265358979323846
#define Speed_UP  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define 	pb	push_back 
#define 	ff	first 
#define 	ss	second 
#define sz(x) (int)x.size()
#warning Remeber to change t
using namespace std;
typedef long long ll;
inline void setIO(string name="") {
	#ifndef ONLINE_JUDGE 
	freopen((name+".in").c_str(), "r", stdin); 
	freopen((name+".out").c_str(), "w", stdout);
	#endif
	}

int main(){
	Speed_UP
	ll t;
	t=1;
	while(t--){
    ll n;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++)
      cin>>arr[i];
    
    ll cur=arr[0];
    ll ans=0;
    for(int i=1;i<n;i++){
      cur=max(arr[i],cur);
      ans+=cur-arr[i];
    }
    cout<<ans;
		
		
		
	}





}


Measured memory_bytes: 5172
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = (n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==v.size()-1?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    vi a(n);
    cin >> a;
    vl sum(n+1,0);
    rep(i,n) sum[i+1] = sum[i]+a[i];
    ll ans = linf;
    int l = 1,m = 2,r = 3;
    while(m <= n-2) {
        if(m == r) r++;
        while(l+1 < m) {
            ll pre = abs(sum[l]-(sum[m]-sum[l]));
            ll nx = abs(sum[l+1]-(sum[m]-sum[l+1]));
            if(pre > nx) l++;
            else break;
        }
        while(r+1 < n) {
            ll pre = abs((sum[r]-sum[m])-(sum[n]-sum[r]));
            ll nx = abs((sum[r+1]-sum[m])-(sum[n]-sum[r+1]));
            if(pre > nx) r++;
            else break;
        }
        ll mn = min({sum[l],sum[m]-sum[l],sum[r]-sum[m],sum[n]-sum[r]});
        ll mx = max({sum[l],sum[m]-sum[l],sum[r]-sum[m],sum[n]-sum[r]});
        chmin(ans,mx-mn);
        m++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 2560
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args){
		solve();
	}
	public static void solve(){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a==b){
			System.out.println(c);
		}
		else if(a==c){
			System.out.println(b);
		}
		else{
			System.out.println(a);
		}
	}
}


Measured memory_bytes: 23892
#include <iostream>

using namespace std;

long long cub(int x) {
    return 1ll * x * x * x;
}

int main() {
    int N, K;
    long long s, t;

    cin >> N >> K;
    
    s = (N/K)*(N/K)*(N/K);
    t = (N+K/2)/K * (N+K/2) /K * (N+K/2) /K;
    t += s;

    if (K & 1) {
        cout << cub(N/K) << endl;
    } else {
        cout << cub( (N+K/2)/K ) + cub(N/K) << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
    int s;
    cin >> s;
    cout << s / 3600 << ':';
    s -= 3600 * (s / 3600);
    cout << s / 60 << ':';
    s -= 60 * (s / 60);
    cout << s << '\n';
}


Measured memory_bytes: 3080
#include <iostream>
#include <stdio.h>
#include <algorithm>

using namespace std;

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

    int i=0, H[N], l;
    for(int i=0 ; i < N ; i++){
        cin >> H[i];
    } 
        for(int i =0; i<N ; i++){
        //cout << H[i] << endl;
    }

    if(K >=N){
        cout << 0 << endl;
        return 0;
    }

    sort(H, H+N);
    long A = 0;
    for(int i =0; i<N-K ; i++){
        A += H[i];
    }
    cout << A << endl;

return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <cmath>
#include <cstring>

using namespace std;

const double EPS=(1e-10);
bool EQ(double a,double b){
    return abs(a-b)<EPS;
}

typedef complex<double> P;
typedef pair<double,double> pdd;

double calc(double a1,double b1,double a2,double b2,double x,double r){
    return (a2*a1*x*x*x)/3.0+(x*x*(a1*a2*r+b2*a1+a2*b1))/2.0+(a2*b1*r+b1*b2)*x;
}

int main(){
    int n;
    double r;
    while(cin>>n>>r&&!(n==0&&EQ(r,0))){
        vector<P> dots;
        vector<pdd> co;
        dots.push_back(P(-1000,0));
        for(int i=0;i<n;i++){
            double x,y;
            cin>>x>>y;
            dots.push_back(P(x,y));
        }
        dots.push_back(P(1000,0));
        double sum=0;
        n+=2;
        for(int i=1;i<n;i++){
            double a=(dots[i-1].imag()-dots[i].imag())/(dots[i-1].real()-dots[i].real());
            double b=dots[i-1].imag()-a*dots[i-1].real();
            co.push_back(pdd(a,b));
        }
        double ax=dots[1].real();
        double bx=ax+r;
        int nxtApos=n;
        int nxtBpos=n;
        // rツづ個値ツつェツづづ個凝ヲツ甘板づ可甘慊づ慊づェツづつ「ツづゥツつゥツづーツ探ツ催オ
        for(int i=0;i<n;i++){
            if(dots[i].real()>bx&&!EQ(dots[i].real(),bx)){
                nxtBpos=i;
                break;
            }
        }
        for(int i=0;i<n;i++){
            if(dots[i].real()>ax&&!EQ(dots[i].real(),ax)){
                nxtApos=i;
                break;
            }
        }
        // nxtBposツつェnツづ可づ按づゥツづ慊づ堕アツつッツづゥ
        while(nxtBpos!=n&&nxtApos!=n){
            // ツ篠淞づ個湘ェツ渉環づ鳴づ個仰猟猟」ツつェツ渉ャツつウツつ「ツづ個づ債づつソツづァツつゥ
            double adis=dots[nxtApos].real()-ax;
            double bdis=dots[nxtBpos].real()-bx;
            double dis=min(adis,bdis);
            double t=ax+dis;
            double s=ax;
            sum+=calc(co[nxtApos-1].first,co[nxtApos-1].second,co[nxtBpos-1].first,co[nxtBpos-1].second,t,r);
            sum-=calc(co[nxtApos-1].first,co[nxtApos-1].second,co[nxtBpos-1].first,co[nxtBpos-1].second,s,r);
            ax+=dis;bx+=dis;
            if(EQ(adis,bdis)){
                nxtApos++;
                nxtBpos++;
            }
            else if(adis<bdis)nxtApos++;
            else nxtBpos++;
        }
        printf("%.10f\n",sum);
    }
    return 0;
}

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

#define ll long long

int main(){
    ll H, W, ans;
    cin >> H >> W;
    if(H == 1 || W == 1) ans = 1;
    else if(H%2 != 0 && W%2 != 0)      ans = (H/2) * (W/2+1+W/2) + W/2+1;
    else if(H%2 == 0 && W%2 != 0) ans = (H/2) * (W/2+1+W/2);
    else if(H%2 != 0 && W%2 == 0) ans = (H/2) * W + W/2;
    else if(H%2 == 0 && W%2 == 0) ans = (H/2) * W;
    cout << ans << endl;
    return 0;
}

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

int main()
{
  int X, Y;
  cin >> X >> Y;
  int ans = 0;
  if (X == 1)
    ans += 300000;
  if (Y == 1)
    ans += 300000;
  if (X == 2)
    ans += 200000;
  if (Y == 2)
    ans += 200000;
  if (X == 3)
    ans += 100000;
  if (Y == 3)
    ans += 100000;
  if (X == 1 && Y == 1)
    ans += 400000;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

using namespace std;

char s[11];

int main() {
    int n, i;
    
    scanf("%s", s);
    
    n = strlen(s);
    
    if (n % 2 != 0) {
        puts("No");
        
        return 0;
    }
    
    for (i = 0; i < n; i++) {
        if (i % 2 == 0 && s[i] == 'h') continue;
        if (i % 2 == 1 && s[i] == 'i') continue;
        
        puts("No");
        
        return 0;
    }
    
    puts("Yes");
    
    return 0;
}


Measured memory_bytes: 128
a, b, k = map(int, input().split())
if a + k - 1 >= b - k + 1:
    for j in range(a, b+1):
        print(j)
else:
    for j in range(a, a+k):
        print(j)
    for j in range(b-k+1, b+1):
        print(j)


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

// Binary Indexed Tree(1-indexed)
const int MAX_N = 110000;

struct BIT {
    int bit[MAX_N + 1] = {}, n;

    void init(int n_) {
        n = n_;
    }

    int sum(int i) {
        int s = 0;
        while (i > 0) {
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }

    void add(int i, int x) {
        while (i <= n) {
            bit[i] += x;
            i += i & -i;
        }
    }
};

int N;
int a[110000], imos[110000], idx[110000];
signed main() {
    cin >> N;
    for (int i = 1; i <= N; i++)cin >> a[i];

    // 解の存在範囲を初期化
    int lb = 0, ub = 1e9 + 1;

    // 解の存在範囲が1より大きい間、繰り返す
    while (ub - lb > 1) {
        int mid = (lb + ub) / 2;
        for (int i = 1; i <= N; i++)imos[i] = a[i] >= mid ? 1 : -1;
        for (int i = 1; i <= N; i++)imos[i] += imos[i - 1];

        for (int i = 0; i <= N; i++)idx[i] = i;
        stable_sort(idx, idx + N + 1, [](int a, int b) {return imos[a] < imos[b];});

        int cur = 0;
        BIT bit;
        bit.init(N + 1);
        for (int i = 0; i <= N; i++) {
            cur += bit.sum(idx[i] + 1);
            bit.add(idx[i] + 1, 1);
        }

        if (cur * 2 >= N * (N + 1) / 2) {
            // midが条件を満たせば、解の存在範囲は[mid, ub)
            lb = mid;
        } else {
            // midが条件を満たさなければ、解の存在範囲は[lb, mid)
            ub = mid;
        }
    }

    // この時点で、lb + 1 = ubとなっている
    cout << lb << endl;
}


Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
string ans="";
// string lcsprint(int dp[][3001],int i,int j)
// {
//     if(i==0 or j==0)
//         return "";
// }
int dp[3001][3001];

int lcs(string& s,string& t,int i,int j)
{
    if(i==s.size() or j==t.size())
    {
        return 0;
    }
    if(dp[i][j]!=-1)
        return dp[i][j];
        if(s[i]==t[j])
    {
        return dp[i][j]=1+lcs(s,t,i+1,j+1);
    }
    else{
        return dp[i][j]=max(lcs(s,t,i+1,j),lcs(s,t,i,j+1));
    }
}
int main()
{
    memset(dp,-1,sizeof(dp));
	string s,t;
	cin>>s>>t;
    string a="";
    int i=0,j=0;
    int len=lcs(s,t,i,j);
    while(len>0)
    {
        if(s[i]==t[j])
        {
            a+=s[i];
            i++;
            j++;
            len--;
        }else{
            if(dp[i][j+1]>dp[i+1][j])
            {
                j++;
            }else{
                i++;
            }
        }
    }
   
    cout<<a<<endl;

}

Measured memory_bytes: 39204
S = input()

cpos = -1
# fpos = 0
ans = False

for i, si in enumerate(S):
    if si == 'C':
        cpos = i
        break

if cpos >= 0:
    fpos = -1
    for i, si in enumerate(S):
        if si == 'F':
            fpos  = i
    if fpos > cpos:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 2940
num = int(raw_input())
x = raw_input().split()
i = 0
y = []
while i < num :
	y.append(int(x[i]))
	i = i + 1
ma, mi = y[0], y[0]
i = 1
while i < num :
	if ma < y[i] :
		ma = y[i]
	if mi > y[i] :
		mi = y[i]
	i = i + 1
s = sum(y)
print u"%d %d %d" % (mi, ma, s)

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

int main(){
  int n,k,x,y=0;
  int a=0,b=0;
  cin >>n>>k;
  for(int i=0;i<n;i++){
    cin >>x;
    b=k-x;
    a=x;
    if(a<=b){
      y+=2*a;
    }
    else{
      y+=2*b;
    }
  }
  cout <<y<<endl;
}

Measured memory_bytes: 384