akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  ll MOD = 1e9 + 7;
  vector<int> A(N, 0);
  REP(i, N){
    int tmp; cin >> tmp;
    A[tmp]++;
  }
  bool flag = true;
  if(N % 2 == 0){
    for(int i = 1; i < N; i += 2){
      if(A[i] != 2) flag = false;
    }
    ll ans = 1;
    if(flag){
      REP(i, N/2){
        ans *= 2;
        ans %= MOD;
      }
      cout << ans << endl;
    }else{
      cout << 0 << endl;
    }
  }else{
    if(A[0] != 1) flag = false;
    for(int i = 2; i < N; i += 2){
      if(A[i] != 2) flag = false;
    }
    ll ans = 1;
    if(flag){
      REP(i, N/2){
        ans *= 2;
        ans %= MOD;
      }
      cout << ans << endl;
    }else{
      cout << 0 << endl;
    }
  }
}

Measured memory_bytes: 640
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <limits>
#include <memory>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

#define all(a) (a).begin(), (a).end()
#define sz(a) static_cast<int>((a).size())
#define fillchar(a, x) memset(a, x, sizeof(a))
#define rep(i, a, b) for(int i=int(a); i<=int(b); ++i)
#define irep(i, a, b) for(int i=int(a); i>=int(b); --i)
#define replr(i, a, b) rep(i, a, (b)-1)
#define reprl(i, a, b) irep(i, (b)-1, a)
#define repn(i, n) rep(i, 0, (n)-1)
#define irepn(i, n) irep(i, (n)-1, 0)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef pair<LL,LL> PLL;
typedef pair<int,int> PII;
typedef pair<double,double> PDD;
typedef vector<LL> VL;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<string> VS;
template<class T, class S> ostream& operator<<(ostream& os, const pair<T, S>& v) { return os<<"("<<v.first<<", "<<v.second<<")"; }
template<class T> ostream& operator<<(ostream& os, const vector<T>& v) { os<<"["; repn(i, sz(v)) { if(i) os<<", "; os<<v[i]; } return os<<"]"; }
template<class T> bool setmax(T &_a, T _b) { if(_b>_a) { _a=_b; return true; } return false; }
template<class T> bool setmin(T &_a, T _b) { if(_b<_a) { _a=_b; return true; } return false; }
template<class T> T gcd(T _a, T _b) { return _b==0?_a:gcd(_b,_a%_b); }

string s;
vector<int> a;

LL dfs(int i, LL sum, LL cur) {
    if(i>=sz(a)) {
        return sum+cur;
    }
    return dfs(i+1, sum+cur, a[i])+dfs(i+1, sum, cur*10+a[i]);
}

int main() {
    ios_base::sync_with_stdio(false);

    cin>>s;
    for(char c: s) a.pb(int(c-'0'));
    LL ans=dfs(1, 0, a[0]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
A = input()

Alphabet = list("abcdefghijklmnopqrstuvwxyz")

N = len(A)
ans = N*(N-1)/2 + 1

for i in Alphabet:
  z = 0
  for j in range(len(A)):
    if i == A[j]:
      z+=1
  if z>1:
    ans -= z*(z-1)/2
    
print(int(ans))

Measured memory_bytes: 9064
h,w = map(int,input().split())
C = [list(input()) for i in range(h)]

queue = []
visited = [] 
visited = [[0 for i in range(w)] for i in range(h)]
ans = 0

for i in range(h):
    for j in range(w):
        if C[i][j] == '.':
            queue.append([i,j])
            visited[i][j] = 1

            dy_dx = [[1,0],[0,1],[-1,0],[0,-1]]

            while len(queue) > 0:
                now = queue.pop(0)
                for k in range(4):
                    y = now[0]+dy_dx[k][0]
                    x = now[1]+dy_dx[k][1]
                    if 0 <= y < h and 0 <= x < w:
                        if C[y][x] != '#' and visited[y][x] == 0:
                            visited[y][x] = visited[now[0]][now[1]]+1 #移動回数のカウント
                            queue.append([y,x])
                    
        for l in range(h):
            for m in range(w):
                ans = max(ans,visited[l][m])
            
        queue = []
        visited = [[0 for i in range(w)] for i in range(h)]              
        
print(ans-1)

Measured memory_bytes: 9240
'use strict'

const main = (INPUT) => {
  const [S, T] = INPUT.split('\n')
  let str = S
  for (let i = 0; i < S.length; i++) {
    const tmp = str[0]
    str = str.slice(1) + tmp
    if (T === str) {
      console.log('Yes')
      return
    }
  }
  console.log('No')
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 29520
using System;
using System.Linq;

namespace A
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			var line = Console.ReadLine().Split().Select(int.Parse).ToArray();
			var a = line[0];
			var b = line[1];
			Console.WriteLine(a * b % 2 == 0 ? "Even" : "Odd");
		}
	}
}

