akhauriyash/Code-Regression huggingface dataset:
#include <queue>
#include <tuple>
#include <cstdio>
#include <cstring>
using namespace std;
#define SENTINEL 99999
typedef tuple<int,int,int> tiii; //building, floor, depth
int M[2][101],B[2][101],n;
int bfs(int i){
memset(M,99,sizeof(M));
	queue<tiii> q;
	q.push(make_tuple(i,0,0));M[i][0]=0;
	for(;!q.empty();){
		tiii t=q.front();q.pop();
		int building=get<0>(t);
		int floor=get<1>(t);
		int depth=get<2>(t);
		for(;B[building][floor]==1&&B[building][floor+1]==1;){
			if(M[building][floor+1]>M[building][floor])M[building][floor+1]=M[building][floor];
			floor++;
		}
		for(;B[building][floor]==2;){
			if(M[building][floor-1]>M[building][floor])M[building][floor-1]=M[building][floor];
			floor--;
		}
		if(floor==n-1)return depth;
		for(i=2;i>=0;i--)if(floor+i<n&&M[building^1][floor+i]>M[building][floor]){
			M[building^1][floor+i]=M[building][floor];
			q.push(make_tuple(building^1,floor+i,depth+1));
		}
	}
	return SENTINEL;
}
int main(){
	int i,j;
	for(;scanf("%d",&n),n;){
		for(j=0;j<2;j++){
			for(i=0;i<n;i++)scanf("%d",B[j]+i),M[j][i]=SENTINEL;
			B[j][i]=0,M[j][i]=SENTINEL;
		}
		i=min(bfs(0),bfs(1));
		printf(i==SENTINEL?"NA\n":"%d\n",i);
	}
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
int static dp[3002][3002];

int lcs(string str1,string str2,int m,int n)
{
    for(int i=1;i<=m;i++)
    {
        for(int j=1;j<=n;j++)
        {
            if(str1[i-1] == str2[j-1])
                dp[i][j] = 1+dp[i-1][j-1];

            else 
                dp[i][j] = max(dp[i-1][j] , dp[i][j-1]); 
        }

    }

    return dp[m][n];
}

int main()
{
    string s,t;
    cin>>s>>t;
    int m= s.length();
    int n= t.length();

    for(int i=0;i<=m;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(i==0 ||j==0)
            dp[i][j] = 0;
        }
    }

    lcs(s,t,m,n);

    int i=m,j=n;
    vector <char >vec;
    while(i>0 && j>0)
    {
        if(s[i-1] == t[j-1])
        {
            vec.push_back(s[i-1]);
            i--;
            j--;
        }

        else 
        {
            if(dp[i-1][j] > dp[i][j-1])
                i--;

            else 
                j--;
        }
    }
    reverse(vec.begin(),vec.end());

    for(int i=0;i<vec.size();i++)
    {
        cout<<vec[i];
    }
    if(vec.size()==0)
        cout<<" ";

        cout<<"\n";

    return 0;

}

Measured memory_bytes: 38756
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s; cin >> s;
  int cntx = 0;
  for(int i = 0; i < s.length(); i++)if(s[i]=='x')cntx++;
  cout << (((15 - cntx)>=8) ? "YES" : "NO") << endl;
  //cout << >=8 ? "YES" : "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp>>;

const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline void finish()
{
  cout << -1 << endl;
  exit(0);
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  int now = n;
  vector<int> ans;
  while (now != 0)
  {
    bool update = false;
    for (int i = max(0, now - m); i < now; ++i)
    {
      if (s[i] == '0')
      {
        ans.push_back(now - i);
        now = i;
        update = true;
        break;
      }
    }
    if (!update)
      finish();
  }
  reverse(all(ans));
  rep(i, ans.size()) cout << ans[i] << (i == ans.size() - 1 ? "\n" : " ");
  return 0;
}


Measured memory_bytes: 1096
def main():
    s = input().strip()

    c = 0
    for i in range(len(s)):
        if i == 0:
            if s[i] != 'A':
                print('WA')
                return
        elif i == 1 and not s[i].islower():
            print('WA')
            return
        elif 2 <= i and i <= len(s) - 2:
            if s[i] == 'C':
                c += 1
            else:
                if not s[i].islower():
                    print('WA')
                    return
        else:
            if not s[i].islower():
                print('WA')
                return
        
    if c != 1:
        print('WA')
        return
        
    print('AC')


if __name__ == '__main__':
    main()


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

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 1000000007
#define PI 3.14159265
#define endl '\n'


using namespace std;

void quick ()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);/*//*/
}

int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

void readFromText()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
   quick();
//    readFromText();
    int n ; cin >> n ; long long sum = 0 ;
    for (int i = 1 ; i <= n ; i++){
        if (i%3!=0&&i%5!=0){
            sum+=i;
        }
    }
    cout << sum << endl ;
    return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <limits>
#include <queue>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

#define rep(i,n) for(int i=0;i<(n);++i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"
const int INF = numeric_limits<int>::max();

