akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    double a,b,t,c=0;
    ll ans=0,i=1;;
    cin>>a>>b>>t;
    t+=0.5;
    c=a;
    while((c)<t)
    {
    ans+=(b);
    c+=(a*i);
   // i++;
    }
    cout<<ans<<endl;

}
return 0;
}

Measured memory_bytes: 256
#ALDS1_2_B
n = int(input())
a = [int(i) for i in input().split()]
cnt = 0
for ni in range(n):
  mini = ni
  for ii in range(ni,n):
    if a[ii] < a[mini]:
      mini = ii
  if mini != ni:
    cnt += 1
    a[ni], a[mini] = a[mini], a[ni]
print(" ".join([str(i) for i in a]))
print(cnt)


Measured memory_bytes: 5608
def knapsack(items, num, weight):
    r = weight + 1
    C = [[0] * r for i in range(num + 1)]
    
    for i, item in enumerate(items, start=1):
        item_v, item_w = item
        for w in range(1, r):
            if item_w <= w:
                v1 = item_v + C[i - 1][w - item_w]
                v2 = C[i - 1][w]
                C[i][w] = max(v1, v2)
            else:
                C[i][w] = C[i - 1][w]
    return C[-1][-1]

import sys

file_input = sys.stdin

N, W = map(int, file_input.readline().split())

items = [map(int, line.split()) for line in file_input]

ans = knapsack(items, N, W)

print(ans)

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


int main()
{
    int N, L;
    cin >> N >> L;
    vector<string> S(N);
    for (int i=0; i<N; i++) cin >> S.at(i);
    sort(S.begin(), S.end());
    

    for (int i=0; i<N; i++) {
        cout << S.at(i); 
    }
    cout << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

#define ALL(V) (V).begin(),(V).end()

using namespace std;

typedef pair<int,int> ii_t;

#define MAX 100010
#define RMAX 1000
char is_prime[MAX];
#define PMAX 100000
int prime[PMAX];

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0;i<n;i++)
        cin >> a[(i+1)%n];
    vector<int> x(n);
    vector<int> y(n);

    for (int i=1;i<n;i++)
        a[i] -= a[i-1];

    x[n-1] = a[n-1] / 2;
    for (int i=n-2, p=1;i>=0;i--,p*=-1)
        x[i] = a[i] + (p * x[n-1]);

    for (int i=0;i<n;i++) {
        cout << (2*x[i]);
        if (i==n-1)
            cout << endl;
        else
            cout << " ";
    }
    return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 3223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    int N,M;cin >> N >> M;
    int ans = max(0,N*(N-1)/2) + max(0,M*(M-1)/2);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

