akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
using namespace std;
const int MAX = 1e5 + 10;
const ll MOD = 1e9 + 7;
int N, M, K, Q;

int main()
{
	int i, j, k;
	ll n, s;
	scanf("%lld %lld", &n, &s);
	if (n == s) {
		printf("%lld", n + 1);
		return 0;
	}
	for (ll d = 2; d*d <= n; ++d) {
		ll tmp = n;
		ll check = 0;
		while (tmp > 0) {
			check += tmp % d;
			tmp /= d;
		}
		if (check == s) {
			printf("%lld", d);
			return 0;
		}
	}
	ll t = abs(n - s);
	ll mini = LINF;
	for (ll d = 1; d*d <= t; ++d) {
		if (t % d == 0) {
			ll b = t / d + 1;
			if ((n / b + n % b == s) && b >= sqrt(n)) mini = min(mini, b);
		}
	}
	if (mini == LINF) printf("-1");
	else printf("%lld", mini);

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
 
using namespace std;
 
int main()
{
  int N;
  cin >> N;
  
  vector<int> t(N+1), x(N+1), y(N+1);
  for (int i = 1; i <= N; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  
  for (int i = 1; i <= N; i++) {
    int dist = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
    if (t[i] - t[i-1] >= dist && (t[i] - t[i - 1])%2 == dist%2) {
    	;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  
  return 0;
}

Measured memory_bytes: 1408
import java.util.*;

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

        char i;
        int count;
        boolean isBeautiful = true;
        
        if( w.length() % 2 != 0 )isBeautiful = false;
        
        else{
          
		 for( i = 'a' ; i <= 'z' ; i++){
           count = 0;
			for(char x: w.toCharArray()){
			   if(x == i)count++;
            }
           
           if( count % 2 != 0 )isBeautiful = false;
         }
          
        }
         
        if( isBeautiful )System.out.println("Yes");
        else System.out.println("No");
	  }
}

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

int main() {
  int N;
  scanf("%d", &N);

  vector<long long> A(N + 1, 0);
  vector<long long> B(N, 0);
  for (int i = 0; i < N + 1; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++) {
    cin >> B.at(i);
  }

  long long ans = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(i) <= B.at(i)) {
      // モンスターを倒しきれるときは倒しきる
      B.at(i) -= A.at(i);
      ans += A.at(i);
      A.at(i) = 0;
    } else {
      // モンスターを倒しきれない場合はできる限り倒しておく
      A.at(i) -= B.at(i);
      ans += B.at(i);
      B.at(i) = 0;
    }

    if (B.at(i) > 0) {
      // 余力がある場合は、次の隣の町のモンスターも倒す
      if (A.at(i + 1) <= B.at(i)) {
        // 余力で全て倒しきれる場合
        B.at(i) -= A.at(i + 1);
        ans += A.at(i + 1);
        A.at(i + 1) = 0;
      } else {
        // モンスターを倒しきれない場合はできる限り倒しておく
        A.at(i + 1) -= B.at(i);
        ans += B.at(i);
        B.at(i) = 0;
      }
    }
  }

  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 1792
#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>

namespace adaptor = boost::adaptors;

void solve()
{
	int64_t n;
	std::cin >> n;

	std::vector<int64_t> R(n);
	for (int64_t i = 0; i < n; i++) {
		std::cin >> R[i];
	}

	int64_t max_diff = INT64_MIN;
	int64_t min_value = R[0];

	for (int64_t i = 1; i < n; i++) {
		max_diff = std::max(R[i] - min_value, max_diff);
		min_value = std::min(R[i], min_value);
	}

	std::cout << max_diff << std::endl;

}

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



Measured memory_bytes: 4420
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    let n: usize = util::get();

    let towns: Vec<(i64, i64)> = (0..n)
        .map(|_| {
                 let xy: Vec<i64> = util::gets();
                 (xy[0], xy[1])
             })
        .collect::<HashSet<_>>()
        .iter()
        .cloned()
        .collect();

    let xs: Vec<_> = {
        let mut t: Vec<_> = towns.iter().map(|&(x, _)| x).zip(0..).collect();
        t.sort();
        t
    };
    let ys: Vec<_> = {
        let mut t: Vec<_> = towns.iter().map(|&(_, y)| y).zip(0..).collect();
        t.sort();
        t
    };

    let mut costs: Vec<_> = xs.windows(2)
        .chain(ys.windows(2))
        .map(|w| (w[1].0 - w[0].0, w[0].1, w[1].1))
        .collect();
    costs.sort();

    let mut uft = UFT::new(towns.len());
    let mut a = 0;
    let mut e = 0;

    for &(c, from, to) in costs.iter() {
        if !uft.same(from, to) {
            uft.unite(from, to);
            a += c;
            e += 1;
        }

        if e >= towns.len() - 1 {
            break;
        }
    }

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

struct UFT {
    parents: Vec<usize>,
    rank: Vec<usize>,
}

impl UFT {
    fn new(n: usize) -> UFT {
        UFT {
            parents: (0..n + 1).collect(),
            rank: vec!(0; n),
        }
    }

    fn find(&mut self, i: usize) -> usize {
        if self.parents[i] == i {
            i
        } else {
            let p1 = self.parents[i];
            let p = self.find(p1);
            self.parents[i] = p;
            p
        }
    }

    fn unite(&mut self, x: usize, y: usize) {
        let xp = self.find(x);
        let yp = self.find(y);

        if xp != yp {
            if self.rank[xp] < self.rank[yp] {
                self.parents[xp] = yp;
            } else {
                self.parents[yp] = xp;
                if self.rank[xp] == self.rank[yp] {
                    self.rank[xp] += 1;
                }
            }
        }
    }

    fn same(&mut self, x: usize, y: usize) -> bool {
        self.find(x) == self.find(y)
    }
}


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

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

int main()
{
    long long n;
    scanf("%lld",&n);
    for(long long i=1LL; i<=3500LL; i++) {
        for(long long j=i+1; j<=3500LL; j++) {
            long long LCM1 = i / gcd(i,j) * j;
            long long LCM2 = LCM1 / gcd(LCM1, n) * n;
            long long f = 4LL * LCM2 / n;
            long long x = LCM2 / i;
            long long y = LCM2 / j;
            if(f-x-y > 0 && LCM2 % (f-x-y) == 0LL) return !printf("%lld %lld %lld", i, j, LCM2 / (f-x-y));
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 201010
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	#ifdef mod
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
	#else
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x) if (y&1) ret=ret*x;return ret;}
	#endif
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n;
ll a[sz];

ll f[sz],g[sz];
int w[sz],sum[sz];
ll S[sz];
void work(ll *f)
{
	rep(i,1,n-1)
	{
		ll x=a[i],y=a[i+1],w=0;
		while (x<a[i+1]) x*=4,++w;
		while (a[i]>=y*4) y*=4,--w;
		::w[i]=w;sum[i]=sum[i-1]+w;S[i]=S[i-1]+w*i;
	}
	stack<pii>s;s.push(MP(-1,INT_MAX));s.push(MP(0,0));
	rep(i,1,n-1)
	{
		while (sum[i]>=s.top().sec) s.pop();
		int j=s.top().fir;
		f[i]=S[i]-S[j+1]-1ll*(j+1)*(sum[i]-sum[j+1]);
		if (j>0) f[i]+=f[j];
		s.push(MP(i,sum[i]));
	}
}

int main()
{
	file();
	read(n);
	rep(i,1,n) read(a[i]);
	work(f);
	reverse(a+1,a+n+1);work(g);reverse(g+1,g+n+1);
	ll ans=1e18;
	rep(i,0,n) chkmin(ans,i+2*(g[i+2]+(i?f[i-1]:0)));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 8448
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    N = I()
    S = _S()
    alpha = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
    ans = ""
    for s in S:
        ind = (alpha.index(s)+N) if (alpha.index(s)+N)<26 else (alpha.index(s)+N)-26
        ans += alpha[ind]
    print(ans)


main()



Measured memory_bytes: 27036
h,w,k=map(int,input().split())
s=[list(input())for _ in range(h)]
b=[w*[0]for _ in range(h)]
c=[]
d=-1
bb=[]
for i in range(h):
  if "#" not in s[i]:
    c.append(0)
    if d>-1:
      b[i]=b[d]
    else:bb.append(i)
  else:
    c.append(1)
    d=i
    if len(bb)>0:
      for j in bb:b[j]=b[d]
      bb=[]
a=1
for i in range(h):
  f=False
  if c[i]==0:continue
  for j in range(w):
    if s[i][j]=="#":
      if f:a+=1
      f=True
    b[i][j]=a
  if f:
    a+=1
    m=i
for i in b:print(*i)

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M;

int best=1;

void hoge(int v) {
	if(M/v>=N) best=max(best,v);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	for(i=1;i*i<=M;i++) if(M%i==0) {
		hoge(i);
		hoge(M/i);
	}
	cout<<best<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main(){
    int count = 0;
    string s,t;
    cin >> s >> t;
    int x = stoi(s + t);
    for(int i = 0; i <= 1000;i++){
        if(i * i == x){
            cout << "Yes" << endl;
            count = 1;
        }
    }
    if(count == 0) cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<utility>
using namespace std;
char a[1001][1001];
int n,m,tx,ty,ans;
int xx[8]={0,1,0,-1,-1,1,-1,1},yy[8]={1,0,-1,0,-1,-1,1,1}; 
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			if(a[i][j]=='#')
				continue;
			for(int k=0;k<8;k++){
				tx=i+xx[k];
				ty=j+yy[k];
				if(a[tx][ty]=='#')
					ans++;
			}
			a[i][j]='0'+ans;
			ans=0;	
		}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)
			cout<<a[i][j];
		cout<<endl;
	}
	return 0;
}

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

int max(int a, int b){
  return a >= b ? a : b;
}
int lmax(long int a, long int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int lmin(long int a, long int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
long int power(int a,int b){
  long int count=1;
  for(int i=0;i<b;i++){
    count *= 2;
  }
  return count;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int N;float stock=0.0;
  scanf("%d",&N);
  float num[N];char s[N][4];
  for(int i=0;i<N;i++) scanf("%f %s",&num[i],&s[i]);
  for(int i=0;i<N;i++){
    if(strcmp(s[i],"BTC")==0)stock += 380000.0*num[i];
    else stock += num[i];
  }
  printf("%f",stock);
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main() {
  int X, Y;
  cin >> X >> Y;
  
  int ans = 10000000000000;
  
  if( X <= Y ) ans = Y-X;
  if( -X <= Y ) ans = min(ans,Y+X+1);
  if( X <= -Y ) ans = min(ans, -Y-X+1);
  if( -X <= -Y ) ans = min(ans, -Y+X+2);
  cout << ans << endl;

}


Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()

int
main(int argc, char **argv)
{
	const double scale[3] = {1.1, 0.6, 0.2};
	int n[2][4];

	for (int i = 0; i < 2; ++i)
	{
		for (int j = 0; j < 4; ++j)
			n[i][j] = 0;
	}

	double s[2];
	while (scanf("%lf%lf", &s[0], &s[1]) != EOF)
	{
		for (int i = 0; i < 2; ++i)
		{
			int j;
			for (j = 0; j < 3; ++j)
			{
				if (s[i] >= scale[j])
					break;
			}

			n[i][j]++;
		}
	}

	for (int i = 0; i < 4; ++i)
		printf("%d %d\n", n[0][i], n[1][i]);

	return 0;
}

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

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

int main(void){
  int x,y;
  cin >> x >> y;
  cout << lcm(x,y) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string enki;
cin>>enki;
if(enki == "A"){
  cout<<"T"<<endl;
}else if(enki == "T"){
    cout<<"A"<<endl;
}else if(enki == "C"){
    cout<<"G"<<endl;
}else if(enki == "G"){
    cout<<"C"<<endl;
}
  

}

Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <iostream>
using namespace std;
vector<double> interpolation(vector<double> x, vector<double> y) {
	int n = x.size() - 1;
	vector<vector<double> > dp(n + 1, vector<double>(n + 2));
	for (int i = 0; i <= n; i++) dp[i][i + 1] = y[i];
	for (int i = 2; i <= n + 1; i++) {
		for (int r = i; r <= n + 1; r++) {
			int l = r - i;
			dp[l][r] = (dp[l + 1][r] - dp[l][r - 1]) / (x[r - 1] - x[l]);
		}
	}
	vector<double> ret(n + 1); ret[0] = y[0];
	vector<double> mul({ 1 });
	for (int i = 0; i < n; i++) {
		vector<double> mul2(i + 2, 0);
		for (int j = 0; j <= i; j++) mul2[j + 1] = mul[j];
		for (int j = 0; j <= i; j++) mul2[j] -= i * mul[j];
		mul = mul2;
		for (int j = 0; j <= i + 1; j++) ret[j] += mul[j] * dp[0][i + 2];
	}
	return ret;
}
int n;
int main() {
	while (cin >> n, n) {
		vector<double> x(n + 3);
		for (int i = 0; i < n + 3; i++) cin >> x[i];
		int ret = -1;
		for (int i = 0; i < n + 3; i++) {
			vector<double> a, b;
			for (int j = 0; j < n + 3; j++) {
				if (i != j) {
					a.push_back(j);
					b.push_back(x[j]);
				}
			}
			vector<double> res = interpolation(a, b);
			if (abs(res[n + 1]) <= 1.0e-4) ret = i;
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <vector>
#include <unordered_set>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  std::unordered_set<int> s;

  int in;
  cin >> in;
  s.insert(in);
  cin >> in;
  s.insert(in);
  cin >> in;
  s.insert(in);

  cout << s.size() << endl;
  
  return 0;
}


Measured memory_bytes: 256
/****************************************************************************
Is this the real life? Is this just fantasy?
Caught in a landslide, no escape from reality
Open your eyes, look up to the skies and see
I'm just a poor boy, I need no sympathy
Because I'm easy come, easy go, little high, little low
Any way the wind blows doesn't really matter to me, to me!!!
--------------------------------------------------
CP is quite cool.It becomes cooler when you enjoy learning new things
******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define endl "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,a,b) for(int i=a;i<=b;i++)
#define pool(i,a,b) for(int i=a;i>=b;i--)
#define pi pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(a) a.size()
#define ff first
#define ss second
#define debug(x) cout<<#x<<" = "<<x<<endl;
const int mod=1e9+7;

ll binpowmod(ll a, ll b,ll p=mod) 
{
  a%=p;
  ll res = 1;
  while (b > 0) 
  {
    if (b & 1)
      res = (res * a)%p;
    a = (a * a)%p;
    b >>= 1;
  }
  return res%p;
}
//FERMAT INVERSE
ll inv(ll x)
{
  int p=1e9+7;  
  /*you can change fixed mod value here*/                       
  return binpowmod(x,p-2,p);
}

void solve()
{
  ll n;
  cin>>n;
  ll ans=binpowmod(10,n);
  ans%=mod;
  ans-=1ll*2*binpowmod(9,n);
  ans%=mod;
  ans+=binpowmod(8,n);
  ans%=mod;
  cout<<(ans+mod)%mod<<endl;

} 

int main()
{

  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif

  ios::sync_with_stdio(false);
  cin.tie(0);

  int t=1;
  // cin>>t;
  while(t--)
  {
    solve();
  }

  return 0;
}


Measured memory_bytes: 3648
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Compression;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var X = ReadLong();
            var ans = 0;
            var money = 100.0;
            while (money<X)
            {
                ans++;
                money += Floor(money * 0.01);
            }
            WriteLine(ans);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
const int N=100000;
//const ll M = 1000000000+7;

ll cnt = 0; 

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(ll n){
  if(n==0) return 1;
  mint ans = f(n/2);
  ans *= ans;
  if(n%2==1) ans*= 2;
  return ans;
}

mint choose(ll n, ll k){
  mint x=1, y=1;
  rep(i,k){
    x *= (n-i);
    y *= (i+1);
  }
  return x / y;
}

int main(){ 
  int x,y;
  cin >> x>>y;

  ll t=0,yo=x/2;
  
  if(x%2==1)  t++;
  

  while(yo>=0){
    if(y==yo+2*t) break;
    t++;t++;
    yo--;
    //cout << t <<yo<<endl;
  }

  if(yo<0) {
    cout << 0 << endl;
    return 0;
  }

  
  
  cout << choose(t+yo,min(t,yo)).x <<endl;;
  
}


Measured memory_bytes: 256
/*
    @uthor: Amit Kumar
    user -->GitHub: drviruses ; CodeChef: dr_virus_ ; Codeforces,AtCoder,Hackerearth,Hakerrank: dr_virus;
*/
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using namespace std::chrono;
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;
//#define ln mp::cpp_int;
#define ll    long long
#define ld    long double
#define ull   unsigned long long
#define all(vec) vec.begin(),vec.end()
#define endl "\n"
ll google_itr = 1;
#define google(x) cout<<"Case #"<<x<<":"
#define pi 3.14159265358979323846264338327950L

const ll mod = 1e9+7;
const ll inf = 1e18;


void virus(){
    ll len;
    cin>>len;
    vector<ll> arr(len),pre(len);
    for(auto &i:arr) cin>>i;
    partial_sum(arr.begin(),arr.end(),pre.begin());
    ll ans = 0;
    for(auto i=0; i<len; i++){
        ans = ((ans%mod) + (((arr[i]%mod)*((pre[len-1] - pre[i])%mod))%mod))%mod;
    }
    cout<<ans%mod;
}


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
  /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/

    ll t = 1;
    //cin>>t;
    while(t--){
           auto start = high_resolution_clock::now();
           virus();
           auto stop = high_resolution_clock::now();
           auto duration = duration_cast<seconds>(stop - start);
           cerr << "\n Time: "<<duration.count()<<endl;
        //your code goes here
    }
    return 0;
}

Measured memory_bytes: 6368
#include <iostream>
using namespace std;
typedef long long int LL;
#define MOD 1000000007

LL pow(LL m, LL n)
{
	LL res = 1,x = 1,a = m;
	while (x <= n) {
		if ((x & n) > 0) {
			res *= a;
			res %= MOD;
		}
		a *= a;
		if(a >= MOD)
			a %= MOD;
		x <<= 1;
	}
	res %= MOD;
	return res;
}

int main()
{
	LL m, n;
	cin >> m >> n;
	cout << pow(m,n) << endl;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int S = 0, M = 0;
    for (int i = 0; i < N; ++i) {
        int p;
        cin >> p;
        S += p;
        M = max(M, p);
    }
    int ans = S - M / 2;
    cout << ans << endl;
}

Measured memory_bytes: 256
result = 2e50
X, K, D = map(int, input().split())

if (X < 0):
	lo, hi = 0, K
	while (lo < hi):
		mid = int(lo+ (hi - lo) / 2)
		if (X + mid*D >= 0):
			hi = mid;
		else:
			lo = mid + 1;
	if (X + hi*D < 0):
		p1 = hi
		if (abs(X + p1*D) < result):
			result = abs(X + p1*D)
	else:
		p1 = lo
		rem1 = K - p1
		if (rem1%2 == 1):
			result = min((result, abs(X + p1*D + D), abs(X + p1*D - D)))
		p2 = lo - 1
		rem2 = K - p2
		if (rem2%2 == 1):
			result = min((result, abs(X + p2*D + D), abs(X + p2*D - D)))
	print(result)
elif (X > 0):
	lo, hi = 0, K
	while (lo < hi):
		mid = int(lo+ (hi - lo) / 2)
		if (X - mid*D <= 0):
			hi = mid;
		else:
			lo = mid + 1
	if (X - hi*D > 0):
		p1 = hi;
		if (abs(X - p1*D) < result):
			result = abs(X - p1*D)
	else:
		p1 = lo
		rem1 = K - p1
		if (rem1%2 == 1):
			result = min((result, abs(X - p1*D - D), abs(X - p1*D + D)))
		p2 = lo - 1;
		rem2 = K - p2
		if (rem2%2 == 1):
			result = min((result, abs(X - p2*D - D), abs(X - p2*D + D)))
	print(result)
else:
	if (K%2 == 1):
		print(D)
	else:
		print(0)


Measured memory_bytes: 62156
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
  
    int s1, s2;
    

    String ch[] = {"A","B","C","D","E"};

    s1 = scan.nextInt();
    while( s1 > 0){
        s2 = scan.nextInt();
        
        int max_type = 0;
        int max_s = s1 + s2;
      
        for(int i=1; i<5; ++i){
            s1 = scan.nextInt();
            s2 = scan.nextInt();
            if( max_s < s1 + s2 ){
                max_s = s1 + s2;
                max_type = i;
            }
        }
      
        System.out.println(ch[max_type] +" "+ max_s);
      
        s1 = scan.nextInt();
    }
  }
}


Measured memory_bytes: 29728
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long[] a = new long[n];

			for (int i = 0; i < n; i++) {
				a[i] = in.nextLong() - (i+1);
			}

			Arrays.sort(a);

			long ans = 0;
			for (int j = 0; j < n; j++) {
				ans += Math.abs(a[j]-a[n/2]);
			}

			out.println(ans);


		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


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

int main(){
  int N;
  cin>>N;
  string S;
  cin>>S;
  int t=N;
  for(int i=0;i<N-1;i++){
    if(S.at(i)==S.at(i+1)){
      t--;
    }
  }
  cout<<t<<endl;
}

Measured memory_bytes: 512
A, B, C, X, Y = map(int, input().split())

ans = 10 ** 9
for i in range(0,max(X,Y)*2+1,2):
  p = i * C + A * max(X - i // 2, 0) + B * max(Y - i // 2, 0)
#  print (i,max(X - i // 2, 0),max(Y - i // 2, 0),p,ans)
  ans = min(ans, p)
print (ans)

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
typedef long long ll;
int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a % b);
}
int main(){
    ios::sync_with_stdio(false);
    int a, b;
    while(cin >> a >> b)
        cout << gcd(a, b) << " " << ll(a)*ll(b)/gcd(a, b) << endl;
    return 0;
}

Measured memory_bytes: 1192
using System;
using System.Linq;
namespace atcoder
{
    class Program
    {
        static void Main()
        {
            var A = new ReadLine();
            var a = A.Int();
            var b = A.Int();
            var c = A.Int();
            var total = 10000000;
            for (var i = 0; i < a[2]; i++)
            {
                var d = A.Int();
                var Q = d[0] - 1;
                var W = d[1] - 1;

                if (total > b[Q] + c[W] - d[2])
                {
                    total = b[Q] + c[W] - d[2];
                }
            }
            var total2 = b.Min() + c.Min();
            if (total < total2)
            {
                Console.WriteLine(total);

            }
            else
            {
                Console.WriteLine(total2);

            }
        }
    }
    class ReadLine
    {
        public int Number()
        {
            int vs = int.Parse(Console.ReadLine());
            return vs;
        }
        public int[] Int()
        {

            int[] vs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            return vs;
        }
        public string[] String()
        {

            string[] vs = Console.ReadLine().Split(' ').ToArray();
            return vs;
        }
    }
}

Measured memory_bytes: 35676
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool hei(int n){
	rep(0,i,100){
		if(i*i==n){
			return true;
		}
	}
	return false;
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int a[114514];
int memo[114][114];
int ans[114][114];
signed main(){
	ic(h) ic(w)
	ic(n)
	rep(0,i,n)cin>>a[i];
	int sum=0;
	rep(0,i,h){
		if(i%2==0){
			rep(0,j,w){
				memo[i][j]=sum;
				sum++;
			}
		}
		else{
			for(int j=w-1;j>=0;j-=1){
				memo[i][j]=sum;
				sum++;
			}
		}
	}
	int sum1=0;
	rep(0,i,n){
		rep(0,j,a[i]){
			rep(0,k,h)rep(0,l,w)if(memo[k][l]==sum1)ans[k][l]=i+1;
			sum1++;
		}
	}
	rep(0,i,h){
		rep(0,j,w)cout<<ans[i][j]<<" ";
		cout<<endl;	
	}							
}				

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace C
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = RInt();
            int[] h = RIntAr();

            long cnt = 0;
            while (true)
            {
                if (h.Sum() == 0)
                {
                    Console.WriteLine(cnt);
                    return;
                }

                int max = h.Max();
                int beforeIdx = int.MinValue;
                for (int i = 0 ; i < h.Length ; i++)
                {
                    if (h[i] == max)
                    {
                        h[i]--;
                        if (beforeIdx != i - 1) cnt++;
                        beforeIdx = i;
                    }
                }
            }
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}


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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		@SuppressWarnings("unused")
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] l = new int[m];
		int[] r = new int[m];

		for (int i = 0; i < m; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}

		Arrays.sort(l);
		Arrays.sort(r);

		if (l[m - 1] > r[0]) {
			System.out.println(0);
		} else {
			System.out.println(r[0] - l[m - 1] + 1);
		}
		sc.close();
	}
}

