akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    int n, m;
    cin >> n >> m;
    vector<P> v(m);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        v[i].first = b;
        v[i].second = a;
    }
    sort(all(v));
    int ans = 0;
    int t = 0;
    rep(i, m)
    {
        if (t <= v[i].second)
        {
            ans++;
            t = v[i].first;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include "bits/stdc++.h"
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
const ll MOD=1000003,MAX=MOD;
ll 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 ruijo(ll a,ll n){
	if(n==0) return 1;
	if(n%2==0) return ruijo(a*a%MOD,n/2);
	else return ruijo(a,n-1)*a%MOD;
}
int main(){
	COMinit();
	int Q;
	scan(Q);
	rep(i,Q){
		ll x,d,n;
		scan(x>>d>>n);
		if(d==0) prin(ruijo(x,n));
		else{
			if(x*inv[d]>0&&x*inv[d]/MOD==(x*inv[d]+n-1)/MOD){
				prin(fac[(x*inv[d]+n-1)%MOD]*finv[(x*inv[d]-1)%MOD]%MOD*ruijo(d,n)%MOD);
			}
			else{
				prin(0);
			}
		}
	}
	return 0;
}


Measured memory_bytes: 24320
#include<bits/stdc++.h>
using namespace std;
int n,p;
int a[55];
long long mem[55][2];
long long f(int x,int now) {
    if(x==n+1) return now==p;
    if(mem[x][now]==-1) {
        mem[x][now] = 0;
        mem[x][now] = f(x+1,now) + f(x+1,(now+a[x])%2);
    }
    return mem[x][now];
}
main() {
    int i;
    scanf("%d%d",&n,&p);
    for(i=1;i<=n;i++) scanf("%d",&a[i]);
    memset(mem,-1,sizeof(mem));
    printf("%lld",f(1,0));
}


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

using namespace std;

int const N = 1e5 + 1;
int n, m, p[N];
bool vis[N];
vector<vector<int> > g;
vector<int> cur;

void DFS(int u) {
  vis[u] = true;
  cur.push_back(u);

  for(int i = 0; i < g[u].size(); ++i)
    if(!vis[g[u][i]])
      DFS(g[u][i]);
}

int main() {
  cin >> n >> m;
  g.resize(n);
  for(int i = 0; i < n; ++i)
    cin >> p[i], --p[i];
  for(int i = 0, a, b; i < m; ++i) {
    cin >> a >> b;
    --a, --b;
    g[a].push_back(b);
    swap(a, b);
    g[a].push_back(b);
  }

  int res = 0;
  for(int i = 0; i < n; ++i) {
    if(!vis[i]) {
      DFS(i);

      sort(cur.begin(), cur.end());
      for(int j = 0; j < cur.size(); ++j)
        if(binary_search(cur.begin(), cur.end(), p[cur[j]]))
          ++res;
      cur.clear();
    }
  }

  cout << res << endl;

  return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  
  for(int i = 0; i < n; i++) {
    int a;
    cin >> a;
    v.at(i) = a;
  }
  
  int ans = 0;
  
  for(int i = 0; i < n; i++) {
    if(i % 2 == 0) {
      if(v.at(i) % 2 == 1) ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

const int N = 5005;
char seq[N];

set<string> Q;
int main() {
	int K;
	while(~scanf("%s %d", seq, &K)) {
		Q.clear();


		int len = strlen(seq);
		for(int i = 0; i < len; ++i) {
			string tt;
			int flag = 0;
			for(int j = i; j < i + K + flag && j < len; ++j) {
				tt += seq[j];
				int presize = Q.size();
				Q.insert(tt);
				int nowsize = Q.size();
				if(presize == nowsize) {
					flag ++;
					continue;
				}

				if((int)Q.size() == K + 1) {
					string bottom = *(--Q.end());
					if(bottom == tt) {
						Q.erase(--Q.end());
						break;
					} else Q.erase(--Q.end());
				}
			}
		}

		printf("%s\n", (*(--Q.end())).c_str());
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    ll ans=0;
    while(1){
        if((a%2)||(b%2)||(c%2)){
            cout<<ans<<endl;return 0;
        }
        else if(a==b&&b==c){
            cout<<-1<<endl;return 0;
        }
        ll aa=a,bb=b,cc=c;
        a=(bb+cc)/2;b=(aa+cc)/2;c=(aa+bb)/2;
        ans++;
    }
    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    int ac = 0,wa = 0,re = 0,tle = 0;
    vector<string> ju(n);
    rep(i,n){
        cin >> ju[i];
        if(ju[i] == "AC") ac++;
        if(ju[i] == "WA") wa++;
        if(ju[i] == "TLE") tle++;
        if(ju[i] == "RE") re++;
    }
    cout << "AC x " << ac << endl << "WA x " << wa << endl << "TLE x " << tle << endl << "RE x " << re << endl;
    return 0;
}

Measured memory_bytes: 6424
// AOJ 2265: Programming Contest Challenge Book
// 2017.10.15

#include <stdio.h>
#include <stdlib.h>

long long a[100005];
char buf[50], *p;

int cmp(long long *a, long long *b)
{
	if (*a == *b) return 0;
	return *a < *b ? 1 : -1;
}

long long getInt()
{
	long long n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int check(int i)
{
	if (a[i+4]+a[i+5] > a[i+3]) return 1;
	if (a[i+1]+a[i+3] > a[i] && a[i+5]+a[i+4] > a[i+2]) return 1;
	if (a[i+1]+a[i+4] > a[i] && a[i+5]+a[i+3] > a[i+2]) return 1;
	if (a[i+1]+a[i+5] > a[i] && a[i+4]+a[i+3] > a[i+2]) return 1;
	if (a[i+2]+a[i+3] > a[i] && a[i+5]+a[i+4] > a[i+1]) return 1;
	if (a[i+2]+a[i+4] > a[i] && a[i+5]+a[i+3] > a[i+1]) return 1;
	if (a[i+2]+a[i+5] > a[i] && a[i+4]+a[i+3] > a[i+1]) return 1;
	if (a[i+3]+a[i+4] > a[i] && a[i+5]+a[i+2] > a[i+1]) return 1;
	if (a[i+3]+a[i+5] > a[i] && a[i+4]+a[i+2] > a[i+1]) return 1;
	if (a[i+4]+a[i+5] > a[i] && a[i+3]+a[i+2] > a[i+1]) return 1;
	return 0;
}

int main()
{
	int n, i, j;
	long long ans;

	fgets(buf, 10, stdin); n = atoi(buf);
	for (i = 0; i < n; i++) {
		fgets(p=buf, 40, stdin); a[i] = getInt();
	}
	qsort(a, n, sizeof(long long), cmp);
	ans = 0;
	for (ans = 0, i = 2; i < n; i++) {
		if (a[i-2] < a[i-1] + a[i]) break;
	}
	if (i + 3 >= n) goto Done;
	i -= 2;

	if (check(i)) for (j = 0; j < 6; j++) ans += a[i+j];
	else {
		for (j = 0; j < 3; j++) ans += a[i+j];
		for (i += 5; i < n; i++) {
			if (a[i-2] < a[i-1] + a[i]) {
				ans += a[i-2]+a[i-1]+a[i];
				break;
			}
		}
		if (i == n) ans = 0;
	}
Done:
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ll modpow(ll a, ll n, ll mod_) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod_;
        a = a * a % mod_;
        n >>= 1;
    }
    return res;
}

//const ll mod = 998244353;
const ll mod = 1e9 + 7;
const ll MAX_SIZE = 1000005;
array<ll, MAX_SIZE> fac, inv, finv;
ll fac_init() {
    // combination init
    fac[0] = 1;
    for (ll i = 1; i < MAX_SIZE; i++) fac[i] = fac[i - 1] * i % mod;
    finv[0] = modpow(fac[MAX_SIZE - 1], mod - 2, mod);
    repe(i, 1, MAX_SIZE) finv[i] = finv[i - 1] * (MAX_SIZE - i) % mod;
    reverse(all(finv));

    //inv init
    repe(i, 1, MAX_SIZE) inv[i] = modpow(i, mod - 2, mod);
}

ll perm(ll a, ll b) { return fac[a] * finv[a - b] % mod; }

ll comb(ll a, ll b) { return fac[a] * finv[b] % mod * finv[a - b] % mod; }

int main() {
    init();
    ll N, K;
    cin >> N >> K;
    ll s = N - 1;
    fac_init();
    if(K>=s){
        cout << comb(N + s, s) << endl;
        return 0;
    }

    ll ans = 0;

    rep(i,K+1){
        ll A = N - i;
        ll m = i;

        ans = (ans + comb(N, A) * comb(A+m-1, m)) % mod;
    }
    cout << ans << endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; string s; cin>>n>>s;
	vector<int>cntr(26,0);
	for(auto&&i:s)++cntr.at(i-'a');
	vector<int>cntl(26,0);
	int ans=0,tans=0;
	for(int i=0;i<n;++i){
		int c=s.at(i)-'a';
		bool ex=false;
		if(cntl.at(c)&&cntr.at(c))ex=true;
		++cntl.at(c),--cntr.at(c);
		if(ex){
			if(!cntr.at(c))--tans;
		}
		else if(cntl.at(c)&&cntr.at(c))++tans;
		ans=max(ans,tans);
	}
	cout<<ans<<"\n"s;
}


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

const int M = 1000005;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  int MAX = 0;
  rep(i,n){
      cin >> a[i];
      MAX = max(MAX, a[i]);
  }
  vector<int> cnt(MAX+5);
  for (int x : a) {
    // if (cnt[x] != 0) {
    //   cnt[x] = 2;
    //   continue;
    // }
    for (int i = x; i < cnt.size(); i += x) cnt[i]++;
  }
  int ans = 0;
  for (int x : a) {
    if (cnt[x] == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7968
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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 int mod=1000000007;
const int INF=1001001001;

int main() {
  int N;
  cin>>N;
  vector<int>X(N);
  for(int i=0;i<N;i++){
    cin>>X[i];
  }
  int MIN=INF;
  for(int P=1;P<=100;P++){
    int sum=0;
    for(int i=0;i<N;i++){
      int r=abs(X[i]-P);
      sum+=r*r;
    }
    if(sum<MIN){MIN=sum;}
  }
  cout<<MIN<<endl;
  return 0;  
}

Measured memory_bytes: 3596
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func main() {
	n := readInt()
	a := make(map[int]int, n)
	for i := 1; i <= n; i++ {
		a[i] = readInt()
	}
	cnt := 1
	i := 1
	for {
		switch {
		case a[i] == 2:
			fmt.Println(cnt)
			os.Exit(0)
		case a[i] == -1:
			fmt.Println(-1)
			os.Exit(0)
		default:
			cnt++
			i, a[i] = a[i], -1
		}
	}
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aut(r,v) __typeof(v) r = (v)
#define each(it,o) for(aut(it,(o).begin()); it!=(o).end(); ++it)
#define reach(it,o) for(aut(it,(o).rbegin()); it!=(o).rend(); ++it)
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T1, typename T2> ostream& operator<<(ostream& o, const pair<T1, T2>& p)
{return o<<"("<<p.first<<", "<<p.second<<")";}
template<typename T>string join(const vector<T>&v, string del=", ")
{stringstream s;rep(i,v.size())s<<del<<v[i];return s.str().substr(del.size());}
template<typename T>ostream& operator<<(ostream& o, const vector<T>&v)
{if(v.size())o<<"["<<join(v)<<"]";return o;}
template<typename T>ostream& operator<<(ostream& o, const vector<vector<T> >&vv)
{int l=vv.size();if(l){o<<endl;rep(i,l){o<<(i==0?"[ ":",\n  ")<<vv[i]<<(i==l-1?" ]":"");}}return o;}
template<typename T>ostream& operator<<(ostream& o, const set<T>& st)
{vector<T> v(st.begin(),st.end());o<<"{ "<<join(v)<<" }";return o;}
template<typename T1, typename T2>ostream& operator<<(ostream& o, const map<T1, T2>& m)
{each(p,m){o<<(p==m.begin()?"{ ":",\n  ")<<*p<<(p==--m.end()?" }":"");}return o;}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

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

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const ll INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n; cin >> n;
    vvl A(n, vl(n));
    vl C(1<<n);
    rep(i,n) rep(j,n) cin >> A[i][j];
    rep(k,1<<n) rep(i,n) REP(j,i+1,n){
        if(k>>i & 1 && k>>j & 1)
            C[k] += A[i][j];
    }

    ll ans = 0;
    vl dp(1<<n);
    rep(k,1<<n){
        for(int l=k; l>0; l=(l-1)&k){
            dp[k] = max(dp[k], dp[k - l] + C[l]);
        }
    }
    cout << dp[(1<<n) - 1] << endl;
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define a first
#define b second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
const int MOD = 1000000007; 


int main() {
    string s;
    cin >> s;
    int n = s.size();
    if (n < 4) {
        cout << 0 << endl;
        return 0;
    }
    int keta = 1, bnum=0; 
    unordered_map<int, ll> mp;
    per(i, n) {
        int c = s[i] - '0';
        bnum += c*keta%2019;
        bnum %= 2019;
        keta = keta*10%2019;
        mp[bnum]++; 
    }
    ll ret = 0;
    for (auto& p : mp) {
        ll c = p.second;
        ret += c*(c-1)/2; 
        if (p.first==0) ret += c; 
    }
    cout << ret << endl;
    return 0;
}

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

#define PB          push_back
#define PF          push_front
#define MP          make_pair
#define FI          first
#define SE          second
#define SIZE( A )   int( ( A ).size( ) )
#define ALL( A )    ( A ).begin( ), ( A ).end( )
#define ALLR( A )   ( A ).rbegin( ), ( A ).rend( )

using namespace std;

typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         lf;
typedef pair< int, int >    pii;
typedef pair< ll, ll >      pll;
typedef vector< bool >      vb;
typedef vector< lf >        vd;
typedef vector< ll >        vll;
typedef vector< int >       vi;
typedef vector< pii >       vpii;

const int MAXN = int( 1e5 )+10;
const int MOD  = int( 360 );
const int oo   = INT_MAX;

int n, odd, even, cnt;
int arr[ MAXN ];

bool reduce() {
  if( odd != 1 ) return false;
  int gcd = 0;
  for( int i = 0; i < n; ++i ) {
    if( arr[i] == 1 ) return false;
    if( arr[i]%2 ) --arr[i];
    gcd = __gcd( gcd, arr[i] );
  }
  odd = even = 0;
  for( int i = 0; i < n; ++i ) {
    arr[i] /= gcd;
    if( arr[i]%2 ) ++odd;
    else ++even;
  }
  return true;
}

int main( ) {

  #ifdef LOCAL
    freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
  #else
    //freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
    ios_base::sync_with_stdio( 0 );
    cin.tie( 0 );
  #endif

  while( cin >> n ) {
    even = odd = cnt = 0;
    for( int i = 0; i < n; ++i ) {
      cin >> arr[ i ];
      if( arr[i]%2 ) ++odd;
      else ++even;
    }
    while( reduce() ){ ++cnt; }
    even += cnt;
    if( even%2 ) {
      cout << "First\n";
    }
    else {
      cout << "Second\n";
    }
  }
  return 0;
}


Measured memory_bytes: 640
import java.io.*;
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int a[]=new int[n];
    long ans=0;
    for( int i=0;i<n;i++)
    {
      a[i]=sc.nextInt();
    
    }
    Arrays.sort(a);
    ans+=(long)a[n-1];
    int p=2;
   for( int i=n-2;p<=n&&i>=0;i--)
   {
     if(p==n)
       break;

        ans+=(long)a[i];
        p++;
       if(p==n)
       break;
     ans+=(long)a[i];
     p++;
   }
     
    
    System.out.println(ans);
  }
}


Measured memory_bytes: 60644
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<cassert>
#include<random>
#include<time.h>
#include<functional>
using namespace std;
using ll=long long;
using ld=long double;
using pint=pair<int,int>;
using pll=pair<ll,ll>;
#define MOD 1000000007LL
#define INF 1000000000LL
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v)  sort(ALL(v));v.erase(unique(ALL(v)),v.end());
#define pb push_back

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin >> n;
	vector<ll> h(n);
	REP(i, n) cin >> h[i];
	vector<ll> dp(n, 0);
	dp[0] = 0;
	dp[1] = abs(h[0] - h[1]);
	FOR(i, 2, n) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]),
					dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[n - 1] << endl;
	return 0;
}

/* --------------------------------------- */


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define ll long long
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);


int main() {
  int a,b;
  cin >> a >> b;
  
  string s = to_string(min(a,b));
  
  rep(i,max(a,b)) {
  cout << s;
  }
   
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int n,x,i,j,k;
	while(1){
		int t=0;
	scanf("%d %d",&n,&x);
		if(n==0&&x==0)break;
		for(i=1;i<=n;i++){
			for(j=i+1;j<=n;j++){
				for(k=j+1;k<=n;k++){
					if(i+j+k==x)t++;
					}
				}
			}
		printf("%d\n",t);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <list>
#include <string>
#include <map>
#include <numeric>
#include <queue>
#include <stack>

using namespace std;
using ll = long long;

int main() {

	int n, m, ans = 1e9, p , cnt;
	int a[310][310] = { 0 };
	int sum[310] = { 0 };
	bool jud[310][310] = { false };

	cin >> n >> m;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> a[i][j];
			jud[i][j] = true;
		}
	}

	for (int k = 1; k <= m; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (jud[i][j] == true) {
					sum[a[i][j]]++;	//　数え上げ
					break;
				}
			}
		}

		p = 0;
		for (int i = 1; i <= m; i++) {
			if (p < sum[i]) {
				p = sum[i];
				cnt = i;
			}
			sum[i] = 0;
		}


		ans = min(p, ans);

		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				if (a[i][j] == cnt) {
					jud[i][j] = false;
					break;
				}
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 768
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

s = input()

a,b = "",""

a = s[0]

if a != s[1]:
    b = s[1]

    if a in s[2:] and b in s[2:]:
        print("Yes")
    else:
        print("No")
else:
    if a != s[2] and s[2] == s[3]:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 38384
// May this submission get accepted!

#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 STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
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) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return 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
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll h, w; cin >> h >> w;
    vector<string> a(h);
    REP(i, h) cin >> a[i];

    vector<bool> fr(h, 1), fc(w, 1);
    REP(i, h) REP(j, w) {
        if (a[i][j] == '#') {
            fr[i] = 0;
            fc[j] = 0;
        }
    }

    REP(i, h) if (!fr[i]) {
        REP(j, w) if (!fc[j]) {
            cout << a[i][j];
        }
        cout << endl;
    }
    
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int main(){
  int N, M;
  int X[112345];
  int gaps[112345];

  scanf("%d %d", &N, &M);
  if(M == 1){
    printf("0\n");
  }else{
    for(int i=0; i < M; i++){
      scanf("%d", X + i);
    }
    sort(X, X + M);
    for(int i=0; i < M - 1; i++){
      gaps[i] = X[i + 1] - X[i];
    }
    sort(gaps, gaps + M - 1);
    int skip = 0;
    for(int i=0; i < N - 1; i++){
      if((M - 1) - 1 - i >= 0){
        skip += gaps[(M - 1) - 1 - i];
      }else{
        break;
      }
    }
    int total = X[M - 1] - X[0];
    printf("%d\n", total - skip);
  }


  return 0;
}


Measured memory_bytes: 896
S = input()

tmpR = 0
tmpL = 0
index1 = 0
index2 = 0
ansLst = [0] * len(S)
for i in range(len(S)):
    if S[i] == 'R':
        tmpR += 1
    else:
        tmpL += 1
        if S[i - 1] == 'R':
            index1 = i - 1
            index2 = i
        if i == (len(S)) - 1 or S[i + 1] == 'R':
            if tmpR % 2 != 0:
                if tmpL % 2 == 0:
                    ansLst[index1] = ((tmpR // 2) + 1) + ((tmpL // 2))
                    ansLst[index2] = (tmpR - ((tmpR // 2) + 1)) + (tmpL - ((tmpL // 2)))
                else:
                    ansLst[index1] = ((tmpR // 2) + 1) + ((tmpL // 2))
                    ansLst[index2] = (tmpR - ((tmpR // 2) + 1)) + (tmpL - ((tmpL // 2)))
            else:
                if tmpL % 2 == 0:
                    ansLst[index1] = ((tmpR // 2)) + ((tmpL // 2))
                    ansLst[index2] = (tmpR - ((tmpR // 2))) + (tmpL - ((tmpL // 2)))
                else:
                    ansLst[index1] = ((tmpR // 2)) + ((tmpL // 2))
                    ansLst[index2] = (tmpR - ((tmpR // 2))) + (tmpL - ((tmpL // 2)))
            tmpR = 0
            tmpL = 0

for i in ansLst:
    print(i, end= ' ')

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

using ll = long long;
#define int long long

// [a -> b-1]
#define reps(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
// [0 -> a-1]
#define rep(i, a) reps(i, 0, (a))
// [a-1 -> b]
#define rreps(i, a, b) for (int i = (int)((a)-1); i >= (int)(b); i--)
// [a-1 -> 0]
#define rrep(i, a) rreps(i, a, 0)
#define all(v) (v).begin(), (v).end()
// next_permutation(all(v))
#define PERM(v) next_permutation(all(v))
/*sort(all(v));
 * (v).erase(unique(all(v)), v.end())*/
#define UNIQUE(v)\
	sort(all(v));\
	(v).erase(unique(all(v)), v.end())
#define MINV(v) min_element(all(v))
#define MAXV(v) max_element(all(v))
#define MIN3(a, b, c) min(min(a, b), c)
#define MIN4(a, b, c, d) min(MIN3(a, b, c), d)
#define MIN5(a, b, c, d, e) min(MIN4(a, b, c, d), e)
#define MIN6(a, b, c, d, e, f) min(MIN5(a, b, c, d, e), f)
#define MAX3(a, b, c) max(max(a, b), c)
#define MAX4(a, b, c, d) max(MAX3(a, b, c), d)
#define MAX5(a, b, c, d, e) max(MAX4(a, b, c, d), e)
#define MAX6(a, b, c, d, e, f) max(MAX5(a, b, c, d, e), f)
// b is [a, c)
#define RANGE(a, b, c) ((a) <= (b) && (b) < (c))
// c is [a, e) && d is [b, f)
#define RANGE2D(a, b, c, d, e, f) (RANGE((a), (c), (e)) && RANGE((b), (d), (f)))
#define chmin(a, b) a = min(a, (b))
#define chmin3(a, b, c) a = MIN3(a, (b), (c))
#define chmin4(a, b, c, d) a = MIN4(a, (b), (c), (d))
#define chmin5(a, b, c, d, e) a = MIN5(a, (b), (c), (d), (e))
#define chmin6(a, b, c, d, e, f) a = MIN6(a, (b), (c), (d), (e), (f))
#define chmax(a, b) a = max(a, (b))
#define chmax3(a, b, c) a = MAX3(a, (b), (c))
#define chmax4(a, b, c, d) a = MAX4(a, (b), (c), (d))
#define chmax5(a, b, c, d, e) a = MAX5(a, (b), (c), (d), (e))
#define chmax6(a, b, c, d, e, f) a = MAX6(a, (b), (c), (d), (e), (f))
#define fcout cout << fixed << setprecision(15)
#define YES(f) cout << ((f) ? YES_STR : NO_STR) << endl;

const string YES_STR = "Yes";
const string NO_STR = "No";

bool solve(long long N, std::vector<std::string> W) {
	set<string> s;
	rep(i, N) {
		s.insert(W[i]);
		if (i) {
			if (W[i][0] != W[i-1].back()) {
				return false;
			}
		}
	}
	return s.size() == N;
}

signed main() {
	long long N;
	scanf("%lld",&N);
	std::vector<std::string> W(N);
	for(int i = 0 ; i < N ; i++){
		std::cin >> W[i];
	}
	YES(solve(N, std::move(W)));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#define int long long int
#define MOD 1000000007
#define MAX INT_MAX
using namespace std;

int add(int a, int b) {
    int z = (a%MOD + b%MOD) % MOD;
    return z;
}

int mul(int a, int b) {
    int z = (a%MOD * b%MOD) % MOD;
    return z;
}

int myXOR(int x, int y) {
     return (x | y) & (~x | ~y);
}

void solve() {
    int n;
    cin >> n;
    vector <int> v;
    for(int i=0;i<2*n;i++) {
        int x;
        cin >> x;
        v.push_back(x);
    }
    sort(v.begin(), v.end());
    int sum = 0;
    for(int i=0;i<2*n;i+=2)
        sum += min(v[i], v[i+1]);
    cout << sum << '\n';
    return ;
}              

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    solve();
    return 0;
}


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


int main(){
vector<int> vec(5);

rep(i,5) {
  cin >> vec.at(i);
  if (vec.at(i) == 0) {
    cout << i+1 << endl;
  }
}



return 0;
}

Measured memory_bytes: 3620
S = input()
S = "".join(list(reversed(S)))
str_list = ["dream", "dreamer", "erase", "eraser"]
rev_str = []
for i in str_list:
    rev_str.append("".join(list(reversed(i))))
is_OK = True
while len(S) > 0:
    if S[0:5] in rev_str:
        S = S[5:]
    elif S[0:6] in rev_str:
        S = S[6:]
    elif S[0:7] in rev_str:
        S = S[7:]
    else:
        is_OK = False
        break
if is_OK:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 134824
#include<stdio.h>

int main(){
    int r,g,b;
    scanf("%d %d %d", &r, &g, &b);

    if((r*100 + g*10 + b) %4 == 0){
        printf("YES\n");
    }
    else{
        printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<set>
#include<vector>
using namespace std;

int main(void) {
	int n, cnt = 1, num = 1;
	set<int> b;
	cin >> n;
	vector<int> a(n+1);
	for (int i = 1; i <= n; i++) cin >> a[i];

	while (1) {
		num = a[num];
		if (b.count(num) == 1) {
			cout << "-1" << endl;
			return 0;
		}
		b.insert(num);
		if (num == 2) {
			cout << cnt << endl;
			return 0;
		}
		cnt++;
	}
}

Measured memory_bytes: 5376
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int cnt=100000;
	for(int i=0;i<n;i++){
		cnt=cnt*1.05;
		if((cnt%1000)>0){
			cnt+=1000;
			cnt-=(cnt%1000);
		}
	}
	cout<<cnt<<endl;
return 0;
}

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

int main() {
  string T;
  cin >> T;
  
  if (T.size() == 1){
    if (T.at(0) == '?'){
      T.at(0) = 'D';
    }
    cout << T << endl;
    return 0;
  }
  
  for (int i =0; (T.at(i) == 'D' || T.at(i) == '?') && (i < T.size()-1) ; i++){
    if (T.at(i) == '?')
      T.at(i) = 'D';
  }
  //P以降
  for (int i =0; i < (T.size()-1); i++){
    if (T.at(i) == 'P' && T.at(i+1) == '?'){
      T.at(i+1) = 'D';
    }else if (T.at(i) == '?'){
      T.at(i) = 'D';
    }
  }
  //
  if(T.at(T.size()-1) == '?')
    T.at(T.size()-1) = 'D';
  
  cout << T << endl;
}

Measured memory_bytes: 3756
#include <iostream> 
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
	int a[5];
	for(int i=0;i<5;i++){
		cin>>a[i];
	}
	sort(a,a+5);
	for(int i=4;i>=0;i--)
		printf("%d%c",a[i],i==0?'\n':' ');
    return 0;
}

Measured memory_bytes: 1160
/*
ID: Nipun Paul
LANG: C++
PROB: God knows
*/

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int a,b[100005]={0},e=0,f=0,sum=0,sum1=0,d=0;
    cin>>a;
    for(int i=0; i<a; i++)
    {
        cin>>b[i];
    }
    sort(b,b+a);
    d=(a/2);
    if(b[d-1]!=b[d])
    {
        cout<<b[d]-b[d-1]<<endl;
    }
    else
    {
        cout<<"0"<<endl;
    }
    //d=(b[a-1]+b[0])/2;
    /*for(int i=0; i<a; i++)
    {
        if(b[i]<d)
        {
            e=b[i];
            sum++;
        }
        else if(b[i]>=d)
        {
            break;
        }
    }
    for(int i=a-1; i>=0; i--)
    {
        if(b[i]>=d)
        {
            f=b[i];
            sum1++;
        }
        else if(b[i]<d)
        {
            break;
        }
    }*/
    /*if(sum1==sum)
    {
        cout<<f-e<<endl;
    }
    else
    {
        cout<<"0"<<endl;
    }*/
    return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#define dlog(str) cout << "====" << str << endl;
#else
#define dlog(str)
#endif
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define FOR(i, s, e) for(int i = s, i##_l = (e); i < i##_l; i++)
#define LLI long long int
#define _min(a,b) ((a<b)?a:b)
#define _max(a,b) ((a<b)?b:a)
#define chmax(a, b) a = _max(a, b)
#define chmin(a, b) a = _min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define pm(a) ((a)?1:-1)
#define SORT(v) sort(v.begin(),v.end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
// int 2.14E±9    lli 9.2E±18    double 1.7E±380


int main()
{
	cout << fixed << setprecision(10);


	int n;
	cin >> n;
	int k1 = n % 10;
	switch (k1)
	{
	case 2:case 4:case 5:case 7:case 9:cout << "hon"; return 0;
	case 0:case 1:case 6:case 8:cout << "pon"; return 0;
	case 3:cout << "bon"; return 0;
	}

	return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 1e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 3e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }


typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n,a[55];
main() {
    file("dishes");
    ios;
    cin>>n;
    fo(i,1,n,1) cin>>a[i];
    fo(i,1,n,1) {
        fo(j,i,n,1) {
            swap(a[i],a[j]);
            bool t=0;
            fo(k,1,n-1,1) {
                if (a[k]>a[k+1]) t=1;
            }
            if (!t) return !(cout<<"YES");
            swap(a[i],a[j]);
        }
    }
    cout<<"NO";
    return 0;
}
/**

*/


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>
using namespace std;

int main() {
  int N, M; cin >> N >> M;
  map<int, int> WA;
  map<int, int> AC;
  long long ac_cnt = 0;
  long long wa_cnt = 0;
  for (int i = 0; i < M; i++) {
    int p;
    string s;
    cin >> p >> s;
    if (s == "WA" && !AC[p]) WA[p]++;  
    if (s == "AC" && !AC[p]) AC[p]++;  
  }

  for (int i = 1; i <= N; i++) {
    if (!AC[i]) continue;
    wa_cnt += WA[i];
    ac_cnt += AC[i];
  }

  cout << ac_cnt << " " << wa_cnt << endl;
}


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

using namespace std;

int solve(int A[], int i, int m, int n){
    if(m == 0) return 1;
    if(m < 0) return 0;
    if(n <= i) return 0;
    int u = solve(A, i+1, m - A[i], n);
    int y = solve(A, i+1, m, n);
    return max(u,y);
}

int main(void){
    int n; cin >> n;
    int A[n];
    for(int i = 0; i < n; i++) cin >> A[i];
    int q; cin >> q;
    int m[q];
    for(int i = 0; i < q; i++) cin >> m[i];
    for(int i = 0; i < q; i++){
        if(solve(A, 0, m[i], n)){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    return 0;
}


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

int main() {
  
  int A, B ,mon;
  cin >> A >> B;
  
  if ( A > B ){
    mon += A ;
    A--;
  }
  else{
    mon += B;
    B--;
  }
  
  if ( A > B ){
    mon += A ;
    A--;
  }
  else{
    mon += B;
    B--;
  }
  
  cout << mon << endl;
  
}


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

int a[100005];
int main()
{
	int n,Max=-1,Min=100005,k=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),Min=min(Min,a[i]),Max=max(Max,a[i]);
	if(Max-Min>1) return !printf("No");
	if(Max==Min)
	{
		if(Max==n-1) return !printf("Yes");
		if(n>=2*Max) return !printf("Yes");
		return !printf("No");
	}
	for(int i=1;i<=n;i++) if(a[i]==Max) k++;
	int M=Max-(n-k);
	if(M>0&&k>=2*M) return !printf("Yes");
	return !printf("No");
}

Measured memory_bytes: 512
#include <iostream>
#include <iosfwd>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <cassert>
#include <cctype>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <math.h>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <sstream>
#include <complex>
#include <fstream>
#include <functional>
#include <numeric>
#include <utility>
#include <algorithm>
#include <assert.h>
#include <unordered_map>
#pragma GCC optimize ("-O3")
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
#define tolower(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define toupper(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define ll long long int
ll max(ll a, ll b) {  return a > b ? a : b; }
ll gcd(ll a, ll b) { if (a == 0) return b; return b == 0 ? a : gcd(b, a % b);}
#define case(i) cout<<"Case #"<<i<<": ";
#define pii pair <ll , ll >
#define pb push_back
#define PRECISION 10
const ll inf = 1e16;
const int MAXN = 100001;
const int LOGN = 22;
const int MAXBIT = 22;
const int DIGITSIZE = 19;
ll mod = 1e9 + 7;
ll MOD = 998244353;
int x4[] = {1, -1, 0, 0};
int y4[] = {0, 0, 1, -1};
void getac(int T) {
  int n,k;
  cin>>n>>k;
  ll arr[n+1];
  for(int i=1;i<=n;i++)
  {
    cin>>arr[i];
  }
  ll dp[n+1];
  dp[0]=0;
  dp[1]=0;
  for(int i=2;i<=n;i++){
    dp[i]=INT_MAX;
    int l=k;
    for(int j=i-1;j>=1 && l;j-- && l--){
        dp[i]=min(dp[i],dp[j]+abs(arr[i]-arr[j]));
    }

  }
  cout<<dp[n];
}
int  main()
{

    fastio;
    int t = 1;
    //cin >> t;
    int t_t = 1;
    while (t--) {

        getac(t_t);
        t_t++;
    }
    return 0;
}

Measured memory_bytes: 1792
N, Y = map(int, input().split())
for a in range(N + 1):
    for b in range(N + 1 - a):
        if a * 10000 + b * 5000 + (N - a - b) * 1000 == Y:
            print(a, b, (N - a - b))
            exit()
print("-1 -1 -1")


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

/*	Author: 🆉🅴🅽🅾🅻🆄🆂	*/

int main(){
	ll n, W, maxVal = 1, ans = 0;	cin>>n>>W;	ll w[n], v[n];
	for(ll i = 0; i < n; i++)	cin>>w[i]>>v[i];
	for(auto x : v)	maxVal += x;
	ll dp[n+1][maxVal];
	for(ll i = 1; i < maxVal; i++)	dp[0][i] = INT_MAX;	dp[0][0] = 0;
	for(ll i = 1; i <= n; i++){
		for(ll j = 0; j < maxVal; j++){
			dp[i][j] = dp[i-1][j];
			if(j >= v[i-1])	dp[i][j] = min(dp[i][j], w[i-1] + dp[i-1][j-v[i-1]]);
		}
	}
	for(ll i = 0; i < maxVal; i++)	if(dp[n][i] && dp[n][i] <= W)	ans = i;
	cout<<ans;
}

// Time: O(N*sum of values)
// Space: O(N*sum of values)

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

int main() {
    string str;
    long ans = 0, temp = 0;
    cin >> str;
    rep(i, str.length()) {
        if(str.at(i) == 'W') ans += temp;
        else temp++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int SIZE=10000000;
bool is_prime[SIZE];
int main() {
    memset(is_prime,-1,sizeof(is_prime));
    for(int i=2;i*i<SIZE;i++) {
        if(!is_prime[i]) continue;
        for(int j=i*2;j<SIZE;j+=i) is_prime[j]=0;
    }
    vector<int> prime;
    for(int i=2;i<SIZE;i++) if(is_prime[i]) prime.push_back(i); 
    int N,P;
    while(scanf("%d %d",&N,&P),N!=-1) {
        int pos=upper_bound(prime.begin(),prime.end(),N)-prime.begin();
        vector<int> L;
        for(int i=0;i<P;i++) {
            for(int j=i;j<P;j++) {
                L.push_back(prime[pos+i]+prime[pos+j]);
            }
        }
        sort(L.begin(),L.end());
        printf("%d\n",L[P-1]);
    }
}

Measured memory_bytes: 16548
S = input()

ans = 0
tmp = 0
flag = False

for i in S:
    if (i == "A") or (i == "C") or (i == "G") or (i == "T"):
        tmp += 1
        flag = True
    elif (tmp > ans) and flag:
        ans = tmp
        tmp = 0
        flag = False
    elif flag:
        tmp = 0
        flag = False

if (ans < tmp):
    ans = tmp

print(ans)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <math.h>
#include <climits>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <map> 
#include <set>
#include <string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
const ll MD = 1000000007;

/* sample input

*/

int main()
{
	string str;
	cin >> str;

	ll len = str.length();
	for (ll i = 0; i < len-8; i++) {
		cout << str[i];
	}

	return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

N,X,M = map(int,readline().split())
nex = [0] * M
sums = [0] * M

for i in range(M):
  nex[i] = i * i % M
  sums[i] = i

ans = 0
while N:
  if N & 1:
    ans += sums[X]
    X = nex[X]
  sums = [sums[i] + sums[nex[i]] for i in range(M)]
  nex = [nex[nex[i]] for i in range(M)]
  N >>= 1
  
print(ans)

Measured memory_bytes: 27684
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <time.h>

#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <iostream>

using namespace std;

int run()
{
    int N = 0;
    scanf("%d", &N);
    vector<int> v(2 * N, 0);
    for(int i = 0; i < 2 * N; i ++) scanf("%d", &v[i]);
    sort(v.begin(), v.end());
    int ans = 0;
    for(int i = 0; i < 2 * N; i += 2) ans += v[i];
    printf("%d\n", ans);
    return 0;
}

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

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

int main(){
    int n;
    ll y;
    cin >> n >> y;
    int a,b,c;
    a=-1;
    b=-1;
    c=-1;
    int cnt=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n-i;j++){
            if((1000*i+5000*j+10000*(n-i-j))==y){
            a=n-i-j;
            b=j;
            c=i;
            }
        }
    }

    cout << a << " " << b << " " << c << endl;
    return 0;
}

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

int64_t BitCountRange(int64_t b, int64_t x) {
    if(x <= 0) return 0;
    int64_t retval = (x >> (b + 1)) << b;
    retval += ((x >> b) & 1) * (1 + x - ((x >> b) << b));
    return retval;
}

int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int64_t A, B, ans;
    cin >> A >> B;
    ans = 0;
    for(int b = 0; b < 60; b++) {
        ans |= ((BitCountRange(b, B) - BitCountRange(b, A - 1)) & 1) << b;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
	int A, B; cin >> A >> B;
	string ans;
	if (A*B % 2 == 0)
	{
		ans = "No";
	}else{
		ans = "Yes";
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// this is a varirty of good question of 0-1 knapsack as it provide higher constraints so because of that we will
// see a new version of 0-1 knapsack
typedef long long int ll;
#define vec vector<ll>
using namespace std;
int main()
{
	long long int n,w;
	cin>>n>>w;
	long long int   i,j;
	long long int  a[n],val[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>val[i];
	}
	int maxval=0;
	for(i=0;i<n;i++)
	{
		maxval+=val[i];
	}
	long long int dp[n+1][maxval+1];
	for(i=1;i<=maxval;i++)
	{
		dp[0][i]=1e18;
	}
	dp[0][0]=0;
//	for(i=0;i<=n;i++)
//	{
//		for(j=0;j<=maxval;j++)
//		{
//			cout<<dp[i][j]<<"  ";
//		}
//		cout<<"\n";
//	}
	long long int an=0;
	for(i=0;i<n;i++)
	{
		for(j=0;j<=maxval;j++)
		{
			if(val[i]<=j)
			{
				dp[i+1][j]=min(dp[i][j],a[i]+dp[i][j-val[i]]);
			}
			else{
				dp[i+1][j]=dp[i][j];
			}
			if(dp[i+1][j]<=w)
			{
				an=max(an,j);
			}
		}
	}
	cout<<an;
//	for(i=0;i<=n;i++)
//	{
//		for(j=0;j<=maxval;j++)
//		{
//			cout<<dp[i][j]<<"  ";
//		}
//		cout<<"\n";
//	}
////	for(j=0;j<=maxval;j++)
////	{
////		if(dp[n][i]==w)	
////		{
////			cout<<j;
////			break;
////		}
////	}
//	cout<<dp[n][w];
//}
/*
3 5
1 1
2 3
3 4
*/
}


Measured memory_bytes: 82480
main(){
  int i,n;
  scanf("%d",&n);
  double a[n],b[n],c[n],d[n],e[n],f[n];
  for(i=0;i<n;i++)
    scanf("%lf%lf%lf%lf%lf%lf",&a[i],&b[i],&c[i],&d[i],&e[i],&f[i]);
  for(i=0;i<n;i++)
    if((a[i]-d[i])*(a[i]-d[i])+(b[i]-e[i])*(b[i]-e[i])>(c[i]+f[i])*(c[i]+f[i]))
      puts("0");
    else{
      if(sqrt((a[i]-d[i])*(a[i]-d[i])+(b[i]-e[i])*(b[i]-e[i]))+c[i]<f[i]){
	puts("-2");
	continue;
      }
      if(sqrt((a[i]-d[i])*(a[i]-d[i])+(b[i]-e[i])*(b[i]-e[i]))+f[i]<c[i]){
	puts("2");
	continue;
      }
      puts("1");
    }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <queue>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

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

using namespace std;

bool is_integer( float x ){
    return floor(x)==x;
}

bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}

//yakusuu rekkyo
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // push its partner
            if (N/i != i) res.push_back(N/i);
        }
    }

    sort(res.begin(), res.end());
    return res;
}


vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // exponential

        // divide as much as you can
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // push the result
        res.push_back({a, ex});
    }

    // last num (if the lasting n is prime number and not 1)
    if (N != 1) res.push_back({N, 1});
    return res;
}



int main() {
    int d,n; cin >> d >> n;
    if(d == 0 && n == 100) cout << 101;
    else if(d == 0) cout << n;
    else if(d == 1 && n == 100) cout << 10100;
    else if(d == 1) cout << 100*n;
    else if(d == 2 && n == 100) cout << 1010000;
    else cout << 100*100*n;


    return 0;
}











Measured memory_bytes: 3596
list = []
dict = {}

while True:
	team,point = map(int,raw_input().split(","))
	if team == 0 and point == 0:
		break
	
	dict[team] = point
	if not point in list:
		list.append(point)
	
list.sort()
list.reverse()

while True:
	try:
		team = int(raw_input())
	except EOFError:
		break
	
	print list.index(dict[team]) + 1

Measured memory_bytes: 6340