akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n; scanf("%d", &n); std::vector<int> a(n), b(n);
	for(int i = 0; i < n; i++) scanf("%d", &a[i]);
	for(int i = 0; i < n; i++) scanf("%d", &b[i]);

	int ans = [a, b, n] {
		int A = 0, B = 0, C = 0, D = 0;
		for(int i = 0; i < n; i++) {
			if(a[i] & 1) A++;
			else B++;
			if(b[i] & 1) C++;
			else D++;
		}
		return (A * D + B * C) % 2;
	}();
	for(int k = 29; k > 1; k--) {
		for(int i = 0; i < n; i++) {
			a[i] &= (1 << k) - 1;
			b[i] &= (1 << k) - 1;
		}
		sort(begin(b), end(b));

		int X = 0;
		for(int i = 0; i < n; i++) {
			int A = upper_bound(begin(b), end(b), (1 << k) - a[i] - 1)
				  - lower_bound(begin(b), end(b), (1 << (k - 1)) - a[i]);
			int B = upper_bound(begin(b), end(b), (1 << (k + 1)) - a[i] - 1)
				  - lower_bound(begin(b), end(b), (1 << k) + (1 << (k - 1)) - a[i]);
			X += (A + B) % 2;
		}
		if(X & 1) ans ^= (1 << (k - 1));
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long int ll;
int main(){
	string s;
	cin >> s;
	int ans = 101;
	for(char i = 'a'; i <= 'z'; i++){
		string t = s;
		int cnt = 0;
		while(!t.empty()){
			bool flag = true;
			for(int j = 0; j < t.size(); j++){
				if(t[j] != i) flag = false;
			}
			if(flag) break;
			for(int j = 0; j < t.size(); j++){
				if(j == t.size() - 1) t.pop_back();
				else if(t[j] != i) t[j] = t[j + 1];
			}
			cnt++;
		}
		if(cnt < ans) ans = cnt;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <numeric>
#define ll long long 
#define wolfe ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define elif else if
using namespace std;
int main () {
    wolfe;
    char a;
    cin >> a;
    if(a>='a' && a<='z') cout << 'a' << endl;
    else cout << 'A' << endl;
    return 0;
}

Measured memory_bytes: 3640
N, M = map(int, input().split())
G = [[] for _ in range(N)]
rG = [[] for _ in range(N)]
for _ in range(M):
    s, t = map(int, input().split())
    G[s-1].append(t-1)
E = [0]*N
for v in range(N-1)[::-1]:
    n = len(G[v])
    for nv in G[v]:
        E[v]+=(E[nv]+1)*(1/n)
ans = E[0]
for v in range(N-1):
    if len(G[v]) == 1:
        continue
    index = -1
    tmp = -1
    for i, nv in enumerate(G[v]):
        if tmp<E[nv]:
            index = nv
            tmp = E[nv]
    n = len(G[v])-1
    E[v] = 0
    for nv in G[v]:
        if nv == index:
            continue
        E[v]+=(E[nv]+1)*(1/n)
    for vv in range(v)[::-1]:
        E[vv] = 0
        n = len(G[vv])
        for nv in G[vv]:
            E[vv]+=(E[nv]+1)*(1/n)
    ans = min(ans, E[0])
print(ans)

Measured memory_bytes: 61144
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
#include <numeric>
#include <bitset>
#include <cassert>
#include <functional>

using namespace std;
typedef long long ll;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#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 all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

int main() {
	ll x;
	cin >> x;
	ll x_divided = x / 11;
	if (x % 11 == 0) {
		cout << x_divided * 2 << endl;
	}
	else if (x % 11 <= 6) {
		cout << x_divided * 2 + 1 << endl;
	}
	else {
		cout << x_divided * 2 + 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <climits>
#include <iostream>
#include <vector>

using namespace std;

// merge v[left] to v[mid-1] and v[mid] to v[right-1]
int merge(vector<int>& v, int left, int mid, int right) {
    vector<int> l(mid - left + 1);
    for (int i = 0; i < l.size() - 1; ++i)
        l[i] = v[i + left];
    vector<int> r(right - mid + 1);
    for (int i = 0; i < r.size() - 1; ++i)
        r[i] = v[i + mid];

    l[l.size() - 1] = INT_MAX;
    r[r.size() - 1] = INT_MAX;

    int idx_left = 0;
    int idx_right = 0;
    int compare_count = 0;
    for (int i = left; i < right; ++i) {
        if (l[idx_left] < r[idx_right]) {
            v[i] = l[idx_left];
            ++idx_left;
        } else {
            v[i] = r[idx_right];
            ++idx_right;
        }
        ++compare_count;
    }

    return compare_count;
}

// sort v[left] to v[right-1] with merge sort algorithm
// v[right] will not be modified
int _merge_sort(vector<int>& v, int left, int right) {
    int count = 0;

    if (left + 1 < right) {
        int mid = left + (right - left) / 2;
        count += _merge_sort(v, left, mid);
        count += _merge_sort(v, mid, right);
        count += merge(v, left, mid, right);
    }

    return count;
}

int merge_sort(vector<int>& v) { return _merge_sort(v, 0, v.size()); }

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

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

    int count = merge_sort(s);

    cout << s[0];
    for (int i = 1; i < n; ++i)
        cout << ' ' << s[i];
    cout << '\n';

    cout << count << '\n';
}



Measured memory_bytes: 6784
#define taskname "test"

#include <bits/stdc++.h>

using namespace std;

#define sz(x) (int)x.size()
#define fi first
#define se second

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

int n;
string s;

void read_input()
{
    cin >> s;
    n = sz(s);
}

void solve()
{
    for(int i = 0; i < n; ++i)
        if(s[i] == '?') s[i] = 'D';
    cout << s << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    read_input();
    solve();
}



Measured memory_bytes: 3736
n=int(input())
w=[input() for _ in range(n)]
f=True
for i in range(1,n):
	if w[i-1][-1] == w[i][0]:
		f=True
	else:
		f=False
		break
if f==False:
	f=False
elif len(list(set(w))) == len(w):
	f=True
else:
	f=False
if f:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3064
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }

unordered_map<int, int> prime(int x) {
    unordered_map<int, int> ans;
    int a = 2;
    while (x >= a * a) {
        if (x % a == 0) {
            ans[a]++;
            x /= a;
        }
        else {
            a++;
        }
    }
    ans[x]++;
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    ll ans = 1;
    unordered_map<int, int> Pall;
    REP(x, 2, N + 1) {
        auto P = prime(x);
        for (auto& p : P) {
            Pall[p.first] += p.second;
        }
    }
    for (auto& p : Pall) {
        ans *= ll(p.second + 1);
        ans %= 1000000007;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n, k;
	cin>>n>>k;
	string s;
	cin>>s;
	int curr = 0;
	for (int i = 0; i < s.size(); ) {
		int j = i;
		while ((j + 1 < s.size()) && (s[j + 1] == s[i]))
			j++;
		curr += j - i;
		i = j + 1;
	}
	cout<<min(n - 1, curr + 2 * k);
}


Measured memory_bytes: 512
#include <cstdio>

const int mo=1000000007;
int dp[2005][2005],fac[4000005],inv[4000005];

int ksm(int x,int y){
	int i=1;
	for (;y;y>>=1,x=1ll*x*x%mo)
		if (y&1) i=1ll*i*x%mo;
	return i;
}

void calc(int n){
	fac[0]=1;
	for (int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mo;
	inv[n]=ksm(fac[n],mo-2);
	for (int i=n;i>=1;i--) inv[i-1]=1ll*inv[i]*i%mo;
}

long long C(int n,int m){
	return 1ll*fac[n]*inv[m]%mo*inv[n-m]%mo;
}

int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	if (k==1){
		puts("1");
		return 0;
	}
	calc(n*k);
	dp[0][0]=1;
	for (int i=0;i<=n;i++)
		for (int j=i;j<=n;j++){
			if (i) dp[i][j]=dp[i-1][j];
			if (j) dp[i][j]=(dp[i][j]+dp[i][j-1]*C(i+j*(k-1)-1,k-2))%mo;
		}
	printf("%lld\n",1ll*dp[n][n]*fac[n]%mo);
}

Measured memory_bytes: 46336
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-9;
const int inf=1e8;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vi in(n+1);
	rep(i,n)cin>>in[i+1];
	vp tmp(n+1);
	rep(i,n+1)tmp[i]=pii(in[i],i);
	sort(all(tmp),[](pii a,pii b){
		return (a.first!=b.first?a.first>b.first:a.second>b.second);
	});
	int nt=tmp[0].second;
//	rep(i,n+1)cout<<" "<<tmp[i].first<<" "<<tmp[i].second<<endl;
	vi out(n+1);
	rep(i,n){
		int t=tmp[i].second,mt=tmp[i+1].second;
		ll r=(-tmp[i+1].first+tmp[i].first)*(ll)(i+1);
//		cout<<nt<<" "<<r<<endl;
		out[nt]+=r;
		if(mt<nt)nt=mt;
	}
	rep(i,n)cout<<out[i+1]<<endl;
}
//1 2 0 3 0 4 0 5 8 0











Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define max(a, b) (a>b)?a:b
using namespace std;
long double pre[200005], maxi, cur;
int n, k, arr[200005];
int main()
{
    cin>>n>>k;
    for(int i = 0; i<n; ++i)
        cin>>arr[i];
    
    cur = 0;//add
    for(int i = 0; i<k; ++i)
        cur+=(arr[i]+1)/2.0;
    maxi = cur;

    for(int i = k; i<n; ++i)
    {
        cur = cur-((arr[i-k]+1)/2.0)+((arr[i]+1)/2.0);
        maxi = max(maxi, cur);
    }
    cout<<fixed<<setprecision(20)<<maxi<<"\n";
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MOD2 100000000
#define ll long long
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define all(v) v.begin(),v.end()
ll mod=MOD;
using namespace std;
long long int fast_exp(long long int base,long long int ex) {
    long long int res=1;
    while(ex>0) {
       if(ex%2==1) res=(res*base)%mod;
       base=(base*base)%mod;
       ex/=2;
    }
    return res%mod;
}
long long int gcd(long long int a, long long int b)
{
    if(b==0)return a;
     return gcd(b,a%b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   long long int a,b;
  cin>>a>>b;
  if(!(b%a))a=a+b;
  else a=b-a;
  cout<<a;
   return 0;

}


Measured memory_bytes: 256
n,k = list(map(int, input().split()))
l = list(map(int, input().split()))
dp = [False]*(k+1)
for i in range(1,k+1):
    for e in l:
        if i-e>=0:
            if dp[i-e]==False:
                dp[i]=True
                break
if dp[k]:
    print("First")
else:
    print("Second")

Measured memory_bytes: 41836
#include <bits/stdc++.h>
	#include <cstdio>
	#include <cstring>
	#include <cmath>
	#include <cstring>
	#include <chrono>
	#include <complex>
	#define endl "\n"
	#define ll long long int
	#define vi vector<int>
	#define vll vector<ll>
	#define vvi vector < vi >
	#define pii pair<int,int>
	#define pll pair<long long, long long>
	#define mod 1000000007
	#define inf 1000000000000000001;
	#define all(c) c.begin(),c.end()
	#define mp(x,y) make_pair(x,y)
	#define mem(a,val) memset(a,val,sizeof(a))
	#define eb emplace_back
	#define f first
	#define s second
	
	using namespace std;
    vector<int> arr[1000000];
    int vis[1000000];

    int dfs(int v){
        int ans=0;
        ans++;
        vis[v]=1;
        for(int child:arr[v]){
            if(!vis[child])
            ans+=dfs(child);
        }
        return ans;
    }

	int main()
	{
		std::ios::sync_with_stdio(false);
		int n,m,a,b;
        cin>>n>>m;
        while(m--){
            cin>>a>>b;
            arr[a].push_back(b);
            arr[b].push_back(a);
        }
        int maxans=INT_MIN,ans;
        for(int i=1;i<=n;i++){
            if(!vis[i]){
                ans=dfs(i);
                if(ans>maxans)
                maxans=ans;
            }
        }
        cout<<maxans;
		return 0;
	}


Measured memory_bytes: 43508
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <bitset>
using namespace std;


const double EPS = 1e-9;

int main(){
	map<char, string> enc;
	enc[' ']  = "101";
	enc['\''] = "000000";
	enc[',']  = "000011";
	enc['-']  = "10010001";
	enc['.']  = "010001";
	enc['?']  = "000001";
	enc['A']  = "100101";
	enc['B']  = "10011010";
	enc['C']  = "0101";
	enc['D']  = "0001";
	enc['E']  = "110";
	enc['F']  = "01001";
	enc['G']  = "10011011";
	enc['H']  = "010000";
	enc['I']  = "0111";
	enc['J']  = "10011000";
	enc['K']  = "0110";
	enc['L']  = "00100";
	enc['M']  = "10011001";
	enc['N']  = "10011110";
	enc['O']  = "00101";
	enc['P']  = "111";
	enc['Q']  = "10011111";
	enc['R']  = "1000";
	enc['S']  = "00110";
	enc['T']  = "00111";
	enc['U']  = "10011100";
	enc['V']  = "10011101";
	enc['W']  = "000010";
	enc['X']  = "10010010";
	enc['Y']  = "10010011";
	enc['Z']  = "10010000";

	string d = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
	map<string, char> dec;
	for(int i = 0; i < 32; i++){
		dec[bitset<5>(i).to_string()] = d[i];
	}

	//map<string, char>::iterator it = dec.begin();
	//for(; it != dec.end(); it++){
	//	cout << it->second << ':' << it->first << endl;
	//}

	string s;
	while(getline(cin, s)){
		string e = "";
		for(int i = 0; i < s.size(); i++){
			e += enc[s[i]];
		}
		while(e.size()%5 != 0){
			e += "0";
		}
		for(int i = 0; i < e.size(); i+=5){
			cout << dec[e.substr(i, 5)];
		}
		cout << endl;
	}


	return 0;
}

Measured memory_bytes: 1200
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   ff   first
#define   ss   second
#define   pii  pair<int,int>
using namespace std;

inline void solve(){
    int n,a=2,b=1,ans=2;
    cin >> n;
    for (int i=1;i<=n+1;i++){
        if (i==1) ans=2;
        else if (i==2) ans=1;
        else {
            ans = a+b;
            a=b,b=ans;
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 3600
#include <stdio.h>
#define MAX 25

typedef struct{
  int parent;
  int left;
  int right;
  int order;
}Node;

Node T[MAX];
int n;
void Preorder(int);
void Inorder(int);
void Postorder(int);

int main(){
  int i, id, l, r, root = 0;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    T[i].parent = -1;
    T[i].left = -1;
    T[i].right = -1;
    T[i].order = i;
  }
  for(i = 0; i < n; i++){
    scanf("%d%d%d",&id, &l, &r);
    T[id].left = l;
    T[id].right = r;
    if(l != -1) T[l].parent = id;
    if(r != -1) T[r].parent = id;
  }
  for(i = 0; i < n; i++){
    if(T[i].parent == -1) root = i;
  }

  printf("Preorder\n");
  Preorder(root);
  printf("\nInorder\n");
  Inorder(root);
  printf("\nPostorder\n");
  Postorder(root);
  printf("\n");
  
  return 0;
}

void Preorder(int r){
  if(r != -1){
    printf(" %d",T[r].order);
    if(T[r].left != -1) Preorder(T[r].left);
    if(T[r].right != -1) Preorder(T[r].right);
  }
}

void Inorder(int r){
  if(r != -1){
    if(T[r].left != -1) Inorder(T[r].left);
    printf(" %d",T[r].order);
    if(T[r].right != -1) Inorder(T[r].right);
  }
}

void Postorder(int r){
  if(r != -1){
    if(T[r].left != -1) Postorder(T[r].left);
    if(T[r].right != -1) Postorder(T[r].right);
    printf(" %d",T[r].order);
  }
}

Measured memory_bytes: 616
import sys

arr = []
for line in sys.stdin:
    h1, m1, s1, h2, m2, s2 = map(int, line.split())
    
    a1 = h1 * 3600 + m1 * 60 + s1
    a2 = h2 * 3600 + m2 * 60 + s2
    
    a3 = a2 - a1
    
    h3 = int(a3 / 3600)
    a3 -= h3 * 3600
    m3 = int(a3 / 60)
    s3 = a3 - m3 * 60
    
    print(h3, m3, s3)
        


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

#define  SZ(items) (int)items.size()
#define  CLR(a)  memset(a,0,sizeof(a))
#define  SET(a)  memset(a,-1,sizeof(a))

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

template <class T> inline T gcd(T a, T b) { while (b) { a = a%b; swap(a, b); } return a; }

long long computeXOR(const long long n)
{
	// Modulus operator are expensive on most of the  
	// computers. n & 3 will be equivalent to n % 4.    

	switch (n & 3) // n % 4  
	{
	case 0: return n;     // if n is multiple of 4 
	case 1: return 1;     // If n % 4 gives remainder 1   
	case 2: return n + 1; // If n % 4 gives remainder 2     
	case 3: return 0;     // If n % 4 gives remainder 3   
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	long long a, b;
	cin >> a >> b;

	long long s1 = computeXOR(a - 1);
	long long s2 = computeXOR(b);

	long long res = s1^ s2;

	cout << res << endl;

	return 0;
}

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

int main() {
	int n;
	scanf("%d", &n);
	int arr[n];
	int d1=0, d2=0, d4=0;
	for (int i=0; i<n; i++) {
		scanf("%d", &arr[i]);
		if (arr[i]%4==0) d4++;
		else if (arr[i]%2==0) d2++;
		else d1++;
	}
	printf("%s\n", (d4>=d1 || (d4==d1-1 && d2==0)) ? "Yes": "No");
}


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

inline int read()
{
	int x=0,f=1,c=getchar();
	while(c<48) c=='-'&&(f=-1),c=getchar();
	while(c>47) x=x*10+c-'0',c=getchar();
	return x*f;
}

const int MAXN = 600005;
const int mod = 924844033;
std::vector<int> G[MAXN];
int fac[MAXN],ifac[MAXN],cnt[MAXN],sz[MAXN];
int f[MAXN],g[MAXN],rev[MAXN];
int n;

inline void addedge(int u,int v)
{
	G[u].push_back(v);
	G[v].push_back(u);
}

inline int qpow(int x,int k)
{
	int res=1;
	for(int i=k; i; i>>=1,x=1ll*x*x%mod)
		if(i&1) res=1ll*res*x%mod;
	return res;
}

inline void init(int n)
{
	for(int i=fac[0]=1; i<=n; ++i)
		fac[i]=1ll*fac[i-1]*i%mod;
	ifac[n]=qpow(fac[n],mod-2);
	for(int i=n; i; --i)
		ifac[i-1]=1ll*ifac[i]*i%mod;
}

inline int cat(int n,int k)
{return 1ll*fac[n]*ifac[k]%mod*ifac[n-k]%mod;}

inline void dfs(int x,int fa)
{
	sz[x]=1;
	for(int y : G[x])
		if(y^fa) dfs(y,x),sz[x]+=sz[y],++cnt[sz[y]];
	++cnt[n-sz[x]];
}

inline void ntt(int *a,int n,int type)
{
    for(int i=0; i<n; ++i)
        if(i<rev[i]) swap(a[i],a[rev[i]]);
    for(int i=1; i<n; i<<=1)
    {
        int rt=qpow(5,(mod-1)/(i<<1));
        if(type==-1) rt=qpow(rt,mod-2);
        for(int j=0; j<n; j+=(i<<1))
            for(int k=0,w=1; k<i; ++k,w=1ll*w*rt%mod)
            {
                int x=a[j+k],y=1ll*w*a[j+k+i]%mod;
                a[j+k]=(x+y)%mod,a[j+k+i]=(x-y+mod)%mod;
            }
    }
    if(type==1) return;
    int inv=qpow(n,mod-2);
    for(int i=0; i<n; ++i)
        a[i]=1ll*a[i]*inv%mod;
}

int main(int argc, char const *argv[])
{
	n=read();
	for(int i=1; i<n; ++i) addedge(read(),read());
	dfs(1,0); init(n);
	for(int i=1; i<=n; ++i) f[i]=1ll*cnt[i]*fac[i]%mod;
	for(int i=(reverse(f,f+n+1),0); i<=n; ++i) g[i]=ifac[i];
	int lim=1,l=0;
	while(lim<=n<<1) lim<<=1,++l;
	for(int i=0; i<lim; ++i)
		rev[i]=(rev[i>>1]>>1)|((i&1)<<(l-1));
	ntt(f,lim,1),ntt(g,lim,1);
	for(int i=0; i<lim; ++i)
		f[i]=1ll*f[i]*g[i]%mod;
	ntt(f,lim,-1); reverse(f,f+n+1);
	for(int i=1; i<=n; ++i)
	{
		int t=1ll*ifac[i]*f[i]%mod;
		printf("%lld\n",(1ll*n*cat(n,i)%mod-t+mod)%mod);
	}
	return 0;
}

Measured memory_bytes: 46584
N, X = map(int, raw_input().split())

sz = [4 * 2 ** i - 3 for i in range(N + 1)]
num = [2 * 2 ** i - 1 for i in range(N + 1)]

def func(lv, id):
    mid = (sz[lv] + 1) / 2
    if lv == 0:
        return 1
    if id == 1:
        return 0
    if id == mid:
        return (num[lv] - 1) / 2 + 1
    if id == sz[lv]:
        return num[lv]
    if 1 < id < mid:
        return func(lv - 1, id - 1)
    if mid < id < sz[lv]:
        return func(lv - 1, id - sz[lv - 1] - 2) + num[lv - 1] + 1

print func(N, X)

Measured memory_bytes: 2692
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
struct state {
	unsigned short d;
	int ans;
};
int n, m, c;
vi dp;
vi dark;
map<int, int> darks;
vvi cnct;
int calc(int num) {
	if (dp[num] == 998)
		return 998;
	if (dp[num] != 999)
		return dp[num];
	dp[num] = 998;
	REP(i, c) {
		int local=0;
		REP(j, m)
			if (((num >> j) & 1) && darks.count(cnct[dark[j]][i]) != 0)
				local |= 1 << darks[cnct[dark[j]][i]];
		if(local!=num)
		dp[num] = min(dp[num],calc(local)+1);
	}
	return dp[num];
}
int main() {
	cin >> n >> m >> c;
	dark.resize(m);
	REP(i, m) {
		cin >> dark[i];
		darks[dark[i]] = i;
	}
	cnct.resize(n + 1, vi(c));
	FOR(i, 1, n + 1)
		REP(j, c)
		cin >> cnct[i][j];
	dp.resize(1<<m,999);
	dp[0] = 0;
	cout << calc((1<<m)-1) << endl;
}

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

public class Main {
    static int N;
    static int M;
    static Edge[] edges;
    static long[] d;
    static long INF = Long.MAX_VALUE;
    static boolean[] negative;

    private static void init() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        M = scanner.nextInt();

        negative = new boolean[N];
        Arrays.fill(negative, false);

        edges = new Edge[M];
        for(int i = 0; i < M; i++) {
            int from = scanner.nextInt() - 1;
            int to = scanner.nextInt() - 1;
            long cost = -scanner.nextLong();
            Edge e = new Edge(from, to, cost);
            edges[i] = e;
        }

        d = new long[N];
        Arrays.fill(d, INF);

        scanner.close();
    }

    private static void bellmanFord(int s) {
        d[s] = 0;
        for(int i = 0; i < N; i++) {
            boolean update = false;
            for(int j = 0; j < M; j++) {
                Edge e = edges[j];
                if(d[e.from] != INF && d[e.from] + e.cost < d[e.to]) {
                    d[e.to] = d[e.from] + e.cost;
                    update = true;
                }

            }
            if(!update) break;
        }

        for(int i = 0; i < N; i++) {
            boolean update = false;
            for(int j = 0; j < M; j++) {
                Edge e = edges[j];
                if(d[e.from] != INF && d[e.from] + e.cost < d[e.to]) {
                    d[e.to] = d[e.from] + e.cost;
                    update = true;
                    negative[e.to] = true;
                }
                if(negative[e.from]) {
                    negative[e.to] = true;
                }
            }
            if(!update) break;
        }
    }

    public static void main(String args[]) {
        init();
        bellmanFord(0);
        long ans = -d[N - 1];

        bellmanFord(0); // もう1回bellmanFord回して、Nの頂点の結果が変わって入ればスコアに関わる閉路がある

        if(ans == -d[N - 1] && !negative[N - 1]) {
            System.out.println(ans);
        } else {
            System.out.println("inf");
        }
    }
}

class Edge {
    int from;
    int to;
    long cost;

    public Edge(int from, int to, long cost) {
        this.from = from;
        this.to = to;
        this.cost = cost;
    }
}

Measured memory_bytes: 30008
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
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; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    ll N;
    cin >> N;
    VLL A(N);
    vector<pair<ll, ll>> B;
    rep(i,N){
        cin >> A[i];
        if(A[i]<0){
            B.PB(make_pair(abs(A[i]), 1));
        }
        else{
            B.PB(make_pair(abs(A[i]), 0));
        }
    }
    sort(all(B));
    reverse(all(B));
    rep(i,N){
        if(B[i].S==1){
            B[i].F*=-1;
        }
    }
    ll sum=0;
    rep(i,N-1){
        if(B[i].F<0){
            B[i].F*=-1;
            B[i+1].F*=-1;
        }
    }
    rep(i,N){
        sum+=B[i].F;
    }
    cout << sum << endl;
}

Measured memory_bytes: 6080
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    string S; cin >> S;
    string res;
    if (count(S.begin(), S.end(), 'x') >= 8) res = "NO";
    else res = "YES";

    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  string s;
  cin>>s;
  for(int i=0;i<4;i++) cout<<s[i];
  cout<<" ";
  for(int i=4;i<12;i++) cout<<s[i];
  cout<<endl;
}



Measured memory_bytes: 256
#include<queue>
#include<string>
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  priority_queue<int> Q;
  vector<int> answer;
  string str;
  int q;
  while(cin >> str && str != "end"){
    if(str == "insert"){
      cin >> q;
      Q.push(q);
    }
    else{
      answer.push_back(Q.top());
      Q.pop();
    }
  }
  for(int variable = 0;variable < answer.size();++variable)
    cout << answer[variable] << endl;
}
    

Measured memory_bytes: 8912
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main(){
  string bun;
  
  getline(cin,bun);
  
  for(int i=0;i<bun.size();i++){
    if(bun[i] <= 'z' && bun[i] >= 'a'){
      printf("%c",bun[i]-32);
    }
    else{
      printf("%c",bun[i]);
    }
  }
  cout << endl;
}

Measured memory_bytes: 1160
import java.util.*;

class Main{

    int h, w, n;
    char[][] board, board2;
    String[] s;
    boolean change;

    void solve(){
        Scanner sc = new Scanner (System.in);

        h = sc.nextInt();
        w = sc.nextInt();
        n = sc.nextInt();

        s = new String[h];
        for(int i=0; i<h; i++) s[i] = sc.next();

        boolean cake = false;
        for(int i=0; i<h; i++){
            for(int j=0; j<w-1; j++){
                board = new char[h][w];
                board2 = new char[h][w];
                for(int l=0; l<h; l++) board[l] = s[l].toCharArray();

                if(board[i][j]==board[i][j+1]) continue;
                
                char tmp = board[i][j];
                board[i][j] = board[i][j+1];
                board[i][j+1] = tmp;
                for(int k=0; k<h; k++){
                    for(int l=0; l<w; l++){
                        board2[k][l] = board[k][l];
                    }
                }
                down();
                cake();

                cake = true;
                for(int k=0; k<h; k++){
                    for(int l=0; l<w; l++){
                        if(board[k][l]!='.'){
                            cake = false;
                            break;
                        }
                    }
                    if(!cake) break;
                }
                if(cake) break;
            }
            if(cake) break;
        }

        if(cake) System.out.println("YES");
        else System.out.println("NO");
    }

    void cake(){
        change = false;
        delete();
        if(change) cake();
    }

    void down(){
        LinkedList<Character> list = new LinkedList<Character>();
        for(int k=0; k<w; k++){
            for(int l=0; l<h; l++){
                if(board[l][k]=='2' || board[l][k]=='.') list.add('.');
                else list.addFirst(board[l][k]);
            }
            for(int l=h-1; l>=0; l--){
                board[l][k] = list.pollFirst();
                board2[l][k] = board[l][k];
            }
        }
    }

    void delete(){
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){

                if(board2[i][j]=='.') continue;
                int idx1 = i, idx2 = j;
                for(int k=i+1; k<h; k++){
                    if(board2[k][j]!=board2[i][j]) break;
                    idx1 = k;
                }

                if(idx1-i+1>=n){
                    change = true;
                    for(int k=i; k<=idx1; k++) board[k][j] = '2';
                }

                for(int k=j+1; k<w; k++){
                    if(board2[i][k]!=board2[i][j]) break;
                    idx2 = k;
                }

                if(idx2-j+1>=n){
                    change = true;
                    for(int k=j; k<=idx2; k++) board[i][k] = '2';
                }
            }
        }
        down();
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

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

int main() {
  int W, H, x, y, r;
  std::cin >> W >> H >> x >> y >> r;
  if (x >= r && y >= r && x + r <= W && y + r <= H) {
    std::cout << "Yes\n";
  } else {
    std::cout << "No\n";
  }
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

int main(){
    ll n ; cin >> n;
    ll ans = 0;
    vector<ll> a(n,0);
    rep(i,n){
        ll x; cin >>x;
        if(i-x>=0) ans = ans + a.at(i-x);
        if(i+x<n) a.at(i+x)++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4844
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int l, r, d;
        cin >> l >> r >> d;

        cout << (r / d - (l - 1) / d);
        
    }
    
    return 0;
}



Measured memory_bytes: 3636
// INCLUDES
#include <bits/stdc++.h>
#include<assert.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//DEFINES
#define MAX 1000001
#define pii pair<int, int>
#define c1 __builtin_popcount
#define F first
#define S second
#define all(s) begin(s),end(s)
#define MIN3POS(a, b, c) (a) =< (b) ? ((a) =< (c) ? 1 : 3) : ((b) =< (c) ? 2 : 3)
#define MAX3POS(a,b,c) (a) >= (b) ? ((a) >= (c) ? 1 : 3) : ((b) >= (c) ? 2:3)
#define endl '\n'
#define int long long
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define FOR(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define IOS   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);}
//NAMESPACES
using namespace __gnu_pbds; 
using namespace std;
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif
//HELPERS

vector<int> powers2(32,0);void initialize(){ for(int i=1;i<powers2.size();i++) powers2[i] = powers2[i-1]*2;}
int32_t main()
{
IOS
int n,x,y;
cin>>n>>x>>y;
map<int,int> mp;
for(int i=1;i<=n;i++) {
    for(int j=i;j<=n;j++) {
        int a = abs(x-i) + 1 + abs(j-y);
        int b = abs(x-j) + 1 + abs(y-i);
        int c = abs(j-i);
        // debug(a,b,c);
        mp[min({a,b,c})]++;
    }
}
for(int i=1;i<n;i++) cout<<mp[i]<<endl;
// for(auto [k,v] : mp) cout<<k<<" "<<v<<endl;
return 0;
}
// Use emplace back in place of pushback
// Use tie function , for object destructuring  

Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    string s;
    cin >> s;
    vector<ll> A(26);
    rep(i, s.size()){
        A[s[i] - 'a']++;
    }
    ll sz = (ll)s.size();
    ll ans = 1 + sz * (sz - 1) / 2;
    rep(i, 26){
        ans -= A[i] * (A[i] - 1) / 2;
    }
    
    output(ans);
    return 0;
}

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

#define pb push_back
#define mp make_pair
#define loop1(x,s,e) for(int x=s;x!=e;x+=1-2*(s>e))
#define input_matrix(a,m,n) for(int i=0;i<m;i++)for(int j=0;j<n;j++)cin>>a[i][j];
#define input_array(a,n) for(int i=0;i<n;i++)cin>>a[i];
#define all(x) x.begin(),x.end()
#define newl "\n"
#define tests(t) int t; cin>>t; while(t--)
#define speed ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main()
 {
	int n,k;
	cin>>n>>k;
	vector<int> a(n),dp(n);
	loop1(i,0,n)dp[i]=INT_MAX;
	input_array(a,n);
	dp[0]=0;dp[1]=abs(a[1]-a[0]);
	
	for(int i=1;i<n;i++)
	{
	      for(int j=i-k>0?i-k:0;j<i;j++){ dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j])); }
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
 
#define INF 10000000000
 
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))

