akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define MOD 998244353
// #define INF 100000000000

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


template <class T>
ostream &operator<<(ostream &o, const vector<T>&obj) {
    o << "["; for (int i = 0; i < (int)obj.size(); ++i) o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const vector<vector<T>>&obj) {
    o << "[" << endl; for (int i = 0; i < (int)obj.size(); ++i) o << "  " << obj[i] << endl; o << "]"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const pair<T, U>&obj) {
    o << "(" << obj.first << ", " << obj.second << ")"; return o;
}
template <class T, class U>
ostream &operator<<(ostream &o, const map<T, U>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const set<T>&obj) {
    o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}
template <class T>
ostream &operator<<(ostream &o, const queue<T>&obj) {
    queue<T> obj_cp = obj;
    bool first = true;
    o << "{";
    while (!obj_cp.empty()) { o << (!first ? ", " : "") << obj_cp.front(); obj_cp.pop(); first = false; }
    o << "}"; return o;
}

void print() {
    cout << "\n";
}
template<class Head, class... Body>
void print(Head head, Body... body) {
    cout << head << " ";
    print(body...);
}


ull pow_mod(ull x, ull n) {
    ull ans = 1;
    while (n != 0) {
        if (n & 1) {
            ans = ans * x % MOD;
        }
        x = x * x % MOD;
        n = n >> 1;
    }
    return ans;
}

#define N_MAX 200000
vector<ull> fac(N_MAX+1);
vector<ull> ifac(N_MAX+1);

void init_fac() {
    fac[0] = 1;
    ifac[0] = 1;
    for (int i = 1; i <= N_MAX; i++) {
        fac[i] = fac[i-1] * i % MOD;
        ifac[i] = ifac[i-1] * pow_mod(i, MOD-2) % MOD;
    }
}

ull comb_mod(ull a, ull b) {
    assert(a > 0 && b >= 0 && a >= b);
    ull tmp = ifac[a-b] * ifac[b] % MOD;
    return tmp * fac[a] % MOD;
}

