akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#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 repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  string s;
  cin>>s;
  ll n=sz(s);
  ll ans=0;
  for(int bit=0;bit<(1<<n-1);bit++){
    ll k=0;
    rep(i,n-1){
      if((1<<i)&bit){
        k*=10;
        k+=s[i]-'0';
        ans+=k;
        k=0;
      }
      else{
        k*=10;
        k+=s[i]-'0';
      }
    }
    k*=10;
    k+=s[n-1]-'0';
    ans+=k;
  }
  COUT(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    long long n;
    cin>>n;
    long long ue,sum,ketasu=(long long)0;
    for(long long i=n;i>0;i/=10){
        ketasu++;
        ue=i%10;
        sum+=i%10;
    }
    ketasu--;
    cout<<max((ketasu*9)+ue-1,sum)<<endl;
    return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A[] = new int[3];
		for (int i = 0; i < 3; i++) {
			A[i] = sc.nextInt();
		}
		Arrays.sort(A);
		System.out.println(A[0]+A[2]*10+A[1]);
	}
}


Measured memory_bytes: 22612
#include<iostream>
#include<string>
#define MAX 200000
using namespace std;

/*
popcount(n)
f(n) = n%popcount(n)が0になるまで
*/

long long n;
string X;

void f(long long k, long long n){
    
	if(n == 0) cout << k << endl;
	else{
        //cは1の個数
		long long m=n, c=0;
		while(m){
			c += m&1;
			m >>= 1;
		}
        if(c == 0){
        cout << k << endl;
        return;
    } 
		f(k+1, n%c);
	}
   
}

int main(){

    cin >> n;
    cin >> X;

    long long num = 0;

    //1の数を数える
    for(int i = 0;i < n;i++){
        if(X[i] == '1') num++;
    }

    long long x[MAX],y[MAX],z[MAX],b = 1;

    x[n - 1] = 1%num;
    y[n - 1] = 1%(num + 1);
    if(num - 1 != 0){
        z[n - 1] = 1%(num - 1);
    }
    

    for(int i = n - 2;i >= 0;i--){
        //i桁目が1だったときの mod num + 1
        y[i] = (2*y[i + 1])%(num + 1);
        //i桁目が1だったときの mod num - 1
        if(num - 1 != 0){
        z[i] = (2*z[i + 1])%(num - 1);
        }
    }

    //mod num + 1のときの値
    long long ans1 = 0;
    for(int j = 0;j < X.size();j++){
            if(X[j] == '1') ans1 = (ans1 + y[j])%(num + 1);
    }

    //mod num - 1のときの値
    long long ans2 = 0;
    if(num - 1 != 0){
    
    for(int j = 0;j < X.size();j++){
            if(X[j] == '1') ans2 = (ans2 + z[j])%(num - 1);
    }
    }
    
    for(int i = 0;i < n;i++){
        
        string s;
        long long mod = num;
        long long c = 0;
        s = X;
        if(X[i] == '0'){
            s[i] = '1';
            mod++;
            
            c = (ans1 + y[i])%mod;
        }
        if(X[i] == '1'){
            s[i] = '0';
            mod--;
            if(mod != 0){
            c = (ans2 - z[i] + mod)%mod;
            }
        }

        if(mod <= 0){
            cout << "0" << endl;
        }
        else if(c != 0){
            f(1, c);
        }
        else{
            cout << "1" << endl;
        }
    }
 
    return 0;
}

Measured memory_bytes: 6864
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 99999999999
#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(150) << 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 5100000
#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,R,X,Y,H,W,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  map<int,int>P;
  rep(i,0,N){
    cin >> A;
    P[A]++;
  }
  if(P.size()%2==0)flag=-1;
  Out(P.size()+flag);
}

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

using namespace std;

int main()
{
  int n, tmp;
  cin >> n;
  vector<int> a;
  for (int i = 0; i < n; ++i)
  {
    cin >> tmp;
    a.push_back(tmp);
  }

  int swapCount = 0;
  for (int i = 0; i < n; ++i)
  {
    int minIndex = i;
    for (int j = i; j < n; ++j)
      if (a[j] < a[minIndex]) minIndex = j;
    if (a[i] > a[minIndex])
    {
      swapCount++;
      swap(a[i], a[minIndex]);
    }
  }

  for (int i = 0; i < n - 1; i++)
    printf("%d ", a[i]);
  printf("%d\n", a[n - 1]);
  printf("%d\n", swapCount);
  return 0;
}

Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//�]���؂�グ�� =>  (a + b - 1) / b 

signed main(){
	int a; cin>>a;
  if(a==7 || a==5 || a==3){
    cout<<"YES"<<endl;
  }
else cout<<"NO";
	
	return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int n;
int cnt,flag;
int flag1;

//int vec[4][2] ={{1,0},{-1,0},{0,1},{0,-1}};
int t[1000000],x[1000000],y[1000000];

int main(void){
    cin >> n;
    for(int i = 1; i < n+1; i++){
        cin >> t[i] >> x[i] >> y[i];
    }

    flag = 1;
    int dt,dx,dy;
    for(int i = 0; i < n; i++){
        dt = t[i+1]-t[i];
        dx = x[i+1]-x[i];
        dy = y[i+1]-y[i];

        if((dt < (dx + dy)) || ((dt + dx + dy)%2 == 1)){
            flag = 0;
            break;
        }
    }

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

Measured memory_bytes: 8832
#include<cstdio>
#include<algorithm>
using namespace std;
int n,k,l[100],sum;
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;++i)
		scanf("%d",&l[i]);
	sort(l+1,l+n+1);
	for(int i=n;i>n-k;--i)
		sum+=l[i];
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

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

vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z));
    return res;
}

