akhauriyash/Code-Regression huggingface dataset:
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

template <typename T>
void make_unique(vector<T>& vec) {
  sort(all(vec));
  vec.erase(unique(all(vec)), vec.end());
}

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

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


ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    cout<<10-(nxt()/200)<<endl;
	printclock;
	return 0;
}

Measured memory_bytes: 3808
#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>
using namespace std;

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

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

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;
}

//gcd,lcm,べき,二進展開
//組み合わせ、mod計算
//最短路問題、bit、union find

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

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

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

// 二項係数計算

long long 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;
}



int main() {

	COMinit();

	
	ll N, K;
	cin >> N >> K;
	ll a[100];
	repn(i, K) cin >> a[i];

	ll dp[100][2000] = {};

	rep(i, N + 1) { dp[1][i] = COM(N, a[1])*COM(a[1], i) % MOD; 
	}

	for (int i = 2; i <= K; i++) {
		rep(j, N+1) {
			rep (k, j + 1) {
				dp[i][j] += COM(N - k, j - k)*COM(N - j + k, a[i] - j + k) % MOD*dp[i - 1][k] % MOD;
				dp[i][j] %= MOD;
				
			}
			
		}
	}

	cout << dp[K][N];



	system("PAUSE");


}


Measured memory_bytes: 25464
#include <iostream>
#include <vector>

using namespace std;
const long long mod=1e9+7;
 
int main(){
  int N, M;
  cin >> N >> M;
 
  //  0段目があるので、N+1の配列を用意し、
  //  壊れていない階段をtrue=1、壊れている階段をfalse=0で初期化。
  //  これを使ってスキップの処理を行う。
  vector<int> oks(N + 1, true);
  for(int i = 0; i < M; ++i) {
    int a;
    cin >> a;
    oks[a] = false;
  }

  //  0~N段目までの"通り数"を入れる配列
  vector<long long int> dp(N + 1);

  //  0段目を1で初期化
  dp[0] = 1;
 
  for(int now = 0; now < N; ++now){
    //  ここがポイント。
    //  階段が壊れていなければ、ここのfor loopはi = N - 1 を除いて二回、i = N - 1のときは一回実行される。
    //  この二回の実行の繰り返しによって上記の漸化式が実装でされることになる。
    //  以下に簡単なイメージ図を添付。  
    for(int next = now + 1; next <= min(N, now + 2); ++next){
      //  最初に作ったoks配列を用いることで壊れている床をスキップする。
      if (oks[next]) {
        //  漸化式。
        dp[next] += dp[now];

        //  期待される出力のためにmodで割る。
        dp[next] %= mod;
      }
     }
   }

   // 求めたいN番目の通り数を出力。
   cout << dp[N] << endl;
   return 0;
}


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

#define mp make_pair
#define X first
#define Y second
#define FOE(x, a) for(auto x : a)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FOD(i, a, b) for(int i = a; i >= b; i--)

using namespace std;

typedef long long ll;
typedef pair <int, int> ii;

const int N = 101;
const int X = 510;
const int MOD = 1e9 + 7;

int n, x, d[X];
int F[X][X][X], C[X][X];

void add(int &x, int y){
    x += y;
    x -= (x >= MOD) * MOD;
}

void sub(int &x, int y){
    x -= y;
    x += (x < 0) * MOD;
}