Measured memory_bytes: 72788
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>

using namespace std;

int main(void){
    string S;
    cin>>S;

    int ans=0;
    int count=0;

    for(int i=0;i<S.length();i++){
        if(S[i]=='A'||S[i]=='T'||S[i]=='G'||S[i]=='C'){
            count++;
            ans=ans>count?ans:count;
        }else{
            ans=ans>count?ans:count;
            count=0;
        }
    }

    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int My_Inf = 2147483647;
const long long int My_LInf = 9223372036854775807;

struct plant {
	double fertrate;

	double lovewater;
	double vital;
};
double pw;
vector<plant>plants;

double getmon(const double water) {
	double ans = water*pw;
	for (auto p:plants) {
		double rest = p.vital - water*p.lovewater;
		if (rest < 0) {
			ans += 0;
		}
		else {
			ans += rest / p.fertrate;
		}
	}
	return ans;
}

int main() {
	while (1) {
		plants.clear();
		int N; cin >> N; if (!N)break;
		cin >> pw;
		for (int i = 0; i < N; ++i) {
			double vw, pf, vf, t; cin >> vw >> pf >> vf >> t;
			double fertrate = vf / pf;
			double water= vw;
			plants.push_back(plant{ fertrate,water,t });

		}
		double amin = 0;
		double amax = 100;
		while (amin < amax - 1e-12) {
			double amid1 = (amin * 2 + amax) / 3;
			double amid2 = (amin + amax * 2) / 3;
			double mon1 = getmon(amid1);
			double mon2 = getmon(amid2);
			if (mon1 < mon2) {
				amax = amid2;
			}
			else {
				amin = amid1;
			}
		}
		double ans = getmon((amin+amax)/2);
		cout <<setprecision(22)<<fixed<< ans << endl;
	}
	return 0;
}

Measured memory_bytes: 6140
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int k;
  vector<int> vec(5);
  cin>>vec[0]>>vec[1]>>vec[2]>>vec[3]>>vec[4]>>k;
  sort(vec.begin(), vec.end());
  if(vec[4]-vec[0]>k){
    cout<<":("<<endl;
  }
  else{
    cout<<"Yay!"<<endl;
  }
}

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