void debug_out(vector<string> __attribute__ ((unused)) args, __attribute__ ((unused)) int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}

#ifdef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
#else
#define debug(...) 42
#endif

const double PI = acos(-1);
typedef long long ll;
#define int ll
#define fori(n) for(int i=0; i<int(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;

void solve() {
    cins(s);
    cins(t);
    if(t.size()==s.size()+1 && s+t.back()==t)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

signed main() {
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    solve();
}



Measured memory_bytes: 3608
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")
#define int long long

using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 35;

int n, a[N], b[N], ind[N], T, dp[N][LOG];

bool cmp(int x, int y){
	return (a[x]) * (b[y] + a[y] + 1) > a[y] * (a[x] + b[x] + 1);
}

bool cmp2(int x, int y){
 	return b[x] < b[y]; 
}

vector<int> Fir, Sec, Ps;

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> T;
	for (int i = 1; i <= n; i++){
		cin >> a[i] >> b[i];
		if (a[i] != 0) Fir.pb(i);
		else Sec.pb(i);
	}
	sort(all(Fir), cmp);
	ll t = 0;
  	sort(all(Sec), cmp2);
	Ps.pb(0);
	for (auto u:Sec){
		Ps.pb(Ps.back() + 1 + b[u]);
	}
	Ps.pb(INF);
  	//cout << Ps[1] << '\n';
	ll ans = 0;
	int cnt = 0;
  	memset(dp, 63, sizeof dp);
	dp[0][0] = 0;
	for (int i = 1; i <= Fir.size(); i++){
		dp[i][0] = 0;
      	for (int j = 1; j < LOG; j++){
         	if (dp[i - 1][j - 1] > T) dp[i][j] = dp[i - 1][j];
			else dp[i][j] = min(dp[i - 1][j], (dp[i - 1][j - 1] + 1) * (a[Fir[i - 1]] + 1) + b[Fir[i - 1]]);
 		}
	}
	for (int j = 0; j < LOG; j++){
		ll ted = j;
		ll t = dp[Fir.size()][j];
		//cout << t << '\n';
		if (t > T) continue;
      	for (int i = 0; i < Sec.size(); i++){
			t += b[Sec[i]] + 1;
			if (t <= T) ted++;
		}
		ans = max(ans, ted);
	}
	cout << ans;








	return 0;
}


Measured memory_bytes: 62832
#include <iostream>
#include <cmath>
#include <set>
#include <string>

using namespace std;
using LLONG = long long;

int main()
{
    string a, b;
    cin >> a >> b;
    int value = stoi(a + b);
    int root = static_cast<int>(sqrt(value));
    if (value == root * root)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var e, v int
	var a []int
	fmt.Scan(&e)
	for i := 0; i < e; i++ {
		fmt.Scan(&v)
		a = append(a, v)
	}

	for i := 0; i < e; i++ {
		if a[i] == a[e-1] {
			fmt.Printf("%d", a[i])
		} else {
			fmt.Printf("%d ", a[i])
		}
	}
	fmt.Print("\n")

	for i := 1; i < e; i++ {
		key := a[i]
		j := i - 1
		for j >= 0 && a[j] > key {
			a[j+1] = a[j]
			j--
		}
		a[j+1] = key
		for i := 0; i < e; i++ {
			if a[i] == a[e-1] {
				fmt.Printf("%d", a[i])
			} else {
				fmt.Printf("%d ", a[i])
			}
		}
		fmt.Print("\n")
	}
}


Measured memory_bytes: 1184
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long hp = scanner.nextLong();
        scanner.close();

        long sumAttack = 0;
        long nextHp = hp;
        long numMon = 1;
        while(true) {
            if(nextHp != 1) {
                sumAttack += numMon;
                nextHp = nextHp / 2;
                numMon = numMon * 2;
            } else {
                sumAttack += numMon;
                break;
            }
        }

        System.out.println(sumAttack);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#include <stdio.h>
