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

#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define vll vector<ll>
#define pll pair<ll , ll>
#define vpll vector<pair<ll, ll> >
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define N 100001
#define HOLE 1000000007

ll fn(ll x,ll rn[])
{
    if(rn[x]==x) return x;
    else return rn[x]=fn(rn[x],rn);
}

void un(ll x,ll y,ll rn[],ll sz[])
{
    x=fn(x,rn);
    y=fn(y,rn);
    if(x==y) return;
    if(sz[x]<sz[y]) swap(x,y);
    sz[x]+=sz[y];
    rn[y]=x;
    return;
}

ll power(ll x,ll y)
{
    ll res = 1; // Initialize result

    while (y > 0) {
        // If y is odd, multiply x with result
        if (y & 1)
            res = (res * x)%HOLE;

        // n must be even now
        y = y >> 1; // y = y/2
        x = (x * x)%HOLE; // Change x to x^2
    }
    return res;
}

vector <ll> adjl[N];
ll marked[N]={0};
vector <ll> order;

void dfs (ll x){

    if(marked[x])
        return;
    marked[x]=1;

    REP(i,0,adjl[x].size()){

    }

    return;
}

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

    ll q=1;
    //cin>>q;
    while(q--){

        ll x,y,a,b,c;
        cin>>x>>y>>a>>b>>c;

        pair<ll,int> apples[a+b+c];

        int flag=0;
        ll u;
        REP(i,0,a){
            cin>>u;
            apples[i]=MP(-u,0);
        }
        REP(i,a,a+b){
            cin>>u;
            apples[i]=MP(-u,1);
        }
        REP(i,a+b,a+b+c){
            cin>>u;
            apples[i]=MP(-u,2);
        }

        sort(apples,apples+a+b+c);

        ll rcnt=0;
        ll gcnt=0;
        ll ccnt=0;
        ll sum=0;

        REP(i,0,a+b+c){
            if(apples[i].second==0){
                if(rcnt>=x)continue;
                else{
                    sum+=apples[i].first*-1;
                    rcnt++;
                }
            }
            else if(apples[i].second==1){
                if(gcnt>=y)continue;
                else{
                    sum+=apples[i].first*-1;
                    gcnt++;
                }
            }

            else{
                sum+=apples[i].first*-1;
                ccnt++;
            }

            if((rcnt+gcnt+ccnt)>=(x+y)){
                break;

            }


        }

        cout<<sum<<endl;

    }

return 0;
}


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

using namespace std;

const int size = 2e5+10;
const int INF = 1e9;
long long a[size];
long long b[size];
long long s[size];

int main() {
    //freopen("input.in", "r", stdin);
    //freopen("output.out", "w", stdout);
    int n;
    cin >> n;
    a[0] = 0;
    s[0] = 0;
    b[0] = 0;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
        b[i] = abs(a[i] - a[i-1]);
        s[i] = b[i] + s[i-1];
    }
    a[n+1] = 0;
    b[n+1] = abs(a[n+1] - a[n]);
    s[n+1] = b[n+1] + s[n];
    for (int i = 1; i <= n; i++){
        cout << s[i-1] + abs(a[i-1] - a[i+1]) + s[n+1] - s[i+1] << '\n';
    }
    


    return 0;
}

Measured memory_bytes: 4480
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <istream>
#include <iterator>
#include <sstream>
#include <list>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define assign_if_greater(V, T) V=max(V,T)
using namespace std;
typedef long long ll;
typedef long double ld;

//

//
// inputs
int N;
int C[2*1000*100+10];
//

int main(){
//startmain
//
cout << fixed << setprecision(0);
//
cin >> N;
REP(i,N)
    cin >> C[i];
//
([&](){
    ll MOD=1ll*1000*1000*1000+7;
    ll invalid=-1;
    vector<queue<int>> indices;
    vector<int> nexts;
    nexts.resize(N);
    indices.resize(2*1000*100+10);
    REP(i,N)
        indices[C[i]].push(i);
    REP(i,N) {
        if(indices[C[i]].size()<=1)
            nexts[i]=invalid;
        else {
            indices[C[i]].pop();
            nexts[i]=indices[C[i]].front();
        }
    }
    vector<ll> DP;
    DP.resize(N+10,-1);
    function<ll(int)> solveDP;
    solveDP=[&](int cur){
        if (DP[cur]!=invalid)
            return DP[cur];
        if (cur==N)
            return DP[cur]=1;
        if (nexts[cur]!=invalid && nexts[cur]!=cur+1) {
            return DP[cur]=AS_MOD(solveDP(cur+1) + solveDP(nexts[cur]), MOD);
        } else {
            return DP[cur]=solveDP(cur+1);
        }
    };
    cout << solveDP(0) << endl;
})();
//

return 0;}
//endmain
//

//

//


