akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        H: usize,
        W: usize,
        h: usize,
        w: usize,
    }
    let ans = (H - h) * (W - w);
    println!("{}", ans);
}

Measured memory_bytes: 4352
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=998244353,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)            cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)             cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)         cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)         cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f)     cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

ll freq[M];

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    ll d[n];
    ll maxi=0;
    rep(i,0,n){
        cin >> d[i];
        maxi=max(maxi,d[i]);
        freq[d[i]]++;
    }
    if(freq[0]!=1 || d[0]){
        cout << 0;
        return 0;
    }
    ll ans=1;
    for(ll i=0; i<maxi; i++){
        if(!freq[i]){
            cout << 0;
            return 0;
        }
        ans*=power(freq[i],freq[i+1]);
        ans%=mod;
    }
    cout << ans;
    return 0;
}
/* The judge is never wrong! Your code is buggy
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

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

using namespace std;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

string s;
int n;

int main()
{
	cin >> n >> s;
	int len = s.size();
	for (int i = 0; i < len; i+=1)
	{
		if (s[i] + n >= 'A' && s[i] + n <= 'Z') printf("%c", s[i] + n);
		else printf("%c", s[i] + n - 26);
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 3005

struct Info{
	bool operator<(const struct Info &arg) const{

		return A < arg.A;
	}
	int A,B;
};

int N,T;
int dp[SIZE][SIZE];
Info info[SIZE];

int main(){

	scanf("%d %d",&N,&T);

	for(int i = 0; i < N; i++){

		scanf("%d %d",&info[i].A,&info[i].B);
	}
	sort(info,info+N);

	for(int i = 0; i <= N; i++){
		for(int k = 0; k <= T-1; k++){

			dp[i][k] = 0;
		}
	}

	/*
	 * 注文する集団内で一番時間がかかるものは、
	 * T-1に注文した方が良い
	 * →一番時間がかかる料理で場合分けできる
	 * →昇順にdpすれば良い
	 * */

	int ans = 0;

	for(int a = 0; a < N; a++){ //料理のループ

		ans = max(ans,dp[a][T-1]+info[a].B); //料理aを最後に注文する
		if(a == N-1)break;

		for(int t = 0; t <= T-1; t++){

			dp[a+1][t] = dp[a][t];
		}

		for(int t = T-1; t-info[a].A >= 0; t--){

			dp[a+1][t] = max(dp[a+1][t],dp[a][t-info[a].A]+info[a].B);
		}
		for(int t = 1; t <= T-1; t++){

			dp[a+1][t] = max(dp[a+1][t],dp[a+1][t-1]);
		}
	}

	printf("%d\n",ans);

	return 0;
}


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