int powMod(int n, int k){
    assert(n >= 0);
    if (k == 0)
        return 1;
    int res = powMod(n, k >> 1);
    res = (ll) res * res % MOD;
    if (k & 1)
        res = (ll) res * n % MOD;
    return res;
}

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

    cin >> n >> x;
    FOR(i, 1, n){
        int l;
        cin >> l;
        d[l]++;
    }

    FOR(i, 0, x){
        C[i][0] = 1;
        FOR(j, 1, i){
            add(C[i][j], C[i - 1][j]);
            add(C[i][j], C[i - 1][j - 1]);
        }
    }

    F[x + 1][0][0] = 1;
    FOD(i, x + 1, 1)
        FOR(j, 0, x)
            FOR(s, j * i, x)
                FOR(k, 0, x - j){
                    if (s + k * (i - 1) > x)
                        break;
                    add(F[i - 1][j + k][s + k * (i - 1)], (ll) F[i][j][s] * C[j + k][k] % MOD * powMod(s - (i - 2) * j + k, d[i - 1]) % MOD);
                }

    int ans = 0;
    FOR(i, 0, x - 1){
        int val = F[0][i + 1][x - i];
        if (i & 1)
            sub(ans, val);
        else
            add(ans, val);
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 14984
#include <bits/stdc++.h>
#define ll long long
#define str string
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define SET(x, y) memset(x, y, sizeof x)
#define ff fflush(stdout)
using namespace std;
int main () {
  ll a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q;
  scanf("%lld %lld", &a, &b);
  a += b; a %= 24;
  printf("%lld\n", a);
  return 0;
}

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

const double pi = acos(-1);

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm

    int R;
    cin >> R;

    cout << fixed << setprecision(4) << 2.0*pi*R << "\n";

    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++)
    {
        cin >> vec.at(i);
    }
    int count = 0;

    while(true)
    {
        bool even = true;
        for (int i = 0; i < n; i++)
        {
            if (vec.at(i) % 2 != 0) even = false;
        }
        if (!even) break;
        for (int i = 0; i < n; i++)
        {
            vec.at(i) /= 2;
        }
        count ++;
    }
    
    cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

int main()
{
    string S,T;
    cin >> S;
    cin >> T;
    int count=0;
    rep(i,S.length()){
        if(S[i]!=T[i])count++;
    }  
    cout << count << endl;
}

Measured memory_bytes: 3836
import sys
def input():
	return sys.stdin.readline()[:-1]
from collections import deque
H, W, K = map(int, input().split())
sh, sw, gh, gw = map(int, input().split())
c = ["@" * (W+2)] + ["@" + input() + "@" for _ in range(H)] + ["@" * (W+2)]
INF = 10**6+5
dist = [[INF for _ in range(W+2)] for _ in range(H+2)]
dist[sh][sw] = 0
q = deque()
q.append(sh*(W+2)+sw)
DI = [1, 0, -1, 0]
DJ = [0, 1, 0, -1]
while q:
	l = q.popleft()
	i, j = l//(W+2), l%(W+2)
	for di, dj in zip(DI, DJ):
		for k in range(1, K+1):
			ii, jj = i+di*k, j+dj*k
			if c[ii][jj] == "@":
				break
			if dist[ii][jj] <= dist[i][j]:
				break
			if dist[ii][jj] > dist[i][j] + 1:
				dist[ii][jj] = dist[i][j] + 1
				if ii == gh and jj == gw:
					print(dist[ii][jj])
					sys.exit()
				q.append(ii*(W+2) + jj)
print(-1)

Measured memory_bytes: 166644
#include <bits/stdc++.h>
#define fio     ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define pi      3.14159265
#define ll      long long
#define repe    ll tc,cas=0;cin>>tc;while(tc--)
#define op      freopen("output.txt", "w", stdout);
using namespace std;

