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

using namespace std ;

using singlebit = uint32_t;
using doublebit = uint64_t;
static constexpr int digit_level = 8 * sizeof(singlebit);

static constexpr singlebit find_inv(singlebit n, int d = 6, singlebit x = 1) {
	return d == 0 ? x : find_inv(n, d - 1, x * (2 - x * n));
}
template <singlebit mod> class fast_modint {
	// Fast Modulo Integer, Assertion: mod < 2^(bits of singlebit - 1) and mod is prime
private:
	singlebit n;
	static constexpr singlebit r2 = (((doublebit(1) << digit_level) % mod) << digit_level) % mod;
	static constexpr singlebit ninv = singlebit(-1) * find_inv(mod);
	singlebit reduce(doublebit x) const {
		singlebit res = (x + doublebit(singlebit(x) * ninv) * mod) >> digit_level;
		return res < mod ? res : res - mod;
	}
public:
	fast_modint() : n(0) {};
	fast_modint(singlebit n_) { n = reduce(doublebit(n_) * r2); };
	static constexpr singlebit get_mod() { return mod; }
	singlebit get() const { return reduce(n); }
	bool operator==(const fast_modint& x) const { return n == x.n; }
	bool operator!=(const fast_modint& x) const { return n != x.n; }
	fast_modint& operator+=(const fast_modint& x) { n += x.n; n -= (n < mod ? 0 : mod); return *this; }
	fast_modint& operator-=(const fast_modint& x) { n += mod - x.n; n -= (n < mod ? 0 : mod); return *this; }
	fast_modint& operator*=(const fast_modint& x) { n = reduce(doublebit(n) * x.n); return *this; }
	fast_modint operator+(const fast_modint& x) const { return fast_modint(*this) += x; }
	fast_modint operator-(const fast_modint& x) const { return fast_modint(*this) -= x; }
	fast_modint operator*(const fast_modint& x) const { return fast_modint(*this) *= x; }
	fast_modint inv() const { return binpow(mod - 2); }
	fast_modint binpow(singlebit b) const {
		fast_modint ans(1), cur(*this);
		while (b > 0) {
			if (b & 1) ans *= cur;
			cur *= cur;
			b >>= 1;
		}
		return ans;
	}
};

using modint = fast_modint<1000000007>;

struct combination
{
    vector<modint>fact , inv ;
    combination(int sz) : fact(sz + 1) , inv(sz + 1)
    {
        fact[0] = 1ll ;
        inv[0] = 1ll ;
        for(long long i = 1 ; i <= sz ; ++i)
        {
            fact[i] = (fact[i-1] * i) ;
            inv[i] = fact[i].inv() ;
        }
    }
    modint choose(int n , int k) const
    {
        if(k < 0 || n < k)
            return 0 ;
        return (fact[n] * inv[k] * inv[n - k]) ;
    }
};

const int MAX = 4e5 + 5 ;

combination table(MAX) ;

int NoofSequences(int N, int M) 
{ 
	map<int, int> prime; 
	for (int i = 2; i * i <= M; ++i) 
	{ 
		while (M % i == 0) 
		{ 
			prime[i]++; 
			M /= i; 
		} 
	} 
	if (M > 1) 
		prime[M] += 1; 
	modint ans = 1ll ;
	for (auto it : prime) 
		ans = ans * table.choose(N + it.second - 1, N - 1) ; 
	return ans.get(); 
} 

int main() 
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n , m ;
	cin>>n>>m ;
	return cout<<NoofSequences(n, m)<<"\n" , 0; 
} 

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

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
    if (a > b) a = b;
}

