akhauriyash/Code-Regression huggingface dataset:
def main():
    n = int(input())
    digits = len(str(n))
    ans = 0
    if digits%2 == 1:
        for i in range(1, digits+1, 2):
            if i ==  digits:
                ans += n - 10**(i-1) + 1
                break
            ans += 9*10**(i-1)
    else:
        for i in range(1, digits+1, 2):
            ans += 9*10**(i-1)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const INF: i64 = 1 << 60;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let D: usize = sc.get();
    let c: Vec<i64> = sc.vec(26);
    let s: Vec<Vec<i64>> = sc.mat(D, 26);
    let mut last = vec![0; 26];
    let mut ans = Vec::new();
    for d in 0..D {
        let mut max_score_d = -INF;
        let mut max_t = 0;
        for t in 0..26 {
            let mut score_d = 0;
            let mut last_d = last.clone();
            score_d += s[d][t];
            last_d[t] = d as i64 + 1;
            for i in 0..26 {
                score_d -= c[i] * (d as i64 + 1 - last_d[i]);
            }
            if max_score_d < score_d {
                max_score_d = score_d;
                max_t = t;
            }
        }
        last[max_t] = d as i64 + 1;
        ans.push(max_t);
    }
    for d in 0..D {
        println!("{}", ans[d] + 1);
    }
}


Measured memory_bytes: 2248
import sys
input = sys.stdin.readline