int main() {
  int n;
  cin>>n;
  vi a(n);
  REP(i, n) cin>>a[i];
  vi cnt(100005);
  REP(i, n) cnt[a[i]]++;
  ll ans = 0;
  REP(i, 100005) {
    ans += i*cnt[i];
  }
  int q;
  cin>>q;
  while(q--) {
    int b,c;
    cin>>b>>c;
    ll x = (c-b) * cnt[b];
    ans += x;
    cout << ans << endl;
    cnt[c] += cnt[b];
    cnt[b] = 0;
  }
  

  return 0;
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n, K;
    cin >> n >> K;
    int p[n];
    rep(i,n){
        cin >> p[i];
        p[i]--;
    }
    ll a[n];
    rep(i,n)cin >> a[i];
    ll ans = -1001001001001001001;
    rep(i,n){
        ll dp[n] = {};
        int now = i;
        ll loop = 0;
        ll sum = 0;
        rep(j,n){
            if(j > 0) dp[j] = dp[j-1];
            dp[j] += a[now];
            now = p[now];
            if(now == i){
                loop = j + 1;
                sum = max(sum, dp[j]);
                break;
            }
        }
        rep(j,loop){
            if(j+1>K)break;
            ll tmp = (K-(j+1))/loop*sum+dp[j];
            ans = max(ans,tmp);
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define dbg puts("It's Just Begining.Wait For The End!!!!!\n")
#define CHECK(x) cout << (#x) << " is " << (x) <<"\n";
#define endl printf("\n")
typedef pair<ll,ll> pii;
#define pb push_back
#define ms(a,b) memset(a, b, sizeof(a))
#define in(x) scanf("%lld",&x)
#define out(x) printf("%lld",x)
#define sps printf(" ");
#define X first
#define Y second
#define dou(x) cout<<fixed<<setprecision(6)<<x
#define MAX 100005
#define mod 1000000007
int main()
{
    map<string,ll>mp;
    ll i,j,k,l=0,n;
    in(n);
    for(i=0;i<n;i++)
    {
        string s;
        cin>>s;
        mp[s]++;
        l=max(l,mp[s]);
    }
    auto it=mp.begin();
    vector<string>ans;
    for(;it!=mp.end();it++)
    {
        if(it->second==l)ans.pb(it->first);
    }
    sort(ans.begin(),ans.end());
    for(i=0;i<ans.size();i++)
    {
        cout<<ans[i];endl;
    }
    return 0;
}


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

using ll = long long;
using ul = unsigned long;
using ull = unsigned long long;
#define vec vector
#define rep(_i,_n) for(ll _i = 0; _i < _n; _i++)
#define rep2(_i,_s,_n) for(ll _i = _s; _i < _n; _i++)
#define elif else if
#define push(_a) push_back(_a)
#define fullSort(_a) sort(_a.begin(), _a.end())
#define inputVecI(_name, _n) vec<int> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecL(_name, _n) vec<long> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecLL(_name, _n) vec<ll> _name(_n);rep(_i, _n)cin >> _name[_i];
#define inputVecS(_name, _n) vec<string> _name(_n);rep(_i, _n)cin >> _name[_i];
#define findMaxIdx(_name) distance(_name.begin(), max_element(_name.begin(), _name.end()))
#define printVec(_vec) cout << "{";rep(i, _vec.size()-1)cout << _vec[i] << ",";cout << _vec[_vec.size()-1];cout << "}\n";
#define append(_x) push_back(_x)
#define mapLoop(_i, _name) for(auto i = _name.begin(); i != _name.end(); i++)

int main()
{
    int A, B, K;
    cin >> K;
    cin >> A >> B;
    rep2(i, A, B + 1){
      if(i % K == 0){
        cout << "OK" << endl;
        return 0;
      }
    }
    cout << "NG" << endl;
		return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
	
	int weight[10];
	for(int i = 0; i < 10; i++)
		weight[i] = 1 << i;
		
	int n;
	while(cin >> n){
		if(n % 2){
			n -= 1;
			cout << weight[0] << (n ? " " : "");
		}
	
		while(n){
			int c = 0;
			for(int i = n; i % 2 == 0;){
				c++;
				i /= 2;
			}
			n -= weight[c];
			cout << weight[c] << (n ? " " : "");
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
/*
[ ( ^ _ ^ ) ]
*/

import java.io.*;
import java.util.*;


public class Main {
    int INF = (int)1e9;
    long MOD = 1000000007;


    void solve(InputReader in, PrintWriter out) throws IOException {
        long x = in.nextLong();
        long y = (x/500)*1000;
        x %= 500;
        y += (x/5)*5;
        out.println(y);
    }
    

    public static void main(String[] args) throws IOException {
        if(args.length>0 && args[0].equalsIgnoreCase("d")) {
            DEBUG_FLAG = true;
        }
        InputReader in = new InputReader();
        PrintWriter out = new PrintWriter(System.out);
        int t = 1;//in.nextInt();
        long start = System.nanoTime();
        while(t-- >0) {
            new Main().solve(in, out);
        }
        long end = System.nanoTime();
        debug("\nTime: " + (end-start)/1e6 + " \n\n");
        out.close();
    }
    
    static boolean DEBUG_FLAG = false;
    static void debug(String s) {
        if(DEBUG_FLAG) System.out.print(s);
    }
    
    public static void show(Object... o) {
        System.out.println(Arrays.deepToString(o));
    }
    
    static class InputReader {
        static BufferedReader br;
        static StringTokenizer st;
    
        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> num(1e5+1, 0);
    rep(i, n) {
        int a;
        cin >> a;
        ++num[a];
    }
    ll ans = 1;
    int idx = (n&1) ? 0 : 1;
    if (n&1) {
        if (num[idx] != 1) {
            cout << 0 << endl;
            return 0;
        }
        else {
            ans = 1;
        }
    }
    else {
        if (num[idx] != 2) {
            cout << 0 << endl;
            return 0;
        }
        else {
            ans = 2;
        }
    }
    idx += 2;
    while(1) {
        if (idx >= n) break;
        if (num[idx] != 2) {
            cout << 0 << endl;
            return 0;
        }
        idx += 2;
        ans = (ans * 2LL) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string T;
    cin >> T;
    bool mode = false;
    REP(i, T.size()) {
      if(T[i] == 'P') {
        mode = true;
      } else if(T[i] == 'D') {
        mode = false;
      } else {
        T[i] = 'D';
      }
    }
    cout << T << endl;
}

Measured memory_bytes: 3772
#include "bits/stdc++.h"

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef vector<pii> vpii;

int main() {
  ll N;
  string S;
  cin >> N >> S;
  vi v(N + 1);
  for (ll i = 0; i < N; i++) {
    if (S[i] == '#') v[i + 1] = v[i] + 1;
    else v[i + 1] = v[i];
  }

  ll ans = (1ll << 60);
  for (ll i = 0; i < N; i++) {
    ans = min(ans, v[i] + N - v[N] - i + v[i]);
  }

  ans = min(ans, v[N]);
  cout << ans << endl;
}

Measured memory_bytes: 2180
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main(){
    int x,y;
    cin >> x >> y;

    if(y%2==1){
        cout << "No" << endl;
        return 0;
    }else if(y/2-x<0 || 2*x-y/2<0){
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 3636
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	//数値の入力
		int n = sc.nextInt();
        int x = sc.nextInt();
      	//配列
        int a[] = new int[n];
        for(int i = 0; i < n; i++){
        	a[i] = sc.nextInt();
        }
		Arrays.sort(a);
        int count = 0;
      
        long sum = 0;
        for (int i=0; i<n; ++i){
          sum = sum + a[i];
        }
      	if(sum == x){
          System.out.println(n);
        }else if(sum < x){
          System.out.println(n-1);
        }else{
        for(int i = 0; i < n; i++){
          if(x >= a[i]){
             x = x - a[i];
            count++;
          }
        }
        System.out.println(count);
      }
        }
}


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

ll INF = 1e13;
 
int main(void){
    int n;
    cin>>n;
    vector<vector<int> > v(n);
    rep(i, n) {
        int a;
        cin>>a;
        vector<int>tmp(21);
        int now = 0;
        while(a>0){
            tmp[now] = a%2;
            a/=2;
            now++;
        }
        v[i] = tmp;
    }
    vector<vector<int> >s(21, vector<int>(n+1));
    rep(i, n){
        rep(j, 21){
            s[j][i+1] = s[j][i] + v[i][j];
        }
    }
    ll ans = 0;
    rep(i, n){
        ll now = INF;
        rep(j, 21){
            auto itr = upper_bound(s[j].begin(), s[j].end(), s[j][i]+1);
            int idx = itr-s[j].begin();
            now = min(now, (ll)idx-(ll)i-1);
        }
        ans += now;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 40960
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define INF 1000000007
using namespace std;

int main(void) {
	int h,w;cin >> h >> w;
	char grid[55][55];
	for(int i=0; i<55; i++)for(int j=0; j<55; j++)grid[i][j]='.';
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			cin >> grid[i][j];
		}
	}
	int d[4]={-1,0,1,0};
	for(int i=1; i<=h; i++){
		for(int j=1; j<=w; j++){
			if(grid[i][j]=='#' && grid[i-1][j]=='.' && grid[i+1][j]=='.' && grid[i][j-1]=='.' &&grid[i][j+1]=='.'){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

using namespace std;

#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define f first
#define s second
#define mp make_pair
#define pb push_back

int main(void){
  int a[10],in;
  rep(i,10)a[i]=0;
  rep(i,3){
    cin>>in;
    in --;
    a[in]++;
  }
  //rep(i,10)cout<<a[i]<<" ";cout<<endl;
  cout<<(a[4] == 2 && a[6] == 1?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

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

ll a, b, c;
ll k;

int main() {
  //
  cin >> a >> b >> c;
  cin >> k;

  ll cnt = 0;
  while (true) {
    if (b > a) break;
    ++cnt;
    b *= 2;
  }

  while (true) {
    if (c > b) break;
    ++cnt;
    c *= 2;
  }

  if (cnt <= k) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 28;
bool mark[maxn];
int main(){
	int s, i = 1;
	cin >> s;
	//mark[s] = 1;
	while(!mark[s]){
	mark[s] = 1;
	i ++;
	if(s % 2 == 0)
		s = s / 2;
	else
		s = s * 3 + 1;
	}
	cout << i ;
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;

int main() {
    int N, K;
    cin >> N >> K;
    vector<ll> H(N);
    rep(i, N) cin >> H[i];
    sort(H.begin(), H.end());
    ll ans = 0;
    rep(i, max(0, N - K)) ans += H[i];
    cout << ans << endl;
}

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

using ll = long long;
static const ll MOD = 1e9 + 7;

// 組合せを素数で割った値を求める
const int MAX = 510000;
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;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, k;
  cin >> n >> k;
  
  if(k >= n) k = n - 1;
  
  COMinit();
  
  ll ans = 0;
  for(int i = 0; i <= k; i++){
    ll emp = i, occ = n - i;
    ans += COM(n, emp) * COM(n - 1, n - occ);
    ans %= MOD;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 12160
#include<stdio.h>

int main(){
	
	int i,j;
	int num;
	int array[100];
	
	scanf("%d",&num);
	
	for(i=num-1; i>=0; i--){
		scanf("%d",&array[i]);
	}
	
	for(i=0; i<num; i++){
		if(i)	printf(" ");
		printf("%d",array[i]);
	}
	printf("\n");
		
	return 0;
}




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

int main(){
  int N;
  cin >>N;
  vector<int> a(N);
  for(int i=0;i<N;i++)
    cin >>a.at(i);
  vector<int> x(N,0);
  for(int i=0;i<N ;i++){
    while(a.at(i)>0){
      if(a.at(i)%2>0)
        break;
      a.at(i)/=2;
      x.at(i)++;
    }
  }
  sort(x.begin(),x.end());
  cout <<x.at(0) <<endl;
}


Measured memory_bytes: 256
from sys import exit

# import copy
# import numpy as np
from collections import deque, Counter


(K,) = map(int, input().split())

q = Counter([])
tmp = K

if K % 2 == 0 or K % 5 == 0:
    print(-1)
    exit()


if K % 7 == 0:
    L = 9 * K / 7
else:
    L = 9 * K

tmp = 10

for i in range(1, 10 ** 9):
    if tmp > L:
        tmp = tmp % L
    if tmp % L == 1:
        print(i)
        exit()
    tmp *= 10



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

int main(void){
 int N, Q;
  string S;
  cin >> N >> Q >> S;
  vector<int> count(N - 1, 0);
  for(int i = 1; i < N; i++){
   if(S[i - 1] == 'A' && S[i] == 'C'){
     count[i] = count[i - 1] + 1;
   }
    else count[i] = count[i - 1];
    //cout << count[i];
  }
  for(int i = 0; i < Q; i++){
    int l, r;
    cin >> l >> r;
    
    cout << count[r - 1] - count[l - 1] << endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
#if !defined(ONLINE_JUDGE)
#include "prettyprint/prettyprint.hpp"
#endif//*/

using namespace std;
typedef long long ll;

#define all(x) x.begin(), x.end()

template<class Container> istream& operator>> (istream &in, vector<Container> &c) {for(auto &x :c) in >> x; return in; }
template<class A, class B> istream& operator>> (istream &in, pair<A, B> &c) {in >> c.first >> c.second; return in; }
template<class Container> ll gcd(Container &a) { auto g = *a.begin(); for(auto &x : a) g = __gcd(g, x); return g; }
template<typename T> T Min(const T &a){ return a; }
template<typename T, typename ...Args> T Min(const T &a, const Args&... args) { T b = Min(args...); return (a < b ? a : b);}
template<typename T> T Max(const T &a) { return a; }
template<typename T, typename ...Args> T Max(const T &a, const Args&... args) { T b = Max(args...); return (a > b ? a : b); }
template<typename T> T gcd(const T &a){ return a; }



int main()
{
    int t = 1;
    while(t--)
    {
        int n, k; cin >> n >> k;
        vector<ll> h(n); cin >> h;
        vector<ll> x(n, INT_MIN);
        while(k--)
        {
            int a, b; cin >> a >> b;
            --a, --b;
            x[a] = max(x[a], h[b]);
            x[b] = max(x[b], h[a]);
        }
        int cnt = 0;
        for(int i = 0; i < n; i++)
        {
            if(x[i] < h[i]) {
                cnt++;
            }
        } cout << cnt;

    }
}

Measured memory_bytes: 4840
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
typedef long long ll;
typedef unsigned long long ull;
typedef long double LD;
using namespace std;
const int INF = 2147483647;
const int INF2 = 0x3f3f3f3f;
const ll INF64 = 1e18;
const double INFD = 1e30;
const double EPS = 1e-9;
const double PI = acos(-1);
const int MOD = 998244353;
template <typename T>
inline T read() {
    T X = 0, w = 0;
    char ch = 0;
    while (!isdigit(ch)) {
        w |= ch == '-';
        ch = getchar();
    }
    while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
    return w ? -X : X;
}
const int MAXN = 500005;
int n, m, k;
int dr[4] = {1, 0, -1, 0};
int dc[4] = {0, 1, 0, -1};
int dr2[8] = {1, 1, 1, -1, -1, -1, 0, 0};
int dc2[8] = {1, 0, -1, 1, 0, -1, 1, -1};
int CASE = 1;
int main() {
#ifdef LOCALLL
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif
    scanf("%d%d", &n, &m);
    if (m >= n)
        printf("unsafe");
    else
        printf("safe");
    return 0;
}

Measured memory_bytes: 3828
import collections
import math
N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(N))

l = list(c.keys())
v = list(c.values())
cnt = 0
for i in range(len(l)):
    cnt += math.floor((math.sqrt(1+8*v[i])-1)/2)

if N == 1:
    print(0)
else:
    print(cnt)

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

#define LIM	123456*2
bool p[LIM];

void init() {
	fill(p, p + LIM, true);
	p[0] = p[1] = false;
	for (int i = 4; i < LIM; i += 2) p[i] = false;
	for (int i = 3; i < LIM; i += 2) 
		if (p[i]) for (int j = i * 2; j < LIM; j += i) p[j] = false;
}

int main() {
	init();
	int n;
	while (cin >> n, n) {
		int cnt = 0;
		for (int i = n + 1; i <= n * 2; i++) if (p[i] == true)cnt++;
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using ProCon.Util;

namespace ProCon
{
    class Program
    {
        static void Main(string[] args)
        {
            AC137C();
        }

        static void AC137C()
        {
            //https://atcoder.jp/contests/abc137/tasks

            var n = int.Parse(Console.ReadLine());
            long count = 0;

            List<string> listS = new List<string>();

            Dictionary<string, long> kv = new Dictionary<string, long>();

            for (int i = 0; i < n; i++ )
            {
                char[] s = Console.ReadLine().ToCharArray();
                Array.Sort(s);
                string str =  new string(s);
                if(kv.ContainsKey(str))
                {
                    count += kv[str];
                    kv[str] = kv[str] + 1;
                }
                else
                {
                    kv.Add(str, 1);
                }
            }


            Console.WriteLine(count);
            Console.ReadKey();

        }

    }
}


Measured memory_bytes: 28632
N=int(input())
MOD=10**9+7

dp={b:1 for b in "ACGT"}

for _ in range(N-1):
  dp_new={}
  for k in dp:
    for b in "ACGT":
      new=k[-3:]+b
      if new[-3:] in ("AGC","GAC","ACG") or new in ("AGGC","ATGC","ACGC","AGTC","AGGC"):
        continue
      else:
        dp_new.setdefault(new,0)
        dp_new[new]+=dp[k]
  dp=dp_new

print(sum(dp.values())%MOD)

Measured memory_bytes: 3064
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
 
class Program {
    static void Main(string[] args){
       //var HW  = Console.ReadLine().Split().Select(a => long.Parse(a)).ToArray();
        
       var N = int.Parse(Console.ReadLine());
       
       var S1 = Console.ReadLine();
       var S2 = Console.ReadLine();
       long ans = 1L;
       var i = 0;
       var flag = true;
       if(S2[0] == S1[0]){
           ans = 3;
           i = 1;
           flag = true;
       }else{
           ans = 6;
           i = 2;
           flag = false;
       }
       
       for(;i < N;i++){
           //Console.WriteLine(i);
           if(S2[i] == S1[i]){
               if(flag){
                   ans *= 2;
                   ans %= 1000000007;
               }else{
                   ans *= 1;
                   ans %= 1000000007;
               }
               flag = true;
           }else{
               if(flag){
                   ans *= 2;
                   ans %= 1000000007;
               }else{
                   ans *= 3;
                   ans %= 1000000007;
               }
               i++;
               flag = false;
           }
       }
       Console.WriteLine(ans);
    }      
}


Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    void Calc()
    {
        var sc = new Scanner();
        int a = sc.NextInt();
        int b = sc.NextInt();
        if ( a == b )
        {
            Console.WriteLine("a == b");
        }
        else if ( a > b )
        {
            Console.WriteLine("a > b");
        }
        else if ( a < b )
        {
            Console.WriteLine("a < b");
        }
    }

    static void Main()
    {
        new Program().Calc();
    }

    class Scanner
    {
        string[] s = new string[0];
        int i = 0;
        char[] cs = new char[] { ' ' };

        public string Next()
        {
            if (i < s.Length) return s[i++];
            s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return s[i++];
        }
        public int NextInt() { return int.Parse(Next()); }
        public long NextLong() { return long.Parse(Next()); }
        public double NextDouble() { return double.Parse(Next()); }
    }
}

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

int main() {
  int N;
  cin >> N;
  int A[100010], cnt_minus = 0, cnt_zero = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] < 0) {
      cnt_minus++;
      A[i] *= -1;
    }
    if (A[i] == 0) cnt_zero++;
  }

  long long ans = 0;
  int minv = 1 << 30;
  for (int i = 0; i < N; i++) {
    ans += A[i];
    minv = min(minv, A[i]);
  }
  if ((cnt_zero + cnt_minus) % 2 != 0) {
    ans -= minv * 2;
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, AB):
    g = defaultdict(dict)
    for a, b in AB:
        g[a][b] = 1
        g[b][a] = 1

    f = 1
    s = N

    def df(v):
        d = {v: 0}
        q = [(v, 0)]
        while q:
            v, c = q.pop()
            for u in g[v]:
                if u not in d:
                    d[u] = c + 1
                    q.append((u, c+1))
        return d

    sd = df(s)
    fd = df(f)

    # print(fd)
    # print(sd)

    fc = 0
    sc = 0
    for i in range(2, N):
        if i == s or i == f:
            continue

        if sd[i] >= fd[i]:
            fc += 1
        elif sd[i] < fd[i]:
            sc += 1

    return 'Fennec' if fc > sc else 'Snuke'


def main():
    N = read_int()
    # N, M = read_int_n()
    AB = [read_int_n() for _ in range(N-1)]
    print(slv(N, AB))


if __name__ == '__main__':
    main()


Measured memory_bytes: 89984
#[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 ( 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 , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ 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 , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        n: u64, a: u64
    }
    println!("{}", n*n-a);
}

Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

#define mod 1000000007

class UnionFind{
    private:
        vector<int> p;

    public:
        UnionFind(int n)
        {
            p = vector<int>(n, -1);
        }

        int getparent(int n)
        {
            if(p[n] == -1) return n;
            else return p[n] = getparent(p[n]);
        }

        void addnode(int x, int y){
            x = getparent(x);
            y = getparent(y);
            if(x > y) swap(x, y);
            p[y] = x;
            return;
        }
};

int main()
{
    int v, e;
    cin >> v >> e;
    priority_queue<pair<int, pair<int, int> > > edges;
    for(int i = 0; i < e; i++){
        int s, t, w;
        cin >> s >> t >> w;
        edges.push(make_pair(-w, make_pair(s, t)));
    }
    long long int ans = 0;
    UnionFind UF = UnionFind(v);
    for(int i = 0; i < v - 1; i++){
        int w = (edges.top()).first;
        pair<int, int> p = (edges.top()).second;
        int x = p.first;
        int y = p.second;
        edges.pop();
        while(UF.getparent(x) == UF.getparent(y)){
            w = (edges.top()).first;
            p = (edges.top()).second;
            x = p.first;
            y = p.second;
            edges.pop();
        }
        // cout << x << " " << y << " " << -w << endl;
        ans -= w;
        UF.addnode(x, y);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4452
# include <iostream>
# include <cstdio>

using namespace std ;

long long x[6] ;

int main()
{
	for ( int i = 1; i <= 5 ; i++ ) scanf("%lld" , x + i) ;
	for ( int i = 1 ; i <= 5 ; i++ )
	{
		if ( x[i] == 0 ) printf("%d\n" , i) ;
	}
	return 0 ;
}

Measured memory_bytes: 3828
# URL https://refining-process.hatenablog.com/entry/2019/07/21/005322
N = int(input())
a = list(map(int,input().split()))

b = [0 for i in range(N)]

def check(i):
    cnt = 0
    n = i
    while n <= N:
        cnt += b[n-1]
        n += i
    return cnt

for i in range(N-1, -1, -1):
    if (a[i] + check(i+1)) % 2 == 1:
        b[i] = 1

ans = []
cnt = 0
for i in range(N):
    if b[i] == 1:
        cnt += 1
        ans.append(i+1)

print(cnt)
L = [str(int(i)) for i in ans]
print(' '.join(L))

# N = int(input())
# A = list(map(int, input().split()))
# Ab = [0] * N
# for i in range(1,N+1):
#     Ab[i-1] = sum([A[j-1] for j in range(1,N+1) if j % i == 0])
# print(Ab)
# ans = [0] * N
# for i, a in enumerate(Ab[::-1]) :
#     if i <= N / 2:
#         ans[i] = a
#     else :
#     print(a)


Measured memory_bytes: 22324
#include <iostream>
#include <vector>
#include <algorithm>
#define NMAX 105
#define WMAX 10005
#define DIAGONAL 1
#define TOP 0

using namespace std;
struct Item
{
    int value, weight;
};

int N, W;
Item items[NMAX + 1];
int C[NMAX + 1][WMAX + 1], G[NMAX + 1][WMAX + 1];

void compute(int &maxValue, vector<int> &selection)
{
    for (int w = 0; w <= W; w++)
    {
        C[0][w] = 0;
        G[0][w] = DIAGONAL;
    }
    for (int i = 1; i <= N; i++)
        C[i][0] = 0;

    for (int i = 1; i <= N; i++)
    {
        for (int w = 1; w <= W; w++)
        {
            C[i][w] = C[i - 1][w];
            G[i][w] = TOP;
            if (items[i].weight > w)
                continue;
            if (items[i].value + C[i - 1][w - items[i].weight] > C[i - 1][w])
            {
                C[i][w] = items[i].value + C[i - 1][w - items[i].weight];
                G[i][w] = DIAGONAL;
            }
        }
    }

    maxValue = C[N][W];

    selection.clear();
    for (int i = N, w = W; i >= 1; i--)
    {
        if (G[i][w] == DIAGONAL)
        {
            selection.push_back(i);
            w -= items[i].weight;
        }
    }

    reverse(selection.begin(), selection.end());
}

void input()
{
    cin >> N >> W;
    for (int i = 1; i <= N; i++)
    {
        cin >> items[i].value >> items[i].weight;
    }
}

int main()
{
    int maxValue;
    vector<int> selection;
    input();
    compute(maxValue, selection);

    cout << maxValue << endl;
    return 0;
}


Measured memory_bytes: 11044
#include<cstdio>

const int MAX_N = 1000;
int N,M;
int A[MAX_N];

int gcf(int a,int b);

int ans = 0;
int main(){
	scanf("%d %d",&N,&M);
	for(int i= 0;i<N;i++){
		scanf("%d",&A[i]);
	}
	
	if(N%M==0){
		for(int i = 0; i < N;i+=M){
			int max = 0,min = 1000;
			for(int j = 0; j < M;j++){
				if(A[i+j] < min) min = A[i+j];
				if(A[i+j] > max) max = A[i+j];
			}
			ans += max - min;
		}
	}else{
		int gnum =0;
		int gcfn = gcf(N,M);
		gnum = N/gcfn;
		for(int i = 0; i < gnum; i++){
			int max = 0,min = 1000;
			for(int j = 0;j < M; j++){
				int k = (i*M + j)%(N);
				if(A[k] < min) min = A[k];
				if(A[k] > max) max = A[k];
			}
			ans += max - min;
		}
	}
	
	printf("%d\n",ans);
	
	return 0;
}

int gcf(int a,int b){
	if(a < b){ int dum = a; a = b; b = dum;}
	if(a % b == 1) return 1;
	else if(a % b == 0) return b;
	else gcf(b,a % b);
}

Measured memory_bytes: 2748
# include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
template<typename T>vector<T> make_v(size_t a){ return vector<T>(a); }
template<typename T,typename... Ts>auto make_v(size_t a, Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type fill_v(T &t, const V &v){ t = v; }
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type fill_v(T &t, const V &v){ for(auto &e : t) fill_v(e, v); }
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, m;
int x[202020];

int main(){
    cin >> n >> m;
    REP(i, m){
        cin >> x[i];
    }
    sort(x, x + m);
    vector<int>v;
    REP(i, m){
        if(i)v.emplace_back(x[i] - x[i - 1]);
    }
    sort(ALL(v));
    LL ans = 0;
    REP(i, (int)v.size() - (n - 1)){
        ans += v[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1276
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)

	aa := make([]int, n)
	bb := make([]int, n)
	ma := make([]int, n)
	mb := make([]int, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt(scanner)
	}
	for i := 0; i < n; i++ {
		bb[i] = getNextInt(scanner)
	}

	ans := 0

	for i := 0; i < 30; i++ {
		mapmod(i, n, aa, ma)
		mapmod(i, n, bb, mb)

		sort.Ints(mb)
		t := 1 << uint(i)

		c := 0
		for ii := 0; ii < n; ii++ {
			t1 := search(ma[ii], 0, n, t, mb)
			t2 := search(ma[ii], t1, n, t*2, mb)
			t3 := search(ma[ii], t2, n, t*3, mb)
			c += n - t3 + t2 - t1
		}
		c %= 2
		ans |= c << uint(i)
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}

func mapmod(k, n int, aa, mm []int) {
	for i := 0; i < n; i++ {
		mm[i] = aa[i] % (2 << uint(k))
	}
}

func search(a, l, r, t int, mb []int) int {
	for l < r {
		m := (l + r) >> 1
		if a+mb[m] >= t {
			r = m
			continue
		}
		l = m + 1
	}
	return l
}


Measured memory_bytes: 13056
# -*- coding: utf-8 -*-

n = int(input())
A = list(map(int, input().split()))
A = [A[i]-(i+1) for i in range(n)]
A.sort()

if n == 1:
    print(0)
    exit()

ans = 10**100
for i in [n//2-1, n//2]:
    ans = min(ans, sum([abs(A[j]-A[i]) for j in range(n)]))

print(ans)


Measured memory_bytes: 26128
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <math.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);
 
int main() {
  int x,y,z;
  cin>>x>>y>>z;
  swap(x,y);
  swap(x,z);
  cout<<x<<" "<<y<<" "<<z<<endl;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f, MOD = 1000000007;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*-----------------------------------------*/
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  if (n == 0) {
    cout << 0 << '\n';
    return 0;
  }
  string ans = "";
  while (n != 0) {
    if (n & 1) {
      ans += '1';
      n = (n - 1) / -2;
    } else {
      ans += '0';
      n /= -2;
    }
  }
  reverse(ALL(ans));
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e6 + 233;
ll fac[maxn],Inv[maxn];
int exgcd(int a,int b,int& x,int &y){
	if(b==0){
		x = 1;y = 0;
		return a;
	}
	int d = exgcd(b,a%b,y,x);
	y -= (a/b)*x;
	return d;
}
inline ll inv(int i){
	int x,y;
	exgcd(i,mod,x,y);
	return (x+mod)%mod;
}
void init(){
	fac[0] = Inv[0] = 1;
	ll ans = 0;
	for(int i=1;i<maxn;i++){
		fac[i] = fac[i-1]*i%mod;
		Inv[i] = Inv[i-1]*inv(i)%mod;
	}
}
inline ll C(int n,int k){
	if(k>n)return 0;
	return fac[n]*Inv[k]%mod*Inv[n-k]%mod;
}
inline ll cal(int x,int y){
//	cout<<"!"<<x<<" "<<y<<" "<<C(x+y,x)<<endl;
	return C(x+y,x);
}
int main()
{
	init();
	int r1,r2;
	int c1,c2;
	cin>>r1>>c1>>r2>>c2;
	ll ans = 0;
	for(int i=r1;i<=r2;i++){
//		cout<<"!"<<cal(i+1,c2)<<" "<<cal(i+1,c1-1) << endl;
		ans = (ans+cal(i+1,c2)+mod-cal(i+1,c1-1))%mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 31488
//To debug :  g++ -g file.cpp -o code
//to flush output : fflush(stdout) or cout.flush()
//cout<<setprecision(p)<<fixed<<var
//use 1LL<<i to for 64 bit shifting , (ll)2 because by default 2 is ll
 
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define ld long double
#define pi acos(-1.0)

#define SZ(x)  (ll)(x.size())

//comment the below if now required

#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second


#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main()
{

    ll n;

    cin>>n;

    cout<<(1000-n%1000)%(1000);


    return 0;
}

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

int main(){
	int n;
  	cin>>n;
    int ac=0, wa=0, tle=0, re=0;
  	while (n--){
    	string in;
      	cin>>in;
      	if (in.compare("AC")==0) ac++;
      	else if (in.compare("WA")==0) wa++;
      	else if (in.compare("TLE")==0) tle++;
      	else if (in.compare("RE")==0) re++;
    }
  	cout<<"AC x "<<ac<<endl;
  	cout<<"WA x "<<wa<<endl;
  	cout<<"TLE x "<<tle<<endl;
  	cout<<"RE x "<<re<<endl;
}

Measured memory_bytes: 3612
package main

import (
	"fmt"
)

func main() {
	var N, M, X int
	fmt.Scan(&N, &M, &X)

	C := make([]int, N)
	A := make([][]int, N)

	for i := 0; i < N; i++ {
		fmt.Scan(&C[i])
		A[i] = make([]int, M)
		for j := 0; j < M; j++ {
			fmt.Scan(&A[i][j])
		}
	}
	ams := int(1e9)
	for k := 0; k < 1<<uint(N); k++ {
		cost := 0
		tmpl := make([]int, M)
		for l := 0; l < N; l++ {
			if (k>>uint(l))&1 == 1 {
				cost += C[l]
				for p := 0; p < M; p++ {
					tmpl[p] += A[l][p]
				}
			}
		}
		flag := true
		for q := 0; q < M; q++ {
			if tmpl[q] < X {
				flag = false
			}
		}
		if flag {
			if cost < ams {
				ams = cost
			}
		}
	}
	if ams == int(1e9) {
		fmt.Println(-1)
	} else {
		fmt.Println(ams)
	}
}


Measured memory_bytes: 2220