akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>

using namespace std;

#define ll long long

void solve()
{
    string S;
    cin >> S;
    ll size = S.size();

    bool isOk = true;
    for (ll i = 0; i < size; i++)
    {
        bool isEven = ((i + 1) % 2 == 0);
        if (isEven)
        {
            if (S[i] != 'L' && S[i] != 'U' && S[i] != 'D')
            {
                isOk = false;
            }
        }
        else
        {
            if (S[i] != 'R' && S[i] != 'U' && S[i] != 'D')
            {
                isOk = false;
            }
        }
    }

    cout << (isOk ? "Yes" : "No") << endl;
}

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


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {

    int n, a;
    scanf("%d", &n);

    double mysum = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d", &a);
        mysum += (double) 1 / a;

    }

    printf("%f", (double) 1 / mysum);
    return 0;

}

Measured memory_bytes: 128
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first 
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e5)+10;
vii adj(N);
int a[N],b[N];
int dp[N];
void  solve(){

}
int32_t main()
{
    FIO
    int n,w; cin>>n>>w;
    fi(i,n) cin>>a[i]>>b[i];
    fi(i,w+1) dp[i]=0;
    for(int i=0;i<n;i++){
        for(int j=w-a[i];j>=0;j--){
            dp[j+a[i]]=max(dp[j+a[i]],dp[j]+b[i]);
        }
    }
    cout<<dp[w]<<"\n";
    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

Measured memory_bytes: 15820
#include <iostream>
#include <string>
#include <map>
#include <deque>
#include <vector>
typedef unsigned int UINT;
using namespace std;

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


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
l=[0]*n
for i in range(n-1,-1,-1):
    x=l[i:n:i+1]
    if a[i]==x.count(1)%2:
        l[i]=0
    else:
        l[i]=1
print(l.count(1))
ans=[]
for i in range(n):
    if l[i]==1:
        ans.append(i+1)
ans=map(str,ans)
print(" ".join(ans))


Measured memory_bytes: 81128
x1, y1, x2, y2 = map(int, input().split())

dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx
x4 = x1 - dy
y4 = y1 + dx

print(x3, y3, x4, y4)


Measured memory_bytes: 9028
import sys

A=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
for i in range(n):
    b=int(input())
    for l in range(3):
        if b in A[l]:
            A[l][A[l].index(b)]=0

for i in range(3):
    if A[i][0] == A[i][1] == A[i][2]:
        print('Yes')
        sys.exit()
    elif A[0][i] == A[1][i] == A[2][i]:
        print('Yes')
        sys.exit()
if A[0][0] == A[1][1] == A[2][2]:
    print('Yes')
    sys.exit()
elif A[0][2] == A[1][1] == A[2][0]:
    print('Yes')
    sys.exit()
else:
    print('No')


Measured memory_bytes: 9180
#include<iostream>
using namespace std;
#define M 100005
#define N -1

struct Node{int p,l,r;};

Node t[M];
int n,d[M];

void pri(int u){
	int i,c;
	cout<<"node "<<u<<": ";
	cout<<"parent = "<<t[u].p<<", ";
	cout<<"depth = "<<d[u]<<", ";
	
	if(t[u].p==N)cout<<"root, ";
	else if(t[u].l==N)cout<<"leaf, ";
	else cout<<"internal node, ";
	
	cout<<"[";
	
	for(i=0,c=t[u].l;c!=N;i++,c=t[c].r){
		if(i)cout<<", ";
		cout<<c;
	}
	cout<<"]"<<endl;
}

int rec(int u,int p){
	d[u]=p;
	if(t[u].r!=N)rec(t[u].r,p);
	if(t[u].l!=N)rec(t[u].l,p+1);
	return 0;
}

int main(){
	int i,j,d,v,c,l,r;
	cin>>n;
	for(i=0;i<n;i++)t[i].p=t[i].r=t[i].l=N;
	
	for(i=0;i<n;i++){
		cin>>v>>d;
		for(j=0;j<d;j++){
			cin>>c;
			if(j==0)t[v].l=c;
			else t[l].r=c;
			l=c;
			t[c].p=v;
		}
	}
	for(i=0;i<n;i++){
		if(t[i].p==N)r=i;
	}
	
	rec(r,0);
	
	for(i=0;i<n;i++) pri(i);
	
	return 0;
}


Measured memory_bytes: 7760
#include <iostream>
#include <cstdlib>
#include <queue>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
#include <bitset>
using namespace std;

int main()
{
    string s;
    int itr;
    long long ans, tmp;
    ans = 0;
    cin >> s;
    if(s.length() == 1){
        ans = stoi(s);
    }
    else {
        bitset<9> b;
        int l = s.length() - 1;
        for(int i=0; i<(int)pow(2, l); ++i){
            b = static_cast<bitset<9>>(i);
            itr = 0;
            tmp = 0;
            // cout << b << endl;
            tmp = (long long)(s[itr] - '0');
            // cout << tmp << endl;
            for(int j=l-1; j>=0; --j){
                if(b[j] == 0){
                    tmp = 10 * tmp + (s[++itr] - '0');
                }
                else {
                    ans += tmp;
                    tmp = (long long)(s[++itr] - '0');
                }
                // cout << "tmp is " << tmp << endl;
            }
            ans += tmp;
            // cout << "tmp ans: " << ans << endl;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
using namespace std;
typedef pair<int,int> P;// F -> to, S -> cost
typedef pair<P,int> PP;// F->P(to,cost), S->discount
int c,n,m,s,d;
vector<P> vec[1000]; // F -> pos , S -> cost
int MD[1000][13];
const int INF = 1<<29;

void dijkstra(){
  priority_queue<PP,vector<PP>,greater<PP> > que;
  rep(i,n+1)rep(j,13)MD[i][j] = INF;
  //syokika
  MD[s][c] = 0;
  que.push(PP(P(0,s),c));//dis,start,discount

  while(!que.empty() ){
    PP p = que.top();que.pop(); //priority_queのPPと
    int v = p.F.S;
    
    for(int i=0;i<vec[v].size();i++){
      P po = vec[v][i]; //vectorのPPは意味が違うので注意！！！
      //if(MD[v][po.S] < po.F.S)continue;
      if(MD[po.F][p.S] > p.F.F + po.S){
	MD[po.F][p.S] = p.F.F+po.S;
	que.push(PP(P(MD[po.F][p.S],po.F),p.S));
      }
      if(p.S > 0 && MD[po.F][p.S-1] > p.F.F + po.S/2 ){
	MD[po.F][p.S-1] = p.F.F+po.S/2;
	que.push(PP(P(MD[po.F][p.S-1],po.F),p.S-1));
   
      }
    }
  }
}


int main(){
  int x,y,co;
  while(true){
    cin >> c >> n >> m >> s >> d;
    if(c+n+m+s+d == 0)break;
    rep(i,1000)vec[i].clear();
    rep(i,m){
      cin >> x >> y >> co;
      vec[x].push_back(P(y,co));
      vec[y].push_back(P(x,co));
    }
    dijkstra();
    int ans = INF;
    for(int i=0;i<=c;i++){
      ans = min(ans,MD[d][i]);
    }
    cout << ans << endl;
  }
  return 0;
}

//Version.1

Measured memory_bytes: 1268
import qualified Data.Set as S

---
readInt :: String -> Int
readInt = read

remove :: Eq a => a -> [a] -> [a]
remove e = filter (/= e)

---
main :: IO ()
main = do
    [price, _] <- fmap (map readInt . words) getLine
    hDigits    <- fmap (S.fromList . remove ' ') getLine
    
    print $ head [
        p | p <- [1..], 
        S.null $ S.intersection hDigits (S.fromList . show $ p),
        price <= p
        ]


Measured memory_bytes: 4868
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());

        // 主処理
        long div = (long) Math.sqrt(n);
        while (n % div != 0) {
            div--;
        }
        long result = div + n / div - 2;

        // 出力
        System.out.println(result);
        sc.close();
    }
}


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

using namespace std;

typedef long long ll;

int main(){

    int n, k;
    cin >> n >> k;

    string s;
    cin >> s;
    int mx = 0;
    int l = 0, r = 0, cur = 0;
    bool started = false;

    for( ; l < n; l++){
        while( r < n ){
            if( s[r] == '0' ){
                if( !started )
                    started = true, cur++;
            }else{
                started = false;
            }
            if( cur > k )
                break;
            r++;
        }

        mx = max(mx, r-l);
        if( l != n-1 )
            if( s[l] == '0' && s[l+1] == '1' )
                cur--;
    }

    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

// ^= -> ビットごとの排他的論理和を計算する

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	vector<double>a(n); rep(i, n)cin >> a[i];
	double sum = 0;
	rep(i, n) {
		sum += (1 / a[i]);
	}
	cout << fixed << setprecision(15) << 1 /sum << endl;
	return 0;
}

Measured memory_bytes: 256
from functools import reduce
import numpy as np


def _gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def gcd(*n):
    return reduce(_gcd, n)


def my_bisect(x):

    def find_pos(left, right):
        return left + (right - left - 1) // 2

    def func(left, right, prev):
        if right - left == 1:
            return [left]
        if right - left == 2:
            return [left, left+1]
        pos = find_pos(left, right)
        g1 = gcd(*x[left:pos+1])
        g2 = gcd(*x[pos+1:right])
        if prev is not None:
            g1, g2 = gcd(g1, prev), gcd(g2, prev)
        if g1 < g2:
            return func(left, pos + 1, max(g1, g2))
        else:
            return func(pos + 1, right, max(g1, g2))
    return func(0, len(x), None)


N = int(input())
A = list(map(int, input().split()))
print(max([gcd(*np.delete(A, i)) for i in my_bisect(A)]))



Measured memory_bytes: 24776
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int A= 0, B =0 ;
	for(int i = 0; i < 3; i++)
	{
	 	if(s[i]=='A')
	 	{
	 		A++;
	 	}
	 	else
	 	{
	 		B++;
	 	}
	}
	if(A==3 || B == 3)
	{
		cout << "No";
	}
	else
	{
		cout << "Yes";
	}
}

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


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    string s;
    ll n;
    cin >> s >> n;
    ll siz=s.size();
    vector<ll>cnt(siz,1);
    ll x=0;
    for(ll i=0;i<siz-1;i++){
        if(s[i]==s[i+1]){
            cnt[x]++;
        }
        else {
            x++;
        }
    }
    ll ans=0;
    for(ll i=0;i<siz;i++){
        ans+=cnt[i]/2;
    }
    for(ll i=siz-1;i>=0;i--){
        if(cnt[i]!=1){
            x=i;
            break;
        }
    }
    ans*=n;
    if(x==0){
        cout << siz*n/2 << endl;
        return 0;
    }
    if(s[0]==s[siz-1]){
        ans-=((cnt[0]/2)+(cnt[x]/2)-((cnt[0]+cnt[x])/2))*(n-1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }
 
using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;
 
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};
 