int compare_long(const void *a, const void *b) {
	return *(long*)a - *(long*)b;
}

int main() {
	long N;
	long i, j;
	long ans = INF;
	long tmp;
	long data[100001];
	long a[101];
	
	scanf("%ld", &N);
	for(i=0;i<N;i++) {
		scanf("%ld", &a[i]);
	}
	
	for(i=-100;i<=100;i++) {
		tmp = 0;
		for(j=0;j<N;j++) {
			tmp += (i - a[j]) * (i - a[j]);
		}
		ans = min(ans, tmp);
	}
	
	printf("%ld\n", ans);
	
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
ll n,i,j,k,l,m,a[301010];
char c;
string s;
std::vector<ll> q1 ;
map<ll,ll> q2;
set<ll> q3;
int main() {
    cin>>a[1]>>a[2]>>a[3];
    sort(a+1,a+1+3);
    if(a[1]==a[2]&&a[2]!=a[3])
    {
        cout<<"Yes";
    }
    else if(a[3]==a[2]&&a[2]!=a[1])
    {
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
vector<vi> to;
vi ans;
void dfs(int v, int p = -1){
  for(int u : to[v]){
    if(u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
}

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,q; cin >> n >> q;
  to = vector<vi>(n);
  rep(i,n-1){
    int a,b; cin >> a >> b;
    a--;  b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans = vi(n);
  rep(i,q){
    int p,x; cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0);
  rep(i,n) cout << ans[i] << " ";
  cout << "\n";
  return 0;
}


Measured memory_bytes: 24324
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,l,m=1,s=0; cin>>n;
  for(int i=0; i<n; i++){
    cin>>l; s+=l; m=max(m,l);
  }
  cout<<(s-m>m?"Yes":"No");
}

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

int main() {
    int n;
    cin >> n;
    int ans = 1001001001;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        int cnt = 0;
        while (a % 2 == 0) {
            cnt++;
            a /= 2;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0005
  * GCD and LCM
  */
object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).map(_.split(" +").map(_.toInt))
      .map { case Array(a, b) => (gcd(a, b), lcm(a, b)) }
      .foreach { case (g, l) => println(s"$g $l") }
  }

  def gcd(m: Int, n: Int): Int = {
    (m, n) match {
      case (a, b) if a < b => gcd(b, a)
      case (a, b) if b == 0 => a
      case (a, b) => gcd(b, a % b)
    }
  }

  def lcm(m: Int, n: Int): Int = {
    (m, n) match {
      case (a, b) if a < b => lcm(b, a)
      case (a, b) => (a.toLong * b.toLong / gcd(a, b).toLong).toInt
    }
  }
}

Measured memory_bytes: 44092
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }
    val ss = (0 until m).map { readLine()!!.split(' ').map { it.toInt() }.drop(1) }
    val ps = readLine()!!.split(' ').map { it.toInt() }

    var ans = 0

    for (i in 0 until (1 shl n)) {
        ss.indices
                .all { j -> ss[j].count { i shr (it - 1) and 1 == 1 } % 2 == ps[j] }
                .let { if (it) ans++ }
    }

    println(ans)
}


Measured memory_bytes: 38296
#!/usr/bin/env python

import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

MOD = 10 ** 9 + 7

def fact(n):
    if n <= 1:
        return 1
    return fact(n - 1) * n

n, k = map(int, raw_input().split())

if n > k:
    print 0
else:
    print fact(k) / fact(k - n) % MOD


Measured memory_bytes: 5732
#include "bits/stdc++.h"
using namespace std ;
const long long N=1e5+5, M = 1e5, OO = 1e16;
long long  mem[101][N];
int Profit[N], Weight[N], n, k;
long long knapsack(int i = n-1, int rem = k)
{
    if(rem < 0)
        return -OO;
    if(i < 0)
        return 0;
    long long &ret = mem[i][rem];
    if (ret != -1)
        return ret;
    ret = max(knapsack(i - 1, rem) , knapsack(i - 1, rem - Weight[i]) + Profit[i]);
    return	ret;
}
int main()
{
    scanf("%d %d", &n, &k);
    memset(mem, -1, sizeof mem);
    for(int i = 0 ; i < n ; ++i)
        scanf("%d %d", Weight+i, Profit+i);
    cout<<knapsack();

}


Measured memory_bytes: 79232
#include <stdio.h>
int gcd(int x, int y) {
	int r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}
int main() {
	int n, sum = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			for (int k = 1; k <= n; k++) {
				sum += gcd(i, gcd(j, k));
			}
		}
	}
	printf("%d\n", sum);
	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long long int li;