const int fennec = 0, snuke = 1;
int start[2];
int N;
vvi edge;
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  in(N);
  start[0] = 0; start[1] = N-1;

  edge.resize(N, vi());
  rep(i, N-1) {
    int a, b;
    in(a); in(b);
    --a; --b;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  int dest[2][N];
  fill(dest[0], dest[0]+N, INF);
  fill(dest[1], dest[1]+N, INF);
  dest[fennec][0] = 0;
  dest[snuke][N-1] = 0;
  queue<int> q;
  rep(player, 2) {
    q.push(start[player]);
    while (!q.empty()) {
      int p = q.front(); q.pop();
      iter(it, edge[p]) {
        int to = *it;
        if (dest[player][to] > dest[player][p] + 1) {
          dest[player][to] = dest[player][p] + 1;
          q.push(to);
        }
      }
    }
  }

  int nodes[2] = {0, 0};
  rep(i, N) {
    if (dest[0][i] <= dest[1][i])
      ++nodes[0];
    else
      ++nodes[1];
  }
  if (nodes[0] > nodes[1])
    out("Fennec");
  else
    out("Snuke");
  return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 

using namespace std;

int main() {
	int i, j;
	char x, y;

	cin >> x >> y;

	if ((int)x == (int)y) {
		cout << "=" << endl;
	}
	else if ((int)x < (int)y) {
		cout << "<" << endl;
	}
	else {
		cout << ">" << endl;
	}










	return 0;
}

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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    COMinit();
    long long h,w,a,b;
    cin>>h>>w>>a>>b;
    long long ans=0;

    for(int i=0;i<h-a;i++){
        ans+=COM(b+i-1,i)*COM(w-b-1+h-i-1,h-i-1)%MOD;
        ans%=MOD;
        
    }
    cout<<ans<<endl;

    
}

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

int main(void){
    long long x, j;
    cin >> x;
    j = 100;
    
    for(int i = 0;;++i){
        if(j >= x){
            cout << i << endl;
            break;
        }
        j = j * 1.01;
    }
}

Measured memory_bytes: 3640
#include <stdio.h>

long long min(long long a,long long b){
  if(a < b){
    return a;
  }
  return b;
}


int main(void){
  long long N,a;
  long long minimam;

  scanf("%lld",&N);

  for(int i = 0;i < 5;i++){
    scanf("%lld",&a);
    if(i == 0) minimam = a;
    minimam = min(minimam,a);
  }

  printf("%lld\n",(N+minimam-1)/minimam+4);

  return 0;
}

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

int main() {
    int n;
    cin >> n;
    int l[n];
    rep(i, n) cin >> l[i];
    sort(l, l + n);

    int ans = 0;
    rep(i, n) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (l[i] == l[j] || l[j] == l[k] || l[i] == l[k]) continue;
                if (l[k] < l[i] + l[j]) ans++;
            }
        }
    }

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


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <utility>

using namespace std;
typedef pair<int, int> edge;

int L;
int N, M;
vector<edge> G[25];

int main(void)
{
	cin >> L;
	for(int x = L; x; x /= 2) N++;
	N--;
	
	for(int i = 1; i <= N; i++){
		G[i-1].push_back(make_pair(i, 1<<(i-1)));
		G[i-1].push_back(make_pair(i, 0));
		M += 2;
	}
	
	int sum = (1<<N);
	for(int i = N-1; i >= 0; i--){
		if(L & (1<<i)){
			G[i].push_back(make_pair(N, sum));
			sum += (1<<i);
			M++;
		}
	}
	
	cout << N+1 << " " << M << endl;
	for(int i = 0; i <= N; i++){
		if(G[i].size() == 0) continue;
		for(int j = 0; j < G[i].size(); j++){
			cout << i+1 << " " << G[i][j].first+1 << " " << G[i][j].second << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<math.h>
using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	vector<string>s(h);
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	int count = 0;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				count++;
			}
		}
	}
	if (count == h + w - 1) {
		cout << "Possible" << endl;
	}
	else
		cout << "Impossible" << endl;
}
	



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

