akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	vl a(3);
	rep(i, 3) cin >> a[i];
	int cnt = 0;
	while(cnt < 1e7) {
		rep(i, 3) if(a[i]&1) {
			cout << cnt << endl;
			return 0;
		}
		cnt++;
		vl b(3);
		rep(i, 3) {
			rep(j, 3) if(i != j) {
				b[i] += a[j] / 2;
			}
		}
		a = b;
	}
	cout << -1 << endl;
	return 0;
}

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

int main(){
  int n,d;
  cin>>n>>d;
  vector<vector<int>>a(n,vector<int>(d));
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      cin>>a[i][j];
    }
  }
  int kotae=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      int kyori=0;
      for(int k=0;k<d;k++){
        kyori+=(a[i][k]-a[j][k])*(a[i][k]-a[j][k]);
      }
      int kazu=sqrt(kyori);
      if(kazu*kazu==kyori)kotae++;
    }
  }
  cout<<kotae<<endl;
  return 0;
}




Measured memory_bytes: 3684
/* *********************************
Author        :Scau.ion
Created Time  :2016/09/04 20:36:43
File Name     :ion.cpp
********************************** */

#include <bits/stdc++.h>

#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<PII>
#define X first
#define Y second
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

using namespace std;

const int maxn=510;

char g[maxn];
bool ans1[maxn][maxn],ans2[maxn][maxn];

int main()
{
	int h,w;
    scanf("%d%d",&h,&w);
    for (int j=1;j<=h;++j)
    {
        scanf("%s",g+1);
        for (int k=1;k<=w;++k)
        {
            if (g[k]=='#')
            {
                ans1[j][k]=1;
                ans2[j][k]=1;
            }
        }
    }
    for (int j=1;j<=h;j+=4)
    {
        for (int k=2;k<=w;++k)
        {
            ans1[j][k]=1;
            ans1[j+3][k]=1;
        }
        ans1[j+1][w]=1;
        ans1[j+2][w]=1;
    }
    ans2[1][1]=1;
    for (int j=2;j<=h;j+=4)
    {
        for (int k=1;k<w;++k)
        {
            ans2[j][k]=1;
            ans2[j+1][k]=1;
        }
        ans2[j+2][1]=1;
        ans2[j+3][1]=1;
    }
    for (int j=1;j<=h;++j)
    {
        for (int k=1;k<=w;++k)
        {
            if (ans1[j][k]) printf("#");
            else printf(".");
        }
        printf("\n");
    }
    printf("\n");
    for (int j=1;j<=h;++j)
    {
        for (int k=1;k<=w;++k)
        {
            if (ans2[j][k]) printf("#");
            else printf(".");
        }
        printf("\n");
    }
	return 0;
}


Measured memory_bytes: 1280
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
// template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, n; cin >> n >> k;
    vector<int> a(n); rep (i, n) cin >> a[i];
    sort(all(a));
    ll ans = 0;
    rep (i, k) ans += a[i];
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

ll fc(vector<int> &ld, vector<int> &c, int d){
  ll ret = 0;
  rep(i, 26){
    ret += (ll)c.at(i)*(d - ld.at(i));
  }
  return ret;
}

ll ret(vector<int> &c, vector<vector<int>> &s, vector<int> &ld, int t, int day, bool f){
  ll ans = 0;
  int tmp = ld.at(t);
  ld.at(t) = day;
  ans += s.at(day).at(t);
  ans -= fc(ld, c, day);
  if(f == false)ld.at(t) = tmp;
  return ans;
}

int main(){
  int D;
  cin >> D;
  vector<int> ld(26, -1);
  vector<int> c(26);
  rep(i, 26) cin >> c.at(i);
  vector<vector<int>> s(D, vector<int>(26));
  rep(i, D){
    rep(j, 26){
      int in;
      cin >> in;
      s.at(i).at(j) = in;
    }
  }
  rep(i, D){
    ll mx = -9e18;
    int jj = 0;
    rep(j, 26){
      ll r = ret(c, s, ld, j, i, false);
      if(r > mx){
        mx = r;
        jj = j;
      }
    }
    cout << jj+1 << endl;
    ret(c, s, ld, jj, i, true);
  }
  return 0;
}

Measured memory_bytes: 3680
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


ll power(ll m, ll n)
{
	ll x = 1;
	if (n > 0)
	{
		x = power(m, n / 2);
		if (n % 2 == 0)
		{
			x = (x * x) % mod;
		}
		else
		{
			x = (((x * x) % mod) * m) % mod;
		}
	}

	return x;
}

ll com(ll n, ll k)
{
	ull x = 1;
	ull y = 1;
	for (ll i = k; i >= 1; i--)
	{
		x = (x * (n - i + 1)) % mod;
		y = (y * i) % mod;
	}

	return x / y;
}

// nCm を求める
class Com
{
	public:
	const int MAX = 510000;

	vector<ll> fac, finv, inv;

