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

//{{{
#if ((_WIN32 || __WIN32__) && __cplusplus < 201103L)
#define lld I64d
#else
#define lld lld
#endif
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<LL, int> pii;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define clr(a, b) memset(a, b, sizeof(a))
// clang-format off
#define debug(args...) {vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr<<endl;}
 vector<string> split(const string& s, char c) {vector<string> v; stringstream ss(s); string x;
 while (getline(ss, x, c)) v.push_back(x); return v;} void err(vector<string>::iterator) {}
 template<typename T, typename... Args> void err(vector<string>::iterator it, T a, Args... args)
{cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", "; err(++it, args...);}
// clang-format on
//}}}
//

int T;

const int mod = 1e9 + 7;
const int N = 1e2 + 10;
int x;
int n;
int a[N];

// LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
// LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }

int head[N], e;
struct E
{
    int v, next;
} edge[N];

void addedge(int u, int v)
{
    edge[e].v = v;
    edge[e].next = head[u];
    head[u] = e++;
}

LL dp[111];
bool inque[111];
queue<int> q;

int main()
{
#ifdef LOCAL
    freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
#endif

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

        clr(dp, 0);
        dp[1] = 1000;
        inque[1] = 1;
        q.push(1);

        while (!q.empty())
        {
            int day = q.front();
            LL money = dp[day];
            q.pop();

            inque[day] = 0;

            for (int i = day + 1; i <= n; i++)
            {
                if (a[i] > a[day])
                {
                    LL d = money % a[day];
                    LL v = money / a[day] * a[i];
                    LL tot = v + d;
                    dp[i] = max(dp[i], tot);

                    if (!inque[i])
                    {
                        inque[i] = true;
                        q.push(i);
                    }
                }
                else
                {
                    dp[i] = max(dp[i], money);
                    if (!inque[i])
                    {
                        inque[i] = true;
                        q.push(i);
                    }
                }
                // debug(i, dp[i]);
            }
        }

        cout << dp[n] << endl;
    }

    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
using pii = pair<int, int>;

#define rep(i,k,n) for(int i=(k); i != int(n); ++i)
#define sz(x) x.size()
#define all(x) x.begin(), x.end()

#define dbg(x) cout << #x << '=' << x << '\n'
#define dbg2(x, y) cout << #x << '=' << x << ' ' << #y << '=' << y << '\n' 

#define input() (*istream_iterator<int>(cin))
#define strin() (*istream_iterator<string>(cin))
#define output(x) cout << x << '\n' 

int main(){
    ios::sync_with_stdio(false);
    int n = input();
    vector<int> worker(n);
    n--;
    while(n--) worker[input()-1]++;
    for(int cur: worker) cout << cur << "\n";
}

Measured memory_bytes: 4020
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<complex>
#include<cstdio>
typedef unsigned long long ull;
#define rep(i,a) for(int i=0;i<a;i++)
#define loop(i,a,b) for(int i=a;i<b;i++)
using namespace std;
const double eps = 1e-10;
const double pi = acos(-1);
const double inf = (int)1e8;
const double EPS=1e-10;

typedef complex<double> P;
typedef vector<P> G;
 
struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};
P pin(){
    double x,y;
    char d;
    cin>>x>>y;
    P p(x,y);
    return p;
}
double cross(P a,P b){
    return imag(conj(a)*b);
}
P crosspointLL(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  return m[0] + B / A * (m[1] - m[0]);
}
int main(void){
  int n;
  cin>>n;
  rep(i,n){
    P a=pin(),b=pin(),c=pin();
    P t1=(a+b)/2.0;
    P t2=(b+c)/2.0;
    P out=crosspointLL(L(t1,(b-a)*P(0,1)+t1),L(t2,(c-b)*P(0,1)+t2));
    printf("%.3f %.3f %.3f\n",out.real(),out.imag(),abs(out-a));
  }
  return 0;
}

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