int main() {
  int n; cin >> n;
  int sum, m;
  vector<int>a(n);
  for(int i; i<n; i++){
    cin >> a[i];
    sum += a[i];
  }
  int p = 0;
  for(int i = 0; i<n; i++){
    cin >> a[i];
    p += a[i];
    m = min(m, abs(p-(sum-p)) );
  }
  cout << m << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=1000000007,MAX=200005,INF=1<<30;

ll cnt[20][20];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<ll> A;
    for(int i=0;i<N;i++){
        string S;cin>>S;
        int j=0;
        while(j<si(S)&&S[j]!='.') j++;
        if(j==si(S)){
            A.push_back(stoll(S)*1000000000);
        }else{
            ll X=0;
            for(int k=0;k<=j+9;k++){
                if(k<si(S)&&S[k]=='.') continue;
                X*=10;
                if(k<si(S)) X+=ll(S[k]-'0');
            }
            A.push_back(X);
        }
    }
    
    ll ans=0;
    
    for(ll x:A){
        int a=0,b=0;
        ll y=x;
        while(y%2==0){
            a++;
            y/=2;
        }
        while(y%5==0){
            b++;
            y/=5;
        }
        
        chmin(a,18);
        chmin(b,18);
        
        for(int i=0;i<=18;i++){
            for(int j=0;j<=18;j++){
                if(i+a>=18&&j+b>=18) ans+=cnt[i][j];
            }
        }
        cnt[a][b]++;
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 5328
a,b=map(int,input().split())
if a<0 and b<0:
    if (b-a)%2==0:
        print("Negative")
    else:
        print("Positive")
elif a<0 and b>0:
    print("Zero")
elif a>0:
    print("Positive")
else:
    print("Zero")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

long long gcd(long long a, long long b) {
  long long r = 1;
  while (r != 0) {
    r = a%b;
    a = b;
    b = r;
  }
  return a;
}

int comb(int n, int k) {
  vector<int> a(k);
  rep(i, k) {
    a.at(i) = n-i;
  }
  for(int i=2; i<=k; i++) {
    int tmp = i;
    rep(j, k) {
      int gc = gcd(a.at(j), tmp);
      tmp /= gc;
      a.at(j) /= gc;
    }
  }

  ll ans = 1;
  rep(i, k) {
    ans = ans * a.at(i);
    ans %= mod;
  }
  return ans;
}

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

  int n, m; cin >> n >> m;
  unordered_map<int, int> mp;
  for(int i=2; i*i<=m; i++) {
    while (m%i==0) {
      mp[i]++;
      m /= i;
    }
  }
  if (m != 1) {
    mp[m]++;
  }

  ll ans = 1;
  for(auto e: mp) {
    ans *= comb(n+e.second-1, e.second);
    ans %= mod;
  }
  cout << ans << endl;
}

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

static const int NIL = -1;

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

int n;
Node T[26];
int D[26], H[26];

void set_depth(int u, int d) {
    if (u == NIL)
        return;
    D[u] = d;
    set_depth(T[u].left, d + 1);
    set_depth(T[u].right, d + 1);
}

int set_height(int u) {
    int h1 = 0, h2 = 0;
    if (T[u].left != NIL)
        h1 = set_height(T[u].left) + 1;
    if (T[u].right != NIL)
        h2 = set_height(T[u].right) + 1;
    return H[u] = max(h1, h2);
}

int get_sibling(int u) {
    int p = T[u].parent;
    if (p == NIL) return NIL;
    if (T[p].left != u && T[p].left != NIL)
        return T[p].left;
    if (T[p].right != u && T[p].right != NIL)
        return T[p].right;
    return NIL;
}

void print_node(int u) {
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "sibling = " << get_sibling(u) << ", ";

    int degree = 0;
    if (T[u].left != NIL) degree++;
    if (T[u].right != NIL) degree++;
    cout << "degree = " << degree << ", ";

    cout << "depth = " << D[u] << ", ";
    cout << "height = " << H[u] << ", ";

    if (T[u].parent == NIL) cout << "root";
    else if (T[u].left == NIL && T[u].right == NIL) cout << "leaf";
    else cout << "internal node";
    cout << endl;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++)
        T[i].parent = T[i].left = T[i].right = NIL;

    for (int i = 0; i < n; i++) {
        int u, l, r;
        cin >> u >> l >> r;
        T[u].left = l;
        T[u].right = r;
        if (l != NIL) T[l].parent = u;
        if (r != NIL) T[r].parent = u;
    }

    int root;
    for (int i = 0; i < n; i++) {
        if (T[i].parent == NIL) root = i;
    }

    set_depth(root, 0);
    set_height(root);

    for (int i = 0; i < n; i++) {
        print_node(i);
    }
    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define int long long
using namespace std;
string h,q;
int n,x,ans=0,used[10],w,y;
void dfs(int d,string l){
  if(l==h)return;
  if(d==h.size()){
    int p,pp;
    stringstream ss(l);
    ss>>p;
    pp=min(abs(n-p),(int)pow(10,w)-abs(n-p));
    if(pp>ans){
      ans=pp;
      q=l;
    }
  }
  else{
    if(!d){
      used[y]=1;
      dfs(d+1,l+(char)(y+'0'));
    }
    else for(int i=0;i<=9;i++){
      if(!used[i]){
        used[i]=1;
        dfs(d+1,l+(char)(i+'0'));
        used[i]=0;
      }
    }
  }
}
main(){
  cin>>h;
  w=h.size();
  if(h[0]>='5')y=h[0]-5-'0';
  else y=h[0]-'0'+5;
  stringstream ss(h);
  ss>>n;
  dfs(0,"");
  cout<<q<<endl;
}

Measured memory_bytes: 3348
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;

#define M 1000010


int main(){
	IOS;
	tihs;

	ll n,k;
	cin>>n>>k;
	ll a[n+1];
	rep(i,1,n+1)cin>>a[i];
	bool vis[n+1]={0};
	ll j=0;
	vll v;
	rep(i,1,n+1){
		ll now=i; v.pb(now);
		vis[now]=1;
		while(1){
			now=a[now];
			if(vis[now]){
				j=now;break;
			}
			else v.pb(now),vis[now]=1;
		}
		break;
	}
	// teln(v,sz(v));tel(j);
	ll ans=-1,dif=0;
	rep(i,0,sz(v)){
		if(v[i]==j){
			dif=i;
			break;
		}
	}
	if(k<dif)cout<<v[k];
	else {
		k-=dif;
		ll rem=sz(v)-dif;
		k%=rem;
		cout<<v[dif+k];
	}
    // 1 2 3 4 5 6 

	return 0;
}

	

Measured memory_bytes: 7068
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

  int N; cin >> N;
  vec A(N); rep(i, N) cin >> A[i];

  int res = 0;
  while(1) {
    rep(i, N) {
      if(A[i]%2 != 0) {
        cout << res << endl;
        return 0;
      }
      A[i]/=2;
    }
    res++;
  }
  return 0;
}


