akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#define mod 1000000007
using namespace std;

int n,x,y,z;
int dp[42][1000010];

int main(){
	scanf("%d %d %d %d",&n,&x,&y,&z);int p=(1<<(x+y+z))-1,di=(1<<(x+y+z-1))|(1<<(y+z-1))|(1<<(z-1));
	dp[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=p;j++){
			for(int k=1;k<=10;k++){
				int dq=((j<<k)|(1<<(k-1)))&p;
				if((dq&di)==di)continue;
				dp[i+1][dq]=(dp[i+1][dq]+dp[i][j])%mod;
			}
		}
	}int ans=1;
	for(int i=1;i<=n;i++){
		ans=((long long)ans*10)%mod;
	}
	for(int i=0;i<=p;i++){
		ans=(ans-dp[n][i])%mod;
	}printf("%d\n",(ans+mod)%mod);return 0;
}

Measured memory_bytes: 104576
#include<bits/stdc++.h>
using namespace std;
#define ll      long long int
#define MOD     1000000007
#define pb      push_back
#define mp      make_pair
#define all(v)  (v).begin(),(v).end();
#define T		int t;cin>>t;while(t--)
#define IOS     ios_base::sync_with_stdio(false);cin.tie(NULL);

int main() {


	int N;
	cin >> N;

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

	int dp[N + 1];
	for (int i = 0 ; i < N + 1; i++)dp[i] = INT_MAX;

	dp[0] = 0;

	dp[1] = dp[0] + abs(h[1] - h[0]);

	for (int  i = 2 ; i < N ; i++ ) {

		dp[i] = min ( dp[i] , min(dp[i - 1] + abs(h[i] - h[i - 1]) , dp[i - 2] + abs(h[i] - h[i - 2])));

	}

	cout << dp[N - 1] << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long A, B, Q;
  cin >> A >> B >> Q;
  vector<long> s(A); rep (i, A) cin >> s[i]; sort(s.begin(), s.end());
  vector<long> t(B); rep (i, B) cin >> t[i]; sort(t.begin(), t.end());
  rep (i, Q) {
    long s_left = -1000000000000000l;
    long s_right = 1000000000000000l;
    long t_left = -1000000000000000l;
    long t_right = 1000000000000000l;
    long x;
    cin >> x;
    auto it_s = lower_bound(s.begin(), s.end(), x);
    if (it_s != s.begin()) s_left = *(it_s - 1);
    if (it_s != s.end()) s_right = *(it_s);
    auto it_t = lower_bound(t.begin(), t.end(), x);
    if (it_t != t.begin()) t_left = *(it_t - 1);
    if (it_t != t.end()) t_right = *(it_t);

    long ans = max(abs(s_right - x), abs(t_right - x));
    ans = min(ans, max(abs(s_left - x), abs(t_left - x)));
    ans = min(ans, abs(s_left - x) * 2 + abs(t_right - x));
    ans = min(ans, abs(t_left - x) * 2 + abs(s_right - x));
    ans = min(ans, abs(s_right - x) * 2 + abs(t_left - x));
    ans = min(ans, abs(t_right - x) * 2 + abs(s_left - x));

    cout << ans << endl;
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 2944
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 998244353LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#ifdef LOCAL_ENV
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define DUMP(x)
#define DEBUG(x)
#endif

#define MAX_VALUE 9223372036854775807LL

template <ull N, class T, class... Args, std::enable_if_t<N == 0, int> = 0>
auto make_multiple_vector(Args... args) {
    return T(args...);
}

template <ull N, class T, class... Args, std::enable_if_t<N != 0, int> = 0>
auto make_multiple_vector(ull size, Args... args) {
    using value_type = std::decay_t<decltype(make_multiple_vector<N - 1, T>(args...))>;
    return vector<value_type>(size, make_multiple_vector<N - 1, T>(args...));
}

int solve() {
	ll n;
	cin >> n;
	--n;

	ll res = 0;
	REPD(a, 1, n + 1) {
		res += n / a;
	}



	RET(res);

	return 0;
}

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

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  cout << (b%a == 0 ? a+b : b-a) << endl;

  return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

int calc(int k, int[] xs) {
    int ans = 0; // k 個のグループの個数
    int p = 0;
    while (p+1 < xs.length) {
        p += k - 1;
        ans++;
    }
    return ans;
}

void main() {
    auto nk = readints;
    int k = nk[1];
    auto xs = readints;

    auto ans = calc(k, xs);
    writeln(ans);
}



Measured memory_bytes: 4100
#include<stdio.h>
int N,M,t,r=0,i,j,x;
int main()
{
	scanf("%d%d",&N,&M);
	for(i=0;i<N;i++)
	{
		for(t=j=0;j<M;j++)
		{
			scanf("%1d",&x);
			t+=x;
		}
		r=r<t?t:r;
	}
	printf("%d\n",r);
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
//#pragma GCC optimize ("-O3")

using namespace std;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//const long double PI = 3.14159265358979323846;  /* pi */

int main() {
    //ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int k;
	cin >> k;
	vector<bool> visited(k, false);
	int val = 0;
	int ans = 0;
	for (int i = 0; i < 1e6; i++)
	{
		ans ++;
		val = val * 10 + 7;
		val = val % k;
		int rem = val % k;
		if (visited[rem])
			break;
		visited[rem] = true;
		if (rem == 0)
			break;
	}
	if (visited[0])
		cout << ans << "\n";
	else
		cout << -1 << "\n";
	return 0;
}


Measured memory_bytes: 3732
from math import sqrt


def main():
    a, b, c = map(int, input().split())
    if c - a - b < 0:
        print('No')
        exit()

    if 4 * a * b < (c - a - b) * (c - a - b):
        print('Yes')
    else:
        print('No')


main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
	
#define ll long long
#define endl '\n'
 
// template < typename T >
// void self_max(T &a, T b){a = max(a, b);}
// template < typename T >
// void self_min(T &a, T b){a = min(a, b);}

void solve(){
	int n; cin>>n;
	cout<<(!n)<<endl;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1; //cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define TRUE 1
#define FALSE 0

typedef struct{
  int stk[1000];
  int top;
}Stack;

Stack S;

int isEmpty();
void push(int);
int pop();

int main(){
  int x;
  int a, b;
  char s[100];

  S.top = 0;

  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a+b);
    }
    
    else if(s[0] == '-'){
      a = pop();
      b = pop();
      push(b-a);
    }
    
    else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a*b);
    }

    else{
      x = atoi(s);
      push(x);
    }
  }

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

  return 0;
}

