akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

#include <bits/stdc++.h>
using namespace std;
signed main(){
    int N; cin>>N;
    vec a(N);
    REP(i,N) cin>>a[i];
    vec B;
    REP(i,N){
        if((N-i)%2==0) B.push_back(a[N-1-i]);
    }
    for(int i=0; i<N; i+=2){
        B.push_back(a[i]);
    }
    if(N%2==0){
        REP(i,N) cout<<B[i]<<" ";
    }
    else REP(i,N) cout<<B[N-1-i]<<" ";
    cout<<endl;
}


Measured memory_bytes: 5488
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i]
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
const int maxN = 1000001;
int isSubstring(string s1, string s2) { 
    int M = len(s1); 
    int N = len(s2); 
    for (int i = 0; i <= N - M; i++) { 
        int j; 
        for (j = 0; j < M; j++){
            if (s2[i + j] != s1[j]){
                break; 
            }
        }
        if (j == M){
            return 1; 
        }
    } 
    return 0; 
} 
int32_t main(){
    SPEED;
    int x;
    cin >> x;
    if(x == 0) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int N; cin >> N;

	bool ok = false;
	while(N > 0){
		if (N % 10 == 9){
			ok |= true;
			break;
		} // end if
		N /= 10;
	} // end while

	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
s = list(input())
now_1 = "0"
cnt_1 = 0
for i in range(len(s)):
    if s[i] != now_1:
        cnt_1 += 1
    if now_1 == "0":
        now_1 = "1"
    else:
        now_1 = "0"
now_2 = "1"
cnt_2 = 0
for i in range(len(s)):
    if s[i] != now_2:
        cnt_2 += 1
    if now_2 == "0":
        now_2 = "1"
    else:
        now_2 = "0"
print(min(cnt_1,cnt_2))

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

#define maxn 100002
#define FOR(i, l, r) for (int i=l; i<=r; ++i)
#define FORD(i, r, l) for (int i=r; i>=l; --i)
#define REP(i, r) for (int i=0; i<(int)r; ++i)
#define REPD(i, r) for (int i=(int)r-1; i>=0; --i)
#define fi first
#define se second
#define mk make_pair
#define nil NULL
#define y0 __y0
#define y1 __y1
#define x0 __x0
#define x1 __x1
#define next __next
#define sz size
#define Debug(X) {cerr << #X << " = " << X << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}
typedef long long ll;
typedef double db;
typedef pair<db, db> dd;
typedef pair<int, int> ii;
typedef vector<int> vi;
const int inf = 1e9;
template<class T> int getbit(T x, int pos) {return (x>>(pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1<<(pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1<<(pos-1));}
template<class T> T sqr(T a) {return a*a;}

struct person {
    int gold, silver, bronze;
} a[maxn];
int x, y, z;
ll ps_x[maxn], ps_y[maxn], MAX_x[maxn], MAX_y[maxn];
priority_queue<int> pq;

bool cmp(person a, person b) {
    return a.gold-a.silver>b.gold-b.silver;
}

int main() {
    //freopen("coins.inp", "r", stdin);
    //freopen(".out", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> x >> y >> z;
    FOR(i, 1, x+y+z) cin >> a[i].gold >> a[i].silver >> a[i].bronze;
    sort(a+1, a+x+y+z+1, cmp);
    FOR(i, 1, x+y+z) ps_x[i] = ps_x[i-1] + a[i].gold;
    FORD(i, x+y+z, 1) ps_y[i] = ps_y[i+1] + a[i].silver;
    FOR(i, 1, x+y+z) {
        pq.push(-a[i].gold+a[i].bronze);
        if (i>x) {
            MAX_x[i] = MAX_x[i-1] + pq.top();
            pq.pop();
        }
    }
    while (pq.sz()) pq.pop();
    FORD(i, x+y+z, 1) {
        pq.push(-a[i].silver+a[i].bronze);
        if (i<=x+z) {
            MAX_y[i] = MAX_y[i+1] + pq.top();
            pq.pop();
        }
    }
    ll res = 0;
    FOR(i, x, x+z) {
        res = max(res, ps_x[i]+MAX_x[i]+ps_y[i+1]+MAX_y[i+1]);
    }
    cout << res;
}


Measured memory_bytes: 4480
//Carry a Cheese
#include<bits/stdc++.h>
using namespace std;

int main(){
  int l1, l2, l3;
  while(true){
    cin>>l1>>l2>>l3;
    int l11=l1*l1, l22=l2*l2, l33=l3*l3;
    if(l1==0 && l2==0 && l3==0)break;
    int min_l=min(min(l11+l22, l22+l33), l33+l11);
    int n;
    cin>>n;
    while(n--){
      int r;
      cin>>r;
      if(min_l<r*r*4)cout<<"OK"<<endl;
      else cout<<"NA"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

using namespace std;

int main()
{

    char x;

    cin >> x;
    cout << ++x;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
int main() {
  int X, Y, A, B, C;
  cin >> X >> Y >> A >> B >> C;
  vector<ll> P(A), Q(B), R(C);
  rep(i, A) cin >> P[i];
  rep(i, B) cin >> Q[i];
  rep(i, C) cin >> R[i];
  priority_queue<pair<ll, int> > S;
  rep(i, B) S.push(make_pair(Q[i], 0));
  rep(i, C) S.push(make_pair(R[i], 1));
  vector<ll> ret(B+C+1);
  int cnt = 0, cntQ = 0;
  while(!S.empty()) {
    auto top = S.top();
    S.pop();
    if(top.second == 0) {
      cntQ++;
      if(cntQ > Y) continue;
    }
    cnt++;
    ret[cnt] = ret[cnt-1] + top.first;
  }
  sort(all(P), greater<ll>());
  vector<ll> Ps(A+1);
  rep(i, A) Ps[i+1] = Ps[i] + P[i];
  ll ans = 0;
  rep(i, min(A+1, X+1)) {
    if(X+Y-i < B+C+1) ans = max(Ps[i] + ret[X+Y-i], ans);
  }
  cout << ans << endl;
  return 0;
}


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

int a, b, k;

int main ()
{
	cin >> a >> b >> k;
	for (int i = a; i <= min (a + k - 1, b); ++i)
		cout << i << endl;
	for (int j = max (a + k - 1 + 1, b - k + 1); j <= b; ++j)
		cout << j << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

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

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int b[n];
    
    for(int i=0;i<n-1;++i)
    {
        cin >> b[i];
    }

    int ret = b[0] + b[n-2]; // for a[0] and a[n-1]
    for(int i=1;i<n-1;++i)
    {
        ret += min(b[i], b[i-1]);
    }

    cout << ret << endl;
}

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

int main(){
    int w,a,b;
    cin >> w >> a >> b;
    int L = min(a,b);
    int R = max(a,b);
    int r = L + w;
    if (r>R){
        cout << 0 << endl;
        return 0;
    }
    else{
        cout << R-r << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	ll ans = 0;
	int maxValue = 0;
	rep(i,n){
		cin>>a[i];
		ans += a[i];
		maxValue = max(maxValue,a[i]);
	}
	ans -= (maxValue/2);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3168
#include<iostream>
using namespace std;
int main()
{
         int a,b,c;
         cin >> a >> b >>c ;
       int a1 ,a2  ,b2 ;
a1=a+b ,a2=a+c  ,b2=b+c  ;
       if  (a1<=a2 and a1<=b2)
        cout << a1;
       else if(a2 <=a1 and a2<=b2)
       cout << a2;
       else cout << b2;

    return 0;
}

Measured memory_bytes: 760
S = input()
S1 = S[:(len(S) - 1) // 2:]
S2 = S[(len(S) + 3) // 2 - 1:]

ans = 'Yes'
for i in range(len(S) // 2 + 1):
    if S[i] != S[-i - 1]:
        ans = 'No'
        print(ans)
        exit()

for i in range((len(S1) // 2) + 1):
    if S1[i] != S1[-i - 1]:
        ans = 'No'
        print(ans)
        exit()

for i in range(len(S2) // 2 + 1):
    if S2[i] != S2[-i - 1]:
        ans = 'No'
        print(ans)
        exit()

print(ans)

Measured memory_bytes: 3064
//https://atcoder.jp/contests/abc166/tasks/abc166_c
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<static_cast<ll>(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}

template< typename T >
struct edge {
  int src, to;
  T cost;
  edge(int _to, T _cost) : src(-1), to(_to), cost(_cost) {}
  edge(int _src, int _to, T _cost) : src(_src), to(_to), cost(_cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};

template< typename T>
struct node {
  vector<edge<T>> edges;
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WeightedGraph = vector< node< T > >;
using UnWeightedGraph = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;

int main() {
  ll N,M; cin>>N>>M;
  vector<ll> hn(N+1);
  FOR(i,1,N+1){
    cin>>hn.at(i);
  }
  WeightedGraph<ll> graph(N+1);
  FOR(i,1,M+1){
    ll A,B; cin>>A>>B;
    graph.at(A).edges.emplace_back(B,1);
    graph.at(B).edges.emplace_back(A,1);
  }

  ll ans=0;
  FOR(i,1,N+1){
    bool check=true;
    auto& n=graph.at(i);
    ll ch=hn.at(i);
    for(auto& e:n.edges){
      auto eh=hn.at(e.to);
      if(ch>eh){
      }else{
        check=false;
        break;
      }
    }
    if(check) ++ans;
  }
  cout<<ans<<endl;

  return 0;
}

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

int main()
{

 ll k,j=0,sum=1;
 cin>>k;
 for(ll i=k;i>=1;i=i/2)
 {
     
    sum=sum+j;
    if(i==k)
    {
        j=1;
       
    }
 j=j*2;
 }
 cout<<sum;
 
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<ll,ll>;
//const int 1001001001;
const int NMAX=8;
const ll MOD=1000000007;
const int dbase=80*160;

template<typename T>
struct BIT {
  int n;
  vector<T> d;
  BIT(int n=0):n(n),d(n+1) {}
    //末尾の要素(i&-i)をたす→一つ上の階層なので、要素の更新の時に使える
  void add(int i, T x=1) {
    for (i++; i <= n; i += i&-i) {
      d[i] += x;
    }
  }
     //末尾の要素(i&-i)を引く→一つ上の一つ左の階層なので、要素の総和をとる時に使える
  T Sum(int i) {
    T x = 0;
    for (i++; i; i -= i&-i) {
      x += d[i];
    }
    return x;
  }
	T sum(int l, int r) {
    return Sum(r-1) - Sum(l-1);
  }
};

vector<vector<ll>> to(200005);
vector<ll> in(200005);
vector<ll> out(200005);
vector<vector<ll>> C(200005);

ll cnt=0;
ll c2(ll n) { return n*(n+1)/2;}

void dfs (ll x, ll p){
	in[x]=cnt++;
	for(int v:to[x]){
		if (v==p)continue;
		dfs(v,x);
	}
	out[x]=cnt;
}

int main(){
	ll n;
	vector<ll> c(200005);

	cin>>n;

	rep(i,n)cin>>c[i];

	rep(i,n-1){
		int a1,b1;
		cin>>a1>>b1;
		a1--;b1--;
		to[a1].push_back(b1);
		to[b1].push_back(a1);
	}

	dfs(0,-1);

	rep(i,n){
		C[c[i]-1].push_back(i);
	}
	//rep(i,n)cout<<in[i]<<endl;
	ll tot=n*(n+1)/2;
	BIT <ll> bi(n);
	rep(i,n)bi.add(i,1);



	rep(cnow,n){
		//各色ごとに答え
		vector<ll>& col=C[cnow];
		sort(col.begin(),col.end(), [&](ll a, ll b){
			return in[a]>in[b];
		});
		ll ans=tot;
vector<P> changed;

		for(ll i:col){
			ll cnt=1;

			for(ll v:to[i]){
	//			cout<<v<<'v'<<i<<'i'<<endl;
				if (in[v]<in[i])continue;
			ll temp=bi.sum(in[v],out[v]);
		//	cout<<temp<<'t'<<endl;
			ans-=temp*(temp+1)/2;
		//	cout<<ans<<'a'<<endl;
			cnt+=temp;
		  }
		//	cout<<cnt<<"cnt"<<endl;
			bi.add(in[i],-cnt);
			changed.push_back(make_pair(in[i],cnt));
		}
		ll adn=bi.Sum(n-1);
	//	cout<<adn<<"adn"<<endl;
		ans-=c2(adn);
		cout<<ans<<endl;

	//	cout<<"bef"<<endl;
		for (auto p:changed){
			bi.add(p.first,p.second);
		}


	}



return 0;
}


Measured memory_bytes: 39112
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long int
#define F first
#define S second
#define pb push_back

using namespace std;
using namespace __gnu_pbds;

typedef tree<ll, null_type, less<ll>, rb_tree_tag, 
tree_order_statistics_node_update> 
new_data_set; 

const ll N=10005;
ll a[N];

int main()
{
    // ios_base:: sync_with_stdio(false);
    // cin.tie(NULL); cout.tie(NULL);
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    // ll t;
    // cin>>t;
    // while(t--)
    {
        ll i,j,k,n,m,ans=0,cnt=0,sum=0;  
        cin>>n;
        a[1]=1;
        for(i=2;i<N;i++){
            ll x=i*i;
            while(x<N){
                a[x]=x;
                x*=i;
            }
        }
        for(i=1;i<N;i++){
            if(a[i]<a[i-1]){
                a[i]=a[i-1];
            }
        }
        cout<<a[n];
    }
}

Measured memory_bytes: 384
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int h = sc.nextInt();
      int w = sc.nextInt();
      String[] str = new String[h];
      for(int i = 0;i < h;i++){
      	str[i] = sc.next();
        System.out.println(str[i]);
        System.out.println(str[i]);
      }
    }
}

Measured memory_bytes: 22100
#include<iostream>
#include<bitset>
using namespace std;
int const MAXN=1e4+9;
int r;
int c;
bitset<MAXN> cookie[10];

int main()
{
	while(cin>>r>>c&&r&&c)
	{
		for(int i=0;i<r;i++)
			for(int j=0;j<c;j++)
			{
				bool flag;
				cin>>flag;
				//bitset没有重载>> 
				cookie[i][j]=flag;
			}
		int perm=1<<r;
		int res=0;
		for(int i=0;i<perm;i++)
		{
			for(int j=0;j<r;j++)
				if(i&(1<<j))
					cookie[j].flip();
			int t_res=0;
			for(int j=0;j<c;j++)
			{
				int sum=0;
				for(int k=0;k<r;k++)
					if(cookie[k][j])
						sum++;
				t_res+=max(sum,r-sum);	
			}
			res=max(res,t_res);
			for(int j=0;j<r;j++)
				if(i&(1<<j))
					cookie[j].flip();
		}
		cout<<res<<endl;
	}
	return 0;
}


Measured memory_bytes: 3056
from itertools import combinations

def add_combination(S, cmb):
	new_S = ''
	
	for i in range(len(S)):
		new_S += S[i]
		if i in cmb:
			new_S += '+'
	
	return eval(new_S)
	
S = input()
sum_S = int(S)

for i in range(1, len(S)):
	for cmb in combinations(range(len(S)-1), i):
		sum_S += add_combination(S, cmb)

print(sum_S)

Measured memory_bytes: 3064
import java.util.*;

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

        for (int a=0;a<=N;a++){
            for(int b=0;b<=N-a;b++){
                int c = N-a-b;
                int total = a*10000 + b*5000 + c*1000;
                if(total == Y){
                    System.out.println(a+" "+b+" "+c);
                    return;
                }
            }
        }

        System.out.println("-1 -1 -1");
    }
}

Measured memory_bytes: 23380
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
int main()
{
    int N, moto;
    std::cin >> N >> moto;
    std::vector<int> costs(N);
    for( auto& e: costs ) std::cin >> e;
    std::cout << N + (moto - std::accumulate( begin(costs), end(costs), 0)) / *std::min_element( begin(costs), end(costs)) << std::endl;
}

Measured memory_bytes: 256
A, B, C = map(int, input("").split(" "))

if (A+B) >= C:
    # print("a")
    print(C+B)
elif C>(A+B):
    if C==A+B:
        # print("b")
        print(A+B+B)
    elif C>A+B:
        # print("d")
        print(A+B+B+1)
    else:
        # print("c")
        print(C+A)




Measured memory_bytes: 2940
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

struct edge{
  int to,cost;
};

int A,B,C,N = 0,W,H,ans,dp[HMAX][WMAX];
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};
bool check(int i){
	if(i%2){
		return false;
	}
	for (int j = 0; j < i/2; ++j)
	{
		if(S[j] != S[j+i/2]){
			return false;
		}
	}
	return true;
}

void solve(){
	for (int i = 1; i < S.size(); ++i)
	{
		if(check(S.size()-i)){
			ans = S.size()-i;
			return;
		}
	}
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> S;
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n;
  cin >> n;
  set<string> st;
  REP(i, n) {
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << SZ(st) << endl;
}

Measured memory_bytes: 19224
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;

public class Main {
    private static final StringBuilder builder = new StringBuilder();
    public static void main(String[] args) {
        read();
        String s = builder.toString();
        if (s.equalsIgnoreCase("RRR")) {
            System.out.print(3);
            return;
        }

        if (s.contains("RR")) {
            System.out.print(2);
            return;
        }

        if (s.contains("R")) {
            System.out.print(1);
            return;
        }

        System.out.print(0);
    }

    private static void read() {
        builder.setLength(0);
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) {
                    break;
                } else {
                    builder.appendCodePoint(b);
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static int readInt() {
        read();
        return Integer.parseInt(builder.toString());
    }

    private static int readInt(int radix) {
        read();
        return Integer.parseInt(builder.toString(), radix);
    }

    private static long readLong() {
        read();
        return Long.parseLong(builder.toString());
    }

    private static long readLong(int radix) {
        read();
        return Long.parseLong(builder.toString(), radix);
    }

    private static BigInteger readBigInteger() {
        read();
        return new BigInteger(builder.toString());
    }

    private static BigInteger readBigInteger(int radix) {
        read();
        return new BigInteger(builder.toString(), radix);
    }

    private static double readDouble() {
        read();
        return Double.parseDouble(builder.toString());
    }

    private static BigDecimal readBigDecimal() {
        read();
        return new BigDecimal(builder.toString());
    }

    private static float readFloat() {
        read();
        return Float.parseFloat(builder.toString());
    }

    private static void skipLine() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == '\n' || b == -1) {
                    break;
                }
            } catch (IOException e) {
                break;
            }
        }
    }

    private static void skip() {
        while (true) {
            try {
                int b = System.in.read();
                if (b == ' ' || b == '\n' || b == -1) break;
            } catch (IOException e) {
                break;
            }
        }
    }

}


Measured memory_bytes: 32332
#include<bits/stdc++.h>
#define read() Read<int>()
namespace pb_ds{   
    namespace io{
        const int MaxBuff=1<<15;
        const int Output=1<<23;
        char B[MaxBuff],*S=B,*T=B;
		#define getc() ((S==T)&&(T=(S=B)+fread(B,1,MaxBuff,stdin),S==T)?0:*S++)
        char Out[Output],*iter=Out;
        inline void flush(){
            fwrite(Out,1,iter-Out,stdout);
            iter=Out;
        }
    }
    template<class Type> inline Type Read(){
        using namespace io;
        register char ch;
        register Type ans=0; 
        register bool neg=0;
        while(ch=getc(),(ch<'0' || ch>'9') && ch!='-');
        ch=='-'?neg=1:ans=ch-'0';
        while(ch=getc(),'0'<= ch && ch<='9') ans=ans*10+ch-'0';
        return neg?-ans:ans;
    }
    template<class Type> inline void Print(register Type x,register char ch='\n'){
        using namespace io;
        if(!x) *iter++='0';
        else{
            if(x<0) *iter++='-',x=-x;
            static int s[100]; 
            register int t=0;
            while(x) s[++t]=x%10,x/=10;
            while(t) *iter++='0'+s[t--];
        }
        *iter++=ch;
    }
}
using namespace pb_ds;
using namespace std;
typedef long long ll;
const int N=5e5+5;
const int Mod=998244353;
int n,m,ans;
int fac[N],inv[N];
inline int Pow(int x,int y){
	int res=1;
	while (y){
		if (y&1) res=1ll*res*x%Mod;
		x=1ll*x*x%Mod;
		y>>=1;
	}
	return res;
}
inline void math_init(int nn){
	fac[0]=1;
	for (int i=1;i<=nn;++i)
		fac[i]=1ll*fac[i-1]*i%Mod;
	inv[nn]=Pow(fac[nn],Mod-2);
	for (int i=nn;i;--i)
		inv[i-1]=1ll*inv[i]*i%Mod;
}
inline int C(int x,int y){
	if (x<y || x<0 || y<0) return 0;
	return 1ll*(1ll*fac[x]*inv[y]%Mod)*inv[x-y]%Mod;
}
inline void ad(int &x,int y){
	x+=y;
	if (x>=Mod) x-=Mod;
	if (x<0) x+=Mod;
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	n=read(),m=read();
	math_init(max(n,m));
	for (int i=0;i<=n && i<=m;++i){
		int now=1ll*C(n,i)*C(m,i)%Mod;
		now=1ll*now*fac[i]%Mod;
		now=1ll*now*Pow(m+1,n-i)%Mod;
		now=1ll*now*Pow(n+1,m-i)%Mod;
		if (i&1) ad(ans,Mod-now);
		else ad(ans,now);
	}
	printf("%d\n",ans);
	return 0;
}

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

bool valid(int r,int c,int cr,int cc)
{
    if(cr<0 || cr>=r || cc<0 || cc>=c)
        return 0;
    return 1;
}
int main() {
	// your code goes here
	int r,c;
	cin>>r>>c;
	//char a[r][c];
	int grid[r][c];
	char a[r][c];
	for(int i=0;i<r;i++)
	{
	    for(int j=0;j<c;j++)
	    {
	        cin>>a[i][j];
	        grid[i][j] = 0; 
	    }
	    
	}
	grid[0][0] = 1;
	for(int i=0;i<r;i++)
	{
	    for(int j=0;j<c;j++)
	    {
	        //check up
	        if(a[i][j] == '#')
	            continue;
	            
	        if(valid(r,c,i-1,j) == 1)
	        {
	            if(a[i-1][j] == '.')
	            {
	                grid[i][j] =(grid[i][j] +  grid[i-1][j])%1000000007;
	            }
	        }
	        
	        //check left
	        if(valid(r,c,i,j-1)==1)
	        {
	            if(a[i][j-1] == '.')
	            {
	                grid[i][j] =(grid[i][j] +  grid[i][j-1])%1000000007;
	            }
	        }
	    }
	    
	}

	cout<<grid[r-1][c-1];
	    
	
	return 0;
}


Measured memory_bytes: 5120
#include<iostream>
#include<string>
#include<sstream>
using namespace std;

class Stack{
	private:
		int sp;
		int S[100];
	public:
		Stack(){
			sp=0;
		}
		bool isFull() const{
			return (sp==100);
		}
		bool isEmpty() const{
			return (sp==0);
		}
		void push(int d);
		int top();
		void pop();
};

void Stack::push(int d){
	if(isFull()){
		return;
	}
	S[sp++]=d;
}

int Stack::top(){
	if(isEmpty()){
		return -1;
	}
	return S[sp-1];
}

void Stack::pop(){
	if(isEmpty()){
		return;
	}
	sp--;
}


int main(){
	Stack s;
	string expr;
	getline(cin,expr);
	istringstream is(expr);
	while(!is.eof()){
		string op;
		is>>op;
		int tmp1,tmp2;
		switch(op[0]){
			case '+':
				tmp1=s.top();
				s.pop();
				tmp2=s.top();
				s.pop();
				s.push(tmp2+tmp1);
				break;
			case '-':
				tmp1=s.top();
				s.pop();
				tmp2=s.top();
				s.pop();
				s.push(tmp2-tmp1);
				break;
			case '*':
				tmp1=s.top();
				s.pop();
				tmp2=s.top();
				s.pop();
				s.push(tmp2*tmp1);
				break;
			default:
				istringstream is2(op);
				is2>>tmp1;
				s.push(tmp1);
				break;
		}
	}
	cout<<s.top()<<endl;
	
	return 0;
}

Measured memory_bytes: 3212
def f(x, y):
  return (x + y) / 2

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=False)

while True:
  if len(A) == 1:
    break
  A[0] = f(A[0], A[1])
  del A[1]

print(A[0])

Measured memory_bytes: 3060
#include<iostream>
#include<vector>>
#include<string>
#include<algorithm>
#include<queue>
#include<map>

using namespace std;
int main() {
	int N, T;
	vector<int>As;
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		int temp;
		cin >> temp;
		As.push_back(temp);
	}

	int min = As[0];
	int diff_max = 0;
	int diff_n = 0;
	for (int i = 1; i < As.size(); i++) {
		//最小値の確認
		if (As[i] - min > diff_max) {
			diff_max = As[i] - min;
			diff_n = 1;
		}
		else if (As[i] - min == diff_max) {
			diff_n++;
		}
		//最小値の更新
		if (min > As[i])
			min = As[i];

	}

	cout << diff_n << endl;
	return 0;
}

Measured memory_bytes: 892
MAX = 10 ** 18

n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)

if a[-1] == 0:
  print(0)
else:
  ans = 1
  for i in range(n):
    if ans > MAX: break
    ans *= a[i]

  if ans > MAX:
    print(-1)
  else:
    print(ans)


Measured memory_bytes: 21640
#include<stdio.h>
#include<string.h>
char map[51][51];
int next[4][2]={0,1,1,0,0,-1,-1,0},book[51][51],h,w,head,tail,flag;
struct aa
{
    int x,y;
    int step;
}que[2501];
int main()
{
    int i,j,sum=0;
    head=1;
    tail=1;
    que[head].x=1;
    que[head].y=1;
    que[head].step=0;
    tail++;
    book[1][1]=1;
    void bfs(int x,int y);
    scanf("%d%d",&h,&w);
    for(i=1;i<=h;i++)
    {
        getchar();
        for(j=1;j<=w;j++)
        {
            scanf("%c",&map[i][j]);
            if(map[i][j]=='.')
                sum++;
        }
    }
    sum-=1;
    bfs(1,1);
    if(flag==0)
        printf("-1\n");
    else
        printf("%d\n",sum-que[tail-1].step);
    return 0;
}
void bfs(int x,int y)
{
    int i,tx,ty;
    while(head<tail)
    {
        for(i=0;i<4;i++)
        {
            tx=que[head].x+next[i][0];
            ty=que[head].y+next[i][1];
            if(tx<1||tx>h||ty<1||ty>w)
                continue;
            if(map[tx][ty]=='.'&&book[tx][ty]==0)
            {
                que[tail].x=tx;
                que[tail].y=ty;
                que[tail].step=que[head].step+1;
                tail++;
                book[tx][ty]=1;
            }
            if(tx==h&&ty==w)
            {
                flag=1;
                break;
            }
        }
        if(flag==1)
            break;
        head++;
    }
    return;
}


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

int main(){
  int a[2]; cin >> a[0] >> a[1];
  int b[2]; cin >> b[0] >> b[1];
  int v[2];
  int c[2];
  int d[2];
  v[0] = b[0]-a[0];
  v[1] = b[1]-a[1];
  c[0] = b[0]-v[1];
  c[1] = b[1]+v[0];
  d[0] = a[0]-v[1];
  d[1] = a[1]+v[0];
  cout << c[0] << " " << c[1] <<" " <<d[0]<< " " << d[1] << endl;
  
}

Measured memory_bytes: 256
// Created by Nikolay Budin

#ifdef LOCAL
#  define _GLIBCXX_DEBUG
#else
#  define cerr __get_ce
#endif
#include <bits/stdc++.h>
#define ff first
#define ss second
#define szof(x) ((int)x.size())

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef unsigned long long ull;
int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;
#ifdef LOCAL
	mt19937 tw(9450189);
#else
	mt19937 tw(chrono::high_resolution_clock::now().time_since_epoch().count());
#endif
uniform_int_distribution<ll> ll_distr;
ll rnd(ll a, ll b) { return ll_distr(tw) % (b - a + 1) + a; }


void solve() {
	int h, w;
	cin >> h >> w;
	int n;
	cin >> n;
	int sx, sy;
	cin >> sx >> sy;
	--sx; --sy;
	string s, t;
	cin >> s >> t;
	int lx = 0, rx = h, ly = 0, ry = w;
	for (int i = n - 1; i >= 0; --i) {
		if (t[i] == 'L') {
			ry = min(ry + 1, w);
		} else if (t[i] == 'R') {
			ly = max(ly - 1, 0);
		} else if (t[i] == 'U') {
			rx = min(rx + 1, h);
		} else {
			lx = max(lx - 1, 0);
		}

		if (s[i] == 'L') {
			ly++;
		} else if (s[i] == 'R') {
			ry--;
		} else if (s[i] == 'U') {
			lx++;
		} else {
			rx--;
		}

		if (ly >= ry || lx >= rx) {
			cout << "NO\n";
			return;
		}
	}

	if (lx <= sx && sx < rx && ly <= sy && sy < ry) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}
}


int main() {
#ifdef LOCAL
	auto start_time = clock();
	cerr << setprecision(3) << fixed;
#endif
	cout << setprecision(15) << fixed;
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	int test_count = 1;
	// cin >> test_count;
	for (int test = 1; test <= test_count; ++test) {
		solve();
	}
	
#ifdef LOCAL
	auto end_time = clock();
	cerr << "Execution time: " << (end_time - start_time) * (int)1e3 / CLOCKS_PER_SEC << " ms\n";
#endif
}


Measured memory_bytes: 920
# Code for C - Many Requirements
# Use input() to fetch data from STDIN
[n, m, q] = map(int, input().split())
a = [0 for x in range(q)]
b = [0 for x in range(q)]
c = [0 for x in range(q)]
d = [0 for x in range(q)]

for i in range(q):
    s = [int(x) for x in input().split()]
    [a[i], b[i], c[i], d[i]] = s

max_score = 0
def g(A, depth):
    global max_score
    if depth == 0:
        score = 0
        for i in range(q):
            if A[b[i] - 1] - A[a[i] - 1] == c[i]:
                score += d[i]
        if score > max_score:
            max_score = score
        return

    if len(A) == 0:
        for i in range(1, m + 1):
            g([i], depth - 1)
            return

    for i in range(A[-1], m + 1):
        g(A + [i], depth - 1)

g([], n)

print(max_score)


Measured memory_bytes: 9252
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int p = sc.nextInt();
		int a =1000;
		int i=2;
		while(a<p) {
			a=1000*i;
			i++;
		}
		System.out.println(a-p);

	}

}





Measured memory_bytes: 35924
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <set>

using namespace std;

int main() {
    int x, t;
    cin >> x >> t;
    cout << max(0, x - t) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;


public class Main {
	public static void main(String[] args)  throws IOException
	{
	    BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
	    int N = Integer.parseInt(buf.readLine());
	    String[] list;
	    String[] check = new String[N];
	    int i,j,l;
	    for(int k=0; k<N; k++){
	        list = buf.readLine().split(" ");
	        i = Integer.parseInt(list[0]);
	        j = Integer.parseInt(list[1]);
	        l = Integer.parseInt(list[2]);
	        check[k] = Check(i,j,l);
	    }
	    for(int k = 0; k<N; k++){
	    	System.out.println(check[k]);
	    }
	    
	}
	
	public static String Check(int a,int b,int c){
		if(a-b >0 && a-c>0){
			if(a*a == b*b + c*c){
				return"YES";
			}else{
				return "NO";
			}
		}else if(b-a >0 && b-c>0){
			if(b*b == a*a + c*c){
				return "YES";
			}else{
				return "NO";
			}
		}else{
			if(c*c == b*b + a*a){
				return "YES";
			}else{
				return "NO";
			}
		}
	}
		
}

Measured memory_bytes: 20168
console.log((args=>{
  const X = args.trim();
  const L = X.length;
  let s = 0, t = 0;
  for ( let i = 0; i < L; i++ ) {
    if ( X[i] === 'S' ) s++;
    if ( X[i] === 'T' ) {
      if ( s > 0 ) s--;
      else t++;
    }
  }
  return `${s+t}`;
})(require('fs').readFileSync('/dev/stdin','utf8')));


Measured memory_bytes: 32456
#include<iostream>

using namespace std;

int main(){
    int N,*a,flag=0;
    cin >> N;
    a = new int[N];
    for(int i=0;i<N;i++) cin >> a[i];
    for(int i=0;i<N;i++){
        if(a[i] % 2 == 0){
            if(a[i] % 3 != 0 && a[i] % 5 != 0){
                flag++;
            }
        }
    }
    if(flag > 0) cout << "DENIED" << endl;
    else cout << "APPROVED" << endl;
}

Measured memory_bytes: 888
#include <iostream>

using namespace std;

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

    int r = 0;
    for (int i = 0; i < n; i++) {
        int l, t;
        cin >> l >> t;
        r += (t - l + 1);
    }
    cout << r << endl;
}

Measured memory_bytes: 256
/*
[arc097] E - Sorted and Sorted
*/

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 2000;
const int INF = 1e8;

int N;
int c[2 * MAX_N], a[2 * MAX_N];
int dp[MAX_N + 1][MAX_N + 1];
int pos[2][MAX_N];
int cost[2][MAX_N][MAX_N + 1];

int solve() {
    for (int i = 0; i < 2 * N; i++) {
        pos[c[i]][a[i]] = i;
    }

    for (int wb = 0; wb < 2; wb++) {
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                if (pos[wb][i] > pos[wb][j]) {
                    cost[wb][i][N]++;
                }
            }
            for (int j = N - 1; j >= 0; j--) {
                cost[wb][i][j] =
                    cost[wb][i][j + 1] + (pos[wb ^ 1][j] < pos[wb][i]);
            }
        }
    }

    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            dp[i][j] = INF;
        }
    }

    dp[0][0] = 0;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N; j++) {
            if (i < N) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cost[0][i][j]);
            }
            if (j < N) {
                dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + cost[1][j][i]);
            }
        }
    }

    return dp[N][N];
}