Measured memory_bytes: 13268
def main():
    N = int(input())
    X = tuple(map(int, input().split()))
    Y = tuple(map(int, input().split()))

    if X == Y:
        print(0)
        return

    P = {v: i for i, v in enumerate(sorted(permutations(range(1, N + 1))))}
    print(abs(P[X] - P[Y]))


def permutations(iterable, r=None):
    pool = tuple(iterable)
    n = len(pool)
    r = n if r is None else r
    if r > n:
        return
    indices = list(range(n))
    cycles = list(range(n, n-r, -1))
    yield tuple(pool[i] for i in indices[:r])
    while n:
        for i in reversed(range(r)):
            cycles[i] -= 1
            if cycles[i] == 0:
                indices[i:] = indices[i+1:] + indices[i:i+1]
                cycles[i] = n - i
            else:
                j = cycles[i]
                indices[i], indices[-j] = indices[-j], indices[i]
                yield tuple(pool[i] for i in indices[:r])
                break
        else:
            return


if __name__ == "__main__":
    main()

Measured memory_bytes: 11820
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx;
    int dy = ty - sy;

    string ans = string(dx, 'R') + string(dy, 'U') + string(dx, 'L') + string(dy, 'D')
                + string(1, 'D') + string(dx + 1, 'R') + string(dy + 1, 'U') + string(1, 'L')
                + string(1, 'U') + string(dx + 1, 'L') + string(dy + 1, 'D') + string(1, 'R');

    cout << ans << '\n';
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 2010
#define mod 1000000007
using namespace std;
int n, k, f[N][N], s[N], ans;
//f[i][j]=填完了1~i，当前填入的最小数=j，方案数
int main(){
	scanf("%d%d", &n, &k);
	memset(f, 0, sizeof(f)); f[0][n+1]=1;
	s[n+1]=1; for(int i=n; i; i--)s[i]=(s[i+1]+f[0][i])%mod;
	for(int i=1; i<=k-1; i++){
		for(int j=1; j<=n+1-i; j++)f[i][j]=s[j];
		s[n+1]=f[i][n+1]; for(int j=n; j; j--)s[j]=(s[j+1]+f[i][j])%mod;
	}
	ans=0; for(int i=2; i<=n+1; i++)ans=(ans+f[k-1][i])%mod;
	for(int i=1; i<=n-k-1; i++)ans=ans*2%mod;
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 16000
#include<stdio.h>

int main(){
  int n; scanf("%d",&n);
  int f=0,t;
  for(int i=0; i<n; i++){
    scanf("%d",&t);
    if (t%2==0){ if((t%3!=0)&&(t%5!=0)) f=1; }
  }
  if(f==1) printf("DENIED\n");
  else printf("APPROVED\n");
  return 0;
}

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

int main(){
	int n; cin>>n;
	int b[n+2]={};
	b[0]=b[n]=(1<<30);
	for(int i=1; i<n; i++){
		cin>>b[i];
	}
	int ans=0;
	for(int i=0; i<n;i++){
		ans+=min(b[i],b[i+1]);
	}
	cout<<ans<<endl;
}
		
		

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans

int N;
vp A;

void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    cin >> N;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        A.emplace_back(a, i);
    }
    sort(all(A));
    int ans = 0;
    for (int i = 0; i < N; i += 2) {
        if ((i - A[i].second) % 2 != 0)
            ans++;
    }
    cout << ans << endl;

    solve();
    return 0;
}


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

