akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define INF 10000000
#define REP(i, n) for(int i = 0;i < (n);i++)
#define all(n) n.begin(),n.end()

using namespace std;

using ll = long long;
using PII = pair<int, int>;

class BIT{
	vector<ll> bit;
	int n;
public:
	BIT(int n_){
		n = n_;
		REP(i, n){
			bit.push_back(0);
		}
	}

	void add(int i, int x){
		while(i <= n){
			bit[i] += x;
			i += i & -i;
		}
	}

	int getSum(int i){
		int s = 0;
		while(i > 0){
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}
};

int main(void){
	int n, q;
	cin >> n >> q;
	BIT bit(n);
	REP(i, q){
		int com, x, y;
		cin >> com >> x >> y;
		if(com == 0){
			bit.add(x, y);
		}else{
			cout << bit.getSum(y)-bit.getSum(x-1) << endl;
		}
	}
}

Measured memory_bytes: 3848
while True:
  s = input()
  if s=="#":
    break

  g, y, m, d = s.split()
  y, m, d = int(y), int(m), int(d)
  if y>=32 or (y==31 and m>=5):
    g = "?"
    y -= 30
  print(g, y, m, d)


Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <string.h>
#include <string>

using namespace std;

int main()
{
    int n, d, x;
    cin >> n >> d >> x;
    int a[n];
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    int choco = 0;
    for (int i=0; i<n; i++) {
        int tmp = 1;
        while (true) {
            if (tmp > d) break;
            choco++;
            tmp += a[i];
        }
    }
    cout << choco+x << '\n';
   return 0;
}

Measured memory_bytes: 3608
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N = int(readline())

    p = [int(input()) for _ in range(N)]
    p.sort(reverse=True)

    ans = (p[0] // 2 + sum(p[1:]))
    print(ans)


if __name__ == '__main__':
    main()


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

int solve(int x, int i){
  if(x % 2 != 0){
    return i;
  }
  return solve(x / 2, i+1);
}

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

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

  ll ans = 0;
  for(int i = 0; i < n; i++){
    ans += solve(a[i], 0);
  }

  cout << ans << endl;

  return 0;
}

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

void CHECK_NUM(int, int);
void INCLUDE3(int, int, int);
void END_CHECK_NUM(int, int);

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

	CHECK_NUM(n, 1);

	return 0;
}

void CHECK_NUM(int n, int i)
{
	int x = i;
	if (x % 3 == 0) {
		cout << " " << i;
		END_CHECK_NUM(n, i);
	}
	INCLUDE3(x, i,n);
}

void INCLUDE3(int x, int i,int n)
{
	if (x % 10 == 3) {
		cout << " " << i;
		END_CHECK_NUM(n, i);
	}
	x /= 10;
	if (x) {
		INCLUDE3(x, i, n);
	}
	END_CHECK_NUM(n, i);
}

void END_CHECK_NUM(int n, int i)
{
	if (++i <= n) {
		CHECK_NUM(n, i);
	}
	cout << endl;

	exit(0);
}


Measured memory_bytes: 4276
n = int(input())
a = [int(input()) for i in range(n)]
b = sorted(a)
max_a = max(a)
max_cnt = a.count(max_a)
for i in range(n):

    if max_a > a[i]:
        print(max_a)
    else:
        if max_cnt > 1:
            print(a[i])
        else:
            print(b[-2])