int main()
{
    int k, x; cin >> k >> x;
    for (int i = x - k + 1; i <= x + k - 1; i++) {
        cout << (i == x - k + 1 ? "" : " ") << i;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;

public class Main implements Runnable {

    private int n;
    private long x;
    
    public static void main(String[] args) throws IOException {
        Main c = new Main();
	c.run();
    }

    private void set() {
	try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
	    String[] parts = br.readLine().split("[\\s]+");
	    n = Integer.parseInt(parts[0]);
	    x = Long.parseLong(parts[1]);
	} catch (IOException e) {
	    e.printStackTrace();
	}
    }

    @Override
    public void run() {
	set();
	long[] length = new long[n+1];
	long[] number = new long[n+1];
	length[0] = 1;
	number[0] = 1;
	for (int i=1;i<n+1;i++) {
	    length[i] = 2*length[i-1]+3;
	    number[i] = 2*number[i-1]+1;
	}
	long num = 0;
	long rem = x;
	for (int i=n;i>=0;i--) {
	    if (i == 0) {
		num++;
		break;
	    }
	    
	    if (rem == 1) break;
	    if (rem == length[i]) {
		num += number[i];
		break;
	    }
	    if (rem == length[i-1]+2) {
		num += number[i-1]+1;
		break;
	    }

	    if (rem < length[i-1]+2) {
		rem = rem - 1;
	    } else {
		rem = rem - (length[i-1]+2);
		num += number[i-1]+1;
	    }
	}
	System.out.println(num);
    }

    private long pow(long base,long power) {
	if (power == 0) return 1;
	if (power%2 == 0) {
	    long h = pow(base,power/2);
	    return h*h;
	} else {
	    return base*pow(base,power-1);
	}
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const ll MAX = 100001;

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

    int N, W;
    cin >> N >> W;

    vector<ll> w(N), v(N);
    REP(i, N) cin >> w[i] >> v[i];

    vector<vector<ll> > dp(N + 1, vector<ll>(MAX, 1LL << 60));

    dp[0][0] = 0;

    REP(i, N) REP(j, MAX) {
        if (j - v[i] >= 0)
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i]);
        dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
    }

    int ans = 0;
    REP(j, MAX)
        if (dp[N][j] <= W)
            ans = j;

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 81520
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt(), s = sc.nextInt(), t=0;
		Map<Integer, Integer> m = new HashMap<Integer, Integer>();
		for (int i=0; i<=K; i++) {
			for (int j=0; j<=K; j++) {
				m.put(i+j, m.get(i+j)==null ? 1 : m.get(i+j)+1);
			}
		}
		for (int k=0; k<=K; k++) if (m.containsKey(s-k)) t+=m.get(s-k);
		System.out.println(t);
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 56928
#include<iostream>
#include<string>
#include<stack>
#include<algorithm>
#include<queue>
#include<cmath>
#include<numeric>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<iomanip>
#include<functional>
#include<bitset>

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

using namespace std;
typedef long long ll;

int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    ll ans = 0;
    if(a>k) ans = k;
    else if(a+b>k) ans = a;
    else{
        ans = a-(k-a-b);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define pii pair<int,int>
#define mii map<int,int>
#define F first
#define S second
#define forn(i,n) for(int i = 0; i<n; i++)
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb push_back
#define sortv(v) sort(v.begin(), v.end())
#define debug(x) cout<<#x<<" : "<<x<<endl
#define all(x) x.begin(),x.end()
#define printv(v) for(auto it : v) cout<<it<<" ";cout<<endl;
#define prec(n) fixed<<setprecision(n)
const int mod1 = 1000000007;
const int mod2 = 998244353;
const int N = 1e5;

int main()
{
	optimize

	#ifndef ONLINE_JUDGE
	freopen("inputf.in", "r", stdin);
	freopen("outputf.in", "w", stdout);
	#endif

	string s;
	cin>>s;

	int to = 0;
	for(char x : s)
	{
		to += (x-'0');
	}
	if(to%9 == 0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;


	return 0;
}

Measured memory_bytes: 3764
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque, defaultdict
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right
def mcomb(n, k, mod):
    def mfac(l, r, mod):
        ans = l
        for i in reversed(range(r, l)):
            ans *= i
            ans %= mod
        return ans

    A = mfac(n,n-k+1,mod)
    B = mfac(k,1,mod)
    # B = mpow(B,mod-2,mod)
    B = pow(B, mod-2, mod)
    return A * B % mod

def solve():
    N = II()
    MOD = 1000000007
    if N == 1:
        print(0)
        return
    # print(pow(9, N), pow(8, N))
    # print(pow(10, N), 2 * pow(9, N) - pow(8, N))
    ans = pow(10, N, MOD) - ((2 * pow(9, N, MOD)) % MOD - pow(8, N, MOD)) % MOD
    print(ans % MOD)

    
if __name__ == '__main__':
    solve()



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

const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int n,m;cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2<<endl;
}

Measured memory_bytes: 256
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e15;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}

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


void solve()
{
    int n;
    cin>>n;
    int x=n/3;
    int z=(x*(x+1))/2;
    z=3*z;
    int ans=(n*(n+1))/2;
    ans-=z;
    x=n/5;
    z=(x*(x+1))/2;
    z=5*z;
    ans-=z;
    x=n/15;
    z=(x*(x+1))/2;
    z=15*z;
    ans+=z;
    cout<<ans<<endl;
    
}


int32_t main()
{
    
    IOS;
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  ll n, x, m;
  cin >> n >> x >> m;
  deque <ll> a = {x};
  vector <int> vis(m, 0);
  vis[x] = 1;
  int s = 0;
  while (true) {
    ll add = (1LL * a.back() * a.back()) % m;
    if (vis[add]) {
      s = vis[add];
      break;
    }
    a.pb(add);
    vis[add] = sz(a);
  }
  if (n <= s) {
    ll ret = 0;
    for (int i = 0; i < n; i++) {
      ret += a[i];
    }
    cout << ret << '\n';
    return (0);
  }
  ll ret = 0;
  for (int i = 0; i < s - 1; i++) {
    ret += a.front();
    a.pop_front();
    n -= 1;
  }
  int lambda = sz(a);
  ll xx = n / lambda;
  ll yy = n % lambda;
  ret += xx * accumulate(all(a), 0LL);
  for (int i = 0; i < yy; i++) {
    ret += a[i];
  }
  cout << ret << '\n';
  return (0);
}


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

// 0 から v までの XOR を計算する
long long f(long long v){

  if (v == 0) {
    return 0;
  }

  // 0 から始めているので v + 1 個の整数で考える
  v++;

  // 答え
  long long res = 0;
  
  // i 桁目の偶奇を調べる
  for (int i = 0; i < 50; i++) {

    // 1 の個数を計算するために、周期を求める
    long long loop = (1LL << (i+1));

    // 1 の個数 = ループした回数 × 1 が出てくる回数
    // 0(000) から 4(100) までの場合下 2 桁までを数える
    long long count = (v / loop) * (loop / 2);
    
    // 0(000) から 4(100) までの場合、 3 桁目で 1 が出てくる回数を加える
    count += max(0LL, (v % loop) - (loop / 2));

    // その桁が 奇数 だったら答えに加える
    if (count % 2 == 1) {
      res += 1LL << i;
    }

  }

  return res;
}

int main() {

  long long A, B;
  cin >> A >> B;

  // (0 から B までの XOR) XOR (0 から A - 1 までの XOR)
  long long answer = f(B) ^ f(A - 1);

  cout << answer << endl;

  return 0;

}

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

using namespace std;
#define ll long long int
const int MAXN = 2 * 1e5 + 5;


ll fastpower(int a, int b, int MOD){
    ll res = 1;
    while(b){
        if(b & 1) res = (res * a)%MOD;
        a *= a;
        a %= MOD;
        b >>= 1;
    }
    return res;
}


void solve(){
    int n, p;
    cin >> n >> p;
    string s; cin >> s;

    if( p == 5 || p == 2){
        ll ans = 0;
        for(int i = 0; i < n; ++i){
            if( (s[i] - '0') % p == 0 ){
                ans += i + 1;
            }
        }
        cout << ans << '\n';
        return;
    }

    vector<ll> counts(p, 0);
    counts[0] = 1;
    int curr = 0;
    for(int i = 0; i < n; ++i){
        curr *= 10; curr += s[i] - '0';curr %= p;
        int val = fastpower(10, n - i - 1, p) * curr; val %= p;
        counts[val]++;
    }
    ll ans = 0;
    for( int i = 0; i < p; ++i){
        ans += counts[i] * (counts[i] - 1) /2;
    }

    cout << ans << '\n';

}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
	//int t; cin >> t;
	//while(t--)
		solve();
}


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

