akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <numeric>

using namespace std;


int main(){
    int d,n;
    cin>>d>>n;
    int ans;
    ans=pow(100,d)*n;
    if(n==100)ans+=pow(100,d);
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  ll N;
  cin >> N;
  ll beki[35];
  beki[0]=1;
  for(int i=1;i<35;i++){
    beki[i]=-2LL*beki[i-1];
  }
  int bit[35];
  fill(bit,bit+35,-1);
  bit[0]=0;
  for(int i=0;i<34;i++){
    if(N==0LL) break;
    if(N%beki[i+1]!=0){
      bit[i]=1;
      N-=beki[i];
    }else{
      bit[i]=0;
    }
  }

  for(int i=34;i>=0;i--){
    if(bit[i]!=-1){
      cout << bit[i];
    }
  }
  cout << endl;
  return 0;
}

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

#define get_variable_name(x) #x
#define debug(x) cout << #x << " = " << x << endl

#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())
#define REVERSE(x) reverse( (x).begin(),(x).end())
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define PW(x) (1LL<<(x))

using namespace std;
using ll = int64_t;
using P = pair<int, int>;

template<class T,class U>
ostream& operator<<(ostream &os, const pair<T, U> &p) {
    os << get_variable_name(p) << " = (" << p.first <<", " << p.second << ")";
    return os;
}

template<class T>
ostream& operator <<(ostream& os, const vector<T> &v){
    cout << get_variable_name(v) << " = [";
    for(auto i : v) 
        os << " " << i;
    os << " ]";
    return os;
}


const int INF = 1e8;

int main() {
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    cout << N*(N+1)/2 << endl;
}


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

using namespace std;

static const int INF = 1e9 + 7;

using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using ull = unsigned long long;



void hawawa()
{
  int n, x;
  cin >> n >> x;
  vector<ll> a(n);
  for (auto&& i : a)
  {
    cin >> i;
  }
  long long ans = 0;
  for (int i = 1; i < n; i++) {
    if (a[i - 1] + a[i] <= x) continue;
    long long dist = a[i - 1] + a[i] - x;
    ans += dist;
    a[i] = max(0ll, a[i] - dist);
    dist = a[i - 1] - x;
    if (a[i - 1] > x) {
      a[i - 1] -= dist;
    }
  }
  cout << ans << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  hawawa();
}

Measured memory_bytes: 1024
s = input()
year = int(s[0:4])
month = int(s[5:7])
day = int(s[8:10])
if year < 2019:
    print('Heisei')
elif year == 2019 and month < 4:
    print('Heisei')
elif year == 2019 and month == 4 and day < 31:
    print('Heisei')
else:
    print('TBD')

Measured memory_bytes: 3060
import sys
ans1, ans2, count = 0,0.0,0
for line in sys.stdin:
	num = (map(int, line.split(",")))
	ans1, ans2, count = ans1 + num[0]*num[1], ans2 + num[1], count + 1
print ans1
print int(round(ans2/count))

Measured memory_bytes: 6392
#include <bits/stdc++.h>
using namespace std;
#define N 100100
#define M 1010

int n,m,b,c;
int a[N],line[N],mp[M][M];

int main()
{
	scanf("%d%d",&n,&m);
	b=1;
	for (int i=2;i<=100 && b<n;i+=2)
	{
		line[i]=1; b++; c=1;
		for (int j=2;j<=98 && b<n;j+=2) mp[i-1][j]=1,b++;
	}
	for (int i=100;i && c<m;i-=2)
		for (int j=1;j<=99 && c<m;j+=2) mp[i][j]=1,c++;
	puts("100 100");
	for (int i=1;i<=100;i++)
	{
		if (line[i]) for (int j=1;j<=100;j++) printf("#"); else
		for (int j=1;j<=100;j++) printf(mp[i][j] ? "#" : ".");
		puts("");
	}
	return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}

