akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
//#define int long long  ←保留
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
 
int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
 
int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}
 
int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
 
int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
 
/*-------------ここまで---------------------------------------------*/
 
//C++(GCC9.2.1)
 
/*signed*/int main(void) {
  int x;
  cin>>x;
  if(x<1200) cout<<"ABC"<<endl;
  else cout<<"ARC"<<endl;
  return 0;
}

Measured memory_bytes: 3564
//k_tourist
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 500005
#define non __builtin_popcount
#define ml map<ll, ll> 
#define uml unordered_map<ll, ll>
#define ms map<string , ll> 
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define pl pair<ll, ll>
#define vl vector<ll>
#define vll vector<pl>
#define tpl pair<ll, pl>
#define vlll vector<tpl>
#define vs vector<string>
#define pb push_back
#define mk make_pair
#define M_PI 3.14159265358979323846
#define endl '\n'
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define inf ((ll)1e18 + 1)
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define pow powr
#define rep(i,a,b)  for (i=(a);i<(b);i++)
#define nrep(i,a,b) for (i=(a);i>(b);i--)
using namespace std;
 
bool isp[mx];
 
void sv(){
 
	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void bta_de_yarr(){
    
	ll  i, j,n, a[mx], m, od=0;
	cin>>n>>m;
	rep(i, 1, n+1)
	{
        cin>>a[i];
        a[i]/=2;

        if(a[i] & 1)
        od = 1;
    }

    ll l= a[1], fl=0;
    rep(i, 2, n+1){


        l= (a[i]/__gcd(a[i], l))*l;

        if(l > m)
        {
            fl = 1;
            break;
        }
/*
        //l= (a[i]/__gcd(a[i], l))*l;//(l/__gcd(a[i], l));
         ll x= a[i]/__gcd(a[i], l);
        // ll y= l/__gcd(a[i], l);


       // if(l > m)
       if(x > m/l)
        {
            fl = 1;
            break;
        }

        l= x*l;

        //l = x*y;
        */
    }

    ll ans=0;
    if(!fl){

        // // ans= m/l;// - m/(2*l);
        // // ll an= ans/2;
        // // if(ans %2)
        // // an++;

        // // ans= an;
        // // if(l&1 || (!od))
        // // ans= m/l - m/(2*l);

        // ll l1= (l/__gcd(l, 2LL)) *2;

        // ans= m/l - m/l1;

        // // else if(!od)
        // // ans= m/l;
        // // else
        // // {
        // //     ans= 
        // // }


        ll kr= (l/a[1])%2, fg=0;

        rep(i, 2, n+1)
        if((l/a[i])%2 != kr)
        {
            fg= 1;
            break;
        }

        if(!fg){

           // ans= m/l;
            // if(kr){
            //     ans= m/(2*l);
            // }
            // else
            // {
                ans= m/l - m/(2*l);
            //}
            
        }

        

    }

    cout<<ans;
	
	cout<<endl;
}

int main(){
    fst
	ll t;
    t= 1;
	//cin>>t;
    while(t--){
        bta_de_yarr();
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s=scan.nextLine();
		int c=-1,z=0;
		for(int i=0;i<s.length();i++) {
			if(s.charAt(i)=='A' && c==-1) {
				c=i;
			}
			if(s.charAt(i)=='Z') {
				z=i;
			}
		}
		System.out.println(z-c+1);
	}

}


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

#define ll long long

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

    ll n, r;
    cin >> n >> r;
    if(n < 10){
        r += 100*(10-n);
    }
    cout << r << endl;
}

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

using namespace std;
typedef long long ll;
const ll mod = (ll)1e9 + 7;
const ll INF = 1e17;

// a*x - b*y = return value = GCD(a,b). x,y >= 0
ll egcd(ll a, ll b, ll &x, ll &y) { // MINUS B*Y
	if (b == 0) {
		x = 1; y = 0;
		return a;
	}

	ll d = egcd(b, a%b, y, x);
	y = a - x * (a / b) - y;
	x = b - x;
	return d;
}
// modular inverse; works for any mod p (coprime with a)
ll inverse(ll a, ll p=mod) {
	ll x, y;
	egcd(a%p + p, p, x, y);
	return x % p;
}

ll fact[(int)2e5 + 1];
void fillFact() {
	fact[0] = 1;
	for (int i = 1; i < 2e5 + 1; i++) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= mod;
	}
}

//Be sure to fillFact() before using this
//nCk with mod, uses mult inverse
//here assumes mod is prime, otherwise use egcd
ll choose(ll n, ll k) {
	if (k > n) { return 0; }
	ll num = fact[n], denom = fact[k];
	denom *= fact[n - k]; denom %= mod;

	ll multInv = inverse(denom);
	num *= multInv; num %= mod;
	return num;
}

struct edge {
	int u, v; ll w;
	edge() {}
	edge(int _u, int _v, ll _w) :
		u(_u), v(_v), w(_w) {}
};

