akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        Queue<String> name = new LinkedList<>();
        Queue<Integer> time = new LinkedList<>();
        int a = in.nextInt();
        int b = in.nextInt();
        int timer = 0;

        for (int i = 0; i < a; i++) {
            name.add(in.next());
            time.add(in.nextInt());
        }
        while (name.size() != 0) {
            if (time.peek() - b > 0) {
                name.add(name.poll());
                time.add(time.poll() - b);
                timer += b;
            } else {
                timer += time.poll();
                System.out.println(name.poll() + " " + timer);
            }
        }
    }
}



Measured memory_bytes: 76380
import java.io.*;
import java.util.*;

public class Main {
    static PrintWriter out = new PrintWriter(System.out);
    static Scanner sc = new Scanner(System.in);
    static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    long mod = 1000000000+7;

    public static void main(String[] args) throws IOException {
        Main main = new Main();
        main.solve();
//        out.println(main.solve());
        out.flush();
    }
    void solve() throws IOException {
        long n =sc.nextLong();
        Map<Long, Integer> map = new HashMap<>();
        for(long p=2; p*p<=n; p++){
            if(n%p!=0) continue;
            int cnt = 0;
            while(n%p==0){
                cnt++;
                n = n/p;
            }
            map.put(p,cnt);
        }
        if(n>1) map.put(n,1);
        long ans = 0;
        for(long key:map.keySet()){
            int val = map.get(key);
            ans += helper(val);
        }
        out.println(ans);
    }
    int helper(int n){
        int ans = 0, i = 1;
        while(n>0){
            if(n>=i) ans++;
            n -= i;
            i++;
        }
        return ans;
    }
}

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