int a[101];

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

    int mx = -1;
    for(int i=0;i<n;i++){
        cin >> a[i];
        mx = max(mx, a[i]);
    }
    ll ans = 0;
    for(int i = 1; i <= mx; i++){
        bool chk = 0;
        for (int j = 0; j < n; j++){
            if (a[j] >= i and !chk){
                chk = 1;
            }
            else if (a[j] < i and chk){
                chk = 0;
                ans++;
            }
        }
        if (chk) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;
ll mod = 1000000007;

int main() {
    int n,k;
    scanf("%d %d",&n,&k);
    string s;
    cin >> s;
    vector<int> ls,rs;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            if (s[i] == 'L') ls.push_back(i);
            else rs.push_back(i);
        } else if (s[i - 1] != s[i]) {
            if (s[i] == 'L') ls.push_back(i);
            else rs.push_back(i); 
        }
    }
    int kukan = min(ls.size(),rs.size());
    int ans = 0; 
    if (k >= kukan) ans = n - 1;
    else {
        //if (kukan == ls.size()) {
        //    int cnt = 0;
        //    while(k - cnt) {
        //        int i = 0;
        //        while(s[ls[cnt + i]] == 'L') {
        //          s[ls[cnt+i]] = 'R';
        //          i++; 
        //          if (cnt + i >= n) break;
        //        }
        //        cnt++;
        //    }
        //} else {
        //    int cnt = 0;
        //    while(k - cnt) {
        //        int i = 0;
        //        while(s[rs[cnt + i]] == 'R') {
        //          s[rs[cnt+i]] = 'L';
        //          i++; 
        //          if (cnt + i >= n) break;
        //        }
        //        cnt++;
        //    }
        //}
        if (s[0] == 'L') {
            int cnt = 0;
            while(k - cnt) {
                if (cnt > rs.size()) break;
                int i = rs[cnt];
                while(s[i] == 'R') {
                  s[i] = 'L';
                  i++; 
                  if (i >= n) break;
                }
                cnt++;
            }    
        } else {
            int cnt = 0;
            while(k - cnt) {
                if (cnt > ls.size()) break;
                int i = ls[cnt];
                while(s[i] == 'L') {
                  s[i] = 'R';
                  i++; 
                  if (i >= n) break;
                }
                cnt++;
            }
        }
        for (int i = 0; i < n; i++) {
            if (s[i] == 'L') {
                if (i > 0 && s[i-1]=='L') ans++;
            } else {
                if (i < n - 1 && s[i+1] == 'R') ans++;
            }
        } 
    }
    printf("%d\n",ans); 
}

Measured memory_bytes: 1020
#include <iostream>
#include <cstdio>
#include <iomanip>

#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>

#include <numeric>
#include <algorithm>
#include <functional>

#include <cctype>

#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(unsigned int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> P;
const int dx[] = {1,0,-1,0};
const int dy[] = {0,-1,0,1};
const double EPS = 1e-9;
const int days[] = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    int N;
    cin >> N;
    map<string,bool> U;
    rep(i,N){
        string u;
        cin >> u;
        U[u] = true;
    }
    int M;
    cin >> M;
    vector<string> T(M);
    rep(i,M) cin >> T[i];
    bool open = false;
    rep(i,M){
        string s = T[i];
        if(U.find(s) != U.end()){
            if(open){
                cout << "Closed by " << s << endl;
            }else{
                cout << "Opened by " << s << endl;
            }
            open = !open;
        }else{
            cout << "Unknown " << s << endl;
        }
    }
    return 0;
}

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

int main () {
    int n, m;
    scanf("%d%d", &n, &m);
    pair<int, int> l[m];
    for (int a=0; a<m; a++) {
        int x, y;
        scanf("%d%d", &x, &y);
        l[a] = pair<int, int>(y, x);
    }
    sort(l, l+m);
    int ret = 0; 
    int last = -1;
    for (int i=0; i<m; ) {
        int j = i+1;
        while (j < m && l[i].first == l[j].first)
            j++;
        if (l[j-1].second >= last) {
            ret++;
            last = l[j-1].first;
        }
        i = j;
    }
    cout << ret << endl;
}

Measured memory_bytes: 1024
a, b, k = gets.split.map(&:to_i)

#自分のだけで満足
if a >= k
  a = a-k
#青木くんのに手を出して満足
elsif a+b >= k
  b = b - (k-a)
  a = 0

#全部食べて満足しない
else
  a = 0
  b = 0
end

puts "#{a} #{b}"

Measured memory_bytes: 14228
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;
}
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " <<to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void solve(){
    ll n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    ll cnt=1,ans=0;
    rep(i,n){
      if(a[i]!=cnt)++ans;
      else ++cnt;
    }
    if(cnt==1)cout<<-1<<"\n";
    else cout<<ans<<"\n";
}
 
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i=0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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 ll INF = 1LL << 60;
//cout << fixed << setprecision(10);

int main(){
    ll n, cnt=0, a, b; cin>>n;
    vector<ll> v(n), p(n), q(n);
    rep(i,n) v[i]=i+1;
    rep(i,n) cin>>p[i];
    rep(i,n) cin>>q[i];
    bool findp=false, findq=false;
    do{
        cnt++;
        if(findp && findq) break;
        if(!findp){
            rep(i,n){
                if(v[i]!=p[i]) break;
                if(i==n-1) findp=true, a=cnt;
            }
        }
        if(!findq){
            rep(i,n){
                if(v[i]!=q[i]) break;
                if(i==n-1) findq=true, b=cnt;
            }
        }
    }while(next_permutation(all(v)));
    cout<<abs(a-b);
}

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

