akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
 
int main() {
  int H, N, i;
  bool can = false;
  cin >> H >> N;
  vector<int> A(N);
  for (i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A.rbegin(), A.rend());
  for (i = 0; i < N; i++) {
    H -= A[i];
    if (H <= 0) {
      can = true;
      break;
    }
  }
  if (can == true) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

void printhig(ll a[], ll n)
{
	ll hight = 0;
	ll max = 0;

	for (ll i = 0; i < n; i++)
	{
		if (a[i] >= max)
		{
			max = a[i];
		}
		else
		{
			hight = hight + max - a[i];
		}
	}
	cout << hight << endl;
}

int main()
{
	ll n;
	cin >> n;
	ll a[n];
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}

	printhig(a, n);
}

Measured memory_bytes: 5132
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>

#define CH(N,A,B) (A<=N&&N<B)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define RREP(i,a,b) for(int i=(b-1);a<=i;i--)

using namespace std;

int main() {
  int n;
  string s[55];
  cin>>n;
  REP(i,0,n){
    cin>>s[i];
    sort(s[i].begin(), s[i].end());
  }

  int d[50][26];
  REP(i,0,n)REP(j,0,26) d[i][j] = 0;
  REP(i,0,n){
    REP(j,0,s[i].size()){
      d[i][s[i][j] - 'a']++;
    }
  }

  int minnum[26] = {};
  REP(i,0,26){
    int tmp = 10000;
    REP(j,0,n){
      tmp = min(tmp, d[j][i]);
    }
    minnum[i] = tmp;
  }


  /////

  string ans = "";
  REP(i,0,26){
    int m = min(d[0][i], minnum[i]);
    string alph[26]={"a","b","c","d","e","f","g","h","i","j",
                     "k","l","m","n","o","p","q","r","s","t",
                     "u","v","w","x","y","z"};
    REP(j,0,m) ans += alph[i];
  }

  cout<<ans<<endl;

/*
  string ans = "";

  REP(l,0,s[0].size()){
    REP(r,l,s[0].size()){

      int diff = r-l;
      string subs = s[0].substr(l,diff);
      int cnt = 0;

      //test
      cout<<"subs: "<<subs<<endl;

      REP(i,1,n){

        bool flag = false;
        REP(tl,0,s[i].size()){
          REP(tr,tl,s[i].size()){
            if(tr < s[i].size()){
              int tdiff = tr - tl;
              string tsubs = s[i].substr(tl,tdiff);
              if(subs == tsubs){
                flag = true;
                cnt++;
                break;
              }
            }
          }
          if(flag) break;
        }
      }
      //test
      cout<<"cnt ---> "<<cnt<<endl;

      if(cnt == n-1 && ans.size() < subs.size()){
        ans = subs;
      }
    }
  }

  cout<<ans<<endl;
*/


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define forr(i,a,b) for (ll i = a; i < b; i++)
#define all(v) v.begin(), v.end()
#define pb push_back
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef vector<ll> vl;
typedef vector<ii> vii;

const ll MX = 300005;
const ll inf = 2e18;
#define ptr nodo*
#define tam 301000

int main () 
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,b;
    cin>>n>>b;
    int dig=0;

    while(n>=b)
    {
        dig++;
        n=n/b;
    }
    if (n!=0)
        dig++;
    cout<<dig<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <sstream>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define SZ(x) (int)(x.size())
#define F0(i,n) for(int i=0;i<n;i++)
#define F1(i,n) for(int i=1;i<=n;i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define P(x) cerr << #x << "=" << x << endl

const int MOD = 998244353;
const double pi = atan(1.0)*4.0;
const double eps = 1e-8;
ll gcd(ll x, ll y) { return y ? gcd(y, x%y) : x; }
int bc(int n) { return n ? bc((n-1)&n)+1 : 0; }

int i, j, k, m, n, l, M;

ll modpow(ll x, ll n) {
    if (n == 0) return 1;
    ll y = modpow(x, n / 2); y = (y * y) % MOD;
    if (n & 1) y = (y * x) % MOD;
    return y;
}

const int MAXN = 300001;
ll f[MAXN], rf[MAXN];

ll C(int n, int k) {
    return f[n] * rf[k] % MOD * rf[n - k] % MOD;
}



int main() {
    //freopen("x.in", "r", stdin);

    f[0] = rf[0] = 1;
    for (int i = 1; i < MAXN; i++) {
        f[i] = (f[i - 1] * i) % MOD;
        rf[i] = modpow(f[i], MOD - 2);
    }

    ll A, B, K;
    while (cin >> n >> A >> B >> K) {
        ll ans = 0;
        for (int cA = 0; cA <= n; cA++) {
            ll r = K - cA * A;
            if (r < 0 || r > n * B || r % B != 0) continue;
            int cB = r / B;
            ans += C(n, cA) * C(n, cB) % MOD;
            ans %= MOD;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int A, B, C;
    cin >> A >> B >> C;
    cout << ( A <= C && B >= C ? "Yes" : "No" ) << endl;
    return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  string s;
  cin >> s;
  if (s[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  } 
  int C_count = 0;
  for (int i = 2; i < s.size() - 1; ++i) {
    if (s[i] == 'C') C_count++;
  }
  if (C_count != 1) {
    cout << "WA" << endl;
    return 0;
  }
  for (int i = 1; i < s.size(); ++i) {
    if (s[i] == 'C') continue;
    if (isupper(s[i])) {
      cout << "WA" << endl;
      return 0;
    }
  }
  cout << "AC" << endl;
  return 0;
}


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

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

    vector<int> vec(N, 0);

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

    sort(vec.begin(), vec.end());

    if(vec.size() <= 2){
        cout << 0 << endl;
        return 0;
    }

    int count = 0;

    for(int i = 0; i < vec.size() - 2; i++){
        for(int j = i + 1; j < vec.size() - 1; j ++){
            for(int k = j + 1; k < vec.size(); k++){
                if(vec[i] != vec[k] && vec[i] != vec[j] && vec[j] != vec[k]){
                    if(vec[i] + vec[j] > vec[k] && vec[j] + vec[k] > vec[i] && vec[i] + vec[k] > vec[j]){
                        count++;
                    }
                }
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3632
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<double> dp(n + 1);
    dp[0] = 1;
    for(int i = 1; i <= n; i++){
        double p; cin >> p;
        vector<double> next(n + 1);
        for(int j = 0; j < i; j++){
            next[j] += dp[j] * (1 - p);
            next[j + 1] += dp[j] * p;
            // next[j] = dp[j] * (1 - p) + (j ? dp[j - 1] * p : 0);
        }
        dp.swap(next);
    }
    printde(dp);
    double ans = 0;
    for(int i = n / 2 + 1; i <= n; i++){
        ans += dp[i];
    }
    cout << fixed << setprecision(20) << ans << '\n';
}


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

int main(){
  char s[100010];
  cin >> s;
  int n = strlen(s);
  //cout << n << endl;
  int c_0=0, c_1=0;
  for(int i=0; i<n; i++){
    if(s[i]=='0') c_0++;
    else          c_1++;
  }
  //cout << c_0 << "\t" << c_1 << endl;
  cout << min(c_0, c_1)*2 << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(6)
         << sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2))
         << endl;
    return 0;
}


Measured memory_bytes: 3264
#include<bits/stdc++.h>
using namespace std;
int n,m,ans,a[200005];
map<int,int>mp;
int main()
{
    long long ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
    {
        if(mp.count(i-a[i]))ans+=mp[i-a[i]];
        mp[a[i]+i]++;
    }
    printf("%lld\n",ans);
    return 0;
}

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

int main(){
  ll n;
  cin >>n;
  vector<char> alp(26);
  vector<char> name;
  alp[0]='z';
  alp[1]='a';
  for(int i=2;i<26;i++){
    alp[i]='a'+i-1;
  }

  while(n>0){
    int temp;
    temp = n%26;
    if (temp==0) n--;
    name.push_back(alp[temp]);
    n /=26;
  }
  reverse(name.begin(),name.end());
  rep(i,name.size()){
    cout << name[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3604
while True:
    try:
        a=[int(i) for i in input().split()]
        b=[int(i) for i in input().split()]
    except:break
    hit=sum([1 for i in range(4) if a[i]==b[i]])
    blow=8-len(set(a)|set(b))-hit
    print("{0} {1}".format(hit,blow))


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

signed main(void)
{
	string s;
	cin >> s;
	int a, b;
	a = (s[0] - '0') * 10 + (s[1] - '0');
	b = (s[2] - '0') * 10 + (s[3] - '0');
	if ((a == 0 || a > 12) && (b == 0 || b > 12))
		cout << "NA" << endl;
	else if (a > 12 && b <= 12 || a == 0)
		cout << "YYMM" << endl;
	else if (a <= 12 && b > 12 || b == 0)
		cout << "MMYY" << endl;
	else if (a <= 12 && b <= 12)
		cout << "AMBIGUOUS" << endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
lint powmod(lint a, lint b)
{
    if (b == 0)
    {
        return 1;
    }
    else
    {
        if (b % 2 == 0)
        {
            lint half = powmod(a, b / 2);
            return half * half % MOD;
        }
        else
        {
            return a * powmod(a, b - 1) % MOD;
        }
    }
}
lint nCr(lint n, lint r)
{
    if (r > n - r)
    {
        r = n - r;
    }
    lint dividend = 1;
    lint divisor = 1;
    for (lint i = 1; i <= r; ++i)
    {
        dividend = dividend * (n - i + 1) % MOD;
        divisor = divisor * i % MOD;
    }
    lint ans = dividend * powmod(divisor, MOD - 2) % MOD;
    return ans;
}
int main()
{
    lint n, m;
    cin >> n >> m;
    map<int, int> memo;
    for (int i = 2; i * i <= m; i++)
    {
        while (m % i == 0)
        {
            m /= i;
            memo[i]++;
        }
    }
    if (m != 1)
    {
        memo[m]++;
    }
    lint ans = 1;
    for (auto i = memo.begin(); i != memo.end(); i++)
    {
        ans = ans * (nCr(i->second + n - 1, n - 1)) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int N =fsc.nextInt();
        int K =fsc.nextInt();
        int[] P = new int[N];
        
        int ans = 0;
        for (int i = 0; i < N; i++) {
        	P[i] = fsc.nextInt();
        }
        fsc.close();
        
        Arrays.sort(P);
        for (int i = 0; i < K; i++) {
        	ans += P[i];
        }
        System.out.println(ans);
    }
        

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 32632
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]

cnt = 0
for i in a:
    ans = [i[x]*b[x] for x in range(m)]
    if sum(ans) + c > 0:
        cnt+=1

print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=100005;
//i_am_noob
int cnt0=0,cnt1=0;
string str;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> str;
	rep(sz(str)) str[i]%2?cnt0++:cnt1++;
	print1(min(cnt0,cnt1)*2);
	return 0;
}


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

using namespace std;
const int N = 2e5 + 5;

int n;
int a[N], b[N];
set<int> s;

int main()
{
  cin >> n;
  for (int i=1; i<=n; i++) cin >> a[i];
  for (int i=n; i>=1; i--)
  {
    int cnt = 0;
    for (int j=i; j<=n; j+=i)
    {
      cnt += (b[j]);
    }
    if (cnt%2!=a[i]) 
    {
      s.insert(i);
      b[i] = 1;
    }
  }
  cout << s.size() << '\n';
  for (auto it = s.begin(); it!=s.end(); it++) cout << *it << " ";
  return 0;
}


Measured memory_bytes: 8320
n = int(input())
a = input()
b = input()
c = input()
res = 0
for i in range(n):
  if a[i] == b[i] and b[i] == c[i]:
    pass
  elif a[i] != b[i] and b[i] != c[i] and c[i] != a[i]:
    res += 2
  else:
    res += 1
print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,w;
    cin>>h>>w;
    char mat[200][200];
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
            cin>>mat[i][j];
    }
    for(int i=1;i<=2*h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cout<<mat[(i+1)/2][j];
        }
        cout<<endl;
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
///...................................*****.................................................///
///        Author :  MD. Rakibul Islam ( mmdrakibul2912@gmail.com )                         ///
///                  Department of Computer Science                                         ///
///                  & Engineering,                                                         ///
///                  Comilla University , Bangladesh.                                       ///
///...................................*****.................................................///
using namespace std;
int main()
{
    int n, m, i, j, k, l;
    string s;
    cin>>n;
    cin>>s;
    char c=s[0];
    int pos=0;
    for(i=0; i<n; i++)
    {
        if(s[i]!=c)
        {
            pos=i;
            break;
        }
    }
    for(i=0; i<n-1; i++)
    {
        if(s[i]!='0')
        {char x=s[i];
        for(j=i+1; j<n; j++)
        {
            if(s[j]==x)
            {
                s[j]='0';
            }
            else
            {
                break;
            }
        }}
        else
            ;
    }
    int cnt=0;
    for(i=0; i<n; i++)
    {
        if(s[i]!='0')
            cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}


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

a = [int(input()) for _ in range(n)]

if len(a) == 1:
    print(1)
    exit(0)

a.sort()
ans = 0

prev = a[0]
tmp = 0

for i in range(n):
    if a[i] != prev:
        if tmp % 2 == 1:
            ans += 1

        tmp = 1

    else:
        tmp += 1

    prev = a[i]

if tmp % 2 == 1:
    ans += 1

print(ans)


Measured memory_bytes: 7388
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, k, c; cin >> n >> k >> c;
    string s; cin >> s;

    VI l, r;
    for (int i = 0; l.size() < k; ++i) {
        if (s[i] == 'x')continue;
        if (!l.empty() && i - c <= l.back())continue;
        l.push_back(i);
    }
    for (int i = n - 1; r.size() < k; --i) {
        if (s[i] == 'x')continue;
        if (!r.empty() && r.back() <= i + c)continue;
        r.push_back(i);
    }

    FOR(i, 0, k)if (l[i] == r[k - i - 1])cout << l[i] + 1 << "\n";
}

Measured memory_bytes: 3468
#include<stdio.h>
int main()
{
  int S,h,m,s;

    scanf("%d",&S);

    h = S / 3600;

    m = (S - h*3600) / 60;

    s = (S - (h*3600 + m*60));
  
    printf("%d:%d:%d\n",h,m,s);

    return 0;
}

Measured memory_bytes: 1808
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

const int MAX = 200001;
ll fac[MAX], finv[MAX], inv[MAX];
bool Pre = true;
void cominit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    FOR(i, 2, MAX) {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
ll com(int n, int k) {
    if (Pre) {
        cominit();
        Pre = false;
    }
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {
    init();

    int n, k; cin >> n >> k;
    chmin(k, n - 1);
    ll ans = 0;
    eFOR(i, 0, k)(ans += com(n, i) * com(n - 1, i) % mod) %= mod;
    cout << ans << "\n";
}

Measured memory_bytes: 4992
// https://beta.atcoder.jp/contests/abc103/tasks/abc103_a

#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
int main()
{
	vector<int> A(3);
	cin >> A[0] >> A[1] >> A[2];

	sort(A.begin(), A.end());

	int ans = 0;
	for(int i=0;i<3;i++){
		if (i!=0){
			ans += abs(A[i] - A[i-1]);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
"use strict";

/**
 * Resolves problem.
 * @param  {string} input
 * @returns {string}
 */
var main = function(input) {
    const params = input.split(" ").map(x => parseInt(x));
    const a = params[0];
    const b = params[1];

    const difference = b - a;
    let height = 0;
    for (let i = 1; i < 1000; i++) {
        height = height + i;
        if ((i + 1) === difference) {
            return height - a;
        }
    }
};

const output = main(require("fs").readFileSync("/dev/stdin", "utf8"));
console.log(output); // console.log outputs with trailing new line!


Measured memory_bytes: 21064
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int n, k;
  	cin >> n >> k;
  	int h;
    int count = 0;
	rep(i,n){
    	cin >> h;
      	if(h>=k) count++;
    }
  	cout << count << endl;
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const int MOD = 1e9+7;
const int INF = 1<<30;
const ll LINF = 1LL<<60;

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

    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    cout << m2 + (60 - m1) + 60 * (h2 - h1 - 1) - k << endl;

    return 0;
}

Measured memory_bytes: 3692
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    VEC(int,a,5);
    int k;cin>>k;
    rep(i,5){
        for(int j=i+1;j<5;j++){
            //cout<<abs(a[i]-a[j])<<endl;
            if(abs(a[i]-a[j])>k){
                cout<<":(";
                return 0;
            }
        }
    }
    cout<<"Yay!";
}



Measured memory_bytes: 256
K, T = map(int, input().split())
A = list(map(int, input().split()))

A = sorted(A)

Amax = A[-1]

Atwo = sum(A)-Amax

if T == 1:
	print(K-1)
	exit()
if T ==2:
	print(max(A[-1]-1-Atwo, 0))
	exit()

if Amax-1 > Atwo:
	print(Amax-1-Atwo)
else:
	print(0)

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

using namespace std;

struct Edge {
	int to, cap, cost, rev;
};
struct Node {
	int to, cost;
};
bool operator>(const Node& n1, const Node& n2) {
	return n1.cost > n2.cost;
}

typedef long long ll;

const int inf = 1e9+5;

vector< vector<Edge> > G;

int prevE[10000], prevV[10000], h[10000], dist[10000];

void add_edge(int from, int to, int cap, int cost) {
//	cout << from << " " << to << " " << cap << " " << cost << endl;
	G[from].push_back((Edge){to, cap, cost, (int)G[to].size()});
	G[to].push_back((Edge){from, 0, -cost, (int)G[from].size()-1});
}
int min_cost_flow(int s, int t, int f) {
	ll res = 0;
	int N = G.size();
	fill(h, h+N, 0);
	while (f) {
		fill(dist, dist+N, inf); dist[s] = 0;
		priority_queue<Node, vector<Node>, greater<Node> > Q; Q.push((Node){s, 0});
		while ( !Q.empty() ) {
			Node node = Q.top(); Q.pop();
			int v = node.to, cost = node.cost;
			if (node.cost > dist[v]) continue;
			assert(dist[v] == cost);
			for (int i = 0; i < G[v].size(); ++i) {
				Edge& e = G[v][i];
				if (e.cap > 0 && dist[v]+e.cost+h[v]-h[e.to] < dist[e.to]) {
					dist[e.to] = dist[v]+e.cost+h[v]-h[e.to];
					prevV[e.to] = v;
					prevE[e.to] = i;
					Q.push((Node){e.to, dist[e.to]});
				}
			}
		}
		if (dist[t] == inf) return -1;
		for (int i = 0; i < N; ++i) h[i] += dist[i];
		int d = f;
		for (int v = t; v != s; v = prevV[v]) {
			Edge& e = G[prevV[v]][prevE[v]];
			d = min(d, e.cap);
		}
		f -= d;
		res += h[t] * d;
//		assert(d == 1);
		for (int v = t; v != s; v = prevV[v]) {
			Edge& e = G[prevV[v]][prevE[v]];
			e.cap -= d;
			G[e.to][e.rev].cap += d;
		}
	}
	return res;
}

int main() {
	int N; cin >> N;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i] >> B[i];
	}

	set<int> S;
	for (int i = 0; i < N; ++i) {
		S.insert(A[i]);
		S.insert(B[i]);
	}
	map<int, int> tbl;
	int id = 0;
	for (int v : S) {
		tbl[v] = id;
		++id;
	}
	int M = tbl.size();
	int s = N+M, t = s+1;
	G.resize(t+1);
	for (int i = 0; i < N; ++i) {
		add_edge(s, i, 1, 0);
	}
	for (int i = 0; i < M; ++i) {
		add_edge(N+i, t, 1, 0);
	}
	for (int i = 0; i < N; ++i) {
		int aid = tbl[A[i]], bid = tbl[B[i]];
		add_edge(i, N+aid, 1, A[i]);
		add_edge(i, N+bid, 1, B[i]);
		add_edge(i, t, 1, A[i]+B[i]);
	}
	int sum = 0;
	for (int i = 0; i < N; ++i) {
		sum += A[i] + B[i];
	}
	int f = min_cost_flow(s, t, N);
	assert(f >= 0);
	int ans = sum - f;
	cout << ans << endl;
}

Measured memory_bytes: 3620
# coding: utf-8

N=int(input())
#S=input()
#A,B = map(int, input().split())
#A,B = input().split()
#List = [int(input()) for i in range(5)]

List = list(map(int, input().split()))
ans=0
i=1
while i<=N:
    if i%2!=0 and List[i-1]%2!=0:
        ans+=1
    i+=1
print(ans)

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

int main(){
    
    int s, m, h;
    
    cin >> s;
    
    m = s/60;
    
    h = m/60;
    
    m = m%60;
    s = s%60;
    
    cout << h << ":" << m << ":" << s <<endl;

    return 0;
}

Measured memory_bytes: 3084
n = int(input())
t = list(map(int, input().split()))
a = list(map(int, input().split()))

tc = []
ac = []

tc.append((t[0], t[0]))
flag = 1
for i in range(n-1):
    if t[i+1] > t[i]:
        tc.append((t[i+1], t[i+1]))
    elif t[i+1] < t[i]:
        flag = 0
    else:
        tc.append((1, t[i+1]))

a.reverse()
ac.append((a[-1], a[-1]))
for i in range(n-1):
    if a[i+1] > a[i]:
        ac.append((a[i+1], a[i+1]))
    elif a[i+1] < a[i]:
        flag = 0
    else:
        ac.append((1, a[i+1]))

ac.reverse()
import sys
if flag == 0:
    print(0)
    sys.exit()

else:
    ans = 1
    for i in range(n):
        maxi = min(tc[i][1], ac[i][1])
        mini = max(tc[i][0], ac[i][0])
        ans *= max(0, maxi-mini+1)
        ans %= 10**9+7

    print(ans)


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

int main(void){
    int X; cin>>X;
    double ans=1;
    for(int i=1;i<=X;i++){
        for(int j=2;j<=X;j++){
            if(pow(i,j)<=X)ans=max(ans,pow(i,j));
        }
    }
    cout<<ans;
}

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

int main()
{

        int a,b;
        cin >> a>> b;
        if(a< b)
        {
                for(int i = 0;i< b;i++)
                {
                        cout << a;
                }
                cout << endl;
        }
        else if (a>= b)
        {
                for(int i=0; i< a;i++)
                {
                        cout << b;
                }
                cout << endl;
        }

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int & v : a) cin >> v;
	int ans = 0;
	for(int i = 0, j = 0; i < n; i = j){
		while(j < n && (j == i || a[j] <= a[j - 1])) j++;
		ans = max(ans, j - i);
	}
	cout << ans - 1 << endl;
	return 0;
}


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


int main() {
	string S;
	cin >> S;
	string ansS;
	for (int i = 0;i<S.size();++i) {
		if (0 == i%2) {
			ansS += S[i];
		}
	}
	cout << ansS << endl;
	return 0;
}

Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    int n, m;
    cin >> n >> m;
    if (n >= 10 || m >= 10) {
        cout << -1 << "\n";
        return 0;
    }
    cout << n * m << "\n";
}

Measured memory_bytes: 256
#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 INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n, k, q;
    cin >> n >> k >> q;
    vector<ll> decp(n);
    REP(i, q) {
        ll a; cin >> a;
        decp[a-1]++;
    }

    REP(i, n) {
        if (k - (q - decp[i]) <= 0) {
            cout << "No" << endl;
        } else {
            cout << "Yes" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
// https://atcoder.jp/contests/practice2/tasks/practice2_b

#include <atcoder/all>

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
template <typename T>
using VV = V<V<T>>;
using VVL = VV<ll>;
template <typename T>
using VVV = VV<V<T>>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
using asc_pq = priority_queue<T, V<T>, greater<T>>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline ll len(V<T> arr) {
  return arr.size();
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N, Q;
  cin >> N >> Q;

  fenwick_tree<ll> bit(N);

  rep(i, N) {
    ll a;
    cin >> a;
    bit.add(i, a);
  }

  rep(i, Q) {
    ll t;
    cin >> t;

    if (t == 0) {
      ll p, x;
      cin >> p >> x;

      bit.add(p, x);
    } else if (t == 1) {
      ll l, r;
      cin >> l >> r;

      ll res = bit.sum(l, r);
      cout << res << "\n";
    }
  }
}


Measured memory_bytes: 8256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
 
 
const int INF = 1000000;
 
 
 int main(){
 	int k,n,m;
 	cin>>k;
 	for(int i = 0; i < k; i++){
 		scanf("%d:%d", &m, &n);
	 	m = m>12?m-12:m;
		double d = 360.0 * m / 12.0;
		d += 30.0 * n / 60.0;
		double e = 360.0 * n / 60.0;
		double f = min(abs(d-e),abs(360-abs(d-e)));
		
		if(f < 30.0) cout<<"alert"<<endl;
		else if(f >= 90.0) cout<<"safe"<<endl;
		else cout<<"warning"<<endl;
	}
 }

Measured memory_bytes: 1232
#include<bits/stdc++.h>
#define op ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

int a[100][100];
int main()
{
    op;
    int n,m,ans=0;
    cin>>n>>m;
    for(int k,i=1;i<=n;i++)
    {
        cin>>k;
        for(int q,j=1;j<=k;j++)
        {
            cin>>q;
            a[i][q]++;
        }
    }
    for(int cnt,i=1;i<=m;i++)
    {
        cnt=0;
        for(int j=1;j<=n;j++)
        {
            if(a[j][i]>0) cnt++;
        }
        ans+=(cnt/n);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
int main(){
	long long N;
  cin >> N;
  vector<long long> s(N);
  froop1(0,N){
    cin >> s.at(i);
  }
  long long a = s.at(0);
  froop1(0,N - 1){
    a = gcd(a,s.at(i + 1));
  }
  cout << a << endl;
return 0;
  }

Measured memory_bytes: 3996
N = int(input())
A = list(map(int, input().split(' ')))
Q = int(input())
BC = [list(map(int, input().split(' '))) for _ in range(Q)]
cnt = [0 for _ in range(10**5+1)]
sum_a = sum(A)
# print(A)
for i in range(len(A)):
    cnt[A[i]] += 1
    # print(A[i])
    # print(cnt[A[i]])
for bc in BC:
    # print(sum_a)
    # print(cnt.count(bc[0]))
    # print((bc[1]-bc[0])*cnt.count(bc[0]))
    sum_a = sum_a + (bc[1]-bc[0])*cnt[bc[0]]
    print(sum_a)
    cnt[bc[1]] += cnt[bc[0]]
    cnt[bc[0]] = 0


Measured memory_bytes: 32992
n = input()
digit = [int(n[-(i + 1)]) for i in range(len(n))]
digit.append(0)

ans = 0
for i in range(len(digit)):
  if digit[i] > 5 or (digit[i] == 5 and digit[i + 1] >= 5):
    ans += 10 - digit[i]
    digit[i] = 0
    digit[i + 1] += 1
  else:
    ans += digit[i]
    digit[i] = 0

print(ans)


Measured memory_bytes: 15672
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  rep(i, N){
    cin>>A[i];
    A[i]-=(i+1);
  }
  sort(ALL(A));
    ll M=N/2;
    ll Ans=0;
    rep(i, N){
      Ans+=abs(A[M]-A[i]);

    }
    cout<<Ans<<endl;
    return 0;

} 

Measured memory_bytes: 4776
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
set<int>S;
int a;
int main()
{
	for(int i=0;i<3;i++)
	{
		cin>>a;
		S.insert(a);
	}
	printf("%d\n",S.size());
	return 0;

}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	len := len(s)
	ans := "WA"
	if strings.HasPrefix(s, "A") && strings.Count(s, "C") == 1 {
		i := strings.Index(s, "C") + 1 // 0 index
		if i >= 3 && i <= len-1 {
			s = strings.Replace(s, "A", "", 1)
			s = strings.Replace(s, "C", "", 1)
			if strings.ToLower(s) == s {
				ans = "AC"
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>

int main(){

    string a,b,c;
    cin >> a >> b >> c;
    char s1 = a[0];
    s1 = s1 - 0x20;
    char s2 = b[0];
    s2 = b[0] - 0x20;
    char s3 = c[0];
    s3 = c[0] - 0x20;
    cout << s1 << s2 << s3 << endl;


    

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <map>
#include <tuple>
using namespace std;

long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

long long N, L[100009], R[100009], A[100009];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> A[i];
	for (int i = 1; i <= N; i++) L[i] = gcd(L[i - 1], A[i]);
	for (int i = N; i >= 1; i--) R[i] = gcd(R[i + 1], A[i]);

	long long maxn = 0;
	for (int i = 1; i <= N; i++) maxn = max(maxn, gcd(L[i - 1], R[i + 1]));
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 2560
d, g = map(int, input().split())

p = []
c = []
ans = []
cnt = 0
ss = 0
for _ in range(d):
    pp, cc = map(int, input().split())

    p.append(pp)
    c.append(cc)



for x in range(2**d):
    ss = 0
    cnt = 0
    for i in range(d):
        if (x>>i)&1:

            ss += (i+1)*100*p[i] + c[i]
            cnt += p[i]
    if ss>=g:
        ans.append(cnt)

    else:
        for l in range(d)[::-1]:
            if  ((x >> l) & 1):
                continue

            for _ in range(1,p[l]):
                ss += (l+1)*100
                cnt += 1

                if ss>=g:
                    ans.append(cnt)
                    break

print(min(ans))














Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(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 ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

class Point {
  public:
  double x, y;
  Point(double x = 0, double y = 0): x(x), y(y) {}
  Point operator + (Point p) { return Point(x + p.x, y + p.y); }
  Point operator - (Point p) { return Point(x - p.x, y - p.y); }
  Point operator * (double a) { return Point(a * x, a * y); }
  Point operator / (double a) { return Point(x / a, y / a); }
  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }
};
typedef Point Vector;
double norm(Vector a) {
  return a.x*a.x + a.y*a.y;
}
double abs(Vector a) {
  return pow(norm(a), 0.5);
}
struct Segment {
  Point p1, p2;
};
double dot(Vector a, Vector b) {
  return a.x * b.x + a.y * b.y;
}
Point project(Segment s, Point p) {
  Vector base = s.p2 - s.p1;
  double r = dot(p-s.p1, base) / norm(base);
  return s.p1 + base * r;
}
Point reflect(Segment s, Point p) {
  return p + (project(s, p) - p) * 2.0;
}

int main() {
  double x, y;
  Segment s;
  cin >> x >> y;
  s.p1.x = x; s.p1.y = y;
  cin >> x >> y;
  s.p2.x = x; s.p2.y = y;
  ll n;
  cin >> n;
  cout << fixed << setprecision(10);
  rep(i, n) {
    Point p;
    cin >> x >> y;
    p.x = x; p.y = y;
    Point res = reflect(s, p);
    cout << res.x << ' ' << res.y << endl;
  }
}


Measured memory_bytes: 3300
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int main(void){
    int n, x; cin >> n >> x;
    x--;

    int m = 2 * n - 1;
    vi a(m);
    rep(i, m){
        a[i] = i;
    }
    swap(a[m / 2], a[x]);

    sort(begin(a), begin(a) + m / 2, greater<int>());
    sort(begin(a) + m / 2 + 1, end(a), greater<int>());

    if(x != 0 and x != m - 1){
        cout << "Yes" << endl;
        for(auto & e : a){
            cout << e + 1 << endl;
        }
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 2304