const ll MAXN=2e5+51,MOD=1e9+7;
ll cnt,num,ftot,res=1;
ll fact[MAXN],finv[MAXN],factor[MAXN],exponent[MAXN];
inline ll read()
{
    register ll num=0,neg=1;
    register char ch=getchar();
    while(!isdigit(ch)&&ch!='-')
    {
        ch=getchar();
    }
    if(ch=='-')
    {
        neg=-1;
        ch=getchar();
    }
    while(isdigit(ch))
    {
        num=(num<<3)+(num<<1)+(ch-'0');
        ch=getchar();
    }
    return num*neg;
}
inline ll qpow(ll base,ll exponent)
{
	ll res=1;
	while(exponent)
	{
		if(exponent&1)
		{
			res=(li)res*base%MOD;
		}
		base=(li)base*base%MOD,exponent>>=1;
	}
	return res;
}
inline void setup(ll cnt)
{
	fact[0]=fact[1]=finv[0]=1;
	for(register int i=2;i<=cnt;i++)
	{
		fact[i]=(li)fact[i-1]*i%MOD;
	}
	finv[cnt]=qpow(fact[cnt],MOD-2);
	for(register int i=cnt-1;i;i--)
	{
		finv[i]=(li)finv[i+1]*(i+1)%MOD;
	}
}
inline void getFact(ll num)
{
	for(register int i=2;i<=sqrt(num);i++)
	{
		if(num%i==0)
		{
			factor[++ftot]=i;
			while(num%i==0)
			{
				num/=i,exponent[ftot]++;
			}
		}
	}
	if(num!=1)
	{
		factor[++ftot]=num,exponent[ftot]=1;
	}
}
int main()
{
	cnt=read(),getFact(num=read()),setup(200000);
	for(register int i=1;i<=ftot;i++)
	{
		res=(li)res*fact[cnt+exponent[i]-1]%MOD;
		res=(li)res*finv[cnt-1]%MOD*finv[exponent[i]]%MOD;
	}
	printf("%d\n",res);
}