#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 ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int x; cin >> x;
    cout << (x>=30?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    int last = 0;

    while(true)
    {
        if (s[last]=="")
        {
            char ans = last + 'A';
            cout << ans  << endl;
            break;
        }
        int tmp = s[last][0] - 'a';
        
        s[last].erase(s[last].begin());
        last = tmp;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    string s;
    cin>>n;
    cin>>s;
    int ans=0;
    for(int i=0;s[i];++i){
        ans++;
        while(s[i+1]==s[i])
            i++;
    }
    cout<<ans<<endl;
}


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

int main() {
  int n, q;
  std::vector<int> s, t;

  std::cin >> n;
  s.resize(n);
  for (int i = 0; i < n; ++i) std::cin >> s[i];
  std::cin >> q;
  t.resize(q);
  for (int i = 0; i < q; ++i) std::cin >> t[i];

  sort(begin(s), end(s));

  int res = 0;
  for (auto&& num : t) {
    if (std::binary_search(begin(s), end(s), num)) {
      res++;
    }
  }

  std::cout << res << std::endl;
}

Measured memory_bytes: 3280
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
    int N,K;cin>>N>>K;
    vector<int> A;
    for(int i = 0;i < N;i++){
        int _a;cin>>_a;
        A.push_back(_a);
    }
    vector<vector<ll>> dp(N+1, vector<ll>(K+1, 0));
    vector<vector<ll>> sum(N+1, vector<ll>(K+2,1));
    dp[0][0] = 1;
    sum[0][0] = 0;
    for(int i = 1;i < N+1;i++){
        sum[i][0] = 0;
        for(ll j = 0;j < K+1;j++){
            dp[i][j] = (sum[i-1][j+1] - sum[i-1][max(j-A[i-1],0LL)]+MOD)%MOD;
            sum[i][j+1] = (sum[i][j] + dp[i][j]) % MOD;
        }
    }
    // for(int i = 0;i < N+1;i++){
    //     for(int j = 0;j < K+1;j++){
    //         cout<<dp[i][j]<<" ";
    //     }cout<<endl;
    // }
    // for(int i = 0;i < N+1;i++){
    //     for(int j = 0;j < K+2;j++){
    //         cout<<sum[i][j]<<" ";
    //     }cout<<endl;
    // }
    cout<<dp[N][K]<<endl;
}

Measured memory_bytes: 159088
use std::io::{self, Read, Write};
use std::str::{self, FromStr};

pub struct IO<R: Read, W: Write>(R, io::BufWriter<W>);

impl<R: Read, W: Write> IO<R, W> {
    pub fn new(reader: R, writer: W) -> Self {
        Self(reader, io::BufWriter::new(writer))
    }

    pub fn read<T: FromStr>(&mut self) -> T {
        let token = self
        .0
        .by_ref()
        .bytes()
        .map(|b| b.unwrap())
        .skip_while(|&b| (b as char).is_whitespace())
        .take_while(|&b| !(b as char).is_whitespace())
        .collect::<Vec<u8>>();

        unsafe { str::from_utf8_unchecked(token.as_slice()) }
        .parse()
        .ok()
        .expect("Can't parse it.")
    }

    pub fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }

    pub fn write<S: ToString>(&mut self, s: S) {
        self
        .1
        .write_all(s.to_string().as_bytes())
        .unwrap();
    }

    pub fn flush(&mut self) {
        self
        .1
        .flush()
        .unwrap();
    }
}


fn main() {
    let (r, w) = (io::stdin(), io::stdout());
    let mut rw = IO::new(r.lock(), w.lock());
    solve(&mut rw);
}

fn solve(rw: &mut IO<std::io::StdinLock, std::io::StdoutLock>) {
    let (A, B, C, X): (u32, u32, u32, u32) = (rw.read(), rw.read(), rw.read(), rw.read());

    let mut ans = 0;
    for a in 0..=A {
        for b in 0..=B {
            for c in 0..=C {
                if 500 * a + 100 * b + 50 * c == X {
                    ans += 1
                }
            }
        }
    }

    println!("{}", ans);
}

Measured memory_bytes: 2140
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
vector<ll> p;
void check(ll n, ll x) {
	ll s[3];
	vector<ll> v[2];
	ll m=2*n-1;
	v[0].clear();
	for (ll i=0;i<m;i++) v[0].PB(p[i]);
	for (ll k=0;k<n;k++) {
		ll cur=k&1; ll nxt=cur^1;
		for (auto &w:v[cur]) printf("%lld ",w);
		printf("\n");
		v[nxt].clear();
		for (ll i=1;i<v[cur].size()-1;i++) {
			s[0]=v[cur][i-1];
			s[1]=v[cur][i];
			s[2]=v[cur][i+1];
			sort(s,s+3);
			v[nxt].PB(s[1]);
		}
	}
	assert(v[(n&1)^1][0]==x);
}
int main() {
	ios_base::sync_with_stdio(false);
	ll n,x; scanf("%lld%lld",&n,&x);
	ll m=2*n-1;
	if (x==1||x==m) {
		printf("No\n");
	}
	else {
		vector<ll> v;
		for (ll i=1;i<=m;i++) {
			if (i!=x) v.PB(i);
		}
		sort(v.begin(),v.end());
		ll vs=v.size();
		vector<ll> l,r;
		for (ll i=0;i<vs/2;i++) l.PB(v[i]);
		for (ll i=vs/2;i<vs;i++) r.PB(v[i]);
		sort(l.begin(),l.end());
		sort(r.begin(),r.end());
		reverse(r.begin(),r.end());
		if (*(l.rbegin())>x) reverse(l.begin(),l.end());
		if (*(r.begin())<x) reverse(r.begin(),r.end());
		for (auto &w:l) p.PB(w);
		p.PB(x);
		for (auto &w:r) p.PB(w);
		printf("Yes\n");
		for (auto &w:p) printf("%lld\n",w);
		//printf("\n");
		//check(n,x);
	}
}

