akhauriyash/Code-Regression huggingface dataset:
//minamoto
#include<bits/stdc++.h>
#define R register
#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 cmin(T&a,const T&b){return a>b?a=b,1:0;}
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
using namespace std;
const int N=2005;
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;}
int f[N][N],g[N],mx[N],n,res,k;
void dfs(int u,int fa){
	memset(f[u],0xef,sizeof(f[u]));
	f[u][0]=1;
	go(u)if(v!=fa){
		dfs(v,u),memcpy(g,f[u],(max(mx[u],mx[v]+1)+1)<<2);
		fp(i,0,mx[u])fp(j,0,mx[v])if(i+j+1<=k)
			cmax(g[max(i,j+1)],f[u][i]+f[v][j]);
		cmax(mx[u],mx[v]+1),memcpy(f[u],g,(mx[u]+1)<<2);
	}
}
int main(){
	scanf("%d%d",&n,&k);
	for(R int i=1,u,v;i<n;++i)scanf("%d%d",&u,&v),add(u,v),add(v,u);
	dfs(1,0);
	fp(i,1,n)fp(j,0,min(mx[i],k))cmax(res,f[i][j]);
	printf("%d\n",n-res);
	return 0;
}

Measured memory_bytes: 16128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long llong;
int main(){
    int n;
    cin >> n;
    
    llong ax, ay;
    int x, y;

    cin >> x >> y;
    ax = x; 
    ay = y;

    for (int i = 0; i < n - 1; i++){
        scanf("%d %d", &x, &y);

        if (ax < x) ax = x;
        else if (ax % x != 0) ax += x - (ax % x);

        if ((ax / x) * y < ay) ax += (ay - (ax / x) * y) / y * x;
        if ((ax / x) * y < ay) ax += x;

        ay = ax / x * y;
    }

    cout << ax + ay << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define N 1000005

using namespace std;

void solve()
{
	ll n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n - 1; ++i)
	{
		for (int j = 1; j*i <= n-1; ++j)
		{
			ans++;
		}
	}
	cout << ans << endl;
}

int32_t main()
{
	IOS
	ll T = 1;
	// cin >> T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  int A, B, C, D, E, F;
  cin >> A >> B >> C >> D >> E >> F;
  vector<int> a(F + 1), b(F + 1);
  a[0] = b[0] = 1;
  for (int i = 0; i <= F; i++) {
    if (a[i] && i + A <= F) a[i + A] = 1;
    if (a[i] && i + B <= F) a[i + B] = 1;
    if (b[i] && i + C <= F) b[i + C] = 1;
    if (b[i] && i + D <= F) b[i + D] = 1;
  }
  double mx = -1, x, y;
  for (int i = 0; i <= F; i++) {
    if (b[i]) {
      for (int j = 1; j <= F; j++) {
        if (j * E >= i && i + j * 100 <= F && a[j]) {
          if (i * 1.0 / (i + 100 * j) > mx) {
            mx = i * 1.0 / (i + 100 * j);
            x = i + j * 100, y = i;
          }
        }
      }
    }
  }
  cout << x << " " << y << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <iostream>
#include <bitset>
using namespace std;
#define N 5
int fa[N],d[N];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int main()
{
	for(int i=1,x,y;i<=3;i++)scanf("%d%d",&x,&y),fa[find(x)]=find(y),d[x]++,d[y]++;
	for(int i=2;i<=4;i++)if(find(i-1)!=find(i))return puts("NO"),0;
	for(int i=1;i<=4;i++)if(d[i]>2)return puts("NO"),0;
	puts("YES");
}

Measured memory_bytes: 256
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <bits/stdc++.h>  
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define vl vector<ll>
#define N 100005
#define mod 1000000007

int main()
{   
    ll n;cin>>n;
    ll a[n];
    for(ll i=0;i<n;i++)
    cin>>a[i];
    ll cnt=0;
    for(ll i=n-1;i>0;i--)
    {
        if(a[i-1]<=a[i])
        continue;
        if((a[i-1]-1)>a[i])
        {
            cnt=1;break;
        }
        else
        a[i-1]-=1;
    }
    if(cnt)
    cout<<"No"<<"\n";
    else
    cout<<"Yes"<<"\n";
    return 0;
}

Measured memory_bytes: 4316
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		int N = cin.nextInt();
		while(N--!=0){
			int runner=0;
			int score=0;
			int out=0;
			while(true){
				String str = cin.next();
				if(str.equals("HIT")){
					runner++;
					if(runner>=4){
						score++;
						runner--;
					}
				}
				else if(str.equals("HOMERUN")){
					score+=runner+1;
					runner=0;
				}
				else{
					out++;
				}
				if(out==3){
					break;
				}
			}
			System.out.println(score);
		}
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
// (setq-default c-basic-offset 2)

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

  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a % 2 == 0 and !((a % 5 == 0) or (a % 3 == 0))) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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 main() {
  int N;
  cin >> N;
  cout << (N - 1) / 2 << endl;
}

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