void solve()
{
	int n, a, b, c;
	cin >> n >> a >> b >> c;
	int l[n] , res = inf;
	for(int i = 0; i < n; ++i) cin >> l[i];
	rep(i, (1 << n)){
		rep(j, (1 << n)){
			rep(k, (1 << n)){
				int x = 0, y = 0, z = 0;
				int u = 0, v = 0, w = 0;
				rep(t, n){
					int m = (1 << t);
					if(i & m){
						++u;
						x += l[t];
					}
					else if(j & m){
						++v;
						y += l[t];
					}
					else if(k & m){
						++w;
						z += l[t];
					}	
				}
				if(!u || !v || !w) continue;
				res = min(res, abs(x - a) + abs(y - b) + abs(z - c) + (u + v + w - 3) * 10);
			}
		}
	}
	cout << res << '\n';
	
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
#define pi acos(-1)
const int MOD = 1000000007; // 998244353
int32_t main(){
	boost;
	//freopen(".in","r",stdin);
	ld A,B,H,M;
	cin>>A>>B>>H>>M;
	ld degH,degM;
	H+=(M/60.0);
	degM=((M*360.0)/60.0);
	degH=(((H*5.0)*360.0)/60.0);
	ld angle=(abs(degH-degM)*pi)/180.0;
	cout<<fixed<<setprecision(15)<<sqrt(A*A+B*B-2*A*B*cos(angle))<<"\n";
	return 0;
}

//do smth instead of nothing and stay organized
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 4184
#include<bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long n,i,sum=0;
    static unsigned long long ara[200003];
    cin>>n;
    for(i=0;i<n;i++)
        cin>>ara[i];
    sort(ara, ara+n, greater<unsigned long long>());
    for(i=0;i<n-1;i++)
    {
        if(i==0)
            sum=sum+ara[i];
        else if(i%2==0)
            sum=sum+ara[i/2];
        else
            sum=sum+ara[i/2+1];
    }
    cout<<sum<<"\n";
    return 0;
}


Measured memory_bytes: 5192
#include <iostream>
#include <cstdio>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
struct node
{
    ll a,b,c;
    bool operator==(node &m)const
    {
        return (a==m.a&&b==m.b&&c==m.c);
    }
}an[10][20004];
ll ans[10];

bool operator<(const node &x,const node &y)
{
    ll sum1 = x.a+x.b+x.c;
    ll sum2 = y.a+y.b+y.c;
    if(sum1 != sum2)
        return sum1 < sum2;
    if(x.a != y.a)
        return x.a < y.a;
    if(x.b != y.b)
        return x.b < y.b;
    if(x.c != y.c)
        return x.c < y.c;
    return false;
}
bool cmp(const node &x,const node &y)
{
    return y < x;
}
//set<node> s;
int main()
{
    int n,m,cnt=0;
    scanf("%d%d",&n,&m);
    for(int i = 0; i < n; i++)
    {
        node tem;
        scanf("%lld%lld%lld",&tem.a,&tem.b,&tem.c);
        //if(s.find(tem)==s.end())
        //{
            //printf("没有%lld %lld %lld\n",tem.a,tem.b,tem.c);
           // s.insert(tem);
            for(int j = 0; j < 8; j++)
            {
                an[j][i].a = (j&4)==0?tem.a:-tem.a;
                an[j][i].b = (j&2)==0?tem.b:-tem.b;
                an[j][i].c = (j&1)==0?tem.c:-tem.c;
            }
           //cnt++;
       // }

    }
   // printf("cnt==%d\n",cnt);
    for(int i = 0; i < 8; i++)
        sort(an[i],an[i]+n,cmp);
    //if(m > cnt)
     //  return -1;//m=cnt;
    for(int i = 0; i < 8; i++)
    {
        ans[i] = 0;
        for(int j = 0; j < m; j++)
        {
            ans[i] += (an[i][j].a+an[i][j].b+an[i][j].c);
        }
    }
    ll maxx = -1;
    for(int i = 0; i < 8; i++)
    {
        if(ans[i]>maxx)
            maxx = ans[i];
    }
    printf("%lld\n",maxx);
    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
ll n,k;
  cin>>n>>k;
  if(k%2==1){
    ll c=n/k; 
    c*=c*c;
    cout<<c<<endl;
  }
  else{
    ll c=n/k; 
    ll v=c;
    c*=c*c;
    //cout<<c<<endl;
    k/=2;
    ll d=n/k-v;
    d*=d*d;
    c+=d;
    cout<<c<<endl;
  }
}

Measured memory_bytes: 3572
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll H;
ll W;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;
vll MASU[base10_5];
ll CNT[2000][2000]={};
ll CNTH[2000][2000]={};
ll llmin(ll a,ll b){
    if(a>=b) return b;
    return a;
}
ll llmax(ll a,ll b){
    if(a<=b) return b;
    return a;
}
int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> H;
    cin >> W;
    rep(hi,H){
        string S;
        cin >> S;
        rep(wi,W){
            //cout << wi << endl;
            if(S.substr(wi,1)=="#")   MASU[hi].push_back(1);
            else             MASU[hi].push_back(0);
        }
    }

    ll ans = 0;

    rep(hi,H){
        ll bef = 1;

            rep(wi,W){
            if(MASU[hi][wi]==0){
                if(bef==0) CNT[hi][wi] = CNT[hi][wi-1];
                else{
                    ltmp = 1;
                    while(1){
                        if(wi+ltmp>=W) break;
                        if(MASU[hi][wi+ltmp]==1) break;
                        ltmp++;
                    }
                    CNT[hi][wi]+=ltmp;
                }
            }
            bef = MASU[hi][wi];
        }
    }
    rep(wi,W){
        ll bef = 1;
        rep(hi,H){
            if(MASU[hi][wi]==0){
                if(bef==0) CNTH[hi][wi] = CNTH[hi-1][wi];
                else{
                    ltmp = 1;
                    while(1){
                        if(hi+ltmp>=H) break;
                        if(MASU[hi+ltmp][wi]==1) break;

                        ltmp++;
                    }
                    CNTH[hi][wi]+=ltmp;
                }
            }
            bef = MASU[hi][wi];
        }
    }


    rep(hi,H){
        rep(wi,W){
            ans = llmax(ans,CNT[hi][wi]+CNTH[hi][wi]-1);
        }
    }
    cout << ans << endl;
    

}

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A * B == C * D) {
        cout << A * B;
    } else if (A * B > C * D) {
        cout << A * B;
    } else {
        cout << C * D;
    }
}