int main() {
    cin >> N;
    for (int i = 0; i < 2 * N; i++) {
        char raw_c;
        cin >> raw_c >> a[i];
        c[i] = (raw_c == 'W' ? 0 : 1);
        a[i]--;
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 47232
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

typedef pair< int, int > pii;
typedef long long ll;

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	double N, M, D;
	cin >> N >> M >> D;
	double ans = (2 * N - 2 * D) / N / N * (M - 1);
	if (D == 0)
		ans *= 0.5;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// #pragma GCC optimize ("Ofast")
using namespace std;

#define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (st                                  derr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef map<pii, int> mpii;
typedef set<int> sti;
const int INF = 1e9, MOD = INF + 7 /* INF - 1755647 */;
int gcd(int a, int b) { return (b ? gcd(b, a % b) : a); }
int power(int a, int b) { return (!b ? 1 : power(a, b / 2) * power(a, b / 2) * (b % 2 ? a : 1)); }

/////////////////////////////////////////////////////////////////////

const int N = 1e4 + 20, M = 2e1 + 2;

vi v;
int a[] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
bool dp[N][N];

int32_t main() {

    sync;
    
    int n, m; cin >> n >> m;
    for(int i = 0; i < m; i++) {
        int x; cin >> x;
        v.push_back(x);
    }

    sort(all(v));
    reverse(all(v));

    dp[0][0] = true;
    for(int i = 1; i <= n / 2; i++) for(int j = 1; j <= n; j++) for(int k : v) if (j >= a[k]) dp[i][j] |= dp[i - 1][j - a[k]];

    int mx = 0;
    for(int i = 1; i <= n / 2; i++) if (dp[i][n]) mx = i;
   
    vi ans;
    for(int i = 1; i <= mx; i++) for(int k : v) if (a[k] <= n && dp[mx - i][n - a[k]]) {
        n -= a[k];
        ans.push_back(k);
        break;
    }

    for(int k : ans) cout << k;
    cout << endl;

    return 0;
}


Measured memory_bytes: 49536
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	double a, b, h, m;
	cin >> a >> b >> h >> m;
	double gosa  = (m/60.0)*30.0;
	double kakudo = (double)abs(30*h+gosa - 6*m);
	double sita = (kakudo / 180.000)*PI;
	double ans = sqrt(a*a+b*b-2*a*b*cos(sita));
	cout << fixed << setprecision(15) << ans << endl;
	return 0;
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

vector<li> res[100100];
li rest[100100];

int main() {
    li n;
    cin >> n;
    li m = -1;
    repp(i, 1, n + 2) {
        if (i * (i - 1) == n * 2) {
            m = i;
            break;
        } else if (i * (i - 1) > n * 2) {
            break;
        }
    }
    if (m < 0) {
        puts("No");
        return 0;
    }
    puts("Yes");
    cout << m << endl;
    li num = m - 1;
    li frontier = 0;
    rep(i, m) {
        rest[i] = INF;
        rep(j, i) {
            res[i].pb(rest[j]);
            rest[j]++;
        }
        rep(j, num - i) {
            rest[i] = min(rest[i], frontier);
            res[i].pb(frontier);
            frontier++;
        }
    }

    rep(i, m) {
        cout << sz(res[i]) << " ";
        rep(j, sz(res[i])) {
            cout << res[i][j] + 1;
            if (j < sz(res[i]) - 1)cout << " ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 5504
#include <iostream>

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 5000;
int const inf = 1000000000;

int v[5 + nmax];
ll dp[5 + nmax];

int main() {
  int n, a, b;
  std::cin >> n >> a >> b;
  for(int i = 1; i <= n; i++)
    std::cin >> v[i];
  v[n + 1] = n + 1;
  for(int i = 1; i <= n + 1; i++) {
    int smax = -1, bigger = 0;
    dp[i] = 1LL * nmax * inf;
    for(int j = i - 1; 0 <= j; j--) {
      if(v[j] < v[i] && smax < v[j]) { 
        dp[i] = std::min(dp[i], dp[j] + 1LL * bigger * a + 1LL * (i - j - 1 - bigger) * b);
      }
      if(v[j] < v[i])
        smax = std::max(smax, v[j]);
      else
        bigger++;
    }
  }
  std::cout << dp[n + 1];
  return 0;
}


Measured memory_bytes: 3712