akhauriyash/Code-Regression huggingface dataset:
unittest
{
	assert( [ "3", "1 2", "2 3", "1", "1 3" ].parse.expand.solve == 3 );
	assert( [ "2", "1 2", "1", "1 2" ].parse.expand.solve == 1 );
	assert( [ "5", "1 2", "3 2", "3 4", "5 3", "3", "1 3", "2 4", "2 5" ].parse.expand.solve == 9 );
	assert( [ "8", "1 2", "2 3", "4 3", "2 5", "6 3", "6 7", "8 6", "5", "2 7", "3 5", "1 6", "2 8", "7 8" ].parse.expand.solve == 62 );
}



import core.bitop;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	auto abs = new long[ 2 ][ n - 1 ];
	foreach( ref ab; abs )
	{
		input.popFront;
		ab = input.front.split.to!( long[] );
		ab[] -= 1;
	}
	input.popFront;
	auto m = input.front.to!( long );
	auto uvs = new long[ 2 ][ m ];
	foreach( ref uv; uvs )
	{
		input.popFront;
		uv = input.front.split.to!( long[] );
		uv[] -= 1;
	}
	return tuple( n, abs, uvs );
}

auto solve( long n, long[ 2 ][] abs, long[ 2 ][] uvs )
{
	// 辺配列を隣接リストに変換
	auto nss = new Tuple!( long, long )[][ n ];
	foreach( i, ab; abs )
	{
		nss[ ab[ 0 ] ] ~= tuple( ab[ 1 ], 1L << i );		// 辺番号を付与
		nss[ ab[ 1 ] ] ~= tuple( ab[ 0 ], 1L << i );		// 辺番号を付与
	}
	
	// 制約に含まれる辺集合をビット列で作成
	auto ws = new long[ uvs.length ];
	foreach( ref w, uv; lockstep( ws, uvs ) )
	{
		w = dfs( nss, -1, uv[ 0 ], uv[ 1 ] );
	}
	
	// 全制約を満たすパターンの数を計算
	auto ans = 0L;
	foreach( wt; 1L .. ( 1L << uvs.length.signed ) )
	{
		// 制約集合wtに含まれる辺集合をビット列で作成
		auto nt = 0L;
		for( auto i = 0L, b = wt; 0 < b; i++, b >>= 1 )
		{
			if( b & 1 ) nt |= ws[ i ];
		}
		
		// 制約集合wtを満たす塗り方のパターン数を計算
		auto nc = nt._popcnt;
		auto nr = abs.length.signed - nc;
		auto p = ( 2L ^^ nc - 1 ) * ( 2L ^^ nr );
		
		// 包除原理に沿ってパターン数合計を増やしたり減らしたりする
		if( wt._popcnt % 2 == 1 ) ans += p;
		else                      ans -= p;
	}
	return ans;
}

long dfs( Tuple!( long, long )[][] nss, long p, long s, long e )
{
	foreach( n; nss[ s ] )
	{
		if( n[ 0 ] == p ) continue;
		if( n[ 0 ] == e ) return n[ 1 ];
		auto b = dfs( nss, s, n[ 0 ], e );
		if( b != 0 ) return n[ 1 ] | b;
	}
	return 0L;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    ll X = 0;
    ll Y = 0;
    ll T = 0;
    rep(i, N) {
        ll t, x, y;
        cin >> t >> x >> y;
        ll dist = abs(X- x) + abs(Y-y);
        ll time = t - T;
        if (dist <= time && dist % 2 == time % 2) {
            T = t;
            X = x;
            Y = y;
            continue;
        }else {
            cout << "No" << '\n';
            return;
        }
    }
    cout << "Yes" << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
    
 
int main(){
    int year, month, day;
    char slash1, slash2;
    
    cin >> year >> slash1 >> month >> slash2 >> day;
    
    
    if(year < 2019){
        cout << "Heisei" << endl;
    }
    else if(year == 2019 && month < 04){
        cout << "Heisei" << endl;
    }
    else if(year == 2019 && month == 04 && day <= 30){
        cout << "Heisei" << endl;
    }
    else{
        cout << "TBD" << endl;
    }
    
}

Measured memory_bytes: 256
using System;

namespace ABC148A
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string b = Console.ReadLine();
            if (a == "1" && b == "2" || a == "2" && b == "1")
                Console.WriteLine(3);
            else if (a == "2" && b == "3" || a == "3" && b == "2")
                Console.WriteLine(1);
            else if (a == "1" && b == "3" || a == "3" && b == "1")
                Console.WriteLine(2);
            Console.ReadKey();
               


        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll n, a;
	cin >> n;
	ll cnt[n+1];
	memset(cnt, 0, sizeof(cnt));
	zep(i, 0, n){
		cin >> a;
		cnt[a]++;
	}
	//printa(cnt, 1, n)
	
	priority_queue<ll> q;
	rep(i, 1, n){
		if(cnt[i] > 0){
			q.push(cnt[i]);
		}
	}
	
	ll ans[n+1];
	memset(ans, 0, sizeof(ans));
	ll z = n;
	ll c = 0;
	ll l = 1;
	rrep(u, n, 1){
		//cout << u << z << endl;
		ll r = z/u;
		
		rep(i, l, r){
			ans[i] = u;
		}
		l = r+1;
		
		while(!q.empty() && q.top() == u){
			c++;
			q.pop();
		}
		if(z > 0){
			z -= c;
		}
	}
	
	rep(i, 1, n){
		print(ans[i])
	}
	return 0;
}