Measured memory_bytes: 256
n,r = gets.split.map(&:to_i)
while n !=0 && r != 0
	res = []
	n.downto(1) do |i|
		res.push(i)
	end
	0.upto(r-1) do |i|
		p,c = gets.split.map(&:to_i)
		tmp = []
		(p-1).upto(p+c-2) do |i|
			tmp.push(res[i])
		end
		0.upto(n-1) do |i|
			next if p-1 <= i && i < p + c -1 
			tmp.push(res[i])
		end
		res = tmp
	end
	n,r = gets.split.map(&:to_i)
	puts res[0]
end

Measured memory_bytes: 9464
#include<bits/stdc++.h>
#define MaxN 100000+100
using namespace std;
int a[3];
int b[3];
bool check()
{
	for(int i=0;i<3;i++)
		if(a[i]%2==1)
			return false;
	return true;
}
void opee()
{
	b[0]=(a[1]+a[2])/2;
	b[1]=(a[0]+a[2])/2;
	b[2]=(a[0]+a[1])/2;
	for(int i=0;i<3;i++)	
		a[i]=b[i];
}
int main()
{
	for(int i=0;i<3;i++)
		scanf("%d",&a[i]);
	if(a[0]==a[1]&& a[1]==a[2] && a[0]%2==0)
		printf("-1\n");
	else
	{
		int ope=0;
		while(check())
		{
			ope++;
			opee();
		}
		printf("%d\n",ope);
	}
	return 0;
}

Measured memory_bytes: 256
#include<string>
#include<iostream>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    string a[n],b[m];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    if(m>n){
        cout<<"No"<<endl;
        return 0;
    }
    else{
        for(int i=0;i<=n-m;i++){
            for(int l=0;l<=n-m;l++){
                int f=0;
                for(int j=i;j<m+i;j++){
                    for(int k=l;k<m+l;k++){
                        if(a[j][k]!=b[j-i][k-l]){
                            f=1;
                            break;
                        }
                    }
                    if(f==1){
                        break;
                    }
                }
                if(f==0){
                    cout<<"Yes"<<endl;
                    return 0;
                }
            }
        }
        cout<<"No"<<endl;
        return 0;
    }
}

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

int dp[ma + 1][ma + 1];

string getLCS(string& x, string& y, int len)
{
	string lcss = "";
	int i = x.length();
	int j = y.length();
	while (len > 0)
	{
		if (x[i - 1] == y[j - 1])
		{
			lcss = x[i - 1] + lcss;
			i--;
			j--;
			len--;
		}
		else
		{
			if (dp[i][j - 1] > dp[i - 1][j])
			{
				j--;
			}
			else
			{
				i--;
			}
		}
	}
	return lcss;
}


int lcsTopDown(int i, int j, string& x, string& y)
{
	if (i == 0 || j == 0)
	{
		return 0;
	}
	if (dp[i][j] != -1)
	{
		return dp[i][j];
	}
	if (x[i - 1] == y[j - 1])
	{
		dp[i][j] = 1 + lcsTopDown(i - 1, j - 1, x, y);
		return dp[i][j];
	}
	else return dp[i][j] = max(lcsTopDown(i - 1, j, x, y), lcsTopDown(i, j - 1, x, y));
}

int main()
{
	memset(dp, -1, sizeof(dp));
	string a, b;
	cin >> a >> b;
	int length = lcsTopDown(a.length(), b.length(), a, b);
	cout << getLCS(a, b, length);
}


Measured memory_bytes: 39280
fn keta(x: usize) -> usize {
    let mut keta = 0;
    let mut y = x;
    while y > 0 {
        keta += 1;
        y /= 10;
    }
    keta
}

fn top(x: usize) -> usize {
    let mut top = 0;
    let mut y = x;
    while y > 0 {
        top = y;
        y /= 10;
    }
    top
}

