akhauriyash/Code-Regression huggingface dataset:
#include <iostream> 
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>
#include <climits>

using namespace std;

using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

using ll = long long int;

#define mp(a,b) make_pair(a,b)

const int MOD = 1000 * 1000 * 1000 + 7;

bool res() {
	int n;
	cin >> n;
	if (!cin) return false;

	ll pot = pow(2, n);

	map<int, int> rest;
	int minn = 10;
	for (int i = 0; i < pot; ++i) {
		int num;
		cin >> num;
		minn = min(minn, -num);

		if (rest.find(-num) == rest.end()) rest.insert(mp(-num, 1));
		else ++rest[-num];
	}

	vi act, sig;

	act.push_back(minn);
	sig.push_back(minn);
	--rest[minn];
	if (rest[minn] == 0) rest.erase(minn);

	bool pos = true;

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < act.size(); ++j) {
			auto it = rest.upper_bound(act[j]);
			if (it == rest.end()) {
				pos = false;
				break;
			}
			else {

				sig.push_back(it->first);
				--rest[it->first];
				if (rest[it->first] == 0) rest.erase(it->first);
			}
		}

		act = sig;
	}

	if (pos) cout << "Yes\n";
	else cout << "No\n";

	return true;
}

int main() {
	while (res()) {}
	return 0;
}

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

#define EQ(a,b) (abs((a)-(b)) < EPS)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define sz size()
#define all(a) (a).begin(),(a).end()

using namespace std;
typedef double D;
typedef pair<D,D> P;
typedef pair<P,P> L;

const D EPS = 1e-8;
const D PI = acos(-1);

inline P add(P a, P b){ return P(a.fs+b.fs, a.sc+b.sc);}
inline P sub(P a, P b){ return P(a.fs-b.fs, a.sc-b.sc);}
inline D abs(P x){return sqrt(x.fs*x.fs + x.sc*x.sc);}

//for vector
inline D dot(P a, P b){return a.fs*b.fs+a.sc*b.sc;}
inline D cross(P a, P b){return a.fs*b.sc-a.sc*b.fs;}

//rotate a point counter-clockwise on the origin
inline P rotate(P v, D s){
  return P(v.fs*cos(s) - v.sc*sin(s), v.fs*sin(s) + v.sc*cos(s) );
}

inline int ccw(P a,P b,P c){
  b = sub(b,a); c = sub(c,a);
  if (cross(b,c)>EPS) return 1;   //counter clockwise
  if (cross(b,c)<-EPS) return -1; //clockwise
  if (dot(b, c)<-EPS) return 2;   //c--a--b on line
  if (abs(b)+EPS<abs(c)) return -2;   //a--b--c on line
  return 0;                       //on segment
}

inline bool is_cp(L a,L b){
  if(ccw(a.fs,a.sc,b.fs)*ccw(a.fs,a.sc,b.sc)<=0)
    if(ccw(b.fs,b.sc,a.fs)*ccw(b.fs,b.sc,a.sc)<=0)return true;
  return false;
}

inline D seg_p_dis(L a,P x){
  if(dot(sub(a.sc,a.fs),sub(x,a.fs))<EPS)return abs(sub(x,a.fs));
  if(dot(sub(a.fs,a.sc),sub(x,a.sc))<EPS)return abs(sub(x,a.sc));
  return abs(cross(sub(a.sc,a.fs),sub(x,a.fs)))/abs(sub(a.sc,a.fs));
}

D g[111][111],d[111];
L starl[111][5];
P starv[111][5],c,p;
int n,m,l,x,y,a,r;
bool use[111];

int main(){
  while(scanf("%d%d%d",&n,&m,&l), n){
    for(int i=0;i<n;i++){
      scanf("%d%d%d%d",&x,&y,&a,&r);
      c = P(x,y), p = P(0,r);
      for(int j=0;j<5;j++)starv[i][j] = add(c,rotate(p,PI*(a+j*72)/180));
      for(int j=0;j<5;j++)starl[i][j] = L(starv[i][j],starv[i][(j+2)%5]);
    }

    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	D dis = 1e9;
	for(L a : starl[i]){
	  for(L b : starl[j]){
	    if(is_cp(a,b)){dis = 0; break;}
	  }
	}
	if(dis>EPS){
	  for(P a : starv[i]){
	    for(L b : starl[j])dis = min(dis, seg_p_dis(b,a));
	  }
	  for(P a : starv[j]){
	    for(L b : starl[i])dis = min(dis, seg_p_dis(b,a));
	  }
	}
	g[i][j] = g[j][i] = dis;
      }
      g[i][i] = 0;
    }
    
    for(int i=0;i<n;i++)d[i] = 1e9;
    d[m-1] = 0;
    memset(use,0,sizeof(use));
    
    for(;;){
      int v = -1;
      for(int u=0;u<n;u++){
	if(!use[u] && (v<0 || d[v] > d[u]))v = u;
      }
      
      if(v<0 || v==l-1)break;
      use[v] = 1;
      
      for(int u=0;u<n;u++){
	d[u] = min(d[u],d[v]+g[u][v]);
      }
    }
    
    printf("%.9lf\n",d[l-1]);
  }
}	

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