int isEmpty(){
  if(S.top == 0)
    return TRUE;

  else
    return FALSE;
}

void push(int x){
  S.top++;
  S.stk[S.top] = x;
}

int pop(){
  if(isEmpty()){
    fprintf(stderr,"underflow!!");
    exit(8);
  }

  else
    S.top--;

  return S.stk[S.top + 1];
}



Measured memory_bytes: 2144
#include<stdio.h>
#include<algorithm>
#define INF 0x3f3f3f3f
#define maxn 100010
using namespace std;

struct node
{
    int l,r;
}bri[maxn],a[maxn];

bool cmp(node a,node b);

int main()
{
    int i,j,n,m,flag,cnt = 1;
    bri[0].l = -1,bri[0].r = INF;
    scanf("%d%d",&n,&m);
    for(i = 0; i < m; i++)
        scanf("%d%d",&a[i].l,&a[i].r);
    sort(a,a+m,cmp);
    for(i = 0; i < m; i++)
    {
        flag = 0;
        for(j = 0; j < cnt; j++)
        {
            if(a[i].l >= bri[j].r || a[i].r <= bri[j].l) continue;
            flag = 1;
            bri[j].l = max(bri[j].l,a[i].l);
            bri[j].r = min(bri[j].r,a[i].r);
            break;
        }
        if(!flag)
        {
            bri[cnt].l = a[i].l;
            bri[cnt].r = a[i].r;
            cnt++;
        }
        sort(bri,bri+cnt,cmp);
    }
    printf("%d\n",cnt);
    return 0;
}