class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

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

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

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

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    n, m = map(int, input().split())
    abl = []
    for _ in range(m):
        a,b = map(int, input().split())
        abl.append((a,b))

    uf = UnionFind(n)
    ans_r = []
    curr_ans_minus = 0
    for ab in reversed(abl):
        a,b = ab
        if not uf.same(a-1,b-1): 
            a_size = uf.size(a-1)
            b_size = uf.size(b-1)
            curr_ans_minus += (a_size+b_size)*(a_size+b_size-1)//2
            curr_ans_minus -= (a_size*(a_size-1)//2 + b_size*(b_size-1)//2)
            uf.union(a-1,b-1)
        ans_r.append(curr_ans_minus)


    all_sum = n*(n-1)//2
    for v in reversed(ans_r[:-1]):
        print(all_sum-v)
    print(all_sum)

if __name__ == "__main__":
    main()

Measured memory_bytes: 24520
// All Heil Fire Lord Zuko

#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define PB push_back
#define debug(x) cerr << #x << " = " << x << endl

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

typedef long long ll;
typedef long double ld;

const int N = 2 * 100 * 1000 + 19;

int32_t main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n;
    string s;
    cin >> n;
    cin >> s;
    if (n >= 3200)
        cout << s;
    else
        cout << "red";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector <int> vi;
#define f first
#define s second
#define FOR(i,s,e) for (ll i = s; i <= (ll)e; i++)
#define DEC(i,s,e) for (ll i = s; i >= e; i--)
#define aFOR(i,s) for (auto i: s)
#define maxn 1001
#define maxx 501
#define INF 1e9
#define pb push_back
#define int ll
int N;
int p[maxn];
int A[maxn];

vi adj[maxn];

int dp[maxn];

int dp2[maxn][maxx];
int B[maxn];
bool vis[maxn];
bool np = 0;
set <int> st;

void dfs(int x){
	if (vis[x] || np){
		np = 1;
		return;
	}
	vis[x] = 1;
	

	dp[x] = INF;
	aFOR(i,adj[x]){
		dfs(i);
	}
	int sm = 0;
	FOR(i,0,adj[x].size()-1){
		B[i] = abs(A[adj[x][i]] - dp[adj[x][i]]);
		sm += min(A[adj[x][i]],dp[adj[x][i]]);
	}
	if (A[x] < sm){
		dp[x] = INF;
		np = 1;
		return;
	}

	st.clear();
	st.insert(0);
	
	FOR(i,0,adj[x].size()-1){
		vi newst;
		
		aFOR(j,st) newst.pb(j);
		aFOR(j,newst) if (j + B[i] <= 5000) st.insert(j+B[i]);
	}
	
	//FOR(i,0,adj[x].size()-1) cout<<B[i]<<' ';
	//cout<<'\n';
		
	
	if (adj[x].empty()) dp[x] = 0;
	else{
		auto it = st.upper_bound(A[x] - sm);
		it--;
		//cout<<*it<<' ';
		dp[x] = - *it + sm;
		
		FOR(i,0,adj[x].size()-1) dp[x] += B[i];
	}
}

int32_t main(){
	cin>>N;
	
	FOR(i,2,N){
		cin>>p[i];
		adj[p[i]].pb(i);
	}

	FOR(i,1,N) cin>>A[i];

	dfs(1);
	

	if (dp[1] == INF || np) cout<<"IMPOSSIBLE";
	else cout<<"POSSIBLE";
}


Measured memory_bytes: 640
#include <iostream>
#include<vector>
#include<algorithm>
#define ll long long
#define pb push_back
#define hu 1000001
#define sc(x) scanf("%lli",&x)
ll M = 1000000000 + 7;
using namespace std;
vector<ll>vec[hu],sad(hu),arr(hu);
ll n,fac[hu+3],inv[hu+3];
ll mod(ll xx, ll yy)
{
    return (xx*yy)%M;
}
void dfs2(ll par,ll node)
{   ll k =n-sad[node];
    arr[node] = mod(inv[k],mod(sad[node],arr[par]));
    for( auto it=vec[node].begin();it!=vec[node].end();it++)
    {   auto It=*it;
        if(par!=It)
        {
            dfs2(node,It);
        }
    }
}
void dfs(ll par,ll node)
{
    sad[node]=1;
   for( auto it=vec[node].begin();it!=vec[node].end();it++)
    {   auto It=*it;
        if(par!=It)
        {
            dfs(node,It);
            sad[node] =sad[It]+sad[node];
        }
    }
}

void precal()
{
    fac[0]=1;
    fac[1]=1;
    inv[1]=1;
    for( int i = 2;i<=n;i++)
    {
        inv[i] = mod(inv[M%i],(M-M/i));
        fac[i] = mod(i,fac[i-1]);
    }
}

void solve()
{
    sc(n);
    for( int i=1;i<n;i++)
    {
        ll adi,meg;
        sc(adi);
        sc(meg);
        vec[adi].pb(meg);
        vec[meg].pb(adi);
        
    }
 
    ll node=1,par=0;
    precal();
    dfs(par,node);
    arr[node] = fac[n];
    for(int i=1;i<=n;i++)
    {
        arr[node]= mod(inv[sad[i]],arr[node]);
    }

    for( auto it : vec[node])
    {
        dfs2(node,it);
    }
   
    ll ind=-1,answer=-1;
	for (int i = 1; i <= n; i++)
	{  /* vec[i].clear();
	    if(answer==-1 && ind==-1)
	    {
	        ind=i;
	        answer=arr[i];
	        continue;
	    }
	    if(answer==arr[i])
	    {
	        ind=i;
	        
	    }
	    else if(arr[i]>answer)
	    {
	        ind=i;
	        answer=arr[i];
	    }
	    */
	  cout << arr[i]<<"\n";
	}
	//cout << ind << " "<<answer<<"\n";
	arr.clear();
	sad.clear();
	
}

int main()
{ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //sc(t);
    while(t--) solve();
    
}


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

signed main() {
	int n, l;
	cin >> n >> l;
	vector<int> a(n);
	rep(i, n) {
		a[i] = l + i;
	}
	int s = 0;
	rep (i, n) s += a[i];
	int ans = 1e9;
	rep (i, n) {
		int t = s - a[i];
		if(abs(t - s) < abs(ans - s)) ans = t;
	}
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int m, n, a[100][100], b,i,j;

	scanf("%d %d\n", &n, &m);

	for (i = 0; i < n; i++)
		for (j = 0; j < m; j++) {
			if (j < m - 1)
				scanf("%d ", &a[i][j]);
			else
				scanf("%d\n", &a[i][j]);
		}

	for (j = 0; j < m; j++) {
		scanf("%d", &b);
		for (i = 0; i < n; i++)
			a[i][j] *= b;
	}

	for (i = 0; i < n; i++) {
		b = 0;
		for (j = 0; j < m; j++)
			b += a[i][j];
		printf("%d\n", b);
	}

	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int top=0;
int push(int);
int pop(void);

int main(){

  int x,y,z;
  char d[100];

  while(scanf("%s",d)!=EOF){

    if(d[0]=='+'){
      x=pop();
      y=pop();
      push(y+x);
    }

    else if(d[0]=='-'){
      x=pop();
      y=pop();
      push(y-x);
    }

    else if(d[0]=='*'){
      x=pop();
      y=pop();
      push(y*x);
    }

    else{
      z=atoi(d);
      push(z);
    }

  }

    printf("%d\n",pop());
    return 0;
}

int d[100];

int push(int n){
  d[top++]=n;
  return n;
}

int pop(void){
  return d[--top];
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
	int N, M;
	cin >> N >> M;
	
	int A[100] = {};
	int sum = 0;
	
	for(int i = 0; i < N; i++){
      	int t;
		cin >> t;
	    A[i] = t;
		sum += t;
	}
	
	sort(A, A+N, greater<int>());

	cout << ((sum <= A[M-1] * 4 * M) ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i + 1];
    }
    auto dp = make_v<int>(n + 1, 4);
    fill_v(dp, INF);
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= 3; j++) {     // previous
            for (int k = 0; k <= 3; k++) { // now
                if (k > a[i]) {
                    continue;
                }
                if (j > 0 && a[i] - k < j) {
                    continue;
                }
                if (i == 1) {
                    chmin(dp[i][k], dp[i - 1][j] + a[i] - k);
                } else {
                    chmin(dp[i][k], dp[i - 1][j] + 2 * (a[i] - k));
                }
            }
        }
    }
    int res = INF;
    for (int i = 0; i <= a[n]; i++) {
        chmin(res, dp[n][i] + i);
    }
    cout << res << endl;
}