Measured memory_bytes: 256
// Problem : E - Sum of gcd of Tuples (Hard)
// Contest : AtCoder - AtCoder Beginner Contest 162
// URL : https://atcoder.jp/contests/abc162/tasks/abc162_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define db long double
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define mi map<int,int>
#define ml map<ll,ll>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define MAX 4294967295
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define MAXN 15000005
#define inf 1e10
#define PI acos(-1.0)
#define int long long

int n,k;

int binpow(int x,int y){
    x %= mod;
    int res = 1;
    while(y){
        if(y&1) res = (res*x)%mod;
        x = (x*x)%mod;
        y /= 2;
    }
    return res;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    cin>>n>>k;
    vi ans(k+1);
    int res = 0;
    for(int i=k;i>=1;i--){
        ans[i] = binpow(k/i,n);
        for(int j=2*i;j<=k;j+=i) ans[i] = (ans[i]-ans[j]+mod)%mod;
        res = (res + (ans[i]*i)%mod)%mod;
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3972
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
map <int ,int>mapi;
map< int,int  > ::iterator it;
int a[1005][1005],b[1005];
int main(){
	int n,l,r,ans=0,i;
	cin>>n;
	rep(i,n){
		cin>>l>>r;
		ans+=(r-l+1);
	}
	cout<<ans<<endl;
}


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

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> l;
	vector<int> r;
	int temp;
	for (int i = 0; i < m; i++) {
		cin >> temp;
		l.push_back(temp);
		cin >> temp;
		r.push_back(temp);
	}
	int temp_l = l[0], temp_r = r[0];
	for (int i = 1; i < m; i++) {
		if (temp_l < l[i]) {
			temp_l = l[i];
		}
		if (temp_r > r[i]) {
			temp_r = r[i];
		}
	}

	int ans;

	if (temp_r <= n) {
		ans = temp_r - temp_l + 1;
	}
	else if (temp_l < n && n < temp_r) {
		ans = n - temp_l + 1;
	}
	else
	{
		ans = 0;
	}
	if (ans < 0) {
		ans = 0;
	}
	cout << ans;
	

	return 0;
}

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







int main(){
  


  int64_t n,m,x;
  cin>>n>>m>>x;

  
  vector<int64_t> cost(n+1);
  
  vector<vector<int64_t>> understand(n+1,vector<int64_t>(m+1));
  
  for (int64_t i=1;i<=n;i++){
    int64_t c;
    cin>>c;
    cost.at(i)=c;
    
    for (int64_t j=1;j<=m;j++){
      int64_t a;
      cin>>a;
      understand.at(i).at(j)=a;
    }
  }
  
  
  int64_t answer=-1;
  
  for (int64_t i=0;i<(1<<n);i++){
    
    bitset<12> s(i);
    

    
    int64_t totalcost=0;
    
    vector<int64_t> algo(m+1);
    algo.at(0)=x;
    
    for (int j=0;j<n;j++){
      
      if (s.test(j)){
        for (int64_t k=1;k<=m;k++){
          algo.at(k)+=understand.at(n-j).at(k);
        }
      }
    }
    

    
    
    int64_t flag=1;
    for (int64_t k=1;k<=m;k++){
      
      if (algo.at(k)<x){
      flag=0;
        break;
      }
    }
    

    
    if (flag==1){
      for (int64_t j=0;j<=n-1;j++){
        if (s.test(j)){
          totalcost+=cost.at(n-j);
        }
      }
    }
    
      

    
    if (totalcost!=0 ){
      
      if (answer==-1){
        answer=totalcost;
      }
      else {
      answer=min(answer,totalcost);
      }
    }
  
      
        
      
      
      

  }
  
    
    

  
  cout<<answer<<endl;
      

  
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  sort(A.rbegin(), A.rend());
  
  long long c = 0;
  for(int i = 1; i < N; i++){
    c += A[i / 2];
  }
  
  cout << c << endl;
  
  return 0;
}

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

#define MAXN 100010
#define ll long long
#define mod 1000000007

using namespace std;

int n, ans;

int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
	int n;
	cin >> n;
	cout << a[n - 1] << endl;
	
	return 0;
}

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

vector<string> v_input(int L) {
  vector<string> v(L);
  for (int i = 0; i < L; i++) {
    cin >> v.at(i);
  }
  return v;
}

