akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;

// AOJ 2149
public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt(), A = sc.nextInt(), B = sc.nextInt(), C = sc.nextInt(), X = sc.nextInt();
			if (N == 0 && A == 0 && B == 0 && C == 0 && X == 0) break;
			// ArrayList<Integer> Y = new ArrayList<Integer>();
			int[] Y = new int[N];
			
			for (int i = 0; i < N; i++) Y[i] = sc.nextInt();
			
			int idx = 0, f = 0;
			for (f = 0; f <= 10000; f++) {
				if (Y[idx] == X) idx++;
				//System.out.println("frame " + f + ":" + X);
				X = (A * X + B) % C;
				if (idx == N) break;
			}
			if (f == 10001) f = -1;
			System.out.println(f);
		}
	}	
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back

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

  int A, B, C;
  cin >> A >> B >> C;
  int a;
  a = A + B;
  if(a >= C){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector< vector<pair<int,int>> > tree(n);
	for (int i = 1; i < n; i++) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		tree[a].emplace_back(b, i);
		tree[b].emplace_back(a, i);
	}
	vector<int> ans(n);
	function<void(int, int)> dfs = [&](int u, int p) {
		set<int> se;
		if (p != -1) {
			se.insert(ans[p]);
		}
		int x = 1;
		for (auto pp : tree[u]) {
			int v = pp.first;
			if (pp.second == p) continue;
			while (se.find(x) != se.end()) x++;
			ans[pp.second] = x;
			se.insert(x);
			dfs(v, pp.second);
		}
	};
	dfs(0, -1);
	int mx = 0;
	for (int i = 1; i < n; i++) {
		mx = max(mx, ans[i]);
	}
	cout << mx << '\n';
	for (int i = 1; i < n; i++) {
		cout << ans[i] << '\n';
	}
	return 0;
}


Measured memory_bytes: 16512
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
#include <cmath>
#include <utility>
#include <numeric>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i=0;(i)<(n);(i)++)
#define repi(i, n) for (int i=0;(i)<=(n);(i)++)
#define repr(i, n) for (int i=n;(i)>=0;(i)--)
#define INF (1<<29)
#define print(x) (cout<<x<<endl)

int main() {
    int n; cin>>n;
    int k; cin>>k;
    vi xs(n); rep(i, n) cin>>xs[i];
    int ans=0;
    rep(i, n) {
        ans += min(abs(xs[i])*2, abs(xs[i]-k)*2);
    }
    print(ans);
}

Measured memory_bytes: 256
import java.util.*;


class Main{
    //ans
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
      long[] inp = new long[4]; 
      inp[0] = (long)sc.nextInt();
      inp[1] = (long)(long)sc.nextInt();
      inp[2] = (long)sc.nextInt();
      inp[3] = (long)sc.nextInt();
      long[] time = new long[4];
      int ti = 0;
      for(int i = 0;i<2;i++){
        for(int k = 2;k<4;k++){
          time[ti]=inp[i]*inp[k];
          ti++;
        }
      }
      long max = time[0];
      for(int i = 1;i<4;i++){
        if(time[i]>max){
          max = time[i];
        }
      }
      System.out.println(max);
    }
}

Measured memory_bytes: 27092
def main():
    N = int(input())
    A = map(int, input().split())
    l0 = [0] * 61
    l1 = [0] * 61
    for i in A:
        t = format(i, 'b').zfill(61)
        for j, v in enumerate(t):
            if v == '1':
                l1[j] += 1
            else:
                l0[j] += 1
    a = 0
    for i in range(61):
        a += ((2 ** i) * (l0[60-i] * l1[60-i])) % (10 ** 9 + 7)
    return a % (10**9 + 7)

print(main())





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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	double r;
	cin>>r;
	cout<<2*M_PI*r<<endl;
	return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, A, B; 
  cin >> N >> A >> B;

  int ans = N/(A+B)*A;
  N %= (A+B);
  ans += min(N, A);

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

typedef struct point2d{
  int64 x,y;
} point;

typedef struct line2d{
  point s,t;
} line;

void swap(int64 *a,int64 *b){
  int64 tmp=*a;
  *a=*b;
  *b=tmp;
}

int func(const line *a,const point *b){
  int64 p=a->s.x;
  int64 q=a->s.y;
  int64 r=a->t.x;
  int64 s=a->t.y;
  int64 t=(s-q)*(b->x-p)-(r-p)*(b->y-q);
  return t==0?0:(t>0?1:-1);
}

