akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;
#include<cstdio>
#include<cmath>  // use "abs" function.

// non-recursive algorithm.
#define N 3
#define N2 9

int main()
{
    int MDT[N2][N2];   // Manhattan Distance Table.
    int dx[4] = {0, -1, 0, 1};  // move.
    int dy[4] = {1, 0, -1, 0};

    int i, j;
    for(i = 0; i < N2; i++){
        for(j = 0; j < N2; j++){
            MDT[i][j] = abs((i / N) - (j / N)) + abs((i % N) - (j % N));
        }
    }
    int pre_f[N2], f[N2], pre_space, space, pre_MD, MD, depth;
    for(i = 0; i < N2; i++){
        scanf("%d", &pre_f[i]);
        if(pre_f[i] == 0) pre_space = i;
    }

    pre_MD = 0;
    for(i = 0; i < N2; i++){
        if(pre_f[i] != 0){
            pre_MD += MDT[i][pre_f[i] - 1];
        }
    }

    int level, sx, sy, tx, ty, diff, trail[101], s, r, rev_sp;

    for(level = pre_MD; level < 100; level++, level++){  // DFS.
        for(i = 0; i < N2; i++) f[i] = pre_f[i];
        space = pre_space;
        MD = pre_MD;
        depth = 0;
        trail[0] = 4;
        s = 0;

        while(depth >= 0 && MD > 0)
        {
            sx = space / N;
            sy = space % N;
            for(r = s; r < 4; r++){
                if((trail[depth] ^ r) == 2) continue;  // go forward.
                tx = sx + dx[r];
                ty = sy + dy[r];

                if(tx < 0 || tx >= N || ty < 0 || ty >= N) continue;
                diff = MDT[sx * N + sy][f[tx * N + ty] - 1] - MDT[tx * N + ty][f[tx * N + ty] - 1];
                if(depth + 1 + MD + diff > level) continue;  // branch cut.

                break;
            }
            if(r < 4){  // next direction.
                swap(f[sx * N + sy], f[tx * N + ty]);
                space = tx * N + ty;
                MD += diff;
                depth++;
                trail[depth] = r;
                s = 0;
            }else{
                // back-track.
                r = trail[depth] ^ 2;
                s = trail[depth] + 1;
                depth--;
                if(depth >= 0){
                    rev_sp = space + N * dx[r] + dy[r];
                    MD += MDT[space][f[rev_sp] - 1] - MDT[rev_sp][f[rev_sp] - 1];
                    swap(f[space], f[rev_sp]);
                    space = rev_sp;
                }
            }
        };
        if(depth >= 0) break;
    }
    printf("%d\n", depth);

    return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
    int N, tmp, ans=0;
    cin >> N;
    vector<int> p, q;
    for (int i = 0; i < N; i++) {
        cin >> tmp;
        p.push_back(tmp);
        q.push_back(tmp);
    }
    sort(q.begin(), q.end());
    for (int i = 0; i < N; i++) {
        if (p[i] != q[i]) {
            ans++;
        }
    }
    if (ans <= 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long  
#define pb push_back
#define mk make_pair
#define mod 998244353
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define loop(i,l,r) for(int i=l;i<r;i++)
#define all(x) x.begin(),x.end()

int main()
{
    ios::sync_with_stdio(0) ;
    cin.tie(0); 
    int n,t,a,b;
    cin>>n>>t;int aa=0;int bb=0;
    vector<pair<int,int>> v;v.pb(mk(0,0));
    for(int i=0;i<n;i++)
    {
        cin>>a>>b;aa+=a;bb+=b;
        v.pb(mk(a,b));
    }
    sort(v.begin(),v.end());
    int dp[n+1][t];
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<t;j++)
        dp[i][j]=0;
    }
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<t;j++)
        {
            if(v[i].first>j)
            {
                dp[i][j]=dp[i-1][j];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],v[i].second+dp[i-1][j-v[i].first]);
            }
            
        }
    }
    int ans=0;
    for(int i=1;i<n;i++)
    {
        ans=max(ans,dp[i][t-1]+v[i+1].second);
    }ans=max(ans,dp[n][t-1]);
    cout<<ans;
    return 0;
}
//make all values ll


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define Mod 1000000007
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
#define INF 999999999999999999
#define NN (ll)(1e6+5)
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   {    
       string s,t;
       cin>>s>>t;
       if(s==t.substr(0,s.size()))
        cout<<"Yes\n";
       else
        cout<<"No\n"; 
   }
}

Measured memory_bytes: 3656
R,C,K=map(int, input().split())
M=[[0 for i in range(C)]for i in range(R)]
for i in range(K):
  r,c,v=map(int, input().split())
  r-=1
  c-=1
  M[r][c]=v