Measured memory_bytes: 3340
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

int main() {
int n;
while(true){
    cin>>n;if(n==0)break;
    vector<int> v(n);
    int sum=0;
    int  ave=0;
    int ans=0;
    rep(i,n){
        cin>>v[i];
        sum+=v[i];
    }
    ave=(sum)/(n);
    rep(i,n){
        if(ave>=v[i])ans++;
    }
    cout<<ans<<endl;




}
    return 0;
}



Measured memory_bytes: 3128
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;
ll chk[200001] = {0};
ll ans[200001] = {0};

int main(){
  ll x;
  cin >> x;
  ll ans = 0;
  ans += (x/500)*1000;
  x %= 500;
  ans += (x/5)*5;
  printf("%lld\n", ans);
  return 0;
}


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

using namespace std;

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

int adjMatrix[MAX_SIZE][MAX_SIZE];
int done[MAX_SIZE];
vector<int> cur_nodes;
vector<int> cur_stack;

bool findCycle(int cur) {
    cur_stack.push_back(cur);
    if (done[cur])
        return true;
    done[cur] = 1;
    for (auto it : cur_nodes)
        if (adjMatrix[cur][it] && findCycle(it))
                return true;
    cur_stack.pop_back();
    done[cur] = 0;
    return false;
}

bool findAnyCycle() {
    for (auto cur : cur_nodes)
        if (findCycle(cur))
            return true;
    return false;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, a, b;
    cin >> n >> m;
    memset(adjMatrix, 0, sizeof(adjMatrix));
    for (int ctr1 = 0; ctr1 < m; ++ctr1)
        cin >> a >> b, adjMatrix[a - 1][b - 1] = 1;
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
        cur_nodes.push_back(ctr1);

    memset(done, 0, sizeof(done));
    redo:
    if (findAnyCycle()) {
        cur_nodes.clear();
        cur_nodes.push_back(cur_stack.back());
        cur_stack.pop_back();
        while (cur_stack.back() != cur_nodes.front())
            cur_nodes.push_back(cur_stack.back()), cur_stack.pop_back();
        memset(done, 0, sizeof(done));
        cur_stack.clear();
        for (int ctr1 = 0; ctr1 < cur_nodes.size(); ++ctr1) {
            for (int ctr2 = 0; ctr2 < cur_nodes.size(); ++ctr2)
                if (adjMatrix[cur_nodes[ctr1]][cur_nodes[ctr2]] && ctr1 != (ctr2 + 1) % cur_nodes.size()) {
                    swap(cur_nodes[(ctr1 + cur_nodes.size() - 1) % cur_nodes.size()], cur_nodes.back());
                    cur_nodes.pop_back();
                    goto redo;                       
                }
        }
    } else {
        cout << -1;
        return 0;
    }
    cout << cur_nodes.size() << "\n";
    for (auto it : cur_nodes)
        cout << it + 1 << "\n";

    return 0;
}

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

using namespace std;

int main()
{
    vector<int> a(5);
    for(int i=0;i<5;i++) cin >> a[i];
    
    int k;
    cin>>k;

    if(a[4]-a[0]>k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
}

Measured memory_bytes: 256
import math
x=int(input())

def is_prime(x):
    ma = math.ceil(math.sqrt(x))
    for i in range(2,ma+1):
        if x%i==0:
            return False
    else:
        return True

while(1):
    if x==1:
        x+=1
        continue
    elif x==2:
        print(x)
        break
    if is_prime(x):
        print(x)
        break
    x+=1

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
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;
}
ll a[100100];
ll n;
int main(){
    cin>>n;
    ll nowmin=n+1;
    ll sum=0;
    vl ans(n+1);
    map<ll,ll> mp,id;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        mp[a[i]]++;
        if(id.find(a[i])==id.end())id[a[i]]=i;
    }
    mp[0]++;
    for(auto it=--mp.end();;it--){
        if(it==mp.begin())break;
        nowmin=min(nowmin,id[it->fi]);
        sum+=it->se;
        it--;
        ll last=it->fi;
        it++;
        ans[nowmin]+=1ll*(it->fi-last)*sum;
        //cout<<it->fi<< " "<<it->se<<endl;
    }
    for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 15104
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    string s;
    cin>>s;
    int price=700;
    for(int i=0;i<s.length();i++){
        if('o'==s[i]){
            price+=100;
        }
    }
    cout<<price<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    int n, i;
    double sum1=0.00000, sum2=0.00000, sum3=0.00000, sum4=0.00000;
    int x[100], y[100], d[100];
    
    scanf("%d", &n);
    
    for(i=0; i<n; i++){
        scanf("%d", &x[i]);
    }
    for(i=0;  i<n; i++){
        scanf("%d", &y[i]);
        d[i]=x[i]-y[i];
        sum1 += fabs(d[i]);
        sum2 += fabs(d[i])*fabs(d[i]);
        sum3 += fabs(d[i])*fabs(d[i])*fabs(d[i]);
        if(sum4 < fabs(d[i])) sum4 = fabs(d[i]);
    }
    sum2 = pow(sum2, 1.0*1/2);
    sum3 = pow(sum3, 1.0*1/3);
    
    printf("%.6f\n%.6f\n%.6f\n%.6f\n", sum1, sum2, sum3, sum4);
    return 0;
    

}


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

