akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> c(n+1,0);
  for(int i=1;i<=n;i++){
    c.at(i)=i;
    for(int p=1;p<=i;p*=6)
      c[i]=min(c[i],c[i-p]+1);
    for(int p=1;p<=i;p*=9)
      c[i]=min(c[i],c[i-p]+1);
  }
  cout<<c[n]<<endl;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    int r, s, p;
    cin >> r >> s >> p;
    string str;
    cin >> str;
    rep(i, n)
    {
        if (i < k)
        {
            if (str[i] == 'r')
            {
                ans += p;
            }
            if (str[i] == 'p')
            {
                ans += s;
            }
            if (str[i] == 's')
            {
                ans += r;
            }
        }
        else {
            if(str[i]==str[i-k]){
                str[i] = 0;
            }
            else {
                if (str[i] == 'r')
                {
                    ans += p;
                }
                if (str[i] == 'p')
                {
                    ans += s;
                }
                if (str[i] == 's')
                {
                    ans += r;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3756
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

S = input()
N = len(S)


def is_palindrome(s):
    return s == s[::-1]


print('Yes' if all(is_palindrome(s) for s in [S, S[:(N - 1) // 2], S[(N + 3) // 2 - 1]]) else 'No')


Measured memory_bytes: 38384
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cstring>
typedef long long ll;
#define rep(i,s,t) for (ll i = s ; i < t ; ++ i)
#define mod 1000000007
#define maxn 200005

using namespace std;

ll fac[maxn],inv[maxn];

int f(ll a,ll b)
{
    ll ans = 1;
    while (b)
    {
        if (b%2)
           ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
}

void init()
{
    fac[0] = 1;
    rep(i,1,maxn)
       fac[i] = fac[i-1] * i % mod;
    inv[maxn-1] = f(fac[maxn-1],mod-2);
    for (ll i = maxn-2 ; i >=0 ; -- i)
        inv[i] = inv[i+1] * (i+1) % mod;
}
int main()
{
    init();
    int h,w,a,b;
    cin>> h >> w >> a >> b;
    ll ans = 0;
    for (int i = b + 1 ; i <= w ; i++)
    {
        int sum = h - a + i - 2 ;
        ll cmp1 = fac[sum] * inv[i - 1] % mod;
        cmp1 = cmp1 * inv[h-a-1] % mod;

        sum = a + w - i - 1;
        ll cmp2 = fac[sum] * inv[a - 1] % mod;
        cmp2 = cmp2 * inv[w-i] % mod;

        cmp1 = cmp1 * cmp2 % mod;
        ans = (ans + cmp1) % mod;
    }
    cout<< ans <<endl;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;
int ans;
signed main(){
	ios_base::sync_with_stdio(0);
	for(int i=0;i<4;i++){
		char c;
		cin>>c;
		if(c=='+') ans++;
		else ans--;
	}
	cout<<ans;
	re 0;
}

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#define INF numeric_limits<int>::infinity()
#pragma endregion


int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    P((a+b)*c/2);
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	long long n,a,z=0,i,j;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a;
		for(j=0;j>=0;j++){
			if(a%2==1){
				break;
			}
			a/=2;
			z++;
		}
	}
	cout<<z;
}

Measured memory_bytes: 256
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
#define BIGP   1000000007
#define INF_I  std::numeric_limits<ll>::max()
#define INF_F  std::numeric_limits<float>::infinity()
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    ll N, D;
    cin >> N >> D;
    ll D2 = D * D;
    ll cnt = 0;
    rep(i, N)
    {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= D2)
        {
            ++cnt;
        }
    }
    cout << cnt;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 105
#define INF 100000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 100005;
const int MOD = 1000000007;
ll dp[64][N];
int main(){
    int n;
    cin>>n;
    string s[64];
    char c[4]={'A','G','C','T'};
    REP(i,4){
        REP(j,4){
            REP(k,4){
                s[k+4*j+16*i]=s[k+4*j+16*i]+c[i]+c[j]+c[k];
            }
        }
    }
    map<string,int>m;
    REP(i,64){
        m[s[i]]=i;
        //cout<<i<<s[i]<<endl;
    }
    REP(i,64){
        if(s[i]!="AGC"&&s[i]!="ACG"&&s[i]!="GAC"){
            dp[i][3]=1;
        }
    }
    for(int i=3;i<n;i++){
        REP(j,64){
            REP(k,4){
                string T=s[j]+c[k];
                if(!(T[1]=='A'&&T[2]=='G'&&T[3]=='C')&&!(T[0]=='A'&&T[2]=='G'&&T[3]=='C')&&!(T[0]=='A'&&T[1]=='G'&&T[3]=='C')&&!(T[1]=='A'&&T[2]=='C'&&T[3]=='G')&&!(T[1]=='G'&&T[2]=='A'&&T[3]=='C')){
                    string q="";
                    q.push_back(T[1]);
                    q.push_back(T[2]);
                    q.push_back(T[3]);
                    //cout<<T<<" "<<q<<m[q]<<endl;
                    dp[m[q]][i+1]+=dp[j][i];
                    dp[m[q]][i+1]%=MOD;
                    //OUT(T);
                }
            }
        }
    }
    ll ans=0;
    REP(i,64){
        ans+=dp[i][n];
        ans%=MOD;
    }
    OUT(ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

ll dp[1010][1010];

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

	ll q;
	cin >> q;
	while (q--) {
		string x, y;
		cin >> x >> y;
		memset(dp, 0, sizeof(dp));
		
		REP(i, x.size()) {
			REP(j, y.size()) {
				if (x[i] == y[j]) {
					chmax(dp[i + 1][j + 1], dp[i][j] + 1);
				}
				chmax(dp[i + 1][j + 1], dp[i + 1][j]);
				chmax(dp[i + 1][j + 1], dp[i][j + 1]);
			}
		}

		cout << dp[x.size()][y.size()] << endl;
	}

	return 0;
}



Measured memory_bytes: 11192
#include<stdio.h>
int main(void){
	int number;
	int nenrei;
	int age[7] = {0};
	int i;
	while(scanf("%d",&number)){
		if(number == 0){
			break;
		}
		for(i = 0;i < number;i++){
			scanf("%d",&nenrei);
			if(nenrei < 10){
				age[0]++;
			}
			else if(nenrei >= 10 && nenrei < 20){
				age[1]++;
			}
			else if(nenrei >= 20 && nenrei < 30){
				age[2]++;
			}
			else if(nenrei >= 30 && nenrei < 40){
				age[3]++;
			}
			else if(nenrei >= 40 && nenrei < 50){
				age[4]++;
			}
			else if(nenrei >= 50 && nenrei < 60){
				age[5]++;
			}
			else{
				age[6]++;
			}
		}
		for(i = 0;i < 7;i++){
			printf("%d\n",age[i]);
		}
		for(i = 0;i < 7;i++){
			age[i] = 0;
		}
	}
	return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

ll gcd(ll x, ll y){ return y==0? x: gcd(y, x%y); }

int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	
	int n=sz(s), pct=0, gct=0, ans = 0;
	rep(i, n){
		if(s[i]=='g'){
			if(pct <  gct){ans++; pct++;}
			else gct++;
		}else{
			if(pct < gct) pct++;
			else{ ans--; gct++;}
		}
	}
	cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
#define ll long long
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	if((s[0]==s[1] && s[2]==s[3] && s[2]!=s[0]) || (s[0]==s[2] && s[1]==s[3] && s[2]!=s[1]) || (s[0]==s[3] && s[2]==s[1] && s[2]!=s[3]))
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD=1e9+7;
template <class Q>
void clearQueue(Q & q) {
    q = Q();
}
void solve(){
    int n,l;cin>>n>>l;
    vector<string>v(n);
    for(int i=1;i<=n;i++){
        cin>>v[i-1];
    }
    sort(v.begin(),v.end());
    for(auto x:v) cout<<x;
    
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL); 
	int T=1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


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

#define fs first
#define sc second
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ if (!v.size()) puts(""); rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int n, a[101010];
int cnt[101010];

#define MAX_P 200005
lint fact[MAX_P];

lint mod_pow(lint a, lint x) {
		lint ret = 1;
			for (lint i  = 1ll << 60; i; i >>= 1) {
						ret *= ret;
								ret %= mod;
										if (x & i) { ret *= a; ret %= mod; }
											}

				return ret;
}

void init(int p){
	fact[0]=1;
	for(int i=1;i<MAX_P;i++) fact[i]=(fact[i-1]*i)%p;
}

lint mod_inverse(lint n) {
		return mod_pow(n, mod - 2);
}

lint mod_fact(int n){
	if(n==0) return 1;
	return fact[n];
} 

// nCk のmod
lint mod_Combination(lint n, lint k) {
		return mod_fact(n) * mod_inverse(mod_fact(k)) % mod * mod_inverse(mod_fact(n - k)) % mod;
}

signed main() {
	cin >> n;
	int k = -1;
	rep(i, n + 1) {
		cin >> a[i];
		cnt[a[i]]++;
		if (cnt[a[i]] == 2) k = a[i];
	}

	init(mod);
	vi idx;
	rep(i, n + 1) {
		if (a[i] == k) idx.pb(i);
	}

	for (int i = 1; i <= n + 1; ++i) {
		int beet = 0;
		if (n - idx[1] + idx[0] >= i - 1) beet = mod_Combination(n - idx[1] + idx[0], i - 1);
		//cout << ( mod_comb(n + 1, i, mod) - beet + mod ) % mod << endl;
		cout << ( mod_Combination(n + 1, i) - beet + mod ) % mod << endl;
	}
}




Measured memory_bytes: 3584
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int A[100010];
    rep(i, N) cin >> A[i];
    cout << ((N - 1) + K - 1 - 1) / (K - 1) << endl;

    return 0;
}


Measured memory_bytes: 640
import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N, M = LI()
    H = LI()
    AB = [LI_() for _ in range(M)]
    good = [True]*N
    for i in AB:
        if H[i[0]]>=H[i[1]]:
            good[i[1]] = False
        if H[i[0]]<=H[i[1]]:
            good[i[0]] = False

    print(len([i for i in good if i]))

if __name__ == '__main__':
    resolve()


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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define SUBL freopen("/home/ajinkya/Desktop/input.txt","r",stdin); freopen("/home/ajinkya/Desktop/output.txt","w",stdout); 
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;




int main()
{
    fastio 
    //SUBL
  	ll a;
  	cin >> a;
  	cout << 3*a*a;
    return 0;
}         	

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
//#include <cmath>
//#include <iomanip>
//#include <map>
//#include <unordered_map>
//#include <cstring>
#include <queue>

using namespace std;
using ll = long long;
// using pint = pair<int, int>;
// ll INF = 1LL << 60;

int a[1000001];

int main() {
	int K;
	cin >> K;
	a[1] = 7 % K;
	for (int i = 2; i <= K; i++) a[i] = (a[i - 1] * 10 + 7) % K;
	for (int i = 1; i <= K; i++) {
		if (a[i] == 0) {
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 7492
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define For(i,j,k)	for(int i=j;i<=k;++i)
#define Dow(i,j,k)	for(int i=k;i>=j;--i)
#define ll long long
#define inf 1e8
using namespace std;
inline ll read()
{
	ll t=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')	c=getchar();}
	while(c>='0'&&c<='9')	t=t*10+c-48,c=getchar();
	return t*f;
}
int n,m,vis1[200001],vis2[200001],x,y;
int main()
{
	n=read();m=read();
	For(i,1,m)
	{
		x=read();y=read();
		if(x>y)	swap(x,y);
		if(x==1)	vis1[y]=1;
		if(y==n)	vis2[x]=1;
	}
	For(i,1,n)	if(vis1[i]&&vis2[i])	{puts("POSSIBLE");return 0;}
	puts("IMPOSSIBLE");
}

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

int main() 
{
	int n, k;
    cin >> n >> k;
    int a[n];
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a, a + n);

    int best = INT_MAX;
    int j = 0;
    for(int i=k-1;i<n;i++) {
        best = min(best, a[i] - a[j]);
        j++;
    }

    cout << best;
    return 0;
}


Measured memory_bytes: 640
K=input()
D=int(input())
mod=10**9+7

L=len(K)

DP=[0]*D#DP[num][limit]で,一つ前の桁について,「桁和,そこまでKと一致していれば1」の場合の数
LIMIT=[]

for j in range(10):
    if j>int(K[0]):
        continue
    if j==int(K[0]):
        LIMIT=j%D
    else:
        DP[j%D]+=1

for ketanum in K[1:]:
    NDP=[0]*D

    for i in range(D):
        for j in range(10):
            NDP[(i+j)%D]=(NDP[(i+j)%D]+DP[i])%mod

    for j in range(int(ketanum)):
        NDP[(LIMIT+j)%D]+=1

    LIMIT=(LIMIT+int(ketanum))%D

    DP=NDP

print((DP[0]-1+ (LIMIT==0) )%mod)

Measured memory_bytes: 43228
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)


int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> vec(n);
    rep(i,n){
        cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end(), greater<ll>() );


    ll ans = 0;
    rep(i,n){
        if(k > 0){
            k--;
            continue;
        }else{
            ans += vec.at(i);
        }
    }

    cout << ans << endl;
    

}


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

long long n, k;
long long a[1005] = {0};
vector<long long> v;

long long solve();

int main() {
  cin >> n >> k;
  for(int i = 0; i < n; ++i) {
    cin >> a[i];
    if(i != 0) a[i] += a[i - 1];
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0, fin = 1, bf;
  for(long long l = 0; l < n; ++l)
    for(long long r = l; r < n; ++r) {
      long long now = a[r];
      if(l != 0) now -= a[l - 1];
      v.push_back(now);
    }
  sort(v.begin(), v.end(), greater<long long>());
  bf = v.size();
  while(fin * 2 <= v[0]) fin *= 2;
  while(fin > 0) {
    long long i = 0;
    for(i = 0; i < bf; ++i) {
      if(v[i] >= fin)
        v[i] -= fin;
      else
        break;
    }
    if(i >= k)
      ans += fin;
    else
      i = bf;
    bf = i;
    fin /= 2;
    sort(v.begin(), v.begin() + i, greater<long long>());
  }
  return ans;
}


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

int o(int a, int b) {
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
		return 1;
	}
	return 0;
}

int main() {
	int a, b;
	cin >> a >> b;
	if (o(a,b)) {
		printf("Possible \n");
	}
	else {
		printf("Impossible \n");
	}
}

Measured memory_bytes: 256
N,x = map(int,input().split())
A = list(map(int,input().split()))
ans = 0
for i in range(1,N):
    cnt = A[i-1] + A[i] - x
    if cnt > 0:
        A[i] = max(0,x-A[i-1])
        ans += cnt
print(ans)


Measured memory_bytes: 14132
#define _USE_MATH_DEFINES
#define INF 100000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double EPS = 1e-8;


int main(){
	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		bool visited[201];
		memset(visited,0,sizeof(visited));
		list<int> tl,hl;
		for(int i=0;i<n;i++){
			int num;
			scanf("%d",&num);
			visited[num] = true;
			tl.push_back(num);
		}

		for(int i=1;i<=2*n;i++){
			if(!visited[i]) hl.push_back(i);
		}

		tl.sort();
		hl.sort();

		int field=-1;
		int turn=0;
		while(1){
			if(hl.empty() || tl.empty()) break;

			if(turn==0){
				list<int>::iterator taro_it = lower_bound(tl.begin(),tl.end(),field);
				if(taro_it != tl.end()){
					field = *taro_it;
					tl.erase(taro_it);
				}
				
				else{
					field = -1;
				}
				turn = 1;
			}

			else{
				list<int>::iterator hanako_it = lower_bound(hl.begin(),hl.end(),field);
				if(hanako_it != hl.end()){
					field = *hanako_it;
					hl.erase(hanako_it);
				}
				
				else{
					field = -1;
				}
				turn = 0;
			}
		}

		int taro = 0;
		int hanako = 0;
		if(!tl.empty()){
			hanako = tl.size();
		}

		else if(!hl.empty()){
			taro = hl.size();
		}
		printf("%d\n%d\n",taro,hanako);
	}
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>

#define S_MAX 10

long dfs(int index, long accum, long sum, char *digits);


int main()
{
  char s[S_MAX + 1];
  long answer;
  
  scanf("%s", &s);
  answer = dfs(0, 0, 0, s);
  printf("%ld\n", answer);

  return 0;
}


long dfs(int index, long accum, long sum, char *digits)
{
    char temp[2];
    int current_digit;
	  
    temp[0] = digits[index];
    temp[1] = '\0';
    if (temp[0] == '\0')
    {
	return sum + accum;
    }
	  
    current_digit = atoi(temp);
    // '+'を入れる場合
    return dfs(index + 1, 0, sum + accum, digits)
	// '+'を入れない場合
	+ dfs(index + 1, accum * 10 + current_digit, sum, digits);
}


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

int main() {
  int N;
  cin >> N;
 
  int a;
  vector<int> number(N);
  for(int i=0; i<N; i++){
    cin >> a;
    number.at(i)=a;
  }
  
  //降順並び替え
  int temp;
  for(int i=0; i<N; i++){
    for(int j=i+1; j<N; j++){
      if(number.at(i)<=number.at(j)){
        temp=number.at(i);
        number.at(i)=number.at(j);
        number.at(j)=temp;
      }
    }
  }
  
  //出力
  int Alice=0, Bob=0;
  if(N%2==0){
    for(int i=0; i<N/2; i++){
      Alice+=number.at(i*2);
    }
    for(int i=0; i<N/2; i++){
      Bob+=number.at(i*2+1);
    }
  }
  else{
    for(int i=0; i<(N+1)/2; i++){
      Alice+=number.at(i*2);
    }
    for(int i=0; i<N/2; i++){
      Bob+=number.at(i*2+1);
    }    
  }
  cout << Alice-Bob << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename 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);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    string N; cin >> N;
    ll sum = 0;

    for(auto c:N){
        int t = c - '0';

        sum += t;
        sum %= 9;
    }

    if(sum == 0){
        return "Yes";
    }else{
        return "No";
    }
    return res;
}
int main(void) {
    cin.tie(0); ios::sync_with_stdio(false);
    //solve<ll>(0);
    cout << fixed << setprecision(12) << solve<string>() << endl;
    return 0;
}

Measured memory_bytes: 3680
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> v(n), c(n);
	rep(i, n) cin >> v[i];
    rep(i, n) cin >> c[i];
	int ans = 0;
	rep(i, n) {
		if (v[i] >= c[i]) ans += v[i] - c[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
    using namespace std;
     
    int main() {
    					int h,w,i,j;
    	while(1){
    		cin>>h>>w;
    		if (h==0&&w==0){
    			break;
     
    		}
    		for(i=0;i<h;i++){
    			for(j=0;j<w;j++){
    				cout<<"#";
    			}
    		cout<<endl;	
     
    		}
    		cout<<endl;
    	}
    }


Measured memory_bytes: 3080
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws Exception
	{
		int[] nDice = new int[6];

			int nT = 1;

				int nN = 5;
		int nW = 4,nB = 6,nE = 3;
				int nS = 2;

		int nSumDice = nN + nS + nE + nW + nB;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
		String[] strDice = br.readLine().split(" ");

		String strGetch = br.readLine();
		char[] cArray = strGetch.toCharArray();

		for(int i=0; i<6; i++)
		{
			nDice[i] = Integer.parseInt(strDice[i]);
		}

		for(char c : cArray)
		{
			if(c == 'E')
			{
				nW = nB;
				nB = nE;
				nE = 21 - nSumDice;
			}
			else if(c == 'W')
			{
				nE = nB;
				nB = nW;
				nW = 21 - nSumDice;
			}
			else if(c == 'S')
			{
				nN = nB;
				nB = nS;
				nS = 21 - nSumDice;
			}
			else if(c == 'N')
			{
				nS = nB;
				nB = nN;
				nN = 21 - nSumDice;
			}

			nSumDice = nN + nS + nE + nW + nB;

			nT = 21 - nSumDice;

/*			System.out.printf("%3d\n",nN);
			System.out.printf("%d %d %d\n",nW,nB,nE);
			System.out.printf("%3d\n",nS);*/

			}

			System.out.println(nDice[nT-1]);

	}
}

Measured memory_bytes: 24332
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(ll A, ll B, ll C, ll K) {
  int ans;
  if (K < A) {
    ans = K;
  } else if (K <= A + B) {
    ans = A;
  } else {
    ans = 2*A + B - K;
  }
  cout << ans << endl;
}

int main() {
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  ll C;
  cin >> C;
  ll K;
  cin >> K;
  solve(A, B, C, K);
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int  main(){
 int a;
 cin >> a;
 for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
       if(i*j==a){
          cout << "Yes" << endl;
          return 0;
       }
    }
 }
 cout << "No" << endl;
return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())

a = [[int(x) for x in input().split()] for i in range(n)]
b = [int(input()) for j in range(m)]

for num_a in a:
    cnt = 0
    result = 0
    for i in num_a:
        result+=i*b[cnt]
        cnt+=1
        
    print(result)


Measured memory_bytes: 6016
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
l = "abcdefghijk"

def dfs(cur, mx):
    if len(cur) == N:
        print(cur)
        return
    # print(l[:mx+2])
    for c in range(len(l[:mx+2])):
        t = cur
        t += l[:mx+2][c]
        # print(cur)
        dfs(t, max(c, mx))
        # dfs(cur, max(c, mx+1))

dfs("", -1)


Measured memory_bytes: 6480
N=int(input())
A=list(map(int,input().split()))
i=0
for a in A:
    if a%2==0:
        if a%3==0 or a%5==0:
            i=0
        else:
            print("DENIED")
            i=1
            break

if i==0:
    print("APPROVED")


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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<vector<int>> to(n);
  for (int i = 0; i < m; i++)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }

  queue<int> q;
  vector<int> dist(n, -1);
  vector<int> pre(n, -1);

  dist[0] = 0;
  q.push(0);

  while (!q.empty())
  {
    int v = q.front();
    q.pop();
    for (int i : to[v])
    {
      if (dist[i] != -1)
      {
        continue;
      }
      dist[i] = dist[v] + 1;
      pre[i] = v;
      q.push(i);
    }
  }

  cout << "Yes" << endl;
  for (int i = 0; i < n; i++)
  {
    if (i == 0)
    {
      continue;
    }
    int ans = pre[i];
    ans++;
    cout << ans << endl;
  }
}


Measured memory_bytes: 10492
K, S = map(int, input().split())

count = 0
for i in reversed(range(K+1)):
    tmp = S - i
    for j in reversed(range(K+1)):
        tmp_tmp = tmp -j
        if tmp_tmp < 0 or tmp_tmp > K:
            continue
        else:
            # print(i, j, tmp_tmp)
            count += 1

print(count)
    


Measured memory_bytes: 41052
#include<stdio.h>
   int n;
   char a[100005];
   int main()
   {
   while(scanf("%d",&n)!=EOF)
      {
      scanf("%s",&a);
      int s=1;	
	  for(int i=0;i<n-1;i++)
	     if(a[i]!=a[i+1])
		    s++;
	  printf("%d\n",s);		
      }	
   } 

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

int main(){
    int N,Q;
    cin>>N>>Q;
    string S;
    cin>>S;
    int p[Q][2];
    int ans[Q];

    for(int i=0;i<Q;i++){
        cin>>p[i][0];
        cin>>p[i][1];
    }

    int iS[N];
    int c=0;
    for(int i=0;i<N-1;i++){
        iS[i]=c;
        if(S[i]=='A' && S[i+1]=='C') {
            c=c+1;
        }
        iS[i+1]=c;
    }

    for(int i=0;i<Q;i++){
        int tmp = iS[p[i][0]-1];
        int tmp2 = iS[p[i][1]-1];
        ans[i]=tmp2-tmp;
    }
    
    for(int i=0;i<Q;i++)cout<<ans[i]<<endl;
    //for(int i=0;i<N;i++)cout<<iS[i]<<endl;
}

Measured memory_bytes: 2688
A,B,C,X=$<.read.split.map(&:to_i)

ret = 0
0.upto(A) do |a|
0.upto(B) do |b|
0.upto(C) do |c|
    ret += 1 if a*500+b*100+c*50 == X
end
end
end

puts ret

Measured memory_bytes: 1788
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math
import bisect
import heapq
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
    return int(readline())
a,b,c = readInts()
if (c-a-b) > 0 and 4*a*b < (c-(a+b))**2:
    print('Yes')
else:
    print('No')


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

namespace UnionFindTree {
  template<std::size_t N>
  void Init(int (&ps)[N]) {
    for(int i = 0; i < (int)N; ++i) ps[i] = i;
  }
  template<std::size_t N>
  int Find(int (&ps)[N], int x) {
    return ps[x] == x ? x : ps[x] = Find(ps, ps[x]);
  }
  template<std::size_t N>
  void Unite(int (&ps)[N], int x, int y) {
    x = Find(ps, x);
    y = Find(ps, y);
    if( x == y ) return;
    if( rand() & 0x01 ) std::swap(x, y);
    ps[x] = y;
  }
  template<std::size_t N>
  bool Same(int (&ps)[N], int x, int y) {
    return Find(ps, x) == Find(ps, y);
  }
};
using namespace UnionFindTree;

// http://atc001.contest.atcoder.jp/tasks/unionfind_a
void Verify_1() {
  int par[112345];
  int n, q;
  scanf("%d %d", &n, &q);
  Init(par);
  for(int i = 0; i < q; ++i) {
    int c, x, y;
    scanf("%d %d %d", &c, &x, &y);
    x += 1; y += 1;
    if( c == 0 ) {
      Unite(par, x, y);
    }
    else {
      puts(Same(par, x, y) ? "Yes" : "No");
    }
  }
}

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A
// 
void Verify_2() {
  int par[11234];
  int n, q;
  scanf("%d %d", &n, &q);
  Init(par);
  for(int i = 0; i < q; ++i) {
    int c, x, y;
    scanf("%d %d %d", &c, &x, &y);
    if( c == 0 ) {
      Unite(par, x, y);
    }
    else {
      puts(Same(par, x, y) ? "1" : "0");
    }
  }
}

int main() {
  Verify_2();  
  return 0;
}

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

using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  int h,w;
  cin>>h>>w;

  const int INF = 1e8;
  using P = pair<int, int>;
  set<P> sp;
  multiset<int> ans;

  auto push=[&](int j,int x){
    sp.emplace(j,x);
    ans.emplace(j+x);
  };

  push(0,INF);
  for(int j=1;j<=w;j++) push(j,-j);
  sp.emplace(w+1,-(w+1));

  auto erase=[&](P p){
    assert(sp.count(p));
    sp.erase(p);
    ans.erase(ans.find(p.first+p.second));
  };

  for(int i=0;i<h;i++){
    int a,b;
    cin>>a>>b;
    int v=INF;

    // erase points in [a, b]
    while(1){
      auto it=sp.lower_bound(P(a,-INF));
      if(b<it->first) break;
      v=it->second;
      erase(*it);
    }

    // add if last range exceed [a, b]
    if(v!=INF){
      auto it=sp.lower_bound(P(a,-INF));
      if(b+1<it->first) push(b+1,v);
    }

    if(ans.size()==1) cout<<-1<<newl;
    else cout<<i+1+*ans.begin()<<newl;
  }
  return 0;
}


Measured memory_bytes: 22376
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
v0 = v[0::2]
v1 = v[1::2]
c0 = Counter(v0).most_common()
c1 = Counter(v1).most_common()
if c0[0][0] == c1[0][0] :
    if len(c0)*len(c1) == 1 :
        print(n//2)
    elif len(c0) == 1 :
        print(n-c0[0][1]-c1[1][1])
    elif len(c1) == 1 :
        print(n-c1[0][1]-c0[1][1])
    else :
        if c0[0][1]+c1[1][1] > c1[0][1]+c0[1][1] :
            print(n-c0[0][1]-c1[1][1])
        else :
            print(n-c1[0][1]-c0[1][1])
else :
    print(n-c0[0][1]-c1[0][1])

Measured memory_bytes: 21084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename X> ostream& operator << (ostream& x,const vector<X>& v){for(ll i=0;i<v.size();++i) x<<v[i]<<" ";return x;}
template <typename X> ostream& operator << (ostream& x,const set<X>& v){for(auto it:v) x<<it<<" ";return x;}
template <typename X, typename Y> ostream& operator << (ostream& x, const pair<X,Y>& v) {x<<v.ff<<" "<<v.ss;return x;}
template <typename T, typename S> ostream& operator << (ostream& os, const map<T, S>& v) { for (auto it : v) os << it.first << "=>" << it.second << endl; return os; }
struct pair_hash {inline std::size_t operator()(const std::pair<ll, ll> & v) const {return v.first*31+v.second;}};
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL)
#define pb push_back
#define fr first
#define sc second
#define prnt(m) for(auto it = m.begin() ; it != m.end() ; ++it){cout<<*it<<endl;}
#define tra(it,m) for(auto it=m.begin();it!=m.end();++it)
#define DBG(x) cout<<"# # #     "<<x<<'\n';
#define fri(i,s,n) for(long long i=s;i<n;i++)
#define mod 1000000007LL
#define mod2 998244353
#define vct2 vector<vector<ll>>
#define vct vector<ll>
#define pll pair<ll,ll>
#define rz(n) resize(n)
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define arrin(a,n) for(ll i = 0; i < n ; i++){cin>>a[i];}
#define arrout(a,n) for(ll i = 0;i < n; i++){cout<<a[i]<<" ";}
#define ex(s) cout<<s<<endl,exit(0);
#define infy 2e18
#define five 100005;
#define six 1000005;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//___________________________________________________________________________________________________________________________________________________________
const int N = five;
int dpp[N];
vector<int> dp[N];
bool vis[N];
int f(int i)
{
       if(dpp[i] != -1){return dpp[i];}
       //vis[i] = true;
       dpp[i] = 0;
       for(int k : dp[i]){
              dpp[i]= max(dpp[i],1+f(k));
       }
       return dpp[i];
}
int main()
{
       int n,m;
       cin>>n>>m;
       fri(i,0,m){
              int x,y;
              cin>>x>>y;
              --x;--y;
              dp[x].pb(y);
       }
       memset(dpp,-1,sizeof dpp);
       int ans = 0;
       memset(vis,false,sizeof vis);
       fri(i,0,n){
              ans = max(ans,f(i));
       }
       cout<<ans<<endl;
}


Measured memory_bytes: 7552
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << (n - 30) / 2 << endl;
    return 0;
}




Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b){
  if (b == 0){
    return a;
  } else {
    return gcd(b, a % b);
  }
}
int main(){
  int p, q;
  cin >> p >> q;
  int g = gcd(p, q);
  p /= g;
  q /= g;
  int ans = 1;
  for (int i = 2; i * i <= q; i++){
    if (q % i == 0){
      ans *= i;
      while (q % i == 0){
        q /= i;
      }
    }
  }
  if (q != 1){
    ans *= q;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3100
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);
        int W = scn.nextInt();
        int H = scn.nextInt();
        int x = scn.nextInt();
        int y = scn.nextInt();
        int r = scn.nextInt();
        if ((x-r >= 0 && x+r <= W ) && (y-r >= 0 && y+r <= H)) {
        	System.out.println("Yes");
        } else {
        	System.out.println("No");
        }
    }
}


Measured memory_bytes: 26388
// 4_abc131_d
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define INF (1e16)
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<int, int>> v(n);
    rep(i, n){
        int a, b;
        cin >> a >> b;
        v[i] = make_pair(b, a);
    }
    sort(v.begin(), v.end());
    ll t = v[n - 1].first;
    for(int i = n - 1; i >= 0; i--){
        if(t > v[i].first) t = v[i].first;
        t -= v[i].second;
    }
    if(t >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
import java.io.*;
import java.lang.*;

class Main{

    public static void main(String args[]){
	//BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
	Scanner in= new Scanner(System.in);
	List<Integer> vec = new ArrayList<Integer>();
	for(int i=0;i<10;i++){
	    int val;
	    val = in.nextInt();
	    vec.add(val);
	}

	Collections.sort(vec,new Comparator<Integer>(){
		
			 @Override
			     public int compare(Integer a,Integer b){
			     return b.compareTo(a);
			 }
			 
	    });
	for(int i=0;i<3;i++){
	    System.out.println(vec.get(i));
	}	
	
    }
    
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(10);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif
using P = pair<int,int>; using vp = vector<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
////////////////

void solve(){
  ini(N);
  vl v(N); in(v);
  int cnt = 0;
  rep(i , N - 1){
    if(v[i] < v[i + 1]) cnt++;
  }
  out(N - cnt);
  out(N);
}


Measured memory_bytes: 3544