Measured memory_bytes: 8684
n = int(input())
h = [int(i) for i in input().split()]

dp = [1e9] * n
dp[0] = 0

for i in range(1,n):
    dp[i] = min(dp[i], dp[i-1] + abs(h[i] - h[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]))

print(dp[-1])

Measured memory_bytes: 13800
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


vector<vector<int>>memo;
int main() {
	int N; cin >> N;
	for (int num = 0; num < N;++num){
		int W, H; cin >> W >> H;
		vector<vector<int>>field(H, vector<int>(W));
		for (int y = 0; y < H; ++y) {
			for (int x = 0; x < W; ++x) {
				cin >> field[y][x];
			}
		}
		memo = vector<vector<int>>(2, vector<int>(1 << W));
		for (int y = 0; y < H; ++y) {
			for (int x = 0; x < W; ++x) {
				
				const int i = y*W + x;
				int tar = i & 1, cur = tar ^ 1;
				for (int i = 0; i < (1 << W); ++i) {
					memo[cur][i] = 0;
				}
				if (i == 0)assert(tar == 0 && cur == 1);
				for (int pre = 0; pre < (1 << W); ++pre) {
					if (((x==0)||!(pre & 1)) && !(pre&(1 << (W-1)))) {
						memo[cur][((pre << 1) + 1) & ((1 << W) - 1)] = max(memo[cur][((pre << 1) + 1) & ((1 << W) - 1)], memo[tar][pre] + field[y][x]);
					}
					memo[cur][(pre << 1)&((1<<W)-1)] = max(memo[cur][(pre << 1)&((1 << W) - 1)], memo[tar][pre]);
				}
			}
		}
		int ans=0;
		for (int i = 0; i < (1 << W); ++i) {
			ans = max(ans, memo[(W*H) % 2][i]);
		}
		cout << "Case " << num+1 << ": " << ans << endl;
		
	}
	return 0;
}

Measured memory_bytes: 19248
#pragma region
#include <bits/stdc++.h>
using namespace std;
using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define f first
#define s second
#define szof(a) (int)a.size()
#define allof(a) a.begin(), a.end()

void pr(int x) { printf("%d", x); }
void pr(ll x) { printf("%lld", x); }
void pr(char x) { printf("%c", x); }
void pr(const string &x) { printf("%s", x.c_str()); }
void pr(bool x) { printf(x ? "true" : "false"); }
void pr(double x) { printf("%lf", x); }
void pr(const char *x) { printf("%s", x); }

template <typename S, typename T>
void pr(pair<T, S> x);

template <class T>
void pr(const T &x);

template <class T, class... Ts>
void pr(const T &t, const Ts &... ts) {
    pr(t);
    pr(ts...);
}
template <class T1, class T2>
void pr(const pair<T1, T2> &x) {
    pr("{", x.f, ", ", x.s, "}");
}
template <class T>
void pr(const T &x) {
    pr("{");
    bool fst = 1;
    for (const auto &a : x)
        pr(!fst ? ", " : "", a), fst = 0;
    pr("}");
}

void ps() { pr("\n"); }
template <class T, class... Ts>
void ps(const T &t, const Ts &... ts) {
    pr(t);
    if (sizeof...(ts)) pr(" ");
    ps(ts...);
}
void pc() { pr("]\n"); }
template <class T, class... Ts>
void pc(const T &t, const Ts &... ts) {
    pr(t);
    if (sizeof...(ts)) pr(", ");
    pc(ts...);
}
#define debug(x...) pr("[", #x, "] = ["), pc(x)
#ifndef LOCAL
#define debug(x...) 42
#endif
#pragma endregion

/**
 * Status: Tested
 * Allows queries for the minimum of the last k elements added
 */
template <typename T>
struct sliding_window {
    int k, n;
    deque<pair<T, int>> q;
    sliding_window(int k = 1)
        : k(k), n(0) {
    }
    void add(T e) {
        while (!q.empty() && q.front().second <= n - k)
            q.pop_front();
        while (!q.empty() && q.back().first >= e)
            q.pop_back();
        q.push_back({ e, n++ });
    }
    T query() {
        return q.front().first;
    }
};

int main() {
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#endif
    int n, k;
    scanf("%d%d", &n, &k);
    vi p(n);
    for (int i = 0; i < n; ++i)
        scanf("%d", &p[i]);

    vi right(n);
    int r = 0;
    for (int i = 0; i < n; ++i) {
        r = max(r, i);
        while (r + 1 < n && p[r + 1] > p[r])
            ++r;
        right[i] = r;
    }
    debug(right);
    int ans = 0;
    int numsort = 0;
    if (right[0] >= k - 1) {
        numsort = 1;
    } else {
        ans = 1;
    }
    sliding_window<int> minw(k), maxw(k);
    for (int i = 0; i < k; ++i) {
        minw.add(p[i]);
        maxw.add(-p[i]);
    }
    for (int i = k; i < n; ++i) {
        int prevmn = minw.query();
        minw.add(p[i]);
        maxw.add(-p[i]);
        int curmx = -maxw.query();

        // if sorted
        if (right[i - k + 1] >= i) {
            numsort = 1;
            continue;
        }

        if (!(prevmn == p[i - k] && curmx == p[i])) {
            ++ans;
        }
    }
    debug(numsort);
    printf("%d\n", ans + numsort);
}

Measured memory_bytes: 3456
#include <iostream>

using namespace std;
#define MAX 1000005
#define NIL -1

