akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;
vi ans(11111111,1);
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
ll n;cin>>n;
  for(ll i = 2;i <= n;i++){
    for(ll j = i;j < 11111111;j += i){
ans[j]++;
    }
  }
  ll an = 0;
  for(int i=1;i<=n;i++){
    an += i * ans[i];
  }
  cout<<an<<endl;
  return 0;
}


Measured memory_bytes: 90020
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _overload4(_1,_2,_3,_4,name,...) name
#define _overload3(_1,_2,_3,name,...) name
#define _overload2(_1,_2,name,...) name
#define _re(n) _rep(i,n)
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(ll i=a;i<b;++i)
#define _repc(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) _overload4(__VA_ARGS__,_repc,_repi,_rep,_re)(__VA_ARGS__)
#define _rre(n) _rrep(i,n)
#define _rrep(i,n) _rrepi(i,0,n)
#define _rrepi(i,a,b) for(ll i=b-1;i>=a;i--)
#define _rrepc(i,a,b,c) for(ll i=a+(b-a-1)/c*c;i>=a;i-=c)
#define rrep(...) _overload4(__VA_ARGS__,_rrepc,_rrepi,_rrep,_rre)(__VA_ARGS__)
#define sum(...) accumulate(range(__VA_ARGS__),0)
#define _range(i) (i).begin(),(i).end()
#define _rangek(i,k) (i).begin(),(i).begin()+k
#define range(...) _overload2(__VA_ARGS__,_rangek,_range)(__VA_ARGS__)
#define LINF (ll)1000000000000000000
#define MOD (ll)1000000007
#define INF (int)1000000007
#define Yes(i) out(i?"Yes":"No")
#define YES(i) out(i?"YES":"NO")
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,size) vector<type> name(size);
#define VEC(type,name,size) vector<type> name(size);in(name)
struct aaa{aaa(){cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}aaaaaaa;
inline void in() {}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec);
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p);
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec);
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p);
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p){is >> p.first;is >> p.second;return is;}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){os << vec[0];rep(i,1,vec.size()){os << ' ' << vec[i];}return os;}
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){cin>>head;in(move(tail)...);}
template <class T>
inline void out(T t){cout<<t<<'\n';}
inline void out(){cout<<'\n';}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){cout<<head<<' ';out(move(tail)...);}


int main(){
    INT(w,h,n);
    vec(int,a,w);
    rep(i,0,n){
        INT(x,y);
        if(a[x]<y)a[x]=y;
    }
    rrep(i,0,w-1){
        if(a[i]<a[i+1])a[i]=a[i+1];
    }
    rep(i,0,w-1)a[i]=i+a[i+1];
    a[w-1]=w-1;
    out(*min_element(range(a)));
}
















Measured memory_bytes: 3356
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N;
        cin >> N;
        vector<ll> A(N);
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
        }

        vector<ll> a(N);
        vector<ll> d(N); // a[0]との相対的な量
        for (int i = 2; i < N; i += 2) {
            d[i] = d[i - 2] + (A[i - 1] - A[i - 2]);
        }
        d[1] = d[N - 1] + (A[0] - A[N - 1]);
        for (int i = 3; i < N; i += 2) {
            d[i] = d[i - 2] + (A[i - 1] - A[i - 2]);
        }
        ll suma = accumulate(all(A), 0ll);
        ll sumd = accumulate(all(d), 0ll);
        ll x = (suma - sumd * 2) / N;
        for (int i = 0; i < N; ++i) {
            a[i] = 2 * d[i] + x;
        }

        for (int i = 0; i < N; ++i) {
            cout << a[i];
            if (i < N - 1) cout << " ";
            else cout << endl;
        }


    }
};


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

    Solve().solve();


    return 0;
}


Measured memory_bytes: 3712
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    ll t, i, j, k, p, q, r, x, y, u, v, n, m;
	string a,b;
	cin>>a>>b;

	i=0;
	j=0;
	n=a.size();
	m=b.size();
	ll ans=INT_MAX;
	Ff(i,0,n-m+1)
	{
		ll cnt=0;
		Ff(j,0,m)
		{
			if(a[i+j]!=b[j])
			cnt++;
		}
		ans=min(ans,cnt);
	}

	cout<<ans;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10684
#include <stdio.h>
int main(void){
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    while(a>0 && c>0){
        c-=b;
        a-=d;
    }
    if(c<=0)
        printf("Yes");
    else
        printf("No");
}


Measured memory_bytes: 1732
// AOJ 1041
#include<cstdio>

int main()
{
	int n;
	while( scanf( "%d", &n ), n )
	{
		int sum = 0;
		for( int i = 0; i != n/4; ++i )
		{
			int a; scanf( "%d", &a );
			sum += a;
		}
		printf( "%d\n", sum );
	}

	return 0;
}

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