struct node { vector<edge> edges; };
vector<int> ans;
//Everything is 0-indexed
struct tree {
	vector<node> nodes;
	vector<int> parent, subtreeSize;
	vector<ll> ways;
	int root, n;

	tree(int _n, int _r = 0) : n(_n), root(_r) { nodes.resize(n); parent.resize(n, -1); subtreeSize.resize(n, 1); ways.resize(n, 1); }

	void add_edge(int u, int v, ll w = 1ll) {
		edge e1(u, v, w); edge e2(v, u, w);
		nodes[u].edges.push_back(e1);
		nodes[v].edges.push_back(e2);
	}

	void dfs(int u, int p) {
		vector<ll> allWays, childSubtree;
		for (auto &e : nodes[u].edges) {
			if (e.v == p) { continue; }
			parent[e.v] = u;
			dfs(e.v, u);
			subtreeSize[u] += subtreeSize[e.v];
			allWays.push_back(ways[e.v]);
			childSubtree.push_back(subtreeSize[e.v]);
		}
		if (allWays.empty()) { return; }

		ll res = 1;
		for (int w : allWays) { res *= w; res %= mod; }

		ll prefix = childSubtree[0];
		for (int i = 1; i < childSubtree.size(); i++) {
			ll cur = childSubtree[i];
			prefix += cur;

			res *= choose(prefix, cur);
			res %= mod;
		}

		ways[u] = res;
	}

	void reroot(int u, int p) {
		ans[u] = ways[u];

		for (auto &e : nodes[u].edges) {
			if (e.v == p) { continue; }

			ll prevWaysU = ways[u], prevWaysV = ways[e.v];

			ways[u] *= inverse(ways[e.v]); ways[u] %= mod;
			ways[u] *= inverse(choose(n-1, subtreeSize[e.v])); ways[u] %= mod;
	
			subtreeSize[u] -= subtreeSize[e.v];
			subtreeSize[e.v] += subtreeSize[u];

			ways[e.v] *= ways[u]; ways[e.v] %= mod;
			ways[e.v] *= choose(n-1, subtreeSize[u]); ways[e.v] %= mod;

			reroot(e.v, u);

			ways[u] = prevWaysU; ways[e.v] = prevWaysV;

			subtreeSize[e.v] -= subtreeSize[u];
			subtreeSize[u] += subtreeSize[e.v];
		}
	}
};

int main() {
	fillFact();
	int n; cin >> n;
	tree t(n);
	for (int i = 0; i < n-1; i++) {
		int u, v; cin >> u >> v; u--; v--;
		t.add_edge(u, v);
	}
	ans.resize(n);
	t.dfs(0, -1);
	t.reroot(0, -1);

	for (auto &x : ans) { cout << x << endl; }
}

Measured memory_bytes: 24812
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int count = scanner.nextInt();
        int candies = scanner.nextInt();
        int[] arr = new int[count];
        for (int i = 0; i < count; ++i) {
            arr[i] = scanner.nextInt();
        }

        long[][] dp = new long[count + 1][candies + 1];
        dp[0][0] = 1;
        for (int i = 0; i <= count; ++i) {
            for (int j = 0; j <= candies; ++j) {
                if (i > 0) {
                    dp[i][j] = dp[i - 1][j];
                    if (j > arr[i - 1]) {
                        dp[i][j] += 1000000007 - dp[i - 1][j - arr[i - 1] - 1];
                    }
                    dp[i][j] %= 1000000007;
                }
                if (j > 0) {
                    dp[i][j] += dp[i][j - 1];
                    dp[i][j] %= 1000000007;
                }
            }
        }

        long ans = dp[count][candies];
        if (candies > 0) {
            ans += 1000000007 - dp[count][candies - 1];
        }
        System.out.println(ans % 1000000007);
    }
}


Measured memory_bytes: 127572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char DNA,ans;
  cin >> DNA;
  if (DNA == 'A'){
    ans ='T';
  }else if(DNA == 'T'){
  	  ans = 'A';
  }else if(DNA == 'G'){
  	  ans = 'C';
  }else if(DNA == 'C'){
  	  ans = 'G';
  }
  cout << ans << endl;
}


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

#define int long long int
#define loop(i,s,e) for(int i=s; i<e; i++)
#define endl '\n'
#define vii vector<int>
#define pii pair<int, int>
#define ff first
#define ss second
#define N 100001
#define pb push_back
#define INF LLONG_MAX
#define inf INT_MAX

void INP();

#define bug(...)        __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}
int arr[3001];
int dp[3001][3001][3];

int util(int f, int b, int player){
	if(f>b) return 0;

	if(dp[f][b][player]!=-1) return dp[f][b][player];

	if(player==1){
		int p = arr[f]+util(f+1, b, 3-player);
		int q = arr[b]+util(f, b-1, 3-player);
		return dp[f][b][player] = max(p, q);
	}
	
	int c = util(f+1, b, 3-player)-arr[f];
	int d = util(f, b-1, 3-player)-arr[b];
	return dp[f][b][player] = min(c, d);

}