dp0=[[0 for j in range(C)] for i in range(R)]
dp1=[[0 for j in range(C)] for i in range(R)]
dp2=[[0 for j in range(C)] for i in range(R)]
dp3=[[0 for j in range(C)] for i in range(R)]
dp1[0][0]+=M[0][0]
for r in range(R):
  for c in range(C):
    if 0<r:
      dp1[r][c]=max(max(dp1[r-1][c],dp2[r-1][c],dp3[r-1][c])+M[r][c],dp1[r][c])
      dp0[r][c]=max(max(dp1[r-1][c],dp2[r-1][c],dp3[r-1][c]),dp0[r][c])
    if 0<c:
      dp3[r][c]=max(dp2[r][c-1]+M[r][c],dp3[r][c],dp3[r][c-1])
      dp2[r][c]=max(dp1[r][c-1]+M[r][c],dp2[r][c],dp2[r][c-1])
      dp1[r][c]=max(dp0[r][c-1]+M[r][c],dp1[r][c],dp1[r][c-1])
      dp0[r][c]=max(dp0[r][c-1],dp0[r][c])
print(max(dp1[-1][-1],dp2[-1][-1],dp3[-1][-1]))

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

using namespace std;

int main() {
	int n;
	cin >> n;
	int cmax = 100 / 4;
	int dmax = 100 / 7;
	for (int i = 0; i <= cmax; i++) {
		for (int j = 0; j <= dmax; j++) {
			if(4*i + 7*j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())

 int main ()
 {
   int n;
   cin>>n;
   double b=(n+1)/2;
   if(n%2==0)
     cout<<0.5<<endl;
   else
     cout<<b/n<<endl;
 }
   
   
   


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))[::-1]

ans = 0
tmp = 0
last = H[0]
for h in H[1:]:
    if h >= last:
        tmp += 1
        last = h
    else:
        last = h
        tmp = 0
    ans = max(ans, tmp)

print(ans)

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

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

// array pointer = *a, num of element = n, key key
int lower_bound(int *a, int n, int key){
    int ng, mid, ok;
    ng = -1, ok = n-1;
    while (abs(ok - ng) > 1){
        mid = (ok + ng) / 2;
        if (key <= a[mid]){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    if (a[ok] >= key)return ok;
    return n;
}

//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
    if (y == 0){ 
        return x;
    }else if (x > y){
        return gcd(y, x % y);
    }else{
        return gcd(x, y % x);
    }
}

unsigned long lcm(unsigned long x, unsigned long y){
    unsigned long g = gcd(x, y);
    return x*y/g;

}



long long factorial(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}




/*unsigned long long pascal[100][100] = {0};
void make_pascal(void){
    for (int i = 0; i < 100; i++){
        pascal[i][0] = 1;
    }
    pascal[1][1] = 1;
    for (int i = 2; i < 100; i++){
        for (int j = 1; j < 100; j++){
           pascal[i][j] = (pascal[i-1][j-1]+pascal[i-1][j]) % mod;
        }
    }
}*/
long long mod = 1000000007;

//x ^ n
long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % mod;
        x = x * x % mod;
    }
    return res;
}

/*int struct_ascending_compare(const void *p, const void *q) {
    return ((structname*)p)->member - ((strcutname*)q)->member;
}*/