int K; string S;
void input()
{
    cin>>K>>S;
}

void solve()
{
    if(S.length()<=K) cout<<S<<endl;
    else{
        for(int i=0;i<K;++i) cout<<S[i];
        cout<<"..."<<endl;
    }
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

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

using namespace std;

char s[300][301];
int sum1[600][301];
int sum2[600][301];

int get1(int p, int l, int r) {
    l = max(l, 0);
    r = min(r + 1, 300);
    
    if (p < 0 || p >= 600) return 0;
    
    return sum1[p][r] - sum1[p][l];
}

int get2(int p, int l, int r) {
    p += 300;
    l = max(l, 0);
    r = min(r + 1, 300);
    
    if (p < 0 || p >= 600) return 0;
    
    return sum2[p][r] - sum2[p][l];
}

int main() {
    int h, w, i, j, k;
    long long ans = 0;
    
    scanf("%d %d", &h, &w);
    
    for (i = 0; i < h; i++) scanf("%s", s[i]);
    
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            if (s[i][j] == '#') {
                sum1[i + j][i + 1]++;
                sum2[i - j + 300][i + 1]++;
            }
        }
    }
    
    for (i = 0; i < 600; i++) {
        for (j = 1; j <= 300; j++) {
            sum1[i][j] += sum1[i][j - 1];
            sum2[i][j] += sum2[i][j - 1];
        }
    }
    
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            if (s[i][j] == '.') continue;
            
            for (k = 1; ; k++) {
                int x = i + k;
                int y = j - k;
                
                if (x >= h || y < 0) break;
                if (s[x][y] == '.') continue;
                
                ans += get1(i + j - k * 2, i - k, i);
                ans += get1(i + j + k * 2, x, x + k);
            }
            
            for (k = 1; ; k++) {
                int x = i + k;
                int y = j + k;
                
                if (x >= h || y >= w) break;
                if (s[x][y] == '.') continue;
                
                ans += get2(i - j - k * 2, i - k, i);
                ans += get2(i - j + k * 2, x, x + k);
            }
            
            for (k = 1; i + k * 2 < h; k++) {
                if (s[i + k * 2][j] == '.') continue;
                
                if (j - k >= 0 && s[i + k][j - k] == '#') ans--;
                if (j + k < w && s[i + k][j + k] == '#') ans--;
            }
            
            for (k = 1; j + k * 2 < w; k++) {
                if (s[i][j + k * 2] == '.') continue;
                
                if (i - k >= 0 && s[i - k][j + k] == '#') ans--;
                if (i + k < h && s[i + k][j + k] == '#') ans--;
            }
        }
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0){ break; }
		int minval = INT_MAX, maxval = 0, sum = 0;
		for(int i = n; i > 0; --i){
			int s;
			cin >> s;
			minval = min(s, minval);
			maxval = max(s, maxval);
			sum += s;
		}
		cout << (sum - minval - maxval) / (n - 2) << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <map>
using namespace std;
map<string, int> table;
int main()
{
	string word, frequent, longest;
	size_t N = 0;
	while (cin >> word)
	{
		table[word]+=1;
		if (table[word] > N) 
		{
			frequent = word; 
			N = table[word];
		}
		if (word.size() > longest.size())longest = word;
	}
	cout << frequent <<' '<< longest << endl;
	return 0;
}


Measured memory_bytes: 3088
import java.util.Map;
import java.util.Scanner;

public class Main {

    /**
     * 本処理を実行します。
     */
    public static void execute() {
        Scanner sc = new Scanner(System.in);

        int n = nextInt(sc);

        int odd = 0;
        int even = 0;

        for (int i = 0; i < n; i++) {
            int a = nextInt(sc);
            if ((a & 1) == 1) {
                // 奇数
                odd++;
            } else {
                // 偶数
                even++;
            }

        }

        if (odd == n) {
            out((int)Math.pow(3, n) - 1);
        } else if (even == n) {
            out((int)Math.pow(3, n) - (int)Math.pow(2, n));
        } else {
            out ((int)Math.pow(3, n) - (int)Math.pow(2, even));
        }
    }