Measured memory_bytes: 151040
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	queue<pair<string,int> > q;
	q.push(mp(string("01234567"),0));
	map<string,int> res;
	while(q.size()){
		string cur=q.front().first;
		int cur_count=q.front().second;
		q.pop();
		
		if(res.count(cur))
			continue;
		res[cur]=cur_count;
		
		int ci=-1,cj=-1;
		rep(i,8)
			if(cur[i]=='0')
				ci=i/4,cj=i%4;
		int di[]={-1,1,0,0};
		int dj[]={0,0,-1,1};
		rep(i,4){
			int ni=ci+di[i],nj=cj+dj[i];
			if(ni<0 || 2<=ni || nj<0 || 4<=nj)
				continue;
			string temp=cur;
			swap(temp[ci*4+cj],temp[ni*4+nj]);
			q.push(mp(temp,cur_count+1));
		}
	}
	for(string s;getline(cin,s),s.size()==15;){
		s.erase(remove(allof(s),' '),s.end());
		cout<<res[s]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 2220
import java.util.*;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        s = s.replaceAll("C", "A");
        s = s.replaceAll("G", "A");
        s = s.replaceAll("T", "A");

        int ans = 0;

        int now = 0;

        for(String value : s.split("")) {
            if (value.equals("A")) {
                now++;
            } else {
                if (now > ans) {
                    ans = now;
                }
                now = 0;
            }
        }

        if (now > ans) {
            ans = now;
        }

        // 出力
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std; 
int dfs(int n, int s, int x)
{
   int sum=0;
   if(n==0 && s==0)
   return 1;
   if(n>0){
       for(int i=x; i<10; i++){
           if(s-i>=0) sum+=dfs(n-1, s-i, i+1);
       }
   }
   return sum;
}
 int main(void)
{
   int n, s;
   while(cin >> n >> s)
{
       if(n==0 && s==0)
   break;
       cout << dfs(n, s, 0) << endl;
   }
   return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <cmath>
#include <vector>
#include <numeric>
using namespace std;

int main()
{
	int n;
	int max;
	while(cin>>n)
	{
		max = sqrt(1.0*n);
		vector<bool> prime(n+1, true);
		prime[0]=false;
		prime[1]=false;
		for(int i=2; i<=max; ++i)
		{
			if(prime[i])
			{
				for(int j=i*2; j<=prime.size()-1; j+=i)
				{
					prime[j]=false;
				}
			}
		}
		cout << accumulate(prime.begin(), prime.end(), 0) << '\n';
	}
}

Measured memory_bytes: 1020
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000007

using namespace std;
typedef long long ll;

mt19937 mrand(random_device{}());
int rnd(int x) { return mrand() % x; }

template <typename T> void read(T &x) {
  x = 0;
  char c = getchar();
  T sig = 1;
  for (; !isdigit(c); c = getchar())
    if (c == '-')
      sig = -1;
  for (; isdigit(c); c = getchar())
    x = (x << 3) + (x << 1) + c - '0';
  x *= sig;
}

class Solution {
public:
  void solve() {
    int n, d;
    read(n), read(d);
    ll allow = (ll)d * d;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      int x, y;
      read(x), read(y);
      ll dist = (ll)x * x + (ll)y * y;
      if (dist <= allow)
        ans++;
    }
    printf("%d", ans);
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  Solution solution = Solution();
  solution.solve();
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  string tmp = "yuiophjklnm";
  map<char, bool> mp;
  for(int i=0;i<(int)(tmp.size());++i) {
    mp[tmp[i]] = true;
  }
  while(1) {
    string s; cin >> s;
    if(s == "#") break;
    bool right = mp[s[0]];
    int cnt = 0;
    for(int i=1;i<(int)(s.size());++i) {
      if(right != mp[s[i]]) cnt++;
      right = mp[s[i]];
    }
    cout << cnt << endl;
  }
}



Measured memory_bytes: 3192
import java.util.*;

public class Main{

    public static void main(String args[]){

        // スキャナーの宣言
        Scanner sc = new Scanner(System.in);
        // 文字列の入力
        String s = sc.next();
        int fn = Integer.parseInt(s.substring(0, 2));
        int sn = Integer.parseInt(s.substring(2, 4));
        String answer;

        if(fn >= 1 && fn <= 12 && sn >= 1 && sn <= 12){
            answer = "AMBIGUOUS";
        }else if(fn >= 1 && fn <= 12 && !(sn >= 1 && sn <= 12)){
            answer = "MMYY";
        }else if(!(fn >= 1 && fn <= 12) && sn >= 1 && sn <= 12){
            answer = "YYMM";
        }else{
            answer = "NA";
        }

        // 出力
        System.out.println(answer);

    }

}

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

using namespace std;

int main()
{
	int x, y, z;
	cin >> x >> y >> z;
	int a = x - y, b = y - z;
	cin >> x >> y >> z;
	if (a != x - y || b != y - z)
		goto pnz;
	cin >> x >> y >> z;
	if (a != x - y || b != y - z)
		goto pnz;
	cout << "Yes" << endl;
	return 0;
pnz:
	cout << "No" << endl;
	return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(3*n);
    for(int i = 0; i < 3*n; i++) cin >> a[i];
    sort(a.begin(), a.end());
    long long int ans = 0;
    for(int i = 3*n-2; i >= n; i -= 2) ans += a[i];
    cout << ans << endl;
    return 0;
}

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

ll gcd(ll a, ll b) {
  if(a==0) return b;
  if(a>b) return gcd(a%b, b);
  else return gcd(b%a, a);
}
ll lcm(ll a, ll b) {
  ll tmp=gcd(a,b);
  return (a/tmp)*(b/tmp)*tmp;
}

int gcd(int a, int b) {
  if(a==0) return b;
  if(a>b) return gcd(a%b, b);
  else return gcd(b%a, a);
}
int lcm(int a, int b) {
  int tmp=gcd(a,b);
  return (a/tmp)*(b/tmp)*tmp;
}

int  main(){
  ll a,b;
  cin >> a >> b;
  cout << gcd(a,b) << endl;
}



Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
char s[111111];
int ls;
bool chk(){
	while(ls){
		if(ls >= 7){
			if(
			s[ls-7] == 'd' &&
			s[ls-6] == 'r' &&
			s[ls-5] == 'e' &&
			s[ls-4] == 'a' &&
			s[ls-3] == 'm' &&
			s[ls-2] == 'e' &&
			s[ls-1] == 'r'){
				ls -= 7;
				continue;
			}
		}
		if(ls >= 6){
			if(
			s[ls-6] == 'e' &&
			s[ls-5] == 'r' &&
			s[ls-4] == 'a' &&
			s[ls-3] == 's' &&
			s[ls-2] == 'e' &&
			s[ls-1] == 'r'){
				ls -= 6;
				continue;
			}
		}
		if(ls >= 5){
			if(
			s[ls-5] == 'd' &&
			s[ls-4] == 'r' &&
			s[ls-3] == 'e' &&
			s[ls-2] == 'a' &&
			s[ls-1] == 'm' ||
			s[ls-5] == 'e' &&
			s[ls-4] == 'r' &&
			s[ls-3] == 'a' &&
			s[ls-2] == 's' &&
			s[ls-1] == 'e'){
				ls -= 5;
				continue;
			}
		}
		return false;
	}
	return true;
}
int main(){
	scanf("%s",s);
	ls = strlen(s);
	puts(chk()?"YES":"NO");
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=8000;
const long INF=1e9;
int main(){
	int A,B;cin>>A>>B;
	if(A<10&&B<10) cout<<A*B<<endl;
	else cout<<-1<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int res = 0;
		for(int i = 0; i < n; i++){
			int pos = sc.nextInt();
			int tmp = 2 * pos;
			int tmp2 = Math.abs(2 * (pos - k));
			if(tmp > tmp2){
				res += tmp2;
			}else{
				res += tmp;
			}
		}
		System.out.println(res);

 	}
}




Measured memory_bytes: 35972
// Problem : B - Tag
// Contest : AtCoder - Tokio Marine & Nichido Fire Insurance Programming Contest 2020
// URL : https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

ll a,v,b,w,t;


int main() {
    ios::sync_with_stdio(false);cin.tie(0);
	cin>>a>>v>>b>>w>>t;
	if(a<b){
		if(a+v*t>=b+w*t) cout<<"YES";
		else  cout<<"NO";
	}
	else{
		if(a-v*t<=b-w*t) cout<<"YES";
		else  cout<<"NO";
	}


    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
//#include <boost/lexical_cast.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pb push_back
#define mp make_pair
#define endl '\n'
#define PI acos(-1)
#define P pair<int,int>
typedef tree<int,null_type,less_equal <int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

long mod=1e9+7;
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int a,b;
	cin>>a>>b;
	if(a>=13)
		cout<<b;
	else if(a>=6&&a<=12)
		cout<<b/2;
	else
		cout<<0;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int[] prime;
    static int n;

    public static void main(String[] args) {
        while(read()){
            slove();
        }
    }
    static boolean read(){
        if(!sc.hasNextInt())
            return false;
        n = sc.nextInt();
        return true;
    }
    static void Prime(int a){
        prime = new int[a+1];
        for(int i = 2; i < prime.length; i++)prime[i] = 1;

        for(int i = 2; i < prime.length; i++){
            if(prime[i] == 1){
                for(int j = i*2; j < prime.length; j+= i)
                    prime[j] = 0;
            }
        }
    }

    static void slove(){
        int res = 0;
        Prime(n);
        for(int i = 2; i < prime.length; i++){
            if(prime[i] == 1)
                res++;
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 20000
#include<stdio.h>
void swap(int *a,int *b){
	int temp=*a;
	*a=*b;
	*b=temp;
}

int main(){
	int x,y,t;
	for(int i=0;i<3000;i++){
		scanf("%d %d",&x,&y);
		if(x==0&&y==0)break;
		if(x>y){
			swap(&x,&y);
		}
		printf("%d %d\n",x,y);
	}
	return 0;
}


Measured memory_bytes: 2736
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

/*
 *vector<int>::iterator it1 = lower_bound(data.begin(),data.end(),7);
 *vector<int>::iterator it2 = upper_bound(data.begin(),data.end(),7);
 */

using namespace std;


long long cal(string S, long long bit){
	long long ret = 0;
	long long start = 0;

	for(long long i = 0; i < (S.size()-1); i++){
		if((bit>>i) & 1){
			long len;
			len = (i-start+1);
			ret += atol(S.substr(start, len).c_str());
			start = i+1;
		}
	}
	ret += atol(S.substr(start).c_str());
	return ret;
}

int main(){
	string S;
	cin >> S;
	long long ans = 0;
	for(long long bit = 0; bit < ((long long)1<<(S.size()-1)); bit++){
		ans += cal(S, bit);
	}
	//cout << hist.size() << endl;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<math.h>

using namespace std;

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

	int n;
	string ans;
	cin >> n;
	if(n < 1000) ans = "ABC\n";
	else		ans = "ABD\n";

	cout << ans; 
				
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int a,b,o,ab,n;
  char c[]={'p','p'};
  a=b=o=ab=0;
  while(scanf("%d,%s",&n,c) != EOF){
    if(c[0]=='A' && c[1]!='B'){
      a++;
    }
    else if(c[0]=='B'){
      b++;
    }
    else if(c[0]=='O'){
      o++;
    }
    else if(c[0]=='A' && c[1]=='B'){
      ab++;
    }
    c[0]=c[1]='p';
  }
  printf("%d\n%d\n%d\n%d\n",a,b,ab,o);
  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
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 long long INF = 1LL << 60;
const int inf = 1001001001;
 
int main(){

    ll a;
    double b;
    cin >> a >> b;
    ll c=b*100+0.1;
    cout << a*c/100 << endl; 
}


Measured memory_bytes: 3676
//minamoto
#include<bits/stdc++.h>
#define R register
#define pb emplace_back
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=2e5+5;
struct eg{int v,nx;}e[N<<1];int head[N],tot;
inline void add(R int u,R int v){e[++tot]={v,head[u]},head[u]=tot;}
vector<int>t1[N],t2[N];
int a1[N],a2[N],st[N],b[N],rt1,rt2;
int n,top;
void dfs1(int u){
	for(auto v:t1[u])dfs1(v);
	if(a1[u])st[++top]=u;
	while(top>=2){
		add(st[top],st[top-1]),add(st[top-1],st[top]);
		top-=2;
	}
}
void dfs2(int u){
	for(auto v:t2[u])dfs2(v);
	if(a2[u])st[++top]=u;
	while(top>=2){
		add(st[top],st[top-1]),add(st[top-1],st[top]);
		top-=2;
	}
}
void dfs(int u,int c){
	b[u]=c;
	go(u)if(!b[v])dfs(v,-c);
}
int main(){
	scanf("%d",&n);
	fp(i,1,n)a1[i]=a2[i]=1;
	for(R int i=1,fa;i<=n;++i){
		scanf("%d",&fa);
		if(fa==-1)rt1=i;else t1[fa].pb(i),a1[fa]^=1;
	}
	for(R int i=1,fa;i<=n;++i){
		scanf("%d",&fa);
		if(fa==-1)rt2=i;else t2[fa].pb(i),a2[fa]^=1;
	}
	fp(i,1,n)if(a1[i]!=a2[i])return puts("IMPOSSIBLE"),0;
	puts("POSSIBLE");
	top=0,dfs1(rt1);
	top=0,dfs2(rt2);
	fp(i,1,n)if(a1[i]&&!b[i])dfs(i,1);
	fp(i,1,n)printf("%d ",b[i]);
	return 0;
}

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

long long int a[200001],tmp[200001];
long long int ans=0;
void mergesort(int l,int r){
	if(l==r)	return;
	int mid=(l+r)/2;
	mergesort(l,mid);mergesort(mid+1,r);
	int lcnt=l,rcnt=mid+1,cnt=0;
	while(lcnt<=mid&&rcnt<=r){
		if(a[lcnt]<=a[rcnt]){
			ans+=r-rcnt+1;
			tmp[cnt++]=a[lcnt++];
		}
		else
			tmp[cnt++]=a[rcnt++];
	}
	while(lcnt<=mid)
		tmp[cnt++]=a[lcnt++];
	while(rcnt<=r)
		tmp[cnt++]=a[rcnt++];
	for(int i=l;i<=r;i++)
		a[i]=tmp[i-l];
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		a[i]=a[i]+a[i-1]-k;
	mergesort(0,n);
	cout<<ans<<endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define endl "\n"
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 2e+9 + 10;
typedef pair<ll, ll> P;

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

  ll H,W; cin >> H>>W;
  if (H==1 || W==1) {
    cout << 1 << endl;
    return 0;
  }

  ll res = H*W;
  
  if(res%2==0)cout << res/2<< endl;
  else cout << res/2+1<<endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())


def main(n):
    prime = [0 for _ in range(n + 1)]
    for i in range(2, n + 1):
        for j in range(2, n + 1):
            if j > i:
                break
            while i % j == 0:
                i //= j
                prime[j] += 1
    e2 = 0
    e4 = 0
    e14 = 0
    e24 = 0
    e74 = 0
    for i in range(2, n + 1):
        if prime[i] >= 2:
            e2 += 1
        if prime[i] >= 4:
            e4 += 1
        if prime[i] >= 14:
            e14 += 1
        if prime[i] >= 24:
            e24 += 1
        if prime[i] >= 74:
            e74 += 1
    ret = e74
    if e2 > 2 and e4 > 1:
        ret += e4 * (e4 - 1) // 2 * (e2 - 2)
    if e4 > 1 and e14 > 0:
        ret += e14 * (e4 - 1)
    if e2 > 0 and e4 > 0:
        ret += e24 * (e2 - 1)

    return ret


if __name__ == '__main__':
    print(main(n))

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}
struct edge {
    ll to, cost;
};

int N;
vector<vector<edge>> tree;
vector<int> ans;
vector<bool> flag;
void dfs(int i) {
  flag[i] = true;
  for(int k = 0; k < tree[i].size(); ++k) {
    if(flag[tree[i][k].to] == false) {
      if(tree[i][k].cost % 2 == 0) {
        ans[tree[i][k].to] = ans[i];
      } else {
        ans[tree[i][k].to] = 1 - ans[i];
      }
      dfs(tree[i][k].to);
    }
  }
}

int main() {
  cin >> N; tree.resize(N + 1); ans.resize(N + 1); flag.resize(N + 1, false);
  REP(i, N - 1) {
    ll a, b, c; cin >> a >> b >> c;
    edge e1 = {b, c};
    tree[a].push_back(e1);
    edge e2 = {a, c};
    tree[b].push_back(e2);
  }
  dfs(1);
  for(int i = 1; i <= N; ++i) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 12272
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <iomanip>
#include <cstdlib>
using namespace std;

int main() {
    int n, d;
    cin >> n >> d;
    if (n % (d * 2 + 1) == 0) {
        cout << n / (d * 2 + 1) << endl;
    }
    else cout << n / (d * 2 + 1) + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <utility>
#include <vector>


int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);
    int n; std::cin >> n;
    if(n >= 30) std::cout << "Yes\n"; else std::cout << "No\n";
    
    return 0;
}

Measured memory_bytes: 3648
N = input()
X = input().split()
total1 = 0
total2 = 0
for i in X:
    i = int(i)
    total1 += 1
    total2 += i
total2 *= 2
total1 *= 2
min = total2/total1
if min >= 1:
    if min%int(min) >=0.5:
        min = int(min) + 1
    elif min%int(min) == 0 :
        min = int(min)
    else:
        min = int(min) 
else:
    min = 1


sum = 0
for i in X:
    i  = int(i)
    sum += (min-i)*(min-i)
print(sum,end="")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ull = uint64_t;
using ll = int64_t;
using ld = long double;

int main() {
//    freopen("in.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.setf(ios::fixed);
    cout.precision(20);

    int n;cin >> n;
    ll x;cin >> x;
    vector<ll> a(n);

    for (ll& v: a) {
        cin >> v;
    }

    sort(a.begin(), a.end());
    ll ans = 0, s = 0;
    for (ll& v: a) {
        s += v;
        ans += s <= x;
    }

    ans -= s < x;
    cout << ans << "\n";
}




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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    if (h < w) swap(h, w);

    int ans = (n + h - 1) / h;
    cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Main main = new Main();
		main.solveB();
	}

	private void solveB() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		int[] num = new int[N + 1];
		for (int i = 0; i < M; i++) {
			num[sc.nextInt()]++;
			num[sc.nextInt()]++;
		}
		for (int j = 1; j <= N; j++) {
			System.out.println(num[j]);
		}
	}
}

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

int main() {
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n);
  vector<int> b(m);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  for (int i = 0; i < m; i++) {
    cin >> b.at(i);
  }
  
  long long t = 0;
  for (int i = 0; i < m; i++) {
    t += b.at(i);
  }
  int j = m;
  int ans = 0;
  for (int i = 0; i < n + 1; i++) {
    while (j > 0 && t > k) {
      j--;
      t -= b.at(j);
    }
    if (t > k) break;
    ans = max(ans, i + j);
    if (i == n) break;
    t += a.at(i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4808
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int n,x[105],ans=0x3f3f3f3f;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>x[i];
	for(int i=1;i<=100;i++){
		int s=0;
		for(int j=1;j<=n;j++)s+=(x[j]-i)*(x[j]-i);
		ans=min(ans,s);
	}
	cout<<ans;
}

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> S(N + 1);
    {
        string s;
        cin >> s;
        for(unsigned long i{0}; i < N; ++i)S[i + 1] = S[i] + (s[i] == 'W');
    }
    unsigned long ans{numeric_limits<unsigned long>::max()};
    for(unsigned long i{0}; i <= N; ++i){
        unsigned long w{S[i]}, r{N - i - S.back() + S[i]};
        ans = min(ans, 2 * max(w, r) - min(w, r));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5220
def gcd(x, y):
    if x > y:
        return gcd(y, x)
    if y % x == 0:
        return x
    else:
        return gcd(y % x, x)


def main():
    x, y = map(int, input().split())
    print(gcd(x,y))

if __name__ == "__main__":
    main()

Measured memory_bytes: 7692
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <stdint.h>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

#define REP(i,f,n) for(int i=(f); i < (n); ++i)
#define PER(i,f,n) for(int i=(n-1); i >= f; --i)

constexpr int evx[4] = { 1, 0, -1, 0 };
constexpr int evy[4] = { 0, 1, 0, -1 };

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

signed main()
{
    ios::sync_with_stdio(false);
	int n;
	cin >> n;
	REP(i, 0, n)
	{
		array<int, 3> a;
		cin >> a[0] >> a[1] >> a[2];
		sort(a.begin(),a.end());
		cout << (a[2] * a[2] == a[1] * a[1] + a[0] * a[0]
				? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 3176
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

char c[301][301];
int dp[301][301];
int dp2[301][301];
int g(int a,int b,int j){
	if(dp2[a][b]>=0){
		return dp2[a][b];
	}
	if(a==0||b==0){
		return dp2[a][b]=0;
	}
	int r=0;
	if(c[a-1][j]==c[b-1][j+1]){
		r++;
	}
	return dp2[a][b]=r+g(a-1,b-1,j);
}
int f(int a,int b,int j){
	if(dp[a][b]>=0){
		return dp[a][b];
	}
	if(a==0||b==0){
		return dp[a][b]=0;
	}
	return dp[a][b]=min(f(a-1,b,j),f(a,b-1,j))+g(a,b,j);
}
int main() {
	int H,W;
	cin >> H >> W;
	for(int i=0;i<H;i++){
		cin >> c[i];
	}
	int ret=0;
	for(int i=0;i+1<W;i++){
		memset(dp,-1,sizeof(dp));
		memset(dp2,-1,sizeof(dp2));
		ret+=f(H,H,i);
	}
	cout << ret << endl;


	return 0;
}



Measured memory_bytes: 1656
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <set>
#include <vector>
#include <functional>
#include <map>
#include <queue>
using namespace std;
int n;
long long sum[200001],Xor[200001];
int main()
{
  cin>>n;
  for (int i=0;i<n;i++)
  {
    int x;
    cin>>x;
    sum[i+1]=(sum[i]+x);
    Xor[i+1]=(Xor[i]^x);
  }
  long long res=0;
  for (int i=0;i<n;i++)
  {
    int hi=n-1,lo=i;
    while (hi>=lo)
    {
      int mid=(hi+lo)/2;
      if ((sum[mid+1]-sum[i])>(Xor[mid+1]^Xor[i])) 
        hi=mid-1;
      else 
        lo=mid+1;
    }
    res+=(hi+1-i);
  }
  cout<<res<<endl;
  //system("pause");
  return 0;
}

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

int main() {
  int N,T,A;
  cin >> N >> T >> A;
  
  vector<int>H(N);
  vector<double>temp(N);
  vector<double>dis(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
    temp.at(i) = T - H.at(i)*0.006;
    if (A > temp.at(i)){
      dis.at(i) = A - temp.at(i);
    }
    else {
      dis.at(i) = temp.at(i) - A;
    }
  }
  
  for (int i = 0; i < N; i++) {
    for (int j = i; j < N; j++) {
      if (dis.at(i) > dis.at(j)){
        break;
      }
      else if (j == N - 1){
        cout << i + 1 << endl;
        i = N;
        break;
      }
    }

  }
}



Measured memory_bytes: 384
X, Y, Z, K = map(int, input().split())

A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))
C_list = list(map(int, input().split()))

val_list = []


A_list = sorted(A_list, reverse=True)
B_list = sorted(B_list, reverse=True)
C_list = sorted(C_list, reverse=True)

#print(A_list)
#print(B_list)
#print(C_list)

for a in range(len(A_list)):
    if a + 1 > K:
        break
    for b in range(len(B_list)):
        if b + 1 > K:
            break
        if (a+1) * (b+1) > K:
            break
            
        for c in range(len(C_list)):
            if c + 1 > K:
                break
            if (a+1) * (b+1) * (c+1) > K:
                break
        
            val_list.append(A_list[a] + B_list[b] + C_list[c])

val_list = sorted(val_list, reverse=True)
for i in range(K):
    print(val_list[i])

    


            


Measured memory_bytes: 9568
#include<bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
#define REP(i,y) for(int i=0; i<y; ++i)
int INF = 1<<30, N;
vector<vi> X(18, vi(2));
vi V_(18), V(18), Vb(18);
inline int search(int F){
  if(__builtin_popcount(F)&1) return INF;
  REP(i,N){
    V_[i] = V[i] = X[i][F%2];
    Vb[i] = F%2;
    F>>=1;
  }
  sort(V.begin(), V.begin()+N);
  int ans = 0;
  REP(i,N){
    for(int j=i; j<N; ++j){
      if(!(V[i]==V_[j] && (j-i+Vb[j])%2==0)) continue;
      ans += j-i;
      for(int k=j-1; k>=i; --k){
        V_[k+1] = V_[k];
        Vb[k+1] = Vb[k]+1;
      }
      goto END;
    }
    return INF;
END:
    continue;
  }
  return ans;
}
int main(){
  cin >> N;
  REP(i,N) cin >> X[i][0];
  REP(i,N) cin >> X[i][1];
  int ans=INF;
  REP(i,1<<N) ans = min(ans, search(i));
  cout << (ans==INF?-1:ans) << endl;
  return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] b = new int[n+1];

    for (int i = 1; i < n; i++) {
      b[i] = sc.nextInt();
    }

    b[n] = b[n-1];
    
    int ans = b[1];
    for (int i = 2; i <= n; i++) {
      ans += Math.min(b[i-1], b[i]);
    }
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 23892
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;


int main(void)
{
	int N; cin >> N;
	int sum = 0; 
	vector<int> T(N);
	rep(i, 0, N) {
		cin >> T[i];
		sum += T[i];
	}

	int M; cin >> M;
	vector<pair<int, int>> PX(M);
	rep(i, 0, M)cin >> PX[i].first >> PX[i].second;

	rep(i, 0, M) {
		cout << sum - T[PX[i].first - 1] + PX[i].second << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>

#define mp make_pair
#define x first
#define y second
#define pb push_back
using namespace std;

const int N = 105;
int n, a[N], sum;

int main()
{
    cin >> n;
    for(int i=1; i<n; ++i) cin >> a[i];
    a[0] = a[1]; a[n] = a[n-1];
    for(int i=1; i<=n; ++i) sum += min(a[i], a[i-1]);
    cout << sum;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N;

    cin >> N;
    
    vector<int> A(N), temp_A(N);

    for (int i = 0; i < N; i++){
        int v;
        cin >> v;
        A[i] = v;
        temp_A[i] = v;
    }
    
    sort(temp_A.begin(), temp_A.end());
    
    int largest = temp_A[temp_A.size() - 1];
    int second_largest = temp_A[temp_A.size() - 1];
    if (temp_A.size() > 1){
        second_largest = temp_A[temp_A.size() - 2];
    }

    // vector<int> index_largest;

    for (int i = 0; i < N; i++){
        if (A[i] == largest){
            // index_largest.push_back(i);
            cout << second_largest << endl;
        }
        else{
            cout << largest << endl;
        }
    }
}


Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] bossInfo = new int[n +1];
		for(int i =0;i <n-1;i++) {
			bossInfo[sc.nextInt()]++;
		}
		for(int i =1;i <=n;i++) {
			System.out.println(bossInfo[i]);
		}
	}
}

Measured memory_bytes: 57692
#include <iostream>

using namespace std;
int par[100010],sz[100010];

void init(int n){
	for(int i=0;i<n;i++){
		par[i] = i; sz[i] = 1;
	}
}

int find(int x){
	if(par[x]==x) return x;
	return par[x] = find(par[x]);
}

void unite(int x, int y){
	x = find(x); y = find(y);
	if(x==y) return;
	if(sz[x]>sz[y]) swap(x,y);
	par[x] = y;
	sz[y] += sz[x];
}

bool same(int x, int y){
	return find(x)==find(y);
}

int main(){
    int i,n,m; cin >> n >> m;
    init(n);
    for(i=0;i<m;i++){
        int x,y; cin >> x >> y; x--; y--;
        unite(x,y);
    }
    int s = 0;
    for(i=0;i<n;i++){
        if(find(i)==i) s++;
    }
    cout << s - 1 << endl;
}

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

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

using namespace std;

int main(){
	int r,d;
	long long x; cin>>r>>d>>x;
	rep(i,10){
		x=r*x-d;
		cout<<x<<endl;
	}

	return 0;
}


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

using namespace std;

int main(){
    long long n, ans = 0;
    cin >> n;
    vector<long long> a(n);
    for(int i = 0; i < n; i++){
        long long in;
        cin >> in;
        a[i] = in - i - 1;
    }
    sort(a.begin(), a.end());
    long long dt = -1 * a[n / 2];
    for(int i = 0; i < n; i++){
        ans += abs(a[i] + dt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
void InsertionSort(int N, vector<int>& A) {
	for (int i = 1; i < N; i++) {
		if (A.at(i - 1) > A.at(i)) {
			int tmp = A.at(i);
			int j = i;
			while (j > 0) {
				if (A.at(j - 1) <= tmp) break;
				A.at(j) = A.at(j - 1);
				j--;
			}
			A.at(j) = tmp;
		}
		for (int k = 0; k < N; k++) {
			cout << A.at(k);
			if (k != N - 1) cout << ' ';
		}
		cout << endl;
	}
}
int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	for (int i = 0; i < N; i++) {
		cin >> A.at(i);
		cout << A.at(i);
		if (i != N - 1) cout << ' ';
	}
	cout << endl;
	InsertionSort(N, A);
}


Measured memory_bytes: 3092
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int l = sc.nextInt();
        int[][] a = new int[n][m];
        int[][] b = new int[m][l];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                a[i][j] = sc.nextInt();
            }
        }
        for(int i = 0; i < m; i++){
            for(int j = 0; j < l; j++){
                b[i][j] = sc.nextInt();
            }
        }
        for(int i = 0; i < n; i++){
                for(int k = 0; k < l; k++){
                	long ans = 0;
                	for(int j = 0; j < m; j++){
                    ans += (a[i][j]*b[j][k]);
                }
                	System.out.print(ans);
                	
                	if(k < l-1) {
                		System.out.print(" ");
                	}
            }
            System.out.println("");
        }
    }
}


Measured memory_bytes: 54652
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
		}

		Arrays.sort(a);
		int count = 0;
		for (int i = 0; i < n; i++) {
			int idx = i + 1;
			for (int j = 0; j < i; j++) {
				int ab = a[i] + a[j];
				while (idx < n && a[idx] < ab) idx++;
				count += Math.max(0, idx - i - 1);
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 25644
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S; cin >> S;
	REP(i, 3) {
		if (S[i] == '1')cout << '9';
		else if (S[i] == '9')cout << 1;
		else cout << S[i];
	}
	cout << endl;
}


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

int main(){
    int r,g,b;
    cin >> r >> g >> b;
    int num = r*100+g*10+b;
    if(num%4==0){
        cout << "YES\n";
    }else{
        cout << "NO\n";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>

int main()
{
long long int n;
std::vector<long long int> a;
std::cin >> n;
for(long long int i = 0; i < 3 * n; i++){
    long long int aa;
    std::cin >> aa;
    a.push_back(aa);
}
std::sort(a.begin(), a.end());
long long int count = 0;
for(long long int i = n; i < 3 * n; i += 2){
    count += a[i];
}
std::cout << count << std::endl;
return 0;
}

Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const long long INF = 1e18;
int n;

int main() {
    cin >> n;
    vector< vector<int> > F(n, vector<int>(10, 0));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < 10; ++j) {
            cin >> F.at(i).at(j);
        }
    }

    vector< vector<long long> > P(n, vector<long long>(11, 0));
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < 11; ++j) {
            cin >> P.at(i).at(j);
        }
    }

    long long mans = -INF;
    for(int bit = 1; bit < (1<<10); ++bit) {
        vector<int> flg(10, 0);
        for(int i = 0; i < 10; ++i) {
            if(bit & (1<<i)) flg.at(i) = 1;
        }

        long long sum = 0;
        for(int i = 0; i < n; ++i) {
            int icnt = 0;
            for(int j = 0; j < 10; ++j) {
                if(flg.at(j) == F.at(i).at(j)) {
                    if(flg.at(j) == 1) icnt++;
                }
            }
            sum += P.at(i).at(icnt);
        }
        chmax(mans, sum);
    }

    cout << mans << endl;
}