template<class T, class U>
void ckmax(T &a, U b)
{
    if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;

const int MAXN = 100013;

int N, L, T;
pii arr[MAXN];
bool hasl, hasr;
pii ans[MAXN];
vpi pos;

bool cmp(pii a, pii b)
{
    if (a.fi != b.fi)
    {
        return a.fi < b.fi;
    }
    return a.se > b.se;
}
int32_t main()
{
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(4);
    ios_base::sync_with_stdio(false); cin.tie(0);
    // freopen("test.in", "r", stdin);
    // freopen("test.out", "w", stdout);
    cin >> N >> L >> T;
    pii lol;
    FOR(i, 0, N)
    {
        cin >> arr[i].fi >> arr[i].se;
        if (arr[i].se == 2) arr[i].se = -1;
        int ft = arr[i].fi + arr[i].se * T;
        ft %= L;
        if (ft < 0) ft += L;
        ans[i] = {ft, arr[i].se};
        if (i == 0) lol = ans[i];
    }
    int idx = 0;
    if (arr[0].se == 1)
    {
        FOR(j, 1, N)
        {
            if (arr[j].se == 1) continue;
            //count the # these guys intersect.
            int d = arr[j].fi - arr[0].fi;
            ll k = max(0ll, (2ll * T - d + L)) / L;
            idx += k;
            idx %= N;
            // cerr << 2 * T - d + L << '/' << L << endl;
            //d/2, (d+L)/2,....(d+(k-1)L)/2
            //(d + (k-1)L) / 2 <= T -> d+(k-1)L <= 2T => (2T - d + L)/L >= k
        }
        // cerr << idx << " intersectons\n";
        sort(ans, ans + N);
        FOR(i, 0, N) if (ans[i] == lol) idx = i - idx;
        if (idx < 0) idx += N;
        //the ith is ant #idx
        //so i-idx ant #0
        //val[idx1] corresponds to idx
    }
    else
    {
        FOR(j, 1, N)
        {
            if (arr[j].se == -1) continue;
            int d = arr[0].fi + L - arr[j].fi;
            ll k = max(0ll, (2ll * T - d + L)) / L;
            idx += k;
            idx %= N;
        }
        sort(ans, ans + N);
        //the ith is ant #-idx
        //so the i+idx is ant #0
        FOR(i, 0, N) if (ans[i] == lol) idx = i + idx;
        if (idx > N) idx -= N;
    }
    rotate(ans, ans + idx, ans + N);
    FOR(i, 0, N)
    {
        cout << ans[i].fi << '\n';
    }
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr lint B1 = 1532834020;
constexpr lint M1 = 2147482409;
constexpr lint B2 = 1388622299;
constexpr lint M2 = 2147478017;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint R, C, K;
  cin >> R >> C >> K;
  vector<vector<lint>> board(R, vector<lint>(C, 0));
  REP(i, K) {
    lint r, c, v;
    cin >> r >> c >> v;
    r--; c--;
    board[r][c] = v;
  }
  vector<vector<vector<lint>>> dp(R, vector<vector<lint>>(C, vector<lint>(4, -1)));
  dp[0][0][0] = 0;
  if(board[0][0] > 0) dp[0][0][1] = board[0][0];
  REP(i, R) REP(j, C) REP(k, 4) {
    if(dp[i][j][k] == -1) continue;
    if(i != R-1) {
      dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k]);
      if(board[i+1][j] > 0) dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][k] + board[i+1][j]);
    }
    if(j != C-1) {
      dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
      if(board[i][j+1] > 0 && k < 3) dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k] + board[i][j+1]);
    }
  }
  lint ans = 0;
  REP(i, 4) ans = max(ans, dp[R-1][C-1][i]);
  cout << ans << endl;
}

Measured memory_bytes: 706020
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int main()
{
    int n, i, p = 0;
    int x[101], y[101];
    double D[4] = {0};
     
    scanf("%d", &n);
    for(i=0; i<n; i++) scanf("%d", &x[i]);
    for(i=0; i<n; i++) scanf("%d", &y[i]);
     
    do{
         
        if(p == 0){
            for(i=0; i<n; i++) D[0] = fmax(D[0], abs(x[i]-y[i]));
        }else{
            for(i=0; i<n; i++) D[p] += pow(abs(x[i]-y[i]), p);
            D[p] = pow(D[p], (1.0/(double)p));
            printf("%f\n", D[p]);
        }
         
        p++;
         
    }while(p<4);
     
     
    printf("%f\n", D[0]);
     
    return 0;
}

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

int main(int argc, const char *argv[]) {
    int x, y;
    int h, m, s;
    
    cin >> x;
    
    s = x % 60;

    x = x / 60;
    m = x % 60;
    
    x = x / 60;
    h = x % 60;
    
    
    
    cout << h << ":" << m << ":" << s << endl;

    return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <iterator>

using namespace std;

#if 1
#define PRINT(x) { cout << #x << ": " << (x) << endl; }
#define PRINT_CONTAINER(x)  { cout << #x << ": ";                       \
        for (size_t ix = 0; ix < (x).size(); ++ix) cout << (x)[ix] << ", "; \
        cout << endl; }
#else
#define PRINT(x)
#define PRINT_CONTAINER(x)
#endif

struct Sword
{
    int a;
    int b;
};

bool compare(const Sword& a, const Sword& b)
{
    //return a.b > b.b;
    if (a.b > b.b) return true;
    else if (a.b == b.b && a.a < b.a) return true;
    else return false;
}

vector<Sword> swords;

int main(int argc, char *argv[])
{
    int n, h;
    scanf("%d %d", &n, &h);
    vector<int> a, b;
    for (int i = 0; i < n; ++i)
    {
        int aa, bb;
        scanf("%d %d", &aa, &bb);
        Sword s = {aa, bb};
        swords.push_back(s);
    }
    sort(swords.begin(), swords.end(), compare);
    // for (int i = 0; i < n; ++i)
    // {
    //     cout << swords[i].a << ", " << swords[i].b << endl;
    // }
    int imaxa = 0;
    int maxa = 0;
    for (int i = 0; i < n; ++i)
    {
        if (swords[i].a >= maxa)
        {
            imaxa = i;
            maxa = swords[i].a;
        }
    }
    int cnt = 0;
#if 1
    for (int i = 0; i < n; ++i)
    {
        if (swords[i].b > maxa)
        {
            h -= swords[i].b;
            ++cnt;
            if (h <= 0)
            {
                printf("%d\n", cnt);
                return 0;
            }
        }
        else
        {
            break;
        }
    }
#else
    for (int i = 0; i < imaxa; ++i)
    {
            h -= swords[i].b;
            ++cnt;
            if (h <= 0)
            {
                printf("%d\n", cnt);
                return 0;
            }
    }
#endif
    if (h % swords[imaxa].a == 0)
        cnt += h / swords[imaxa].a;
    else
        cnt += (h / swords[imaxa].a) + 1;
    printf("%d\n", cnt);

}


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