    /**
     * 次の標準入力をintで受け取ります。
     * @return 標準入力値(int)
     */
    public static int nextInt(Scanner sc) {
        return sc.nextInt();
    }

    /**
     * 次の標準入力をStringで受け取ります。
     * @return 標準入力値(String)
     */
    public static String nextString(Scanner sc) {
        return sc.next();
    }

    /**
     * 次の標準入力を指定回数分intで受け取ります。
     * @param n 取得回数
     * @return 取得した標準入力値の配列(int)
     */
    public static int[] nextInts(Scanner sc, int n) {
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = nextInt(sc);
        }

        return arr;
    }

    /**
     * 標準出力にオブジェクトを出力します。
     * @param o 出力対象
     */
    public static void out(Object o) {
        System.out.println(o);
    }

    public static void main(String[] args) {
        execute();
    }

    public static void putCountMap(Map<Integer, Integer> map, int value) {
        if (map.containsKey(value)) {
            map.put(value, map.get(value) + 1);
        } else {
            map.put(value, 1);
        }
    }
}



Measured memory_bytes: 23764
import sys

input = sys.stdin.readline

N, K = map(int, input().split())
S = set()
for _ in range(K):
    l, r = map(int, input().split())
    S.add((l, r))

mod = 998244353
dp = [0 for _ in range(N+1)]
dp[1] = 1
acc = [0 for _ in range(N+1)]
acc[1] = 1
for i in range(1, N+1):
    for (l, r) in S:
        left = max(i - r - 1, 0)
        right = max(i - l, 0)
        # print("left", left, "right", right)
        dp[i] += acc[right] - acc[left]
        dp[i] %= mod
    acc[i] = acc[i-1] + dp[i]
    acc[i] %= mod

# print(acc)
print(dp[N])

Measured memory_bytes: 93952
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007


void solve()
{
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<a+b+c-max({a,b,c});
    return;
}

int main()
{
        fast;
        ll q;
        q=1;
        // cin>>q;
        while(q--)
        	solve();
        
        return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
using namespace std;
 
 
//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)
 
#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
 
//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<char> vch;
typedef vector<long long> vll;
typedef vector<string> vstr;
 
 
int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b){ll ans=1; rep(i, b){ans=ans*a%MOD;} return ans;}
 
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}
 
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};
 
 
 
 
template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}
 
 
vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}
 
 
 
 
int main(){
 
    cin.tie(0);
    ios::sync_with_stdio(false);


    int n, m;
    cin >> n >> m;
    
    

    vint a(m), b(m);
    rep(i, m){
        cin >> a[i] >> b[i];
    }

    if(m==1){
        ppp("IMPOSSIBLE");
        return 0;
    }

    bool relay1[n]={false}, relay2[n]={false};


    rep(i, m){
        if(a[i] == 1){
            relay1[b[i]-1] = true;
        }
        if(b[i] == n)
            relay2[a[i]-1] = true;
    }
 
    rep(i, n){
        if(relay1[i] && relay2[i]){
            ppp("POSSIBLE");
            return 0;
        }
    }


    ppp("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <fstream>
#include <bitset>
#include <time.h>
#include <assert.h>

#define LL long long
#define VI vector<int>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

using namespace std;


class Compress {
public:
    vector<int> v;
    map<int, int> rev;
    
    
    // ??§?¨???§?????????
    // v????????????????????????????´?
    Compress(vector<int> vec) {
        this->v = vec;
        sort(this->v.begin(), this->v.end());
        this->v.erase(unique(this->v.begin(), this->v.end()), this->v.end());
        
        for (int x : v) {
            rev[this->zip(x)] = x;
        }
    }

    int zip(int x) {
        return lower_bound(ALL(this->v), x) - this->v.begin();
    }
    
    int unzip(int x) {
        return this->rev[x];
    }
};




int main(int argc, char *argv[]) {
    int N, M, X, Y;

    cin >> N >> M;
    vector<int> treasureX(N), treasureY(N);
    FOR(i, 0, N) {
        cin >> X >> Y;
        treasureX[i] = X;
        treasureY[i] = Y;
    }

    // ?????????????????§?¨???§???
    Compress cx(treasureX);
    Compress cy(treasureY);
    
    vector<vector<int>> field(5100, vector<int>(5100, 0));

    // ??§???????????§?¨???§?´????????????¨???
    FOR(i, 0, N) {
        int x = cx.zip(treasureX[i]);
        int y = cy.zip(treasureY[i]);
        field[y+1][x+1]++;
    }
    FOR(i, 0, field.size() - 1) {
        FOR(j, 0, field[0].size() - 1) {
            field[i + 1][j + 1] += field[i + 1][j] + field[i][j + 1] - field[i][j];
        }
    }
    
    // ??§???????????§?¨???§????????¢??????????????°????¨????
    FOR(i, 0, M){
        int lx, ly, rx, ry;
        cin >> lx >> ly >> rx >> ry;
        lx = cx.zip(lx);
        rx = cx.zip(rx + 1);
        ly = cy.zip(ly);
        ry = cy.zip(ry + 1);
        std::cout << field[ry][rx] - field[ry][lx] - field[ly][rx] + field[ly][lx] << std::endl;
    }
}

Measured memory_bytes: 105324
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

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

		final int n = sc.nextInt();
		final int nHalf = n / 2;

		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			list.add(sc.nextInt());
		}

		Collections.sort(list);

		final int numHalf = list.get(nHalf - 1);
		final int numHalfNext = list.get(nHalf);

		if (numHalf == numHalfNext) {
			System.out.print(0);
			return;
		}

		System.out.print(numHalfNext - numHalf);

	}

}