int main() {
  int N;
  //double v[N];
  cin >> N;
  //for (int i = 0; i < N; i++) {
    //cin >> v[i];
  //}
  vector<double> vec(N);
for (int i = 0; i < N; i++) {
  cin >> vec.at(i);
}
  sort(vec.begin(), vec.end());
  //reverse(vec.begin(), vec.end());
  //cout << vec.at(0) << endl;
  double S = vec.at(0);
  /* for (int i = 1; i < N; i++) {
    S += vec.at(i)/(2.0 ^ i);
  } */
  for (int i = 1; i < N; i++) {
    S = (S + vec.at(i))/ 2.0 ;
  } 
  cout << S << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
/****************************/
int h,w,x;
char c[10][10];
int ans=0;
int main()
{
	int left=0;
	cin>>h>>w>>x;
	rep(i,h)
	{
		rep(j,w)
		{
			cin>>c[i][j];
			if(c[i][j]=='#')
			{
				left++;
			}
		}
	}
	rep(i,1<<(h+w))
	{
		char c1[10][10];
		rep(a,10)
		{
			rep(b,10)
			{
				c1[a][b]=c[a][b];
			}
		}
		rep(j,h)
		{
			if(i>>j&1)
			{
				rep(k,w)
				{
					c1[j][k]='.';
				}
			}
		}
		rep3(j,h,h+w)
		{
			if(i>>j&1)
			{
				rep(k,h)
				{
					c1[k][j-h]='.';
				}
			}
		}
		int cnt=0;
		rep(k,h)
		{
			rep(l,w)
			{
				if(c1[k][l]=='#')
				{
					cnt++;
				}
			}
		}
		if(cnt==x)
		{
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n, a[maxn];
long long dp[maxn][3];
long long f(int pos, bool changed){
	if(pos == n) return 0;
	if(dp[pos][changed] != -1) return dp[pos][changed];
	long long val = a[pos];
	if(changed) val = -val;
	long long nocambio = val + f(pos + 1, 0);
	long long cambio = LLONG_MIN;
	if(pos + 1 < n) cambio = -val + f(pos + 1, 1);
	dp[pos][changed] = max(nocambio, cambio);
	return dp[pos][changed];
}
int main() {
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> a[i];
	memset(dp,-1,sizeof(dp));
	cout << f(0,0) << endl;
	return 0;
}

Measured memory_bytes: 7680
import math

x = 0
y = 0
alpha = 90

while True:
    a, b = map(int, input().split(','))
    if a == b == 0:
        break
    
    x += a * math.cos(alpha / 180 * math.pi)
    y += a * math.sin(alpha / 180 * math.pi)
    
    alpha -= b
    
print(int(x))
print(int(y))

Measured memory_bytes: 7664
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
const long long INF = 1LL << 60;
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;
    vector<int> a(N), b(N), c(N), dpa(N), dpb(N), dpc(N);
    rep(i, N) cin >> a.at(i) >> b.at(i) >> c.at(i);
    rep(i, N) dpa.at(i) = 0,dpb.at(i) = 0,dpc.at(i) = 0;
    dpa.at(0) = a.at(0); dpb.at(0) = b.at(0); dpc.at(0) = c.at(0);
    for(int i=1;i<N;i++){
        chmax(dpa.at(i),max(dpb.at(i-1)+a.at(i),dpc.at(i-1)+a.at(i)));
        chmax(dpb.at(i),max(dpc.at(i-1)+b.at(i),dpa.at(i-1)+b.at(i)));
        chmax(dpc.at(i),max(dpa.at(i-1)+c.at(i),dpb.at(i-1)+c.at(i)));
    }
    cout << max({dpa.at(N-1),dpb.at(N-1),dpc.at(N-1)}) << endl;
    return 0;
}

Measured memory_bytes: 5616
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long ans0 = a * c;
    long long ans1 = a * d;
    long long ans2 = b * c;
    long long ans3 = b * d;
    long long ans = max(ans0, max(ans1, max(ans2, ans3)));

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

static const long long MOD_NUM = 1000000007LL;

static void A_task();

int main()
{
	A_task();
	fflush(stdout);
	return 0;
}

static void A_task()
{
	int X, Y;
	get2int(X, Y);

	int prize = 0;
	if (X <= 3) {
		prize += (4 - X) * 100000;
	}
	if (Y <= 3) {
		prize += (4 - Y) * 100000;
	}
	if((X == Y) && (X == 1)) {
		prize += 400000;
	}
	printf("%d\n", prize);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define int long long
#define MOD 1000000007
#define mod 998244353
#define ff first
#define ss second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define vvi vector<vi>
#define endl "\n"
using namespace std;

int colour[100005];
int vis[100005];
void solve1();
void solve()
{
    int T=10;cin>>T;
    for(int z=1;z<=T;z++)
    {
        solve1();
    }
}
signed main()
{
    std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    solve1();
    return 0;
}
void solve1()
{
    int x,k,d;cin>>x>>k>>d;
    x=abs(x);
    int p=x/d;
    p=min(p,k);
    k-=p;
    if(k%2==0)
    {
        cout<<(x-p*d)<<endl;
    }
    else
    {
        cout<<abs(x-((p+1)*d))<<endl;
    }
}


Measured memory_bytes: 3644
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 100005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n;
   cin>>n;
   int a[n];
   int tot=0;
   rep(i,0,n){cin>>a[i];tot+=a[i];}
   int mn=1e9;
   for(int i=0;i<n;i++)
   {  int sum=0;
      for(int j=0;j<i;j++)
      {
          sum+=a[j];
      }
      mn=min(mn,abs(tot-2*sum));
   }
   cout<<mn<<endl;
}



Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{Write, BufWriter};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn dist(a: &[f64], b: &[f64], size: usize) -> f64 {
    let mut d = 0.0;
    for i in 0..size {
        let d2 = a[i] - b[i];
        d += d2 * d2;
    }
    return d.sqrt();
}

fn main() {
    input! {
        n: usize,
        d: usize,
        x: [[f64; d]; n],
    }
    let mut ans = 0;
    for i in 0..n {
        for j in 0..i {
            let di = dist(&x[i], &x[j], d);
//            println!("{}, {}: {}", i, j, di);
            let fl = di as i64;
            if ((fl * fl) as f64).sqrt() == di {
                ans += 1;
            };
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
x=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(x[int(input())-1])

Measured memory_bytes: 61588
#include<bits/stdc++.h>
#define ls p<<1
#define rs p<<1|1 
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define mm make_pair
#define pi 2*acos(0.0)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout.precision(i);cout<<fixed<<ans<<endl;
#define lowbit(x) (x)&(-x)
#define out(x) {cout<<x<<endl;return 0;} 
#define all(v) v.begin(),v.end() 
#define mem(x,i) memset(x,i,sizeof(x)) 
#define mec(x,y) memcpy(x,y,sizeof(y))
#define eps 1e-8 
#define ull unsigned long long
#define cps CLOCKS_PER_SEC
using namespace std;
typedef long long ll;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
ll gcd(ll x,ll y){if(y==0) return x;else return gcd(y,x%y);} 
ll ksm(ll a,ll b){ll r=1;while(b){if(b&1) r=(r*a)%mod;a=a*a%mod;b>>=1;}return r;} 
void exgcd(ll a, ll b, ll &x, ll &y, ll &d){if(!b) d=a,x=1,y=0;else exgcd(b,a%b,y,x,d),y-=a/b*x;}
ll inv(ll a, ll p){ll x,y,d;exgcd(a,p,x,y,d);x=(x%p+p)%p;return x;}
inline int read()
{
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
const int maxn=1e5+100;
map<int,int> mp;
int main()
{
	FOR(i,1,100)
	FOR(j,1,100)
	FOR(k,1,100) mp[i*i+j*j+k*k+i*j+j*k+i*k]++;
	
	int n=read();
	FOR(i,1,n) cout<<mp[i]<<endl;
	return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};


//-----------------------------------------------------------------------------

char a,b;

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

	cin>>a>>b;
	if(a==b) cout<<"H";
	else cout<<"D";
	cout<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}*/

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

	int n;
	cin >> n;
	vector<int> t(n+1), x(n+1), y(n+1);
	rep(i, n) {
		cin >> t[i+1] >> x[i+1] >> y[i+1];
	}
	t[0] = 0, x[0] = 0, y[0] = 0;

	// 奇数マスが偶数マスか

	// そもそもたどり着けるか

	bool can = true;

	rep(i, n) {
		int time = t[i + 1] - t[i];
		int dx = x[i + 1] - x[i];
		int dy = y[i + 1] - y[i];

		if (abs(dx + dy) > time) {
			can = false;
			break;
		}

		if (abs(dx + dy) % 2 != time % 2) {
			can = false;
			break;
		}
	}

	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
 
int main(void){
  int k,n,i;
  scanf("%d %d",&k,&n);
  int a[n];
  for(i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }
  
  int max = k-a[n-1] + a[0];
  for(i = 0;i < n-1;i++){
    if(a[i+1] - a[i] > max)
      max = a[i+1] -a[i];
  }

  printf("%d",k - max);
  return 0;
}

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

// template {{{
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); (i) += 1)
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); (i) -= 1)

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; }
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// }}}

void solver() {
    string t;
    cin >> t;

    for (auto &i: t) {
        if (i == '?') i = 'D';
    }

    cout << t << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 3756
#include<cstdio>
#include<algorithm>
using namespace std;
int N,A[1<<18];
pair<int,int> F[1<<18],G[1<<18];
int B[1<<18];
int main(){
	pair<int,int> tmp[100];
	scanf("%d",&N);
	for(int i=0;i<1<<N;++i) scanf("%d",A+i);
	for(int i=1;i<1<<N;++i){
		if(__builtin_popcount(i)==1){
			if(A[i]>A[0]) F[i]=std::make_pair(A[i],i), G[i]=std::make_pair(A[0],0);
			else F[i]=std::make_pair(A[0],0), G[i]=std::make_pair(A[i],i);
		}
		else{
			int t=1; tmp[1]=std::make_pair(A[i],i);
			for(int j=0;j<N;++j) if(i>>j&1){
				tmp[++t]=F[i^(1<<j)];
				tmp[++t]=G[i^(1<<j)];
			}
			sort(tmp+1,tmp+t+1); t=unique(tmp+1,tmp+t+1)-tmp-1;
			F[i]=tmp[t]; G[i]=tmp[t-1];
		}
	}
	for(int i=1;i<1<<N;++i) B[i]=std::max(B[i-1],F[i].first+G[i].first);
	for(int i=1;i<1<<N;++i) printf("%d\n",B[i]);
	return 0;
}

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

int main(){
    int a[3], sum=0;
    for(int i=0;i<3;i++){
        cin >> a[i];
        sum += a[i];
    }
    if(sum>21){
        cout << "bust" << endl;
    }else{
        cout << "win" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import std.algorithm,
       std.string,
       std.range,
       std.array,
       std.stdio,
       std.conv;

bool check(string s) {
  if (s.length % 2) { return false; }
  string a = s[0..$/2],
         b = s[$/2..$];
  return a == b;
}

void main() {
  string s = readln.chomp;

  size_t del = 1;

  while (del < s.length - 1) {
    if (check(s[0..$-del])) {
      break;
    } else {
      del++;
    }
  }

  writeln(s[0..$-del].length);
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
using namespace std;
#define MOD 1000000007
class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};





int main() {
	int n;
	cin >> n;
	int *c = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		c[i]--;
	}
	long long *dp = new long long[n+1];
	int last[200020];
	dp[0] = 1;
	memset(last, -1, sizeof(last));
	
	for (int i = 1; i <= n; i++) {
		dp[i] = dp[i-1];
		if (last[c[i-1]] != -1 && last[c[i-1]] != i - 1) {
			dp[i] += dp[last[c[i-1]]] % MOD;
		}
		last[c[i-1]] = i;
	}
	
	dp[n] = dp[n] % MOD;
	cout << dp[n];
	


	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)

int main() {
    int N;
    cin >> N;
    int M = N;
    if(N%2==0) ++M;
    vector<pair<int,int> > v;
    for(int i=1;i<=N;++i){
        for(int j=i+1;j<=N;++j){
            if(i+j!=M) v.emplace_back(i,j);
        }
    }
    cout << v.size() << '\n';
    for(int i=0;i<v.size();++i) cout << v[i].first << " " << v[i].second << '\n';
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a * 2 <= b && b <= a * 4 && b % 2 == 0) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

        sc.close();
    }
}

Measured memory_bytes: 35760
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)