int main(){
  int N;
  int i, j;
  int flag = 0;
  cin >> N;
  for (i = 1; i <= 9; i++) {
    for (j = i; j <= 9; j++) {
      if (N == i*j)
        flag = 1;
    }
  }
  if (flag)
    puts("Yes");
  else
    puts("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 r, d, x;
  cin >> r >> d >> x;
  for (i64 i = 0; i < 10; ++i) {
    x = r * x - d;
    cout << x << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
 
#define mem(dp,a)       memset(dp,a,sizeof dp)
#define ninja           ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb(x)           push_back(x)
#define mp(x,y)         make_pair(x,y)
#define all(c)          c.begin(), c.end()
#define ff              first
#define ss              second
#define nl              '\n'
#define inf             1e9+7
 
int main()
{
    ninja
    string s; cin>>s;
    if(s[2]==s[3] and s[4]==s[5])
        cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
}


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

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

const ll MOD = 1000000007;
const long double EPS = 1e-10;

template<class Abel> class UnionFind {
    public:
    int n;
    vector<int> par, rank;
    vector<Abel> diff_weight;

    UnionFind(int n, Abel SUM_UNITY = 0) {
        rep(n) {
            par.push_back(i);
            rank.push_back(0);
            diff_weight.push_back(SUM_UNITY);
        }
    }

    int find(int x) {
        if(par[x] == x){
            return x;
        }
        int root = find(par[x]);
        diff_weight[x] += diff_weight[par[x]];
        return par[x] = root;
    }

    Abel weight(int x) {
        find(x);
        return diff_weight[x];
    }

    bool unite(int x, int y, Abel w) {
        w = w + weight(x) - weight(y);
        x = find(x);
        y = find(y);

        if(x == y) return false;

        if(rank[x] < rank[y]){
            par[x] = y;
            diff_weight[x] = -w;
        }else{
            par[y] = x;
            diff_weight[y] = w;
            if(rank[x] == rank[y]) rank[x]++;
        }

        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }

    bool is_same(int x, int y) {
        return find(x) == find(y);
    }
};

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n,m,a,b,w;
    char q;
    cin >> n >> m;
    while(n != 0 || m != 0){
        UnionFind<int> uf(n+1);

        rep(m){
            cin >> q >> a >> b;
            if(q == '!'){
                cin >> w;
                uf.unite(a,b,w);
            }else{
                if(uf.is_same(a,b)){
                    cout << uf.diff(a,b) << endl;
                }else{
                    cout << "UNKNOWN" << endl;
                }
            }
        }

        cin >> n >> m;
    }
    
}


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

typedef long long ll;
const int maxn = 110, maxm = 1e5 + 10;
int n, V; ll f[maxm];

int main() {
	scanf("%d %d", &n, &V);
	for (int i = 1, v, w; i <= n; i++) {
		scanf("%d %d", &v, &w);
		for (int j = V; j >= v; j--) {
			f[j] = max(f[j], f[j - v] + w);
		}
	}
	ll ans = 0;
	for (int i = 0; i <= V; i++) {
		ans = max(ans, f[i]);
	}
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 1152
N,A,B,C,D = map(int,input().split())
if N % A == 0 :
  a = N // A
else:
  a = (N // A) + 1
if N % C == 0:
  c = N // C
else:
  c = (N // C) + 1
x = a*B
y = c*D
if x <= y:
  print(x)
else:
  print(y)


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 	    make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define mod        1000000007
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll power(ll a , ll b,ll modi)
{
    a%=modi;
    ll res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % modi ;
        }
        b/=2 ;
        a = (a*a) % modi ;
    }
    return res ;
}
//int a[200001];
int b[200001];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t=1;
	//cin>>t;
	while(t--)
	{
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
        cin>>b[i];
        }
    sort(b,b+n,greater<int>());
    ll ans=0;
    ans+=b[0];
    int j=1;
    int y=0;
    for(int i=2;i<n;i++){
        ans+=b[j];
        y++;
        if(y==2){
            y=0;
            j++;
        }
    }
    cout<<ans;
	}
return 0;
}


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

using namespace std;

#define fori(i, j, k) for (int i = j; i < (k); i++)
#define pb push_back

typedef long long ll;
typedef vector<int> vi;

const int maxn = 3e3 + 1;
const ll inf = 2e18, mod = 1e9 + 7;

int n;
ll a[maxn];
bool dp[maxn];
vi graph[maxn];

void dfs(int u, int prev = -1)
{
	dp[u] = false;
	for (int i : graph[u])
		if (i ^ prev)
		{
			dfs(i, u);
			if (a[i] < a[u] && !dp[i])
				dp[u] = true;
		}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n;
	fori (i, 0, n)
		cin >> a[i];
	int u, v;
	fori (i, 1, n)
	{
		cin >> u >> v;
		graph[--u].pb(--v);
		graph[v].pb(u);
	}
	fori (i, 0, n)
	{
		dfs(i);
		if (dp[i])
			cout << i + 1 << ' ';
	}
	cout << endl;
}

Measured memory_bytes: 640
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0xccccccc;
const ll LINF = 922337203685477580LL;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}



//head

int q, h, s, d;
int n;
ll ans;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> q >> h >> s >> d >> n;
  if(q*2 < h) h = q*2;
  if(h*2 < s) s = h*2;
  if(s*2 < d) d = s*2;
  ans += (ll)(n>>1)*d;
  ans += (n&1)*s;
  cout << ans << endl;
}

Measured memory_bytes: 3648
h, w = map(int, input().split())

