akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <bitset>
#include <utility>
#include <assert.h>
using namespace std;
#define rank rankk
#define mp make_pair
#define pb push_back
#define xo(a,b) ((b)&1?(a):0)
#define tm tmp

//#define LL ll
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const int INF=0x3f3f3f3f;
const ll INFF=0x3f3f3f3f3f3f3f3fll;
const int MAX=3e5+10;
//const ll MAXN=2e8;
//const int MAX_N=MAX;
const ll MOD=1e9+7;
//const long double pi=acos(-1.0);
//const double eps=0.00000001;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<typename T>inline T abs(T a) {return a>0?a:-a;}
template<class T> inline
void read(T& num) {
    bool start=false,neg=false;
    char c;
    num=0;
    while((c=getchar())!=EOF) {
        if(c=='-') start=neg=true;
        else if(c>='0' && c<='9') {
            start=true;
            num=num*10+c-'0';
        } else if(start) break;
    }
    if(neg) num=-num;
}
inline ll powMM(ll a,ll b,ll M){
    ll ret=1;
    a%=M;
//    b%=M;
    while (b){
        if (b&1) ret=ret*a%M;
        b>>=1;
        a=a*a%M;
    }
    return ret;
}
void open()
{
//    freopen("1009.in","r",stdin);
    freopen("out.txt","w",stdout);
}

char a[MAX];
int st[MAX];
int dp[MAX];
map<int,int>last;//某个状态第一次出现的位置+1
set<int>s;//2的幂次有哪些 便于确定是否有
vector<int> er;//2的幂次
int id(char x)
{
    return x-'a';
}
int now;
int an,pos;
int main()
{
    scanf("%s",a);
    now=1;
    s.insert(now);
    er.push_back(now);
    for(int i=1;i<=25;i++)
    {
        now*=2;
        er.pb(now);
        s.insert(now);
    }
//    cout<<now<<endl;
    memset(dp,0x3f,sizeof(dp));
    int len=strlen(a);
    st[0]=(1<<id(a[0]));
    last[st[0]]=1;
    dp[0]=1;
    for(int i=1;i<len;i++)
    {
        st[i]=(st[i-1]^(1<<id(a[i])));
        if(!st[i]||s.count(st[i]))//仅1个奇数 或不存在奇数
        {
            dp[i]=1;//以此结尾的前缀最少分1块
            if(!last[st[i]])//之前未出现过
                last[st[i]]=i+1;
            else if(dp[last[st[i]]-1]>dp[i])
                last[st[i]]=i+1;
            continue;
        }
//        if(last[st[i]])
        //自己无法构成
        for(int j=0;j<26;j++)
        {
            int who=(st[i]^er[j]);
            if(last[who])//之前出现过
            {
                pos=last[who]-1;
                dp[i]=min(dp[i],dp[pos]+1);//多开1块
            }
        }
        if(last[st[i]])//之前出现过与之一样的状态
        {
            dp[i]=min(dp[i],dp[last[st[i]]-1]+1);
            if(dp[i]<dp[last[st[i]]-1])
                last[st[i]]=i+1;
        }
//        if(!last[st[i]])
        else//未出现过
            last[st[i]]=i+1;
    }
    printf("%d\n",dp[len-1]);
    return 0;
}
/*
abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx
*/


Measured memory_bytes: 206208
<?php
fscanf(STDIN, "%d", $s);
$n=strlen($s);

$ans=0;

for($i=1; $i<$n; $i+=2){
    $ans+=pow(10,$i)-pow(10,$i-1);
}
if($n%2==1){
    $ans+=$s-(pow(10,$n-1)-1);
}

echo $ans;

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */

int main(void){
    int n;
    cin >> n;
    vector<int> a, b, c;
    for(int i=0; i<n; i++){
        int tmp_a, tmp_b, tmp_c;
        cin >> tmp_a >> tmp_b >> tmp_c;
        a.push_back(tmp_a);
        b.push_back(tmp_b);
        c.push_back(tmp_c);
    }
    int dp[n][3];
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i=0; i<n-1; i++){
        for(int j=0; j<3; j++){
            if(j == 0){
                dp[i+1][j] = max(dp[i][1]+a[i+1], dp[i][2]+a[i+1]);
            }
            else if(j == 1){
                dp[i+1][j] = max(dp[i][0]+b[i+1], dp[i][2]+b[i+1]);
            }
            else if(j == 2){
                dp[i+1][j] = max(dp[i][0]+c[i+1], dp[i][1]+c[i+1]);
            }
        }
    }
    cout << max({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;
    return 0;
}

Measured memory_bytes: 2796
N,M = map(int,input().split())
switch = [i for i in range(1,N+1)]
light = {}

for i in range(M):
  ks = list(map(int,input().split()))
  light[i+1] = ks[1:] 
p = list(map(int,input().split()))
res = 0
for i in range(2**len(switch)):  # 空集合を除く場合はrange(1, 2**len(list1))
    li = []
    cnt = 0
    for j in range(len(switch)):
        if (i >> j) &1 == 1:
            li.append(switch[j])
    for j in range(1,M+1):
      if len(set(light[j]) & set(li)) % 2 == p[j-1]:
        cnt += 1
    if cnt == M:
      res += 1
print(res)

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

int main()
{
	int win, cur;
	cin >> win >> cur;

	if (win - cur * 2 > 0)
	{
		cout << win - cur * 2 << endl;
	}
	else
	{
		cout << 0 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
const int MaxN = 1e5;
typedef long long LL;

int n;
LL a[3 * MaxN + 5];
LL head[MaxN + 5], tail[MaxN + 5];
LL sumh, sumt;
int main()
{
	while(scanf("%d", &n) != EOF)
	{
		sumh = 0, sumt = 0;
		priority_queue<LL>que1;
		priority_queue<LL, vector<LL>, greater<LL> >que2;
		for(int i = 1; i <= 3 * n; i++)
		{
			scanf("%lld", &a[i]);
			if(i >= 1 && i <= n) 
			{
				que2.push(a[i]);
				sumh += a[i];
			}
			else if(i >= 2 * n + 1 && i <= 3 * n)
			{
				que1.push(a[i]);
				sumt += a[i];
			}
		}

		head[0] = sumh;
		tail[n + 1] = sumt;
		for(int i = n + 1; i <= 2 * n; i++)
		{
			que2.push(a[i]);
			sumh += a[i] - que2.top();
			head[i - n] = sumh;
			que2.pop();
		}
		
		for(int i = 2 * n; i >= n + 1; i--)
		{
			que1.push(a[i]);
			sumt += a[i] - que1.top();
			tail[i - n] = sumt;
			que1.pop();
		}

		LL ans = -1LL << 60;
		for(int i = 0; i <= n; i++)
			ans = max(ans, head[i] - tail[i + 1]);
		printf("%lld\n", ans);
		memset(a, 0, sizeof(a));
		memset(head, 0, sizeof(head));
		memset(tail, 0, sizeof(tail));
	}
	return 0;
}

Measured memory_bytes: 5876
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 22;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint();
	int S[600000];
	rep(i, N) S[i + N] = getint();
	rep(i, N) S[i] = getint();
	int A0 = S[N];
	int B0 = S[0];

	if (N == 1) {
		printf("%d %d\n", 0, A0 ^ B0);
		Would you please return 0;
	}

	rep(i, N - 1) S[i] ^= S[i + 1];
	S[N - 1] ^= B0;
	for (int i = N; i < N + N - 1; i++) S[i] ^= S[i + 1];
	S[N + N - 1] ^= A0;
	for (int i = N; i < N + N; i++) S[i + N] = S[i];

	int Z[600000];
	N = 3 * N;
	Z[0] = N;
	int i = 1;
	int j = 0;
	while (i < N) {
		while (i + j < N && S[j] == S[i + j]) j++;
		Z[i] = j;
		if (j == 0) {
			i++;
			continue;
		}
		int k = 1;
		while (i + k < N && k + Z[k] < j) {
			Z[i + k] = Z[k];
			k++;
		}
		i += k;
		j -= k;
	}
	N /= 3;
	
	int AB = A0 ^ B0;
	rep(i, N) {
		if (Z[i + N] >= N) {
			putint(i);
			putint(AB);
		}
		AB ^= S[i + N];
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

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

int main(){
    int i = 0;
    while(i < 3000){
        int x, y;
        scanf("%d %d", &x, &y);
        if(x == 0 && y == 0) break;
        i++;
        if(x <= y){
            printf("%d %d\n", x, y);
        }else{
            printf("%d %d\n", y, x);
        }
    }
    return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main()
{
    int n,cnt=0;
    scanf("%d",&n);
    int arr[n];
    int arrsorted[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&arr[i]);
        arrsorted[i]=arr[i];
    }
    sort(arrsorted,arrsorted+n);
    for(int i=0;i<n;i++)
    {
        if(arrsorted[i]!=arr[i])
            cnt++;
    }
    if(cnt<=2)
       printf("YES");
    else
        printf("NO");

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<stdio.h>
#include <sstream>
#define pi 3.141592653589793238462
#define limit 100005
#define mo 1000000007
typedef long long int lli;
typedef unsigned long long int ulli;
const lli mod=9999999999999983;
lli primes[6]={1125899906842597,1495921043,1005985879,1495921043,1005985879,1495921043};
using namespace std;
vector<lli>adj[2000009];
lli parent[2000009];
lli vis[2000009];
lli level[2000009];
lli dist[2000009];
lli dp[1009][1009];
lli arr[2000009];
lli brr[2000009];
lli crr[2000009];
lli hashing[2000009];
lli ar[509][509];
lli br[509][509];
lli cr[509][509];
string str[2000009];


lli solve(lli n,lli m)
{
     if(dp[n][m]!=-1)
        return (dp[n][m]%mo);

     if(n<0||m<0)
            return 0;

         if(n==0&&m==0)
            return 1;

    return dp[n][m]=(solve(n-1,m)+solve(n,m-1))%mo;
}


int main()
{
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
    int start_s = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    vector<lli>vect,vt,vct;
    vector<lli>::iterator itt;
    set<lli>st;
    set<lli>::iterator itr;
    map<lli,lli>mp;
    map<lli,lli>::iterator it;
    //string str;

    lli i,j,k,n,m,q,t,a,b,c,maxi=INT_MIN,mini=INT_MAX,sum=0,ans=0,res=0,val=0,ans1=0,ans2=0,rem=0,diff=0,cnt=0,l,r,flag=0,e,index,val1=0,val2=0,x,y,z,h=0,u,v,mid,len,tot,fl=0;
    char ch;

    cin>>n>>m;

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

        memset(dp,-1,sizeof(dp));

        for(i=0;i<n;i++)
        {
            for(j=0;j<m;j++)
            {
                if(str[i][j]=='#')
                    dp[i][j]=0;
            }
        }

    cout<<solve(n-1,m-1);
}


Measured memory_bytes: 75904
# coding=utf-8
# Date: 2020-01-08
# Author: lee215

import heapq

get = lambda: int(raw_input().strip())
getl = lambda: raw_input().strip()
gets = lambda: map(int, raw_input().strip().split())
getss = lambda n: [gets() for _ in xrange(n)]


H = get()

heap = [[H, 1]]
res = 0
while heap:
    h, n = heapq.heappop(heap)
    res += n
    if h == 1: continue
    heapq.heappush(heap, [h / 2, n * 2])

print res


Measured memory_bytes: 2692
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

s = input()
t = input()

print("Yes" if len(s)+1 == len(t) and t.startswith(s) else "No" )

Measured memory_bytes: 67596
#include<iostream>
#include<cstring>
#define inf 0x3f3f3f3f
using namespace std;
int p[25][25];
int m,n;
int mins;
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
void dfs(int x,int y,int step)
{
    step++;
    if(step>10)
        return ;
    for(int k=0;k<4;k++)
    {
        int nx=x+dx[k];
        int ny=y+dy[k];
        if(p[nx][ny]==1)
            continue;
        while(p[nx][ny]==0||p[nx][ny]==2)
        {
            nx+=dx[k];
            ny+=dy[k];
        }
        if(p[nx][ny]==-1)
            continue;
        if(p[nx][ny]==1)
        {
            p[nx][ny]=0;
            dfs(nx-dx[k],ny-dy[k],step);
            p[nx][ny]=1;
        }
        if(p[nx][ny]==3)
        {
            if(step<mins)
                mins=step;
        }
    }
}
int main()
{
    while(cin>>n>>m&&(n!=0||m!=0))
    {
        mins=inf;
        memset(p,-1,sizeof(p));
        for(int i=1;i<=m;i++)
            for(int j=1;j<=n;j++)
            cin>>p[i][j];
        for(int i=1;i<=m;i++)
            for(int j=1;j<=n;j++)
            if(p[i][j]==2)
            {
                dfs(i,j,0);
            }
            if(mins<inf)
                cout<<mins<<endl;
            else
                cout<<"-1"<<endl;
    }
    return 0;
}



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

static const ll INF = 1000000000;

int main() {
  int H, N;
  cin >> H >> N;
  vector<P> mypair(N);
  int A, B;
  rep(i, N) {
    cin >> A >> B;
    P p = make_pair(A, B);
    mypair[i] = p;
  }
  sort(mypair.begin(), mypair.end());

  // h以上のダメージを与える時の最小消費mpを保存
  vector<ll> dp(H, INF);
  for (int h = 0; h < H; h++) {
    for (int i = 0; i < N; i++) {
      P p = mypair[i];
      if (p.first > h) {
        dp[h] = min(dp[h], (ll)p.second);
      } else {
        dp[h] = min(dp[h], dp[h - p.first] + p.second);
      }
    }
  }

  cout << dp[H - 1] << endl;
  return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  int k[M];
  int s[M][N];
  
  for (int i = 0; i < M; i++) {
    cin >> k[i];
    for (int j = 0; j < k[i]; j++) {
      cin >> s[i][j];
    }
  }
  
  int p[M];
  for (int i = 0; i < M; i++) {
    cin >> p[i];
  }
  
  int bits;
  bool light[M];
  bool ok[1 << N];
  for (bits = 0; bits < (1 << N); bits++) {
    for (int i = 0; i < M; i++) {
      light[i] = true;
      int ons = 0;
      for (int j = 0; j < k[i]; j++) {
        if ((bits >> (s[i][j]-1) & 1)) {ons++;}
      }
      if ((ons - p[i]) % 2 != 0) {light[i] = false;}
    }
    
    ok[bits] = true;
    for (int i = 0; i < M; i++) {
      if (!light[i]) ok[bits] = false;
    }
  }
  
  int ans = 0;
  for (int i = 0; i < (1 << N); i++) {
    if (ok[i]) {ans++;}
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll MOD = 1e9 + 7;
constexpr int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
template <class T>
inline void chmin(T &a, T b) { a = min(a, b); }
template <class T>
inline void chmax(T &a, T b) { a = max(a, b); }
template <class T>
inline bool kbit(T &x, int k) { return ((x >> k) & 1LL); }
template <class T>
void zip(V<T> &v) {
    sort(all(v));
    v.erase(unique(all(v)), v.end());
}
void debug() { cerr << "ok" << endl; }
template <class T>
void printv(const vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cout << v[i] << (i + 1 == v.size() ? '\n' : ' ');
}
template <class T>
void readv(vector<T> &v) {
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    ll a[3];
    cin >> n >> a[0] >> a[1] >> a[2];
    V<V<int>> s(n);
    for (int i = 0; i < n; i++) {
        string t;
        cin >> t;
        for (int j = 0; j < 2; j++) {
            if (t[j] == 'A') s[i].eb(0);
            if (t[j] == 'B') s[i].eb(1);
            if (t[j] == 'C') s[i].eb(2);
        }
    }
    V<int> res(n);
    for (int i = 0; i < n; i++) {
        if (a[s[i][0]] == 0 && a[s[i][1]] == 0) {
            cout << "No\n";
            return 0;
        }
        if (a[s[i][0]] == 0) {
            a[s[i][0]]++;
            a[s[i][1]]--;
            res[i] = s[i][0];
            continue;
        }
        if (a[s[i][1]] == 0) {
            a[s[i][0]]--;
            a[s[i][1]]++;
            res[i] = s[i][1];
            continue;
        }
        if (i + 1 == n) {
            res[i] = s[i][0];
            continue;
        }
        if (s[i + 1][0] == s[i][0] || s[i + 1][1] == s[i][0]) {
            a[s[i][0]]++;
            a[s[i][1]]--;
            res[i] = s[i][0];
        } else {
            a[s[i][0]]--;
            a[s[i][1]]++;
            res[i] = s[i][1];
        }
    }
    cout << "Yes\n";
    string c = "ABC";
    for (int i = 0; i < n; i++) {
        cout << c[res[i]] << '\n';
    }
}

Measured memory_bytes: 9012
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int t = 0;
  while(a>=b) b*=2, ++t;
  while(b>=c) c*=2, ++t;
  cout << (t<=k?"Yes":"No") << endl;
}


Measured memory_bytes: 3628
package main

import (
  "fmt"
)

func main() {
  var n int
  fmt.Scan(&n)
  
  var i int = n / 1000
  var change int
  if n % 1000 == 0 {
  	change = 1000 * i - n
  } else {
    change = 1000 * ( i + 1 ) - n
  }
  
  fmt.Println(change)
}

Measured memory_bytes: 1772
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;

struct Edge{
    int to, id;
    Edge(int t, int i): to(t), id(i){}
};

vector<vector<Edge>> G;
vector<int> el;
bool dfs(int v, int tv, int p=-1){
    if(v==tv) return true;
    for(Edge e: G[v]){
        if(e.to == p) continue;
        if(dfs(e.to, tv, v)){
            el.emplace_back(e.id);
            return true;
        }
    }
    return false;
}

int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    ll N; cin>>N;
    G.resize(N+10);
    vector<P> E(N-1);
    REP(i, N-1) {
        int a, b; cin>>a>>b;
        a--, b--;
        G[a].emplace_back(b, i);
        G[b].emplace_back(a, i);
    }
    ll M; cin>>M;
    vector<ll> eset(M);
    REP(i, M) {
        int a, b; cin>>a>>b;
        a--, b--;
        el = vector<int>();
        dfs(a, b, -1);
        for(int id: el){
            eset[i] |= 1LL<<id;
        }
    }
    ll ans = 0;
    REP(i, 1LL<<M){
        ll mask = 0;
        REP(j, M){
            if((i>>j)&1){
                mask |= eset[j];
            }
        }
        int white = __builtin_popcountll(mask);
        ll tmp = 1LL<<(N-1-white);
        if(__builtin_popcountll(i)%2 == 0) ans += tmp;
        else ans -= tmp;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
  int a,b;
  cin>>a>>b;
  cout<<a/b<<" "<<a%b<<" ";
  double aa=a,bb=b;
  aa/=bb;
  printf("%.6lf\n",aa);
}



}
main() try{
    mainmain();
}
catch(...){
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

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

    vector<int> a(n);
    for (auto i = 0; i < n; i++) cin >> a[i];
    sort(a.begin(), a.end());

    int ans = 0;
    vector<bool> flags(a.back() + 1, true);
    flags[0] = false;
    for (auto i = 0; i < n; i++) {
        if(!flags[a[i]]) continue;
        flags[a[i]] = false;
        for (auto j = 2 * a[i]; j <= a.back(); j += a[i]) flags[j] = false;
        if(i < n - 1 and a[i] == a[i + 1]) continue;
        ans++;
    }

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

Measured memory_bytes: 4312
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>
#include <sstream>
#include <istream>
#include <iomanip>
#include <typeinfo>
#include <stack>

using namespace std;
typedef long long ll;
//奇数　Nは全てに辺が伸びる
//      
int main(){
    ll N;
    cin >> N;
    
    ll sum = 0;

    vector<pair <ll, ll > > ans;
    for(ll i = N; i > 0; i--){
        //ll conf = 0;
        for(ll j = i - 1; j > 0; j--){
            
            if(N % 2 == 1){
                //奇数のとき、Nに関しては全ての辺に辺を結ぶ
                if(i == N){
                    ans.push_back(make_pair(i, j));
                    continue;
                }
                if((i + j) % N  != 0){
                    ans.push_back(make_pair(i, j));
                }
            }else{
                if((i + j) % N  != 1){
                    ans.push_back(make_pair(i, j));
                }                
            }



            
            //conf += j;
        }
        //cout << conf << endl;
    }

    cout << ans.size() << endl;
    for(ll i = 0; i < ans.size(); i++){
        cout << ans[i].first << " " << ans[i].second << endl;
    }

} 

Measured memory_bytes: 512
// base: https://atcoder.jp/contests/agc037/submissions/7895840
// hint: https://www.youtube.com/watch?v=68Z88ttiuUg

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 998244353;

ll powmod(ll x, ll n) { // like pow(x, n)
  ll r = 1;
  while (n) {
    if (n & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return r;
}

ll cnts[3]; // 0: r, 1: g, 2: b

int main(int argc, char** argv) {
  int N;
  cin >> N;
  string S;
  cin >> S;

  ll ans = 1;
  ll tmp = 0; // the count of mid color. e.g. The count of G in (BBB)(GG)
  rep(i, 3 * N) {
    int c;
    if (S[i] == 'R') {
      c = 0;
    } else if (S[i] == 'G') {
      c = 1;
    } else {
      c = 2;
    }

    int a = (c + 1) % 3;
    int b = (c + 2) % 3;

    if ((cnts[a] > 0) && (cnts[b] > 0)) { // we can make triple
      ans *= tmp;
      ans %= MOD;
      --cnts[a];
      --cnts[b];
      --tmp;
    } else if ((cnts[a] > 0) || (cnts[b] > 0)) {
      if (cnts[a] == 0) { swap(a, b); }
      // Now, cnts[a] > 0 and cnts[b] == 0
      if (cnts[a] > tmp) { // cnts[a] is the largest. e.g. a is B in (BBB)(GG)
        ans *= cnts[a] - tmp;
        ans %= MOD;
        ++tmp;
      }
      ++cnts[c];
    } else { // both are 0
      ++cnts[c];
    }
  }

  // ans *= N!
  rep(i, N) {
    ans *= (i + 1);
    ans %= MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
   ll n,m;
   cin>>n>>m;
   vector<ll> k(m),p(m);
   vector<vector<ll>> s(m);
   for(ll i=0;i<m;i++){
        cin>>k.at(i);
        s.at(i).resize(k.at(i));
        for(ll j=0;j<k.at(i);j++){
            cin>>s.at(i).at(j);
        }
   }
   for(ll i=0;i<m;i++)cin>>p.at(i);
   ll ans=0;
   for(ll bit=0;bit<(1LL<<n);bit++){
        bool flag=true;
        for(ll i=0;i<m;i++){
            ll cnt=0;
            for(ll j=0;j<k.at(i);j++){
                if(bit&(1LL<<(s.at(i).at(j)-1)))cnt++;
            }
            if(cnt%2!=p.at(i)){
              flag=false;
              break;
            }
        }
        if(flag)ans++;
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,v,l[200005],b,e;
int main(){
    cin>>n;
    b=ceil((double)(n+1)/2);
    e=(n%2==0)?(-1):(1);
    for(int i=1;i<=n;i++)
	{
        cin>>v;
        l[b]=v;
        b+=i*e;
        e*=-1;
    }
    for(int i=1;i<=n;i++)
    cout<<l[i]<<" ";
    return 0;
}

Measured memory_bytes: 2944
from collections import deque
import sys
input = sys.stdin.readline
N,Q = (int(x) for x in input().split())
connection ={i:[] for i in range(1,N+1)}
#木の構造
for i in range(1,N):
    a,b = (int(x) for x in input().split())
    connection[a].append(b)
    connection[b].append(a)

#各頂点のポイント入力
point ={i:0 for i in range(1,N+1)}
for i in range(1,Q+1):
    p,x = (int(x) for x in input().split())
    point[p] +=x

#深さ優先探索
dq =deque()
dq.append(1)
passed ={i:0 for i in range(1,N+1)} #各頂点を通過チェック、０は未通過
while dq:
    now =dq.pop()
    passed[now] =1
    for next in connection[now]:
        if passed[next] ==1:
            continue
        point[next] +=point[now]
        dq.append(next)
        #print(next,end=" ")
print(*point.values())

Measured memory_bytes: 112468
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long co[26] = { 0 };
int main() {
	string s;
	cin >> s;
	long long n = s.size();
	for (int i = 0; i < n; i++) {
		co[int(s[i] - 'a')]++;
	}
	long long ans = n * (n - 1) / 2 + 1;
	for (int j = 0; j < 26; j++) {
		if (co[j] >= 2) {
			ans -= co[j] * (co[j] - 1) / 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
using System;
using System.IO;
using System.Collections.Generic;

namespace ABC118A
{
    public partial class Program
    {
        void Solve(StreamScanner ss, StreamWriter sw)
        {
            //---------------------------------
            var A = ss.Next(int.Parse);
            var B = ss.Next(int.Parse);

            sw.WriteLine(B % A == 0 ? A + B : B - A);
            //---------------------------------
        }
    }

    public class StreamScanner
    {
        static readonly char[] Separator = { ' ' };
        readonly StreamReader streamReader;

        string[] line = new string[0];
        int index = 0;

        public bool EndOfStream { get { return streamReader.EndOfStream && index >= line.Length; } }

        public StreamScanner(Stream stream)
        {
            this.streamReader = new StreamReader(stream);
        }

        public string Next()
        {
            return Next(s => s);
        }

        public string[] Next(int x)
        {
            return Next(s => s, x);
        }

        public string[][] Next(int x, int y)
        {
            return Next(s => s, x, y);
        }

        public T Next<T>(Func<string, T> parser)
        {
            if (EndOfStream) throw new EndOfStreamException();
            if (index < line.Length) return parser(line[index++]);
            index = 0;
            line = streamReader.ReadLine()?.Split(Separator, StringSplitOptions.RemoveEmptyEntries);
            return Next(parser);
        }

        public T[] Next<T>(Func<string, T> parser, int x)
        {
            var ret = new T[x];
            for (var i = 0; i < x; ++i) ret[i] = Next(parser);
            return ret;
        }

        public T[][] Next<T>(Func<string, T> parser, int x, int y)
        {
            var ret = new T[y][];
            for (var i = 0; i < y; ++i) ret[i] = Next(parser, x);
            return ret;
        }
    }

    public partial class Program
    {
        static void Main()
        {
            Excute(Console.OpenStandardInput(), Console.OpenStandardOutput());
        }

        public static void Excute(Stream input, Stream output)
        {
            var ss = new StreamScanner(input);
            var sw = new StreamWriter(output);
            new Program().Solve(ss, sw);
            sw.Flush();
        }
    }
}

Measured memory_bytes: 13140
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a= new int[n];
		for(int i = 0;i<n;i++)
			a[i] = sc.nextInt();
		Arrays.sort(a);
		for(int i = 0;i<n-1;i++) {
			if(a[i]==a[i+1]) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}

Measured memory_bytes: 65292
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int comb[2100][2100] = {};

int main(){
    for(int i = 0; i < 2100; i++){
        comb[i][0] = 1;
    }
    for(int i = 1; i < 2100; i++){
        for(int j = 1; j < i; j++){
            comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % MOD;
        }
        comb[i][i] = 1;
    }
    long long int K, N;
    cin >> N >> K;
    for(int i = 1; i <= K; i++){
        if(i - 1 > N - K){
            cout << 0 << endl;
            continue;
        }
        cout << (comb[K - 1][i - 1] * comb[N - K + 1][i]) % MOD << endl;
    }
    return 0;
}

Measured memory_bytes: 33280
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 510000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  lli A,B,C,D,E,F,N,M,K,L,X,Y,Z,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  Out((N-1)/2);
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
int dp[111][11111],N,W,c[111],d[111],bnu;
int kei(int i,int j){
    if(dp[i][j])return dp[i][j];
    if(i==N+1){return 0;}
    if(j<d[i]){return kei(i+1,j);}
    return dp[i][j]=bnu=max(kei(i+1,j),kei(i+1,j-d[i])+c[i]);
}
int main(){
    cin>>N>>W;
    for(int i=1;i<N+1;i++)cin>>c[i]>>d[i];
    cout<<kei(0,W)<<endl;
}

Measured memory_bytes: 6844
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int main() {
	vector<int> a(4);
	for (int& i : a) cin >> i;
	cout << accumulate(a.begin(), a.end(), 0) / 60 % 60 << endl << accumulate(a.begin(), a.end(), 0) % 60 << endl;
}


Measured memory_bytes: 3064
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
            int[] input = Input.InputMultipleNum();
            Console.WriteLine(input[0] < input[1] ? 0 : 10);
        }

    }

    static class Input
    {
        static public int InputSingleNum() { return int.Parse(Console.ReadLine()); }
        static public int[] InputMultipleNum() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }

        static public string InputSingleStr() { return Console.ReadLine(); }
        static public string[] InputMultipleStr() { return InputSingleStr().Split(' '); }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
 
using namespace std;
typedef long long ll;
int INF=1;
// 四則演算
// 構文がおかしい場合は-INF
int analysis(string s,bool ope){
  if(s=="")return -INF;
  if(!ope){
    bool isNumber=true;
    int minOnePos=1000000;
    for(int i=0;i<(int)s.size();i++){
      if(!(s[i]>='0'&&s[i]<='1'))isNumber=false;
      else if(s[i]=='1')minOnePos=min(minOnePos,i);
    }
    if(isNumber){
      if((int)s.size()-minOnePos>11)return -INF;
      int num=0;
      for(int i=0;i<(int)s.size();i++){
	num=num*2;
	if(s[i]=='1')num+=(s[i]-'0');
      }
      if(num<0||num>=1024)return -INF;
      return num;
    }
    if(s[0]=='('){
      int cnt=1;
      bool ok=true;
      for(int i=1;i<(int)s.size()-1;i++){
	if(s[i]=='(')cnt++;
	else if(s[i]==')')cnt--;
	if(cnt==0)ok=false;
      }
      // 括弧を取る場合、必ず中にoperatorが存在
      if(ok&&cnt==1&&s[s.size()-1]==')')
	return analysis(s.substr(1,s.size()-2),true);
    }
  }
  int cnt=0;
  for(int i=s.size()-1;i>=0;i--){
    if(s[i]==')')cnt++;
    else if(s[i]=='(')cnt--;
    else if(cnt==0&&s[i]=='+'){
      int res1=analysis(s.substr(0,i),false);
      int res2=analysis(s.substr(i+1),false);
      if(res1==-INF||res2==-INF)return -INF;
      else{
	if(res1+res2>=1024||res1+res2<0)return -INF;
	return res1+res2;
      }
    }
    else if(cnt==0&&s[i]=='-'){
      int res1=analysis(s.substr(0,i),false);
      int res2=analysis(s.substr(i+1),false);
      if(res1==-INF||res2==-INF)return -INF;
      else{
	if(res1-res2>=1024||res1-res2<0)return -INF;
	return res1-res2;
      }
    }
  }
  cnt=0;
  for(int i=s.size()-1;i>=0;i--){
    if(s[i]==')')cnt++;
    else if(s[i]=='(')cnt--;
    else if(cnt==0&&s[i]=='*'){
      int res1=analysis(s.substr(0,i),false);
      int res2=analysis(s.substr(i+1),false);
      if(res1==-INF||res2==-INF)return -INF;
      else{
	if(res1*res2>=1024||res1*res2<0)return -INF;
	return res1*res2;
      }
    }
  }
  return -INF;
}

string s;
vector<int> poss;
int res;
char chs[]={'0','1','+','-','*','(',')'};
void rec(int depth){
  if(depth==(int)poss.size()){
    int b=analysis(s,false);
    res=max(res,b);
  }
  else{
    for(int i=0;i<7;i++){
      s[poss[depth]]=chs[i];
      rec(depth+1);
    }
  }
}

int main(){
  while(cin>>s){
    poss.clear();
    for(int i=0;i<(int)s.size();i++)
      if(s[i]=='.')poss.push_back(i);
    res=-1;
    rec(0);
    cout<<res<<endl;
  }
  return 0;
}

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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << (a) << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int N = 1e5 + 10;

int n, val[N];
vi adj[N];
string s;

int mod(int x) {
    while (x < 0) x += 26;
    while (x >= 26) x -= 26;
    return x;
}

bool vis[N];
int dfs(int u) {
    if (vis[u]) return 0;
    vis[u] = 1;
    int ans = val[u];
    for (int v : adj[u]) ans += dfs(v);
    return ans;
}

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

    cin >> s; n = si(s);
    s = "a" + s + "a";
    forn(i,si(s)-1) val[i] = mod(int(s[i+1])-s[i]);
    for (int i = 0, j = n; i < j; i++, j--) {
        val[i] = mod(val[i] + val[j]);
        val[j] = 0;
    }
    int m; cin >> m;
    while (m--) {
        int l,r; cin >> l >> r; l--;
        int u = min(l,n-l), v = min(r,n-r);
        adj[u].pb(v);
        adj[v].pb(u);
    }

    bool ok = 1;
    forn(u,n+1) if (!vis[u]) ok &= dfs(u)%26 == 0;
    cout << (ok ? "YES" : "NO") << endl;

    return 0;
}


Measured memory_bytes: 6252
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  int A, B, X;
  while (cin >> A >> B >> X) {
    bool res = A <= X && X <= A + B;
    cout << (res ? "YES" : "NO") << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), x = in.ni();
        int[] a = in.ni(n);
        long ans = 0;
        for (int i = 0; i < n-1; i++) {
            if(a[i]+a[i+1]>x){
                if(a[i]>x){
                    ans += a[i+1];
                    a[i+1] = 0;
                    ans += a[i]-x;
                }else{
                    ans += a[i+1]+a[i]-x;
                    a[i+1] = x-a[i];
                }
            }
        }
        out.println(ans);
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N, A, B;

void makes(int a, int b, int v) {
    if(a == b) {
        cout << a << " ";
        return;
    }
    int x = (a ^ b) & (-(a ^ b));
    v ^= x;
    int y = v & (-v);
    makes(a, a ^ y, v);
    makes(a ^ y ^ x, b, v);
}

signed main() {
    cin >> N >> A >> B;
    if(__builtin_popcount(A ^ B) & 1) {
        puts("YES");
        makes(A, B, (1 << N) - 1);
    } else {
        puts("NO");
    }
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

vector<ll>relation[20], money(20, 1);

int main() {
	string s;
	cin >> s;
	s[3] = '8';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
import * as fs from "fs"

const main = (input: string) => {
  let isBad = false
  let p = ""
  for (var i = 0; i < input.length; i++) {
    if (p == input[i]) {
      isBad = true
      break
    }
    p = input[i]
  }
  if (isBad) {
    console.log("Bad")
  } else {
    console.log("Good")
  }
}

main(fs.readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 7372
import sys

def enum_div(n):
    ir=int(n**(0.5))+1
    ret=[]
    for i in range(1,ir):
        if n%i == 0:
            ret.append(i)
            if (i!= 1) & (i*i != n):
                ret.append(n//i)
    return ret

from collections import deque    
#    q = deque(l)
#    q.append(4) # 後ろから4を挿入, l=deque([0,1,2,3,4])
#    q.appendleft(5)#前から5を挿入, l=deque([5,0,1,2,3,4])
#    x = q.pop() #後ろの要素を取り出す, x=4, l=deque([5,0,1,2,3])
#    y = q.popleft() # 前の要素を取り出す, y=5, l = deque([0,1,2,3])

def get_primenumber(number):#エラトステネスの篩
    prime_list = []
    search_list = deque(list(range(2,number+1)))
#    search_list = list(range(2,number+1))
    #search_listの先頭の値が√nの値を超えたら終了
#    while search_list[0] <= math.sqrt(number):
    while search_list[0]**2 <= number:
      #search_listの先頭の値が√nの値を超えたら終了
      #search_listの先頭をprime_listに入れて、先頭をリストに追加して削除
        head_num = search_list.popleft()
#        head_num = search_list.pop(0)
        prime_list.append(head_num)
        #head_numの倍数を除去
        search_list =deque( [num for num in search_list if num % head_num != 0])
    #prime_listにsearch_listを結合
    prime_list.extend(search_list)
    return prime_list

n=int(input())
ap=list(map(int,input().split()))
amin=min(ap)
amax=max(ap)

if amax==1:
    print("pairwise coprime")
    sys.exit()

if amin!=1:
    bp=enum_div(amin)+[amin]
    bp.sort()
    bp=bp[1:]
    for bpi in bp:
        yn=""
        for ai in ap:
            if ai%bpi!=0:
                yn="coprime"
                break
        if yn=="":
            print("not coprime")
            sys.exit()

if n>=78500 :
    print("setwise coprime")
    sys.exit()

aa=[0]*(amax+1)
for ai in ap:
    aa[ai]+=1

#p=get_primenumber(amax)

#for pp in p:
for pp in range(2,amax+1):
    psum=sum(aa[pp: :pp])
#    print("pp:",pp,psum)
    if psum>=2:
            print("setwise coprime")
            sys.exit()
## max_13.txt ... max_16.txt : "setwise coprime"
print("pairwise coprime")
   


Measured memory_bytes: 183936