akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define int ll
typedef pair<int,int> pii;
#define fi first
#define se second
#define Sort(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/4
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
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 int MOD = 998244353;
const int MOD = 1000000007;


/*----------------------------------------------------------------*/
signed main(){

	int a,b,x;
	cin >> a >> b >> x;

	if(a == 0)cout << b/x + 1;
	else cout << b/x - (a-1)/x << endl;

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=gnu++17 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2017-qualb.contest.atcoder.jp/tasks/code_festival_2017_qualb_b
// rm -r -f test;oj dl https://abc048.contest.atcoder.jp/tasks/abc048_b


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int N;
string S;

int main(){
    cin>>N>>S;

    int ans=1;
    char s=S[0];
    for(int i=1;i<N;i++){
        if(s!=S[i]){
            ans++;
        }
        s=S[i];
    }

    cout<<ans;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
        ios::sync_with_stdio(0);
        cin.tie(0);
        long long x,k,d;
        cin>>x>>k>>d;
        if((abs(x/d)>k) || (abs(x/d)==k && abs(x)%d ==0))
        {
                cout<<(abs(x)-(k*d));
        }
        else
        {
                long long c = abs(x)%d;
                k = k-(abs(x)/d);
                if(c > d/2 && k>=1)
                {
                        c-=d;
                        k--;
                        c = abs(c);
                }
                if(k%2==0)
                        cout<<c;
                else
                        cout<<abs(c-d);
        }
return 0;
}



Measured memory_bytes: 3644
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> x = new ArrayList<>();
        for(int i = 0;i < n;i++){
            x.add(sc.nextInt());
        }
        int min = 0;
        for(int i = 0;i < n;i++){
            if(x.get(i) <= k - x.get(i)){
                min += x.get(i)*2;
            }
            else{
                min += (k - x.get(i))*2;
            }
        }
        System.out.println(min);
    }
}


Measured memory_bytes: 21844
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int x, y;
	cin >> x >> y;
	long long ans = 0;
	if(x == 1) ans += 300000;
	if(x == 2) ans += 200000;
	if(x == 3) ans += 100000;
	if(y == 1) ans += 300000;
	if(y == 2) ans += 200000;
	if(y == 3) ans += 100000;
	if(x == 1 && y == 1) ans += 400000;
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A,B,C;
    cin >> A >> B >> C;
    int ans;
    if(A-B<C){
        ans = C-(A-B);
        
    }else{
        ans = 0;
        
    }
    
    cout << ans << endl;
}


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

