akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a/gcd(a,b)*b;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int h, w, a[666][666], hs[666][666], vs[666][666], res;
string s[333];

signed main() {
	cin >> h >> w;
	rep(i,h) {
		cin >> s[i];
		rep(j,w) if (s[i][j]=='#') a[i+j+1][i-j+300] = 1;
	}
	reps(i,1,600) reps(j,1,600) {
		hs[i][j] += a[i][j] + hs[i][j-1];
		vs[i][j] += a[i][j] + vs[i-1][j];
	}
	reps(i,1,600) reps(j,1,600) reps(k,j,600) {
		int d = k-j;
		if (a[i][j] && a[i][k]) {
			if (i-d>=0) {
				res += hs[i-d][k] - hs[i-d][j-1];
				if (a[i-d][j]) res--;
				if (a[i-d][k]) res--;
			}
			if (i+d<=600) {
				res += hs[i+d][k] - hs[i+d][j-1];
				if (a[i+d][j]) res--;
				if (a[i+d][k]) res--;
			}
		}
		if (a[j][i] && a[k][i]) {
			if (i-d>=0) res += vs[k][i-d] - vs[j-1][i-d];
			if (i+d<=600) res += vs[k][i+d] - vs[j-1][i+d];
		}
	}
	cout << res << endl;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define MAX 200000

int n;
vector<int> e[MAX+1];
ll c[MAX+1];
vector<bool> b(MAX+1, false);

void dfs(int s, int p){
	b[s]=true;
	if(p!=-1) c[s]+=c[p];
	for(int i=0; i<e[s].size(); i++){
		if(e[s][i]!=s && !b[e[s][i]]){
			dfs(e[s][i], s);
		}
	}
	return;
}

int main(){
	int q;
	cin >> n >> q;
	for(int i=0; i<n-1; i++){
		int a, b;
		cin >> a >> b;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	for(int i=0; i<q; i++){
		int p, x;
		cin >> p >> x;
		c[p]+=x;
	}

	dfs(1, -1);

	for(int i=1; i<=n; i++) cout << c[i] << " ";
	cout << endl;
	return 0;
}

Measured memory_bytes: 24320
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll l; cin >> l;

    ll n = 0;
    for(ll i = 1; i <= l; i *= 2, ++n);

    vector<tuple<ll, ll, ll>> ans;
    RANGE(i, 1, n-1) {
        ans.emplace_back(i, i+1, 0);
        ans.emplace_back(i, i+1, 1LL << n-i-1);
    }
    for (ll i = 0, mask = 1; i < n-1; ++i, mask <<= 1) {
        if (mask & l) {
            ans.emplace_back(1, n-i, l & ~((mask << 1) - 1));
        }
    }

    cout << n << " " << ans.size() << endl;
    REP(i, ans.size()) {
        cout << get<0>(ans[i]) << " ";
        cout << get<1>(ans[i]) << " ";
        cout << get<2>(ans[i]) << "\n";
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d, n = 26;
    cin >> d;
    vector<int> c(n);
    vector<vector<int>> s(d, vector<int>(n));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < n; j++) {
            cin >> s[i][j];
        }
    }
    for (int i = 0; i < d; i++) {
        cout << 1 << '\n';
    }
    return 0;
}

Measured memory_bytes: 3708
program main
	implicit none
    integer N, M, i, j, k, dl
	integer, allocatable :: a(:), b(:), c(:), d(:)
	read(*, *) N, M
	allocate(a(1:N))
	allocate(b(1:N))
	allocate(c(1:M))
	allocate(d(1:M))
	do i = 1, N
		read(*, *) a(i), b(i)
	end do
	do i = 1, M
		read(*, *) c(i), d(i)
	end do
	do i = 1, N
		dl = 5d8
		do j = 1, M
			if(dl > abs(c(j)-a(i)) + abs(d(j)-b(i))) then
				dl = abs(c(j)-a(i)) + abs(d(j)-b(i))
				k = j
			end if
		end do
		write(*, *) k
	end do
end program main

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

int main() {
  int l;cin>>l;
  double a = l/3.0;
  double v = pow(a, 3);
  printf("%.16f", v);
}


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

void boost1() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

int main() {

    long long int n,x,m,i,j,prev,ans,finalans,curr,flag=INT_MIN,rem;
    cin>>n>>x>>m;
    prev=x;
    finalans=x;
    unordered_map<long long int,long long int>mp;
    mp[x]=1;
    for(i=2;i<=n;i++)
    {
        ans=(prev*prev)%m;
        // cout<<ans<<" ";
        if(mp[ans]!=0)
        {
            long long int prev_pos=mp[ans];
            long long int cycle_length=i-prev_pos;
            long long int done_uptill=i-1;
            long long int rem_cnt=n-done_uptill;
            long long int cnt=rem_cnt/cycle_length;
            vector<long long int>cycle;
            vector<long long int>pre_sum;
            for(j=prev_pos;j<i;j++)
            {
                long long int val=ans;
                cycle.push_back(val);
                ans=(ans*ans)%m;
            }
            long long int pree=0;
            for(j=0;j<cycle.size();j++)
            {
                pree+=cycle[j];
                pre_sum.push_back(pree);
            }
            finalans+=(cnt*pre_sum[cycle_length-1]);
            long long int remm=rem_cnt%cycle_length;
            if(remm!=0)
                finalans+=pre_sum[remm-1];
            break;
        }
        if(ans==0)
        {
            flag=0;
            break;
        }
        if(ans==1)
        {
            flag=1;
            curr=i;
            break;
        }
        finalans=finalans+ans;
        prev=ans;
        mp[ans]=i;
    }
    // cout<<"aaya"<<endl;
    // cout<<endl;
    if(flag==0)
    {
        cout<<finalans<<endl;
    }
    else if(flag==1)
    {
        prev=finalans;
        rem=n-curr+1;
        finalans=finalans+rem;
        cout<<finalans<<endl;
    }
    else{
        cout<<finalans<<endl;
    }

    
}