int main(){
	int n,p,max = 0,sum = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> p;
		sum += p;
		if(p > max) max = p;
	}
	cout << sum - max/2 << endl;
	return 0;
}


Measured memory_bytes: 256
#include "vector"
#include "string"
#include "set"
#include "map"
#include "sstream"
#include "algorithm"
#include "cmath"
#include "cassert"
#include "iostream"
#include "numeric"
#include "fstream"
#include "queue"
#include <functional>
#include <climits>
#include <cstring>
#include <ctime>
#include <list>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <complex>
#include <limits>
#include <random>

#define int64 long long int

const int M = 1e9 + 7;

void MultL(int64 &a, int64 b) {
    a = (a * b) % M;
}
void AddL(int64 &a, int64 b) {
    a = (a + (b + M)) % M;
}

int64 Mult(int64 a, int64 b) {
    return (a * b) % M;
}
int64 Add(int64 a, int64 b) {
    return (a + (b + M)) % M;
}

using namespace std;



int get(int n, int k) {
    if (n <= 0) return 0;
    int res = n / (k - 1);
    if (n % (k - 1)) ++res;
    return res;



}
/*

 6 3
5 2 1 3 4 6

 */
int main() {
    std::ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    vector<int64> data(n);
    for (int i = 0; i < n; ++i) cin >> data[i];

    int p = -1;
    for (int i = 0; i < n; ++i) if (data[i] == 1) p = i;

    int res = (n - 1) / (k - 1);
    if ((n - 1) % (k - 1)) {
        ++res;
    }
    cout << res << endl;

    return 0;
}








Measured memory_bytes: 1024
#include<iostream>
#include<queue>
using namespace std;
int HPinit,HP;
int H,W;
string a[100];
int dx[4]={-1,1,0,0};
int dy[4]={0,0,-1,1};
int d[26];
string s;
int P,p[12];
main()
{
	while(cin>>HPinit>>HP,HP)
	{
		cin>>H>>W;
		for(int i=0;i<H;i++)cin>>a[i];
		int T;cin>>T;
		for(int i=0;i<T;i++)
		{
			char c;cin>>c;
			cin>>d[c-'A'];
		}
		int S;cin>>S;
		s="";
		for(int i=0;i<S;i++)
		{
			char c;cin>>c;
			int n;cin>>n;
			for(int j=0;j<n;j++)s+=c;
		}
		cin>>P;
		for(int i=0;i<P;i++)cin>>p[i];
		vector<vector<int> >vis(s.size()+1,vector<int>(1<<P,0));
		vis[0][0]=HPinit;
		int x=0,y=0;
		for(int i=0;i<s.size();i++)
		{
			int dir=s[i]=='U'?0:s[i]=='D'?1:s[i]=='L'?2:3;
			int tx=x+dx[dir],ty=y+dy[dir];
			int lo=d[a[tx][ty]-'A'];
			for(int j=0;j<1<<P;j++)
			{
				if(vis[i][j]==0)continue;
				if(vis[i][j]>lo)
				{
					vis[i+1][j]=max(vis[i+1][j],vis[i][j]-lo);
				}
				else
				{
					for(int k=0;k<P;k++)
					{
						if(!(j>>k&1))
						{
							vis[i][j|1<<k]=max(vis[i][j|1<<k],min(vis[i][j]+p[k],HP));
						}
					}
				}
			}
			x=tx;y=ty;
		}
		bool ok=false;
		for(int i=0;i<1<<P;i++)if(vis[s.size()][i]>0)ok=true;
		cout<<(ok?"YES":"NO")<<endl;
	}
}



Measured memory_bytes: 19020
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,h,m;
string s;
vi v;
const double PI = 3.1415926535;
void solve(){
	cin >> a >> b >> h >> m;
	double angleM=  m*6;
	double angleH = (h*30)+m/60.0*30;
	double dif = abs(angleH-angleM);
	if(dif > 180){
		dif = 360-dif;
	}
	printf("%0.9f\n",sqrt(a*a+b*b-2*a*b*cos(dif*PI/180.0)) ); ;
}

int main(){

	int t= 1;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 4164
//m-candies
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <bool> vb;
typedef vector <double> vd;
typedef vector <ll> vll;
typedef vector <vector <int>> vvi;
typedef vector <vector <long long>> vvll;
typedef vector <vd> vvd;
typedef vector <long long> vll;
typedef pair <int, int> pii;
typedef pair<ll , ll> pll;
typedef vector <pair <int, int>> vpii;

const int MOD = 1e9+7;

// prefixes in dp

int main()
{
    ll n, k; cin >> n >> k;
    vi a(n + 1, 0);
    for(int i =1; i<= n; i++)
        cin >> a[i];
    vvll state(k+1, vll(n+1, 0));
    state[0][0] = 1;
    for(int i = 0; i <= k; i++)
        for(int j = 0; j <= n; j++)
        {
            if(i == j && j == 0) continue;
            // state[i][j] += (i-l < 0 || j - 1 < 0? 0 :state[i - l][j-1] % MOD);
            state[i][j] = ((j-1 < 0? 0 :(state[i][j-1] - (i - a[j] - 1 < 0? 0: state[i - a[j] - 1][j-1]))) + (i - 1 < 0? 0:state[i-1][j])) % MOD; 
        }
    cout << (state[k][n] - (k - 1 < 0? 0:state[k-1][n]) + MOD)%MOD << endl;    

}

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a;
    cin >> a;
    int g = a + a * a + a * a * a;
    cout << g << '\n';
    return 0;
}
/* take it easy */