Measured memory_bytes: 8304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include<set> 
#include<math.h>
#define pai arccos(-1);
#define keta(n) cout << fixed << setprecision((n));
#define ll long long;
int main(){
  string s;
  cin>>s;
  if('a'<=s[0]&&s[0]<='z')cout<<'a';
  else cout<<'A';



}


Measured memory_bytes: 3616
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.IO.Pipes;

public class HelloWorld
{
    static bool res = false;
    static public void Main()
    {
        //var NL = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var S = Console.ReadLine();

        if (S[S.Length -1] == 's')
        {
            S += "es";
        }
        else
        {
            S += "s";
        }

        Console.WriteLine(S);
    }
}


Measured memory_bytes: 25892
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = INT_MAX;
const ll LLINF = INT64_MAX;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n), id(n + 1);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
        id[a[i]] = i;
    }
    set<ll> s;
    s.insert(-1);
    s.insert(n);
    ll ans = 0;
    for (ll i = 1; i <= n; i++)
    {
        auto it = s.lower_bound(id[i]);
        auto r = *it;
        auto l = *(--it);
        ans += i*(id[i]-l)*(r-id[i]);
        s.insert(id[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 12800
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;

int check(vector< vector<int> > &v, int R, int C){
  int res = 0;
  REP(j, C){
    int cnt[2];
    cnt[0] = cnt[1] = 0;
    REP(i, R) cnt[v[i][j]]++;
    res += max(cnt[0], cnt[1]);
  }
  return res;
}

int main() {
  int R, C;
  while(cin >>R >>C && (R || C)){
    int ans = 0;
    vector< vector<int> > v(R, vector<int>(C)), _v;
    REP(i, R) REP(j, C) cin >>v[i][j];
    REP(b, (1 << R)){
      _v = v;
      REP(i, R){
        if(((b >> i) & 1) == 0) continue;
        REP(j, C) _v[i][j] = 1 - _v[i][j];
        ans = max(ans, check(_v, R, C));
      }
    }
    cout <<ans <<endl;
  }
  return 0;
}

Measured memory_bytes: 1864
#include <bits/stdc++.h>
using namespace std;
#define INF 10000000
vector<vector<int>> vec(420,vector<int>(420,INF) );
vector<vector<bool>> used(420,vector<bool>(420, false) );
int main(){
    int n, ma, mb;
    cin >> n >> ma >> mb;
    vector<int> a(n),b(n),c(n);
    for(int i=0; i<n; i++){
        cin >> a.at(i) >> b.at(i) >> c.at(i);
    }
    int asum = accumulate(a.begin(), a.end(),0);
    int bsum = accumulate(b.begin(), b.end(),0);
    vec[0][0] = 0;
    for(int i =0; i<n; i++){
       for(int j = 0; j<=400; j++){
           for(int k = 0; k<=400; k++){
               if(!used[j][k] && vec[j+a[i]][k+b[i]]> vec[j][k]+c[i] ){
                 vec[j+a[i]][k+b[i]] =  vec[j][k] + c[i];
                 used[j+a[i]][k+b[i]] = true;
               }
           }
       } 
       for(int j = 0; j<=400; j++){
           for(int k = 0; k<=400; k++){
               used[j][k] = false;
           }
       }
    }
    int  ans = INF;
    for(int i = 1; i<=400; i++){
        if(i*ma> asum || i*mb > bsum) break;
        ans = min(ans, vec[i*ma][i*mb]);
    }
    if(ans == INF) ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 1024
n=int(input())
X=[]
X=input().split()
X=[int(u) for u in X]
m=int(input())
A=[]
A=input().split()
A=[int(u) for u in A]
for i in range(0,m):
    a=A[i]
    p=0
    for u in range(a,n):
        if (X[a-1]+1)==X[u]:
            p=p+1
    if p==0:
        if X[a-1]!=2019:
            X[a-1]=X[a-1]+1
for i in range(0,n):
    print(X[i])


Measured memory_bytes: 5612
#include <iostream>
#include <deque>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main()
{
    int n,k;
    cin >> n >> k;
    std::deque<int> v;
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        v.push_back(tmp);
    }
    
    int max = 0;
    if(n>k){
        // 取り出し回数がキューより少ない場合
        for(int i=0; i<=k; i++){
            for(int j=0; j<=k; j++){
                if(i+j > k) break;
                //cout << "-----" << endl << i << "," << j << endl << "L:";
                
                int tmp = 0;
                std::vector<int> vec;
                std::deque<int> v2(v);
                // 左端から取り出し
                for(int kk=0; kk<i; kk++){
                    //cout << v2.front() << ", ";
                    tmp += v2.front();
                    vec.push_back(v2.front());
                    v2.pop_front();
                }
                //cout << endl << "R:";
                // 右端から取り出し
                for(int kk=0; kk<j; kk++){
                    //cout << v2.back() << ", ";
                    tmp += v2.back();
                    vec.push_back(v2.back());
                    v2.pop_back();
                }
                
                // 操作回数が残っていたら負の価値を詰めなおす
                int remain =  k-(i+j);
                //cout << endl << "remain:" << remain << endl;
                std::sort(vec.begin(), vec.end());
                std::vector<int>::iterator itr = vec.begin();
                for(int kk=0; kk<remain; kk++){
                    if(itr == vec.end()) break;
                    if(*itr >= 0) break;
                    //cout << *itr << ",";
                    tmp -= *itr;
                    ++itr;
                }
                if(tmp > max){
                    max = tmp;
                }
                //cout << endl << "curr:" << tmp << ", max:" << max << endl;
            }
        }
    }else{
        // 取り出し回数がキューより多い場合
        // 全て取り出してから負の価値を返せるだけ返す
        std::sort(v.begin(), v.end());
        std::deque<int>::iterator itr = v.begin();
        while(itr != v.end()){
            max += *itr;
            //out << "curr:" << *itr << ", max:" << max << endl;
            ++itr;
        }
        for(int i=0; i<(k-n); i++){
            if(v.front() >= 0) break;
            max -= v.front();
            //cout << "minus" << v.front() << ", max:" << max << endl;
            v.pop_front();
        }
    }
    cout << max << endl;

    return 0;
}

Measured memory_bytes: 256
/*	
TELL YOUR CODE TO START BELIEVING IN GOD!!
THEY HATE US BECAUSE THEY AIN'T US
	ARIJIT SUR 
	@duke_knight
	@surcode
	IIT ISM 
 WORK SO HARD THAT YOUR IDOL BECOMES YOUR COMPETITOR 
 */
#include<bits/stdc++.h>
#define SIZE 100008
#define mod (ll)(1e9+7)
#define INF 0x3f3f3f3f
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define abs(a) (a>0?a:-a)
#define all(a) a.begin(),a.end()
#define pb push_back
#define sort(a) sort(all(a))
#define reverse(a) reverse(all(a))
#define input(a) {for(int i=0;i<a.size();i++) cin>>a[i];}
#define display(a) {for(int i=0;i<a.size();i++) cout<<a[i]<<" "; cout<<endl;}
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef long long ll;
void solve(){
	int n,x,t;
    cin>>n>>x>>t;
    int ans = n/x*t;
    if(n%x) ans+=t;
    printf("%d\n", ans);
}
int main()
{
    IOS
    int t=1;
    //cin>>t;
    while(t--){
    	solve();
    }
    return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int A[N + 2];
	ll sum = 0;
	A[0] = 0;
	rep(i, 1, N + 1) cin >> A[i];
	A[N + 1] = 0;

	rep(i, 1, N + 2) {
		sum += abs(A[i] - A[i - 1]);
	}

	rep(i, 0, N) {
		ll res = sum - abs(A[i + 1] - A[i]) - abs(A[i + 2] - A[i + 1]) + abs(A[i + 2] - A[i]);
		cout << res << endl;
	}

	

}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;

int main(){
   ll N; cin>>N;
   ll l[N]; CINA(l,N);
   sort(l,l+N);
   ll ans = 0;
   for(int i=N-1;i>0;--i){
       for(int j=i-1;j>0;--j){
           ll a = l[i];
           ll b = l[j];
           int idx = distance(l,lower_bound(l,l+j,a-b+1));
           ans += max(j-idx,0);
       }
   }
   cout << ans << "\n";
}

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

int main(){
  int N;
  cin >> N;
  vector<int> V(N),C(N);
  for(int i = 0; i < N; i++){
    cin >> V[i];
  }
  for(int i = 0; i < N; i++){
    cin >> C[i];
  }
    
    int ans = 0;
  for(int i = 0; i < N; i++){
    int A = V[i] - C[i];
    if(A >= 0){
      ans += A;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
int n = 100005,m;
vector<int> longest(n,-1);
vector<vector<int>> Graph(n,vector<int>());

int dfs(int i){
  int res = 0;
  for(auto j:Graph.at(i)){
    if(longest.at(j) == -1) longest.at(j) = dfs(j);
    res = max(res,longest.at(j)+1);
  }
  return res;
}
 
int main() {
  cin >> n >> m;
  rep(i,m){
    int x,y;
    cin >> x >> y;
    Graph.at(x).push_back(y);
  }
  for(int i=1;i<=n;i++) Graph.at(0).push_back(i);
  int ans = dfs(0)-1;
  cout << ans << endl;
  
  
  return 0;
}






Measured memory_bytes: 9336
import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]

def main():
    n, k = LI()
    hs = LI()
    ans = 0
    for h in hs:
        if h >= k:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 11904
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	int win=0,k=s.size();
	rep(i,k)if(s[i]=='o')win++;
	YN(win+(15-k)>=8);
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,b;
    double a;
    scanf("%d",&n);
    if(n<=1000)
    {
        b=1000-n;
    }
    else
    {
        a=(double)n/1000.0;
        if(a==(int)a)
        {
            b=a*1000-n;
        }
        else
        {
            b=((int)a+1)*1000-n;
        }
    }printf("%d\n",b);
    return 0;
}


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

using i32 = int_fast32_t;
using i64 = int_fast64_t;

int main() {
    i32 k, n;
    cin >> k >> n;
    vector<i64> a(n*2);
    for (i32 i = 0; i < n; i++) {
        i32 t;
        cin >> t;
        a[i] = t;
        a[i+n] = t + k;
    }

    i64 ans = INT64_MAX;
    for (i32 i = 0; i <= n; i++) {
        ans = min(ans, a[i+n-1] - a[i]);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3328
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x,y;
  cin >> x >> y;
  REP(a,x+1){
    int b = x-a;
    if(a*2+b*4==y){
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";
  return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>
#define N 1000000000
int main(){
  int *S;
  int *T;
  int n,q;
  int i,j,k;
  int cnt = 0;
  int b = 0;
  int left,right,mid;

  scanf("%d",&n);
  if(n > 10000)
    exit(1);
  S = (int*)malloc(sizeof(int) * n);
  for(i = 0; i < n; i++){
    scanf("%d",&S[i]);
    if(S[i] > N)
      exit(1);
  }

  scanf("%d",&q);
  if(q > 500)
    exit(2);
  T = (int*)malloc(sizeof(int) * q);
  for(i = 0; i < q; i++){
    scanf("%d",&T[i]);
    if(T[i] > N)
      exit(1);
      for(j = 0; j < i; j++){
	if(T[i] == T[j]){
	  printf("Tは互いに異なる要素を入力してください\n");
	  exit(1);
	}
      }
  }

  for(i = 0; i < q; i++){
    for(j = 0; j < n; j++){
      if(T[i] == S[j]){
 	cnt++;
	break;
      }
    }
  }

  if(cnt < 0)
    cnt = 0;



  printf("%d\n",cnt);
  return 0;
}




Measured memory_bytes: 2088
def dfs(n,G,visited,cnt):
    visited[n] = True
    if not False in visited:
        visited[n] = False
        return cnt + 1
    for x in G[n]:
        if visited[x] == True:
            continue
        cnt = dfs(x,G,visited,cnt)
    visited[n] = False
    return cnt


def main():
    N,M = map(int ,input().split())
    G = [list() for x in range(N)]
    for i in range(M):
        a,b = map(int,input().split())
        a = a - 1
        b = b - 1
        G[a].append(b)
        G[b].append(a)
    visited = [False] * N
    ans = dfs(0,G,visited,0)
    print(ans)

if __name__ == '__main__':
    main()


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const ll LL_INF = 1e17 + 10;
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

int cnt[200];

char s[MAXN];

void solve(){
	int n;
	scanf("%d%s", &n, &s[0]);
	REP(i, 0, n) {
		cnt[s[i]]++;
	}
	ll ans = 1ll;
	REPN(i, 'a', 'z') {
		ans = (ans * (cnt[i] + 1)) % MOD;
	}
	ans = (ans + MOD - 1) % MOD;
	cout << ans << endl;
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define EPS 1e-10
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
typedef long long llong;
int ans(llong x,llong y) {
	if (y == 0)return 1;
	int res = ans(x*x%MOD, y / 2)%MOD;
	if (y & 1)res *= x%MOD;
	return res;
}
signed main() {
	int n;
	cin >> n;
	vector<int>v(n),t(n);
	rep(i, 0, n) {
		cin >> v[i];
		t[v[i] / 2]++;
	}

	sort(v.begin(), v.end(), greater<int>());
	if (n % 2 == 0) {
		//if (accumulate(v.begin(), v.end(), 0) != (n / 2)*(n / 2) * 2) {
		//	cout << 0 << endl;
		//	return 0;
		//}
		for (int i = 0; i < n / 2; i++) {
			if (t[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
		}
	}

	else {
		//if (accumulate(all(v), 0) != (n / 2)*(n / 2 + 1) * 2) {
		//	cout << 0 << endl;
		//	return 0;
		//}
		for (int i = 1; i <= n / 2; i++) {
			if (t[i] != 2) {
				cout << 0 << endl;
				return 0;
			}
		}
	}


	cout << ans(2, n / 2)%MOD << endl;



	return 0;
}

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main(){

    int a, b, c;
    cin >> a >> b >> c;

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

    return 0;
}


Measured memory_bytes: 3060
#include<cstdio>

int main() {
	while (1) {
		int m, nmin, nmax, p[201], maxg = 0, n;
		scanf("%d %d %d", &m, &nmin, &nmax);
		for (int i = 1; i <= m; i++) {
			scanf("%d", &p[i]);
		}
		for (int j = nmin; j <= nmax; j++) {
			if (p[j] - p[j+1] >= maxg) {
				maxg = p[j] - p[j+1];
				n = j;
			}
		}
		if (m == 0 && nmin == 0 && nmax == 0) {
			return 0;
		}
		else {
			printf("%d\n", n);
		}
	}
}


Measured memory_bytes: 2728
#include <bits/stdc++.h>
using namespace std;
constexpr int P = 1E9 + 7;
void inc(int &a, int b) {(a += b) >= P ? a -= P : 0;}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    string s;
    cin >> s;
    s += '1';
    n = s.length();
    int dp[2][2][3][3] = {};
    int c = 0;
    dp[c][0][0][0] = 1;
    for (int i = 0; i < n; ++i) {
        c ^= 1;
        memset(dp[c], 0, sizeof(dp[c]));
        for (int parity = 0; parity <= 1; ++parity) {
            for (int num = 0; num <= 2; ++num) {
                if (s[i] != '1') {
                    for (int step = 0; step <= 2; ++step)
                        inc(dp[c][parity][(num + 1) >= 3 ? num - 1 : num + 1][step], dp[c ^ 1][parity][num][step]);
                }
                if (s[i] != '0') {
                    inc(dp[c][parity ^ (num != 1)][0][parity == 0 && num == 0], dp[c ^ 1][parity][num][0]);
                    inc(dp[c][parity ^ (num != 1)][0][1 + (parity == 1 && num == 0)], dp[c ^ 1][parity][num][1]);
                    inc(dp[c][parity ^ (num != 1)][0][2], dp[c ^ 1][parity][num][2]);
                }
            }
        }
    }
    cout << (dp[c][0][0][2] + dp[c][1][0][2]) % P << endl;
    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    cin >> N;

    repd(i, 1, 10) {
        repd(j, 1, 10) {
            if (i * j == N) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#pragma GCC optimize("O3")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cstring>
#include <numeric>
#include <set>
#include <queue>
#include <deque>
#include <array>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <map>
#include <functional>
#include <bitset>
#include <complex>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using ld = long double;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int h, w;
	cin >> h >> w;
	vector<vector<char>> a(h, vector<char>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
		}
	}
	const int mod = 1e9 + 7;
	vector<vi> dp(h, vi(w, 0));
	dp[0][0] = 1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] != '#') {
				if (i > 0) {
					dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
				}
				if (j > 0) {
					dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
				}
			}
		}
	}
	cout << dp[h - 1][w - 1];
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
#define MAXN 233333
using namespace std; 

typedef long long LL;
const LL MOD = 1e9+7;
LL a[MAXN],s[MAXN],ga[MAXN],ans,k;
LL n;
LL qpow(LL a,LL x){
	if(x==0){
		return 1;
	}
	LL t = qpow(a,x/2)%MOD;
	if(x%2==0){
		return (t*t)%MOD;
	}
	else
		return (((t*t)%MOD)*a)%MOD;
}
LL rev(LL x){
	return qpow(x,MOD-2);
} 
LL calc(LL x,LL y){
	//if(!y) return 1;
	if(x<y) return 0;
	else return (((ga[x]*rev(ga[y]))%MOD)*rev(ga[x-y]))%MOD;
}
int main()
{
	cin>>n>>k;
	for(int i = 1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	for(int i = 1;i<=n;i++){
		s[i] = (a[i] + s[i-1])%MOD; 
		ga[i] = (i==1?1:(ga[i-1]*i)%MOD); 
	}
	ga[0] = 1;
	for(LL i = 1;i<=n-1;i++){
		LL w = calc(i-1,k-2);
		ans += w*(s[n]-s[n-i]-s[i]);
		ans %= MOD;
	} 
	cout<<ans;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

#define I
int main() {
    string s; cin >> s;
    string orig(s);

    int L = s.size();
    if (L != 26) {
        vector<int> st(26, 0);
        for (char c:s) {
            st[c - 'a']++;
        }
        rep(i,26){
            if (st[i]==0){
                s.pb((char)('a'+i));
                break;
            }
        }
        cout << s << endl;
        return 0;
    }

    if (!next_permutation(ALL(s))) {
        cout << -1 << endl;
        return 0;
    }
    for (int i=0; i<L; ++i) {
        if (s[i] == orig[i]) continue;
        s.erase(s.begin()+i+1, s.end());
        break;
    }
    cout << s << endl;
    return 0;
}


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

int main() {
  for(int i = 0; i < 9; i++) {
    string s;
    int a, p;
    cin >> s >> a >> p;
    int ans = 200*a + 300*p;

    cout << s << ' ' << a+p << ' '<< ans << endl;
  }
}

Measured memory_bytes: 1200
#include<bits/stdc++.h>>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a==b)
    {
        for(int i=0;i<a;i++)
        {
            cout<<a;
        }
    }
    else if(a<b)
    {
        for(int i=0;i<b;i++)
        {
            cout<<a;
        }
    }
    else
    {
         for(int i=0;i<a;i++)
        {
            cout<<b;
        }
    }


    return 0;
}


Measured memory_bytes: 3540
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] a = new int[n];
		for(int i=0; i<a.length; i++){
			a[i] = scn.nextInt();
		}
      	int[] b = new int[n];
      	for(int i=a.length-1; i>=0; i-=2){
        	System.out.print(a[i]+ " ");
      }
       for(int i=a.length%2; i<a.length; i+=2){
        System.out.print(a[i]+ " ");
      }
	}
}

Measured memory_bytes: 61880
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<vector>
#define LL long long
#define PP std::pair<int,int>
int N;
std::vector<PP> A;
LL ans = 1;
LL S[2];
LL mod = 1e9 + 7;
int main() {
	std::cin >> N;
	for (int i = 0; i < N; i++) {
		int tmp;
		std::cin >> tmp;
		A.emplace_back(PP{ tmp,0 });
	}
	for (int i = 0; i < N; i++) {
		int tmp;
		std::cin >> tmp;
		A.emplace_back(PP{ tmp,1 });
	}
	std::sort(A.begin(), A.end());
	for (int i = 0; i < 2 * N; i++) {
		int s = A[i].second;
		if (S[(s + 1) & 1]) {
			ans *= S[(s + 1) & 1];
			S[(s + 1) & 1]--;
			ans %= mod;
		}else{
			S[s & 1]++;
		}
	}
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, K;
	cin >> N >> K;

	cout << (N-1) / (K * 2 + 1) + 1 << endl;;
	return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
 
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
 
//template functions
/////////////////////////
void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

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


//Answer


int main() {

long N,max=0,ans=0;
cin>>N;
vector<long> A(N);
for(long i=0;i<N;i++){
cin>>A.at(i);
if(A.at(i)>max){
    max=A.at(i);
}else{
    ans=ans+(max-A.at(i));
}
}
cout<<ans<<endl;


}


Measured memory_bytes: 239272
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {

    string s = "";

    for (int i = 0; i < 3; i++) {
        string c; cin >> c;
        s = s + c[i];
    }

    cout << s << endl;

    return 0;
}



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

#define pb push_back
#define F first
#define S second
#define fo(i,a,b)  for(int i = a; i < b; i++)

using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
#define Mosta     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ReadFile            freopen("input.in","r",stdin)
#define WriteFile           freopen("output.txt","w",stdout)
const ll mod7 = 1000000007,mod = 1000000000,OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi=acos(-1);
const ld rad=Pi/180.0;
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
ll nCr (ll n,ll m)
{
    return(m == 0)?1:n*nCr(n-1,m-1)/m;
}
/*****************************************************/

int main()
{
    int n , mx = 0;
    cin >> n;

    map<string , int> mp;

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

    for(const auto & x : mp){
        int l = x.second;
        if(l > mx)
            mx = l;
    }

    for(auto it = mp.begin(); it != mp.end(); ++it){
        if(it->second == mx)
            cout << it->first << "\n";
    }

    return 0;
}


Measured memory_bytes: 25216
n, *a = map(int, open(0).read().split())
a = [0] + a + [0]
all_sum = sum([abs(a[i] - a[i+1]) for i in range(n+1)])
for i in range(1,n+1):
    print(all_sum - abs(a[i-1] - a[i]) - abs(a[i] - a[i+1]) + abs(a[i-1] - a[i+1]))

Measured memory_bytes: 20280
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
typedef long long ll;
const ll longinf=1LL<<60;
using namespace std;


int q;
ll a,b,B,type;
ll sum1, sum2;

priority_queue<ll> q1;
priority_queue<ll, vector<ll>, greater<ll>> q2;

int main()
{
    cin >> q;
    while (q--)
    {
        cin >> type;
        if (type == 1)
        {
            cin>>a>>b;
            B+=b;
            if (q2.empty() || a>=q2.top())
            {
                q2.push(a);
                sum2+=a;
                q2.push(a);
                sum2+=a;
                a = q2.top(); q2.pop();
                sum2-=a;
                q1.push(a);
                sum1+=a;
            }else
            {
                q1.push(a);
                sum1+=a;
                q1.push(a);
                sum1+=a;
                a = q1.top(); q1.pop();
                sum1-=a;
                q2.push(a);
                sum2+=a;
            }
        }else
        {
            cout<<q1.top()<<' '<<(sum2-sum1)/2+B<<endl;
        }
    }

    return 0;
}




Measured memory_bytes: 4588
str = gets.split
N,M,V,P = str[0].to_i, str[1].to_i, str[2].to_i, str[3].to_i
a = Array.new(N+1)
str = gets.split
for i in 0...N do
    a[i] = str[i].to_i
end
a[N] = 0
a.sort!.reverse!

if P >= V
    ok = a[P-1] - M
    i = P
    while ok <= a[i] && i < N
        i += 1
    end
    puts i
else
    minus = N-V
    ok = minus * M
    i = P
    x = 0
    while ok >= x && i <= N && a[P-1] - a[i-1] <= M
        dif = a[i-1] - a[i]
        x += dif*(i-P+1)
        i += 1
    end
    i -= 1
    puts i
end

Measured memory_bytes: 11280
#include<bits/stdc++.h>
#define N 505
using namespace std;
bool dp[N][N],f[N][N];int a[N],b[N],n;
inline bool check(int x){
	for (int i=0;i<=50;i++)
		for (int j=0;j<=50;j++) dp[i][j]=f[i][j];
	for (int i=1;i<=n;i++) dp[a[i]][a[i]]=1;
	for (int i=1;i<=x;i++)
		for (int j=0;j<=50;j++) dp[j][j%i]=1;
	for (int k=0;k<=50;k++)
		for (int i=0;i<=50;i++)
			for (int j=0;j<=50;j++)
				if (dp[i][k]&&dp[k][j]) dp[i][j]=1;
	for (int i=1;i<=n;i++) if (!dp[a[i]][b[i]]) return 0;
	return 1;
}
inline void build(int x){for (int i=0;i<=50;i++) f[i][i%x]=1;}
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=1;i<=n;i++) scanf("%d",&b[i]);
	long long ans=0;
	if (!check(50)) return puts("-1"),0;
	for (int i=51;i;i--){
		if (check(i-1)) continue;
		else build(i),ans=ans+((long long)(1)<<(i));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  int n,k;
  scanf("%d%d",&n,&k);
  char s[n];
  scanf("%s",s);
  if(s[k-1]=='A')
  s[k-1]='a';
  else if(s[k-1]=='B')
  s[k-1]='b';
  else if(s[k-1]=='C')
  s[k-1]='c';
  printf("%s",s);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;

ll n,a;


int main(){
	cin>>n;	
	int i,j;i=sqrt(n);
	for(;i>0;i--){
		if(n%i==0){
			j=n/i;
			break;
		}
	}
	while(j>0){
		a++;j/=10;	
	}
	cout<<a;
	return 0;
}

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

int main()
{
	int q, c, a, n;
	
	scanf("%d", &q);
	
	for (int i = 0; i < q; i++){
		int ans = 0;
		scanf("%d %d %d", &c, &a, &n);
		while (1){
			if (c >= 1 && a >= 1 && n >= 1){
				ans++;
				c--;
				a--;
				n--;
			}
			else if (c >= 2 && a >= 1){
				ans++;
				c -= 2;
				a--;
			}
			else if (c >= 3){
				ans++;
				c -= 3;
			}
			else {
				break;
			}
		}
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 1028
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>

#define mod 1000000007
#define REP(i,n) for(int i=0; i<n; i++)

using namespace std;
using ll = long long;

void solve() {
    string s;
    cin >> s;
    s.replace(0, 4, "2018");
    cout << s << endl;
}

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

Measured memory_bytes: 256