Measured memory_bytes: 6368
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.channels.NonWritableChannelException;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        // create a to z map
        Map<Character, Integer> alphamap = new HashMap<Character, Integer>();
        for(int i='a'; i<='z'; i++) {
            alphamap.put((char) i, 0);
        }
        
        String line = "";
        while ( (line = br.readLine()) != null ) {
            for (int i=0; i<line.length(); i++) {
                char c = line.charAt(i);
                c = Character.toLowerCase(c);
                if (alphamap.containsKey(c)) {
                    alphamap.replace(c, alphamap.get(c) + 1);
                }
            }
        }


        

        
        for( Character c : alphamap.keySet()) {
            System.out.println(c + " : " + alphamap.get(c));
        }
        
        
    }


}


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

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

	string S, T;
	cin >> S >> T;

	int ans = 1e9;

	for (int i = 0; i+T.size()-1 < S.size(); ++i) {
		int cnt = 0;
		for (int j = 0; j < T.size(); ++j) {
			if (S[i+j] != T[j]) {
				++cnt;
			}
		}
		// cout <<i << " " << cnt << endl;
		ans = min(ans, cnt);
	}

	cout << ans << endl;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<math.h>
int main()
{
	int a,b,i,j,x,bb,f[401],k=0;
	for(i=1;i<=400;i++)
	f[i]=i*i;
	scanf("%d%d",&a,&b);bb=b;
	while(bb)
	{
		a*=10;
		bb/=10;
	}
	a+=b;
	//printf("%d\n",a);
	for(i=1;i<=400;i++)
	{
		if(f[i]==a)
		{
			k=1;
		}
	}
	if(k)
	puts("Yes");
	else puts("No");
}

Measured memory_bytes: 128
#include<stdio.h>
#include<limits.h>

int m[100][100], p[100], n;

void MCO(void){
  int i, j, k, l, q;
  for(i = 1; i <= n; i++) m[i][i] = 0;
  for(l = 2; l <= n; l++){
    for(i = 1; i <= n - l + 1; i++){
      j = i + l - 1;
      m[i][j] = INT_MAX;
      for(k = i; k <= j - 1; k++){
	q = m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j];
	m[i][j] = min(m[i][j], q);
      }
    }
  }
  printf("%d\n", m[1][n]);
}

int min(int m, int q){
  if(m < q) return m;
  else return q;
}

int main(){
  int c, i;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d%d", &p[i], &c);
  }
  p[n] = c;
  MCO();
  return 0;
}

Measured memory_bytes: 636
//be naame khodaa
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <cstdio>
#include <algorithm>
#include <set>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <sstream>
#include <complex>
#define pb push_back

using namespace std;
typedef long long ll;

const int N = 1000*1000 + 5;

int f[N];

int main(){
	ios::sync_with_stdio(0);
	string t, s;
	cin >> t >> s;
	int n = s.length();
	f[0] = -1;
	for (int i = 1; i <= n; i++){
		f[i] = f[i-1];
		while (f[i] >= 0 && s[i-1] != s[f[i]])
			f[i] = f[f[i]];
		f[i]++;
	}
	int cur = 0;
	for (int i = 0; i < t.size(); i++){
		while (cur >= 0 && t[i] != s[cur])
			cur = f[cur];
		cur++;
		if (cur == n) cout << i-n+1 << '\n', cur = f[n];
	}
}


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

const ll mod = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vec oks(N+1, true);
    rep(i, M) {
        int a;
        cin >> a;
        oks[a] = false;
    }

    vector<ll> cnt(N+1);
    cnt[0] = 1;

    for (int now=0; now<=N-1; now++) {
        for (int next=now+1; next<=min(N, now+2); next++) {
            if (oks[next]) {
                cnt[next] += cnt[now];
                cnt[next] %= mod;
            }
        }
    }

    cout << cnt[N] << endl;

}

Measured memory_bytes: 1536
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

const int N=1e5+5;
ll mm[N];
ll opt[N];

int main(){	
	int n;scanf("%d",&n);
	ll k;scanf("%lld",&k);
	FER(i,0,n)scanf("%lld",&mm[i]);
	ll cur=0;
	FER(i,0,60){
		int c1=0,c0=0;
		FER(j,0,n){
			if((mm[j]>>i)&1)c1++;
			else c0++;
		}
		if(c1>=c0)opt[i]=(1LL<<i)*c1+cur;
		else opt[i]=(1LL<<i)*c0+cur;
		cur=opt[i];
	}
	ll mx=0;
	ll prev=0;

	//FER(i,0,5)cout<<opt[i]<<" ";
	//cout<<endl;

	IFR(i,59,0){
		if((k>>i)&1){
			ll c=0;
			FER(j,0,n)if((mm[j]>>i)&1)c++;
			//if(i==2)trace(c);
			c=(1LL<<i)*c;
			//if(i==2)trace(c);
			ll val=prev+c;
			if(i!=0)val+=opt[i-1];
			mx=max(mx,val);
		}
		ll d1=(k>>i)&1;
		FER(j,0,n){
			ll d2=(mm[j]>>i)&1;
			if(d1^d2)prev+=(1LL<<i);
		}
		//trace(prev);
		//trace(mx);
	}
	ll val=0;
	FER(i,0,n)val+=mm[i]^k;
	mx=max(mx,val);
	printf("%lld\n",mx);
	return 0;
}