int main(){
 int n;
  cin >> n;
  vector <int> p(n), q(n);
  rep(i, n) cin >> p[i];
  rep(i, n) cin >> q[i];
  vector <int> a(n);
  rep(i, n) a[i] = i + 1;
  
  map<vector <int>, int> mp;
  do{
    mp[a] = mp.size(); 
  }while(next_permutation(a.begin(), a.end()));
  
  int ans = abs(mp[p] - mp[q]);
  cout << ans << endl;
}


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

int main() {
    string a, b, c;
    cin >> a >> b >> c;
    if (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

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

using ll = long long;
using ull = unsigned long long;

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

    string s, t;
    cin >> s >> t;

    int len = s.size();
    int ops = 0;
    for (int i = 0; i < len; ++i) {
        if (s[i] != t[i]) {
            ++ops;
        }
    }

    cout << ops << "\n";


    return 0;
}

Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  if(a*2-1>a+b){
    cout << a*2-1 << endl;
  } else if (b*2-1>a+b){
    cout << b*2-1 << endl;
  } else {
    cout << a+b << endl;
  }
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;

	if (n%2) {
		cout << 0 << endl;
		return 0;
	}

	ll res = 0;
	for (; n > 0; n /= 5) res += n/10;
	cout << res << endl;
}



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

long long int arr[3005];
long long int dp[3005][3005];
int n;
long long int call(int i,int j)
{
	 
	   
	 if(j==i+1)
	 return max(arr[j],arr[i]);
	 
	 if(j==i)
	  return arr[i];
	  
	  if(dp[i][j]!=-1)
	   return dp[i][j];
	   
	return dp[i][j]=max(arr[i]+min(call(i+2,j),call(i+1,j-1)),arr[j]+min(call(i,j-2),call(i+1,j-1)));
}

 int main()
{ 
    
     cin>>n;
     long long int sum=0;
     for(int i=0;i<n;i++)
    {
	   cin>>arr[i];
       sum+=arr[i];
   }
       for(int i=0;i<=n;i++)
         for(int j=0;j<=n;j++)
          dp[i][j]=-1;
          
     cout<<2*call(0,n-1)-sum<<endl;  
       
     return 0;
}




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

using namespace std;

