akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,A,B) for(int i=A;i<B;i++)
#define INF 1000*1000*1000+7

int main(){
    int n; cin>>n;
    int a[n];
    FOR(i,0,n) cin>>a[i];
    sort(a,a+n);
    // FOR(i,0,n) cout<<a[i]<<' '<<endl;
    double mid = (double)a[n-1]/2.0;
    // cout<<mid<<endl;
    double minv = INF;
    int ans;
    for(int i = 0;i<n;i++){
        // minv = min( abs(mid-a[i]), minv );
        // cout<<a[i]<<' '<<abs(mid-a[i])<<endl;
        if( abs(mid-a[i]) < minv ){
            minv = abs(mid-a[i]);
            ans = a[i];
            // cout<<minv<<' ';
        }
    }

    cout <<a[n-1]<<' ' << ans << endl;
    // cout << a[n-1] << endl;



    // FOR(i,0,10) cout << i<<endl;
    // FOR(j,0,10) cout << j<<endl;
    return 0;
}


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

typedef unsigned long long ull;

int bitCount(int bit) {
    if (bit == 0) return 0;
    return bitCount(bit >> 1) + (bit & 1);
}

int main(void) {

    const ull MOD = 1e+9 + 7;
    ull sum = 0;
    ull N;
    vector<ull> A;

    cin >> N;
    A.reserve(N + 1);

    for (ull i = 0; i < N; i++) {
        cin >> A[i];
    }

    for (int i = 0; i < 60; i++) {
        ull n0 = 0, n1 = 0;
        for (int j = 0; j < N; j++) {
            if ((A[j] >> i) & 1) n1++;
            else n0++;
        }
        ull tmp = n0 * n1 % MOD;
        ull d = (1ll << i) % MOD;
        tmp = tmp * d % MOD;
        sum = (sum + tmp) % MOD;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
inline bool p(ll x) {
 if (x<=3){
   return x>1;
  }
  
  if(!(x%2) || !(x%3)){
    return false;
  }
  
  for (ll i = 5; i <= sqrt(x); i += 6) {
    if (!(x %i) || !(x%(i+2))) {
      return false;
    }
  }
  return true;
}
int main() {
  ll x;
  cin>>x;
  for (ll i =x;;++i) {
    if (p(i)) {
      cout <<i;
      return 0;
     }
   }
}


Measured memory_bytes: 256
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  3.14159265  // PI = acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
typedef long long ll;
typedef long double ld;
//template <class Type>
 

inline int D(){
	int t;
	scanf("%d",&t);
	return t;
}
inline ll llD(){
	ll t;
	scanf("%lld",&t);
	return t;
}
 
 
ll MOD=998244353; 
const int N=1e6 + 3 , M=5;
int OO=1e6; 
 
ll n,m,k,T,cnt,SU;
string str,ans;
vector<pair<char,int>> vec;


 
int main(){
	
	cin>>n;
	double x=1.0*n/3.0;
	cout<<fixed<<x*x*x<<endl;
	


}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A,B,m;
  cin >> A >> B >> m;
  vector<int> a(A);
  for(int i=0;i<A;i++) cin >> a.at(i);
  vector<int> b(B);
  for(int i=0;i<B;i++) cin >> b.at(i);
  
  int money=200000;
  
  for(int i=0;i<m;i++){
    int x,y,z;
    cin >> x >> y >> z;
    money=min(money,a.at(x-1)+b.at(y-1)-z);
  }
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  cout << min(money,a.at(0)+b.at(0)) << endl;
}

Measured memory_bytes: 4060
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <set>
#include <queue>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 100005;

int N;
int a[105];

int main()
{
	while(scanf("%d", &N) != EOF)
	{
		int Alice = 0, Bob = 0;
		for(int i = 1; i <= N; i++) scanf("%d", &a[i]);
		sort(a + 1, a + N + 1);
		for(int i = 1; i <= N; i++) {
			if(i & 1) Alice += a[N - i + 1];
			else Bob += a[N - i + 1];
		}
		printf("%d\n", Alice - Bob);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;

const int N = 100 * 1000 + 5;
const long long inf = 1ll * N * N;
int n;
long long e, t;

long long a[N];
long long dp[N];

long long get(int i, int j) {
	return dp[j] + a[i] - a[j] + max(t, 2 * (a[i] - a[j + 1]));
}

int32_t main() {
	cin >> n >> e >> t;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	sort(a + 1, a + n + 1);
	dp[0] = 0;
	int p = 0;
	long long c = inf;
	for (int i = 1; i <= n; i++) {
	/*	while (p < i - 1 && get(i, p + 1) <= get(i, p)) {
	//		cout << "72 " << i << " " << p << " " << get(i, p) << endl;
			p++;
		}
		dp[i] = get(i, p);
	//	cout << "73 " << i << " " << p << " " << dp[i] << endl;*/
		while (2 * (a[i] - a[p + 1]) > t) {
			c = min(c, dp[p] - a[p] - 2 * a[p + 1]);
			p++;
		}
		dp[i] = inf;
		if (p < i) {
			dp[i] = dp[p] + a[i] - a[p] + t;
		}
		dp[i] = min(dp[i], 3 * a[i] + c);
		
	//	cout << "73 " << i << " " << p << " " << dp[i] << endl;
	//	cout << "72 " << get(2, 0) << endl;
	}
	cout << dp[n] + e - a[n];
	return 0;
}



Measured memory_bytes: 5196
from sys import stdin


def main():
    N, X = [int(x) for x in stdin.readline().rstrip().split()]
    L_list = [int(x) for x in stdin.readline().rstrip().split()]

    count = 1
    D = 0

    for L in L_list:
        D = D + L
        if D <= X:
            count += 1
        else:
            break

    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<vector>

#define MAX 105

struct Point{
    int id;
    int d;
    int f;
    bool flag;
    std::vector<int> child;
};

int stack[MAX];
int sp = 0;
int count = 1;

Point p[MAX];

void push(int id){
    if(p[id].flag == false){
        stack[sp++] = id;
        p[id].d = count++;
        p[id].flag = true;
    }
}

void pop(){
    p[stack[--sp]].f = count++;
    //return stack[sp];
}

void dft(int id){
    //std::cout << id << "に対しdft\n";
    push(id);
    int size = p[id].child.size();
    for(int i=0;i<size;i++){
        if(p[p[id].child[i]].flag == false){
            dft(p[id].child[i]);
        }
    }
    pop();
}

int main(){
    int n;
    int size;
    std::cin >> n;
    for(int i=1;i<=n;i++){
        std::cin >> p[i].id >> size;
        for(int j=0;j<size;j++){
            int tmp;
            std::cin >> tmp;
            p[i].child.push_back(tmp);
        }
    }
    for(int i=1;i<=n;i++){
        if(p[i].flag == false){
            dft(i);
        }
    }
    
    for(int i=1;i<=n;i++){
        std::cout << p[i].id << ' ' << p[i].d << ' ' << p[i].f << '\n';
    }
    
    return 0;
}
    



Measured memory_bytes: 3168
#include <iostream>
#define NMAX 200002
using namespace std;
int main(){
  long N,D,x,y,ans = 0;
  cin >> N >> D;
  for(int i = 0; i < N; i++){
    cin >>x >> y;
    if(x*x+y*y <= D*D)ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
s = input()
sn = len(s)

lis_2 = []
for i in range(1 << (sn - 1)):
    lis = [0, sn]
    for j in range(sn - 1):
        if (i >> j) & 1:
            lis.append(j + 1)
    lis = sorted(lis)
    #print(lis)
    sum1 = 0
    for j in range(len(lis) - 1):
        sum1 += int(s[lis[j]:lis[j + 1]])
    lis_2.append(sum1)
#print(lis_2)
print(sum(lis_2))


Measured memory_bytes: 9108
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>

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

  auto maxi = *std::max_element(std::begin(v), std::end(v));
  std::cerr << maxi << std::endl;
  int m = maxi / 2;
  int diff = std::numeric_limits<int>::max();
  int res;
  for (auto&& e : v) {
    if (e == maxi) continue;
    int cur = std::abs(e - m);
    if (cur < diff) {
      res = e;
      diff = cur;
    }
  }
  std::cout << maxi << " " << res << std::endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>

using namespace std;

#define out(v) cout<<v<<"\n"
#define rep(i,n) for(int i=0;i<(n);++i)

using pii = pair<int, int>;

vector<vector<pii>> edge;
vector<int> ans_v;
vector<bool> visited;

void dfs(int s, int par_color) {
  // 親の色と違う色をつける
  int color = 0;
  if (color == par_color)
    ++color;
  visited[s] = true;
  for (const auto& e : edge[s]) {
    if (visited[e.first])
      continue;
    dfs(e.first, color);
    ans_v[e.second] = color;
    ++color;
    if (color == par_color)
      ++color;
  }
}
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; cin >> N;

  edge.resize(N);
  visited.resize(N, false);
  ans_v.resize(N-1);

  rep(i, N-1) {
    int a, b; cin >> a >> b;
    --a; --b;
    edge[a].emplace_back(b, i);
    edge[b].emplace_back(a, i);
  }
  int ans = 0;
  rep(i, N)
    ans = max(ans, (int)edge[i].size());
  cout << ans << endl;

  dfs(0, -1);
  rep(i, N-1) {
    cout << ans_v[i]+1 << endl;
  }

  return 0;
}


Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <algorithm>

int main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	for (int &e : a) std::cin >> e;
	
	std::sort(a.begin(), a.end());
	
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			for (int k = j + 1; k < n; k++) {
				if (a[i] == a[j] or a[j] == a[k]) continue;
				if (a[i] + a[j] > a[k]) ans++;
			}
		}
	}
	
	std::cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 3636
#[allow(unused_imports)]
use itertools::Itertools;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: usize,
        mut xy: [(i64, i64); n],
    }

    for i in 0..n {
        xy[i] = (xy[i].0 + xy[i].1, xy[i].0 - xy[i].1);
    }

    let mnx = xy.iter().map(|(x, _)| x).min().unwrap();
    let mxx = xy.iter().map(|(x, _)| x).max().unwrap();
    let mny = xy.iter().map(|(_, y)| y).min().unwrap();
    let mxy = xy.iter().map(|(_, y)| y).max().unwrap();

    println!("{}", std::cmp::max(mxx - mnx, mxy - mny));
}


