akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define sync ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define mod 100000007
using namespace std;


int main()
{
    
    // freopen("C:\\Users\\Akarshan\\Desktop\\cp-temp\\running_on_fumes_chapter_1_input.txt","r",stdin);
    // freopen("C:\\Users\\Akarshan\\Desktop\\cp-temp\\output.txt","w",stdout);
    ll x;
    cin>>x;
    if(x>=30)
        cout<<"Yes"<<endl;
    else 
        cout<<"No"<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	int n;
	cin >> n;
	if (n < 1200) {
		cout << "ABC" << endl;
 	}
	else if (n < 2800) {
		cout << "ARC" << endl;
	}
	else {
		cout << "AGC" << endl;
	}
}

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

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

    int n;
    cin >> n;

    vector<int> cnt(100010);
    rep(i, n) {
        int a;
        cin >> a;
        // --a;
        ++cnt[a];
    }
    int ans = 0;
    for(int i = 1; i <= 100000; ++i) {
        int sum = 0;
        sum = cnt[i-1]+cnt[i]+cnt[i+1];
        ans = max(ans, sum);
    }

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




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

int main() {
	int H, W;
	
	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				cout << "#";
			}cout << endl;
		}cout << endl;
	}

	return 0;

}                   


Measured memory_bytes: 3080
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = n - 1; i>= 0; i--)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define sq(a) (a)*(a)
#define nl "\n"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<ll> vll;
const int MAXN = 100005;
ll mod=1000000007;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	int n=s.size();
	int ans=0;
	rep(i,n){
	    if(i%2){
            if(s[i]%2==0) ans++;
	    }
	    else{
            if(s[i]%2==1) ans++;
	    }
	}
	int cnt=0;
	rep(i,n){
        if(i%2){
            if(s[i]%2==1) cnt++;
        }
        else{
            if(s[i]%2==0) cnt++;
        }
	}
	cout<<min(ans,cnt);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N;
    cin >> N;

    vector<int> v_a;

    // vectorに整数列を入れる。
    for(int i=0; i<N; i++)
    {
        int temp;
        cin >> temp;
        v_a.push_back(temp);
    }

    // 残したレンガ
    int keep_cnt = 0;

    for(auto it_v=v_a.begin(); it_v != v_a.end(); it_v++)
    {
        // 整数iを探す
        if(*it_v == (keep_cnt+1))
        {
            // 残すレンガの数をインクリメントする
            keep_cnt++;
        }
    }

    if(keep_cnt == 0)
    {
        // 全部砕いたら-1を出力
        cout << -1 << endl;
    }
    else
    {
        // 残ったレンガの数から割ったレンガの数を算出する
        cout << (N - keep_cnt) << endl;
    }

    return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define one 1.0
#define inf 1000000000000000000
#define ret return
#define all(vl) vl.begin(),vl.end()
#define sor sort 
#define cl clear
#define m_p make_pair 
#define sz(a) a.size()
#define lb lower_bound
#define up upper_bound
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;
typedef map<string,ll> mapstl;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	vector<ll> vl;
	string s = "~abcdefghijklmnopqrstuvwxyz";
	if(n<=26)
	{
		cout<<s[n]<<endl;
		return 0;
	}
	ll chu = 26;
	while(n>=26)
	{
		ll tmp = n%26;
		n/=26;
		if(tmp == 0)
		{
			tmp = 26;
			n--;
		}
		vl.pb(tmp);
	}
	if(n>0)
	vl.pb(n);
	reverse(all(vl));
	for(int i=0;i<vl.size();i++)
	{
		if(vl[i]>0)cout<<s[vl[i]];
		else cout<<"z";
	}
	cout<<endl;
	return 0;
}


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

void solve(long long N, long long x, vector<long long> a){
	long long res = 0;
	for (int i = 0; i < N-1; i++) {
		if (a[i]+a[i+1]>x) {
			if (a[i]>=x) {
				res += (a[i]-x)+a[i+1];
				a[i+1] = 0;
				a[i] = x;
			} else {
				res += a[i+1]-(x-a[i]);
				a[i+1] = x-a[i];
			}
		}
	}
	printf("%lld\n", res);
}