int main() {
  int N, M;
  cin >> N;
  vector<string> S = v_input(N);
  cin >> M;
  vector<string> T = v_input(M);
  
  int Max = 0;
  for (int i = 0; i < N; i++) {
    int C = 0;
    for (int k = 0; k <= i; k++) {
      if (S.at(k) == S.at(i)) {
        C++;
      }
    }
    if (C > 1) {continue;}
    
    int count = 0;
    for (int j = 0; j < N; j++) {
      if (S.at(i) == S.at(j)) {
        count++;
      } 
    }
    
    for (int j = 0; j < M; j++) {
      if (S.at(i) == T.at(j)) {
        count--;
      } 
    }   
    Max = max(Max, count);
  }

  cout << Max << endl;
  
}


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

#define SYNC ios::sync_with_stdio(0);
#define F first
#define S second
#define endl '\n'


using namespace std;

using ll = long long int;
using ii = pair<int, int>;
using vii = vector<ii>;
using vi = vector<int>;
using graph = vector<vi>;
const int INF = 0x3f3f3f3f;
const int MAXN = 58;
const ll mod = 1000000007;

vi x;
int des[MAXN], n, a;
ll dp[58][5500];
int seen[58][5050];
int offset = 2500;
ll sol (int sum, int idx) {
    if (idx == n+1) return !sum;
    if (seen[idx][sum+offset]) return dp[idx][sum+offset];
    seen[idx][sum+offset] = 1;
    return dp[idx][sum+offset] = sol(sum+des[idx], idx+1) + sol(sum, idx+1);
    //cout << dp[idx][sum + offset] << endl;
}

int main() {
    SYNC
    cin >> n >> a;
    x.assign(n+1, 0);
    for (int i = 1; i <= n; ++i) {
        cin >> x[i];
    }
    for (int i = 1; i <= n; ++i) {
        des[i] = x[i] - a;
    }
    cout << sol(0, 1) - 1 << endl;

    return 0;
}

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

using ll = long long;

int main()
{
    ios::sync_with_stdio(false);

    int N; cin >> N;

    auto initial = vector<int>(N);
    for (auto& x : initial) cin >> x;

    auto delta = vector<int>(N-1);
    for (auto i = 0; i < N-1; i++)
        delta[i] = initial[i+1]-initial[i];

    int M; ll K; cin >> M >> K;

    auto pi = vector<int>(N-1);
    iota(begin(pi), end(pi), 0);

    for (auto i = 0; i < M; i++)
    {
        int a; cin >> a;
        a--;
        swap(pi[a], pi[a-1]);
    }

    auto piK = vector<int>(N-1);
    auto used = vector<bool>(N-1);
    for (auto i = 0; i < N-1; i++) if (!used[i])
    {
        auto cycle = vector<int>({i});
        for (auto j = pi[i]; j != i; j = pi[j])
        {
            cycle.push_back(j);
            used[j] = true;
        }

        for (auto j = 0; j < int(cycle.size()); j++)
            piK[cycle[j]] = cycle[(j + K) % cycle.size()];
    }

    auto x = ll(initial[0]);
    for (auto i = 0; i < N; i++)
    {
        cout << x << "\n";
        if (i != N-1) x += delta[piK[i]];
    }
}


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



int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	for(int i = 0; i < s.length(); i++){
		int now = (s[i] - 'A') + n;
		if(now > 25) {
			now = now - 25;
			cout << char('A' - 1 + now);
		}else{
			cout << char('A' + now);
		}
	}
	return 0;
}


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

using namespace std;

const int M = 1e5 + 10 ;
const int MOD = 1e9 + 7;
int n;
vector <int> adj[M] ;
int dp[M][2] ;

int solve(int p , int u , int c) {
    if(adj[u].size() == 1 && p != -1) return 1;
    int &ret = dp[u][c] ;
    if(ret != -1) return ret ;
    ret = 1 ;
    for(auto i : adj[u]) {
        if(i == p) continue;
        if(c == 1) ret = (1ll * ret * solve(u, i, 0)) % MOD ;
        else {
            int x = (solve(u, i, 0) + solve(u, i, 1)) % MOD ;
            ret = (1ll * ret * x) % MOD ;
        }
    }
    return ret ;
}

int main() {
    scanf ("%d", &n);
    for(int i = 0 ; i < n-1 ; ++i) {
        int u, v;
        scanf ("%d %d", &u, &v);
        --u, --v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    memset (dp, -1, sizeof dp);
    cout << (solve(-1, 0, 0) + solve(-1, 0, 1)) % MOD;
}


Measured memory_bytes: 14848
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,x=1,i;
	cin>>n;
	for(i=2;;i=i*2)
	{
		if(n!=1)
		{
		n=n/2;
		x=x+i;
		}
		else
		{
			break;
		}
	}	
	cout<<x<<endl;
}


Measured memory_bytes: 3624
# -*- coding: utf-8 -*-

"""
参考：https://kyopro-friends.hatenablog.com/entry/2019/01/12/231000
・メモ化再帰
・手番はメモしなくていい
・負け状態を押し付けられるかどうか
"""

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
aN = LIST()

# メモ[山の残数] = 今の手番がこの局面から勝てるか
memo = [None] * (K+1)

def dfs(k):
    # 既に見た局面ならメモの内容を返す
    if memo[k] != None:
        return memo[k]
    for i in range(N):
        # 山の残数より多くは取れない
        if k-aN[i] < 0:
            break
        # 1つでも負けを押し付ける手があれば勝てる
        if not dfs(k-aN[i]):
            memo[k] = True
            return True
    # 負けを押し付ける手がなかったので自分が負ける
    memo[k] = False
    return False

