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

typedef long long ll;
#define int ll
#define pb push_back
const int INF = 1e18;
const int inf = 1e9;
int n,m,x;

signed main(){

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


	#ifndef ONLINE_JUDGE
		time_t t1 = clock(), t2;
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
		// freopen("err.txt", "w", stderr);
	#endif



	
	cin>>n>>m>>x;
	int cost[n];
	int arr[n][m];
	for(int i=0;i<n;i++){
		cin>>cost[i];
		for(int j=0;j<m;j++)
			cin>>arr[i][j];
	}
	int tot = INF;
	for(int i=1;i<(1<<n);i++){
		vector<int> cur(m,0);
		int co = 0;
		for(int j=0;j<n;j++){
			if ((i>>j)&1){
				co += cost[j];
				for(int l=0;l<m;l++)
					cur[l] += arr[j][l];
			}
		}

		bool flag = true;
		for(int j=0;j<m;j++){
			if (cur[j] < x){
				flag = false;
				break;
			}
		}

		if (flag)
			tot = min(tot,co);
	}

	if (tot == INF)
		cout<<-1;
	else
		cout<<tot;

	return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
	llong N;
	vector<llong> A;
	map<llong, llong> m;

	cin >> N;
	A.resize(N);
	for (auto &in: A) {
		cin >> in;
		for (int i = 0; i < 60; ++i) {
			m[i] += (in>>i)&1;
		}
	}

	llong ans = 0;
	for (int i = 0; i < 60; ++i) {
		__int128 res = (N - m[i]) * m[i] % mod;
		res = res * (1ll<<i) % mod;
		ans = (ans + res) % mod;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
typedef pair<int, int> P;

int n, m, a;
int pos[101];	//pos[i] = i??????????????????????????????, ??????pos[i]?????????????????????????????°??????.

int main() {
	int i;
	
	while (cin >> n >> m >> a) {
		if (!n) break;
		for (i = 1; i <= n; i++) pos[i] = i;
		
		vector<P> vec;
		for (i = 0; i < m; i++) {
			int h, p, q;
			cin >> h >> p >> q;
			vec.push_back(P(h, p));
		}
		sort(vec.begin(), vec.end(), greater<P>());
		
		//??????
		for (i = 0; i < m; i++) {
			int p = vec[i].second;
			swap(pos[p], pos[p + 1]);
		}
		
		//?????????
		for (i = 1; i <= n; i++) {
			if (pos[i] == a) {
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
int main() {
  int n;
  cin >> n;
  vector<tuple<string, int, int>> data(n);
  rep(i,n){
    cin >> get<0>(data[i]) >> get<1>(data[i]);
    get<1>(data[i]) *= -1;
    get<2>(data[i]) = i+1;
  }
  sort(data.begin(),data.end());
  rep(i,n){
    cout << get<2>(data[i]) << endl;
  }
}


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

int main() {
  long N, K;
  cin >> N >> K;
  vector<long> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);

  vector DP(41, vector(2, -1L));
  DP.at(0).at(0) = 0;
  for (int i = 0; i < 40; i++) {
    int ri = 40 - i - 1;
    long mask = 1LL << ri;
    int cnt = 0;
    for (auto a : A) if (a & mask) cnt++;
    long c0 = cnt * mask;
    long c1 = (N - cnt) * mask;
    if (DP.at(i).at(1) != -1) {
      DP.at(i + 1).at(1) = max(DP.at(i + 1).at(1), DP.at(i).at(1) + max(c0, c1));
    }
    if (DP.at(i).at(0) != -1) {
      if (K & mask) DP.at(i + 1).at(1) = max(DP.at(i + 1).at(1), DP.at(i).at(0) + c0);
    }
    if (DP.at(i).at(0) != -1) {
      if (K & mask) DP.at(i + 1).at(0) = max(DP.at(i + 1).at(0), DP.at(i).at(0) + c1);
      else DP.at(i + 1).at(0) = max(DP.at(i + 1).at(0), DP.at(i).at(0) + c0);
    }
  }
  cout << max(DP.at(40).at(0), DP.at(40).at(1)) << "\n";
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    cout << n / 3 << endl;
    
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"
 
#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
typedef long long ll;
using namespace std;

int n;
string s;

int main(){
	cin>>n>>s;
	for(string ans:{"SS","SW","WS","WW"}){
		lp(n-1){
			if(s[i+1]=='o')
				if(ans[i]=='S')
					if(ans[i+1]=='S')
						ans+='S';
					else ans+='W';
				else if(ans[i+1]=='S')
					ans+='W';
				else ans+='S';
			else if(ans[i]=='S')
				if(ans[i+1]=='S')
					ans+='W';
				else ans+='S';
			else if(ans[i+1]=='S')
				ans+='S';
			else ans+='W';
		}
		if(ans[0]==ans[n]){
			if(s[0]=='o'){
				if(ans[0]=='S'){
					if(ans[n-1]==ans[1]){
						ans.pop_back();
						cout<<ans<<endl;
						return 0;
					}
				}
				else if(ans[n-1]!=ans[1]){
					ans.pop_back();
					cout<<ans<<endl;
					return 0;
				}
                    }
			else if(ans[0]=='S'){
				if(ans[n-1]!=ans[1]){
					ans.pop_back();
					cout<<ans<<endl;
					return 0;
				}
			}
			else if(ans[n-1]==ans[1]){
				ans.pop_back();
				cout<<ans<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<endl;
	return 0;
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

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

int n,m;
double v[22][22];
double dp[1<<16][22];

double dfs(int state,int num){
	
	if(dp[state][num] != -1)return dp[state][num];
	double ret = 0;
	
	REP(i,n){
		if(!(state & (1<<i))){
			double tmp = 0;
			double p = 1;
			for(int k = num;k < m;k++){
				tmp += p * (1 - v[i][k]) * dfs(state|(1<<i),k);
				p *= v[i][k];
			}
			ret = max(ret,tmp+p);
		}
	}
			
	return dp[state][num] = ret;
}

int main(){
	
	cin >> n >> m;
	
	REP(i,1<<16)REP(j,22)dp[i][j] = -1;
		
	REP(i,n){
		REP(j,m){
			cin >> v[i][j];
		}
	}
	
	cout << Decimal << dfs(0,0) << endl;
	
	return 0;
}


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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

int IN_int(){
    int x;
    scanf("%d",&x);
    return x;
}

//library----------------------------------------------

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const int NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}


signed main(){
    CIN(N,M,R);
    Graph G(N,vector<ll>(N,INF));
    vi r(R);
    rep(i,R)cin>>r[i];
    rep(i,N)G[i][i]=0;
    rep(i,M){
        int from,to,dis;
        cin>>from>>to>>dis;
        G[from-1][to-1]=dis;
        G[to-1][from-1]=dis;
    }
    ll ans=INF;
    sort(all(r));
    rep(i,N){
        rep(j,N){
            rep(k,N){
                G[j][k]=min(G[j][k],G[j][i]+G[i][k]);
            }
        }
    }
    do
    {
        ll cls=0;
        rep(i,R-1){
            cls+=G[r[i]-1][r[i+1]-1];
        }
        ans=min(ans,cls);
    } while (next_permutation(all(r)));
    printf("%lld\n",ans);

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>
#include<set>


using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

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

#define ketasitei setprecision(15) //15桁表示



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

	ll h, w;
	cin >> h >> w;

	ll n;
	cin >> n;

	cout << (n+max(h,w)-1) / max(h, w) << endl;

	return 0;
}

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

using namespace std;

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


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
  int	n, a=0, w=0, t=0, r=0;
  char	s[4]={0};

  scanf("%d", &n);
  for(int i=0; i<n; i++){
    scanf("%s", s);
    if	   ( strcmp(s, "AC")==0 ){ a++; }
    else if( strcmp(s, "WA")==0 ){ w++; }
    else if( strcmp(s, "TLE")==0 ){ t++; }
    else						  { r++; }
  }
  printf("AC x %d\n", a);
  printf("WA x %d\n", w);
  printf("TLE x %d\n", t);
  printf("RE x %d\n", r);
  return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b > c + d) {
    cout << "Left" << endl;
  } else if (a + b < c + d) {
    cout << "Right" << endl;
  } else {
    cout << "Balanced" << endl;
  }
  return 0;
}

Measured memory_bytes: 3624
// abc132_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;


int mod_pow(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

ll factorial[2001];
void make_factorial(int mo){ factorial[0] = 1; REPN(i, 1, 2001) factorial[i] = (i * factorial[i-1]) % mo; }
ll get_factorial(int n){ return n >= 0 ? factorial[n] : 0; }

ll nCk(int n, int k, int mo){
    ll a = get_factorial(n);
    ll b = get_factorial(n-k) * get_factorial(k) % mo;
    ll b_inv = mod_pow(b, mo-2, mo);
    return a * b_inv % mo;
}

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, K;
    cin >> N >> K;

    int b = K;
    int r = N - K;

    make_factorial(MOD);

    REPN(i, 1, K+1){
        ll ans = (nCk(r+1, i, MOD) * nCk(b-1, i-1, MOD)) % MOD;
        print(ans);
    }

    return 0;
}


Measured memory_bytes: 508
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int n;
		Scanner in = new Scanner(System.in);
		n = in.nextInt();
		in.nextLine();
		String x = in.nextLine();
		String[] heap = x.split(" ");
		in.close();
		for(int i = 0; i < n; i++) {
			System.out.println(relationships(heap, i, n));
		}
	}
	
	public static String relationships(String[] heap, int i, int n) {
		String s = "node " + (i + 1) + ": key = " + heap[i] + ", ";
		int parent = (i - 1) / 2;
		int leftC = (2 * i) + 1;
		int rightC = (2 * i) + 2;
		if(parent >= 0 && parent < n && parent != i) {
			s = s.concat("parent key = " + heap[parent] + ", ");
		}
		if(leftC >= 0 && leftC < n) {
			s = s.concat("left key = " + heap[leftC] + ", ");
		}
		if(rightC >= 0 && rightC < n) {
			s = s.concat("right key = " + heap[rightC] + ", ");
		}
		return s;
	}
}


Measured memory_bytes: 27672
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
using namespace std;
typedef long long ll;

void Main()
{
    ll a, b, n;
    cin >> a >> b >> n;
    int max = 0;

    if (b > n)
    {
        max = floor(a * n / b) - a * floor(n / b);
    }
    else
    {
        n = b-1;
        max = floor(a * n / b) - a * floor(n / b);
    }
    cout << max << endl;
}

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

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


int main()

{
    int n;
    cin>>n;
    ll a[n];

    for(int i=0;i<n;i++)
    {
        cin>>a[i];

    }
    ll cur=a[0]-1;

    for(int i=1;i<n;i++)
    {
        if(cur>a[i]){
            cout<<"No\n";
            exit(0);
        }

        cur= max((a[i]-1),cur);
    }

    cout<<"Yes\n";



    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

long long search_patty(long long ans, int n, long long res, vector<long long> num_layer, vector<long long> num_patty) {
    // cout << ans << ' ' << n << ' ' << res << endl;
    if (res <= 1) return ans;
    else if (res < num_layer[n - 1] + 1) {
        ans = search_patty(ans, n - 1, res - 1, num_layer, num_patty);
        return ans;
    } else if (res < num_layer[n] - 1) {
        ans += num_patty[n - 1];
        res -= num_layer[n - 1] + 1;
        if (!res) return ans;
        else ans = search_patty(ans + 1, n - 1, res - 1, num_layer, num_patty);
        return ans;
    } else {
        ans += num_patty[n];
        return ans;
    }
}

int main() {
    int N; long long X;
    cin >> N >> X;

    vector<long long> num_layer(N + 1), num_patty(N + 1);
    num_layer[0] = 1; num_patty[0] = 1;
    for (int i = 1; i <= N; i++) {
        num_layer[i] = 2*num_layer[i - 1] + 3;
        num_patty[i] = 2*num_patty[i - 1] + 1;
    }
    
    cout << search_patty(0, N, X, num_layer, num_patty) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep for(int s,i=lk[x];i;i=hd[i])\
if((s=to[i])^y)
const int N=400005;
using namespace std;
int n,to[N],hd[N],lk[N],cnt,
s1[N],s2[N],sum,ans[N];
inline void add(int u,int v){
	to[++cnt]=v,hd[cnt]=lk[u],lk[u]=cnt;
}int u,v;
void cal(int x,int y,int mx){
	if(x>mx)return;
	sum++;
	rep cal(s,x,mx);
}
void dfs(int x,int y,int mx){
	if(x>mx){
		ans[x]+=x>1;
		rep sum=0,cal(s,x,mx),s2[s]=sum,
		ans[x]+=sum,sum=0,cal(s,x,x),s1[s]=sum;
		mx=x;
	}
	rep ans[s]=ans[x]-s2[s]+s1[s],dfs(s,x,mx);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	scanf("%d%d",&u,&v),
	add(u,v),add(v,u);
	dfs(1,0,0);
	for(int i=2;i<=n;i++)
	printf("%d ",ans[i]);
}

Measured memory_bytes: 25344
#include <cmath>
#include<iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
using namespace std;
 
int main(){    
  int N;
  cin >> N;
  int d[N],sum=0;
  for(int i=0;i<N;i++){
    cin >> d[i];
  }

  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      sum += d[i]*d[j];
    }
  }
  
  cout << sum << endl;
}


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

#ifdef _MSC_VER
#include <Windows.h>
#else
#include <unistd.h>
#endif

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD=(LL)1e9+7;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

#define INF 1LL << 50

const LL MAX_N=(LL)2e5+3;
LL fact[MAX_N],ifact[MAX_N],inv[MAX_N];


void _inv(){
    inv[0]=inv[1]=1LL;
    for(LL i = 2LL;i < MAX_N;i++){
        inv[i]= (inv[MOD%i] * (MOD - MOD/i)) % MOD;
    }
}
void calc(){
    _inv();
    fact[0]  =1LL;
    ifact[0] =1LL;
    for(LL i = 1LL;i < MAX_N;i++){
        fact[i] = (fact[i-1LL] * i) % MOD;
        ifact[i]= (inv[i] * ifact[i-1]) % MOD;
    }
}
LL C(LL n, LL r){
    if(n < 0 || r < 0 || r > n)return 0;
    if(r>n/2LL)r = n - r;
    return (fact[n]*ifact[n-r]%MOD)*ifact[r]%MOD;
}
int main(){
    int H,W,A,B;
    cin>>H>>W>>A>>B;
    calc();
    LL ans=0;
    FOR(x,B+1,W+1){
        int y = H - A;
        int mx = x - 1, my = y - 1;
        LL tmp = C(mx + my, mx);
        mx = W - x, my = A - 1;
        tmp *= C(mx + my, mx);
        tmp %= MOD;
        ans += tmp;
        ans %= MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    string S,T;
    cin >> N >> S >> T;
    string ans="";
    for(int i=0; i<N; i++){
        ans.push_back(S.at(i));
        ans.push_back(T.at(i));
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
try:
    while 1:
        N, R = map(int, input().split())
        *C, = map(int, input().split())
        *A, = range(N)
        for c in C:
            lb = N//2; la = N - lb
            TA = A[N//2:]
            TB = A[:N//2]
            A = []
            a = b = 0
            while a < la and b < lb:
                A.extend(TA[a:min(a+c, la)])
                a += c
                A.extend(TB[b:min(b+c, lb)])
                b += c
            if a < la:
                A.extend(TA[a:])
            if b < lb:
                A.extend(TB[b:])
        print(A[-1])
except EOFError:
    ...


Measured memory_bytes: 5612
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int D = Integer.parseInt(sc.next());

        int p = 1 + D;
        int count = 0;
        if ( p < N ) {
            count++;
        } else {
            System.out.println(1);
            System.exit(0);
        }
        
        while (p < (N-D)) {
            p += (2*D+1);
            count++;
        }
            
        System.out.println(count);

    }
}

Measured memory_bytes: 21588
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int[] a = new int[n];
		for(int i=0; i<n; i++) {
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
		int alice=0,bob=0;
		for (int i=0; i<n; i++) {
			if(i%2==0) alice += a[a.length-(1+i)];
			else bob += a[a.length-(1+i)];
		}
		System.out.println(alice-bob);
	}
}


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

const int maxn = 1e5+5;
int n, m, q;
vector<int> adj[maxn];
int color[maxn];

int a[maxn][11];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    cin >> q; 
    deque<pair<int,int>> deq;
    for (int i = 1; i <= q; i++) {
        int v, d, c; cin >> v >> d >> c;
        color[i] = c;
        a[v][d] = i;
        deq.push_front({v,d});
    }
    while (!deq.empty()) {
        auto p = deq.front();
        deq.pop_front();
        int v = p.first;
        int d = p.second;
        if (d > 0) {
            for (int j: adj[v]) {
                if (a[j][d-1] < a[v][d]) {
                    a[j][d-1] = a[v][d];
                    deq.push_front({j,d-1});
                }
            }
        }
    }

    for (int i = 1; i <= n; i++) {
        int t = -1;
        for (int d = 0; d <= 10; d++) {
            t = max(t,a[i][d]);
        }
        cout << color[t] << '\n';
    }
}



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

// int countWays(int n) 
// { 
// 	// table[i] will be storing the number of 
// 	// solutions for value i. We need n+1 rows 
// 	// as the table is consturcted in bottom up 
// 	// manner using the base case (n = 0) 
	

// 	return table[n]; 
// } 

void solve(){
	ll n,d; cin>>n>>d;
	
	d=d*d;
	
	ll ans=0;
	
	while(n--){
		ll x,y; cin>>x>>y;
		
		ll res=x*x+y*y;
		
		if(res<=d){
			ans++;
		}
	}cout<<ans<<"\n";
}

int main(){
	
	 int t=1; //cin>>t;
	
	while(t--){
		solve();
	}
	
	return 0;
		
}

Measured memory_bytes: 3620
#include <iostream>
#include <stdlib.h>
using namespace std;

int main()
{
	int n;
	int a;

	cin >> n;

	a = n % 10;
	a = n % 10;

	if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9){
		cout << "hon" << endl;
	} else if (a == 0 || a == 1 || a == 6 || a == 8){
		cout << "pon" << endl;
	} else if (a == 3){
		cout << "bon" << endl;
	} else {
		exit(0);
	}

	return 0;
}


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

int main(void){
	int N;
	int r=0;//結果
	cin>>N;
	vector<int> a(N);
	for(int i=0; i<N; i++){
		cin>>a[i];
		a[i]--;
	}
	for(int i=0; i<N; i++){
		if(a[i]<i){
			continue;
		}
		if(a[a[i]]==i){
			r++;
		}
	}
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>

using namespace std;

inline int read()
{
  int x=0,f=1;char ch=getchar();
  while (!isdigit(ch)) {if (ch=='-') f=-1;ch=getchar();}
  while (isdigit(ch)) {x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
  return x*f;
}
long long a,b,c,x,y;
long long ans;
int main()
{
  cin>>a>>b>>c>>x>>y;
  while (x>0 && y>0)
  {
  	 if (2*c>a+b) ans+=a+b;
  	 else ans+=2*c;
  	 x--;
  	 y--;
  	 //cout<<ans<<endl;
  }
  if (x>0)
  {
  	ans=ans+min(a*x,2*c*x);
  }
  else
  if (y>0)
    ans=ans+min(b*y,2*c*y);
  cout<<ans;
  return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
edge = Array.new(n+1){Array.new}
anshash = {}
(n-1).times do
  a, b = gets.chomp.split.map(&:to_i)
  edge[a].push b
  edge[b].push a
  a,b=b,a if a>b
  anshash[[a,b]] = -1
end

q = [[1, -1]]
(n-1).times do |i|
  vol, used_color = q.shift
  color = 0
  edge[vol].each do |v|
    a,b = [[vol,v].min, [vol,v].max]
    next if anshash[[a,b]] > 0
    color += 1
    color += 1 if color == used_color
    q.push [v, color]
    anshash[[a,b]] = color
  end
end

puts anshash.values.max
anshash.each do |k, v|
  puts v
end

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

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            
            Console.WriteLine(a / 2+a%2);
        }
    }
}


Measured memory_bytes: 13140
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a:i32 = read();
    let b:i32 = read();
    let ans = (0..=1000)
        .filter(|x| x * 8 / 100 == a && x /10 == b)
        .nth(0)
        .unwrap_or(-1);
    println!("{}", ans);
}

Measured memory_bytes: 2148
from bisect import bisect_left
N = int(input())
A = [int(i) for i in input().split()]
A.sort()
cs = [A[0]]
ans = 1
for a in A[1:]:
    cs.append(cs[-1]+a)
for i in range(N-2, -1, -1):
    if cs[i]*2 >= A[i+1]:
        ans += 1
    else:
        break
print(ans)


Measured memory_bytes: 65148
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  int n;
  cin >> n;
  map<string, int> srtr;
  string str;
  cin >> str;
  srtr[str] = 1;

  for(int i = 1; i < n; i++){
    string temp;
    cin >> temp;
    if(srtr[temp] == 1 || str.back() != temp.front()){
      cout << "No" << endl;
      return 0;
    }
    srtr[temp] = 1;
    str = temp;
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int n, m, l, i, j, k;
    long long int a[100][100], b[100][100], c[100][100] = {0};

    scanf("%d %d %d", &n, &m, &l);

    for (i = 0; i < n; i++){
        for (j = 0; j < m; j++){
            scanf("%d", &a[i][j]);
        }
    }

    for(i = 0; i < m; i++){
        for (j = 0; j < l; j++){
            scanf("%d", &b[i][j]);
        }
    }

    for (i = 0; i < n; i++){
        for (j = 0; j < l; j++){
            for (k = 0; k < m; k++){
                c[i][j] += a[i][k] * b[k][j];
            }
        }
    }

    for (i = 0; i < n; i++){
        for (j = 0; j < l - 1; j++){
            printf("%lld ", c[i][j]);
        }
        printf("%lld\n", c[i][j]);
    }

    return 0;
}

Measured memory_bytes: 840
import java.util.Scanner;

//Swap Cipher
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			char[] s = sc.next().toCharArray();
			int[][] swap = new int[n][2];
			for(int i=0;i<n;i++)for(int j=0;j<2;j++)swap[i][j]=sc.nextInt()-1;
			for(int i=n-1;i>=0;i--){
				int a = swap[i][0];
				int b = swap[i][1];
				int d = b-a;
				s[a] = (char)((s[a]-'a'+d)%26+'a');
				s[b] = (char)((s[b]-'a'+d)%26+'a');
				char t = s[a];
				s[a] = s[b];
				s[b] = t;
			}
			System.out.println(new String(s));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <stdio.h>
int main(){
  int x,a,b;
  scanf("%d%d%d",&x,&a,&b);
  int c=x-a;
  int d=x-b;
  
  if(c<0)
    c=c*-1;
  
  if(d<0)
    d=d*-1;
  
  if(c>d)
    printf("B");
  
  if(c<d)
    printf("A");
  
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define int long long
#define d lld
#define pii pair<int,int>
#define fst first
#define sec second
#define ULTRA 2134567890
#define de(x) if(x!=0 && MODE==x)
#define MODE 0
using namespace std;

int H,W;
int C[2];
int D[2];
bool v[3007][3007] = {};
bool tp[3007][3007] = {};
char S[3007][3007] = {};
int mask[4][2] = {
    { 1, 0},
    { 0, 1},
    {-1, 0},
    { 0,-1}
};

bool ok(int r, int c) {
    return (1 <= r && r <= H && 1 <= c && c <= W) && S[r][c] == '.';
}

queue<pii> que;
void dfs(int r, int c) {
    v[r][c] = 1;
    for (int i=0; i<4; i++) {
        int n_r = r + mask[i][0];
        int n_c = c + mask[i][1];
        if (ok( n_r, n_c) && !v[n_r][n_c]) {
            dfs( n_r, n_c);
        }
    }
    for (int i=-2; i<=2; i++) {
        for (int j=-2; j<=2; j++) {
            int n_r = r + i;
            int n_c = c + j;
            if (ok( n_r, n_c) && !v[n_r][n_c] && !tp[n_r][n_c]) {
                tp[n_r][n_c] = 1;
                que.push({n_r, n_c});
            }
        }
    }
}

main() {
    int i,j;

    cin >> H >> W;
    cin >> C[0] >> C[1];
    cin >> D[0] >> D[1];

    for (i=1; i<=H; i++) {
        scanf("%s", S[i]+1);
    }

    que.push({ C[0], C[1]});
    int step = 0;
    while (!que.empty() && !v[ D[0] ][ D[1] ]) {
        int goal = que.size();
        while (goal--) {
            pii now = que.front();
            que.pop();
            if (!v[now.fst][now.sec]) {
                dfs( now.fst, now.sec);
            }
        }
        de(1) {
            for (i=1; i<=H; i++) {
                for (j=1; j<=W; j++) {
                    printf("%d", v[i][j]);
                }
                printf("\n");
            }
            printf("\n");
        }
        step++;
    }

    if( v[ D[0] ][ D[1] ])
        printf("%lld\n", step-1);
    else
        printf("-1\n");

    return 0;
}

//
//          ___ ___  __________  __________
//         /////\  \/\   ______\/\\\\\\\\\\\  Code by ~Ice Tea~ of
//        //// \ \  \ \  \_____/\ \\\\_____/      New Empire of CHSH ...
//       ////   \ \  \ \  \      \ \\\\\\\\\\\
//      ////__   \ \  \ \  \      \ \\\\_____/
//     ///////\   \ \  \ \  \______\ \\\\_______   ________
//    ////____/    \ \__\ \___   ___\ \\\\\\\\\\\ _\  ___  \_
//   /__/           \/__/\/__/\  \__/\ \\\\_____//\  .\_/\_  \
//                           \ \  \   \ \\\\\\\\\\\\  \_\/_\  \
// ... with the AC Power of   \ \  \   \ \\\\_____/ \   _____  \
//   The Great Tsundere Doggy. \ \  \   \ \\\\     \ \  \  \ \  \
//                              \ \__\   \ \\\\\\\\\\ \__\  \ \__\
//                               \/__/    \/________/\/__/   \/__/
//


Measured memory_bytes: 12764
#include <stdio.h>

int main(void) {
	
	int S;
	
	int h,m,s;
	
	scanf("%d\n",&S);
	
	h = S / 3600;
	
	m = (S % 3600 ) / 60;
	
	s = (S % 3600 ) % 60 ;
	
	
	printf("%d:%d:%d\n", h , m , s );
	
	return 0;
}

Measured memory_bytes: 596
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    let chars: Vec<char> = buf.trim().chars().collect();

    let mut max = 0;
    let mut t = 0;
    for c in chars {
        match c {
            'A' | 'G' | 'C' | 'T' => {
                t+=1;
            },
            _ => {
                max = std::cmp::max(max, t);
                t = 0;
            },
        }
    }

    max = std::cmp::max(max, t);

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


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

int main()
{
  int N;
  int L[201];
  cin>>N;
  for (int i=0;i<N*2;i++)
    cin>>L[i];
  sort(L,L+N*2);
  int ans=0;
  for (int i=0;i<N*2;i+=2)
    ans+=L[i];
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	int a,b,c,s;
	cin>>a>>b>>c;
	s=3*max(a,max(b,c))-a-b-c;
	if(s%2)s+=3;
	cout<<s/2<<endl;
}

Measured memory_bytes: 256
fibo_list=[0 for i in range(48)]

def fibo(n):
    f=fibo_list[n]
    if f:
        return f
    else:
        if n==0 or n==1:
            return 1
        else:
            f=fibo(n-1)+(fibo(n-2))
    fibo_list[n]=f
    return f


n=input()
print(fibo(n))

Measured memory_bytes: 6444
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    ll ans = 0;
    if (N % 2LL == 1LL) { // 奇数
        cout << 0 << endl;
        return 0;
    } else { // 偶数
        FOR(i, 1, 28) {
            ll div = 1LL;
            REP(j, i) { div *= 5LL; }
            ans += (N / div) / 2LL;
        }
        cout << ans << endl;
        return 0;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ri register int
const long double PI=3.141592653589793238462643383279;
const int N=500005;
int n,a[500005],i,j,k;
char c[500005];
long long ans;
int main()
{
	scanf("%s",c+1);
	n=strlen(c+1);
	if(c[0]=='<')
		a[0]=1;
	for(i=0;i<=n;++i)
		if((c[i+1]=='<'&&i==0)||(c[i]=='>'&&c[i+1]=='<')||(c[i]=='>'&&i==n))
		{
			a[i]=0;
			k=1;
			for(j=i-1;j>=0&&c[j+1]=='>';--j,++k)
				a[j]=max(a[j],k);
			k=1;
			for(j=i+1;j<=n&&c[j]=='<';++j,++k)
				a[j]=max(a[j],k);
		}
	for(i=0;i<=n;++i)
		ans+=a[i];
	cout<<ans;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
char c[maxn];
int s[maxn];
int main(){
	int i,j,k,m,n,q;
	cin>>n>>q;
	scanf("%s",c+1);
	for(i=2;i<=n;i++){
		if(c[i]=='C'&&c[i-1]=='A')s[i]=s[i-1]+1;
		else s[i]=s[i-1];
	}
	while(q--){
		int x,y;
		scanf("%d%d",&x,&y);
		printf("%d\n",s[y]-s[x]);
	}
	return 0;
}

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

int main() {
  // ここにプログラムを追記
  
  int N, A, B;
  cin >> N >> A >> B;
  
  //プラン１
  int a = N * A;
  
  //安い方
  int x = min(a, B);
  
  cout << x << endl;
  
  return 0;
  
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, x;
	cin >> n >> x;

	vector<int> l(n);
	for (auto &v : l) {
		cin >> v;
	}

	vector<int> dp(n + 1);
	for (int i = 1; i <= n; i++) {
		dp[i] += dp[i - 1] + l[i - 1];
	}
	
	int ans = 0;
	for (int i = 0; i <= n; i++) {
		if (dp[i] <= x) {
			ans++;
		} else {
			break;
		}
	}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;
constexpr int mod = 1e9+7;

int main(){
  string s;
  cin >> s;
  int n = sz(s);
  
  for (int i = n/2-1; i >= 0; i--) {
    if (s.substr(0, i + 1) == s.substr(i + 1, i + 1)) {
      if (n == 2 * i + 2) continue;
      cout << 2 * i + 2 << endl;
      return 0;
    }
  }
  
  return 0;
} 

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

int main()
{
    int h,n;
    std::cin >> h >> n;
    long long res = 0;
    for(int i = 0; i < n; i++){
        int t;
        std::cin >> t;
        res += t;
    }
    std::cout << (h <= res ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD      1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;
ll ans=0;

int main(){

    
    cin >> N;
    cin >> K;

    if(K==N+1){
        cout << 1 << endl;
    }else{
        ll left     = 0;
        ll right    = 0;

        for( int cnt = 1 ; cnt <=K-1 ; cnt++ ){
            ll d = cnt-1;
            left += d;
            right += (N-d);
        }    

        for( int cnt = K ; cnt <=N+1 ; cnt++ ){
            ll d = cnt-1;
            left += d;
            right += (N-d);
            ans += (right - left) + 1;
            ans = ans % MOD;
            //cout << left << " : " << right << " = " << ans << endl;

        }    

        cout << ans << endl;

    }

}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pairs;

#define MOD 998244353


ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}



int main(){
    for(ll i = 0; i<10000; i++){
        ll x;
        cin>>x;
        cout<<"Case"<<" "<<i+1<<":"<<" "<<x<<endl;
    }
    
    return 0;
}
 



Measured memory_bytes: 3004
#include<stdio.h>
#include<stdlib.h>
#define MAX 20000  // スタックの最大値

typedef struct{
  int top;         // スタックポインタ(一番上の位置)
  int S[MAX];
}Stack;


// スタック st の初期化
void initialize(Stack *st)
{
  st->top = 0;
  st->S[st->top] = 0;
}

// スタック st が空かどうかを確認
int isEmpty(Stack *st)
{
  return st->top == 0;
}

// スタック st が一杯かどうかを確認
int isFull(Stack *st)
{  
  return st->top >= MAX - 1;
}

// スタック st に要素 x をプッシュ(一番上に要素を追加)
void push(int x, Stack *st)
{
  if (isFull(st)) 
    exit(1);

  st->top++;
  st->S[st->top] = x;
}

// スタック st から要素をポップ(一番上の要素を取り出す)
int pop(Stack *st) {
  if (isEmpty(st)) 
    exit(1);

  st->top--;
  return st->S[st->top+1];
}


int main(void)
{
  Stack st1;     // '\' の開始位置を格納するスタック
  Stack st2_j;   // 各水たまりの最も左の'\' の位置を格納するスタック
  Stack st2_a;   // 各水たまりの水量を格納するスタック

  // スタック初期化
  initialize(&st1);
  initialize(&st2_j);
  initialize(&st2_a);
	
  char c;
  int sum = 0;  // 水たまりの総水量

  // 地形を読み込み，各水たまりの水量を計算
  for (int i = 0; (c = getchar()) != EOF; i++) {
    if (c == '\\') {                                 // '\' が出た時の処理
      // 位置 i を st1 にプッシュ(write your code)
    	push(i,&st1);
    }else if (!isEmpty(&st1) && c == '/') {          // '/' が出た時の処理
      // 水たまりの総水量 sum を更新(write your code)
    	int j = pop(&st1);
    	
    	sum += i-j;
      // st2_j と st2_a を用いて水たまりの水量を更新 
      int a = i - j;   // 更新する水たまりの水量を a に格納していく
      while (!isEmpty(&st2_j) && st2_j.S[st2_j.top] > j) {  // 最も左の '\' の位置が j よりも大きい場合，以下を繰り返す
        // 水たまりの水量を求めていく (write your code)
      	a += pop(&st2_a);
      	pop(&st2_j);
      }
      // 更新した水たまりの「最も左の'\' の位置」および「水量」を更新 (write your code)
    	push(j,&st2_j);
    	push(a,&st2_a);
    }
  }

  printf("%d\n", sum);       // 水たまりの総水量を出力
  printf("%d", st2_a.top);   // 水たまりの個数を出力

  // 各水たまりの水量を断面図の左から出力(スタックの底から出力)
  for (int i = 1; i <= st2_a.top; i++) 
    printf(" %d", st2_a.S[i]);  
    printf("\n");

  return 0;
}


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

int main() {
	double a, b, c, d, e, f;
	while (cin >> a >> b >> c >> d >> e >> f) {
		double ansX = (e*c - b*f) / (a*e - b*d);
		double ansY = (a*f - d*c) / (a*e - b*d);
		if (ansX < 0.0005&&-0.0005 < ansX)ansX = 0;
		if (ansY < 0.0005&&-0.0005 < ansY)ansY = 0;
		printf("%.3f %.3f\n", ansX, ansY);
	}

	return 0;
}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const int N = 100005;
vector<pair<int, int>> con[N];
int minEdge = 1e9;
bool eq = false;
int sz[N];
ll ans = 0;
int n;
void dfs(int s =1, int p = 0){
	sz[s] = 1;
	int mne = 1e9, mxs = 0;
	for(auto it : con[s]){
		int v = it.F;
		int weight = it.S;
		mne = min(mne, weight);
		if(v != p){
			dfs(v, s);
			sz[s] += sz[v];
			ans += min(sz[v], n - sz[v]) * 2ll * weight;
			if(sz[v] == n - sz[v]){
				minEdge = weight;
			}
			mxs = max(mxs, sz[v]);
		}
	}
	mxs = max(mxs, n - sz[s]);
	if(2 * mxs < n){
		minEdge = mne;
	}
}
int main(){
	sd(n);
	for(int i = 1; i < n; i++){
		int u, v, w;
		sd(u); sd(v); sd(w);
		con[u].push_back({v, w});
		con[v].push_back({u, w});
	}
	dfs();
	printf("%lld\n", ans - minEdge);
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll a, b;
    
    cin >> a >> b;
    
    if((a + b) % 2 != 0) printf("IMPOSSIBLE");
    else printf("%d", (a + b) / 2);
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,k;std::cin>>n>>k;
    std::vector<lint>a(n);
    for(lint&x:a)std::cin>>x;
    std::sort(a.begin(),a.end(),std::greater<>{});
    std::cout<<std::accumulate(a.begin(),a.begin()+k,0ll)<<'\n';
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N, K;
int A[200005], B[200005];

int main() {
  INCANT;
  cin >> N >> K;
  rep(i, N) cin >> A[i];
  int cnt=0;
  while(cnt<K) {
    fill(B, B+N, 0);
    rep(i, N) {
      B[max(i-A[i], 0)]++;
      B[min(i+A[i]+1, N)]--;
    }
    A[0]=B[0];
    bool flag=A[0]==N;
    for (int i=1;i<N;i++) {
      A[i] = A[i-1]+B[i];
      if (A[i]<N) flag=false;
    }
    if (flag) break;
    cnt++;
  } 
  rep(i, N) cout << A[i] << ' ';
  cout << endl;
  return 0;
}

Measured memory_bytes: 5168
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	rep(i, n) {
		char c = s[n - 1];
		string sub = s.substr(0, n - 1);
		s = c + sub;
		if (s == t) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(0);

    int N;
    cin >> N;
    for (int i = 1; i <= 9; i++)
        for (int j = 1; j <= 9; j++)
        {
            if (i * j == N)
            {
                cout << "Yes\n";
                return 0;
            }
        }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main(void){

    int num1=0, num2=0;
    int leng=0, side=0;
    int cell, blacked;
    int error=0;

    do{
        if(error==1){
            printf("[error] you wrong input number. return again.\n");
        }
        scanf("%d %d\n%d %d",&num1,&num2,&leng,&side);
        error =1;
    }while((0>leng || num1<leng) || (0>side || num2<side) || (num1>20 || num1<1) || (num2>20 || num2<1) );

    cell = num1 * num2;

    blacked = num2*leng + num1*side - leng*side;

    printf("%d\n", cell-blacked);
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {
    int A,B,C;
    Scd3(A,B,C);
    printf("%d\n", A*B/2 );

    return 0;
}



Measured memory_bytes: 256
#import<bits/stdc++.h>
using namespace std;string s;long long r[10]={1,11,112,1124,11248,112496,1124992,11249984,112499968,1124999936};long long a,i;main(){cin>>s;for(;i<s.size();++i)a+=(r[s.size()-i-1]<<i)*(s[i]-48);cout<<a<<endl;}

Measured memory_bytes: 256
x = []
y = []
x[0] = gets.chomp.to_i
i = 1
while x[i-1] != 0
  x[i] = gets.chomp.to_i
  i = i+1
end
i = i-1
x.delete_at(i)
i = i-1

for j in 0..i
 change = 1000-x[j] 
 y[j] = 0
   if change >= 500
      y[j] = y[j] + 1
      change = change-500
   end
   if change >= 100
      y[j] = y[j]+1
      change = change - 100
     while change >= 100
       y[j] = y[j] + 1
       change = change-100      
     end
     
   end
   if change >= 50
     y[j] = y[j]+1
     change = change-50
   end
   if change >= 10
      y[j] = y[j]+1
      change = change-10
     while change >= 10
       y[j] = y[j]+1
       change = change-10      
     end
   end
   if change >= 5
     y[j] = y[j]+1
     change = change-5
   end
   if change >= 1
      y[j] = y[j]+1
      change = change-1
     while change >= 1
       y[j] = y[j]+1
       change = change-1   
     end
   end
end
for k in 0..i
  puts y[k]
end 



Measured memory_bytes: 6844