int main(void){
    int n, k;
    long long ans = 0;
    scanf("%d %d", &n, &k);
    for (int b = k+1; b <= n; b++){
        long long tmp;
        tmp = (n/b+1)*(b-k);
        if ((n/b+1)*b-1 > n){
            tmp -= n+1>(n/b)*b+k?(n/b+1)*b-(n+1):(n/b+1)*b-((n/b)*b+k);
        }
        if (b*0+k == 0) --tmp;
        ans += tmp;
    }    
    printf("%lld\n", ans);
    return 0;

}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
  char p[50001]={1,1};
  int i,j;
  for(i=2;i*i<50002;i++){
    if(p[i])continue;
    for(j=2;i*j<50002;j++)p[i*j]=1;
  }
  int n,c;
  while(scanf("%d",&n),n){
    c=0;
    for(i=2;i*2<=n;i++){
      if(!(p[i]+p[n-i])){
	//printf("%d %d\n",i,n-i);
	c++;
      }
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 656
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [list(map(int,input().split())) for _ in range(m)]
ans = min(a)+min(b)
for i in range(m):
    ans = min(ans, a[c[i][0]-1]+b[c[i][1]-1]-c[i][2])
print(ans)


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

const int N = 1e3 + 10;
const int mod = 1e9 + 7;

typedef long long LL;

int n, a[N];

void solve(int x){
	for(int i=2; i*i<=x; i++){
		while(x % i == 0){
			a[i]++;
			x/=i;
		}
	}
	if(x > 1){
		a[x]++;
	}
}

int main(){
	scanf("%d", &n);
	memset(a, 0, sizeof(a));
    for(int i=2; i<=n; i++){
        solve(i);
    }
    LL s = 1;
    for(int i=2; i<=n; i++){
        s = s * (a[i] + 1) % mod;
    }
    printf("%lld\n", s);
	return 0;
}


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

//#define int long long
typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;
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 { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
} comb(500000);

mint perm(int n, int k){
    mint res = comb(n,k);
    res *= comb.fact[k];
    return res;
}


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;
    mint now = 0;
    for (int i=0;i<=N;i++){
        now += mint(-1).pow(i)*perm(M,i)*perm(M-i,N-i)*perm(M-i,N-i)*comb(N,i);
    }
    cout << now << "\n";
}

Measured memory_bytes: 10964
N,K = map(int,input().split())

Prob = 0

for i in range(N):
  score = i+1
  if score >= K:
    Prob += 1/N
  else:
    mk = 1
    while  score*2**mk < K:
      mk += 1
    Prob += 1/N*0.5**mk

print(Prob)

Measured memory_bytes: 2940
#include "bits/stdc++.h"
#define int long long

using namespace std;


signed main() {
    int N, A, B;
    cin >> N >> A >> B;
    int q = N / (A + B), r = N % (A + B);
    int ra = r < A ? r : A;
    cout << q * A + ra << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = int_fast64_t;

ll n, w, weight[100], value[100], dp[101][400][101];

int main(){
	scanf("%ld %ld", &n, &w);
	for(int i=0; i<n; i++) scanf("%ld %ld", &weight[i], &value[i]);
	
	for(int i=0; i<n; i++){
		for(int j=0; j<=300; j++){
			for(int k=0; k<n; k++){
				dp[i+1][j][k] = std::max(dp[i+1][j][k], dp[i][j][k]);
				dp[i+1][j+weight[i]-weight[0]][k+1] = std::max(dp[i+1][j+weight[i]-weight[0]][k+1], dp[i][j][k] + value[i]);
			}
		}
	}	
	
	ll ans = 0;
	for(ll j=0; j<400; j++){
		for(ll k=0; k<=n; k++){
			if(j + k * weight[0] <= w) ans = std::max(ans, dp[n][j][k]);
		}
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 31104
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,i;
	float a[11];
	cin>>n;
	float sum=0;
	for(i=0;i<n;i++){
	  cin>>a[i];	
	}
	sort(a,a+n);
	for(i=0;i<n-1;i++)
	sum+=a[i];
	sum+=a[i]/2;
	cout<<sum<<endl;
	
	
	
	return 0;
} 

Measured memory_bytes: 256
N = int(input())
h = list(map(int, input().split()))

# DP
dp = [0] * N
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, N):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]))
print(dp[N-1])

Measured memory_bytes: 13928
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c=-1, int p=-1) {
    int k=1;
    rep(i,g[v].size()) {
        int u = g[v][i].to, ei = g[v][i].id;
        if (u==p) continue;
        if (k == c) ++k;
        ans[ei] = k; ++k;
        dfs(u,ans[ei],v);
    }
}
int main() {
    ll l, r; cin >> l >> r;
    ll ans = 2020;
    for (ll i=l;i<=r-1;i++) {
        for (ll j=l+1;j<=r;j++) {
          ans = min(ans, (i%2019)*(j%2019)%2019);
          if (ans == 0) break;
        }
        if (ans == 0) break;
    }

    cout << ans << endl;
}


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 n;
   cin >> n;
   vector<int> a(n);
   rep(i,n) cin >> a[i];
   
   int ans = 0;
   for(int i=1;i<=n;i++){
       
       if(i%2 == 1 && a[i-1]%2 == 1) ans++;
   }
   cout << ans << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int max_l = 0, l = 0;
    string S;
    cin >> S;

    map<char, bool> m = {
        {'A', true},
        {'C', true},
        {'G', true},
        {'T', true},
    };
    REP(i, S.size()) {
        if (m[S[i]]) {
            l++;
        } else {
            max_l = max(max_l, l);
            l = 0;
        }
    }
    max_l = max(max_l, l);
    cout << max_l << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut a: [u64; n],
    }
    let mut ans = 0;
    for i in 0..n - 1 {
        if a[i] > a[i + 1] {
            let diff = a[i] - a[i + 1];
            ans += diff;
            a[i + 1] += diff;
        }
    }
    println!("{}", ans)
}


Measured memory_bytes: 5576
// ==============================================
// Library
// ==============================================
#define _CRT_SECURE_NO_WARNINGS

// When you are using the gcc compiler, you need only the following lines.
// #include <bits/stdc++.h>

// When you are using other compilers, you need the following line instead.
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

using namespace std;