if dfs(K):
    print('First')
else:
    print('Second')


Measured memory_bytes: 96708
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(X: int, Y: int):
    n = (Y - 2*X) / 2
    if (int(n) == n) and (0<=n<=X):
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61708
#include <iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin>>a>>b>>c;
    if (a>b){
        swap (a,b);
    }
    if (b>c){
        swap (b,c);
    }
    if (a>b){
        swap (a,b);
    }
    cout<<a<<" "<<b<<" "<<c<<endl;
}



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

int n,ans=0;
int a[105];

double average=0.00;

int qz(double k)
{
	int ans_1=int(k),ans_2=int(k+1.00);
	if (k-ans_1<ans_2-k)  return ans_1;
	else return ans_2;
}

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=n;i++)  average=average*1.00+double(a[i]);
	average=(average*1.00)/(n*1.00);
	average=qz(average);
	
	for (int i=1;i<=n;i++)  ans+=(average-a[i])*(average-a[i]);
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(void){
    int n,i,flag,tmp,sum=0,a[100];
    double m;
    scanf("%d %lf\n",&n,&m);
    for(i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    do{ flag=0;
        for(i=0; i<n-1; i++){
            if(a[i]<a[i+1]){
                tmp=a[i];
                a[i]=a[i+1];
                a[i+1]=tmp;
                flag=1;
            }
        }
    }while(flag==1);
    flag=0;
    for(i=0; i<n; i++){
        sum+=a[i];
        }
    for(i=0; i<m; i++){
        if(a[i]<sum/(4*m))flag=1;
    }
    if(flag==1)printf("No");
    else printf("Yes");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] srgs) {
        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();

        System.out.println((a*b) + " " + (2*(a+b)));

        sc.close();
    }
}


Measured memory_bytes: 26136
# coding: utf-8
# Your code here!

num = int(input())
costs = sorted(list(map(int, input().split())), reverse = True)

total = 0
for i in range(1, num+1):
    total += (i + 1) * costs[i-1]
ans = (total * (4 ** (num - 1))) % (10 ** 9 + 7)
print(ans)

Measured memory_bytes: 26024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, n+1)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define whole(x) (x).begin(),(x).end()
#define rwhole(x) (x).rbegin(), (x).rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define P pair<int, int>
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};


int main(){
    int n;
    cin >> n;
    vector<int> t(n);
    vector<int> v(n);
    rep(i, n) cin >> t[i];
    rep(i, n) cin >> v[i];
    v.push_back(0);
    vector<int> st(n+1);
    rep(i, n) {
        st[i+1] = st[i] + t[i];
    }
    vector<int> speed(st.back()+1);
    rep(i, speed.size()) {
        if (i==0) continue;
        int res = speed[i-1] + 1;
        auto it = lower_bound(whole(st), i);
        it--;
        int num = it - st.begin();
        chmin(res, v[num]);
        for (int j=num+1; j<=n; j++) {
            int th = v[j] + (st[j]-i);
            chmin(res, th);
        }
        speed[i] = res;
        //cout << i << " " << res << endl;
    }
    double ans = 0.0;
    rep(i, speed.size()-1) {
        ans += 0.5 * (speed[i]+speed[i+1]);
        if (speed[i]==speed[i+1]) {
            auto it = upper_bound(whole(st), i);
            it--;
            int num = it - st.begin();
            if (speed[i]<v[num]) {
                ans += 0.25;
            }
        }
    }
    printf("%.10f\n", ans);
    return 0;
}


Measured memory_bytes: 3780
if __name__ == "__main__":
    while True:
        a,op,b = map(str,input().split())
        if op is "+":
            print("%d"%(int(a)+int(b)))
        elif op is "-":
            print("%d"%(int(a)-int(b)))
        elif op is "*":
            print("%d"%(int(a)*int(b)))
        elif op is "/":
            print("%d"%(int(a)/int(b)))
        else:
            break

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

bool has_black(string s) {
  for (char c: s) 
    if (c == '#') return true;
  
  return false; 
}

int main() {
  int h, w;
  cin >> h >> w;

  vector<bool> mh(h, false);
  vector<bool> mw(w, false);
  
  vector<string> g(h);
  for (int i = 0; i < h; i++) {
    cin >> g[i];

    if (has_black(g[i])) {
      mh[i] = true;
    }
  }

  for (int i = 0; i < w; i++) {
    string v = "";
    for (int j = 0; j < h; j++) {
      v += g[j][i];
    }

    if (has_black(v)) {
      mw[i] = true;
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) 
      if (mh[i] && mw[j]) cout << g[i][j];
    
    if (mh[i]) cout << endl;
  }
}


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cerr << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