int main() {
    int n; cin >> n;
    map<char,bool> mp;
    rep(i,n){
        char s;
        cin >> s;
        mp[s] = true;
    }
    if(mp.size() == 3) cout << "Three";
    else cout << "Four";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <algorithm>

int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<std::vector<std::pair<unsigned long, long long>>> graph(N + 1);
  for (int i = 0; i < M; ++i) {
    int L, R, D;
    std::cin >> L >> R >> D;
    graph[L].push_back({R, D});
    graph[R].push_back({L, -D});
  }
  std::vector<long long> cost(N + 1, 0);
  std::vector<bool> used(N + 1, false);
  for (int i = 1; i <= N; ++i) {
    if (!used[i]) {
      used[i] = true;
      std::queue<unsigned long> queue;
      queue.push(i);
      while (!queue.empty()) {
        auto p = queue.front();
        queue.pop();
        for (auto e : graph[p]) {
          if (used[e.first]) {
            if (cost[p] + e.second != cost[e.first]) {
              std::cout << "No" << std::endl;
              return 0;
            }
          } else {
            used[e.first] = true;
            cost[e.first] = cost[p] + e.second;
            queue.push(e.first);
          }
        }
      }
    }
  }
  std::cout << "Yes" << std::endl;
  return 0;
}

Measured memory_bytes: 14080
N,C=map(int,input().split())
from collections import defaultdict
Cbef=defaultdict(int)
time=defaultdict(int)
TV=[tuple(map(int,input().split())) for i in range(N)]
TV.sort(key=lambda x:x[0])
for s,t,c in TV:
    if Cbef[c]==s:
        time[s]+=1
        time[t]-=1
        Cbef[c]=t
    else:
        time[s-1]+=1
        time[t]-=1
        Cbef[c]=t
ans=0
now=time[0]
ans=now
for i in range(1,10**5+1):
    now+=time[i]
    ans=max(ans,now)
print(ans)

Measured memory_bytes: 27704
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
int main(){
  ll n,zero_cnt=0,num,sum;
  vector<ll> po_num,ne_num;
  vector<pair<ll,ll>> ans;
  cin >> n;
  ll a;
  for(ll i=0;i<n;i++){
    cin >> a;
    if(a>0){
      po_num.push_back(a);
    }else if(a<0){
      ne_num.push_back(a);
    }else{
      zero_cnt++;
    }
  }
  if(po_num.size()==0&&zero_cnt==0){
    ll max=-10000000;
    bool f=false;
    for(ll i=0;i<ne_num.size();i++){
      max=(ne_num[i]<max)?max:ne_num[i];
    }
    sum=max;
    for(ll i=0;i<ne_num.size();i++){
      if(ne_num[i]!=max||f==true){
        ans.push_back(make_pair(sum,ne_num[i]));
        sum-=ne_num[i];
      }else if(ne_num[i]==max){
        f=true;
      }
    }
    cout << sum << endl;
  }else if(ne_num.size()==0&zero_cnt==0){
    ll min=100000000,cnt=0;
    bool f=false;
    for(ll i=0;i<po_num.size();i++){
      min=(po_num[i]>min)?min:po_num[i];
    }
    ll j=0;
    sum=min;
    while(cnt<po_num.size()-2){
      if(po_num[j]!=min||f==true){
        ans.push_back(make_pair(sum,po_num[j]));
        sum-=po_num[j];
        cnt++;
      }else{
        f=true;
      }
      j++;
    }
     ans.push_back(make_pair(po_num[po_num.size()-1],sum));
     sum = po_num[po_num.size()-1]-sum;
    cout << sum << endl;
  }else{
    for(int i=0;i<zero_cnt;i++){
      if(po_num.size()==0){
        po_num.push_back(0);
      }else{
        ne_num.push_back(0);
      }
    }
    for(int i=1;i<po_num.size();i++){
      ans.push_back(make_pair(ne_num[0],po_num[i]));
      ne_num[0]-=po_num[i];
    }
    sum=po_num[0];
    for(int i=0;i<ne_num.size();i++){
      ans.push_back(make_pair(po_num[0],ne_num[i]));
      sum+=-ne_num[i];
      po_num[0]-=ne_num[i];
    }
    cout << sum <<endl;
  }
  for(int i=0;i<ans.size();i++){
    cout << ans[i].first<<" "<<ans[i].second<<endl;
  }
}


Measured memory_bytes: 5104
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int d = Integer.parseInt(sc.next());
		int train,bus;
		train=Math.min(a,b);
		bus=Math.min(c,d);
		System.out.print(train+bus);
    }
}

Measured memory_bytes: 22100
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int total = min(a, b) + min(c, d);
    cout << total << endl;

    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < up; ++i)
#define repp(i, up) for (ll i = 0; i <= up; ++i)
#define rrep(i, lo, up) for (ll i = lo; i < up; ++i)
#define rrepp(i, lo, up) for (ll i = lo; i <= up; ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))

#define rdi(i) ll i; scanf("%lld", &i)
#define rds(s) string s; cin >> s
#define rdc(c) char c; cin >> c

#define INF 10000000000
//#define MOD 1000000007
#define MOD 998244353

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

ll pw(ll a, ll n) {
    if (n <= 0) {
        return 1;
    } else if (n == 1) {
        return a;
    } else if (n % 2 == 0) {
        ll work = pw(a, n / 2);
        return work * work % MOD;
    } else {
        return pw(a, n - 1) * a % MOD;
    }
}

vector<ll> f;
vector<ll> ff;