Measured memory_bytes: 3648
//abc126_d.cpp
//Sat May 25 20:06:40 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;
struct edge {int to, cost;};
vector<edge> G[100000];
int color[100000];

void paint(int x){
	for (int i=0;i<G[x].size();i++){
		edge e = G[x][i];
		if (color[e.to] == -1){
			if (e.cost%2==0){
				color[e.to] = color[x];
			}else {
				color[e.to] = (color[x]+1)%2;
			}
			paint(e.to);
		}
	}
}

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

	for (int i=0;i<n-1;i++){
		edge tempe;
		int u;
		cin >> u >> tempe.to >> tempe.cost;
		u--;
		tempe.to--;
		G[u].push_back(tempe);
		edge tempe2;
		tempe2.to = u;
		tempe2.cost = tempe.cost;
		G[tempe.to].push_back(tempe2);
	}

	fill(color,color+n,-1);
	color[0] = 0;

	paint(0);

	for (int i=0;i<n;i++){
		cout << color[i] << endl;
	}
}

Measured memory_bytes: 8320
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <locale>
#include <queue>
#include <tuple>
#include <map>
#include <fstream>

using namespace std;


#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))




int main() {
	ll n;
	cin >> n;
	vector<ll> as(n);
	vector<ll> p(100000,0);
	ll ans = 0;
	rep(i, n){
		cin >> as[i];
		p[as[i]-1]++;
		ans += as[i];
	}
	ll q;
	cin >> q;
	vector<ll> anss;
	rep(i,q){
		ll b,c;
		cin >>b >> c;
		ans-=p[b-1]*b;
		ans+=p[b-1]*c;
		p[c-1]+=p[b-1];
		p[b-1]=0;
		anss.push_back(ans);
	}
	rep(i,q){
		cout << anss[i] <<endl;
	}
	return 0;
}


Measured memory_bytes: 5884
n = Array.new(2)
n[0], n[1], k = gets.split.map(&:to_i)
k.times do |i|
    n[i%2] -= 1 if n[i%2].odd? 
    n[1-i%2] += n[i%2] /= 2
end

puts "#{n[0]} #{n[1]}"


Measured memory_bytes: 1788
N = int(input())
L = list(map(int, input().split()))

max_L = 0
sum_L = 0
for i in range(N):
    sum_L += L[i]
    if L[i] > max_L:
        max_L = L[i]
    
sum_L -= max_L
if max_L < sum_L:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=998244353;
string gcd(string a, string b){
  if(a.size()<b.size()) swap(a, b);
  if(b.empty()) return a;
  int n=a.size(), m=b.size();
  for(int i=n-m; i<n; i++){
    if(b[i-n+m]=='1'){
      if(a[i]=='0') a[i]='1';
      else a[i]='0';
    }
  }
  while(!a.empty()){
    if(a.back()=='0') a.pop_back();
    else break;
  }
  return gcd(b, a);
}
ll p2[4001];
ll solve(string g, string x, string y, int i){
  int n=x.size(), m=g.size();
  if(n<m) return 1;
  if(n-m+1==i){
    if(x>=y) return 1;
    else return 0;
  }
  if(x[i]=='1'){
    if(y[i]=='1') return (p2[n-m-i]+solve(g, x, y, i+1))%MOD;
    for(int j=0; j<m; j++){
      if(g[j]=='1'){
        if(y[i+j]=='0') y[i+j]='1';
        else y[i+j]='0';
      }
    }
    return (p2[n-m-i]+solve(g, x, y, i+1))%MOD;
  }else{
    if(y[i]=='0') return solve(g, x, y, i+1);
    for(int j=0; j<m; j++){
      if(g[j]=='1'){
        if(y[i+j]=='0') y[i+j]='1';
        else y[i+j]='0';
      }
    }
    return solve(g, x, y, i+1);
  }
}
int main()
{
	int n; cin>>n;
  string x; cin>>x;
  string a[6];
  for(int i=0; i<n; i++){
    cin>>a[i];
    reverse(a[i].begin(), a[i].end());
  }
  string g=a[0];
  for(int i=1; i<n; i++){
    g=gcd(g, a[i]);
  }
  p2[0]=1;
  for(int i=1; i<=4000; i++){
    p2[i]=p2[i-1]*2%MOD;
  }
  reverse(g.begin(), g.end());
  string y;
  for(int i=0; i<x.size(); i++){
    y+='0';
  }
  cout<<solve(g, x, y, 0)<<endl;
	return 0;
}

Measured memory_bytes: 32768
input = gets.chomp.split(" ").map(&:to_i)