int main(int argc, char const *argv[]) {
    ull N, M, K;
    cin >> N >> M >> K;

    if (N == 1) {
        cout << M << endl;
        return 0;
    }

    init_fac();

    ull ans = 0;
    for (unsigned int k = 0; k <= K; ++k) {
        ull x = (comb_mod(N-1, k) * pow_mod(M-1, N-1-k)) % MOD;
        ans = (ans + x) % MOD;
    }
    ans = (ans * M) % MOD;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6280
#include<iostream>
#include<algorithm>
using namespace std;
int n, k, a[51], i, ans; 
int main()
{
	cin >> n >> k;
	for(i = 0; i < n; i ++)
	{
		cin >> a[i];
	}
	sort(a, a + n);
	for(i = n - 1; i > n - k - 1; i --){
		ans += a[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    let c:Vec<Vec<char>> = (0..3).map(|_| read::<String>().chars().collect()).collect();
    //debug!(c);
    println!("{}{}{}", c[0][0], c[1][1], c[2][2]);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int c[9] = {0};
    int amin = 0, amax = 0;
    
    rep(i, n) {
        c[min(a[i] / 400, 8)]++;
    }
    
    rep(i, 9) {
        if (i == 8) {
            amax = amax + c[i];
            
            if (c[i]) {
                amin = max(amin, 1);
            }
        }
        else {
            if (c[i]) {
                amin++;
                amax++;
            }
        }
    }
    
    cout << amin << " " << amax << endl;
    return 0;
}

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

using namespace std;
const int N = 200000 + 10;
typedef long long ll;
int b[N], pre[N], vis[N], a[N], mark[N];
vector<int> path[N];
int main()
{
    int n;
    scanf("%d", &n);
    for(int i = 1; i<=n; i++)
        scanf("%d", &a[i]);
    int sb = n /2 + 1;
    if(n & 1)
    {
        b[sb] = a[1];
        sb++;
        for(int i = 2; i<=n; i+=2)
        {
            b[sb] = a[i];
            b[n - sb + 1] = a[i+1];
            sb ++;
        }
    }
    else
        for(int i = 1; i<=n; i+=2)
        {
            b[sb] = a[i];
            b[n - sb + 1] = a[i+1];
            sb ++;
        }
    for(int i = 1; i<=n; i++){
            if(i!=1)
            printf(" ");
        printf("%d", b[i]);
    }
    return 0;
}


Measured memory_bytes: 10752
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
typedef long long lint;
using namespace std;
 
int main(){
    int a,b;
    cin>>a>>b;
    if(a*b%2==0){
        cout<<"No";
    }else{
        cout<<"Yes";
    }
   
    return 0;
}

Measured memory_bytes: 256
//69行目から編集
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size())
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

//Simple Array Input
#define SAI int n;cin >> n;vi a(n);ain(a)
//Simple Graph Input
#define SGI(m) for(int i=0;i<m;i++){int a,b;cin >> a >> b;g[--a].pb(--b);g[b].pb(a);}
//Simple Tree Input
#define STI SGI(n-1)

typedef long long ll;
typedef long long integer;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvl;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a){
    for(int i=0;i<a.size();i++)cout << a[i] << (i < a.size()-1 ? ' ' : '\n');
}
///////////////////////////////////////////////////////////


int main(void){
	int n,p;cin >> n >> p;
	ll mod = p;

	string s;cin >> s;

	reverse(s.begin(),s.end());

	if(p == 2){
        ll ans = 0;
        reverse(s.begin(),s.end());

        rep(i,n){
            if((s[i] - '0') % 2 == 0){
                ans += (ll)(i + 1);
            }
        }
        cout << ans << '\n';
        return 0;
	}else if(p == 5){
        ll ans = 0;
        reverse(s.begin(),s.end());

        rep(i,n){
            if((s[i] - '0') % 5 == 0){
                ans += (ll)(i + 1);
            }
        }
        cout << ans << '\n';
        return 0;
	}


	vector<ll> a(n);
	ll now = 1;
	rep(i,n){
		a[i] = (now * (s[i] - '0')) % mod;
		now = (now * 10LL) % mod;
	}		
	vector<ll> c(n+1,0);
	rep(i,n){
		c[i+1] = (c[i] + a[i]) % mod;
	}

	vector<ll> cnt(p+1,0);
	rep(i,n+1){
		cnt[c[i]]++;
	}
	ll ans = 0;
	rep(i,p){
		ll c = cnt[i];
		ans += c * (c - 1) / 2; 
	}
	cout << ans << '\n';
}

Measured memory_bytes: 3708
#include <iostream>

using namespace std;

int main()
{
  long long n, a, b, ans = 0;
  cin >> n >> a >> b;
  if ( a > b || ( a != b && n == 1 ) ) {
    ans = 0;
  } else {
    ans = 1 + ( n - 2 ) * ( b - a );
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	ll A,B,C,K;
	scan(A>>B>>C>>K);
	ll ans=0;
	if(K>A){
		ans+=A;
		K-=A;
		if(K>B){
			K-=B;
			prin(ans-K);
		}
		else{
			prin(ans);
		}
	}
	else{
		prin(K);
		return 0;
	}
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
 
using namespace std;
 
#define ll unsigned long long int
#define pb push_back
#define mp make_pair
#define inff 100000
#define ff first
#define ss second
#define sz(x) ((int) (x).size())
#define fast cin.sync_with_stdio(0);cin.tie(0)
#define rep(i,N) for(int i = 0;i < N;i++)
#define frep(i,a,b) for(int i = a;i <= b;i++)
#define pii pair<int , int>
#define pll pair<ll , ll>
#define vii vector<int>
#define vpii vector< pii >
#define fill(A,v) memset(A,v,sizeof(A))
#define setbits(x) __builtin_popcountll(x)
#define print(A,j,k) for(int ii=j;ii<k;ii++)cout<<A[ii]<<" ";cout<<"\n"
#define all(x) (x).begin(), (x).end()
#define gcd __gcd
#define CASES int t;cin>>t;while(t--)
#define FILE freopen("inp.txt" , "r" , stdin);
#define ld long double

const int MOD = 1e9 + 7;
const int N = 1e6 + 5;
const int K = (1 << 17) + 10;	
const ll INF = 2e18 + 500;
const int inf = 0x7fffffff;
const int SQRT = 500;
const int lgN = 20;

int main(int argc, char const *argv[])
{
	fast;

	string s;
	cin >> s;
	ll ans = 1;
	
	map<char , int> cnt;
	cnt[s[0]] += 1;
	for (int i = 1;i < s.size();i++) {
		ans += (i) - cnt[s[i]];
		cnt[s[i]] += 1;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 720
//BISMILLAHHIR RAHMANIR RAHIM
#include<bits/stdc++.h>
using namespace std;
typedef long long int            ll;
typedef unsigned long long int   ull;
#define min3(a,b,c)              min(a,min(b,c))
#define F                        first
#define S                        second
#define PB                       push_back
#define MP                       make_pair
#define PI                       2*acos(0.0)
#define MOD                      998244353
int main()
{
    int len,len1,len2,cnt=0,cnt2=0,cnt3=0;
    string s;
    cin>>s;
    len=s.size();
    len1=(len-1)/2;
    len2=(len+3)/2;
    for(int i=0,l=len1-1; i<len1; i++,l--){
        if(s[i]==s[l])cnt++;
    }
    for(int i=len2-1, b=len-1; i<len; i++,b--){
        if(s[i]==s[b])cnt2++;
    }
    for(int i=0,l=len-1; i<len; i++,l--){
        if(s[i]==s[l]){
            cnt3++;
        }
    }
    if(cnt==len1 && cnt2-1==(len-len2) && cnt3==len)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    //cout<<len1<<" "<<cnt<<endl;
    //cout<<len-len2+1<<" "<<cnt2<<endl;
    return 0;
}


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

int main(){
    int a,b;
    
    cin >> a >> b;
    
    if (a < b) cout << "a < b" << endl;
    else if (a > b) cout << "a > b" << endl;
    else if (a == b) cout <<"a == b" << endl;
    
    return 0;
}

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

    /*考察:ろうそくを着ける範囲はx1 ~ xn の中で連続したk個の座標となる。
    　その範囲で一番左をL 一番右をRとしたとき、LとRの符号が一致（正・正or負・負）
    　のときは、１通り（例；一番左まで行き一番右まで行く）
    しかし符号が異なるとき、すぬけ君がその範囲を移動するとき2通りの行き方がある。
    １．座標０からRまで行き、RからLまで行くとき、
    ２．座標０からLまで行き、LからRまで行くとき。
    ここで１と２ともに含まれる時間はRからLまで、である。
    よって、座標０からRまで行くとき、と座標０からLまで行くときの最小時間＋RからLまでの時間が
    LからRまでかかる最小時間である。*/

int main(){
    ll n,k;//ろうそくと、着ける本数を受け取る。
    cin >> n >> k;
    vector<ll>a(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i);//座標を配列を用いて再現。
    }
    ll  ans = 1e18;//答えを限りなく大きくする。
    for(int R=k-1;R<n;R++){
        int L = R - k + 1 ;
        ll hutatoori = min(abs(a.at(L)),abs(a.at(R)));
        ll kyoutuu=abs(a.at(L)-a.at(R));
        ll check = hutatoori + kyoutuu;
        ans = min(ans,check);
    }
    cout << ans << endl;
}



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

using System.IO;

namespace ALDS1_5_D
{
    class Program
    {
        private static int n;
        private static int[] A;
        private static long pairOfReverse = 0;

        static void Main(string[] args)
        {
            n = int.Parse(Console.ReadLine());
            A = Console.ReadLine()
                       .Split(' ')
                       .Select(s => int.Parse(s))
                       .ToArray();
            Program.MergeSort(0, Program.A.Length - 1);
            Console.WriteLine(Program.pairOfReverse);
        }

        private static void Merge(int leftInd, int midInd, int rightInd)
        {
            int[] leftArry = new int[midInd - leftInd + 1];
            int[] rightArry = new int[rightInd - midInd];

            for (int i = 0; i < leftArry.Length; i++)
            {
                leftArry[i] = Program.A[leftInd + i];
            }

            for (int i = 0; i < rightArry.Length; i++)
            {
                rightArry[i] = Program.A[midInd + 1 + i];
            }

            for (int l = 0, r = 0, k = leftInd; k <= rightInd; k++)
            {
                if (l < leftArry.Length && r >= rightArry.Length || l < leftArry.Length && r < rightArry.Length && leftArry[l] <= rightArry[r])
                {
                    Program.A[k] = leftArry[l];
                    l++;
                }
                else
                {
                    Program.A[k] = rightArry[r];
                    r++;
                    Program.pairOfReverse += leftArry.Length - l;
                }
            }
        }

        private static void MergeSort(int leftInd, int rightInd)
        {
            if (leftInd < rightInd)
            {
                int midInd = (leftInd + rightInd) / 2;
                Program.MergeSort(leftInd, midInd);
                Program.MergeSort(midInd + 1, rightInd);
                Program.Merge(leftInd, midInd, rightInd);
            }
            return;
        }
    }
}



Measured memory_bytes: 41720
from copy import deepcopy
import sys
from itertools import accumulate
N,X = map(int,input().split())
Llist = list(map(int,input().split()))

ruiseki = accumulate(Llist)
for i,r in enumerate(ruiseki,2):
    if r <= X:
        continue
    else:
        print(i-1)
        sys.exit()
print(i)

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

#define int long long
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define endl "\n"
#define ends " "
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
#define debugV(v) cerr << #v << ": [ "; for(int __ = 0; __ < v.size(); __++) cerr << v[__] << ((__ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugVP(v) cerr << #v << ": [ "; for(int ___ = 0; ___ < v.size(); ___++) cerr << '{' << v[___].first << ", " << v[___].second << '}' << ((___ != v.size() - 1) ? ", " : ends); cerr << ']' << endl
#define debugA(a, n) cerr << #a << ": [ "; for(int ____ = 0; ____ < n; ____++) cerr << a[____] << ((____ != n - 1) ? ", " : ends); cerr << ']' << endl
#define print(args...) fprintf (stderr, args)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
const int INF = 1e9, MOD = INF + 7;

/////////////////////////////////////////////////////////////////////

const int N = 3e3 + 20;

int dp[N][N];
pii par[N][N];

int32_t main(){

    sync;

    string s, t; cin >> s >> t;
    int n = s.size(), m = t.size();
    for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) {
    	if (dp[i][j] < dp[i - 1][j]) dp[i][j] = dp[i - 1][j], par[i][j] = par[i - 1][j];
    	if (dp[i][j] < dp[i][j - 1]) dp[i][j] = dp[i][j - 1], par[i][j] = par[i][j - 1];
    	if (s[i - 1] == t[j - 1] && dp[i][j] < dp[i - 1][j - 1] + 1) dp[i][j] = dp[i - 1][j - 1] + 1, par[i][j] = make_pair(i, j);
    }
    pii p = par[n][m];
    string ans = "";
    while(p.first > 0 && p.second > 0) {
    	ans += s[p.first - 1];
    	p = par[p.first - 1][p.second - 1];
    }
    reverse(all(ans));
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 213504
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


int main(void) {
    ll N, H;
    cin >> N >> H;
    ll i;
    priority_queue<P> q;
    for(i=0; i<N; i++) {
        ll a, b;
        cin >> a >> b;
        q.push(P(a, 0));
        q.push(P(b, 1));
    }
    
    ll ans=0;
    while(H>0) {
        P f=q.top(); q.pop();
        ll u=f.ft;
        
        if(f.sc==1) {
            H-=u;
            ans++;
        }else {
            ans+=(H+u-1)/u;
            break;
        }
    }
    
    pt(ans);
    
}


Measured memory_bytes: 6384
#include<iostream>
#include<algorithm>
using namespace std;
const int MAX=100005;
struct Card{
	int value;char color;
} temp1[MAX/2],temp2[MAX/2],A[MAX],B[MAX];
void merge(Card A[],int left,int right){
	int mid=left+(right-left)/2;
	int len1=mid-left,len2=right-mid;
	for(int i=0;i<len1;i++)temp1[i]=A[left+i];
	for(int i=0;i<len2;i++)temp2[i]=A[mid+i];
	int i=0,j=0,k=left;
	while(i<len1&&j<len2){
		if(temp1[i].value>temp2[j].value){
			A[k++]=temp2[j++];
		}else{
			A[k++]=temp1[i++];
		}
	}
	while(i<len1)A[k++]=temp1[i++];
	while(j<len2)A[k++]=temp2[j++];
}
void MergeSort(Card A[],int left,int right){
	if(right==left+1)return;
	if(left<right){
		int mid=left+(right-left)/2;
		MergeSort(A,left,mid);
		MergeSort(A,mid,right);
		merge(A,left,right);
	}
}
int partition(Card A[],int left,int right){
	int x=A[right].value;
	int i=left-1,j;
	for(j=left;j<right;j++){
		if(A[j].value<=x){
			i++;
			swap(A[i],A[j]);
		}
	}
	swap(A[i+1],A[j]);
	return i+1;
}
void QuickSort(Card A[],int left,int right){
	if(left<right){
		int q=partition(A,left,right);
		QuickSort(A,left,q-1);
		QuickSort(A,q+1,right);
	}
}
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>A[i].color>>A[i].value;
		B[i].color=A[i].color;
		B[i].value=A[i].value;
	}
	MergeSort(A,0,n);
	QuickSort(B,0,n-1);
	bool isstable=true;
	for(int i=0;i<n;i++){
		if(A[i].color!=B[i].color||A[i].value!=B[i].value){
			isstable=false;
			break;
		}
	}
	cout<<(isstable?"Stable":"Not stable")<<endl;
	for(int i=0;i<n;i++){
		cout<<B[i].color<<" "<<B[i].value<<endl;
	}
	return 0;
}


Measured memory_bytes: 5328
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define EPS 1e-10
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

string getReverse(string str);
bool isLeap(int y);
ll gcd(ll a, ll b);
ll lcm(ll a, ll b);
double distanceAB(double xa, double ya, double xb, double yb);
void trace(int A[], int N);

/*
class Target
{
public:
	vector <string> draw(int n)
	{

	}
};
*/


struct bar
{
	int h, p, q;
	
	bool operator>(const bar &b) const
	{
		return h > b.h;
	}
};


int main()
{
	while (1)
	{
		int n, m, a;
		vector<bar> vbars;
		
		cin >> n >> m >> a;
		if (n == 0 && m == 0 && a == 0) break;
		
		rep(i, m)
		{
			bar b;
			cin >> b.h >> b.p >> b.q;
			vbars.push_back(b);
		}
		
		sort(vbars.begin(), vbars.end(), greater<bar>());
		for (unsigned int i=0; i<vbars.size(); i++)
		{
			if (vbars[i].p == a)
			{
				a = vbars[i].q;
			} else if (vbars[i].q == a) {
				a = vbars[i].p;
			}
		}
		cout << a << endl;
	}
	
	return 0;
}


string getReverse(string str)
{
	string ret = "";
	for (int i=str.length()-1; i>=0; i--)
	{
		ret += str.substr(i, 1);
	}
	return ret;
}

bool isLeap(int y)
{
	return y % 400 == 0
						? true : y % 100 == 0
						? false : y % 4 == 0
						? true : false;
}

ll gcd(ll a, ll b)
{
	return (b > 0) ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b)
{
	return a / gcd(a, b) * b;
}

void trace(int A[], int N)
{
	REP(N)
	{
		if (i > 0) cout << " ";
		cout << A[i];
	}
	cout << endl;
}

double distanceAB(double xa, double ya, double xb, double yb)
{
	return sqrt((xb-xa)*(xb-xa) + (yb-ya)*(yb-ya));
}

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

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;

const int INF = 1e9;
const ll lINF = 1e18;
const int MOD = 1e9+7;
const int SIZE = 100;


int main() {
	string s;
	cin >> s;
	ll ans = 1;
	ll c[26];
	for (int i = 0; i < 26; i++) {
		c[i] = 0;
	}
	for (ll i = 0; i < s.length(); i++) {
		s[i] -= 97; c[s[i]]++;
	}
	for (ll i = 1; i < s.length(); i++) {
		ll add = i;
		for (int j = 0; j < 26; j++) {
			if (c[j] > s.length() - i) {
				add -= (c[j] - (s.length() - i));
			}
		}
		ans += add;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(x-r < 0 || y-r < 0 || x+r > W || y+r > H){
		cout << "No" <<endl;
	}
	else{
		cout << "Yes" <<endl;
	}
	return 0;
}

Measured memory_bytes: 1156
int main()
{
  int a[4];
  int i = 0;
  while (i < 4)
  {
    scanf("%d ",&a[i]);
    //if (i % 2 == 0 && i != 0)
    i++;
  }
  if (a[0] % 2 == 0 || a[1] % 2 == 0)
    printf("Even");
  else
    printf("Odd");
}

Measured memory_bytes: 384
#include<iostream>

using std::cout;
using std::cin;
using std::endl;

void numberOfWay(int n, int x) {
    int num = 0;
    int first;
    int second;
    int third;
    for (first = 1; first <= n - 2; first++) {
        third = x - first; 
        for (second = first + 1; second <= n - 1; second++) {
            int third_temp = third - second;
            if (first < second && second < third_temp && third_temp <= n) {
                num++;
            }
        }
    }
    cout << num << endl;
}

int main(void) {
    int n;
    int x;
    cin >> n >> x;
    while (n != 0 || x != 0) {
        numberOfWay(n , x); 
        cin >> n >> x;
    }
    return 0;
}

Measured memory_bytes: 3076
N, D = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(i + 1, N):
        t = 0
        for y, z in zip(X[i], X[j]):
            t += abs(y - z) ** 2
        t = t ** 0.5
        if t % 1 == 0:
            ans += 1
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()
 
vec Prime(1e7,0),W(1e7,0),isPrime(1e7+1,0);
void sosu(ll n){
  isPrime.at(0)=1;
  isPrime.at(1)=1;
  ll t=0;
  rep(i,n+1){
    if(isPrime.at(i)==0){
      Prime.at(t)=i;
      t++;
      for(ll j=2*i;j<=n;j+=i){
        isPrime.at(j)=1;
      }
    }
  }
}
bool factor(ll M){
  rep(i,100000){
    if(Prime.at(i)>1e3){
      if(M==1){
        return true;
      }else{
        if(W.at(M)==0){
          W.at(M)=1;
          return true;
        }else{
          return false;
        }
      }
    }else{
      if(M%Prime.at(i)==0&&W.at(i)!=0){
        return false;
      }else if(M%Prime.at(i)==0){
        while(M%Prime.at(i)==0){
          M/=Prime.at(i);
        }
        W.at(i)=1;
      }
    }
  }
}
 
int main(){
  ll N,s,k=0;
  cin >> N;
  vec A(N);
  sosu(1e6);
  rep(i,N){
    cin >> A.at(i);
    if(k!=1&&!factor(A.at(i))){
      k=1;
    }
    if(i==0){
      s=A.at(i);
    }else{
      s=gcd(s,A.at(i));
    }
  }
  if(k==0){
    cout << "pairwise coprime" << endl;
  }else if(s==1){
    cout << "setwise coprime" << endl;
  }else{
    cout << "not coprime" << endl;
  }
}


Measured memory_bytes: 245340
#include<stdio.h>
#ifdef DEBUG
#include<conio.h>
#endif // DEBUG

int main () {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif // DEBUG

    int a, b;
    while (scanf("%d %d", &a, &b), 0 != a && 0 != b)
    {
        for (size_t i = 0; i < a; i++)
        {
            for (size_t j = 0; j < b; j++)
            {
                if(0 == (i + j) % 2) printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }

#ifdef DEBUG
    getch();
#endif // DEBUG
    return 0;
}




Measured memory_bytes: 2120
//    _____ _     _                _           _     _ _     _     
//    \_   \ |_  (_)___  __      _| |__   __ _| |_  (_) |_  (_)___ 
//     / /\/ __| | / __| \ \ /\ / / '_ \ / _` | __| | | __| | / __|
//  /\/ /_ | |_  | \__ \  \ V  V /| | | | (_| | |_  | | |_  | \__ \
//  \____/  \__| |_|___/   \_/\_/ |_| |_|\__,_|\__| |_|\__| |_|___/
//                                                                 
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int sz=1e6+9;
ll x;

int main(){
	cin>>x;
	ll ans=0;
	ans+=(x/500)*1000;
	x%=500;
	ans+=(x/5)*5;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h> 
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <iostream>
using namespace std;
int main(){
	int n, m;
	int a[301][301];
	cin>>n>>m;
	int i, j, k;
	for(i=1;i<=n;i++){
		for(j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	int high=n, low=1;
	int test;
	int t=1;
	int tt;
	int s, u, v, w;
	int c[301];//记录每个比赛的参赛人数 
	int valid[301]; 
	for(k=1;low<high;k++){
		test=(high+low)/2;
		for(i=1;i<=300;i++){
			valid[i]=1;
		}
		for(s=1;s<=m;s++){
			t=1; 
			for(u=1;u<=m;u++){
				c[u]=0;
			}//l30-33：将每个比赛参加人数重置为0 
			for(i=1;i<=n;i++){
				for(j=1;j<=m;j++){
					if(valid[a[i][j]]==0) continue;
					c[a[i][j]]++;
					break;
				}
			}//记录每个比赛参赛人数 
			for(i=1;i<=m;i++){
				if(c[i]>test){
					t=0;
					valid[i]=0;
					break;
				}
			}//如果有一个比赛参赛人数超过test，取消该比赛 
			if(t==0) continue;
			if(t==1) break;
		}//判断test是否可行 
		if(t==1) high=test;
		if(t==0) low=test+1; 
	}
	cout<<high;
	return 0;
}

Measured memory_bytes: 640
N, M = map(int, input().split())
box_num = [1]*N
box_color = [0]*N
box_color[0] = 1   # 0:白 1:赤 2:白or赤

for _ in range(M):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    box_num[x] -= 1
    box_num[y] += 1

    if box_num[y] != 1:
        if box_color[x]==box_color[y]:
            pass
        else:
            box_color[y] = 2
    else:
        box_color[y] = box_color[x]

ans = 0
for n, c in zip(box_num, box_color):
    if n>0:
        if c != 0:
            ans += 1

print(ans)

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

namespace B___I_miss_youa
{
    class Program
    {
        static void Main(string[] args)
        {
            var one = Console.ReadLine();
            int intone = one.Length;
            StringBuilder x = new StringBuilder();
            for (int i = 0; i < intone; i++)
            {
                x.Append("x");
            }
            Console.WriteLine(x.ToString());

        }
    }
}


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

int main()
{
    map<char, string> str_map;
    cin >> str_map['a'];
    cin >> str_map['b'];
    cin >> str_map['c'];

    char index = 'a';
    char tmp_char;

    while (true) {
        tmp_char = str_map[index][0];
        str_map[index].erase(str_map[index].begin());
        index = tmp_char;
        if (str_map['a'].empty() || str_map['b'].empty() || str_map['c'].empty()) {
            break;
        }

    }

    while (true) {
        if (str_map[index].empty()) {
            cout << char(index - 32) << endl;
            break;
        }
        tmp_char = str_map[index][0];
        str_map[index].erase(str_map[index].begin());
        index = tmp_char;
    }
}


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

using namespace std;

int main(void){
    
    int H,W; cin >> H>>W;

    
    int cost[10][10];
  
    
    for(int i = 0;i < 10;i++)
        for(int j = 0;j < 10;j++){
         cin >> cost[i][j];
        }
    
    for(int k = 0;k <= 9;++k){
        for(int i = 0;i <= 9;++i){
          for(int j = 0;j <= 9;++j){
            cost[i][j] = min(cost[i][j],cost[i][k] + cost[k][j]);
        }
        }
}


    int count = 0;
    
    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            int input;
            cin >> input;
            if(input >= 0){
                count+=cost[input][1];
                
            }
        }
    }
        
    cout << count << endl;
    return 0;
    
}
        

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

using namespace std;

int n, m, x;
vector<int> c;
vector<vector<int> > a;

const int INF = 1e8;

int get_cost(const vector<bool>& v){
    vector<int> rikaido(m,0);
    int cost = 0;
    for(int i=0; i!=n; i++){
        if(v.at(i)){
            for(int j=0; j!=m; j++) rikaido.at(j) += a.at(i).at(j);
            cost += c.at(i);
        }
    }
    bool is_master = true;
    for(const auto& ri : rikaido) if(ri < x) is_master = false;
    /*cout << "v:";
    for(auto vi:v) cout << (int)vi;
    cout << "   " << cost << endl;*/
    return is_master ? cost : INF;
}


int dfs(vector<bool>& v){
    if(v.size() == n) return get_cost(v);
    else{
        vector<bool> nv1 = v, nv2 = v;
        nv1.push_back(true);
        nv2.push_back(false);
        return min(dfs(nv1), dfs(nv2));
    }
}


int main(){
    cin >> n >> m >> x;
    c.resize(n);
    a.resize(n, vector<int>(m,-INF));
    for(int i=0; i!=n; i++){
        cin >> c.at(i);
        for(auto& ai:a.at(i)) cin >> ai;
    }

    vector<bool> init(0);
    int out;
    out = dfs(init);

    cout << (!(out==INF) ? out : -1) << endl;
    
    return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  cin>>n;
  int ans = 252521;
  REP(i,n){
    int a;
    cin>>a;
    int c = 0;
    while(a%2==0){
      a/=2; c++;
    }
    CHMIN(ans,c);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){
  
  char card[36][3], cardA[36][3], cardB[36][3];
  char temp[3];
  int  num, i, j, minj, flag;

  scanf("%d", &num);
  
  for(i = 0; i < num; i++){
    scanf("%s", card[i]);
    strcpy(cardA[i], card[i]);
    strcpy(cardB[i], card[i]);
  }
  
  for(i = 0; i < num; i++){
    for(j = num-1; j > i; j--){
      if( cardA[j][1] < cardA[j-1][1] ){
	strcpy(temp, cardA[j]);
	strcpy(cardA[j], cardA[j-1]);
	strcpy(cardA[j-1], temp);
      }
    }
  }
  for(i = 0; i < num-1; i++){
    printf("%s ", cardA[i]);
  }
  printf("%s", cardA[num-1]);
  printf("\n");

  minj = 0;
  
  for(i = 0; i < num-1; i++){
    if(flag == 1){
      break;
    }

    flag = 0;
    
    if(cardA[i][1] == cardA[i+1][1]){
      
      for(j = minj; j < num; j++){
	if(flag != 2){
	  if(card[j][1] == cardA[i][1]){
	    if(card[j][0] != cardA[i][0]){
	      flag = 1;
	      break;
	    }
	    else{
	      minj = j+1;
	      flag = 2;
	    }
	  }
	}
      }
    }
    else{
      minj = 0;
    }
  }
  
  if(flag == 1){
    printf("Not stable\n");
  }
  else{
    printf("Stable\n");
  }

  minj = 0;  
  for(i = 0; i < num - 1; i++){
    minj = i;
    
    for(j = i+1; j < num; j++){
      
      if(cardB[j][1] < cardB[minj][1]){
	minj = j;
      }
      
    }
    if(i != minj){
      strcpy(temp, cardB[i]);
      strcpy(cardB[i], cardB[minj]);
      strcpy(cardB[minj], temp);
    }
  }
  
  for(i = 0; i < num-1; i++){
    printf("%s ", cardB[i]);
  }
  printf("%s", cardB[num-1]);
  printf("\n");

  minj = 0;
  flag = 0;
  
  for(i = 0; i < num-1; i++){
    if(flag == 1){
      break;
    }

    flag = 0;

    if(cardB[i][1] == cardB[i+1][1]){
      for(j = minj; j < num; j++){
	if(flag != 2){
	  if(card[j][1] == cardB[i][1]){
	    if(card[j][0] != cardB[i][0]){
	      flag = 1;
	      break;
	    }
	    else{
	      minj = j+1;
	      flag = 2;
	    }
	  }
	}
      }
    }
    else{
      minj = 0;
    }
  }

  if(flag == 1){
    printf("Not stable\n");
  }
  else{
    printf("Stable\n");
  }
  
  return 0;
}



Measured memory_bytes: 2068
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define se second
#define mp make_pair
#define fi first
#define del(a,vec) vec.erase(std::remove(vec.begin(), vec.end(), a), vec.end());
#define search(f,l,v) binary_search(f,l,v)
#define iter(a,b) vector<int>::iterator a,b
#define lower(v,num) lower_bound (v.begin(), v.end(), num);
#define upper(v,num) upper_bound (v.begin(), v.end(), num); 
#define removecopy(a) unique(a.begin(), a.end()); 
#define ll long long int
namespace Rahul{
    bool isPrime(int n) 
    {if (n <= 1)  return false; if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; }
    ll pow (ll x, ll n,ll mod) {//calculate x^n
    if (n == 0) return 1;

    ll res = pow (x, n / 2,mod);

    res = (res * res) % mod;
    if (n % 2) res = (res * x ) % mod;

    return res;
    }
    ll _gcd(ll a,ll b)
    {
        if(a==0)
            return b;
        else    
            return _gcd(b%a,a);
    }
    //s.erase(s.find(2)) where s={1,2,3,3,2}; 
};

using namespace Rahul;
int main()
{
     ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
     
     priority_queue<int>q;
     q.push(-100);
     q.push(-101);
     q.push(-102);
     q.push(-103);
     q.push(-104);
     q.push(-105);
     unordered_map<int,int>cn;
     cn[100]++;
     cn[101]++;
     cn[102]++;
     cn[103]++;
     cn[104]++;
     cn[105]++;
     while(1)
        {
            int num=q.top();
            q.pop();
            num=-num;
            for(int i=100;i<=105;i++)
                {
                    if(cn[num+i]==0)
                    q.push(-(num+i));
                    cn[num+i]++;
                }
            // cout<<num<<endl;    
            if(num>100000)
            break;
        }
     int n;
     cin>>n;
     if(cn[n])
        cout<<1<<endl;
    else
    cout<<0<<endl;
     
}


Measured memory_bytes: 4388
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        for(int i=0 ;i<n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        int[] memo = new int[h+1];
        Arrays.fill(memo, Integer.MAX_VALUE);
        memo[0] = 0;
        for(int i=0; i<h; i++) {
            if(memo[i] == Integer.MAX_VALUE) continue;
            for(int j=0; j<n; j++) {
                int next = Math.min(h, i + a[j]);
                memo[next] = Math.min(memo[next], memo[i] + b[j]);
            }
        }

        System.out.println(memo[h]);


    }

}


Measured memory_bytes: 27880
// https://onlinejudge.u-aizu.ac.jp/courses/library/3/DSL/2/DSL_2_B
#include <bits/stdc++.h>

using namespace std;

int n, q;

int data[400000];

void add(int i, int val)
{
    i += n - 1;
    data[i] += val;
    while (i > 0)
    {
        i = (i - 1) / 2;
        data[i] = data[i * 2 + 1] + data[i * 2 + 2];
    }
}

int getSum(int a, int b, int x, int l, int r)
{
    if (r <= a || b <= l)
        return 0;
    else if (a <= l && r <= b)
        return data[x];
    else
    {
        int vl = getSum(a, b, x * 2 + 1, l, (l + r) / 2);
        int vr = getSum(a, b, x * 2 + 2, (l + r) / 2, r);
        return vl + vr;
    }
}

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

    int _n = 1;
    while (_n < n)
        _n *= 2;
    n = _n;

    for (int i = 0; i < q; i++)
    {
        int com, x, y;
        cin >> com >> x >> y;

        if (com == 0)
            add(x - 1, y);
        else
            cout << getSum(x - 1, y, 0, 0, n) << endl;
    }

    return 0;
}



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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }

struct vertex { int c; int d; };
struct query { int v; int d; int c; };
vector<vector<int>> adj;
vector<vertex> ver;

void dfs(int v, int p, int d, int c) {
  if (!ver[v].c) ver[v].c = c;
  for (auto x: adj[v]) {
    if (x==p) continue;
    if (ver[x].d>=d-1) continue;
    else {
      ver[x].d = d-1;
      dfs(x,v,d-1,c);
    }
  }
}

int main() {
  int N, M; cin >> N >> M;
  adj.resize(N); ver.resize(N,{0,-1});
  rep(i,M) {
    int a, b; cin >> a >> b; a--; b--;
    adj[a].push_back(b); adj[b].push_back(a);
  }
  int Q; cin >> Q;
  query q[Q];
  rep(i,Q) {
    int v, d, c; cin >> v >> d >> c; v--;
    q[i] = {v, d, c};
  }

  per(i,Q) {
    dfs(q[i].v, -1, q[i].d, q[i].c);
  }
  rep(i,N) cout << ver[i].c << endl;
  // cout << result << endl;
  return 0;
}

Measured memory_bytes: 8440
#define LOCAL
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
  out << "["; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
  return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
  out << "{"; bool first = true;
  for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;
mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

struct fast_ios {
  fast_ios() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
  };
} fast_ios_;

const int N = 1e6 + 10;
char s[N];
int main() {
  scanf("%s", s);
  for (int i = 0; s[i]; ++i) {
    if (s[i] == '?') s[i] = 'D';
  }
  puts(s);
  return 0;
}


Measured memory_bytes: 3384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mx 200005

int main()
{
	int n;
	cin>>n;
	
	int a[mx];
	for(int i=0;i<n;i++) cin>>a[i];
	sort(a,a+n);
	reverse(a,a+n);
	ll sum=0;
	int id=0;
	for(int i=0;i<n-1;i++)
	{
	
	sum+=a[id];
	if(i%2==0)
	id++;
	
	
    }
	cout<<sum<<endl;
	
	
	 
	    
}

Measured memory_bytes: 4372
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	

    int N; cin >> N;
    vector<LL> A(N);
    REP(i,N)
    {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    LL ans = 0;
    if(N % 2 == 0)
    {
        REP(i,N)
        {
            if(i < N/2 - 1) ans -= 2 * A[i];
            if(i == N/2 - 1) ans -= A[i];
            if(i == N/2) ans += A[i];
            if(i > N/2) ans += 2 * A[i];
        }
    }
    else
    {
        LL tmp;
        // lsls...l pattern
        REP(i,N)
        {
            if(i <= (N-1)/2 - 1) 
            {
                dump("phase1")
                ans -= 2 * A[i];
            }
            else if(i == (N-1)/ 2 || i == (N-1)/2 + 1) 
            {
                dump("phase2")
                ans += A[i];
            }
            else 
            {
                dump("phase3")
                ans += 2 * A[i];
            }
            dump(i)
            dump(ans)
        }
        tmp = ans;
        ans = 0;
        // slsl...s pattern
        REP(i,N)
        {
            if(i < (N-1)/2 - 1) ans -= 2 * A[i];
            else if(i == (N-1)/2 - 1 || i == (N-1)/2) ans -= A[i];
            else ans += 2 * A[i];
            dump(ans)
        }

        ans = max(tmp, ans);


    }

    cout << ans << endl;

}


Measured memory_bytes: 1024
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		int H = Integer.parseInt(tokens[0]);
		int A = Integer.parseInt(tokens[1]);
		int result = H / A;
		if (H % A != 0) {
			result++;
		}
		System.out.println(result);
	}

	void calc() {
	}

	void showResult() {
	}
}


Measured memory_bytes: 22996