Measured memory_bytes: 60180
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ld INF = 1e9+123;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll 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;
}
int main(){
    int N;
    cin>>N;
    VEC(string,v,0);
    
    string bef="";
    REP(i,N){
        string s;
        cin>>s;
        auto t=find(ALL(v),s);
        //sl(s,bef[0],s[0],bef[0]!=s[0],t != v.end());
        if(i>0&&(s[0] != bef[0] || t != v.end())){
            cout<<"No";return 0;
        }
        v.push_back(s);
        bef=s[s.length()-1];
    }
    
    
    cout<<"Yes";
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
 
typedef long long ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
const double PI=3.14159265358979323846;
 
using namespace std;
 
int main() {
	
	double a, b, h, m;

	cin >> a >> b >> h >> m;

	double ld = h * (double)30 + (double)30 * m / (double)60;
	double sd = m * (double)6;
	double rn = abs(ld - sd);

	//cout << cos((double)(rn * PI /180)) << endl;

	double aa = a*a + b*b - 2*a*b*cos( (double)(rn * PI /180) );

	//cout << aa << endl;

	double ans = sqrt(aa);

	cout << fixed << setprecision(20) << ans << endl;
}

Measured memory_bytes: 4156
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<cmath>
#include<math.h>

using namespace std;

int main(void){

    double a, b, x;
    double height;
    double ans;

    cin >> a >> b >> x;


    if(a*a*b/2 <= x){
        ans = atan(2*(a*a*b-x)/(a*a*a)) * 180/M_PI;
    }else{
        ans = 90 - atan((2*x)/(a*b*b)) * (180/M_PI);
    }
    
    printf("%.10lf\n",ans);

    return 0;
}

Measured memory_bytes: 256
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc127_a.cpp
 * time   : Fri May  1 16:48:33 2020
 * quest  : A - Ferris Wheel
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  cout << ((a >= 13) ? b : (a >= 6) ? b / 2 : 0) << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
using ll = long long;
using P = pair<ll, ll>;

const ll infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void fail() {
    cout << -1 << endl;
    exit(0);
}

int main(){
    string s, ans = "";
    cin >> s;
    ll n = s.size();
    ll w;
    cin >> w;
    for(ll i=0; i < n; i++){
        if(i % w == 0) ans += s[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int N,K;
  cin>>N>>K;
  vector<int>height(N);
  for(int i=0;i<N;i++){
  cin>>height.at(i);
  }
  int count;
  for(int i=0;i<N;i++){
	if(height.at(i)>=K){
    count++;
    }
  }
  cout<<count<<endl;
  }

Measured memory_bytes: 3644
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

typedef double P_type; //座標(integer or real)
typedef double G_real; //実数の戻り値(float or double or long double)
typedef complex<P_type> P;
const G_real P_eps = 1e-8; //整数の時はゼロ

namespace std {
  template<class T>
  bool operator<(const complex<T> &a, const complex<T> &b) {
    return abs(a.real() - b.real()) < P_eps ? a.imag() + P_eps < b.imag() : a.real() + P_eps < b.real();
  }
};

P rotate(P p, double theta) {
  return p * P(cos(theta), sin(theta));
}

//内積
P_type dot(P a, P b) {
  return (a * conj(b)).real();
}

//外積
P_type cross(P a, P b) {
  return (conj(a) * b).imag();
}

//反時計回り
int ccw(P a, P b, P c) {
  if (cross(b - a, c - a) > P_eps) return 1; //COUNTER_CLOCKWISE(center:a)
  if (cross(b - a, c - a) < -P_eps) return -1; //CLOCKWISE(center:a)
  if (dot(b - a, c - a) < -P_eps) return -2; //c -> a -> b
  if (dot(a - b, c - b) < -P_eps) return 2; //a -> b -> c
  return 0; //a -> c -> b
}

/*
// 偏角 [-pi, pi]
// complex<int|ll> 使用時の std::arg の代わり
G_real arg(P p) {
  return atan2(imag(p), real(p));
}
*/

int main() {
  int A, B, H, M;

  cin >> A >> B >> H >> M;

  auto p = P(A, 0);
  auto q = P(B, 0);

  p = rotate(p, H * 2 * M_PI / 12 + M * 2 * M_PI / (12 * 60));
  q = rotate(q, M * 2 * M_PI / 60);

  debug(p, q);

  double dist = abs(p - q);

  printf("%.20lf\n", dist);

  return 0;
}

Measured memory_bytes: 4060
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define int long long
typedef long long ll;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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;
}

__attribute__((constructor)) void initial() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int X;
  cin >> X;
  
  int M=100;
  int ans=0;
  while(M<X){
    ans++;
    M+=M/100;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
def check(x,k,arr):
    now = 0
    for i in range(len(arr)):
        now+=int((arr[i]-1)/x)
    return now<=k

n, k = map(int,input().split())
arr = list(map(int,input().split()))

r, l = 1e9, 0
while (l+1<r):
    x = int((r+l)/2)
    if check(x,k,arr):
        r = x
    else:
        l = x
print(int(r))



Measured memory_bytes: 30800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    vector<pair<ll,ll>> A(N);
    rep(i,N){
        ll a,b;
        cin >> a >> b;
        A[i]=make_pair(M-a,b);
    }
    sort(all(A));
    ll sum=0;
    priority_queue<ll> que;
    for(int i=M;i>=0;i--){
        while(true){
            if(!A.empty() && A.back().first>=i){
                que.push(A.back().second);
                A.pop_back();
            }
            else break;
        }
        if(!que.empty()){
            sum+=que.top();
            que.pop();
        }
    }
    cout << sum;

}

/*

さてはアンチだなオメー

 */



Measured memory_bytes: 2936
def gcd(n,m):
  a=max(n,m)
  b=min(n,m)
  while b!=0:
    a,b=b,a%b
  return a
n=int(input())
l=list(map(int,input().split()))
l1=[]
l1.append(l[0])
for i in range(1,n):
  l1.append(gcd(l1[-1],l[i]))
l2=[]
l2.append(l[-1])
for i in range(n-2,-1,-1):
  l2.append(gcd(l2[-1],l[i]))
l3=[]
for i in range(2,n):
  l3.append(gcd(l1[i-2],l2[n-i-1]))
l3.append(l2[n-2])
l3.append(l1[n-2])
print(max(l3))
            
                



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

int main() {
  string S;
  long long K;
  cin >> S >> K;
  int count = 0;
  
  vector<char>C(S.size());
  for (int i = 0; i < S.size(); i++) {
    C.at(i) = S.at(i);
    if (C.at(i) == '1' && i < K){
      count++;
    }
  }
  if (count == K){
    cout << 1 << endl;
    return 0;
  }
  
  for (int i = 0; i < S.size(); i++) {
    if (C.at(i) != '1'){
      cout << C.at(i) << endl;
      break;
    }
  }
}

Measured memory_bytes: 3568
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int r = stdIn.nextInt();
		int c = stdIn.nextInt();
		
		int[][] h = new int[r+1][c+1];
		
		for(int i = 0; i < r; i++) {
			int rsum = 0;
			for(int j = 0; j < c; j++) {
				int tmp = stdIn.nextInt();
				rsum += tmp;
				h[i][j] = tmp;
			}
			h[i][c] = rsum;
		}
		
		for(int i = 0; i < c+1; i++) {
			int rsum = 0;
			for(int j = 0; j < r; j++) {
				rsum += h[j][i];
			}
			h[r][i] = rsum;
		}
		
		for(int i = 0; i < r+1; i++) {
			for(int j = 0; j < c; j++) {
				System.out.print(h[i][j] + " ");
			}
			System.out.println(h[i][c]);
		}
	}
}