int main(){
    int n,m,r,q;
    while(cin>>n>>m,n){
        cin>>r;
        vector<vector<int>> usert(m);
        vector<int> userh(m,0);
        for(int i=0;i<r;i++){
            int t,n,m,s;
            cin>>t>>n>>m>>s;
            m--;
            if(s==1){
                if(userh[m]==0)
                    usert[m].push_back(t);
                userh[m]++;

            }
            if(s==0){
                if(userh[m]==1)
                    usert[m].push_back(t);
                userh[m]--;

            }


        }
        cin>>q;
        for(int i=0;i<q;i++){
            int ts,te,m;
            cin>>ts>>te>>m;
            m--;
            int cnt=0;
            bool isusin=0;
            for(int i=0;i<usert[m].size();i++){
                if(!isusin){
                    isusin=1;
                }
                else{
                    isusin=0;

                    int span=min(usert[m][i],te)-max(usert[m][i-1],ts);
                    if(span>=0)
                        cnt+=span;
                }
            }
            cout<<cnt<<endl;
        }





    }
}

Measured memory_bytes: 3388
import java.util.*

fun main(args : Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val aa = readLine()!!.split(" ").map { it.toInt() }

    val pQueue = PriorityQueue<Int>(n){ i1, i2 ->
        return@PriorityQueue i2-i1
    }
    pQueue.addAll(aa)

    repeat(m) {
        val max = pQueue.poll()
        pQueue.add(max/2)
    }

    var sum = 0L
    pQueue.forEach {
        sum += it.toLong()
    }

    println(sum)
}

Measured memory_bytes: 72584
def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
Mod=10**9+7
n=int(input())
print((power_func(10,n,Mod)-2*power_func(9,n,Mod)+power_func(8,n,Mod))%Mod)

Measured memory_bytes: 9228
#include <iostream>
#include <vector>
#include <cmath>
#include <map>

using namespace std;