int main(){
    int N,M;
    cin>>N>>M;
    vector<pair<int,int>> in(M);
    for(int i=0; i<M; i++){
        cin>>in[i].second>>in[i].first;
        in[i].second--;
    }

    vector<int> cnt(N,0);
    vector<pair<int,int>> cp;
    map<int,int> ans_on,ans_under;
    cp = in;

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

    for(int i=0; i<M; i++){
        cnt[in[i].second]++;
        ans_on[in[i].first] = in[i].second+1;
        ans_under[in[i].first] = cnt[in[i].second];
    }

    for(int i=0; i<M; i++){
        cout<<setfill('0')<<right<<setw(6)<<ans_on[cp[i].first];
        cout<<setfill('0')<<right<<setw(6)<<ans_under[cp[i].first];
        cout<<endl;
    }

}

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

int main() {
	int A, B, K;
	cin >> A >> B >> K;
	for (int i = 0; i < K; i++) {
		if (A % 2 == 1) A--;
		A /= 2;
		B += A;
		i++;
		if (i >= K) break;
		if (B % 2 == 1) B--;
		B /= 2;
		A += B;
	}
	cout << A << " " << B << endl;
}

Measured memory_bytes: 256
from functools import cmp_to_key

def argsort(arr):
    def cmp(p1, p2):
        x1, y1 = p1
        x2, y2 = p2
        if x1 >= y1 == 0:
            if y2 > 0: return -1
            if y2 < 0: return 1
            if x2 < 0: return -1
            return 0
        if x2 >= y2 == 0:
            if y1 > 0: return 1
            if y1 < 0: return -1
            if x1 < 0: return 1
            return 0
        if y1 == 0: return 1
        if y2 == 0: return -1
        if y1 > 0 and y2 < 0: return 1
        if y2 > 0 and y1 < 0: return -1
        if x1 * y2 > x2 * y1: return -1
        if x1 * y2 < x2 * y1: return 1
        return 0
    return sorted(arr, key=cmp_to_key(cmp))

def dist(x, y):
    return (x**2 + y**2)**0.5

N = int(input())

P = [tuple(map(int, input().split())) for _ in range(N)]
P = argsort(P)

C = [(0, 0)]
for i in range(N):
    C.append((C[-1][0] + P[i][0], C[-1][1] + P[i][1]))

res = 0

for i in range(N):
    for lt in range(N):
        for rt in range(N):
            if lt <= i <= rt:
                x = C[rt + 1][0] - C[lt][0]
                y = C[rt + 1][1] - C[lt][1]
            elif i <= rt < lt or rt < lt <= i:
                x = C[rt + 1][0] + C[N][0] - C[lt][0]
                y = C[rt + 1][1] + C[N][1] - C[lt][1]
            else:
                continue
            res = max(res, dist(x, y))

print(res)

Measured memory_bytes: 44396
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);
	int h1,m1,h2,m2,k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int t0 = h1*60 + m1, t1 = h2 * 60 + m2;
	cout << (t1 - t0 - k) << endl;
	
}

Measured memory_bytes: 3660
import numpy as np

if __name__ == '__main__':
    rows = []
    for i in range(3):
        rows.append([int(i) for i in input().split()])
    mat = np.matrix(rows)

    upper_a = [mat[i, :].max() for i in range(3)]
    upper_b = [mat[:, i].max() for i in range(3)]

    # print(upper_a)
    # print(upper_b)

    for a1 in range(upper_a[0]+1):
        bs = [v - a1 for v in mat[0, :].tolist()[0]]
        # print(bs)
        for a2 in range(upper_a[1]+1):
            vals = [a2 + b for b in bs]
            # print(vals)
            if vals == mat[1, :].tolist()[0]:
                for a3 in range(upper_a[2]+1):
                    vals = [a3 + b for b in bs]
                    if vals == mat[2, :].tolist()[0]:
                        print('Yes')
                        exit(0)

    print('No')


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

using namespace std;
using ll = long long;

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

  string s, t;
  cin >> s >> t;

  if (t.substr(0, s.size()) == s) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }

  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
 
const int INF = (int)1e9;
const int N = 15;
const int M = (1 << N) + 5;
int g[N][N];
int n;
int a[N][M];
int dp[2][M][N];
 
void read()
{
    int m;
    scanf("%d%d", &n, &m);
    for (int i = 0; i < m; i++) {
        int v, u, w;
        scanf("%d%d%d", &v, &u, &w);
        v--;u--;
        g[v][u] = g[u][v] = w;
    }
}
 
void precalc()
{
    for (int mask = 0; mask < (1 << n); mask++) {
        for (int v = 0; v < n; v++) {
            if ((mask >> v) & 1) {
                a[v][mask] = INF;
                continue;
            }
            a[v][mask] = 0;
            for (int u = 0; u < n; u++) {
                if (((mask >> u) & 1) == 0) continue;
                a[v][mask] += g[v][u];
            }
        }
    }
}
 