fn main() {
    let n = read::<usize>();
    let k = keta(n);
    //let t = top(n);
    //let b = n % 10;

    let mut count = 0;
    for i in 1..n + 1 {
        if i % 10 == 0 {
            continue;
        }
        for j in 1..k + 1 {
            //println!("{} {}", i, j);
            if j == 1 {
                if top(i) == i % 10 {
                    count += 1;
                }
            } else if j == 2 {
                if top(i) + i % 10 * 10 <= n {
                    count += 1;
                }
            } else if j == k {
                if i % 10 < top(n) {
                    count += 10usize.pow((j - 2) as u32);
                } else if i % 10 == top(n) {
                    let a = 10usize.pow((k - 1) as u32) * (i % 10);
                    count += (n - a) / 10;
                    if top(i) <= n % 10 {
                        count += 1;
                    }
                }
            } else {
                count += 10usize.pow((j - 2) as u32);
            }
        }
    }
    println!("{}", count);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main(){
    int A,B,C;
    cin>>A>>B>>C;
    if(A==B&&B==C){
        cout<<"No"<<endl;
    }else if(A!=B&&B!=C&&A!=C){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC137A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            if (((a + b) > (a - b)) && ((a + b) > (a * b)))
            {
                Console.WriteLine(a + b);
            }
            else if (((a - b) > (a + b)) && ((a - b) > (a * b)))
            {
                Console.WriteLine(a - b);
            }
            else if (((a * b) > (a - b)) && ((a * b) > (a + b)))
            {
                Console.WriteLine(a * b);
            }
            else if (((a * b) ==(a - b)) && ((a * b) > (a + b)))
            {
                Console.WriteLine(a * b);
            }
            else if (((a * b) == (a + b))&& ((a * b) > (a - b)))
            {
                Console.WriteLine(a * b);
            }
            else if (((a - b) == (a + b)) && ((a - b) > (a * b)))
            {
                Console.WriteLine(a - b);
            }
            else if (((a - b) == (a + b)) && ((a - b) == (a * b)))
            {
                Console.WriteLine(a - b);
            }


            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

int main(){
    string S;
    cin>>S;
    ll N = S.size();
    vv rem(N+1,v(13));

    rem[0][0] = 1;
    ll now =1;
    rep(i,1,N+1){
        if(S[N-i] == '?'){
            rep(j,0,13)rep(k,0,10){
                rem[i][(j+k*now)%13] += rem [i-1][j];
                rem[i][(j+k*now)%13] %= MOD;
            }
        }
        else{
            int num = S[N-i]-'0';
            rep(j,0,13){
                rem[i][(j+num*now)%13] = rem[i-1][j];
                rem[i][(j+num*now)%13] %= MOD;
            }
        }
        now*=10;
        now %= 13;
    }
    cout<<rem[N][5];
    return 0;
}

Measured memory_bytes: 13568
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int INF=1e9;
ll devine(ll x,ll y){
  if(x<0&&y<0){
    if(x%y<0){return (x/y)+1;}
  }
  return x/y;
}
ll amari(ll x,ll y){
  if(x<0&&y<0){
    if(x%y<0){return (x%y)-y;}
  }
  return x%y;
}
int main(){
  ll n,x;
  cin>>n;
  vll bit(0);
  if(n==0){cout<<0<<endl;}
  else{
    while(n!=0){
      x=amari(n,-2);
      n=devine(n,-2);
      bit.push_back(x);
    }
    for(int i=bit.size();i>0;i--){
      cout<<bit[i-1];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*2
#define REP(i,n) for(long long i = 0;i < n;++i)
#define cycle_per_sec 2806192512
int main() {
	int n, m;
	cin >> n >> m;
	vector<tuple<long long,long long,long long>> hoge;
	REP(i, n) {
		long long a, b, c;
		cin >> a >> b >> c;
		hoge.push_back(make_tuple(a,b,c));
	}
	long long ans = 0;
	for (int i = -1; i < 2;i += 2) {
		for (int q = -1; q < 2; q += 2) {
			for (int j = -1; j < 2; j += 2) {
				vector<long long> oo;
				long long pre_ans = 0;
				for (int t = 0; t < n; ++t) {
					oo.push_back(get<0>(hoge[t]) * i + get<1>(hoge[t]) * q + get<2>(hoge[t]) * j);
				}
				sort(oo.begin(), oo.end(), greater<long long>());
				REP(i, m) {
					pre_ans += oo[i];
				}
				ans = max(ans, pre_ans);
			}
		}
	}
	cout << ans << endl;
}
/*
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <fstream>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <assert.h>
using namespace std;
#define eps 0.000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define seg_size 65536*2
#define REP(i,n) for(long long i = 0;i < n;++i)
#define cycle_per_sec 2806192512
int main() {
int d, n;
cin >> d >> n;
int cnt = 0;
int divise = 1;
for (int i = 0; i < d; ++i) {
divise *= 100;
}
for (int i = 1; i >= 0; ++i) {
if (i % divise == 0) {
int hoge = i / divise;
if (hoge % 100 != 0) {
cnt++;
if (cnt == n) {
cout << i << endl;
return 0;
}
}
}
}
}*/

Measured memory_bytes: 256
#E red and green apples

x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)

ans1 = p[:x]+q[:y]
ans1.sort()

for i in range(c):
    if r[i] > ans1[i]:
        ans1[i] = r[i]
    else:
        break

print(sum(ans1))

Measured memory_bytes: 23328
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x,a[100000];
	long long ans=0;
	cin>>n>>x;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++){
		if(a[i]>x){
			ans+=a[i]-x;
			a[i]=x;
		}
	}
	for(int i=0;i<n-1;i++){
		if(a[i]+a[i+1]>x){
			ans+=a[i+1]+a[i]-x;
			a[i+1]=x-a[i];
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define pb push_back
#define f first
#define s second

using namespace std;

const int N=1e5+5;
const int MOD=1e9+7;

typedef long long ll;
typedef long double ld;

void inlld(ll &a){scanf("%lld", &a);}
void ind(int &a){scanf("%d", &a);}

ll n, k, arr[N];

int main()
{
	inlld(n);
	inlld(k);
	for(ll a=1; a<=n; a++)
		inlld(arr[a]);
	ll ans_for_one=0;
	for(ll a=2; a<=n; a++)
		for(ll b=1; b<a; b++)
			if(arr[b]>arr[a])
				ans_for_one++;
	ll ans=(ans_for_one*k)%MOD;
	for(ll a=1; a<=n; a++)
	{
		ll num_greater=0;
		for(ll b=1; b<=n; b++)
			if(arr[b]>arr[a])
				num_greater++;
		ll toadd=(k*(k-1))/2;
		toadd%=MOD;
		toadd*=num_greater;
		toadd%=MOD;
		ans+=toadd;
		ans%=MOD;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string output = "No";
            for (int i = 0; i <= 14; i++)
            {
                if ((N - i * 7) % 4 == 0 && (N - i*7)>=0)
                {
                    output = "Yes";
                    break;
                }
            }
            Console.WriteLine(output);
        }

    }
}


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

int main() {
	string m;
	cin >> m;
	int s = 0, n = 0, w = 0, e = 0;
	for (int i = 0;i < m.size();i++) {
		if (m[i] == 'S')s++;
		else if (m[i] == 'N')n++;
		else if (m[i] == 'W')w++;
		else if (m[i] == 'E')e++;
	}
	if (s > 0 && n > 0 && w > 0 && e > 0)cout << "Yes";
	else if (s == 0 && n == 0 && w > 0 && e > 0)cout << "Yes";
	else if (s > 0 && n > 0 && w == 0 && e == 0)cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int n;
int a[100003];
int s[100003];

int main()
{
	cin >> n;

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

		if (i == 2)
		{
			s[2] = abs(a[2] - a[1]);
		}

		if (i > 2)
		{
			int x = s[i - 2] + abs(a[i - 2] - a[i]);
			int y = s[i - 1] + abs(a[i - 1] - a[i]);
			s[i] = min(x, y);
		}
	}

	cout << s[n] << endl;

	return 0;
}

Measured memory_bytes: 1024
n =int(input())
lista = [input().split() for i in range(n)]
x = input()
dicta = dict(lista)
rmnum = lista.index([x,dicta.get(x)])
lista[0:rmnum+1] =[]
ans = 0
for i in range(len(lista)):
    ans+=int(dicta.get(lista[i][0]))
print(ans)

Measured memory_bytes: 3064
n, m, x = map(int, input().split())
import numpy as np
import itertools

l = []
for i in range(n):
    l.append(list(map(int, input().split())))

arr = np.array(l)

minimum = 10 ** 5 * 13
for boo in itertools.product([True, False], repeat=n):
    if arr[np.array(list(boo))].sum(axis=0)[1:m+1].min() >= x:
        temp = arr[np.array(list(boo))].sum(axis=0)[0]
        if temp < minimum:
            minimum = temp

if arr.sum(axis=0)[1:m+1].min() < x:
    print(-1)
else:
    print(minimum)

Measured memory_bytes: 27344
def is_leap_year(y)
  return y%4==0&&y%100!=0 || y%400 == 0;
end

fst = true

loop do
  a, b = gets.split.map(&:to_i)

  break if a == 0 && b == 0

  puts "" if !fst

  fst = false
  
  fl = false
  
  for i in a..b
    if is_leap_year i
      print i, "\n"

      fl = true
    end
  end

  puts "NA" if !fl
end

Measured memory_bytes: 8708
#include <stdio.h>

int main(){
    int a;
    scanf("%d", &a);
    printf("%d:%d:%d\n", a / 3600, (a - 3600*(a/3600))/60, a - 60*((a - 3600*(a/3600))/60) - 3600*(a/3600));
    return 0;
}


Measured memory_bytes: 2056
n, a, b = [ int(v) for v in input().split() ]
town_list = [ int(v) for v in input().split() ]
fatigue_list = [ 0 for i in range(n) ]

for i in range(n-1):
	d = town_list[i+1] - town_list[i]
	fatigue_list[i+1] = fatigue_list[i] + min(a*d,b)
print(fatigue_list[-1])


Measured memory_bytes: 64408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int like[10] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};

int check(int x) {
    int y;
    while(x) {
        int y = x % 10;
        if(like[y] == false) {
            return false;
        }
        x /= 10;
    }
    return true;
}

int main() {
    int N, K, D;


    cin >> N >> K;

    for(int i = 0;i < K; ++i) { // 1 is considered true
        cin >> D;
        like[D] = 0; // dislike a number
    }

    int x, y;
    for(int i = N;i < 100000; ++i) {
        if(check(i)) {
            cout << i;
            break;
        }

    }

}


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

using namespace std;

int gcd(int a, int b){

    if(b > a){
        int t = a;
        a = b;
        b = t;
    }

    if(b == 0){
        return a;
    }

    return gcd(b, a % b);
}

int main(){

    int N;
    cin >> N;
    vector<int> A;
    A.reserve(N);

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

    vector<int> l, r;
    l.reserve(N);
    r.reserve(N);

    l[0] = A[0];
    for(int i = 1; i < N; i++){
        l[i] = gcd(l[i - 1], A[i]);
    }

    r[N - 1] = A[N - 1];
    for(int i = N - 2; i >= 0; i--){
        r[i] = gcd(r[i + 1], A[i]);
    }

    int ans = max(r[1], l[N - 2]);
    for(int i = 1; i < N - 1; i++){
        temp = gcd(l[i - 1], r[i + 1]);
        ans = max(ans, temp);
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<stack>

using namespace std;
int d[100],f[100];
int M[100][100];
int n,t=0;

void dfs(int s){
    stack<int> S;
    int u;
    bool found=0;
    
    S.push(s);
    d[s]=++t;
    while( !S.empty() ){
	u=S.top();
	found=0;
	for(int v=0;v<n;v++){
	    if(M[u][v]==1 && d[v]==0){
		S.push(v);
		d[v]=++t;
		found=1;
		break;
	    }
	}
	if(found==0){
	    S.pop();
	    f[u]=++t;
	}
    }
}
    
int main(){
    int u,k,v;

    cin >> n;
    for(int i=0;i<n;i++){
	cin >> u >> k;
	u--;
	for(int j=0;j<k;j++){
	    cin >> v;
	    v--;
	    M[u][v]=1;
	}
    }

    for(int i=0;i<n;i++){
	if(d[i]==0) dfs(i);
    }

    for(int i=0;i<n;i++){
	cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3084
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef vector<string> VS;
//typedef pair<int, int> pii;
//typedef vector<pii> VP;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;
struct edge { int to, cost; };
int N;
vector<vector<edge> >G;


typedef pair<int, int> P;
VI d;

void dikstra(int s) {
	priority_queue<P, vector<P>, greater<P> >que;
	REP(i, N)d[i] = INF;
	d[s] = 0;
	que.push(P(0, s));
	while (!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if (d[v] < p.first)continue;
		REP(i, G[v].size()) {
			edge e = G[v][i];
			if (d[e.to] > d[v] + e.cost) {
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to], e.to));
			}
		}
	}
}

void chokkei(int *s, int *g) {
	dikstra(0);
	int ma = -1;
	REP(i, N) {
		if (ma < d[i]) {
			*s = i;
			ma = d[i];
		}
	}
	dikstra(*s);
	ma = -1;
	REP(i, N) {
		if (ma < d[i]) {
			*g = i;
			ma = d[i];
		}
	}
}


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

	cin >> N;
	d.resize(N);
	G.resize(N);
	REP(i, N - 1) {
		int a, b, c; cin >> a >> b >> c; 
		G[a].push_back((edge) { b, c });
		G[b].push_back((edge) { a, c });
	}
	int s, g;
	chokkei(&s, &g);
	//cout << s << " " << g << endl;
	cout << d[g] << endl;
	
	return 0;
}




Measured memory_bytes: 11932
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    string s;cin>>s;
    bool b=true;
    ll n=s.size();
    rep(i,n)if(s[i]!=s[n-1-i])b=false;
    rep(i,(n-1)/2)if(s[i]!=s[(n-1)/2-1-i])b=false;
    REP(i,(n+3)/2,n)if(s[i]!=s[n-1-i])b=false;
    if(b)out("Yes");
    else out("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int N; cin>>N;
	vector<ll> A(N);
	ll ans = 1;
	rep(i,N){cin>>A[i]; if(A[i] == 0){ans = 0;}}
	if(ans == 0){cout<<ans<<endl; return  0;}
	ll max = 1e18;
	rep(i,N){
		if(max/ans < A[i]){cout<<-1<<endl; return 0;}
		ans *= A[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4048
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	if len(x) == 0:
		return []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa != x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans

"""
def nibu(x,n,r):
	ll = 0
	rr = r
	while True:
		mid = (ll+rr)//2

	if rr == mid:
		return ll
	if (ここに評価入れる):
		rr = mid
	else:
		ll = mid+1
"""

n = onem()
nn = n
N = 1
co = 0
while True:
	N *= 2
	if n < N:
		break
	co += 1
	if co > 19:
		break

data = []

ap = 1
for i in range(1,co+1):
	data.append([i,i+1,0])
	data.append([i,i+1,ap])
	ap *= 2
for i in range(co,-1,-1):
	if n - pow(2,i) >= pow(2,co):
		data.append([i+1,co+1,n-pow(2,i)])
		n -= pow(2,i)
print(co+1,len(data))
for i in range(len(data)):
	print(jo(data[i]))

Measured memory_bytes: 65612
#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 k;
    string s;
    cin >> k >> s;
    if (s.size() <= k) return cout << s, 0;
    s = s.substr(0, k);
    cout << s + "...";
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

long long int dp[101000];

int main()
{
    int n, k;
    int a[101000];

    cin >> n >> k;

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

    for (int i = 0; i <= n; i++) {
        dp[i] = 1LL << 30;
    }

    dp[0] = dp[1] = 0;

    for (int i = 1; i < n; i++) {
        for (int j = 1; j <= k; j++) {
            if (dp[i+j] > dp[i]+abs(a[(i+j)-1]-a[i-1])) {
                dp[i+j] = dp[i]+abs(a[(i+j)-1]-a[i-1]);
            }
        }
    }
    
    cout << dp[n] << endl;
}


Measured memory_bytes: 1408
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll mod=1e9+7;

int main()
{
    ll k,t;
    cin >> k >> t;
    vector<ll> a(t);
    ll sum=0;
    rep(i,t){
        cin >> a[i];
        sum+=a[i];
    }
    sort(a.rbegin(),a.rend());
    cout << max(0LL,a[0]*2-sum-1) << endl;
    
    return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#define MAX_N 250
 
int N;
int heap[MAX_N];
 
int main() {
  int i, parent, left, right;
  scanf("%d", &N);
  for(i = 0; i < N; ++i) {
    scanf("%d", heap+i);
  }
  for(i = 0; i < N; ++i) {
    printf("node %d: key = %d, ", i+1, heap[i]);
    parent = (i-1)/2;
    left = i*2 + 1;
    right = i*2 + 2;
    if(i != 0) printf("parent key = %d, ", heap[parent]);
    if(left < N) printf("left key = %d, ", heap[left]);
    if(right < N) printf("right key = %d, ", heap[right]);
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 2064
#!/usr/bin/python
# -*- coding: utf-8 -*-

# def
def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

def str_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(input()))
    return np.array(x)

def int_map():
    return map(int,input().split())

def int_list():
    return list(map(int,input().split()))

def print_space(l):
    return print(" ".join([str(x) for x in l]))

# import
import numpy as np
import collections as col
from scipy.sparse.csgraph import connected_components
from scipy.sparse import csr_matrix

# main
N,M =int_map()
AB = int_mtx(M)

n, _ = connected_components(csr_matrix(([1]*M, (AB[:,0]-1, AB[:,1]-1)),(N,N)))

print(n-1)

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

using namespace std;

int main(){
  int K;
  cin >> K;
  vector<int> s(32);

  s[0] = 1;
  s[1] = 1;
  s[2] = 1;
  s[3] = 2;
  s[4] = 1;
  s[5] = 2;
  s[6] = 1;
  s[7] =  5;
  s[8] =  2;
  s[9] =  2;
  s[10] =  1;
  s[11] =  5;
  s[12] = 1;
  s[13] =  2;
  s[14] =  1;
  s[15] =  14;
  s[16] =  1;
  s[17] =  5;
  s[18] =  1;
  s[19] =  5;
  s[20] =  2;
  s[21] =  2;
  s[22] =  1;
  s[23] =  15; 
  s[24] = 2;
  s[25] =  2;
  s[26] =  5;
  s[27] =  4;
  s[28] =  1;
  s[29] =  4;
  s[30] =  1;
  s[31] =  51;

  cout << s[K - 1];


  
 return 0;
}





Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int a, b, x;
int main()
{
	scanf("%d %d %d", &x, &a, &b);
	if(a >= b) printf("delicious\n");
	else if((a + x) >= b) printf("safe\n");
	else printf("dangerous\n");
	return 0;
}

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

#define ll long long int
#define MAX 100001

using namespace std;

void calculate(vector<ll>& count, ll& sum)
{
  ll Q, B, C;
  cin >> Q;
  for (ll i = 0; i < Q; i++){
    cin >> B >> C;
    sum += (count[B] * (C - B));
    count[C] += count[B];
    count[B] = 0;
    cout << sum << '\n';
  }
}

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, sum = 0, element;
  cin >> N;
  vector<ll> count(MAX, 0);
  for (ll i = 0; i < N; i++){
    cin >> element;
    sum += element;
    count[element]++;
  }
  calculate(count, sum);
  return 0;
}


Measured memory_bytes: 3968
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C



N,A=ilint()
a=[0]+A[:]
x=[0]*(N+1)
ans=[]
for k in range(N,0,-1):
    tmp=0
    l=2*k
    while l<=N:
        tmp+=x[l]
        l+=k
    if tmp%2!=a[k]:
        x[k]=1
        ans.append(k)
print(len(ans))
if len(ans)>0:
    lprint(ans,' ')

Measured memory_bytes: 103716
<?php
fscanf(STDIN, "%d %d", $h, $w);
for ($i = 0; $i < $h; $i++) {
	fscanf(STDIN, "%s", $s[]);
}
$vs = [[1,0],[1,1],[1,-1],[0,1],[0,-1],[-1,0],[-1,1],[-1,-1]];
for ($i = 0; $i < $h; $i++) {
	for ($j = 0; $j < $w; $j++) {
		if ($s[$i][$j] == '.') {
			$c = 0;
			foreach ($vs as $v) {
				$x = $i + $v[0];
				$y = $j + $v[1];
				if (isset($s[$x][$y]) && $s[$x][$y] == '#') {
					$c++;
				}
			}
			$s[$i][$j] = $c;
		}
	}
}
echo implode("\n", $s);

Measured memory_bytes: 4856
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
#from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    h, n = map(int, input().split())
    a = list(map(int, input().split()))
    print("Yes") if sum(a) >= h else print("No")

if __name__ == '__main__':
    main()



Measured memory_bytes: 78272
N = int(input())
X = input()
X_arr = list(X)
N, X = int(N), int(X, 2)
MAX_N = 2 * 10 ** 5


def popcount(x):
    cnt = 0
    for i in range(x.bit_length()):
        if x & 1 << i:
            cnt += 1
    return cnt


memo = [0] * (MAX_N + 1)
for i, n in enumerate(range(1, MAX_N + 1), start=1):
    cnt = 0
    while n:
        p = popcount(n)
        n = n % p
        cnt += 1
    memo[i] = cnt


x_popcount = popcount(X)
p_upper, p_downer = x_popcount + 1, x_popcount - 1
y_upper = X % p_upper
y_downer = X % p_downer if p_downer else None

for i in range(N):
    if X_arr[i] == '0':
        z = (y_upper + pow(2, (N - i - 1), p_upper)) % p_upper
    else:
        if not p_downer:
            print(0)
            continue
        z = (y_downer - pow(2, (N - i - 1), p_downer)) % p_downer

    print(memo[z] + 1)


Measured memory_bytes: 12440
#include <stdio.h>
int main(void){
	int p_vol,day,remain,sum=0,l,weight;
	scanf("%d",&p_vol);
	scanf("%d %d",&day,&remain);
	for (int i = 0; i < p_vol; ++i){
		scanf("%d",&weight);
		l=(day-1)/weight;
		sum=sum+l+1;
	}
	sum=sum+remain;
	printf("%d\n",sum);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <numeric>
 
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
string S,T;
vector<ll> so;


ll N,K,M;

int main() {
    cin >> N;
    ll i = 2;
    while(true){
        bool found = false;
        for(int j=0;j<so.size();j++){
            if(i%so[j]==0){
                found = true;
                break;
            }
        }
        if(!found){
            so.push_back(i);
            if(i>=N){
                cout << i << endl;
                return 0;
            }
        }
        i++;
    }
    
}


Measured memory_bytes: 3664
#include <stdio.h>

int main()
{
	int n, k, i, j, tmp, sum = 0;
	int l[50];

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

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

	for (i = 0; i < n; i++){
		for (j = n -1; j > i; j--){
			if (l[j] > l[j - 1]){
				tmp = l[j];
				l[j] = l[j - 1];
				l[j-1] = tmp;
			}
		}
	}
	for (i = 0; i < k; i++)
		sum += l[i];

	printf("%d", sum);

	return 0;
}

Measured memory_bytes: 128