int main() {
    int A,B;
    cin >> A >> B;
    cout << max({A+B, A-B, A*B}) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000007
//0=48,A=65,a=97

int main() {
    int n;cin >> n;
    vector<int> a(n);for(int i=0;i<n;i++) cin >> a[i];
    vector<int> b(n);
    b=a;
    for(int i = n/2; i >= 1; i--) {
        int sum=0;
        for(int j = 2*i; j <= n; j+=i) {
            sum += b[j-1];
        }
        if(b[i-1]%2 != sum%2) b[i-1]=1;
        else b[i-1]=0;
        
    }

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

    vector<int> c;
    for(int i = 0; i < n; i++) {
        if(b[i]==1) c.push_back(i+1);
    }

    cout << c.size() << endl;
    if(c.size()==0) return 0;

    for(int i = 0; i < c.size()-1; i++) {
        cout << c[i] << ' ' ;
    }
    cout << c[c.size()-1] << endl;

    return 0;
}

Measured memory_bytes: 5204
#include<iostream>
using namespace std;
using ll = long long;

ll mod = 1e9 + 7;
ll dp[110][10]; // dp[h][k] = h段からなり0がkに来るものの組合せ
int h, w, k;

int main(){
    cin >> h >> w >> k;
    dp[0][0] = 1, k--;
    for (int i = 0; i < h; i++){
        for (int j = 0; j < (1 << (w - 1)); j++){
            bool out = true;

            for (int k = 0; k < w - 2; k++){
                if (j & (1 << k) && j & (1 << (k + 1)))out = false;
            }
            if (!out)continue;
            int p[w];
            for (int k = 0; k < w; k++)p[k] = k;
            for (int k = 0; k < w - 1; k++){
                if ((j >> k) & 1)swap(p[k], p[k + 1]);
            }
            for (int k = 0; k < w; k++){
                dp[i + 1][p[k]] += dp[i][k];
                dp[i + 1][p[k]] %= mod;
            }
        }
    }
    cout << dp[h][k] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

int main(void)
{
    char s[128];
    int stack[128];
    int size;
    int a, b;
    int tmp;

    size = 0;
    while (scanf("%s", s) != EOF){
        if (isdigit(s[0])){
            tmp = atoi(s);
        }
        else {
            b = stack[size - 1];
            a = stack[size - 2];
            size -= 2;
            switch (s[0]){
                case '+': tmp = a + b; break;
                case '-': tmp = a - b; break;
                case '*': tmp = a * b; break;
            }
        }
        stack[size] = tmp;
        size++;
    }

    printf("%d\n", stack[0]);

    return (0);
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
const int INF = 1e18, MOD = 1e9 + 7;
int k;

signed main() {
    cin>>k;
    queue<int> q;
    for (int i = 1; i < 10; i++) {
        q.push(i);
    }
    
    while (k-- > 1) {
        int a = q.front();
        q.pop();
        if (a % 10 != 0) q.push(a * 10 + a % 10 - 1);
        q.push(a * 10 + a % 10);
        if (a % 10 != 9) q.push(a * 10 + a % 10 + 1);
        // cerr<<a<<endl;
    }
    cout<<q.front()<<endl;
}

Measured memory_bytes: 5180
import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int size = Integer.parseInt(br.readLine());
		String line = br.readLine();

		String[] str = line.split(" ");
		int[] a = new int[size];
		for (int i=0; i<size; i++) {
			a[i] = Integer.parseInt(str[i]);
		}

		for (int i=0; i<size; i++) {
			System.out.print("node "+(i+1)+": key = "+a[i]+", ");
			if (i != 0)
				System.out.print("parent key = "+a[(i-1)/2]+", ");
			if (i*2+1 < size)
				System.out.print("left key = "+a[i*2+1]+", ");
			if (i*2+2 < size)
				System.out.print("right key = "+a[i*2+2]+", ");
			System.out.println();
		}
	}
}

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

#define FOR(i, j, k) for(int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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 <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for(T &x : vec)
        is >> x;
    return is;
}

ll dp[2001][2001];
ll sdp[2001][2001];
const ll mod = 1000000007;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, m;
    cin >> n >> m;
    vi s(n), t(m);
    cin >> s;
    cin >> t;

    REP(i, n) {
        REP(j, m) {
            if(s[i] == t[j]) {
                dp[i][j] = 1;
                if(i > 0 and j > 0)
                    dp[i][j] = (dp[i][j] + sdp[i - 1][j - 1]) % mod;
                // REP(k, i) REP(l, j) dp[i][j] = (dp[i][j] + dp[k][l]) % mod;
            }
            sdp[i][j] = dp[i][j];
            if(i > 0 and j > 0)
                sdp[i][j] = (sdp[i][j] - sdp[i - 1][j - 1] + mod) % mod;
            if(i > 0)
                sdp[i][j] = (sdp[i][j] + sdp[i - 1][j]) % mod;
            if(j > 0)
                sdp[i][j] = (sdp[i][j] + sdp[i][j - 1]) % mod;
            // cout << i << " " << j << " " << dp[i][j] << endl;
        }
    }

    ll ans = 0;
    REP(i, n) REP(j, m) ans = (ans + dp[i][j]) % mod;
    // REP(i, n) {
    //     REP(j, m) cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    cout << ans + 1 << endl;
    // cout << dp[n - 1][m - 1] << endl;

    return 0;
}


Measured memory_bytes: 62592
#include <stdio.h>

int main(void){
    int n,t = 0;
    scanf("%d",&n);
    while(n != 1){
        if(!(n % 3)){
            n/=3;
        }
        else{
            n/=3;n++;
        }
        t++;
    }
    printf("%d\n",t);
    return 0;
}

