akhauriyash/Code-Regression huggingface dataset:
#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;
#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;

class UnionFind {
public:
	vector<int> Parent;

	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	int root(int A) {
		if (Parent[A] < 0)return A;
		return Parent[A] = root(Parent[A]);
	}

	int size(int A) {
		return -Parent[root(A)];
	}

	bool unite(int A, int B) {
		A = root(A);
		B = root(B);
		if (A == B)
			return false;

		if (size(A) < size(B))
			swap(A, B);

		Parent[A] += Parent[B];
		Parent[B] = A;

		return true;
	}

	bool same(int A, int B) {
		if (root(A) == root(B))
			return true;
		else
			return false;
	}
};

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

	int N;
	const int C = 1e+5;
	cin >> N;
	UnionFind uni(222222);
	VI A(N),B;
	REP(i, N) {
		cin >> A[i];
		int n = A[i];
		A[i] += C;
		for (int j = 1; j*j <= n; ++j){
			if (n%j == 0) {
				if(j!=1)uni.unite(j, A[i]);
				if (j*j != n)uni.unite(n / j, A[i]);

			}
		}
	}
	B = A;
	SORT(B);

	REP(i, N) {
		if (A[i] != B[i]) {
			if (uni.root(A[i]) != uni.root(B[i])) {
				cout << 0 << endl;
				return 0;
			}
		}
	}
	cout << 1 << endl;

	return 0;
}




Measured memory_bytes: 6308
N, M = map(int,input().split())
AB = [[] for _ in range(N)]
for i in range(M):
  A, B = map(int,input().split())
  AB[A-1].append(B-1)
  AB[B-1].append(A-1)
T = [-1]*N
T[0] = 0
tlist = [0]
t_change = True
while t_change:
  t_change = False
  tlist2 = []
  for t in tlist:
    for i in AB[t]:
      if T[i]==-1:
        t_change = True
        T[i] = t
        tlist2.append(i)
  tlist = tlist2
  
if -1 in T:
  print('No')
else:
  print('Yes')
  for i in range(1,N):
    print(T[i]+1)


