akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000001
using namespace std;
typedef long long ll;
string s;

int main(){
  std::cin >> s;
  ll res = 0;
  rep(i,0,(1<<s.size()-1)){
    ll tmp = s[0]-'0';
    rep(j,1,s.size()){
      if(i&(1<<(j-1))){
        res+=tmp;
        tmp=0;
      }
      tmp*=10;
      tmp+=s[j]-'0';
    }
    res+=tmp;
  }
  std::cout << res << '\n';
}

Measured memory_bytes: 256
class ABC135:
    def __init__(self):
        pass

    def solve(self, N):
        ans = 0
        A = list(map(int, input().split()))
        B = list(map(int, input().split()))
        for i in range(len(B)):
            diff = min(A[i], B[i]);
            A[i] -= diff
            B[i] -= diff
            ans += diff
            diff = min(A[i+1], B[i]);
            A[i+1] -= diff
            B[i] -= diff
            ans += diff
        print(ans)

if __name__ == '__main__':
    N = int(input())
    problem = ABC135()
    problem.solve(N)


Measured memory_bytes: 18624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
int a[200005];
ll sum[200005],_xor[200005],ans=0;
int main()
{
	cin>>n;
	ll b=0,c=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		b+=a[i];
		c^=a[i];
		sum[i]=b;
		_xor[i]=c;
	}
	int j=0;
	for(int i=0;i<n;i++)
	{
		while(j<n)
		{
			if((i==0)&&(sum[j]!=_xor[j]))
				break;
			if((i>0)&&((sum[j]-sum[i-1])!=(_xor[j]^_xor[i-1])))
				break;
			++j;
		}
		ans+=(ll)j-i;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, __VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 100010

int A, B;
string S;
int main()
{
    cin >> A >> B >> S;
    REP(i, S.length()) {
        if(i == A) {
            if(S[i] != '-') {
                printf("No\n");
                return 0;
            }
        } else {
            if(S[i] < '0' || S[i] > '9') {
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}


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

int dp[4][10000];
int main()
{
	int a, b; cin >> a >> b;
	dp[0][0] = 1;
	for (int c = 0; c < 3; c++) {
		for (int d = 0; d <= b; d++) {
			for (int e = 0;e<=a&&e<=d; e++) {
				dp[c + 1][d] += dp[c][d-e];
			}
		}
	}
	cout << dp[3][b] << endl;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    ll N,K; cin >> N >> K;
    vector<ll> h;
    rep(i, N) {
        int a; cin >> a;
        h.push_back(a);
    }
    sort(all(h));

    ll min = 1e9;
    ll tmp = 0;
    // h[i+K]-h[i+1]の最小値を選ぶ
    rep(i, N-K+1){
        tmp = h[i+K-1]-h[i];
        if(min > tmp) min = tmp;
    }
    cout << min << ln;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 2005, MAXM = 10005;
int visp[MAXN], deg[MAXN], uu[MAXN], vv[MAXN], vise[MAXM], arr[MAXN];
int par[MAXN], que[MAXN], fr[MAXM], to[MAXM], cnt[MAXN], n, m, tot;
int nxt[MAXM], dir[MAXM], dep[MAXM], dfn[MAXN], lg[MAXM];
vector<int> gra[MAXN], vec[MAXN];

int tmp[MAXN][MAXN];

void dfs1(int u, int fa) {
	par[u] = fa, dep[u] = dep[fa] + 1;
	for (int v : gra[u]) if (v != fa) dfs1(v, u);
}

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i < n; i++) {
		int u, v; scanf("%d%d", &u, &v);
		gra[u].push_back(v), gra[v].push_back(u);
		++deg[u], ++deg[v];
	}
	dfs1(1, 0);
	for (int i = 1; i <= m; i++) {
		int u, v; scanf("%d%d", &u, &v);
		uu[i] = fr[i] = u, vv[i] = to[i] = v;
		vec[u].push_back(i), vec[v].push_back(i);
		if (dep[u] > dep[v]) swap(u, v);
		while (dep[v] > dep[u]) ++cnt[v], v = par[v];
		while (v != u) ++cnt[v], ++cnt[u], v = par[v], u = par[u];
	}
	int ans = 0, all = m;
	for (int i = 1; i <= n; i++) ans += min(cnt[i], 2);
	int he = 1, ta = 0;
	for (int i = 1; i <= n; i++) if (deg[i] == 1) que[++ta] = i;
	
	while (he <= ta) {
		int u = que[he++];
		visp[u] = 1;
		for (int v : gra[u]) if (!visp[v]) {
			if (--deg[v] == 1) que[++ta] = v;
			int cnt = 0;
			for (int i : vec[u])
				if (!vise[i] && fr[i] != to[i]) arr[++cnt] = i;
			for (int i = 1; i < cnt; i += 2) {
				int a = arr[i], b = arr[i + 1];
				vise[a] = vise[b] = 1, ++all;
				int p = fr[a] == u ? to[a] : fr[a];
				int q = fr[b] == u ? to[b] : fr[b];
				fr[all] = p, to[all] = q;
				nxt[a] = nxt[b] = all;
				dir[a] = fr[a] == u, dir[b] = to[b] == u;
				vec[p].push_back(all);
				vec[q].push_back(all);
			}
			if(cnt & 1) {
				int p = arr[cnt];
				(fr[p] == u ? fr[p] : to[p]) = v;
				vec[v].push_back(p);
			}
		}
		vec[u].clear();
	}
	for (int i = all; i > 0; i--) {
		if (nxt[i]) dir[i] ^= dir[nxt[i]];
		if (i <= m && dir[i]) swap(uu[i], vv[i]);
	}
	printf("%d\n", ans);
	for (int i = 1; i <= m; i++) printf("%d %d\n", uu[i], vv[i]);
	return 0;
}

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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vd=vector<double>;
using vvd=vector<vd>;
using vs=vector<string>;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}

template<typename Tuple>
void print_tuple(ostream&,const Tuple&){}
template<typename Car,typename... Cdr,typename Tuple>
void print_tuple(ostream& os,const Tuple& t){
	print_tuple<Cdr...>(os,t);
	os<<(sizeof...(Cdr)?",":"")<<get<sizeof...(Cdr)>(t);
}
template<typename... Args>
ostream& operator<<(ostream& os,const tuple<Args...>& t){
	print_tuple<Args...>(os<<'(',t);
	return os<<')';
}

template<typename Ch,typename Tr,typename C>
basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>& os,const C& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-9;

tuple<int,int> solve(string s)
{
	tuple<int,int> res(-1,-1);
	rep(i,s.size()-1)
		if(set<char>(begin(s)+i,begin(s)+i+2).size()==1)
			return mt(i+1,i+2);
	rep(i,s.size()-2)
		if(set<char>(begin(s)+i,begin(s)+i+3).size()<=2)
			return mt(i+1,i+3);
	return mt(-1,-1);
}

int main()
{
	for(string s;cin>>s;){
		auto res=solve(s);
		cout<<get<0>(res)<<' '<<get<1>(res)<<endl;
	}
}


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

const int maxn = 305;
char grid[maxn][maxn];
int h, w, K;
int ans[maxn][maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> h >> w >> K;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> grid[i][j];
        }
    }
    int cur = 1;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (grid[i][j] == '#') {
                if (j > 0 && ans[i][j-1] == 0) {
                    for (int k = 0; k < j; k++) {
                        ans[i][k] = cur;
                    }
                }
                ans[i][j] = cur;
                for (int k = j+1; k < w && grid[i][k] == '.'; k++) {
                    ans[i][k] = cur;
                }
                cur++;
            }
        }
    }
    assert(cur == (K+1));

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (ans[i][j] == 0) {
                if (i > 0) {
                    ans[i][j] = ans[i-1][j];
                }
                else {
                    for (int k = i+1; k < h; k++) {
                        if (ans[k][j] != 0) {
                            ans[i][j] = ans[k][j];
                            break;
                        }
                    }
                }
            }
        }
    }
    //output
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << ans[i][j] << ' ';
        }
        cout << '\n';
    }
}