int main(){
	long long N;
	long long x;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	scanf("%lld",&x);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	solve(N, x, a);
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
using namespace std;
#define pb push_back
#define ll long long
#define ae addEdge
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define vvi vector< vector<int> >
#define pii pair <int,int>
#define sortv sort(v.begin(),v.end())
#define sorta sort(a.begin(),a.end())
#define sortb sort(b.begin(),b.end())
#define sorts sort(s.begin(),s.end())

ll knapsack(vi w, vi v, int n, int wt){
	vector<vector<ll> > dp(n+1,vll (wt+1,0));
	for(int i=0;i<n+1;i++){
		for(int j=0;j<wt+1;j++){
			if(i==0 || j==0) dp[i][j]=0;
			else if(w[i-1]>j) dp[i][j]=dp[i-1][j];
			else dp[i][j]= max(dp[i-1][j], v[i-1]+dp[i-1][j-w[i-1]]);
			//cout<<"i"<<i<<"j"<<j<<"dp[i][j]"<<dp[i][j]<<" ";
		}
	}
	return dp[n][wt];
}

int main(){
	ll n,wt;
	cin>>n>>wt;
	vi w,v;
	int a,b;
	for(int i=0;i<n;i++){
		cin>>a>>b;
		w.pb(a); v.pb(b);
	}
	cout<<knapsack(w,v,n,wt)<<endl;
}

Measured memory_bytes: 80256
#include <stdio.h>

int main(void){
	int h,w,i,j,sq;
	
	while(1){
		scanf("%d %d",&h,&w);
		if(h == 0 && w == 0) break;
		
		for(i=0;i < h;i++){
			for(j=0;j < w;j++){
				if(j == 0 || j == w-1 || i == 0 || i == h-1){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
// Inshallah, Boys played well !!

#include <bits/stdc++.h>
using namespace std;
#define author Saurabh
#define pii pair<int,int> 
#define vpi vector<pair<int,int> >
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define ff(i,s,e) for(int i=s;i<=e;i++)
#define fb(i,e,s) for(int i=e;i>=s;i--)
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test int t;scanf("%d",&t);while(t--)
#define setp(x) setprecision(x)
#define int long long
signed main(){
    fast;
    int n,m,x;
    cin >> n >> m;
    int s=0;
    ff(i,0,m-1){
        cin >> x;
        s+=x;
    }
    n-=s;
    if(n>=0){
        cout << n;
    }
    else
    cout << "-1";

}


Measured memory_bytes: 3612
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string.h>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <math.h>
#include <assert.h>
#define ff first
#define ss second
#define ll long long
#define mod 998244353
using namespace std;
string s;
ll dp[200009], pov[200009], cur, p[200009];
int main () {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>s;
    pov[s.size() - 1] = 1;
    for(int i=int(s.size())-2;i>=0;i--)
        pov[i] = 10 * pov[i + 1] % 2019;
    ll ans = 0;
    dp[0] = 1;
    for(int i=int(s.size())-1;i>=0;i--) {
        int new_cur = ((s[i]-'0') * pov[i] + cur) % 2019;
//        cout<<i<<" "<<new_cur<<endl;
        ans += dp[new_cur];
        dp[new_cur]++;
        cur = new_cur;
    }
    cout<<ans;
}
/*
 4
 -2 2 3 5
 3 10 21 5
 */


Measured memory_bytes: 5284
#include <bits/stdc++.h>
#define N 200006
using namespace std;
int n,m,x,y,t,a[N],s[N];
inline int read()
{
	int x=0,c=getchar(),f=1LL;while(c<'0'||c>'9')f=(c=='-'?-f:f),c=getchar();
	while(c>='0'&&c<='9')x=(x<<1LL)+(x<<3)+c-48,c=getchar();return f>0?x:-x;
}
void print(long long x)
{
	if(x>9)print(x/10);putchar(x%10+48);
}
int main()
{
	n=read();x=1;y=n;t=0;
	for(int i=1;i<=n;i++)a[i]=read();
	for(int i=n;i>=1;i--){
		if(t==0)s[x++]=a[i];
		else s[y--]=a[i];
		t^=1;
	}
	for(int i=1;i<n;i++)printf("%d ",s[i]);printf("%d\n",s[n]);
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
string s;
int a[20];
int lens,p=0;
int main(){
	cin>>s;lens=s.size();
	for(int i=0;i<lens;i++){
		if(s[i]=='0'){
			p++;a[p]=0;
		}
		else if(s[i]=='1'){
			p++;a[p]=1;
		}
		else{
			if(p>0)p--;
		}
	}
	for(int i=1;i<=p;i++)cout<<a[i];
	cout<<endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <set>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define eps 0.0000000001
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define random(a, b) rand()*rand()%(b-a+1)+a
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 10000+10;
const int mod = 1e9+7;
struct node
{
    int cost;
    double x;
    double L;
    node(double _x, double _L, int _cost):x(_x), L(_L), cost(_cost){}
    bool operator < (const node &x1)const{
        return x > x1.x;
    }
};
int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    priority_queue<node> qq;
    int Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    qq.push(node((double)Q, 0.25, Q));
    qq.push(node((double)H/2.0, 0.5, H));
    qq.push(node((double)S/4.0, 1.0, S));
    qq.push(node((double)D/8.0, 2.0, D));

    LL ans = 0;
    while(N){
        node now = qq.top();
        qq.pop();
        int cost = now.cost;
        double ll = now.L;
        ans+=(LL)(N/ll)*cost;
        N -= (LL)(N/ll)*ll;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<stack>
#include<map>
#include<queue>
#include<set>
#define int long long
using namespace std;
const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int N;
	cin >> N;
	vector<int> vec(N + 1);
	vec.at(0) = INF;
	vec.at(N) = INF;
	for(int i = 1;i < N;i++) {
		cin >> vec.at(i);
	}
	int ret = 0;
	for(int i = 0;i < N;i++) {
		ret += min(vec.at(i),vec.at(i + 1));
	}
	cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int a[3];

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	FOR(i, 3) cin >> a[i];
	sort(a, a+3);
	cout << a[0]+a[1] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>
#include<stack>
#include <utility>
#include <tuple>
#define INF 1000000000000
const long long MOD = 1000000007;

using namespace std;
typedef long long llong;
#define debug cout << "Hello" << endl;
//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong K;
    cin >> K;
    string s="";
    for(int i=0; i<K; i++){
        s = s + "ACL";
    }
    cout << s << endl;
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    cout << (n + 1) / 2 << endl;
}

Measured memory_bytes: 3632
q = int(input())
n = 10**5
nums = [False]*2+[True]*(n-2)
ans = [0]*n
for i in range(2, n):
    if nums[i]:
        for j in range(i*2, n, i):
            nums[j] = False
pre = 0
for i in range(3, n, 2):
    if nums[i] and nums[(i+1)//2]:
        ans[i] += pre+1
        pre = ans[i]
    else:
        ans[i] = pre
for _ in range(q):
    l, r = map(int, input().split())
    print(ans[r]-ans[max(l-2, 1)])


Measured memory_bytes: 10436
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int MOD = 1000000007;
template<class T> void add(T &a, T b) { a = (a + b) % MOD; }

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> S(N), T(M);
    rep(i, 0, N) cin >> S[i];
    rep(i, 0, M) cin >> T[i];
    vector<vector<long long>> sum(N + 1, vector<long long>(M + 1));
    sum[N][M] = 1;
    rep(i, 0, N) rep(j, 0, M) {
        add(sum[i+1][j+1], sum[i+1][j] + sum[i][j+1] - sum[i][j] + MOD);
        if(S[i] == T[j]) add(sum[i+1][j+1], sum[i][j] + 1);
    }
    cout << sum[N][M] << endl;
    return 0;
}


Measured memory_bytes: 31616
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

// #define ANS  //for answer
#define CMP  //for compe
#ifdef CMP
using namespace std;
#else
#endif

#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 INF 2e9
#define ALL(v) v.begin(), v.end()
#define nv(x) #x, (x)
#define ncv(x) #x, ":", (x)
#define ncvc(x) #x, ":", (x), ","
using ll = long long;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
void pPRINT(std::ostream& ost) {}
template <class T, class... U>
void pPRINT(std::ostream& ost, const T t, const U... u) {
  ost << t << " ";
  pPRINT(ost, u...);
}
template <class... T>
void PRINT(const T... t) { pPRINT(std::cout, t...); }
template <class... T>
void PRINTl(const T... t) {
  pPRINT(std::cout, t...);
  std::cout << "\n";
}
template <class T>
void PRINTa(const T* const t, const ll size) {
  REP(i, size)
  PRINT(t[i]);
  PRINTl();
}
template <class T>
void PRINTal(const T* const t, const ll size) {
  REP(i, size)
  PRINTl(i, ":", t[i]);
}
#ifndef DBG
#define DEBUG(...)
void init() {}
#else
#define DEBUG(...)                                                     \
  {                                                                    \
    PRINT("##DEBUG##", "file :", __FILE__, ", line :", __LINE__, "["); \
    PRINT(__VA_ARGS__);                                                \
    PRINTl("]");                                                       \
  }
void init() {
  DEBUG("INIT");
  cin.tie(0);
  ios::sync_with_stdio(false);
}
#endif
#ifdef ANS
#else
#endif

void solve();

int main(int argc, char* argv[]) {
  DEBUG("MAIN");
  init();
  solve();

  return 0;
}

constexpr ll calc(const ll n) {
  ll ans = 0;
  if (n % 2 != 0) {
    return ans;
  }
  REP(i, n / 2 + 1) {
    ll x = n - i * 2;
    if (x % 5 == 0) ans += x / 5;
  }
  return ans;
}

void solve() {
  DEBUG("SOLVE START");

  ll n;
  cin >> n;
  ll ans = 0;
  ll c = 0;
  if (n % 2 == 0) {
    n /= 2;
    DEBUG(ncv(n));
    while (n >= 5) {
      n /= 5;
      ans = ans + n;
      DEBUG(ncv(c), ncv(n), ncv(ans));
      c++;
    }
  }
  PRINT(ans);

  return;
}

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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------

//動的計画法で役に立つ関数
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; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

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

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

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int N; cin >> N;
    VI dp(N+1, INF);
    dp[0] = 0;
    FOR(i, 1, N+1)
    {
        int six=1, nine=1;
        chmin(dp[i], dp[i-1]+1);
        while((i-pow(6, six)) >=0)
        {
            chmin(dp[i], dp[i-pow(6, six)]+1);
            six++;
        }
        while((i - pow(9, nine))>=0)
        {
            chmin(dp[i], dp[i-pow(9, nine)]+1);
            nine++;
        }
    }
    
    cout << dp[N] << endl;

    return 0;
}



Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuilder sb = new StringBuilder();
		int n = sc.nextInt();
		int[] v = { 4, 7 };
		boolean[] dp = new boolean[n + 1];
		dp[0] = true;
		for (int i = 0; i < 2; i++) {
			for (int j = 0; j < n + 1; j++) {
				if (j >= v[i]) {
					if (dp[j - v[i]]) {
						dp[j] = true;
					}
				}
			}
		}
		if (dp[n]) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23892
n, k = map(int, input().split())
mod = 10**9 + 7
sums = [0,n+1]
for i in range(2, n+2):
    score = (sums[i-1] + n-2*(i-1)) % mod
    sums.append(score)
cum_sum = [0]
for i in range(1, len(sums)):
    cum_sum.append(cum_sum[i-1]+sums[i])

print((cum_sum[-1] - cum_sum[k-1])%mod)

Measured memory_bytes: 27996
X,N = (int(x) for x in input().split())
ans = 10000
ansnum = -3
if (N > 0):
    p = list(map(int, input().strip().split()))
    for i in range(-1,102):
        preans = abs(X-i)
        if(preans < ans) and (i in p ) == False:
            ans = preans
            ansnum = i
    print(ansnum)
else:
    print(X)

Measured memory_bytes: 9196
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)

string s;

int main(void){
	cin >> s;
	int a, z;
	int n = s.size();
	rep(i, n){
		if(s[i] == 'A'){
			a = i;
			break;
		}
	}
	rrep(i, n){
		if(s[i] == 'Z'){
			z = i;
			break;
		}
	}
	cout << z-a+1 << endl;
	return 0;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define MaxN 100003

const int Mod = 1e9 + 7;
int N;
int fir[MaxN], nex[MaxN << 1], to[MaxN << 1], cnt;
long long f[MaxN][2];

inline int Rd() {
	int x = 0; char ch = getchar();
	while(ch < '0' || ch > '9') ch = getchar();
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
	return x;
}
inline void add(int u, int v) {
	nex[++cnt] = fir[u], to[cnt] = v, fir[u] = cnt;
	nex[++cnt] = fir[v], to[cnt] = u, fir[v] = cnt;
	return;
}

void Dfs(int str, int fa) {
	f[str][0] = f[str][1] = 1;
	for(int i = fir[str]; i; i = nex[i]) {
		if(to[i] == fa) continue;
		Dfs(to[i], str);
	} (f[fa][0] *= f[str][1]) %= Mod, (f[fa][1] *= (f[str][1] + f[str][0]) % Mod ) %= Mod;
	return;
}

int main() {
	int u, v;
	N = Rd();
	for(reg int i = 1; i < N; ++i)
		u = Rd(), v = Rd(), add(u, v);
	f[0][1] = 1, Dfs(1, 0);
	cout << f[0][1] << endl;
	return 0;
}

Measured memory_bytes: 7936
#include<stdio.h>
 #include<vector>
 #include<algorithm>
 using namespace std;
 typedef long long ll;
 int main()
 {
	 int a, b, x, y;
	 scanf("%d%d%d%d", &a, &b, &x, &y);
	 printf("%lf %d\n", double(a)*double(b) / 2, x + x == a && y + y == b);
 }

Measured memory_bytes: 1752
#include <iostream>
#include <algorithm>

int N;
int A;
int x[55];
int X;
long long dp[55][55][2505];

int main()
{
	std::cin >> N >> A;
	X = A;
	for (int i = 0; i < N; ++i) {
		std::cin >> x[i];
		X = std::max(X, x[i]);
	}

	for (int j = 0; j <= N; ++j)
		for (int k = 0; k <= N; ++k)
			for (int s = 0; s <= N * X; ++s) {
				if (j == 0 && k == 0 && s == 0)
					dp[j][k][s] = 1;
				else if (j >= 1 && s < x[j - 1])
					dp[j][k][s] = dp[j - 1][k][s];
				else if (j >= 1 && k >= 1 && s >= x[j - 1])
					dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k - 1][s - x[j - 1]];
				else
					dp[j][k][s] = 0;
			}

	long long ans = 0;
	for (int k = 1; k <= N; ++k)
		ans += dp[N][k][k*A];

	std::cout << ans << '\n';

	return 0;
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;


signed main(){
    int N;
    double A[100];
    cin >> N;
    REP(i, N) cin >> A[i];
    double ans = 0;
    REP(i, N) ans += 1 / A[i];
    printf("%.10f\n", 1 / ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int d[100001];

int main(){
	int n,m;
	cin>>n;
	m=n/2;
	for (int i=1;i<=n;i++){
		cin>>d[i];
	}
	sort(d+1,d+n+1);
	cout<<d[m+1]-d[m]<<endl;
	return 0;
}

Measured memory_bytes: 640
from sys import exit
X,Y,Z = [int(n) for n in input().split()]
# N = int(input())
# a = [int(input()) for _ in range(N)]
# L = len(S)
# T = str(input())
ans = 0
b = max(Y,Z)
while(X>b):
    ans+=1
    X-=Z
    X-=Y
print(ans-1 if X<Z else ans)
exit()


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

// 全体の最大公約数に一致するというまさかの展開
// 細かい証明は調べればよろし
// gcd(a,b) = gcd(b,b-a) から　ユークリッドの互助法的に二匹の時は解ける。
// あとは帰納法なりなんなりで証明すればよさそう。
// とりあえず、数字のランダム引き算で最小になるときは「最大公約数」と覚えておくことがポイント

int GCD(int a,int b){ //ユークリッドの互助法で最大公約数
    if (a%b == 0){
        return b;
    }
    else {
        return GCD(b,a%b);
    }
}

int main(){
    int N; cin >> N;
    int mons[N+1];

    int i,j;


    rep(i,N){       
        cin >> mons[i];
    }



    int temp = mons[0];

    rep(j,N){
        temp = GCD(temp,mons[j]);
    }

    cout << temp << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>
#include <iomanip>

using namespace std;
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; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

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

	ll N;
	cin >> N;

	vector<ll> A(N);
	for (ll i = 0; i < N; ++i) cin >> A[i];

	vector<ll> Bu;
	vector<ll> Bl;

	bool flag_up = true;
	bool enable = true;
	for (ll i = 0; i < N - 1; ++i)
	{
		if (A[i] > A[i + 1])
		{
			flag_up = false;
			enable = true;
			break;
		}
		if (A[i] < A[i + 1])
		{
			flag_up = true;
			enable = true;
			break;
		}
	}

	if (!enable)
	{
		std::cout << "1000" << endl;
		return 0;
	}

	if (flag_up)
	{
		Bl.push_back(A[0]);
	}
	else
	{
		Bu.push_back(A[0]);
	}
	bool iniial_flag_up = flag_up;

	for (ll i = 2; i < N; ++i)
	{
		ll dA = A[i] - A[i - 1];

		if (flag_up && dA < 0)
		{
			Bu.push_back(A[i - 1]);
			flag_up = false;
			continue;
		}

		if (!flag_up && dA > 0)
		{
			Bl.push_back(A[i - 1]);
			flag_up = true;
			continue;
		}
	}

	if (flag_up)
	{
		Bu.push_back(A[N - 1]);
	}
	else
	{
		Bl.push_back(A[N - 1]);
	}

	ll iMax = min(Bu.size(), Bl.size());
	ll money = 1000;
	ll stock = 0;
	if (iniial_flag_up)
	{
		for (ll i = 0; i < iMax; ++i)
		{
			stock += money / Bl[i];
			money = money % Bl[i];

			money += stock * Bu[i];
			stock = 0;
		}
	}
	else
	{
		for (ll i = 0; i < iMax - 1; ++i)
		{
			stock += money / Bl[i];
			money = money % Bl[i];

			money += stock * Bu[i + 1];
			stock = 0;
		}
	}

	cout << money << endl;
}


Measured memory_bytes: 3660
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int x;
    cin >> x;
    int d = x % 10; x /= 10;
    int c = x % 10; x /= 10;
    int b = x % 10; x /= 10;
    int a = x;

    string ops = "+-";
    rep (i, 2)
    {
        int sum1 = a + (i == 0 ? b : -b);
        rep (j, 2)
        {
            int sum2 = sum1 + (j == 0 ? c : -c);
            rep (k, 2)
            {
                int sum3 = sum2 + (k == 0 ? d : -d);
                if (sum3 == 7)
                {
                    cout << a << ops[i] << b << ops[j] << c << ops[k] << d << "=7\n";
                    return 0;
                }
            }
        }
    }

    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
a, b, c, d = map(int, input().split())

if d < a or b < c:
    print("0")
elif c <= a and b <= d:
    print(b-a)
elif a <= c and d <= b:
    print(d-c)
elif c <= a:
    print(d-a)
else:
    print(b-c)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
    cin>>a;
    b=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.size();i++)
    {
        if(a[i]=='b') a[i]='d';
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==b) printf("Yes");
    else printf("No");
    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
import java.util.Arrays;
import java.util.stream.Stream;
public class Main {
	public static void main(String args[]){
      	Scanner sc = new Scanner(System.in);
      	String a = sc.nextLine();
        String[] b = a.split(" ");
        int[] c = Stream.of(b).mapToInt(Integer::parseInt).toArray();
        Arrays.sort(c);
        int p = (c[1]-c[0]+c[2]-c[1]);
        System.out.println(p);
    }
}

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

long long map[2][2][1010][1010];//[i][j][x][y]; i:0=W,1=B; j:0=Even,1=Odd
long long sum[2][2][1010][1010];//[i][j][x][y]; sum

void buildSum(int i, int j, int K) {
	for (int y = 0; y < K; y++) {
		for (int x = 0; x < K; x++) {
			if (y == 0) {
				if (x == 0) sum[i][j][x][y] = map[i][j][x][y];
				else sum[i][j][x][y] = sum[i][j][x - 1][y] + map[i][j][x][y];
			}
			else {
				if (x == 0)sum[i][j][x][y] = sum[i][j][x][y - 1] + map[i][j][x][y];
				else sum[i][j][x][y] = sum[i][j][x - 1][y] + sum[i][j][x][y - 1] - sum[i][j][x - 1][y - 1] + map[i][j][x][y];
			}
		}
	}
}

int calcSum(int i, int j, int xt, int yt, int xs, int ys) {
	int s1 = sum[i][j][xt - 1][yt - 1];
	int s2 = xs != 0 ? sum[i][j][xs - 1][yt - 1] : 0;
	int s3 = ys != 0 ? sum[i][j][xt - 1][ys - 1] : 0;
	int s4 = (xs != 0 || ys != 0) ? sum[i][j][xs - 1][ys - 1] : 0;
	return s1 - s2 - s3 + s4;
}

int main() {
	int N, K, xi, yi, ans = 0;
	char ci;
	cin >> N >> K;

	for (int i = 0; i < N; i++) {
		cin >> xi >> yi >> ci;
		int xq = xi / K, yq = yi / K, xr = xi % K, yr = yi % K;
		int color = ci == 'W' ? 0 : 1;
		int evenOrodd = (xq + yq) % 2;
		map[color][evenOrodd][xr][yr]++;
	}
	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 2; j++) {
			buildSum(i, j, K);
		}
	}
	for (int i = 1; i <= K; i++) {
		for (int j = 1; j <= K; j++) {
			//偶数盤左上が白⇔奇数盤で左上が黒, (WB,EO,xt,yt,xs,ys)
			int sum1 = calcSum(0, 0, K, K, i, j) + calcSum(1, 0, i, K, 0, j) + calcSum(1, 0, K, j, i, 0) + calcSum(0, 0, i, j, 0, 0)
				+ calcSum(1, 1, K, K, i, j) + calcSum(0, 1, i, K, 0, j) + calcSum(0, 1, K, j, i, 0) + calcSum(1, 1, i, j, 0, 0);
			int sum2 = calcSum(1, 0, K, K, i, j) + calcSum(0, 0, i, K, 0, j) + calcSum(0, 0, K, j, i, 0) + calcSum(1, 0, i, j, 0, 0)
				+ calcSum(0, 1, K, K, i, j) + calcSum(1, 1, i, K, 0, j) + calcSum(1, 1, K, j, i, 0) + calcSum(0, 1, i, j, 0, 0);
			int sum3 = max(sum1, sum2);
			ans = max(ans, sum3);
		}
	}
	
	cout << ans << endl;

	return 0;
}

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

const int MAX = 510000;
const int MOD = 1000000007;

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(){
  COMinit();
  int n,k;
  cin>>n>>k;
  for(int i=1;i<=k;i++){
    cout<<(COM(n-k+1,i)*COM(k-1,i-1))%MOD<<endl;
  }
}

Measured memory_bytes: 15540
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX
#define INFL LLONG_MAX
typedef long long ll;
using namespace std;


int main(){
  ll h;
  cin >> h;

  if(h){
    cout << 0 << endl;
  }
  else{
    cout << 1 << endl;
  }

  }


Measured memory_bytes: 3616
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float('inf')

n_nodes, m_edges = map(int, input().split())
edges = []
for _ in range(m_edges):
    u, v = map(int, input().split())
    edges.append([u - 1, v - 1])
# pprint(edges)


def find_root(v):
    if v != parents[v]:
        parents[v] = find_root(parents[v])
    return parents[v]


def has_same_root(u, v):
    return find_root(u) == find_root(v)


def unite(u, v):
    root_u, root_v = find_root(u), find_root(v)
    if root_u == root_v:
        return
    if rank[root_u] < rank[root_v]:
        root_u, root_v = root_v, root_u
    parents[root_v] = root_u
    rank[root_u] += rank[root_v]


res = 0
for i in range(m_edges):
    parents = [i for i in range(n_nodes)]
    rank = [1] * n_nodes
    for j in range(m_edges):
        if i == j:
            continue
        u, v = edges[j]
        if not has_same_root(u, v):
            unite(u, v)
    # pprint(parents)
    count = 0
    for v in range(n_nodes):
        if parents[v] == v:
            count += 1
    if count > 1:
        res += 1

print(res)


Measured memory_bytes: 42988
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

struct Edge {
    int to, id;
    Edge(int to, int id) :to(to), id(id) {}
};

vector<Edge> adj[55];

bool dfs(int now, int tar, int from, vector<int> & edges_bit) {
    if (now == tar) { return true; }
    
    for(auto e: adj[now]) {
        if (e.to == from) continue;
        
        if (dfs(e.to, tar, now, edges_bit)) { edges_bit.push_back(e.id); return true; }
    }
    return false;
}

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

    int n; cin >> n;
    rep(i, n-1) {
        int a, b; cin >> a >> b; --a; --b;
        adj[a].emplace_back(b, i);
        adj[b].emplace_back(a, i);
    }

    int m; cin >> m;
    vector<ll> edges_bit(m, 0);
    rep(i, m) {
        int u, v; cin >> u >> v; --u; --v;
        vector<int> edges_id;
        dfs(u, v, -1, edges_id);
        for(auto id: edges_id) edges_bit[i] |= 1LL<<id;
    }

    ll ans = 0;
    rep(bit, 1<<m) {
        ll mask = 0;
        rep(i, m) if (bit>>i&1) mask |= edges_bit[i];
        int white = __builtin_popcountll(mask);
        ll val = 1LL<<(n-1-white);

        if (__builtin_popcount(bit)%2==0) ans += val;
        else ans -= val; 
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>
using namespace std;
int main()
{

    long long int a,b,c,d;
    cin>>a>>b>>c>>d;
    long long arr[4];
    arr[0]=a*c;
    arr[1]=a*d;
    arr[2]=b*c;
    arr[3]=b*d;
    sort(arr,arr+4);
    cout<<arr[3];

    return 0;
}


Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main(){
    int N = 0;
    cin >> N;

    map<string, int> s;

    for(int i=0; i<N; i++){
        string str;
        cin >> str;
        sort(str.begin(), str.end());
        // cout << str;
        s[str]++;
    }

    long long count = 0;

    for(auto& i : s){
        int temp = i.second;
        count += (long long)temp*(temp-1)/2;
    }

    cout << count << endl;

    return 0;

}

Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>

using namespace std;

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	long long  l, r;
	cin >> l >> r;
	int ans = 2019;

	for (long long i = l; i < r; i++) {
		for (long long j = i + 1; j <= r; j++) {
			ans = min((long long)ans, ((i * j) % 2019));
			if (ans == 0) {
				cout << ans << endl;
				return 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}




Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let x:usize = read();
    let y:usize = read();
    let z:usize = read();
    println!("{}", (x-z) / (y+z));
}


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

using namespace std;

using int64 = long long;
const int INF = 1 << 30;


int main()
{
  int N, C;

  cin >> N >> C;
  vector< pair< int, int > > t[100001];

  for(int i = 0; i < N; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    --c;
    t[a].emplace_back(b, c);
  }

  int ret = 0, rest = 0, lock[30] = {};

  for(int i = 1; i < 100001; i++) {
    for(auto &p : t[i]) {
      if(lock[p.second] == 0) {
        if(rest > 0) --rest;
        else ++ret;
      }
      lock[p.second] = max(lock[p.second], p.first);
    }
    for(int j = 0; j < C; j++) {
      if(lock[j] == i) lock[j] = 0, ++rest;
    }
  }

  cout << ret << endl;
}

Measured memory_bytes: 5760
#include <stdio.h>
int main (void){
   
	int a,b,menseki,nagasa;

	scanf("%d %d",&a,&b);
	
	menseki = a * b ;

	nagasa = (a * 2) + (b * 2) ;

	printf("%d %d\n",menseki,nagasa);

	 
     return 0;
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
#include <limits>
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける





//a,b=x0,y0
//c,d=x1,y1
//e,f=x2,y2
bool pxpy(double &a,double &b,double &c,double &d,double &e,double &f,double &outpx, double &outpy){
  //double outpx,outpy;
  double ea=e-a,ca=c-a,bd=b-d,bf=b-f,aa=a*a,bb=b*b,cc=c*c,dd=d*d,ee=e*e,ff=f*f;
  if (ea*bd-ca*bf==0.0){return false;}
  outpy=ea*(aa+bb-cc-dd)-ca*(aa+bb-ee-ff);
  outpy=0.5*outpy/(ea*bd-ca*bf);
  if (c!=a){
    outpx=(2.0*bd*outpy-aa-bb+cc+dd)/(2.0*ca);
  }else{
    outpx=(2.0*bf*outpy-aa-bb+ee+ff)/(2.0*ea);
  }
  return true;
}


int n;
int main(){
  double ans=10000000000000000.0;
  cin >> n ;
  vector<double> x(n),y(n);
  REP(i,n){
    cin>>x[i]>>y[i];
  }

  if (n==2){
    double xx=x[0]-x[1];
    double yy=y[0]-y[1];
    cout<<sqrt(xx*xx+yy*yy)*0.5<<endl;
    return 0;
  }


  double py,px,tx,ty;
  double ltmp,lmax;
  REP(i,n){
    for(int j=i+1;j<n;j++){
      for(int k=j+1;k<n;k++){
        if (pxpy(x[i],y[i],x[j],y[j],x[k],y[k],px,py)==false)continue;
        lmax=0.0;
          for(int m=0;m<n;m++){
            tx=x[m]-px;
            ty=y[m]-py;
            ltmp=sqrt(tx*tx+ty*ty);
            //if (isinf(ltmp)){

            //}else{
              lmax=max(lmax,ltmp);
            //}
          }
        ans=min(ans,lmax);
      }
    }
  }



  double ans2=1000000000000.0;
  
   
  REP(i,n){
    for(int j=i+1;j<n;j++){
      double xx=(x[i]-x[j])*0.5+x[j];
      double yy=(y[i]-y[j])*0.5+y[j];
      lmax=0.0;
      REP(k,n)
      {
        ltmp=sqrt((xx-x[k])*(xx-x[k])+(yy-y[k])*(yy-y[k]));
        lmax=max(lmax,ltmp);
      }
      ans2=min(ans2,lmax);
    }
  }
  

  cout<<setprecision(16)<<min(ans,ans2)<<endl;
  return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;cin >> s >> t;
	string ans=s;
	int lens=s.size(),lent=t.size();
	bool find=false;
	for(int i=lens-lent+1;i>=0;--i){
		bool flg=true;
		rep(j,lent){
			if(s[i+j]!=t[j] && s[i+j]!='?'){
				flg=false;
				break;
			}
		}
		if(flg){
			ans=ans.substr(0,i)+t+ans.substr(i+lent,lens-lent-i);
			find=true;
			break;
		}
	}
	rep(i,lens){
		if(ans[i]=='?') ans[i]='a';
	}
	if(find) cout << ans << endl;
	else cout << "UNRESTORABLE" << 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 FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n, k, r, s, p;
	string t;
	cin >> n >> k >> r >> s >> p >> t;
	ll res = 0;
	vector<int> hand(n);
	rep (i, n) {
	  if (i < k) {
		if (t[i] == 'r') {
		  res += p;
		  hand[i] = 2;
		} else if (t[i] == 's') {
		  res += r;
		  hand[i] = 0;
		} else {
		  res += s;
		  hand[i] = 1;
		}
	  } else {
		if (t[i] == 'r') {
		  if (hand[i - k] == 2 && t[i - k] == 'r') {
			hand[i] = 1;
		  } else {
			hand[i] = 2;
			res += p;
		  }
		} else if (t[i] == 's') {
		  if (hand[i - k] == 0 && t[i - k] == 's') {
			hand[i] = 1;
		  } else {
			hand[i] = 0;
			res += r;
		  }
		} else {
		  if (hand[i - k] == 1 && t[i - k] == 'p') {
			hand[i] = 0;
		  } else {
			hand[i] = 1;
			res += s;
		  }
		}
	  }
	}
	cout << res << endl;
	
    return 0;
}



Measured memory_bytes: 3788
from bisect import bisect_left
n = int(input())
L = list(map(int, input().split()))
L = sorted(L)
ans = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        ans += bisect_left(L, L[i] + L[j]) - j - 1
print(ans)

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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String str = br.readLine();
			
			if(str == null){
				break;
			}
			
			String[] tmpArray = str.split(",");
			
			String ID = tmpArray[0];
			double weigh = Double.parseDouble(tmpArray[1]);
			double height = Double.parseDouble(tmpArray[2]);
			
			if(BMI(weigh, height) >= 25){
				System.out.println(ID);
			}
		}
	}
	
	static double BMI(double w, double h){
		return w/h/h;
	}

}

Measured memory_bytes: 24288
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n;
		while ((n = in.nextInt()) > 0) {
			boolean[][] map = new boolean[n][n];
			int[] fnum = new int[n];
			int fcount = 0;
			int m = in.nextInt();
			for (int i = 0; i < m; i++) {
				int a = in.nextInt() - 1;
				int b = in.nextInt() - 1;
				if (a == 0) {
					fnum[fcount] = b;
					fcount++;
				}
				map[a][b] = true;
				map[b][a] = true;
			}
			int count = fcount;
			for (int i = 0; i < fcount; i++) {
				int num = fnum[i];
				for (int j = 1; j < n; j++) {
					if (map[num][j]) {
						if (!map[0][j]) {
							count++;
						}
						map[0][j] = true;
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 46312
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <iomanip>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  // Input
  int N, K;
  std::cin >> N >> K;

  // Main
  double res = 0;
  for (int n = 1; n <= N; ++n) {
    int x = std::ceil(std::log2(K) - std::log2(n));
    if (x < 0)
      x = 0;
    double tmp = std::pow(0.5, x);
    assert(tmp <= 1.0);
    res += tmp;
  }
  res /= N;

  // Output
  std::cout << std::setprecision(12) << res << std::endl;

  return 0;
}


Measured memory_bytes: 384
from collections import defaultdict
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a_max = max(a)
A = defaultdict(int)
for i in range(n):
    A[a[i]] += 1
ans = 0
if A[0] == n:
    print(n)
    exit()
for i in range(a_max):
    ans = max(ans,A[i]+A[i+1]+A[i+2])
print(ans)

Measured memory_bytes: 24512
#include <bits/stdc++.h>
typedef long long int lint;

#define PI acos(-1)
#define INF64 1LL << 60
#define INF32 1 << 29
#define LIMIT(d_in, d_min, d_max) max(d_min, min(d_max, d_in))
#define all(a) (a).begin(), (a).end()
#define INV ((long long int)1000000007)

using namespace std;

void execute()
{
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	cout << (H - h) * (W - w) << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	execute();

	int stop;
	cin >> stop;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep1(i,b) for(ll i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define vi vector<ll>
#define all(v) v.begin(), v.end()

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

	ll n = 0;
	cin >> n;
	ll arr[n];
	rep(i, n) {
		cin >> arr[i];
	}
	sort(arr, arr + n);
	
	ll mid1 = (n / 2) - 1;
	ll mid2 = mid1 + 1;
	
	cout << arr[mid2] - arr[mid1] << endl;
	
	//cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 1024
using System;

namespace ABC053Ax
{
    class Program
    {
        static void Main(string[] args)
        {
            int a;

            a = int.Parse(Console.ReadLine());
           

            if (a < 1200)
                Console.WriteLine("ABC");
            else
                Console.WriteLine("ARC");

            Console.ReadKey();

        }
    }
}


Measured memory_bytes: 11092