Measured memory_bytes: 9004
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define loop(n) FOR(i,0,n)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	vector<LL>a(n);
	vector<LL>b(n);

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

	
	LL cnt = 0;
	LL diff = 0;
	for (int i = n - 1; i >= 0; i--) {
		if ((a[i] + cnt) % b[i] != 0) {
			diff = b[i] - (a[i] + cnt) % b[i];
			cnt += diff;
		}
		
	}

	cout << cnt << endl;
	
	return 0;
}



Measured memory_bytes: 1792
S = input()
T = input()

if len(S) < len(T):
    print('UNRESTORABLE')
else:
    pos = []
    # Sのi文字目をスタートとしたときにマッチするか
    for i in range(len(S)-len(T)+1):
        # print('S[i]', S[i])
        match = True
        for j in range(len(T)):
            # print('-', T[j], S[i+j])
            if T[j] == S[i+j] or S[i+j] == '?':
                pass
            else:
                match = False
        if match:
            pos.append(i)

    # print(pos)
    if len(pos) == 0:
        print('UNRESTORABLE')
    else:
        ans = 'z' * 51
        for pi in pos:
            r = ''
            for j in range(pi):
                if S[j] == '?':
                    r += 'a'
                else:
                    r += S[j]
            r += T
            for j in range(pi+len(T), len(S)):
                if S[j] == '?':
                    r += 'a'
                else:
                    r += S[j]
            ans = min(ans, r)
        print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <stack>