Measured memory_bytes: 1024
/*
A2356:   Palindromic Anagram
*/

#include <stdio.h>
#include <string.h>

int N;
char strbuf[40];
int alpha_cnt[26];
int product[26];


/*kisuuko no mojiga 0~1 ko hokawa guusuu*/
int chkpalin()
{
  int i;
  int cnt;
  for(i=0;i<26;i++)
    cnt += (alpha_cnt[i] & 1);
  return(cnt);
 }
/*kaijou wo motometekara juufukubun wo waru*/
unsigned long long count_palin()
{
  int i,j,k;
  int sum=0;
  int kosuu;
  unsigned long long seki;
  for(i=0;i<26;i++)
    sum += (alpha_cnt[i] / 2);
  for(i=1;i<=sum;i++)
    product[i]=i;
#if 1
  for(i=0;i<26;i++)
    if(alpha_cnt[i] > 2)
      {    kosuu = alpha_cnt[i]/2;
           for(k=2;k<=kosuu;k++)	   
	     for(j=1;j<=sum;j++)
	       if(product[j] % k == 0)
		 {
		   product[j] /= k;
		   break;
		 }
      }
#endif
#if 0
  for(i=1;i<=sum;i++)
    printf("%d:",product[i]);
  printf("\n");
#endif
  seki = 1LL;
  for(i=1;i<=sum;i++)
    {
      seki *= product[i];
    }
  return(seki);
}
main()
{
  int i,ret;
  scanf("%s",strbuf);
  N=strlen(strbuf);
  for(i=0;i<N;i++)
    alpha_cnt[strbuf[i]-'a']++;

  ret=chkpalin();
  if(ret > 1)
    printf("0\n");
  else
    printf("%lld\n",count_palin());
return(0);
}

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

using namespace std;

long long inv(long long a,long long mod){
	long long b=mod,p=1,q=0;
	while(b){
		long long c=a/b,d=a;
		a=b;
		b=d%b;
		d=p;
		p=q;
		q=d-c*q;
	}
	return (p+mod)%mod;
}
int fs=505050;
vector<long long> fact(fs),ifact(fs);
long long binom(int a,int b,long long mod){
	if(a<b || b<0) return 0;
	return fact[a]*ifact[b]%mod*ifact[a-b]%mod;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n,k;
	cin >> n >> k;
	vector<long long> a(n);
	for(int i=0;i<n;i++) cin >> a[i];
	
	long long mod=1000000007;
	
	fact[0]=1;
	for(int i=1;i<fs;i++) fact[i]=fact[i-1]*i%mod;
	ifact[fs-1]=inv(fact[fs-1],mod);
	for(int i=fs-1;i>0;i--) ifact[i-1]=ifact[i]*i%mod;
	
	sort(a.begin(),a.end());
	long long res=0;
	for(int i=n-1;i>=0;i--){
		long long coef=binom(i,k-1,mod);
		res=(res+coef*a[i]%mod)%mod;
	}
	for(int i=0;i<n;i++){
		long long coef=binom(n-i-1,k-1,mod);
		res=(res+mod-coef*a[i]%mod)%mod;
	}
	cout << res << "\n";
	return 0;
}