int main(){
  int n,k;cin>>n>>k;
  int a[n];
  fol(i,n){
    cin>>a[i];
  }
  int dp[n+k]={};
  fol(i,n+k){dp[i] = 1E9;}
  dp[0] = 0;
  for(int i=0;i<n;i++){
    for(int j=1;j<=k&&i+j<n;j++){
      dp[i+j] = min(dp[i+j],abs(a[i]-a[i+j])+dp[i]);
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
import collections, scipy.misc, numpy
n, p = map(int, input().split())
a = numpy.array(list(map(int, input().split())))
a %= 2
c = collections.Counter(a)
ans = 0
for i in range(p, c[1] + 1, 2):
    ans += 2 ** c[0] * scipy.misc.comb(c[1], i, exact=True)
print(ans)


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


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
 
    int n;
    cin>>n;
    int a[n];
    bool used[2222]={};
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    int ans = 1e9;
    for(int i=0;i<=2000;i++){
        ans = min(ans,max(i-a[0],a[n-1]-i));
    }
    cout << ans<< endl;
    
}


Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n,A[200001][3];
    cin>>n;
    rep(i,n)rep(j,3) cin>>A[i][j];
    int dp[200001][3]={0};
    rep(i,n)rep(j,3) dp[i+1][j]=max(dp[i][(j+1)%3],dp[i][(j+2)%3])+A[i][j];
    cout<<*max_element(dp[n],dp[n]+3);
}

Measured memory_bytes: 4992
import heapq
N = int(input())
q = []
for _ in range(N):
	at,bt = map(int,input().split())
	heapq.heappush(q,[bt,at])

cond = True
cnt = 0
tmp = 0
for _ in range(N):
	d,c = heapq.heappop(q)
	cnt += (d - tmp)
	cnt -= c
	if cnt < 0:
		cond = False
		break
	tmp = d

if cond:
	print("Yes")
else:
	print("No")



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

void solve(long long N, long long X, long long T){
    ll div = (N+X-1)/X;
    cout << div*T << endl;

}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long T;
    scanf("%lld",&T);
    solve(N, X, T);
    return 0;
}