void brute(int v, int our, int cost, int mask, int V) {
    if (v == n) {
        dp[0][mask | our][V] = min(dp[0][mask | our][V], cost);
        return;
    }
    brute(v + 1, our, cost, mask, V);
    if ((mask >> v) & 1) return;
    if (v == V) return;
    brute(v + 1, our | (1 << v), cost + a[v][mask], mask, V);
    return;
}
 
int main()
{
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
 
    read();
    precalc();
 
    for (int mask = 0; mask < (1 << n); mask++)
        for (int v = 0; v < n; v++)
            dp[0][mask][v] = dp[1][mask][v] = INF;
    dp[1][0][0] = 0;
 
    for (int mask = 0; mask < (1 << n); mask++) {
        
        for (int v = 0; v < n; v++) {
            if (dp[0][mask][v] == INF) continue;
            for (int u = 0; u < n; u++) {
                if ((mask >> u) & 1) continue;
                if (g[v][u] == 0) continue;
                dp[1][mask][u] = min(dp[1][mask][u], dp[0][mask][v] + a[u][mask] - g[v][u]);
            }
        }
 
        for (int v = 0; v < n; v++) {
            if (dp[1][mask][v] == INF) continue;
            brute(0, 1 << v, dp[1][mask][v], mask, v);
        }
 
    }
 
    printf("%d\n", dp[0][(1 << n) - 1][n - 1]);
 
    return 0;
}


Measured memory_bytes: 6016
n = int(input())
a = list(map(int, input().split()))
st = [0] * 10
extra = 0
for x in a:
    if x >= 3200:
        extra += 1
        continue
    for i in range(0, 2801, 400):
        if i <= x <= i + 399:
            st[i // 400] = 1
            break
ans = sum(st)
print(max(ans, 1), ans + extra)


Measured memory_bytes: 3060
N, M, K = map(int, input().split())
f = 0
for i in range(0, N+1):
  if N == 2 * i:
    if K == i * M:
      print("Yes")
      f = 1
      break
  elif (K - i * M) % (N - 2 * i) == 0 and 0 <= (K - i * M) // (N - 2 * i) <= M:
    print("Yes")
    f = 1
    break
if f == 0:
  print("No")

Measured memory_bytes: 61984
import java.util.Scanner;

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

		int w, n;
		w = sc.nextInt();
		n = sc.nextInt();

		int[] ans;
		ans = new int[w + 1];

		for (int i = 0; i <= w; i++) {
			ans[i] = i;
		}

		for (int i = 0; i < n; i++) {
			int a, b;
			String[] s = sc.next().split(",");
			a = Integer.parseInt(s[0]);
			b = Integer.parseInt(s[1]);
			int noise;
			noise = ans[a];
			ans[a] = ans[b];
			ans[b] = noise;
		}

		for (int i = 1; i <= w; i++) {
			System.out.println(ans[i]);
		}

	}
}


Measured memory_bytes: 25892
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int i=0,ans,s,st,nd;
    cin>>s;
    nd=s%100;
    st=s/100;
    if((0<st&&st<13)&&(0<nd&&nd<13))
    {
        cout<<"AMBIGUOUS";
    }
    
    else if((0<nd) && (nd<13))
    {
         cout<<"YYMM";
    }
   
    else if((0<st)&&(st<13))
    {
        cout<<"MMYY";
    }
    else
    {
        cout<<"NA";
    }
    return 0;
}

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

int main() {
	int a, b, k;
	cin >> a >> b >> k;

	for ( int i = 1; i <= k; i++ ) {
		if ( i % 2 == 1 ) {
			if ( a % 2 == 1 ) {
				a--;
			}
			a /= 2;
			b += a;
		}

		if ( i % 2 == 0 ) {
			if ( b % 2 == 1 ) {
				b--;
			}
			b /= 2;
			a += b;
		}
	}

	cout << a << ' ' << b << endl;
}


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

int gcd(int a, int b) {
    int c = 2;
    int result = 1;
    
    while (a >= c && b >= c) {
        if (a % c == 0 && b % c == 0) {
            a /= c;
            b /= c;
            result *= c;
        } else {
            c++;
        }
    }
    return result;
}

int main(){
//    cout << fixed << setprecision(10);
    int N;
    cin >> N;
    
    int sum = 0;
    
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            int temp = gcd(i, j);
            for (int k = 1; k <= N; k++) {
                sum += gcd(temp, k);
            }
        }
    }
    
    cout << sum;

    return 0;
}


Measured memory_bytes: 3596
N = int(input())
l=[]
if N==1:
   print(1)
   exit()
for i in range(N):
   a,b=map(int,input().split())
   l.append((a,b))
l2=[]
for i in range(N):
   for j in range(N):
      if i!=j:
         l2.append((l[i][0]-l[j][0],l[i][1]-l[j][1]))
from collections import Counter
l2=max(Counter(l2).values())
print(N-l2)

