akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define EB emplace_back
#define MP make_pair
#define all(o) (o).begin(), (o).end()
#define mset(m,v) memset(m,v,sizeof(m))
#define fr(i,n) for(lli i=0;i<n;++i)
#define rep(i,a,b) for(lli i=a;i<=b;++i)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#define endl '\n'
typedef long long int lli;
typedef long double ld;
typedef pair< lli,lli > ii;
typedef vector<lli> vi;
typedef vector<ii> vii;
typedef vector<vi> graph;
lli MOD=1000000007;long double EPS=1e-9;


void pre(){

}

void solve(){
	lli arr[3];
	fr(i,3)cin>>arr[i];
	lli mincost=MOD*MOD;
	do{
		lli temp=abs(arr[1]-arr[2])+abs(arr[1]-arr[0]);
		remin(mincost,temp);
	}while(next_permutation(arr,arr+3));
	cout<<mincost<<endl;

}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	pre();
	int t=1;
	//cin>>t;
	for(int i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);


void solve(int testCase){

    int n , m;
    scanf("%d %d" , &n , &m);

    vector < vi > adj(n+1);
    vi in (n+1 , 0);
    vi dis(n+1 , 0);

    for(int i = 0 ; i < m ; i ++){
            int u , v; scanf("%d %d" , &u , &v);

            adj[u].push_back(v);
            in[v] ++;
    }

    queue < int > q;
    for(int i = 1 ; i <= n ; i ++){
            if(in[i] == 0)q.push(i);
    }

    int ans = 0;
    while( !q.empty() ){
            int u = q.front();
            q.pop();

            ans = max(ans , dis[u]);

            for(int v : adj[u]){
                    dis[v] = max(dis[v] , dis[u] + 1);
                    in[v] --;
                    if(in[v] == 0)q.push(v);
            }
    }

    printf("%d\n" , ans);

}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


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

int dp[20][331][2000];