const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod


#include <bits/stdc++.h>
using namespace std;
signed main(){
    string N; cin>>N;
    vec O(2,0);
    REP(i,N.size()){
        if(N[i]=='0') O[0] ++;
        else O[1] ++;
    }
    int ans = min(O[0],O[1])*2;
    Out(ans);
}

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

using namespace std;

ifstream fin("fisier.in");
ofstream fout("fisier.out");

char s[100005];
char actual;

int main(){
    int n,i,j,answer=1;

    cin>>n;
    cin>>s;

    actual=s[0];

    for(i=1;i<n;i++)
        if(s[i]!=actual){
            actual=s[i];
            answer++;
        }

    cout<<answer;

    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long a, b, x;
	cin >> a >> b >> x;
	long long   i= a/x;
	long long  j= b/x;
	if (a%x == 0) {
		cout << j - i + 1 << endl;
	}
	else {
		cout << j - i << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ljc 998244353
using namespace std;
#define gc getchar
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
int n,m,col[1011010],x[1010][1010];
int vis[101010],mat[101010],matt[101010];
vector<int> e[10101]; 
int check(int u,int tim){
    for (auto v:e[u]){
        if (tim^vis[v]){
            vis[v]=tim;  
            if (!mat[v]||check(mat[v],tim)){
                mat[v]=u;matt[u]=v;return 1;
            }
        }
    }
    return 0;
}
int num[1010][1010];
void solve(int i){
	if (i>m) return;
	for (int j=1;j<=n;j++){
		e[j].clear();
		mat[j]=vis[j]=0;
		for (int k=i;k<=m;k++){
			e[j].push_back(x[j][k]);
		}
	}
	int ans=0;
	for (int j=1;j<=n;j++) ans+=check(j,j);
//	assert(ans==n);
	for (int j=1;j<=n;j++){
		if (matt[j]==x[j][i]) continue;
		for (int k=i;k<=m;k++){
			if (matt[j]==x[j][k]){
				swap(x[j][i],x[j][k]),swap(num[j][i],num[j][k]);break;
			}
		}
	}
	solve(i+1);
}
inline void mysort(int k){
	for (int i=1;i<=n;i++){
		for (int j=1;j<n;j++){
			if (num[j][k]>num[j+1][k]) swap(num[j][k],num[j+1][k]);
		}
	}
}
inline void print(){
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			printf("%d ",num[i][j]);
		}
		puts("");
	}
}
signed main(){
	n=read(),m=read();
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			num[i][j]=x[i][j]=read();
			col[(i-1)*m+j]=i;
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++){
			x[i][j]=col[x[i][j]];
		}
	}
	solve(1);
	print();
	for (int j=1;j<=m;j++) mysort(j);
	print();
	return 0;
}