int main() {
        int h, n;
        cin >> h >> n;
        int sum = 0;
        for(int i = 0; i < n; i++) {
                int a;
                cin >> a;
                sum += a;
                if(sum >= h) {
                        cout << "Yes" << endl;
                        return 0;
                }
        }
        cout << "No" << endl;
        return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define rep(i, n) for ( int i = 0; i < n; i++)
typedef unsigned long long llong;

static const int MAX = 10001;

main(){
  int n, a[3], T[MAX];
  cin >> n;
  rep(i, n) cin >> a[i];
  rep(i, MAX) T[i] = 0;

  sort(a, a+n);

  vector<int> ans;
  int t = a[0];
  for ( int x = 1; x*x <= t; x++ ){
    if ( t%x == 0) {
      ans.push_back(x);
      if ( x != t/x ) ans.push_back(t/x);
    }
  }

  for ( int i = 1; i < n; i++ ){
    vector<int> tmp;    
    for ( int j = 0; j < ans.size(); j++ ){
      if ( a[i]%ans[j] == 0 ) tmp.push_back(ans[j]);
    }
    ans = tmp;
  }

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

  for ( int i = 0; i < ans.size(); i++ ) cout << ans[i] << endl;

}

Measured memory_bytes: 1220
//#pragma GCC optimize "trapv"
#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand rng
#define fios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define M_PI 3.14159265358979323846
typedef long long ll;



int main() {
	//fios;
	int d, t, s;
	cin >> d >> t >> s;

	if(s * t >= d) cout << "Yes";
	else cout << "No";

	cout << endl;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, h, z = 0;
    pii a[200005] = {};
    cin >> n >> h;
    fr(n) cin >> a[i + i].first >> a[i + i + 1].first, a[i + i + 1].second = 1;
    sort(a, a + n + n);
    reverse(a, a + n + n);
    fr(n + n) {
        if (a[i].second) h -= a[i].first, z++;
        else {
            cout << z + (h - 1) / a[i].first + 1;
            return 0;
        }
        if (h <= 0) {
            cout << z;
            return 0;
        }
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n); for(int i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> state;
long double pi = acos(-1);
const int INF = 1001001001;


// 最小公倍数を求める
int euqlid (int a, int b){
  int temp;
  temp = a % b;
  if(temp == 0)return b;
  return euqlid(b,temp);
}
ll conbination(ll a,ll b){
  ll u = 1;
  ll d = 1;
  while(b != 0){
    u *= a;
    d *= b;
    a--;
    b--;
  }
  return u / d;
}
int strtoint(char s){
  return (int(s-'0'));
}
char changeS(char alpha){
  if(0x41 <= alpha and alpha <= 0x5A)return (alpha + 0x20);
  else if(0x61 <= alpha and alpha <= 0x7A)return (alpha - 0x20);
  return alpha;
}
int fact(int n){
  if(n == 1)return 1;
  return n * fact(n-1);
  }
int ceil(int a,int b){
  // a/bの切り上げを考える
  return (a+b-1)/b;
}

int main() {
  int k;
  cin >> k;
  int ans = -1;

  if(k % 2 == 0){
    cout << ans << endl;
    return 0;
  }
  int seven = 7;
  int cnt = 1;
  seven %= k;
  while(1){
    if(seven == 0)break;
    else{
      seven =(7 + seven * 10) % k;
      cnt++;
    }
    if(cnt > k){
      cout << ans << endl;
      return 0;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3632
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll A, B; cin >> A >> B; A -= 1; B -= 1;
    
    ll ha = 2 * (A / 50); ll hb = 2 * (B / 50); ll h_all = ha + hb + 4; ll w_all = 100;
    
    vector<string> ans(h_all, "");
    
    // white
    string w_line; REP(i,100) w_line += "."; // white line
    string w_cross; REP(i,100) w_cross += i%2 == 0 ? "#" : ".";
    string b_line; REP(i, 100) b_line += "#"; // black line
    REP(i,ha) ans[i] =  i%2 == 0 ? w_cross : b_line;
    
    ll a_remain = A - 50 * (ha / 2); string w_last = "";
    REP(i, 100){
        if(i < a_remain * 2){
            w_last += (i % 2 == 0) ? "#" : ".";
        }
        else{
            w_last += "#";
        }
    }
    ans[ha] = w_last; ans[ha+1] = b_line;
    
    // black
    ans[ha+2] = w_line;
    FOR(i, ha+3, ha+hb+3) ans[i] = i%2 == 0 ? w_line : w_cross;
    ll b_remain = B - 50 * (hb / 2); string b_last = "";
    REP(i, 100){
        if(i < b_remain * 2){
            b_last += (i % 2 == 0) ? "#" : ".";
        }
        else{
            b_last += ".";
        }
    }
    ans[ha+hb+3] = b_last;
    
    cout << h_all << " " << w_all << endl;
    for(string line : ans) cout << line << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

string s;
set<string> ans;
void solve(){
  ans.clear();
  for(int i = 0; i < s.size(); i++){
    string _s[2];
    _s[0] = s.substr(0,i);
    _s[1] = s.substr(i,s.size()-i);
    for(int j = 0; j < 4; j++){
      if(j==2)reverse(_s[0].begin(), _s[0].end());
      if(j)reverse(_s[1].begin(), _s[1].end());
      ans.insert(_s[0]+_s[1]);
      ans.insert(_s[1]+_s[0]);
    }
  }
  cout << ans.size() << endl;
}
int main(){
  int t;
  cin >> t;
  while(t--){
    cin >> s;
    solve();
  }
  return 0;
}

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

int main()
{
    int N, K;
    cin >> N >> K;
    if (2 * K == N || (2 * K - 1) == N || 2 * K < N)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
// C++ program to find the longest 
// path in the DAG 

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

// Function to traverse the DAG 
// and apply Dynamic Programming 
// to find the longest path 
void dfs(int node, vector<int> adj[], int dp[], bool vis[]) 
{ 
	// Mark as visited 
	vis[node] = true; 

	// Traverse for all its children 
	for (int i = 0; i < adj[node].size(); i++) { 

		// If not visited 
		if (!vis[adj[node][i]]) 
			dfs(adj[node][i], adj, dp, vis); 

		// Store the max of the paths 
		dp[node] = max(dp[node], 1 + dp[adj[node][i]]); 
	} 
} 

// Function to add an edge 
void addEdge(vector<int> adj[], int u, int v) 
{ 
	adj[u].push_back(v); 
} 

// Function that returns the longest path 
int findLongestPath(vector<int> adj[], int n) 
{ 
	// Dp array 
	int dp[n + 1]; 
	memset(dp, 0, sizeof dp); 

	// Visited array to know if the node 
	// has been visited previously or not 
	bool vis[n + 1]; 
	memset(vis, false, sizeof vis); 

	// Call DFS for every unvisited vertex 
	for (int i = 1; i <= n; i++) { 
		if (!vis[i]) 
			dfs(i, adj, dp, vis); 
	} 

	int ans = 0; 

	// Traverse and find the maximum of all dp[i] 
	for (int i = 1; i <= n; i++) { 
		ans = max(ans, dp[i]); 
	} 
	return ans; 
} 

// Driver Code 
int main() 
{ 
	int n, m;
	cin >> n >> m;
	vector<int> adj[100009]; 
	
	for(int x, y, i = 0; i < m; i++) {
	    cin >> x >> y;
	    addEdge(adj, x, y);    
	}
	
	cout << findLongestPath(adj, n); 
	return 0; 
} 


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

using namespace std;

int main(int argc, char *argv[]) {
  vector<int> result;
  int a[4], b[4], hit, blow;

  while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    hit = blow = 0;

    for (int i = 0; i < 4; i++)
      if (a[i] == b[i])
        hit++;
    for (int i = 0; i < 4; i++)
      for (int j = 0; j < 4; j++)
        if (a[i] == b[j])
          blow++;
    blow -= hit;

    result.push_back(hit);
    result.push_back(blow);
  }

  for (int i = 0; i < result.size(); i += 2)
    cout << result[i] << ' ' << result[i+1] << endl;
  return 0;
}

Measured memory_bytes: 1220
#include <stdio.h>
#define MAX 2000001

int A[MAX], B[MAX], C[MAX];

int main(){

  int i, n;

  // Input n
  scanf("%d", &n);

  // Initialize
  for(i = 0; i < MAX; i++){
    A[i] = 0;    
    B[i] = 0;
    C[i] = 0;
  }

  // Input A[]
  for(i = 1; i <= n; i++) scanf("%d", &A[i]);

  // Counting number
  for(i = 0; i < n; i++) C[A[i+1]]++;

  // Calculate cumulative sum
  for(i = 1; i < MAX; i++) C[i] = C[i] + C[i-1];

  // Counting Sort
  for(i = n; i >= 1; i--){
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }

  // Output
  for(i = 1; i <= n; i++){
    printf("%d", B[i]);
    if(i < n) printf(" ");
   }
  printf("\n");

  return 0;
}

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

template <typename T>
T max(T a,T b,T c){
    if(b>a)a=b;
    if(c>a)a=c;
    return a;
}

int main () {
    int a,b,c;
    int k;
    scanf("%d%d%d", &a, &b, &c);
    scanf("%d", &k);
    int m = max(a, b, c);
    long long result = a+b+c;
    result -= m;
    for(int i =0 ; i< k; i++)
        m<<=1;
    printf("%lld", result+m);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
void kock(int, double[1][2],double[1][2]);


int main(){

  int n;

  double p1[1][2];
  double p2[1][2];

  p1[0][0] = 0.0;
  p1[0][1] = 0.0;
  p2[0][0] = 100.0;
  p2[0][1]= 0.0;

  scanf("%d",&n);

  printf("%f %f\n",p1[0][0],p1[0][1]);

  kock(n,p1,p2);

  printf("%f %f",p2[0][0],p2[0][1]);

  return 0;

}


void kock(int n, double p1[1][2], double p2[1][2]){

  double s[1][2],t[1][2],u[1][2];
double rad = M_PI * 60.0 / 180.0;

  if(n == 0){

    return;

  }


    s[0][0] = (2 * p1[0][0] + 1 * p2[0][0]) / 3; /*sのx座標*/

    s[0][1] = (2 * p1[0][1] + 1 * p2[0][1]) /3; /*sのy座標*/

    t[0][0] = (1 * p1[0][0] + 2 * p2[0][0]) / 3;

    t[0][1] = (1 * p1[0][1] + 2 * p2[0][1]) / 3;

    u[0][0] = (t[0][0] - s[0][0]) * cos(rad) - (t[0][1]-s[0][1]) * sin(rad) + s[0][0];

    u[0][1] = (t[0][0] - s[0][0]) * sin(rad) +(t[0][1]-s[0][1]) * cos(rad)  + s[0][1];
  
  

  kock(n-1,p1,s);

  printf("%f %f\n",s[0][0],s[0][1]);
 
  kock(n-1,s,u);

  printf("%f %f\n",u[0][0],u[0][1]);

  kock(n-1,u,t);

  printf("%f %f\n",t[0][0],t[0][1]);

  kock(n-1,t,p2);


}

Measured memory_bytes: 636
/*---- enazuma11-------  */
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define all(v) v.begin(),v.end()
#define inc(a,n) sort(a,a+n)
#define dec(a,n) sort(a,a+n,greater<int>() )
#define F first
#define S second
#define M 1000000007

/* int x[]={-1,-1,0,1,1,1,0,-1};
int y[]={0,1,1,1,0,-1,-1,-1};
*/
/* int x[]={-1,0,1,0};
int y[]={0,1,0,-1};
*/

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	int a[n];
	ll s=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		s+=a[i];
	}
	inc(a,n);
	ll mx=a[n-1];
	s-=a[n-1];
	if(mx<s)
	cout<<"Yes";
	else
	cout<<"No";
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>                                                                      #include <bits/stdc++.h>
using namespace std;
int main() {
    bool f = true;
    int N; cin >> N;
    for (int i = 1; i < 10; i++) {
        if (N%i == 0 && N/i >= 1 && N/i <= 9 ) {
        cout << "Yes" << endl; f = false;
        break; }
    }
    if(f) cout << "No" << endl;
}

Measured memory_bytes: 256
def main():
    S = list(input())

    checklist = [0 for i in range(26)]

    for i in S:
        checklist[ord(i) - ord("a")] += 1

    ans = True
    for i in checklist:
        if i > 1:
            ans = False

    if not ans:
        print(-1)
        return 0
    else:
        ans = False
        for i in range(len(checklist)):
            if checklist[i] == 0:
                for i in S:
                    print(i, end="")
                print(chr(i + ord("a")), end = "")
                print()
                ans = True
                break
        if not ans:
            new_S = []
            for i in S:
                new_S.append(ord(i))
            for i in range(len(new_S) - 1):
                if new_S[i] > new_S[i + 1]:
                    for j in range(i - 1):
                        print(S[j], end = "")
                    print(chr(new_S[i - 1] + 1), end = "")
                    print()
                    ans = True
                    break
            if not ans:
                print(-1)
#main()

def ABC069D():

    H, W = map(int, input().split())
    N = int(input())
    a = list(map(int, input().split()))
    ans = []
    for i in range(N):
        for j in range(a[i]):
            ans.append(i + 1)
    printlist = [[0 for i in range(W)] for j in range(H)]
    k = 0
    for i in range(H):
        for j in range(W):
            printlist[i][j] = ans[k]
            k += 1
        if i % 2 != 0:
            printlist[i] = printlist[i][::-1]

    for i in range(H):
        for j in range(W):
            print(printlist[i][j], end = "")
            if j != W:
                print(" ", end = "")
        print()
    print()
#ABC069D()

import math
def cc(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def ABC057D():

    N, A, B = map(int, input().split())
    v = list(map(int, input().split()))
    v = sorted(v)[::-1]

    anslist = []
    for i in range(A, B + 1):

        anslist.append([sum(v[0:i]) / i, i, v[i - 1]])
    anslist.sort()
    anslist = anslist[::-1]
    ans = anslist[0][0]
    key = anslist[0][2]
    long = anslist[0][1]
    print(ans)
    for i in range(1, len(anslist)):
        if anslist[i][0] == anslist[i - 1][0]:
            ans = anslist[i][0]
            key = anslist[i][2]
            long = anslist[i][1]
        else:
            break
    #print(anslist)
    #print(ans, key, long)
    cnt = 0
    for i in v:
        if i == key:
            cnt += 1

    c = 0
    for i in v[:long]:
        #print(i)
        if i == key:
            c += 1
    #print(c, long)
    ans = 0
    if c == long:
        for i in range(A,  min(B + 1, cnt + 1)):
            ans += cc(cnt, i)
    else:
        ans = cc(cnt, c)
    #print(anslist)
    #print(cnt, c, long)
    print(ans)
ABC057D()


Measured memory_bytes: 3260
import java.util.*;

public class Main {
    public static void main(String[] args) {	
	Main main = new Main();
    	main.solveA();
    }
    
    private void solveA() {
    	Scanner sc = new Scanner(System.in);
    	String s = sc.next();
	int top = 0;

	for(int i=0; i < 3; i++){
	    if (s.charAt(i) == 'o') top += 100;
	}
	
    	System.out.println(700 + top);
    }
}

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

int  num[3][3];
bool bingo[3][3], flag = false;
int  n, b;

int main() {
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> num[i][j];
            bingo[i][j] = false;
        }
    }
    cin >> n; int b[n];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (b[i] == num[j][k]) bingo[j][k] = true;
            }
        }
    }
    for (int i = 0; i < 3; i++) {
        if (bingo[i][0] && bingo[i][1] && bingo[i][2]) flag = true;
    }
    for (int i = 0; i < 3; i++) {
        if (bingo[0][i] && bingo[1][i] && bingo[2][i]) flag = true;
    }
    if (bingo[0][0] && bingo[1][1] && bingo[2][2]) flag = true;
    if (bingo[0][2] && bingo[1][1] && bingo[2][0]) flag = true;
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

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

	double high = 0;
	double low = DBL_MAX;

	double x;
	while( cin >> x ) {
		if( x > high ) { high = x; }
		if( x < low ) { low = x; }
	}

	cout << fixed << setprecision( 2 ) << (high - low) << endl;
	return 0;
}



Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int h,w,n;cin>>h>>w>>n;
    vector<int> a(n+1);
    for(int i=1;i<n+1;i++) cin>>a.at(i);
    int num=1,cnt=0;
    int vec[h][w];
    for(int i=0;i<h;i++){
        if(i%2==0){
            for(int j=0;j<w;j++){
                vec[i][j]=num;
                cnt++;
                if(cnt==a.at(num)){
                    cnt=0;
                    num++;
                }
            }
        }
        else{
            for(int j=w-1;j>-1;j--){
                vec[i][j]=num;
                cnt++;
                if(cnt==a.at(num)){
                    cnt=0;
                    num++;
                }
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout<<vec[i][j]<<" ";
        }
        cout<<endl;
    }
}


Measured memory_bytes: 384
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		List<Integer> list = new ArrayList<>();

		int n = sc.nextInt();
		int k = sc.nextInt();
		String result = (2*k-1)<=n?"YES":"NO";

		System.out.println(result);

	}
}