void alpha()
{	

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

	int n;
	cin>>n;

	loop(i,0,n) cin>>arr[i];

	// for(int i=0; i<n; i++) cout<<arr[i]<<" ";

	// cout<<"hello"<<endl;

	cout<<util(0, n-1, 1)<<endl;
}

int32_t main(){

	ios_base:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//INP();
    int t=1;
	//cin>>t;

  	while(t--) alpha();

	return 0;

}






















inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}
 
 

Measured memory_bytes: 211456
#include <stdio.h>
int main (void){
    int A,N,anc;

    scanf("%d",&N);
    scanf("%d",&A);

    anc = N - (N/500)*500;
    if(anc -A <=0){
         printf("Yes");
    }else{
         printf("No");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

const ll MOD = 1e+9 + 7;

struct data {
  ll prime;
  int power;
  data(ll prime, int power) : prime(prime), power(power) {}
};
vector<data> result;
void factorization(ll N) {
  if(N == 1 || N == 0) return;

  bool first = true;
  int n = N;
  while(n % 2 == 0) {
    if(first) {
      result.push_back(data(2LL, 1));
      first = false;
    } else {
      result[result.size()-1].power++;
    }
    n /= 2;
  }
  first = true;

  for(ll i=3; i<ceil(sqrt(N)); i+=2) {
    while(n % i == 0) {
      if(first) {
	result.push_back(data(i, 1));
	first = false;
      } else {
	result[result.size()-1].power++;
      }
      n /= i;
    }
    first = true;
  }

  if(n != 1) {
    result.push_back(data(n, 1));
  }

  return;
}


#define N_MAX 30
ll fact[N_MAX]; // 階乗
ll inv[N_MAX]; // 逆元
ll power(ll x, int n) {
  ll ans = 1;
  while(n > 0) {
    if((n & 1) == 1) {
      ans = ans * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return ans;
}
void FermatCombination() {
  fact[0] = 1;
  inv[0] = 1;
  for(int i=1; i<N_MAX; i++) {
    fact[i] = (fact[i-1] * i) % MOD;
    inv[i] = power(fact[i], (int)MOD-2) % MOD; // フェルマーの小定理の逆元
  }
}
ll comb(int n, int k) {
  if(2*k > n) k = n-k;
  ll ans = 1LL;
  for(int i=0; i<k; i++) {
    ans *= (n-i) % MOD;
    ans %= MOD;
  }
  return ans * inv[k] % MOD; // フェルマーの小定理
}


int main(){
  FermatCombination();

  int N;
  ll M;
  cin >> N >> M;

  factorization(M);

  ll ans = 1;
  int n = N-1;
  for(int i=0; i<result.size(); i++) {
    int m = result[i].power + n;
    ans *= comb(m, n);
    ans %= MOD;
  }

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


Measured memory_bytes: 256
N,M=gets.split.map(&:to_i)
pys=$<.read.split.map(&:to_i).each_slice(2).with_index.map do |py,i|
    p,y = py
    [p,y,i]
end

ss = []
n = 0
j = 0
pys.sort.each do |p,y,i|
    if n == p
        j += 1
    else
        j = 1
        n = p
    end
    ss << [i, "%06d%06d" % [p,j]]
end
ss.sort.each {|s| puts s[1]}



Measured memory_bytes: 39372
#include <iostream>
#include <cstdio>
#include <cmath>
// #include <stack>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;

int N = 0;
int pos = 0;
vector<int> pre, in, post;

void reconstruction(int s, int e) {
    if (s > e) { return; }
    int root = pre[pos++];
    int m = distance(in.begin(), find(in.begin(), in.end(), root));

    reconstruction(s, m - 1);
    reconstruction(m + 1, e);
    post.push_back(root);
}

int main() {
    int t;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> t;
        pre.push_back(t);
    }
    for (int i = 0; i < N; i++) {
        cin >> t;
        in.push_back(t);
    }
    
    reconstruction(0, N - 1);
    
    for (int i = 0; i < N; i++) {
        if (i != 0) {
            cout << " ";
        }
        cout << post[i];
    }
    cout << endl;

    return 0;
}



Measured memory_bytes: 3164
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

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

int main(){
	std::string s;
	std::cin >> s;
	int cnt = 0;
	REP(i, 0, s.size()) cnt += (s[i]=='p');
	printf("%ld\n", s.size()/2 - cnt);
	return 0;
}



Measured memory_bytes: 3852
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
function next(){return obj.next();}
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
Main();
function Main(){
  var one = nextIntArray();
  var A = one[0];
  var B = one[1];
  myout(A * B / 2);
}


Measured memory_bytes: 7372
#include <stdio.h>
int main(void)
{
int A,B,C;


scanf("%d",&A);
scanf("%d",&B);
scanf("%d",&C);

if(A==B&&A!=C)
printf("Yes");
else if(B==C&&A!=B)
printf("Yes");
else if(A==C&&A!=B)
printf("Yes");
else
printf("No");
return 0;
}

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

using namespace std;

int arr[200005], pos[200005];
int main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> arr[i];
        pos[arr[i]] = i;
    }
    set <int> s;
    long long res = 0;
    for (int i = 1; i <= n; i++) {
        int l = 0, r = n + 1;
        if (s.size() > 0) {
            auto x = s.lower_bound(pos[i]);
            if (*x < pos[i]) {
                x = --s.end();
            }
            if (*x < pos[i]) {
                l = *x;
            } else {
                r = *x;
                if (x != s.begin()) {
                    l = *(--x);
                }
            }
        }
        res += 1LL * i * (r - pos[i]) * (pos[i] - l);
        s.insert(pos[i]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
999
)");
#define cin input
#endif

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

	if(n>999)
		cout << "ABD" << endl;
	
	else
	{
		cout << "ABC" << endl;
	}
	
}

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

int main()
{
  int n;
  int d, x;
  cin >> n;
  cin >> d >> x;
  
  int consumption = n;
  int tmp;
  for (int i = 0; i < n; i ++)
  {
    cin >> tmp;
    consumption += ((d - 1) / tmp);
  }
  
  cout << consumption + x << endl;
}

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

int main()
{
  int N, A, B;
  cin >> N >> A >> B;
  
  if(N * A >= B) {
    cout << B <<endl;
  }
  
  else{
    cout << N * A <<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<int>vis;
vector<int>a;
vector<int>cycle;
long long k;

int main()
{
  int n;
  cin>>n>>k;
  vis.resize(n);
  a.resize(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    a[i]--;
  }
  int s=0;
  while(!vis[s])
  {
      vis[s]=1;
      if(!k)
      {
          cout<<s+1<<endl;
          return 0;
      }
      s=a[s];
      k--;
  }
  int f=s;
  cycle.push_back(f);
  int d=a[s];
  while(d!=f)
  {
      cycle.push_back(d);
      d=a[d];
  }
  int r=cycle.size();
  k+=r;
  long long ans=k%r;
  cout<<cycle[ans]+1<<endl;

  return 0;
}


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

using namespace std;

const int N = 1e5 + 5;

int n, a[N], m;

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    
    int ans = 0;
    for (int i = 1; i <= n; i++) ans += (a[i] >= m);
    cout << ans;
    return 0;
}

Measured memory_bytes: 640
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
AB = [tuple(map(int,input().split())) for i in range(n)]
A = [ai for ai,bi in AB]
B = [bi for ai,bi in AB]
A.sort()
B.sort()
if n % 2 == 0:
  aa = (A[n//2-1]+A[n//2]) # 実際はこれの二分の１
  bb = (B[n//2-1]+B[n//2])
  print(bb-aa+1)

else:
  aa = (A[n//2]) # 実際はこれの二分の１
  bb = (B[n//2])
  print(bb-aa+1)

# print(aa,bb)
# minx,maxx=0,0
# for ai,bi in AB:
#   minx += ai
#   maxx += bi



Measured memory_bytes: 123564
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

// vector 操作  vector<int> data(10,5) 5が10個　data(10) 要素数10
// v.size(), v.empty(), v.insert(itr,値), v.erase(itr) (first,last),
// sort(itr), find(all(x),値),reverse(itr),accumulate(itr,0) 積算,
//v.swap
// stringも同じ itrがただの数字になる
// s.substr(n,m)n番目以降m文字取り出す　erase(n,m)も  s.find
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

// map 操作  map<string,int> mp キー=string 値=int型  pair< , >型
// 代入:mp["abc"]=123  mp.erase(キー)
// itr = mp.begin()のとき　itr->first = key, itr->second = val
// mp.find(key) itrを返す
typedef pair<int,int> P;  //q(p.first,p.second)で定義できる？

// lcm( , ) gcd( , ) 最大公約数　最小公倍数
//if(cin.eof()) break; 入力数が決まってないとき
//ifstream  while(ifs>>data)

// 浮動小数点
// cout << fixed; 以下と組み合わせで小数点以下n桁
// cout << setprecision(n) << 値; n桁表記
// defaultfloat
int main (){
    ll int n;
    cin >> n;
    vector<string> s(n);
    REP(i,n){
        cin >> s[i];
    }

    velli v(0);
    ll int iter=1;
    ll int itermax=1;

    sort(all(s));

    REP(i,n-1){
        if(s[i]== s[i+1]){
            iter += 1;
            if(iter > itermax){
                v.erase(all(v));
                itermax=iter;
                v.pb(i);
            } 
            if(iter == itermax){
                v.pb(i);
            }
        } else {
            iter = 1;
        }
    }
    if(itermax == 1){
        REP(i,n){
            cout << s[i] << endl;
        }
    } else {
    for(int i = 1;i<v.size();i++){
        cout << s[v[i]] << endl;
    }
    }

}

Measured memory_bytes: 14208
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
//ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
//ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
int main() {
	deque<ll> num;
	int K;
	scanf("%d", &K);
	if (K <= 9) {
		printf("%d\n", K);
		return 0;
	}
	rep(i, 1, 10) {
		num.push_back(i);
	}
	K -= 9;
	while(1) {
		ll v = num.front();
		num.pop_front();
		rep(t, -1, 2) {
			if (v % 10 == 9 && t == 1 || v % 10 == 0 && t == -1)continue;
			num.push_back(v * 10 + v % 10 + t);
			if (--K == 0) {
				printf("%lld\n", num.back());
				return 0;
			}
		}
	}
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n)for(unsigned long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main() {
  int n;
  cin >> n;
  if(n==1){
    cout << 1 << endl;
    return 0;
  }
  vector<int>prime(n);
  for(int i=2;i<=n;i++){
    if(i==2){
      prime[1]++;
      continue;
    }
    if(i==3){
      prime[2]++;
      continue;
    }
    int num=i;
    for(int j=2;j<=i;j++){
      while(num%j==0){
        prime[j-1]++;
        num/=j;
      }
    }
  }
  rep(i,n){
    prime[i]++;
    prime[i]%=MOD;
  }
  ll sum = 1;
  rep(i,n){
    if(prime[i]>1){
      sum*=prime[i];
      sum%=MOD;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int countn = 0;

void bubbleSort(int* a, int n) {
	int i, j;
	for ( i = 0; i < n - 1; i++) {
		for (j = n - 1; j >= i + 1; j--) {
			if (a[j-1] > a[j]) {
				swap(a[j-1], a[j]);
				countn++;
			}
		}
	}
}

int main() {

	int n;
	int a[110];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	bubbleSort(a, n);
	for (int i = 0; i < n; i++) {
		cout << a[i];
		if (i < n - 1) cout << ' ';
	}
	cout << endl;
	cout << countn << endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
typedef vector<int> ivec;

const int MOD=1000000007;
int INF=100100100100100;

void solve(){
  int n;cin>>n;
  ivec a(n);rep(i,n)cin>>a[i];
  string s;cin>>s;
  
  ivec basis;
  for(int i=n-1;i>=0;i--){
    for(int x:basis)a[i]=min(a[i],a[i]^x);
    if(a[i]){
      if(s[i]=='1'){
        cout<<1<<endl;
        return;
      }
      basis.pb(a[i]);
    }
  }
  cout<<0<<endl;
}
  
signed main(){
  int t;cin>>t;
  rep(i,t)solve();
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
 
#define pii pair<int, int>
#define endl "\n"
#define int long long
#define F first
#define S second
#define B begin
#define E end
#define RB rbegin
#define RE rend
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
const int INF = 1e9 + 1;
const double EPS = 1e-10;
const ll P = 1e9 + 7;
const int Q = 47;
 
using namespace std;
 
void hello()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}
 
void show(vector<int>& arr)
{
    for (auto i : arr)
        cout << i << " ";
    cout << endl;
}
void show(vector<vector<int>>& arr)
{
    for (auto i : arr)
        show(i);
    cout << endl;
}


signed main()
{
    hello();
    
    int n, k;
    cin >> n >> k;
    vector <int> seq(n);
    for (int i = 0; i < n; ++i)
        cin >> seq[i];
    int maxs = 0, sum = 0;
    for (int i = 0; i < k; ++i)
        sum += seq[i] + 1;
    maxs = sum;

    for (int i = 1; i < n; ++i)
    {
        if (i + k - 1 >= n)
            break;
        sum -= seq[i - 1] + 1;
        sum += seq[i + k - 1] + 1;
        maxs = max(maxs, sum);
    }

    cout << maxs / 2;
    if (maxs % 2)
        cout << ".5";
    cout << endl;

}

Measured memory_bytes: 1792
import java.util.*; 

class Main{
public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
       	int ans=0;
  		int[] a=new int[n];
		for(int c=0;c<n;c++){
    		a[c]=sc.nextInt();
           if(a[c]%2==0){
           	if(a[c]%3==0||a[c]%5==0){
            	ans=0;
            }else{
            	ans=1;
               break;
            }
           }
    	}
    
 	if(ans==0){
    		System.out.println("APPROVED");
    	}else{
     		System.out.println("DENIED");
   	 }

    	
    }
}

Measured memory_bytes: 21844
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            int[] A = in.nextIntArray(N);

            Arrays.sort(A);
            List<Long> list = new ArrayList<>();
            int before = 0;
            for (int i = N - 1; i >= 0; i--) {
                if (before != A[i]) {
                    before = A[i];
                } else {
                    list.add((long) A[i]);
                    before = 0;
                }
                if (list.size() == 2) break;
            }

            long ans = 0;
            if (list.size() == 2)
                ans = list.get(0) * list.get(1);
            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

    }
}



Measured memory_bytes: 36040
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let s: String = read();
    let c: Vec<char> = s.chars().collect();

    let mut tmp = 0;
    let mut i = 0;
    let mut ans: u64 = 0;
    let l = c.len();
    while i < l {
        if c[i] == 'A' {
            tmp += 1;
            i += 1;
        } else if c[i] == 'B' && i + 1 < l && c[i + 1] == 'C' {
            ans += tmp;
            i += 2;
        } else {
            tmp = 0;
            i += 1;
        }
    }
    println!("{}", ans);
}


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
#define each(i, map) for (auto& i : map)

int main()
{
    int N, K; cin >> N >> K;
    vector<int> h(N, 0);
    rep (i, 0, N) cin >> h[i];

    vector<int> dp(N+1, INF);
    dp[0] = 0;
    for (int now = 0; now < N; ++now) {
        for (int next = now+1; next <= min(N, now+K); ++next) {
            dp[next] = min(dp[next], abs(h[now]-h[next])+dp[now]);
        }
    }

    cout << dp[N-1] << endl;
}

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

int main(void) {
    int N, L;
    string input;
    vector<string> words;

    cin >> N >> L;

    while (N--) {
        cin >> input;
        words.push_back(input);
    }

    sort(words.begin(), words.end());

    for (int i = 0; i < words.size(); i++) {
        cout << words[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main(){
    ll N,K;
    cin>>N>>K;
    vector<ll>A(N);
    rep(i,N){
        cin>>A[i];
    }
    for(int i=K;i<N;i++){
        if(A[i-K]<A[i]){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
}

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

int main(){
  int a, b;
  cin >> a >> b;
  int max,min;
  if(a==b){
    cout << a * 2 <<endl;
  }else{
    if(a<b){
      max=b;
      min=a;
    }else{
      max=a;
      min=b;
    }
    cout << max * 2 - 1 <<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
main(){
  int i,j,n,code;
  char cm[7],o,dict[262145];
  for(i=0,scanf("%d",&n);i<n;i++){
    scanf("%s",cm);
    j=code=o=0;
    while(o!='\n'){
      scanf("%c",&o);
      if(o=='A') code+=1*pow(4,j++);
      else if(o=='C') code+=2*pow(4,j++);
      else if(o=='G') code+=3*pow(4,j++);
      else if(o=='T') code+=4*pow(4,j++);
    }
    if(cm[0]=='i') dict[code] = 1;
    if(cm[0]=='f') dict[code] ? printf("yes\n") : printf("no\n");
  }
  return 0;
}

Measured memory_bytes: 496
#include <bits/stdc++.h>
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 INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}

int main()
{
	int h,w,n;
	cin >> h >> w>> n;
	int count=0;
	int at=0;
	vector<int>a(n+1,0);
	vector<int> t(n + 1, 0);
	vector<vector<int>>ans(h+1,vector<int>(w+1,0));
	for(int i=0; i<n;i++){
		cin >>a[i];
		t[i]=a[i]+(i==0?0:t[i-1]);
	}
	for(int a=0;a<h;a++){
		for(int b=0;b<w;b++){
			if(a%2==0){
				ans[a][b]=at+1;
			}else{
				ans[a][w-b-1]=at+1;
			}
			count++;
			if(count >=t[at]){
				at++;
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
		cout << ans[i][j]<<((j==w-1)?"\n":" ");

		}

	}
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>

int compare_int(const void *a, const void *b){
    //クイックソート
    return *(int*)a - *(int*)b;
}

int main(){

    int n;
    scanf("%d",&n);

    int ab[n][2];
    for(int i=0;i<n;i++){
        scanf("%d %d",&ab[i][1],&ab[i][0]); //arrayの0列目についてソートするためab[B][A]と入れている
    }

    //Bの値について行単位でクイックソート
    qsort(ab,n,sizeof(ab[0]),compare_int);

    int sum=0;
    int flag=1;

    for(int i=0;i<n;i++){
        sum+=ab[i][1];
        if(sum>ab[i][0]){
            flag=0;
            break;
        }
    }

    if(flag>0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 3324
N=int(input())
import math
n1=int(math.sqrt(N))

list1=[0 for i in range(N)]

for x in range(1,n1) :
  for y in range(1,n1) :
    for z in range(1,n1) :
      k=x*x+y*y+z*z+x*y+y*z+z*x
      if k<=N :
        list1[k-1]+=1
for item in list1 :
  print(item)

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

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

        int k = scanner.nextInt();
        int n = scanner.nextInt();
        List<Integer> locations = new ArrayList<>();

        int maxDiff = 0;
        int beforeLocation = 0;
        int totalDistance = 0;
        int firstLocation = 0;
        int lastLocation = 0;
        for (int i = 0; i < n; i++) {
            int a = scanner.nextInt();
            locations.add(a);
            if (i == 0) {
                firstLocation = a;
            } else if (i == (n - 1)) {
                lastLocation = a;
            }

            totalDistance += a;
            int diff = a - beforeLocation;
            if (diff > maxDiff) {
                maxDiff = diff;
            }
            beforeLocation = a;
        }

//        if (firstLocation > maxDiff || (k - lastLocation) > maxDiff) {
        if (((k - lastLocation) + firstLocation) > maxDiff) {
            System.out.println(lastLocation - firstLocation);
        } else {
            System.out.println(k - maxDiff);
        }
    }
}


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

int main() {
 int N;
 int A;
  cin >> N >> A;
    if(N/500==0) {cout << "Yes" << endl;}
  else if(N%500<=A) {cout <<"Yes" << endl;}
  else if(N%500>A) {cout << "No" << endl;}

}


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

int main() {
    int n,m,c;
    cin>>n>>m>>c;
    int b[m];
    int ans=0;
    for (int i=0;i<m;i++)
        cin>>b[i];
    for (int i=0;i<n;i++) {
        int sum=c;
        for (int j=0;j<m;j++) {
            int a;cin>>a;
            sum+=a*b[j];
        }
        if (0<sum)
            ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

typedef long long ll;

ll d;
ll c[29];
ll a[369][29];
ll t[369];
ll b[29];
ll b2[29];
ll now[369];
ll ans;
bool vv[369];
ll ans3[369];
double ch1 = 1.4;
double ch2 = 0.3 / 26;

bool g()
{
    ll re = 0;
    for(ll i = 1; i <= 26; i++) b[i] = 0;
    for(ll i = 1; i <= d; i++)
    {
        b[now[i]] = i;
        for(ll j = 1; j <= 26; j++)
        {
            re -= (i - b[j]) * c[j];
        }
        re += a[i][now[i]];
        if(re * (ch1 - ch2 * i) < ans3[i]) return false;
    }
    if(ans < re) {ans = re; return true;}
    else return false;
}

bool f()
{
    ll x = rand() % 26 + 1;
    ll y = rand() % d + 1;
    if(vv[y])
    {
        return g();
    }
    ll ans2 = 0;
    ll t2 = now[y];
    now[y] = x;
    vv[y] = true;
    bool v = false;
    if(rand() % 100 == 0) v = f();
    else v = g();
    if(!v) now[y] = t2;
    vv[y] = false;
    return v;
}

int main()
{
//    freopen("input.txt", "r", stdin);
    srand(time(NULL));
    scanf("%lld", &d);
    for(ll i = 1; i <= 26; i++)
    {
        scanf("%lld", &c[i]);
    }
    for(ll i = 1; i <= d; i++)
    {
        for(ll j = 1; j <= 26; j++)
        {
            scanf("%lld", &a[i][j]);
        }
    }
    ans = 0;
    for(ll i = 1; i <= d; i++)
    {
        ll mx = -4e18, mi = 0;
        for(ll ii = 1; ii <= 26; ii++)
        {
            t[i] = ii;
            ll ans2 = 0;
            ll tt = b[t[i]];
            b[t[i]] = i;
            for(ll j = 1; j <= 26; j++)
            {
                ans2 -= (i - b[j]) * c[j];
            }
            ans2 += a[i][t[i]];
            if(mx < ans2) mx = ans2, mi = ii;
            b[t[i]] = tt;
        }
        t[i] = mi;
        b[t[i]] = i;
        for(ll j = 1; j <= 26; j++)
        {
            ans -= (i - b[j]) * c[j];
        }
        ans += a[i][t[i]];
        now[i] = mi;
        ans3[i] = ans;
    }
    ll k = 0;
    k = 150000;
    while(k--)
    {
        f();
    }
    for(ll i = 1; i <= d; i++) printf("%lld\n", now[i]);
//    printf("\n\n%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3904
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  ui N; cin >> N;
  vector<ull> A(N);
  for(auto& i : A) cin >> i;

  ull ans{};
  for (int i = 0; i < 64; ++i) {
    ull cnt0{}, cnt1{};
    for (const auto& a : A) {
      if ((int)(a >> i) & 0x01) {
        ++cnt1;
      }
      else {
        ++cnt0;
      }
    }
    ull res = 1ULL << i;
    res %= INF;
    res *= cnt0;
    res %= INF;
    res *= cnt1;
    res %= INF;

    ans += res;
    ans %= INF;
  }
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 2560
a,b = map(int,input().split())

def prime_d(n):
 i = 2
 t = []
 while i * i <= n:
  while n % i == 0:
   n /= i
   t.append(i)
  i += 1
 if n > 1:
  t.append(n)
 return t

l = set(prime_d(a))
m = set(prime_d(b))

print(len(l&m)+1)




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

int main(){
	int n; cin >> n;
	string s, t; cin >> s >> t;
	string h;
	for(int i = 0; i < s.size(); i++){
		h += s[i];
		h += t[i];
	}
	cout << h << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int A = Integer.parseInt(sc.next());
		sc.close();
		System.out.println((int) Math.pow(N, 2) - A);
	}

}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

vector<pair<ll, ll> > prime_factor(ll n) {
    vector<pair<ll, ll> > res;
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i != 0) continue;
        ll ex = 0;
        while (n % i == 0) {
            ex++;
            n /= i;
        }
        res.push_back({i, ex});
    }
    if (n != 1) res.push_back({n, 1});
    return res;
}

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

    auto res = prime_factor(n);
    int ans = 0;
    for (auto p : res) {
        int x = p.second;
        int b = 1;
        while (b <= x) {
            x -= b;
            b++;
            ++ans;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3600
class UnionFind:
    def __init__(self, n):
        self.v = [-1] * n

    def find(self, x):
        if self.v[x] < 0:
            return x
        else:
            self.v[x] = self.find(self.v[x])
            return self.v[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return False
        else:
            if self.v[x] > self.v[y]:
                x, y = y, x
            self.v[x] += self.v[y]
            self.v[y] = x
            return True

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

    def size(self, x):
        return -self.v[self.find(x)]


def main():
    import sys
    input = sys.stdin.readline
    N, M = map(int, input().split())

    uf = UnionFind(N)
    for _ in range(M):
        a, b = (int(x) - 1 for x in input().split())
        uf.unite(a, b)

    cnt = 0
    for v in range(N):
        if uf.find(v) == v:
            cnt += 1

    print(cnt - 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10796
Imp = list(map(int, input().split()))
A = Imp[0]
B = Imp[1]
re = 0
if A % 3 == 0:    
    re = 1
if B % 3 == 0:
    re = 1
if (A+B) % 3 == 0:
        re = 1
        
if re ==1:
    print("Possible")
else:
    print("Impossible")

Measured memory_bytes: 3060
#include <map>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
//#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T& a, T b){if (a > b) {a = b; return 1;} return 0;}
  const long long INF = 1LL << 60;

int main(){
  int n = 0;
  cin >> n;
  vector<long long> dp(n);

  vector<long long> h(n);
  rep(i,n) cin >> h.at(i);
  rep(i,dp.size()) dp.at(i) = INF;
  dp.at(0) = 0;
  for(int i = 1; i < n; i++){
    chmin(dp.at(i),dp.at(i-1)+abs(h.at(i)-h.at(i-1)));
    if(i > 1){
      chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
    }
  }
  cout << dp[n-1];
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

template <typename T>
vector<T> eratos(T n){
    vector<T> primeVec;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = false; isPrime[1] = false;
    for(int p = 2; p*p <= n; p++){
        if(isPrime[p]) for(int i = p*2; i <= n; i += p) isPrime[i] = false;
    }
    for(int p = 2; p <= n; p++) if(isPrime[p]) primeVec.push_back(p);
    return primeVec;
}

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

    int n;
    cin >> n;

    vector<int> sosuu_list = eratos(55555);

    for(auto x : sosuu_list){
        if(n <= 0) break;
        if(x % 10 == 1){
            cout << x << " \n"[n == 1];
            n--;
        }
    }
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;
int main(){
	int n;
	int flag = 1;
	string s;
	cin >> n;
	cin >> s;
	if(n%2 == 1){
		flag = -1;
	}else{
		int h = n/2;
		rep(i,n/2){
			if(s[i] != s[n/2+i]) flag = -1;
		}
	}
	if(flag == 1){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}



Measured memory_bytes: 256
import Control.Monad

main = do
    [a,b] <- map read.words<$> getLine :: IO [Int]
    putStrLn $ case (((a+12)`mod`14) , ((b+12)`mod`14)) of
        (a,b) | a>b -> "Alice"
        (a,b) | a<b -> "Bob"
        otherwise -> "Draw"


Measured memory_bytes: 508
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int h, w, n; cin >> h >> w >> n;
	int x = max(h, w);
	cout << (n + x - 1) / x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
	//#include <vector>
	//#include<math.h>
	//#include <algorithm>
#include <functional>
	//#include <numeric>
	//#include<cmath>
#include <stdio.h> 
	//#include <cstdint>
	//#include <string>
	//#include <cstdlib>
	//#define pi 3.14159265359
using namespace std;


	int main() {

		uint64_t a, b;
		cin >> a;
		cin >> b;
		uint64_t tmp;
		uint64_t r;
		uint64_t x;

		x = a * b;

		if (a < b) {
			tmp = a;
			a = b;
			b = tmp;
		}

		r = a % b;
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}

		cout << x / b;

		return 0;

	}

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

int manhattan(int x, int y, int tx, int ty) {
  return abs(x-tx)+abs(y-ty);
}

int main () {
  int n, m; cin >> n >> m;
  int x[n], y[n], tx[m], ty[m];
  for (int i = 0; i < n; i++)
    cin >> x[i] >> y[i];
  for (int i = 0; i < m; i++)
    cin >> tx[i] >> ty[i];
  for (int i = 0; i < n; i++) {
    int ans = 0;
    int best = manhattan(x[i],y[i],tx[0],ty[0]);
    for (int j = 0; j < m; j++) {
      if (best > manhattan(x[i],y[i],tx[j],ty[j])) {
        ans = j;
        best = manhattan(x[i],y[i],tx[j],ty[j]);
      }
    }
    cout << ans+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 256