Measured memory_bytes: 8960
#include "bits/stdc++.h"
using namespace std;
const int N = 61;
const int mod = 1e9 + 7;
long long n;
int dp[N][2][2][2];
int go(int pos , bool carry , bool fineu , bool finev){
	if(pos >= N){
		if(carry){
			return 0;
		}
		return fineu && finev;
	}
	if(dp[pos][carry][fineu][finev] != -1){
		return dp[pos][carry][fineu][finev];
	}
	int dig = (n >> pos) & 1;
	int res = 0;
	int u , v;
	u = 1;
	v = (1 + carry) & 1;
	res += go(pos + 1 , (1 + carry) >> 1 , (u != dig) ? u < dig : fineu , (v != dig) ? v < dig : finev);
	u = 0;
	v = carry;
	res += go(pos + 1 , 0 , (u != dig) ? u < dig : fineu , (v != dig) ? v < dig : finev);
	res -= (res >= mod) * mod;
	res += go(pos + 1 , 1 , (u != dig) ? u < dig : fineu , (v != dig) ? v < dig : finev);
	res -= (res >= mod) * mod;
	return dp[pos][carry][fineu][finev] = res;
}
int main(){
	cin >> n;
	memset(dp , -1 , sizeof(dp));
	cout << go(0 , 0 , 1 , 1) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
 
#define f first
#define s second
#define MAX_N 155
#define INF 1000000000
 
using namespace std;
 
typedef pair<int,int> P;
 
int main(void){
 
  int n,m,k,a,b;
 
  while(cin >> n >> m,n|m){
    vector<P>v[MAX_N];
     
    for(int i=1;i<=n;i++){
      cin >> k;
      for(int j=0;j<k;j++){
    cin >> a >> b;
    v[i].push_back(make_pair(a,b));
      }
    }
 
    int dp[MAX_N][11][80];
 
    for(int i=0;i<MAX_N;i++)
      	for(int j=0;j<11;j++)
  			for(int k=0;k<80;k++)
      			dp[i][j][k]=INF;
 
    for(int i=0;i<11;i++)
      for(int j=0;j<80;j++)
    	dp[0][i][j]=dp[1][i][j]=0;
 
    for(int i=2;i<=n;i++){
      for(int j=0;j<v[i].size();j++){
    	for(int l=m;l>=0;l--){
      		for(int k=0;k<v[i-1].size();k++)
        	dp[i][j][l]=min(dp[i][j][l],dp[i-1][k][l]+(v[i][j].s+v[i-1][k].s)*abs(v[i][j].f-v[i-1][k].f));
      		
      		if(l<m){
        		if(i==2)dp[i][j][l]=0;
        		for(int p=0;p<v[i-2].size();p++)
          			dp[i][j][l]=min(dp[i][j][l],dp[i-2][p][l+1]+(v[i][j].s+v[i-2][p].s)*abs(v[i][j].f-v[i-2][p].f));
      		}
    	}
      }
    }
     
    int ans=INF;
    for(int i=0;i<v[n].size();i++)ans=min(ans,dp[n][i][0]);
    if(m>0)for(int i=0;i<v[n-1].size();i++)ans=min(ans,dp[n-1][i][1]);
 
    cout << ans << endl;
  }
 
  return 0;
}

Measured memory_bytes: 1764
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = list(map(lambda x: x*(-1), a))
heapq.heapify(a)
for i in range(m):
    heapq.heappush(a, ((heapq.heappop(a)*-1//2)*(-1)))
print(sum(a)*-1)

Measured memory_bytes: 14180
import std.stdio, std.conv, std.string;

void main() {
	int N = readln().chomp().to!(int);
	long [256] cnt;
	foreach(i; 0..256) cnt[i] = 0;
	foreach(i; 0..N) {
		string S;
		S = readln();
		cnt[S[0]]++;
	}

	long res = 0;
	string m = "MARCH";
	foreach(i; 0..5) {
		foreach(j; (i+1)..5) {
			foreach(k; (j+1)..5) {
				res += cnt[m[i]] * cnt[m[j]] * cnt[m[k]];
			}
		}
	}
	writeln(res);
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const int MAXN = 2e5;
const int INF = 1e9 + 2;
const ld pi = acos(-1);
const ll MOD = 1e9 + 7;
const ll POW = 1e9 + 9;

ll a, b, c, cnt[11];

int main() {

    faster();

    cin >> a >> b >> c;

    cnt[a]++;
    cnt[b]++;
    cnt[c]++;

    if(cnt[5] == 2 && cnt[7] == 1){
        cout << "YES";
    }
    else{
        cout << "NO";
    }

    return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

void solve() {
	int n, m; scanf("%d%d", &n, &m);
	printf("%d", (1<<m)*(m*1900+(n-m)*100));
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

constexpr int MOD = 1000000007;

int mod(const ll &x){
    return x > 0 ? x % MOD : (x+MOD) % MOD;
}

int modm(const ll &x,const ll &m){
    return (x % MOD) * (m % MOD) % MOD;
}

int modpow(ll x, ll p) {
    int ret = 1;
    while(p > 0) {
        if (p & 1) ret = modm(ret,x);
        x = modm(x,x);
        p >>= 1;
    }
    return ret;
}

// x * modinv(d)
int modd(ll x,ll d) {
    return modm(x,modpow(d,MOD-2));
}

int main(void)
{
    IOS
    constexpr int FACT = 100010;
    int fact[FACT];
    fact[0] = 1;
    FOR(i,1,FACT) fact[i] = modm(fact[i-1],i);
    auto comb = [&](int x,int y) {
        int r = fact[x];r = modd(r,fact[y]);r = modd(r, fact[x-y]);return r;};
    
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    REP(i,n) cin >> v[i];
    sort(ALL(v));

    int ans = 0;
    REP(i,n-k+1) {
        int ncr = comb(n-i-1,k-1);
        ans = mod(ans - modm(v[i],ncr));
        ans = mod(ans + modm(v[n-i-1],ncr));
    }

    cout << ans << '\n';


    return 0;
}

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

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

	const int cake = 4;
	const int donut = 7;

	bool ans = false;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; j++) {
			int value = cake * i + donut * j;
			if (value == N) {
				ans = true;
				break;
			}
		}
	}

	std::cout << (ans ? "Yes" : "No") << std::endl;

	return 0;
}


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

struct Edge{
    int to, money;
    ll time;
};

bool operator< (const Edge &edge1, const Edge &edge2){
    return edge1.time > edge2.time;
};

const int MAX_MONEY = 2500;

int main(){
    int N,M,S;
    cin >> N >> M >> S;
    priority_queue<Edge> queue;
    vector<vector<Edge>> edge(N, vector<Edge>());
    rep(i, M){
        Edge e;
        int u,v,a,b;
        cin >> u >> v >> a >> b;
        u--,v--;
        e.to = u, e.money = a, e.time = b;
        edge[v].push_back(e);
        e.to = v;
        edge[u].push_back(e);
    }
    vector<P> nodes(N);
    rep(i, N){
        int c, d;
        cin >> c >> d;
        nodes[i] = {c, d};
    }
    S = min(MAX_MONEY, S);
    Edge e;
    e.to = 0, e.money = S, e.time = 0;
    queue.push(e);
    vector<vector<ll>> dp(N, vector<ll>(MAX_MONEY));
    rep(i, N) rep(j,MAX_MONEY) dp[i][j] = -1;
    while(queue.size() > 0){
        e = queue.top();
        queue.pop();
        if(dp[e.to][e.money] > 0) continue;
        dp[e.to][e.money] = e.time;
        for(auto ne : edge[e.to]){
            if(ne.money > e.money) continue;
            Edge nse;
            nse.to = ne.to, nse.money = e.money - ne.money, nse.time = ne.time + e.time;
            queue.push(nse);
        }
        e.money += nodes[e.to].first;
        if(e.money < MAX_MONEY){
            e.time += nodes[e.to].second;
            queue.push(e);
        }
    }
    for(int i = 1;i < N;i++){
        ll ans = 1000000000000000000;
        rep(j, MAX_MONEY){
            ans = min(ans, dp[i][j]);
        }
        cout << ans << endl;
    }
    return 0;
}



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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
// typedef pair<ll,ll> p;

int n,m;



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

  vector<bool> a(n+1, true);
  vector<ll> dp(n+1);

  for(int i = 0; i<m; i++){
    ll tmp;cin >> tmp;
    a[tmp] = false;
  }
  dp[0] = 1;

  for(int i = 0; i < n; i++){
    for(int j = i+1; j <= min(n, i+2); j++){
      if(a[j]){
        dp[j] += dp[i];
        dp[j] %= 1000000007;
      }
    }
  }
  cout << dp[n]<< endl;


}

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



using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,n) for(int i=0;i<(int)n;++i)
#define FORNUM(p, x) for (int num = p; num < (int)(x); ++num)
#define FORI(p, x) for (int i = p; i < (int)(x); ++i)
#define FORJ(p, x) for (int j = p; j < (int)(x); ++j)
#define FORK(p, x) for (int k = p; k < (int)(x); ++k)
#define FORL(p, x) for (int l = p; l < (int)(x); ++l)

typedef pair<int,int>P;
#define INF 1000000000
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

ll n, k, a,b;
ll dat[100005];
vector<pair<int, ll> > p;
int main(){
	cin >> n >> k;
	FORI(0,n){
		cin >> a >> b;
		p.push_back(make_pair(a, b));
	}
	sort(p.begin(), p.end());
	for(auto t:p){
		if (k <= t.second) {
			cout << t.first << endl;
			break;
		}
		k -= t.second;
	}
	return 0;
}


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

int main(){
	long long x,a;
	cin >> x;
	a= 100;
	long long counter = 0;
	while(1){
		a = a * 1.01;
		counter ++;
		if(a >= x){
			break;
		}
	}
	cout << counter;
	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include <vector>
#include <cstdlib>
#include<algorithm>
#include<string>
#include<cmath>
#include<math.h>
#include <list>
#include <iomanip>
#define ll double
using namespace std;
vector <ll> arr (100000);


int main() {
   ll n;
   cin>>n;
   vector <ll> p;
   for(ll i=0;i<n;i++)
   {
     ll temp;
     cin>>temp;
     p.push_back(temp);
   }
   vector <vector <ll>> arr (n+1,vector <ll> (n+1,0));
  arr[0][0]=1;
  for(ll i=1;i<=n;i++)
  {
    for( ll j=0;j<=n;j++)
    {
      if(j==0)
      {
        arr[i][j]=arr[i-1][j]*(1-p[i-1]);
        continue;
      }
      if(j>i)
      {
        arr[i][j]=0;
        continue;
      }
      arr[i][j]=arr[i-1][j]*(1-p[i-1])+arr[i-1][j-1]*(p[i-1]);
      

    }
  }
  ll ans=0;
  for(long long i=n/2+1;i<=n;i++)
  {
    ans+=arr[n][i];

  }
 cout << setprecision (10) << fixed << ans;
// cin>>n;
  // cin>>h;
return 0;
	// Write your code here
}


Measured memory_bytes: 74564
def main():
    s = int(input())
    a_set = set()
    a = s
    cnt = 1
    while a not in a_set:
        cnt += 1
        a_set.add(a)
        if a % 2 == 0:
            a = a // 2
        else:
            a = a * 3 + 1
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
import numpy as np

N, M, X = map(int, input().split())

Cs = []
As = []
for _ in range(N):
    t = tuple(map(int, input().split()))
    Cs.append(t[0])
    As.append( np.array(t[1:]) )

mincost = 10 ** 10
for i in range(2 ** N):
    cost = 0
    skills = np.zeros(M, np.int64)
    for j in range(N):
        if i & (1 << j):
            skills += As[j]
            cost += Cs[j]
    if np.amin(skills) >= X:
        mincost = min(mincost, cost)

if mincost == 10 ** 10:
    print(-1)
else:
    print(mincost)


Measured memory_bytes: 27268
from sys import stdin


def main() -> None:
    a, b, c = [int(next_str()) for _ in range(3)]
    s = min(a, b, c)
    l = max(a, b, c)
    m = a + b + c - s - l

    for v in (s, m, l):
        if v % 2 == 0:
            print(0)
            return

    print(s * m)


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define each(a,x) for(auto a : (x))
#define all(a) (a).begin(),(a).end()
#define chmin(a,b) ((a) = min((a),(b)))
#define chmax(a,b) ((a) = max((a),(b)))
#define in_range(x,l,r) ((l)<=(x) && (x)<(r))
#define printvec(a) rep(i,a) cout << a[i] << " \n"[i+1==(a).size()];
#define fs first
#define sc second
#define em emplace
#define eb emplace_back
#define sz size()
#define MP make_pair
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;

const ll INF = 1e8;
const D EPS = 1e-8;
const ll MOD = 1e9+7;

int main(){
  int x, y, a, b, c;
  cin >> x >> y >> a >> b >> c;
  vector<int> p(a), q(b), r(c);
  for (int i = 0; i < a; ++i) {
    cin >> p[i];
  }
  sort(all(p));
  reverse(all(p));
  for (int i = 0; i < b; ++i) {
    cin >> q[i];
  }
  sort(all(q));
  reverse(all(q));
  for (int i = 0; i < c; ++i) {
    cin >> r[i];
  }
  sort(all(r));
  reverse(all(r));

  priority_queue<int, vector<int>, greater<int> > que;
  for (int i = 0; i < x; ++i) {
    que.push(p[i]);
  }
  for (int i = 0; i < y; ++i) {
    que.push(q[i]);
  }

  for (int i = 0; i < c; ++i) {
    if (que.top() >= r[i]) break;
    que.pop();
    que.push(r[i]);
  }

  long long int ans = 0;
  while(not que.empty()) {
    ans += que.top();
    que.pop();
  }

  cout << ans << endl;
}


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

int nx[200005],n;
long long a[200][26],le[200],l,r;
char ch[200005];

void kmp()
{
	int j=0;
	for(int i=2;i<=n/2;i++)
	{
		while(j&&ch[j+1]!=ch[i]) 
			j=nx[j];
		if(ch[j+1]==ch[i]) 
			j++;
		nx[i]=j;
	}
}

long long calc(int c,long long w)
{
	int id=1;
	if(le[id]>=w)
	{
		int s=0;
		for(int i=1;i<=w;i++)
		{
			if(ch[i]-'a'==c) 
				s++;
		}
		return s;
	}
	while(w>=le[id])
	{
		a[id+1][c]=a[id][c]+a[id-1][c];
		le[id+1]=le[id]+le[id-1];
		id++;
	}
	long long s=a[id-1][c];
	if(w==le[id-1]) 
		return s;
	else 
		return s+calc(c,w-le[id-1]);
}

int main()
{
	scanf("%s",ch+1);
	n=strlen(ch+1);
	kmp();
	cin>>l>>r;
	le[0]=n/2-nx[n/2];
	le[1]=n/2;
	for(int i=1;i<=n/2;i++)
	{
		a[1][ch[i]-'a']++;
		if(i<=le[0]) 
			a[0][ch[i]-'a']++;
	}
	for(int i=0;i<=25;i++) 
		printf("%lld ",calc(i,r)-calc(i,l-1));
}

Measured memory_bytes: 896
<?php
fscanf(STDIN, "%d", $N);
$xList = explode(" ", trim(fgets(STDIN)));

$min = min($xList);
$max = max($xList);

// 総当りにしてみる…だめなら考える
$ans = 0x1 << 31;
for($i = $min; $i <= $max; $i++) {
	$wk = 0;
	foreach($xList as $v) {
		$wk += pow($i - $v, 2);
	}
	$ans = min($ans, $wk);
}

echo "{$ans}\n";


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

const char wall = '#';
vector<vector<char>> fields;
vector<vector<bool>> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return b/gcd(a,b)*b;}

const long double PI = (acos(-1));

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

  int a, b, x;
  cin >> a >> b >> x;
  ll v = a * a * b; //体積
  long double h = 2 * (v-x) / pow(a, 2);
  long double ans = 0.0;
  if (h <= b) {
    // 桁数と変数名を指定
    //cout << fixed << setprecision(6) << ans << endl;
    //cout << fixed << setprecision(7) << h << endl;
    ans = atan2(h, a) * 180 / M_PI; // こっちがわはあってる
    // 桁数と変数名を指定
    //cout << fixed << setprecision(6) << ans << endl;
  } else {
    h = double(2*x)/b/b;
    //cout << fixed << setprecision(7) << h << ", " << b << endl;
    ans = 90.0 - double(atan(h/a)) * double(180.0) / M_PI;
    //ans = b * atan
    //cout << fixed << setprecision(7) << atan2(h, b)<< endl;
  }
  cout << fixed << setprecision(7) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>

#define MAX_N 50

using namespace std;

int N, K;
int V[MAX_N];

int main( int argc, char **argv )
{
    // input
    cin >> N >> K;

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

    // solve
    long long ans = 0;
    int R = min( N, K );
    for ( int A = 0; A <= R; A++ )
    {
        for ( int B = 0; B <= R - A; B++ )
        {
            // cout << "=== A(" << A << ") B(" << B << ") ===" << endl;
            priority_queue<int> que;
            for ( int i = 0; i < A; i++ ) que.push( -V[i] );
            for ( int i = 0; i < B; i++ ) que.push( -V[N - 1 - i] );

            long long sum = 0;
            int throwAwayNum = 0;
            while ( !que.empty() )
            {
                int x = -que.top();
                que.pop();
                // cout << x << endl;

                if ( x < 0 && A + B + throwAwayNum < K )
                    throwAwayNum++;
                else
                    sum += x;
            }
            // cout << "sum = " << sum << endl;
            ans = max( ans, sum );
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from itertools import product
from collections import deque
INF = 1e7
def main():
    H, W = map(int, input().split())
    ch, cw = map(lambda x: int(x)+1, input().split())
    dh, dw = map(lambda x: int(x)+1, input().split())
    S = [["#"]*(W+4) for _ in range(H+4)]
    whites = [] #　道であるindex
    for i in range(2, H+2):
        tmp = input()
        for j in range(2, W+2):
            S[i][j] = tmp[j-2]
            if S[i][j] == ".":
                whites.append((i,j))

    dxdy = [(1,0), (-1,0), (0,1), (0,-1)]
    magic = list(product(range(-2, 3), repeat=2))
    magic.remove((0, 0))
    for to_remove in dxdy:
        magic.remove(to_remove)
    
    # graph = {idx: deque() for idx in whites}
    # for idx in whites:
    #     x = idx[0]
    #     y = idx[1]
    #     for dx, dy in dxdy:
    #         if S[x+dx][y+dy] == ".":
    #             graph[idx].append((x+dx, y+dy))
    # graph2 = {idx: deque() for idx in whites}
    # for idx in whites:
    #     x = idx[0]
    #     y = idx[1]
    #     for mx, my in magic:
    #         if S[x+mx][y+my] == ".":
    #             graph2[idx].append((x+mx, y+my))
    
    def bfs(u,v):
        dist = [[INF] * (W+4) for _ in range(H+4)] #indexed from 1
        # seen = [[0] * (W+4) for _ in range(H+4)] #indexed from 1
        queue = deque()
        # seen[u][v] = 1
        dist[u][v] = 0
        queue.append((u,v))
        while queue:
            p, q = queue.popleft()
            # if not graph[(p,q)]:
            #     queue.popleft()
            #     continue
            # g,h = graph[(p,q)].popleft()
            # if seen[g][h]:
            #     continue
            # seen[g][h] = 1
            # dist[g][h] = min(dist[g][h], dist[p][q])
            for dx, dy in dxdy:
                g = p+dx
                h = q+dy
                if S[g][h]=="." and dist[g][h] > dist[p][q]:
                    dist[g][h] = dist[p][q]
                    queue.appendleft((g,h))
            for dx, dy in magic:
                g = p+dx
                h = q+dy
                if S[g][h]=="." and dist[g][h] > dist[p][q]+1:
                    dist[g][h] = dist[p][q]+1
                    queue.append((g,h))
            # dist[g][h] = min(dist[g][h], dist[p][q]+1)
            # queue.append((g,h))
        return dist

    D = bfs(ch, cw)
    ans = D[dh][dw]
    if ans == INF:
        print(-1)
    else:
        print(ans)

if __name__ == "__main__":
    main()

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

int main() {
	int N, min;
	int score = 0;
	int s[105];
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> s[i];
		score += s[i];
	}

	min = score;
	if (score % 10 == 0) {
		for (int i = 0; i < N; ++i) {
			if (min > s[i] && s[i] % 10 != 0)
				min = s[i];
		}
		score -= min;
	}
	
	cout << score << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(v,a,b) for(int v=a; v<=b; v++)
using namespace std;
const int maxn=300+5;
int a[maxn][maxn];
bool mark[maxn];
int cnt[maxn];
int n,m;
void Count()
{
	fo(i,1,m) cnt[i]=0;
	fo(i,1,n) {
		fo(j,1,m) {
			if(mark[a[i][j]]) {
				cnt[a[i][j]]++;
				break;
			}
		}
	}
	return;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>m;
	fo(i,1,n) {
		fo(j,1,m) {
			cin>>a[i][j];
		}
	}
	fo(i,1,m) mark[i]=true;
	int ans=1e9;
	fo(i,1,m) {
		Count();
		int cur=0,id;
		fo(j,1,m) {
			if(cnt[j]>cur) {
				cur=cnt[j];
				id=j;
			}
		}
		ans=min(ans,cur); mark[id]=false;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long 

using namespace std;

void solve(){
	int t ;
	cin>>t;
	
	if(t == 0){
		cout << 1;
		}
	else if (t == 1){
		cout << 0;
		}	
		
					
				
		
		
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
		
	
	

}


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

using namespace std;

#define int long long

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FORR(i, a, b) for (int i = (a); i >= (b); i--)

#define pb push_back
#define VDEL(v, n) v.erase(v.begin() + (n))
#define ALL(v) v.begin(), v.end()

#define INT_INF 200000000

#define TINT(str) atoi(str.c_str())
#define TSTR(num) to_string(num)

typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<vector<int>> VII;

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

//the end of library zone

int N, M, K;

int A[20000];
int DP[20010];

signed main() {
    cin >> N >> M >> K;

    REP(i, N) {
        int a;
        cin >> a;
        A[i] = a;

        DP[i] = LLONG_MAX;
    }

    DP[N] = LLONG_MAX;
    DP[0] = 0;

    //配るDP
    REP(i, N) {
        int minv = LLONG_MAX;
        int maxv = 0;

        FOR(h, 1, M + 1) {
            if((i + h) <= N) {

                //最大値、最小値を更新
                minv = min(minv, A[i + h - 1]);
                maxv = max(maxv, A[i + h - 1]);

                //最小値を更新
                DP[i + h] = min(
                    DP[i + h], 
                    (DP[i] + K + h * (maxv - minv))
                );
            }
        }
    }

    cout << DP[N] << endl;

    return 0;
}



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

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

  double ans=0;
  for(int i=1;i<=N;i++){
    double p=1;
    p /=N;
    int point =i;
    // int x=1;
    while(point < K){
      point *= 2;
      p *=0.5;
    //   cout << "i;" << i ;
    //   cout << " x:" << x ;
    //   cout << " p:" << p ;
    //   cout << " point:" << point << endl;
    //  x++;
    }
    ans += p;
  }
  printf("%.10f\n",ans);
}

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

int main(){
  int n, m;  scanf("%d %d", &n, &m);
  int acnum = 0, penanum = 0;
  int pena[100005] = {0};
  for(int i=0; i<m; i++){
    int p;  scanf("%d", &p);
    char s[4];  scanf("%s", s);
    if(strcmp(s, "AC")==0 && pena[p]!=-1){
      
      acnum++;
      penanum += pena[p];
      pena[p] = -1;
    }else if(pena[p]!=-1){
      pena[p]++;
    }
  }
  printf("%d %d\n", acnum, penanum);
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <cmath>


int a()
{
    std::string a;
    std::cin >> a;

    if(a == "hi" || a == "hihi" || a == "hihihi"
       || a == "hihihihi" || a == "hihihihihi")
    {
        std::cout << "Yes";
    }
    else
    {
        std::cout << "No";
    }
    
    return 0;
}


int main(int argc, const char * argv[])
{
    a();
    return 0;
}

Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;
use std::io::prelude::*;

fn main() {
    let s: String = read();

    let his = ["hi", "hihi", "hihihi", "hihihihi", "hihihihihi"];
    let ans = if his.contains(&&s.as_str()) {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}


fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()

}

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




typedef long long ll;
#define INF 1LL<<40
#define def INF
template<class V, int NV> struct SegTree {
    V comp(V l, V r) { return min(l, r); };
    vector<V> val; SegTree() { val = vector<V>(NV * 2, def); }
    V get(int l, int r) { //[l,r]
        if (l > r) return def;
        l += NV; r += NV + 1; V ret = def;
        while (l < r) { if (l & 1) ret = comp(ret, val[l++]); if (r & 1) ret = comp(ret, val[--r]); l /= 2; r /= 2; }
        return ret;
    }
    void update(int i, V v) { i += NV; val[i] = v; while (i>1) i >>= 1, val[i] = comp(val[i * 2], val[i * 2 + 1]); }
    void add(int i, V v) { update(i, val[i + NV] + v); }
};
int N, Q, A, B, X[201010];
//-----------------------------------------------------------------------------------
/*ll dp[201010][201010][201010];
ll orderN3() {
    rep(i, 0, Q + 1) rep(a, 0, N + 1) rep(b, 0, N + 1) dp[i][a][b] = INF;
    dp[0][0][0] = 0;
    rep(i, 0, Q) rep(a, 0, N + 1) rep(b, 0, N + 1) if (dp[i][a][b] != INF) {
        dp[i + 1][X[i]][b] = min(dp[i + 1][X[i]][b], dp[i][a][b] + abs(a - X[i]));
        dp[i + 1][a][X[i]] = min(dp[i + 1][a][X[i]], dp[i][a][b] + abs(b - X[i]));
    }

    ll ans = INF;
    rep(a, 0, N + 1) rep(b, 0, N + 1) ans = min(ans, dp[Q][a][b]);
    return ans;
}*/
//-----------------------------------------------------------------------------------
ll dp2[2][201010];
ll orderN2() {
    rep(i, 0, N + 1) dp2[0][i] = INF;
    dp2[0][A] = 0;

    rep(i, 0, Q) {
        int b;
        if (i == 0) b = B;
        else b = X[i - 1];

        // reset
        rep(a, 0, N + 1) dp2[(i + 1) % 2][a] = INF;

        // 1. b -> X[i]
        rep(a, 0, N + 1) dp2[(i + 1) % 2][a] = min(dp2[(i + 1) % 2][a], dp2[i % 2][a] + abs(b - X[i]));
        // 2. a -> X[i]
        rep(a, 0, N + 1) dp2[(i + 1) % 2][b] = min(dp2[(i + 1) % 2][b], dp2[i % 2][a] + abs(a - X[i]));
    }

    ll ans = INF;
    rep(a, 0, N + 1) ans = min(ans, dp2[Q % 2][a]);
    return ans;
}
//-----------------------------------------------------------------------------------
SegTree<ll, 1 << 18> dp3, dpplus, dpminus;
ll offset = 0;
ll orderNlogN() {
    dp3.update(A, 0);
    dpplus.update(A, 0+A);
    dpminus.update(A, 0-A);

    rep(i, 0, Q) {
        int b;
        if (i == 0) b = B;
        else b = X[i - 1];

        // 1. b -> X[i]
        offset += abs(X[i] - b);

        // 2. a -> X[i]
        ll mi = INF;
        mi = min(mi, dpminus.get(0, X[i]) + X[i]);
        mi = min(mi, dpplus.get(X[i], N) - X[i]);
        mi -= abs(X[i] - b);

        dp3.update(b, mi);
        dpplus.update(b, mi + b);
        dpminus.update(b, mi - b);
    }

    ll ans = dp3.get(0, N) + offset;
    return ans;
}
//-----------------------------------------------------------------------------------
int main() {
    cin >> N >> Q >> A >> B;
    rep(i, 0, Q) scanf("%d", &X[i]);

    cout << orderNlogN() << endl;
}

Measured memory_bytes: 13440
a = input().split()
n = int(a[0])
q = int(a[1])
listn = []
listt = []
anslistn = []
anslistt = []
keika = int(0)

for i in range(n):
	a = input().split()
	listn.append(a[0])
	listt.append(int(a[1]))

while listt: 
	num = listt.pop(0) - q
	keika += q
	if num > 0:
		listt.append(num)
		listn.append(listn.pop(0))
	else:
		keika += num
		anslistn.append(listn.pop(0))
		anslistt.append(keika)

i = int(0)

for i in range(n):
	print(str(anslistn[i]) + ' ' + str(anslistt[i]))
	


Measured memory_bytes: 10904
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

char c;

int main(int argc, const char * argv[]) {
  cin >> c;
  
  if (c == 'a' || c == 'i'|| c == 'u'|| c == 'e'|| c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean isDevisible = false;
        for (int i = 1; i < 10 ; i ++){
            for (int j = 1 ; j < 10; j++){
                if (i * j == n){
                    isDevisible = true;
                    break;
                }
            }
        }
        System.out.println(isDevisible ? "Yes" : "No");
        sc.close();
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    ll a,b,c;
    cin >> a >> b >> c;
    bool ok = false;
    
    if((ll)4*a*b < (ll)a*a + b*b + c*c + 2*a*b -(2*b*c) - (2*a*c) && c-a-b > 0) ok = true;
    if (ok) cout << "Yes" <<endl;
    else cout << "No" << endl;
}

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

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int x[5];
    rep(i, 5) {
        cin >> x[i];
    }
    rep(i, 5) {
        if(x[i] == 0){
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
 
const ll INF = 1LL << 60;
 
ll N, K;
string S;
int main() {
    cin >> N >> K >> S;
 
    ll score = 0;
    rep(i, N - 1) {
        if (S[i] == S[i + 1]) score++;
    }
 
    ll ans = min(N - 1, score + 2 * K);
    cout << ans << endl;
}

Measured memory_bytes: 3716