N = input[0]
K = input[1]
(1..K).each do |i|
  combinations = 1
  (1..i).each do |e|
    combinations = combinations*(N-K+2-e)/e
  end
  (1..(i-1)).each do |e|
    combinations = combinations*(K-e)/e
  end
  answer = combinations% (10**9+7)
  puts answer
end


Measured memory_bytes: 2172
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;
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; }
void say(bool yes){cout<<(yes?"YES":"NO")<<endl;};

int main(){

    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        ll x;
        cin >> x;
        ans += 2 * min(x, K - x);
    }
    cout << ans << endl;

    return 0;
}

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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }


int main(void) {
    double r, pi;
    cin >> r;
    pi = 3.1415926535;

    cout << 2*pi*r << endl;
    return 0;
}


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

using namespace std;

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

    int n, x, t;
    cin >> n >> x >> t;
    cout << (n + x - 1) / x * t;

    return 0;
}


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

int ind_2(int64_t a){
  int count=0;
  while(a%2==0){
    ++count;
    a=a/2;
  }
  return count;
}

int main(){
  int N;
  cin>>N;
  vector<int64_t> a(N);
  int sum=0;
  for(int i=0;i<N;++i){
    cin>>a.at(i);
    sum=sum+ind_2(a.at(i));
  }

  cout<<sum<<endl;
}

Measured memory_bytes: 384
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> dp;
vector<vector<char>> c;
const int mod = 1000000007;
int add(int x, int y) {
	while(x < 0) x += mod;
	while(y < 0) y += mod;

	int res = (x + y) % mod;
	return res;
}
int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int h, w;
	cin >> h >> w;

	c.assign(h + 1, vector<char>(w + 1, '#'));
	dp.assign(h + 1, vector<int>(w + 1, 0));
	dp[1][1] = 1;
	for(int i = 1; i <= h; i++) {
		for(int j = 1; j <= w; j++) {
			cin >> c[i][j];
			if(c[i][j] == '#') continue;
			dp[i][j] += add(dp[i - 1][j], dp[i][j - 1]);
		}
	}

	cout << dp[h][w];

}

Measured memory_bytes: 5248
/*
ID: leezhen
TASK: practice
LANG: C++11                
*/
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <bitset>
#include <list>

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;
typedef long long ll;
const int inf = 1e9;
const int mod = 1e9+7;

int main() {
	int d;
	scanf("%d", &d);
	printf("Christmas");
	while(d < 25) {
		printf(" Eve");
		d++;
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define mp make_pair
const int mod=1e9+7;
void solve()
{
  int n;
  cin>>n;
  map<string,int> um;
  um["AC"]=um["WA"]=um["TLE"]=um["RE"]=0;
  string s;
  for(int i=0;i<n;i++)
  {
    cin>>s;
    um[s]++;
  }
  cout<<"AC x "<<um["AC"]<<endl;
  cout<<"WA x "<<um["WA"]<<endl;
  cout<<"TLE x "<<um["TLE"]<<endl;
  cout<<"RE x "<<um["RE"]<<endl;

}

int main()
{
  fastio
  solve();
}


Measured memory_bytes: 3672
// ABC161B - Popular Vote

#include <bits/stdc++.h>
using namespace std;

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

	int ans = 0;
	int s;
	if (sum % (4 * M) == 0) {
		s = sum / (4 * M);
	} else {
		s = sum / (4 * M) + 1;
	}
	
	for (int i = 0; i < N; i++) {
		if (A.at(i) >= s) {
			ans++;
		}
	}

	if (ans >= M) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}


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

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N; cin >> N;
    VS s(N); VI t(N); REP(i,N) cin >> s[i] >> t[i];
    string S; cin >> S;
    int ans = 0;
    int i = N-1;
    while(s[i]!=S) ans += t[i--];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
s=list(input())

flag=True
for i in range(len(s)):
    if (i+1)%2==0:
        if s[i] not in {'L', 'U', 'D'}:
                flag=False
                
                break;
    else:
        if s[i] not in {'R', 'U', 'D'}:
                flag=False
               
                break;
if flag:
    print('Yes')
else:
    print('No')
        


Measured memory_bytes: 2940
import java.util.Scanner;

/**
 * https://beta.atcoder.jp/contests/abc076/tasks/abc076_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		int G = sc.nextInt();
		sc.close();
		
		int ans = R + (G-R)*2;
		System.out.println(ans);

	}

}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */


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

	LL N, K; cin >> N >> K;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	map<LL, LL>M;
	FOR(i, 0, N) {
		M[a[i]]++;
	}
	VL p;
	for (auto it : M) {
		p.push_back(it.second);
	}
	SORT(p);
	DD(de(p));
	LL ans = 0LL;
	FOR(i, 0, SZ(p) - K ) {
		ans += p[i];
	}


	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 16500
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef pair <int, int> ii;
typedef vector <int> vi;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n, a, b;
    cin >> n >> a >> b;
    int val = abs(a - b);
    if(!(val % 2)) cout << "Alice\n";
    else cout << "Borys\n";
    return 0;
}

Measured memory_bytes: 256
N, L = map(int, input().split())

make = lambda:[None, None, 0]
root = make()
def construct(s):
    n = root
    for i in s:
        if n[i] is None:
            n[i] = n = make()
        else:
            n = n[i]
    n[2] = 1