Measured memory_bytes: 3760
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

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

    static class APluralForm {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String s = in.readString();
            int n = s.length();

            System.out.println(s.charAt(n - 1) == 's' ? s + "es" : s + "s");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String readString() {
            final StringBuilder stringBuilder = new StringBuilder();
            int c = read();
            while (isSpaceChar(c))
                c = read();
            do {
                stringBuilder.append((char) c);
                c = read();
            } while (!isSpaceChar(c));
            return stringBuilder.toString();
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 36204
from collections import deque

def area(map):
    total = 0
    s1 = deque()
    s2 = deque()
    for i in range(len(map)):
        if map[i] == "\\":
            s1.append(i)    # 右斜面の要素番号を格納
        elif len(s1) > 0 and map[i] == "/":
            old = s1.pop()  # 水面の高さ(仮)を取り出す
            tmp = 0
            while len(s2) > 0 and old < s2[-1][0]:
                tmp += s2.pop()[1]  # 水没地帯の面積を計算(横に輪切りにするイメージで下から計算)
            s2.append([old, tmp + i - old]) # s2[[水面の始点, 水没地帯の面積(水面以外の面積 + (水面の終点 - 水面の始点)]]

    # 合計の水没面積を計算
    for i in range(len(s2)):
        total += s2[i][1]
    print(total)

    if s2:
        print(len(s2), end=" ")
        for i in range(len(s2)):
            if i != len(s2)-1:
                print(s2[i][1], end = " ")
            else:
                print(s2[i][1])
    else:
        print(len(s2))


if "__main__" == __name__:
    map = input().rstrip()
    area(map)


Measured memory_bytes: 6772
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#define rep(i, n) for(Int (i) = 0; (i) < (n); (i)++)
using namespace std;
using Int = int64_t;
constexpr long long int mod = 1e9 + 7;

//aとbが割り切れるまで割る(既約分数になるまで)
std::pair<Int, Int> Reduce(Int a, Int b) {

	const auto f = [](Int n) -> unordered_map<Int, Int> {
		unordered_map<Int, Int> res;
		for (Int i = 2; i * i <= n; ++i) {
			if (n % i != 0)continue;
			res[i] = 0;
			while (n % i == 0) {
				n /= i;
				res[i]++;
			}
		}
		if (n != 1)res[n] = 1;
		return res;
	};

	auto res_a = f(a), res_b = f(b);

	Int ans = 1;// 割るべき数

	for (auto itr = res_a.begin(); itr != res_a.end(); ++itr) {
		auto tmp = res_b.find(itr->first);
		if (tmp != res_b.end()) {//もしbにも同様の因数があったら
			ans *= (pow(itr->first, min(res_b[itr->first], itr->second)));
		}
	}

	return make_pair(a / ans, b / ans);

}

int main() {

	Int A, B; cin >> A >> B;

	cout << Reduce(A, B).first * B << endl;

}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = readInt >>= print . ( ^ 2 )

Measured memory_bytes: 508
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef long long in;
typedef vector<in> VI;
typedef vector<VI> VVI;
VVI egs;
VI str;
VI clr;
void pnt(in v, in d, in c){
  if(str[v]>=d)
    return;
  if(str[v]==-1)
    clr[v]=c;
  str[v]=d;
  forv(i,egs[v]){
    pnt(egs[v][i],d-1,c);
  }
}
VI v,d,c;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n,m;
  cin>>n>>m;
  egs.resize(n);
  in ta,tb;
  forn(i,m){
    cin>>ta>>tb;
    --ta;
    --tb;
    egs[ta].PB(tb);
    egs[tb].PB(ta);
  }
  str.resize(n,-1);
  clr.resize(n,0);
  in q;
  cin>>q;
  v=d=c=VI(q);
  forn(i,q)
    cin>>v[i]>>d[i]>>c[i];
  for(in i=q-1;i>=0;--i){
    pnt(v[i]-1,d[i],c[i]);
  }
  forn(i,n)
    cout<<clr[i]<<"\n";
  return 0;
}


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

int i, n;
string s, rs;
map<char, char> M;

string Solve(char start, char last) {
  string rs;
  while(rs.size() != s.size()) rs += " ";

  rs[0] = start; rs[n - 1] = last;

  for(i = 0; i < n - 1; ++i)
    if(s[i] == 'o') rs[(i + n + 1) % n] = (rs[i] == 'S' ? rs[(i + n - 1) % n] : M[rs[(i + n - 1) % n]]);
    else rs[(i + n + 1) % n] = (rs[i] == 'W' ? rs[(i - 1 + n) % n] : M[rs[(i + n - 1) % n]]);

  for(i = 0; i < n; ++i) {
    int st = (i + n - 1) % n;
    int dr = (i + n + 1) % n;
    if(rs[i] == 'S') {
      if(s[i] == 'o' && rs[st] != rs[dr]) return "-1";
      if(s[i] == 'x' && rs[st] == rs[dr]) return "-1";
    } else {
      if(s[i] == 'o' && rs[st] == rs[dr]) return "-1";
      if(s[i] == 'x' && rs[st] != rs[dr]) return "-1";
    }
  }

  return rs;
}

int main() {
  ios_base::sync_with_stdio(0);

  cin >> n >> s;

  M['S'] = 'W'; M['W'] = 'S';

  rs = Solve('S', 'S');
  if(rs != "-1") return cout << rs << '\n', 0;
  rs = Solve('S', 'W');
  if(rs != "-1") return cout << rs << '\n', 0;
  rs = Solve('W', 'S');
  if(rs != "-1") return cout << rs << '\n', 0;

  cout << Solve('W', 'W') << '\n';

  return 0;
}

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

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10
#define MAX_N 100000

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int n, k, a[MAX_N+1];

int main(){
  while(scanf("%d%d", &n, &k) && n+k){
    REP(i, 1, n+1) scanf("%d", a+i);
    REP(i, 1, n+1) a[i] += a[i-1];
    int res = 0;
    REP(i, k, n+1) res = max(res, a[i] - a[i-k]);
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 1576
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001

int main(){
    ll A, B, Q; cin >> A >> B >> Q;
    vector<ll> S(A+2);
    vector<ll> T(B+2);
    S[0] = (1LL << 60) * (-1);
    S[A+1] = 1LL << 60;
    T[0] = (1LL << 60) * (-1);
    T[B+1] = 1LL << 60;

    for(int i=1; i<=A; i++)
        cin >> S[i];
    for(int i=1; i<=B; i++)
        cin >> T[i];

    for(int i=0; i<Q; i++){
        ll X; cin >> X;

        vector<ll> s(2);
        vector<ll> t(2);
        s[0] = upper_bound(S.begin(), S.end(), X) - S.begin();
        s[1] = s[0] - 1;
        t[0] = upper_bound(T.begin(), T.end(), X) - T.begin();
        t[1] = t[0] - 1;
        ll ans = 1LL << 60;

        for(int k=0; k<2; k++){
            for(int l=0; l<2; l++){
                ans = min(ans, abs(X - S[s[k]]) +  abs(S[s[k]]-T[t[l]]));
                ans = min(ans, abs(X - T[t[l]]) +  abs(S[s[k]]-T[t[l]]));
            }
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 2944
#include <iostream>

int main (void)
{
	// variables for main process
	int rate_increase;
	int speed_decrease;
	int weight_algae;

	// STEP.01
	// read out the given data
	std::cin >> rate_increase;
	std::cin >> speed_decrease;
	std::cin >> weight_algae;

	// STEP.02
	// calculate & output the total weight of the algae
	for (size_t itr = 0; itr < 10; itr++)
	{
		// update the total weight of the algae
		weight_algae = rate_increase * weight_algae - speed_decrease;

		// output the total weight of the algae
		std::cout << weight_algae << std::endl;
	}

	// STEP.END
	return 0;
}

Measured memory_bytes: 256
#include <iostream>


int main()
{
	int w, h, x, y, r;

	std::cin >> w >> h >> x >> y >> r;

	// horizontal check
	if (x - r < 0 || x + r > w) printf("No\n");

	// vertical check
	else if (y - r < 0 || y + r > h) printf("No\n");

	else printf("Yes\n");


	return 0;
}


Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>

int main(void){
  double x,h;

  while(1){
    scanf("%lf%lf",&x,&h);
    if(!x && !h) break;

    printf("%.6lf\n",2*x*sqrt(x*x+4*h*h)/2+x*x);
  }

  return 0;
}

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

int main(){
   int N,X,Y;
   cin >> N >> X >> Y;
   X -= 1;
   Y -= 1;

   vector<int> ans(N-1);
   rep(i,N-1){
      ans.at(i) = 0;
   }
   

   for(int j=0;j<N;j++){
      for(int l=j+1;l<N;l++){
         int d = l - j;
         d = min(d,abs(X-j) + abs(Y-l) + 1);
         d -= 1;
         ans.at(d) += 1;
      }
   }

   rep(i,N-1){
      cout << ans.at(i) << endl;
   }
   return 0;  
}

Measured memory_bytes: 256
import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val a = readLine()!![0]
    val ans = if (a.isUpperCase()) 'A' else 'a'
    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


Measured memory_bytes: 34616
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

// ref: https://atcoder.jp/contests/abc116/submissions/13357105
// crux: pick max. "k" values and adjust for "cnt"

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          begin(x),end(x)
#define     rz(x)           resize(x)
#define     asn(x,y)        assign(x,y)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        ((a)*((b)/gcd((a),(b))))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n,k;
    cin>>n>>k;

    vector<pii> v(n);
    for(int i=0;i<n;++i)
        cin>>v[i].S>>v[i].F;

    sort(all(v));                       // sorting in decreasing order
    reverse(all(v));

    priority_queue<int> pq;
    vi mark(n+1);

    int sum=0,cnt=0;
    for(int i=0;i<k;++i)                // picking max. "k" values (provides a base to work on)
    {
        if(mark[v[i].S])
            pq.push(-v[i].F);
        else
        {
            mark[v[i].S]=1;
            ++cnt;
        }

        sum+=v[i].F;
    }

    int ans=sum+cnt*cnt;
    for(int i=k;i<n;++i)                // increasing "cnt"...
    {
        if(cnt==k)
            break;

        if(mark[v[i].S])
            continue;

        mark[v[i].S]=1;

        int x=-pq.top();
        pq.pop();

        sum+=v[i].F-x,++cnt;
        ans=max(ans,sum+cnt*cnt);
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



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

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


Measured memory_bytes: 256
#include <stdio.h>

void leap(int a,int b)
{
    int d = 0;
    for(int i = a;i <= b;i++){
        if(i % 400 == 0 || (i % 4 == 0 && i % 100 != 0)){
            printf("%d\n",i);
            ++d;
        }
    }
    if(d == 0){
        printf("NA\n");
    }
    return;
}

int main(void)
{
    int a,b;
    int e = 0;
    while(1){
        scanf("%d %d",&a,&b);
        if(e >= 1 && (a != 0 && b != 0)){
            printf("\n");
        }
        if(a == 0 && b == 0){
            break;
        }else{
        leap(a,b);
        ++e;
        }
    }
    return 0;
}

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

int a, b;

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

    cin >> a >> b;

    if (a < b ) {
        cout << "a < b" << '\n';
    } else if (a > b) {
        cout << "a > b" << '\n';
    } else {
        cout << "a == b" << '\n';
    }
    return 0;
}


Measured memory_bytes: 3160
# n, m = map(int, '12 3'.split())
# a = list(map(int, '4 56 78 901 2 345 67 890 123 45 6 789'.split()))
n, m = map(int, (input()).split())
a = list(map(int, input().split()))

a = sorted(a, reverse=True)
thresh = float(sum(a))/(4*m)

filtered = len(list(filter(lambda x: x >= thresh, a)))

if filtered >= m:
  print('Yes')  
else:
  print('No')


Measured memory_bytes: 3064
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        
        System.out.print(n * m + " ");
        System.out.println(n * 2 + m * 2);
    }
}


Measured memory_bytes: 26228
#include <iostream>
#include <string>

int main()
{
    std::string s;
    std::cin >> s;
    int count;
    for(int i = 0; i < 3; i++)
    {
        if(s[i] == '1')
        {
            count++;
        }
    }
    std::cout << count << std::endl;
    return 0;
}

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

int main() {
  int N,x,ans=0;
  cin >> N >> x;
  int a[N+10];
  for(int i=0; i<N; i++) cin >> a[i];
  sort(a,a+N);
  for(int i=0; i<N; i++){
    if(x>=a[i]){
      ans+=1;
      x-=a[i];
    }else{
      cout << ans << endl;
      return 0;
    }
  }if(x!=0) cout << ans-1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

int main(){
	string str;

	while( getline(cin, str) ){
		bool flag = 0;
		while(!flag){
			for(int i=0;i<str.size();i++){
				if(str[i]>='a' && str[i]<='z'){
					str[i]=(char)(str[i]+1);
					if(str[i]>'z'){
						str[i]-=('z'-'a'+1);
					}
				}
			}
			if(str.find("the")!=string::npos || str.find("this")!=string::npos || str.find("that")!=string::npos ){
				flag = 1;
			}
			//cout << str << endl;
		}
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<map>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<utility> 
#include<fstream>
#include<cassert>
#include<cstdlib>
#include<deque>
#include<list>
#include<bitset>
#include<cassert>
#include<functional>
using namespace std;
int n,dp[100005],la[100005],pre[200005],va[200005],deg[100005];
void dfs(int v,int pa)
{
	int cnt=0;
	for(int i=la[v];~i;i=pre[i])
	{
		int u=va[i];
		if(u==pa) continue;
		dfs(u,v);
		if(dp[u]==0) cnt++;else dp[v]+=dp[u];
	}
	if(cnt>1) dp[v]+=cnt-1;
	dp[v]=max(dp[v],0);
}
int main()
{
	scanf("%d",&n);
	memset(la,-1,sizeof(la));
	for(int i=0;i<n-1;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		pre[2*i]=la[x];
		va[2*i]=y;
		la[x]=2*i;
		pre[2*i+1]=la[y];
		va[2*i+1]=x;
		la[y]=2*i+1;
		deg[x]++;deg[y]++;
	}
	bool flag=0;
	int ro=-1;
	for(int i=0;i<n-1;i++)
	{
		if(deg[i]>=3) ro=i; 
	}
	if(ro==-1)
	{
		cout<<1;
		return 0;
	}
	dfs(ro,-1);
	printf("%d",dp[ro]);
	return 0;
}

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

public class Main {
	static long[] dp;
	static int mod = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		sc.close();

		dp = new long[s + 1];
		Arrays.fill(dp, -1);
		dp[0] = 1;
		System.out.println(dfs(s));
	}

	static long dfs(int s) {
		if (dp[s] != -1) {
			return dp[s];
		}
		if (1 <= s && s <= 2) {
			return dp[s] = 0;
		}
		if (3 <= s && s <= 5) {
			return dp[s] = 1;
		}

		long ret = 0;
		for (int i = s - 3; i >= 0; i--) {
			ret += dfs(i);
			ret %= mod;
		}
		return dp[s] = ret;
	}
}


Measured memory_bytes: 36224
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
bool chmin(ll& a, ll& b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll& b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
string S;
int main() {
    cin >> S;
    rep(i, S.length()) {
        cout << "x";
    }
}

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

int main() {
  int N;
  cin >> N;
  vector<int>vec(N);
  for (int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  int A, B;
  A = 0;
  B = 0;
  for(int j= 0; j<N/2; j++){
    A += vec.at(2*j);
    B += vec.at(2*j+1);
  }
  if (N%2 ==1)
     A+= vec.at(N-1);
    
  cout << A-B <<endl;
}
    
    
    
  

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

int main(void)
{
    int l;
    cin >> l;

    double a,ans=0;
    a = (double)l / 3.0;

    if(a*3!=(double)l)
        ans = a*a*((double)l-2*a);
    else
        ans = pow(a, 3);

    cout << fixed << setprecision(6) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[]args) {
	Scanner s = new Scanner(System.in);
	int n = s.nextInt();
	int a = s.nextInt();
	int b = s.nextInt();

	int costTrain = n * a;
	int costTaxi = b ;

	if(costTrain<=costTaxi){
		System.out.println(costTrain);
	}else
	{
		System.out.println(costTaxi);
	}

}
}


Measured memory_bytes: 22996