V<int> construct(int a, int b, int mask, int N) {
	if (__builtin_popcount(mask) == 1) {
		return {a, b};
	}
	int p = -1;
	int ca, cb;

	rep(i, N) if ((mask >> i) & 1) {
		if (((a >> i) ^ (b >> i)) & 1) {
			ca = (a >> i) & 1;
			cb = (b >> i) & 1;
			p = i;
			break;
		}
	}
	int ch = -1;
	rep(i, N) if ((mask >> i) & 1) {
		if (i != p) {
			ch = i;
			break;
		}
	}

	int na = (ca ? (a ^ (1 << p)) : a);
	V<int> vl = construct(na, na ^ (1 << ch), mask ^ (1 << p), N);
	int nb = (cb ? (b ^ (1 << p)) : b);
	V<int> vr = construct(na ^ (1 << ch), nb, mask ^ (1 << p), N);

	V<int> vec;
	for (int x : vl) {
		int nx = x;
		if (ca) nx |= (1 << p);
		vec.pb(nx);
	}
	for (int x : vr) {
		int nx = x;
		if (cb) nx |= (1 << p);
		vec.pb(nx);
	}	
	return vec;
}

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	int ca = (__builtin_popcount(A)) & 1;
	int cb = (__builtin_popcount(B)) & 1;
	if (ca == cb) {
		puts("NO");
		return 0;
	}
	puts("YES");
	auto res = construct(A, B, (1 << N) - 1, N);
	rep(i, res.size()) cout << res[i] << (i+1==res.size()?'\n':' ');

	return 0;
}

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