#include <cstdlib>
 
using namespace std;
 
int main()
{
    int a, b;
    string s;
    stack<int> St;
 
    while(cin >> s) {
        if (s == "+") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a+b);
        }
        else if (s == "-") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a-b);
        }
        else if (s == "*") {
            b = St.top(); St.pop();
            a = St.top(); St.pop();
            St.push(a*b);
        }
        else {
            St.push(atoi(s.c_str()));
        }
    }
    cout << St.top() << endl;
 
    return 0;
}

Measured memory_bytes: 3212
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  int n; cin >> n;
  vector<int> a(n), c(9, 0);
  for(int i=0;i<n;i++){
    cin >> a[i];
    a[i] = min(a[i], 3200);
    c[a[i]/400]++;
  }
  int cnt=0;
  for(int i=0;i<c.size()-1;i++){
    if(c[i]>0){cnt++;}
  }
  cout << max(cnt,1) << " " << cnt + c[8] <<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
    	Scanner in = new Scanner(System.in);
    	int i = in.nextInt();
    	for(int j = 0;j < i;j++){
    		int a = in.nextInt();
    		int b = in.nextInt();
    		int c = in.nextInt();
    		a = a * a;
    		b = b * b;
    		c = c * c;
    		if(a == b + c || b == a + c || c == b + a){
    			System.out.println("YES");
    		}
    		else{
    			System.out.println("NO");
    		}
    	}
    }
}

Measured memory_bytes: 23540
def solve(K):
    lun = [0]

    def nextLunlun(arr, d=0):
        arr[d] += 1
        if arr[d] == 10:
            if d + 1 == len(arr):
                arr.append(1)
                arr[d] = 0
                return arr
            else:
                arr = nextLunlun(arr, d + 1)
                arr[d] = arr[d + 1] - 1 if arr[d + 1] > 0 else 0
                return arr
        if d + 1 != len(arr):
            if abs(arr[d] - arr[d + 1]) > 1:
                if arr[d] < arr[d + 1]:
                    arr[d] = arr[d + 1] - 1
                    return arr
                else:
                    arr = nextLunlun(arr, d + 1)
                    arr[d] = arr[d + 1] - 1 if arr[d + 1] > 0 else 0
                    return arr
        return arr

    for _ in range(K):
        lun = nextLunlun(lun)

    ans = 0
    for i in range(len(lun)):
        ans += lun[i] * (10 ** i)

    print(ans)


if __name__ == '__main__':
    K = int(input())
    solve(K)