#define fi  first
#define se second
#define pb(x)       push_back(x)
#define mp(a,b)  make_pair(a,b);
#define sz(a)  ((int)(a).size())
#define all(x) x.begin(),x.end()

#define ff(i,a,b) for(ll i=a;i<=b;++i)

#define de(a) cout << #a << " = " << a << endl;
#define dd(a) cout << #a << " = " << a << "  ";

#define INF 0x3f3f3f3f
#define mem(a,b)   memset(a,b,sizeof(a))
#define file freopen("in.txt","r",stdin)
#define jkl ios::sync_with_stdio(false);cin.tie(0);
/*********************************************/
int main() {
	int a[214];
	ff(i,1,200) a[i]=i;
	int n;
	cin >> n;
	ll hh=0;
	ff(i,1,n) {
		int x;
		cin >> x;
		if(x!=i) hh++;
	}
	if(hh==2||hh==0) cout << "YES";
	else cout << "NO";
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do smth instead of nothing and stay organized
*/


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

using namespace std;
typedef long long ll;
const ll inf=(1ll<<61);
const ll mod=1e9+7;
const int MX=3e5+9;
int n,k;
vector<int>v;
map<int,int>m;
int main(){
    cin>>n>>k;
    if((1<<n)<k+1){
        puts("-1");
        return 0;
    }
    for(int i=0;i<=n;i++){
        if(k&(1<<i))m[(1<<i)]=1;
    }
    if(k==1&&n==1){
        puts("-1");
        return 0;
    }
    if(k==0){
        for(int i=0;i<(1<<n);i++)cout<<i<<" "<<i<<" ";
        return 0;
    }
    n=(1<<n);
    for(int i=0;i<n;i++){
        if(m[i])continue;
        cout<<i<<" ";
    }
    for(int i=0;i<n;i++){
        if(m[i]){
            cout<<i<<" ";
        }
    }
    for(int i=n-1;i>=0;i--){
        if(m[i])continue;
        cout<<i<<" ";
    }
    for(int i=n-1;i>=0;i--){
        if(m[i]){
            cout<<i<<" ";
        }
    }
}


Measured memory_bytes: 7936
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

ans = [0]
for i in range(n):
    top = a[i]
    if i == 0:
        ans.append(top)
    elif i != n - 1:
        ans += [top] * 2

print(sum(ans[:n]))


Measured memory_bytes: 31592
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int a[1010];
ll q[1000010];
int main() {
    int n, K;
    scanf("%d%d", &n, &K);
    for (int i=1; i<=n; i++)
        scanf("%d", &a[i]);
    int cnt = 0;
    for (int i=1; i<=n; i++) {
        ll sum = 0;
        for (int j=i; j<=n; j++) {
            sum += a[j];
            q[++cnt] = sum;
        }
    }
    ll ans = 0;
    for (int d=60; d>=0; d--) {
        ans |= 1ll<<d;
        int cc = 0;
        for (int i=1; i<=cnt; i++)
            if ((q[i] & ans) == ans)
                cc++;
        if (cc < K)
            ans ^= (1ll<<d);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 4352
n = int(input())
t,x,y = 0,0,0
for i in range(n):
  ti,xi,yi = map(int,input().split())
  dt,dx,dy = ti-t, abs(xi-x), abs(yi-y)
  if dx +dy <= dt and (dt -dx-dy)%2 ==0:
    continue
  else:
    print('No')
    break
else:
  print('Yes')
  
  

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <deque>
#include <set>
#include <unordered_set>
#include <list>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <climits>
#include <ctime>
#include <random>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main() {
	ll n, ans = 0;
	cin >> n;
	map<pair<int, int>, int>m;
	map<int, int>c;
	for (int i = 1; i <= n; ++i) {
		string s = to_string(i);
		m[{s[0], s[s.size() - 1]}]++;
	}
	for (auto i : m)
		ans += 1ll * i.second * m[{i.first.second, i.first.first}];
	cout << ans;
}

Measured memory_bytes: 256
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)

	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}

		buf = append(buf, l...)

		if !p {
			break
		}
	}

	return string(buf)
}