//出力
void Yes(){ cout << "Yes" << endl; }
void yes(){ cout << "yes" << endl; }
void No(){ cout << "No" << endl; }
void no(){ cout << "no" << endl; }
void Possible(){ cout << "Possible" << endl; }
void possible(){ cout << "possible" << endl; }
void Imossible(){ cout << "Impossible" << endl; }
void imossible(){ cout << "impossible" << endl; }

//マクロ
#define INF 1800000000
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define sort(a) sort(a.begin(), a.end())
#define reverse(a) reverse(a.begin(), a.end())


long long n, a, b;

//d回以上で全滅できるか
bool C(long long d, vector<long long> f){
    
    long long count = 0;
    for(int i = 0; i < n; i++){
        if(f[i] >= b * d){
            count += (f[i] - b * d) / (a - b);
            if((f[i] - b * d) % (a - b) != 0) count++;
        }
    }

    //cout << d << " " << (count <= d) << endl;

    if(count <= d) return true;
    else return false;

}

int main(){

    cin >> n >> a >> b;
    vector<long long> f(n);
    for(int i = 0; i < n; i++) cin >> f[i];
    

    //二部探索
    long long ub = INF;
    long long lb = 0;
    //ubが答え
    while(ub - lb > 1){
        long long mid = (ub + lb) / 2;
        if(C(mid, f)) ub = mid;
        else lb = mid;
    }

    cout << ub << endl;
    return 0;
}

Measured memory_bytes: 1792
import heapq
 
N,M = map(int, input().split())
A = list(-int(i) for i in input().split()) 

heapq.heapify(A)

for i in range(M):
    x=heapq.heappop(A)//(-2)
    heapq.heappush(A, -x)
 
print(-sum(A))

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

#define pb(a) push_back(a)
#define INF 1145141919810
#define mod 1000000007

typedef long long ll;

const int dsize = 1e5+5;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
vector<ll> prime;

ll inv[dsize],fac[dsize];

