akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <cstring>
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

void comb(vector<vector <long long int> > &v){
  for(int i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(int k = 1;k <v.size();k++){
    for(int j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

int main() {
    ll N, M;

    cin >> N >> M;

    if(N<2 && M<2) {
        cout << "0";
    } else if(N>=2 && M<2) {
        vector<vector<long long int> > v(N+1,vector<long long int>(N+1,0));
        comb(v);
        cout << v[N][2];
    } else if(N<2 && M>=2) {
        vector<vector<long long int> > v(M+1,vector<long long int>(M+1,0));
        comb(v);
        cout << v[M][2];
    } else {
        vector<vector<long long int> > v(N+1,vector<long long int>(N+1,0));
        comb(v);
        vector<vector<long long int> > w(M+1,vector<long long int>(M+1,0));
        comb(w);
        cout << v[N][2] + w[M][2];
    }
    return 0;

}

Measured memory_bytes: 384
n = int(input())
h_ls = list(map(int, input().split()))
h_ls = h_ls

mincost_ls = [float('inf')] * n
mincost_ls[0] = 0
mincost_ls[1] = abs(h_ls[1] - h_ls[0])
for i in range(n-2):
    mincost_ls[i+2] = min(mincost_ls[i+1] + abs(h_ls[i+2] - h_ls[i+1]), 
        mincost_ls[i] + abs(h_ls[i+2] - h_ls[i]))
print(mincost_ls[-1])

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

int main(){
    string S;
    cin>>S;
    int N=S.size(),R,L,j,k=-1;
    S+='e';
    vector<int> v(N,0);

    for(int i=0;i<N;++i){
        if(S[i]=='R'&&S[i+1]=='L') {
            j=i;
            R=j-k;
        }
        if(S[i]=='L'&&(S[i+1]=='R'||S[i+1]=='e')) {
            k=i;
            L=k-j;
            v[j]=(R+1)/2+L-(L+1)/2;
            v[j+1]=R-(R+1)/2+(L+1)/2;
        }

    }

    for(int i=0;i<N;++i)cout<<v[i]<<" ";
    return 0;

}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  cout << a.back()-a.front() << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <stack>

using namespace std;

#define sz(X) ((int)(X).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define all(X) (X).begin(),(X).end()
#define FOR(i, a, n) for(int i=(a), __ ## i=(n); i<__ ## i; i++)
#define REP(I,N) FOR(I,0,N)
#define PR(X) cout<<#X<<" = "<<(X)<<" "
#define PRL cout<<endl
#define PRV(X) {cout<<#X<<" = {";REP(__prv,sz(X)-1)cout<<(X)[__prv]<<",";if(sz(X))cout<<*(X).end();cout<<"}"<<endl;}

template<class T> ostream &operator<<(ostream &os, const vector<T> &vec)
{
	os << '{';
	REP(i, sz(vec))
	{
		os << vec[i];
		if (i + 1 != sz(vec))
			os << ',';
	}
	os << '}';
	return os;
}

template<class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &par)
{
	os << '(' << par.X << ',' << par.Y << ')';
	return os;
}

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<bool> VB;
typedef vector<unsigned long long> VULL;
typedef vector<vector<int>> VVI;
typedef queue<int> QI;

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : abs(x);
}

template<class T> T sqr(T x)
{
	return x * x;
}

LL dp[1000010];

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

	LL n;
	cin >> n;

	dp[0] = 1;
	dp[1] = n;

	LL sum = n + 1;

	FOR(i, 2, n + 1)
	{
		dp[i] = (1000000007LL + (n - 1)*(n - 1) + sum - dp[i - 2] + max(n - i + 1, 0LL)) % 1000000007;
		sum = (sum + dp[i]) % 1000000007;
	}

	cout << dp[n];

	return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;
string alphabet = "abcdefghijklmnopqrstuvwxyz";
string ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
 string s;
 cin >> s;
 int sum = 0;
 for(int i = 0;i < 4;i++){
     if(s[i] == '+')sum++;
     else sum--;
 }
 cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
typedef long long int ll;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T>
bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false;}
template<typename T>
bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false;}
// clang-format on