void calcCrossPoint(const line *a,const line *b,double *x,double *y){
  if(0==func(a,&(b->s))){
    *x=b->s.x;
    *y=b->s.y;
    return;
  }
  if(0==func(a,&(b->t))){
    *x=b->t.x;
    *y=b->t.y;
    return;
  }
  if(0==func(b,&(a->s))){
    *x=a->s.x;
    *y=a->s.y;
    return;
  }
  if(0==func(b,&(a->t))){
    *x=a->t.x;
    *y=a->t.y;
    return;
  }
  double p=a->t.y-a->s.y;
  double q=-(a->t.x-a->s.x);
  double r=b->t.y-b->s.y;
  double s=-(b->t.x-b->s.x);
  double z=a->s.x*a->t.y-a->s.y*a->t.x;
  double w=b->s.x*b->t.y-b->s.y*b->t.x;
  double det=p*s-q*r;
  *x=(s*z-q*w)/det;
  *y=(-r*z+p*w)/det;
  return;
}

void scanfLine(line *a){
  scanf("%lld%lld%lld%lld",&(a->s.x),&(a->s.y),&(a->t.x),&(a->t.y));
  return;
}

void run(void){
  int q;
  scanf("%d",&q);
  while(q--){
    line a,b;
    scanfLine(&a);
    scanfLine(&b);
    double x,y;
    calcCrossPoint(&a,&b,&x,&y);
    printf("%.9lf %.9lf\n",x,y);    
  }
}

int main(void){
  run();
  return 0;
}