struct Dinic {
    //using F = int; const static F INF = 0x3f3f3f3f; 
    using F = long long; const static F INF = 0x3f3f3f3f3f3f3f3f; 
    struct Edge {
        int v, bro; F cap;
        Edge() {}
        Edge(int _v, int _bro, F _cap) : v(_v), bro(_bro), cap(_cap) {}
    };
    vector<Edge> e;
    vector<int> pos, cur;
    int n, s, t, m;
    Dinic(int _n, int _s, int _t) : n(_n), s(_s), t(_t), m(0) {
        pos.assign(n, -1);
        cur.resize(n);
        d.resize(n);
        e.reserve(4e5);
    }
    void add(int u, int v, F c=INF) {
        assert(u < n && v < n);
        e.emplace_back(v, pos[u], c); pos[u] = m++;
        e.emplace_back(u, pos[v], 0); pos[v] = m++;
    }
    vector<int> d;
    // build layer graph
    bool bfs() {
        fill(d.begin(), d.end(), -1);
        d[s] = 0;
        queue<int> q; q.push(s);
        while (!q.empty()) {
            int u = q.front(); q.pop();
            for (int i = cur[u] = pos[u]; i != -1; i = e[i].bro) {
                int v = e[i].v;
                if (d[v] == -1 && e[i].cap != 0) {
                    d[v] = d[u] + 1;
                    q.push(v);
                }
            }
        }
        return d[t] != -1;
    }
    // find blocking flow
    F dfs(int u, F lim) {
        if (u == t) return lim;
        F tot = 0;
        for (int& i = cur[u]; i != -1; i = e[i].bro) {
            int v = e[i].v;
            if (e[i].cap != 0 && d[v] == d[u] + 1) {
                F flow = dfs(v, min(e[i].cap, lim-tot));
                tot += flow;
                e[i].cap -= flow;
                e[i^1].cap += flow;
                if (tot == lim) return lim;
            }
        }
        return tot;
    }
    F flow() {
        F res = 0;
        while (bfs()) {
            res += dfs(s, INF);
        }
        return res;
    }
};
using ll=long long;
void solve() {
    int n; cin >> n;
    vector<int> a(n);
    ll best = 0;
    for (auto& x: a) {
        cin >> x;
        if (x > 0) best += x;
    }
    int S = 0, T = n + 1;
    Dinic mc(T+1, S, T);
    // remove i?
    for (int i = 0; i < n; i++) {
        if (a[i] > 0) mc.add(i+1, T, a[i]);
        if (a[i] < 0) mc.add(S, i+1,-a[i]);
    }
    for (int i = 1; i <= n; i++) {
        for (int j = i; (j+=i) <= n;) {
            mc.add(i, j);
        }
    }
    cout << best - mc.flow();
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 256
//kruskal tree
#include <cstdio>
#include <algorithm>
using namespace std;
#define M 9999
int parent[M],a[M],b[M];
pair<int,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int differ(int a,int b){
	int x=root(a),y=root(b);
	if(x==y)return 0;
	return 1;
}
int unite(int a,int b){
	int x=root(a),y=root(b);
	if(x==y)return 0;
	parent[x]=y;
	return 1;
}
int main(){
	int i,j,n,m,r,R;
	for(;scanf("%d%d",&n,&m),n;printf("%d\n",R)){
		for(i=0;i<m;i++)scanf("%d%d%d",a+i,b+i,&node[i].first),node[i].second=i,a[i]--,b[i]--;
		sort(node,node+m);
		for(R=-1,i=0;i<m;i++){
			for(j=0;j<n;j++)parent[j]=j;
			for(j=i;j<m;j++)if(unite(a[node[j].second],b[node[j].second]))r=node[j].first-node[i].first;
			for(j=1;j<n&&!differ(0,j);j++);
			if(j==n&&(R==-1||R>r))R=r;
		}
	}
}

Measured memory_bytes: 1152
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;

int main(){
	string s, t;
	cin >> s >> t;

	int ans = 0;
	int n = s.size();
	for(int i = 0; i < n; i++){
		char tmp = s[n - 1];
		for(int i = n; i >= 2; i--) s[i - 1] = s[i - 2];
		s[0] = tmp;

		if(s == t){
			ans = 1;
			break;
		}
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const string YES = "Yes";
const string NO = "No";

int main(){
    string n;
    cin >> n;
    ll total = 0;
    for(char c : n){
        total += c - '0';
    }
    if(total % 9 == 0){
        cout << YES << endl;
    }else{
        cout << NO << endl;
    }
    return 0;
}


Measured memory_bytes: 3732
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

string s[3];
int main()
{
    while(cin >> s[0])
    {
        if(s[0] == "0" ) break;
         cin >> s[1] >> s[2];
         bool b = false, w = false;
         REP(3)
         {
             if(s[i][0] == 'b' && s[i][1] == 'b' && s[i][2] == 'b') b = true; 
             if(s[i][0] == 'w' && s[i][1] == 'w' && s[i][2] == 'w') w = true; 
             if(s[0][i] == 'b' && s[1][i] == 'b' && s[2][i] == 'b') b = true; 
             if(s[0][i] == 'w' && s[1][i] == 'w' && s[2][i] == 'w') w = true; 

         }
         if(s[0][0] == 'b' && s[1][1] == 'b' && s[2][2] == 'b' ) b = true;
         if(s[0][0] == 'w' && s[1][1] == 'w' && s[2][2] == 'w' ) w = true;
         if(s[0][2] == 'b' && s[1][1] == 'b' && s[2][0] == 'b' ) b = true;
         if(s[0][2] == 'w' && s[1][1] == 'w' && s[2][0] == 'w' ) w = true;

         if(w){ cout << "w" << endl; continue;}
         if(b){ cout << "b" << endl; continue;}
         cout << "NA" << endl; 
    }
    return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class 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;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

////////// 二項係数(N<=10^7) //////////

ll fac[MAX],finv[MAX],inv[MAX];
// fac[i] i!
// finv[i] i!の逆元
// inv[i] iの逆元

// テーブルを作る前処理
void COM_init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(ll i=2; i<MAX; ++i){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

// 二項係数計算
ll COM(ll n,ll k){
  if(n<k) return 0;
  if(n<0 || k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

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

int main(){
  ll N,ans=0;
  cin>>N;
  
  COM_init();
  for(int i=1; i<=N/3; ++i){
    ll T=N-3*i;
    ans+=COM(T+i-1,i-1);
    ans%=MOD;
  }
  
  ans=(ans%MOD+MOD)%MOD;
  co(ans);
  return 0;
}

Measured memory_bytes: 50648
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 200009;
#define ll long long
ll a[maxn];
int main(){
	ll n, t;
	scanf("%lld%lld", &n, &t);
	for(int i = 0; i < n; ++i){
		scanf("%lld", &a[i]);
	}
	sort(a, a+n);
	a[n] = 1e10;
	ll x, num, sum = 0;
	for(int i = 0; i <= n; ++i){
		if(i == 0) x = a[i]+t, num = a[i];
		else{
			if(a[i] > x) sum = sum + x - num, x = a[i]+t, num = a[i];
			else x = max(x, a[i]+t);
		}
	}
	printf("%lld\n", sum);
	return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int W = scanner.nextInt();
        int[] w = new int[n];
        int[] v = new int[n];
        for (int i = 0; i < n; ++i) {
            w[i] = scanner.nextInt();
            v[i] = scanner.nextInt();
        }
        System.out.println(knapsack(W, w, v));
    }

    private static long knapsack(int W, int[] w, int[] v) {
        long[][] dp = new long[w.length][W + 1];
        for (long[] dpRow : dp) {
            Arrays.fill(dpRow, -1);
        }
        return calcMaxValue(0, w, v, W, dp);
    }

    private static long calcMaxValue(int curInd, int[] w, int[] v, int W, long[][] dp) {
        if (curInd >= w.length)
            return 0;
        if (dp[curInd][W] != -1)
            return dp[curInd][W];
        if (w[curInd] > W)
            return calcMaxValue(curInd + 1, w, v, W, dp);
        long maxValue = Math.max(
                calcMaxValue(curInd + 1, w, v, W, dp),
                v[curInd] + calcMaxValue(curInd + 1, w, v, W - w[curInd], dp));
        dp[curInd][W] = maxValue;
        return maxValue;
    }
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(int(chrono::steady_clock::now().time_since_epoch().count()));

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

    int N;
    cin >> N;

    string S;
    cin >> S;

    int Q;
    cin >> Q;

    for (int q = 0; q < Q; q++) {
        int K;
        cin >> K;

        ll d = 0, dm = 0, m = 0, dmc = 0;
        for (int i = 0; i < N; i++) {
            if (i >= K) {
                char r = S[i - K];
                if (r == 'D') { dm -= m; d--; }
                else if (r == 'M') { m--; }
            }
            char c = S[i];
            if (c == 'D') d++;
            else if (c == 'M') { dm += d; m++; }
            else if (c == 'C') dmc += dm;
        }
        cout << dmc << "\n";
    }

    return 0;
}



Measured memory_bytes: 1948
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const ll MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r,g,b,n;
    ll ans=0;
    cin>>r>>g>>b>>n;
    rep(i,3001){
        rep(j,3001){
            if((n-i*r-j*g)%b==0 && n-i*r-j*g>=0) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	private static final BigDecimal BD1000000007 = new BigDecimal(1000000007);
	private static BufferedReader brStdin = new BufferedReader(new InputStreamReader(System.in));
	private static String[] readBuf = null;
	private static int readPtr = 0;
	private static String getString() throws IOException {
		while ( readBuf == null || readPtr >= readBuf.length ) {
			readBuf = brStdin.readLine().split(" ");
			readPtr = 0;
		}
		return readBuf[readPtr++];
	}
	private static int getInt() throws IOException {
		return Integer.parseInt(getString());
	}
	private static long getLong() throws IOException {
		return Long.parseLong(getString());
	}
	private static BigDecimal getBD() throws IOException {
		return new BigDecimal(getString());
	}
	@SuppressWarnings("unused")
	private static String[] getStringArray(int size) throws IOException {
		String stringArray[] = new String[size];
		for (int i = 0; i < stringArray.length; i++) {
			stringArray[i] = getString();
		}
		return stringArray;
	}
	@SuppressWarnings("unused")
	private static int[] getIntArray(int size) throws IOException {
		int intArray[] = new int[size];
		for (int i = 0; i < intArray.length; i++) {
			intArray[i] = getInt();
		}
		return intArray;
	}
	@SuppressWarnings("unused")
	private static long[] getLongArray(int size) throws IOException {
		long longArray[] = new long[size];
		for (int i = 0; i < longArray.length; i++) {
			longArray[i] = getLong();
		}
		return longArray;
	}
	@SuppressWarnings("unused")
	private static BigDecimal[] getBDArray(int size) throws IOException {
		BigDecimal bdArray[] = new BigDecimal[size];
		for (int i = 0; i < bdArray.length; i++) {
			bdArray[i] = getBD();
		}
		return bdArray;
	}
	
	public static void main(String args[]) throws IOException {
		int n = getInt();
		int k = getInt();
		BigDecimal f[] = new BigDecimal[n+1];
		f[0]=BigDecimal.ONE;
		for (int i = 1 ; i <= n ; i++) {
			f[i]=f[i-1].multiply(new BigDecimal(i));
		}
		BigDecimal a = f[k-1].multiply(f[n-k+1]).divide(f[k-1]).divide(f[n-k]) ;
		BigDecimal d = a.divide(BD1000000007, BigDecimal.ROUND_DOWN);
		System.out.println(a.subtract(BD1000000007.multiply(d))) ;
		for ( int i = 2; i <= k ; i++ ) {
			if ( n-k+1-i < 0 ) {
				System.out.println(0) ;
			} else {
				a = a.multiply(new BigDecimal(k-i+1)).multiply(new BigDecimal(n-k+2-i)).divide(new BigDecimal((i-1)*i));
				d = a.divide(BD1000000007, BigDecimal.ROUND_DOWN);
				System.out.println(a.subtract(BD1000000007.multiply(d))) ;
			}
		}
	}
}


Measured memory_bytes: 85980
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)

#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll xs, ys, xt, yt;
int N;
const int MAX_N = 1000;
ll x[MAX_N + 2], y[MAX_N + 2], r[MAX_N + 2];

// set V in main
// d[MAX_V] shows the answer

const int MAX_V = 100000;

struct edge{int to; double cost;};
typedef pair<double, int> P;

int V;
vector<edge> G[MAX_V];
double d[MAX_V];

void dijkstra(int s){
  priority_queue<P, vector<P>, greater<P>  > que;
  fill(d, d + V, INFll);
  d[s] = 0;
  que.push(P(0,s));

  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second;
    if(d[v] < p.first) continue;
    for(int i = 0; i < G[v].size(); i++){
      edge e = G[v][i];
      if(d[e.to] > d[v] + e.cost){
      d[e.to] = d[v] + e.cost;
      que.push(P(d[e.to], e.to));
      }
    }
  }
}

int main(){
  cin >> xs >> ys >> xt >> yt;
  cin >> N;
  REP(i, N) cin >> x[i] >> y[i] >> r[i];
  x[N] = xs, x[N + 1] = xt, y[N] = ys, y[N + 1] = yt, r[N] = 0, r[N + 1] = 0;

  REP(i, N + 2) {
    for (int j = i + 1; j < N + 2; j++) {
      double dis = sqrt(double((x[i] - x[j]) * (x[i] - x[j])) + double((y[i] - y[j]) * (y[i] - y[j])));
      double cost = max(0.0, dis - r[i] - r[j]);
      G[i].pb(edge{j, cost});
      G[j].pb(edge{i, cost});
    }
  }

  V = N + 2;
  dijkstra(N);
  cout << fixed << setprecision(12) << d[N + 1] << endl;


  return 0;
}


Measured memory_bytes: 24596
#include "bits/stdc++.h"
//Can you get AC?
using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin>>s;
    bool flag = false;
    REP(i,s.length()-1){
        if(s.substr(i,2)=="AC") flag = true;
    }
    if(flag) print("Yes");
    else print("No");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
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 (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }


void dfs(int i, int j, int N, int M, vvi& garden) {
	if (garden.at(i).at(j) == 1) garden.at(i).at(j) = 0;
	repk(k, i - 1, i + 2) {
		repk(l, j - 1, j + 2) {
			if (k < 0 || k >= N || l < 0 || l >= M || (k == i && l == j))continue;
			cout << k << " " << l << endl;
			if (garden.at(k).at(l) == 1)dfs(k, l, N, M, garden);
		}
	}
}


int solve(int N, int M, vvi& garden) {
	int cnt = 0;
	rep(i, N) {
		rep(j, M) {
			if (garden.at(i).at(j) == 1) {
				cnt++;
				dfs(i, j, N, M, garden);
			}
		}
	}
	return cnt;
}
int get_n(int n) {
	for (int i = 0; ; i++) {
		if (i * (i + 1) / 2 <= n && n < (i + 1) * (i + 2) / 2) {
			return i;
		}
	}
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(18);


	long long int N;
	long long int M;
	cin >> N;
	if (N == 1) {
		cout << 0;
		return 0;
	}

	M = N;
	vi A(10e6, 0);

	//素因数分解
	while (N != 1) {
		int flag = 0;
		repk(i, 2, sqrt(N) + 1) {
			//cout <<  N << " " << i << endl;
			if (N % i == 0) {
				flag = 1;
				N = N / i;
				A.at(i) += 1;
				//cout << i << " " << A.at(i) << " " << N << endl;
				break;
			}
		}
		if (flag == 0) {
			if(N<10e6)A.at(N) += 1;
			else A.at(0) += 1;
			N = 1;
		}
	}

	int cnt = 0;
	rep(i, 10e6) {
		cnt += get_n(A.at(i));
	}
	cout << cnt;
	return 0;
}


Measured memory_bytes: 42284
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>

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

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<P, int> PP;
struct edge{ int to, time, cost; };
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

int n, q;
int score[(int)1e+7 + 1];
std::vector<int> v;
std::multiset<int> leader;

int main(){
	std::cin >> n >> q;
	rep(i, n)std::cin >> score[i], v.push_back(score[i]);
	std::sort(v.begin(), v.end());
	rep(i, q){
		char que[10];
		int a;
		std::cin >> que >> a;
		if (que[0] == 'A')leader.insert(score[a - 1]);
		else if (que[0] == 'R')leader.erase(leader.lower_bound(score[a - 1]));
		else{
			int ans = -1;
			int l = 0, r = infi;
			while (l <= r){
				int m = (l + r) / 2, fail = 0, prev = 0;
				for (std::multiset<int>::iterator it = leader.begin(); it != leader.end(); ++it){
					int pos = std::lower_bound(v.begin(), v.end(), *it - m) - v.begin();
					fail += std::max(pos - prev, 0);
					prev = std::upper_bound(v.begin(), v.end(), *it) - v.begin();
				}
				fail += std::max(n - prev, 0);
				if (fail <= a)ans = m, r = m - 1;
				else l = m + 1;
			}
			if (ans == -1)std::cout << "NA" << std::endl;
			else std::cout << ans << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 11120
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//-----CODE------//

void solve(void)
{
  int N,T;cin>>N>>T;
  int pT = INF, nT = -1*INF;
  int ANS = 0;
  for (int i = 0; i < N; i++)
  {
     int X; cin>>X;
    if(X <= nT)ANS -= (nT - X);
    nT = X + T;
    ANS += T;
  }
  cout<<ANS<<endl;

  
  return; 
}
int32_t main(int32_t argc, const char *argv[])
{
std::ios::sync_with_stdio(false);
std::cin.tie(0);

std::cout << std::fixed;
std::cout << std::setprecision(9);
solve();

return 0;
}

Measured memory_bytes: 256
package main

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

type pair struct {
	l, r int
}

func solve() {
	s := getRunes()
	n := len(s)

	ans := make([]int, n)
	cntR, cntL := 0, 0
	b := pair{-1, -1}
	for i, c := range s {
		if c == 'R' {
			cntR++
		} else {
			cntL++
		}

		if i == n-1 || (c == 'L' && s[i+1] == 'R') {
			ans[b.l] = (cntR+1)/2 + cntL/2
			ans[b.r] = (cntL+1)/2 + cntR/2

			cntR, cntL = 0, 0
		} else if c == 'R' && s[i+1] == 'L' {
			b.l, b.r = i, i+1
		}
	}

	for _, a := range ans {
		fmt.Fprintln(wr, a)
	}
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

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

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#ifdef CURIOUSCAT
#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)
#else
#define Pr(f,...)
#endif

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=1e6+50,P=998244353;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int gcd(int a,int b){ return !b?a:gcd(b,a%b); }

int C(int n,int m) { 
	if (m<0||m>n)return 0;
	if(m<=1)return m==1?n:1;
	return 1ll*C(n/2,m/2)*C(n%2,m%2)%2;
}

int n,pw[N],sg[3][N],ans,m,o[N],w[N],mx[3];
vector<int> g[N];
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
#endif
	read(n); 	
	{int w=1;rep(i,1,18)w=mul(w,10);
	pw[0]=1;rep(i,1,n)pw[i]=mul(pw[i-1],w);}
	lop(k,0,3){
		rep(i,1,n)g[i].clear();
		read(m); 
		rep(i,1,m){
			int u,v; 
			read(u),read(v); 
			if(u>v)swap(u,v); 
			g[u].pb(v); 
		}
		mem(o,0); 
		dec(v,n,1){
			for(int d:g[v])o[w[d]]=v; 
			int x=0;
			while(o[x]==v)++x;
			w[v]=x;
			sg[k][x]=add(sg[k][x],pw[v]);
			if(w[v])Pr("w[%d]=%d\n",v,w[v]); 
			cmax(mx[k],x); 
		}
		Pr("%d,%d\n",sg[k][0],sg[k][1]); 
	}
	rep(i,0,mx[0])rep(j,0,mx[1])ans=add(ans,mul(sg[0][i],mul(sg[1][j],sg[2][i^j]))); 
	printf("%d\n",ans); 
	return 0;
}


Measured memory_bytes: 34416
#include<bits/stdc++.h>
using   namespace      std;
typedef long long      LL;
typedef vector<int>    VI;
typedef pair<int,int>  PII;

int main(){

	string s;
	cin>> s;
	bool bad = false;
	for(int i=1; i<4; i++){
		if(s[i] == s[i-1]){
			bad = true;
			break;
		}
	}

	cout<< (bad ? "Bad" : "Good")<< endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define FFOR(i, a, b) for(int (i)=a;(i)>(b);--(i))
#define rrep(i,n) FFOR(i,0,n)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define lb long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb push_back
#define mod 1000000007LL
#define INF 123456789012345
#define int ll
typedef pair<int, int> P;
typedef pair<int, P> PP;

const int maxn =1e5 + 10;

//initialization here
//
int xR[maxn],vR[maxn],xL[maxn],vL[maxn];
int sumR[maxn],sumL[maxn];
int optimR[maxn],optimL[maxn];
//
//initialization finish


// your function is here
//

//
// your function finished

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	// your code is here
	//

	int n,c; cin >> n >> c;
	xR[0]=0;vR[0]=0;xL[0]=0;vL[0]=0;
	FOR(i,1,n+1)
	{
		int x,v;cin>>x>>v;
		xR[i] = x;
		vR[i] = v;
		xL[n-i+1] = c-x;
		vL[n-i+1] = v;
	}
	sumR[0] = 0;sumL[0] = 0;
	FOR(i,1,n+1)
	{
		sumR[i] += sumR[i-1] +xR[i-1] -xR[i] + vR[i];
		sumL[i] += sumL[i-1] +xL[i-1] -xL[i] + vL[i];
	}

	optimR[0] = 0;optimL[0] = 0;
	
	FOR(i,1,n+1)
	{
		optimR[i] = max(optimR[i-1], sumR[i]);
		optimL[i] = max(optimL[i-1], sumL[i]);
	}

	int best = 0;

	FOR(i,1,n+1)
	{
		best = max(best, sumR[i]);
		best = max(best,sumR[i] - xR[i] + optimL[n-i]);
	}

	FOR(i,1,n+1)
	{
		best = max(best, sumL[i]);
		best = max(best,sumL[i] - xL[i] + optimR[n-i]);
	}

	Print(best);
	//
	// your code finished


	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << "Impossible"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int N = 12;

int deg[N] = { 1 }, sum[N];
string ans = "";

void make_ans(int len, int cur, int n) {
    if (cur == len)
        return;
    for (int i = 0; i < 26; ++i)
        if ((i + 1) * deg[len - cur - 1] > n) {
            ans.pb(i + 'a');
            make_ans(len, cur + 1, n - i * deg[len - cur - 1]);
            return;
        }
}

void solve() {
    loop1(i, N - 1) {
        deg[i] = deg[i - 1] * 26;
        sum[i] = sum[i - 1] + deg[i];
    }
    int n; cin >> n;
    --n;
    int mns = upper_bound(sum, sum + N, n) - sum;
    --mns;
    n -= sum[mns];
    make_ans(mns + 1, 0, n);
    cout << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //int t; cin >> t; loop(i, t)
    solve();
    return 0;
}

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

int main() {
    for(string s1, s2, s3; cin >> s1, s1 != "0"; ) {
        cin >> s2 >> s3;
        string s = s1 + s2 + s3;
        string bit[] = {
            "111000000",
            "000111000",
            "000000111",
            "100100100",
            "010010010",
            "001001001",
            "100010001",
            "001010100"
        };

        int winner = -1;
        for(int i = 0; i < 8; i++) {
            string t;
            for(int j = 0; j < 9; j++) {
                if(bit[i][j] == '1') t.push_back(s[j]);
            }
            if(t[0] == 'w' && t[1] == 'w' && t[2] == 'w') winner = 0;
            if(t[0] == 'b' && t[1] == 'b' && t[2] == 'b') winner = 1;
        }
        if(winner == 0) {
            cout << 'w' << endl;
        }
        else if(winner == 1) {
            cout << 'b' << endl;
        }
        else {
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 1188
i = []
gets.split(" ").each do |n|
  i << n.to_i
end
if (i[0] - i[1]) > 1
  puts i[0] + (i[0] - 1)
elsif (i[0] - i[1]) < -1
  puts i[1] + (i[1] - 1)
else
  puts i[0] + i[1]
end



Measured memory_bytes: 3836
#include <stdio.h>
#define N 2000000
void insert(int);
void heapIncreaseKey(int *,int,int);
int ExtractMax(int *);
void maxHeapify(int *,int);

int Heap,A[N];

int main(){
  int aaa;
  char bbb[20];

  while(1){
    scanf("%s",bbb);
    if(bbb[0]=='e'&&bbb[1]=='n')
      break;
    if(bbb[0]=='i'){
      scanf("%d",&aaa);
      insert(aaa);
    }
    else{
      printf("%d\n",ExtractMax(A));
    }
  }
  return 0;
}
void insert(int aaa){
  Heap++;
  A[Heap]=-3;
  heapIncreaseKey(A,Heap,aaa);
}
void heapIncreaseKey(int *A,int i,int aaa){
  int m;
  if(aaa<A[i])
    return;
  A[i]=aaa;
  while(i>1&&A[i/2]<A[i]){
    m=A[i];
    A[i]=A[i/2];
    A[i/2]=m;
    i=i/2;
  }
}
int ExtractMax(int *A){
  int max;
  if(Heap<1)
    return -3;
  max=A[1];
  A[1]=A[Heap];
  Heap--;
  maxHeapify(A,1);
  return max;
}
void maxHeapify(int *A,int i){
  int l,r,largest,m;
  l=2*i;
  r=2*i+1;

  if(l<=Heap && A[l]>A[i])
    largest=l;
  else
    largest=i;
  if(r<=Heap && A[r]>A[largest])
    largest=r;
  if(largest!=i){
    m=A[i];
    A[i]=A[largest];
    A[largest]=m;
    maxHeapify(A,largest);
  }
}
	  



Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define M 1000000007
#define U 998244353
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define N 1000005
#define U 998244353
#define bs binary_search
#define endl '\n'
#define FILEIO     freopen("input.txt","r",stdin); freopen("output.txt","w", stdout);
#define PI 3.1415926535
#define INF LLONG_MAX-5
using namespace std;
int po(int n, int exp){
    int prod=1;
    rep(i,0,exp)
        prod*=n;
    return prod;
}

signed main()
{
    ios_base::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);
    int TESTS=1;
    // cin>>TESTS;
    while(TESTS--)
    {   
        int n;
        cin>>n;
        if(n==1||n==2){
            cout<<"No";
            r0;
        }
        if(n%2==0){
            for(int i=2; i<n; i+=2){
                if((i^(n+1))>=1&&(i^(n+1))<=n&&(i^(n+1))!=i){
                    cout<<"Yes"<<endl;
                int r = 2;
                while(r<n){
                    cout<<r<<" "<<r+1<<endl;
                    cout<<r<<" "<<1<<endl;
                    cout<<1<<" "<<n+r+1<<endl;
                    cout<<n+r<<" "<<n+r+1<<endl;
                    r+=2;
                }
                cout<<n+1<<" "<<3<<endl;
                cout<<n<<" "<<i<<endl;
                cout<<n+(i^(n+1))<<" "<<2*n<<endl;
                r0;
                }
            }
            cout<<"No";
            r0;
        }
        cout<<"Yes"<<endl;
        int r = 2;
        while(r<=n){
            cout<<r<<" "<<r+1<<endl;
            cout<<r<<" "<<1<<endl;
            cout<<1<<" "<<n+r+1<<endl;
            cout<<n+r<<" "<<n+r+1<<endl;
            r+=2;
        }
        cout<<n+1<<" "<<3;
    }   
}       

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

class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);
		int a= scanner.nextInt();
		int b= scanner.nextInt();
		int c= scanner.nextInt();
		
		int[] foo ={a,b,c};
		
		Arrays.sort(foo);
		
		System.out.println(foo[0]+foo[1]);
			
	}

}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	string S;
	cin >> S;
	vector<vector<int> > g(N);
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		if (a != b)g[b].push_back(a);
	}
	vector<int> ca(N, 0);
	vector<int> cb(N, 0);
	queue<int> qu;
	vector<int> B(N, 0);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < g[i].size(); j++) {
			if (S[g[i][j]] == 'A') {
				ca[i]++;
			}
			else {
				cb[i]++;
			}
		}
		if (ca[i] == 0 || cb[i] == 0) {
			B[i] = 1;
			qu.push(i);
		}
	}
	while ((int)qu.size() > 0) {
		int a = qu.front(); qu.pop();
		for (int i = 0; i < g[a].size(); i++) {
			if (B[g[a][i]] == 0) {
				int z;
				if (S[a] == 'A') {
					z = (--ca[g[a][i]]);
				}
				else {
					z = (--cb[g[a][i]]);
				}
				if (z == 0) {
					B[g[a][i]] = 1;
					qu.push(g[a][i]);
				}
			}
		}
	}
	string res = "No";
	for (int i = 0; i < N; i++) {
		if (B[i] == 0) {
			res = "Yes";
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 16976
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e18+1;

void add(ll &x, ll y)
{
    x+=y;
    if(x>=mod)
    {
        x-=mod;
    }
}
ll memo[51][51];

ll ncr(ll n,int r)
{
     if(memo[n][r]) return memo[n][r];
     if(n==r) return 1;
     if(r==1) return n;
     memo[n][r] = ncr(n-1, r) + ncr(n-1, r-1);
     return memo[n][r];
}

vector<long double> v(51);

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

    long double n, a, b;
    cin >> n >> a >> b;
    for(int i=1; i<=n; i++)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.begin()+n+1);
    if(v[n]==v[n-a])
    {
        ll an=0;
        int i=a;
        vector<int> vec;
        while(v[n]==v[n-i+1]&&i!=-1)
        {
            if(i<=b) vec.push_back(i);
            i++;
        }
        i--;
        for(auto j : vec)
        an+=ncr(i, j);
        cout << fixed << setprecision(6) << v[n] << endl << an;
        return 0;
    }
    long double c=0;
    ll mi = INF; int d=0;
    for(int i=0; i<a; i++)
    {
        c+=v[n-i];
        if(v[n-i]<mi)
        {
            mi=v[n-i];
            d=1;
        }
        else if(v[n-i]==mi)
        {
            d++;
        }
    }
    int e=d;
    int i=n-a;
    while(v[i]==mi)
    {
        e++;
        i--;
    }
    c/=a;
    cout << fixed << setprecision(6) << c << endl << ncr(e, d);

}

//TODO: 56
//come back to 50D, 55D, DP-J


Measured memory_bytes: 256
//kalyanchirla
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
#define int long long
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define csl ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define setbits(x) __builtin_popcountll(x)
#define zrobits(x) __builtin_ctzll(x)
#define mod 1000000007

int32_t main()
{ 
    csl;

    int n;
    cin >> n;

    int arr[n];

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

    bool v[n];
    for(int i=0;i<n;i++) v[i]=false;
    int count=0;
    int i=0;
    while(true)
    {
        if(i==1)
        {
            break;
        }
        if(v[i]==false)
        {
            v[i]=true;
            count++;
            i = arr[i]-1;
        }
        else
        {
            count=-1;
            break;
        }
        
    }
    cout << count << "\n";
}

Measured memory_bytes: 4480
import sys
 
n = int(input())
a = list(map(int, input().split()))
aa = [0]
for i in range(n):
    aa.append(aa[i] + a[i])
 
ans = sys.maxsize
 
def getdiff(left, center, right):
    return abs((aa[center] - aa[left]) - (aa[right] - aa[center]))
 
L = 1
R = 3
 
for C in range(2, n):
    while L + 1 < C and getdiff(0, L, C) > getdiff(0, L + 1, C):
        L += 1
    while R + 1 < n and getdiff(C, R, n) > getdiff(C, R + 1, n):
        R += 1
    pqrs = [aa[L], aa[C] - aa[L], aa[R] - aa[C], aa[n] - aa[R]]
    pqrs.sort()
    ans = min(ans, pqrs[3] - pqrs[0])
 
print(ans)

Measured memory_bytes: 115388