	void init()
	{
		fac.resize(MAX);
		fac[0] = fac[1] = 1;

		finv.resize(MAX);
		finv[0] = finv[1] = 1;

		inv.resize(MAX);
		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 get(int n, int k)
	{
		if (n < k || n < 0 || k < 0)
		{
			return 0;
		}
		return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
	}
};


int main()
{
	ll n, a, b;
	cin >> n >> a >> b;

	ull p = power(2, n);

	Com c;
	c.init();

	ll v1 = 1;
	for (ll i = n; i > n - a; i--) {
		v1 = (v1 * i) % mod;
	}
	ll v2 = 1;
	for (ll i = n; i > n - b; i--) {
		v2 = (v2 * i) % mod;
	}
	v1 = (v1 * c.finv[a]) % mod;
	v2 = (v2 * c.finv[b]) % mod;

	ll res = p - v1 - v2 - 1;
	res += 10 * mod;
	println(res % mod);
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
    vector<int> A(3);
    for(int i=0;i<3;i++) cin >> A.at(i);
    sort(A.begin(),A.end());
    cout << A.at(2)-A.at(0) << endl;    
}

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

// mod の処理を忘れさせてくれるライブラリ
// https://github.com/atcoder-live/library/blob/master/mint.cpp
const int mod = 1000000007;
struct mint {
  long long x;
  mint(long long x = 0):x((x % mod + mod) % mod) {}
  mint operator-() const {return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(long long t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};

// 繰り返し自乗法で 2 の n 乗を計算する
mint f (int n) {
  if (n == 0) {
    return 1;
  }
  mint x = f(n / 2);
  x *= x;
  if (n % 2 == 1) {
    x *= 2;
  }
  return x;
}

// a 回のループで計算する
mint choose (int n, int a) {
  mint x = 1;
  mint y = 1;
  for (int i = 0; i < a; i++) {
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

int main() {

  int n, a ,b;
  cin >> n >> a >> b;

  mint answer = f(n);

  // 0 本パターンを引く
  answer -= 1;

  // nCa を引く
  answer -= choose(n, a);

  // nCb を引く
  answer -= choose(n, b);

  cout << answer.x << endl;

  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

bool solve(ll A, ll B, ll C) {
	if (C >= B) {
		ll x = C + 1 - B;
		if (x >= A) x++;
		if (x * (B + 1) >= A * B) return false;
	}
	for (ll x = C / 2 - 5; x <= C / 2 + 7; x++) {
		if (x <= 0 || x == A) continue;
		ll id = x;
		if (x > A) id--;
		ll y = C + 1 - id;
		if (C >= B) y++;
		if (C >= B && y <= B) y--;
		if (y <= 0) continue;
		if (x * y >= A * B) return false;
	}
	return true;
}

ll solve() {
	ll A, B;
	scanf("%lld%lld", &A, &B);
	if (A > B) swap(A, B);
	ll L = A - 1, R = A + B;
	while(R - L > 1) {
		ll x = (L + R) / 2;
		if (solve(A, B, x))
			L = x;
		else
			R = x;
	}
	return L;
}

int main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int t;
	scanf("%d", &t);
	while(t--)
		printf("%lld\n", solve());

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		//int n = sc.nextInt();
		//int s = 0;
		//int end =  0;
		int n = 3;
		int na[] = new int[n];
		int a, b, c;
		for (int i = 0; i < n; i++)
		{
			na[i] = sc.nextInt();
		}
		if(na[0] >= na[1] && na[0] >= na[2])
		{
			a= na[0];
			b= na[1];
			c= na[2];
		}
		else if (na[1] >= na[0] && na[1] >= na[2])
		{
			a= na[1];
			b= na[0];
			c= na[2];
		}
		else
		{
			a= na[2];
			b= na[1];
			c= na[0];
		}
		if(a == b && b ==  c)
		{
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}

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


int main() {
  int n,k,i;
  cin>>n>>k;
  int a[n];
  set<int> kind;
  for(i=0;i<n;i++){
    cin>>a[i];
    kind.insert(a[i]);
  }
  int ans;
  if(k>=kind.size()){
    cout<<0<<endl;
    return 0;
  }
  
  else {
    int s[200002]={};
    for(i=0;i<n;i++)
      s[a[i]]++;
    sort(s,s+200002);
    int cnt=0,ans=0;
    for(i=0;i<200002;i++){
      if(s[i]>0){
        cnt++;
        ans+=s[i];
      }
      if(cnt+k>=kind.size())
        break;
    }
    cout<<ans;
  }
  
  
}

Measured memory_bytes: 11136
#include <stdio.h>
 
int main(void) {
    int n;
    int syakkinn=100000;
    int i;
    scanf("%d",&n);
    for(i=0;i<n;i++) {
        syakkinn*=1.05;
        if(syakkinn%1000!=0)syakkinn+=1000;
        syakkinn-=syakkinn%1000;
    }
    printf("%d\n",syakkinn);
    return 0;
}

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

int A[102];
int dp[100005];

int main() {

    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);
    
    int N, K;
    cin >> N >> K;
    
    for(int i=1; i<=N; i++)
        cin >> A[i];
    
    for(int i=1; i<=K; i++)
    {
        for(int j=1; j<=N; j++)
            if(A[j] <= i)
                dp[i] |= (dp[ i - A[j] ] == 0);
    }
    
    if(dp[K])
        cout << "First\n";
    else
        cout << "Second\n";
    
    return 0;
}

Measured memory_bytes: 640
/*
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <numeric>

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> x(n, 0);

    for (int i = 0; i < n; i++)
        cin >> a[i];

    x[n - 1] = a[n - 1];

    for (int i = 0; i < n - 1; i++)
    {
        if (i % 2 == 0)
            x[n - 1] -= a[i];
        else
            x[n - 1] += a[i];
    }

    x[n - 1] /= 2;

    for (int i = n - 2; i >= 0; i--)
    {
        x[i] = a[i] - x[i + 1];
    }

    for (int i = 0; i < n; i++)
        cout << x[i] * 2 << " ";

    return 0;
}

Measured memory_bytes: 2048
<?php
while (true) {
    fscanf(STDIN, "%d %d", $a, $b);
    if ($a === 0 && $b === 0) {
        break;
    }else if ($a >= $b) {
        echo $b.' '.$a.PHP_EOL;
    }else{
        echo $a.' '.$b.PHP_EOL;
    }
}
 

Measured memory_bytes: 15160
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;

int find(int i, vector<int>& ds) {
    if (ds[i] == i) return i;
    ds[i] = ds[ds[i]];
    return find(ds[i], ds);
}

bool unionSets(int i, int j, vector<int>& ds) {
    int p1 = find(i, ds);
    int p2 = find(j, ds);
    if (p1 == p2) return false;

    ds[p1] = p2;
    return true;
}

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

    int n, m;
    cin>>n>>m;
    vector<int> ds(n);
    rep(i, n) ds[i] = i;
    rep(i, m) {
        int v1, v2;
        cin>>v1>>v2;
        unionSets(v1, v2, ds);
    }

    int q;
    cin>>q;
    rep(i, q) {
        int s, t;
        cin>>s>>t;
        if (find(s, ds) == find(t, ds)) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
#include <unistd.h>
#include <cctype>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 1 << 30
#define LLINF LLONG_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
using ll = long long;
using Pll = pair<ll,ll>;
using Pii = pair<int,int>;
using Pdd = pair<double,double>;
using dcomplex = complex<double>;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}
ll power(ll x,ll n){ll a=1;REP(i,n)a*=x;return a;}
double inf() {return std::numeric_limits<double>::infinity();}

double comb(ll p, ll q) {
  ll ans = 1;
  for(ll i = 0; i < q; i++) {
    ans *= (p-i);
    ans /= (i+1);
  }
  return ans;
}

ll N;
ll A,B;

int main() {
  cin >> N;
  int ans = 11;
  for(ll i = 1; i <= sqrt(N); i++) if(N%i == 0) {
    auto s1 = to_string(i);
    auto s2 = to_string(N/i);
    // cout << s1 << " " << s2 << endl;
    ans = min((int)max(s1.size(),s2.size()),ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N, K;
std::vector<pair<ll, ll>> V;
ll dp[105][100005];
ll A, B;

ll rec(ll x, ll y) {
	if(y > K) {
		return -1e9;
	}
	if(x == N) {
		return 0;
	}
	ll &ans = dp[x][y];
	if(ans != -1) {
		return ans;
	}
	// if(V[x].first + y <= K)
	ans = max(V[x].second + rec(x + 1, y + V[x].first), rec(x + 1, y));
	return ans;
}

int main() {
	scanf("%lld %lld", &N, &K);
	for(int i = 0; i < N; i++) {
		scanf("%lld %lld", &A, &B);
		V.push_back(make_pair(A, B));
	}
	memset(dp, -1, sizeof(dp));
	cout << rec(0, 0);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 82304
use std::io;
use std::cmp;


fn main() {
    let n = read_one::<usize>();
    let mut ln = read::<usize>();
    ln.sort();
    let mut ans: usize = 0;
    for i in 0..n - 1 { for j in (i + 1)..n - 1 {
        let pos = ln.lower_bound(&(ln[i] + ln[j]));
        ans += pos - j - 1;
    }}
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

pub trait BinarySearch<T> {
    fn lower_bound(&self, x: &T) -> usize;
    fn upper_bound(&self, x: &T) -> usize;
}

impl<T: Ord> BinarySearch<T> for [T] {
    fn lower_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();

        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                cmp::Ordering::Less => {
                    low = mid + 1;
                },
                _ => {
                    high = mid;
                }
            }
        }
        low
    }

    fn upper_bound(&self, x: &T) -> usize {
        let mut low = 0;
        let mut high = self.len();
        while low != high {
            let mid = (low + high) / 2;
            match self[mid].cmp(x) {
                cmp::Ordering::Greater => {
                    high = mid;
                },
                _ => {
                    low = mid + 1;
                }
            }
        }
        low
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
#define sz(a) ll(a.size())
void solve(){
	ll n,m,res=0;
	cin>>n>>m;
	vector<p2> v(n);
	for(ll i=0;i<n;i++)
		cin>>v[i].second>>v[i].first;
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	set<ll> s;
	for(ll i=0;i<m;i++)
		s.insert(i);
	for(ll i=0;i<n;i++){
		auto it=s.lower_bound(m-v[i].second+1);
		if(s.empty()||it==s.begin())
			continue;
		s.erase(prev(it,1));
		res+=v[i].first;
	}
	cout<<res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    clock_t z=clock();
    ll qc=1;
    //cin>>qc;
    for(ll i=1;i<=qc;i++){
        solve();
    }
    debug("Total Time:%.4Lf\n",(ld)(clock()-z)/CLOCKS_PER_SEC);
}


Measured memory_bytes: 9500
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
#define double long double
#define PI 3.141592653589793
typedef long long ll;
const int MOD = 1000000007;
const int INF = 11000000000000;
const double EPS = 1e-10;
using namespace std;
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

vector<int> divisor(int n){
  vector<int> ret;
  for(int i = 1;i*i <= n;i++){
    if(n%i == 0){
      ret.push_back(i);
      if(i*i != n)ret.push_back(n/i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}


signed main() {
  int n;cin>>n;
  if(n%2 ==0)cout << n/2-1 << endl;
  else cout << n/2 << endl;
}




Measured memory_bytes: 256
require 'prime'
require 'set'
require 'tsort'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end
class Hash
  include TSort
  alias tsort_each_node each_key
  def tsort_each_child(node, &block)
    fetch(node).each(&block)
  end
end
hash = Hash.new
v,e = gi
rep v do |i|
	hash[i] = []
end
rep e do
	s,t = gi

	hash[t] << s
end 
puts hash.tsort

Measured memory_bytes: 11852
#include<bits/stdc++.h>
using namespace std;
set<char> s;
char a[100005];
int ans, len, ini[30];

int main()
{
	scanf("%s", a + 1); len = strlen(a + 1);
	int lin = (a[1] == a[len]);
	int qaq = (len & 1); int lpl = abs(lin - qaq);
	if(lpl & 1) printf("First");
	else printf("Second");
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
#include <iomanip>
using namespace std;

int main(void){
    int n;
    cin >> n;
    int a[n];
    int count = 0;
    int check = 1;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    for(int i = 0; i < n; i++){
        if(a[i] != check)
            count++;
        else if(a[i] == check)
            check++;
    }
    if(count == n)
        cout << -1 << endl;
    else
        cout << count << endl;
}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if ((A == 5 && B == 7 && C == 5) || (A == 5 && B == 5 && C == 7) || (A == 7 && B == 5 && C == 5)) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int a, b;
	cin >> a >> b;
	if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) cout << "Possible" << endl;
	else cout << "Impossible" << endl;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
a=list(zip(range(n),a))#[index,a]の配列
a.sort(key=lambda x:x[1])#aの昇順で並べる
dp=[[0 for i in range(n+1)]for j in range(n+1)] #dp[x][y]:=左にx、右にy人並べたときの最大値
ans=0
for k in range(n):# k人目まで終了、k+1人目に対して
  i,ai=a.pop()#aの大きいものから取り出す
  dp[k+1][0]=dp[k][0]+ai*(i-k)
  dp[0][k+1]=dp[0][k]+ai*(n-k-1-i)
  for l in range(k):#右にl+1人並べたとき
    dp[k-l][l+1]=max(dp[k-l-1][l+1]+ai*(i-k+l+1),dp[k-l][l]+ai*(n-l-1-i))
for k in range(n+1):
  ans=max(ans,dp[k][n-k])

print(ans)


Measured memory_bytes: 125236
#include <cstdio>
#include <vector>

using namespace std;

bool inOrder(vector<int> a)
{
	int t = a[1] - a[0];
	for (int i = 0; i < a.size() - 1; i++){
		if (a[i + 1] - a[i] != t){
			return (false);
		}
	}
	
	return (true);
}

int main(void)
{
	int n;
	int h[128];
	int i, j;
	int ans;
	vector<int> t;
	
	while (scanf("%d", &n) && n){
		
		for (i = 0; i < n + 1; i++){
			scanf("%d", &h[i]);
		}
		
		for (i = 0; i < n + 1; i++){
			t.clear();
			for (j = 0; j < n + 1; j++){
				if (i != j){
					t.push_back(h[j]);
				}
			}
			if (inOrder(t)){
				ans = h[i];
				break;
			}
		}
		
		printf("%d\n", ans);
	}
	
	return (0);
}

Measured memory_bytes: 1056
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;



#define INF 1000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<ll,ll> a,pair<ll,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}
const ll MAX = 5100000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 // 二項係数計算
ll COM(ll n, ll k){
     if (n < k) return 0;
     if (n < 0 || k < 0) return 0;
     return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

 using graph = vector<vector<ll>>;
 pair<pair<ll,ll>,ll> p[100010];

 int main(){
     cin.tie(0);
     ios::sync_with_stdio(false);
     
     string s;
     cin>>s;
     ll n=s.size();
     vector<ll> l(n+1,0),r(n+1,0);
     ll sum=0;
     rep(i,n){
         if(s[i]=='<') l[i+1]=l[i]+1;
     }
     r[n]=0;
     for(ll i=n-1;i>=0;i--){
         if(s[i]=='>') r[i]=r[i+1]+1;
     }
     rep(i,n+1){
         sum+=max(l[i],r[i]);
     }
     cout<<sum<<endl;
     return 0;
 }

Measured memory_bytes: 8732
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define pf push_front
#define ulli unsigned long long int
#define what_is(x) cerr << #x << " is " << x << endl;
#define pi 2*acos(0.0)
#define F  first
#define S  second
#define endl '\n'
#define all(x) x.begin(),x.end()
using namespace std;

int main()
{
//cout.precision(9);
//cout.setf(ios::fixed,ios::floatfield);
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
	lli T=1;
    //cin>>T;
	while(T--)
	{
        lli n,k,i,j,b,c;
        cin>>n;
        vector<lli> dp(3,0),nwdp(3,0),a(3,0);
        for(i=0;i<n;i++)
        {
            for(j=0;j<3;j++)
            cin>>a[j];
            for(j=0;j<3;j++)
            {
                for(k=0;k<3;k++)
                {
                    if(j!=k)
                    {
                        nwdp[k]=max(nwdp[k],dp[j]+a[k]);
                    }
                }
            }
            dp=nwdp;
        }
        cout<<max({dp[0],dp[1],dp[2]})<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

int main() {
    int a; cin >> a;
    if (a >= 1000) cout << "ABD" << endl;
    else cout << "ABC" << endl;
}
    


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  int ans = c - (a - b);
  if ( ans > 0) {
    cout << ans << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define N 1000002
#define mod 1000000007
#define pb push_back
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int mxN = 1e5 + 5;
int h[mxN];
int cache[mxN];
int n;
int dp(int idx){
	if(idx==n)
		return 0;
	if(idx>n)
		return INT_MAX;
	int &ans = cache[idx];
	if(ans!=-1)
		return ans;
	int case1,case2;
	case1 = case2 = INT_MAX; 
	if(idx+2<=n)
		case1 = abs(h[idx+2] - h[idx]) + dp(idx+2);
	if(idx+1<=n)
		case2 = abs(h[idx+1] - h[idx]) + dp(idx+1);
	return ans = min(case1,case2);
}
void solve(){
	cin>>n;
	memset(cache,-1,sizeof(cache));
	for(int i = 1 ; i <= n;i++)
		cin>>h[i];
	cout<<dp(1)<<'\n';
}
int main() {	
	// IOS
	ll T;
	// cin>>T;
	
	T = 1;
	// ll i = 1;
	while(T--){
		// cout<<"Case #"<<i<<": ";
		
		solve();
		// i++;
	}
	return 0;
	
}

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

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)
#define rrep(i,a,b) for(int (i)=int(a);(i)>=int(b);(i)--)

#define put(a) cout << (a) << endl
#define puts(a) cout << (a) << " "

#define llint long long int

#define INF (long long)(1e9+1)
#define MOD (long long)(1e9+7)
#define INF64 (long long)(1e18+1)

#define F first
#define S second

#define Pii  pair<int,int>
#define Pll  pair<long long,long long>
#define Piii pair<int,pair<int,int>>
#define Plll pair<long long,pair<long long,long long>>

#define Vll(a,b,c)    vector<vector<long long>> (a)((b),vector<long long>((c))
#define Vlll(a,b,c,d) vector<vector<vector<long long>>> (a)((b),vector<vector<long long>>((c),vector<long long>((d)))

#define MAX_N 1000000

llint my_binary_search(llint ary[], llint key, llint left, llint right) {
	llint middle;
	if (right < left) {
		return -(INF64);
	} else {
		middle = left + (right - left) / 2;
		if (ary[middle] > key) {
			return my_binary_search(ary, key, left, middle - 1);
		} else if (ary[middle] < key) {
			return my_binary_search(ary, key, middle + 1, right);
		} else {
			return middle;
		}
	}
}

struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for(int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

int main (void)
{
	//INPUT
	int a,b;
	cin >> a >> b;
	// vector<llint> A(N);
	// rep(i,0,N) {
	// 	cin >> A[i];
	// }
	// string S;
	// cin >> S;
	// llint len;
	// len = S.length();


	//SOLVE

	if (a<b) {
		rep(i,0,b) {
			cout << a;
		}
		// char ans[] = a*int(b);
	} else {
		rep(i,0,a) {
			cout << b;
		}
		// char ans[] = b*int(a);
	}
	cout << endl;
	//OUTPUT
	// rep

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int s = S.length();
    int a = -1, z = 0;
    for(int i = 0; i < s; i++){
      if(S.charAt(i) == 'A' && a == -1){
        a = i;
      }else if(S.charAt(i) == 'Z'){
        z = i;
      }
    }
    System.out.println(z-a+1);
  }
}

Measured memory_bytes: 28484
#include <bits/stdc++.h>
#define int long long
#define INT_MAX INT64_MAX
#define INT_MIN INT64_MIN
#define PI 3.14159265358979323846
#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main
#define MOD 1000000007
/* DEFINE cout */
#define pln cout << "===============================\n"
#define on cout<<"\n"
#define os cout<<" "
#define o2(a,b) cout<<a<<" "<<b
#define o(a) cout << a
#define bitcount __builtin_popcountll
/* DEFINE cout */
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);//fastio
using namespace std;
struct hash_pair { // use pair as key in unordered_map<pair<int,int>,int,hash_pair>;
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
bool prime[10000001];
int P=MOD-2;
int factorial[10000001]={0};
int powerFunction(int x,int y){
    int res = 1;
    int p = MOD;
    x = x % p;
    while (y > 0){
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
void sieveFunction(int maxLimit){
    memset(prime, true, sizeof(prime));
    prime[0] = prime[1]=false;
    for(int i=2; maxLimit >= i ; i++){
        if(prime[i]){
            for(int j=2*i ; maxLimit >= j ; j+=i)
                prime[j]=false;
        }
    }
}
void factorialFunction(int maxLimit){
    factorial[0]=1;
    for(int i=1 ; i <= maxLimit ; i++)
        factorial[i]=(factorial[i-1]*i)%MOD;
    return;
}
int gcd(int a, int b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
signed main(){
    int n;
    cin >> n;
    string str;
    cin >> str;
    int w, r;
    w = r = 0;
    for(int i=0; n>i; i++){
        if(str[i] == 'R'){
            r++;
        }else{
            w++;
        }
    }
    int white[n];
    int c = 0;
    for(int i=0; n>i; i++){
        if(str[i] == 'W'){
            c++;
        }
        white[i] = c;
    }
    if(r == 0){
        cout << 0 << endl;
    }else{
        cout << white[r-1] << endl;
    }
}






Measured memory_bytes: 5320
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		int[] A = new int[N+1];
		int[] B = new int[N];
		long count = 0;
		
		for(int i = 0; i < N+1; i++) {
			A[i] = stdIn.nextInt();
		}
		for(int i = 0; i < N; i++) {
			B[i] = stdIn.nextInt();
		}
		
		for(int i = 0; i < N; i++) {
			if(A[i] >= B[i]) {
				count += B[i];
			}
			else {
				if(B[i]-A[i] >= A[i+1]) {
					count += (A[i]+A[i+1]);
					A[i+1] = 0;
				}
				else {
					count += B[i];
					A[i+1] -= (B[i]-A[i]);
				}
			}
		}
		
		System.out.println(count);

	}

}

Measured memory_bytes: 63832
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

const int MAX = 300000;
vector<int> primes;

vector<int> prime_factor(int n) {
	const int ori = n;
	vector<int> res;
	for(int i = 0; i < (int)primes.size() && primes[i] <= n; ++i) {
		if(n % primes[i] == 0)
			res.push_back(primes[i]);
	}

	return res;
}

vector<int> sieve() {
	vector<int> res;
	vector<bool> prime(MAX, true);

	for(int n = 0; 7 * n + 1 < MAX; ++n) {
		if(n) {
			const int x = 7 * n + 1;
			if(prime[x]) {
				res.push_back(x);
				for(int i = x + x; i < MAX; i += x)
					prime[i] = false;
			}
		}

		if(7 * n + 6 < MAX) {
			const int x = 7 * n + 6;
			if(prime[x]) {
				res.push_back(x);
				for(int i = x + x; i < MAX; i += x)
					prime[i] = false;
			}
		}
	}

	return res;
}

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

	primes = sieve();

	for(int n; cin >> n, n > 1;) {
		vector<int> pf = prime_factor(n);
		cout << n << ": ";
		for(int i = 0; i < (int)pf.size(); ++i)
			cout << pf[i] << (i + 1 == (int)pf.size() ? "\n" : " ");
	}

	return EXIT_SUCCESS;
}

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

int main(int argc, char const *argv[]) {
    int n, a, b, p;
    int p1=0, p2=0, p3=0;
    cin >> n >> a >> b;
    for(int i=0;i<n;i++){
        cin >> p;
        if(p<=a) {
            p1++;
        }else if(p<=b){
            p2++;
        }else{
            p3++;
        }
    }
    cout << min(min(p1, p2), p3) << endl;
    return 0;
}


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

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

/*********** Constants ***********/
const auto INF = static_cast<ll>(1e15);
const auto MOD = static_cast<ll>(1e9 + 7);

/*********** Variables ***********/
ll ANS;
string INPUT;
stack<ll> NUM;

/*********** Functions ***********/
bool init() {
    getline(cin, INPUT);
    return true;
}

void solve() {
    string str;
    for (char input : INPUT) {
        if (input == ' ') {
            if (!str.empty()) {
                NUM.push(strtol(str.c_str(), nullptr, 10));
            }
            str = "";
        }
        else if (input == '+') {
            ll a = NUM.top(); NUM.pop();
            ll b = NUM.top(); NUM.pop();
            NUM.push(a + b);
        }
        else if (input == '-') {
            ll a = NUM.top(); NUM.pop();
            ll b = NUM.top(); NUM.pop();
            NUM.push(b - a);
        }
        else if (input == '*') {
            ll a = NUM.top(); NUM.pop();
            ll b = NUM.top(); NUM.pop();
            NUM.push(a * b);
        }
        else {
            str += input;
        }
    }
    ANS = NUM.top();
}

void output() {
    cout << ANS << endl;
}

int main() {
    init();
    solve();
    output();
    return 0;
}


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

int main() {

    char a;
    char b;
    
    scanf("%c %c", &a,&b);
    
    if(a=='H' && b=='H'){
        puts("H");
    }else if (a == 'H' && b == 'D') {
        puts("D");
    } else if (a == 'D' && b == 'H') {
        puts("D");
    } else if (a == 'D' && b == 'D') {
        puts("H");
    }


    return 0;

}


Measured memory_bytes: 128
N = int(input())
A = [0] + [int(s) for s in input().split()] + [0]
s = sum([abs(A[i + 1] - A[i]) for i in range(N + 1)])
for i in range(1, N + 1):
    print(s - abs(A[i] - A[i - 1]) -
          abs(A[i + 1] - A[i]) + abs(A[i + 1] - A[i - 1]))


Measured memory_bytes: 14048
#include <bits/stdc++.h>
#define LL long long
#define For(I,X,Y) for(I=(X);I<=(Y);I++)
#define ForDown(I,X,Y) for(I=(X);I>=(Y);I--)
using namespace std;

inline LL Read(){
	LL X=0;char CH=getchar();bool F=0;
	while(CH>'9'||CH<'0'){if(CH=='-')F=1;CH=getchar();}
	while(CH>='0'&&CH<='9'){X=(X<<1)+(X<<3)+CH-'0';CH=getchar();}
	return F?-X:X;
}

LL N,M,A,B,Ans;

int main(){
	A=Read(),B=Read();
	
	printf("%lld",(A-1)*(B-1));
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

	int a = scan.nextInt();
	String op = scan.next();
	int b = scan.nextInt();

	if(op.charAt(0) == '+'){
	    System.out.println(a+b);
	}else{
	    System.out.println(a-b);
	}
    }
}


Measured memory_bytes: 21972
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int n,ans,s=0;
  char x[200010];
  scanf("%s",x);
  n=ans=strlen(x);
  for(int i=0;i<n;i++){
    if(x[i]=='S')
      s++;
    else if(s){
      ans-=2;
      s--;
    }
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

int main() {
  int n;
  cin >> n;
  V<int> l(n);
  rep(i, n) cin >> l[i];

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

  int ans = 0;
  for (int i = 0; i < n - 2; ++i) {
    for (int j = i + 1; j < n - 1; ++j) {
      auto left =
          upper_bound(l.begin() + j + 1, l.end(), abs(l[i] - l[j])) - l.begin();
      auto right =
          lower_bound(l.begin() + j + 1, l.end(), l[i] + l[j]) - l.begin();
      ans += right - left;
    }
  }
  cout << ans << endl;
}


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

int dp[50];

int fib(int n)
{
	if (n == 0 || n == 1) return dp[n] = 1;
	if (dp[n]) return dp[n];
	return dp[n] = fib(n - 1) + fib(n - 2);
}

int main()
{
	int n;
	cin >> n;
	cout << fib(n) << endl;

    return 0;
}



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

int main(){
  int K,S;
  cin >> K >> S;
  
  int count=0;
  
  for(int i=0; i<=K; i++){
    for(int j=0; j<=K; j++){
      if(S-K <= (i+j) && (i+j)<= S){
        count++;
      }
    }
  }
  cout << count << endl;
  
  
}


Measured memory_bytes: 3576
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  vector<int> A(N), B(N);
  for(int i=0;i<N;++i) {
    cin>>A[i];
    B[i] = A[i];
  }
  sort(B.begin(), B.end());
  for(int i=0;i<N;++i) {
    if(A[i]==B[N-1]) cout<<B[N-2]<<endl;
    else cout<<B[N-1]<<endl;
  }
}



Measured memory_bytes: 4844
#include <bits/stdc++.h> 
 
#define INF (1<<31) - 1 //INT_MAX/2
#define MOD 1000000007
#define PI  acos(-1)
 
using ll  = long long;
using ull = unsigned long long;

int main(int argc, char *argv[])
{
    int N, A, B;
    std::cin >> N >> A >> B;

    std::vector<int> P(N);
    for (int i = 0; i < N; i++) {
        std::cin >> P[i];
    }

    int count1 = 0;
    int count2 = 0;
    int count3 = 0;
    for (int i = 0; i < N; i++) {
        if (P[i] <= A) {
            count1++;
        }
        if (P[i] >= A+1 && P[i] <= B) {
            count2++;
        }
        if (P[i] >= B+1) {
            count3++;
        }
    }

    std::cout << std::min({count1, count2, count3}) << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (abs(x - a) < abs(x - b))
		cout << 'A' << endl;
	else
		cout << 'B' << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n;
int x[1 << 18];
int mx[1 << 18][2];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 0; i < (1 << n); ++i) {
        cin >> x[i];
        mx[i][0] = x[i];
	}
	for (int i = 0; i < n; ++i) {
        for (int j = 0; j < (1 << n); ++j) {
            if ((j >> i) & 1) continue;
            for (int k = 0; k < 2; ++k) {
                int v = mx[j][k];
                int t = j ^ (1 << i);
                if (mx[t][0] < v) {
                    mx[t][1] = mx[t][0];
                    mx[t][0] = v;
                }
                else if (mx[t][1] < v) {
                    mx[t][1] = v;
                }
            }
        }
	}
	for (int i = 0; i < (1 << n); ++i) {
        mx[i][0] += mx[i][1];
	}
	for (int i = 1; i < (1 << n); ++i) {
        int ret = mx[i][0];
        for (int j = 0; j < n; ++j) {
            if ((i >> j) & 1) {
                ret = max(ret, mx[(i ^ (1 << j)) | ((1 << j) - 1)][0]);
            }
        }
        printf("%d\n", ret);
	}
	return 0;
}


Measured memory_bytes: 6144
#include <iostream>
std::string m[12];
void d(int x,int y){
	if(x>0&&m[y][x-1]-48)m[y][x-1]=48,d(x-1,y);
	if(x<11&&m[y][x+1]-48)m[y][x+1]=48,d(x+1,y);
	if(y>0&&m[y-1][x]-48)m[y-1][x]=48,d(x,y-1);
	if(y<11&&m[y+1][x]-48)m[y+1][x]=48,d(x,y+1);
	return ;
}
main(){
	while(1){
		int y=12;
		for(;y;y--)std::cin>>m[y-1];
		if(std::cin.eof())return 0;
		int r = 0;
		for(;y<12;y++)for(int x=0;x<12;x++)if(m[y][x]-48)r++,m[y][x]=48,d(x,y);
		std::cout<<r<<'\n';
	}
}

Measured memory_bytes: 0
def partpall(s,n):
	if s!=s[::-1]:
		return False
	else:
		return True

def pall(s,n):
	if s!=s[::-1]:
		return False
	return partpall(s[n//2 +1 :],n) and partpall(s[:n//2 ],n)


# s=input("enter:")
s=input()
# print("sucess",s,s[::-1])
# revStr=s[::-1]
n=len(s)
# print(n)
if pall(s,n):
	print("Yes")
else:
	print("No")

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define INF 1000000000000
using ll = long long;


int main(){
  int n;
  cin >> n;
  vector<ll> a(n+1),b(n);
  rep(i,n+1)cin >> a.at(i);
  rep(i,n)cin >> b.at(i);
  ll ans = 0;
  rep(i,n){
    if(a.at(i)>=b.at(i)){
      a.at(i)-=b.at(i);
      ans+=b.at(i);
      b.at(i)=0;
      continue;
    }else{
      b.at(i)-=a.at(i);
      ans+=a.at(i);
      a.at(i)=0;
    }
    if(a.at(i+1)>=b.at(i)){
      a.at(i+1)-=b.at(i);
      ans+=b.at(i);
      b.at(i)=0;
      continue;
    }else{
      b.at(i)-=a.at(i+1);
      ans+=a.at(i+1);
      a.at(i+1)=0;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
    #ifdef magUNbos
    freopen("in","r",stdin);
    freopen("out","w",stdout);
    #endif // magUNbos
    int n;
    cin>>n;
    ll a[n];
    map <ll, ll> m;
    For(i,n){
        cin>>a[i];
        m[a[i]]=i;
    }
    sort(a,a+n);
    ll ans = 0;
    For(i,n){
        if((abs(i-m[a[i]]) % 2)){
            ans++;
           // cerr<<i<<" : "<<m[a[i]]<<endl;
        }
    }
    cout<<ans/2<<endl;




}


Measured memory_bytes: 7296
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 5000
#define MAXK 5000

int n, k;
int a[MAXN];
int b[MAXK+1];

int input() {
	if (scanf("%d %d", &n, &k) < 0) return 0;
	for (int i=0; i<n; i++) scanf("%d", &a[i]);
	return 1;
}

void init() {
}

int check(int m) {
	for (int i=1; i<=k; i++) b[i] = 0;
	b[0] = 1;
	for (int i=0; i<n; i++) {
		if (i==m) continue;
		for (int j=k-a[i]; j>=0; j--)
			if (b[j]) b[j+a[i]] = 1;
	}
	for (int i=max(0, k-a[m]); i<k; i++)
		if (b[i]) return 1;
	return 0;
}

int solve() {
	sort(a, a+n);
	int s=-1, t=n;
	while (t-s>1) {
		int m = (s+t)/2;
		if (check(m)) t = m;
		else s = m;
	}
	return t;
}

void output(int ans) {
	printf("%d\n", ans);
}

void cleanup() {
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 256