def divide(h, w):
  ans = h*w
  for w1 in range(1, w):
    s1 = h*w1

    w2 = (w-w1)//2
    s21 = h*w2
    s31 = h*(w-w1-w2)
    ans1 = max(s1, s21, s31) - min(s1, s21, s31)

    h2 = h//2
    s22 = (w-w1)*h2
    s32 = (w-w1)*(h-h2)
    ans2 = max(s1, s22, s32) - min(s1, s22, s32)
    ans = min(ans, ans1, ans2)
  return ans

print(min(divide(h, w), divide(w, h)))


Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <set>

using namespace std;

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

	int N;
	cin >> N;

	string S;
	cin >> S;

	int max_cnt = 0;
	for (int i = 1; i < N; i++)
	{
		set<char> cnt_left;
		for (int j = 0; j < i; j++)
		{
			cnt_left.insert(S[j]);
		}

		set<char> cnt_right;
		for (int j = i; j < N; j++)
		{
			cnt_right.insert(S[j]);
		}

		int cnt = 0;
		for (char e : cnt_left)
		{
			if (cnt_right.find(e) != cnt_right.end())
			{
				cnt++;
			}
		}

		max_cnt = max(max_cnt, cnt);
	}

	cout << max_cnt;

	return 0;
}


Measured memory_bytes: 256
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}


*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>

using namespace std;
 