Measured memory_bytes: 2100
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    x, n = map(int, input().split())
    P = set(list(map(int, input().split())))
    res = 0
    mi = f_inf
    for i in range(-200, 200):
        if i not in P:
            if abs(x - i) < mi:
                mi = abs(x - i)
                res = i
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9192
if __name__ == '__main__':
    x = list(input())

    for i in range(2**3):
        state =[]
        state.append(x[0])
        for j in range(3):
            if ((i >> j) & 1) == 1:
                state.append('+')
            else:
                state.append('-')
            state.append(x[j+1])
        str_state = ''.join(state)
        if eval(str_state) == 7:
            print(str_state + '=7')
            break


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define int long long
#define st first
#define nd second
#define rd third
#define FOR(i, a, b) for(int i =(a); i <=(b); ++i)
#define RE(i, n) FOR(i, 1, n)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)
#define REP(i, n) for(int i = 0;i <(n); ++i)
#define VAR(v, i) __typeof(i) v=(i)
#define FORE(i, c) for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
template<typename TH> void _dbg(const char* sdbg, TH h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename TH, typename... TA> void _dbg(const char* sdbg, TH h, TA... t) {
  while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(itt, (x)) cerr <<*itt <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define cerr if(0)cout
#endif
#define next ____next
#define prev ____prev
#define left ____left
#define hash ____hash
typedef long long ll;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<pair<int, int> > VPII;
typedef vector<pair<ll, ll> > VPLL;

template<class C> void mini(C&a4, C b4){a4=min(a4, b4); }
template<class C> void maxi(C&a4, C b4){a4=max(a4, b4); }
template<class T1, class T2>
ostream& operator<< (ostream &out, pair<T1, T2> pair) { return out << "(" << pair.first << ", " << pair.second << ")";}
template<class A, class B, class C> struct Triple { A first; B second; C third;
  bool operator<(const Triple& t) const { if (st != t.st) return st < t.st; if (nd != t.nd) return nd < t.nd; return rd < t.rd; } };
template<class T> void ResizeVec(T&, vector<int>) {}
template<class T> void ResizeVec(vector<T>& vec, vector<int> sz) {
  vec.resize(sz[0]); sz.erase(sz.begin()); if (sz.empty()) { return; }
  for (T& v : vec) { ResizeVec(v, sz); }
}
typedef Triple<int, int, int> TIII;
template<class A, class B, class C>
ostream& operator<< (ostream &out, Triple<A, B, C> t) { return out << "(" << t.st << ", " << t.nd << ", " << t.rd << ")"; }
template<class T> ostream& operator<<(ostream& out, vector<T> vec) { out<<"("; for (auto& v: vec) out<<v<<", "; return out<<")"; }

    
int32_t main() {

  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(10);
  cerr << fixed << setprecision(10);
  cin.tie(0);
  //double beg_clock = 1.0 * clock() / CLOCKS_PER_SEC;
  
  int n, m;
  cin>>n>>m;
  int cost = 0;
  VPII costs;
  REP (i, n) {
    int a;
    cin>>a;
    costs.PB({a, 0});
  }
  REP (i, m) {
    int a;
    cin>>a;
    costs.PB({a, 1});
  }
  sort(ALL(costs));
  for (auto p : costs) {
    if (p.nd == 0) {
      cost += p.st * (m + 1);
      n--;
    } else {
      cost += p.st * (n + 1);
      m--;
    }
  }
  cout<<cost<<endl;
    
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  return 0;
}


Measured memory_bytes: 4464
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdio.h>

int main()
{   int a,b;
    scanf("%d%d",&a,&b);
    if(a>12){
        printf("%d",b);
    }else if(a>5){
        printf("%d",b/2);
    }else{
    printf("0");
    }
    return 0;
}


Measured memory_bytes: 128
N, capW = map(int, input().split())
items = [tuple(map(int, input().split())) for _ in range(N)]

def knapsack01(items, capW):
    dp = [0] * (capW+1)
    for wi, vi in items:
        dp = [v1 if v1 >= v2 else v2 for v1, v2 in zip(dp, [0]*wi + [v+vi for v in dp[:capW-wi+1]])]
    return max(dp)

print(knapsack01(items, capW))


Measured memory_bytes: 15080
#include<bits/stdc++.h>
using namespace std;
#define V vector
#define L long long
#define W V<L>
#define R(n) for(L i=0;i<n;i++)
W S(V<W>&p,L E){if(!E){return{1,0};}V<V<W>>T(2);for(W x:p){T[x[1]&1].push_back({x[0]/2,x[1]/2});if(x[0]&1){T[(x[1]+1)&1].push_back({x[0]/2,(x[1]+1)/2});}}R(2){L c=0;for(W x:T[!i]){L Q=(2*x[0]+x[1])%3;c^=(Q+1);}if(!c){W A=S(T[i],E-1);A[0]*=2;A[1]*=2;A[1]+=i;return A;}}for(W&v:p){v[0]++;}W A=S(p,E);A[0]--;return A;}
int main(){L M=2e17,n;cin>>n;V<W>p(n);R(n){L a,b;cin>>a>>b;p[i]={a+M,b+M};}W Q=S(p,70);cout<<Q[0]-M<<" "<<Q[1]-M;}

Measured memory_bytes: 37052
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

double D, E;

int main() {
  while(1){
    cin>>D>>E;
    if(D==0 && E==0) break;
    double ans = (double)1e9;
    for(double x = 0.0; x <= D; x += 1.0){
      double y = D - x;
      ans = min(ans, fabs(sqrt(x*x + y*y) - E));
    }
    printf("%.4lf\n", ans);
  }
  return 0;
}

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

int main(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll flag;
    ll ans = 0;
    for(ll i=1;i<n;++i){
        flag = 0;
        string a = s.substr(0,i);
        string b = s.substr(i,n-i);
        for(ll j=0;j<26;++j){
            if(a.find('a'+j)!=-1 and b.find('a'+j)!=-1){
                flag++;
            }
        }
        ans=max(ans, flag);
    }
    cout<<ans<<endl;
}

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

using namespace std;
using LL = long long int;

const int INF = 1000000000;

const int MAX_N = 105;

int N, M, L;

class Edge{
public:
    Edge(int from = -1, int to = -1, int dist = -1, int e = -1) : from(from), to(to), dist(dist), e(e) {}
    int from, to, dist, e;
    
    int money;
    int damage;
    int pos;

    bool operator < (const Edge& e) const {
        return e.damage < e.damage;
    }
    bool operator > (const Edge& e) const {
        return e.damage > e.damage;
    }
};

vector<Edge> edges[MAX_N];

int dist[MAX_N][MAX_N];

bool input()
{
    for(int i = 0; i < MAX_N; i++) {
        edges[i].clear();
    }
    cin >> N >> M >> L;
    if(N == 0 && M == 0 && L == 0) {
        return false;
    }
    for(int i = 0; i < M; i++) {
        int a,b,c,d;
        cin >> a >> b >> c >> d; a--; b--;
        edges[a].push_back(Edge(a,b,c,d));
        edges[b].push_back(Edge(b,a,c,d));
    }
    return true;
}

int main()
{
    while(input()) {
        for(int i = 0; i < MAX_N; i++) {
            for(int j = 0; j < MAX_N; j++) {
                dist[i][j] = INF;
            }
        }

        priority_queue<Edge, vector<Edge>, greater<Edge>> pque;
        Edge start; start.pos = 0; start.money = L; start.damage = 0; pque.push(start);
        dist[0][L] = 0;

        while(pque.size()) {
            Edge e = pque.top();
            pque.pop();
            int pos = e.pos;
            int money = e.money;
            int damage = e.damage;
            // cerr << dist[pos][money] << " " << damage << endl;
            if(dist[pos][money] < damage) {
                continue;
            }

            // cerr << "OK" << endl;

            for(int d = 0; d < edges[pos].size(); d++) {
                Edge edge = edges[pos][d];
                int next = edge.to;
                //金を使わない
                if(dist[next][money] > dist[pos][money] + edges[pos][d].e) {
                    dist[next][money] = dist[pos][money] + edges[pos][d].e;
                    Edge nextState; 
                    nextState.damage = dist[next][money];
                    nextState.money = money;
                    nextState.pos = next;
                    // cerr << nextState.pos << " " << nextState.damage << endl;
                    pque.push(nextState);
                }
                //金を使う
                if(money - edge.dist >= 0) {
                    if(dist[next][money - edge.dist] > dist[pos][money]) {
                        dist[next][money - edge.dist] = dist[pos][money];
                        Edge nextState; 
                        nextState.damage = dist[next][money - edge.dist];
                        nextState.money = money - edge.dist;
                        nextState.pos = next;

                        pque.push(nextState);
                    }  
                }
            }
        }

        int ans = INF;
        for(int i = 0; i <= L; i++) {
            ans = min(ans, dist[N-1][i]);
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3644
#coding: utf-8

s = input()
for i in range(len(s)):
    if ord(s[i]) >= ord('a') and ord(s[i]) <= ord('z'):
        print(chr(ord(s[i])-32), end='')
    elif ord(s[i]) >= ord('A') and ord(s[i]) <= ord('Z'):
        print(chr(ord(s[i])+32), end='')
    else:
        print(s[i], end='')
print("")


Measured memory_bytes: 5724
import java.util.Scanner;
import java.math.BigDecimal;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a,b;
        a = sc.nextInt();
        b = sc.nextInt();
        double c= (double)a/b;
        String str = BigDecimal.valueOf(c).toPlainString();
        System.out.println(a/b+" "+a%b+" "+str);
    }
}


Measured memory_bytes: 26612
# coding: utf-8
# Your code here!
import queue

N = int(input())

e = []
v2e = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = map(lambda x: int(x)-1, input().rstrip().split())
    v2e[a].append((b, i))
    v2e[b].append((a, i))
    
count = 0
f = [False] * N
f[0] = True
c = [-1] * (N - 1)
q = queue.Queue()
q.put((-1, 0))
while q.qsize() > 0:
    ie, v = q.get()
    t = 0
    for i, j in v2e[v]:
        if f[i] == False:
            if t == ie:
                t += 1
            q.put((t, i))
            c[j] = t
            f[i] = True
            t += 1
                
print(max(c) + 1)
for i in range(len(c)):
    print(c[i] + 1)
   


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

int main() {
  char s[4];
  rep(i,4) cin >> s[i];

  char s1,s2;
  s1 = s[0];
  s2 = ' ';
  int c1,c2;
  c1 = c2 = 0;
  rep(i,4) {
    if(s[i]==s1){ c1++; }
    else if(s2==' '){ s2 = s[i]; c2++; }
    else if(s[i]==s2){ c2++; }
    else{ cout << "No" << endl; return 0; }
  }
  if(c1==2 && c2==2) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
N = gets.to_i
M = gets.to_i
A = gets.split.map(&:to_i).map{|i|i-1}
sum = Array.new(N){0}
M.times do |round|
  gets.split.map(&:to_i).map{|i|i-1}.each.with_index do |b, i|
    case A[round]
      when i
        sum[i] += 1
      when b
        sum[i] += 1
      else
        sum[A[round]] += 1
    end
  end
end
puts sum

Measured memory_bytes: 8920
#include <bits/stdc++.h>
using namespace std;
int main(void){

    int a, b, c, d;
    cin >> a >> b >> c >> d ;
    
    while(1){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }
        
        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            break;
            
        }
    }


}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define ll int64_t
#define _GLIBCXX_DEBUG
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//約数列挙(√N)
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}
//素因数分解(√N)
map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}
//素数テーブル(NloglogN)
vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
//二項係数(K)
template< typename T >
T binomial(int64_t N, int64_t K) {
  if(K < 0 || N < K) return 0;
  T ret = 1;
  for(T i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
//二項係数テーブル(N^2)
template< typename T >
vector< vector< T > > binomial_table(int N) {
  vector< vector< T > > mat(N + 1, vector< T >(N + 1));
  for(int i = 0; i <= N; i++) {
    for(int j = 0; j <= i; j++) {
      if(j == 0 || j == i) mat[i][j] = 1;
      else mat[i][j] = mat[i - 1][j - 1] + mat[i - 1][j];
    }
  }
  return mat;
}
int main(){
  int n;
  cin >> n;
  vector<int> soinsu(100);
  rep(i,n){
    auto m=prime_factor(i+1);
    for(auto j:m)
      soinsu.at(j.first-1)+=j.second;
  }
  ll ans=0;
  rep(i,100)
    if(soinsu.at(i)>=74)ans++;
  rep(i,100){
    rep(j,100){
      if(i==j)continue;
      if(soinsu.at(i)>=4&&soinsu.at(j)>=14)ans++;
    }
  }
  rep(i,100){
    rep(j,100){
      if(i==j)continue;
      if(soinsu.at(i)>=2&&soinsu.at(j)>=24)ans++;
    }
  }
  rep(i,100){
    rep(j,100){
      rep(k,j){
        if(i==j||j==k||i==k)continue;
        if(soinsu.at(i)>=2&&soinsu.at(j)>=4&&soinsu.at(k)>=4)ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    int n;
    string s;
    cin >> n >> s;
    vector<int> clist;
    long drui[n+1], mrui[n+1], dmrui[n+1];
    drui[0] = mrui[0] = dmrui[0] = 0;
    for (int i=0; i<n; i++) {
        char c = s[i];
        drui[i+1] = drui[i];
        mrui[i+1] = mrui[i];
        dmrui[i+1] = dmrui[i];
        if (c == 'D') 
            drui[i+1]++;
        else if (c == 'M') {
            mrui[i+1]++;
            dmrui[i+1] += drui[i];
        }
        else if (c == 'C')
            clist.push_back(i+1);
    }
    int q; cin >> q;
    for (int i=0, k; i<q; i++) {
        cin >> k;
        long sum = 0;
        for (auto end:clist) {
            int begin = max(end - k, 0);
            long dm = dmrui[end] - dmrui[begin],
                 d_m = drui[begin] * (mrui[end] - mrui[begin]);
            sum += dm - d_m;
        }
        cout << sum << '\n';
    }
    return 0;
}

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

int main(void)
{
    long n, a, b, c, d, e, min = 0;
    cin >> n >> a >> b >> c >> d >> e;
    if (a > b)
    {
        min = b;
    }
    else
    {
        min = a;
    }
    if (min > c)
    {
        min = c;
    }
    if (min > d)
    {
        min = d;
    }
    if (min > e)
    {
        min = e;
    }

    if (n % min == 0)
    {
        n = n / min;
    }
    else
    {
        n = n / min + 1;
    }
    cout << n + 4 << endl;
    return 0;
}


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

constexpr long long MOD = 1e9 + 7;

ll binExp(ll a, ll e) {
	if (e == 0) {
		return 1;
	}

	if (e % 2 == 1) {
		return (binExp(a, e - 1) * a) % MOD;
	}

	ll b = binExp(a, e / 2);
	return (b * b) % MOD;
}

int main() {
	ll k;
	cin >> k;

	string s;
	cin >> s;

	ll n = s.length();
	ll ans = 0;

	ll fact[n + k + 1];
	ll inv[n + k + 1];

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

	for (int i = n; i <= n + k; ++i) {
		ll a = (((fact[n + k] * inv[n + k - i]) % MOD) * inv[i]) % MOD;
		a = (a * binExp(25, n + k - i)) % MOD;
		ans = (ans + a) % MOD;
	}

	cout << ans;
	
	return 0;
}


Measured memory_bytes: 35556
#include<iostream>

using namespace std;

int main()
{
	int N,M;
	int *L,*R;

	cin >> N >> M;

	L = new int[M];
	R = new int[M];

	for(int i=0;i<M;i++)
	{
		cin >> L[i] >> R[i];
	}

	int l=1,r=N;

	for(int i=0;i<M;i++)
	{
		l = max(L[i],l);
		r = min(R[i],r);
	}

	int ans = max(r - l + 1,0);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    for i in range(1, len(S)):
        if S[i-1] == S[i]:
            return "Bad"
    return 'Good'


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7868
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)




int main(){
    int n; cin>>n;
    if(n==1) cout<<0<<endl;
    else cout<<1<<endl;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

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

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

	int a, b, c;
	cin >> a >> b >> c;

	if(a + b >= c){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}




    return 0;
}



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

int main(){
  int N,M,X;
  cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N,vector<int> (M));
  for(int i=0;i<N;i++){
    cin >> C.at(i);
    for(int j=0;j<M;j++){
      cin >> A.at(i).at(j);
    }
  }
  int mincost=100000000;
  for(int bit=0;bit<(1<<N);bit++){
    vector<int> rikai(M);
    int cost=0;
    for(int i=0;i<N;i++){
      if(bit &(1<<i)){
        cost+=C.at(i);
        for(int j=0;j<M;j++){
          rikai.at(j)+=A.at(i).at(j);
        }
      }
    }
    bool a=true;
    for(int i=0;i<M;i++){
      if(rikai.at(i)<X){
        a=false;
      }
    }
    if(a){
      mincost=min(mincost,cost);
    }
  }
  if(mincost==100000000){
    cout << -1 << endl;
  }
  else{
    cout << mincost << endl;
  }
}

Measured memory_bytes: 3596
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll n,e,t;
    cin>>n>>e>>t;
    vector<ll> a(n);
    for(auto &I:a){cin>>I;}
    ll r=0;
    vector<pll> dp(n,{E,E});
    dp[0]={t,0};
    for(int i=0;i+1<n;i++){
        while(r<n && (a[r]-a[i])*2<=t){
            dp[r].F=min(dp[r].F,dp[i].S+t);
            r++;
        }
        if(r<n){dp[r].F=min(dp[r].F,dp[i].S+2*(a[r]-a[i]));}
        dp[i+1].F=min(dp[i+1].F,dp[i].F+2*(a[i+1]-a[i]));
        dp[i+1].S=min(dp[i+1].S,dp[i].S+t);
        dp[i+1].S=min(dp[i+1].S,dp[i].F);
    }
    cout<<e+min(dp.back().F,dp.back().S+t)<<endl;
    
    
    return 0;
}


Measured memory_bytes: 2560
n, m = map(int, input().split())
a_b = [[int(j) for j in input().split()] for i in range(m)]
a = []
b = []
for i in range(m):
  a.append(a_b[i][0])
  b.append(a_b[i][1])
  
for i in range(1,n+1):
  print(sum(1 for j in a if j == i) + sum(1 for j in b if j == i))
  
  


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

long long int number[101];

int main() {
	ios::sync_with_stdio(0),
	cin.tie(0), cout.tie(0);
	int a,l,sum,Sum;
	while(cin >>a){
		cin >>l;
		if(l==0){
			cout <<a<<'\n';
		}
		else{
			for(int i=0;i<l;i++){
				cin >>number[i];
			}
			for(int i=0;i<=1000000;i++){
				sum=0;
				Sum=0;
				for(int j=0;j<l;j++){
					if(number[j]!=a+i){
						sum++;
					}
					if(number[j]!=a-i){
						Sum++;
					}
				}
				if(sum==l&&Sum==l){
					cout <<a-i<<'\n';
					break;
				}
				else if(sum==l){
					cout <<a+i<<'\n';
					break;
				}
				else if(Sum==l){
					cout <<a-i<<'\n';
					break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int x;
  while(a>0 && c>0)
  {
  	c=c-b;
  //	cout<<c<<" ";
  	if(c<=0)
  	{
  	  x=1; 	
  	  break;
	}
	a=a-d;
//	cout<<a<<" ";
	if(a<=0)
	{
		x=0;
		break;
	}
//	cout<<endl;
  }
 // cout<<"x="<<x<<endl;
  if(x==1)
  cout<<"Yes";
  else
  cout<<"No";
  return 0;
}

Measured memory_bytes: 3620
#template
def inputlist(): return [int(j) for j in input().split()]
#template
N = int(input())
if N == 1:
    print(0)
    exit()

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

li = factorization(N)
n = len(li)
ans = 0
counts = [1]*40
for i in range(2,41):
    counts[i-1] = counts[i-2]+i
from bisect import bisect_right
for i in range(n):
    count = li[i][1]
    ans += bisect_right(counts,count)
print(ans)


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

using I = long long;

vector<I> E(auto N) {
  vector<I> R(N);
  iota(begin(R), end(R), 0);
  return R;
}

vector<I> mul(const auto& A, const auto& B) {
  vector<I> R(A.size());
  for(auto i=0; i<A.size(); ++i) R[i] = B[A[i]];
  return R;
}

vector<I> power(const auto& B, auto K) {
  if(K==0) return E(B.size());
  if(K&1) return mul(B, power(B, K - 1));
  return power(mul(B, B), K >> 1);
}

vector<I> solve(const auto& Y, const auto& B, auto K) {
  vector<I> X(Y.size());
  auto A = power(B, K);
  for(auto i=0; i<X.size(); ++i) X[i] = Y[A[i]];
  return X;
}

int main() {
  I N;
  cin >> N;
  vector<I> X(N);
  for(auto& i: X) cin >> i;
  I M, K;
  cin >> M >> K;
  vector<I> A(M);
  for(auto& i: A) cin >> i;

  vector<I> Y(N);
  Y[0] = X[0];
  for(auto i=1; i<N; ++i) Y[i] = X[i] - X[i-1];
  vector<I> B(N);
  iota(begin(B), end(B), 0);
  for(auto i: A) swap(B[i-1], B[i]);

  I ans = 0;
  for(auto i: solve(Y, B, K)) cout << (ans += i) << endl;
}


Measured memory_bytes: 51968
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define all(a)          (a).begin(), (a).end()
#define sort(a)         sort(all(a))
#define uniq(a)         sort(a);(a).erase(unique(all(a)), (a).end())
#define reverse(a)      reverse(all(a))
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }
#define pb              push_back
#define fst             first
#define int             long long
#define INF             __LONG_LONG_MAX__

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

bool check(const vector<ll> &w, ll k, ll x) {
  // debug3("check", k, x);
  ll cap = 0;
  for (ll wi : w) {
    // debug3(k, cap, wi);
    if (wi > x) return false;

    if (cap + wi > x) {
      k--;
      if (k == 0) return false;
      cap = 0;
    }

    cap += wi;
  }
  return true;
}

void solve() {
  ll n, k; cin >> n >> k;
  vector<ll> w(n); rep(i, n) cin >> w[i];
  ll ok = 1000000000, ng = 0;
  while (ok - ng > 1) {
    ll mid = (ok + ng) / 2;
    if (check(w, k, mid)) ok = mid;
    else ng = mid;
  }
  outl(ok);
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}



Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int x = sc.nextInt();
    int n = sc.nextInt();

    List<Integer> p = new ArrayList<Integer>();
    for(int i=0; i<n; i++){
      p.add(sc.nextInt());
    }

    int abs = 0;
    while(true){
      if(!p.contains(x - abs)){
        System.out.println(x-abs);
        break;
      }else if(!p.contains(x + abs)){
        System.out.println(x + abs);
        break;
      }

      abs++;
    }
    
    return;
  }
}

Measured memory_bytes: 35812
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long ll;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second)return a.second < b.second;
    else return a.first < b.first;
}


void solve(long long A, long long B, long long C, long long X, long long Y){
    ll ans = 10e14;
    rep(i, 202020){
        ll val = 0;
        val += C*i;
        ll x = max(0LL,X - i/2);
        ll y = max(0LL,Y - i/2);
        val += x*A+y*B;
        ans=min(ans,val);
    }
    cout<<ans<<endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(A, B, C, X, Y);
    return 0;
}



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

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 1; i < n; i++) {
            System.out.print(weight(i, i + 1));
            for (int j = i + 2; j <= n; j++) {
                System.out.print(" " + weight(i, j));
            }
            System.out.println();
        }
    }

    int weight(int i, int j) {
        int b = Integer.lowestOneBit(i ^ j);
        for (int x = 0; x < 30; x++) if (((b >> x) & 1) == 1)
            return x + 1;
        return -1;
    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 39704
#include <stdio.h>
#include <string.h>
#include <math.h>

int main() {

    int n, d, x, y;
    scanf("%d %d", &n, &d);
    int cnt = 0;

    for (int i = 0; i < n; i++) {
        scanf("%d %d", &x, &y);
        long long temp1, temp2, mysum;
        temp1 = x;
        temp1 *= x;
        temp2 = y;
        temp2 *= y;
        mysum = temp1;
        mysum += temp2;

        double distance = sqrt(mysum);

        //printf("%lld  %lld %lld %f\n", temp1, temp2, mysum, distance);

        if (distance <= d) {
            cnt++;
        }
    }

    printf("%d", cnt);
    return 0;
}

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

int main(){
    int N,A,B;
    cin >> N;
    A = N % 10;
    B = N / 10;
    for(int i = 0; i < 8; i++){
        A = B % 10 + A;
        B = B /10;
    }
    if (N % A == 0){
        cout << "Yes" <<endl;
    }
    else{
        cout << "No" <<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  int ans=0;
  string s;
  
  for(int i=A;i<=B;i++) {
   
      
      s=to_string(i);
      
      if(s[0]==s[4]&&s[1]==s[3]) {
        ans++;
      }
    
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  char c;
  scanf("%c", &c);
  switch (c) {
  case 'a':
  case 'e':
  case 'i':
  case 'o':
  case 'u':
    printf("vowel\n");
    break;
  default:
    printf("consonant\n");
    break;
  }

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	int n,m;
    cin>>n>>m;
    priority_queue<int> q;
    REP(i,n){
        int a;
        IN(a);
        q.push(a);
    }
    REP(i,m){
        int tmp=q.top();
        tmp/=2;
        q.pop();
        q.push(tmp);
    }
    ll ans=0;
    REP(i,n){
        ans+=q.top();
        q.pop();
    }
    OUT(ans);
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>
#include <sstream>
typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}
/*
ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}*/
int main() {
	cin >> n;
	vector<ll> a(n);
	ll xx = 0;
	rep(i, n) {
		cin >> a[i];
		xx ^= a[i];
	}
	rep(i, n) {
		cout << (xx ^ a[i]) << endl;
	}
}


Measured memory_bytes: 4720
n,m = map(int,input().split())
data = [list(map(int, input().split())) for i in range(m)]

def dfs(pos):
  if visit[pos] == 1:
    return
  visit[pos] = 1
  
  for i in range(n):
    if graph[pos][i] == 1:
      dfs(i)

count = 0
for hen in range(m):
  graph = [[0]*n for i in range(n)]
  visit = [0]*n

  for i in range(m):
    pos1 = data[i][0] - 1
    pos2 = data[i][1] - 1
    if i != hen:
      graph[pos1][pos2] = 1
      graph[pos2][pos1] = 1
  dfs(0)
  connected = True
  for i in range(n):
    if visit[i] == 0:
      connected = False
  if not connected:
    count += 1
print(count)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

int main() {
	int a;
	cin >> a;
	cout << a + a * a + a * a * a << endl;
	return 0;
}


Measured memory_bytes: 3592
s = input()
l = len(s)
a = []
i = 0

data = []
while i + 2 < l:
  a = int(s[i])
  b = int(s[i+1])
  c = int(s[i+2])
  sc = a * 100 + b * 10 + c
  score = abs(753 - sc)
  data.append(score)
  i += 1
  
  
ans = min(data)

print(ans)

  
  

Measured memory_bytes: 3064
#
# 176C
#

n = input()
s = input()

a = s.split()

max = int(a[0])
total = 0

for i in range(int(n)):
    if max>int(a[i]):
        total += max-int(a[i])
    else:
        max = int(a[i])

print(str(total))

Measured memory_bytes: 24868
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e9+7;

#define MAX_V 100005

int main() {
    string s;
    cin >> s;
    string t = "2019/04/30";
    dump(s <= t ? "Heisei" : "TBD");
    return 0;
}

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

using namespace std;

struct trio{
    int wt, sz, v;
    bool operator <(const trio &t) const{
        return sz+wt < t.sz+t.wt;
    }
};

int N;
trio arr[1005];
long long dp[30005];

int main(){
    cin >> N;
    for(int i = 1; i<=N; i++){
        cin >> arr[i].wt >> arr[i].sz >> arr[i].v;
    }
    sort(arr+1, arr+N+1);
    long long ans = 0;
    for(int i = 1; i<=N; i++){
        for(int j = arr[i].sz; j>=0; j--){
            dp[j+arr[i].wt] = max(dp[j+arr[i].wt], dp[j]+arr[i].v);
            ans = max(dp[j+arr[i].wt], ans);
        }
    }
    cout << ans << endl;
}


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

int main(){
	int a,b=0;
	for(int i=0;i<5;i++){
		cin >> a;
		if(a<=40){
			b+=40;
		}else{
			b+=a;
		}
	}
	cout << b/5 << "\n" ;
	return 0;
}

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

char map[8][8];

void init(){
  for(int i = 0; i < 8; i++){
    for(int j = 0; j < 8; j++){
      map[i][j] = '0';
    }
  }
}

void dfs(int a, int b){
  map[a][b] = '0';
  for(int i = -3; i <= 3; i++){
    if(a + i >= 0 && a + i < 8 && map[a+i][b] == '1') dfs(a+i, b);
  }

  for(int i = -3; i <= 3; i++){
    if(b + i >= 0 && b + i < 8 && map[a][b+i] == '1') dfs(a, b+i);
  }

  return;
}

void print_map(){
  for(int i = 0; i < 8; i++){
    for(int j = 0; j < 8; j++){
      cout << map[i][j];
    }
    cout << endl;
  }
}

int main(void){
  int n, a, b;
  cin >> n;
  for(int i = 0; i < n; i++){
    init();
    for(int j = 0; j < 8; j++){
      for(int k = 0; k < 8; k++){
        cin >> map[j][k];
      }
    }
    cin >> a >> b;
    cout << "Data " << i + 1 << ":" << endl;
    dfs(b - 1, a - 1);
    print_map();
  }
  return 0;
}

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

using namespace std;

long long ncr(int n, int r) {
    if (r == 0) return 1;
    if (n == 1 || n == 0) return 0;
    if (r > n / 2) return ncr(n, n - r); 
    long long res = 1; 

    for (int k = 1; k <= r; ++k) {
        res *= n - k + 1;
        res /= k;
    }

    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> a(n), freq(n+1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        freq[a[i]]++;
    }
    long long total = 0;
    vector<long long> possibilities(n+1);
    for (int i = 1; i <= n; i++) {
        if (freq[i] > 0) {
            possibilities[i] = ncr(freq[i], 2);
            total += possibilities[i];
        }
    }
    for (int i = 0; i < n; i++) {
        long long temp = total - possibilities[a[i]];
        temp += ncr(freq[a[i]]-1, 2);
        cout << temp << endl;
    }
    return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>
int main(){
  char ch[1200];
  int counter[26]={};
  int i=0;
  int num=0;
  while(scanf("%c",&ch[i])!=EOF){
    if(ch[i]>='A'&&ch[i]<='Z'){
      num=ch[i]-'A';
      counter[num]++;
    }else if(ch[i]>='a'&&ch[i]<='z'){
      num=ch[i]-'a';
      counter[num]++;
    }
  }
  num=0;
  for(i='a';i<='z';i++){
    printf("%c : %d\n",i,counter[num]);
    num++;
  }
  return 0;
}



Measured memory_bytes: 2032
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

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

    cout << (N+1)/2 << endl;
    
    return 0;
}

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

int main()
{
    int S, h, m, s;
    cin >> S;
    h = S / 3600;
    m = S % 3600 / 60;
    s = S % 3600 % 60;

    cout << h << ":" << m << ":" << s << endl;

    return 0;
}


Measured memory_bytes: 3120