Measured memory_bytes: 9256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <limits>
#include <numeric>
#include <functional>
#include <map>
#define FOR(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using namespace std;

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

	int N, T,tmp;
	int min=10001;
	vector<int> time;
	vector<int> cost;
	
	cin >> N >> T;

	REP(i, N)
	{
		cin >> tmp;
		cost.push_back(tmp);
		cin >> tmp;
		time.push_back(tmp);
	}

	REP(i, N)
	{
		if (time[i] <= T && cost[i] < min)
		{
			min = cost[i];
		}
	}

	if (min == 10001)
	{
		cout << "TLE" << endl;
	}
	else
	{
		cout << min << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
// #include <cassert>
#include <vector>
#include <algorithm>
#include <climits>

#include <stack>
#include <queue>
// #include <deque>
#include <set>
#include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>

#include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;


typedef long long ll;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
typedef pair<long long, long long> pllll;
typedef pair<long long, int> plli;
typedef pair<int,long long> pill;
typedef vector<vector<long long>> vvll;
typedef vector<vector<long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;

#define emplace_back pb
const char el = '\n';

ll dp[200001][2]; //dp[i][bool] = maximum of choosing floor(i/2) non-adjacent,
//given whether we include the last one (bool=0 means we omit, 1 means we include)
ll oddpref[200001]; //oddpref[5] = a[1]+a[3]+a[5]; oddpref[even] is undefined
ll a[200001]; //the array; may contain NEGATIVE

/*
Edge cases:

does negative affect anything??

*/

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

    int n; cin>>n;


    ll oddtemp = 0;
    for (int i=1; i<=n; ++i) {
        cin>>a[i];
        if (i%2 == 1) {
            oddtemp += a[i];
            oddpref[i] = oddtemp;
        }
    }


    dp[1][0]=0;
    // dp[1][1] = 0; //TECHNICALLY UNDEFINED; MAKE SURE WE DON'T USE IT;

    for (int i = 2; i<=n; ++i) {
        if (i%2==1) {
            //doing an even to odd transition; use SAME # of terms

            ll excludecand = max(dp[i-1][0],dp[i-1][1]);
            ll includecand = a[i] + max(dp[i-2][0],dp[i-2][1]);

            dp[i][0] = excludecand;
            dp[i][1] = includecand;
        } else {

            //doing an odd to even transition; can get 1 extra term;
            //if we EXCLUDE a[i], say a[6], then we must include 3 from a[1:5];
            //this forces us to use 1,3,5;
            //if we INCLUDE a[6], then we do 2 from the first 5, where we don't include
            //the last term;
            ll excludecand = oddpref[i-1];
            ll includecand = a[i] + dp[i-1][0];

            dp[i][1] = includecand;
            dp[i][0] = excludecand;
        }

        // cout<<"max including a["<<i<<"]="<<a[i]<<" equals "<<dp[i][1]<<";  ";
        // cout<<"without equals "<<dp[i][0]<<el;

    }

    cout<< max(dp[n][0],dp[n][1]) << el;

}

Measured memory_bytes: 9880
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

ans = sum(B)

for i in range(1, N):
    if (A[i] - A[i - 1]) == 1:
        ans += C[A[i - 1] - 1]

print(ans)






Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  set<int> check;
  int num=a;
  int end=a%b;
  while(true){
    num+=a;
    if(num%b==c){
      puts("YES");
      return 0;
    }

    if(num%b==end){
      puts("NO");
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[55];
int b[55];
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
        b[i] = a[i];
    }
    sort(b+1,b+1+n);
    int cnt = 0;
    for(int i=1;i<=n;i++)
    {
        if(a[i] != b[i]){
            cnt++;
        }
    }
    if(cnt > 2){
        cout<<"NO"<<endl;
    }else{
        cout<<"YES"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n =int(input())
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    #divisors.sort(reverse=True)
    return divisors

l = make_divisors(n)
ans = float('inf')
for i in l:
    ans = min(ans, i-1+n//i-1)
print(ans)


Measured memory_bytes: 3268
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
	int n;
	while(cin >> n , n){
		int dp[100000] = {0};
		int pos = 0;
		rep(i,n){
			int c; cin >> c;
			if((i+1)%2 == 1){ //odd
				if(dp[pos] == 0){
					if(c)dp[pos]++; else dp[pos]--;
					continue;
				}
				if(c == 1 && dp[pos] > 0){
					dp[pos]++;
				}else if(c == 0 && dp[pos] < 0){
					dp[pos]--;
				}else{
					pos++;
					if(c == 1)dp[pos]++;
					else dp[pos]--;
				}
			}else{
				if(c == 1 && dp[pos] > 0){
					dp[pos]++;
				}else if(c == 0 && dp[pos] < 0){
					dp[pos]--;
				}else{
					if(pos == 0){
						dp[pos] *= -1;
					}else{
						dp[pos-1] -= dp[pos];
						dp[pos] = 0;
						pos--;
					}
					if(c == 1) dp[pos]++;
					else dp[pos]--;
				}
			}
		}
		int sum = 0;
		rep(i,100000){
			if(dp[i] < 0)sum += dp[i];
		}
		cout << -sum << endl;
	}
}

Measured memory_bytes: 1252
#include <cstdio>
int main()
{
    int n, t;
    long long res = 0;
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &t);
        res += t;
    }
    printf("%d\n", (int)(res / n));
    return 0;
}

Measured memory_bytes: 0
import Control.Applicative ((<$>))
import Control.Monad (replicateM, unless, guard, foldM)
import Data.List (sort)

main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    solve <$> sort <$> replicateM n (f <$> map read <$> words <$> getLine) >>= putStrLn
    main
  where f [a, b] = (b, a)
  