for i in range(N):
    s = map(int, input())
    construct(s)

caps = {}
st = [(root, 0, 0)]
while st:
    n, i, l = st.pop()
    if i:
        if n[1] is None:
            caps[L - l] = caps.get(L - l, 0) + 1
        else:
            if not n[1][2]:
                st.append((n[1], 0, l+1))
    else:
        st.append((n, 1, l))
        if n[0] is None:
            caps[L - l] = caps.get(L - l, 0) + 1
        else:
            if not n[0][2]:
                st.append((n[0], 0, l+1))
ans = 0
for v in caps:
    k = caps[v]
    if k % 2 == 0:
        continue
    v -= 1
    r = 1
    while v % 4 == 3:
        v //= 4
        r *= 4
    if v % 4 == 1:
        ans ^= r * 2
    else:
        ans ^= r
print('Alice' if ans else 'Bob')

Measured memory_bytes: 28952
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(void)
{
	char input[100000];
	int len, i;
	int check[26] = {};

	scanf("%s", input);

	for (i = 0; i < strlen(input); i++) {
		check[input[i] - 'a']++;
	}

	for (i = 0; i < 'z' - 'a' + 1; i++) {
		if (check[i] == 0) {
			printf("%c", i + 'a');
			exit(0);
		}
	}
	printf("None");
}

Measured memory_bytes: 256
def main():
    a, b = map(int, input().split())
    s = input()

    if s[a] != '-':
        print('No')
    else:
        if s[:a].isdigit() and s[-b:].isdigit():
            print('Yes')
        else:
            print('No')


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