struct Node { int p, l, r; };

Node T[MAX];
int n, D[MAX];

void print(int u) {
	int i, c;
	cout << "node " << u << ": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";

	if (T[u].p == NIL) cout << "root, ";
	else if (T[u].l == NIL) cout << "leaf, ";
	else cout << "internal node, ";

	cout << "[";

	for (int i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
		if (i) cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}

int rec(int u, int p) {
	D[u] = p;
	if (T[u].r != NIL) rec(T[u].r, p);
	if (T[u].l != NIL) rec(T[u].l, p + 1);
}

int main()
{
	int i, j, d, v, c, l, r;

	cin >> n;

	for (i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;

	for (i = 0; i < n; i++) {
		cin >> v >> d;
		for (j = 0; j < d; j++)
		{
			cin >> c;
			if (j == 0) T[v].l = c;
			else T[l].r = c;
			l = c;
			T[c].p = v;
		}
	}

	for (i = 0; i < n; i++) {
		if (T[i].p == NIL) r = i;
	}

	rec(r, 0);

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

	return 0;
}


Measured memory_bytes: 7660
N = int(input())
Hi = list(map(int, input().split()))
    
Hi.reverse()
flag = 0
check = 0
for i in range(0, N-1):
    if Hi[i] > Hi[i+1]:
        flag = 0
    elif (Hi[i] == Hi[i+1]-1) and flag == 0:
        flag = 1
    elif Hi[i] == Hi[i+1]:
        pass
    else:
        check = 1
        
if check == 0:
    print("Yes")
else:
    print("No")
    

Measured memory_bytes: 14396
#include<iostream>
#include<queue>
#include<unordered_map>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 

unordered_map<LL,int> dp;

int main(){
    unordered_map<LL,vector<P>> G;
    int n,m;cin >> n >> m;
    LL hash = 1e9;
    for (int i = 0; i < m; i++) {
        int a,b,c;cin >> a >> b >> c;
        a--,b--;
        if(dp.find(a*hash+c)==dp.end()){
            dp[a*hash+c]=INF;
            G[a*hash+c].pb({a+n,-1});
            G[(n+a)*hash-1].pb({a,c});
        }
        G[a*hash+c].pb({b,c});
        if(dp.find(b*hash+c)==dp.end()){
            dp[b*hash+c]=INF;
            G[b*hash+c].pb({b+n,-1});
            G[(n+b)*hash-1].pb({b,c});
        }
        G[b*hash+c].pb({a,c});
        if(dp.find((a+n)*hash-1)==dp.end()){
            dp[(a+n)*hash-1]=INF;
        }
        if(dp.find((b+n)*hash-1)==dp.end()){
            dp[(b+n)*hash-1]=INF;
        }
    }
    priority_queue<pair<int,P>,vector<pair<int,P>>,greater<pair<int,P>>> pq;
    pq.push({0,{-1,n}});
    dp[n*hash-1]=0;
    while(!pq.empty()){
        int v=pq.top().second.second;
        int r=pq.top().second.first;
        int d=pq.top().first;
        pq.pop();
        int id=dp[v*hash+r];
        if(id<d) continue;
        if(r==-1){
            for(auto g:G[v*hash+r]){
                int to=g.first;
                int rr=g.second;
                int xd=dp[to*hash+rr];
                if(xd>d+1){
                    dp[to*hash+rr]=d+1;
                    pq.push({d+1,{rr,to}});
                }
            }
        }
        else{
            for(auto g:G[v*hash+r]){
                int to=g.first;
                int rr=g.second;
                int xd=dp[to*hash+rr];
                if(xd>d){
                    dp[to*hash+rr]=d;
                    pq.push({d,{rr,to}});
                }
            }
        }
    }
    int ans=INF;
    for(auto g:G[(2*n-1)*hash-1]){
        ans=min(ans,dp[g.first*hash+g.second]);
    }
    if(ans==INF) cout << "-1" << endl;
    else cout << ans << endl;
    return 0;
}



Measured memory_bytes: 91848
def main():
  import sys
  from collections import deque
  n=int(input())
  v=list(map(int,sys.stdin.read().split()))
  w=deque(sorted(v))
  ans=(w.popleft()+w.popleft())/2
  for i in range(n-2):
    ans=ans/2
    ans+=w.popleft()/2
  print(ans)
if __name__=="__main__":
  main()

Measured memory_bytes: 3316
#include <stdio.h>
#include <math.h>

int main(void){
  double a, b, c;
  double s, h, l;
  double d;
  
  scanf("%lf %lf %lf", &a, &b, &c);

  h = b * sin(M_PI * c / 180);
  s = h * a / 2;

  d = sqrt((a * a) + (b * b) - (2 * a * b * cos(M_PI * c /180)));
  l = a + b + d;

  printf("%f\n%f\n%f\n", s, l, h);
  
  return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

using namespace std;
typedef long long ll;
typedef pair <int,int> P;

ll a,b;
string B;

int main(){
  cin >> a;
  cin >> B;
  b += 100LL*(B[0]-'0')+10LL*(B[2]-'0')+(B[3]-'0');
  ll c = a*b;
  c /= 100LL;
  cout << c << endl;

  return 0;
}


Measured memory_bytes: 3684
#include <cstdio>

bool p[10001] = {false};
int n;

int main(){
	p[0] = p[1] = true;
	for(int i = 2; i < 10001; i++){
		if(!p[i]){
			for(int j = i*2; j < 10001; j += i){
				p[j] = true;
			}
		}
	}
	while(scanf("%d",&n) != EOF){
		int ans = 0;
		for(int i = 1;i <= n; i++){
			if(!p[i] && !p[n-i+1]){
				ans++;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2672
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> b(n), ans;
  for (int i = 0; i < n; i++) cin >> b[i];

  auto itr = b.begin();
  bool flag = true;
  for (int i = n - 1; i >= 0; i--) {
    flag = true;
    for (int j = i; j >= 0; j--) {
      if (j + 1 == b[j]) {
        itr = b.begin() + j;
        ans.push_back(j + 1);
        b.erase(itr);
        flag = false;
        break;
      }
    }
    if (flag) {
      break;
    }
  }

  if (b.empty()) {
    for (int i = 0; i < n; i++) {
      cout << ans[n - 1 - i] << endl;
    }
  } else {
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int rectangle(int tate,int yoko);
int main(void){
	int H[1000],W[1000],a,j;
	j=0;
	while(1){
		scanf("%d %d",&H[j] ,&W[j]);
			if((H[j]==0)&&(W[j]==0)){
			break;
	}
		j++;
	}
	for(a=0;a<j;a++){
		rectangle(H[a],W[a]);
		printf("\n");
	}
	return 0;
}
	
	int rectangle(int tate,int yoko){
		int h,i;
		for(h=0;h<tate;h++){
			for(i=0;i<yoko;i++){
				printf("#");
			}
			printf("\n");
		}
		return 0;
	}
	


Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <stack>
#include <string>
#include <cstring>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <climits>

using namespace std;

const int N = 3e5 + 5000;
int n, m, T, a[N];

int main()
{
#ifdef ONLINE_JUDGE
#else
    // freopen("r.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);
    cin >> n >> m;
    cout << m + max(10 - n, 0) * 100;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int h,m1,m2,m3,w;
	m1=0;
	m2=0;
	m3=0;
	for(int i=0;i<10;i++){
		scanf("%d",&h);
		if(m3<h){
			m3=h;
			if(m2<m3){
				w=m2;
				m2=m3;
				m3=w;
				if(m1<m2){
					w=m1;
					m1=m2;
					m2=w;
				}
			}
		}
	}
	printf("%d\n%d\n%d\n",m1,m2,m3);
	return 0;
}


Measured memory_bytes: 2072
# https://atcoder.jp/contests/abc141/tasks/abc141_a
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    s = input()
    if s == 'Sunny':
        print('Cloudy')
    elif s == 'Cloudy':
        print('Rainy')
    else:
        print('Sunny')

if __name__ == '__main__':
    main()


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

int main(){
	int n;
	cin>>n;
	int a[2][n],m=0,M;
	for(int i=0;i<n;i++) cin>>a[0][i];
	for(int i=0;i<n;i++) cin>>a[1][i];
	for(int i=0;i<n;i++){
		M=0;
		for(int j=0;j<n;j++){
			if(i<=j) M+=a[1][j];
			if(i>=j) M+=a[0][j];
		}
		if(m<M) m=M;
	}
	cout<<m;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  ll a, b;
  cin >> a >> b;
  if (min(a, b) == 1) {
    cout << 1 << endl;
    return 0;
  }
  cout << (a*b+1) / 2 << endl;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

vector<vector<ll>> com(51, vector<ll>(51, 0));

void combination()
{
    rep(i, com.size())
    {
        com[i][0] = 1;
    }
    for (int i = 1; i < com.size(); i++)
    {
        for (int j = 1; j < com.size(); j++)
        {
            com[i][j] = com[i - 1][j - 1] + com[i - 1][j];
        }
    }
}

int main()
{
    combination();
    int n, a, b;
    cin >> n >> a >> b;
    vector<ll> v(n);
    rep(i, n) cin >> v[i];
    sort(ALL(v), greater<ll>());

    double sumv = 0;
    rep(i, a) sumv += v[i];
    printf("%.10f\n", sumv / a);

    ll ans = 0;
    int m = count(ALL(v), v[a - 1]);

    if (v[0] == v[a - 1])
    {
        for (int i = a; i <= b; i++)
        {
            ans += com[m][i];
        }
    }
    else
    {
        int r = count(v.begin(), v.begin() + a, v[a - 1]);

        ans = com[m][r];
    }
    OP(ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;
typedef long long ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(string, s);

  int n = sz(s) - 2;

  cout << s.front() << n << s.back() << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <list>
#include <algorithm>
#include <bitset>
#include <string>
#include <cstring>
using namespace std;

#define lli long long int
#define pb push_back
#define M 1000000007

bool compare(pair<int, int> &p1, pair<int, int> &p2)
{
    return true;
}

template <typename T>
T maxInThree(T a, T b, T c)
{
    T temp = max(a, b);
    temp = max(temp, c);
    return temp;
}

template <typename T>
T minInThree(T a, T b, T c)
{
    T temp = min(a, b);
    temp = min(temp, c);
    return temp;
}

void solve()
{
    lli n;
    cin >> n;
    if(n%1000==0) cout << 0 ;
    else {
        cout << (1000- (n%1000)) ;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    solve();

    return 0;
}

Measured memory_bytes: 3560
#include<iostream>
#include<cstdio>
using namespace std;
int sco,p,g;char s;
int main()
{
	while(cin>>s)
	{
		if(s=='p'&&p<g){p++;continue;}
		if(s=='p'&&p==g){g++;sco--;continue;}
		if(s=='g'&&p<g){p++;sco++;continue;}
		if(s=='g'&&p==g){g++;continue;}
	}
	cout<<sco;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = sc.nextInt();
            if (n == 0) break;
            int[] s = new int[n];
            double e = 0.0, v = 0.0;
            for (int i = 0; i < n; i++) {
                s[i] = sc.nextInt();
                e += s[i];
                v += s[i] * s[i];
            }
            e /= n;
            v = v / n - e * e;
            System.out.println(Math.sqrt(v));
        }
    }
}


Measured memory_bytes: 31404
#include <stdio.h>
#include <math.h>
#include <limits.h>
#include <stdlib.h>


int 
main(){
	long long X,K;
	scanf("%lld%lld",&K,&X);
	long long i;
	if(K==1)printf("%lld\n",X);
	else{
		
		for(i= X-(K-1);i<=X+(K-1);i++){
			if(i!=(X+K-1))printf("%lld ",i);
			else printf("%lld\n",i);	
		}
	}

 return 0;
}

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

using ll = long long;

const int MAX_N = 100010;
int par[MAX_N];
int rnk[MAX_N];
int siz[MAX_N];

void init(int n) {
    rep(i,n) {
        par[i] = i;
        rnk[i] = 0;
        siz[i] = 1;
    }
}

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

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    int s = siz[x] + siz[y];
    if (rnk[x] < rnk[y]) {
        par[x] = y;
    } else {
        par[y] = x;
        if (rnk[x] == rnk[y]) rnk[x]++;
    }
    siz[find(x)] = s;
}

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

int size(int x) {
    return siz[find(x)];
}

int main() {
    int n;
    cin >> n;
    while (n != 0) {
        vector<double> x(n), y(n), z(n), r(n);
        rep(i, n) cin >> x[i] >> y[i] >> z[i] >> r[i];
        priority_queue<tuple<double, int, int>> q;
        rep(i, n - 1) {
            for (int j = i + 1; j < n; j++) {
                double dx = x[i] - x[j], dy = y[i] - y[j], dz = z[i] - z[j];
                double d = max(0.0, sqrt(dx * dx + dy * dy + dz * dz) - r[i] - r[j]);
                q.push(make_tuple(-d, i, j));
            }
        }
        double ans = 0;
        init(n);
        while (!q.empty()) {
            auto p = q.top();
            q.pop();
            int a = get<1>(p), b = get<2>(p);
            if (same(a, b)) continue;
            double d = -get<0>(p);
            ans += d;
            unite(a, b);            
        }
        cout << fixed;
        cout << setprecision(3) << ans << "\n";
        cin >> n;
    }
}


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

using namespace std;

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

using ll = long long;

const int Inf = 1e9;
const double EPS = 1e-9;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    rep (i, x) cin >> a[i];
    rep (i, y) cin >> b[i];
    rep (i, z) cin >> c[i];
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    sort(c.rbegin(), c.rend());
    vector<ll> sum, res;
    int cnt = 0;
    rep (i, x) {
        rep (j, y) {
            sum.push_back(a[i] + b[j]);
            cnt++;
        }
    }
    sort(sum.rbegin(), sum.rend());
    rep (i, sum.size()) {
        if (i >= k) break;
        rep (j, z) {
            res.push_back(sum[i] + c[j]);
        }
    }
    
    sort(res.rbegin(), res.rend());
    rep (i, k) cout << res[i] << endl;
    
    return 0;
}



Measured memory_bytes: 43240
/* AtCoder Regular Contest 078. Problem A, by Abreto<m@abreto.net>. */
#include <stdio.h>

int main(void)
{
    int A = 0, B = 0;
    scanf("%d%d", &A, &B);
    printf("%s\n", ((0==A%3)||(0==B%3)||(0==(A+B)%3))?"Possible":"Impossible");
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>//本当は必要なヘッダファイルだけインクルードするべきです
using namespace std;//本当は個別にusingするか変数や関数ごとにstd::をつけるべきです
//本当は関数内に宣言し明示的に初期化するべきです
int n,m,a[100][100],b[100],c[100],i,j;
int main(void){
  cin>>n>>m;
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      cin>>a[i][j];
    }
  }
  for(i=0;i<m;i++)cin>>b[i];
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      c[i]+=a[i][j]*b[j];
    }
    cout<<c[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <stack>
#include <cmath>
#include <map>
#include <cstring>
using namespace std;
#define mod 1000000007
#define PI acos(-1.0)
const long long MAX=200005;
typedef long long ll;
const int INF=0x3f3f3f3f;
int d[8][2]={-1,0,0,-1,0,1,1,0,1,1,-1,-1,-1,1,1,-1};
char a[55][55];
struct knot
{
     int x,y;
};
 knot t,b,c;
 int h,w,m[55][55]={0},sum=0,fg=0,num;
 void bfs(int f,int e)
 {
     queue<knot>s;
     fg=0;
     t.x=f;
     t.y=e;
     //num=1;
     s.push(t);
    while(!s.empty())
     {
         b=s.front();
         s.pop();
         for (int i=0;i<4;i++)
         {
             t.x=b.x+d[i][0];
             t.y=b.y+d[i][1];
             if (t.x>=0&&t.x<h&&t.y>=0&&t.y<w&&a[t.x][t.y]!='#'&&!m[t.x][t.y])
            {
                 fg=1;
               // num++;
                 m[t.x][t.y]=m[b.x][b.y]+1;
                 s.push(t);
             }
         }
    }
 }

int main()
{
    scanf("%d%d",&h,&w);
    for(int i=0;i<h;i++)
        scanf("%s",&a[i]);
    if(a[0][0]=='#')
    {
        printf("-1\n");
        return 0;
    }
    m[0][0]=1;
   // k=1;
    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            if(a[i][j]=='.')sum++;
    bfs(0,0);
    if(m[h-1][w-1]==0)
        printf("-1\n");
    else printf("%d\n",sum-m[h-1][w-1]);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define nummax 110000
using namespace std;

int main() {
	int i, r, D, x[nummax];
	cin >> r >> D >> x[2000];
	for (i = 2001; i <= 2010; i++)
	{
		x[i] = r * x[i - 1] - D;
		cout << x[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long cc;
typedef pair <int, int> pii;
#define X first
#define Y second
#define pb push_back
cc k, a, b;
int main() {
    //freopen("input.inp", "r", stdin);
    //freopen("output.out", "w", stdout);
    //freopen("VOI08LOCO.inp", "r", stdin);
    //freopen("VOI08LOCO.out", "w", stdout);
    ios_base  :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> k >> a >> b;
    if (a >= k) cout << 1;
    else {
        if (a <= b) cout << -1;
        else {
            k -= a;
            cout << 2ll * (k / (a - b) + (k % (a - b) != 0)) + 1;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const long long MOD = 1000000007;

ll K;
map<ll, ll> mp;

signed main(){
    cin >> K;
    ll n = 7, ans = 1;
    while(n % K != 0 && mp[n % K] == 0){
        mp[n % K]++;
        n = (n * 10 + 7) % K;
        ans++;
    }
    if(n % K != 0) ans = -1;
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 66112
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf = 2*1e18;


int main(){
    ll n,t,q;
    cin>>n>>t>>q;
    vector<mp> a(n);
    vector<ll> ans(n);
    for(int i=0;i<n;i++) cin>>a[i].first>>a[i].second;
    ll meet = -inf;
    stack<ll> st;
    st.push( -inf );
    for(int i=0;i<n;i++){
	if( a[i].second==1){
	    st.push( a[i].first );
	}else{
	    ll l = st.top();
	    if( st.size() != 1 ) st.pop();
	    if( meet <= l )meet = max(meet , (l+a[i].first)/2 );
	    meet = max(meet , a[i].first - t);
	    ans[i] = meet;
	}
    }
 //   cout<<"PL"<<endl;
    meet = inf;
    stack<ll> st2;
   // while(!st.empty())st.pop();
    st2.push(inf);
    for(int i=n-1;i>=0;i--){
	if(a[i].second==2){
	    st2.push( a[i].first );
	}else{
	    ll  r = st2.top();
	   // cout<<st2.top()<<' '<<a[i].first<<endl;
	    if( st2.size() != 1 ) st2.pop();
	 //   cout<<i<<' '<<meet<<' '<< ( r+a[i].first)/2<<' ' << a[i].first+t< <endl;
	    if( r <=  meet ) meet = min(meet , ( r + a[i].first )/2 );
	    meet = min(meet , a[i].first + t );
	    ans[i]  = meet;
	    
	}
    }
   // cout<<"ok"<<endl;
    for(int i=0;i<q;i++){
	ll qq;
	cin>>qq;qq--;
	cout<<ans[qq]<<endl;
    }


	return 0;
}



Measured memory_bytes: 5844
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef __int128_t lll;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
template<typename T>string join(V<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isprime(ll n){if(n<2)return 0;if(!(n%2))return !(n-2);lll d=n-1,t,y;while(!(d%2))d>>=1;V<ll> al={2,325,9375,28178,450775,9780504,1795265022};for(ll a:al){if(n<=a)break;t=d,y=modpow(a,t,n);while(t!=n-1&&y!=1&&y!=n-1)y=y*y%n,t<<=1;if(y!=n-1&&!(t%2))return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}
mt19937 rnd; void set_rnd(){random_device r;rnd=mt19937(r());}
V<ll> fact, rfact; void set_fact(int n, ll m){fact.pb(1);rfact.pb(1);FOR(i,1,n+1)fact.pb(fact[i-1]*i%m),rfact.pb(modpow(fact[i],m,m-2));}
const int iinf = 1e9+6;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 2e5+5;
void init(){
  set_rnd();
//  set_fact(N);
}
map<int, int> m;
int n;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  init();
  cin >> n;
  FOR(i, 0, n){
    int a;
    cin >> a;
    m[a]++;
  }
  int c = n, x = 0, prev=0;
  each(itr, m){
    if((itr->fi-prev)%2) x ^= c;
    c -= itr->se;
    prev = itr->fi;
  }
  cout << (x ? "first" : "second") << endl;
  return 0;
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc150/tasks/abc150_e>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

const ll MOD = 1e9+7;
// a^b % MOD;
ll powmod(ll a,ll b) {ll res=1;a%=MOD; for(;b;b>>=1){if(b&1)res=res*a%MOD;a=a*a%MOD;}return res;}

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> C(N); for(auto& in:C) cin >> in;

    sort(C.begin(),C.end());
    for(int i = 0; i < N;i++){
        res += powmod(4,N-1)*C[i]%MOD*(N-i+1)%MOD;
        res %= MOD;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 1792
x,n = map(int,input().split())
a = [int(x) for x in input().split()]

if x == 0:
    print(n)
    exit()

temp = [0] * n

for i in range(n):
    temp[i] = a[i] - x

temp.sort()

abs = 0
ans = 0

while (True):
    if temp.count(abs*-1) == 0:
        ans = x - abs
        break
    elif temp.count(abs) == 0:
        ans = x + abs
        break
    else:
        abs += 1
    #print(ans)


print(ans)


Measured memory_bytes: 9164
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

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

// constexpr inline ll mod = 1'000'000'007;
// constexpr int max_n = 200'000 + 5;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int x = 0;
    for (; a >= b; x++) {
        b *= 2;
    }
    for (; b >= c; x++) {
        c *= 2;
    }
    if (x <= k) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3648
from itertools import combinations as IC
N, M, X = map(int, input().split())
ans = 10 ** 100
L = [list(map(int, input().split())) for i in range(N)]
#print(L)
for i in range(1, N + 1):
  T = list(IC(list(range(N)), i))
  #print(T)
  for j in T:
    t = 0
    l = [0] * M
    for n in list(j):
      for k in range(M+1):
        if k == 0:
          #print(L[n][0])
          t += L[n][0]
        else:
          l[k-1] += L[n][k]
    if len([n for n in l if n >= X]) == M:
      #print(l, t)
      ans = min(ans, t)
print(-1 if ans == 10 ** 100 else ans)

Measured memory_bytes: 9412
#include <iostream>

#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>

using namespace std;
using namespace boost;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

int main() {
    int n;
    cin >> n;
    // undirectedS は無向グラフ、directedS は有向グラフ
    adjacency_list<listS, vecS, undirectedS, no_property,
                   property<edge_weight_t, int>>
        graph1(n);
    for (int i = 0; i < n - 1; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        add_edge(a, b, c, graph1);
    }

    int q, k;
    cin >> q >> k;
    --k;
    vector<PII> v(q);

    for (int i = 0; i < q; i++) {
        int x, y;
        cin >> x >> y;
        v[i] = {x - 1, y - 1};
    }

    // k からの最短距離を求める
    vector<long long> distances1(n);
    vector<int> parents1(n);
    dijkstra_shortest_paths(
        graph1, k,
        distance_map(distances1.data()).predecessor_map(parents1.data()));
    for (auto a : v) {
        cout << distances1[a.first] + distances1[a.second] << endl;
    }
    return 0;
}

Measured memory_bytes: 20600
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn main() {
    let (a, b) = input_tuple();
    if a * b % 2 == 0 {
        println!("Even");
    } else {
        println!("Odd");
    }
}


Measured memory_bytes: 2092
import java.util.*;
import java.util.function.*;

public class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();

		SegmentTree<BitSet> seg=new SegmentTree<>(n,
				new BitSet(0),
				(a,b)->{
					BitSet o=(BitSet)a.clone();
					o.or(b);
					return o;
				});

		BitSet[] cache=new BitSet[26];
		for(int i=0;i<26;++i){
			cache[i]=new BitSet(i+1);
			cache[i].set(i);
		}

		{
			String t=s.next();
			for(int i=0;i<n;++i)
				seg.build_set(i,cache[t.charAt(i)-'a']);
			seg.build();
		}

		for(int q=s.nextInt();q>0;--q){
			if(s.nextInt()==1){
				seg.apply(s.nextInt()-1,cache[s.next().charAt(0)-'a']);
			}else{
				System.out.println(seg.query(s.nextInt()-1,s.nextInt()).cardinality());
			}
		}
	}
}

/**
 * @see http://codeforces.com/blog/entry/18051
 */
class SegmentTree<T>{
	T initv,array[];
	int size;

	/**
	 * a+0=a<br>
	 * a+(b+c)=(a+b)+c
	 */
	BinaryOperator<T> merger;

	SegmentTree(int size,T initvalue,BinaryOperator<T> merger){
		this.size=size;
		this.initv=initvalue;
		this.merger=merger;
		initArray();
	}
	@SuppressWarnings("unchecked")
	private void initArray(){
		array=(T[])new Object[size*2];
		Arrays.fill(array,initv);
	}

	void build_set(int i,T v){
		array[i+size]=v;
	}
	void build(){
		for(int i=size-1;i>0;--i)
			array[i]=merger.apply(array[i<<1],array[i<<1|1]);
	}

	void apply(int p,T value){
		for(array[p+=size]=value;p>1;p>>=1)
			array[p>>1]=merger.apply(array[p],array[p^1]);
	}
	/**
	 * [l, r)
	 */
	T query(int l,int r){
		T res=initv;
		for(l+=size,r+=size;l<r;l>>=1,r>>=1){
			if((l&1)>0) res=merger.apply(res,array[l++]);
			if((r&1)>0) res=merger.apply(res,array[--r]);
		}
		return res;
	}
}


Measured memory_bytes: 113636
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
char mem[114514];
char t[114514];
char c[114514];
string s[114514];
int a[114514],b[114514];
signed main(){
	ic(n) ic(x)
	int sum=0;
	rep(0,i,x){
		cin>>a[i];
		sum+=a[i];
	}
	if(sum>=n){
		c("Yes")
	}
	else c("No")
}		

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

int main() {
	string s; cin >> s;
	string ans;
	for (int i = 0; i < s.size(); i += 2) {
		ans += s[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int n;
  while(cin>>n,n){
    vector<int> v(n);
    REP(i,n){
      string s;cin>>s;
      v[i]=s.size();
    }
    REP(i,n){
      int p=i;
      int tmp=v[p];
      while(tmp<5){
        p++;tmp+=v[p];
      }
      if(tmp==5){
        p++;
        tmp=v[p];
        while(tmp<7){
          p++;tmp+=v[p];
        }
        if(tmp==7){
          p++;
          tmp=v[p];
          while(tmp<5){
            p++;tmp+=v[p];
          }
          if(tmp==5){
            p++;
            tmp=v[p];
            while(tmp<7){
              p++;tmp+=v[p];
            }
            if(tmp==7){
              p++;
              tmp=v[p];
              while(tmp<7){
                p++;tmp+=v[p];
              }
              if(tmp==7){
                p++;
                cout<<i+1<<endl;
                break;
              }
            }
          }
        }
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3176
#include <stdio.h>

int main(){
    long int n, m, count;
    count = 0;

    scanf("%ld %ld", &n, &m);

    if(n >= m/2){
        printf("%ld\n", m/2);
        return 0;
    }else{
        count = n;
        m = m - 2*n;
        while(m >= 4){
            m = m - 4;
            count++;
        }
        printf("%ld\n", count);
        return 0;
    }
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

double calcE()
{
    int n,m;
    scanf(" %d %d", &n, &m);
    vector<int> v(m);
    vector<double> r(m);
    rep(i,m) scanf(" %d %lf", &v[i], &r[i]);

    double sum=0;
    rep(i,m) sum+=r[i];
    double rest=1.0-sum;

    rep(i,m) r[i]+=rest*r[i]/sum;

    double ret=0;
    rep(i,m) ret+=v[i]*r[i];
    return ret;
}

int main()
{
    int t;
    scanf(" %d", &t);

    double maxE=0;
    rep(i,t) maxE=max(maxE,calcE());
    double leader=calcE();

    string ans="NO";
    if(maxE-leader>0.0000001) ans="YES";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3340
#include<iostream> 
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define N 110 
char getc(){char c=getchar();while ((c<'A'||c>'Z')&&(c<'a'||c>'z')&&(c<'0'||c>'9')) c=getchar();return c;}
int gcd(int n,int m){return m==0?n:gcd(m,n%m);}
int read()
{
	int x=0,f=1;char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return x*f;
}
int n;
vector<int> a[N];
signed main()
{
	n=read();
	int s=n*(n+1)/2;
	if (n%2==0)	for (int i=1;i<=n/2;i++) a[i].push_back(i),a[i].push_back(n-i+1);
	if (n%2==1)
	{
		for (int i=1;i<=n/2;i++) a[i].push_back(i),a[i].push_back(n-i);
		a[(n+1)/2].push_back(n);
	}
	int ans=0;
	for (int i=1;i<=(n+1)/2;i++)
		for (int j=i+1;j<=(n+1)/2;j++)
		if (i!=j) ans+=a[i].size()*a[j].size();
	cout<<ans<<endl;
	for (int i=1;i<=(n+1)/2;i++)
		for (int j=i+1;j<=(n+1)/2;j++)
		if (i!=j) 
			for (int x=0;x<a[i].size();x++)
				for (int y=0;y<a[j].size();y++)
				cout<<a[i][x]<<' '<<a[j][y]<<endl;
	return 0;
	//NOTICE LONG LONG!!!!!
}
//分成若干和相等的部分
//n%2=0 分成n/2份
//n%2=1 分成(n+1)/2份 

Measured memory_bytes: 256
import java.util.Scanner

object Main {
  def main(args : Array[String]) = {
    val scanner = new Scanner(System.in)
    val n = scanner.nextLine().toInt
    var amount:Double = 100000

    for(i <- 1 to n) {
      amount = amount * 1.05
      amount = (amount / 1000).ceil * 1000
    }
    println(amount.toInt)
  }
}

Measured memory_bytes: 44664
#include<bits/stdc++.h>
using namespace std;
double fx[37];
double fy[37];
double diff[39][39];
long long int a[100007];
long long int b[100007];
int main()
{
    long long int n,m,p,q,r,s,t,u=0,v,w,x=0,i,j,sum=0;
    cin>>n;
    for(i=1;i<=n+1;i++)
        cin>>a[i];
        for(i=1;i<=n;i++)
        {
            cin>>b[i];
        }
        for(i=1;i<=n;i++)
        {
            if(a[i]+a[i+1]>b[i])
            {
                if(a[i]<b[i])
                    a[i+1]=a[i+1]-(b[i]-a[i]);
                   sum=sum+b[i];
            }
            else if(a[i]+a[i+1]<=b[i])
            {
                sum=sum+a[i]+a[i+1];
                a[i]=0;
                a[i+1]=0;
                //sum=sum+b[i];
            }
            //cout<<sum<<'\n';
        }
    cout<<sum;




}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

int gcd(int a, int b){return (a % b)? gcd(b, a % b) : b;}
int lcm(int a, int b){return a * b / gcd(a, b);}

void solve_A(){
    string s;
    string t;
    cin >> s;
    cin >> t;

    int n = s.size();
    bool flag = true;
    REP(i,n){
        if(s[i] != t[i]) flag = false;
    }

    int m = t.size();
    if((m == n + 1) && flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

void solve_B(){
    int a, b, c, k;
    cin >> a >> b >> c >> k;

    if(a >= k) cout << k << endl;
    else if(a + b >= k) cout << a << endl;
    else cout << 2*a + b - k << endl;
}

void solve_C(){
    
}

int main(void){
    solve_B();
    
    return 0;
}

Measured memory_bytes: 3628