// competitive macro
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i ,n) for (int i = (n) - 1; i >= 0; i--)
#define LL long long
#define ULL unsigned long long

// If you use this function, "cin" speeds up.
// However, you can not mix "cin" and "scanf", "cout" and "printf".
void fastIOS()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
}
// ==============================================
// ==============================================

array<int, 123> asciiBet = {};

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

	int s = n * (n + 1) / 2.0;
	cout << s << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
#include<cmath>
#include<cstring>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

//素因数分解
map<int64_t,int> prime_factor(int64_t n){
    map<int64_t,int>ret;
    for(int64_t i=2;i*i<=n;i++){
        while(n%i==0){
            ret[i]++;
            n/=i;
        }
    }
    if(n!=1)ret[n]=1;
    return ret;
}

int main(){
    int N;
    cin >> N;
    map<ll,int> primeAll;
    for(int i=1;i<=N;i++){
        auto p = prime_factor(i);
        for(auto &x:p){
            primeAll[x.first]+=x.second;
        }
    }

    int over74=0,over24=0,over14=0,over4=0,over2=0;
    for(auto &x:primeAll){
        if(x.second>=2)over2++;
        if(x.second>=4)over4++;
        if(x.second>=14)over14++;
        if(x.second>=24)over24++;
        if(x.second>=74)over74++;
    }
    int res = 0;
    res += over74;
    res += over24*(over2-1);
    res += over14*(over4-1);
    if(over4>=2)res += ((over4*(over4-1))/2)*(over2-2);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import math

def isprime(n):
    if x == 2:
        return True
    if x % 2 == 0:
        return False
    for i in range(3, math.floor(math.sqrt(n))+1 , 2):
        if x % i == 0:
            return False
    return True

n = int(input())
count = 0
for i in range(n):
    x = int(input())
    if isprime(x):
        count += 1
print(count)

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




int main(){
    int N,ans;
    ans = 0;
    cin  >> N;
    string S;
    cin >> S;
    for (int i=0; i <= N-3; i++) {
            if(S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;


int main()
{
	double w,h,x,y;
	double mw,mh;
	ll ans=0;
	cin>>w>>h>>x>>y;
	mw=w/2.0;
	mh=h/2.0;
	if(mw==x && mh==y)
		cout<<setprecision(10)<<w*h/2<<" "<<1<<endl;
	else
		cout<<setprecision(10)<<w*h/2<<" "<<0<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  long long int a[87];
  a[0]=2;a[1]=1;
  for(int i=2;i<n+1;i++){
    a[i]=a[i-1]+a[i-2];
  }
  cout<<a[n];
}
    

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int total = 0;
    
    for (int i = 0; i < N; i++) {
        int n1 = (i + 1) / 10000;
        int n2 = ((i + 1) / 1000) % 10;
        int n3 = ((i + 1) / 100) % 10;
        int n4 = ((i + 1) / 10) % 10;
        int n5 = (i + 1) % 10;
        int sum = n1 + n2 + n3 + n4 + n5;
        if (sum >= A && sum <= B)total += (i+1);
    }
    cout << total << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
A = list(map(int, input().split()))
B = A[:]
for n in range(N):
    B[n] -= (n + 1)

D = defaultdict(int)
ans = 0
for i, a, b in zip(reversed(range(N)), A[::-1], B[::-1]):
    ans += D[-(i + a + 1)]
    D[b] += 1

print(ans)


Measured memory_bytes: 66788
//abc110_c.cpp
//Sat Sep 29 15:42:56 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	string s,t;
	cin >> s >> t;

	int flag = 0;
	std::unordered_map<char,char> map;
	for (int i=0;i<t.length();i++){
		auto itr = map.find(t[i]);
		if (itr != map.end()){
			if (map[t[i]] != s[i]){
//				cout << s[i] << " " << t[i] << endl;
				flag = 1;
				break;
			}
		}else{
			map[t[i]] = s[i];
		}
	}

	std::unordered_map<char,char> map2;
	for (int i=0;i<t.length();i++){
		auto itr2 = map2.find(s[i]);
		if (itr2 != map2.end()){
			if (map2[s[i]] != t[i]){
//				cout << s[i] << " " << t[i] << endl;
				flag = 1;
				break;
			}
		}else{
			map2[s[i]] = t[i];
		}
	}

	if (flag ==1){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 776
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();

    int ichi = N%500;
    
    if(A>=ichi){
    System.out.println("Yes");        
    }else{
    System.out.println("No");    
    }
  }
}


Measured memory_bytes: 35528
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n, m,k; string s; string sp;
char maze[60][60];
int dis[60][60];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main() {
	cin >> s; string res;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != 'B') {
			res.push_back(s[i]);
		}
		else if (res.size() != 0 && s[i] == 'B') {
			res.pop_back();
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0]);
  X = new Array(101).fill(0);
  for(i=1;i<=N;i++){
    var a = i;
    for(j=2;j<=a;j){
      if(a%j==0){
        X[j]++;
        a=a/j;
        if(a==1){
          break;
        }
      }else{
        j++;
      }
    }
  }
  var four=0;
  var three=0;
  for(i=2;i<101;i++){
    if(X[i]==2||X[i]==3) three++;
    if(X[i]>=4) four++;
  }
  var ans = three*four*(four-1)/2+four*(four-1)*(four-2)/2;

  var fifteen=0;
  var fourteen=0;
  for(i=2;i<101;i++){
    if(X[i]>=4&&X[i]<=13) fourteen++;
    if(X[i]>=14) fifteen++;
  }
  ans += fifteen*fourteen+fifteen*(fifteen-1);

  var t25=0;
  var t24=0;
  for(i=2;i<101;i++){
    if(X[i]>=2&&X[i]<=23) t24++;
    if(X[i]>=24) t25++;
  }
  ans += t24*t25+t25*(t25-1);

  var t75=0;
  for(i=2;i<101;i++){
    if(X[i]>=74) t75++;
  }
  ans += t75;

  console.log('%s', ans);
}
  
// "実行する"ボタンを押した時に実行される関数 (デバッグ用)
function debug(){
  var input = document.getElementById("input").value;
  Main(input);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
/**
 *    author: tanishq_code_c
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



void __print(int x) {cerr << x;}; void __print(long x) {cerr << x;}; void __print(long long x) {cerr << x;}; void __print(unsigned x) {cerr << x;}; void __print(unsigned long x) {cerr << x;}; void __print(unsigned long long x) {cerr << x;}; void __print(float x) {cerr << x;}; void __print(double x) {cerr << x;}; void __print(long double x) {cerr << x;}; void __print(char x) {cerr << '\'' << x << '\'';}; void __print(const char *x) {cerr << '\"' << x << '\"';}; void __print(const string &x) {cerr << '\"' << x << '\"';}; void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}


#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif


#define int                                         long long
#define setbits(x)                                  __builtin_popcountll(x)
#define zerobits(x)                                 __builtin_ctzll(x)
#define mod                                         10000007
#define inf                                         1e18
#define endl                                        '\n'
#define pb                                          push_back
#define all(x)                                      x.begin(),x.end()
#define ff                                          first
#define ss                                          second

int powmod(int a, int b) {int res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) {if (b & 1)res = res * a % mod; a = a * a % mod;} return res;}
int fast_pow(int a, int b) {if (b == 1) return a; if (b == 0) return 1; int x = fast_pow(a, b / 2); x *= x; if (b & 1) x *= a; return x;}

void t_c_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(10);
    /*#ifndef ONLINE_JUDGE
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif*/
    string s; cin >> s;
    int n = (int)s.size();
    if (s[n - 1] != 's') {
        s += 's';
    }
    else if (s[n - 1] == 's') {
        s += "es";
    }
    cout << s << endl;
}

int32_t main()
{
    t_c_c();
    return 0;
}


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

int N, P;

int main() {
	cin >> N >> P;
	int cntOdd = 0;
	for (int i = 0; i < N; i++) {
		int x; cin >> x;
		cntOdd += x % 2;
	}

	long long waysOdd = (1LL << (N-cntOdd)) * (cntOdd == 0 ? 0 : 1LL << (cntOdd-1));

	if (P == 1) {
		cout << waysOdd << endl;
	} else {
		cout << (1LL << N) - waysOdd << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main() {
	string S, T;
	cin >> S >> T;

	int A = T.size();
	int B = A - 1;
	char C = T.at(B);

	if (S + C == T) {
		cout << "Yes" << endl;
		}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.util.Arrays;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        while (true) {
            String line = reader.readLine();
            if (line == null || line.isEmpty()) {
                break;
            }
            String[] values = line.split(",");
            double[] distances = new double[11];
            for (int i = 0; i < 10; i++) {
                distances[i + 1] = distances[i] + Double.parseDouble(values[i]);
            }
            int v1 = Integer.parseInt(values[10]);
            int v2 = Integer.parseInt(values[11]);
            double d1 = distances[10] * v1 / (v1 + v2);
            int result = Arrays.binarySearch(distances, d1);
            if (result < 0) {
                result = -result - 1;
            }
            out.println(result);
        }
    }
}

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

const int Maxn = 100005;

int n, m;
int H[Maxn];
vector <int> neigh[Maxn];
int res;

int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; i++)
        scanf("%d", &H[i]);
    for (int i = 0; i < m; i++) {
        int a, b; scanf("%d %d", &a, &b);
        neigh[a].push_back(b);
        neigh[b].push_back(a);
    }
    for (int i = 1; i <= n; i++) {
        bool ok = true;
        for (int j = 0; j < neigh[i].size() && ok; j++) {
            int u = neigh[i][j];
            ok = H[i] > H[u];
        }
        res += ok;
    }
    printf("%d\n", res);
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  
  vector<int>A(200010);
  
  rep(i,N)cin >> A[i];
  
  ll ans = 0;
  int height = A[0];
  int now = 0;
  
  // heightは そこまでで一番高いたかさ
  // ans = 踏み台の高さの合計
  // nowはそのときの踏み台
  
  for(int i = 1; i < N; i++){
    
    //高さを更新する場合
    if(A[i] > height){
      height = A[i];
    }
    //一こ前のほうが高いときは、ansを差分足して、A[i]を差分足しておく
    else if( A[i-1] > A[i]){
      now = A[i-1] - A[i];
      A[i] += now;
      ans += now;
    }
    
  }
  
  cout << ans << endl;
  
  
  
}