Measured memory_bytes: 1920
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

#define INF 1000000007 //1000000000000000003
#define MOD 1000000007
#define MAX 2000005

#define ll long long

//printf("%.10f", );
//cout << fixed << setprecision(10) << heikin << endl;
//vector<vector<int>> data(3, vector<int>(4, -1));
//left + 1 < top

using namespace std;
using P = pair<int, int>;
using Pc = pair<double, int>;
using T = tuple<int, int, int>;
using edge = struct { int to; long long dist; };
const double PI = 3.141592653589793;
long long fact[MAX], inv[MAX];
int dx[] = { -1,0,1,0 };
int dy[] = { 0,-1,0,1 };

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

vector<vector<int>> bingo(3, vector<int>(3));
vector<vector<int>> tree(100005);
int color[100005];
map<P, int>colorMap;
int m = 0;

struct BridgeInfo {
	int town1;
	int town2;
	int year;
	BridgeInfo(int t1, int t2, int y) {
		town1 = t1;
		town2 = t2;
		year = y;
	}
};

struct People {
	int index;
	int town;
	int year;
	People(int i, int t, int y) {
		index = i;
		town = t;
		year = y;
	}
};

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

struct UnionFind {
	vector<int>uf;

	UnionFind(int size) :uf(size, -1) {};