Measured memory_bytes: 39528
#include <iostream>

using namespace std;

int main() {
    
    int i,j,k,n,cnt=0;
    string s;
    cin>>n>>s;
    for(i=1;i<n;i++){
        if(s[i]==s[i-1])
            continue;
        else    
            cnt++;
    }
    cout<<cnt+1;
}

Measured memory_bytes: 512
/*
 _ _ _   _    _   _    _   _ _ _   _    _   _ __ _   __       __
|  _ _| | |  | | | |  | | |  _  | | |  | | |  __  | |   \   /   |
| |_ _  | |__| | | |  | | | |_| | | |__| | | |__| | | |\ \_/ /| |
|_ _  | |  __  | | |  | | |  _ <  |  __  | |  __  | | | \   / | |
 _ _| | | |  | | | |__| | | |_| | | |  | | | |  | | | |  \_/  | |  _   _   _
|_ _ _| |_|  |_| |_ __ _| |_ _ _| |_|  |_| |_|  |_| |_|       |_| |_| |_| |_|

*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
const int MOD=1e9 + 7;
const int N=1000100;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){  
                                                        for (auto &v : vec) is >> v; return is; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve(){
    long h,n;
    cin>>h>>n;
    vector<long> a(n),b(n);
    for(int i=0;i<n;i++)
        cin>>a[i]>>b[i];

    vector<ll> dp(h+1,2e9);
    dp[0]=0;
    for(int i=0;i<=h;i++){
        for(int j=0;j<n;j++){
            long to=min(i+a[j],h);
            dp[to]=min(dp[to],dp[i]+b[j]);
        }
    }
    cout<<dp[h]<<endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int t = 1;
    // cin>>t;
    for (long int tt = 1; tt <= t; tt++) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3720
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		double x = 0;
		double y = 0;
		double a = Math.toRadians(90);
		while (!str.equals("0,0")) {
			String[] data = str.split(",", 2);
			int d = Integer.parseInt(data[0]);
			x = (x + d * Math.cos(a));
			y = (y + d * Math.sin(a));
			a = a - Math.toRadians(Integer.parseInt(data[1]));
			str = br.readLine();
		}
		System.out.println((int) x);
		System.out.println((int) y);
	}
}

Measured memory_bytes: 24244
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[100005];
int main()
{
    int n,f=0,i,x=0,y=0;
    while(cin>>n)
    {
    	for(i=0;i<n;i++)
    	{
	        cin>>a[i];
        }   
           for(i=0;i<n;i++)
    	    {
			   	 if(a[i]%4==0)x++;
			   	 if(a[i]%2==0&&a[i]%4!=0)y++;
			   	 if(x*2+y>=n||x>=n/2)f=1;
			} 	    
		if(f)cout<<"Yes"<<endl;
    	    else cout<<"No"<<endl;
    }
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define neko 200010
#define f(i,a,b) for(register int i=(a);i<=(b);i=-(~i))
int cnt[30],len;
typedef long long ll;
ll ans=1;
char s[neko];
int main()
{
	scanf("%s",s),len=strlen(s)-1;
	f(i,0,len)ans+=i-cnt[s[i]-'a'],++cnt[s[i]-'a'];
	return printf("%lld\n",ans),0;
}

Measured memory_bytes: 384