Measured memory_bytes: 22612
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,N) for(int i = 0;i < (int)(N);i++)
int main() {
  int n,k,q;
  cin>>n>>k>>q;
  vector<int>a(q);
  vector<int>b(n);
  rep(i,q) {
    cin>>a[i];
  }
  rep(i,n) {
    b[i]=k-q;
  }
 rep(i,q){
  b[a[i]-1]++;
 }
 rep(i,n){
   if(b[i]>0)cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
 }

}


Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>

#define PI 3.141592653589793238
#define INF 1050000000

using namespace std;



//cout << fixed << setprecision(15) << << endl;
//cout << << endl;

int main() {

	int a,b,c;

	cin >> a >> b >>c;

	if (b - a == c - b) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}



	return 0;
}

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

int main(){
  int n,m; cin >> n >> m;
  vector<int> l;
  vector<int> r;
  if (n%2)
  {
    for (int i = 1; i <= n/2; i++)
    {
      l.push_back(i);
    }
    for (int i = n/2+1; i <= n; i++)
    {
      r.push_back(i);
    }
    
  }
 
  if (!(n%2))
  {
    for (int i = 1; i < n/2; i++)
    {
      l.push_back(i);
    }
    for (int i = n/2+1; i <= n; i++)
    {
      r.push_back(i);
    }
    
  }
  
  
  vector<int> a;
  vector<int> b;
 
  vector<int> l1;
  vector<int> l2;
  vector<int> r1;
  vector<int> r2;
 
  if (l.size()%2)
  {
    if((int)l.size() != 1)
    {
      for (int i = 0; i < (int)l.size()/2; i++)
      {
        l1.push_back(l.at(i));
      }
      for (int i = l.size()/2 +1; i < (int)l.size(); i++)
      {
        l2.push_back(l.at(i));
      }
      reverse(l2.begin(),l2.end());
 
    }
    
 
    for (int i = 0; i < (int)r.size()/2; i++)
    {
      r1.push_back(r.at(i));
    }
    for (int i = r.size()/2 ; i < (int)r.size(); i++)
    {
      r2.push_back(r.at(i));
    }
    reverse(r2.begin(),r2.end());
  }
 
  if (!((int)l.size()%2))
  {
    for (int i = 0; i < (int)r.size()/2; i++)
    {
      r1.push_back(r.at(i));
    }
    for (int i = r.size()/2 +1; i < (int)r.size(); i++)
    {
      r2.push_back(r.at(i));
    }
    reverse(r2.begin(),r2.end());
    
    
 
 
    for (int i = 0; i < (int)l.size()/2; i++)
    {
      l1.push_back(l.at(i));
    }
    for (int i = l.size()/2 ; i < (int)l.size(); i++)
    {
      l2.push_back(l.at(i));
    }
    reverse(l2.begin(),l2.end());
  }
  
  for (int i = 0; i < (int)l1.size() && i < (int)l2.size(); i++)
  {
    a.push_back(l1.at(i));
    b.push_back(l2.at(i));
  }
  for (int i = 0; i < (int)r1.size() && i < (int)r2.size(); i++)
  {
    a.push_back(r1.at(i));
    b.push_back(r2.at(i));
  }
 
 
  
 
 
  if (a.size() >= m)
  {
    for (int i = 0; i < m; i++)
    {
      cout << a.at(i) << " " <<  b.at(i) << endl;
    }
 
  }
 
}

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

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


  string str = to_string(n);
  for (int i = 0; i < str.size(); i++) {
    if (str[i] == '1')
      cout <<  9;
    else if (str[i] == '9')
      cout <<  1;
    else
      cout << str[i];
  }

  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int A,B,C;
    cin >> A >> B >> C;
    if(A == B && A != C){
        cout << "Yes" << endl;
    }else if(A == C && A != B){
        cout << "Yes" << endl;
    }else if(B == C && A != B){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

using namespace std;

int main()
{
  int n;
  string s;
  cin>>s;
  n=s.size();
  
  int ans=10000000;
  for(int i=0;i<2;i++)
  {
    int tmp=0;
    for(int j=0;j<n;j++)
    {
      if(s[j]!='0'+(j+i)%2)
        tmp++;
    }
    if(tmp<ans)ans=tmp;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<functional>
#include<limits.h>
#include<string.h>
using namespace std;

signed main() {
	int a; cin >> a;
	if (a < 1200)puts("ABC");
	else if (a < 2800)puts("ARC");
	else puts("AGC");
}

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

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

  vector<double> second(K);
  second[0] = 1.0;
  for (int i = 1; i < K; i++) {
    second[i] = second[i-1] * 0.5;
  }

  double sum = 0.0;
  for (int i = 1; i < N + 1; i++) {
    int count = 0;
    for (int j = i; j < K; j *= 2) {
      count++;
    }
    sum += second[count];
  }

  cout<<std::fixed<<std::setprecision(12);
  cout << sum / N << endl;
}


Measured memory_bytes: 1024
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100000
#define MAXM 200000

#define M 1000000007

vector<vector<pair<int,long>>> g;
int n, m;
int s, t;

int input() {
	if (scanf("%d %d", &n, &m) < 0) return 0;
	g.resize(n);
	scanf("%d %d", &s, &t);
	s--, t--;
	for (int i=0; i<m; i++) {
		int x, y, z;
		scanf("%d %d %d", &x, &y, &z);
		x--, y--;
		g[x].push_back({y,z});
		g[y].push_back({x,z});
	}
	return 1;
}

void init() {
}

void dijkstra(int s, long *d, long *c) {
	typedef pair<long,int> node;
	priority_queue<node,vector<node>,greater<node>> q;
	for (int i=0; i<n; i++) {
		d[i] = LONG_MAX;
		c[i] = 0;
	}
	d[s] = 0;
	c[s] = 1;
	q.push({0, s});
	while (!q.empty()) {
		node x = q.top();
		q.pop();
		int v = x.second;
		if (x.first > d[v]) continue;
		for (auto e: g[v]) {
			int u = e.first;
			long w = d[v] + e.second;
			if (w < d[u]) {
				d[u] = w;
				c[u] = c[v];
				q.push({w, u});
			}
			else if(w == d[u]) {
				c[u] += c[v];
				c[u] %= M;
			}
		}
	}
}

long ds[MAXN], dt[MAXN];
long ns[MAXN], nt[MAXN];

void dec(long &a, long b) {
	a = (a-b) % M;
}

long solve() {
	dijkstra(s, ds, ns);
	dijkstra(t, dt, nt);
	//printa(ds, n); printa(ns, n); printa(dt, n); printa(nt, n);
	long len = ds[t];
	long r = ns[t] * nt[s] % M;
	for (int i=0; i<n; i++)	{
		if (ds[i]==dt[i] && ds[i]*2==len) {
			long x = ns[i]*nt[i] % M;
			dec(r, x * x);
		}
	}
	for (int i=0; i<n; i++) {
		for (auto e: g[i]) {
			int j = e.first;
			if (ds[i] + dt[j] + e.second != len)
				continue;
			if (ds[i]*2 < len && dt[j]*2 < len) {
				long x = ns[i]*nt[j] % M;
				dec(r, x * x);
			}
		}
	}
	if (r<0) r += M;
	return r;
}

void output(long ans) {
	printf("%ld\n", ans);
}

void cleanup() {
	g.clear();
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 18772
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	int a[200005];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	long long int b[200005];
	for (i = 0; i <= n; i++)
		b[i] = 0;
	for (i = 0; i < n; i++)
		b[a[i]]++;
	long long int sum = 0;
	for (i = 0; i <= n; i++)
		sum += b[i] * (b[i] - 1) / 2;
	for (i = 0; i < n; i++)
		printf("%lld\n", sum - b[a[i]] * (b[a[i]] - 1) / 2 + (b[a[i]] - 1) * (b[a[i]] - 2) / 2);
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector<vector<int>>
typedef long long ll;
const int INF = 1000000007;

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N, X;
    cin >> N >> X;
    vector<int> A(100010);
    for(int i = 1; i <= N; i++) cin >> A[i];
    
    ll ans = 0;
    for(int i = 1; i <= N; i++){
        int a = A[i - 1] + A[i];
        int b = A[i + 1] + A[i];
        int c = min(a, b);
        if(c > X){
            if(A[i] >= c - X){
                A[i] -= c - X;
                ans += c - X;
            } else {
                ans += A[i];
                A[i] = 0;
            }
            
        }
    }
    
    for(int i = 1; i <= N; i++){
        int b = A[i + 1] + A[i];
        if(b > X){
            if(A[i] >= b - X){
                A[i] -= b - X;
                ans += b - X;
            } else {
                ans += A[i];
                A[i] = 0;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> void puts(T x) { std::cout << x << std::endl; }
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; }

bool color[8];

int main() {
    int n, a[100];
    cin >> n;
    rep(i, n) cin >> a[i];

    int cnt = 0;
    rep(i, n) {
        if (a[i] < 400) color[0] = 1;
        else if (a[i] < 800) color[1] = 1;
        else if (a[i] < 1200) color[2] = 1;
        else if (a[i] < 1600) color[3] = 1;
        else if (a[i] < 2000) color[4] = 1;
        else if (a[i] < 2400) color[5] = 1;
        else if (a[i] < 2800) color[6] = 1;
        else if (a[i] < 3200) color[7] = 1;
        else cnt++;
    }

    int n_min = 0;
    rep(i, 8) if (color[i]) n_min++;
    cout << max(n_min, 1) << ' ' << n_min + cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <numeric>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b; cin >> a >> b;
    cout << a*b << endl;
}

Measured memory_bytes: 3652
#include<iostream>
#define min(a,b) a<b?a:b
using namespace std;
int a[100005];
int main(){
	int n;
	int i,j,k;
	int b,c,d;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>b;
		b--;
		a[b]++;
	}
	c=0;
	for(i=0;i<100000;i++){
		if(a[i]>=3){
			k=(a[i]-1)/2;
			a[i]-=k*2;
			n-=k*2;
		}
	}
	for(i=0,j=0;i<100000;i++){
		if(a[i]<2)continue;
		j=i+1;
		b=0;
		while(1){
			if(a[j]>=2){
				d=min(a[i],a[j])-1;
				a[i]-=d;
				a[j]-=d;
				n-=2*d;
				if(a[i]<=1)break;
			}
			j++;
			if(j==100000)break;
		}
		if(j==100000)break;
	}
	for(i=0;i<100000;i++){
		if(a[i]<2)continue;
		n-=2*(a[i]-1);
	}
	cout<<n<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(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 INF (1 << 30 - 1)
#define LLINF (1LL << 60)
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N >> K;
    while (N > 0) {
        N /= K;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

int main() {
	int i, j, k;
	int a, b, c, d;
	int min1, min2;

	cin >> a >> b >> c >> d;

	min1 = min(a, b);
	min2 = min(c, d);

	cout << min1 + min2 << endl;









	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define scan(a,n) for(long int index=0;index<n;index++) cin>>a[index];
#define print(a,n) for(long int index=0;index<n;index++) cout<<a[index]<<" ";cout<<endl;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define vli vector<long long int>
#define vlli vector<pair<long long int,long long int>>
#define vsi vector<string>
#define vci vector<char>



 
int main() {
   #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    fast;
   ll n;
   cin>>n;
   ll a[n],i,j;
   scan(a,n);
   ll b[n];
   b[0]=0;
   b[1]=abs(a[0]-a[1]);
   for(i=2;i<n;i++){
    b[i]=min(b[i-1]+abs(a[i-1]-a[i]),b[i-2]+abs(a[i-2]-a[i]));
   }
   cout<<b[n-1];



  return 0;    
 }  

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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

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

int F[N], IF[N], dp[N];

int add(int a, int b) {
    int res = (a + b) % MOD;
    return res;
}

int sub(int a, int b) {
    int res = (a - b) % MOD;
    return res < 0 ? res + MOD : res;
}

int mul(int a, int b) {
    return a * b % MOD;
}

int pow_mod(int a, int b) {
    int res = 1;
    while (b) {
        if (b & 1)
            res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}

int C(int n, int r) {
    if (n < 0 or r < 0 or n < r) return 0;
    return mul(F[n], mul(IF[r], IF[n - r]));
}

int ways(pii a, pii b) {
    int x = abs(a.fi - b.fi);
    int y = abs(a.se - b.se);
    return C(x + y, x);
}

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

    F[0] = 1;
    for (int i = 1; i < N; i++) 
        F[i] = mul(F[i - 1], i);
    
    IF[N - 1] = pow_mod(F[N - 1], MOD - 2);
    for (int i = N - 2; i >= 0; i--) 
        IF[i] = mul(IF[i + 1], i + 1);

    int h, w, n;
    cin >> h >> w >> n;

    vii a(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i].fi >> a[i].se;
    }

    a[n] = {h, w};
    sort(all(a));

    for (int i = 0; i <= n; i++) {
        dp[i] = ways({1, 1}, a[i]);
        for (int j = 0; j < i; j++) {
            if (a[j].se > a[i].se) continue;
            dp[i] = sub(dp[i], dp[j] * ways(a[j], a[i]));
        }
    }
    
    cout << dp[n] << "\n";
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))

vector<string> split(string,string);

//template<typename T>
//void swap(T*,T*);
//char ToUpper (char cX) { return toupper(cX); }

int main()
{
    char s,r;
    cin >> s >> r;
    if(s == r)
    {
        cout << "=";
    }
    else if(s < r)
    {
        cout << "<";
    }else
    {
        cout << ">";
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.*;
 
public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int K = in.nextInt();
        int sum = 0;
        int p[] = new int[N];
        for(int i = 0; i < N; i++){
            p[i] = in.nextInt();
        }
      Arrays.sort(p);
      for(int i = 0; i < K; i++){
            sum = sum + p[i];
        }
      System.out.println(sum);
      
    }
 
}

Measured memory_bytes: 38844
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    string number;
    cin >> number;
    REP(i, number.size()) {
        if (number.at(i) == '9') {
            number.at(i) = '1';
        } else if (number.at(i) == '1') {
            number.at(i) = '9';
        }
    }
    cout<< number << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int Q = sc.nextInt();
        int[][] cnt = new int[N+1][N+1];
        for (int i = 0; i < M; i++) {
            int L = sc.nextInt();
            int R = sc.nextInt();
            cnt[L][R]++;
        }

        int[][] prefSum = new int[N+1][N+1];
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= N; j++) {
                prefSum[i][j] = prefSum[i][j-1]+prefSum[i-1][j]+cnt[i][j]-prefSum[i-1][j-1];
            }
        }

        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < Q; i++) {
            int p = sc.nextInt();
            int q = sc.nextInt();
            int tmp = prefSum[q][q] - prefSum[p-1][q] - prefSum[q][p-1] + prefSum[p-1][p-1];
            ans.append(tmp).append('\n');
        }

        System.out.print(ans);
    }
}


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

using namespace std;

const int N=1e5+10;

typedef vector<int> vec;

class RUQ
{
public:
    vec data;
    vec lazy;
    int n;

    RUQ(int _n)
    {
        data.resize(4*_n);
        lazy.resize(4*_n);
        for(n=1;n<_n;n<<=1);
        fill(data.begin(),data.end(),0);
        fill(lazy.begin(),lazy.end(),0);
    }

    void Down(int p,int l,int r)
    {
        if(l+1>=r)
        {
            data[p]+=lazy[p];
        }else
        {
            lazy[p*2+1]+=lazy[p];
            lazy[p*2+2]+=lazy[p];
        }
        lazy[p]=0;
    }

    void update(int p,int l,int r,int x,int a,int b)
    {
        if(a>=r||b<=l) return;
        if(a<=l&&r<=b)
        {
            lazy[p]+=x;
            return;
        }
        Down(p,l,r);
        int mid=(l+r)/2;
        update(p*2+1,l,mid,x,a,b);
        update(p*2+2,mid,r,x,a,b);
    }

    int query(int p,int l,int r,int a,int b)
    {
        if(a>=r||b<=l) return -1;
        Down(p,l,r);
        if(a<=l&&r<=b) return data[p];
        int mid=(l+r)/2;
        if(a<mid)
        {
            return query(p*2+1,l,mid,a,b);
        }else
        {
            return query(p*2+2,mid,r,a,b);
        }
    }
};

int main()
{
    int n,q;

    while(scanf("%d %d",&n,&q)!=EOF)
    {

        RUQ ruq(n);
        while(q--)
        {
            int op,a,b,c;
            scanf("%d",&op);
            if(op)
            {
                scanf("%d",&a);
                printf("%d\n",ruq.query(0,0,ruq.n,a-1,a));
            }else
            {
                scanf("%d %d %d",&a,&b,&c);
                ruq.update(0,0,ruq.n,c,a-1,b);
            }
        }
    }

    return 0;
}



Measured memory_bytes: 5988