Measured memory_bytes: 596
#include<stdio.h>

int main(void){
    int A, B;
    char op;
    scanf("%d %c %d", &A, &op, &B);
    if(op == '+'){
        printf("%d\n",(A+B));
    }else{
        printf("%d\n",(A-B));
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	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 operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////



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

	ll ans;
	if (B - 1 > N) { ans = A * N / B; }
	else { ans = A * (B - 1) / B; }

	cout << ans << endl;
	
	system("PAUSE");
}


Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
using namespace std;
int n, a, c[126]; long long s;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a; s += a;
		for (int i = 1; i <= 125 && i <= a; i++) c[i]++;
	}
	for (int i = 1; i <= 125; i++) s -= max(c[i] - i * 4, 0);
	cout << s + 1 << endl;
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#define cpp mp::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
	int to;
	ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	int N, M;
	cin >> N >> M;
	if (M <= N) {
		cout << 0 << endl;
		return 0;
	}
	int X[100000];
	rep(i, M) {
		cin >> X[i];
	}
	sort(X, X + M);
	vector<int> y;
	for (int i = 1; i < M; i++) {
		y.push_back(X[i] - X[i - 1]);
	}
	sort(y.begin(), y.end());
	int ans = 0;
	rep(i, M - N) {
		ans += y[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 1276
#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 mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

ll DP[4][3005][3005];

int main() {
  int R, C, K;
  cin>>R>>C>>K;
  ll arr[R][C];
  for(int i=0;i<R;++i) {
    for(int j=0;j<C;++j) {
      arr[i][j] = 0;
    }
  }
  int r, c;
  ll v;
  for(int i=0;i<K;++i) {
    cin>>r>>c>>v;
    r--;
    c--;
    arr[r][c] = v;
  }
  if(arr[0][0]>0) {
    DP[1][0][0] = arr[0][0];
    DP[2][0][0] = arr[0][0];
    DP[3][0][0] = arr[0][0];
  }
  for(int j=1;j<C;++j) {
    for(int k=1;k<=3;++k) {
      DP[k][0][j] = max(DP[k-1][0][j-1]+arr[0][j], DP[k][0][j-1]);
    }
  }

  for(int i=1;i<R;++i) {
    DP[0][i][0] = DP[3][i-1][0];
    for(int k=1;k<=3;++k) {
      DP[k][i][0] = DP[3][i-1][0]+arr[i][0];
    }
  }
  for(int i=1;i<R;++i) {
    for(int j=1;j<C;++j) {
      DP[0][i][j] = DP[3][i-1][j];
      DP[1][i][j] = DP[3][i-1][j]+arr[i][j];
      for(int k=1;k<=3;++k) {
        DP[k][i][j] = max(DP[k][i][j], max(DP[k][i][j-1], max(DP[k-1][i][j-1]+arr[i][j], DP[k-1][i][j])));
      }
    }
  }
  cout<<DP[3][R-1][C-1]<<endl;
}



Measured memory_bytes: 355556
/*
ID: y1197771
PROG: test
LANG: C++
*/
#include<bits/stdc++.h>
#define pb push_back
#define FOR(i, n) for (int i = 0; i < (int)n; ++i)
#define dbg(x) cout << #x << " at line " << __LINE__ << " is: " << x << endl
typedef long long ll;
using namespace std;
typedef pair<int, int> pii;
const int maxn = 1e3 + 10;
int h, w;
string s[110];
void solve() {
    while(cin >> h) {
        cin >> w;
        for (int i = 0; i < h; i++)
            cin >> s[i];
        for (int i = 0; i < h; i++) {
            cout << s[i] << endl;
            cout << s[i] << endl;
        }
    }
}
int main() {
    //freopen("test.in", "r", stdin);
    //freopen("test.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


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

int min(int x,int y){
	return x<y? x: y;
}

int main(void){
	int N,K,ans=0,i,p=1e9;
	scanf("%d%d",&N,&K);
	int x[N],kouho[K];
	int set,left,right;
	for(i=0;i<N;i++){scanf("%d",&x[i]);}
	
	for(i=0;i<N-K+1;i++){
		set = 0;
		ans = 0;
		int j = i;
		while(set<K){//K個
			kouho[set] = x[j];
			set++;
			j++;
		}
		left = kouho[0];
		right = kouho[K-1];
		ans += min(abs(left),abs(right));
		ans += abs(right - left);
		if(ans<p) p = ans;
	}
	
	
	printf("%d",p);
	
	return 0;
}

Measured memory_bytes: 896
import math
from decimal import Decimal

num = list(map(int,input().split()))

'''
誤差でアウト

a = num[0]**0.5
b = num[1]**0.5
c = num[2]**0.5

if math.sqrt(num[0]) + math.sqrt(num[1]) < math.sqrt(num[2]):
    print("Yes")
else:
    print("No")
'''


a = num[0]
b = num[1]
c = num[2]

if (c-(a+b))**2 - 4*a*b > 0 and c-a-b > 0:
    print("Yes")
else:
    print("No")

'''
誤差を小さくするテクニックらしいが，これでもダメだった
if (c**2 - (a+b)**2)/(c+a+b) > 0:
    print("Yes")
else:
    print("No")
'''

Measured memory_bytes: 5076
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    int n;
    cin>>n;

    vi a(n+1), b(n);
    int sum = 0;

    for(int &x:a) {cin>>x; sum+=x;}
    for(int &x:b) cin>>x;

    for(int i=0;i<n;i++){
        int temp = a[i];
        a[i] = max(a[i] - b[i], 0LL);
        b[i] -= temp;
        // cout<<b[i]<<endl;

        if(b[i] > 0){
            a[i+1] = max(a[i+1] - b[i], 0LL);
        }
    }

    // for(int x:a) cout<<x<<' ';
    //     cout<<endl;

    for(int i=0;i<n+1;i++) sum-=a[i];

    cout<<sum;
} 

Measured memory_bytes: 1792
#include <iostream>

using namespace std;

int main() {
    int n, m;   cin >> n >> m;
    int *c = new int[m];
    for (int i = 0; i < m; i++)
        cin >> c[i];

    int *dp = new int[n+1];
    for (int i = 0; i <= n; i++)
        dp[i] = 1000000;
    dp[0] = 0;

    for (int i = 0; i < m; i++) {
        for (int j = 0; j <= n; j++) {
            if (j >= c[i])
                dp[j] = min(dp[j-c[i]]+1, dp[j]);
        }
    }

    cout << dp[n] << endl;

    return 0;
}


Measured memory_bytes: 3324
// inputに入力データ全体が入る
function Main(input) {
  var input = input.split(' ')
  var a = Number(input[0])
  var b = Number(input[1])
  if (a > 9 || b > 9){
    console.log(-1)
  	return;
  }
  var result = a * b;
  console.log(result);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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

int main()
{
	int T=1;
	// cin >> T ;

	while(T--)
	{
		string s,t ;
		cin>>s>>t ;

		int n=s.size() , m=t.size() ;
		int dp[n+1][m+1] ;
		for(int i=0 ; i<=n; i++)
		{
			for(int j=0 ; j<=m ; j++)
			{
				if(!i || !j) { dp[i][j]=0 ; continue ; }
				if(s[i-1]==t[j-1]) dp[i][j] = 1+dp[i-1][j-1] ;
				else dp[i][j]=max(dp[i-1][j],dp[i][j-1]) ; 
			}
		}

		int i=n , j=m ;
		string ans ;
		while(dp[i][j])
		{
			if(s[i-1]==t[j-1])
			{
				ans.push_back(s[i-1]) ;
				i-- ;
				j-- ;
			}
			else if(dp[i-1][j]>dp[i][j-1]) i-- ;
			else j-- ;
		}
		reverse(ans.begin(),ans.end()) ;
		cout<<ans<<endl ;
	}
	return 0;
}

Measured memory_bytes: 38800
#include <bits/stdc++.h>
using namespace std;
// #define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

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

signed main(){
	int n;
	cin>>n;
	vi cnt(9,0);
	rep(_,n){
		int a;cin>>a;
		if(a>=3200){
			a=3200;
		}
		cnt[a/400]++;
	}
	int ans=0;
	rep(i,8) if(cnt[i]>0)ans++;

	cout<<max(ans,1)<<' '<<ans+cnt[8]<<endl;
	


	return 0;
}



Measured memory_bytes: 3588
#include <iostream>

int main() {
    int x, y;
    std::cin >> x;
    std::cin >> y;
    if (x < y) {
        std::cout << 'a' << " < " << 'b' << '\n';
    } else if (x > y) {
        std::cout << 'a' << " > " << 'b' << '\n';
    } else {
        std::cout << 'a' << " == " << 'b' << '\n';
    }
    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
typedef long long ll;
#define fr first
#define sc second
#define int ll

using namespace std;
const int MN = 4e2+7;
const int MK = 1e5+7;
const int MOD = 1e9+7;

int a[MN];
int s[MN][MN], dp[MN][MN];

signed main(){
    int n, k;
    cin >> n;
    for(int i = 0; i < n; i++)cin >> a[i];
    for(int i = 0; i < n; i++){
        for(int j = i; j < n; j++){
            if(i == j)s[i][j] = a[i];
            else{
                s[i][j] = s[i][j-1] + a[j];
            }
        }
    }
    for(int z = 0; z < n; z++){
        for(int l = 0; l+z < n; l++){
            int r = l+z;
            if(l == r){
                dp[l][r] = 0;
                continue;
            }
            dp[l][r] = 1e18+7;
            for(int i = 1; i <= r-l; i++){
                dp[l][r] = min(dp[l][r], s[l][l+i-1] + s[l+i][r] + dp[l][l+i-1] + dp[l+i][r]);
            }
            //cout << l << ' ' << r << " : " << dp[l][r] << endl;
        }
    }
    cout << dp[0][n-1];
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define rep(i, n)    for(ll i = 0; i < (n); ++i)
#define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
#define repD(i, a, n)  for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fill(a)  memset(a, 0, sizeof (a))
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll tt=1;
    // cin >> tt;
    while((tt)--){
      ll a ,b; cin >> a >> b;
      if(a%b!=0){
            cout << a/b+1 << endl;
      }else{
        cout << a/b << endl;
      }
    }
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MON 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

class Vec{
public:
  double x, y;
  Vec(double x = 0, double y = 0):x(x),y(y){}

  void read(){
    cin >> x >> y;
  }
  
  Vec operator+(const Vec &other)
  {
    Vec result = *this;
    result.x += other.x;
    result.y += other.y;
    return result;
  }

  Vec operator-(const Vec &other)
  {
    Vec result = *this;
    result.x -= other.x;
    result.y -= other.y;
    return result;
  }

  Vec operator*(const float &k)
  {
    Vec result = *this;
    result.x *= k;
    result.y *= k;
    return result;
  }

  Vec operator/(const float &k)
  {
    Vec result = *this;
    result.x /= k;
    result.y /= k;
    return result;
  } 
  
  double cross(const Vec &other)
  {
    return x*other.y - y*other.x;
  }

  double dot(const Vec &other){
    return x*other.x + y*other.y;
  }
  
  bool operator==(const Vec &other) const
  {
    return abs(x - other.x) < EPS && abs(y - other.y) < EPS;
  }

  float norm()
  {
    return sqrt(x*x+y*y);
  }

  float norm2()
  {
    return x*x+y*y;
  }

  Vec standard(){
    Vec result = *this;
    return result/result.norm();
  }
};

class Line{
public:
  Vec a, b;
  Vec vect;
  Line(Vec a = Vec(), Vec b = Vec()):a(a),b(b),vect(b-a){}

  //projection
  Vec proj(Vec p){
    p = p - a;
    return a + vect * vect.dot(p) / vect.norm2();
  }

  //reflection
  Vec reflect(Vec p){
    return proj(p) * 2 - p;
  }

  bool onSegment(Vec p){
    return abs((p-a).cross(b-a)) < EPS && (p-a).dot(p-b) < EPS;
  }
};


//ccw:1, cw:-1, other:0
Int CCW(Vec a, Vec b, Vec c){
  b = b - a;
  c = c - a;
  if(b.cross(c) > EPS)return -1;
  if(b.cross(c) < -EPS)return 1;
  return 0;
}

int main(){
  Int q;
  cin >> q;
  while(q--){
    Vec p0, p1, p2, p3;
    p0.read();
    p1.read();
    p2.read();
    p3.read();
    Vec s1 = p1 - p0;
    Vec s2 = p3 - p2;
    if(abs(s1.cross(s2)) < EPS)cout << 2 << endl;
    else if(abs(s1.dot(s2)) < EPS)cout << 1 << endl;
    else cout << 0 << endl;
  }
  return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-5;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

int main(void) {
	double T, X;
	cin >> T >> X;
	cout << fixed << setprecision(10) << T/X << endl;
}


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

#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define bug(x) cerr<<#x<<" is "<<x<<endl

using namespace std;

#define int ll

const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"No\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b) % mo;
}

const int maxn = 1e5+5;



main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n; cin>>n;
    vector<int> a(n);
    int x;
    REP(i,n) cin>>x, a[x-1]=i;
    vector<int> A(n),B(n);
    REP(i,n){
        if (i!=0){
            int d = a[i] - a[i-1];
            A[i] = B[i-1] = 1;
            if (d>0) A[i] +=d; else B[i-1]-=d;
        }
    }
    B[n-1] = 1;
    RREP(i,n-1) B[i] += B[i+1];
    A[0] = 1;
    FOR(i,1,n) A[i] += A[i-1];
    REP(i,n) cout<<A[i]<<" \n"[i==n-1];
    REP(i,n) cout<<B[i]<<" \n"[i==n-1];
} 

Measured memory_bytes: 1152
// finish date: 2018/04/15

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int N;
    cin >> N;
    vi a(N);
    rep(i, N) cin >> a[i];
    vi X = a;
    sort(X.begin(), X.end());
    int val1 = X[N / 2 - 1];
    int val2 = X[N / 2];
    rep(i, N) {
        if (a[i] <= val1) cout << val2 << endl;
        else cout << val1 << endl;
    }

    return 0;
}

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

using namespace std;
 
typedef long long ll;


int take_box[8] = {0};
int sum_take[3] = {0};

int main(){
    int n;
    cin >> n;
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> l;
    for(int i = 0; i < n; i++)
    {
        int tmp;
        cin >> tmp;
        l.push_back(tmp);
    }
    

    int loop = 1 << (n*2);
    //cout << loop << endl;

    
    int ans = 1 << 16;
    for(int i = 0; i < loop; i++)
    {
        int unused_cnt = 0;
        int score = 0;
        int tmp = i;
        sum_take[0] = 0;
        sum_take[1] = 0;
        sum_take[2] = 0;
        for(int j = 0; j < n; j++)
        {
            take_box[j] = (tmp >> (j*2)) % 4;
        }
        for(int j = 0; j < n; j++)
        {
            if (take_box[j] == 3){
                unused_cnt++;
                continue;    
            }    
            sum_take[take_box[j]] += l[j];
        }
        if (sum_take[0] == 0 || sum_take[1] == 0 || sum_take[2] == 0){
            continue;
        }
        score += sum_take[0] > a ? sum_take[0] - a : a - sum_take[0];
        score += sum_take[1] > b ? sum_take[1] - b : b - sum_take[1];
        score += sum_take[2] > c ? sum_take[2] - c : c - sum_take[2];
        score += (n - unused_cnt - 3 ) * 10;
        ans = min(score, ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<set>
using namespace std;

int n,a[200005];
set<int> s;
set<int>::iterator it;

int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	if (a[1]) {puts("-1");return 0;}
	for (int i=2;i<=n;i++) if (a[i]>a[i-1]+1) {puts("-1");return 0;}
	
	int cnt=0;
	long long ans=0;
	for (int i=n;i>=2;i--,cnt++) 
	{
		s.insert(a[i]+cnt);
		while (!s.empty())
		{
			it=s.begin();
			if ((*it)<=cnt) s.erase(it);else break;
		}
		ans+=s.size();
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
 
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
/* (๑╹◡╹) */
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll MOD = 1000000007;
template<class T>
inline bool chmin(T &a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
 /* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)*/
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
/* (๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹)(๑╹◡╹) */
///////////////////////////////////////////////
const int MAX = 510000;
 
long long fac[MAX], finv[MAX], inv[MAX];
 



int main() {
	int ans = 0;
	int A,B; cin >> A >> B;
	ans = max(A+B,max(A-B,A*B));
	
	
	cout << ans << endl;
}


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

vector<pll> A;
bool cmp(pll a, pll b) { return a.second < b.second; }

int main() {
    ll N, M;
    cin >> N >> M;
    A.resize(M); //配列の個数を変える
    rep(i,M) cin >> A[i].first >> A[i].second;
    sort(A.begin(), A.end(), cmp);
    ll ans = 0;
    ll end = 0;
    rep(i,M){
        if (A[i].first >= end) {
            end = A[i].second;
            ++ans;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  
  vector<int> b(n);
  if (n % 2 == 0) {
    rep(i, n / 2) {
      b[i] = a[n - 1 - 2 * i];
      b[n / 2 + i] = a[2 * i];
    }
  } else {
    b[n / 2] = a[0];
    rep(i, n / 2) {
      b[i] = a[n - 1 - 2 * i];
      b[n / 2 + 1 + i] = a[2 * i + 1];
    }
  }
  printf("%d", b[0]);
  for (int i = 1; i < n; ++i) printf(" %d", b[i]);
  printf("\n");
  return 0;
}

Measured memory_bytes: 4852
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
bool comp[N];
int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
cin>>n;
vector<char> is_prime(5*n+1, true);
is_prime[0] = is_prime[1] = false;
for (int i = 2; i <= 5*n; i++) {
    if (is_prime[i] && (long long)i * i <= 5*n) {
        for (int j = i * i; j <= 5*n; j += i)
            is_prime[j] = false;
    }
    if(is_prime[i]&&i>=n)
    {
    	cout<<i;
    	break;
	}
}
}






Measured memory_bytes: 768
//05
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    double h=-1,l=1<<30,sum=0;
    for(int i=0;i<n;i++){
      double s;
      cin>>s;
      sum+=s;
      h=max(s,h);
      l=min(s,l);
    }
    cout<<int((sum-h-l)/(n-2))<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }
const int VX[] = { 0, 1, 0, -1 };
const int VY[] = { 1, 0, -1, 0 };
const long MOD = 1000000007;

typedef long long ll;

int main()
{
	//	--- I/O 高速化 ---
	cin.tie(0);
	ios::sync_with_stdio(false);
	// --- ここまで ---

	int N;
	cin >> N;

	vector<int> a(3 * N);
	REP(i, 3 * N)
	{
		cin >> a[i];
	}

	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());

	ll ret = 0;

	for (int i = 1; i < 2 * N; i += 2)
	{
		ret += a[i];
	}

	cout << ret << endl;
	
	return 0;
}



Measured memory_bytes: 1408
h,w=map(int,input().split())
field=[list(input()) for i in range(h)]

l=[[0]*w for i in range(h)]
r=[[0]*w for i in range(h)]
u=[[0]*w for i in range(h)]
d=[[0]*w for i in range(h)]

for i in range(h):
    for j in range(w):
        if field[i][j]=="#":
            l[i][j]=0
        elif j==0:
            l[i][j]=1
        else:
            l[i][j]=l[i][j-1]+1

for i in range(h):
    for j in reversed(range(w)):
        if field[i][j]=="#":
            r[i][j]=0
        elif j==w-1:
            r[i][j]=1
        else:
            r[i][j]=r[i][j+1]+1

for i in range(h):
    for j in range(w):
        if field[i][j]=="#":
            u[i][j]=0
        elif i==0:
            u[i][j]=1
        else:
            u[i][j]=u[i-1][j]+1

for i in reversed(range(h)):
    for j in range(w):
        if field[i][j]=="#":
            d[i][j]=0
        elif i==h-1:
            d[i][j]=1
        else:
            d[i][j]=d[i+1][j]+1

ans=0
for i in range(h):
    for j in range(w):
        tmp=l[i][j]+r[i][j]+u[i][j]+d[i][j]-3
        ans=max(ans,tmp)
print(ans)


Measured memory_bytes: 309384
#include <iostream>

using namespace std;

int main () {
	long long x, y, z, n = 0;
	cin >> x;
	y = x / 11;
	z = x % 11;
	n += y * 2;

	if(z <= 6 && z > 0){
		n += 1;
	}else if(z > 6){
		n += 2;
	}

	cout << n << endl;

}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from operator import itemgetter

# 区間スケジューリング

N = int(readline())
m = map(int,read().split())
XL = zip(m,m)

LR = [(x-l,x+l) for x,l in XL]
LR.sort(key = itemgetter(1))

INF = 10 ** 18
prev_R = -INF
cnt = 0
for L,R in LR:
    if prev_R > L:
        continue
    cnt += 1
    prev_R = R

print(cnt)

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  int64_t answer = numeric_limits<int64_t>::max();
  for (int i = 0; i < (1 << N); i++) {
    if (__builtin_popcount(i) != K) continue;

    int64_t total = 0;
    int64_t prev = 0;
    for (int j = 0; j < N; j++) {
      if (i & (1 << j)) {
        int64_t target = max(prev + 1, A[j]);
        total += target - A[j];
        prev = target;
      } else {
        prev = max(prev, A[j]);
      }
    }
    answer = min(total, answer);
  }
  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

// ABC 27-C
// http://abc027.contest.atcoder.jp/tasks/abc027_c
 
public class Main {
	
	public static void main (String[] args) throws java.lang.Exception {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		long k = in.nextLong();
		
		long[] counts = new long[100001];
		
		for (int i = 0; i < n; i++) {
			int a = in.nextInt();
			long b = in.nextLong();
			
			counts[a] += b;
		}
		
		int answer = 0;
		long counter = 0;
		while (counter < k) {
			counter += counts[answer];
			answer++;
		}
		
		System.out.println(answer - 1);
		
//		HashMap<Integer, Long> count = new HashMap<Integer, Long>();
//		ArrayList<Integer> keys = new ArrayList<Integer>();
//		
//		for (int i = 0; i < n; i++) {
//			int a = in.nextInt();
//			long b = in.nextLong();
//			
//			if (keys.indexOf(a) >= 0) {
//				b += count.get(a);
//			} else {
//				keys.add(a);
//			}
//			count.put(a, b);
//		}
//		
//		
//		keys.sort(null);
//		
//		int index = 0;
//		long counter = 0;
//		
//		while (true) {
//			counter += count.get(keys.get(index));
//			if (counter < k) {
//				index++;
//			} else {
//				break;
//			}
//		}
//		
//		System.out.println(keys.get(index));
	}
}

Measured memory_bytes: 65468