Measured memory_bytes: 1280
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const int MX = 100 * 1000 + 7;

vector<int> g[MX];
bool was[MX];
int f[MX];

int dfs(int v) {
    if (was[v]) {
        return f[v];
    }
    was[v] = true;
    for (int to : g[v]) {
        f[v] = max(f[v], dfs(to) + 1);
    }
    return f[v];
}
int main() {
#ifdef FASTIO
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
    }

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, dfs(i));
    }

    cout << ans << "\n";
    return 0;
}



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

int main(){
    string word, frequent = "", longest = "";
    map<string, int> mp;
    while(cin >> word){
        mp[word]++;
        if(mp[frequent] < mp[word]){
            frequent = word;
        }
        if(longest.size() < word.size()){
            longest = word;
        }
    }
    cout << frequent << " " << longest << endl;
}

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

#define all(x) x.begin(),x.end()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)

using namespace std;
using ll=long long int;
using ld=long double;

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

ll N,D,ans=0;
cin>>N>>D;
forn(i,N) {
  ll x,y;
  cin>>x>>y;
  if(x*x+y*y<=D*D) ans++;
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3616
n,m=map(int,input().split())
s=[]
c=[]
k=[-1]*(n+1)
for _ in range(m):
    s_,c_=map(int,input().split())
    s.append(s_)
    c.append(c_)
for i in range(m):
    if k[s[i]]==-1:
        k[s[i]]=c[i]
    elif k[s[i]]==c[i]:
        pass
    else:
        print(-1)
        exit()
if n==1:
    ans=str(max(0,k[1]))
else:
    if k[1]==0:
        print(-1)
        exit()
    ans=str(max(1,k[1]))
for i in range(2,n+1):
    ans+=str(max(0,k[i]))
print(ans)


Measured memory_bytes: 3064
n = int(input())
arr = list(map(int, input().split()))
arr.sort()
if arr[0] == 0:
    print(0)
else:
    ans = 1
    for i in arr:
        ans = ans * i
        if ans > 1000000000000000000:
            ans = -1
            break
    print(ans)

Measured memory_bytes: 21648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
/******************************************
* AUTHOR : PANDRAVISAM SHIVA SANTHOSH *
* Handle : santhosh_80 *
* INSTITUTION : IIT Palakkad *
******************************************/
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
#define ll long long int 
#define mod 1000000007
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define S(x) scanf("%d",&(x))
#define P(x) printf("%d\n",(x))
#define Sl(x) scanf("%lld",&(x))
#define Pl(x) printf("%lld\n",(x))
#define pb push_back
#define f first
#define s second

const int N = 1e5 +1;

int dp[N] ;
vector<int> vi[N] ;
int vist[N] ;

void dfs(int i) {
	vist[i] = 1 ;
	for(auto x : vi[i]){
		if(!vist[x])dfs(x) ;
		dp[i] = max(dp[i],dp[x]+1);
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m ; cin >> n >> m ;
	for(int i = 0; i < m ; i++){
		int x,y;cin >> x >> y ;
		vi[x].pb(y) ;
	}
	for(int i = 1 ; i <= n ; i++){
		if(!vist[i])dfs(i) ;
	}
	int max1 = -1;
	for(int i = 1; i <= n ; i++){
		//cout << dp[i] << " " ;
		max1 = max(dp[i],max1) ;
	}
	cout << max1 ;
 	return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <queue>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)

int n, k, ans, asc, p[200020], q[200020], r[200020], s[200020];
deque<int> dq;

int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  cin >> n >> k;
  REP(i,n) cin >> p[i];
  for(int i = n; i > 0; --i) if(p[i-1] < p[i]) q[i-1] = q[i] + 1;

  REP(i,n) {
    while(dq.size() && p[i] < p[dq.back()]) dq.pop_back();
    dq.push_back(i);
    if(i - k + 1 >= 0) {
      r[i - k + 1] = p[dq.front()];
      if(dq.front() == i - k + 1) dq.pop_front();
    }
  }
  dq.clear();
  REP(i,n) {
    while(dq.size() && -p[i] < -p[dq.back()]) dq.pop_back();
    dq.push_back(i);
    if(i - k + 1 >= 0) {
      s[i - k + 1] = p[dq.front()];
      if(dq.front() == i - k + 1) dq.pop_front();
    }
  }

  REP(i,n-k+1) {
    if(q[i] >= k-1) { asc = 1; continue; }
    if(i > 0 && r[i-1] == p[i-1] && s[i] == p[i+k-1]) continue;
    ++ans;
  }
  cout << ans + asc << endl;
  return 0;
}

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

using namespace std;

const int N = 100010;

vector <int> g[N];
vector <int> pref[N];
vector <int> suff[N];
int n, m, down[N], up[N];

void fix (int u = 1) {
  for (int v : g[u]) {
    g[v].erase(find(g[v].begin(), g[v].end(), u));
    fix(v);
  }
}

void go (int u = 1) {
  down[u] = 1;
  for (int v : g[u]) {
    go(v);
    down[u] = down[u] * 1LL * (1 + down[v]) % m;
  }
  int sz = g[u].size();
  pref[u].resize(sz + 1);
  suff[u].resize(sz + 1);
  pref[u][0] = suff[u][sz] = 1;
  for (int i = 0; i < sz; ++i) {
    pref[u][i + 1] = pref[u][i] * 1LL * (1 + down[g[u][i]]) % m;
  }
  for (int i = sz - 1; i >= 0; --i) {
    suff[u][i] = suff[u][i + 1] * 1LL * (1 + down[g[u][i]]) % m;
  }
}

void dfs (int u = 1) {
  for (int i = 0; i < g[u].size(); ++i) {
    int v = g[u][i];
    up[v] = pref[u][i] * 1LL * suff[u][i + 1] % m;
    up[v] = up[v] * 1LL * up[u] % m;
    ++up[v]; if (up[v] >= m) up[v] -= m;
    dfs(v);
  }
}

int main() {
  cin >> n >> m;
  for (int i = 1; i < n; ++i) {
    int u, v;
    scanf("%d %d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  fix(); go(); up[1] = 1; dfs();
  for (int i = 1; i <= n; ++i) {
    int ans = up[i] * 1LL * down[i] % m;
    printf("%d\n", ans);
  }
  return 0;
}



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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string ws[] = {"Sunny", "Cloudy", "Rainy"};
    string s;
    cin >> s;
    int t;
    rep(i, 3) {
        if (s == ws[i]) t = (i+1)%3;
    }
    cout << ws[t] << endl;
    return 0;
}



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

using lint = long long;

int main(){
    int n, k;
    while(cin >> n >> k, n){
        vector<lint> sum(n + 1);
        for(int i = 1 ; i <= n ; ++i){
            cin >> sum[i];
            sum[i] += sum[i - 1];
        }

        lint ans = -(1LL << 62);
        for(int i = k ; i <= n ; ++i){
            ans = max(ans, sum[i] - sum[i - k]);
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;
int main(){
  int n;cin>>n;
  vector<int> a(n);
  for(int i = 0; n > i; i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
  double nw = (double)(a[0]+a[1])/2;
  for(int i = 2; n > i; i++){
    nw = (double)(nw+a[i])/2;
  }
  cout << fixed << setprecision(10) << nw << endl;
}

Measured memory_bytes: 384
import string
from collections import Counter
n = int(input())
S = [input() for _ in range(n)]
S_set = [set(list(l)) for l in S]
char_set = set(list(string.ascii_lowercase))
for sub in S_set:
    char_set = char_set & sub
if char_set == set([]):
    print('')
else:
    enable_charset = {c: 99 for c in char_set}
    for sent in S:
        counter = Counter(sent)
        for c in enable_charset.keys():
            enable_charset[c] = min(enable_charset[c], counter[c])
    res = ''
    for k, v in enable_charset.items():
        res += k * v
    print(''.join(sorted(res)))

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#include <tuple>
#include <iterator>
using namespace std;
using ll = long long;

int main()
{
  int a, b;
  cin >> a >> b;
  int sum = 0;
  for (int i = 1; i <= b - a; ++i)
    sum += i;
  cout << sum - b << endl;
  return 0;
}

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

int main() {
  long long n,sum=0, mod=2019;
  cin>>n;
  vector<bool> vec(n+1,0);
  vector<int> ans;
  int a[n+1];
  for(int i=1; i<=n; i++){
    cin>>a[i];
  }
  for(int i=n; i>=1; i--){
    int j=i;
    sum=0;
    while(j+i<=n){
      j+=i;
      sum+=vec[j];
    }
    if(sum%2!=a[i]){
      vec[i]=1;
      ans.push_back(i);
    }
  }
  
  cout<<ans.size()<<endl;
  
  for(int i=0 ;i<ans.size(); i++)
    cout<<ans[i]<<endl;
  
  
}

Measured memory_bytes: 2428
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

int s[200009][29];

int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  rep(i,n)cin>>a[i];

  rep(i,n){
    rep(j,20){
      s[i+1][j]=s[i][j];
      if(a[i]>>j&1){
        s[i+1][j]++;
      }
    }
  }

  auto is=[&](int mid,int t){
    bool ok=true;
    rep(i,20){
      if(s[mid][i]-s[t][i]>1){
        ok=false;
      }
    }
    return ok;
  };
  auto bs=[&](int t){
    int l=-1,r=n+1;
    while(r-l>1){
      int mid=(l+r)/2;
      if(is(mid,t)){
        l=mid;
      }
      else{
        r=mid;
      }
    }
    return l;
  };

  ll ans=0;
  rep(i,n){
    int x=bs(i);
    ans+=x-i;
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 23680
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int w, d;
        cin >> w >> d;
        if(w == 0)
            return 0;

        vector<int> h1(w), h2(d);
        for(int i=0; i<w; ++i)
            cin >> h1[i];
        for(int i=0; i<d; ++i)
            cin >> h2[i];
        sort(h1.rbegin(), h1.rend());
        sort(h2.rbegin(), h2.rend());

        int i = 0;
        int j = 0;
        int ret = 0;
        while(i < w || j < d){
            if(i < w && j < d && h1[i] == h2[j]){
                ret += h1[i];
                ++ i;
                ++ j;
            }else if(i < w && (j == d || h1[i] > h2[j])){
                ret += h1[i];
                ++ i;
            }else{
                ret += h2[j];
                ++ j;
            }
        }

        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
 
int main(){
int m,n;
int a[1000][1000];
int b[1000];
cin>>m>>n;
 
for(int i=1;i<=m;i++){
for(int g=1;g<=n;g++){
cin>>a[i][g];
}}
for(int g=1;g<=n;g++){
cin>>b[g];
}
 
int c[1000]={};
for(int i=1;i<=m;i++){
for(int g=1;g<=n;g++){
c[i]+=a[i][g]*b[g];
}}
 
for(int i=1;i<=m;i++){
cout<<c[i]<<endl;
}
 
return 0;
}//1_6_D


Measured memory_bytes: 3504
// Last Change: 06/27/2019 20:31:15.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

namespace NS {
void LoopUntilZeroInpput() {
  int hogegegege = 0;
  while (cin >> hogegegege && hogegegege != 0) {
  }
}
} // namespace NS

int main() {
  ll N, K;
  cin >> N >> K;

  ll maxVal = (N - 2) * (N - 1) / 2;

  if (maxVal < K) {
    cout << -1 << endl;
    return 0;
  }

  cout << N - 1 + maxVal - K << endl;
  for (ll i = 1; i < N; ++i) {
    cout << 1 << ' ' << i + 1 << endl;
  }
  ll j = 2, k = 3;
  for (ll i = 0; i < maxVal - K; ++i) {
    cout << j << ' ' << k << endl;

    ++k;
    if (k > N) {
      ++j;
      k = j + 1;
    }
  }

  //NS::LoopUntilZeroInpput();
}


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

using namespace std;

const int maxn=100005;

int n;
int p[maxn];
int x[maxn];
int c[maxn];
set<int> s;
 
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>x[i];
	for(int i=1;i<=n;i++){
		p[x[i]]=i;
	}		
	long long ans=0;
	s.insert(0);s.insert(n+1);
	for(int i=n;i>=1;i--){
		set<int>::iterator it2=s.lower_bound(p[i]),it1=it2;
		it1--;
		long long q1=0;
		if(it1!=s.begin()){
			set<int>::iterator it3=it1;
			it3--;
			long long hl=(*it1)-(*it3);
			hl*=(*it2)-p[i];
			q1+=hl;
		} 
		set<int>::iterator it4=it2;
		it4++;
		if(it4!=s.end()){
			long long hl=(*it4)-(*it2);
			hl*=p[i]-(*it1);
			q1+=hl;
		}
		ans+=q1*i;
		s.insert(p[i]); 
	}
	cout<<ans;
	return 0;
} 

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

const int r = 1e9;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k, s;
  cin >> n >> k >> s;
  for(int i = 0; i < n; ++i){
	if (i < k){
		cout << s << " ";
	}else{
		(s == r) ? cout << r-1 << " ": cout << r << "\n";
	}
  }
  cout << "\n";
return 0;
}

Measured memory_bytes: 1408
import sys
from collections import defaultdict
from itertools import combinations

input = sys.stdin.readline


def main():
    N = int(input())
    x = [0] * N
    y = [0] * N
    for i in range(N):
        x[i], y[i] = map(int, input().split())

    if N == 1:
        print(1)
        sys.exit()

    vector = defaultdict(int)
    for a, b in combinations(range(N), 2):
        dx = x[a] - x[b]
        dy = y[a] - y[b]
        if dx == 0:
            vector[(0, abs(dy))] += 1
        elif dx > 0:
            vector[(dx, dy)] += 1
        else:
            vector[(-dx, -dy)] += 1

    ans = N - max(vector.values())
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9548
N = int(input())
A = [int(a) for a in input().split()]
B = [abs(a) for a in A]

for i in range(N):
    if A[i] > 0:
        po = i
        break
else:
    po = -1
for i in range(N):
    if A[i] < 0:
        ne = i
        break
else:
    ne = -1
mi = min(B)
for i in range(N):
    if B[i] == mi:
        mii = i
        break
else:
    mii = -1

if po >= 0 and ne >= 0:
    print(sum(B))
    t1, t2 = A[po], A[ne]
    if po > ne:
        po, ne = ne, po
    # print("pone =", po, ne)
    if po == ne:
        del A[ne]
        A = [0] + A
    else:
        del A[ne]
        del A[po]
        A = [t1, t2] + A
else:
    print(sum(B) - 2 * mi)
    t = A[mii]
    del A[mii]
    A = [t] + A
# print(A)
prev = A[0]
for i in range(1, N):
    a, b = max(prev, A[i]), min(prev, A[i])
    if i == N-1 or A[i+1] < 0:
        print(a, b)
        prev = a - b
    else:
        print(b, a)
        prev = b - a


Measured memory_bytes: 65108
n,d = map(int,input().split())
import numpy as np
xlist = [list(map(int,input().split())) for i in range(n)]
xarray = np.array(xlist)
ans = 0
for i in range(n):
  for j in range(i+1,n):
    if np.linalg.norm(xarray[i]-xarray[j])==int(np.linalg.norm(xarray[i]-xarray[j])):
      ans+=1
print(ans)

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

int main(){
    ll n,ans=0;
    cin>>n;
    vector<ll> a(n+1);
    for(ll i=0;i<=n;i++)cin>>a[i];
    for(ll i=0;i<n;i++){
        ll b;cin>>b;
        ans+=min(b,a[i]);
        b=max(b-a[i],(ll)0);
        if(b>0){
            ans+=min(a[i+1],b);
            a[i+1]=max(a[i+1]-b,(ll)0);
        }
    }
    cout<<ans<<endl;
}

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

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

using namespace std;

template <typename T> T &chmin(T &a, const T &b) {return a = min(a, b);}
template <typename T> T &chmax(T &a, const T &b) {return a = max(a, b);}

using ll = long long;
using ld = long double;

const int INF = 1e9;
const ld eps = 1e-9, pi = acos(-1.0);
int n;


int main(){
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  int xmax=x;
  int ymin=y;
  int tmp;
  REP(i, n){ cin >> tmp; chmax(xmax, tmp); }
  REP(i, m){ cin >> tmp; chmin(ymin, tmp); }
  cout << ((xmax < ymin) ? "No War" : "War") << endl;
}

Measured memory_bytes: 256
N = int(input())
S = list(input())
West = [0]*(N+1)
East = [0]*(N+1)
for i in range(N):
    if S[i]=="W":
        West[i+1]=West[i]+1
    else:
        West[i+1]=West[i]
for i in range(N):
    if S[i]=="E":
        East[i+1]=East[i]+1
    else:
        East[i+1]=East[i]
ans = float("inf")
for i in range(N+1):
    tmp = West[i]+(East[N]-East[i])
    if tmp<ans: ans = tmp
print(ans)

Measured memory_bytes: 25508
W,a,b=list(map(int,input().split()))
if a<=b:
    d=b-(a+W)
    if d<=0:
        print(0)
        exit()
    print(d)
else:
    d=a-(b+W)
    if d<=0:
        print(0)
        exit()
    print(d)


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

ll gcd(ll a, ll b) {
    if (a == 0) {
        return b;
    }
    if (b == 0) {
        return a;
    }
    if (a < b) gcd(b, a);
    ll r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}


int main() {

    ll A, B;
    cin >> A >> B;

    cout << A * B / gcd(A, B) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int n; scanf("%d", &n);
	n %= 10;
	if(n == 0 || n == 1 || n == 6 || n == 8) printf("pon\n");
	else if(n == 3) printf("bon\n");
	else printf("hon\n");

	return 0;
}

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

using namespace std;

int main(){
	vector<int> S, T;
	int i, n, q, sin, tin;
	int left, mid ,right, key, cnt = 0;
	
	cin >> n;
	for(i=0;i<n;++i){
		cin >> sin;
		S.emplace_back(sin);
	}
	cin >> q;
	for(i=0;i<q;++i){
		cin >> tin;
		T.emplace_back(tin);
	}
	
	for(i=0;i<q;++i){
		key = T[i];
		left = 0, right = n;
		while(left < right){
			mid = (left + right)/2;
			if(S[mid] == key){
				cnt++;
				break;
			}
			else if(key < S[mid])right = mid;
			else left = mid + 1;
		}
	}
	cout << cnt << endl;
	
	return 0;
}


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

using namespace std;

int decide(vector<int> &ans, int a, int num) {
    int retval = 0;
    for(int i = num; i < ans.size(); i += num + 1) {
        retval += ans[i];
    }
    return (retval % 2) == a ? 0 : 1;
}

int main() {
    int n;
    cin >> n;
    
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    
    vector<int> ans(n, 0);
    int m = 0;
    for(int i = n - 1; i >= 0; i--) {
        ans[i] = decide(ans, a[i], i);
        m += ans[i];
    }
    
    cout << m << endl;
    if(m > 0) {
        for(int i = 0; i < n; i++) {
            if(ans[i] == 1) {
                cout << i + 1;
                if(i < n - 1) {
                    cout << " ";
                }
            }
            if(i == n - 1) {
                cout << endl;
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 2432
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

using namespace std;
typedef long long ll;
const ll INF = 1000000000000000000;
const ll MAX_A = 100000 + 2;
const ll MAX_B = 100000 + 2;
const ll MAX_Q = 100000 + 2;
ll s[MAX_A];
ll t[MAX_B];
ll x[MAX_Q];

int main() {

  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  ll A, B, Q;
  cin >> A >> B >> Q;

  for(ll i = 0; i < A; i++) cin >> s[i];
  for(ll i = 0; i < B; i++) cin >> t[i];
  for(ll i = 0; i < Q; i++) cin >> x[i];
  
  sort(s, s + A);
  sort(t, t + B);

  for(ll i = 0; i < Q; i++) {

    ll lba = -1;
    ll uba = A;
    while (lba + 1 < uba) {
      ll mid = (lba + uba) / 2;
      if(s[mid] > x[i]) uba = mid;
      else lba = mid;
    }

    ll lbb = -1;
    ll ubb = B;
    while (lbb + 1 < ubb) {
      ll mid = (lbb + ubb) / 2;
      if(t[mid] > x[i]) ubb = mid;
      else lbb = mid;
    }

    ll ans = INF;
    ll w1, w2;
    
    if(lba != -1 && lbb != -1) {
      w1 = max(abs(s[lba] - x[i]), abs(t[lbb] - x[i]));
      ans = min(ans, w1);
    }

    if(lba != -1 && ubb != B){
      w1 = abs(s[lba] - x[i]) * 2 + abs(t[ubb] - x[i]);
      w2 = abs(s[lba] - x[i]) + abs(t[ubb] - x[i]) * 2;
      ans = min(ans, min(w1, w2));
    }

    if(uba != A && lbb != -1) {
      w1 = abs(s[uba] - x[i]) * 2 + abs(t[lbb] - x[i]);
      w2 = abs(s[uba] - x[i]) + abs(t[lbb] - x[i]) * 2;
      ans = min(ans, min(w1, w2));
    }

    if(uba != A && ubb != B) {
      w1 = max(abs(s[uba] - x[i]), abs(t[ubb] - x[i]));
      ans = min(ans, w1);
    }
    
    cout << ans << endl;
  }
  
  return 0;
}



Measured memory_bytes: 5456
#include <iostream>
#include <utility>
#include <stdint.h>
#include <set>
#include <map>

using namespace std;

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

  map<unsigned, multiset<unsigned, greater<unsigned>>> jobs;
  multiset<unsigned, greater<unsigned>> available_jobs;

  for (int n=0; n<N; ++n) {
    unsigned a, b;
    cin >> a >> b;
    if (jobs.count(a)==0)
      jobs[a] = multiset<unsigned, greater<unsigned>>();
    jobs[a].emplace(b);
  }

  uint64_t sum = 0;
  for (int m=1; m<=M; ++m) {
    if (jobs.count(m) > 0)
      available_jobs.insert(jobs[m].begin(), jobs[m].end());
    if (available_jobs.size()==0)
      continue;
    sum += *available_jobs.begin();
    available_jobs.erase(available_jobs.begin());
  }
  
  cout << sum << endl;

  return 0;
}


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

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

    int n;
    cin >> n;

    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> que;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        que.push(make_pair(b, a));
    }

    int now = 0;
    bool f = true;
    while(!que.empty()){
        pair<int, int> tp = que.top();
        que.pop();

        now += tp.second;
        if(tp.first >= now) continue;
        f = false;
        break;
    }

    cout << (f ? "Yes" : "No") << endl;


    return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int t,n,l[MAXN],r[MAXN],k[MAXN];
vector<pair<int,int> > v1,v2;
int main()
{
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        v1.clear(); v2.clear();
        ll ans=0;
        for(int i=1;i<=n;i++) 
        {
            scanf("%d%d%d",&k[i],&l[i],&r[i]);
            if(l[i]>=r[i])
            {
                ans+=r[i];
                v1.push_back(P(k[i],l[i]-r[i]));
            }
            else
            {
                ans+=l[i];
                v2.push_back(P(n-k[i],r[i]-l[i]));
            }
        }
        sort(v1.begin(),v1.end()); sort(v2.begin(),v2.end());
        priority_queue<int,vector<int>,greater<int> > pque;
        for(auto p:v1)
        {
            pque.push(p.S);
            while(pque.size()>p.F)
                pque.pop();
        }
        while(pque.size()) {ans+=pque.top(); pque.pop();}
        for(auto p:v2)
        {
            pque.push(p.S);
            while(pque.size()>p.F)
                pque.pop();
        }
        while(pque.size()) {ans+=pque.top(); pque.pop();}
        printf("%lld\n",ans);
    }
    return 0;
}

Measured memory_bytes: 8028
#include <iostream>
#include <vector>
using namespace std;
#define endl '\n'

using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x;
    cin >> x;
    cout << (x / 500) * 1000 + ((x%500)/5)*5;
    return 0;
}

Measured memory_bytes: 256
import sys


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


def main():
    S = input()
    ans = "Yes"
    for i in range(len(S)):
        if (i+1) % 2 == 1:
            if S[i] == "L":
                ans = "No"
        else:
            if S[i] == "R":
                ans = "No"
        if ans == "No":
            print(ans)
            exit()
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        n: usize,
        a: [usize; n],
    );

    let mut ans = Vec::new();
    ans.resize(n, 0);

    let mut b = Vec::new();

    for i in (0..n).rev() {
        let mut tmp = 0;
        let mut j = i + 1;
        while j <= n {
            tmp += ans[j-1];
            j += i + 1;
        }
//        println!("{}, {}", i, tmp);
        if tmp % 2 != a[i] {
            ans[i] = 1;
        }
        else {
            ans[i] = 0;
        }
        if ans[i] == 1 {
            b.push(i);
        }
    }

//    println!("{:?}", a);
//    println!("{:?}", ans);
    println!("{}", b.len());
    b.sort();
    for i in 0..b.len() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", b[i] + 1);
    }
    println!();

//    let mut c = Vec::new();
//    c.resize(n, 0);
//    for i in 0..n {
//        let mut t = i + 1;
//        let mut tt = 0;
//        while t <= n {
//            tt += ans[t-1];
//            t += i + 1;
//        }
//        c[i] = tt % 2;
//    }

//    assert_eq!(a, c);
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 13436
N, Q = STDIN.gets.chomp.split(' ').map(&:to_i)
S = STDIN.gets.chomp

ruiseki = Array.new(0)
ruiseki.push(0) # 累積和の一つ目は0
ruiseki.push(0) # 一文字目の分をpush

for i in 1..N do
  if S[i - 1, 2] == "AC" then
    ruiseki.push(ruiseki[i] + 1)
  else
    ruiseki.push(ruiseki[i])
  end
end

for q in 1..Q do
  l, r = STDIN.gets.chomp.split(' ').map(&:to_i)
  puts ruiseki[r] - ruiseki[l]
end

Measured memory_bytes: 3452
n, t = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

max = [0]

for a in A[::-1][:-1]:
  if a > max[-1]:
    max.append(a)
  else:
    max.append(max[-1])

max.reverse()
  
ans = 0
maxp = 0

for i in range(n):
  p = max[i] - A[i]
  if p > maxp:
    ans = 1
    maxp = p
  elif p == maxp:
    ans += 1

print(ans)

Measured memory_bytes: 14252
N = int(input())
ans = 0

for i in range(N+1):
    if(i % 15 == 0):
        #FizzBuzz
        pass
    elif(i % 3 == 0):
        #Fizz
        pass
    elif(i % 5 == 0):
        #Buzz
        pass
    else:
        ans += i
print(ans)

Measured memory_bytes: 9140
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef
tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long long ll;
typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("amusing.in", "r", stdin);
    //freopen("amusing.out", "w", stdout);
}

void solve() {
    int n;
    cin >> n;
    vi a(n);
    int xr = 0;
    forn(i, n){
        cin >> a[i];
        xr ^= a[i];
    }
    forn(i, n) cout << (a[i] ^ xr) << ' ';
    cout << '\n';
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

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

N = int(input())

A = []
data = []
for i in range(N):
    a = int(input())
    A.append(a)
    x = [list(map(int, input().split())) for _ in range(a)]
    data.append(x)

ans = 0
for i in range(1<<N):
    bit = [0] * N
    cnt = 0
    for j in range(N):
        div = 1 << j
        bit[j] = (i // div) % 2
        if bit[j] == 1:
            cnt += 1

    flag = True
    for j in range(N):
        if bit[j] == 0:
            continue
        for a in range(A[j]):
            x = data[j][a]
            if bit[x[0]-1] != x[1]:
                flag = False
                break
        if not flag:
            break
    
    if flag:
        ans = max(ans, cnt)

print(ans)



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

int main(){
	int a,b;
	cin >> a >> b;
	if(b&1) cout << "No\n";
	else{
		b /= 2;
		int ca = b-a;
		int cb = b-(2*ca);
		if(ca < 0 || cb < 0) cout << "No\n";
		else cout << "Yes\n";
	}
}

Measured memory_bytes: 3632
from collections import defaultdict
def main():
    n, k, q = map(int, raw_input().split())
    a = map(int, raw_input().split())
    d = defaultdict(list)
    for i, x in enumerate(a):
        d[x].append(i)
    a.append(-1)
    ans = 1001001001
    for x in sorted(d.keys()):
        p = 0
        b = []
        s = 0
        for j, y in enumerate(a):
            if y < x:
                if j - p >= k:
                    t = a[p:j]
                    t.sort()
                    b.extend(t[:j-p-k+1])
                p = j + 1
        if len(b) >= q:
            b.sort()
            ans = min(ans, b[q-1] - x)
        else:
            break
    print ans
main()


Measured memory_bytes: 3320
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
  //   String[] nyu=sc.nextLine().split(" ");

     String nyu=sc.nextLine();
//int A=Integer.parseInt(nyu[0]);
//int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu[2]);
//int D=Integer.parseInt(nyu);


//     String nyu2=sc.nextLine();
//int E=Integer.parseInt(nyu2);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(C){
case 7:
case 5:
case 3:
System.out.println("YES") ;
break;
default:
System.out.println("NO") ;

break;
}
*/

//int res=Math.min((A*B),C);

//for(String tem:nyu){
//if(tem.equals("1"))res++;
//}
//int res=0;
//for(int i=0;i<300;i++){
//if(num[i]==1)res=i;
//}

//char[] c = nyu.toCharArray();


//System.out.println(nyu+"-"+line_r_2+"-"+nyu2+"-"+line_r_1);


if(nyu.contains("9")){
//double res=Math.ceil((AB)/2);

System.out.println("Yes");
//}else if((int)c[0]>(int)c[2]){
//System.out.println(">");

}else{
System.out.println("No");

}




	}
}

Measured memory_bytes: 21716
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var ABC = Sarray();
            var A = ABC[0];
            var B = ABC[1];
            var C = ABC[2];
            for (var i = 1; i <= B; ++i)
            {
                if (A * i % B == C)
                {
                    WriteLine("YES");
                    return;
                }
            }
            WriteLine("NO");
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include "bits/stdc++.h"
using namespace std;

const int N=2e6+20,MOD=1e9+7,C=26;

int k,f[N],ie[N];
string s;
long long ans=1;

int mul(int a,int b) {return (1ll*a*b)%MOD;}

int power(int a,int b)
{
	int num=a,ans=1;
	for(int i=0;i<31;i++)
	{
		if(b&(1<<i)) ans=(1ll*ans*num)%MOD;
		num=(1ll*num*num)%MOD;
	}
	return ans;
}

int inverse_euler(int n)
{
	return power(n,MOD-2);
}

int ncr(int n,int r)
{
	return (1LL*f[n]*((1LL*ie[r]*ie[n-r])%MOD))%MOD;
}

void precompute()
{
	f[0]=1;
	for(int i=1;i<N;i++) f[i]=(1LL*f[i-1]*i)%MOD;
	for(int i=0;i<N;i++) ie[i]=inverse_euler(f[i]);
}

int main()
{
	precompute();

	cin>>k>>s;

	int n=k+s.size();
	ans=power(C,n);

	for(int i=0;i<s.size();i++)
	{
		ans=(ans-mul(ncr(n,i),power(C-1,n-i)))%MOD;
		if(ans<0) ans+=MOD;
	}

	printf("%lld",ans);
}

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

int n, q, cnt[200010], ans[200010];
bool gt[200010];
vector<int> G[200010];

void dfs(int k) {
    gt[k] = true;
    ans[k] += cnt[k];
    for (int i = 0; i < G[k].size(); i++) {
        if (!gt[G[k][i]]) {
            ans[G[k][i]] = ans[k];
            dfs(G[k][i]);
        }
    }
}

int main() {
    cin >> n >> q;
    for (int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;  b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    for (int i = 0; i < q; i++) {
        int p, x;
        cin >> p >> x;
        cnt[p - 1] += x;
    }
 
    dfs(0);
 
    for (int i = 0; i < n; i++) {
        if (i != 0) cout << " ";
        cout << ans[i];
    }
 
}

Measured memory_bytes: 24192