solve :: [(Int,Int)] -> String
solve = maybe "No" (const "Yes") . foldM f 0
  where f cw (t, w) = do
          guard $ cw + w <= t
          return $ cw + w



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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.length() / 2; i++) {
    if (s[i] != s[s.length() - 1 - i]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

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

	auto ans = "APPROVED";
	for (auto i = 0; i < N; ++i)
	{
		int A;
		cin >> A;
		if (A % 2 != 0)
		{
			continue;
		}

		if ((A % 3 != 0) && (A % 5 != 0))
		{
			ans = "DENIED";
		}
	}

	cout << ans << endl;

	return 0;
}

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


int main() {
    int n;
    cin >> n;
    map<int,int>mp;
    rep(i,n) {
        int a;
        cin >> a;
        mp[a]++;
    }
    int ans = 0;
    for(auto i : mp) {
        if(i.second%2) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8156
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <climits>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <fstream>

#define pb push_back
#define mp make_pair

using namespace std;

int main(){
    long long int n,p,x = 0,t;
    cin>>n>>p;
    for(int i = 0; i < n; i++){
        cin>>t;
        if(t%2 == 1)x++;
    }
    if(p == 1){
        if(x == 0){
            cout<<0<<endl;
        }else{
            cout<<(1LL<<(n-1))<<endl;
        }
    }else{
      if(x == 0){
        cout<<(1LL<<n)<<endl;
      }else{
        cout<<(1LL<<(n-1))<<endl;
      }
    }
}


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

int n;
const int MAX = 100010;
const long long INF = 1e18;
struct edge{
    int to;
    long long cost;
};
vector<edge> G[MAX];
long long D[MAX];
typedef pair<int, long long> P;

void dijkstra(int s){
    for(int i = 0; i < n; i++){
        D[i] = INF;
    }
    D[s] = 0;
    priority_queue<P, vector<P>, greater<P>> q;
    q.push({s, 0});
    while(!q.empty()){
        P p = q.top();
        q.pop();
        int now = p.first;
        if(D[now] < p.second) continue;
        for(int i = 0; i < G[now].size(); i++){
            edge e = G[now][i];
            if(D[e.to] > D[now] + e.cost){
                D[e.to] = D[now] + e.cost;
                q.push({e.to, D[e.to]});
            }
        }
    }
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n - 1; i++){
        int a, b;
        long long c;
        cin >> a >> b >> c;
        a--; b--;
        G[a].push_back({b, c});
        G[b].push_back({a, c});
    }

    int q, k;
    cin >> q >> k;
    dijkstra(k - 1);

    for(int i = 0; i < q; i++){
        int x, y;
        cin >> x >> y;
        cout << D[x - 1] + D[y - 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 11120
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n, ans2=0;

	cin>>n;

	vi a(n);

	vvi b(29, vi(n));

	rep(i, n) cin>>a[i];

	rep(i, n){
		int tempb;
		cin>>tempb;
		rep(j, 29) b[j][i]=tempb%(2<<j);
	}

	rep(j, 29){
		sort(all(b[j]));
		int ans=0;
		rep(i, n){
			int tempa=a[i]%(2<<j);
			vi::iterator r1, r2, r3, r4;
			r1=lower_bound(all(b[j]), (1<<j)-tempa);
			r2=upper_bound(all(b[j]), (2<<j)-tempa-1);
			r3=lower_bound(all(b[j]), (3<<j)-tempa);
			r4=upper_bound(all(b[j]), (4<<j)-tempa-1);
			ans+=(int)(r2-r1)+(int)(r4-r3);
		}
		if(ans%2) ans2+=(1<<j);
	}
	cout<<ans2<<endl;
}

Measured memory_bytes: 24576
#include "bits/stdc++.h"

#define rep(i,n) for(int i = 0;i<n;i++)
#define vv(Type, n,m,d)vector<vector<Type>> vv(n, vector<Type>(m, d));

using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

	int n, k;
	cin >> n >> k;
	vector<int> a(n+1);
	int j;
	
	for (int i = 1; i <= n; i++){
		cin >> j;
		a[i] += a[i - 1] + j + 1;
		//cout << a[i] << endl;
	}

	long double ans = -1, b;

	for (int i = k; i <= n; i++) {
		b = a[i] - a[i - k];
		ans = max(ans, b);
	}

	printf("%.15Lf\n", ans/2);





	return 0;
}


Measured memory_bytes: 4000
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {
	
	ll N, X;
	cin >> N >> X;
	vll m(N);
	rep(i, N) cin >> m[i];

	X -= accumulate(all(m), 0);
	sort(all(m));
	cout << N + X / m[0] << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main(){
    int a,b;
    scanf("%d %d",&a,&b);
    if(a == 1){
        a = 14;
    }
    if(b == 1){
        b = 14;
    }
    if(a > b){
        printf("Alice\n");
    }else if(a < b){
        printf("Bob\n");
    }else{
        printf("Draw\n");
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
bool comp(pi &a,pi &b){
  return a.first>b.first;
}
int main(){
  int n,h;cin>>n>>h;
  int a[100010],b[100010];
  rep(i,n) cin>>a[i]>>b[i];
  pi p[200010];
  rep(i,n){
    p[i]=mp(a[i],0);
    p[i+n]=mp(b[i],1);
  }
  n*=2;
  sort(p,p+n,comp);
  int res=0,j=0;;
  while(h>0){
    if(p[j].second==1){
      h-=p[j].first;
      res++;
      j++;
    }
    else{
      res+=ceil((double)h/p[j].first);
      break;
    }
  }
  prin(res);
    


  

  return 0;
}


Measured memory_bytes: 2560
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := NewScanner()

	s := sc.ReadString()

	if s[len(s)-1] == 's' {
		fmt.Println(s + "es")
	} else {
		fmt.Println(s + "s")
	}
}

// from [my library](https://github.com/ikngtty/go-contestlib)
// -   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}

	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base, exponent int) int {
	if exponent < 0 {
		panic(fmt.Sprintf("exponent (%d) should not be a minus", exponent))
	}

	answer := 1
	for i := 0; i < exponent; i++ {
		answer *= base
	}
	return answer
}

func Ceil(divident, dividor int) int {
	if dividor == 0 {
		panic("dividor should not be 0")
	}

	quo := divident / dividor
	rem := divident % dividor

	if rem != 0 {
		if (divident > 0 && dividor > 0) ||
			(divident < 0 && dividor < 0) {
			return quo + 1
		}
	}
	return quo
}

// -   sortutil

func ReverseInts(a []int) {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
}

func ReverseStrings(a []string) {
	sort.Sort(sort.Reverse(sort.StringSlice(a)))
}

// -   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}

func (sc *Scanner) ReadFloat() float64 {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.ParseFloat(text, 64)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1776
#include <stdio.h>

int x=0;
int y=0;
int z=0;
int main(void)
{
    int N,Y;
    scanf("%d%d",&N,&Y);
    for(int a=0;10000*a<=Y;a++){
        for(int b=0;5000*b<=Y-a;b++){
                if(10000*a+5000*b+1000*(N-a-b)==Y){
                    x=a;
                    y=b;
                    z=N-b-a;
                }
        }
    }
    if((x==0&&y==0&&z==0)||(x<0||y<0||z<0))
        printf("-1 -1 -1\n");
    else
        printf("%d %d %d\n",x,y,z);
    
    return 0;
}


Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	static class Player implements Comparable<Player>{
		int number;
		double time;

		Player(int number, double time) {
			this.number = number;
			this.time = time;
		}

		Player(Player p) {
			this(p.number, p.time);
		}

		public int compareTo(Player o) {
			return (int)(this.time * 100 - o.time * 100);
		}
	}

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		Player player[] = new Player[24];
		Player toFinal[] = new Player[8];

		for (int i = 0; i < 24; i++) {
			int number = sc.nextInt();
			double time = sc.nextDouble();
			player[i] = new Player(number, time);
		}
		int first, second;
		Arrays.sort(player, 0, 7);
		toFinal[0] = player[0];
		toFinal[1] = player[1];
		Arrays.sort(player, 8, 15);
		toFinal[2] = player[8];
		toFinal[3] = player[9];
		Arrays.sort(player, 16, 23);
		toFinal[4] = player[16];
		toFinal[5] = player[17];
		Player swap = new Player(player[8]);
		player[8] = player[2];
		player[2] = swap;
		swap = new Player(player[9]);
		player[9] = player[3];
		player[3] = swap;
		swap = new Player(player[16]);
		player[16] = player[4];
		player[4] = swap;
		swap = new Player(player[17]);
		player[17] = player[5];
		player[5] = swap;
		Arrays.sort(player, 6, 23);
		toFinal[6] = player[6];
		toFinal[7] = player[7];
		for (int j = 0; j < 8; j++) {
			System.out.println(toFinal[j].number + " " + toFinal[j].time);
		}
	}
}

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

using namespace std;
typedef long long ll;

void solve() {
    ll N, K;
    cin >> N >> K;
    vector<ll> cnt(K);
    for(int i = 1; i <= N; i++) cnt[i % K]++;

    ll ans = 0;
    for(int b = 1; b <= N; b++) {
        int a = (K * N - b) % K; 
        int c = (K * N - b) % K;
        if ((a + c) % K != 0) continue;
        ans += cnt[a] * cnt[c];
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
from itertools import accumulate
n = int(input())
a = list(map(int,input().split()))
aa = list(accumulate(a))
cnt1 = 0
cnt2 = 0
#+はじまり
modify_sum1 = 0
start1 = 1
for ai in aa:
    cur_val1 = (ai + modify_sum1)*start1
    if cur_val1 <= 0:
        cnt1+=1 - cur_val1
        modify_sum1+=(1 - cur_val1)*start1
    start1 *= (-1)
#-はじまり
modify_sum2 = 0
start2 = -1
for ai in aa:
    cur_val2 = (ai + modify_sum2)*start2
    if cur_val2 <= 0:
        cnt2+=1 - cur_val2
        modify_sum2+=(1 - cur_val2)*start2
    start2 *= (-1)
print(min([cnt1,cnt2]))


Measured memory_bytes: 14212
#include <bits/stdc++.h>
#define off  exit( 0 )
#define cn   continue
#define rt   return
#define sc   scanf
#define pr   printf
#define pb   push_back
#define pf   push_front
#define p_f  pop_front
#define p_b  pop_back
#define ff   first
#define ss   second
#define ll   long long
#define ld   long double
#define N    200256
#define M    998244353
#define I    1000000000000000000
#define pdd  pair < ld, ld >
#define pll  pair < ll, ll >
#define pii  pair < int, int >
#define sqr( a )           a * a
#define all( c )           c.begin(), c.end()
#define srt( c )           sort( all( c ) )
#define rev( c )           reverse( all( c ) )
#define srtr( c )          sort( c.rbegin(), c.rend() );

using namespace std;
ll n, k, m;
void solve()
{
    sc( "%I64d%I64d", &n, &k );
    m = ( n * ( n - 1 ) ) / 2;
    m -= k;
    if( ( ( n - 2 ) * ( n - 1 ) ) / 2 < k )
    {
        pr( "-1" );
        rt;
    }
    pr( "%I64d\n", m );
    for( int i = 1; i <= n; i ++ )
        for( int j = i + 1; j <= n; j ++ )
        {
            if( !m )rt;
            m --;
            pr( "%d %d\n", i, j );
        }

}

int main()
{
    int tt = 1;
    //sc( "%d", &tt );
    for( int i = 1; i <= tt; i ++ )
        solve();
}












Measured memory_bytes: 256
import java.io.*
import java.util.*

fun solve(N: Int, M: Int, A: LongArray){
    val queue = PriorityQueue<Long>()
    A.forEach{ queue.add(-it) }
    repeat(M){
        queue.offer(queue.poll()/2)
    }
    println(-queue.sum())
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val M = sc.next().toInt()
    val A = LongArray(N)
    for (i in 0 until N) {
        A[i] = sc.next().toLong()
    }
    solve(N, M, A)
}



Measured memory_bytes: 45768
#include <stdio.h>

int main(void){

	int S,h,m,s;

	scanf("%d",&S);

	h=S/3600;
	m=(S-h*3600)/60;
	s=S-h*3600-m*60;
	printf("%d:%d:%d\n",h,m,s);

	return 0;
}

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


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

#define A_MAX 10001

void Counting_Sort(int *, int *);
int n;

int main(){
        int *A, *B;
        int i;

        scanf("%d", &n);
        A = malloc(sizeof(int) * n);
        B = malloc(sizeof(int) * n);

        for(i = 0; i < n; i++){
                scanf("%d", &A[i]);
        }

        Counting_Sort(A, B);
        
        for(i = 0; i < n ;i++){
                printf("%d", B[i]);
                if(i + 1 != n)printf(" ");
        }
        printf("\n");

        return 0;
}

void Counting_Sort(int *A, int *B){
        int C[A_MAX];
        int i, j;

        for(i = 0; i <= A_MAX; i++){
                C[i] = 0;
        }

        for(i = 0 ; i < n ; i++){
                C[A[i]]++;
        }

        for(j = 0 ; j <= A_MAX ; j++){
                C[j] = C[j] + C[j - 1];
        }

        for(j = n - 1 ; j >= 0 ; j--){
                B[C[A[j]]-1] = A[j];
                C[A[j]]--;
        }

}


Measured memory_bytes: 17436
N = int(input())
C = list(input())
count = list()
W = 0
R = 0

for i in C:
    if i == "R":
        R += 1

if R == 0:
    count.append(0)

for i in C:

    if i == "W":
        W += 1
    else:
        R -= 1

    if W <= R:
        count.append(R)
    else:
        count.append(W)

print(min(count))

Measured memory_bytes: 18624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<ll, ll>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
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> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

#include <functional>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin, n;
    vector<ll> x(n), y(n), p(n);
    REP(i, 0, n) {
        cin, x[i], y[i], p[i];
    }
    const ll inf = 1LL << 60;
    vector<ll> ans(n + 1, inf);
    auto dist1 = make_v(1 << n, n, 0LL), dist2 = make_v(1 << n, n, 0LL);
    REP(bits, 0, 1 << n) {
        REP(i, 0, n) {
            dist1[bits][i] = min(abs(x[i]), abs(y[i])) * p[i];
            dist2[bits][i] = min(abs(x[i]), abs(y[i])) * p[i];
            REP(j, 0, n) {
                if ((bits >> j) & 1) {
                    chmin(dist1[bits][i], abs(x[i] - x[j]) * p[i]);
                    chmin(dist2[bits][i], abs(y[i] - y[j]) * p[i]);
                }
            }
        }
    }

    auto func = [&](auto &f, int pos, int cnt, int bit1, int bit2) {
        if (pos == n) {
            ll cost = 0;
            REP(i, 0, n) {
                cost += min(dist1[bit1][i], dist2[bit2][i]);
            }
            chmin(ans[cnt], cost);
            return;
        }
        f(f, pos + 1, cnt + 1, bit1 + (1 << pos), bit2);
        f(f, pos + 1, cnt + 1, bit1, bit2 + (1 << pos));
        f(f, pos + 1, cnt, bit1, bit2);
    };

    func(func, 0, 0, 0, 0);

    REP(i, 0, n + 1) {
        print(ans[i]);
    }

    return 0;
}


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

const int mod = 1000000007;
typedef long long LL;
void reduce(int & x) { x += x >> 31 & mod; }
int mul(int a, int b) { return (LL) a * b % mod; }
int pow(int a, int b, int res = 1) {
	for (; b; b >>= 1, a = mul(a, a)) if (b & 1) res = mul(res, a);
	return res;
}
int remod(LL x) { x %= mod; return x + (x >> 63 & mod); }
const int MAXS = 2000010;
int fac[MAXS], inv[MAXS];
inline int C(int a, int b) { return (LL) fac[a] * inv[b] % mod * inv[a - b] % mod; }
int calc(int x1, int y1, int x2, int y2, int x3, int y3, int dx, int dy) {
	if (x2 + dx > x3 || y2 + dy > y3) return 0;
	return (LL) C(x2 - x1 + y2 - y1, x2 - x1) *
				C(x3 - x2 + y3 - y2 - dx - dy, x3 - x2 - dx) % mod *
				(x2 - x1 + y2 - y1 + 2) % mod;
}
int solve(int xl, int yl, int xm, int ym, int xr, int yr) {
	LL res = 0;
	for (int i = xl; i < xm; ++i)
		res += calc(xl, yl, i, ym, xr, yr, 0, 1);
	for (int i = yl; i < ym; ++i)
		res += calc(xl, yl, xm, i, xr, yr, 1, 0);
	res += calc(xl, yl, xm, ym, xr, yr, 0, 0);
	return remod(res);
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	fac[0] = fac[1] = inv[0] = inv[1] = 1;
	for (int i = 2; i != MAXS; ++i) {
		fac[i] = mul(fac[i - 1], i);
		inv[i] = mul(inv[mod % i], mod - mod / i);
	}
	for (int i = 2; i != MAXS; ++i) inv[i] = mul(inv[i], inv[i - 1]);
	int x1, x2, x3, x4, x5, x6;
	int y1, y2, y3, y4, y5, y6;
	std::cin >> x1 >> x2 >> x3 >> x4 >> x5 >> x6;
	std::cin >> y1 >> y2 >> y3 >> y4 >> y5 >> y6;
	int xl[4], yl[4], xm[4], ym[4], xr[4], yr[4];
	xl[0] = x1 - 1, yl[0] = y1 - 1;
	xl[1] = x2, yl[1] = y1 - 1;
	xl[2] = x1 - 1, yl[2] = y2;
	xl[3] = x2, yl[3] = y2;
	xm[0] = x3 - 1, ym[0] = y3 - 1;
	xm[1] = x4, ym[1] = y3 - 1;
	xm[2] = x3 - 1, ym[2] = y4;
	xm[3] = x4, ym[3] = y4;
	xr[0] = x5, yr[0] = y5;
	xr[1] = x6 + 1, yr[1] = y5;
	xr[2] = x5, yr[2] = y6 + 1;
	xr[3] = x6 + 1, yr[3] = y6 + 1;
	LL ans = 0;
	for (int i = 0; i != 4; ++i)
		for (int j = 0; j != 4; ++j)
			for (int k = 0; k != 4; ++k) {
				int t = __builtin_parity(i | j << 2 | k << 4) ? -1 : 1;
				ans += solve(xl[i], yl[i], xm[j], ym[j], xr[k], yr[k]) * t;
			}
	std::cout << remod(ans) << std::endl;
	return 0;
}


Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <cmath>
#include <typeinfo>
#include <set>
#include <bitset>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;



int main(){
  int a,b;
  cin >> a >> b;
  int m = min(a,b);
  for(int i=0; i<a+b-m; i++){
    cout << m;
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
long long n,k,ans,h[200005];
int main(){
	scanf("%lld%lld",&n,&k);
	for(int i=0;i<n;++i)scanf("%lld",&h[i]);
	std::sort(h,h+n);
	for(int i=0,j=n-k;i<j;++i)ans+=h[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1664
if __name__ == "__main__":
    a, b = map(lambda x: int(x), input().split())
    mask = (1 << 32) - 1
    print(f"{(a & b) & mask:032b}")
    print(f"{(a | b) & mask:032b}")
    print(f"{(a ^ b) & mask:032b}")



Measured memory_bytes: 5620
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int x,y;
int main(){
	ios::sync_with_stdio(0);
	cin>>x>>y;
	rep(i,x+1){
		if(i*2+(x-i)*4==y){
			cout<<"Yes";
			re 0;
		}
	}
	cout<<"No";
	re 0;
}

Measured memory_bytes: 3660
import java.util.*;

class Main {
    public static void main(String args[]) {
        Scanner inp = new Scanner(System.in);
        do_(inp);
        inp.close();
    }
    public static void do_(Scanner inp) {
        int a = inp.nextInt();
        int b = inp.nextInt();
        System.out.println(Math.max(Math.max(a + b, a - b), a * b));
    }
}


Measured memory_bytes: 23124
n, m = map(int, input().split())
p = [list(map(int, input().split())) for _ in range(n)]
p.sort(key=lambda x: x[0])

yen = 0
for i in p:
    if m == 0:
        break
    if m < i[1]:
        yen+=m*i[0]
        break
    else:
        yen+=i[0]*i[1]
        m -= i[1]
print(yen)

Measured memory_bytes: 29020