int main(void)
{
    int W, a, b;
    cin >> W >> a >> b;

    if(b > a+W)
        cout << b-(a+W) << endl;
    else if(a > b+W)
        cout << a-(b+W) << endl;
    else
        cout << 0 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using pll=pair<ll,ll>;
using plll=pair<ll,pll>;
using graph=vector<vector<int>>;

const ll MOD=1000000007;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

ll abs1(ll a){
  if(a>=0)return a;
  else return -a;
}

ll pow1(ll a,ll b,ll p=LLONG_MAX){
  ll ret=1;
  while(b!=0){
    if((b&1)==1){
      ret*=a;
    }
    a*=a;
    if(a>=p)a%=p;
    b=b>>1;
  }
  return ret;
}

int digit(ll a,ll b){
  int i=0;
  while(a!=0){
    a/=b;
    i++;
  }
  return i;
}

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modInv(ll a,ll p=MOD){
  a%=p;
  ll n=solveLinear(a,p,1);
  n%=p;
  if(n<0)return n+p;
  return n;
}

ll fact(ll n,ll p=MOD){
  if(n<0)return 0;
  int i;
  ll ret=1;
  for(i=0;i<n;i++){
    ret=ret*(i+1);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll perm(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    if(ret>=p)ret%=p;
  }
  return ret;
}

ll binom(ll n,ll k,ll p=MOD){
  if(n<0 || k<0 || n<k)return 0;
  int i;
  ll ret=1,fact=1;
  for(i=0;i<k;i++){
    ret=ret*(n-i);
    fact*=i+1;
    if(ret>=p)ret%=p;
    if(fact>=p)fact%=p;
  }
  return (ret*modInv(fact))%p;
}

void pushHeap(vector<int>& h,int n){
  int i=h.size();
  h.push_back(n);
  while(i!=0 && h[(i-1)/2]<h[i]){
    swap(h[i],h[(i-1)/2]);
    i=(i-1)/2;
  }
  h[i]=n;
}

int popHeap(vector<int>& h){
  int n=h.size()-1;
  if(n==-1)return 0;
  int i,ret=h[0];
  swap(h[0],h[n]);
  h.pop_back();
  for(i=0;i<n;){
    int j=2*i+1;
    if(j>=n)break;
    if(j!=n-1 && h[j]<h[j+1])j++;
    if(h[i]<h[j]){
      swap(h[i],h[j]);
    }
    i=j;
  }
  return ret;
}

vector<int> ver;
void dfs(const graph &g,int v){
  ver[v]=1;
  for(auto i:g[v]){
    if(ver[i]!=1)continue;
    dfs(g,i);
  }
}

int main(){
  int i,j,k,cnt=0;
  int n;
  cin>>n;
  int p[n];
  for(i=0;i<n;i++)cin>>p[i];
  vector<pll> v;
  for(i=0;i<n;i++){
    v.push_back(pll(p[i],i));
  }
  sort(v.begin(),v.end());
  int ma=0;
  for(i=1;i<n;i++){
    if(v[i-1].second<v[i].second){
      cnt++;
    }else{
      ma=max(ma,cnt);
      cnt=0;
    }
  }
  ma=max(ma,cnt);
  /*j=n;
  for(i=n-1;i>=0;i--){
    if(p[i]==j){
      cnt++;
      j--;
    }
  }
  int mi=n-cnt;
  j=1;cnt=0;
  for(i=0;i<n;i++){
    if(p[i]==j){
      cnt++;
      j++;
    }
  }*/
  cout<<n-ma-1<<endl;
}

Measured memory_bytes: 6896
#include <cstdio>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
#include <functional>

using namespace std;

class Edge{
public:
	int from,to,cost;
	Edge(){}
	Edge(int _from,int _to,int _cost){
		from = _from;
		to = _to;
		cost = _cost;
	}
};

int n,m,k;
int dk[3000];

typedef pair<int,int> intpair;
priority_queue<intpair,vector<intpair>,greater<intpair> > q;

const int INF = 10000000;

vector<Edge> r[3000];
vector<Edge> roads;

int solve(){
	while(!q.empty()){
		intpair p = q.top(); q.pop();
		int v = p.second;
		if(dk[v] < p.first){continue;}
		for(int i=0;i<r[v].size();i++){
			Edge edge = r[v][i];
			if(dk[edge.to] > dk[v] + edge.cost){
				dk[edge.to] = dk[v] + edge.cost;
				q.push(intpair(dk[edge.to],edge.to));
			}
		}
	}
	int max = 0;
	double a,b;
	int c;
	for(int i=0;i<roads.size();i++){
		Edge ed = roads[i];
		a = dk[ed.from];
		b = dk[ed.to] + ed.cost;
		c = (a + b + 1) / 2;
		//printf("%d)%d<-(%d)->%d(%d : %d\n",dk[ed.from],ed.from,ed.cost,ed.to,dk[ed.to],c);
		if(max < c){max = c;}
	}
	//printf("%d\n",max);
	//printf("%d:%d\n",p,a);
	return max;
}

int main(){
	scanf("%d %d %d",&n,&m,&k);
	int a,b,c;
	for(int i=0;i<m;i++){
		scanf("%d %d %d",&a,&b,&c);
		a--;b--;
		r[a].push_back(Edge(a,b,c));
		r[b].push_back(Edge(b,a,c));
		roads.push_back(Edge(a,b,c));
	}
	fill(dk,dk+3000,INF);
	for(int i=0;i<k;i++){
		scanf("%d",&a);
		a--;
		dk[a] = 0;
		q.push(intpair(0,a));
	}	
	printf("%d\n",solve());
}

Measured memory_bytes: 6208
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
void solve(){       
	int n, m, a[108000];
	vector<int> res;
	cin >> n >> m;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		if(i)res.push_back(a[i] - a[i-1]);
	}
	sort(res.begin(), res.end(), greater<int>());
	int ans = a[n-1] - a[0];
	for(int i = 0;i < m - 1 && i < res.size();i++)ans -= res[i];
	cout << ans << endl;
}

int main(){
	int t;
	cin >> t;
	while(t--)solve();
	return 0;
}

Measured memory_bytes: 2476
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#define ll long long int
#define MOD 1000000007LL
using namespace std;

int main() {
    int n;
    cin>>n;
    ll tt=1;
    ll aa=1;
    for(int i=0;i<n;i++){
        ll t,a;
        cin>>t>>a;
        ll ttt,aaa;
        if(tt%t==0){
            ttt=tt/t;
        }else{
            ttt=tt/t+1;
        }
        if(aa%a==0){
            aaa=aa/a;
        }else{
            aaa=aa/a+1;
        }
        tt=max(ttt,aaa)*t;
        aa=max(ttt,aaa)*a;
    }
    cout<<tt+aa<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

ll a,b,c,k;
void input(){
    fast_io();
    cin >> a >> b >> c >> k;
}

int solve(){
    ll ans = 0;
    if(k<a) ans = k;
    else if(k<=(a+b)) ans = a;
    else{
        ans = a-(k-a-b);
    }
    cout << ans << endl;
    return 0;
}   

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

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>	

using namespace std;

int main() {
	int r, g, b, N;
	cin >> r >> g >> b >> N;

	int ans = 0;

	for (int i = 0; (N - (i * g)) >= 0; ++i) {
		for (int j = 0; (N - (i * g + j * b)) >= 0; ++j) {
			if ((N - (i * g + j * b)) % r == 0) {
				++ans;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
package main

import (
    "fmt"
    "os"
    "bufio"
)

func main() {
    var fp *os.File
    fp = os.Stdin
    reader := bufio.NewReaderSize(fp, 1024)
    var queue [][]int
  	var H, W int
	fmt.Scan(&H, &W)
    visited := make([][]int, H)

    for i := 0; i < H; i++ {
      line, _, _ := reader.ReadLine()

        for j, v := range line {
            visited[i] = append(visited[i], -1)

            if string(v) == "#" {
                var val []int
                val = append(val, i)
                val = append(val, j)
                queue = append(queue, val)
                visited[i][j] = 0
            }
        }
    }

    // BFS
    var dx [4]int
    var dy [4]int
    dx[0] = 0
    dx[1] = 0
    dx[2] = 1
    dx[3] = -1
    dy[0] = 1
    dy[1] = -1
    dy[2] = 0
    dy[3] = 0
    var now_x, now_y, next_x, next_y int
    var cnt int = 0

    for len(queue) > 0 {
        now_y = queue[0][0]
        now_x = queue[0][1]

        for i := 0; i < 4; i++ {
            next_y = queue[0][0] + dy[i]
            next_x = queue[0][1] + dx[i]

            if next_x >= 0 && next_x <= W - 1 &&
               next_y >= 0 && next_y <= H - 1 &&
               visited[next_y][next_x] == -1 {
               var val []int
               val = append(val, next_y)
               val = append(val, next_x)
               queue = append(queue, val)
               visited[next_y][next_x] = visited[now_y][now_x] + 1
               cnt = visited[next_y][next_x]
            }
        }

        queue = queue[1:]
    }

    fmt.Println(cnt)
}


Measured memory_bytes: 121344
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main()
{
    int N;
    cin >> N;

    vector<int> V(N);
    vector<int> C(N);

    for (int i = 0; i < N; ++i) {
        cin >> V[i];
    }

    for (int i = 0; i < N; ++i) {
        cin >> C[i];
    }

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        if (V[i] > C[i]) {
            ans += V[i] - C[i];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np

n = int(input())
arr = list(map(int, input().split()))
base = [i + 1 for i in range(n)]

count = 0
for i in range(n):
    if arr[i] != base[i]:
        count += 1

if count <= 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 21648
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int H, W, K, ans;
char C[10][10];
char now[10][10];


int Solve(int h, int w){
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++) now[i][j] = C[i][j];
  }

  for (int i = 0; i < H; i++){
    if (h % 2 != 0){
      for (int j = 0; j < W; j++) now[i][j] = 'R';
    }
    h /= 2;
  }
  for (int j = 0; j < W; j++){
    if (w % 2 != 0){
      for (int i = 0; i < H; i++) now[i][j] = 'R';
    }
    w /= 2;
  }

  int cnt = 0;
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      if (now[i][j] == '#') cnt++;
    }
  }

  if (cnt == K) ans++;

  return 0;
}

int main(){
  scanf("%d%d%d", &H, &W, &K);
  for (int i = 0; i < H; i++) scanf("%s", C + i);

  for (int i = 0; i < pow(2, H); i++){
    for (int j = 0; j < pow(2, W); j++){
      Solve(i, j);
    }
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 4148
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class UnionFindTree
{
    vector<int> parent; // em[h
    vector<int> rank;   // ØÌ³ÌãÀ
    int find(int x){
        if(parent[x] == x)
            return x;
        return parent[x] = find(parent[x]);
    }
public:
    UnionFindTree(int n){ // RXgN^
        parent.resize(n);
        for(int i=0; i<n; ++i)
            parent[i] = i;
        rank.assign(n, 0);
    }
    void unite(int x, int y){ // xÆyÌO[vð¹
        if((x = find(x)) != (y = find(y))){
            if(rank[x] < rank[y])
                parent[x] = y;
            else{
                parent[y] = x;
                if(rank[x] == rank[y])
                    ++ rank[x];
            }
        }
    }
    bool same(int x, int y){ // xÆyÌO[vª¯¶©ð²×é
        return find(x) == find(y);
    }
    int num(){ // O[vÌðÔ·
        vector<bool> root(parent.size(), false);
        for(unsigned i=0; i<parent.size(); ++i)
            root[find(i)] = true;
        return count(root.begin(), root.end(), true);
    }
};

int main()
{
    for(;;){
        int n, m;
        cin >> n >> m;
        if(n == 0)
            return 0;

        vector<pair<int, pair<int, int> > > e(m);
        for(int i=0; i<m; ++i){
            cin >> e[i].second.first >> e[i].second.second >> e[i].first;
            -- e[i].second.first;
            -- e[i].second.second;
        }
        sort(e.begin(), e.end());

        int ret = INT_MAX;
        for(int i=0; i<m; ++i){
            UnionFindTree uft(n);
            int rest = n-1;
            for(int j=i; j<m; ++j){
                if(!uft.same(e[j].second.first, e[j].second.second)){
                    uft.unite(e[j].second.first, e[j].second.second);
                    -- rest;
                    if(rest == 0){
                        ret = min(ret, e[j].first - e[i].first);
                        break;
                    }
                }
            }
        }

        if(ret == INT_MAX)
            cout << -1 << endl;
        else
            cout << ret << endl;
    }
}

Measured memory_bytes: 968
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n,k;
    cin >> n >> k;

    int cnt= 1;
    while(n){
        n/=k;
        if(n>=1){
            cnt++;
        }
        else{
            break;
        }
    }

    cout << cnt;

    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "
const int MXN = 2e5+5;
int in[MXN];

map<int, int> M;

int main()
{
  int n;
  scanf("%d", &n);
  FOR(i, 1, n)
    {
    scanf("%d", &in[i]);
    M[in[i]]++;
    }
  LL sum = 0;
  for(auto i: M)sum += (LL)i.s * (i.s-1)/2;
  FOR(i, 1, n)
    {
    printf("%lld\n", sum - M[in[i]]+1);
    }
}


Measured memory_bytes: 8320
n=int(input())
l=[int(i) for i in input().split()]
s=0
s1=0 
for i in l:
    if i%4==0:
        s+=1 
    elif i%2==0:
        s1+=1 
if s+s1//2>=n//2:
    print('Yes')
else:
    print('No')

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

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for(int i=0; i<s.size()-1; i++){
        if(s[i]!=s[i+1]){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <cstring>
#include <utility>
#include <map>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;


int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    //vector<int> b(n);
    for(ll i=0;i<n;i++)
    {  cin>>a[i];}
    
    ll ans=0;
    ll cntt=0;
    ll cnta=0;
    for(ll i=0;i<n;i++)
    {
        if(a[i]==1)
            continue;
        for(ll j=0;j<n;j++)
        {
            if(a[i]>a[j])
            {
                cntt++;
                if(i<j)
                    cnta++;
            }
        }
    }
    // ans+=(cnta+cnta+(k-1)*cntt)*k/2;
    ans=k*(k-1)/2;
    ans%=1000000007;
    ans*=cntt;
    ans%=1000000007;
    ans+=cnta*k;
    ans%=1000000007;
    //ans+=cnta*k+(k+k*k)*cntt/2;
    //    ans+=k*(2*cnta+(k-1)*cntt)/2;
 
    
    cout<<ans<<endl;
    
}




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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n;
	string s;
	cin >> n >> s;

	int ans = 1;
	char nowColor = s[0];
	for (int i = 1; i < n; i++) {
		if (nowColor == s[i]) {
			continue;
		}
		nowColor = s[i];
		ans++;
	}

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


Measured memory_bytes: 512
import java.util.Scanner;

//0621 2016
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt(), w = sc.nextInt();
        int[][] c = new int[h][3];
        for (int i = 0; i < h; i++) {
            char[] l = sc.next().toCharArray();
            for (int j = 0; j < w; j++) {
                if (l[j] == 'W')
                    c[i][0]++;
                else if (l[j] == 'B')
                    c[i][1]++;
                else
                    c[i][2]++;

            }
        }
        int min = Integer.MAX_VALUE;
        for (int i = 0; i < h; i++) {
            for (int j = i + 1; j < h - 1; j++) {
                int t = 0;
                for (int k = 0; k < h; k++) {
                    if (k <= i)
                        t += w - c[k][0];
                    else if (k <= j)
                        t += w - c[k][1];
                    else
                        t += w - c[k][2];
                }
                min = Math.min(min, t);
            }
        }
        System.out.println(min);
    }
}



Measured memory_bytes: 26208
#pragma GCC diagnostic error "-std=c++11"
#include<bits/stdc++.h>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,b,a) for(int i=b;i>=a;--i)
#define gcd(a,b) __gcd(a,b)
#define MEM(a,x) memset(a,x,sizeof(a))
#define VI vector<int>
#define PII pair<int,int>
#define ull unsigned long long
#define ll long long
#define fi first
#define se second
#define INF 0x3f3f3f3f
using namespace std;
const int N=2e5+5;
template<class T>inline void read(T &res)
{
char c;T flag=1;
while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;res=c-'0';
while((c=getchar())>='0'&&c<='9')res=res*10+c-'0';res*=flag;
}
int n,pre[4005][3],a[4005];
ll ans;
int main(){
    cin>>n;
    rep(i,1,n){
        char x;
        cin>>x;
        if(x=='R')a[i]=0;
        else if(x=='G')a[i]=1;
        else a[i]=2;
    }
    rep(i,1,n)rep(j,0,2)pre[i][j]=pre[i-1][j]+(a[i]==j);
    rep(i,1,n-2){
        rep(j,i+1,n-1){
            if(a[i]==a[j])continue;
            ans+=pre[n][3-a[i]-a[j]]-pre[j-1][3-a[i]-a[j]];
            if((2*j-i)<=n&&a[2*j-i]==3-a[i]-a[j])ans--;
        }
    }
    cout<<ans<<'\n';
	return 0;
}


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

int main()
{
    int t;
    vector<int> answer;
    cin >> t;
    for (int i = 0; i < t; i++)
    {
        int n, k;
        cin >> n >> k;
        int cost = 0;
        vector<int> x(n);
        vector<int> x_gap(n - 1);
        for (int j = 0; j < n; j++)
        {
            cin >> x.at(j);
            if (j != 0)
            {
                x_gap.at(j - 1) = x.at(j) - x.at(j - 1);
            }
        }
        sort(x_gap.begin(), x_gap.end());
        for (int j = 0; j < n - k; j++)
        {
            cost += x_gap.at(j);
        }
        answer.push_back(cost);
    }
    for (int i = 0; i < t; i++)
    {
        cout << answer.at(i) << endl;
    }
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int a,b,c,d=0,e=0;
signed main(){
	cin>>a>>b>>c;
	if(a==5){
		d++;
	}else if(a==7){
		e++;
	}
	if(b==5){
		d++;
	}else if(b==7){
		e++;
	}
	if(c==5){
		d++;
	}else if(c==7){
		e++;
	}
	if(d==2&&e==1){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2　//1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) (max(x,y)-min(x,y))
#define all(v) v.begin(),v.end()
#define UPDight(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int,int>;
typedef vector<int> vit;

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

    int n;
    cin >> n;
    vector<pii> gu, ki;
    reps(i, 100000){
      gu.emplace_back(0, i);
      ki.emplace_back(0, i);
    }
    int v;
    reps(i, n){
      cin >> v;
      if(i % 2 == 0){
	gu[v - 1].fi ++;
      } else {
	ki[v - 1].fi ++;
      }
    }
    sort(all(gu), greater<pii>());
    sort(all(ki), greater<pii>());
    int ans = 0;
    if(gu[0].se == ki[0].se){
      if(gu[0].fi > ki[0].fi){
	ans = gu[0].fi + ki[1].fi;
      } else if(gu[0].fi < ki[0].fi){
	ans = gu[1].fi + ki[0].fi;
      } else {
	ans = gu[0].fi + max(gu[1].fi, ki[1].fi);
      }
    } else {
      ans = gu[0].fi + ki[0].fi;
    }
    cout << n - ans << '\n';
    return 0;
}


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

int main(void){
 
    string s,t;
    cin >> s >> t;
    if(s[0] == t[2] && s[1] == t[1] && s[2] == t[0]){
        cout << "YES" <<endl;
    }
    else{
        cout << "NO" <<endl;
    }
}

Measured memory_bytes: 3620
n = int(input())
d = []
for i in range(n):
    s, p = input().split()
    d.append([s, int(p), i + 1])
d = sorted(d, key=lambda x: x[1], reverse=True)
d = sorted(d, key=lambda x: x[0])
for i in range(n):
    print(d[i][2])


Measured memory_bytes: 3060
#! /usr/bin/env python3

N, M = map(int, input().split())
B = {x+1:1 for x in range(N)}
f = {x+1:0 for x in range(N)}
f[1] = 1
for i in range(M):
    x, y = map(int, input().split())
    B[x] -= 1
    B[y] += 1
    if f[x] : f[y] = 1
    if B[x] < 1 : f[x] = 0
ans = 0
for k, v in f.items() : ans += v
print(ans)

Measured memory_bytes: 27368
#include <bits/stdc++.h>
        #define ll long long
        #define ld long double
        #define pb push_back
        #define fi first
        #define se second
        #define end "\n"
        #define fast ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
        #define GCD(x,y)          (__gcd((x), (y)))
        #define LCM(x,y)          (((x)/__gcd((x), (y)))*(y))
        #define mem(x,y) memset(x,y,sizeof(x))
        using namespace std;
        long long n,i,t,j,l,y,k,r,a[301301],b[301000],k1,k2,ma,mi,sum, s1,in,jm,f,xx,cur,x,jj,ii,m,z,mia,mib,ans,sum1;
        string s,s2;
        double te;
        char c[101][101];
        long long power(long long x, unsigned long long y)
{
    if (y == 0)
        return 1;
    else if (y % 2 == 0)
        return power(x, y / 2) * power(x, y / 2);
    else
        return x * power(x, y / 2) * power(x, y / 2);
}
        map<long long ,long long>mr;
         map<long long ,long long>mc;

        int main()
        {

            fast;
           // cin>>t;
           // while(t--){
                   cin>>n>>x>>t;
                   y=n/x;
                   if(n%x)y++;
                   cout<<y*t;

        }









Measured memory_bytes: 3616
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	if a > b {
		fmt.Println(2*a - 1)
		return
	}
	if a < b {
		fmt.Println(2*b - 1)
		return
	}
	fmt.Println(2 * a)
}


Measured memory_bytes: 512
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <string.h>
#include <sstream>
#include <cctype>
#include <climits>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <vector>
#include <iterator>
#include <algorithm>
#include <stack>
#define _clr(x,y) memset(x,y,sizeof(x))
#define _inf(x) memset(x,0x3f,sizeof(x))
#define pb push_back
#define mp make_pair
using namespace std;
const int INF = 0x3f3f3f3f;
const double eps = 1e-8;
typedef long long LL;
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
	#ifndef ONLINE_JUDGE
		//freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif
	
	LL n,a,b,x[100000+5]={};
	LL ans=0;
	cin>>n>>a>>b;
	for(int i=1;i<=n;i++) cin>>x[i];
	for(int i=2;i<=n;i++)
	{
		ans+=min(b,a*(x[i]-x[i-1]));
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <queue>
#include <stack>
#include <climits>
#include <array>
using namespace std;

typedef long long ll;
#define pb push_back

#define rep(i, n) for (int i=0;i<(n);++i)
#define rep2(i, s, n) for (int i=s;i<(n);++i)
#define rev(i, n) for (int i=(n);i>0;--i)
#define INF (1e9+1e9)


ll l (array<ll, 1000>& L, int n) {
    if (L[n] != -1) return L[n];
    if (n == 0) return 2;
    if (n == 1) return 1;
    L[n] = l(L,n-1) + l(L,n-2);
    return L[n];
}

int main() {
    int n; cin>>n;
    array<ll, 1000> L;
    L.fill(-1);    

    cout << l(L,n) << endl;
}

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

using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	long long int a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<min(a,b)+min(c,d);
	return 0;
}

Measured memory_bytes: 256
#include<string>
#include<cstdio>

using namespace std;

int main(){
    int n,k;
    bool dl[10] = {};

    scanf("%d%d",&n,&k);

    for(int i=0;i<k;i++){
        int tmp;
        scanf("%d",&tmp);
        dl[tmp] = true;
    }

    for(int i=n;;i++){
        bool flag = true;
        string sn = to_string(i);

        for(int j=0;j<sn.size();j++){
            if(!dl[sn[j] - '0'])flag = true;
            else{
                flag = false;
                break;
            }
        }

        if(flag){
            printf("%d\n",i);
            break;
        }
    }

    return 0;
}



Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    SM = sum(A)
    for n in range(N - 1):
        A[n + 1] += A[n]

    ret = MAX
    for n in range(N-1):
        ret = min(ret, abs(SM - 2 * A[n]))
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 31008
#include <iostream>
#include<cstdio>
#include<string>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int j=0,ma=0,i;
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G')
            j++;
        else
        {
            if(j>ma)
                ma=j;
            j=0;
        }
    }
     if(j>ma)
                ma=j;
    cout<<ma<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  string s;
  cin >> s;
  int n=s.size();
  int a[n];
  rep(i,n) a[i]=s[i]-'0';
  ll ans=0;
  rep(i,(1<<(n-1))){
    ll t=a[n-1];
    rep(j,n-1){      
      if(i&(1<<j)){
	ans+=t;
	t=a[n-j-2];
      }
      else {
	ll ke=log10(t)+1;
	//	cout << ke << endl;
	t+=a[n-j-2]*pow(10,ke);
      }
      //      cout << t << endl;
    }
    ans+=t;
    //    cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
    

}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <unordered_set>
#include <cmath>
#include <queue>
#include <stdio.h>
#include <sstream>

using namespace std;
using ll = long long;
using ld = long double;
template <class T> using vec = std::vector<T>;
template <class T> using vvec = std::vector<std::vector<T>>;

#define REP(i, s, e) for (ll i = s; i < e; ++i)

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

    int N; cin >> N;
    string r = "YES";
    int c = 0;
    REP(i, 0, N)
    {
        int n; cin >> n;
        if (n != i + 1) ++c;
        if (c > 2)
        {
            r = "NO";
            break;
        }
    }

    cout << r << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    int a, b, x;
    cin >> a >> b >> x;
    if (a + b < x) {
        cout << "NO" << endl;
    }
    else if (a > x) {
        cout << "NO" << endl;
    }
    else {
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main(void)
 
{
 
int a,b;
 
scanf("%d %d",&a,&b);
 
if(a<b)
 
{
 
printf("a < b\n");
 
}
 
if(a>b)
 
{
 
printf("a > b\n");
 
}
 
if(a==b)
 
{
 
printf("a == b\n");
 
}
 
return 0;
 
}

Measured memory_bytes: 580
#include <algorithm>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define REP(i, m, n) for (int i = int(m); i < int(n); i++)
#define RREP(i, m, n) for (int i = int(n) - 1; i >= int(m); --i)
#define EACH(i, c) for (auto &(i) : c)
#define all(c) begin(c), end(c)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(begin(c), end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x) cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s)                                                               \
    do {                                                                       \
    } while (0)
#define dump(x)                                                                \
    do {                                                                       \
    } while (0)
#define BR
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int, int>;
using VP = vector<PII>;

void solve() {
    VI a(3);
    REP(i, 0, 3) cin >> a[i];
    sort(all(a));
    cout << a[2] - a[0] << endl;
}

signed main() {
    solve();

    return 0;
}

Measured memory_bytes: 256
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 100001;
static const ll MOD = 1000000007;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int n;
	string str; cin >> n >> str;

	ll sum = 0;
	rep(i, str.size()) if(str[i] == 'R') sum++;

	ll ans = 0;
	rep(i, sum){
		if(str[i] != 'R') ans++;
	}
	cout << ans << endl;
	return 0;
}


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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    int n, m;
    cin >> n >> m;
    vector<set<int>> vs(n);

    fo(i, n) {
        int k;
        cin >> k;
        fo(j, k) {
            int a;
            cin >> a;
            vs[i].insert(a);
        }
    }

    int cont = 0;
    fo(i, m) {
        bool pos = true;
        fo(j, n) {
            if ( vs[j].find(i + 1) == vs[j].end() ) {
                pos = false;
                break;
            }
        }
        if ( pos ) cont++;
    }

    cout << cont << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
B = []
for i in range(N):
  B.append(A[i]-(i+1))
B.sort()
lb = [B[N//2]-1,B[N//2]]

sad = float("inf")
for b in lb:
  c = 0
  for j in range(N):
    c += abs( A[j]-(b+j+1) )
  sad = min(sad,c)
print(sad)  

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
using str = string;

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

long int M = 1e+9+7;
int inf = 1e+9;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    string s="";
    cin >> s;
    int ans=0;
    while(1){
        str tmp1="",tmp2="";
        s.erase(s.size()-2);
        tmp1 = s.substr(0,s.size()/2);
        tmp2 = s.substr(s.size()/2,s.size()/2);
        if(tmp1 == tmp2){
            ans = tmp1.size()*2;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
vector<int> axis;
int main()
{
	int n;
	int i,j,sum,tmpsum;
	scanf("%d",&n);
	axis.resize(n);
	scanf("%d",&axis[0]);
	for(i=1;i<n;i++)
	{
		scanf("%d",&axis[i]);
		sum+=abs(axis[i]-axis[i-1]);
	}
	for(i=0;i<n;i++)
	{
		tmpsum=sum;
		if(i==0)
		{
			tmpsum+=abs(axis[1]);
			tmpsum+=abs(axis[n-1]);
			tmpsum-=abs(axis[0]-axis[1]);
		}
		else if(i==n-1)
		{
			tmpsum+=abs(axis[0]);
			tmpsum+=abs(axis[n-2]);
			tmpsum-=abs(axis[n-1]-axis[n-2]);
		}
		else
		{
			tmpsum+=abs(axis[0]);
			tmpsum-=abs(axis[i-1]-axis[i]);
			tmpsum-=abs(axis[i+1]-axis[i]);
			tmpsum+=abs(axis[i+1]-axis[i-1]);
			tmpsum+=abs(axis[n-1]);
		}
		printf("%d\n",tmpsum);
	}
	return 0;
}

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

using namespace std;

int const SIZEMAX = 3100;
string s, t;
int n, m;
int dp[1 + SIZEMAX + 1][1 + SIZEMAX + 1];

int main() {
  cin >> s >> t;
  if(s == "" || t == "") {
    cout << "";
    return 0;
  }
  n = s.length();
  m = t.length();
  for(int i = 1; i <= n; i++) {
    for(int j = 1; j <= m; j++) {
      dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      if(s[i-1] == t[j-1]) {
        dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
      }
    }
  }
  string ans = "";
  int i = n, j = m;
  while(i > 0 && j > 0) {
    if(dp[i][j] == dp[i-1][j]) {
      i--;
    } else if(dp[i][j] == dp[i][j-1]) {
      j--;
    } else {
      ans = s[i-1] + ans;
      i--;
      j--;
    }
  }
  cout << ans;
}


Measured memory_bytes: 37120
#include<stdio.h>

int main()
{
	int a,b,w,flag;
	while(scanf("%d%d%d",&w,&a,&b)!=EOF)
	{
		if(b>a+w) flag=b-a-w;
		if(b+w<a) flag=a-b-w;
		if(a==(b+w)||(a+w)==b) flag=0;
		if(a<=b&&b<=a+w) flag=0;
		if(a<=b+w&&b<=a) flag=0;
		printf("%d\n",flag);
	}
}


Measured memory_bytes: 128
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll X;
    cin >> X;

    ll sum = 0;
    FOR(i, 1, X + 1)
    {
        if (sum >= X)
        {
            cout << i - 1 << endl;
            break;
        }
        sum += i;
    }

    return 0;
}


Measured memory_bytes: 3120
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main{
	static int vectors[][] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};
	public static void main(String args[]){
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			while(true){
				//String str = br.readLine();
				String strs[] = br.readLine().split("[ \t]");
				int max_x = Integer.parseInt(strs[0]);
				int max_y = Integer.parseInt(strs[1]);

				if(max_x == 0) return;
				int direction = 0;
				int x = 1;
				int y = 1;

				while(true){
					//System.out.println(direction + " " + x + " " + y);
					strs = br.readLine().split("[ \t]");
					if(strs[0].equals("FORWARD")){
						int n = Integer.parseInt(strs[1]);
						int vector[] = vectors[direction];
						x += vector[0] * n;
						if(x < 1) x = 1;
						if(x > max_x) x = max_x;
						y += vector[1] * n;
						if(y < 1) y = 1;
						if(y > max_y) y = max_y;

					}else if(strs[0].equals("BACKWARD")){
						int n = Integer.parseInt(strs[1]);
						int vector[] = new int[2];
						vector[0] = 0 - vectors[direction][0];
						vector[1] = 0 - vectors[direction][1];
						x += vector[0] * n;
						if(x < 1) x = 1;
						if(x > max_x) x = max_x;
						y += vector[1] * n;
						if(y < 1) y = 1;
						if(y > max_y) y = max_y;

					}else if(strs[0].equals("RIGHT")){
						direction++;
						direction = direction % 4;

					}else if(strs[0].equals("LEFT")){
						direction--;
						if(direction < 0) direction += 4;;

					}else if(strs[0].equals("STOP")){
						break;
					}

					//System.out.println(x + " " + y);
				}
				System.out.println(x + " " + y);
			}
		}catch(Exception e){
			System.err.print(e);
		}
	}
}

Measured memory_bytes: 27612