func solve(H, W int, rows []string) int {
	h := make([][]int, H)
	v := make([][]int, H)

	for i := 0; i < H; i++ {
		h[i] = make([]int, W)
		v[i] = make([]int, W)
	}

	for i := 0; i < H; i++ {
		ct := 0
		for j := 0; j < W; j++ {
			if rows[i][j] == '#' {
				ct = 0
			} else {
				ct++
			}

			h[i][j] = ct
		}

		ct = 0
		for j := W - 1; j >= 0; j-- {
			if rows[i][j] == '#' {
				ct = 0
			} else {
				ct++
			}

			h[i][j] += ct
		}
	}

	for j := 0; j < W; j++ {
		ct := 0
		for i := 0; i < H; i++ {
			if rows[i][j] == '#' {
				ct = 0
			} else {
				ct++
			}

			v[i][j] = ct
		}

		ct = 0
		for i := H - 1; i >= 0; i-- {
			if rows[i][j] == '#' {
				ct = 0
			} else {
				ct++
			}

			v[i][j] += ct
		}
	}

	max := 0

	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			res := h[i][j] + v[i][j] - 3

			if res > max {
				max = res
			}
		}
	}

	return max
}

func main() {
	var H, W int

	fmt.Scan(&H)
	fmt.Scan(&W)

	rows := make([]string, H)

	for i := 0; i < H; i++ {
		rows[i] = readLine()
	}

	output := solve(H, W, rows)

	fmt.Println(output)
}