int main(){
  int n,m;cin >> n >> m;
  char a[n+m][n+m],b[m][m];
  
  for(int i=0;i<n;++i){
    for(int j=0;j<n;++j){
      cin >> a[i][j];
    }
  }
  for(int i=0;i<m;++i){
    for(int j=0;j<m;++j){
      cin >> b[i][j];
    }
  }

  int z = 0;
  
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(a[i][j] == b[0][0]){
        for(int k=0;k<m;k++){
          for(int l=0;l<m;l++){
            if(a[i+k][j+l] != b[k][l])z += 1;
          }
        }
        if(z == 0){
          cout << "Yes" << endl;
          return 0;
        }
        z = 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
/*input
100000 6
1 2
2 3
3 1
4 5
5 6
6 7
5 5
1 2
2 3
3 1
5 4
5 1
6 5
1 2
2 3
3 4
4 5
5 6
*/
#include <bits/stdc++.h>
#define db(x) cout<<#x<<"="<<(x)<<" "
#define el cout<<endl
using namespace std;
const int MXN = 1e6 + 10;

int M, N; long long ans;
int fus[MXN], c[MXN], cl[MXN]; long long sz[MXN][4];
int GF(int x) {
    if (x == fus[x])
        return x;
    int r = GF(fus[x]);
    c[x] ^= c[fus[x]];
    return fus[x] = r;
}
int main() {
    cin >> N >> M; // n = N;
    iota(fus, fus + N + 1, 0);
    for (int t = 1; t <= M; ++t) {
        int x, y;
        cin >> x >> y;
        int rx = GF(x), ry = GF(y);
        if (rx == ry) {
            if (c[x] ^ c[y] ^ 1) {
                cl[rx] = 1;
            } else {
            }
        } else {
            fus[rx] = ry;
            cl[ry] |= cl[rx];
            c[rx] = c[x] ^ c[y] ^ 1;
        }
    }
    for (int i = 1; i <= N; ++i)
    {
        int r = GF(i);
        sz[r][c[i]]++;
    }
    for (int i = 1; i <= N; ++i)
    {
        int r = GF(i);
        if (i == r) {
            //db(cl[r]), db(r), db(sz[i][0]), db(sz[i][1]), el;
            if (!cl[r]) {
                ans += sz[i][0] * sz[i][1];
            }
            else {
                long long t = sz[i][0] + sz[i][1];
                ans += (t - 1) * t / 2;
            }
        }
    }
    cout  << ans - M << endl;
    return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

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

  vector<int> ret;
  while (n) {
    ret.push_back(n % k);
    n /= k;
  }
  cout << ret.size() << endl;

  return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int powmod(int a, int n, int mod) {
	if (n == 0) return 1;
	if (n % 2 == 0) return powmod((a * a) % mod, n / 2, mod);
	return (a * powmod(a, n - 1, mod)) % mod;
}

int p;
int a[2999];
int fact[2999];
int factInv[2999];

int comb(int n, int k) {
	if (k > n) return 0;
	return fact[n] * factInv[k] % p * factInv[n - k] % p;
}

int b[2999];

signed main() {
	int i, j;
	
	cin >> p;
	rep(i, p) cin >> a[i];
	
	fact[0] = 1;
	for (i = 1; i <= p; i++) fact[i] = (i * fact[i - 1]) % p;
	for (i = 0; i <= p; i++) factInv[i] = powmod(fact[i], p - 2, p);
	
	rep(i, p) {
		rep(j, p) {
			int res = a[i] * comb(p - 1, j) % p * powmod(i, p - 1 - j, p) % p;
			if ((p - j) % 2 == 0) { b[j] += res; b[j] %= p; }
			else b[j] = (b[j] - res + p) % p;
		}
	}
	rep(i, p) { b[0] += a[i]; b[0] %= p; }
	
	rep(i, p) {
		cout << b[i];
		if (i + 1 < p) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
#define el '\n'
typedef long long ll;
int N, R;
int main(){
	cin.tie(0);
	cin.sync_with_stdio(0);
	cin >> N >> R;
	if(N>=10){
		cout << R << el;
	}else{
		cout << R+(100*(10-N)) << el;
	}
}

Measured memory_bytes: 384
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M,X = map(int,input().split())
A = list(map(int,input().split()))

l,r = 0,0
for a in A:
    if a < X:
        l += 1
    else:
        r += 1

print(min(l,r))

Measured memory_bytes: 3060
#include<stdio.h>

int main() {
	int d[2], m[2], checker = 0;
	scanf("%d %d", &m[0], &d[0]);
	scanf("%d %d", &m[1], &d[1]);
	if (m[0]+1 == m[1]) {
		if (d[1] == 1) {
			checker = 1;
		}
	}
	else if (m[0] == 12) {
		if (d[0] == 31) {
			checker = 1;
		}
	}
	printf("%d", checker);
	return 0;
}

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

const int M=2005;
const int MO=1e9+7;
inline void addv(int &x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
}
inline int add(int x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
	return x;
}
inline void subv(int &x,int y)
{
	x-=y;
	if(x<0) x+=MO;
}
inline int sub(int x,int y)
{
	x-=y;
	if(x<0) x+=MO;
	return x;
}
inline int mul(int x,int y)
{
	return 1LL*x*y%MO;
}

int s[M],t[M];

int all[M][M]; 
int dp[M][M]; // select i,j 

int main()
{
	int n,m; scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%d",&s[i]);
	for(int i=1;i<=m;i++)
		scanf("%d",&t[i]);
	for(int i=0;i<=n;i++)
		all[i][0]=1;
	for(int i=0;i<=m;i++)
		all[0][i]=1;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(s[i]!=t[j]) dp[i][j]=0;
			else dp[i][j]=all[i-1][j-1];
			all[i][j]=add(all[i][j-1],all[i-1][j]);
			subv(all[i][j],all[i-1][j-1]);
			addv(all[i][j],dp[i][j]);
		}
	printf("%d\n",all[n][m]);
	return 0;
}

Measured memory_bytes: 31616
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define N 3030
const ll mod=998244353;
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int n,a[N],S;
ll dp[N],ans;
int main(){
	n=read(),S=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
	}
	for(int i=1;i<=n;++i){
		for(int j=S;j>a[i];--j){
			dp[j]=(dp[j]+dp[j-a[i]])%mod;
		}
		dp[a[i]]=(dp[a[i]]+i)%mod;
		ans=(ans+dp[S]*(n-i+1)%mod)%mod;
		dp[S]=0;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
from fractions import gcd
n, m = map(int, input().split())
a = [int(i) // 2 for i in input().split()]
x = 1
for i in range(n):
    x *= a[i] // gcd(x, a[i])
for i in a:
    if x // i % 2 == 0:
        print(0)
        exit()
print((m // x + 1) // 2)

Measured memory_bytes: 16320
package main

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

var scanner = bufio.NewScanner(os.Stdin)

type entry struct {
	id, score int
}

type lessFunc func(p1, p2 *entry) bool

type multiSorter struct {
	entries []entry
	less    []lessFunc
}

func (ms *multiSorter) sort(entries []entry) {
	ms.entries = entries
	sort.Sort(ms)
}

func OrderedBy(less ...lessFunc) *multiSorter {
	return &multiSorter{
		less: less,
	}
}

func (ms *multiSorter) Len() int {
	return len(ms.entries)
}

func (ms *multiSorter) Swap(i, j int) {
	ms.entries[i], ms.entries[j] = ms.entries[j], ms.entries[i]
}

func (ms *multiSorter) Less(i, j int) bool {
	p, q := &ms.entries[i], &ms.entries[j]
	var k int
	for k = 0; k < len(ms.less)-1; k++ {
		less := ms.less[k]
		switch {
		case less(p, q):
			return true
		case less(q, p):
			return false
		}
	}
	return ms.less[k](p, q)
}

func main() {
	for scanner.Scan() {
		m, _ := strconv.Atoi(scanner.Text())
		if m == 0 {
			break
		}
		results := make([]entry, 0)
		for i := 0; i < m; i++ {
			scanner.Scan()
			buf := strings.Split(scanner.Text(), " ")
			data := make([]int, len(buf))
			for i := range data {
				data[i], _ = strconv.Atoi(buf[i])
			}
			id, score := score(data)
			results = append(results, entry{id, score})
		}
		score_axis := func(e1, e2 *entry) bool {
			return e1.score > e2.score
		}
		id_axis := func(e1, e2 *entry) bool {
			return e1.id < e2.id
		}
		OrderedBy(score_axis, id_axis).sort(results)
		// log.Println(results)
		for _, e := range results {
			fmt.Printf("%d %d\n", e.id, e.score)
		}
	}
}

func score(input []int) (int, int) {
	id := input[0]
	data := input[1:]
	frame := 1
	scores := make([]int, 11)
	for frame <= 10 {
		if data[0] == 10 {
			scores[frame] = data[0] + data[1] + data[2]
			data = data[1:]
			frame += 1
		} else if data[0]+data[1] == 10 {
			scores[frame] = data[0] + data[1] + data[2]
			data = data[2:]
			frame += 1
		} else {
			scores[frame] = data[0] + data[1]
			data = data[2:]
			frame += 1
		}
	}
	sum := 0
	for i, v := range scores {
		if i != 0 {
			sum += v
		}
	}
	return id, sum
}



Measured memory_bytes: 1212