#include <tuple>
#include <queue>
// cost, x, to, type
using Edge = tuple<ll, int, int, int>;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> room(n);
    REP(i, 0, n) {
        cin >> room[i];
    }
    vector<vector<Edge>> G(n);
    REP(i, 0, m) {
        int a, b, d;
        cin >> a >> b >> d;
        a--;
        b--;
        G[a].emplace_back(d, -1, b, -1);
        G[b].emplace_back(d, -1, a, -1);
    }
    priority_queue<Edge, vector<Edge>, greater<Edge>> pq;
    pq.emplace(0, 0, 0, room[0]);
    const ll inf = 1LL << 60;
    auto Cost = make_v(n, x + 1, inf);
    while (pq.size()) {
        ll cost;
        int rem, to, type;
        tie(cost, rem, to, type) = pq.top();
        pq.pop();
        if (Cost[to][rem] < cost) continue;
        Cost[to][rem] = cost;
        REP(i, 0, G[to].size()) {
            int ncost, nto;
            tie(ncost, ignore, nto, ignore) = G[to][i];
            int nrem = min(rem + ncost, x);
            if ((type ^ room[nto]) == 2 && nrem < x) continue;
            if (type == room[nto]) {
                nrem = 0;
            }
            int ntype = type;
            if ((type ^ room[nto]) == 2) {
                ntype = room[nto];
                nrem = 0;
            }
            if (chmin(Cost[nto][nrem], cost + ncost)) {
                pq.emplace(Cost[nto][nrem], nrem, nto, ntype);
            }
        }
    }
    cout << *min_element(Cost[n - 1].begin(), Cost[n - 1].end()) << endl;

    return 0;
}



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

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    int N; 
    cin>>N;
    string ans ;
    if(N%10 == 3) ans = "bon";
    else if(N% 10 == 0 || N% 10 == 1 || N% 10 == 6 || N% 10 == 8) ans = "pon";
    else ans = "hon";
    cout << ans << endl; 
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int S;
    cin >> S;
    vector<int> a(4);
    for(int i = 0; i < 4; i++){
        a[i] = S%10;
        S /= 10;
    }

    bool mmyy = true;
    bool yymm = true;

    int month = a[1]*10 + a[0];
    if(month >= 13 || month <= 0){
        yymm = false;
    }

    month = a[3]*10 + a[2];
    if(month >= 13 || month <= 0){
        mmyy = false;
    }

    if(mmyy && yymm){
        cout << "AMBIGUOUS" << endl;
    }
    else if(mmyy){
        cout << "MMYY" << endl;
    }
    else if(yymm){
        cout << "YYMM" << endl;
    }
    else{
        cout << "NA" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define mset(x,y) memset(x,y,sizeof(x))
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define rng(i,a,b) for(int i=int(a);i<=int(b);i++)
#define gnr(i,b,a) for(int i=int(b);i>=int(a);i--)
using namespace std;
using namespace __gnu_pbds;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
#ifdef LOCAL
#define dmp(...) _dmp(#__VA_ARGS__, __VA_ARGS__)
#else
#define dmp(...) (__VA_ARGS__)
#endif
template<class T> using vt=vector<T>;
template<class T> using vvt=vt<vt<T>>;
template<class TA,class TB> void chmax(TA&a,TB b){if(a<b)a=b;}
template<class TA,class TB> void chmin(TA&a,TB b){if(b<a)a=b;}
template<class TA,class TB>
ostream& operator<<(ostream& os,const pair<TA,TB>& p){
	return os<<"{"<<p.fi<<","<<p.se<<"}";
}
template<class T> ostream& operator<<(ostream& os,const vt<T>& v){
	os<<"{";for(auto& e:v)os<<e<<",";return os<<"}";
}
template<class TH> void _dmp(const char *sdbg, TH h){cout<<sdbg<<"="<<h<<endl;}
template<class TH, class... TA> void _dmp(const char *sdbg, TH h, TA...a){
while(*sdbg!=',')cout<<*sdbg++;cout<<"="<<h<<","; _dmp(sdbg+1, a...);
}
template<class T> void make_unique(vt<T>& v) {
	sort(all(v));v.erase(unique(all(v)),v.end());
}
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
int ri(){int x;cin>>x;return x;}
ll rll(){ll x;cin>>x;return x;}
vi rvi(int n){vi v;rep(i,n)v.pb(ri());return v;}
ll n,m;
void MAIN() {
	cin>>n>>m;
	if(n%2) {
		for(int i=1;i<=m;i++) {
			cout<<i<<' '<<(n-i)<<'\n';
		}
	} else {
		int c=1;
		for(int i=1;i<=m;i++) {
			if(2*i-1>=n-2*i+1)c=0;
			cout<<i<<' '<<(n-i+c)<<'\n';
		}
	}
}
int main() {
	ios::sync_with_stdio(false);cin.tie(0);
	int T=1;
	//cin>>T;
	for(int tt=1;tt<=T;tt++) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
#include <numeric>
#include <string>
#include <cstring>
#include <list>
#include <unordered_set>
#include <tuple>
#include <cmath>
#include <limits>
#include <type_traits>
#include <iomanip>
#include <unordered_map>
using namespace std;

using INT = long long;
using UINT = unsigned long long;

UINT gcd(UINT a, UINT b) {
	while (1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

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

const UINT mod = 1000000007;
const double pi = 3.141592653589793238462;
const INT intmax = 9223372036854775807;

UINT _PowMod(UINT x, UINT y, UINT _mod)
{
	if (y == 0)
	{
		return 1;
	}
	else if (y == 1)
	{
		return x % _mod;
	}
	else if (y % 2 == 0)
	{
		auto tmp = _PowMod(x, y / 2, _mod);
		return tmp * tmp % _mod;
	}
	else
	{
		auto tmp = _PowMod(x, y / 2, _mod);
		return (tmp * tmp % _mod) * x % _mod;
	}
}


UINT PowMod(UINT x, UINT y)
{
	return _PowMod(x, y, mod);
}

UINT getModInv(UINT N)
{
	return PowMod(N, mod - 2);
}

INT nCrMod(INT start, INT n, INT r)
{
	if (n < r)
	{
		return 0;
	}
	INT a = start;
	for (size_t i = n; i >= n - r + 1; i--)
	{
		a *= i;
		a %= mod;
	}
	for (size_t i = 1; i <= r; i++)
	{
		a *= getModInv(i);
		a %= mod;
	}
	return a;
}

INT nHrMod(INT start, INT n, INT r)
{
	return nCrMod(start, n + r - 1, r);
}

INT _nCrMod(INT start, INT n, INT r)
{
	if (n <= 0)
	{
		return 0;
	}
	return nCrMod(start, n, r);
}

struct uf
{
	vector<INT> p;

	uf(INT n) : p(n)
	{
		for (size_t i = 0; i < n; i++)
		{
			p[i] = i;
		}
	}

	INT rt(INT n)
	{
		return p[n] == n ? n : p[n] = rt(p[n]);
	}

	void un(INT n, INT m)
	{
		p[rt(n)] = p[rt(m)];
	}

	bool eq(INT n, INT m)
	{
		return rt(n) == rt(m);
	}
};

bool lineCol(INT a1x, INT a1y, INT a2x, INT a2y, INT b1x, INT b1y, INT b2x, INT b2y)
{
	auto ta = (b1x - b2x) * (a1y - b1y) + (b1y - b2y) * (b1x - a1x);
	auto tb = (b1x - b2x) * (a2y - b1y) + (b1y - b2y) * (b1x - a2x);
	auto tc = (a1x - a2x) * (b1y - a1y) + (a1y - a2y) * (a1x - b1x);
	auto td = (a1x - a2x) * (b2y - a1y) + (a1y - a2y) * (a1x - b2x);

	return tc * td < 0 && ta * tb < 0;
}

INT powInt(INT a, INT b)
{
	if (b == 0)
	{
		return 1;
	}
	if (b == 1)
	{
		return a;
	}
	INT tmp = powInt(a, b / 2);
	return (b % 2 == 1 ? a * tmp * tmp : tmp * tmp);
}

INT _sMod(string n, INT mod)
{
	INT k = (n[0] - '0') % mod;
	for (size_t i = 1; i < n.length(); i++)
	{
		k *= 10;
		k += (n[i] - '0');
		k %= mod;
	}
	return k;
}

#define forin(v, n)				\
for (size_t i = 0; i < n; i++)	\
{								\
	cin >> v[i];				\
}

#define vec(t, name, n)			vector<t> name(n)
#define vec_(t, name, n, init)	vector<t> name(n, init)

#define vec2(t, name, n, m)			vector<vector<t>> name(n, vector<t>(m))
#define vec2_(t, name, n, m, init)	vector<vector<t>> name(n, vector<t>(m, init))

struct xy
{
	INT x, y;
	xy() :x(0), y(0) {}
	xy(INT _x, INT _y) : x(_x), y(_y) {}
};

int main()
{
	INT a[3];
	forin(a, 3);
	sort(a, a + 3);
	INT t = 1;
	if (a[0] != a[1])
		t++;
	if (a[2] != a[1])
		t++;

	cout << t << endl;
	return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x: u32,
    }

    let coin500 = x / 500;
    let coin5 = (x % 500) / 5;

    println!("{}", coin500 * 1000 + coin5 * 5);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n;
    cin >> n;
    vector<int> x(n+1);
    vector<int> y(n+1);
    for(int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }
    sort(x.rbegin(), x.rend());
    sort(y.begin(), y.end());
    ll ans = 0;
    for(int i = 0; i < n+1; i++)
    {
        if(x[i] - y[i] > 0)
        {
            ans += 2*(x[i] - y[i]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h> 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vll>;
using vb = vector<bool>;
 
const int INF = 2e9+5;
const ll LLINF = (1LL << 60) + 5;
 
/*
  filippos
  Contest : AtCoder DP contest
  Task : U - Grouping
*/
 
int main(){
  cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);

  int n; cin >> n;
  vvi v(n, vi(n));
  for(auto &x : v)
    for(auto &i : x)
      cin >> i;

  vll mask_value(1<<n, 0);
  for(int mask = 0; mask < (1 << n); mask++){
    ll &value = mask_value[mask];
    vi indexes;
    for(int i = 0; i < n; i++)
      if(mask & (1 << i))
        indexes.push_back(i);
    for(int i = 0; i < indexes.size(); i++)
      for(int j = i + 1; j < indexes.size(); j++)
        value += v[indexes[i]][indexes[j]];
  }

  vll memo(1 << n, -1);
  function<ll(int)> dp = [&](int mask){
    // base case
    if(mask == (1<<n) - 1) return 0LL;
    // memo
    ll &ans = memo[mask];
    if(ans != -1) return ans;
    ans = 0;

    // trick: this brings complexity to O(3^n) (from 4^n),
    // as it let's us generate only subsets of complementar mask.
    int cm = (~mask) & ((1<<n) - 1);
    for(int sc = cm; sc > 0; sc = (sc - 1) & cm){
      ans = max(ans, mask_value[sc] + dp(mask | sc));
    }
    return ans;
  };


  cout << dp(0);

  return cout << endl, 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define int long long
using namespace std;
using Graph = vector<vector<int>>;

signed main(){
  int H, W;
  cin >> H >> W;
  
  vector<string> A(H);
  for( int i = 0; i < H; i++ ) cin >> A.at(i);
  
  vector<vector<int>> ans(H, vector<int>(W, 100000));
  
  //左から見る
  for( int i = 0; i < H; i++ ){
    int now = -1;
    for( int j = 0; j < W; j++ ){
      if( A.at(i).at(j) == '#' ){
        ans.at(i).at(j) = 0;
        now = 0;
      }else{
        if( now == -1 ) continue;
        ans.at(i).at(j) = now+1;
        now++;
      }
    }
  }
  
  //右から見る
  for( int i = 0; i < H; i++ ){
    int now = -1;
    for( int j = W-1; j >= 0; j-- ){
      if( A.at(i).at(j) == '#' ) now = 0;
      else{
        if( now == -1 ) continue;
        ans.at(i).at(j) = min(ans.at(i).at(j), now+1);
        now++;
      }
    }
  }
  
  //上から見る
  for( int i = 0; i < W; i++ ){
    int now = -1;
    for( int j = 0; j < H; j++ ){
      if( A.at(j).at(i) == '#' ) now = 0;
      else{
        if( now == -1 ) continue;
        ans.at(j).at(i) = min(ans.at(j).at(i), now+1);
        now++;
      }
    }
  }
  
  //下から見る
  for( int i = 0; i < W; i++ ){
    int now = -1;
    for( int j = H-1; j >= 0; j--){
      if( A.at(j).at(i) == '#' ) now = 0;
      else{
        if( now == -1 ) continue;
        ans.at(j).at(i) = min(ans.at(j).at(i), now+1);
        now++;
      }
    }
  }
  
  //左から
  for( int i = 0; i < H; i++ ){
    int now = -1;
    for( int j = 0; j < W; j++ ){
      if( now == -1 ) now = ans.at(i).at(j)+1;
      ans.at(i).at(j) = min(ans.at(i).at(j), now);
      now = min(now+1, ans.at(i).at(j)+1);
    }
  }
  
  //右
  for( int i = 0; i < H; i++ ){
    int now = -1;
    for( int j = W-1; j >= 0; j-- ){
      if( now == -1 ) now = ans.at(i).at(j)+1;
      ans.at(i).at(j) = min(ans.at(i).at(j), now);
      now = min(now+1, ans.at(i).at(j)+1);
    }
  }
  
  int num = -1;
  for( int i = 0; i < H; i++ ){
    for( int j = 0; j < W; j++ ) num = max(num, ans.at(i).at(j));
  }
  
  cout << num << endl;
  
}


Measured memory_bytes: 9216
#include<cstdio>
#include<iostream>

#define loop(lp) for(int i = 0; i < lp;i++)
using namespace std;

int main(){
  int n,month,year,day,counter=0;
  cin >> n;
  loop(n){
    counter = 0;
    cin >> year >> month >> day;
    while(year < 1000){
      day++;
      counter++;
      if(year % 3 == 0 || month % 2 != 0){
	if(day > 20){
	  day = 1;
	  month++;
	}
      }else{
	if(day > 19){
	  day = 1;
	  month++;
	}
      }
      if(month > 10){
	month = 1;
	year++;
      }
    }
    cout << counter<<endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
    int n; cin >> n;
    
    vector<int> c(n); for(int i = 0; i < n; i++) { cin >> c[i]; }
    
    for(int i = 1; i <= 900000000; i++)
    {
        bool ok = true;
        
        for(int j = 0; j < n; j++)
        {
            if(c[j] % i != 0)
            {
                ok = false;
            }
        }
        
        if(ok) { cout << i <<endl; }
    }
    
    return 0;
}

Measured memory_bytes: 3048
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
const int MOD = 1e9+7;
const int MOOD = 998244353;
typedef long long ll;
#define PI 3.14159265359
using namespace std;


int main(){
	int a, b, c, k, coun = 0;
	cin >> a >> b >> c >> k;
	while (a >= b){
		b *= 2;
		coun++;
	}
	while (b >= c){
		c *= 2;
		coun++;
	}
	if (coun <= k) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3628
N,M=[int(i) for i in input().split()]

AB=[]
for n in range(N):
    a,b=[int(j) for j in input().split()]
    AB.append((a,b))

AB=sorted(AB)
#sorted(AB, key=lambda x: x[0])

money=0
bottle=M
for a in AB:
    if bottle>=a[1]:
        money+=a[0]*a[1]
        bottle-=a[1]
    else:
        money+=a[0]*bottle
        bottle-=bottle
        break
print(money)

Measured memory_bytes: 17736
n = gets.to_i
puts [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51][n-1]

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include<string>
 
using namespace std;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
     
    int n;
    cin>>n;
    int a[n];
    long int sum = 0;
    for(int i=0; i<n; i++) {
        cin>>a[i];
        sum = sum + a[i];
    }
    sort(a,a+n);
    
    printf("%d %d %ld\n",a[0],a[n-1],sum);
     
    return 0;
     
}


Measured memory_bytes: 3288
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) { for (auto& e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B, M; cin >> A >> B >> M;
	vector<int> a(A); rep(i, 0, A) {
		cin >> a[i];
	}
	vector<int> b(B); rep(i, 0, B) {
		cin >> b[i];
	}
	int ans = INF;
	vector<int> x(M), y(M), c(M); rep(i, 0, M) {
		cin >> x[i] >> y[i] >> c[i];
		x[i]--, y[i]--;
		chmin(ans, a[x[i]] + b[y[i]] - c[i]);
	}
	chmin(ans, *min_element(all(a)) + *min_element(all(b)));
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4224
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;

string L;
int N;

int main() {
    cin >> L;
    N = L.size();

    vv<ll> dp = vvec(N, 2, 0LL);
    dp[0][0] = 1;
    dp[0][1] = 2;
    rep(i, 1, N) {
        if (L[i] == '1') {
            dp[i][0] = (dp[i - 1][0] * 3 + dp[i - 1][1]) % MOD;
            dp[i][1] = dp[i - 1][1] * 2 % MOD;
        }
        else {
            dp[i][0] = dp[i - 1][0] * 3 % MOD;
            dp[i][1] = dp[i - 1][1];
        }
    }

    ll ans = (dp[N - 1][0] + dp[N - 1][1]) % MOD;
    write(ans);
}

Measured memory_bytes: 5840
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main() {
	int A, B; cin >> A >> B;
	for (int i = 1; i <= 1500; ++i) {
		if (A == (int)(i * 0.08) && B == (int)(i * 0.1)) {
			cout << i << endl;
			goto FIN;
		}
	}
	cout << -1 << endl;
FIN: return 0;
}

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

Measured memory_bytes: 256
fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    let vec: Vec<i32> = line.trim().split_whitespace()
        .map(|e| e.parse().unwrap()).collect();
    let (a,b) = (vec[0],vec[1]);
    
    if a*b % 2 == 0 {
        println!("Even");
    } else {
        println!("Odd");
    }
}


Measured memory_bytes: 4352
k = int(input())
num = 0
for _ in range(k):
  num += 1
  digit = [int(digit) for digit in str(num)]
  len_digit = len(digit)
  flag = False
  for i in range(1, len_digit):
    # current_digit = digit[-i]
    # upper_digit = digit[-i-1]
    if digit[-i] == 10:
      digit[-i-1] += 1
      digit[-i] = -1
    elif digit[-i] > digit[-i-1] + 1:
      digit[-i-1] += 1
      digit[-i] = -1
    elif digit[-i] < digit[-i-1] - 1:
      digit[-i] = -1
  if digit[0] == 10:
    num = 10 ** len_digit
  else:
    for i in range(1, len_digit):
      if digit[i] == -1:
        for j in range(i, len_digit):
          digit[j] = max(digit[j-1] - 1, 0)
        break
    num = 0
    for d in digit:
      num = num * 10 + d
print(num)

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

n, m, X, Y = map(int, input().split())
x = map(int, input().split())
y = map(int, input().split())

x_max = max(x)
y_min = min(y)


for i in range(X + 1, Y + 1):
    if x_max < i and i <= y_min:
        print('No War')
        exit()
print('War')

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {

	public static final int BIG_NUM = 2000000000;
	public static final int MOD = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		try {
			String input[] = br.readLine().split("\\s+");

			String str_A = input[0],str_B = input[1];

			BigInteger A = new BigInteger(input[0]);

			if(str_B.charAt(0) == '-'){

				str_B = str_B.substring(1);

			}else{

				str_B = "-" + str_B;
			}
			BigInteger B = new BigInteger(str_B);

			BigInteger ans;

			ans = A.add(B);
			System.out.println(ans);

		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
}




Measured memory_bytes: 71072
#include <stdio.h>

int main(void){
  unsigned long long a,b,n;
  scanf("%lld %lld %lld",&a,&b,&n);
   
  if(b-1>n){
    printf("%lld\n",(a*n)/b);
  }
  else{
    printf("%lld\n",(a*(b-1))/b);
  }
  
  return 0;
}

Measured memory_bytes: 1684
# Reversing Numbers

length = int(input())
array = [int(i) for i in input().rstrip().split()]

reversedArray = [0 for i in range(length)]
for i, a in enumerate(array):
    reversedArray[(length - 1) - i] = a

answer_list = [str(n) for n in reversedArray]
print(' '.join(answer_list))



Measured memory_bytes: 5600
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]
n = int(input())
for k in range(n):
    mark, num = input().split()
    num = int(num)
    cards[pattern.index(mark)][num-1] = True
for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], end=" ")
            print(j+1)


Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
int H, W, a, b, dp[105][105];
char chars[105][105];
int main()
{
	cin >> H >> W;
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> chars[i][j];
		}
	}
	if (chars[0][0] == '#')
	{
		dp[0][0] = 1;
	}
	for (int i = 1; i < H; i++)
	{
		if (chars[i][0] == '#')
		{
			if (chars[i - 1][0] == '#')
			{
				dp[i][0] = dp[i - 1][0];
			}
			else
			{
				dp[i][0] = dp[i - 1][0] + 1;
			}
		}
		else
		{
			dp[i][0] = dp[i - 1][0];
		}
	}
	for (int j = 0; j < W; j++)
	{
		int i = 0;
		if (chars[0][j] == '#')
		{
			if (chars[0][j - 1] == '#')
			{
				dp[0][j] = dp[0][j - 1];
			}
			else
			{
				dp[0][j] = dp[0][j - 1] + 1;
			}
		}
		else
		{
			dp[i][j] = dp[0][j - 1];
		}
	}
	for (int i = 1; i < H; i++)
	{
		for (int j = 1; j < W; j++)
		{
			if (chars[i][j] == '#')
			{
				if (chars[i - 1][j] == '#')
				{
					a = dp[i - 1][j];
				}
				else
				{
					a = dp[i - 1][j] + 1;
				}
				if (chars[i][j - 1] == '#')
				{
					b = dp[i][j - 1];
				}
				else
				{
					b = dp[i][j - 1] + 1;
				}
				dp[i][j] = min(a, b);
			}
			else
			{
				dp[i][j] = min(dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}
	cout << dp[H - 1][W - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
/*
 * taete.cpp
 *
 *  Created on: 2018/04/26
 *      Author: J01003
 */
#include<iostream>
using namespace std;

int main(){

	int  W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(x<r){
		cout<<"No"<<endl;
	}else if(y<r){
		cout<<"No"<<endl;
	}else if(W-r<x){
		cout<<"No"<<endl;
	}else if(H-r<y){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}

	return 0;
}






Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll n;
cin>>n;
ll a[n]={};
ll f=0;
ll counter=10000000;
ll ca=0;
for(ll i=0; i<n; i++){
cin>>a[i];}
for(ll i=-100; i<=100; i++){
for(ll j=0; j<n; j++){
ca+=(a[j]-i)*(a[j]-i);}
counter=min(ca,counter);
ca=0;}
cout<<counter<<endl;}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#define N 100005
using namespace std;
typedef long long ll;
int vis[N],a[N];
void creat()
{
    for(int i=2; i<=400; i++)
    {
        if(!vis[i])
        {
            for(int j=i*2; j<=N; j+=i)
                vis[j]=1;
        }
    }
}
int main()
{

    memset(vis,0,sizeof(vis));
    creat();
    vis[1]=1;
    int sum=0,n;
    for(int i=1; i<=N; i++)
    {
        if(i%2==1)
        {
            if(vis[i]==0&&vis[(i+1)/2]==0)
                sum++;
        }

        a[i]=sum;
    }
    while(scanf("%d",&n)==1)
    {
        while(n--)
        {
            int c,b;
            scanf("%d%d",&c,&b);

            printf("%d\n",a[b]-a[c-1]);
        }
    }
}

Measured memory_bytes: 1408
const MOD: usize = 998244353;
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let x = sc
        .chars()
        .into_iter()
        .map(|c| if c == '0' { 0 } else { 1 })
        .collect::<Vec<_>>();

    let mut ans = vec![0; n * 2 + 1];

    for k in 2..(n * 2 + 1) {
        if (n * 2) % k != 0 || n % k == 0 {
            continue;
        }
        assert_eq!(k % 2, 0);
        let mut dp = [[0; 2]; 2];
        dp[0][0] = 1;
        for i in 0..(k / 2) {
            let x = x[i];
            let mut next = [[0; 2]; 2];
            for prev in 0..2 {
                for next_bit in 0..2 {
                    for below in 0..2 {
                        if below == 0 && next_bit > x {
                            continue;
                        }
                        let next_below = if next_bit < x { 1 } else { below };
                        next[next_below][next_bit] += dp[below][prev];
                        if next[next_below][next_bit] >= MOD {
                            next[next_below][next_bit] -= MOD;
                        }
                    }
                }
            }
            dp = next;
        }

        let below = (dp[1][0] + dp[1][1]) % MOD;
        let half = (dp[0][0] + dp[0][1]) % MOD;

        let mut ok = true;
        for i in 0..n {
            let t = i % (k / 2);
            let s = i % k;
            let y = if t == s { x[t] } else { x[t] ^ 1 };
            if x[i] < y {
                ok = false;
                break;
            }
            if x[i] > y {
                break;
            }
        }

        ans[k] = if ok { (below + half) % MOD } else { below };
    }

    for i in 1..(2 * n + 1) {
        let mut cur = 2 * i;
        while cur <= 2 * n {
            if ans[cur] > 0 {
                ans[cur] = (ans[cur] + MOD - ans[i]) % MOD;
            }
            cur += i;
        }
    }

    let ans = ans
        .into_iter()
        .enumerate()
        .fold(0, |ans, (i, v)| (ans + i * v) % MOD);
    println!("{}", ans);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 10492
I=lambda:map(int,input().split());F=1e21;r=range;n,m=I();f=[-F,F];X=[0]+f;Y=X[:];R=[(f,F),(f,-F)];H=[(F,f),(-F,f)]
for i in r(n):*a,c=I();R+=[(a,c)];Y+=[c];X+=a
for i in r(m):a,*b=I();H+=[(a,b)];X+=[a];Y+=b
def g(X):s=dict(enumerate(sorted(set(X))));return{s[i]:i for i in s},s,len(s)
h,s,K=g(X);w,t,L=g(Y);j=lambda:[[0]*(K+2)for i in r(L+2)];V=j();U=j();v=j()
for(a,b),c in R:U[w[c]][h[a]]+=1;U[w[c]][h[b]]+=-1
for d,(e,f)in H:V[w[e]][h[d]]+=1;V[w[f]][h[d]]+=-1
for i in r(L+1):
 for j in r(K+1):U[i][j+1]+=U[i][j];V[i+1][j]+=V[i][j]
q=[(h[0],w[0])];v[w[0]][h[0]]=1;a=0
while q:
 x,y=q.pop();a+=(s[x]-s[x+1])*(t[y]-t[y+1])
 for e,f in[(-1,0),(1,0),(0,1),(0,-1)]:
  c=x+e;d=y+f
  if(K>c>=0<=d<L)*v[d][c]==0:
   if U[(f>0)+y][x]|e==0 or V[y][(e>0)+x]|f==0:q+=[(c,d)];v[d][c]=1
if a>F:a='INF'
print(a)

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

void bubbleSort(int A[], int N, int& cnt) {
  int temp, flag = 1;
  while (flag) {
    flag = 0;
    for (int i = N-1; i > 0; i--) {
      if ( A[i] < A[i-1] ) {
        temp = A[i];
        A[i] = A[i-1];
        A[i-1] = temp;
        flag = 1;
        cnt++;
      }
    }
  }
}

int main() {
  int N, j, cnt;
  int A[100];
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  cnt = 0;
  bubbleSort(A, N, cnt);

  for (int i = 0; i < N; i++) {
    if ( i != 0 ) cout << " ";
    cout << A[i];
  }
  cout << endl << cnt << endl;

  return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
int N,sum,a;
int main()
{
	cin>>N;
	vector<int> h(N), max(N);
	for (int i = 0; i < N; i++) cin>>h[i],max[i]=h[i];
	sort(max.begin(),max.end());
	int MAX=max[max.size()-1];
	for (int i=0;i<MAX;i++)
		for (int j=0;j<N;j++)
		{
			if (h[j]>i)
			{
				a++;
				if (j==0)
				{
					if (i>=h[j+1] && a>0) sum++,a=0;
				}
				else if (j==N-1)
				{
					if (a>0) sum++,a=0;
				}
				else if (i>=h[j+1] && a>0) sum++,a=0;
			}
			else a=0;
		}
	cout<<sum;
	return 0;
}

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

int n;
map<int, int> d;

int main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) {
		int a; cin >> a;
		d[a]++;
	}
	
	int ans = 0;
	for (map<int, int>::iterator it = d.begin(); it != d.end(); it++) {
		int num = it->first;
		int cnt = it->second;
		if (cnt < num) ans += cnt;
		else ans += cnt - num;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4736
dic={"a":0,"b":1,"c":2}
ddic={0:"A",1:"B",2:"C"}
a=[[dic[j] for j in input()][::-1] for i in range(3)]
turn=0

while True:
    if len(a[turn])==0:
        print(ddic[turn])
        break
    po=a[turn].pop()
    turn=po

Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
abc = []

for i in range(0,n):
	if a[i] % 2 == 0:
		abc.append(a[i])

k=len(abc)

for i in range(0,k):
	if abc[i] % 3 != 0 and abc[i] % 5 != 0:
		print("DENIED")
		exit()

print("APPROVED")



Measured memory_bytes: 3060
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
int n,p;
bool prime[150050];//1000000までの素数を求める
void isprime(){
	for(int i = 0;i <150000;i++){
		prime[i] = true;
	}
	prime[0] = false;
	prime[1] = false;
	for(int i = 2;i*i<150000;i++){
		if(prime[i]){
			for(int j = 2*i;j <150000;j+=i){//素数の倍数は素数ではない
				prime[j]= false;
			}
		}
	}
	return;
}


priority_queue<int, vector<int>, greater<int> > pque;
int main(){
	isprime();
	while(cin>>n>>p){
		if(n==-1&&p==-1){
			break;
		}
		int j = n;
		vector<int> que;
		que.clear();
		while(!pque.empty()){
			pque.pop();
		}
		for(int cnt = 0;cnt <=150;cnt++){
			j++;
			while(!prime[j]){
				j++;
			}
			//cout <<j<<endl;
			que.push_back(j);
		}
		for(int i = 0;i <=150;i++){
			for(int j = i;j <=150;j++){
				int matu =que[i] +que[j];
				pque.push(matu);
			}
		}
		for(int i = 0;i <p-1;i++){
			pque.pop();
		}
		cout<<pque.top()<<endl;
	}
	return 0;
}

Measured memory_bytes: 1476
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	int N;
	string S;

	cin >> N >> S;

	int x = 0;
	int max_x = 0;

	for (int i = 0; i < N; i++)
	{
		if (S[i] == 'I') {
			x++;
		}
		else {
			x--;
		}
		chmax(max_x,x);
	}

	cout << max_x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int a, b, c;

signed main() {
	cin >> a >> b >> c;
	
	c -= a - b;
	cout << max(0, c) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;

// t x:0 o:1
// u W:0 S:1
int main() {
  int n, t[101000], u[101000];
  char s[101000];
  scanf("%d", &n);
  scanf("%s", s);
  for(int i=0; s[i]; i++) {
    t[i] = s[i] == 'x' ? 0 : 1;
  }
  for(int j=0; j<4; j++) {
    u[0] = (j >> 1) & 1;
    u[1] = j & 1;
    for(int k=2; k<n; k++) {
      u[k] = u[k-2] ^ u[k-1] ^ t[k-1];
    }
    if((u[n-1] ^ u[0] ^ u[1] ^ t[0]) | (u[n-2] ^ u[n-1] ^ u[0] ^ t[n-1])) {
      continue;
    } else {
      for(int l=0; l<n; l++) {
        printf("%c", u[l] ? 'S' : 'W');
      }
      printf("\n");
      return 0;
    }
  }
  printf("-1");
  return 0;
}

Measured memory_bytes: 1152
n = int(input())
S = []
H = []
C = []
D = []
 
for x in range(0,n):
    L = raw_input().split()
    if L[0] == "S": S.append(int(L[1]))
    elif L[0] == "H": H.append(int(L[1]))
    elif L[0] == "C": C.append(int(L[1]))
    else: D.append(int(L[1]))
 
for x in range(1,14):
    if not x in S: print "S {}".format(x)
for x in range(1,14):
    if not x in H: print "H {}".format(x)
for x in range(1,14):
    if not x in C: print "C {}".format(x)
for x in range(1,14):
    if not x in D: print "D {}".format(x)

Measured memory_bytes: 6452
n,m = map(int,input().split())
ANS = [[0] * 2 for i in range(m)]

a = 0
b = 1
c = 0
f = 1
for i in range(m):
    if n%2 == 0 and (c+2) > n//2 and f == 1:
        b = (b+1) % n
        f = 0
    ANS[i] = [a, b]
    c += 2
    a = (a-1) % n
    b = (b+1) % n
    

for i in range(m):
    print(ANS[i][0]+1, ANS[i][1]+1)

Measured memory_bytes: 81404
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static class Pair implements Comparable<Pair> {
		int key;
		long value;
		
		public Pair(int key, long value) {
			this.key = key;
			this.value = value;
		}

		@Override
		public int compareTo(Pair o) {
			return -Long.compare(this.value, o.value);
		}
	}
	
	public static final int INF = Integer.MAX_VALUE / 2 - 1;
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int D = sc.nextInt();
			final int G = sc.nextInt() / 100;
			
			int[] ps = new int[D];
			int[] cs = new int[D];
			for(int i = 0; i < D; i++) {
				ps[i] = sc.nextInt();
				cs[i] = sc.nextInt() / 100;
			}
			
			int[] DP = new int[G + 1];
			Arrays.fill(DP, INF);
			
			DP[0] = 0;
			for(int i = 0; i < D; i++) {
				for(int value = DP.length - 1; value >= 0; value--) {
					if(DP[value] >= INF) { continue; }
					
					for(int cnt = 1; cnt < ps[i]; cnt++) {
						final int next = Math.min(G, value + (i + 1) * cnt);
						DP[next] = Math.min(DP[next], DP[value] + cnt);
					}
					final int comp = Math.min(G, value + (i + 1) * ps[i] + cs[i]);
					DP[comp] = Math.min(DP[comp], DP[value] + ps[i]);
				}
			}
			
			System.out.println(DP[G]);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

struct N {
  string s;
  int p, i;
};

bool operator<(const N &l, const N &r) {
  if (l.s == r.s) {
    return l.p > r.p;
  }
  return l.s < r.s;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<N> ns(n);
  for (int i = 0; i < n; i++) {
    cin >> ns[i].s >> ns[i].p;
    ns[i].i = i;
  }
  sort(ns.begin(), ns.end());
  for (auto &v : ns) {
    cout << v.i + 1 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define INF 0x3f3f3f3f
const int maxn=1e5+10;
#define _rep(i,a,b) for(int i=(a);i<=(b);++i)
int n,m,Q,a[maxn],b[maxn],mina=INF,minb=INF,ans=INF;

int main()
{
    #ifdef __LOCAL__
        freopen("1.in","r",stdin);
        freopen("1.out","w",stdout);
    #endif
    int x,y,c;
    scanf("%d%d%d",&n,&m,&Q);
    _rep(i,1,n)
        scanf("%d",&a[i]),mina=min(mina,a[i]);
    _rep(i,1,m)
        scanf("%d",&b[i]),minb=min(minb,b[i]);
    ans=min(ans,mina+minb);
    _rep(i,1,Q)
    {
        scanf("%d%d%d",&x,&y,&c);
        ans=min(ans,a[x]+b[y]-c);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ctime>
#include <cstdlib>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main()
{
    string S, T;
    cin >> S >> T;
    int count = 0;
    rep(i, S.size())
    {
        if (S[i] == T[i])
        {
            count++;
        }
    }
    cout << count << endl;
}

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

int main() {
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    for (int i=0; i<S.size()-1; i++) {
        if (S.at(i)==S.at(i+1)) {
            cout << "no\n";
            return 0;
        }
    }
    cout << "yes\n";
}

Measured memory_bytes: 256
H, W  = [int(x) for x in input().split()]
a_s = [input() for _ in range(H)]

rs = []
for a in a_s:
    if "#" in a:
        rs.append(a)
ans = ["" for _ in rs]
for i in range(W):
    comp = True
    for r in rs:
        if r[i] == "#":
            comp = False
    if not comp:
        for j, r in enumerate(rs):
            ans[j] += r[i]

print("\n".join(ans))


Measured memory_bytes: 3060