akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
const int INF = 1<<29;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var)  std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(int i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(int i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline bool isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

class L{
public:
	int count=1;
	int length=0;
};

int main() {

	int N,M,Q;
	cin >> N >> M >> Q;
	vector<vector<int>> v(N,vector<int>(N,0));
	rep(i,M){
		int t1,t2;
		cin >> t1 >> t2;
		t1--;t2--;
		v[t1][t2]++;
	}

	vector<vector<int> > rui(N+1, vector<int>(N+1, 0));
	for (int i = 0; i < N; ++i)
		for (int j = 0; j < N; ++j)
			rui[i+1][j+1] = rui[i][j+1] + rui[i+1][j] - rui[i][j] + v[i][j];

	vector<int> ans(Q,0);
	rep(i,Q){
		int t1,t2;
		cin >> t1 >> t2;
		t1--;//t2--;

		int c=rui[t2][t2] - rui[t1][t2] - rui[t2][t1] + rui[t1][t1];
		ans[i]=c;
	}

	rep(i,Q)p(ans[i]);


	return 0;
}



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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

lli n,m;
vll a;
vll dp;
vll stick;
vll nm;
vll pr;
vll ans;

int main(){
	cin >> n >> m;
	a = vll(m);
	for(lli i = 0;i < m;i++) cin >> a[i];
	sort(a.rbegin(),a.rend());
	dp = vll(n+1, -1);
	pr = vll(n+1);
	nm = vll(n+1);
	dp[0] = 0;
	stick = vll(10);
	stick[0] = 0;
	stick[1] = 2;
	stick[2] = 5;
	stick[3] = 5;
	stick[4] = 4;
	stick[5] = 5;
	stick[6] = 6;
	stick[7] = 3;
	stick[8] = 7;
	stick[9] = 6;
	for(lli i = 0;i <= n;i++){
		for(lli j = 0;j < m;j++){
			if(i-stick[a[j]] >= 0 && dp[i-stick[a[j]]] >= 0){
				if(dp[i] < dp[i-stick[a[j]]]+1){
					dp[i] = max(dp[i], dp[i-stick[a[j]]]+1);
					pr[i] = i-stick[a[j]];
					nm[i] = a[j];
				}
			}
		}
	}
	for(lli i = n;i > 0;i = pr[i]){
		ans.push_back(nm[i]);
	}
	sort(ans.rbegin(),ans.rend());
	for(lli x : ans) cout << x;
	cout << endl;

}


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

int main() {
    int64_t N, u, v;
    cin >> N >> u >> v;
    u--; v--;

    vector<vector<int64_t>> edges(N);
    for (int64_t i = 0; i < N - 1; i++) {
        int64_t A, B;
        cin >> A >> B;
        A--; B--;
        edges[A].push_back(B);
        edges[B].push_back(A);
    }

    //vから各頂点への距離を求める
    vector<int64_t> cost_from_v(N);
    stack<pair<int64_t, int64_t>> st;
    st.push({ v, -1 });
    cost_from_v[v] = 0;

    while (!st.empty()) {
        pair<int64_t, int64_t> top = st.top();
        st.pop();

        for (int64_t next_node : edges[top.first]) {
            if (next_node == top.second) {
                continue;
            }

            st.push({ next_node, top.first });
            cost_from_v[next_node] = cost_from_v[top.first] + 1;
        }
    }

    //uから各頂点への距離を求める
    vector<int64_t> cost_from_u(N);
    st.push({ u, -1 });
    cost_from_u[u] = 0;

    while (!st.empty()) {
        pair<int64_t, int64_t> top = st.top();
        st.pop();

        for (int64_t next_node : edges[top.first]) {
            if (next_node == top.second) {
                continue;
            }

            st.push({ next_node, top.first });
            cost_from_u[next_node] = cost_from_u[top.first] + 1;
        }
    }

    int64_t ans = 0;
    for (int64_t i = 0; i < N; i++) {
        //高橋君と青木君がiで出会うとする
        if (cost_from_v[i] < cost_from_u[i]
         || edges[i].size() == 1) {
            //iで出会うことがない or それが最善になることはないのでskip
            continue;
        }
        
        ans = max(ans, cost_from_v[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 7936
/***
 *          ___           ___
 *         /\  \         /\  \                                     _____
 *         \:\  \        \:\  \                                   /::\  \       ___           ___
 *          \:\  \        \:\  \                                 /:/\:\  \     /\__\         /\__\
 *      _____\:\  \   ___  \:\  \   ___     ___   ___     ___   /:/ /::\__\   /:/__/        /:/  /
 *     /::::::::\__\ /\  \  \:\__\ /\  \   /\__\ /\  \   /\__\ /:/_/:/\:|__| /::\  \       /:/__/
 *     \:\~~\~~\/__/ \:\  \ /:/  / \:\  \ /:/  / \:\  \ /:/  / \:\/:/ /:/  / \/\:\  \__   /::\  \
 *      \:\  \        \:\  /:/  /   \:\  /:/  /   \:\  /:/  /   \::/_/:/  /   ~~\:\/\__\ /:/\:\  \
 *       \:\  \        \:\/:/  /     \:\/:/  /     \:\/:/  /     \:\/:/  /       \::/  / \/__\:\  \
 *        \:\__\        \::/  /       \::/  /       \::/  /       \::/  /        /:/  /       \:\__\
 *         \/__/         \/__/         \/__/         \/__/         \/__/         \/__/         \/__/
 *
 *      @author      : Dylan Dsouza (dsouzadyn@gmail.com)
 *      @created     : Saturday Feb 16, 2019 23:31:31 IST
 */
#include <bits/stdc++.h>

using namespace std;

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

  double a, b;
  cin >> a >> b;
  cout << std::fixed;
  cout << std::setprecision(10) << a / b << endl;

  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll H, W, ans = 999999;
	std::cin >> H >> W;
	vector<string> s(H);

	rep(i, 0, H) {
		std::cin >> s[i];
	}

	vector<vll> cnt(H, vll(W, 9999999));

	queue<pair<ll, ll>> q;
	q.push(make_pair(0, 0));
	if (s[0][0] == '#') {
		cnt[0][0] = 1;
	}
	else {
		cnt[0][0] = 0;
	}

	vector<pair<ll, ll>> vp(2);
	vp[0] = make_pair(1, 0);
	vp[1] = make_pair(0, 1);

	while (!q.empty()) {
		queue<pair<ll, ll>> r;
		while (!q.empty())
		{
			rep(i, 0, 2) {
				ll x = q.front().second + vp[i].second;
				ll y = q.front().first + vp[i].first;
				ll tmp = cnt[q.front().first][q.front().second];
				if (x < W && y < H) {
					if (s[q.front().first][q.front().second] == '.' && s[y][x] == '#') {
						tmp++;
					}
					if (tmp < cnt[y][x]) {
						cnt[y][x] = tmp;
						r.push(make_pair(y, x));
					}
				}
			}
			q.pop();
		}
		q = r;
	}


	std::cout << cnt[H - 1][W - 1] << endl;
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((int)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


////////////////////////////////////////////////////////

bool g[10][10];

int main() {
    ll n, m; cin >> n >> m;
    rep(i, 0, m){
        ll a, b; cin >> a >> b;
        g[a][b] = 1;
        g[b][a] = 1;
    }
    Vl v = {};
    ll cnt = 0;
    Rep(i, 1, n) v.push_back(i);
    // Rep(i, 1, n){
    //     Rep(j, 1, n) cout << g[i][j] << " ";
    //     cout << endl;
    // }
    do{
        bool f = true;
        rep(i, 0, sz(v)-1){
            if(!g[v[i]][v[i+1]]) f = false;
        }
        if(f) cnt++;
    }while(next_permutation(v.begin()+1, v.end()));
    co(cnt);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<list>
#include<algorithm>
#include <ctype.h>
#include<deque>
using namespace std;
using ll = long long int;

constexpr ll MOD = ll(1e9) + 7;
int n;
string s;
ll ret = 0;
ll dp[100001][13];

int main(void) {
	cin >> s;
	n = s.size();
	dp[0][0] = 1;
	for (int i = 0; i < n; i++) {
		if (s[i] == '?') {
			for (int j = 0; j < 10; j++) {
				for (int k = 0; k < 13; k++) {
					dp[i + 1][(k * 10 + j) % 13] += dp[i][k];
					dp[i + 1][(k * 10 + j) % 13] %= MOD;
				}
			}
		}
		else {
			int tmp = s[i] - '0';
			for (int k = 0; k < 13; k++) {
				dp[i + 1][(k * 10 + tmp) % 13] += dp[i][k];
				dp[i + 1][(k * 10 + tmp) % 13] %= MOD;
			}
		}
	}
	ret = dp[n][5];
	cout << ret << endl;
	return 0;

}

Measured memory_bytes: 10624
/** coder Mohammad Al-Hussein *_^ */
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define mp make_pair
#define All(v) v.begin(),v.end()
#define mod  1000000007
#define write freopen("output.txt","w",stdout)
#define read freopen("test (1).txt","r",stdin)
#define FIO std::ios_base::sync_with_stdio(false);
using namespace std;





int main()
{
    int cnt[10]={};
    int a,b,c;
    cin >> a >> b >> c;
    cnt[a]++;
    cnt[b]++;
    cnt[c]++;
    
    if(cnt[5] == 2 && cnt[7] == 1)
        cout << "YES\n";
    else cout << "NO\n";
    





    return 0;
}














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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////

const ll inf = 1LL<<60;

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

  rep(i, n) {
    if (a[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = 1;
  rep(i, n) {
    if (a[i] > 1000000000000000000 / ans) {
      cout << -1 << endl;
      return 0;
    }
    ans *= a[i];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3992
S = input()
A = []
tmp = ""
for i in S:
    if i == "/":
        A.append(int(tmp))
        tmp = ""
    else:
        tmp += i

A.append(int(tmp))
m = A[1]
d = A[2]

if m <= 4:
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 38384
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func increment(bits []bool) bool {
	i := 0
	for i < len(bits) && bits[i] {
		bits[i] = false
		i++
	}
	if i < len(bits) {
		bits[i] = true
	} else {
		return false
	}
	return true
}

func contains(bits uint, queryBits uint) bool {
	// fmt.Printf("%v %v %b %b %b\n", bits, queryBits, bits, ^queryBits, bits & ^queryBits)
	return (bits & ^queryBits) == 0
}

func compress(b []bool) uint {
	n := len(b)

	queryBits := uint(0)
	for i := n - 1; i >= 0; i-- {
		if b[i] {
			queryBits++
		}
		if i != 0 {
			queryBits = queryBits << 1
		}
	}

	return queryBits
}

func main() {
	scanner.Split(bufio.ScanWords)
	n := nextInt()

	k := nextInt()
	b := make([]bool, n)
	for i := 0; i < k; i++ {
		b[nextInt()] = true
	}

	queryBits := compress(b)

	i := uint(0)
	iMax := uint(math.Pow(2.0, float64(n)))
	nPrinted := uint(0)
	nPrintedMax := uint(math.Pow(2.0, float64(k)))
	for i < iMax {
		if contains(i, queryBits) {
			cache := []string{}
			for j := 0; j < n; j++ {
				if (i & (1 << uint(j))) > 0 {
					cache = append(cache, strconv.Itoa(j))
				}
			}
			if i == 0 {
				fmt.Println("0:")
			} else {
				fmt.Printf("%v: %v\n", i, strings.Join(cache, " "))
			}
			nPrinted++
		}
		i++
		if nPrinted >= nPrintedMax {
			break
		}
	}
}



Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  string S;
  cin >> S;
  if (S.size() == 3)
    REVERSE(S);
  cout << S << endl;
  return 0;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=1e5+5;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

int32_t main()
{
    IOS;
int n,x;
cin>>n>>x;
vector<int> in(n);
int ans=0;
    for (int i = 0; i < n; ++i) {
        cin>>in[i];
        if(in[i]>x)ans+=in[i]-x,in[i]=x;
    }
    FOR(i,1,n-1){
        if(in[i]+in[i-1]>x){
            int t=in[i-1]+in[i]-x;
            ans+=t;
            if(in[i]<t)in[i]=0,t-=in[i];
            else in[i]-=t,t=0;
            in[i-1]-=t;
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1024
import copy
import sys
import numpy as np

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    num_set = set([])
    for i in range(N):
        input_raw = read_func().strip().split()
        val = int(input_raw[0])
        if val not in num_set:
            num_set.add(val)
        else:
            num_set.remove(val)

    print len(num_set)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22372
#include<bits/stdc++.h>
using namespace std;
 
const int N = 1e5+3;
vector<int>v[N];
bool vis[N];
list<int>L;
list<int>::iterator it;
void dfs(int u, bool des)
{
    for(int i=0; i<v[u].size(); ++i)
    {
        int e = v[u][i];
        if(!vis[e])
        {
            if(des) L.push_front(e);
            else L.push_back(e);
            vis[e] = true;
            dfs(e, des);
            return;
        }
    }
}
int main()
{
    int n, m, a, b;
    scanf("%d%d",&n,&m);
    while(m--)
    {
        scanf("%d%d",&a,&b);
        v[a].push_back(b);
        v[b].push_back(a);
    }
    L.push_back(1);
    L.push_back(v[1][0]);
    vis[1] = vis[v[1][0]] = true;
    dfs(1,true);
    dfs(v[1][0], false);
    printf("%d\n",L.size());
    for(it=L.begin(); it!=L.end(); ++it)
        printf("%d ",*it);
    printf("\n");
    return 0;
}


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

int main()
{
	bool a[10] = {0};
	int n, k;
	cin >> n >> k;
	while (k--)
	{
		int num;
		cin >> num;
		a[num] = 1;
	}
	for (int i = n; ; i++)
	{
		int tmp = i, flag = 1;
		while (tmp)
		{
			if (a[tmp%10])
			{
				flag = 0;
				break;
			}
			tmp /= 10;
		}
		if (flag)
		{
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  long long x, y;
  cin >> x >> y;
  int n, m;
  int ans;
  n = min(x,y);
  m = max(x,y);
  while(true){
    m = m % n;
    if( m == 0) {
      ans = n;
      break;
    }
    n = n % m;
    if(n == 0){
      ans = m;
      break;
    }
  }
  cout << ans << endl;
}


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

using namespace std;

int sum(int A,int D){
    int i=0;
    while(i*A+1<=D){
        i++;
    }
    return i;
}
int main(){
   int N ,D,X;
   int ans = 0;
   cin >> N >> D >> X;
   vector<int> A(N);
   for(int i=0;i<N;i++){
       cin >> A.at(i);
   }
   for(int i=0;i<N;i++){
       ans += sum(A.at(i),D);
   }
   cout << ans + X << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
print((2**m) * (1900*m + 100*(n-m)))

# unit = 1900*m + 100*(n-m)
# p = 1 / (2**m)
# r = 1 - p
# ans / p = 1*1 + 2*r + 3*(r**2) + 4*(r**3) + ...
# ans * r / p = 1*r + 2*(r**2) + 3*(r**3) + 4*(r**4) + ...
# (ans / p) - (ans * r / p) = 1 + r + r**2 + r**3 + r**4 + ...
# (ans / p) * (1 - r) = 1 / (1 - r)
# ans = 1 / p = 2**m
# answer = ans * unit

Measured memory_bytes: 9164
#abc 145 C
n = int(input())
coor = [] # 各町の座標
dis_ij = []# 各町の距離を格納

for i in range(n):
    x,y = map(int, input().split())
    coor.append((x,y))
    
def dis_2point(s,k):
    return ((s[0] -k[0])**2 + (s[1] - k[1])**2)**0.5

for i in range(n):
    for j in range(i):
        dis_ij.append(dis_2point(coor[i], coor[j]))
print(sum(dis_ij) * 2/n)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i < n; ++i)
#define count(arr) (sizeof(arr) / sizeof((arr)[0]))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)
ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
  // input
  int n; cin>>n;
  vector<vector<int>> a(n,vector<int>(n-1));
  rep(i,n) {
    rep(j,n-1) {
      cin>>a[i][j];
      a[i][j]--;
    }
    reverse(a[i].begin(),a[i].end()); // 末尾からpopさせるため
  }

  // initialize
  vector<pii> q;

  auto check=[&](int i){
    if (a[i].size()==0) return; // もう戦う相手がいないなら何もしない
    int j=a[i].back(); // back: a[i]の末尾の要素の参照を返す
    if (a[j].back()==i) { // 対戦可能かの判断
      if (i>j) swap(i,j);
      q.pb(pii(i,j)); // 重複を許容してpushする
    }
  };

  rep(i,n) check(i); // 最初は全員をcheckして可能な試合をstackする

  // iterate
  int day=0;
  while(q.size()>0){
    day++;
    sort(q.begin(),q.end());
    q.erase(unique(q.begin(),q.end()), q.end()); // 許容した重複を消す
    vector<pii> prevQ;
    swap(prevQ,q); // prevQ: 消化する試合 q: 明日の試合をstackする
    for(pii p:prevQ){ // 試合を消化していく
      int i=p.fi, j=p.se;
      a[i].pop_back();
      a[j].pop_back();
    }
    for(pii p:prevQ){ // 翌日の試合をstackする
      int i=p.fi, j=p.se;
      check(i); check(j);
    }
  }
  // 試合が全て行われたかを確認
  rep(i,n){
    if(a[i].size()){
      cout<<-1<<endl;
      return 0;
    }
  }
  cout<<day<<endl;
  return 0;
}


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

using namespace std;

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

	int n,in;
	long long ans = 0;
	cin >> n;

	vector<int> a(n),b(n);
	vector<int> ma(n),mb(n);

	for (int i = 0;i < n;i++){
		cin >> a[i];
	}	
	for (int i = 0;i < n;i++){
		cin >> b[i];
	}

	long long cnt = 0;

	for (int k = 0;k <= 28;k++){
		long long t = pow(2,k);
		for (int i = 0;i < n;i++){
			ma[i] = a[i] % (2*t);
			mb[i] = b[i] % (2*t);
		}
		sort(mb.begin(),mb.end());
		for (int i = 0;i < n;i++){
			cnt += lower_bound(mb.begin(),mb.end(),2*t-ma[i]) - lower_bound(mb.begin(),mb.end(),t-ma[i]) +
						 mb.end() - lower_bound(mb.begin(),mb.end(),3*t-ma[i]);
		}
		if (cnt%2 == 1) ans += t;
		cnt = 0;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;

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 euclid_gcd(int x, int y)
{
    int r = 0;
    if (x > y)
    {
        swap(x, y);
    }
    while ((r = x % y))
    {
        x = y;
        y = r;
    }
    return y;
}
int main(){
    int N = 0;
    cin >> N;
    vector<int> A(N);
    int gcd = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        gcd = __gcd(gcd, A[i]);
    }
    cout << gcd << endl;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

#ifndef __MACRO_H__
#define __MACRO_H__

#define all(collection) (collection).begin(), (collection).end()  // begin to end
#define rep(i, begin, end) for (ll i = begin; i < end; i++)       // repeat
#define repr(i, begin, end) for (ll i = begin; end < i; i--)      // repeat reverse
#define size(collection) ((ll) (collection).size())               // collection size

#endif



int main(void)
{
	string s, t; cin >> s >> t;

	ll ans = 0;
	rep(i, 0, size(s))
	{
		if (s[i] == t[i])
			ans++;
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<stack>
#include<cstring>
#include<map>
#include<string>
#define ll long long
#define fori for(i=0;i<n;i++)
#define fori1 for(i=1;i<=n;i++)
const ll mod = 1e9 + 7;
using namespace std;
const int maxn = 1005;
ll dp[1000005];
ll a[1000005];
ll b[1000005];
ll C(ll n, ll m)
{
	ll s = 1;
	if (n < m)
		s = 0;
	else if (n == m || m == 0)
		s = 1;
	else
		for (ll i = 1; i <= m; i++)
			s = s * (n - i + 1) / i;
	return s%mod;
}
ll A(ll n, ll r)
{
	ll ans = 1;
	for (ll i = 0; i < r; i++)
		ans *= n - i;
	return ans % mod;
}
ll qpow(ll l, ll e)
{
	ll ans = 1;
	while (e)
	{
		if (e & 1)ans = (ans * l % mod);
		l = (l * l % mod);
		e >>= 1;
	}
	return ans % mod;
}
int main()
{
	ll i, j, k;
	ll t, sum=0;
	ll x, y, n,m,r,c,d,pos,di1,di2;
	string s,s1,s2;
	cin >> n >> r;
	if (n >= 10)
		cout << r << endl;
	else
		cout << r + 100 * (10 - n) << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

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

    ll N, K;
    cin >> N >> K;
    ll MOD = pow(10, 9) + 7;
    vector<ll> A(N + 1), B(N + 1);
    rep(i, N + 1) {
        A[i] = i;
        B[i] = N - i;
    }

    rep(i, N) {
        A[i + 1] += A[i];
        B[i + 1] += B[i];
    }

    K--;
    ll sum = 0;
    for (int i = K; i < N + 1; i++) {
        if (A[i] > B[i])
            continue;
        sum += ((B[i] - A[i]) + 1);
        sum %= MOD;
    }

    cout << sum << endl;
}

Measured memory_bytes: 6348
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int dy[4]={1,0,-1,0};
int dx[4]={0,1,0,-1};
vector<vector<int>> graph;

bool sort_sec(const pair<int,int> &a,const pair<int,int> &b){
   if(a.second<b.second){
      return true;
   }
   return false;
}

void swap(int *a,int *b){
   int temp=*a;
   *a=*b;
   *b=temp;
}

int main(void){
   long long K,A,B;
   cin>>K>>A>>B;
   long long ans=1;
   long long money=0;
   long long temp=0;
   while(1){
      if(temp==K) break;
      if(money>=1){
         ans+=B*money;
         money--;
      }else{
         if(ans>=A&&(K-temp)>1){
            ans=ans-A;
            money++;
         }else{
            ans++;
         }
      }
      temp++;
   }
   cout<<max(1+K,ans)<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

ll gcd(ll m, ll n){
	if (n == 0)return m;
	return gcd(n, m%n);
}//gcd



int main() {

	ll n, c, k;
	cin >> n >> c >> k;
	vector<ll> t(n);
	rep(i, n)cin >> t[i];
	sort(t.begin(), t.end());
	ll count = 1;
	ll now = t[0];
	ll bus = 1;
	for (int i = 1; i < n; i++) {
		if (t[i]-now > k||count+1>c) {
			bus++;
			now = t[i];
			count = 1;
		}
		else {
			count++;
		}
	}
	cout << bus;
	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main(){
    int a,b,d,r;
    double f;
    scanf("%d%d",&a,&b);
    d = a/b;
    r = a%b;
    f = (double)a/(double)b;
    printf("%d %d %f\n",d,r,f);

    return 0;
}

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

using namespace std;


#define PI 3.14159265
#define int long long



main(){

	char c; cin >> c;


	if(c == 'A'){
		cout << 'T' << endl; return 0;
	}

	if(c == 'T'){
		cout << 'A' << endl; return 0;
	}

	if(c == 'C'){
		cout << 'G' << endl; return 0;
	}

	if(c == 'G'){
		cout << 'C' << endl; return 0;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

const int MaxN = 21;
const int Mod = 1000000007;

int N;
int A[MaxN][MaxN];
int Dp[MaxN][1 << MaxN];
bool Vis[MaxN][1 << MaxN];

inline int add(int x, int y) { return (x += y) >= Mod ? x - Mod : x; }

void init() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i)
    for (int j = 0; j < N; ++j)
      scanf("%d", &A[i][j]);
}

int dfs(int x, int s) {
  if (x == -1) return s == 0;
  if (Vis[x][s] == true) return Dp[x][s];
  Vis[x][s] = true;
  for (int i = 0; i < N; ++i) {
    if (A[x][i] == 0) continue;
    if (s & (1 << i)) {
      int q = s &~ (1 << i);
      Dp[x][s] = add(Dp[x][s], dfs(x - 1, q));
    }
  }
  return Dp[x][s];
}

void solve() {
  printf("%d\n", dfs(N - 1, (1 << N) - 1));
}

int main() {
  init();
  solve();
  return 0;
}

Measured memory_bytes: 203008
import sys

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


def resolve():
    ABC = list(input().split())
    print("YES" if ABC.count("5") == 2 and ABC.count("7") == 1 else "NO")

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9+7;

// 各桁の和
template<typename T>
T digit(T num){
  T sum = 0;
  while(num){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

template<typename T>T gcd(T a,T b){
  if(b == 0)
    return a;
  return gcd(b,a%b);
}
template<typename T>T lcm(T a, T b){
  T g = gcd(a,b);
  return a/g*b; 
}

int main(){
  int n;cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  ll ans = 0;
  
  rep(i,n){
    ll tmp = 0;
    while(a[i] % 2 == 0){
      if(a[i] == 0)break;
      tmp++;
      a[i] /= 2;
    }
    ans += tmp;
  }
  
  print(ans)
  return 0;
}


Measured memory_bytes: 384
import bisect

n = int(input())
nums = [-int(input()) for _ in range(n)]

colors = []
max_val = -1 * (10 ** 10)
for num in nums:
	if num >= max_val:
		colors.append(num)
		max_val = num
	else:
		idx_r = bisect.bisect_right(colors, num)
		colors[idx_r] = num
		max_val = min(colors[-1], max_val)

print(len(colors))



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

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

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

    vector<ll> A(n,0);

    for(int i=0;i<n;++i)    cin>>A[i];

    ll ans = A[0];

    for(int i=1;i<n;++i)    ans = gcd(ans, A[i]);

    cout<<ans<<'\n';

    return 0;
}

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

#define int long long
#define vc vector<char>
#define vi vector<int>
#define vs vector<string>
#define si set<int>
#define pii pair<int,int>
#define SORT(c) sort(c.begin(),c.end())
#define SORTC(c, cmp) sort(c.begin(),c.end(),cmp)
#define mapii map<int,int>
#define pb push_back
#define F first
#define S second
#define rep(i, j, k) for (int i=j;i<k;i++)
#define repb(i, j, k) for (int i=j;i>=k;i--)
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define ar array

using namespace std;

#define fast ios::sync_with_stdio(false); cin.tie(0)

int n, m, k;
const int mxN = 2e5;
int a[mxN + 1], b[mxN + 1];
int ans = 0;

void solve() {
    cin >> n >> m >> k;
    int s = 0;
    rep(i, 0, n) {
        a[i] = s;
        int x;
        cin >> x;
        s += x;
    }
    a[n] = s;
    s = 0;
    rep(i, 0, m) {
        b[i] = s;
        int x;
        cin >> x;
        s += x;
    }
    b[m] = s;

    rep(i, 0, n + 1) {
        auto it = upper_bound(b, b + m + 1, k - a[i]);
        if (it != b) {
            it--;
            ans = max(ans, i + (it - b));
//            cout << i << " " << it - b << endl;
        }
    }
    cout << ans;
}

int32_t main() {
    fast;

    int tt{1};
//    cin >> tt;
    while (tt--) {
        solve();
        cout << endl;
    }
    return 0;

}

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

int main() {
  string s1;
  cin >> s1;
  string s2 = s1;
  int len = s1.length();
  int sum1 = 0;
  int sum2 = 1;
  for (int i = 1; i < len; ++i) {
    if (s1[i-1] == s1[i]){
      sum1 += 1;
      if (s1[i] == '0') s1[i] = '1';
      else s1[i] = '0';
    }
  }
  //cout << s1 << endl;
  if (s2[0] == '0') s2[0] = '1';
  else s2[0] = '0';
  for (int i = 1; i < len; ++i) {
    if (s2[i-1] == s2[i]){
      sum2 += 1;
      if (s2[i] == '0') s2[i] = '1';
      else s2[i] = '0';
    }
  }
  //cout << s2 << endl;
  int sum;
  if (sum1 >= sum2) sum = sum2;
  else sum = sum1;
  cout << sum << endl;
}

Measured memory_bytes: 512
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();
        String[] S = new String[N];
        for(int i = 0; i < N; i++){
            S[i] = sc.next();
        }

        Arrays.sort(S);
        String ans = "";
        for(int i = 0; i < N; i++){
            ans += S[i];
        }

        System.out.println(ans);
    }
}


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

struct Card {
    char suit;
    char value;
};

void bubble(struct Card A[], int N)
{
    for(int i = 0; i < N; i++)
    {
        for(int j = N - 1; j >= i + 1; j--)
        {
            if(A[j].value < A[j - 1].value)
            {
                Card t = A[j];
                A[j] = A[j - 1];
                A[j - 1] = t;
            }
        }
    }
}

void selection(struct Card A[], int N) {
    for (int i = 0; i < N; i++)
    {
        int minj = i;
        for(int j = i; j < N; j++)
        {
            if(A[j].value < A[minj].value)
            {
                minj = j;
            }
        }
        Card t = A[i];
        A[i] = A[minj];
        A[minj] = t;
    }
}

void print(struct Card A[], int N) {
    for(int i = 0; i < N; i++)
    {
        if(i > 0)
            cout << " ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
    for(int i = 0; i < N; i++)
    {
        if(C1[i].suit != C2[i].suit)
            return false;
    }
    return true;
}

int main(){
    int N;
    Card C1[100], C2[100];
    char ch;

    cin >> N;
    for(int i = 0; i < N; i++)
        cin >> C1[i].suit >> C1[i].value;

    for(int i = 0; i < N; i++)
        C2[i] = C1[i];

    bubble(C1, N);
    selection(C2, N);

    print(C1, N);
    cout << "Stable" << endl;
    print(C2, N);
    if(isStable(C1, C2, N)) {
        cout << "Stable" << endl;
    }
    else
    {
        cout << "Not stable" << endl;
    }
    return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    
  
  int main(){
 lint N;
 lint ans=0;
 cin >>N; lint A[N]; map<lint,lint> mp;
 rep(i,N){cin >> A[i];
    mp[A[i]]++;
 }
 for(auto x:mp){
     ans+=x.second*(x.second-1)/2;
 }
 rep(i,N){
        cout<<ans-mp[A[i]]+1<<endl;
 }
  }
  
  
     
  

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

// ガウス除去法 (xor)
ll GaussElimination(vl& v) {
  int n = v.size();
  int idx = 0;
  for (int b = 60; 0 <= b; b--) {
    int x = idx;
    while (x < n && ((v[x] >> b) & 1) == 0) x++;
    if (x == n) continue; // もしbitが1の要素がなければスキップ
    swap(v[idx], v[x]);
    rep(i, n) if ((i != idx) && (((v[i] >> b) & 1) == 1)) v[i] ^= v[idx];
    idx++;
  }
  // 部分集合の最大xor値を返す
  ll mx = 0;
  rep(i, n) mx ^= v[i];
  return mx;
}

void solve() {
  int n;
  cin >> n;
  vl a(n);
  rep(i, n) cin >> a[i];
  ll x = 0;
  rep(i, n) x ^= a[i];
  dump(a);
  ll ans = x;
  dump(x);
  rep(i, n) a[i] &= ~x;
  vl v;
  rep(i, n) v.push_back(a[i]);
  ll m = GaussElimination(v);
  dump(a);
  dump(v);
  dump(m);
  ans += m * 2;
  cout << ans << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 2168
H, W = map(int, input().split())
board = []
for i in range(0, H):
	board.append(input())
ans = 'Yes'
for i in range(0, H):
	for j in range(0, W):
		if board[i][j] == '#':
			flag = True
			for k in range(0, 2):
				nexth = i - 1 + 2*k
				nextw = j - 1 + 2*k
				if 0 <= nexth and nexth < H:
					if board[nexth][j] == '#':
						flag = False
						break
				if 0 <= nextw and nextw < W:
					if board[i][nextw] == '#':
						flag = False
						break
			if flag:
				ans = 'No'
				break
	if ans == 'No':
		break
print(ans)

Measured memory_bytes: 39408
import heapq
N = int(input())
*A, = map(int, input().split())
A.sort()
A.reverse()

ans = 0
hq = [(-A[0], A[0], A[0])]
for a in A[1:]:
    s, n, m = heapq.heappop(hq)
    ans += -s
    heapq.heappush(hq, (-min(a, n), n, a))
    heapq.heappush(hq, (-min(a, m), m, a))
print(ans)


Measured memory_bytes: 147700
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

int dx[8] = { 1,0,0,-1,1,1,-1,-1 };
int dy[8] = { 0,-1,1,0,-1,1,-1,1 };

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

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

    string s, t;
    cin >> s >> t;
    if (t.substr(0, s.size()) == s) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define rrep(i, n) for(int i = (int)(n); i>=0; --i)
struct fast_ios { fast_ios(){cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast_ios_;

int main()
{
    string S;
    int K;
    cin >> K >> S;

    if(S.length()>K)
    {
        S = S.substr(0, K);
        S+="...";
    }

    cout << S << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int ans=INF;
    for(int i=0;i*i*i<=n;i++){
      for(int j=0;j*j<=n-(i*i*i);j++){
	ans=min(ans,i+j+(n-(i*i*i)-(j*j)));
      }
    }
      cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 3056
import Data.List
import Control.Monad

main :: IO ()
main = do
  [n, _] <- words <$> getLine
  d <- concat . words <$> getLine
  print $ minimum $ solve n d

solve :: String -> String -> [Int]
solve l d = do
  let n = read l :: Int
  a <- [n + i | i <- [0..9*n]]
  guard $ null $ intersect (show a) d
  return a


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

  if(h==1 || w==1) cout << 1 << endl;
  else cout << (h*w+1)/ 2 << endl; 


 

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	int n, r;
	cin >> n >> r;
    int ans = r + 100 * max(0, 10-n);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d %d %d",$w,$h,$n);
for ($i=0; $i < $n; $i++)
	fscanf(STDIN, "%d %d %d",$p[$i]['x'],$p[$i]['y'],$p[$i]['a']);

$a1=0; $a2=$w; $a3=0; $a4=$h;
for($i=0; $i < $n; $i++)
{ 
	if($p[$i]['a']==1)
		$a1=max($a1,$p[$i]['x']);
	if($p[$i]['a']==2)
		$a2=min($a2,$p[$i]['x']);
	if($p[$i]['a']==3)
		$a3=max($a3,$p[$i]['y']);
	if($p[$i]['a']==4)
		$a4=min($a4,$p[$i]['y']);
}
$resw=($a2-$a1>=0)?$a2-$a1:0;
$resh=($a4-$a3>=0)?$a4-$a3:0;

echo($resw*$resh);



Measured memory_bytes: 4604
from heapq import*
i=input
def f(x):
 x.sort();s,n,*h=0,len(x)
 while n:
  while x and x[-1][0]>=n:k,l,r=x.pop();heappush(h,(r-l,l,r))
  if h:s+=heappop(h)[1]
  n-=1
 return s+sum(r for*_,r in x+h)
for _ in'_'*int(i()):
 n,x,*y=int(i()),[]
 for _ in'_'*n:
  k,l,r=map(int,i().split())
  if l>r:x+=(k,l,r),
  else:y+=(n-k,r,l),
 print(f(x)+f(y))

Measured memory_bytes: 39732
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;

constexpr int MAXB = 100010;

int main() {
    int N;
    ll K;
    cin >> N >> K;
    vector<ll> cnt(MAXB, 0);
    rep(i, N) {
        int a, b;
        cin >> a >> b;
        cnt[a] += b;
    }
    
    rep(i, MAXB) {
        if (K > cnt[i]) {
            K -= cnt[i];
        } else {
            cout << i << "\n";
            break;
        }
    }
    return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; };

  bool can = true;
  REP(i, n) {
    if (a[i] % 2 == 0) {
      if (a[i] % 3 != 0 && a[i] % 5 != 0) {
        can = false;
      }
    }
  }
  cout << (can ? "APPROVED" : "DENIED") << "\n";
}

Measured memory_bytes: 3572
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    while (sc.hasNext()) {
        val a = Array(6, { sc.nextDouble() })
        val div: Double = a[0]*a[4]-a[1]*a[3]
        var x: Double = (a[4]*a[2]-a[1]*a[5])/div
        var y: Double = (a[0]*a[5]-a[2]*a[3])/div
        if (x == 0.0) x*=x
        if (y == 0.0) y*=y

        println(String.format("%.3f %.3f", x, y))
    }
}


Measured memory_bytes: 26720