Measured memory_bytes: 9844
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

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

	for(int i=0; i<S.size(); i++){
		if((i%2==0 && S[i]=='L') || (i%2 && S[i]=='R')){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;


	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
static long[][] memo;
static int N,W;

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
	   N=sc.nextInt();
	   W=sc.nextInt();
	   w=new int[N];
	   v=new int[N];
	   for(int i=0;i<N;i++) {
		   w[i]=sc.nextInt();
		   v[i]=sc.nextInt();
	   }
	   memo=new long[N][W+1];
	   for(long[]a:memo)
		   Arrays.fill(a, -1);
	   dp(0,W);
	//   for(int[]a:memo)
		//   System.out.println(Arrays.toString(a));
	   System.out.println(memo[0][W]);
	}
	static int [] w,v;
	static long dp(int i,int remW) {
		if(remW<0)
			return -inf;
		if(N==i)
			return 0;
		if(memo[i][remW]!=-1)
			return memo[i][remW];
		long leave=dp(i+1,remW);
		long take=0;
	//	if(remW>w[i])
		 take=dp(i+1,remW-w[i])+v[i];
		//System.out.println(take);
		return memo[i][remW]=Math.max(take, leave);
	}
	static final long inf=(long) 1e17;
	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 126548
#include <stdio.h>
#include <string.h>
int main(void){
	int h,w,i;
	scanf("%d %d",&h,&w);
	char c[h][w+1];
	for(i=0;i<h;i++)scanf("%s",c[i]);
	for(i=0;i<h;i++){
		for(int j=0;j<2;j++){
			printf("%s\n",c[i]);
		}
	}
	
	return 0;
}

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

using namespace std;

/**
 *  Name: Chris M. Perez
 *  University: Interamerican University Metro Campus
 *
**/

#define endl '\n'
#define MOD 10e9
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define gcd(x , y) __gcd(x , y)
#define all(x) (x).begin() , (x).end()
#define forn(i , a , b) for(int i=(a);i<(b);i++)
#define forrange(j , a , b) for(int j=(a);j<=(b);j++)
#define nestedforn(i , a , b , j , c , d) for(int i=(a);i<=(b);i++) for(int j=(c);j<=(d);j++)
#define sort_all(x) sort(all(x))
#define zeros_at_beginning(x) __builtin_clz(x)
#define zeros_at_end(x) __builtin_ctz(x)
#define ones(x) __builtin_popcount(x)
#define parity_even_or_odd_ones __builtin_parity(x)

typedef vector<int> vi;
typedef pair<int , int> pii;
typedef tuple<int , int , int> tiii;
typedef vector<pii> vpii;
typedef vector<tiii> vtiii;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long long ll;
typedef long long int lli;

             
inline int input(){
  int n;
  scanf("%d" , &n);
  return n;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);
  cout << fixed;

#ifdef LOCAL_DEFINE
  freopen("input.txt" , "rt" , stdin);
#endif
  
  int n; cin >> n;
  vector<int> v(n);
  forn(i , 0 , n ) cin >> v[i];
  sort_all(v);
  int s = 0;
  forn(i , 0 , (int) v.size() - 1) s += v[i];
  int maxn = *max_element(all(v));
  string ok = (maxn < s) ? "Yes" : "No";
  cout << ok << endl; 
   
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++)
    cin >> a[i];
  for(int i = n-1; i >= 0; i -= 2)
    cout << a[i] << " ";
  for(int i = (n % 2 == 1?1:0); i < n; i += 2)
    cout << a[i] << " ";
  cout << endl;
}

Measured memory_bytes: 2944
a,b = map(int,input().split())
B = format(b,"b")
digit = len(B)
A = format(a,"0"+str(digit)+"b")
def xor(a,b):
    if a and not(b):
        return True
    elif not(a) and b:
        return True
    else:
        return False
ans = 0
for i in range(digit):
    div = 2**(digit-1-i)
    tempa = a%div if A[i] == "1" else 0
    tempb = 1+b%div if B[i] == "1" else 0
    #print("when div is ",div,"\n temp is",tempa%2,tempb%2)
    if div == 1:
        if b-a == 0:
            ans += int(A[i])
        elif A[i] == "1" and ((b-a+1)%4 == 1 or (b-a+1)%4== 2):
            ans += 1
        elif A[i] == "0" and ((b-a+1)%4 == 2 or (b-a+1)%4== 3):
            ans += 1
    elif b-a > div:
        if (tempa+tempb)%2 == 1:
            ans += div
    else:
        if xor(tempa%2 == 1,tempb%2 == 1):
            ans += div
print(ans)

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
#endif
  int n;
  cin>>n;
  cout<<(n-2)*180<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string.h>
#include <string> 
#include <map>
#include <queue>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <cmath>
#define mem0(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,0x3f,sizeof(a))
using namespace std;
typedef long long ll;
typedef long double ld;
const int maxn=200005,inf=0x3f3f3f3f;
const ll llinf=0x3f3f3f3f3f3f3f3f; 

ll a[maxn],sum[maxn];