int main() {
	// 入力
    int N;
    cin >> N;
    long A[N];
    for (int i = 0; i < N; ++i) cin >> A[i];
    
    
    long long ans=0;
    int j=0;long long x=0,sum=0;
    for(int i=0;i<N;i++){
        while(j<N){
            if((x^A[j])!=(sum+A[j])) break; // xor != sum なら停止
            x^=A[j];sum+=A[j];j++;
        }
        ans+=j-i; // iについての検証が完了したところで加算
        //x^=A[i]; // a[i]で値が1の桁が打ち消しあって0になる
        x-=A[i]; // a[i]で値が1の桁が打ち消しあって0になる
        sum-=A[i];
    }
 
	//出力
    cout << ans << endl;
}
 


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

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

  vector<int> L(N);
  rep (i, N) cin >> L[i];

  int ans = 1;
  int D = 0;
  rep (i, N) {
    D = D + L[i];
    if (D <= X) ans++;
    else break;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl;
typedef long long ll;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
typedef pair<ll, ll> P;
typedef map<string, ll> M;
typedef unordered_map<ll, ll> HM;
typedef set<ll> S;
typedef queue<ll> Q;

int main(){
    int x,y,z,k;
    cin >> x >> y >> z >> k;
    V a(x),b(y),c(z),xy(x*y);
    for (int i = 0; i < x; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i < y; i++)
    {
        cin >> b[i];
    }
    for (int i = 0; i < z; i++)
    {
        cin >> c[i];
    }
    
    int index = 0;
    for (int i = 0; i < x; i++)
    {
        for (int j = 0; j < y; j++)
        {
            xy[index] = a[i] + b[j];
            index++;
        }
    }
    sort(ALL(xy), greater<ll>());
    V xyz(k*z);
    index = 0;
    for (int i = 0; i < min(k, x*y); i++)
    {
        for (int j = 0; j < z; j++)
        {
            xyz[index] = xy[i] + c[j];
            index++;
        }
    }
    sort(ALL(xyz), greater<ll>());
    for (int i = 0; i < k; i++)
    {
        OUT(xyz[i]);
    }
}

Measured memory_bytes: 31616
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0
for i in range(n):
  f = min(a[i],b[i])
  ans += f
  a[i] -= f
  g = min(a[i+1],b[i]-f)
  ans += g
  a[i+1] -= g
print(ans)

Measured memory_bytes: 18624
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <numeric>
#include <map>
#include <iomanip>
#include <climits>
#include <string>

using namespace std;

vector<long long> g[222222];
long long sum[222222] = {};
long long used[222222] = {};
vector<pair<int, int> > ans;

void dfs(long long v, long long add = 0)
{
	sum[v] += add;
	ans.push_back({ v, sum[v] });
	used[v] = 1;
	for (auto to : g[v])
		if (!used[to])
			dfs(to, sum[v]);
}

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

	long long n, q;
	cin >> n >> q;
	for (long long i = 0; i < n - 1; i++)
	{
		long long a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	while (q--)
	{
		long long k, s;
		cin >> k >> s;
		sum[--k] += s;
	}
	dfs(0);
	sort(ans.begin(), ans.end());
	for (auto x : ans)
		cout << x.second << ' ';
}

Measured memory_bytes: 28276
n, m = map(int, input().split())
c = [0] * (n + 1) 
for i in range(m):
    a, b = map(int, input().split())
    c[a] += 1
    c[b] += 1

flag = True
for i in range(n + 1):
    if c[i] % 2 == 1:
        flag = False
        break

if flag:
    ans = 'YES'
else:
    ans = 'NO'

print(ans)


Measured memory_bytes: 44632
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
using namespace std;
int i,j,k,n,m;
int out =0;
string s;
int v[3];
vector<int> nums;
vector<int> buf;

void dfs(int i, const int size, const int range_start, const int range_end)
{
  if (i == size) {
    int c3 = count(buf.begin(),buf.end(),3);
    int c5 = count(buf.begin(),buf.end(),5);
    int c7 = count(buf.begin(),buf.end(),7);
    if(c3>0&&c5>0&&c7>0){
      int out = 0;
      for(int i = 0; i < buf.size(); ++i){
        out = 10*out + buf[i];
      }
      if (out <= n){
        nums.push_back(out);
      }
      //cout << out << endl;
    }
  }
  else{
    for(int j = range_start; j <= range_end; ++j){
      buf[i] = v[j];
      dfs(i + 1, size, range_start, range_end);
    }
  }
}

int main(void)
{
  v[0]=3;v[1]=5;v[2]=7;
  cin >> n;
  int size = 3;
  int range_start = 0;
  int range_end = 2;
  for(int k = 3;k<=(int)to_string(n).size();++k){
    buf.resize(k);
    dfs(0, k, range_start, range_end);
  }
  cout << nums.size() << endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	string s; cin >> s;
	if(s[0] == '9') s[0] = '1';
	else if(s[0] == '1') s[0] = '9';
	
	if(s[1] == '9') s[1] = '1';
	else if(s[1] == '1') s[1] = '9';

	if(s[2] == '9') s[2] = '1';
	else if(s[2] == '1') s[2] = '9';

	cout << s << endl;

	return 0;

}


Measured memory_bytes: 256
n = int(input())
s = input()
c = 0
d = 0
for i in range(n):
    if s[i] == '(':
        c += 1
    else:
        d += 1
used_c = [True]*n
used_d = [True]*n
for i in range(n):
    if s[i] == '(':
        for j in range(i+1, n):
            if s[j] == ')' and used_c[j]:
                c -= 1
                used_c[j] = False
                break
    else:
        for j in range(i):
            if s[j] == '(' and used_d[j]:
                d -= 1
                used_d[j] = False
                break
print('('*d+s+')'*c)


Measured memory_bytes: 38640
#include<bits/stdc++.h>
using namespace std;
int m,n;
double t[16][16];
double dp[16][(1<<16)];
double Q[17][16];

int main(){
  cin>>m>>n;
  for(int i=0;i<m;i++)
    for(int j=0;j<n;j++)
      cin>>t[i][j];

  for(int S=(1<<m)-1;S>=0;S--){
    for(int i=0;i<m;i++)Q[n][i]=1.0;
    for(int x=n-1;x>=0;x--){
      for(int i=0;i<m;i++){
        if(S>>i&1)continue;
        dp[x][S]=max(dp[x][S],Q[x+1][i]*t[i][x]+(1.0-t[i][x])*dp[x][S|(1<<i)]);
        Q[x][i]=dp[x][S|(1<<i)]*(1.0-t[i][x])+Q[x+1][i]*t[i][x];
      }
    }
  }
  printf("%.12f\n",dp[0][0]);  
  return 0;
}

Measured memory_bytes: 9444
n, m = map(int, input().split())
H = [0] + list(map(int, input().split()))
G = [[] * (n + 1) for _ in range(n + 1)]
for i in range(m):
	a, b = map(int, input().split())
	G[a].append(b)
	G[b].append(a)

# print(G)

cnt = 0
for i in range(1, n + 1):
	path = G[i] # つながっている展望台の集合
	if len(path) == 0:
		cnt += 1
	else:
		flg = True
		for e in path:
			if H[i] <= H[e]:
				flg = False
		if flg:
			cnt += 1

print(cnt)





Measured memory_bytes: 93548
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	int m[1000],n=0,M=0,N=0,w,I,J,j;
	string r[1000],s;
	while(cin>>s){
		w=0;
		if(s.size()>M){M=s.size();I=n;}
		for(int i=0;i<n;i++)if(s==r[i]){m[i]++;w=1;j=i;break;}
		if(w==0){r[n]=s;m[n]=1;j=n;n++;}
		if(m[j]>N){N=m[j];J=j;}
	}
	cout<<r[J]<<" "<<r[I]<<endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;


vector<ll> divisor(ll N){ // 約数を求める
	vector<ll> ans;
	REP(i,N+1){
		if (i==0) continue;
		if (i*i>N)break;
		if (N%i==0){
			ans.pb(i);
			if (i!=N/i)ans.pb(N/i);
		}
	}
	sort(ans.begin(), ans.end());
  return ans;
}

// 検索タグ
int main() {
	// 入力
	ll N;cin>>N;
    
	// 解法
	ll ans = 0;
	/*

割り算の操作を 1 度以上する場合、そのような K は N の約数です。実際に K で割り切れなくな
るまで操作をしたあと、N mod K = 1 になっているかを確かめることにより、各約数毎に O(log N)
で判定することができます。
よって以上により問題が解けました。N および N − 1 の約数を求める部分がボトルネックとなり、
計算量は O(
√
N) となります。

	
	*/
	// 割り算の操作を 1 度もしない場合
	// 操作によって N mod K は変化しません。
	// したがって、最終的に 1 になるためには N mod K = 1 であることが必要十分です。
	// そのような K は N − 1 の約数のうち、1 でないもの全てであり、その個数は O(√N) で求めることができます。
	vector<ll> divisor1 = divisor(N-1); // N-1の約数のvector
	ans += divisor1.size() - 1; // 1を除く
	// REP(i,divisor1.size())printf("%lld ", divisor1[i]);
	// printf("\n");
	
	// 割り算の操作を 1 度以上する場合、そのような K は N の約数です。
	// 実際に K で割り切れなくなるまで操作をしたあと、N mod K = 1 になっているかを確かめることにより、
	// 各約数毎に O(log N)で判定することができます。
	vector<ll> divisor2 = divisor(N); // Nの約数のvector
	// REP(i,divisor2.size())printf("%lld ", divisor2[i]);
	// printf("\n");
	REP(i,divisor2.size()){
		if (divisor2[i]==1) continue;
		ll num = N;
		while (num%divisor2[i]==0){
			num /= divisor2[i];
		}
		if (num%divisor2[i]==1){
			ans++;
			// printf("hit %lld\n", divisor2[i]);
		}
	}
	// よって以上により問題が解けました。
	// N および N − 1 の約数を求める部分がボトルネックとなり、計算量は O(√N) となります。

	//出力
	printf("%lld\n", ans);
}


Measured memory_bytes: 384
// abc176_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
  int N,X,T;
  cin>>N>>X>>T;
  if (N%X==0) {
    cout<<N/X*T<<endl;
  } else {
    cout<<(N/X+1)*T<<endl;
  }
  return 0;
}