template <class T = ll> T in(){T x;cin >> x;return (x);}
inline ll GCD(ll a,ll b){ll c;while(b!=0){c=a%b;a=b;b=c;}return a;}
inline ll LCM(ll a,ll b){return a*b/GCD(a,b);}
inline ll POW(ll a,ll b){ll c=1;while(b>0){if(b&1){c=a*c%mod;}a=a*a%mod;b>>=1;}return c;}
inline void _nCr(){fac[0]=1;for(int i=1;i<dsize;i++){fac[i]=fac[i-1]*i%mod;}for(int i=0;i<dsize;i++){inv[i]=POW(fac[i],mod-2);}}
inline ll nCr(ll n,ll r){return (fac[n]*inv[r]%mod)*inv[n-r]%mod;}
inline void PRI(ll n){bool a[n+1];for(int i=0;i<n+1;i++){a[i]=1;}for(int i=2;i<n+1;i++){if(a[i]){prime.pb(i);ll b=i;while(b<=n){a[b]=0;b+=i;}}}}

int main() {
	ll n=in(),m=in();
	ll x[n][3];
	for (int i=0;i<n;i++) {
		x[i][0]=in();x[i][1]=in();x[i][2]=in();
	}
	ll ans=0;
	for (int i=0;i<8;i++) {
		ll sum[n];
		for (int j=0;j<n;j++) sum[j]=0;
		for (int j=0;j<n;j++) {
			int p=i;
			for (int k=0;k<3;k++) {
				if (p%2) sum[j]+=x[j][k];
				else sum[j]-=x[j][k];
				p/=2;
			}
		}
		sort(sum,sum+n,greater<ll>());
		ll now=0;
		for (int j=0;j<m;j++) {
			now+=sum[j];
		}
		ans=max(ans,now);
	}
	cout << ans <<endl;
}


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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> b(n);
  for(int i=0;i<k;i++){
    int d;
    cin>>d;
    vector<int> a(d);
    for(int i=0;i<d;i++){
      cin>>a.at(i);
    }
    for(int i=0;i<d;i++){
      for(int j=0;j<n;j++){
        if(j==(a.at(i)-1)){
          b.at(j)=1;
        }
      }
      
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(b.at(i)==0){
      ans++;
    }
  }
 
  cout<<ans<<endl;
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  while(s!="#"){

    int a,b,c,d;
    cin >> a >> b >> c >> d;
    a--; b--; c--; d--;
    int tab[10][10]={{}};
    int h=0,w=0;
    int i=0,j=0;
    for(int k=0;k<s.size();k++){
      if(s[k]=='/'){
	i++;
	if(!w)w=j;
	j=0;
      }else if(s[k]=='b'){
	tab[i][j++]=1;
      }else{
	int num=s[k]-'0';
	j+=num;
      }
    }
    h=i+1;

    tab[a][b]=0;
    tab[c][d]=1;

    int cou=0;
    for(int q=0;q<h;q++){
      if(q)cout << '/';
      cou=0;
      for(int p=0;p<w;p++){
	if(tab[q][p]==0){
	  cou++;
	}else{
	  if(cou)cout << cou;
	  cout << "b";
	  cou=0;
	}
      }
      if(cou)cout << cou;
    }
    cout << endl;
    cin >> s;
  }
  return 0;

}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=998244353;
const int MAX_N=4010;
ll fact[MAX_N], invfact[MAX_N];

ll extgcd(ll a, ll b, ll& x, ll&y){
    ll d=a;
    if(b!=0){
        d=extgcd(b, a%b, y, x);
        y-=(a/b)*x;
    }
    else {
        x=1; y=0;
    }
    return d;
}