Measured memory_bytes: 14112
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
ll dis[110][110];
ll a[1010], b[1010], c[1010];
int main() {
	ll n, m, inf = 1e15;
	rep(i,110)for (int j = i + 1; j < 110; j++)dis[i][j] = dis[j][i] = inf;
	cin >> n >> m;
	rep(i,m){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--, b[i]--;
		dis[a[i]][b[i]] = dis[b[i]][a[i]] = c[i];
	}
	rep(k,n)rep(i,n)rep(j,n)dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
	ll ans = m;
	rep(i,m)rep(j,n){
		if (dis[j][a[i]] + c[i] == dis[j][b[i]]) {
			ans--;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5+10;
// int a[N];
map<int, int> mp;
int main() {
    int n, x;
    scanf("%d",&n);
    for(int i = 0; i < n; i ++) {
        scanf("%d",&x);
        mp[x]++;
        mp[x+1]++;
        mp[x-1]++;
    }
    map<int, int> ::iterator it;
    int MAX = 1;
    for(it = mp.begin(); it != mp.end(); ++it) {
        if(MAX < (*it).second){
            MAX = (*it).second;
        }
    }
    printf("%d\n",MAX);
    return 0;
}


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

void chmax(int &a, int b){
    if(a < b) a = b;
}

int main(){
    int N;
    string S;
    cin >> N >> S;
    int res = 0;
    vector<vector<int>> dp(N+1, vector<int>(N+1, 0));
    for(int i=N-1;i>=0;i--){
        for(int j=N-1;j>i;j--){
            if(S[i] == S[j]){
                chmax(dp[i][j], dp[i+1][j+1]+1);
            }
            chmax(res, min(dp[i][j], j-i));
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 98304
//csjosh

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> //required
// #include <ext/pb_ds/tree_policy.hpp> //required
// using namespace __gnu_pbds; //required 
using namespace std;

#define ll long long 
#define loop(x) for(int i=0;i<x;i++)

#define llu unsigned long long 
#define pb push_back
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define dd fflush(stdout)
#define what_is(x) cerr << #x << " is " << x << endl;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mt make_tuple //use tie
#define eb emplace_back
typedef tuple<int,int,int> State;//use in dijkstra
// ll mod=1e9+7;
// ll power(ll x,ll y,ll mod){
//  ll ans=1;
//  while(y>0){
//   if(y&1){
//     ans=ans*x;
//   }
//   x=x*x;
//   y=y/2;
//  }
//  return ans;
// }

// typedef tree<
// pair<int, int>,
// null_type,
// less<pair<int, int>>,
// rb_tree_tag,
// tree_order_statistics_node_update> ordered_set;
 
ll h[300005];
ll  a[300006];
ll bit[566000];
int n;
ll get(int x){
ll ans=0;
for(int i=x;i>0;i=i-(i&-i))
  ans=max(bit[i],ans);
return ans;
}
void update(int x,ll y){
   for(int i=x;i<=n;i+=(i&-i)){
    bit[i]=max(bit[i],y);
   }
}
int main(){
    IOS;  
   
   cin>>n;
  memset(bit,0,sizeof bit);
   loop(n)cin>>h[i+1];
   loop(n)cin>>a[i+1];
   //first use of BIT
   ll dp[n+3];
   for(int i=1;i<=n;i++){
    dp[i]=get(h[i]-1)+a[i];
    update(h[i],dp[i]);
   }
   cout<<get(n)<<endl;
   
 }



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

int main(){
    int n, m;
    cin >> n >> m;
    int a[n];
    for(int i=0;i<n;i++){
        int b;
        cin >> b;
        a[i] = b;
    }
    cerr << "bello" << endl;
    int ans =0;
    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += a[i];                        /* 総和の計算 */
    }
    cerr << "hello" << endl;
    for(int i=0;i< n ;i++){
        if(a[i] >= ((double)sum/(4 * m))){
            ans++;
        }
    }
    if (ans >= m) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define F first
#define S second
//#define biGinf 9e+18
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define inpv(v) for(auto &x:v) cin>>x
#define otpv(v) for(auto &x:v) cout<<x<<nwl
#define otpv2(v) for(auto &x:v) cout<<x<<" "
#define CASES int tt;cin>>tt; while(tt--)
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<n; i++)
#define sz(v) (int)(v).size()
using vi = vector < int >;
using vii = vector < vi >;
using pii = pair < int , int >;
using vpii = vector < pii >;
using int64 = long long;
//const int64 biGinf = 9e+18;
//const string yo = "YES", no = "NO";
const int inf = 2e9 + 7;
const char nwl = '\n';

int64 knapsack(vpii &re, int n, int wt) {
	vector < int64 > ans(wt + 1);
	for0(i, n) {
		for (int j = wt; j >= re[i].F; j--) {
			ans[j] = max(ans[j], (int64)re[i].S + ans[j - re[i].F]);
		}
	}
	return ans[wt];
}


int main() {
// #ifndef ONLINE_JUDGE
// 	if (fopen("input.txt", "r")) {
// 		freopen("input.txt", "r", stdin);
// 		freopen("output.txt", "w", stdout);
// 	}
// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ur code
	int n, wt;
	cin >> n >> wt;
	vpii re;
	for0(i, n) {
		int x, y;
		cin >> x >> y;
		re.pb({x, y});
	}
	cout << knapsack(re, n, wt);
	return 0;
}


Measured memory_bytes: 1024
from collections import Counter
N = int(input())
D = list(map(int, input().split()))
MOD = 998244353


if D[0] != 0:
    print(0)
    exit()


if D.count(0) != 1:
    print(0)
    exit()


ans = 1
C = Counter(D)
for k, v in C.items():
    if k == 0:
        continue
    ans *= pow(C[k - 1], v, MOD)
    ans %= MOD

print(ans % MOD)


Measured memory_bytes: 24140
from math import ceil

N, A, B = map(int, input().split())
h = []
for _ in range(N):
    h.append(int(input()))
    
left = 0
right = max(h)//B + 1

while right - left > 1:
    mid = (right + left) // 2
    c = sum([ceil((hi-mid*B)/(A-B)) for hi in h if hi > mid * B])
    if c > mid:
        left = mid
    else:
        right = mid
        
print(right)

Measured memory_bytes: 11060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> ii;
typedef pair<string,ll> si;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
#define sort(a) sort(a.begin(),a.end());
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define mp make_pair
#define F first
#define S second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define nl "\n"
#define TC cin>>t;while(t--)
const int MOD = 1e9+7;
const ld PI = 3.1415926535898;
const ll LLMAX = LLONG_MAX;

int main()
{
    int n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
            sum+=i;
    }
    cout<<sum<<nl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define int long long

using namespace std;

int n=0,x=0,k=0;
int arr[200001];
vector<int> otr;
vector<int> pol;
vector<int> zeroes;
int otr_p=0, pol_p=0, zero_p=0;

int pol_pol(int a, int b)
{
	int ll = 0, rr = pol.size()-1;
	while (ll<rr-1)
	{
		int mm = (ll+rr)/2;
		if (a*pol[mm]>b)
			rr = mm;
		else
			ll = mm;
	}
	if (a*pol[ll]>b)
		return -1;
	else if (a*pol[rr]>b)
		return ll;
	else
		return rr;
}

int pol_otr(int a, int b)
{
	if (otr.size()==0)
		return -1;
	int ll = 0, rr = otr.size()-1;
	while (ll<rr-1)
	{
		int mm = (ll+rr)/2;
		if (a*otr[mm]>b)
			rr = mm;
		else
			ll = mm;
	}
	if (a*otr[ll]>b)
		return -1;
	else if (a*otr[rr]>b)
		return ll;
	else
		return rr;
}

int otr_otr(int a, int b)
{
	int ll = 0, rr = otr.size()-1;
	while (ll<rr-1)
	{
		int mm = (ll+rr)/2;
		if (a*otr[mm]>b)
			ll = mm;
		else
			rr = mm;
	}
	if (a*otr[rr]>b)
		return -1;
	else if (a*otr[ll]>b)
		return rr;
	else
		return ll;
}

int cnt(int x)
{
	int res=0;
	for (int i=0; i<pol.size(); i++)
	{
		int ii = pol_pol(pol[i], x);
		if (ii==-1)
			continue;
		res+=max(0ll, ii-i);
	}
	for (int i=0; i<otr.size(); i++)	
	{
		int ii = otr_otr(otr[i], x);	
		if (ii==-1)
			continue;
		ii = max(ii, i+1);
		res+=otr.size()-ii;	
	}		
	for (int i=0; i<pol.size(); i++)
	{
		int ii = pol_otr(pol[i], x);	
		if (ii==-1)
			continue;
		res+=ii+1;
	}
	if (x>=0)
		res+=(zeroes.size()*(n-zeroes.size()))+(zeroes.size()*(zeroes.size()-1)/2);
	return res;
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> k;
	for (int i=0; i<n; i++)
		cin >> arr[i];		
	sort(arr, arr+n);
	for (int i=0; i<n; i++)
	{
		if (arr[i]<0)
			otr.push_back(arr[i]);
		else if (arr[i]==0)
			zeroes.push_back(arr[i]);
		else
			pol.push_back(arr[i]);
	}
	otr_p = otr.size()*pol.size();
	zero_p = zeroes.size()*(n-zeroes.size());
	pol_p = pol.size()*(pol.size()-1)/2+otr.size()*(otr.size()-1)/2;
	int ll = LLONG_MIN/3;
	int rr = LLONG_MAX/3;
	while (ll<rr-1)
	{
		int mm = (ll+rr)/2;
		if (cnt(mm)<k)
			ll = mm;
		else
			rr = mm;
	}
	if (cnt(rr)<k)
		cout << rr+1;
	else if (cnt(ll)<k)
		cout << rr;
	else
		cout << ll;
	return 0;
}


Measured memory_bytes: 4468
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define WHITE 0
#define GRAY 1
#define BLACK 2
//ios::sync_with_stdio(false);
typedef long long LL;
using namespace std;
const int MAXN = 110;
int n, mapp[MAXN][MAXN], color[MAXN], d[MAXN], f[MAXN], tt;

void dfs_visit(int u) {
	color[u] = GRAY;
	d[u] = ++tt;
	for(int i = 0; i < n; i++) {
		if(mapp[u][i] == 1 && color[i] == WHITE) {
			dfs_visit(i);
		}
	}
	color[u] = BLACK;
	f[u] = ++tt;
}

void dfs() {
	tt = 0;
	memset(color, 0, sizeof(color));
	for(int i = 0; i < n; i++) {
		if(color[i] == WHITE) {
			dfs_visit(i);
		}
	}
	for(int i = 0; i < n; i++) {
		printf("%d %d %d\n", i+1, d[i], f[i]);
	}
}

int main() {
	int u, v, k;	
	cin >> n;
	memset(mapp, 0, sizeof(mapp));
	for(int i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		while(k--) {
			cin >> v;
			v--;
			mapp[u][v] = 1;
		}
	}
	dfs();
	return 0;
}




Measured memory_bytes: 3268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace atcorder_BeginnerContest_117
{
    class Program
    {
        static void Main(string[] args)
        {
            double[] dataRow = Array.ConvertAll(Console.ReadLine().Split(' '), double.Parse);
            Console.WriteLine(dataRow[0] / dataRow[1]);
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h> 
int main()
{       
	int x,y,c;       
	while(1)
	{     
		scanf("%d%d",&x,&y);       
		if( x == 0 && y == 0)       
		break;           
		if( x > y )
		{      
			 c = y;       y = x;       x = c;     
		}     
		printf("%d %d\n", x, y);     
	}     
		return 0;   
}

Measured memory_bytes: 600
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let k: usize = input();
    let mut l: Vec<i64> = (0..n).map(|_| input()).collect();
    l.sort_by_key(|l| -l);
    println!("{}", l.iter().take(k).sum::<i64>());
}


Measured memory_bytes: 4352
A = int(input())
li = list(map(int,input().split()))

ans = 1
for i in range(len(li)):
    if li[i] == 0:
        ans = 0

if ans == 0:
    print(ans)
else:
    possible = True
    for i in range(len(li)):
        if int(li[i]) * ans > 1000000000000000000:
            possible = False
            break
        else:
            ans *= li[i]
    if (possible):
        print(ans)
    else:
        print(-1)

Measured memory_bytes: 21660
//In The Name of Beauty
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define IB std::ios::sync_with_stdio(0);
#define pb(x) push_back(x);
#define mp(x,y) make_pair(x,y)
#define pll pair<ll,ll>
#define F first
#define S second
ll const MAXN = 1e5 + 8;
ll const INF  = 1e12 + 8;
ll const delta = 1000000007;

int main()
{
    IB;
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    ll a[n];
    ll mmin = INF;
    set<ll> st;
    for(ll i = 0;i < n;i++){
        cin >> a[i];
        mmin = min(mmin,a[i]);
        st.insert(a[i]);
    }
    if(st.size() > 2)return cout << "No",0;
    if(st.size() == 1){
        if(mmin == n - 1)return cout << "Yes",0;
        if(mmin * 2 <= n)return cout << "Yes",0;
        return cout << "No",0;
    }
    ll cnt = 0;
    for(ll i = 0;i < n;i++){
        if(a[i] == mmin)cnt++;
        if(a[i] - mmin > 1)return cout << "No",0;
    }
    if(mmin < cnt  - 1 + ((n - cnt) > 0))return cout << "No",0;
    if(2 * (mmin - cnt + 1) + cnt > n)return cout << "No",0;
    cout << "Yes";
    return 0;
}
//Written by M_H_H_7


Measured memory_bytes: 5760
#include <iostream>
#include <iomanip>
#include <cstdio>
using namespace std;

int main(){
	int a,b,d,r;
	double f;
	cin >> a >> b;

	d= a / b;
	r= a % b;
	f= (double)a / b;

	cout << d <<" " << r <<" "<<fixed <<setprecision(10)<< f <<endl;



}

Measured memory_bytes: 1244
x, y = map(int, input().split())
ans = float('inf')

filt = lambda a: [ a, float('inf') ][ a < 0 ]

ans = min(ans, filt(   y  -    x )    )
ans = min(ans, filt(   y  - (- x)) + 1)
ans = min(ans, filt((- y) -    x ) + 1)
ans = min(ans, filt((- y) - (- x)) + 2)

print(ans)


Measured memory_bytes: 38384
import sys
n=int(input())
a=sorted(list(map(int,input().split())))

p=set(a[:n//3])
q=set(a[n//3:(n//3)*2])
r=set(a[(n//3)*2:n])

flag=True
if n%3!=0:
    flag=False
if len(set(a))==1 and a[0]==0:
    print("Yes")
    sys.exit()
    
if flag and len(p)==1 and len(q)==1 and len(r)==1:
    if a[0] ^ a[n//3]==a[(2*n)//3]:
        print("Yes")
    else:
        print("No")
else:
    print("No") 


Measured memory_bytes: 15788
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,w,a[110],b[110],dp[110][100010];
signed main(){
    cin>>n>>w;
    rep(i,n)cin>>a[i]>>b[i];
    for(int i=0;i<n;i++){
        for(int j=0;j<w;j++){
            chmax(dp[i+1][j],dp[i][j]);
            if(j+a[i]<=w)chmax(dp[i+1][j+a[i]],dp[i][j]+b[i]);
        }
    }
    int ans=0;
    rep(i,w+1)chmax(ans,dp[n][i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 81408
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

ll f(ll x, ll y, ll z) {
  return x*x+y*y+z*z + x*y + x*z + y*z;
}
int main() {
  ll n;
  cin >> n;
  vector<ll> F(n+1, 0);
  for(ll x=1; f(x,1,1)<=n; x++) {
    for(ll y=1; f(x,y,1)<=n; y++) {
      for(ll z=1; f(x,y,z)<=n; z++) {
        F[f(x,y,z)]++;
      }
    }
  }
  for(ll i=1; i<=n; i++) {
    cout << F[i] << endl;
  }
}


Measured memory_bytes: 3624
#include <iostream>
#include <cmath>

using namespace std;

long long a,b,c,x,y;

int main(){
    cin >> a >> b >> c >> x >> y;
    long long n = x * a + y * b;
    long long m = min(x,y) * c * 2;
    if(x > y){
        m += (x-y) * a;
    }else{
        m += (y-x) * b;
    }
    long long o = max(x,y) * c * 2;
    cout << min(min(m,n),o) << endl;
    return 0;
}

Measured memory_bytes: 256
N,T = map(int,input().split())
X = []
for i in range(N):
  a,b = map(int,input().split())
  X.append((a,b))
X.sort()
#print(X)
A = [];B = []
for i in range(N):
  A.append(X[i][0])
  B.append(X[i][1])
dp = [[0 for _ in range(T)] for _ in range(N+1)]
#dp[i][j] i番目までの料理を頼んだ時j分後の最大値
ans = 0
for i in range(N):
  time, aji = X[i]
  for j in range(T):
    if j-time >= 0:
      dp[i+1][j] = max(dp[i][j-time] + aji,dp[i][j])
    else:
      dp[i+1][j] = dp[i][j]
  
  if i < N-1:
    last = max(B[i+1:])
  else:
    last = 0
  #print(ans,last,dp[i+1][T-1])
  ans = max(ans,dp[i+1][T-1]+last)
print(ans)

Measured memory_bytes: 154508
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;
    vector<int> T(n);
    vector<int> V(n);

    for (int i = 0; i < n; ++i) {
        cin >> T[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> V[i];
    }
    
    const long long INF = 1LL << 60;
    auto calc = [&](int v0, int v1, int mx, int t) -> long double {
        long double res = 0;
        if (v0 > mx || v1 > mx) {
            return -INF;
        }
        if (t < abs(v1 - v0)) {
            return -INF;
        }

        int t0 = (mx - v0);
        int t1 = (mx - v1);
        
        if (t0 + t1 > t) {
            if (v1 > v0) {
                swap(v1, v0);
            }
            long double t1 = v0 - v1;
            long double t0 = (t - t1) / 2;
            t1 += t0;
            long double v = v0 + t0;
            res += (v + v0) / 2.0 * t0;
            res += (v + v1) / 2.0 * t1;
            // cout << v << " : " << t0 << " " << t1 << endl;
        } else {
            res += (v0 + mx) / 2.0 * t0;
            res += (v1 + mx) / 2.0 * t1;
            res += (t - t1 - t0) * 1.0 * mx;
        }
        return res;
    };
    long long res = 0;

    int M = 0;
    for (auto x : V) {
        M = max(M, x);
    }

    vector<long double> dp(M + 1, -INF);
    dp[0] = 0;
    auto ndp = dp;

    for (int i = 0; i < n; ++i) {
        fill(begin(ndp), end(ndp), -INF);
        for (int j = 0; j <= M; ++j) {
            if (dp[j] < 0) {
                continue;
            }
            for (int k = 0; k <= V[i]; ++k) {
                auto mx = calc(j, k, V[i], T[i]);
                ndp[k] = max(ndp[k], dp[j] + mx);
            }
        }
        swap(ndp, dp);
    }
    
    cout << dp[0] << '\n';

    return 0;
}

Measured memory_bytes: 3816
#include<stdio.h>

int H, W, N, K;
int ans_map[50][50];

void check2h(int h, int w, int num) {
	int p;
	int c = 0;
	
	if(num == 2) {
		ans_map[h][w] = 1;
		ans_map[h][w+1] = 1;
		return;
	}
	
	printf("? %d %d %d %d\n", h, w, h, w);
	fflush(stdout);
	scanf("%d", &p);
	ans_map[h][w] = p;
	c += p;
	if(c == num) return;
	
	ans_map[h][w+1] = 1;
}

void check2v(int h, int w, int num) {
	int p;
	int c = 0;
	
	if(num == 2) {
		ans_map[h][w] = 1;
		ans_map[h+1][w] = 1;
		return;
	}
	
	printf("? %d %d %d %d\n", h, w, h, w);
	fflush(stdout);
	scanf("%d", &p);
	ans_map[h][w] = p;
	c += p;
	if(c == num) return;
	
	ans_map[h+1][w] = 1;
}

void check4s(int h, int w, int num) {
	int i, j;
	int p;
	int c = 0;
	
	if(num == 4) {
		for(i=0;i<2;i++) {
			for(j=0;j<2;j++) {
				ans_map[h+i][w+j] = 1;
			}
		}
		return;
	}
	
	for(i=0;i<2;i++) {
		printf("? %d %d %d %d\n", h+i, w, h+i, w+1);
		fflush(stdout);
		scanf("%d", &p);
		if(p > 0) {
			c += p;
			check2h(h+i, w, p);
			if(c == num) return;
		}
	}
}

void check4h(int h, int w, int num) {
	int i;
	int p;
	int c = 0;
	
	if(num == 4) {
		for(i=0;i<4;i++) {
			ans_map[h][w+i] = 1;
		}
		return;
	}
	
	for(i=0;i<2;i++) {
		printf("? %d %d %d %d\n", h, w+i*2, h, w+i*2+1);
		fflush(stdout);
		scanf("%d", &p);
		if(p > 0) {
			c += p;
			check2h(h, w+i*2, p);
			if(c == num) return;
		}
	}
}

void check4v(int h, int w, int num) {
	int i;
	int p;
	int c = 0;
	
	if(num == 4) {
		for(i=0;i<4;i++) {
			ans_map[h+i][w] = 1;
		}
		return;
	}
	
	for(i=0;i<2;i++) {
		printf("? %d %d %d %d\n", h+i*2, w, h+i*2+1, w);
		fflush(stdout);
		scanf("%d", &p);
		if(p > 0) {
			c += p;
			check2v(h+i*2, w, p);
			if(c == num) return;
		}
	}
}

void check25(int h, int w, int num) {
	int i, j;
	int p;
	int c = 0;
	
	if(num == 25) {
		for(i=0;i<5;i++) {
			for(j=0;j<5;j++) {
				ans_map[h+i][w+j] = 1;
			}
		}
		return;
	}
	
	for(i=0;i<2;i++) {
		for(j=0;j<2;j++) {
			printf("? %d %d %d %d\n", h+i*2, w+j*2, h+i*2+1, w+j*2+1);
			fflush(stdout);
			scanf("%d", &p);
			if(p > 0) {
				c += p;
				check4s(h+i*2, w+j*2, p);
				if(c == num) return;
			}
		}
	}
	
	printf("? %d %d %d %d\n", h+4, w, h+4, w+3);
	fflush(stdout);
	scanf("%d", &p);
	if(p > 0) {
		c += p;
		check4h(h+4, w, p);
		if(c == num) return;
	}
	
	printf("? %d %d %d %d\n", h, w+4, h+3, w+4);
	fflush(stdout);
	scanf("%d", &p);
	if(p > 0) {
		c += p;
		check4v(h, w+4, p);
		if(c == num) return;
	}
	
	ans_map[h+4][w+4] = 1;
}

int main() {
	int i, j;
	int p;
	int c = 0;
	long ans = 0;
	long pow = 1;
	
	scanf("%d %d %d %d", &H, &W, &N, &K);
	
	for(i=0;i<10;i++) {
		for(j=0;j<10;j++) {
			if(c == N) break;
			printf("? %d %d %d %d\n", i*5, j*5, i*5+4, j*5+4);
			fflush(stdout);
			scanf("%d", &p);
			if(p > 0) {
				c += p;
				check25(i*5, j*5, p);
			}
		}
	}
	
	for(i=0;i<H;i++) {
		for(j=0;j<W;j++) {
			if(ans_map[i][j]) ans += pow;
			pow *= 2;
			ans %= K;
			pow %= K;
		}
	}
	
	printf("! %ld\n", ans);
	
	return 0;
}

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

int main(){
    string s,t;
    cin >> s >> t;
    int n= s.size();
    ll sum = 0;
    rep(i, n){
        if(s[i]!=t[i]){
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3916
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	String X = sc.next();
      	String ans = "";
      	for(int i=0;i<3;i++){
          ans += X.charAt(i);
        }
      	System.out.println(ans);    	
	}
}

Measured memory_bytes: 26952
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int h,n;
	cin>>h>>n;
	
	vector<pii> vp(n);
	REP(i,n){
		int a,b;
		cin>>a>>b;
		vp[i]=pii(a,b);
	}
	
	vi dp(h+1,INF);
	dp[h]=0;
	for(int i=h;i>0;--i){
		if(dp[i]==INF){}
		else{
			REP(j,n){
				if(i-vp[j].first<0) dp[0]=min(dp[0],dp[i]+vp[j].second);
				else dp[i-vp[j].first]=min(dp[i-vp[j].first],dp[i]+vp[j].second);
			}
		}
	}
	
	cout<<dp[0]<<endl;
}

Measured memory_bytes: 256
n = int(input())
v = list(map(float, input().split()))
while len(v) > 1:
  min_1 = min(v)
  v.remove(min_1)
  min_2 = min(v)
  v.remove(min_2)
  v.append((min_1 + min_2) / 2)
print(v[0])

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

using namespace std;

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

    auto len = s.length();
    long long ans = 0;
    for (unsigned int t = 0; t < (1U << (len - 1)); t++) {
        long long curr = s[0] - '0';
        for (unsigned int i = 0; i < len - 1; i++) {
            if (t & (1U << i)) {
                ans += curr;
                curr = 0;
            }
            curr = curr * 10 + s[i + 1] - '0';
        }
        ans += curr;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vi2 = vector<vector<int>>;
using vb = vector<bool>;
using vb2 = vector<vector<bool>>;
using vc = vector<char>;
using vc2 = vector<vector<char>>;
using vs = vector<string>;
using si = set<int>;
using vs2 = vector<vector<string>>;
using pii = pair<int, int>;
using mii = map<int, int>;
const int INF = 1e9;
const ll LINF = 1e18;
#define MP(a,b) make_pair((a),(b))
#define MT(...) make_tuple(__VA_ARGS__)

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define ALL(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define COUT(x) cout << (x) << endl
#define DCOUT(x,n) cout << fixed << setprecision(n) << (x) << endl

template<typename T>
T gcd(T x, T y){
    if ((x==1)||(y==1)) return 1;
    if (x>y) {
        if (x%y==0) {
            return y;
        }else{
            return gcd(y, x%y);
        }
    }else{
        if (y%x==0) {
            return x;
        }else{
            return gcd(x, y%x);
        }
    }
}

int main() {
    IN(int, n);
    IN(int, k);
    if (k>=n) {
        COUT(0);
        return 0;
    }
    vi a(n);
    REP(i, n){
        cin >> a[i];
    }
    sort(ALL(a));
    ll ans = 0;
    REP(i, n-k){
        ans += a[i];
    }
    COUT(ans);
}


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

main()
{
    long long n,d; cin>>n>>d;
    long long x,y;
    int ans=0;
    while(n--)
    {
        cin>>x>>y;
        if(x*x+y*y<=d*d) ans++;
    }
    cout << ans << "\n";
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"

void Main() {
    int n;
    cin >> n;
    vector<pair<string, int>> vec(n), svec(n);
    for(int i = 0; i < n; ++i){
        string s;
        int p;
        cin >> s >> p;
        vec[i] = make_pair(s, p);
    }
    svec = vec;
    
    sort(svec.begin(), svec.end(),
            [](const pair<string,int>& lhs, const pair<string,int>& rhs){
                return (lhs.first == rhs.first) ?
                (lhs.second > rhs.second) : (lhs.first < rhs.first);
            });
    for(const auto& v : svec){
        auto itr = std::find(vec.begin(), vec.end(), v);
        cout << distance(vec.begin(), itr) + 1 << endl;
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<numeric>
#include<set>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long li;
#define minimize(a,b) (a>(b)?a=(b),1:0)
#define maximize(a,b) (a<(b)?a=(b),1:0)
#define ceil(a,b) (((a)+(b)-1)/(b))
#define yn(i) print((i)?"Yes":"No")
#define chmin(a,b) (a>(b)?a=(b),1:0)
#define abs(n) max((n),-(n))
#define dist(a,b) max((a)-(b),(b)-(a))
#define chmax(a,b) (a<(b)?a=(b),1:0)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define MOD 1000000000
#define rep(i,n) for(int i=0;i<(n);i++)

#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }




string key="keyence";

void add(char m,string s,set<string> st){
  int n=s.size();
  rep(i,n){
    if(s[i]!=m) continue;
    string t;
    repa(j,i,n){
      t.push_back(s[j]);
      st.insert(t);
    }
  }
}

int gcd(int a,int b){
  return b?gcd(b,a%b):a;
}

int legal(string s,string t,int k){
  int n=s.size();
  repa(i,k,n){
    if(s[i]!=t[i-k]) return 0;
  }
  return 1;
}

string merge(string s,string t,int k){
  int n=s.size();
  string ret;
  rep(i,k) ret.push_back(s[i]);
  rep(i,n) ret.push_back(t[i]);
  return ret;
}


int main(){
  li n; cin >>n;
  string s,t; cin >>s >>t;
  rep(i,n){
    if(legal(s,t,i)){
      string q=merge(s,t,i);
      print(q.size());
      return 0;
    } 
  }
  print(2*n);
}





Measured memory_bytes: 3564
#include <iostream>
#include <cstring>

struct {
  auto &operator>>(int &x) {
    char c;
    do
      c = std::cin.rdbuf()->sbumpc();
    while (!isdigit(c));
    for (x = 0; isdigit(c); c = std::cin.rdbuf()->sbumpc())
      x = x * 10 + (c ^ 48);
    return *this;
  }
} io;

const int MAX_N = 100000;

long long f[MAX_N + 1];

int main() {
  int N, W;
  memset(f, 0x3f, sizeof(f));
  io >> N >> W;
  f[0] = 0;
  for (int i = 0, w, v; i < N; ++i) {
    io >> w >> v;
    for (int j = MAX_N; j >= v; j--) f[j] = std::min(f[j], f[j - v] + w);
  }
  for (int i = MAX_N; i >= 0; --i) {
    if (f[i] <= W) {
      std::cout << i;
      break;
    }
  }
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
 
#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
 
int main(){
    ll n;
    cin >> n;
    ll ans = n-1;
 
    for(ll i = 2; i * i <= n; i++){
        if(n % i == 0){
            ans = min(ans,(i-1) + (n/i - 1));
        }
    }
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 384
fn main() {
    let s = {
        let mut s = String::new(); 
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_string()
    };

    let tokens = s.split(" ")
        .map(|num| num.parse().unwrap())
        .collect::<Vec<i32>>();

    let w = tokens[0];
    let h = tokens[1];
    let x = tokens[2];
    let y = tokens[3];
    let r = tokens[4];

    if x >= r && x <= w - r && y >= r && y <= h - r {
        println!("Yes");
    }  else {
        println!("No");
    }
}



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

int A, B;

void input() {
    cin >> A >> B;
}

void solve() {
    int ans;
    ans = ((B - 1) + (A - 1) - 1) / (A - 1);
    cout  << ans << endl;
}

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

Measured memory_bytes: 3632
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll a, v;
    cin >> a >> v;
    ll b, w;
    cin >> b >> w;
    ll t; cin >> t;
    cout << (abs(a - b) <= t * (v - w) ? "YES" : "NO") << '\n';
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

int mp[5005][5005];
int dp[5005][5005];

int main(){

	int n;cin >> n;
	vector<ll> v(n);

	REP(i,n)cin >> v[i];
	sort(ALL(v));

	REP(i,5005)REP(j,5005){
		mp[i][j] = -1;
		dp[i][j] = 2;
	}

	REP(i,n){
		int k = i;
		for(ll j = i+1;j < n;j++){
			while(k < n && 2 * v[j] - v[i] > v[k])k++;
			if(k < n && 2 * v[j] - v[i] == v[k])mp[i][j] = k;
		}
	}

	REP(i,n){
		for(ll j = i+1;j < n;j++){
			if(mp[i][j] != -1){
				ll k = mp[i][j];
				dp[j][k] = max(dp[j][k], dp[i][j] + 1);
			}
		}
	}

	int ans = 0;
	REP(i,n){
		REP(j,n){
			ans = max(ans, dp[i][j]);
		}
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 198892
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner kb = new Scanner(System.in);
		String kn = "No";
		int i = kb.nextInt();
		int j = kb.nextInt();
		int k = kb.nextInt();
		if (i == j && j != k) {
			kn = "Yes";
		} else if (i == k && i != j) {
			kn = "Yes";
		} else if (j == k && k != i) {
			kn = "Yes";
		}

		System.out.println(kn);
		kb.close();
	}

}


Measured memory_bytes: 23764
package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	var n2, n4 int
	for i := 0; i < n; i++ {
		var t int
		fmt.Scanf("%d", &t)
		if t%4 == 0 {
			n4++
		} else if t%2 == 0 {
			n2++
		}
	}
	n1 := n - n2 - n4
	if n2 != 0 {
		if n4 >= n1 {
			fmt.Printf("Yes\n")
		} else {
			fmt.Printf("No\n")
		}
	} else {
		if n4 != 0 && n4+1 >= n1 {
			fmt.Printf("Yes\n")
		} else {
			fmt.Printf("No\n")
		}
	}
}


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

int main(void){
    string s;
    string t;
    cin >> s;
    cin >> t;
    int len = s.length()+t.length();
    char ans[len];
    for(int i = 0; i < len; i++){
        if(i % 2 == 0)
            ans[i] = s[i/2];
        if(i % 2 != 0)
            ans[i] = t[i/2];
    }
    for(int i = 0; i < len; i++)
        cout << ans[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LaL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
using namespace std;

int main(){
  unsigned long long X,L=100,cnt=0;
  cin>>X;
  
  while(X>L){
    L*=1.01;
    cnt++;
  }
  
  cout<<cnt<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

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

bool solve(LL &t, LL &n, LL k, VLL &a, VLL &f) {
    REP(i,0,n) {
        LL ma = (t) / f[i];
        LL diff = max(0LL, a[i] - ma);
        k -= diff;
        if (k < 0) return false;
    }
    return k >= 0;
}

long long meguru_bin(LL &n, LL &k, VLL &a, VLL &f) {
    long long ok = 1LL << 60;
    long long ng = -1;

    while (abs(ok - ng) > 1) {
        long long mid = ng + (ok - ng) / 2;
        //dump(mid);
        if (solve(mid,n,k,a,f)) ok = mid;
        else ng = mid;
    }

    return ok;
}

void solve() {
    LL n,k;
    cin >> n >> k;
    VLL a(n), f(n);
    REP(i,0,n) cin >> a[i];
    REP(i,0,n) cin >> f[i];
    sort(all(a));
    sort(all(f));
    reverse(all(f));

    cout << max(0LL, meguru_bin(n,k,a,f)) << endl;
}

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

Measured memory_bytes: 3328
import sys

def sort_nested_list(nested_list):
    nested_list.sort(key = lambda  x: x[1])
    return nested_list

N = int(input())

jobs = [list(map(int, input().split())) for _ in range(N)]
jobs = sort_nested_list(jobs)
time = 0

for job in jobs:
    hours, deadline = job[0], job[1]
    
    time += hours
    
    if time > deadline:
        print('No')
        sys.exit()

print('Yes')

Measured memory_bytes: 53660
#include <iostream>
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
    int n;cin>>n;
    int ans=0;
    for(int i=0;i<n;i++){
        int x;cin>>x;
        if((i+1)%2 && x%2) ans++;
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Mat = vector<bitset<2501>>;

int h,w;

int calc(Mat mat) {
  int n = mat.size();
  int res = 0;
  for(int i = 0; i < n; i++) {
    int pivot = -1;
    for(int j = res; j < n; j++) {
      if(mat[j][i]) { pivot = j; break; }
    }
    if(pivot == -1) continue;
    swap(mat[res], mat[pivot]);
    for(int j = res + 1; j < n; j++) if(mat[j][i]) mat[j] ^= mat[res];
    res++;
  }
  int ng = 0;
  for(int i = res; i < n; i++) ng |= mat[i][h * w];
  if(ng) return -1;
  return res;
}

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  cin >> h >> w;
  Mat mat(h * w);
  for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) {
    int c; cin >> c;
    mat[i * w + j][h * w] = c;
  }
  for(int i = 0; i < h; i++) for(int j = 0; j < w; j++) {
    for(int k = 0; k < h; k++) for(int l = 0; l < w; l++) {
      if(i == k || j == l || (i + j) == (k + l) || (i - j) == (k - l)) {
        mat[i * w + j][k * w + l] = 1;
      }
    }
  }
  int rnk = calc(mat);
  if(rnk < 0) return (cout << 0 << endl, 0);
  ll ans = 1;
  constexpr int mod = 1e9 + 9;
  for(int i = 0; i < h * w - rnk; i++) ans = ans * 2 % mod;
  cout << ans << endl;
}




Measured memory_bytes: 4412
#include <bits/stdc++.h>
#define print(x) cout << x << '\n';

int a[1000000];

int main()
{
    using namespace std;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // freopen("input.in", "r", stdin);
    
    int n, X;
    int mn;
    cin >> n >> X;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(i == 0) mn = abs(X-a[i]);
        if(i > 0){
            mn = __gcd(abs(X-a[i]), mn);
        }
    }
    cout << mn;
    
    return 0;
}


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


#define mod 1000000007
#define ull unsigned long long int
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return true; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

ll ncr(int n, int k)  
{  
	if(k>n)return 0;
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
#define  deb(x)       cout << '>' << #x << ':' << x << endl;


void  solve()
{
	int h,n;
	cin>>h>>n;
	ll s=0;
	forn(i,n)
	{
		int a;
		cin>>a;
		s+=a;
	}
	h-=s;
	if(h>0)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;

}


int main()
{
 
    FastIO;
    ll t=1;
   	//bcin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll N, K;
string S, T;
vector<vector<pair<ll, ll>>> graph;
vector<ll> gsize;

void solve() {
	cin >> N;
	graph.resize(N, vector<pair<ll, ll>>(0));

	rep(i, N - 1) {
		ll u, v, w;
		cin >> u >> v >> w;
		u--;
		v--;
		graph[u].emplace_back(make_pair(v, w));
		graph[v].emplace_back(make_pair(u, w));
	}

	vector<int> ans(N);

	queue<pair<ll, ll>> Q;
	Q.push(make_pair(0,0));
	ans[0] = 0;

	while (Q.size() != 0) {

		pair<ll, ll> P = Q.front();
		Q.pop();

		rep(i, graph[P.first].size()) {

			if (graph[P.first][i].first == P.second) continue;

			if (ans[P.first] == 0) {
				ans[graph[P.first][i].first] = graph[P.first][i].second % 2;
			}
			else {
				ans[graph[P.first][i].first] = 1 - graph[P.first][i].second % 2;
			}

			Q.push(make_pair(graph[P.first][i].first,P.first));

		}

	}

	rep(i, N) {
		cout << ans[i] << endl;
	}

}

int main() {
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
template<C T>void pr(T a){cout<<a;ln;}
template<C T,C T2>void pr(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s;
  R s;
  rep(i,s.size()) {
    if(i==4) cout << " ";
    cout << s[i];
  }
  ln;
}

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


Measured memory_bytes: 256