	int root(int target) {
		if (uf[target] < 0)return target;
		else return uf[target] = root(uf[target]);
	}

	void merge(int a, int b) {
		a = root(a);
		b = root(b);
		if (a == b)return;
		if (uf[b] < uf[a])swap(a, b);
		uf[a] += uf[b];
		uf[b] = a;
	}
};

ll CalcPow(ll num, ll power) {
	if (power == 0)return 1;
	if (power % 2 == 0) {
		ll half = CalcPow(num, power / 2);
		return (half * half) % MOD;
	}
	else return (num * CalcPow(num, power - 1)) % MOD;
}

ll combination(ll all, ll select) {
	if (all < select) return 0;
	if (all < 0 || select < 0) return 0;
	return fact[all] * (inv[select] * inv[all - select] % MOD) % MOD;
}

void initCombination(int max) {
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= max; ++i) {
		fact[i] = fact[i - 1] * i % MOD;
	}

	inv[max] = CalcPow(fact[max], MOD - 2);
	for (int i = max - 1; 0 <= i; --i) {
		inv[i] = (inv[i + 1] * (i + 1)) % MOD;
	}
}

int main() {

	string N;
	cin >> N;

	string ans = "No";
	for (int i = 0; i < 3;++i) {
		if (N[i] == '7') {
			ans = "Yes";
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 5440