ll mod_inverse(ll a, ll m=MOD){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

ll comb(ll a, ll b){
    if(a<b||a<0||b<0) return 0;
    return fact[a]*invfact[b]%MOD*invfact[a-b]%MOD;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    fact[0]=1;
    invfact[0]=1;
    rep(i,1,MAX_N){
        fact[i]=fact[i-1]*i%MOD;
        invfact[i]=mod_inverse(fact[i]);
    }
    ll K,N;
    cin>>K>>N;
    rep(i,2,2*K+1){
        if(i%2){
            ll k;
            if(i<=K+1) k=i/2;
            else k=K-i/2;
            ll ans=0;
            ll res=1;
            rep(j,0,k+1){
                ans+=comb(k,j)*res%MOD*comb(N+K-2*k-1, N-j)%MOD;
                ans%=MOD;
                res*=2;
                res%=MOD;
            }
            cout <<ans<<"\n";
        }
        else{
            ll k;
            if(i<=K+1) k=i/2-1;
            else k=K-i/2;
            ll ans=0;
            ll res=1;
            rep(j,0,k+1){
                ans+=comb(k,j)*res%MOD*comb(N+K-2*k-2, N-j)%MOD;
                ans%=MOD;
                res*=2;
                res%=MOD;
            }
            res=1;
            rep(j,0,k+1){
                ans+=comb(k,j)*res%MOD*comb(N+K-2*k-3, N-j-1)%MOD;
                ans%=MOD;
                res*=2;
                res%=MOD;
            }
            cout <<ans<<"\n";
        }
    }
}

Measured memory_bytes: 384
#include<iostream>
#include<complex>
#include <algorithm>
using namespace std;
int main()
{
    int n,k,p[1000],i,sum=0;
    cin >> n >> k;
    for(i=0;i<n;i++) cin >> p[i];
    sort(p,p+n);
    for(i=0;i<k;i++)sum+=p[i];
    cout << sum;
    return 0;
}

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

int main() {
  int A, B;
  string S;
  cin >> A >> B >> S;
  if (S[A] != '-') {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i < A; i++) {
    if (!(S[i] >= '0' && S[i] <= '9')) {
      cout << "No" << endl;
      return 0;
    } 
  }
  for (int i = A + 1; i <= A + B; i++) {
    if (!(S[i] >= '0' && S[i] <= '9')) {
      cout << "No" << endl;
      return 0;
    } 
  }  
  cout << "Yes" << endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 200009
ll n,m,i,j,k,l,t,arr5[sz],brr[sz],crr[sz];
map<ll,ll>arr;
int main()
{
    scanf("%lld",&n);
    l=7;
    j=1;
    while(1)
    {
        k=l%n;
        if(k==0)
        {
            printf("%lld\n",j);
            return 0;
        }
        if(arr[k])
            break;
        arr[k]++;
        j++;
        l=k*10+7;
    }
    printf("-1\n");
    return 0;
}


Measured memory_bytes: 66220
#include<iostream>
#include<set>
#include<cmath>
#include<queue>
using namespace std;
typedef pair<int,int> pi;
#define MAX 1024
const double eps = 1.0e-14;
static const int di [] = {1,0,-1,0};
static const int dj [] = {0,1,0,-1};
inline int ceilSqrt(int n){
  if(n<0)return 0;
  return (int)ceil(sqrt((double)n)-eps);
}

inline bool inside(pi p, int rmax){
  return 0<=p.first&&0<=p.second&&p.second<rmax&&p.first<rmax;
}

int main()
{
  while(true){
    static int Height[MAX][MAX];
    static bool vis[MAX][MAX];
    for(int i = 0; i < MAX; ++ i){
      for(int j = 0; j < MAX; ++j ){
	vis[i][j]=false;
	Height[i][j]=0;
      }
    }
    long long int ans = 0;
    long long int N;
    int rmax;
    cin >> N;
    if( N == 0 )break;

    rmax = ceilSqrt(N);
    queue<pi> q;
    q.push(pi(0,0));
    vis[0][0]=true;
    while(!q.empty()){
      pi now = q.front();q.pop();
      //cout << " NOW : " << now.first << ' ' << now.second << endl;
      Height[now.first][now.second] = ceilSqrt( N - (now.first)*(now.first) - (now.second)*(now.second) );
      if( Height[now.first][now.second] == 0 ) continue;
      for(int i = 0; i < sizeof(di)/sizeof(*di); ++i){
	pi next( now.first + di[i], now.second + dj[i] );
	if( !vis[next.first][next.second] && inside( next, rmax ) ){
	  vis[ next.first ][ next.second ] = true;
	  q.push( next );
	}
      }
    }

    for(int i = 0; i < MAX; ++i){
      for(int j = 0; j < MAX; ++j){
	vis[i][j]=false;
      }
    }
    
    //cout << " -------------------------------- " << endl;
    for(int i = 0; i < rmax; ++i){
      for(int j = 0; j < rmax; ++j){
	//if( N<120 )cout << Height[i][j];
	if( !vis[i][j] && Height[i][j] > 0 ){
	  bool i0=false,j0=false;
	  vis[i][j]=true;
	  q.push( pi(i,j) );
	  while(!q.empty()){
	    pi now = q.front();q.pop();
	    i0 |= now.first == 0;
	    j0 |= now.second == 0;
	    for(int k = 0; k < sizeof(di)/sizeof(*di); ++k){
	      pi next(now.first+di[k], now.second+dj[k] );
	      if( !vis[next.first][next.second] && Height[i][j] == Height[next.first][next.second] &&
		  inside( next, rmax ) ){
		vis[next.first][next.second]=true;
		q.push(next);
	      }
	    }
	  }
	  ans += (i0&&j0) ? 1 : ( (i0||j0) ? 2 : 4);
	}
      }
      //if( N < 120 ) cout << endl;
    }
    cout <<6LL*ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 6036
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int t=sc.nextInt();
        int sum=0;

        for(int i=1; a*i<=t; i++){
            sum+=b;
        }
        System.out.println(sum);
        sc.close();
    }
}

Measured memory_bytes: 23252
import math
lines = input().split(" ")
 
A = int(lines[0])
B = int(lines[1])
C = A - 1
result = 0
 
if B == 1:
  print(0)
elif B == 2:
    print(1)
elif A == 20:
    print(1)
elif A >= B:
    print(1)
else:
    result += A
    count = 1
    while result < B:
        result += C
        count += 1
    print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

using ll = long long;

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n, k;
	cin >> n >> k;
	int cnt = 0;
	while(n) {
		cnt++;
		n /= k;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define SW(x) setw(x)    // 桁数指定
#define SF(c) setfill(c) // 埋め文字指定('0')
#define ALL(v) v.begin(), v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    ll ans = 0;

    for (ll i = 1; i <= n; i++)
    {
        ll t;
        cin >> t;
        if (i % 2 == 1 && t % 2 == 1)
            ans++;
    }
    cout << ans << endl;
}

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

template <class T>
class SegTree {
  int n;                        // 葉の数
  vector<T> data;               // データを格納するvector
  T def;                        // 初期値かつ単位元
  function<T(T, T)> operation;  // 区間クエリで使う処理
  function<T(T, T)> update;     // 点更新で使う処理

  // 区間[a,b)の総和。ノードk=[l,r)に着目している。
  T _query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return def;  // 交差しない
    if (a <= l && r <= b)
      return data[k];  // a,l,r,bの順で完全に含まれる
    else {
      T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);  // 左の子
      T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);  // 右の子
      return operation(c1, c2);
    }
  }

 public:
  // _n:必要サイズ, _def:初期値かつ単位元, _operation:クエリ関数,
  // _update:更新関数
  SegTree(size_t _n, T _def, function<T(T, T)> _operation,
          function<T(T, T)> _update)
      : def(_def), operation(_operation), update(_update) {
    n = 1;
    while (n < _n) {
      n *= 2;
    }
    data = vector<T>(2 * n - 1, def);
  }

  // 場所i(0-indexed)の値をxで更新
  void change(int i, T x) {
    i += n - 1;
    data[i] = update(data[i], x);
    while (i > 0) {
      i = (i - 1) / 2;
      data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }

  // [a, b)の区間クエリを実行
  T query(int a, int b) { return _query(a, b, 0, 0, n); }

  // 添字でアクセス
  T operator[](int i) { return data[i + n - 1]; }
};