Measured memory_bytes: 72576
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;

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

	int size = (int)2e5 + 10;
	int cnt[size];
	set<int> uniq_num;
	for (int i = 0; i < size; ++i)
	{
		cnt[i] = 0;
	}

	int n, k;

	cin >> n >> k;
	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;
		uniq_num.insert(a);
		cnt[a - 1]++;
	}

	sort(cnt, cnt + size);
	int diff = uniq_num.size() - k;
	int ans = 0;
	int idx = 0;
	while (diff > 0)
	{
		if (cnt[idx])
		{
			ans += cnt[idx];
			--diff;
		}

		++idx;
	}

	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 10368
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示

void solve(long long A, long long B, long long M, std::vector<long long> a, std::vector<long long> b, std::vector<long long> x, std::vector<long long> y, std::vector<long long> c){
  ll ans=10000000;
  std::vector<ll> av(a); std::vector<ll> bv(b);
  sort(all(av)); sort(all(bv));
  ans = av[0] + bv[0];
  for (size_t i = 0; i < M; i++) {
    ans = min(a[x[i]-1] + b[y[i]-1] - c[i] , ans);
  }
  cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(A);
    for(int i = 0 ; i < A ; i++){
        scanf("%lld",&a[i]);
    }
    std::vector<long long> b(B);
    for(int i = 0 ; i < B ; i++){
        scanf("%lld",&b[i]);
    }
    std::vector<long long> x(M);
    std::vector<long long> y(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&x[i]);
        scanf("%lld",&y[i]);
        scanf("%lld",&c[i]);
    }
    solve(A, B, M, std::move(a), std::move(b), std::move(x), std::move(y), std::move(c));
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n, arr[200005], a, b, ans[200005];
vector<int> adj[200005], v;