Measured memory_bytes: 33760
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int f(int a[][255],int sx,int sy,int vx,int vy,int n){
  int i,j;
  int mx=0;
  for(i=0;i<n;i=j){
    for(;i<n&&a[sx+vx*i][sy+vy*i]==0;i++);
    for(j=i;j<n&&a[sx+vx*j][sy+vy*j];j++);
    if(mx<j-i)
      mx=j-i;
  }

  return mx;
}
int main(){
  int i,j;
  int a[255][255],n;
  int mx;
  char c;
  while(cin>>n&&n){
    for(i=0;i<n;i++){
      for(j=0;j<n;j++){
	cin>>c;
	a[j][i]=c-'0';
      }
    }
    mx=0;
    for(i=0;i<n;i++){
      mx=max(mx,f(a,0,i,1,0,n));
      mx=max(mx,f(a,i,0,0,1,n));
      mx=max(mx,f(a,0,i,1,1,n-i));
      mx=max(mx,f(a,i,0,1,1,n-i));
      mx=max(mx,f(a,n-i-1,0,-1,1,n-i));
      mx=max(mx,f(a,n-1,i,-1,1,n-i));
    }
    cout<<mx<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
H, W = map(int, input().split())
if H == 1 or W == 1:
    print('1')
else:
    a = H // 2 + H % 2
    if H % 2 == 0:
        b = a * W
        print(b)
    else:
        b = a * (W // 2 + W % 2) + (a - 1) * (W // 2)
        print(b)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		return a;
	}
	mint inv() const{
		return pow(mod-2);
	}
	mint& operator/=(const mint a){
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const{
		mint res(*this);
		return res/=a;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

//istream& operator>>(istream& is, const mint& a){return is >> a.x;}
//ostream& operator<<(ostream& os, const mint& a){return os << a.x;}

// 2^n
mint f(int n){
	if(n == 0) return 1;
	mint x = f(n/2);
	x *= x;
	if(n%2 == 1) x *= 2;
	return x;
}

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	ll zero = 0;
	map<P,P> mp;
	rep(i,n){
		ll a, b;
		cin >> a >> b;
		if(a == 0 && b == 0){
			++zero;
			continue;
		}
		ll g = gcd(a, b);
		a /= g;
		b /= g;
		if(b < 0){
			a = -a;
			b = -b;
		}
		if(b == 0 && a < 0){
			a = -a;
			b = -b;
		}
		if(a <= 0){
			swap(a, b);
			b = -b;
			++mp[P(a, b)].first;
		}
		else{
			++mp[P(a, b)].second;
		}
	}
	mint ans = 1;
	for(auto p : mp){
		ll a = p.second.first;
		ll b = p.second.second;
		ans *= mint(2).pow(a) + mint(2).pow(b) - 1;
	}
	ans -= 1;
	ans += zero;
	cout << ans.x << endl;
	return 0;
}

Measured memory_bytes: 19120
/// Thank you tanakh!!!
///  https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp;

const INF: usize = 1 << 30;

fn main() {
    input!(n: usize, s: [chars; n]);
    let mut dictionary = vec![vec![]; 26];
    for i in 0..n {
        let c = s[i][0] as usize - 'a' as usize;
        dictionary[c].push(i);
    }

    let mut jump = vec![INF; n];
    for i in 0..26 {
        for j in 1..dictionary[i].len() {
            jump[dictionary[i][j - 1]] = dictionary[i][j];
        }
    }

    let mut dp = vec![INF; n + 1];
    dp[0] = 0;
    for i in 0..n {
        dp[i + 1] = cmp::min(dp[i + 1], dp[i] + 1);
        if jump[i] != INF {
            dp[jump[i]] = cmp::min(dp[jump[i]], dp[i]);
        }
    }

    println!("{}", dp[n]);
}



Measured memory_bytes: 19312
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

void Compute(ll n,ll x,ll m)
{
    KAKA
    vector<ll> vec;
    vec.eb(x);
   
    bool ok = false;
    vector<ll> rem(m,-1);
     rem[x] = 0;
    ll repeater = -1;
    ll repstrt = -1;
    //if(n <= 100000)
    pragi(0,min(n - 1,m + 1))
    {
        ll prev = vec.back();
        ll nxt = ((prev % m) * (prev % m))%m;
        if(rem[nxt] == -1)
        {
            vec.eb(nxt);
            rem[nxt] = vec.size() - 1;
        }
        else
        {
            repeater = vec.size() - rem[nxt];
            repstrt = rem[nxt];
            ok = true;
            break;
        }
        
    }
    //cout<<repstrt<<"\n";
    ll sum = 0;
    for(auto ele : vec)
    {
        //cout<<ele<<" ";
      sum += ele;
    }
   // cout<<"\n";
    if(ok){
    ll rept_sum = 0;
    pragi(repstrt,vec.size())
    {
        rept_sum += vec[i];
    }
    ll rem_terms = n - vec.size();
    ll q = rem_terms/repeater;
    ll r = rem_terms % repeater;
    sum += (q * rept_sum);
    pragi(repstrt,repstrt + r)
    {
        sum += vec[i];
    }}
    cout<<sum<<"\n";
}
int main()
{
    KAKA
    ll n,x,m;
    cin>>n>>x>>m;
    Compute(n,x,m);
}

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

const int N = 5e3+9;
int p[N], c[N], vis[N], ok;
long long ans, cc, dp[N][N], n, k;
unordered_map<int,int> mp, cost;
unordered_map<int, pair<int, int> > f;

const long long INF = -9999999999999999;

void func(int start, vector<int> &v) {
	if(mp[start] > 0){
		ok = 1;
		return ;
	}
	v.push_back(start);
	mp[start]++;
	func(p[start], v);
	return ;
}

int main() {
	//freopen("input.txt", "r", stdin);
	ans = INF;
	//mp.clear();
	//cost.clear();
	cin >> n >> k;
	//1-indexed based
	for (int i=1;i<=n;i++) {
		cin >> p[i];
	}
	for (int i=1;i<=n;i++) {
		cin >> c[i];
	}
	/*int cycle = 1;
	memset(vis, 0, sizeof(vis));
	for (int i = 1; i <= n; i++) {
		if(!vis[i]) {
			v.clear();
			ok = 0;
			cc = 0LL;
			func(i, v);
			reverse(v.begin(), v.end());
			while(v[0] != v[v.size()-1])
				v.pop_back();
			reverse(v.begin(), v.end());
			if(ok && v.size() > 1) {
				for (int j = 0; j < v.size(); j++){
					cc += c[v[i]];
					f[v[i]] = make_pair(v[0], v.size()); //starting point of the cycle If exists
				}
				//f[v[i]]
				cost[v[0]] = cc;//contains the actual cost of the cycle
			}
		}
	}*/

	long long ff, curmax, csum, cycleSum, t;
	vector<int> path;
	//k = k % (n+1);
	memset(dp, 0, sizeof(dp));
	for (int i = 1; i <= n; i++) {

		path.clear();
		ff = i;
		csum = 0LL;
		
		while(1) { //one cycle will always be there.
			//cout << "cycle\n";
			csum += c[p[ff]];
			path.push_back(ff);
			ff = p[ff];
			if(ff == i)
				break;
		}
		//cout << "\n";
		//for( int j = 0; j < (int) path.size(); j++) {
		//	cout << path[j] << " ";
		//}
		//cout << '\n';
		cycleSum = 0LL;
		for (int j = 0; j < (int)path.size(); j++) {
			if(j + 1 > k) //cycle length is greater than 'k'
				break;
			cycleSum += c[path[j]];
			ans = max(ans, cycleSum);
		}
		//cycle length is smaller or sum of cycle is negative, so point in extending this cycle
		if(cycleSum < 0 || (int)path.size() > k) 
			continue;
		ans = max(ans, cycleSum);
		t = 0LL;
		long long other = 0LL;
		for (int j = 0; j < (int)path.size(); j++) {
			t += c[path[j]];
			if(j+1 > k)
				break;
			other = t + ((k - j - 1) / (int)path.size()) * csum;//number of times it can be wrapped around
			ans = max(ans, other);
		}
	}
	cout << ans << '\n';
	return 0;
}

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

using namespace std;

int main() {
  string s;
  int k;
  cin >> s >> k;
  int n = s.length();
  set<string> res;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < k && i + j < n; j++) {
      res.insert(s.substr(i, j + 1));
    }
  }
  auto it = res.begin();
  for (int i = 0; i < k - 1; i++) {
    it++;
  }
  cout << *it << '\n';
  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(i,e) for(ll i=0;i<e;i++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;

ll i,j;




int main(){
   ll N,K;
   cin>>N>>K;
   V A(N);
   rep(i,N)cin>>A[i];

   map<ll,ll> jud;
   rep(i,N){
      if(jud.count(A[i]))jud[A[i]]++;
      else jud[A[i]]=1;
   }
   V retu;
   for(auto itr=jud.begin();itr!=jud.end();itr++){
      ll p=itr->second;
      retu.push_back(p);
   }
   sort(retu.begin(),retu.end());
   
   ll ans=0;
   if(retu.size()>K)for(ll k=0;k<retu.size()-K;k++)ans+=retu[k];

   cout<<ans<<endl;

   
}


Measured memory_bytes: 16500
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define all(x) x.begin(),x.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG

signed main() {
	int a,b,c;
	cin>>a>>b>>c;
	string ans;
	for(int i=b;i<=c;i++){
		if(i%a==0){
			ans="OK";
			break;
		}
		ans="NG";
	}
	cout<<ans<<endl;
			
	

}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b);
#define mins(a,b) a=min(a,b);

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

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

    if(n%2){
        cout<<"No"<<endl;
        return 0;
    }

    rep(i,n/2){
        if(s[i]!=s[i+n/2]){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

template< typename T, typename E >
struct SegmentTree{
    using F = function< T(T, T) >;
    using G = function< T(T, E) >;
    int sz;
    vector<T> dat;
    F f;
    G g;
    T t1;
    SegmentTree(int n, F f, G g, T t1) : f(f), g(g), t1(t1) {
        sz = 1;
        while(sz < n) sz *= 2;
        dat.clear();
        dat.resize(2 * sz - 1, t1);
    }
    void set(int k, T x) { dat[k + sz - 1] = x; }
    void build() {
        for(int k = sz - 2; k >= 0; k--) {
            dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }
    void update(int k, E x) {
        k += sz - 1;
        dat[k] = g(dat[k], x);
        while(k > 0) {
            k = (k - 1) / 2;
            dat[k] = f(dat[2 * k + 1], dat[2 * k + 2]);
        }
    }
    T query(int a, int b, int k, int l, int r) {
        if(r <= a || b <= l) return t1;
        if(a <= l && r <= b) return dat[k];
        T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
        T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
        return f(vl, vr);
    }
    T query(int a, int b){ return query(a, b, 0, 0, sz); }
    T operator[](int k) { return dat[k + sz - 1]; }
};

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n), cs(n + 1);
    vector<P> d(n + 1); 
    rep(i, 0, n){
        cin >> a[i];
        a[i] -= k;
    }
    rep(i, 0, n){
        cs[i + 1] += cs[i] + a[i];
    }
    rep(i, 0, n + 1){
        d[i] = {cs[i], i};
    }
    for(int ii = 0; ii < d.size(); ii++){
        // cout << d[ii].first << ' ' << d[ii].second << endl;
    }
    SegmentTree<int, int> seg(n + 1,
        [](int a, int b){ return a + b; },
        [](int a, int b){ return a + b; },
        0LL);
    sort(d.rbegin(), d.rend());
    int ans = 0;
    rep(i, 0, n + 1){
        int val = d[i].first;
        int idx = d[i].second;
        int tmp = seg.query(idx, n + 1);
        // cout << val << ' ' << idx << ' ' << tmp << endl;
        ans += tmp;
        seg.update(idx, 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define popcount __builtin_popcount
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve()
{
	ll n,k;
	cin>>n>>k;
	vector<ll>a(n);
	rep(i,n)cin>>a[i];
	for(int i=k;i<n;++i){
		if(a[i]>a[i-k])cout<<"Yes\n";
		else cout<<"No\n";
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll N;
    cin >> N;
    vvll A(N, vll(N));
    rep(i, N) rep(j, N) cin >> A[i][j];

    bool ok = true;
    rep(i, N) rep(j, N) rep(k, N) {
        if(i == k || j == k) continue;
        if(A[i][j] > A[i][k] + A[k][j]) ok = false;
    }
    if(!ok) {
        cout << -1 << endl;
        return 0;
    }

    vvll B(N, vll(N));
    rep(i, N) rep(j, N) B[i][j] = A[i][j];
    rep(i, N) rep(j, N) rep(k, N) {
        if(i == k || j == k) continue;
        if(A[i][j] == A[i][k] + A[k][j]) B[i][j] = 0;
    }

    ll ans = 0;
    rep(i, N) rep(j, N) {
        if(i >= j) continue;
        ans += B[i][j];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1664
import java.util.*;
import java.util.stream.*;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long[] a = new long[n];
		for(int i = 0; i < n; i++) {
			a[i] = in.nextLong() - (i + 1);
		}
		Arrays.sort(a);
		long sum = 0;
		for(long num : a) {
			sum += Math.abs(num - a[n/2]);
		}
		System.out.println(sum);
	}
}

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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  for(int i=0; i<n; i++) cin >> a[i];
  
  int sum = 0;
  int count = 1;
  for(int i=0; i<n; i++) {
    sum += a[i];
    if(sum > x) break;
    count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
const int maxn=100005;
 
int ip,indegree[maxn];
int n,m,seq[maxn];
int fa[maxn];
struct note
{
    int v,next;
};
std::vector<int> edge[maxn];
void addedge(int u,int v)
{
    edge[u].push_back(v);
}
 
int topo()///拓扑，可做模板
{
    queue<int>q;
    for(int i=0; i<n; i++)
    {
        //indeg[i]=indegree[i];
        if(indegree[i]==0){
            fa[i] = 0;
            q.push(i);
        //    std::cout << i<<"!" << std::endl;
        }
    }
    int k=0;
    bool res=false;
    while(!q.empty())
    {
        if(q.size()!=1)res=true;
        int u=q.front();
        q.pop();
        seq[k++]=u;
        for(auto &it : edge[u])
        {
            int v=it;
            indegree[v]--;
            if(indegree[v]==0){
                fa[v] = u;
                q.push(v);
            }
        }
    }
    if(k<n)return -1;///存在有向环，总之不能进行拓扑排序
    if(res)return 0;///可以进行拓扑排序，并且只有唯一一种方式，seq数组即是排序完好的序列
    return 1;///可以进行拓扑排序，有多种情况，seq数组是其中一种序列
}

int main(){
  //  int n,m;
    std::cin >> n >> m;
    for(int i = 1; i <= n + m - 1; i++){
        int u,v;
        std::cin >> u >> v;
        addedge(u,v);
        indegree[v] ++;
      //  std::cout << u << v <<indegree[v] << '!' << std::endl;
    }
    topo();
    for(int i = 1; i <= n; i++){
        std::cout << fa[i] << std::endl;
    }
}


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

int main(){
  int n;
  cin>>n;
  
  int x=n;
  
  int sum=0;
  
  while (x>0){
    sum+=x%10;
    x/=10;
  }
  
  if (n%sum==0){
    cout<<"Yes"<<endl;
  }
  
  else {
    cout<<"No"<<endl;
  }
  
  
    
}
  













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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;

void Main() {
    int a, b, t; cin >> a >> b >> t;
    int ans = (a > t) ? 0 : b * (t/a); 
    cout << ans << endl;
    return;
}

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

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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n;
    string s;
    cin>>n>>s;
    int l=0,r=n-1;
    int ans=0;
    while(l<=r)
    {
//        cout<<s.substr(l,r-l+1)<<" -> ";
        if(s[l]=='R')
//            cout<<"l++",
            l++;
        else if(s[r]=='W')
//            cout<<"l++",
            r--;
        else
//            cout<<"l++",
            l++,r--,ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 3772
a,b = map(int,input().split())
if b<0 and (b-a+1)%2==0:
    print("Positive")
elif b<0 and (b-a+1)%2==1:
    print("Negative")
elif a<0 and b>=0:
    print("Zero")
elif a==0:
    print("Zero")
elif a>0:
    print("Positive")

Measured memory_bytes: 38332
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define ALL(v) (v).begin(), (v).end()
#define ios() ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
constexpr ll MOD = 10e9+7;
constexpr ll INF = 1LL << 60;
constexpr int Inf = 1e9;
inline int in() {int x; cin >> x; return x;}
template <typename T> inline void out(const T& x) {cout << x << endl;}
template <class T> inline bool chmin(T &a, T b){if (a > b){a = b;return 1;}return 0;}
template <class T> inline bool chmax(T &a, T b){if (a < b){a = b;return 1;}return 0;}
//UP = 0;RIGHT = 1; DOWN = 2; LEFT =3;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b)
{
  if (a < b)
    gcd(b, a);
  int r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}
void eratos(bool * isPrime,int max){
  fill(isPrime,isPrime + max,true);
  isPrime[0] = false; 
  isPrime[1] = false; 
  for(int i=2; i<=max/i; ++i) 
      if(isPrime[i]) 
          for(int j=2; j<=max/i; ++j) 
              isPrime[i*j] = false;    
}
//

signed main()
{
  ios();
  int N;
  string S;
  int A[26] = {0};
  cin >> N >> S;
  rep(i,N)
  {
    A[S[i] - 'a'] ++; 
  }
  int ans = 1;
  rep(i,26)
  {
    ans *= (A[i]+1);
    ans %= (int)(1e9 + 7);
  }
  ans --;
  cout << ans%(int)(1e9+7)<< endl;

}


Measured memory_bytes: 512
#include <iostream>
#include <string.h>
#include <cstdlib>
#include <cmath>

#define rep(i,n) for(int i=0; i <(n); i++)

using namespace std;

int main(void){
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    while(1){
        C = C - B;
        if(C <= 0){
            cout << "Yes";
            break;
        }

        A = A - D;
        if(A <= 0){
            cout << "No";
            break;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    R = [0]*N
    G = [0]*N
    B = [0]*N
    for i in range(N-1,-1,-1):
        if S[i] == "R":
            if i == N-1:
                R[i] = 1
            else:
                R[i] = R[i+1] + 1 
                G[i] = G[i+1]
                B[i] = B[i+1]
        elif S[i] == "G":
            if i == N-1:
                G[i] = 1
            else:
                R[i] = R[i+1] 
                G[i] = G[i+1] + 1
                B[i] = B[i+1]
        elif S[i] == "B":
            if i == N-1:
                B[i] = 1
            else:
                R[i] = R[i+1] 
                G[i] = G[i+1]
                B[i] = B[i+1]+1

    answer = 0
    for i in range(N-2):
        for j in range(i+1,N-1):
            if S[i] == "R":
                if S[j] == "G":
                    answer += B[j+1]
                    if 2*j-i < N and S[2*j-i] == "B":
                        answer -= 1
                elif S[j] == "B":
                    answer += G[j+1]
                    if 2*j-i < N and S[2*j-i] == "G":
                        answer -= 1
            elif S[i] == "G":
                if S[j] == "R":
                    answer += B[j+1]
                    if 2*j-i < N and S[2*j-i] == "B":
                        answer -= 1
                elif S[j] == "B":
                    answer += R[j+1]
                    if 2*j-i < N and S[2*j-i] == "R":
                        answer -= 1
            elif S[i] == "B":
                if S[j] == "G":
                    answer += R[j+1]
                    if 2*j-i < N and S[2*j-i] == "R":
                        answer -= 1
                elif S[j] == "R":
                    answer += G[j+1]
                    if 2*j-i < N and S[2*j-i] == "G":
                        answer -= 1

    print(answer)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 69148
n,k = gets.chomp.split(" ").map(&:to_i);
h = gets.chomp.split(" ").map(&:to_i);

h = h.sort.reverse
k.times{
h.shift
 }

ans = 0
len = h.length
len.times{ |x|
  ans += h[x-1]
 }
if len != 0
  puts ans
else
  puts 0
end

Measured memory_bytes: 21360
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

int main(){
    int N, K;
    cin >> N >> K;
    ll H[N];
    rep(i, N) cin >> H[i];
    map<ll, int> mp;
    mp[0]++;
    rep(i, N) mp[H[i]]++;
    int n = 0;
    for(auto &e: mp){
        e.second = n;
        n++;
    }
    ll h[n];
    h[0] = 0;
    rep(i, N) h[mp[H[i]]] = H[i];
    //i:=どこまで見たか、j:=何回変更したか、k:=右端が何であるか
    ll dp[N+1][K+1][n];
    rep(i, N+1) rep(j, K+1) rep(k, n) dp[i][j][k] = INF;
    dp[0][0][0] = 0;
    rep(i, N){
        rep(j, K+1){
            rep(k, n){
                if(dp[i][j][k] == INF) continue;
                int l = mp[H[i]];
                //変更なし
                dp[i+1][j][l] = min(dp[i+1][j][l], dp[i][j][k]+max(0LL, h[l]-h[k]));
                if(j == K) continue;
                //変更あり
                dp[i+1][j+1][k] = min(dp[i+1][j+1][k], dp[i][j][k]);
            }
        }
    }
    ll ans = INF;
    rep(j, K+1) rep(k, n) ans = min(ans, dp[N][j][k]);
    cout << ans << endl;
}

Measured memory_bytes: 213376
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(void){
    unsigned short *a, *b;
    
    int c[VMAX+1];
    int n,i,j;
    scanf("%d", &n);
    
    a = malloc(sizeof(short)*n+1);
    b = malloc(sizeof(short)*n+1);
    
    for(i=0;i<=VMAX;i++) c[i]=0;
    for(i=0; i < n; i++){
        scanf("%hu",&a[i+1]);
        c[a[i+1]]++;
    }

    for(i=1;i<=VMAX;i++) c[i]=c[i]+c[i-1];
    
    for(j=0;j<=n;j++){
        b[c[a[j]]] = a[j];
        c[a[j]]--;
    }
    
    for(i=1;i<=n;i++){
        printf("%d",b[i]);
        if(i<n) printf(" ");
        else printf("\n"); 
    }
    
    return 0;
    
}


Measured memory_bytes: 9588
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;i>=0;i--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
typedef long long ll;
typedef unsigned long long ull;

bool dp[2010][20010];
bool flag;
int ans[3];

void dfs(int N, int Y, int c1, int c2, int c3) {
	if (flag) return;
	int sum = c1 + c2 * 5 + c3 * 10;
	if (sum > Y) return;
	if (dp[N][sum]) return;
	if (N == 0) {
		if (sum == Y) {
			flag = true;
			ans[0] = c1;
			ans[1] = c2;
			ans[2] = c3;
		}
		return;
	}
	dp[N][sum] = true;
	dfs(N - 1, Y, c1, c2, c3 + 1);
	dfs(N - 1, Y, c1, c2 + 1, c3);
	dfs(N - 1, Y, c1 + 1, c2, c3);
}

int main() {

	int N,Y; cin >> N >> Y;
	Y /= 1000;

	REP(i,3) ans[i] = -1;
	flag = false;
	dfs(N, Y, 0, 0, 0);

	cout << ans[2] << " " << ans[1] << " " << ans[0] << endl;

	return 0;
}

Measured memory_bytes: 39296
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    vector<ll> A(N);
    ll out=0;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    ll now=A[0];
    for(int i=1;i<N;i++){
        if(now>A[i]) out += now-A[i];
        now = max(now,A[i]);
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 4836
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int a[300001];
int B[600003];
int n,N=1;
int right(int k){
  return 2*k+2;
}
int left(int k){
  return 2*k+1;
}
int parent(int k){
  return (k-1)/2;
}
void query(int a,int b,int k,int l,int r){
  //if (n==1)res = aray[0];
  if(r<=a || b<=l)return;
  else if(a<=l && r<=b)B[k]++;
  else {
    query(a,b,left(k),l,(l+r)/2);
    query(a,b,right(k),(l+r)/2,r);
  }
}
void update(int root){
  int r=right(root);
  int l=left(root);
  if(r<N-1){
    B[r] += B[root];
    update(r);
  }
  else a[r-N+1] = (B[r]+B[root]>n)?n:B[r]+B[root];
  if(l<N-1){
    B[l]+=B[root];
    update(l);
  }
  else a[l-N+1] = (B[l]+B[root]>n)?n:B[l]+B[root];
}
void init(){
  for(int i=0;i<2*N;i++)B[i]=0;
}
int main(){

  int K,l,r;
  cin>>n>>K;
  int limit = log2(2*pow(10,7));
  while(N<n)N*=2;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<K;i++){
    if(i>43) break;
    for(int j=0;j<n;j++){
      l=(j-a[j]>=0)?j-a[j]:0;
      r=(j+a[j]+1<=n)?j+a[j]+1:n;
      query(l,r,0,0,N);
    }
    update(0);
    init();
  }
  for(int i=0;i<n;i++)
    cout<<a[i]<<" ";
  cout<<endl;
  /*
  int t,p;
  t=p=1;
  for(int i=0;i<2*N-1;i++){
    cout<<B[i]<<" ";
    if(t==p){
      cout<<endl;
      t=1;
      p*=2;
    }
    else t++;
  }*/
  return 0;
}

Measured memory_bytes: 6680
#include<stdio.h>
int main(){
	int a[10001],i;
	
	for(i=1;;i++){
		scanf("%d",&a[i]);
		if(a[i]==0) break;
	}		
	
	for(i=1;;i++){
		if(a[i]==0) break;
		printf("Case %d: %d\n",i,a[i]);
	}

	return 0;
}

Measured memory_bytes: 1748
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;

using P = pair<ll, ll>;
using PP = pair<ll, P>;

int main() {
	int N;
	cin >> N;
	vector<PP> v(N);
	for (int i = 0; i < N; ++i) {
		ll a, b;
		cin >> a >> b;
		v[i] = PP(a + b, P(a, b));
	}
	sort(v.begin(), v.end(), greater<PP>());

	ll T = 0;
	ll A = 0;
	for (int i = 0; i < N; ++i) {
		P vs = v[i].second;
		if (i % 2 == 0) {
			T += vs.first;
		} else {
			A += vs.second;
		}
	}

	ll res = T - A;
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 2560
#include <iostream>

using namespace std;
int n, ans;
int main() {
    cin >> n;
    int c, j, k = 0;
    for (int i=1; i < n+1; i++){
        c = 0;
        j = i;
        while (true){
            if (j%2 != 0)
                break;
            j = j / 2;
            c++;
        }
        if (c >= k){
            k = c;
            ans = i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let mut x: usize = sc.read();
    let mut y: usize = sc.read();
    let na: usize = sc.read();
    let nb: usize = sc.read();
    let nc: usize = sc.read();
    let a: Vec<i64> = sc.vec(na);
    let b: Vec<i64> = sc.vec(nb);
    let c: Vec<i64> = sc.vec(nc);

    let mut p = vec![];
    for a in a.into_iter() {
        p.push((a, 0));
    }
    for b in b.into_iter() {
        p.push((b, 1));
    }
    for c in c.into_iter() {
        p.push((c, 2));
    }

    p.sort();
    p.reverse();

    let mut sum = 0;
    let mut count_z = 0;

    for (value, color) in p.into_iter() {
        match color {
            0 => {
                if x > 0 && x + y > count_z {
                    x -= 1;
                    sum += value;
                }
            }
            1 => {
                if y > 0 && x + y > count_z {
                    y -= 1;
                    sum += value;
                }
            }
            2 => {
                if x + y > count_z {
                    count_z += 1;
                    sum += value;
                }
            }
            _ => unreachable!(),
        }
    }

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

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

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::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()
    }
}


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

const int mod = 1000000007;

int h, w;
int ok[1010][1010];
int dp[1010][1010];

int main() {
  cin >> h >> w;
  rep(i,h) rep(j,w){
    char c; cin >> c;
    if(c == '.') ok[i][j] = 1;
  }
  
  dp[0][0] = 1;
  rep(i,h) rep(j,w){
    if(i == 0 && j == 0) continue;
    if(i > 0) dp[i][j] += dp[i - 1][j];
    if(j > 0) dp[i][j] += dp[i][j - 1];
    dp[i][j] *= ok[i][j];
    dp[i][j] %= mod;
  }
  cout << dp[h-1][w-1] << endl;
  return 0;
}

Measured memory_bytes: 11388
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7


H, W = MI()

if H == 1 or W == 1:
    print(1)
elif H % 2 == 0 and W % 2 == 0:
    print((H * W) // 2)
elif H % 2 == 0 and W % 2 != 0:
    print((H * (W - 1)) // 2 + (H // 2))
elif W % 2 == 0 and H % 2 != 0:
    print((W * (H - 1)) // 2 + (W // 2))
else:
    print(((W - 1) * (H - 1)) // 2 + (W // 2) + (H // 2) + 1)

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

int main(){
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = d; i <= 100; i += d){
        if (l <= i && i <= r) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<queue>
#include<map>
using namespace std;
typedef pair<int,int> P;
int n,m;
typedef struct {
	int cost , limit;
	vector< int > node , taxi;
} edge;
edge info[5010];
bool used[5010];

int main(){
	cin >> n >> m;
	int a,b;
	for(int i=0;i<n;i++){
		cin >> info[i].cost >> info[i].limit;
	}
	for(int i=0;i<m;i++){
		cin >> a >> b; a--; b--;
		info[a].node.push_back(b);
		info[b].node.push_back(a);
	}

	queue<P> que;
	for(int i=0;i<n;i++){
		fill_n(used, 5001 , false);
		//used[i] = true;
		que.push(P(i,info[i].limit));
		while(!que.empty()){
			P p = que.front(); que.pop();
			int now = p.first;
			int dis = p.second;
			if(dis==0) continue;
			int len = info[now].node.size();
			for(int j=0;j<len;j++){
				int next = info[now].node[j];
				if(!used[next]){
					used[next] = true;
					info[i].taxi.push_back(info[now].node[j]);
					que.push(P(info[now].node[j],dis-1));
				}
			}
		}
	}

	priority_queue <P, vector<P>, greater<P> > que1;
	que1.push(P(0,0));
	fill_n(used,5001,false);
	while(!que1.empty()){
		P p = que1.top(); que1.pop();
		int c = p.first; int now = p.second;
		if(used[now]) continue;
		used[now] = true;
		if(now == n-1){
			cout << c << endl;
			break;
		}
		int len = info[now].taxi.size();
		for(int j=0;j<len;j++){
			int next = info[now].taxi[j];
			que1.push(P(c+info[now].cost,next));
		}
	}
}

Measured memory_bytes: 200808
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define N 10003
int mi[N], ma[N];
int main() {
  int n, m;
  while(cin >> n >> m && n+m) {
    rep(i, n) mi[i] = ma[i] = 0;
    rep(i, m) {
      int s, k;
      cin >> s >> k;
      if(k == 1) {
        int c; cin >> c;
        mi[c-1]+=s; ma[c-1] += s;
      } else {
        rep(j, k) {
          int c;
          cin >> c;
          ma[c-1] += s;
        }
      }
    }
    int is1, it1, is2, it2, tmps, tmpt;
    tmps = 1000000007;
    tmpt = 0;
    rep(i, n) {
      if(tmpt < ma[i]) {tmpt = ma[i]; it1 = i;}
      if(mi[i] < tmps) {tmps = mi[i]; is2 = i;}
    }
    tmps = 1000000007;
    tmpt = 0;
    rep(i, n) {
      if(i != it1 && mi[i] < tmps) {tmps = mi[i]; is1 = i;}
      if(i != is2 && tmpt < ma[i]) {tmpt = ma[i]; it2 = i;}
    }
    cout << maxd(ma[it1] - mi[is1], ma[it2] - mi[is2])+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() {
  int x, y, z;
  ;
  cin >> N;
}
void solve() {
  int ans = 1;
  rep(i, 1, N) {
    ans *= i;
    ans %= MOD;
  };
  cout << ans << endl;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
#define pii pair<int, int>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = (1 << 29);

int n, m, R, a, b, c, ans;
vector<vector<int>> d(201, vector<int>(201));
vector<int> r(9), used(9);

void dfs(int depth, int las, int dist) {
    if(depth == R) {
        if(ans > dist) {
            ans = dist;
            return;
        }
    }

    rep(i, R) {
        if(!used[i]) {
            used[i] = 1;
            if(las == -1) {
                dfs(depth+1, i, 0);
            }
            else {
                dfs(depth+1, i, dist + d[r[las]][r[i]]);
            }
            used[i] = 0;
        }
    }
}

int main() {
    ans = INF;
    cin >> n >> m >> R;

    rep(i, n) {
        rep(j, n) {
            if(i != j) {
                d[i][j] = INF;
            }
        }
    }

    rep(i, R) {
        cin >> r[i];
        r[i]--;
    }

    rep(i, m) {
        cin >> a >> b >> c;
        a--;  b--;
        if(d[a][b] > c) {
            d[a][b] = d[b][a] = c;
        }
    }

    rep(k, n) {
        rep(i, n) {
            rep(j, n) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    dfs(0, -1, 0);

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

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

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

  //奇＋
  ll sum = 0;
  ll cnt1 = 0;
  rep (i, n) {
    sum += a[i];
    if (i % 2 == 0) {
      if (sum <= 0) {
        cnt1 += (-1)*sum + 1;
        sum = 1;
      }
    } else {
      if (sum >= 0) {
        cnt1 += sum + 1;
        sum = -1;
      }
    }
  }

  //偶＋
  sum = 0;
  ll cnt2 = 0;
  rep (i, n) {
    sum += a[i];
    if (i % 2 == 1) {
      if (sum <= 0) {
        cnt2 += (-1)*sum + 1;
        sum = 1;
      }
    } else {
      if (sum >= 0) {
        cnt2 += sum + 1;
        sum = -1;
      }
    }
  }

  cout << min(cnt1, cnt2) << endl;

  return 0;
}


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

const int PRIME_MAX = 1000001;
bool isPrime[PRIME_MAX];
void init() {
	fill(isPrime, isPrime + PRIME_MAX, true);
	isPrime[0] = isPrime[1] = false;
	for (int i = 2; i * i <= PRIME_MAX; i++) {
		if (!isPrime[i]) continue;
		for (int j = (i << 1); j < PRIME_MAX; j += i) {
			isPrime[j] = false;
		}
	}
}

int main () {
	init();
	int n, x;
	while (cin >> n >> x, n || x) {
		int menu[n];
		bool dp[x + 1];
		memset(dp, 0, sizeof(dp));
		for (int i = 0; i < n; i++) {
			cin >> menu[i];
		}
		dp[0] = true;
		int result = 0;
		for (int i = 0; i <= x; ++i) {
			if (dp[i]) {
				for (int j = 0; j < n; ++j) {
					if (i + menu[j] <= x) {
						dp[i + menu[j]] = true;
					}
				}
				if (isPrime[i]) result = i;
			}
		}
		if (result == 0) {
			cout << "NA" << endl;
		}
		else {
			cout << result << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3116
import java.util.Scanner;
public class Main{
  public static void main(String args[]){
  	Scanner sc = new Scanner(System.in);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    double d = a/0.08;
    int x = (int)(a/0.08);//a=x*0.08
    if(d!=x) x++;
    System.err.println(x);
      //消費税がa円である範囲(とりあえずxは範囲内)
    int min = a;
    int max = a;
    int xmin = x;
    int xmax = x;
    int i = 0;
    while(min==a){
      xmin--;
      min = (int)(xmin*0.08);
    }
    while(max==a){
      xmax++;
      max = (int)(xmax*0.08);
    }
    System.err.println("min:"+xmin+" max:"+xmax);
    //xmin<x<xmaxの間の数のうち最小のものが答
   	for(int j = xmin+1; j<xmax; j++){
      if(b==(int)(j*0.1)){
        System.out.println(j);
        return;
      }
    }
    System.out.println(-1);
  }
}

Measured memory_bytes: 22868
#include <iostream>

int main()
{
	int W, H, x, y, r;
	std::cin >> W >> H >> x >> y >> r;

	if (x <= 0 || y <= 0) {
		std::cout << "No" << std::endl;
	}
	else{
		if (x - r < 0  || x + r > W || y - r < 0 || y + r > H) {
			std::cout << "No" << std::endl;
		}
		else {
			std::cout << "Yes" << std::endl;
		}
	}
}

Measured memory_bytes: 1156