Measured memory_bytes: 4044
import scala.io.StdIn.{readLine,readInt}
import scala.math.BigDecimal

object Main {
    def round(x:Double) = BigDecimal(x).setScale(3,BigDecimal.RoundingMode.HALF_UP).toDouble 

    def main(args:Array[String]) = {
        val n = readInt
         for(i <- 0 until n) {
            val m = readLine.split(" ").map(_.toDouble)
            val (x12,y12,x13,y13) = (m(0)-m(2),m(1)-m(3),m(0)-m(4),m(1)-m(5))
            val (xx1,yy1,xx2,yy2,xx3,yy3) = (m(0)*m(0),m(1)*m(1),m(2)*m(2),m(3)*m(3),m(4)*m(4),m(5)*m(5))
            val g = 2*(x12*y13 - y12*x13)
            val x = (y13*(xx1 - xx2 + yy1 - yy2) - y12*(xx1 - xx3 + yy1 - yy3))/g
            val y = (x12*(xx1 - xx3 + yy1 - yy3) - x13*(xx1 - xx2 + yy1 - yy2))/g

            printf("%.3f %.3f %.3f\n",round(x),round(y),round(Math.sqrt((x-m(0))*(x-m(0))+(y-m(1))*(y-m(1)))))
        }
    }
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    ll N,M; cin >> N >> M;
    vector<pair<ll,ll>> AB(N);
    REP(i,N){
        ll a,b; cin >> a >> b;
        AB[i] = {a,b};
    }
    sort(ALL(AB));
    ll itr = 0;
    ll ans = 0;
    while(M>0){
        if(M>=AB[itr].second){
            M -= AB[itr].second;
            ans += AB[itr].first * AB[itr].second;
            itr++;
        }else{
            ans += AB[itr].first * M;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4796
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main() {
  	string s,t;
  	cin >> s;
  	cin >> t;
  bool flag = false;
  	for(int i=0;i<s.size();i++){
      if(s[i]==t[i]){
        flag = true;
      }else{
        flag = false;
        break;
    }
    }
  if(flag == true){
  	 cout << "Yes" << endl;
  }else if(flag == false){
  cout << "No" << endl;
  }
  
	return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<string>

int main(){
    int map[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            std::cin >> map[i][j];
        }
    }

    for(int a1 = 0; a1 <= 100; a1++){
        bool ok = true;
        int b[3];
        int a[3];
        a[0] = a1;
        for(int i = 0; i < 3; i++){
            b[i] = map[0][i] - a[0];
        }
        a[1] = map[1][0] - b[0];
        a[2] = map[2][0] - b[0];

        // 全て満たしているかチェック
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(a[i] + b[j] != map[i][j]){
                    ok = false;
                    break;
                }
            }

            if(!ok) break;
        }

        if(ok){
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }

    std::cout << "No" << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long h,w;
  cin >> h >> w;
  if(h==1 || w==1){
    cout << 1 << endl;
  }
  else if(h*w%2==0){
    cout << h*w/2 << endl;
  }
  else{
    cout << h*w/2+1 << endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>

int main(void)
{
    int d;
    while(std::cin >> d)
    {
        int sum = 0;
        for(int i = d; i < 600; i += d)
        {
            sum += (i * i) * d;
        }

        std::cout << sum << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3044
data = input().split()

n = int(data[0])
a = int(data[1])
b = int(data[2])

ab=n
total=n

# ab
if(n > (a+b)):
    if(a > b):
        ab = b
        total = 0
    else:
        ab = a
        total = 0
else:
    if(a > b):
        ab = b
        total = a+b-n
    else:
        ab = a
        total = a+b-n

print(ab, " ", total)

Measured memory_bytes: 3064
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {

	var a, b string
	fmt.Scanf("%s %s", &a, &b)

	var A, B string
	var i, j int
	i, _ = strconv.Atoi(b)
	j, _ = strconv.Atoi(a)
	A = strings.Repeat(a, i)
	B = strings.Repeat(b, j)

	if A >= B {
		fmt.Println(B)
	} else {
		fmt.Println(A)
	}

}


Measured memory_bytes: 1836
import itertools
from math import factorial
from collections import Counter

ans = 0
N, L = map(int, input().split())
x = list(map(int, input().split()))
y = itertools.accumulate(x)
y = [e % L for e in y]
#print(y)
#print(y)
so = set(y)
#print(so)
#print(so)
counter = Counter([0]+y)
#print(counter.values())
#print
for i in counter.values():
    #print(ans)
    if i>1:ans+=factorial(i) // 2 // factorial(i-2)
print(ans)

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

using namespace std;

int main()

{
    int n,m,s,p=1;
    cin>>n>>m;
    for(int i=0;i<m;i++)
        p*=2;
    s=(n-m)*100+1900*m;
    s*=p;

    cout<<s;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
l = list(map(int, input().split()))
l.sort()

import bisect 

def func(x):
  C = 0
  for p in l:
    q = x -p
    j = bisect.bisect_left(l, q)
    C += n-j
  if C >= m:
    return True
  else:
    return False
  
l_ = 0
r_ = 2*10**5 +1
while l_+1 < r_:
  c_ = (l_+r_)//2
  if func(c_):
    l_ = c_
  else:
    r_ = c_
    
ans = 0
cnt = 0
lr = sorted(l, reverse=True)
from itertools import accumulate
cum = [0] + list(accumulate(lr))
for i in lr:
  j = bisect.bisect_left(l, l_-i)
  ans += i*(n-j) + cum[n-j]
  cnt += n -j
ans -= (cnt-m)*l_
print(ans)

Measured memory_bytes: 14268
def answer(a: int, b: int) -> int:
    count = 0
    for i in range(a, b + 1):
        i_str = str(i)
        if i_str[0] == i_str[-1] and i_str[1] == i_str[-2]:
            count += 1

    return count


def main():
    a, b = map(int, input().split())
    print(answer(a, b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 1000005
const ll MOD = 1000000007;

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

	vector<int> p(MAX,1);
	vector<int> sp(MAX,1);
	vector<ll> primes;
	p[0] = p[1] = 0;
	for(ll i=2;i<MAX;i++){
		if(p[i]){
			sp[i] = i;
			primes.pb(i);
			for(ll j=i*i;j<MAX;j+=i){
				if(p[j]){
					p[j] = 0;
					sp[j] = i;
				}
			}
		}
	}

	ll n;
	cin>>n;

	ll ans = 0;
	for(ll pr: primes){
		if(n%pr == 0){
			ll cnt = 0;
			while(n%pr == 0){
				++cnt;
				n /= pr;
			}

			ll lo = 1;
			ll hi = MAX;
			while(lo<hi){
				ll mid = (lo+hi+1)/2;
				if(mid*(mid+1)/2 <= cnt)
					lo = mid;
				else
					hi = mid-1;
			}

			ans += lo;
		}
	}

	if(n != 1)
		++ans;
	cout<<ans<<endl;
}

Measured memory_bytes: 12032
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <stdlib.h>
#include <time.h>
#include <map>
#include <queue>
using namespace std;
int a, b, ans;
int main() {
	cin >> a >> b;
	if(a < 1 || b < 1 || a > 9 || b > 9) {
		cout << -1 << endl;
		return 0;
	}
	cout << a * b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long A, B;
  cin >> A >> B;
  long long i = 1;
  while(true){
    if(A*i % B == 0){
      cout << A*i << endl;
     break; 
    }
    i++;
    
  }
  
  
}


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

typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define test cout<<"#"

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n, k;
	cin>>n>>k;
	vector<ll> v(n);
	for(ll x = 0; x < n; x++)
		cin>>v[x];
	ll ans[n] = {0};
	ans[0] = 0;
	for(ll x = 1; x < n; x++)
	{
		ans[x] = ans[x-1] + abs(v[x]-v[x-1]);
		for(ll y = 2; y <=k; y++)
		{
			if(x-y>=0)
			ans[x] = min(ans[x], ans[x-y]+abs(v[x]-v[x-y]));
		}
	}
	cout<<ans[n-1]<<"\n";
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <functional>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<double> v(N);

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

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

    double V=v[0];

    for (size_t i = 0; i < N-1; i++)
    {
        V = (V+v[i+1])/2;
    }
    cout << setprecision(7) ;
    cout << V << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;
int main(){
  ll n,m;
  cin >> n>> m;
  ll a,b,vs,ss;
  vector<ll> v,s;
  for(int i=0;i<m;i++){
     cin >> a>> b;
     if(b==n) v.push_back(a);
    else if(a==1) s.push_back(b);
  }
  vs=v.size(); ss=s.size();
  sort(v.begin(),v.end());
  if(vs==0||ss==0) cout << "IMPOSSIBLE"<<endl;
  else{
  for(int i=0;i<ss;i++){
    if(binary_search(v.begin(),v.end(),s[i])){
      cout <<"POSSIBLE"<<endl;
      return 0;
    }
  }
  cout <<"IMPOSSIBLE"<<endl;
}
}


Measured memory_bytes: 1984
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <math.h>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
using namespace std;
using ll=long long;
#define MOD  1000000007


int main(int argc, char const *argv[]) {
  ll n,k,h[100100];
  std::cin >> n >> k;
  for(int i=0; i<n; i++) std::cin >> h[i];
  sort(h,h+n);
  ll ans=MOD;
  for(int i=0; i<n-k+1; i++){
    ll a=h[i+k-1]-h[i];
    if(ans>a) ans=a;
  }
  std::cout << ans << '\n';


  return 0;
}


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

  const int MOD = 1000000007;
  const double PI = acos(-1); 

  //long long
  using ll = long long;

  //出力系
  #define print(x) cout << x << endl
  #define yes cout << "Yes" << endl
  #define YES cout << "YES" << endl
  #define no cout << "No" << endl
  #define NO cout << "NO" << endl
  
  // begin() end()
  #define all(x) (x).begin(),(x).end()

  //for
  #define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

  //最大公約数（ll）
  ll gcd(ll x, ll y) { return y ? gcd(y,x%y) : x;}

  //素因数分解
  vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
      if(n % i) continue;
      res.emplace_back(i, 0);
      while(n % i == 0){
        n /= i;
        res.back().second++;
      }
    }
  if(n != 1) res.emplace_back(n, 1);
  return res;
  }



// // 二分探索(最小値を出す問題は疑う)
// bool C(ll x){
//     ll res = 0;
//     for(int i = 0; i < N; ++i){
// 		res += max(0ll, A[i]-x/F[i]);
//     }
//     return res <= K;
// }

//   ll binary_search(ll ok, ll ng){
//     while(abs(ok - ng) > 1){
//       ll mid = (ok + ng) / 2;
//       if(C(mid)) ok = mid;
//       else ng = mid;
//     }
//     return ok;
//   }



int main() {
ll A, B, C;
cin >> A >> B >> C;

if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0 ) print(0);
else print(min(A * B, min(A * C, B * C)));

}

Measured memory_bytes: 256
from heapq import heapify,heappush,heappop
N, M = map(int, input().split())
A = list(map(lambda x: -int(x), input().split()))
heapify(A)
for i in range(M):
  tmp = heappop(A)
  heappush(A,-((-tmp)//2))
A = list(A)

print(-sum(A))


Measured memory_bytes: 20436
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


class saidan:
    def __init__(self,n,cl):
        self.n = n
        self.cl = cl
        self.l = 0
        self.r = n

    def check(self):
        for i in range(self.l,n):
            if cl[i] == 0:
                self.l = i 
                break
        else:
            self.l = self.n-1 


        for i in range(n-self.r,n):
            if cl[self.n-1-i] == 1:
                self.r = self.n-i
                break
            else:
                self.r = 0

        return self.r - self.l

    def swap(self):
        # print('swap', self.l,self.r)
        # print(self.cl)
        cl[self.l], cl[self.r-1] = cl[self.r-1],cl[self.l]

n = ii()
c = input()

cl = []
for i in range(n):
    if c[i] == 'R':
        cl.append(1)
    else:
        cl.append(0)

sd = saidan(n,cl)

ans = 0
while 1:
    if sd.check() <= 1:
        break
    
    sd.swap()
    ans += 1

print(ans)



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

int main(){

  int pasta=2000,juice=2000,in;

  for(int i=0; i<3; i++){
    cin>>in;
    if(in<pasta)pasta = in;
  }
  for(int i=0; i<2; i++){
    cin >> in;
    if(in<juice)juice = in;
  }

  cout << pasta + juice - 50 << endl;

  return 0;
}

Measured memory_bytes: 1160
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Spandan Mishra
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BAnOddProblem solver = new BAnOddProblem();
        solver.solve(1, in, out);
        out.close();
    }

    static class BAnOddProblem {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.readInt();
            int[] a = new int[n + 1];
            int ans = 0;
            for (int i = 1; i <= n; i++) {
                a[i] = in.readInt();
                if (i % 2 == 1 && a[i] % 2 == 1)
                    ans++;
            }

            System.out.println(ans);

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new RuntimeException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new RuntimeException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



Measured memory_bytes: 32380