int n,s;
int main(){
    dp[0][0][0]=1;
    for(int i=0;i<10;i++){
        for(int j=0;j<331;j++){
            for(int k=0;k<(1<<10);k++){
                if(dp[i][j][k]==0) continue;
                for(int l=0;l<10;l++){
                    if(!((k>>l)&1) && j+l*(i+1)<=330){
                        dp[i+1][j+l*(i+1)][k|(1<<l)]+=dp[i][j][k];
                    }
                }
            }
        }
    }
    while(cin>>n>>s){
        int ans=0;
        if(s>330){
            printf("0\n");
            continue;
        }
        for(int i=0;i<(1<<10);i++){
            ans+=dp[n][s][i];
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 27772
#include <iostream>
using namespace std;
//
// Created by karayuu on 2018-12-19.
//
int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a < b && b < c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3104
def resolve():
    n,k,q=map(int,input().split())
    a=[int(input()) for _ in range(q)]
    pnt=[k-q]*n
    for i in a:
        pnt[i-1]+=1
    for i in range(n):
        print('Yes' if pnt[i]>0 else 'No')
resolve()

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

int gcd(int n,int m){
  if(n%m==0) return m;
  else gcd(m,n%m);
}

int main()
{
  int x,y,g;
  cin >> x >> y;
  
  if(x==y) g=x;
  else if(x>y) g=gcd(x,y);
  else g=gcd(y,x);
  cout << g << endl;

  return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>

int main(void)
{
    int r, D, answer;

    scanf("%d %d %d", &r, &D, &answer);

    for (int i = 0; i < 10; i++)
    {
        answer = r * answer - D;
        printf("%d\n", answer);
    }
    
    return 0;
}

Measured memory_bytes: 128
#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 dp[110][110][2];
int main()
{ 
    string s;
    cin >>s;
    int n = s.size();
    int K;
    cin >> K;
    dp[0][0][0] = 1;
    rep(i,n)rep(j,K+1)rep(k,2){
        int x = s[i]- '0';//いまのけた
        
        rep(d,10){
            int ni = i+1,nj = j,nk = k;
            if(!k && d > x )continue;
            if(d < x)nk = 1;
            if(d != 0)nj++;
            dp[ni][nj][nk] +=dp[i][j][k];
        
        }
    }
    cout << dp[n][K][0]+dp[n][K][1] << endl;


    return 0;
}   

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

int main()
{
	int w=0,n,m,F=0,t;
	cin>>n>>m;
	int x=m;
	while (x!=0){
		x/=10;
		w++;
	}
	for (int i=1;i<=w;i++) n*=10;
	t=m+n;
	for (int i=1;i<=350;i++)
		if (i*i==t){
			F=1;
			break;
		}
	if (F==1) cout<<"Yes";
	else	  cout<<"No";
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  string A[n];
  for(int i=0;i<n;i++) cin>>A[i];
  string C[n];
  for(int i=0;i<n;i++) C[i]=A[i];
  int ans=0;
  for(int i=0;i<n;i++){
    for(int j=n-1;j>i;j--){
      if(C[j][1]<C[j-1][1]){
	swap(C[j],C[j-1]);
      }
    }
  }
  string x[10],y[10];
  for(int i=0;i<n;i++){
    x[A[i][1]-'0']+=A[i][0];
    y[C[i][1]-'0']+=C[i][0];
  }
  ans=1;
  for(int i=0;i<10;i++) ans&=x[i]==y[i]; 
  for(int i=0;i<n;i++) cout<<C[i]<<" \n"[i==n-1];
  cout<<(ans?"Stable":"Not stable")<<endl;
  
  for(int i=0;i<n;i++) C[i]=A[i];
  for(int i=0;i<n;i++){
    int minj=i;
    for(int j=i;j<n;j++){
      if(C[j][1]<C[minj][1]){
	minj=j;
      }
    }
    if(i!=minj) swap(C[i],C[minj]);
  }
  
  for(int i=0;i<10;i++) x[i]=y[i]="";
  for(int i=0;i<n;i++){
    x[A[i][1]-'0']+=A[i][0];
    y[C[i][1]-'0']+=C[i][0];
  }
  ans=1;
  for(int i=0;i<10;i++) ans&=x[i]==y[i]; 
  for(int i=0;i<n;i++) cout<<C[i]<<" \n"[i==n-1];
  cout<<(ans?"Stable":"Not stable")<<endl;
  
  return 0;
}



Measured memory_bytes: 3204
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

typedef long long ll;
typedef pair<ll, ll> P;

vector<ll> vA, vB, vC;
vector<ll> l;
ll N, A, B, C;
ll ans = LLINF;

void dfs(int d)
{
  if (d == N) {
    if (vA.empty() || vB.empty() || vC.empty()) return;
    //cerr << "A: "; SHOWVEC(vA, vA.size());
    //cerr << "B: "; SHOWVEC(vB, vB.size());
    //cerr << "C: "; SHOWVEC(vC, vC.size());
    //cerr << endl;
    ll cost = 0;
    cost += abs(accumulate(ALL(vA), 0) - A) + 10*(vA.size() - 1);
    cost += abs(accumulate(ALL(vB), 0) - B) + 10*(vB.size() - 1);
    cost += abs(accumulate(ALL(vC), 0) - C) + 10*(vC.size() - 1);
    ans = min(ans, cost);
    return ;
  }
  dfs(d + 1);
  vA.push_back(l[d]); dfs(d + 1); vA.pop_back();
  vB.push_back(l[d]); dfs(d + 1); vB.pop_back();
  vC.push_back(l[d]); dfs(d + 1); vC.pop_back();
}

int main()
{
  cin >> N >> A >> B >> C;
  l = vector<ll>(N);
  REP(i, N) cin >> l[i];
  dfs(0);
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll, ll>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define sps << ' '
#define sp << ' ' << 
# define M_PI   3.14159265358979323846
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353
ll u, r, l, d;

bool check(ll x, ll y){
  if(x >= l and x <= r and y >= u and y <= d) return false;
  else return true;
}

int main()
{
  boost;
  ll tt = 1, n, m, i, a;

  // cin >> tt;

  for(int _ = 1; _ <= tt; _++){
    // cout << "Case #" << _ << ": ";
    cin >> n;
    vi v(200001, 0);

    for(i = 1; i < n; i++){
      cin >> a;
      v[a]++;
    }

    for(i = 1; i <= n; i++){
      cout << v[i] << nl;
    }
  }

  return 0;
}

Measured memory_bytes: 4780
a,b,c = map(int, input().split())
k = int(input())
m = max(a,b,c)
for _ in range(k):
  m*=2
if max(a,b,c)==a: print(m+b+c)
elif max(a,b,c)==b: print(a+m+c)
else: print(a+b+m)

Measured memory_bytes: 9124
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    long h[n];
    int best[n] = {0};
    int i;
    int count=n;
    for(i=0;i<n;i++){
        cin >> h[i];
    }
    int a[m], b[m];
    for(i=0;i<m;i++){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        if(h[a[i]] >= h[b[i]]){
            if(best[b[i]]==0){
                best[b[i]] = 1;
                count --;
            }
        }
        if(h[a[i]] <= h[b[i]]){
            if(best[a[i]]==0){
                best[a[i]] = 1;
                count --;
            }
        }
    }cout << count << endl;
    return 0;
}

Measured memory_bytes: 5584
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  int ret = N;
  rep(i,D){
    ret *= 100;
  }
  if(N == 100){
    if(D == 0) ret += 1;
    if(D == 1) ret += 100;
    if(D == 2) ret += 10000;
  }
  cout << ret << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b,d=0,r=0;
	double f=0.0;
	
	scanf("%d %d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/b;
	
	printf("%d %d %f\n",d,r,f);
	
	return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a=1,i=1,b[100000];
  while(a){
    cin>>a;
    if(a==0){
      break;
    }
    cout<<"Case "<<i<<": "<<a<<'\n';
    i++;
  }
  return(0);
}



Measured memory_bytes: 3008
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll A,B;
	while(cin>>A>>B) {
		ll d = B-A;
		ll bh = 0;
		RANGE(i, 1, d+1) bh+=i;
		
		cout<<bh-B<<endl;
	}
	
	return 0;
}


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

int main() {
    int N; cin >> N;
    int hat[3] = {};
    ll ans = 1, mod = 1000000007;

    REP(i, 0, N) {
        int a; cin >> a;
        int cnt = 0;
        REP(j, 0, 3) {
            if (hat[j] == a) cnt++;
        }
        REP(j, 0, 3) {
            if (hat[j] == a) {
                hat[j]++;
                break;
            }
        }
        ans = (ans * cnt) % mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define array_input int n;cin>>n;int a[n+1],i;for(i=1;i<=n;i++){cin>>a[i];}
#define array_output for(i=1;i<=n;i++){cout<<a[i]<<" ";}cout<<endl;
#define quicker ios::sync_with_stdio(false);
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
const double pi=acos(-1);
const double eps=1e-6;
#define INF 2147483647
#define long_INF 18446744073709551615
#define hehe 23333333

void read(int &x)
{
    x=0;
	char c=getchar();
    while(c<'0' || c>'9')c=getchar();
    while(c>='0' && c<='9')
	{
        x=x*10+c-'0';
        c=getchar();
    }
}

void write(int x)
{
    if(x==0)
	{
		putchar(48);
		return;
	}
    int len=0,dg[20];
    while(x>0)
	{
		dg[++len]=x%10;
		x/=10;
	}
    for(int i=len;i>=1;i--)
	{
		putchar(dg[i]+48);
	}
}

int max(int x,int y)
{
	if (x>y)
	{
		return x;
	}
	else
	{
		return y;
	}
}

int min(int x,int y)
{
	if (x<y)
	{
		return x;
	}
	else
	{
		return y;
	}
}

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	int d;
	cin>>d;
	if (fabs(a-b)<=d && fabs(b-c)<=d || fabs(a-c)<=d)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
}

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

int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  int x = 0;
  for(int i = 0; i < N; i++){
    if(!(a.at(i) == i + 1))x++;
  }
  if(x == 2 || x == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 3624
// https://atcoder.jp/contests/abc132/tasks/abc132_e

#include "algorithm"
#include "iostream"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
using PL = pair<ll, ll>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

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

  VVL edges(N, VL());
  const ll STEP = 3;

  rep(i, M) {
    ll u, v;
    cin >> u >> v;
    u--, v--;
    edges[u].push_back(v);
  }

  ll S, T;
  cin >> S >> T;
  S--, T--;

  ll INF = 1e18;

  VVL dist(N, VL(STEP, INF));
  dist[S][0] = 0;

  queue<PL> q;
  q.push({S, 0});

  while (!q.empty()) {
    PL cur = q.front();
    q.pop();

    ll cp = cur.first;
    ll parity = cur.second;

    ll n_parity = (parity + 1) % STEP;

    for (auto np : edges[cp]) {
      if (dist[np][n_parity] != INF) continue;
      dist[np][n_parity] = dist[cp][parity] + 1;
      q.push({np, n_parity});
    }
  }

  ll res = dist[T][0] == INF ? -1 : dist[T][0] / STEP;
  cout << res << endl;
}

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

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

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

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

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


Measured memory_bytes: 11264
#include<bits/stdc++.h>
#define rep(i,a) for(int i=0;i<a;i++)
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
    int n;
    string s1,s2,s3;
    cin>>n>>s1>>s2;
    rep(i,n){
        s3+=s1[i];
        s3+=s2[i];
    }
    cout<<s3<<endl;
    return 0;
}

Measured memory_bytes: 256
/*input
3141592653589793


*/
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

long long int arr[112345],dp[112345]={0};
long long int pow(long long int a, long long int b, long long int mod){
	if(b==1)return a;
	if(b==0)return 1;
	long long int ret = pow(a, b/2 ,mod);
	ret = ret * ret;
	ret %= mod;
	if(b&1){
		ret=ret*a;
		ret %= mod; 
	}
	return ret;
}

int main() {
	string s,p;
	int ans =0;
	cin>>s;
	p = s;
	for(int i=p.length()-1;i>=1;i--){
		p[i]='9';
		ans += 9;

	}
	if(s==p){
		cout<<ans+s[0]-'0'<<endl;
	} else{
		cout<<ans+s[0]-'0'-1<<endl;
	}


}

Measured memory_bytes: 764
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <math.h>
#include <utility>

using namespace std;

#define INF 210000000
#define int long long

int gcd(int a, int b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

int lcm(int a, int b) { return a * b / gcd(a, b); }

struct Rest{
    string name;
    int point;
    int num;
};
bool cmp(Rest &A, Rest &B) {
    if (A.name != B.name) return A.name < B.name;
    return A.point > B.point;
}
signed main() {
    int n;
    cin >> n;
    vector<Rest> s;
    for(int i=0;i<n;i++){
        string ss;
        int tmp;
        cin >> ss >> tmp;
        Rest r;
        r.name = ss;
        r.point = tmp;
        r.num = i + 1;
        s.push_back(r);
    }
    sort(s.begin(),s.end(),cmp);
    for(int i=0;i<n;i++){
        cout << s[i].num << endl;
    }
}



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

int main(){
  int A, B;
  string op;
  
  cin >> A >> op >> B;
  
  if (op == "+"){
    cout << A + B << endl;
  }else {
    cout << A - B << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<functional>
#include<algorithm>
using namespace std;
int main(void)
{
	int nn,mm,h,m,x,buf[200];
	int i,j;
	scanf("%d",&nn);
	for(i=0;i<nn;i++)	{
		scanf("%d %d",&h,&m);
		x=h*60+m;
		buf[i]=x;
	}
	scanf("%d",&mm);
	for(i=nn;i<nn+mm;i++)	{
		scanf("%d %d",&h,&m);
		x=h*60+m;
		buf[i]=x;
	}
	sort(buf,buf+nn+mm);
	h=buf[0]/60;
	m=buf[0]%60;
	printf("%d:%02d",h,m);
	for(i=1;i<nn+mm;i++)	{
		if(buf[i]!=buf[i-1])	{
			h=buf[i]/60;
			m=buf[i]%60;	
			printf(" %d:%02d",h,m);
		}
	}
	printf("\n");
	return 0;
}


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

struct UnionFind{
  int num;//連結成分の数
  vector<int> r,p;//そのグループのサイズ,自分の親っぽいやつ
  UnionFind(){}
  UnionFind(int n):num(n),r(n,1),p(n,0){iota(p.begin(),p.end(),0);}

  int find(int x){//どのグループに所属するか
    return (x==p[x]?x:p[x]=find(p[x]));//xがグループの名前と一致するまでxを親にする
  }

  bool same(int x,int y){//同じグループかどうか
    return find(x)==find(y);
  }

  void unite(int x,int y){//xとyを同じグループにする
    x=find(x);y=find(y);//xとyのグループの名前をどっちかが変える
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);//サイズが大きい方をxとする
    r[x]+=r[y];//yの親をxにする（今までyだったグループ名がxになる）
    p[y]=x;
    num--;
  }

  int size(int x){//グループの大きさ
    return r[find(x)];
  }

  int count() const{//グループの数
    return num;
  }
};

signed main(){
  int n,m,k;cin>>n>>m>>k;
  UnionFind uf(n);
  vector<int> c(n,0);
  vector<int> a(m),b(m);
  for(int i=0;i<m;i++){
    cin>>a[i]>>b[i];a[i]--;b[i]--;
    uf.unite(a[i],b[i]);
    c[a[i]]++;c[b[i]]++;
  }

  while(k--){
    int u,v;cin>>u>>v;
    u--;v--;
    if(uf.same(u,v)){
      c[u]++;c[v]++;
    }
  }
  for(int i=0;i<n;i++){
    cout<<uf.size(i)-c[i]-1<<endl;
  }
}


Measured memory_bytes: 2816
s = input()

x = int(s[:2])
y = int(s[2:])

if (x > 12 or x == 0) and (y > 12 or y == 0):
    print('NA')
elif (x > 12 or x == 0) and y <= 12:
    print('YYMM')
elif x <= 12 and (y > 12 or y == 0):
    print('MMYY')
else:
    print('AMBIGUOUS')

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <utility>
#include <string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main(){
  vector<int> v;
  for(int i=0;i<5;i++){
	int a;  cin>>a;
    v.push_back(a);
  }
  int k;  cin>>k;
  string ans = "Yay!";
  for(int i=0;i<5;i++){
    for(auto b:v){
      if(abs(b-v[i])>k){ ans = ":("; break; }
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
long long arr[N],mn[N][N];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
  	int n;
  	long long x;
  	cin >> n >> x;
  	for(int i = 0;i < n;++i)cin >> arr[i];
  	for(int i = 0;i < n;i++){
  	    mn[i][0] = arr[i];
  	    for(int j = 1;j <= n;j++){
  	        mn[i][j] = min(mn[i][j - 1], arr[(i + j) % n]);
  	    }
  	}
  	long long ans = (long long)1e18;
  	for(int i = 0;i <= n;i++){
  	    long long cnt = i * x;
  	    for(int j = 0;j < n;j++){
  	        cnt += mn[j][i];
  	    }
  	    ans = min(ans, cnt);
  	}
  	cout << ans;
  	return 0;
} 

Measured memory_bytes: 35076
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
long long N;

int main(){
  int N, cnta=0, cntb=0;
  cin >> N;
  int a[N];
  bool can = false;
  rep(i, N){
    cin >> a[i];
    if(a[i]%4 == 0) cnta++;
    else if(a[i]%2 == 0) cntb ++;
  }
  int M = N;
  if(cntb == 0){
    if(M/2 <= cnta) can = true;
  }
   else{ 
     M -= cntb;
     if((M+1)/2 <= cnta) can = true;
   }
  if(can) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  }

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


typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;

#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp make_pair
#define mt make_tuple
#define fi
#define se second

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

#define forl(i, n) for(int i = 1; i< n; i++)
#define deci(n)  fixed<<setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n)  __builtin_ctz(n)
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)

using namespace std;

// void cpc()
// {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w" , stdout);
// #endif
// }

int main()
{
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w" , stdout);
// #endif
	lli n, k;

	cin >> n >> k;
	lli dp[n] = {500000};
	// cout << n;
	std::vector<int> v(n);

	forz(i, n)
	{
		cin >> v[i];
		dp[i] = 1e9 + 4;
		// cout << v[i] << " ";
	}
	// cout << dp[n - 1] << endl;
	dp[0] = 0;
	// dp[1] = abs(v[1] - v[0]);
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j <= i + k; j++)
		{
			if (j < n )
			{

				dp[j] = min(dp[j], dp[i] + abs(v[j] - v[i]));
			}
		}

	}
	cout << dp[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 1408
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
    string[] input = Console.ReadLine().Split(' ');//Splitで区切り文字を指定して複数個受け取る。
    long n = long.Parse(input[0]);
    int k = int.Parse(input[1]);
    long mod = 1000000007;
    long[] compressions = DivisionCompression(n);
    n = compressions.Length;
    long[,] dp = new long[k+2,n];//置いた個数と右端の数番号
    long[,] sums = new long[k+2,n+1];

    for(int i = 0; i < n; i++)
    {
      dp[1,i] = 1;
      sums[1,i+1] = sums[1,i] + compressions[i]*dp[1,i];
      sums[1,i+1] %= mod;
    }

    for(int i = 2; i <= k+1; i++)
    {
      for(int j = 0; j < n; j++)
      {
        dp[i,j] = sums[i-1,n-j];
        dp[i,j] %= mod;
        sums[i,j+1] = sums[i,j];
        sums[i,j+1] %= mod;
        sums[i,j+1] += compressions[j]*dp[i,j];
        sums[i,j+1] %= mod;
      }
    }


    Console.WriteLine(dp[k+1,0]);
	}

  static long[] DivisionCompression(long num)
  {//x=1~numまでを[n/x]の値で座標圧縮。配列の個数を2√numまで圧縮できる。
  //返り値の配列は圧縮前の個数。
  //例えばnum=10なら、[1,1,1,2,5]を返す。
    int dividesCount = (int)Math.Sqrt(num);
    long[] divides = new long[dividesCount+1];//前半の(x/i)の値
    long[] answers;
    for(int i = 0; i < dividesCount; i++)
    {
      divides[i] = num/(i+1);
    }

    if(divides[dividesCount-1] == dividesCount)
    {
      answers = new long[2*dividesCount-1];
      for(int i = 0; i < dividesCount; i++) answers[i] = 1;

      for(int i = 0; i < dividesCount-1; i++)
      {
        answers[dividesCount+i] = divides[dividesCount-2-i]-divides[dividesCount-1-i];
      }
    }else
    {
      answers = new long[2*dividesCount];
      for(int i = 0; i < dividesCount; i++) answers[i] = 1;

      divides[dividesCount] = dividesCount;
      for(int i = 0; i < dividesCount; i++)
      {
        answers[dividesCount+i] = divides[dividesCount-1-i]-divides[dividesCount-i];
      }
    }
    
    return answers;
  }
  
}

Measured memory_bytes: 111576
#include<cstdio>
#include<cmath>

#define MAX_STUDENTS 1000

int main(){

    while(1){

        unsigned int n, i, score, scores_data[MAX_STUDENTS] = {0}, sum = 0;
        double alpha = 0, average;

        scanf("%d", &n);

        if(n == 0) break;

        for( i = 0; i < n; i++ ){
            scanf("%d", &score);
            sum += score;
            scores_data[i] = score;
        }

        average = (double)sum / n;

        for( i = 0; i < n; i++ ){
            alpha += pow(scores_data[i] - average, 2);
        }

        alpha /= n;
        
        printf("%.8lf\n", sqrt(alpha));

    }

    return 0;

}


Measured memory_bytes: 2756
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------
    int n;
    cin >> n;
    int a[n];
    int i;
    rep(i,n){
        cin >> a[i];
    }
    sort(a,a+n);

    pri(a[n-1]-a[0]);

    return 0;
}



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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

const int N = 10001;

using P = pair<int, int>;

int n;

struct edge {
    int to;
    int cost;
};

vector<int> dist(N, Inf);
vector<edge> g[N];

void dijkstra(int s) {
    dist[s] = 0;
    priority_queue<P, vector<P>, greater<P> > pq;
    pq.push(P(0, s));

    while (!pq.empty()) {
        P p = pq.top();
        pq.pop();
        int v = p.second;
        if (dist[v] < p.first) continue;

        rep (i, g[v].size()) {
            edge e = g[v][i];
            if (dist[e.to] > dist[v] + e.cost) {
                dist[e.to] = dist[v] + e.cost;
                pq.push(P(dist[e.to], e.to));
            }
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    cin >> n;
    rep (i, n) {
        int u, k;
        cin >> u >> k;
        rep (j, k) {
            int v, c;
            cin >> v >> c;
            edge e = {v, c};
            g[u].push_back(e);
        }
    }
    dijkstra(0);
    rep (i, n) {
        cout << i << " " << dist[i] << endl;
    }
    
    return 0;
}




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


int main()
{
int n,m,i,j,k,cont=0;
int a,b;
int h[100010],x[100010];

for(i=0;i<100010;i++)
{
    x[i] = 0;
}

scanf("%d %d",&n,&m);

for(i=1;i<=n;i++)
{
    scanf("%d",&h[i]);
}

for(i=0;i<m;i++)
{
    a = 0;
    b = 0;
    scanf("%d %d",&a,&b);
    if(h[a]<h[b])
        x[a] = 1;
    else if(h[a]>h[b])
        x[b] = 1;
    else
        x[a] = x[b] = 1;
    
}

for(i=1;i<=n;i++)
{
    if(x[i]==0)
        cont++;
}

printf("%d",cont);
return 0;
}

Measured memory_bytes: 2512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    vector<long long>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a.begin(),a.end());
    if(a[0]==0){cout<<"0\n";}
    else{
        long long prod = 1;
        for(int i=0;i<n;i++)
        {
            if(a[i]<=1000000000000000000/prod)
                prod*=a[i];
            else
            {
                cout<<"-1\n";
                return 0;
            }
            
        }
        cout<<prod<<endl;
    }
    return 0;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N;
    cin >> N;
    vector<vector<Pll>> P(N);
    ll a;
    ll x,y;
    rep(i,N){
        cin >> a;
        rep(j,a){
            cin >> x >> y;
            x--;
            P[i].push_back(Pll(x,y));
        }
    }
    ll ans = 0;
    rep(i,1LL << N){
        vector<ll> v;
        ll cnt = 0;
        bool flag = false;
        rep(j,N){
            if((i>>j) & 1LL){
                v.push_back(j);
                cnt++;
            }
        }
        for(auto& e:v){
            for(auto& p:P[e]){
                ll n = p.first;
                ll m = p.second;
                if(m==1 && ((i>>n)&1LL)==0 ){
                    flag = true;
                    break;
                }else if(m==0 && ((i>>n)&1LL)==1 ){
                    flag = true;
                    break;
                }
            }
            if(flag) break;
        }
        if(!flag){
            cmax(ans,cnt);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
n,m=map(int,input().split())
l=[0 for i in range(n)]
l[0]=1
lc=[1 for i in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  if l[a-1]==1 and lc[a-1]==1:
    lc[a-1]=0
    l[a-1]=0
    l[b-1]=1
    lc[b-1]+=1
  elif l[a-1]==1:
    lc[a-1]-=1
    l[b-1]=1
    lc[b-1]+=1
  else:
    lc[a-1]-=1
    lc[b-1]+=1
ans=0
for i in range(n):
  if l[i]==1 and lc[i]>0:
    ans+=1
print(ans)

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

const int MN = 2e5+5;
int cnt, rem;
string s;

int main(){
    cin >> s; rem = s.size();
    for(char c : s){
        if(c=='S') cnt++;
        else if(cnt) cnt--, rem-=2;
    }
    printf("%d\n",rem);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstring>
#include <map>
#include <set>
using namespace std;

int dp[100001];
map<int, set<int>> G;
  
int dag(int v){
  if(dp[v]!=-1){ return dp[v]; }
  
  int res = 0;
  for(auto it : G[v]){
    int tmp = dag(it) +1;
    res = max(tmp,res);
  }
  
  dp[v] = res;
  return res;
}


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

  for(int i=0;i<M;i++){
    int x,y;
    cin >> x >> y;
    x--;y--;
    G[x].insert(y);
  }
  
  for(int i=0;i<N;i++){dp[i]=-1;}
  
  int path_max = 0;
  for(int i=0;i<N;i++){
    int path_len = dag(i);
    path_max = max(path_len,path_max);
  }

	cout << path_max << endl;
	return 0;
}

Measured memory_bytes: 18176
import sys
input = sys.stdin.readline

def main():
    n=int(input())
    cnt=5
    ans=0
    if n%2==0:
        n=n//2
        while cnt<=n:
            ans+=n//cnt
            cnt*=5
    print(ans)                
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
package main

import (
	"fmt"
)

func main() {
	var N, K, Q int
	fmt.Scan(&N, &K, &Q)
	As := scanNums(Q)
	Points := make([]int, N, N)
	for i := 0; i < N; i++ {
		Points[i] = K
	}

	result := make([]int, N, N)
	for _, v := range As {
		result[v-1]++
	}
	// fmt.Println(result)
	for _, v := range result {
		// fmt.Println(K - Q + v)
		if K-Q+v > 0 {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	}

	// for _, v := range As {
	// 	for i, x := range Points {
	// 		if v-1 == i {
	// 			continue
	// 		}
	// 		Points[i] = x - 1
	// 	}
	// 	// fmt.Println(Points)
	// }
	// // fmt.Println(Points)
	// for _, v := range Points {
	// 	if v <= 0 {
	// 		fmt.Println("No")
	// 	} else {
	// 		fmt.Println("Yes")
	// 	}
	// }
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}


Measured memory_bytes: 6912
N, M, C = map(int, input().split())
Bs = list(map(int, input().split()))
ans = 0
for n in range(N):
  As = list(map(int, input().split()))
  score = C
  for a, b in zip(As, Bs):
    score += a * b
  ans += score > 0
print(ans)

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    string S;
    cin >> S;
    int N = S.size() / 2;
    int ans = 0;
    rep(i, N) {
        if (S[i] != S[S.size() - 1 - i]) {
            ans++;
        }
    }
    cout << ans << '\n';
}

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


Measured memory_bytes: 384
#include <algorithm>
#include <functional>
#include <iostream>
#include <set>
#include<iomanip>
using namespace std;

int main() {
	double T,X;
	cin>>T>>X;
	double ans = T/X;
	cout<<fixed;
	cout<<setprecision(6)<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}
void maxHeapify(int *H,int i,int n){
  int alt,max,l,r;
  l=left(i);
  if(l>n)l=-1;
  r=right(i);
  if(r>n)r=-1;
  if(l!=-1&&l<=n&&H[l]>H[i])max=l;
  else max=i;
  if(r!=-1&&r<=n&&H[r]>H[max])max=r;
  if(max!=i){
    alt=H[i];
    H[i]=H[max];
    H[max]=alt;
    maxHeapify(H,max,n);
  }
}
int main(){
  int i,n;
  int *ar,*H;

  scanf("%d",&n);
  ar=(int *)malloc(sizeof(int)*(n+1));
  H=ar;
  for(i=1;i<=n;i++)scanf("%d",&H[i]);
  for(i=n/2;i>0;i--)maxHeapify(H,i,n);
  
  for(i=1;i<=n;i++)printf(" %d",H[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 2552
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, c float64
	fmt.Scan(&a, &b, &c)
	c *= math.Pi / 180
	h := b * math.Sin(c)
	fmt.Println(a * h / 2.0)
	fmt.Println(a + b + math.Sqrt(h*h+(a-b*math.Cos(c))*(a-b*math.Cos(c))))
	fmt.Println(h)
}



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

int64_t INF = 1LL << 60;

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i = 0; i < n; i++)
    cin >> h[i];
  
  vector<int64_t> dp(100010);
  for(int i = 0; i < dp.size(); i++)
    dp[i] = INF;
    
  dp[0] = 0; dp[1] = abs(h[1] - h[0]);
  
  for(int i = 2; i < n; i++)
    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: 1408
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define rad M_PI/3
#define N 2147483647
#define Max 100000
#define NTL -1
#define min(a,b) ((a>b)?b:a)
  int a[Max];
void getSum(int s,int t){
    int mm=0;
    for(int k=s;k<=t;k++){
        mm+=a[k];
    }
    printf("%d\n",mm);
}
int main(){
  int n,i,j,q;
  int ord,x,y;

  scanf("%d%d",&n,&q);
  for(i=0;i<n;i++){
    a[i]=0;
  }
  while(q--){
    scanf("%d%d%d",&ord,&x,&y);
    if(ord==0){
      a[x]+=y;
    }else{
      getSum(x,y);
    }
  }
  return 0;
}


Measured memory_bytes: 2096
def General_Binary_Search(L,R,cond,Mode=True,Integer=True,ep=1/(1<<20)):
    """一般的な二部探索を行う.
    L:解の下限
    R:解の上限
    cond:条件(1変数関数,広義単調減少 or 広義単調減少を満たす)
    Mode:True->広義単調増加,False->広義単調減少
    Integer:解を整数に制限するか?
    ep:Integer=Falseのとき,解の許容する誤差
    """

    if Integer:
        if Mode:
            L-=1
        else:
            R+=1

        while R-L>1:
            C=L+(R-L)//2
            if cond(C)^Mode:
                L=C
            else:
                R=C
        if Mode:
            return R
        else:
            return L
    else:
        C=L+(R-L)/2
        while (R-C)>ep:
            if cond(C)^Mode:
                L=C
            else:
                R=C
            C=L+(R-L)/2
        return C
#======================================
N,K=map(int,input().split())
A=list(map(int,input().split()))

def f(x):
    r=0
    for a in A:
        r+=(a+x-1)//x
    return r-N<=K

print(General_Binary_Search(1,max(A),f,Mode=True))

Measured memory_bytes: 104136
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647

int main() {
  kyun;
  int a;
  cin >> a;
  int b = a / 500;
  a = a % 500;
  int c = a / 5;
  cout << 1000*b + 5*c;
  hinata;
}

Measured memory_bytes: 256
//aea ctmr


#include <iostream>

using namespace std;



int main(){

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	while(1){
		c -= b;
		if(c <= 0) {cout << "Yes" << endl; return 0;}

		a -= d;
		if(a <= 0) {cout << "No" << endl; return 0;}
	}
	return 0;

}

Measured memory_bytes: 3164
#include <stdio.h>

int main(void)
{
    int a[4], b[4], hitflag[4], hit, blow;
    int i, j, k;
    
    while(scanf("%d%d%d%d%d%d%d%d", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3]) != EOF){
        hit = 0;
        blow = 0;
        
        for(i = 0; i < 4; i++) hitflag[i] = 0;

        for(i = 0; i < 4; i++){
            //printf("i : %d, comparing %d and %d\n", i, a[i], b[i]);
            if(a[i] == b[i]){
                //printf("hit at %d\n", i);
                hit++;
                hitflag[i] = 1;
            }
        }
        for(i = 0; i < 4; i++){
            for(j = 0; j < 4; j++){
                if (hitflag[i] == 1 || hitflag[j] == 1){
                    continue;
                }else {
                    if (a[i] == b[j]){
                        //printf("blow at %d %d\n", i, j);
                        blow++;
                    }
                }
            }
        }
        printf("%d %d\n", hit, blow);
    }

    return (0);
}


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

using namespace std;

int main () {

	int N, K;
	cin >> N >> K;

	vector<int> h(N + 1);
	vector<int> c(N + 1);

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

	int pos = 3;

	c[1] = 0;
	c[2] = abs(h[2] - h[1]);

	while (pos <= N) {

		int mincost = c[pos -1] + abs(h[pos] - h[pos - 1]);

		for (int i = pos - 2; i >= 1 && i >= pos - K; i--) {
			int co = c[i] + abs(h[pos] - h[i]);
			if (co < mincost) {
				mincost = co;
			}
		}

		c[pos] = mincost;

		pos += 1;

	}

	cout << c[N] << "\n";
	
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

int main(){
  long long int a, b, c, d;
  long long int m;
  
  std::cin >> a >> b >> c >> d;
  
  m = a*c;
  if(m < a*d)m = a*d;
  if(m < b*c)m = b*c;
  if(m < b*d)m = b*d;
  
  std::cout << m;
  
  return 0;
}

Measured memory_bytes: 3632
// https://atcoder.jp/contests/abc125/tasks/abc125_b

#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <tuple>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, ans = 0;
    vector<int> v(n), c(n);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    for (int i = 0; i < n; i++) {
        int t = v[i] - c[i];
        if (t > 0) {
            ans += t;
        }
    }
    cout << ans << endl;

    return 0;
}

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

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

  string s, t;
  cin >> s >> t;
  
  int n = s.size();
  string res = "";
  for (int i = 0; i < n; i++) {
    res += s[i];
    if (i != n - 1) res += t[i];
    else if (t.size() == n) res += t[i];
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define mod 1000000007
typedef long long ll;
using namespace std;



int main(){
    ll A,B,Q;
    ll s[100100],t[100100];
    cin >> A >> B >> Q;
    for(int i=1;i<=A;i++) cin >> s[i];
    for(int i=1;i<=B;i++) cin >> t[i];
    s[0] = -100100100100100100;
    t[0] = -100100100100100100;
    s[A+1] = 100100100100100100;
    t[B+1] = 100100100100100100;
    for(int i=0;i<Q;i++){
        ll x;
        cin >> x;
        int itr_s = upper_bound(s,s+A+2,x) - s;
        int itr_t = upper_bound(t,t+B+2,x) - t;

        ll ans = 100100100100100100;
        ll shrine[2] = {s[itr_s-1], s[itr_s]};
        ll temple[2] = {t[itr_t-1], t[itr_t]};

        // shrine -> temple
        for(int i=0;i<2;i++){
            for(int j=0;j<2;j++){
                ll d = abs(x - shrine[i]) + abs(shrine[i] - temple[j]);
                ans = min(ans, d);
            }
        }

        // temple -> shrine
        for(int i=0;i<2;i++){
            for(int j=0;j<2;j++){
                ll d = abs(x - temple[i]) + abs(temple[i] - shrine[j]);
                ans = min(ans, d);
            }
        }
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
	int N, K;
	cin >> N >> K;
	int l[N];

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

	sort(l, l+N);

	int sum = 0;
	for(int i=0;i<K;i++){
		sum += l[N-1-i];
	}
	cout << sum <<endl;
    
	return 0;
}

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

int main(void){
	int n;
	while(1){
		cin >> n;
		if(!n)break;
		vector<char> c(n);
		for(int i = 0; i < n; ++i){
			cin >> c[i];
		}
		vector<int> v(30);
		bool end;
		for(int i = 0; i < n; ++i){
			v[c[i]-'A']++;
			int mx = 0;
			int mxj = 0;
			for(int j = 0; j < 30; ++j){
				mx = max(v[j], mx);
				if(mx==v[j]) mxj=j;
			}
			end = true;
			for(int j = 0; j < 30; ++j){
				if(mxj==j)continue;
				if(mx <= v[j]+n-(i+1)){
					end = false;
					break;
				}
			}
			if(end){
				cout << (char)(mxj+'A') << " " << i+1 << endl;
				break;
			}
		}
		if(!end)
			cout << "TIE" << endl;
	}
	return 0;
}


Measured memory_bytes: 3052
#include <stdio.h>

int main(void)
{
	int x,y,large,small;
	while(1){
		scanf("%d %d",&x,&y);
		if (x==0 && y==0)
			break;
		if(x>=y)
			large=x, small=y;
		else
			large=y, small=x;
		printf("%d %d\n",small,large);
	
	}
	
	return 0;
}

Measured memory_bytes: 600
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;

int main(){
  int n;
  string s;
  scanf("%d", &n);
  cin >> s;
  string t(n/2, 'a');
  if(n % 2 != 0) printf("No\n");
  else{
    REP(i, n/2){
      t.at(i) = s.at(i);
    }
    if (t + t == s){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }
}


Measured memory_bytes: 256