int main() {
	int i,j,n;
	ll ans;
	scanf("%d",&n);
	sum[0]=0;
	for (i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
		sum[i]=sum[i-1]+a[i];
	}
	ans=abs(sum[n]-2*a[1]);
	for (i=2;i<n;i++) {
		ans=min(ans,abs(sum[n]-2*sum[i]));
	}
	printf("%lld\n",ans);
	return 0;
}

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

int take()
{
    int n;
    scanf("%d",&n);
    return n;

}

ll takes()
{
    ll n;
    scanf("%lld",&n);
    return n;

}
#define M 200005
#define Int take()
#define LL takes()

#define fr(n) for(int i=1;i<=n;i++)
#define rfr(n) for(int i=n;i>=1;i--)
int cas;
#define print printf("Case %d:",++cas)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mk  make_pair
#define fill(x,v) memset(x,v,sizeof x)
using namespace std;

ll solve(ll n,ll k,ll cur){
        if(n<=0) return cur;

        ll ans1= solve(n-1,k,cur*2);
        ll ans2= solve(n-1,k,cur+k);
        return min(ans1,ans2);
}


int main(){
        ll n=LL,k=LL;
        printf("%lld\n",solve(n,k,1));
 return 0;
}



Measured memory_bytes: 256
N = int(input())
S = input()