Measured memory_bytes: 4872
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <string>

using namespace std;

using ll = long long;

ll S(ll n) {
    ll ret = 0;
    
    while(n > 0) {
        ret += n % 10;
        
        n /= 10;
    }
    
    return ret;
}

int main() {
    vector<ll> ans;
    
    for (int i = 1; i < 10; i++) {
        ans.push_back(i);
    }
    
    for (int i = 0; i <= 15; i++) {
        for (int j = 1; j < i * 10; j++) {
            bool ok = true;
            
            ll n = stoll(to_string(j) + string(i, '9'));
            
            for (int k = j + 1; k < i * 10; k++) {
                ll m = stoll(to_string(k) + string(i, '9'));
                
                if (n * S(m) > m * S(n)) {
                    ok = false;
                    break;
                }
            }
            
            if (ok) {
                ans.push_back(n);
            }
        }
    }
    
    sort(ans.begin(), ans.end());
    
    ans.erase(unique(ans.begin(), ans.end()), ans.end());
    
    int k;
    cin >> k;
    
    for (int i = 0; i < k; i++) {
        cout << ans[i] << endl;
    }
}


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

int main()
{

    string s;

    cin >> s;

    if(s[0]=='Y' && s[1]=='A' && s[2]=='K' && s[3]=='I')
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


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

int main(){
  int l,r,d,ans=0;
  cin>>l>>r>>d;
  for(int i=1;i<=100;i++){
    if(l<=d*i && d*i<=r)ans++;
  }
  cout<<ans<<endl;
}


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

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

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

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

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

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

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

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

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

use std::cmp::{max, min};

fn main() {
    input! {
        n: usize,
        w: usize,
        wv: [(usize, i64); n],
    }

    let mut tbl = vec![vec![0; w + 1]; n + 1];

    for i in 0..w + 1 {
        for j in 0..n {
            let mut t = tbl[j][i];
            if i >= wv[j].0 {
                t = max(t, tbl[j][i - wv[j].0] + wv[j].1);
            }

            tbl[j + 1][i] = t;
        }
    }

    let ans = tbl[n][w];

    println!("{}", ans);
}


Measured memory_bytes: 106748
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    string s,t;
    cin>>s>>t;

    for(int i=0;i<s.size();i++){
        for(int j=i+1;j<s.size();j++){
            if(s[i]>=s[j]){
                char c;
                c=s[j];
                s[j]=s[i];
                s[i]=c;
            }
        }
    }
    for(int i=0;i<t.size();i++){
        for(int j=i+1;j<t.size();j++){
            if(t[i]<=t[j]){
                char c;
                c=t[j];
                t[j]=t[i];
                t[i]=c;
            }
        }
    }
    
    //cout<<s<<endl<<t<<endl;
    
    if(s<t){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
function main(input) {
    const nums = input.trim().split(/\n/)[1]
        .split(/\s/).map(str => { return Number(str) })
        .sort((a, b) => { return b - a });
    const sum = nums.slice(1).reduce((res, pre) => {
        return res + pre;
    }, 0);
    console.log(nums[0] < sum ? 'Yes' : 'No');
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
n = int(input())
a = list(map(int, input().split(' ')))
res = 1
a = sorted(a)
for i in range(n):
    res = res * a[i]
    if(a[i] == 0):
      print(0)
      exit()
    if res > 1000000000000000000:
        print(-1)
        exit()
print(res)

Measured memory_bytes: 83696
#include <bits/stdc++.h>
using namespace std;
struct UF {
    int *par;
    UF(int n) {
        par=new int[n];
        for(int i=0;i<n;i++) par[i]=i;
    }
    int find(int x) {
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    void unite(int x,int y) {
        x=find(x);
        y=find(y);
        if(x==y) return;
        par[x]=y;
    }
    bool same(int x,int y) {
        return find(x)==find(y);
    }
};
int marked[100000];
char op[100000][2];
int v[100000];
int par[100000];
int main() {
    int N,Q;
    while(scanf("%d %d",&N,&Q),N) {
        par[0]=-1;
        for(int i=1;i<N;i++) {
            scanf("%d",&par[i]);par[i]--;
        }
        fill(marked,marked+100000,0);
        marked[0]=1;
        for(int i=0;i<Q;i++) {
            scanf("%s %d",op[i],&v[i]);v[i]--;
            if(op[i][0]=='M') marked[v[i]]++;
        }
        UF u(N);
        for(int i=1;i<N;i++) {
            if(marked[i]==0) u.unite(i,par[i]);
        }
        long long ans=0;
        for(int i=Q-1;i>=0;i--) {
            if(op[i][0]=='M') {
                if(marked[v[i]]>0) {
                    marked[v[i]]--;
                    if(marked[v[i]]==0) u.unite(v[i],par[v[i]]);
                }
            }else {
                ans+=u.find(v[i])+1;
            }
        }
        printf("%lld\n",ans);
    }
}

Measured memory_bytes: 4536
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i,j,n) for (int i=(j); i < (n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
    string s; int k; cin >> s >> k;
    string two = s + s;
    string two_ = s + s + s;
    ll a = 0, b = 0, c = 0;
    rep(i, s.size()-1){
        if(s[i] == s[i+1]){
            a++;
            i++;
        }
    }
    rep(i, two.size()-1){
        if(two[i] == two[i+1]){
            b++;
            i++;
        }
    }
    rep(i, two_.size()-1){
        if(two_[i] == two_[i+1]){
            c++;
            i++;
        }
    }
    c -= a;
    ll res;
    if(k%2==0){
        res = b + (k-2)/2 * c;
    }
    else{
        res = a + (k-1)/ 2 * c;
    } 
    cout << res << ln;
}

Measured memory_bytes: 256
package main

import(
	"fmt"
)

func isEven(in [200]int, n int) bool{
		for i := 0; i < n; i++ {
				if in[i]%2 == 1 {
						return false
				}
		}
		return true
}

func div(in [200]int, n int) [200]int {
		for i := 0; i < n; i++ {
				in[i] = in[i] / 2
		}
		return in
}

func main() {
		var ans int
		ans = 0
		var flag bool
		flag = true

		var n int
		fmt.Scan(&n)
		var in [200]int
		for i := 0; i < n; i++ {
			fmt.Scan(&in[i])
		}

		for flag  {
				flag = isEven(in, n)
				in = div(in ,n)
				ans++
		}

		fmt.Println(ans-1)
}


Measured memory_bytes: 512
n,c,k=map(int,input().split())
tl=[int(input()) for i in range(n)]
tl.sort()
i=0
bus_count=0
while i<n:
  bus_count+=1
  start=i
  while i<n and tl[i]-tl[start]<=k and i-start<c:
    i+=1
print(bus_count)

Measured memory_bytes: 7384
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
signed main() {
    int H, W, A, B; cin >> H >> W >> A >> B;
    int X = H / A;
    int Y = W / B;
    cout << H * W - (X * Y * A * B) << endl;
    return 0;
}



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

int main()
{
	int A, B, M;
	cin >> A >> B >> M;
	vector<int> a(A), b(B);
	for (int i = 0; i < A; ++i) cin >> a[i];
	for (int i = 0; i < B; ++i) cin >> b[i];
	
	int x[M], y[M], c[M];
	int min_next = 1e9;
	for (int i = 0; i < M; ++i)
	{
		cin >> x[i] >> y[i] >> c[i];
		
		if (min_next > a[x[i]-1] + b[y[i]-1] - c[i])
		{
			min_next = a[x[i]-1] + b[y[i]-1] - c[i];
		}
	}
	
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	
	cout << min(a[0] + b[0], min_next) << endl;
	
	return 0;
}


Measured memory_bytes: 2176
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;

            n =int.Parse(Console.ReadLine());

            if(n%10 == 9 || n/10 ==9)
            Console.WriteLine("Yes");

            else
            Console.WriteLine("No");

            Console.ReadKey();

        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;
 
int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
 
    ll straight = min(K, X / D);
    K -= straight;
    X -= straight * D;
 
    if (K % 2 == 0) {
        cout << X << endl;
    } else {
        cout << D - X << endl;
    }
 
    return 0;
}

Measured memory_bytes: 3600
s = input()

before = 0
before_2 = 1

for i in range(2, len(s)):
    if s[before] == s[before_2]:
        print(before + 1, before_2 + 1)
        exit()
    if s[before] == s[i] and s[before] != s[before_2]:
        print(before + 1, i + 1)
        exit()
    before = before_2
    before_2 = i
if s[-1] == s[-2]:
    print(len(s) - 1, len(s))
    
else:
    print(-1, -1)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define sorted(a_1) sort(a_1.begin(),a_1.end())
#define rsorted(a_1) sort(a_1.rbegin(),a_1.rend())
#define t1(a_1) cout<<a_1<<endl;
#define t2(a_1) for(auto it_test : a_1) cout<<it_test<<" ";
#define MOD 1000000007

long double dp[3001][3001];
long double probability(vector<double>&arr, int index, int tail){
	if(index<0 || tail<0){ return 1.0;}
	if(dp[tail][index]>0.0) return dp[tail][index];
	if(tail==0){
		dp[tail][index]=arr[index]*probability(arr,index-1,tail);
		return dp[tail][index];
	}
	else{
		dp[tail][index]=(1-arr[index])*probability(arr,index-1,tail-1)+arr[index]*probability(arr,index-1,tail);
		return dp[tail][index];
	}
}
void solve(){
    int n;
    cin>>n;
    vector<double>arr(n);
    for(int i=0;i<n;i++){
    	cin>>arr[i];
    }
    memset(dp,0,sizeof(dp));

    //top down
  	// long double ans = probability(arr,n-1,(n%2==0)?n/2-1:n/2);

  	//Bottom up
  	
  	for(int i=0;i<=((n%2==0)?n/2-1:n/2) + 1;i++){
  		for(int j=0;j<=n;j++){
  			if(i==0 || j==0) dp[i][j]=1.0;
  			else if(i==1){
  				dp[i][j] = arr[j-1]*dp[i][j-1];
  			}
  			else{
  				dp[i][j] = (1-arr[j-1])*dp[i-1][j-1] + arr[j-1]*dp[i][j-1];
  			}
  		}
  	}
  	cout<<fixed<<setprecision(10)<<dp[((n%2==0)?n/2-1:n/2) + 1][n];
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    while(t--){
        solve();
    }

return 0;
}

Measured memory_bytes: 144588
#include <stdio.h>

int main(void) {
    int mt_h[21];
    int n;
    int ans = 1;
    scanf("%d",&n);
    for(int i = 0;i<n;i++) {
        scanf("%d",&mt_h[i]);
    }
    for(int i = 1;i<n;i++) {
        int f = 0;
        for(int j = i-1;j>=0;j--) {
            if(mt_h[i]<mt_h[j]) {
                f = 1;break;
            }
        }
        if(f == 0) {
            ans += 1;
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n, m; cin >> n >> m;
    priority_queue<P> q;
    rep(i,n) {
        int a; cin >> a;
        q.push(make_pair(a,1));
    }
    rep(i,m){
        int b, c; cin >> b >> c;
        q.push(make_pair(c,b));
    }
    ll ans = 0;
    rep(i,n){
        P p = q.top();
        q.pop();
        ans += p.first;
        p.second--;
        if(p.second != 0) q.push(p);
    }
    cout << ans << endl;
}

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

using namespace std;

const int mod = 1007050321;
const int base = 521;
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
const int inf = 2e9;

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

    long long X;
    cin >> X;
    cout << X/500*1000 + (X - X/500*500)/5*5;

    return 0;
}


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

ll combination(ll n)
{
  if (n < 0)
  {
    return 0;
  }

  return n * (n - 1) / 2;
}

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> v(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    v[a[i] - 1]++;
  }
  ll all = 0;
  for (int i = 0; i < n; i++)
  {
    all += combination(v[i]);
  }

  for (int i = 0; i < n; i++)
  {
    cout << all - (v[a[i] - 1] - 1) << endl;
  }
}


Measured memory_bytes: 6416
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.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;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int N; char ans[10];

int DFS(int turn, int num){
  if (turn == N){
    for (int i = 0; i < N; i++){
      cout << ans[i];
    }
    cout << endl;
    return 0;
  }

  for (int i = 0; i < num; i++){
    ans[turn] = 'a' + i;
    DFS(turn + 1, num);
  }
  ans[turn] = 'a' + num;
  DFS(turn + 1, num + 1);
  return 0;
}

int main(){
  cin >> N; DFS(0, 0);

  return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mxn= 1e6+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    rishabh();
    int n,x,t;
    cin>>n>>x>>t;
    int ans=n/x;
    if(n%x)ans++;
    cout<<ans*t;
}

Measured memory_bytes: 3612
a = list(map(int,input().split()))
if a[0] != a[1] and a[0] != a[2] and a[1] != a[2]:
  print(3)
elif a[0] == a[1] and a[0] != a[2]:
  print(2)
elif a[0] != a[1] and a[0] == a[2]:
  print(2)
elif a[0] != a[1] and a[1] == a[2]:
  print(2)
elif a[0] == a[1] == a[2]:
  print(1)

Measured memory_bytes: 3064
//K-OS WITH THE OCDE

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <deque>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

typedef long long int ll;
typedef long double db;


#define TEST ll t; cin>>t; while(t--)
#define vell vector<ll>
#define pl pair<ll,ll>
#define all(v) v.begin(),v.end()
#define pb push_back
#define ff first
#define ss second
#define mpp make_pair
#define dbg(x)  cerr << #x << ": "<< x <<endl
#define dbg2(x,y) cerr<< #x <<": "<< x <<" || "<< #y << ": " << y << endl

#define endl "\n"
#define MAX 1e18
#define MIN INT_MIN
#define mod 1000000007


map<ll, ll> mp;

ll cc(ll x , ll y , ll z)
{
    return (x * x + y * y + z * z + x * y + y * z + z * x);
}
void pre()
{
    for (ll i = 1 ; i <= 100 ; ++i) {
        for (ll j = 1 ; j <= 100 ; ++j) {
            for (ll k = 1 ; k <= 100 ; ++k) {

                ll f = cc(i, j, k);
                mp[f]++;
            }
        }
    }
}

void solve()
{
    ll n;
    cin >> n;
    for (ll i = 1 ; i <= n ; ++i)
        cout << mp[i] << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    pre();
    //TEST
    solve();
}



Measured memory_bytes: 6072
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip> 
#include <bits/stdc++.h>
using namespace std;
double pi=3.14159265358979323846264338;
const int MOD=1000000007;

int main() {
	char a;
	cin>>a;
	if(a>'Z'){cout<<"a"<<endl;}
	else cout<<"A"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N,c=0;
  cin>>N;
  for(int i=1;i<N+1;i++){
    if(i%3==0 || i%5==0){
      continue;
    }
    else{
      c+=i;
    }
  }
  cout<<c<<endl;
}


Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>
 

using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

int C[51][51];


int dp[55][55];

int comb(int n, int k){
	if(dp[n][k]>=1)
		return dp[n][k];
	if(n==k)
		return 1;
	if(k==0)
		return 1;
	return dp[n][k] =  comb(n-1,k-1)+comb(n-1,k);
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
 	rep(i,N){
		rep(j,N){
			dp[i][j]=-1LL;
		}
	}
    int v[55];
    rep(i, N) cin >> v[i];
    sort(v, v+N, greater<int>());
    double ans = 0;
    rep(i, A) {
        ans += v[i];
    }
    ans /= A;

    int cnt = 0;
    int X = 0, Y = 0;
    rep(i, N) {
        if (v[i] == v[A-1]) {
            X++;
            if(i < A) Y++;
        } 
    }

    if (Y == A) {
        for (int i = A; i <= min(B,X); i++) cnt += comb(X,i);
    } else {
        cnt += comb(X,Y);
    }

    cout.precision(7);//
    cout << fixed << ans << endl;//
    cout << cnt << endl;

    return 0;
}




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

int main(){
  int n,x;
  cin >> n >> x;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin >> a.at(i);
  
  sort(a.begin(),a.end());
  
  int k=0;
  
  for(int i=0;i<n;i++){
    if(a.at(i)<=x){
      if(i!=n-1){
        x-=a.at(i);
        k++;
      }
      else if(a.at(i)==x)k++;
    }
    else
      break;
  }
  
  cout << k << endl;
}

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

#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
#define OMAZINAI cin.tie(0); ios::sync_with_stdio(false);
#define INF (1LL<<61)
typedef long long int ll;

int main() {
	OMAZINAI;
	int a, b;
	cin >> a >> b;
	cout << (a - 1)*(b - 1) << std::endl;
	return 0;
}

Measured memory_bytes: 256
/*
ID: htc9811
LANG: C++
TASK:
*/

#include<stdio.h>
#include<string>
#include<limits.h>
#include<math.h>
#include<stdlib.h>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
#define debug 0
#define Online 0
const string _TASK="";
inline void _IN(){string s=_TASK+".in";freopen(s.c_str(),"r",stdin);}
inline void _OUT(){string s=_TASK+".out";freopen(s.c_str(),"w",stdout);}

int n;
int a[200005];
long long ans;

int main(){
	if(Online){_IN();_OUT();}
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",a+i);
	for(int i=0;i<n;i++) a[i]-=i;
	sort(a,a+n);
//	for(int i=0;i<n;i++) printf("%d ",a[i]);
//	puts("");
	for(int i=0;i<n/2;i++) ans+=a[n/2]-a[i];
	for(int i=n/2;i<n;i++) ans+=a[i]-a[n/2];
	printf("%lld\n",ans);
	return 0;
}

/*
simple in
5
2 2 3 5 5

simple out
2
*/

Measured memory_bytes: 1024
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    int ans;
    if (a == b && b == c) {
      ans = 1;
    } else if (a == b || b == c || c == a) {
      ans = 2;
    } else {
      ans = 3;
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iostream>
#define ios   ios_base::sync_with_stdio(false);  cin.tie(0);    cout.tie(0);
typedef unsigned long long int ll;
typedef long double ld;
using namespace std;
const int M=1e9+7;
using namespace std;
int main() {
    ios;
  ll h;cin>>h;
  ll i=0,ans=0;
  //cout<<h;
  while(h!=0)
  {
  //   ans+=(1<<i);
     ++i;
     h=h/2;
  }
  ll u=1;
  for(ll j=0;j<i;++j)
  {
      ans+=(u);
      u=u*2;
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, x[10], y[10];
double dst[10][10];
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	cin >> n;
	rep(i, 1, n){
		cin >> x[i] >> y[i];
	}
	rep(i, 1, n){
		rep(j, 1, n){
			dst[i][j] = sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
		}
	}
	double ans = 0;
	rep(i, 1, n){
		double buf = 0;
		rep(j, 1, n){
			buf += dst[i][j];
		}
		buf /= n;
		ans += buf;
	}
	cout << setprecision(12) << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define PLL pair<ll,ll>
#define F first
#define S second
#define MP make_pair
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define N 100001

int main()
{
    fastio;
   string s;
   cin >> s;
   if(s[1]=='B')
   cout <<"ARC"<<'\n';
    else
    cout << "ABC"<<'\n';
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		//??????????????°?¨????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		int a, b, GCD, LCM;

		while ((str = br.readLine()) != null) {
			String[] num = str.split(" ", 0);
			//?????????
			a = Integer.parseInt(num[0]);
			b = Integer.parseInt(num[1]);
			//???????¨????
			GCD = euclid(a, b);
			LCM = a / GCD * b;
			System.out.println(GCD + " " + LCM);
		}
	}
	//??????????????????
	static int euclid(int u, int v) {
		int temp;
		if (u < v) {
			temp = u; u = v; v = temp;
		}
		if (v < 1) return -1;
		if (u % v == 0) return v;
		return euclid(v, u % v);
	}

}

Measured memory_bytes: 24200
n=int(input())
a=0
b=0
c=0
d=0
for i in range(n):
    s=input()
    if s=='AC':
        a+=1
    elif s=='WA':
        b+=1
    elif s=='TLE':
        c+=1
    else:
        d+=1
print('AC x',a)
print('WA x',b)
print('TLE x',c)
print('RE x',d)

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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e15;

int main() {
  ll h;
  cin >> h;
  ll now = 1;
  ll ans = 0;
  while (h != 1) {
    h /= 2;
    ans += now;
    now *= 2;
  }
  ans += now;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(
      new InputStreamReader(System.in));
    
    int number = Integer.parseInt(br.readLine());//数の個数
    String input = br.readLine();//数字の羅列
    int[] numbers = new int[number];//数字の配列
    
    //配列に数字を格納していく
    for(int i = 0; i<number - 1; i++){
      int space = input.indexOf(' ');
      numbers[i] = Integer.parseInt(input.substring(0, space));
      input = input.substring(space+1);
    }
    numbers[number - 1] = Integer.parseInt(input);
    
    //一つ目の数は何回２で割り切れるか？
    int minEven = 0;
    while(numbers[0] %2 == 0){
      numbers[0] = numbers[0] /2;
      minEven++;
    }
    //2つ目以降の数は1つ目より２で割り切れるか？
    for(int j = 1; j<number; j++){
      for(int i = 0; i < minEven; i++){
        if(numbers[j] % 2 != 0){
          minEven = i;
          break;
        }
        else{numbers[j] = numbers[j] /2;}
      }
    }
    System.out.println(minEven);
  }
}


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

abn = [list(map(int,input().split())) for _ in range(n)]


abn.sort()
abn.sort(key = lambda x:x[1])


#print(abn)

ts = 0 # time_stamp
enable = True
for abi in abn:
    a, b = abi

    if not ts + a <= b:
        enable = False
        break
    else:
        ts += a

print('Yes' if enable else 'No')

Measured memory_bytes: 53532
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <set>
using namespace std;

typedef pair<int,int> Pii;
vector<vector<int> > G;
vector<int> mem;

int solve(int i){
  if(mem[i]>-1)return mem[i];
  if(G[i].size()==0)return 0;
  int res=0;
  int k=G[i].size();
  vector<int> tmp(k);
  for(int j=0;j<k;++j)tmp[j]=solve(G[i][j]);
  sort(tmp.begin(),tmp.end());
  for(int j=0;j<k;++j)res=max(res,k-j+tmp[j]);
  mem[i]=res;
  return res;
}

int main(int argc, char const *argv[]) {
  long long n;cin>>n;
  G = vector<vector<int>>(n);
  vector<int> a(n);
  a[0] = -1;
  for(int i=1;i<n;++i){
    cin>>a[i];
    a[i]--;
    G[a[i]].push_back(i);
  }
  mem=vector<int>(n,-1);
  cout<<solve(0)<<endl;
  return 0;
}


Measured memory_bytes: 17408
# A - XOR Circle
from collections import Counter as ct
n=int(input())
a=list(map(int,input().split()))

c=ct(a)
 
if c[0]==n:
    print("Yes")
elif len(c)==2 and c[0]*3==n:
    print("Yes")
elif len(c)==3 and len(set(c.values()))==1:
    a,b,c = c.keys()
    if (a^b^c)==0:
        print("Yes")
    else:
        print("No")
else:
    print("No")


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

using namespace std;

int main(){
	set <long long> st;
	long long a,b,k;
	cin >> a >> b >> k;
	for(long long i = a; i < min(a+k,b); i++){
		st.insert(i);
	}
	for(long long i = b; i > max(a,b-k); i--){
		st.insert(i);
	}
	if(st.empty() && a == b){
		for(long long i = a; i <= min(a+k,b); i++){
			st.insert(i);
		}
		for(long long i = b; i >= max(a,b-k); i--){
			st.insert(i);
		}
	}
	for(auto x : st){
		cout << x << endl;
	}
}

Measured memory_bytes: 256