Measured memory_bytes: 256
n, k = map(int,input().split())
x = n
d = set(map(str,input().split()))
can_use = {str(i) for i in range(10)} ^ d
s_can_use = sorted(list(can_use))
for i in range(10**6):
    if set(list(str(x))) | can_use == can_use:
        print(n)
        break
    else:
        n += 1
        x = n

Measured memory_bytes: 3060
import numpy as np
N,M = map(int,input().split())
A = np.array([list(input()) for n in range(N)])
B = np.array([list(input()) for m in range(M)])
a = "No"
 
for i in range(N-M+1):
  for j in range(N-M+1):
    if (A[i:i+M,j:j+M]==B).all():
      a = "Yes"

print(a)

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

using Tup = tuple<ll, ll, ll>;

void solve() {
    ll N;
    cin >> N;
    vector<Vl> dist(N, Vl(N));
    for (ll i = 0; i < N; i++) {
        for (ll j = 0; j < N; j++) {
            cin >> dist[i][j];
        }
    }

    bool ok = true;
    ll ans = 0;

    for (ll i = 0; i < N; i++) {
        for (ll j = i + 1; j < N; j++) {
            ll mn = L_INF;
            for (ll k = 0; k < N; k++) {
                if (k == i || k == j) continue;
                mn = min(mn, dist[i][k] + dist[k][j]);
            }
            if (mn < dist[i][j]) {
                ok = false;
                break;
            }
            else if (mn > dist[i][j]) {
                ans += dist[i][j];
            }
        }
    }

    if (ok) {
        cout << ans << "\n";
    }
    else {
        cout << -1 << "\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;
import java.util.*;
import java.lang.*; 
import java.util.regex.Pattern;
import java.text.DecimalFormat;
import java.util.stream.IntStream;
public class Main{ 
static int isOn(int S, int j) { return S & (1 << j); }
static int a,b,c;
static int[] dp=new int[4010];
static final int INF=1000000;
static boolean[] prime=new boolean[1000100]; 
public static void main(String[] args)
{ 
Scanner scanner=new Scanner(System.in);
int a=scanner.nextInt();
int b=scanner.nextInt();
if(a>=13)
System.out.println(b);
if(a>=6 && a<=12)System.out.println(b/2);
if(a<=5) System.out.print(0);
}
}


Measured memory_bytes: 23892