Measured memory_bytes: 3540
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a;cin >> a;
  ll b;cin >> b;
  cout << 6 - a - b << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>

using namespace std;

int main()
{
	int n;

	scanf("%d", &n);

	int i;

	int j;

	bool canflag = false;
	for (i = 1; i <= 9; i++)
	{
		for (j = 1; j <= 9; j++)
		{
			if (i * j == n)
				canflag = true;
		}
	}

	if (canflag == true)
		printf("Yes");
	else
		printf("No");
}

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

int main()
{
	while (1)
	{
		int a, b, swap;
		cin >> a >> b;
		if (a == b&&a == 0)
			break;
		if (a > b)
		{
			swap = a; a = b; b = swap;
		}
		cout << a << " " << b << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 1000000001;

int R, L;
int ans = INT_MAX;
int main(){
  cin >> R >> L;
  if(L - R >= 2018){
    ans = 0;
  }else{
    int r = R%2019;
    int l = L%2019;
    if(r >= l){
      ans = 0;
    }else{
      for(int i = r; i < l; i++){
        for(int j = i+1; j <= l; j++){
          ans = min(ans, (i*j)%2019);
        }
      }            
    }
  }
  cout << ans <<endl;
}

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

#define fi first
#define sd second
#define lson (nd<<1)
#define rson (nd<<11)
#define PB push_back
#define mid (l+r>>1)
#define MP make_pair
#define SZ(x) (int)x.size()

using namespace std;

typedef long long LL;

typedef vector<int> VI;

typedef pair<int,int> PII;

inline int read(){
    int res=0, f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){res=res*10+ch-'0';ch=getchar();}
    return res*f;
}

const int MAXN = 3'005;

const int MOD = 998244353;

//这道题，如果考虑每一个区间段会相当复杂，应该考虑每一个和为s的上升子序列
//被多少个区间包括(算贡献)，这是一步很重要的转换
//dp[i][j]表示以i为右端点，和为j的左端点之和
//最终答案为sum(i=1...n)(n-i+1)dp[i][s]
//需要一个前缀和，不然时间上过不去

void addmod(int& a, int b){a+=b;if(a>=MOD)a-=MOD;}
int mulmod(int a, int b){return 1ll*a*b%MOD;}

int dp[MAXN][MAXN];

int pre[MAXN][MAXN];//1-i所有值为j的左端点之和

int n, s;

int A[MAXN];

int main(){
    n=read();s=read();
    for(int i=1;i<=n;++i)A[i]=read();

    for(int i=1;i<=n;++i){
        dp[i][A[i]]=i;
        pre[i][A[i]]=i;
    }

    for(int i=2;i<=n;++i){
        for(int j=1;j<=s;++j){
            addmod(pre[i][j],pre[i-1][j]);
        }
    }

    for(int j=2;j<=s;++j){
        for(int i=1;i<=n;++i)if(j>A[i]){
            addmod(dp[i][j],pre[i-1][j-A[i]]);
        }
        for(int i=1;i<=n;++i){//更新
            pre[i][j]=pre[i-1][j];
            addmod(pre[i][j],dp[i][j]);
        }
    }

    int ans=0;
    for(int i=1;i<=n;++i){
        addmod(ans,mulmod(n-i+1,dp[i][s]));
    }

    cout<<ans;

    return 0;
}


Measured memory_bytes: 70784
# include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s, t, ans;
	int n;
	cin >> n >> s >> t;
	for(int i = 0; i < t.size(); i ++){
		ans += s[i];
		ans += t[i];
	}
	cout << ans << '\n';
}