int main() {
  int n, Q;
  cin >> n >> Q;
  // 要素数n・long long型・区間min・点更新
  SegTree<ll> st(
      n, (1LL << 31) - 1, [](ll a, ll b) { return min(a, b); },
      [](ll a, ll b) { return b; });
  rep(q, Q) {
    int c, x, y;
    cin >> c >> x >> y;
    if (c == 0) {
      // update(x, y)
      st.change(x, y);
    } else {
      // find(s, t)
      cout << st.query(x, y + 1) << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 4828
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i += 2) {
		set<int> s;
		for (int j = 1; j * j <= i; j++) {
			if (i % j == 0) {
				s.insert(j);
				s.insert(i / j);
			}
		}
		if (s.size() == 8) ans++;
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 3576
from collections import Counter

n= int(input())
a=list(map(int,input().split()))
ca = Counter(a)
sa = set(a)
sum_ans=0
for i in sa:
  sum_ans+=(ca[i]*(ca[i]-1))//2

for i in a:
  print(sum_ans-(ca[i]*(ca[i]-1))//2+((ca[i]-1)*(ca[i]-2))//2)

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n;
	cin>>n;
	vector<int> vec(n);
	for(int i=0;i<n;++i)
	{
	    cin>>vec[i];
	}
	
	map<int,int> ma;
	for(int i=0;i<n;++i)
	{
	    ma[vec[i]]++;
	}
	long long ans=0;
	for(auto it=ma.begin();it!=ma.end();++it)
	{
	    long long temp=it->second;
	    temp=(temp*(temp-1))/2;
	    ans+=temp;
	}
	
	for(int i=0;i<n;++i)
	{
	    long long temp1=ma[vec[i]];
	    long long temp=temp1-1;
	    if(temp>=1)
	    temp=(temp*(temp-1))/2;
	    else
	    temp=0;
	    long long y=(temp1*(temp1-1))/2;
	    long long ans1=ans;
	    ans1=ans1-y+temp;
	    cout<<ans1<<endl;
	    
	}
}


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

using namespace std;

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

    int h, w, d;
    cin >> h >> w >> d;

    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j)
            cout << "RYGB"[((i + j) / d % 2) | (((w + i - j) / d % 2) << 1)];
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 512
fun main(){
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val tosi = MutableList(n){ MutableList(0){ 0 } }
    for (i in 0 until m){
        val ab = readLine()!!.split(" ").map { it.toInt() }
        tosi[ab[0] - 1].add(ab[1])
        tosi[ab[1] - 1].add(ab[0])
    }
    val flagList = MutableList(n){ 0 }
    val checkList = MutableList(0){ 0 }
    var flag = -1
    tailrec fun check(d: Int){
        for (i in 0 until tosi[d-1].size){
            if (flagList[tosi[d-1][i] - 1] == 0) {
                checkList.add(tosi[d-1][i])
                flagList[tosi[d-1][i] - 1] = 1
            }

        }
        checkList.removeAt(0)
        if (checkList.size > 0) check(checkList[0])
    }
    for (i in 0 until n){
        if (flagList[i] == 0){
            flag++
            flagList[i] = 1
            for (j in 0 until tosi[i].size){
                checkList.add(tosi[i][j])
                flagList[tosi[i][j] - 1] = 1
            }
        }
        if (checkList.size > 0) check(checkList[0])

    }
    println(flag)
}

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

using namespace std;

// white 0; black 1
int mp[110][110];
int main(){
 //   freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
    int a, b;
    cin >> a >> b;
    int n = 100;
    memset(mp, 0, sizeof(mp));
    for(int i = 0; i < n / 2; i ++){
        for(int j = 0; j < n; j ++){
            mp[i][j] = 1;
        }
    }
    a --; b --;
    for(int i = 0; i < n/2-1; i += 2){
        int j = ((i & 1) ? 1 : 0);
        for(; j < n && a; j+=2, a--){
            mp[i][j] = 0;
        }
        if(!a)break;
    }
    for(int i = n - 1; i > n/2; i -= 2){
        int j = ((i & 1) ? 0 : 1);
        for(; j < n && b; j+=2, b--){
            mp[i][j] = 1;
        }
        if(!b)break;
    }
    cout << n << " " << n << endl;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            if(mp[i][j])cout<<'#';
            else cout<<'.';
        }
        cout << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<algorithm>
#define maxn 100005
using namespace std;
typedef map<int,int>::iterator miter;
int n,t[maxn];
struct node { int v; node *nxt; } edge[maxn*2],*head[maxn],*ncnt;
void addedge(int u,int v)
{
	ncnt++;
	ncnt->v=v,ncnt->nxt=head[u];
	head[u]=ncnt;
}
void dfs(int u,int fa)
{
	map<int,int> cnt;
	for(node *p=head[u];p;p=p->nxt)
	{
		int v=p->v;
		if(v==fa) continue;
		dfs(v,u);
		cnt[t[v]]++;
	}
	miter it;
	for(it=cnt.begin();it!=cnt.end();it++)
		if(it->second>1) cnt[it->first+1]+=it->second-1;
	if(it!=cnt.begin()) { it--; t[u]=it->first+1; }
}
int main()
{
	ncnt=&edge[0];
	scanf("%d",&n);
	for(int i=2;i<=n;i++)
	{
		int x;
		scanf("%d",&x);
		addedge(i,x); addedge(x,i);
	}
	dfs(1,0);
	printf("%d\n",t[1]);
}

Measured memory_bytes: 17024
#include <vector>
using namespace std;

template <typename T>
vector<T> factorize(T n) {
    vector<T> factors;
    for (T p = 2; p *p <= n; ++p) {
        while (n % p == 0) {
            factors.push_back(p);
            n /= p;
        }
    }
    if (n > 1) {
        factors.push_back(n);
    }
    return factors;
}

#include <iostream>
int main() {
    unsigned long long n;
    vector<unsigned long long> f;
    cin >> n;
    f = factorize(n);
    cout << n << ":";
    for (unsigned i = 0; i < f.size(); ++i) {
        cout << " " << f[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1212
s1=int(input())
s2=int(input())
s3=int(input())
s4=int(input())
s5=int(input())
s6=int(input())
s7=int(input())
s8=int(input())
s9=int(input())
s10=int(input())

print(s1+s2+s3+s4+s5+s6+s7+s8+s9+s10)


Measured memory_bytes: 5588
package main

import (
	"fmt"
	"math"
)

func main() {
	// Code for A - Anti-Adjacency
	var N, K int
	fmt.Scanf("%d %d", &N, &K)

	if int(math.Ceil(float64(N)/2)) >= K {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1836
import java.io.*;
import java.util.*;

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		long N = nextLong();
		long M = nextLong();

		long ans = Math.max(Math.min(N, M/2),0);
		N-=ans;
		M-=ans*2;
		ans+=M/4;

		System.out.println(ans);
	}



	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static String concatStringArray(String[] s){
		StringBuffer sb = new StringBuffer();
		for(String x:s){
			sb.append(x);
		}
		return sb.toString();
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 23252
n=int(input())
a_list=list(map(int,input().split()))
for i in range(n):
    a_list[i]=a_list[i]-(i+1)
a_list.sort()
b=a_list[n//2]
Sum=0
for i in a_list:
    Sum=Sum+abs(i-b)
print(Sum)


Measured memory_bytes: 86740
import java.util.Scanner

import scala.collection.mutable
import scala.math._

object Helper {

  implicit class LongImplicits(val i: Long) {
    def isEven = i % 2 == 0

    def isOdd = !isEven

    def **(exp: Long): Long = scala.math.pow(i, exp).longValue
  }

}

object Main {

  def main(args: Array[String]): Unit = {
    import Helper._
    val sc = new Scanner(System.in)
    val x = sc.nextInt()

    val ans = (for {
      a <- (-150L to 150L).to(LazyList)
      b <- (-150L to 150L).to(LazyList)
      if (x == a ** 5 - b ** 5)
    } yield s"$a $b"
      ).head
    println(ans)
  }
}


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

int main()
{
    int n,w;
    cin>>n>>w;
    vector<pair<long int ,long int>> arr(n);
    for(int i=0;i<n;i++)
        cin>>arr[i].first>>arr[i].second;
    sort(arr.begin(),arr.end());
    vector<vector<long int>> dp(n+1,vector<long int>(w+1,0));
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(j<arr[i-1].first)
            dp[i][j]=dp[i-1][j];
            else
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-arr[i-1].first]+arr[i-1].second);
        }
    }
    cout<<dp[n][w];
    return 0;
}


Measured memory_bytes: 80256
n = int(input())
tasks = []
for i in range(n):
    a,b = map(int, input().split())
    tasks.append((b,a))
tasks.sort()

time = 0
for t in tasks:
    b,a = t
    if time+a > b:
        print('No')
        exit()
    time += a
print('Yes')

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */
lint dp[51][51][2501];

int main(){
    int n, a; cin >> n >> a;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    
    rep(i, n) dp[i][0][0] = 1;
    dp[0][1][x[0]] = 1;

    for(int i = 1; i < n; i++){
        for(int j = 1; j <= i+1; j++){
            for(int k = 1; k <= 50 * n; k++){
                dp[i][j][k] = dp[i-1][j][k];
                if(k >= x[i]) dp[i][j][k] += dp[i-1][j-1][k-x[i]];
            }
        }
    }

    
    lint ans = 0;
    for(int i = 1; i <= n; i++){
        ans += dp[n-1][i][a*i];
    }
    out(ans);
}

Measured memory_bytes: 48128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int k, a, b;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  bool f = false;

  cin >> k >> a >> b;
  FOR(i, a, b + 1) {
    if(i % k == 0) f = true;
  }

  cout << (f ? "OK" : "NG") << endl;
}


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

static const int MOD=1e9+7;

int main(){
    string K; cin >> K;
    int D; cin >> D;

    int N=K.size();
    long long dp[N+1][2][D+1]; //dp[桁数][上限ギリギリかどうか][Dで割ったあまり]
    memset(dp,0,sizeof(dp));
    dp[0][0][0]=1;
    for(int i=0;i<N;i++){
        int s=K[i]-'0';
        for(int k=0;k<D;k++){
            for(int j=0;j<2;j++){
                for(int d=0;d<=(j?9:s);d++){
                    dp[i+1][j||(d<s)][(k+d)%D]+=dp[i][j][k%D]%MOD;
                    dp[i+1][j||(d<s)][(k+d)%D]%=MOD;
                }
            }
        }
    }
    long long ans=((dp[N][0][0]+dp[N][1][0])%MOD+MOD-1)%MOD;
    cout << ans << endl;
}

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

using namespace std;

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

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int A, B;
  cin >> A >> B;
  if (B % A == 0)
    cout << A + B << endl;
  else
    cout << B - A << endl;
}


Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
System.out.println(Math.max(a,Math.max(b,c))*9+a+b+c);
}}


Measured memory_bytes: 23764
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    let N = parseInt(input[0][0], 10);
    let v_A = input[1].map(e => parseInt(e, 10));
    let tmp = v_A[0];
    let ans = 0;
    for (let i = 1; i < N; i++){
        if (tmp <= v_A[i]) tmp = v_A[i];
        else ans += tmp - v_A[i];
    }
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 50304