ll combi(ll a, ll b) {
    if (b <= 0 || a - b <= 0) {
        return 1;
    } else {
        return (f[b] * f[a - b] % MOD) * ff[a] % MOD;
    }
}

int main()
{
    ll n;
    cin >> n;
    vector<pair<ll, ll>> ss(n);
    vector<pair<ll, ll>> rem;
    ll ds = 0;
    rep(i, n) {
        string s;
        cin >> s;
        ll m = 0;
        ll d = 0;
        rep(j, s.size()) {
            if (s[j] == '(') {
                ++d;
            } else {
                --d;
            }
            m = min(m, d);
        }
        ss[i].first = m;
        ss[i].second = d;
        ds += d;
    }

    if (ds != 0) {
        cout << "No" << endl;
        return 0;
    }

    sort(ss.begin(), ss.end(), [](const pair<ll, ll>& left, const pair<ll, ll>& right)
         {
             return left.first > right.first;
         });

    ll d = 0;
    rep(i, ss.size()) {
        if (ss[i].second <= 0) {
            rem.push_back(ss[i]);
            continue;
        }
        if (d + ss[i].first < 0) {
            cout << "No" << endl;
            return 0;
        }
        d += ss[i].second;
    }

    ss = rem;
    rem.clear();
    rep(i, ss.size()) {
        if (ss[i].second < 0) {
            rem.push_back(ss[i]);
            continue;
        }
        if (d + ss[i].first < 0) {
            cout << "No" << endl;
            return 0;
        }
        d += ss[i].second;
    }

    ss = rem;
    sort(ss.begin(), ss.end(), [](const pair<ll, ll>& left, const pair<ll, ll>& right)
         {
             return (left.first - left.second) < (right.first - right.second);
         });
    rep(i, ss.size()) {
        if (d + ss[i].first < 0) {
            cout << "No" << endl;
            return 0;
        }
        d += ss[i].second;
    }

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

Measured memory_bytes: 26728
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int main(){
  int m,k; cin >> m >> k;
  vector<int> v;
  int n = 1 << m;
  if(n <= k){
    puts("-1"); 
    return 0;
  }
  if(m == 1){
    if(k == 0){
      puts("0 0 1 1");
    }else{
      puts("-1");
    }
    return 0;
  }
  
  rep(i,n){
    if(i==k) continue;
    v.push_back(i);
  }
  auto v2 = v;
  reverse(v2.begin(),v2.end());
  
  v.push_back(k);
  v.insert(v.end(), v2.begin(), v2.end());
  v.push_back(k);
  
  for(auto x:v){
    cout << x << " ";
  }
  
  return 0;
}

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

int main(){
  ll n,p=1e9+7;
  string s;
  cin>>n>>s;

  ll cnt[30]={};
  for(int i=0;i<n;i++){
    cnt[s[i]-'a']++;
  }

  ll ans=1;
  for(int i=0;i<30;i++){
    if(cnt[i]==0)continue;
    ans*=(cnt[i]+1);
    ans%=p;
  }

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


Measured memory_bytes: 512
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  if(A==B){
    if(B!=C){
      cout << "Yes" << endl;
      return 0;
    }
    else {
      cout << "No" << endl;
      return 0;
    }
  }
  else if(B==C || A==C){
    cout << "Yes" << endl;
    return 0;
  }
  else {
    cout << "No" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
mass = []
for _ in range(H):
    mass.append(list(input()))
for i in range(H):
    for j in range(W):
        counter = 0
        if mass[i][j] == "#":
            print("#", end="")
        else:
            for k in range(-1, 2, 1):
                for l in range(-1, 2, 1):
                    if k == 0 and l == 0:
                        continue
                    if i + k < 0 or i + k >= H or j + l < 0 or j + l >= W:
                        continue
                    if mass[i + k][j + l] == "#":
                        counter += 1
            print(counter, end="")
    print()


Measured memory_bytes: 3444
#include<stdio.h>
#include<string.h>
int main()
{
    int i, n, p, sum=0, high=0;
    scanf("%d", &n);
    for(i=1; i<=n; i++)
    {
        scanf("%d", &p);
        sum= sum+p;
        if(high<p)
        {
            high=p;
        }
        else
        {
            high = high;
        }
    }
    sum= sum-(high/2);
    printf("%d\n", sum);
    return 0;
}


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

int main(){
	
	int n; cin>>n;
	ll cnt{};
	vector<vector<int>> num(10,vector<int>(10));
	for(int i=1; i<=n; i++){
		string s{to_string(i)};
		num.at(s.front()-'0').at(s.back()-'0')++;
	}
	for(int i=1; i<10; i++){
		for(int j=1; j<10; j++){
			cnt += num.at(i).at(j)*num.at(j).at(i);
		}
	}
	cout << cnt << endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	int i;
	for(i=0;i<n;i++)
	cin>>a[i]>>b[i]>>c[i];
	for(i=1;i<n;i++)
	{
		a[i]=a[i]+max(b[i-1],c[i-1]);
		b[i]=b[i]+max(a[i-1],c[i-1]);
		c[i]=c[i]+max(a[i-1],b[i-1]);
	}
	cout<<max(a[n-1],max(b[n-1],c[n-1]));
}

Measured memory_bytes: 4716
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    ll maxh = -1;
    bool ans = true;
    for(int i = 0; i < n; ++i){
        ll h;
        cin >> h;
        if(i > 0 && h < maxh - 1){
            ans = false;
            break;
        }
        maxh = max(maxh, h);
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

string calc(const string &s, string &&t){
    char last;
    int N = s.size();
    if(t[0]=='S'&&s[0]=='o' || t[0]=='W'&&s[0]=='x'){
        last = t[1];
    } else {
        if(t[1]=='W') last = 'S';
        else last = 'W';
    } 

    for (int i = 2; i < N; i++)
    {
        if(s[i-1]=='o'&&t[i-1]=='S' || s[i-1]=='x'&&t[i-1]=='W' ) t += t[i-2];
        else{
            if(t[i-2]=='W') t+='S';
            else t+='W';
        }
    }

    if(last != t[N-1]) return "";
    
    if(s[N-1]=='o' && t[N-1]=='S' || s[N-1]=='x'&&t[N-1]=='W'){
        if(t[N-2]==t[0]) return t;
        else return "";
    } else {
        if(t[N-2]!=t[0]) return t;
        else return "";
    }
}


int main() {
    int N; cin >> N;
    string s; cin >> s;
    string t;
    if((t = calc(s, "SS")) != ""){
        cout << t << endl;
    } else if ((t = calc(s, "SW")) != ""){
        cout << t << endl;  
    } else if ((t = calc(s, "WS")) != ""){
        cout << t << endl;
    } else if ((t = calc(s, "WW")) != ""){
        cout << t << endl;
    } else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
using namespace std;

int main(){
    string S;
    cin >> S;
    int si = S.size();
    int ans = 0;
    for (int i = 0; i < si; i++){
        S = S.substr(0, S.size() - 2);
        string l_1 = S.substr(0, S.size() / 2);
        string l_2 = S.substr(S.size() / 2, S.size() / 2);
        if (l_1 == l_2){
            ans = S.size();
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<iostream>
using namespace std;

int a,b;
int kq;

int main(){
  scanf("%d%d",&a,&b);
  if ((a+b)%2==1) printf("IMPOSSIBLE");
  else{
    kq=(a+b)/2;
    printf("%d",kq);
  }
}


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


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int N,M;
  long long X;
  cin >> N >> M;
  cin >> X;
  long long A[15][15];
  for(int i=0;i<N;i++){for(int j=0;j<M+1;j++) cin >> A[i][j];}
  long long mi=10000000;
  for(long long bit=0;bit < (1<<N);bit++){
    long long MM[15]={0};
    long long money=0;
    for(int i=0;i<N;i++){
      if(bit & (1<<i)){money+=A[i][0];for(int j=1;j<M+1;j++)MM[j]+=A[i][j];}
    }
    bool light=true;
    for(int k=1;k<M+1;k++){
      if(MM[k]<X)light=false;
    }
    if(light) mi=min(mi,money);
  }
  if(mi==10000000)cout << -1 << endl;
  else cout << mi << endl;
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;


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

    cout << N - K + 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define mod 1000000007
 
int n,m,cnt,flag1,flag2,s1,s2;
long long k;
char s[2001][2001];
 
long long quickpow(long long base,long long to)
{
	if(to<=0)return 1;
	if(to==1)return base;
	long long mid=quickpow(base,to>>1);
	if(to&1)return mid*mid%mod*base%mod;
	else return mid*mid%mod;
}
 
struct Matrix{
	long long a[3][3];
	Matrix(){memset(a,0,sizeof(a));}
	Matrix operator*(Matrix &m)
	{
		Matrix ans;
		for(int i=1;i<=2;++i)
			for(int j=1;j<=2;++j)
				for(int k=1;k<=2;++k)
					ans.a[i][j]=(ans.a[i][j]+a[i][k]*m.a[k][j]%mod)%mod;
		return ans;
	}
};
 
int main()
{
	scanf("%d%d%lld",&n,&m,&k);
	for(int i=1; i<=n; ++i)
		scanf("%s",s[i]+1);
	for(int i=1; i<=n; ++i)
	{
		for(int j=1; j<=m; ++j)
			if(s[i][j]=='#')
			{
				++cnt;
				s1+=s[i][j-1]=='#';
				s2+=s[i-1][j]=='#';
			}
		if(s[i][1]=='#' && s[i][m]=='#')++flag1;
	}
	for(int i=1;i<=m;++i)if(s[1][i]=='#' && s[n][i]=='#')++flag2;
	if(flag1 && flag2)
	{
		puts("1");
		return 0;
	}
	if(!flag1 && !flag2)
	{
		printf("%lld\n",quickpow(cnt,k-1));
		return 0;
	}
	if(!flag1)swap(flag1,flag2),swap(s1,s2);
	Matrix A;
	A.a[1][1]=cnt;
	A.a[2][1]=s1;
	A.a[2][2]=flag1;
	--k;
	Matrix ANS;
	ANS.a[1][1]=ANS.a[2][2]=1;
	while(k)
	{
		if(k&1)ANS=ANS*A;
		A=A*A;
		k>>=1;
	}
	printf("%lld\n",(ANS.a[1][1]-ANS.a[2][1]+mod)%mod);
}

Measured memory_bytes: 2176
#include<stdio.h>

#define u 100

int adj[u][u];

int graph(int s,int t){

  if(s==t) return 1;

  else return 0;

}


  int main(){

    int i,j,a,n,d,b[u],c[u],stu;

    scanf("%d",&n);

    for(i=0;i<n;i++){
      for(j=0;j<n;j++){

	adj[i][j]=0;
      }
    }

    for(i=0;i<n;i++){
      scanf("%d%d",&b[i],&c[i]);
      for(j=0;j<c[i];j++){

      scanf("%d",&stu);
      adj[i][stu-1]=1;


    }
    }

    for(i=0;i<n;i++){
      for(j=0;j<n;j++){

	if(j==n-1) printf("%d",adj[i][j]);
	else printf("%d ",adj[i][j]);

    }
      printf("\n");
    }

    return 0;
  }

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
int main()
{
    double s=0.0,p=0.5,n,k,q;int i,c=1,j=0;
    scanf("%lf %lf",&n,&k);
    q=1/n;
    for(i=1;i<=n;i++)
    {j=0;c=i;
        for(c=c;c<k;c=c*2)
        {
            j++;
        }s=s+(q*pow(p,j));
    }printf("%.12lf",s);
}


Measured memory_bytes: 256
def sub():
    N, W = [int(e) for e in input().split()]
    ww = []
    vv = []
    for _ in range(N):
        w, v = [int(e) for e in input().split()]
        ww.append(w)
        vv.append(v)
    
    # dp_table = [[0]*(W+1)]*(N+1)
    dp_table = [[0 for _ in range(W+1)] for _ in range(N+1)]
    # print(len(dp_table), len(dp_table[0]))
    for i in range(N):
        for j in range(W):
            w_next = j+ww[i]
            v_next = vv[i]
            if w_next <= W:
                dp_table[i+1][w_next] = max(dp_table[i+1][w_next], dp_table[i][j] + v_next)
            dp_table[i+1][j] = max(dp_table[i+1][j], dp_table[i][j])


    print(max(dp_table[-1]))
    # print(max(dp_table))

sub()


Measured memory_bytes: 173576
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <fstream>
#include <iostream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using uint64 = unsigned long long;
using vi = std::vector<int>;
using vl = std::vector<int64>;
using pii = std::pair<int, int>;
using pii = std::pair<int, int>;
using pll = std::pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(_) (_).begin(), (_).end()
#define rall(_) (_).rbegin(), (_).rend()
#define print(_) std::cout << (_) << '\n'
#define debug(_) std::cerr << #_ << ": " << (_) << '\n'
#define dbg(vec) for (size_t _ = 0; _ < vec.size(); ++_){std::cerr << #vec << "[" << _ << "] : " << vec[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;  // 1.073741823e9
const int64 INF64 = (1LL<<62) - 1;  // 4.611686018427387903e18
const int MOD = 1000000007;

int main(){
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int n; cin >> n;
  cout << n * n * n << '\n';

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll>>;
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 INF = 2147483647;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    for(int i=1;i<=5;i++){
	int n;cin >> n;
	if(n==0) cout << i << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>
#include <map>

int isMonth(int f) {

    return f <= 12 && f > 0;
}

using namespace std;
int main(int argc, const char * argv[]) {
    
    int s;
    cin >> s;
    int f = s/100;
    int b = s%100;
    bool fm = isMonth(f);
    bool bm = isMonth(b);
    if ( !fm && !bm ){
        cout << "NA" << endl;
    }
    else if ( fm && bm ) {
        cout << "AMBIGUOUS" << endl;
    }
    else if ( fm && !bm) {
        cout << "MMYY" << endl;
    }
    else if ( !fm && bm) {
        cout << "YYMM" << endl;
    }

    return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  using ll = long long;
  ll x;
  cin >> x;

  vector<ll> memo;
  for (ll i = 0; i < 1000; ++i) {
    memo.push_back(pow(i, 5));
  }

  ll a, b;
  for (ll i = 0; i < memo.size(); ++i) {
    // a^5 + b^5 = x
    auto add_it = lower_bound(memo.begin(), memo.end(), x - memo[i]);
    if (add_it != memo.end() && *add_it == x - memo[i]) {
      a = i;
      b = -distance(memo.begin(), add_it);
      break;
    }

    // a^5 - b^5 = x
    auto sub_it = lower_bound(memo.begin(), memo.end(), memo[i] - x);
    if (sub_it != memo.end() && *sub_it == memo[i] - x) {
      a = i;
      b = distance(memo.begin(), sub_it);
      break;
    }
  }

  cout << a << ' ' << b << '\n';

  return 0;
}

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

int main(void) {

  int A, P;
  //cout << "How many apples?" << endl;
  cin >> A;
  //cout << "How many apple piece" << endl;
  cin >> P;

  int num;
  num = 3*A + P;
  cout << num/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(){
  int a, b, c;
  std::cin >> a >> b >>c;
  if(a < b){
    if(b < c) std::cout << a << " " << b << " " << c << std::endl;
    else if(a < c) std::cout << a << " " << c << " " << b << std::endl;
    else std::cout << c << " " << a << " " << b << std::endl;
  }else if(a > b){
    if(a < c) std::cout << b << " " << a << " " << c << std::endl;
    else if(b < c) std::cout << b << " " << c << " " << a << std::endl;
    else std::cout << c << " " << b << " " << a << std::endl;
  }
}


Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<algorithm>
#include<cctype>
using namespace std;
int main() {
	string a, b, c;
	cin >> a >> b >> c;
	a = a.at(0) - 32;
	b = b.at(0) - 32;
	c = c.at(0) - 32;
	cout << a << b << c << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;
using vi = vector<int>;
#define rep(i,n) for(int i=0;i<(int) n;i++)
#define rep1(i,m,n) for(int i=(int) m;i<(int) n;i++)
#define fix(n) cout << fixed << setprecision((int)n)

void absll(ll &x) {
    if(x>=0) return ;
    else x=-x; return;
}

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 ll INF = 1LL << 60;

int N;

//DPテーブル
vector<ll> dp(100010);

int main() {
    string s,t;
    cin >> s >> t;
    rep(i,s.size()) {
        if(s.at(i)!=t.at(i)) {
            cout <<"No"<< endl;
            return 0; 
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 3836
#include <cstdlib>
#include <iterator>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cctype>
#include <functional>
using namespace std;

int main() {
    string n;
    cin >> n;
    for(int i = 0; i < n.size(); i++) {
        if(n[i] == '1') cout << 9;
        else cout << 1;
    }
    cout << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include <algorithm>
#include <functional>

using namespace std;

int main (void){
    long long int N,K,S;
    cin >> N >>K;
    cin >> S;
    for(int i = 0; i <K;i++){
        cout << S <<" ";
    }
    if(S==1000000000){
        for(int i = 0; i <N-K;i++){
            cout << S-1 <<" ";
        }
    }
    else{
        for(int i = 0; i <N-K;i++){
            cout << S+1 <<" ";
        }
    }
    return 0; 
}

Measured memory_bytes: 1280
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;

 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int x = sc.nextInt();
    int y = sc.nextInt();
    int larger = x > y ? x : y;
    int smaller = x > y ? y : x;
    while(true){
      if(larger % smaller == 0){
        System.out.println(smaller);
        break;
      }
      int joyo = larger % smaller;
      larger = smaller;
      smaller = joyo;
    }
  }
 
  
// LinkedList<Integer>[] setsu = new LinkedList[n];
// for(int i = 0; i < n; i++){
//   setsu[i] = new LinkedList<Integer>();
// } 

 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;

      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }

      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 17032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, ll> Pil;

int X, Y;

int main() {
    cin >> X >> Y;

    if (Y % 2 == 0) {
        if (Y/2 - X >= 0 && 2*X - Y/2 >= 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std; 
const int dx[]={1,0,-1,0,1,-1,-1,1}; 
const int dy[]={0,1,0,-1,1,1,-1,-1}; 
const int INF = 1e9; 
const long long LINF = 1e18; 
const double EPS = 1e-8; 
#define pb push_back
#define mk make_pair 
#define fr first 
#define sc second 
#define reps(i,j,k) for(ll i = (j); i < (k); ++i) 
#define rep(i,j) reps(i,0,j) 
#define all(a) (a).begin(),(a).end() 
#define MOD 1000000007 
typedef pair<int,int> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;
typedef long long ll;

template<class T>
ostream& operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()){
		out << v[i] <<", ";
	}
	return out << "}" << endl;
}
ll dp[201][201][201];
int main(){
	int n;
	cin >> n;
	vi a;
	rep(i,n){
		string c;
		cin >> c;
		if(c[0] == 'U'){
			a.pb(1);
		}
		else if(c[0] == 'D'){
			a.pb(-1);
		}
	}
	n = a.size();
	dp[0][0][0] = 1;
	rep(i,n){
		rep(j,i+1){
			rep(k,i+1){
				if(a[i] == 1){
					dp[i+1][j+1][k+1] += dp[i][j][k];
					dp[i+1][j+1][k+1] %= MOD;
					dp[i+1][j][k] += dp[i][j][k]*k;
					dp[i+1][j][k] %= MOD;
				}
				else if(a[i] == -1){
					dp[i+1][j][k] += dp[i][j][k] * j;
					dp[i+1][j][k] %= MOD;
					if(j > 0 && k > 0){
						dp[i+1][j-1][k-1] += dp[i][j][k] * j * k;
						dp[i+1][j-1][k-1] %= MOD;
					}
				}
			}
		}
	}
	cout << dp[n][0][0] << endl;
	return 0;
}

Measured memory_bytes: 33832
#include <stdio.h>
#include <string.h>

#define DEBUG (0)

int main(void)
{
  unsigned long N = 0;
  unsigned long blue = 0;
  unsigned long red = 0;
  unsigned long setnum = 0;
  unsigned long amari = 0;
  unsigned long resultnum = 0;
  
  scanf("%lu %lu %lu\n",&N, &blue, &red);
  
  setnum = N/(blue+red);
  amari = N%(blue+red);
  
#if DEBUG
  printf("%lu\n", setnum);
  printf("%lu\n", amari);
#endif
  
  if(amari < blue){
    resultnum = setnum*blue + amari;
  }else{
    resultnum = setnum*blue + blue;
  }
  
  printf("%lu\n", resultnum);
  

}

Measured memory_bytes: 128
S = input()
N = len(S)
dp = [[0] * 13 for i in range(N + 1)]
dp[0][0] = 1
MOD = 10 ** 9 + 7

for i in range(N):
    if S[i] == '?':
        for k in range(10):
            for j in range(13):
                dp[i + 1][(j * 10 + k) % 13] += dp[i][j]
    else:
        k = int(S[i])
        for j in range(13):
            dp[i + 1][(j * 10 + k) % 13] += dp[i][j]

    for j in range(13):
        dp[i + 1][j] %= MOD

print(dp[N][5])






Measured memory_bytes: 61788
open Printf open Scanf
module MyInt = struct let (+) = (+) let (-) = (-) let (/) = (/) let ( * ) = ( * ) let (mod) = (mod) let (%) = (mod) let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v end
module MyInt64 = struct
	let (+$) = (+) let (-$) = (-) let (/$) = (/) let ( *$) = ( * ) let (+) p q = Int64.add p q let (-) p q = Int64.sub p q let ( * ) p q = Int64.mul p q let (/) p q = Int64.div p q let (+=) r v = r := !r + v let (-=) r v = r := !r - v let ( *=) r v= r := !r * v let (/=) r v = r := !r / v let labs p = if p < 0L then -1L*p else p let (~|) p = Int64.to_int p let (~~|) p = Int64.of_int p let input_i64_array n = Array.init (~| n) (fun _ -> Scanf.scanf " %Ld" (fun v -> v)) let get_i64 _ = Scanf.scanf " %Ld" (fun v -> v) let get_2_i64 _ = Scanf.scanf " %Ld %Ld" (fun u v -> u,v) let get_3_i64 _ = Scanf.scanf " %Ld %Ld %Ld" (fun u v w -> u,v,w) let get_4_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld" (fun u v w x -> u,v,w,x) let get_5_i64 _ = Scanf.scanf " %Ld %Ld %Ld %Ld %Ld" (fun u v w x y -> u,v,w,x,y) let print_i64_endline n = n |> Int64.to_string |> print_endline let (mod) m n = m - (m/n) * n let (%) = (mod) let rec gcd m n = match m,n with | m,0L -> m | m,n -> gcd n (m mod n) let lcm m n = (m*n) / gcd m n let rep from_ to_ fbod = let i,f = ref ~|from_,ref true in while !i <= ~|to_ && !f do match fbod ~~| !i with | `Break -> f := false | _ -> i := !i +$ 1; done
	let string_of_list ?(separator=" ") f ls = let rec f0 a s = match a with | [] -> s | [h] -> s ^ (f h) ^ separator | h::t -> f0 t (s ^ (f h) ^ separator) in f0 ls "" let char_list_of_string str = let rec f0 i a = if i<0 then a else f0 (i-$1) (str.[i]::a) in f0 (String.length str -$ 1) [] let string_of_char_list ls = List.fold_left (fun u v -> u ^ (String.make 1 v)) "" ls
	let (@@@) = (@) let (@) a i = a.(~|i) let (<@) a (i,v) = a.(~|i) <- v
	let ceildiv m n = (m+n-1L) / n
end open MyInt64
let (@) a (i,j) = a.(~|i).(~|j) let (<@) a (i,j,v) = a.(~|i).(~|j) <- v let (<+) a (i,j,v) = a.(~|i).(~|j) <- v + a.(~|i).(~|j)

let () =
	let h,w = get_2_i64 0 in
	let a = Array.init (~|h) (fun _ -> input_i64_array w)
	in
	let ls = ref [] in
	rep 0L (h-2L) (fun i ->
		rep 0L (w-2L) (fun j ->
			if (a@(i,j)) mod 2L = 1L then (
				a<+(i,j,-1L);
				a<+(i,j+1L,1L);
				ls := (i,j,i,j+1L)::!ls;
			); `Ok
		);
		let j = w-1L in
		if (a@(i,j)) mod 2L = 1L then (
			a<+(i,j,-1L);
			a<+(i+1L,j,1L);
			ls := (i,j,i+1L,j)::!ls;
		);
		`Ok
	);
	let i = h-1L in
	rep 0L (w-2L) (fun j ->
		if (a@(i,j)) mod 2L = 1L then (
			a<+(i,j,-1L);
			a<+(i,j+1L,1L);
			ls := (i,j,i,j+1L)::!ls;
		); `Ok
	);
	printf "%d\n" @@ List.length !ls;
	List.iter (fun (p,q,r,s) -> let p,q,r,s = p+1L,q+1L,r+1L,s+1L
	in printf "%Ld %Ld %Ld %Ld\n" p q r s) @@ List.rev !ls;



Measured memory_bytes: 34800
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
string s;
ll ans=0;

void cal(int i,ll sum,ll kari)
{
	if(s.size()==i)
  {
		ans+=sum+kari;
		return;
	}
	cal(i+1,sum,kari*10+(s[i]-'0'));
	cal(i+1,sum+kari,s[i]-'0');
}

int main()
{
	cin>>s;
	cal(0,0,0);
	cout<<ans/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = n-1; i > 0; i--)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};


template<class T>
T gcd(T a,T b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(a%b,b);
}

bool solve(){
  ll n;cin>>n;
  vector<ll>a(n);
  vector<ll>v(n);
  rep(i,n)cin>>a[i];
  rep(i,n)v[i]=a[i]-i-1;
  sort(all(v));
  ll b=v[n/2];
  ll ans=0;
  rep(i,n)ans+=abs(a[i]-b-i-1);
  cout<<ans<<endl;
  return false;
}


signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 3456
import sys
readline = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
#mod = 998244353
INF = 10**18
eps = 10**-7

n = int(readline())
node = [[] for i in range(n)]

for i in range(n-1):
    u,v,w = map(int,readline().split())
    node[u-1].append((v-1,w))
    node[v-1].append((u-1,w))
ans = [-1]*n
ans[0] = 0
def dfs(fro, to, dis):
    ans[to] = dis%2
    for nxt, dist in node[to]:
        if nxt == fro:
            continue
        dfs(to, nxt, (dis+dist)%2)

for to,dis in node[0]:
    dfs(0,to,dis)

print("\n".join(map(str,ans)))



Measured memory_bytes: 187080
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int              { return readIntArray()[0] }
func readInt2() (int, int)      { a := readIntArray(); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(); return a[0], a[1], a[2] }
func readIntArray() []int {
        a := make([]int, 0, 1000)
        sc.Scan()
        for _, v := range strings.Split(sc.Text(), " ") {
                vv, _ := strconv.Atoi(v)
                a = append(a, vv)
        }
        return a
}
func readString() string        { return readStringArray()[0] }
func readStringArray() []string { sc.Scan(); return strings.Split(sc.Text(), " ") }

func main() {
        a, b := readInt2()

        av, bv := a, b
        for i := 0; i < 100000000; i++ {
                //fmt.Printf("a: %d, b: %d\n", av, bv)
                if av < bv {
                        av += a
                } else if bv < av {
                        bv += b
                } else {
                        fmt.Println(av)
                        return
                }
        }
}

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

struct Fraction{
    long long c, p;

    Fraction(long long c, long long p){
        this->c = c;
        this->p = p;
    }

    Fraction operator+ (Fraction obj){
       return Fraction(this->c * obj.p + this->p * obj.c, this->p * obj.p);
    }

    bool operator< (Fraction obj){
        return (this->c * obj.p < this->p * obj.c);
    }

    bool operator> (Fraction obj){
        return (obj < *this);
    }

    bool operator== (Fraction obj){
        return (this->c * obj.p == this->p * obj.c);
    }
};

int func(Fraction target, int a, int n, Fraction sum, int cnt, int product, int lower){
    
    int ret = 0;
    
    if(cnt == n){
        return 0;
    }

    int upper = a / product;
    for(int i = upper; i >= lower; i--){
        Fraction temp(1, i);
        Fraction nextSum = sum + temp;
        if(nextSum == target){
            ret++;
            break;
        }
        if(nextSum > target){
            break;
        }
        ret += func(target, a, n, nextSum, cnt + 1, product * i, i);
    }

    return ret;
}

int main(){

    while(true){
        int p, q, a, n;
        cin >> p >> q >> a >> n;
        if(p == 0){
            break;
        }

        int ans = func(Fraction(p, q), a, n, Fraction(0, 1), 0, 1, 1);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3084
from collections import deque
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    n,q=map(int, input().split())
    aa=[[] for _ in range(n)]
    for _ in range(q):
        qq=list(map(int, input().split()))
        if qq[0]==0:
            aa[qq[1]].append(qq[2])
        elif qq[0]==1:
            print(*aa[qq[1]])
        else:
            aa[qq[1]]=[]

main()


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

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

int main()
{
    int N;
    cin >> N;
    int max = -1;
    long sum = 0;
    rep(i, N){
        int p;
        cin >> p;
        sum += p;
        if(max < p){
            max = p;
        }
    }

    cout << ((sum - max) + (max / 2)) << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] s){
    maxi();
    }
  	public static void maxi(){
    	Scanner s = new Scanner(System.in);
    	int sum = 0;
    	int n = s.nextInt();
    	int[] bs = new int[n -1];
    	for (int i = 0; i < n - 1; i++){
    		bs[i] = s.nextInt();
		}

    	
		sum += bs[0] + bs[n - 2];
    	for (int i = 0; i < n - 2; i++)
    		sum += (int) Math.min(bs[i],bs[i+1]);

    	System.out.println(sum);
	}
  
}

Measured memory_bytes: 22740
#include<iostream>
using namespace std;
int main(){
  int n,m,p,x[100],a,ans;
  double b;
  while(1){
    a=0;
    cin>>n>>m>>p;
    if(n+m+p==0)break;
    for(int i=1;i<=n;i++){
      cin>>x[i];
      a+=x[i];
    }
    a*=100;
    if(x[m]==0)cout<<0<<endl;
    else{     
      b=(double)p/100; 
      b=(int)(a*b);
      ans=(a-b)/x[m];
      cout<<ans<<endl;
	}
  }
  return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    
    class Solve
    {
        const int mod = 1000000007;
        
        
        static void Main(string[] args)
        {

            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            int N = int.Parse(Console.ReadLine());
            int[] d = new int[N];
            for(var i = 0; i < N; i++)
            {
                d[i] = int.Parse(Console.ReadLine());
            }

            Console.WriteLine(d.Distinct().Count());
            

            //Console.Out.Flush();

        }

        
    }

    public class Calculation
    {

    }

    public class Graph
    {
        
    }
}




Measured memory_bytes: 13152