Measured memory_bytes: 256
#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];
    }

    int x_min = *min_element(a.begin(), a.end());
    int x_max = *max_element(a.begin(), a.end());
    int ans = INT_MAX;

    for (int x = x_min; x <= x_max; ++x) {
        int tot = 0;
        for (int i = 0; i < n; ++i) {
            tot += (a[i] - x) * (a[i] - x);
        }
        if (tot < ans) ans = tot;
    }

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


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


int main() {
  int H, W;
  vector<vector<char>> c;
  vector<vector<int>> d;
  typedef pair<int, int> P;

  cin >> H >> W;
  c = vector<vector<char>>(H, vector<char>(W));
  d = vector<vector<int>>(H, vector<int>(W));
  queue<P> q;
  char v;
  for (int i=0; i<H; i++)
    for (int j=0; j<W; j++) {
      cin >> v;
      if (v == '#') {
        q.push(P(i, j));
        d.at(i).at(j) = 0;
      }
      else
        d.at(i).at(j) = -1;
      c.at(i).at(j) = v;
    }
  P p = q.front();
  q.pop();
  int max = 0;
  int dx[4] = {1, 0, -1, 0};
  int dy[4] = {0, 1, 0, -1};
  int xx, yy, x, y, count;
  while (true) {
    xx = p.first;
    yy = p.second;
    for (int i = 0; i < 4; i ++) {
      x = xx + dx[i];
      y = yy + dy[i];
      if (x < 0 || x > H - 1 || y < 0 || y > W - 1 || d.at(x).at(y) >= 0) continue;
      if (c.at(x).at(y) == '.') {
        q.push(P(x, y));
        count = d.at(xx).at(yy) + 1;
        if (max < count) max = count;
        d.at(x).at(y) = count;
      }
    }
    if (q.size() == 0) break;
    p = q.front();
    q.pop();
  }
  cout << max << endl;
}


Measured memory_bytes: 13456
#include <string>
#include <vector>
#include <iostream>
using namespace std;
string s;
int main() {
	cin >> s;
	vector<int> v;
	int ptr = 0;
	while (ptr < s.size()) {
		if (s[ptr] == 'c') v.push_back(0), ptr += 7;
		else v.push_back(1), ptr += 3;
	}
	v.push_back(v.back());
	int p = 0, m = 0, ret = -1;
	for (int i = 1; i < v.size(); i++) {
		if (v[i - 1] == v[i]) {
			int sa = i - p; p = i;
			if (sa > m) m = sa, ret = v[i - 1];
		}
	}
	cout << (ret ? "egg" : "chicken") << endl;
	return 0;
}

Measured memory_bytes: 3188
class UnionFind:
    def __init__(self, n):
        '木の初期化をする'
        self.p = [-1] * n
        self.rank = [1]*n
        self.root = n
    def find(self, x):
        'x の親を返す'
        if self.p[x] == -1:
            return x
        else:
            self.p[x] = self.find(self.p[x])
            return self.p[x]

    def unite(self, x, y):
        'rankの低い親を高い方のの親にする'
        if not self.same(x,y):
            x = self.find(x)
            y = self.find(y)
            if self.rank[x] > self.rank[y]:
                x,y = y,x
            elif self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.p[x] = y
            self.root -= 1
            return True
        else:
            return False

    def same(self, x, y):
        return self.find(x) == self.find(y)


n,m = map(int,input().split())
uf = UnionFind(n)
for i in range(m):
    x,y,z = map(int,input().split())
    uf.unite(x-1, y-1)
print(uf.root)


Measured memory_bytes: 7032
import java.util.Scanner;

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

		StringBuilder sb = new StringBuilder();
		while (in.hasNext()) {
			int a = in.nextInt();
			char op = in.next().charAt(0);
			int b = in.nextInt();

			if (op == '?') {
				break;
			}
			switch (op) {
			case '+':
				sb.append(a + b).append("\n"); break;
			case '-':
				sb.append(a - b).append("\n"); break;
			case '*':
				sb.append(a * b).append("\n"); break;
			case '/':
				sb.append(a / b).append("\n"); break;
			default:
				break;
			}
		}
		System.out.print(sb.toString());
	}
}

Measured memory_bytes: 17336
N = int(input())
X = list(map(int, input().split()))

MOD = 10 ** 9 + 7
ans = 0
for b in range(61):
    ctr = [0, 0]
    for i in range(N):
        ctr[X[i] >> b & 1] += 1

    ans += (1 << b) * ctr[0] * ctr[1]
    ans %= MOD

print(ans)