struct Node
{
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k)
{
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key = k;
	z->left = NIL;
	z->right = NIL;
	
	while (x != NIL)
	{
		y = x;
		if (z->key < x->key)
		{
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if (y == NIL)
	{
		root = z;
	} else {
		if (z->key < y->key)
		{
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u)
{
	if (u == NIL) return;
	inorder(u->left);
	printf(" %d", u->key);
	inorder(u->right);
}

void preorder(Node *u)
{
	if (u == NIL) return;
	printf(" %d", u->key);
	preorder(u->left);
	preorder(u->right);
}


int main()
{
	int n, i, x;
	string com;
	
	cin >> n;
	REP(n)
	{
		cin >> com;
		if (com == "insert")
		{
			cin >> x;
			insert(x);
		} else if (com == "print") {
			inorder(root);
			cout << endl;
			preorder(root);
			cout << endl;
		}
	}
	
	return 0;
}


void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}


double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

Measured memory_bytes: 24660
N, M = gets.split.map(&:to_i)

if N.even?
  pairs = []

  m = N / 2 - 1

  i = N / 2
  d = 2

  m.times do
    next if d == N / 2
    next if i + d > N

    pairs << [i, i + d]

    i -= 1
    d += 2
  end

  i = 1
  d = N - 1

  m.times do
    pairs << [i, i + d]

    i += 1
    d -= 2
  end

  checked = Hash.new(false)
  cnt = 0

  pairs.each do |i, j|
    d = (i - j).abs

    next if checked[d]

    puts [i, j].join(' ')

    cnt += 1
    checked[d] = true
    checked[N - d] = true

    break if cnt >= M
  end
else
  i = 1
  j = N

  M.times do
    puts [i, j].join(' ')
    
    i += 1
    j -= 1
  end
end


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


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

#define INF bit(60)

#define DBGP 1


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

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

typedef pair<li, li> PI;


int main() {
    double a, b;
    cin >> a >> b;
    printf("%.10f\n", (a * b) / (a + b));


    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
	int a, b, c, d;
	scanf("%d %d %d %d", &a, &b, &c, &d);
	for (;;)
	{
		c -= b;
		if (c <= 0)
			break;
		a -= d;
		if (a <= 0)
			break;
	}
	if (a > 0)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    ll N, K;
    cin >> N >> K;
    vll P(N);
    for(auto &e : P)
        cin >> e;
    if(N == K) {
        cout << 1 << endl;
        return 0;
    }
    set<ll> s;
    for(i = 0; i < K; i++) {
        s.insert(P[i]);
    }
    ll ans = 1;
    for(i = 0; i <= N - K - 1; i++) {
        s.insert(P[i + K]);
        auto iter = s.begin();
        ll pmin = *iter;
        iter = s.end();
        ll pmax = *--iter;
        if(P[i] != pmin || P[i + K] != pmax) {
            ans++;
        }
        s.erase(P[i]);
    }
    ll asc = 1;
    ll c = 0;
    ll q = P[0];
    for(i = 1; i < N; i++) {
        if(P[i] > q) {
            asc++;
            if(asc == K) {
                c++;
            }
        } else {
            asc = 1;
        }
        q = P[i];
    }
    if(c > 0)
        ans -= c - 1;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 11136
// B - Golden Apple

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const int MOD = 1e9 + 7;

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

	int ans = (N - 1) / (2 * D + 1) + 1;

	cout << ans << endl;

	return 0;
}

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

int a, b, c, k;

int main() {
  cin >> a >> b >> c >> k;
  int cnt = 0;
  while (b <= a) {
    b <<= 1;
    ++cnt;
  }
  while (c <= b) {
    c <<= 1;
    ++cnt;
  }
  if (cnt <= k)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
	T res = 1;
	for(;n;n>>=1) {
		if (n & 1) res = res * a;
		a = a * a;
	}
	return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
	 return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
	 os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
	for(auto const& x:{args...}){
		cerr<<x<<' ';
	}
	cerr<<ENDL;
}



signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	ll n,m;cin>>n>>m;
	VV<int> e(n,V<int>(0));

	rep(i,0,m){
		int a,b;cin>>a>>b;
		--a;--b;
		e[a].pb(b);
		e[b].pb(a);
	}

	V<bool> used(n,false);
	V<int> ans(n);
	queue<int> q;
	q.push(0);

	while(q.size()){
		int now=q.front();q.pop();

		for(auto&& nex:e[now]){
			if(used[nex])continue;
			ans[nex]=now;
			used[nex]=true;

			q.push(nex);
		}
	}

	cout<<"Yes"<<ENDL;
	rep(i,1,n)cout<<ans[i]+1<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 10316
import java.util.Scanner;

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

        while(n != 0){
            double S = 0;
            int max = -1, min = 1001;

            for(int i = 0; i < n; i++){
                int a = scanner.nextInt();
                S += a;
                if(a < min) min = a;
                if(a > max) max = a;
            }
            System.out.println((int)((S - (min + max)) / (n - 2)));

            n = scanner.nextInt();
        }
    }
}



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

long long gcd(long long a,long long b){
	while(1){
		if(a<b) swap(a,b);
		if(!b) break;
		a %= b;
	}
	return a;
}

inline long long lcm(long long a,long long b){return a*b/gcd(a,b);}

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll a,b,c,d; cin >> a >> b >> c >> d;
    ll ans = b-a+1;
    ll un = lcm(c,d);
    ans -= b/c - (a-1)/c;
    ans -= b/d - (a-1)/d;
    ans += b/un - (a-1)/un;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

typedef long long int int64;

int64 mem[50];

int64 attack(int64 hp, int depth)
{
    if (hp == 1) {
        mem[depth] = 1;
        return 1;
    }
    else if (mem[depth] != -1) {
        return mem[depth];
    }
    else {
        int64 count = 2 * attack(hp / 2, depth + 1) + 1;
        mem[depth] = count;
        return count;
    }
}

int main(int argc, char **argv)
{
    // log2(10^12) = 12 * log2(10) < 12 * 4 = 48;
    int64 H;
    cin >> H;
    for (int i = 0; i < 50; ++i) mem[i] = -1;
    int64 nAttack = attack(H, 0);
    cout << nAttack;
    return 0;
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1; y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

std::pair<long long, long long> chineseRemainderTheorem(
    std::vector<long long> as,
    std::vector<long long> ms
) {
    long long r = 0, m = 1;
    for (int i = 0; i < as.size(); i++) {
        long long a = as[i], n = ms[i];
        long long x, y, gcd;
        gcd = extGCD(m, n, x, y);
        if ((a - r) % gcd != 0) return std::make_pair(0, -1);
        long long temp = (a - r) / gcd * x % (n / gcd);
        r += m * temp;
        m *= n / gcd;
        r = (r % m + m) % m;
    }
    return std::make_pair(r, m);
}

int main() {
    cin >> n >> m;
    Vl a(n), b(n);
    REP(i, n) cin >> a[i];
    REP(i, n) b[i] = a[i]/2;

    Pll p = chineseRemainderTheorem(b, a);
    if (p.second == -1) {
        std::cout << 0 << '\n';
        return 0;
    }
    std::cout << (m%p.second >= p.first ? m/p.second+1 : m/p.second) << '\n';


    return 0;
}


Measured memory_bytes: 3328
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
#pragma GCC optimize("Ofast,no-stack-protector")
#include "bits/stdc++.h"
using namespace std;
const int maxn = 15;
long long cost[1<<maxn][maxn];
long long g[maxn][maxn];
long long f[1<<maxn][maxn];
int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    for(int e = 0; e < m; e++){
        int u, v, w;
        scanf("%d %d %d", &u, &v, &w); u--; v--;
        g[u][v] = w;
        g[v][u] = w;
    }
    for(int i = 0; i < 1<<n; i++){
        for(int j = 0; j < n; j++){
            cost[i][j] = 0;
            for(int h = 0; h < n; h++){
                if(i&(1<<h)) cost[i][j] += g[h][j];
            }
        }
    }
    const long long inf = 1ll<<60;
    for(int i = 0; i < 1<<n; i++)
        for(int j = 0; j < n; j++)
            f[i][j] = inf;
    f[1][0] = 0;
    for(int i = 1; i < 1<<n; i++){
        for(int j = 0; j < n; j++){
            if(f[i][j] == inf) continue;
            if(!(i&(1<<j))) continue;
            for(int u = 0; u < n; u++)
                if(i&(1<<u));
                else if(g[j][u])
                    f[i|(1<<u)][u] = min(f[i|(1<<u)][u], f[i][j] + cost[i^(1<<j)][u]);
            int smask = ((1<<n) - 1) ^ i;
            for(int v = smask; v ; v = smask & (v - 1)){
                assert((i&v) == 0);
                long long add = 0;
                for(int u = 0; u < n; u++) if((i & (1<<u)) && u != j)
                    add += cost[v][u];
                f[i|v][j] = min(f[i|v][j], f[i][j] + add);
            }
        }
    }
    printf("%lld\n", f[(1<<n)-1][n-1]);
    // cout << clock()/(1.0 * CLOCKS_PER_SEC) << endl;
    return 0;
}


Measured memory_bytes: 8064
n = int(input())
a = 0
b = 0
c = 0
d = 0
for i in range(n):
  s = input()
  if s == 'AC':
    a += 1
  elif s == 'WA':
    b += 1
  elif s == 'TLE':
    c += 1
  else:
    d += 1
print('AC' + ' ' + 'x' + ' ' + str(a))
print('WA' + ' ' + 'x' + ' ' + str(b))
print('TLE' + ' ' + 'x' + ' ' + str(c))
print('RE' + ' ' + 'x' + ' ' + str(d))

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

using namespace std;

int bitCount(int m){
    int res = 0;
    for(int t=m;t;t&=t-1) res++;
    return res;
}

int solve(const vector<int>& A, const vector<int>& B){
    int N = A.size();
    int res = 1000000;
    vector<pair<int, int>> v(N);
    for(int m=0;m<(1<<N);m++){
        if(bitCount(m)%2 == 1) continue;
        for(int i=0;i<N;i++) v[i] = make_pair(((m>>i)%2)?B[i]:A[i], i);
        int cnt = 0;
        bool valid = true;
        for(int i=0;i<N;i++){
            int mVal = 100;
            for(int j=i;j<N;j++){
                mVal = min(mVal, v[j].first);
            }
            bool ok = false;
            for(int j=i;j<N;j++){
                if(v[j].first != mVal) continue;
                int d = (v[j].second - i + 10000) % 2;
                if(d != (m>>v[j].second)%2) continue;
                for(int k=j-1;k>=i;k--){
                    swap(v[k], v[k+1]); 
                    ++cnt;
                }
                ok = true;
                break;
            }
            if(!ok){ valid = false; break; }
        }
        if(valid){
            res = min(res, cnt); }
    }
    return res < 1000000 ? res : -1;
}

int main(){
    int N;
    while(cin >> N){
        vector<int> A(N), B(N);
        for(auto& t : A) cin >> t;
        for(auto& t : B) cin >> t;
        cout << solve(A, B) << endl;
    }
}

Measured memory_bytes: 256
x,n = map(int,input().split())
p = list(map(int,input().split()))
ans = 0

for i in range(110):
    xm = x - i
    xp = x + i
    if xm not in p:
        ans = xm
        break
    elif xp not in p:
        ans = xp
        break
    else:
        continue
print(ans)


Measured memory_bytes: 9180
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
int compare(const void *a,const void *b){
    if(*(long long *)a>*(long long *)b)return 1;
    return -1;
}
int main(int argc, const char * argv[]) {
    long long n,d;
    scanf("%lld%lld",&n,&d);
    long long ans=0;
    for(int i=0;i<n;i++){
        long long x,y;
        scanf("%lld%lld",&x,&y);
        if(x*x+y*y<=d*d){
            ans++;
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1732
# https://atcoder.jp/contests/abc079/tasks/abc079_d

from collections import Counter
from functools import reduce

def warshall(d, n):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                if d[i][k] + d[k][j] < d[i][j]:
                    d[i][j] = d[i][k] + d[k][j]

h,w = map(int,input().split())
magic = [list(map(int,input().split())) for _ in range(10)]
counter = Counter()
[counter.update(Counter(map(int, input().split()))) for _ in range(h)]
warshall(magic, 10)
print(reduce(lambda x,y:x+y, [magic[k][1] * v for k,v in counter.items() if k > -1]))


Measured memory_bytes: 3564
/** 
If comrades that you trust gather around you, hope can take physical form and become visible. That’s what I believe.
*/
#include <bits/stdc++.h>
using namespace std;
/**
(▀̿Ĺ̯▀̿ ̿) (ง ͠° ͟ل͜ ͡°)ง
*/
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
    int tt = clock();
    int r; cin >> r;
    cout << 2 * r * 3.14159 << '\n';



    cerr << "TIME = " << (double) 1.0 * (clock() - tt) / CLOCKS_PER_SEC << " seconds" << endl;
	return 0;
}


Measured memory_bytes: 3824
/*
 * AtCode Beginner Contest 130 : C.Rectangle Cuting
 * Credit : Editorial
 * 27 August 2019
 *
 */

#include <bits/stdc++.h>
using namespace std;

double W,H,x,y;

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

	cin >> W >> H >> x >> y;

	bool anotherWay = false;

	double max = (W/2) * H ;

	cout << max << ' ';

	// rectangle can be cut into two same half
	// if point (x,y) on the center of rectangle
	if((x+x == W) && (y+y == H)){
		anotherWay = true;
	}

	if(anotherWay){
		cout << '1' << '\n';
	}else cout << '0' << '\n';

	return 0;
}

Measured memory_bytes: 256