void dfs(int x, int p) {
	int add;
	if (v.empty() or v.back() < arr[x]) {
		v.pb(arr[x]); add = 0;
	} else {
		add = *(lower_bound(all(v), arr[x]));
		*(lower_bound(all(v), arr[x])) = arr[x];
	}
	ans[x] = v.size();
	for (auto it:adj[x]) {
		if (it == p) continue;
		dfs(it, x);
	}
	if (add == 0) v.pop_back();
	else *(lower_bound(all(v), arr[x])) = add;
}

int main() {
	fastio; cin >> n;
	FOR(i, 1, n) cin >> arr[i];
	FOR(i, 1, n-1) {
		cin >> a >> b;
		adj[a].pb(b);
		adj[b].pb(a);
	}
	dfs(1, -1);
	FOR(i, 1, n) cout << ans[i] << "\n";
}

Measured memory_bytes: 30540
#include <stdio.h>

int FuncBePrime(int n)
{
	int i;
	
    if(n < 2)
        return 0;
    else if(n == 2)
        return 1;
	
    if(n % 2 == 0)
        return 0;
	
    for(i = 3; i * i <= n; i += 2)
		if(n % i == 0)
            return 0;
    return 1;
}

int main(void)
{
	int n;
	int buf;
	int count = 0;
	int i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &buf);
		if (FuncBePrime(buf) == 1) count++;
	}
	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 596