ans = 0
for i in range(1000):
    s = ["0", "0", "0"]
    s[0] = str(i // 100)
    s[1] = str((i//10) % 10)
    s[2] = str(i % 10)

    ind = 0
    cnt = 0
    while cnt < 3 and ind < N:
        if S[ind] == s[cnt]:
            cnt += 1
        ind += 1

        if cnt == 3:
            ans += 1

print(ans)


Measured memory_bytes: 70908
#include <bits/stdc++.h>
using namespace std;
const int N = 405;
long long a[N], dp[N][N];
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        a[i] += a[i - 1];
    }
    for (int w = 2; w <= n; ++w) {
        for (int l = 1, r; (r = l + w - 1) <= n; ++l) {
            dp[l][r] = LLONG_MAX;
            for (int m = l; m < r; ++m)
                dp[l][r] = min(dp[l][r], dp[l][m] + dp[m + 1][r]);
            dp[l][r] += a[r] - a[l - 1];
        }
    }
    cout << dp[1][n] << endl;
}


Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include <algorithm>

int main(){
  int n;
  int *x;
  std::cin >> n;
  x = new int[n];

  for (int i=0; i<n ;i++){
    std::cin >> x[i];
  }

  int num2 = 0;
  for (int i=0; i<n ;i++){
    int a=x[i];
    while(1){
      if(a%2!=0){
        break;
      }else{
        a = a/2;
        num2 = num2 +1;
      }
    }

  }
  std::cout<< num2 << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define gcd __gcd
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
#define pr(n) printf("%d ",n)
#define out(n) printf("%d\n",n)
#define llin(a) cin >> a
#define llpr(a) cout << a << " "
#define llout(a) cout << a << endl
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define ck printf("continue\n")
#define all(vec) vec.begin(),vec.end()
#define asc(vec) sort(vec.begin(),vec.end())
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define M 1000000007
#define S 60
#define N 200005  //check the limits, man
// read the constraint properly (ll vs int)
typedef long long int ll;
vector<vector<ll> > ad(S);
ll ar[S];
ll v[N];
ll maxxor(int n)
{
    ll x;
    int i,j,a,m;
    rep(i,n)
    {
        x=v[i];
        if(x>0)
            a=log2(x),ad[a].pb(x),ar[a]=max(ar[a],x);
    }
    for(i=S-1;i>=0;i--)
    {
        m=ad[i].size();
        rep(j,m)
        {
            x=(ar[i]^ad[i][j]);
            if(x>0)
                a=log2(x),ad[a].pb(x),ar[a]=max(ar[a],x);
        }
    }
    ll ans=0;
    for(i=S-1;i>=0;i--)
    {
        if((ar[i]^ans)>ans)
            ans^=ar[i];
    }
    return ans;
}
int main()
{
    int n,i,j,a;
    in(n);
    ll net=0;
    ll x,y;
    rep(i,n)
    {
        llin(v[i]);
        net^=v[i];
    }
    x=1;
    for(i=0;i<S;i++,x*=2)
    {
        if(net&x)
        {
            rep(j,n)
                if(v[j]&x)v[j]^=x;
        }
    }
    ll ans=maxxor(n);
    llout(net+2*ans);
}




Measured memory_bytes: 25132
#include<iostream>
#include<string>
using namespace std;int main(){char ch;int n;cin>>n;cin.get(ch);for(int i=0;i<n;i++){string str;while(1){cin.get(ch);if(ch=='\n')break;str+=ch;}while(1){int idx=str.find("Hoshino");if(idx==-1)break;str[idx+6]='a';}cout<<str<<endl;}return 0;}

Measured memory_bytes: 0
import bisect
N, M = (int(i) for i in input().split()) 
PY = [[int(i) for i in input().split()] for i in range(M)] 
D = [[] for _ in range(N)]

for i, (p, y) in enumerate(PY):
  D[p-1].append((y, i))

ans = [None] * M
output = [[] for _ in range(M)]
for i, d in enumerate(D):
  d.sort()
  for k, (y, j) in enumerate(d):
    ans[j] = (i, k)

for i, k in ans:
  print('{}{}'.format(str(i+1).zfill(6), str(k+1).zfill(6)))

Measured memory_bytes: 85848
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<string>

using namespace std;

#define ll long long

int main(){
    int N;
    double sum = 0;
    cin >> N;
    vector<double> x(N);
    vector<string> u(N);
    for(int i = 0; i < N; i++){
        cin >> x[i] >> u[i];
        if(u[i] == "BTC"){
            sum += x[i] * 380000;
        }else{
            sum += x[i];
        }
    } 
    cout << sum << endl;
    
}

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

using namespace std;

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

ll mod = 1e9+7;
  
// 検索タグ
int main() {
	// 入力
	ll N;cin>>N;
	ll a[N];
    REP(i,N)cin>>a[i];
    
	// 解法
	ll ans = 0;
	ll count = 0;
	REP(i,N){
		if (count+1==a[i])count++;
	}
	if (count==0) ans = -1;
	else ans = N - count;

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


Measured memory_bytes: 1792
#include<stdio.h>
double x[22];
double y[22];
int main(){
    double a,b;
    int now=1;
    while(~scanf("%lf,%lf",&a,&b)){
        x[now]=a;
        y[now++]=b;
    }
    x[0]=x[now-1];
    x[now]=x[1];
    double S=0;
    for(int i=1;i<now;i++){
        S+=(x[i+1]-x[i-1])*y[i];
    }
    if(S<0)S=-S;
    printf("%.8lf",S/2.0);
}

Measured memory_bytes: 1084
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>

using namespace std;

int main() {
  long n,a[300000];
  cin >> n;  
  for(int i = 0; i < n; i++)
    cin >> a[i];
  
  long sum = 0;
  for(int i = 1; i < n; i++) {
    if(a[i] < a[i-1]) {
      sum+= a[i-1] - a[i];
      a[i] = a[i-1];
    }
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 5220
#include <bits/stdc++.h>
#define tt this->
#define ll long long
using namespace std;
int main ()
{
double x;
cin>>x;
cout<<round(x/2);

    return 0;
}

/*
▀█████████▄     ▄████████    ▄████████    ▄████████
  ███    ███   ███    ███   ███    ███   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
 ▄███▄▄▄██▀    ███    ███  ▄███▄▄▄▄██▀   ███    ███
▀▀███▀▀▀██▄  ▀███████████ ▀▀███▀▀▀▀▀   ▀███████████
  ███    ██▄   ███    ███ ▀███████████   ███    ███
  ███    ███   ███    ███   ███    ███   ███    ███
▄█████████▀    ███    █▀    ███    ███   ███    █▀
                            ███    ███

*/


Measured memory_bytes: 384
#include<stdio.h>
#include<algorithm>
using namespace std;
int d[30000];

int min(int a,int b){return a<b?a:b;}

int main(){
	int n,m,p;
	scanf("%d %d %d",&n,&m,&p);
	int i;
	for(i=0;i<m;i++)scanf("%d",&d[i]);
	sort(d,d+m);
	for(i=0;i<m;i++){
		d[i+m]=d[i]+n;
		d[i+m*2]=d[i]+n*2;
	}
	int s=upper_bound(d,d+m*3,p+n)-d;
	int ans=min((p+n)-d[s-m],d[s+m-1]-(p+n));
	for(i=0;i<m-1;i++)ans=min(ans,(d[s+i]-(p+n))+(d[s+i]-d[s+i+1-m]));
	for(i=1;i<m;i++)ans=min(ans,((p+n)-d[s-i])+(d[s-i-1+m]-d[s-i]));
	printf("%d\n",ans*100);
	return 0;
}

Measured memory_bytes: 1156
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

struct Edge {
	int to;
	long long cost;

};

void saiki(int now, int from, long long nowcost, vector<vector<Edge>> &edges, vector<long long> &dist) {
	dist[now] = nowcost;

	for (auto edge : edges[now]) {
		if (edge.to == from)
			continue;
		saiki(edge.to, now, nowcost + edge.cost, edges, dist);
	}
}

int main() {
	int n;
	cin >> n;
	vector<vector<Edge>> edges(n);
	for (int i = 0; i < n - 1; i++) {
		int u, v, w;
		cin >> u >> v >> w;
		u--, v--;
		edges[u].push_back({ v, w });
		edges[v].push_back({ u, w });
	}

	vector<long long> dist(n);
	dist[0] = 0;
	saiki(0, -1, 0, edges, dist);
	
	vector<int> ans(n);
	ans[0] = 0;
	for (int i = 0; i < n; i++) {
		ans[i] = dist[i] % 2;
	}

	for (auto t : ans)
		cout << t << endl;


	return 0;
}

Measured memory_bytes: 11136