Measured memory_bytes: 117448
#include <bits/stdc++.h>
#define db(x) cerr<<#x<<" = "<<x<<'\n';
using namespace std;

struct Edge {
	int u,v,w;
};

int L;
vector<Edge> edges;

void addEdge(int u,int v,int w) {
	edges.push_back({u,v,w});
}

void print(int n) {
	cout<<n<<' '<<edges.size()<<'\n';
	for(Edge edge:edges)
		cout<<edge.u<<' '<<edge.v<<' '<<edge.w<<'\n';
}

int main() {
	//freopen("input","r",stdin);
	//freopen("output","w",stdout);
	cin>>L;
	int k=log2(L),mul=1;
	for(int i=1;i<=k;i++) {
		addEdge(i,i+1,mul);
		addEdge(i,i+1,0);
		mul*=2;
	}
	int rem=L-(1<<k);
	for(int i=k;i>=1;i--)
		if(rem>=(1<<(i-1))) {
			rem-=(1<<(i-1));
			addEdge(i,k+1,mul);
			mul+=(1<<(i-1));
		}
	print(k+1);
}



Measured memory_bytes: 3768
/*
    CP Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Shortcuts */
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(), x.end()
#define VAL(x) cout << #x << ": " << (x) << endl;
#define LOG(x) cout << (x) << endl;
#define SZ(x) (int)(x.size())
#define REP(i, a, b) for(int i = a; i < b; i++)
#define LOGR(x) for(auto a : (x)) cout << a << '\n';

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

const int MAXN = 1e3+5;
const int MOD = 1e9+7;

char a[MAXN][MAXN];
ll dp[MAXN][MAXN];

int main(){

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

    int h, w;
    cin>>h>>w;
    REP(i,0,h){
        REP(j,0,w){
            cin>>a[i][j];
        }
    }

    REP(i,1,h+1){
        REP(j,1,w+1){
            if(a[i-1][j-1] == '.'){
                dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % MOD;
            }
            if(i == 1 && j == 1) dp[i][j] = 1;
        }
    }

    //REP(i,0,h+1){
        //REP(j,0,w+1){
            //cout << dp[i][j] << ' ';
        //}

        //cout << '\n';
    //}

    LOG(dp[h][w]);


    return 0;
}


Measured memory_bytes: 9088
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int n,a,b;
	cin >> n;
	b = n;
	vector<int>vec(n);
	rep(i, n) {
		cin >> a >> vec[i];
		b = max(a, b);
	}
	sort(all(vec));
	cout << b + vec[0] << endl;
}



Measured memory_bytes: 1152
#include<stdio.h>
int main(){
  int a, b, c, t;
  scanf("%d %d %d", &a, &b, &c);
  if(c<b){t=c;c=b;b=t;}
  if(c<a){t=c;c=a;a=t;}
  if(b<a){t=b;b=a;a=t;}
  printf("%d %d %d\n", a, b, c);
  return 0;
}


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

using namespace std;

int l;
char s[100005];

bool check(int v){
	int lb = v;
	int ub = l - v - 1;
	
	bool ok = 1;
	
	for(int ii = ub + 1; ii < lb; ii++){
		if(ii == ub + 1 || s[ii] == s[ii - 1]) continue;
		ok = 0;
	}
	
	return ok;
}

int main(){
	scanf("%s", s);
	
	l = strlen(s);
	
	int lb = 1;
	int ub = l + 1;
	
	while(ub - lb > 1){
		int mid = (lb + ub) / 2;
		
		if(check(mid))
		lb = mid;
		else
		ub = mid;
	}
	
	printf("%d\n", lb);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;const ll INF=1LL<<60;
void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

template<class T,class F>
T bisection(T l,T r,F f,bool left=true,bool discrete=true){
  T eps=discrete?1:pow(10,-12);
  if((!left)^f(r)) return left?r:r+1;
  if(left^f(l)) return left?l-1:l;
  while(r-l>eps){
    T h=(l+r)/2;
    if((!left)^f(h)) l=h;
    else r=h;
  }
  return discrete?left?l:r:(l+r)/2;
}

void solve(){
  ll n,k; cin>>n>>k;
  vector<ll> A(n);
  rep(i,n) cin>>A[i];
  sort(A.begin(),A.end());

  auto check=[&](ll x){
    vector<ll> dp(k,0);
    dp[0]=1;
    rep(i,n){
      if(i==x) continue;
      vector<ll> newdp=dp;
      ll a=A[i];
      rep(j,k){
        if(j+a<k) newdp[j+a]=max(dp[j+a],dp[j]);
      }
      dp=newdp;
    }
    return *max_element(dp.begin()+max((ll)0,k-A[x]),dp.end());
  };
  cout<<bisection((ll)0,n-1,check,false)<<"\n";
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    string s,t; cin>>s>>t;
    t.pop_back();
    if (s==t) {
        cout << "Yes" << '\n';
    }
    else {
        cout << "No" << '\n';
    }
    return 0;
}

Measured memory_bytes: 3628