bool cmp(node a,node b)
{
    if(a.r == b.r)
        return a.l < b.l;
    return a.r < b.r;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;


const int MAX = 510000;

long long 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(int n, int 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(){
    ll N,K; cin>>N>>K;
    ll blue = K;
    ll red = N-K;

       // 前処理
    COMinit();

    ll dp[2100][2100];
    for(int i=0;i<=2050;i++){
        for(int j=0;j<=2050;j++){
            dp[i][j] = 0;
        }
    }

    

    for(int i=1;i<=2050;i++){
        dp[1][i] = 1;
    }

    
    for(int i = 2;i<=2010;i++){
        ll now = 0;
        for(int sum = i; sum<=2010;sum++){
           now += dp[i-1][sum-1];
           ////cout<<i-1<<' '<<sum-1<<endl;
         //  cout<<now<<endl;
         now = now % 1000000007;
           dp[i][sum] = now;
        }
    }

    for(int i=1;i<=K;i++){
        ll ans = COM(N-K+1,i);
        ans  = ans * dp[i][K];
        ans = ans % MOD;
        cout<<ans<<endl;
    }
    

    return 0 ;
}

Measured memory_bytes: 46592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

ll MOD = pow(10, 9) + 7;

ll powmod(ll a, ll p, ll MOD) {
	ll ans = 1;
	ll mul = a;
	for (; p > 0; p >>= 1, mul = (mul * mul) % MOD) {
		if ((p & 1) == 1)ans = (ans * mul) % MOD;
	}
	return ans;
}

ll combmod(ll n, ll r, ll MOD){
  if(n < r) return 0LL;
  if (n < 0 || r < 0) return 0LL;
  vector<ll> ff(n+1), vff(n+1);
  // 1! ~ n!
  ff[0] = 1;
  for(ll i = 1; i < n + 1; i++) {
    ff[i] = ff[i - 1] * i % MOD;
  }
  // n!^(MOD-2) (= n!^(-1))
  ll inv = powmod(ff[n], MOD - 2, MOD);

  // n!^(-1) ~ 1!^(-1)
  vff[n] = inv;
  for(ll i = n - 1; i >= 0; i--) {
    vff[i] = vff[i + 1] * (i + 1) % MOD;
  }

  // n combination r
  ll comb = (((ff[n] * vff[r]) % MOD) * vff[n - r]) % MOD;

  return comb;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

ll g(ll a, ll b){
    return combmod(a + b + 2, a+1, MOD) - 1;
}

int main() {

    ll r1, c1, r2, c2;
    cin >> r1 >> c1 >> r2 >> c2;

    r1--;
    c1--;

    ll ans = g(r2, c2);
    ans = (ans + MOD -  g(r2, c1)) % MOD;
    ans = (ans + MOD -  g(r1, c2)) % MOD;
    ans = (ans + g(r1, c1)) % MOD;

    cout << ans << endl;
    return 0;
}

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

int main() {
  int P,Q,R;
  cin >> P >> Q >> R;
  vector<int> vec(3);
  vec = { P, Q, R};
  sort(vec.begin(), vec.end());
  cout << vec.at(0) + vec.at(1) <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
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 (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i,n-1){
        int a;
        cin >> a;
        mp[a-1]++;
    }
    rep(i,n){
        cout << mp[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 12980
#pragma G++ optimize (2)
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <string>
#define INF 0x3f3f3f3f
#define NO 30005
#define MO 100005
typedef long long ll;
//by Oliver
using namespace std;
ll read()
{
	char ch = ' ', last;
	ll ans = 0;
	while (ch < '0' || ch > '9')
		last = ch, ch = getchar();
	while (ch >= '0' && ch <= '9')
		ans = ans * 10 + int(ch - '0'), ch = getchar();
	if (last == '-')
		return -ans;
	return ans;
}
void write(ll x)
{
	if (x >= 10)
		write(x / 10);
	putchar(x % 10 + '0');
}
//head

int X, Y;
//variable

void init()
{
	X = read(), Y = read();
}
//functions

int main()
{
	init();
	cout << X + Y / 2 << endl;
	return 0;
}
//main


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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define repr(i, n) for (ll i = n - 1; i >= 0; --i)
#define INF 10e12
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

void solve(void)
{
    int n;
    cin >> n;
    vector<vector<int>> day(n, vector<int>(10));
    vector<vector<int>> cost(n, vector<int>(11));
    rep(i, n) rep(j, 10) cin >> day[i][j];
    rep(i, n) rep(j, 11) cin >> cost[i][j];
    ll ans = -INF;
    rep(i, 1 << 10)
    {
        if (i == 0)
            continue;
        vector<int> joisimo(10, 0);
        rep(j, 10) if (i >> j & 1) joisimo[j] = 1;
        ll res = 0;
        int cta;
        rep(j, n)
        {
            cta = 0;
            rep(k, 10) if (joisimo[k] == day[j][k] && joisimo[k] == 1)
                cta++;
            res += cost[j][cta];
        }
        ans = max(ans, res);
    }
    cout << ans << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3540
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int K; cin >> K;
    int A,B; cin >>A>>B;
    for(int i = A; i <= B; i++){
        if(i%K == 0){
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;

}

Measured memory_bytes: 3652
N, K = map(int, input().split(' '))
R, S, P = map(int, input().split(' '))
T = input()
 
flags = [0] * len(T)
 
point_map = {'r': P, 's': R, 'p': S}
 
point_sum = 0
 
for i, t in enumerate(T):
    if i < K:
        point_sum += point_map[t]
        continue
    if t == T[i-K] and not flags[i-K]:
        flags[i] = 1#勝ちを0，勝てなかったことをを1で表現している
        continue
    point_sum += point_map[t]

print(point_sum)

Measured memory_bytes: 4084
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef int64_t llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64


int main(){
    int r,g,b;
    cin >> r >> g >> b;
    if((10*g + b) %4 == 0) cout <<  "YES" << endl;
    else cout << "NO" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);

ll dp[2010][2]={};//iより先からとれる

signed main(){
    ll n,x,y;cin>>n>>x>>y;

    vector<ll> a(n);
    rep(i,n)cin>>a[i];

    if(1<n){
        dp[n][0]=abs(a[n-1]-a[n-2]);
        dp[n][1]=abs(a[n-1]-a[n-2]);
    }else{
        cout<<abs(y-a[0])<<endl;
        return 0;
    }

    for(int i=n-1;0<=i;i--)
    {
        for(int j=i+1;j <= n;j++)
        {   
            if(0<i)dp[i][0]=max(dp[j][1],abs(a[i-1]-a[n-1]));
            else dp[i][0]=max(dp[j][1],abs(y-a[n-1]));
        }

        for(int j=i+1;j <= n;j++)
        {
            dp[i][1]=INF;
            if(0<i)dp[i][1]=min(dp[j][0],abs(a[i-1]-a[n-1]));
            else dp[i][1]=min(dp[j][0],abs(x-a[n-1]));
        }
        //cout<<dp[i][0]<<":"<<dp[i][1]<<endl;
    }

    cout<<dp[0][0]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
#define MAXN 100005
#define INF 1000000005
#define LINF 1000000000000000005

int n;

long long k,a[100005],b[100005],t,ans;

bool bit(int t, int b){
    return (t/(1<<b))%2;
}

bool good(int t, int b){
    for(int i=30;i>b;i--){
        if(bit(t,i) && !bit(k,i)) return 0;
    }
    if(bit(t,b)) return 0;
    return 1;
}

bool goood(int t){
    for(int i=30;i>=0;i--){
        if(bit(t,i) && !bit(k,i)) return 0;
    }
    return 1;
}

int32_t main(){
    ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();
    cin >> n >> k;
    for(int i=1;i<=n;i++){
        cin >> a[i] >> b[i];
    }
    for(int i=30;i>=0;i--){
        t=0;
        if(!bit(k,i)) continue;
        for(int j=1;j<=n;j++){
            if(good(a[j],i)) t+=b[j];
        }
        ans=max(ans,t);
    }
    t=0;
    for(int j=1;j<=n;j++){
        if(goood(a[j])) t+=b[j];
    }
    ans=max(ans,t);
    cout << ans;
}


Measured memory_bytes: 1792
from collections import deque
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]
ans = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == ".":
            visited = [[0 for _ in range(w)] for _ in range(h)]
            visited[i][j] = 1
            que = deque([])
            que.append((i, j, 0))
            while que:
                (x, y, cnt) = que.popleft()
                for (nx, ny) in (x+1,y), (x-1, y), (x, y+1), (x, y-1):
                    if 0<=nx<h and 0<=ny<w:
                        if s[nx][ny] == "." and visited[nx][ny] == 0:
                            que.append((nx, ny, cnt+1))
                            visited[nx][ny] = 1
            ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
using namespace std;
 
int main()
{
  char suit[4] = { 'S','H','C','D', };
  vector<vector<bool> > m(4,vector<bool>(13,true));
  int n;
  cin >> n;
  for(int i=0; i<n; i++){
    char c;
    int j;
    cin >> c >> j;
    switch(c){
    case 'S': m[0][j-1] = false; break;
    case 'H': m[1][j-1] = false; break;
    case 'C': m[2][j-1] = false; break;
    case 'D': m[3][j-1] = false; break;
    }
  }
  for(int i=0; i<4; i++){
    for(int j=0; j<13; j++){
      if(m[i][j]) cout << suit[i] << " " << j+1 << endl;
    }
 }
  return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
    N4RUTO;
    int a,b;
    cin>>a>>b;
    loop(i,1,100000){
        if(floor(i*0.08)==a && floor(i*0.1)==b){
            cout<<i;
            return 0;
        }
    }
    cout<<"-1";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll a[26],b[26];
int main() {
	string s;
	cin>>s;
	for(ll i=0;i<26;i++){
		b[i]=-1;
	}
	for(ll i=0;i<s.size();i++){
		ll now=s[i]-'a';
		ll sa=i-b[now]-1;
		a[now]=max(a[now],sa);
		b[now]=i;
	}
	ll ans=inf;
	for(ll i=0;i<26;i++){
		ll now=s.size()-1-b[i];
		a[i]=max(a[i],now);
		ans=min(ans,a[i]);
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,l;
	cin>>n>>l;
	string s[n];
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
	} 
	sort(s,s+n);
	string ans="";
	for(int i=0;i<n;i++)
	{
		ans=ans+s[i];
	}
	cout<<ans;
}

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

using LL = long long;
using ULL = unsigned long long;

using namespace std;

int main()
{
    int a, b, ans = 0;
    double temp;

    cin >> a >> b;
    temp = ((double)a + (double)b) / 2.0;
    //cout << temp << endl;

    ans = (int)temp;
    if ((temp - (int)temp) > 0) ans += 1;

    cout << ans << endl;
    return 0;
}

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

int main() {
  ll N;
  ll A = 1,B = N;
  cin >> N;
  for (int i=2;i <= sqrt(N); i++) {
    if (N%i == 0)  A = i;
  }
  B = N / A;
  cout << A + B - 2 << endl;
}

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

 int main(){
    string S;

    cin >> S;

    if (S == "Sunny")
        cout << "Cloudy" <<endl;
    else if (S == "Cloudy")
        cout << "Rainy" <<endl;
    else
        cout << "Sunny" <<endl;        
        
    return 0;
 }



Measured memory_bytes: 256
#include <iostream>
#define int long long
using namespace std;

int y;

//6,5,6,5…

signed main() {
	cin >> y;
	
	int ans = (y / 11) * 2;
	if (y % 11 > 6) ans += 2;
	else if (y % 11 > 0) ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long int     ll;
typedef  vector<int>       vi;
typedef  pair<int,int>     pii;
//#define  int               ll
#define  F                 first
#define  S                 second
#define  pb                push_back
#define  mp                make_pair 
#define  si(x)             (int)x.size()
#define  all(x)            x.begin(),x.end()
#define  minv(m,n)         *min_element(m,n)      
#define  maxv(m,n)         *max_element(m,n)
#define  mem(a,x)          memset(a,x,sizeof(a))
#define  rep(i,n)          for(int i=0; i<n;i++)
#define  prs(x)            fixed <<setprecision(x)
#define  w(ttz)            int ttz;cin>>ttz;while(ttz--)
#define  show(a)           for(auto x:a){cout<<x<<" ";}cout<<endl;
#define  mod               100000007
void iosbase(void);

int main() 
{   
  	iosbase();
  	char c;
  	cin>>c;
  	if( c>= 97)
  	{
  		cout<<"a"<<endl;
  	}
  	else
  	{
  		// c=c+32;
  		cout<<"A"<<endl;
  	}
  	return 0;


}


void iosbase(void){
//ios::sync_with_stdio(false);
//cin.tie(nullptr);cout.tie(nullptr);
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif 
}

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

int main(int argc, char** argv){
  int menu[5];
  for(int cnt0=0; cnt0<5; cnt0++) cin >> menu[cnt0];

  int minRem = 10;
  int sum = 0;
  for(int cnt0 = 0; cnt0 < 5; cnt0++){
    int tmpRem = menu[cnt0] % 10;
    if(tmpRem == 0) {
      sum += menu[cnt0];
    }else{
      minRem = min(minRem, tmpRem);
      sum += (menu[cnt0]/10 + 1) *10; 
    }
  }
  cout << sum - 10 + minRem << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <stdexcept>
#include <iostream>
#include <sstream>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <cctype>
#include <vector>
#include <string>
#include <bitset>
#include <cmath>
#include <queue>
#include <stdio.h>
#include <stack>
#include <ctime>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <assert.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define TR(i,x) for(__typeof(x.begin()) i=x.begin();i!=x.end();i++)
#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(ALL(x))
#define CLEAR(x) memset(x,0,sizeof(x))
#define FILL(x,c) memset(x,c,sizeof(x))
#define PB push_back
#define MP make_pair

using namespace std;

const double eps = 1e-8;

typedef map<int,int> MII;
typedef map<string,int> MSI;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<long double> VD;
typedef pair<int,int> PII;
typedef long long int64;
typedef long long LL;
typedef unsigned int UI;
typedef long double LD;

/**
 * 6
 * khabarovsk 20
 * moscow 10
 * kazan 50
 * kazan 35
 * moscow 60
 * khabarovsk 40
 */
int main() {
    int n;
    cin >> n;
    map<string, priority_queue<pair<int, int> > > cop; // city_name -> pair<int, int> ( first -> score, second -> index)
    string line, city;
    int score;
    for (int i = 0; i < n; ++i) {
        cin >> city;
        cin >> score;
        if (cop.find(city) != cop.end()) {
            cop[city].push(make_pair(score, i + 1));
        } else {
            priority_queue<pair<int, int>> q;
            q.push(make_pair(score, i + 1));
            cop[city] = q;
        }
    }

    for (auto p : cop) {
        auto q = p.second;
        while (!q.empty()) {
            auto pa = q.top();
            q.pop();
            cout<<pa.second<<endl;
        }
    }

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# H-Grid


'''
5 2
..
#.
..
.#
..
'''


H, W = map(int, input().split())

data = [[None] * (W+1) for i in range(H+1)]
dp = [[0] * (W+1) for i in range(H+1)]

dp[0] = [0] * (W+1)

for i in range(H):
    temp = list(input())
    dp[i + 1][0] = 0
    for j in range(W):
        data[i + 1][j + 1] = temp[j]


for i in range(1, H + 1):
    for j in range(1, W + 1):
        if (i == 1) and (j == 1):
            dp[i][j] = 1
            continue

        if data[i][j] == '.':
            dp[i][j] = dp[i-1][j] + dp[i][j-1]
        else:
            dp[i][j] = 0

# print(dp)
print(dp[H][W] % (10**9+7))


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

bool dfs(int *p, int k){
	if(k >= 4)
		return true;

	bool res = false;
	for(int i = 1; i < 10 - 2; ++i){
		if(p[i] && p[i + 1] && p[i + 2]){
			p[i]--; p[i + 1]--; p[i + 2]--;
			res |= dfs(p, k + 1);
			p[i]++; p[i + 1]++; p[i + 2]++;
		}
	}
	for(int i = 1; i < 10; ++i){
		if(p[i] >= 3){
			p[i] -= 3;
			res |= dfs(p, k + 1);
			p[i] += 3;
		}
	}
	
	return res;
}

int main() {
	string s;
	while(cin >> s){
		int n[16] = {0};
		vector<int> ans;
		for(int i = 0; i < s.size(); ++i){
			n[s[i] - '0']++;
		}
		for(int i = 1; i < 10; ++i){
			n[i]++;
			if(n[i] > 4){
				n[i]--;
				continue;
			}
			bool res = false;
			for(int j = 1; j < 10; ++j){
				if(n[j] >= 2){
					n[j] -= 2;
					res |= dfs(n, 0);
					n[j] += 2;
				}
				if(res)
					break;
			}
			if(res)
				ans.push_back(i);
			n[i]--;
		}
		if(ans.empty()){
			cout << "0" << endl;
		}
		else{
			for(const auto& v : ans){
				if(ans[0] != v)
					cout << " ";
				cout << v;
			}
			cout << endl;
		}
	}
	return 0;
}

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

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main() {
    string s = "abcdefghijklmnopqrstuvwxyz";
    string t; cin>>t;
    
    rep(i, (int)s.size()){
        int tmp = t.find(s[i]);
        if(tmp >=0 && tmp<=(int)t.size())continue;
        else {
            cout<<s[i]<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
	return 0;
}

Measured memory_bytes: 3748
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int x,y,z,tmp;
    scanf("%d %d %d",&x, &y, &z);
    
    if(x > y){
        tmp = x;
        x = y;
        y = tmp;
    }
    if(y > z){
        tmp = y;
        y = z;
        z = tmp;
    }
    if(x > y){
        tmp = x;
        x = y;
        y = tmp;
    }
    printf("%d %d %d\n",x, y, z);
    return 0;
}



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

public class Main {
        public static void main(String[] args) throws IOException{
                final BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                int n=Integer.parseInt(br.readLine());
                
                for(int i=0;i<n;i++){
                        int line = 0;
                        String str1=br.readLine();
                        String str2=br.readLine();
                        int[][] x=new int[str1.length()+1][str2.length()+1];
                        //str1=" "+str1;
                        //str2=" "+str2;        
                        for(int j=1;j<=str1.length();j++){
                                for(int k=1;k<=str2.length();k++){
                                        char a=str1.charAt(j-1);
                                        char b=str2.charAt(k-1);
                                        if(a==b) x[j][k]=x[j-1][k-1]+1;
                                        else x[j][k]=Math.max(x[j-1][k],x[j][k-1] );
                                        line=Math.max(line, x[j][k]);
                                }
                                
                        }
                        
                        System.out.println(line);
                }
                br.close();
        }
}

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

#define null				""
#define all(dat)			dat.begin(), dat.end()
#define over(msg)			cout << msg << endl, exit(0);
#define loop(i, to)			for (int i = 0; i < to; ++i)
#define cont(i, to)			for (int i = 1; i <= to; ++i)
#define foreach(i, dat)		for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long			num;

using namespace std;

int n, mod = 1e9 + 7;
num dp[100005][2];
vector<int> g[100005];

void dfs(int u, int p) {
	num w = 1, b = 1;
	for (int v : g[u]) {
		if (v == p)  continue;
		dfs(v, u);
		b *= dp[v][0];
		b %= mod;
		w *= dp[v][0] + dp[v][1];
		w %= mod;
	}
	dp[u][0] = w;
	dp[u][1] = b;
}

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n;
	cont (i, n - 1) {
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1, -1);
	cout << (dp[1][0] + dp[1][1]) % mod << endl;
}


Measured memory_bytes: 14208
//
// Created by munaiyi on 2020/3/18.
//
#include <bits/stdc++.h>

using namespace std;

const int maxn = 2e5 + 5;

pair<int, int> monster[maxn], q[maxn];
int head, tail;

int main() {
    int n, d, a;
    scanf("%d%d%d", &n, &d, &a);
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &monster[i].first, &monster[i].second);
    }
    sort(monster, monster + n);
    head = tail = 0;
    long long ans = 0;
    long long now = 0;
    for (int i = 0; i < n; i++) {
        while (head < tail && q[head].first < monster[i].first) {
            now -= q[head].second;
            head++;
        }
        if (now < monster[i].second) {
            long long diff = monster[i].second - now;
            diff = (diff + a - 1) / a;
            ans += diff;
            diff = diff * a;
            now += diff;
            q[tail].second = diff;
            q[tail].first = monster[i].first + 2 * d;
            tail++;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3328
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);
            var foods = Enumerable.Repeat(0, K).ToArray();
            for (int i = 0; i < N; i++)
            {
                var A = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                for (int j = 1; j < A.Length; j++)
                {
                    foods[A[j] -1]++;
                }
            }
            Console.WriteLine(foods.Count(x => x == N));
        }
    }
}


Measured memory_bytes: 13780
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

#define endl '\n'
#define ll long long
const ll mod = 1000000007;

using namespace std;

ll sigma(ll n)
{
	return (n * (n + 1) / 2);
}

ll rsigma(ll n, ll k)
{
	return (sigma(n) - sigma(n - k));
}

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

	ll n, k;
	cin >> n >> k;

	ll cnt = 1;
	for (ll i = k; i < n + 1; i++)
	{
		ll mn = sigma(i - 1);
		ll mx = rsigma(n, i);
		cnt += (mx - mn + 1 ) % mod;
	}

	cout << cnt % mod << endl;

	return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>

int main(){
    int S, h, m, s;
    scanf("%d", &S);
    h = S / 3600;
    m = (S % 3600) / 60;
    s = S % 60;
    printf("%d:%d:%d\n",h, m, s);
  return 0;
}


Measured memory_bytes: 2124
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

ll x[200010], y[200010];
signed main(void)
{
	ll n;
	cin >> n;
	ll rmi = INF, rma = -1, bmi = INF, bma = -1;
	vector<pair<ll, ll>> xy;
	REP(i, n) {
		cin >> x[i] >> y[i];
		if(x[i] > y[i]) swap(x[i], y[i]);
		xy.emplace_back(x[i], i);
		rmi = min(rmi, x[i]);
		bmi = min(bmi, y[i]);
		rma = max(rma, x[i]);
		bma = max(bma, y[i]);
	}

	ll ans = (rma-rmi)*(bma-bmi);
	sort(ALL(xy));
	ll xymax = y[xy.front().second], xymin = y[xy.front().second],
		 d = xy.back().first - xy.front().first;
	REP(i, n) {
		d = min(d, max(xymax, xy.back().first) - min(xymin, xy[i].first));
		xymax = max(xymax, y[xy[i].second]);
		xymin = min(xymin, y[xy[i].second]);
	}
	d = min(d, xymax-xymin);
	rma = bma;
	ans = min(ans, (rma - rmi) * d);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 8432
#include<iostream>
#include<deque>
#include<list>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stack>
#include<queue>
#include<iterator>
#include<string>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;

signed main() {
	int r;
	string ans;
	cin >> r;
	if (r < 1200) {
		ans = "ABC";
	}
	else if (r < 2800)
	{
		ans = "ARC";
	}
	else ans = "AGC";

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
using ll = long long;
int MOD = 1e9 + 7;
using namespace std;
int main()
{
    int n;
    cin >> n;
    int T, X, Y;
    T = 0;
    X = 0;
    Y = 0;
    for (int i = 0; i< n;i++){
        int t, x, y;
        cin >> t >> x >> y;
        int k = t-T;
        if(k<abs(x-X)+abs(y-Y)){
            cout << "No" << endl;
            return 0;
        }
        if ((k-(abs(x - X) + abs(y - Y)))%2==1){
            cout << "No" << endl;
            return 0;
        }
        T = t;
        X = x;
        Y = y;
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000500
using namespace std;
int F[N][2],a[N],n;
inline void ut(int &x,int y) {y<x?x=y:0;}
inline int rd() {
	int x=0,f=1;char ch=getchar();
	while (ch>'9'||ch<'0') {if(ch=='-')f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
	return x*f;
}
int main() {
	n = rd();
	for (int i=1;i<=n;i++) a[i] = rd();
	
	memset(F,127/3,sizeof(F));
	for (int i=1;i<=n;i++) {
		if (i==1) {
			F[i][0] = F[i][1] = 1;
			continue;
		}
		if (a[i] >= a[i-1])
			ut(F[i][0], F[i-1][0]);
		if (a[i] <= a[i-1])
			ut(F[i][1], F[i-1][1]);
		ut(F[i][1], F[i-1][1] + 1);
		ut(F[i][1], F[i-1][0] + 1);
		ut(F[i][0], F[i-1][1] + 1);
		ut(F[i][0], F[i-1][0] + 1);
	}
	printf("%d\n",min(F[n][0], F[n][1]));
	return 0;
}


Measured memory_bytes: 10368
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll MOD=1000000007;
int main(){
  ll n,t;
  cin >> n >> t;
  ll i,j,k;
  vector<ll> v;
  for(i=0;i<n;i++){
    cin >> k;
    v.push_back(k);
  }
  sort(v.begin(),v.end());
  ll ans=1;
  for(i=0;i<n;i++){
    ans*=(i-distance(v.begin(),lower_bound(v.begin(),v.end(),v[i]-t))+1)%MOD;
    ans%=MOD;
  }
  cout << ans % MOD << endl;
  return 0;
}

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

int main()
{
	unsigned int n,y;
	int i, j, k;
	bool flg = false;
	cin >> n >> y;

	for (i = 0; i <= n; i++) {
		for (j = 0; j <= n - i; j++) {
			for (k = 0; k <= n - i - j; k++) {
				if (y == 10000 * i + 5000 * j + 1000 * k && n== i+j+k) {
					flg = true;
					break;
				}
			}
			if (flg) {
				break;
			}
		}
		if (flg) {
			break;
		}
	}
	if (!flg) {
		i = j = k = -1;
	}


	cout << i << " "<< j <<" "<< k << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;


int main(){
  ll n; cin >> n; ll count = 0; ll k = n;
  while(k!=0){
    count++;
    k /= 10;
  }
  
  if(count==1) cout << n << endl;
  else if(count==2) cout << 9 << endl;
  else if(count==3) cout << n-90 << endl;
  else if(count==4) cout << 909 << endl;
  else if(n==100000) cout << 90909 << endl;
  else cout << n-9090 << endl;
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rep2(i, a, b) for (ll i = (a); i < (b); i++)
#define chmax(x, v) do { x = max(x, v); } while (0)
#define chmin(x, v) do { x = min(x, v); } while (0)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

using namespace std;

signed main() {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


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

public class Main {
    static class FS {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

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

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

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

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

        public long[] readLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }

    static final FS sc = new FS();
    static final PrintWriter out = new PrintWriter(System.out);
    static final int mod = 1000000007;

    public static void main(String[] args) {
        solve();
        out.close();
    }

    static void solve() {
        int x = sc.nextInt();
        int y = sc.nextInt();
        if (x >= y) {
            out.println(x - y);
        } else {
            out.println("0");
        }

    }
}


Measured memory_bytes: 32992
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstdio>
#include <queue>

using namespace std;

typedef pair<string, int> P;

string String(vector<int> v) {
	string ret = "";
	for (int i = 0; i < v.size(); ++i)
		ret += v[i] + '0';

	return ret;
}

int main() {
	map<string, int> steps;
	queue<P> Q; Q.push( P("01234567", 0) );

	while ( !Q.empty() ) {
		P p = Q.front(); Q.pop();
		string str = p.first;
		int step = p.second;

		if (steps[str]) continue;
		steps[str] = step+1;

		int pos = -1;
		for (int i = 0; i < 8; ++i)
			if (str[i] == '0') pos = i;

		string next = str;

		if (pos > 3) swap(next[pos], next[pos-4]);
		else swap(next[pos], next[pos+4]);

		Q.push( P(next, step+1) ); next = str;

		if (pos % 4 != 0) { swap(next[pos], next[pos-1]); Q.push( P(next, step+1) ); next = str; }
		if (pos % 4 != 3) { swap(next[pos], next[pos+1]); Q.push( P(next, step+1) ); next = str; }
	}

	int a;
	while (scanf("%d", &a) != EOF) {
		vector<int> now(8, a);
		for (int i = 1; i < 8; ++i) cin >> now[i];
		cout << (steps[String(now)]-1) << endl;
	}
}

Measured memory_bytes: 3588
import java.util.*;

public class Main {

    static long mod = 1_000_000_007;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        int a = sc.nextInt();
        int b = sc.nextInt();
        long all = modPow(2, n)-1;
        long ac = 1, bc = 1;
        for (int i = 0; i < a; i++) {
            ac = ac * (n-i) % mod;
            ac = ac * modPow(i+1, mod - 2) % mod;
        }
        for (int i = 0; i < b; i++) {
            bc = bc * (n-i) % mod;
            bc = bc * modPow(i+1, mod - 2) % mod;
        }
        System.out.println(((all - ac + mod)%mod - bc + mod) % mod);
        sc.close();

    }

    public static long modPow(long base, long exp) {
        long ret = 1;
        while(exp > 0){
            if((exp & 1) == 1){
                ret = ret * base %mod;
            }
            base = base * base %mod;
            exp >>= 1;
        }
        return ret;
    }

}

class Combination {

    /** factorial:階乗 */
    private long fac[];
    /** inverse:逆元（ここでは、fac[i]をMOD-2乗したものをMODで割った余り） */
    private long inv[];
    /** 除数 */
    private int mod;

    /**
     * コンストラクタ
     * @param size 組み合わせの対象となる個数
     * @param mod 除数
     */
    public Combination(int size, int mod){
        this.fac = new long[size +1];
        this.inv = new long[size +1];
        this.mod = mod;

        this.fac[0] = 1;
        this.inv[0] = 1;

        for(int i = 1; i <= size; i++){
            fac[i] = (fac[i -1] * i) %mod;
            inv[i] = modPow(fac[i], (int)mod -2) %mod;
        }
    }

    /**
     * n個の中からr個選ぶ組み合わせの数（nCr）をmodで割った余りを算出する
     * @param n 元の集合の要素数
     * @param r 組み合わせる要素数
     * @return nCr % mod
     */
    public long comb(int n, int r){
        return fac[n] * inv[r] %mod * inv[n - r] %mod;
    }

    /**
     * base^exp をmodで割った余りを算出する
     * @param base 基数
     * @param exp 指数
     * @return base^exp % mod
     */
    private long modPow(long base, int exp) {
        long ret = 1;
        while(exp > 0){
            if((exp & 1) == 1){
                ret = ret * base %mod;
            }
            base = base * base %mod;
            exp >>= 1;
        }
        return ret;
    }

}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

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

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int a,b,c;
    cin >> a >> b >> c;
    
    if((b*c) < a) cout <<"No";
    else cout <<"Yes";
    
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 3692