akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<set>
using namespace std;

int main()
{
	int N, Q;
	while (cin >> N >> Q && N != 0 && Q != 0)
	{
		set<int> numSet[50];
		set<int> allSet;
		for (int i = 0; i < N ; i++)
		{
			int M;
			cin >> M;// M
			for (int j = 0; j < M; j++)
			{
				int tmp;
				cin >> tmp;
				numSet[i].insert(tmp);
				set<int>::iterator it = allSet.find(tmp);
				if (it == allSet.end())
				{
					allSet.insert(tmp);
				}
			}
		}
		int ans = 0;
		int max_count = 0;
		for (set<int>::iterator it = allSet.begin(); it != allSet.end(); it++)
		{
			int count = 0;
			for (int i = 0; i < N; i++)
			{
				set<int>::iterator itt = numSet[i].find(*it);
				if (itt != numSet[i].end())
				{
					count++;
				}
			}
			if (count >= Q &&  count > max_count)
			{
				max_count = count;
				ans = *it;
			}
		}
		cout << ans << endl;

	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;
ll table[] = {5,7,5,7,7};

int main(){
    while(cin >> n && n){
        vector<ll> v(n);
        rep(i,n){
            string s;
            cin >> s;
            v[i] = s.size();
        }
        rep(i,n){
            bool ok = true;
            ll cnt = 0;
            ll pos = 0;
            FOR(j,i,n){
                cnt += v[j];
                if(cnt > table[pos])ok = false;
                else if(cnt == table[pos]){
                    pos++;
                    cnt = 0;
                }
                if(pos == 5)break;
            }
            if(ok){
                cout << i+1 << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 3180
#include<stdio.h>

int solve(int,int);

int n,A[2000];

int main()
{
  int q = 0,m = 0,i = 0;

  scanf("%d",&n);

  for(i = 0;i < n;i++)
    {
      scanf("%d",&A[i]);
    }

  scanf("%d",&q);

  for(i = 0;i < q;i++)
    {
      scanf("%d",&m);
      if( solve(0,m) )
	{
	  printf("yes\n");
	}
      else
	{
	  printf("no\n");
	}
    }
  return 0;
}

int solve(int i,int m)
{
  if( m == 0 )
    return 1;
  if( i >= n )
    return 0;
  return solve(i+1,m) || solve(i+1,m-A[i]);
}



Measured memory_bytes: 2108
#include <iostream>
#include<list>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>
using namespace std;

int main()
{

    bitset<64> b(0);
    int q;cin>>q;
    int tp1,i;
    while(q--){
        cin>>tp1;
        switch(tp1){
        case 0:
            cin>>i;
            cout<<b.test(i)<<"\n";
            break;
        case 1:
            cin>>i;
            b.set(i,1);
            break;
        case 2:
                cin>>i;
                b.set(i,0);
            break;
        case 3:
            cin>>i;
            b.flip(i);
            break;
        case 4:
            cout<<b.all()<<endl;
            break;
        case 5:
            cout<<b.any()<<"\n";
            break;
        case 6:
            cout<<b.none()<<"\n";
            break;
        case 7:
            cout<<b.count()<<"\n";
            break;
        case 8:
            cout<<b.to_ulong()<<"\n";
            break;
         }
    }
}





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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int t, a;
  t = C / B;
  if (C % B != 0) {
    t++;
  }
  a = A / D;
  if (A % D != 0) {
    a++;
  }
  if (t <= a) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <cassert>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    int n;
    cin >> n;
    int k = 0;
    while (true) {
        if (k * (k + 1) / 2 >= n) {
            break;
        }
        ++k;
    }
    for (int i = k; i > 0; --i) {
        if (i <= n) {
            cout << i << "\n";
            n -= i;
        }
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define vi vector <int>
#define vl vector <ll>
#define dl pair <ll, ll>
#define ii pair <int, int>
#define vii vector <ii>
#define ff first
#define ss second
#define graph vector <vector <int> >
#define REP(a, b) for (int i = a; i < b; i++)
#define REP2(a, b) for (int j = a; j < b; j++)
#define REPS(a, b, c) for (int i = a; i < b; i += c)
#define mod 998244353
 
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
 
    int n, k;
    cin >> n >> k;
    ii a[k];
    REP(0, k) {
    	cin >> a[i].ff >> a[i].ss;
    }
    vl dp(n + 1, 0);
    dp[1] = 1;
    dp[2] = -1;
    ll suma = 0;
    REP(1, n) {
    	suma += dp[i];
    	suma = (suma + mod) % mod;
    	REP2(0, k) {
    		if (a[j].ff + i <= n) {
    			dp[a[j].ff + i] += suma;
    			dp[a[j].ff + i] %= mod;
    		}
    		if (a[j].ss + i + 1 <= n) {
    			dp[a[j].ss + i + 1] -= suma;
    			if (dp[a[j].ss + i + 1] >= 0) dp[a[j].ss + i + 1] %= mod;
    			else dp[a[j].ss + i + 1] = -((-1 * dp[a[j].ss + i + 1]) % mod);
    		}
    	}
    }
    suma += dp[n];
    suma = (suma + mod) % mod;
    cout << suma << "\n";
    return 0;
}


Measured memory_bytes: 4796
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

const int maxn = 100;
const int maxk = 100;
int n,k;
long long s[maxk];

int main()
{
    while(cin >> n >> k)
    {
        if(n==0 && k==0) break;

        rep(i,k) cin >> s[i];
        int t;

        rep(j,n)rep(i,k) 
        {
            cin >> t;
            s[i] -= t;
        }
        int flg = 1;
        rep(i,k)if(s[i]<0) flg = 0;

        if(flg) cout << "Yes" << endl;
        else cout << "No" << endl;

    }
    return 0;
}

Measured memory_bytes: 860
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
typedef long long ll;

int main(){
  int n;
  double x[1000],ans=0;
  cin >> n;
  string y[1000];
  FOR(i,n){
    cin >> x[i] >> y[i];
  }
  FOR(i,n){
    if(y[i]=="JPY"){
      ans+=x[i];
    }else{
      ans+=x[i]*380000;
    }
  }

  cout << ans << endl;
  
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
a.append(0)
b.append(0)
count = 0
temp = 0
for i in range(n+1):
    if(a[i] > b[i]):
        count += b[i]
    else:
        count += a[i]
    b[i] = max(0, b[i]-a[i])
    if(a[i+1] > b[i]):
        count += b[i]
    else:
        count += a[i+1]
    a[i+1] = max(0, a[i+1]-b[i])

print(count)

Measured memory_bytes: 82148
#include <stdio.h>
#include<ctype.h>
#include<stdlib.h>
#include<string.h>
typedef long long int ll;
char getch(int n)
{
    char c;
    for(c='a';n>1;c++,n--);
    return c;
}
int main()
{
    ll n,k=26,l,m,i=14;char str[15];
    scanf("%lld",&n);
    while(1)
    {
        m=n%k,l=n/k;
        if(m==0) l--,m=26;
        str[i]=getch(m);
        if(l>=26) i--,n=l;
        else if(l!=0){str[--i]=getch(l);break;}
        else break;
    } 
    for(k=i;k<15;k++)
    printf("%c",str[k]);
}


Measured memory_bytes: 1632
#include <iostream>
using namespace std;
int main(){
    int n;
    int a[3];
    cin >> n;
    for (int i = 0; i < 3; i++) {
        a[i] = 10 - n % 10;
        n /= 10;
    }
    for (int i = 2; i >= 0; i--) {
        cout << a[i];
    }
    cout << endl;
    return 0;
}


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


int main()
{
  int a;
  string s;
  cin >> a >> s;
  if (a >= 3200)
    cout << s << endl;
  else
    cout << "red\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int K;
    cin >> K;
    string S;
    cin >> S;
    int a = (int)S.length();
    
    if(a <= K) cout << S << endl;
    else{
        cout << S.substr(0,K) << "..." << endl;
    }
    
    

    return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 2e5+10, mod = 1e9+7;

void solve() {
    int h, w, m; cin >> h >> w >> m;

    int hc[h + 1], wc[w + 1];
    pii pos[m + 1];
    memset(pos, 0, sizeof(pos));
    memset(hc, 0, sizeof(hc));
    memset(wc, 0, sizeof(wc));

    for (int i = 1; i <= m; ++i) {
        int x, y; cin >> x >> y;
        pos[i] = {x, y};
        ++hc[x];
        ++wc[y];
    }

    int hmx = 0, hcnt = 0;
    for (int i = 1; i <= h; ++i) {
        if (hc[i] == hmx) {
            ++hcnt;
        }
        if (hc[i] > hmx) {
            hcnt = 1;
            hmx = hc[i];
        }
    }

    int wmx = 0, wcnt = 0;
    for (int i = 1; i <= w; ++i) {
        if (wc[i] == wmx) {
            ++wcnt;
        }
        if (wc[i] > wmx) {
            wcnt = 1;
            wmx = wc[i];
        }
    }

    int ans = hmx + wmx, cnt = 0;
    for (int i = 1; i <= m; ++i) {
        int x = pos[i].first, y = pos[i].second;
        if (hc[x] == hmx && wc[y] == wmx) {
            ++cnt;
        }
    }
    
    if (hcnt * wcnt == cnt) {
        --ans;
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 8344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    int k, s, cnt=0; cin >> k >> s;
    rep(i, k+1){
        rep(j, k+1){
            if(s - i - j <= k && s - i - j >= 0 ) cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define N 100010
using namespace std;
struct node{double x,y;}b[N];
node O;
double R;
double sqr(double x){return x*x;}
double dis(node x,node y)
{
    return sqrt(sqr(x.x-y.x)+sqr(x.y-y.y));
}
bool incircle(node x)
{
    if(dis(O,x)<=R) return true;
    return false;
}
node solve(double a,double b,double c,double d,double e,double f)
{
    double y=(f*a-c*d)/(b*d-e*a);
    double x=(f*b-c*e)/(a*e-b*d);
    return (node){x,y};
}
int main()
{
    int n;
    scanf("%d",&n);
    int i,j,k;
    for(i=1;i<=n;i++)
    scanf("%lf%lf",&b[i].x,&b[i].y);
    random_shuffle(b+1,b+n+1);
    R=0;
    for(i=1;i<=n;i++)
    if(!incircle(b[i]))
    {
        O.x=b[i].x;O.y=b[i].y;R=0;
        for(j=1;j<i;j++)
        if(!incircle(b[j]))
        {
            O.x=(b[i].x+b[j].x)/2;
            O.y=(b[i].y+b[j].y)/2;
            R=dis(O,b[i]);
            for(k=1;k<j;k++)
            if(!incircle(b[k]))
            {
                O=solve(
                b[i].x-b[j].x,b[i].y-b[j].y,(sqr(b[j].x)+sqr(b[j].y)-sqr(b[i].x)-sqr(b[i].y))/2,
                b[i].x-b[k].x,b[i].y-b[k].y,(sqr(b[k].x)+sqr(b[k].y)-sqr(b[i].x)-sqr(b[i].y))/2
                );
                R=dis(b[i],O);
            }
        }
    }
    printf("%.10lf\n",R);
}


Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
 #pragma GCC optimize("Ofast")
 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 #include<bits/stdc++.h>
 #define int long long
 using namespace std;

int dp[3005][7005][2];

signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif

 
// -------------------------------------Code starts here--------------------------------------------------------------------- 
    
    int n,t;
    cin>>n>>t;

    pair<int,int>p[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>p[i].first>>p[i].second;
    }
    sort(p+1,p+n+1,greater<>());
    
    int mx=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<t;j++)
        {
            dp[i][j][0]=dp[i-1][j][0];
            dp[i][j][1]=dp[i-1][j][1];
            dp[i][j][1]=max(dp[i-1][j][0]+p[i].second,dp[i-1][j][1]);
            if(j-p[i].first>=0)
            {
                dp[i][j][0]=max(dp[i-1][j-p[i].first][0]+p[i].second,dp[i-1][j][0]);
                dp[i][j][1]=max(dp[i-1][j-p[i].first][1]+p[i].second,dp[i-1][j][1]);
            }
            
            mx=max(dp[i][j][0],dp[i][j][1]);
        }
    }

    cout<<mx;

// -------------------------------------Code ends here------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
     clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 327168
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,d,x,a[105];
	int ans = 0;
	scanf("%d%d%d", &n, &d, &x);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		int t = d/a[i];
		if(d%a[i] != 0){
			t++;
		}
		ans+=t;
	}
	printf("%d\n",ans+x);
	return 0;
 } 

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<math.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define N (1000000000+7)
#define INF (ll)1e16
typedef long long ll;


int main(void){
    string s,t;
    cin>>s>>t;
    vector<ll>ap[26];
    ll ssize=(ll)s.size();
    ll tsize=(ll)t.size();
    for(ll i=0;i<ssize;i++)ap[s[i]-'a'].push_back(i);
    ll cycle=0,now=-1;
    for(ll i=0;i<tsize;i++){
        ll alpha=t[i]-'a';
        if((ll)ap[alpha].size()==0){
            cout<<-1<<endl;
            return 0;
        }
        auto itr=upper_bound(ap[alpha].begin(),
        ap[alpha].end(),now);
        if(itr==ap[alpha].end())cycle++,itr=ap[alpha].begin();
        now=*itr;
    }
    cout<<(ll)cycle*ssize+now+1<<endl;
    return 0;
}

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

using namespace std;

const int maxn = 200010;

string s;
int n;

int dp[maxn][2];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> s;
	n = s.length();
	s = " " + s;
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}

	dp[1][1] = 1;
	dp[2][1] = 1;
	if (s[1] != s[2]) dp[2][1] = 2;

	for (int i = 3; i <= n; i++) {
		//take two 
		dp[i][2] = dp[i-2][1] + 1;
		if (s[i] != s[i-2] || s[i-1] != s[i-3]) {
			dp[i][2] = max(dp[i][2], dp[i-2][2]+1);
		}
		dp[i][1] = dp[i-1][2]+1;
		if (s[i] != s[i-1]) dp[i][1] = max(dp[i][1], dp[i-1][1]+1);
	}

	cout << max(dp[n][1], dp[n][2]) << endl;

}

Measured memory_bytes: 2128
#include <stdio.h>
#include <string.h>
#define MAX 100


int n , pos , c , d = 0;
int pre[1000] , in[1000],post[1000];

int find(int a)
{
	int i ;
	for( i = 0; i < n; i++)
	{
		if(a == in[i]) return i;
	}
	return 0;
}

void rec(int l , int r)
{
	int a , b;
	if(l >= r) return;
	a = pre[d++];
	b = find(a);
	rec(l,b);
	rec(b+1,r);
	post[c++] = a;
}



int main(void)
{
	int i;
	scanf("%d",&n);
	
	for( i = 0; i < n; i++)
	{
		scanf("%d",&pre[i]);
	}
	for( i = 0; i < n; i++)
	{
		scanf("%d",&in[i]);
	}
	rec(0,n);
	for(i = 0; i < n; i++)
	{
		if(i != n-1)printf("%d ",post[i]);
		else printf("%d\n",post[i]);
	}
}



Measured memory_bytes: 2052
main = do
    n <- getLine
    p <- map read <$> words <$> getLine
    q <- map read <$> words <$> getLine
    print $ abs $ solve p - solve q

solve :: [Int] -> Int
solve []      = 0
solve (h : t) = (h - 1) * product [1 .. length t] + solve (next h t)

next a []      = []
next a (h : t) = (if h > a then h - 1 else h) : next a t


Measured memory_bytes: 3888
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;

int w;
int a[100000];
int cnt[100000];

int main(){
	cin >> w;
	rep(i,w) cin >> a[i];
	int tmp = 0;
	rep(i,w){
		tmp--;
		if(a[i] == 0) tmp = INF;
		else if(a[i] > 0){
			if(tmp > 0) cnt[i] = tmp;
		} else{
			tmp = min(tmp,abs(a[i]));
		}
	}
	tmp = 0;
	for(int i = w-1; i >= 0; i--){
		tmp--;
		if(a[i] == 0) tmp = INF;
		else if(a[i] > 0){
			cnt[i] = max(cnt[i],tmp);
		} else{
			tmp = min(tmp,abs(a[i]));
		}
	}
	int ans = 0;
	rep(i,w){
		if(a[i] <= 0) continue;
		ans += min(a[i],cnt[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1940
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
constexpr ll mod = 1000000007;

int main() {
    ll n, a, b, r = 0;
    cin >> n >> a >> b;
    r += (n/(a+b))*a;
    n = n % (a+b);
    r += min(a,n);
    cout << r << endl;
}

Measured memory_bytes: 256
NMC = input()
NMC_ = NMC.split()
N = int(NMC_[0])
M = int(NMC_[1])
C = int(NMC_[2])
B = input()
B_ = B.split()
B_list = [int(n) for n in B_]
true = 0

for i in range(N):
    s = 0
    A = input()
    A_ = A.split()
    A_list = [int(n) for n in A_]
    for j in range(M):
        s += A_list[j] * B_list[j]
    if s + C > 0:
        true += 1
        
print(true)

Measured memory_bytes: 3064
#define NDEBUG

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#include <assert.h>
// for DEBUG {{{
#ifdef NDEBUG
#define DEBUG_PRINT(fmt, ...) ((void)0)
#else
#define DEBUG_PRINT(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
#endif
#define ASSERT_RANGE(min,x,max) assert(((x)>=(min)) && ((x)<=(max)))
// }}}

typedef long long ll;

#define GET_D(x) fscanf(stdin,"%d",&(x)) > 0
#define GET_LLD(x) fscanf(stdin,"%lld",&(x)) > 0
#define GET_S(x) fscanf(stdin,"%s",(x)) > 0
#define PUT_D(x) fprintf(stdout,"%d\n",(x))

#define FOR(i,min,max) for ((i) = (min); (i) < (max); (i)++)

int sort_int(int *a, int N) {// {{{
	int i;
	for (i = 0; i < N-1; i++) {
		int j;
		for (j = i + 1; j < N; j++) {
			if (a[i] > a[j]) {
				int tmp = a[i];
				a[i] = a[j];
				a[j] = tmp;
			}
		}
	}
	return 0;
}// }}}
void merge_int(int *a, int *b, int lower, int sep, int upper) {// {{{
	int i_lower = lower;
	int i_upper = sep;
	int i_b = 0;
	while ((i_lower < sep) && (i_upper < upper)) {
		if (a[i_lower] < a[i_upper]) {
			b[i_b++] = a[i_lower++];
		} else {
			b[i_b++] = a[i_upper++];
		}
	}
	if (i_lower >= sep) {
		while (i_upper < upper) {
			b[i_b++] = a[i_upper++];
		}
	} else {
		while (i_lower < sep) {
			b[i_b++] = a[i_lower++];
		}
	}
	for (i_lower = 0; i_lower < i_b; i_lower++) {
		a[i_lower+lower] = b[i_lower];
	}
}// }}}
void merge_sort_int(int *a, int *b, int lower, int upper) {// {{{
	int sep;
	if ((lower == upper) || (lower + 1 == upper)) {
		return;
	}
	sep = (lower + upper) / 2;
	merge_sort_int(a,b,lower,sep);
	merge_sort_int(a,b,sep,upper);
	merge_int(a,b,lower,sep,upper);
}// }}}


#define N_MIN 1
#define N_MAX 100000

int main(int argc, char **argv) {
	int n;
	int k;
	int h[N_MAX];
	GET_D(n);
	GET_D(k);
	{
		int i;
		FOR(i,0,n) {
			GET_D(h[i]);
		}
	}
	{
		int ret = 0;
		int i;
		FOR(i,0,n) {
			ret += (h[i] >= k);
		}
		PUT_D(ret);
	}
	return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <queue>
using namespace std;

typedef long long lli;

const int MAXR = 102;
const int MAXC = 12;
const lli INF = 1LL<<60;

int R, C;
lli G[MAXR][MAXC];
int numR[MAXR], numC[MAXC];

int main() {
  bool first = true;
  while(cin >> R && R) {
    cin >> C;
    vector<pair<int,int> > v;
    for(int i = 0; i < R+1; ++i) {
      for(int j = 0; j < C+1; ++j) {
        string s;
        cin >> s;
        if(s == "?") {
          G[i][j] = INF;
          v.push_back(make_pair(i,j));
        } else {
          G[i][j] = atoi(s.c_str());
        }
      }
    }

    fill(numR, numR+MAXR, 0);
    fill(numC, numC+MAXC, 0);
    for(int i = 0; i < R; ++i) {
      for(int j = 0; j < C; ++j) {
        if(G[i][j] == INF) {
          ++numR[i];
          ++numC[j];
        }
      }
    }

    queue<pair<int,int> > que;
    for(int i = 0; i < R; ++i) {
      for(int j = 0; j < C; ++j) {
        if(G[i][j] == INF) {
          if(numR[i] == 1 || numC[j] == 1) {
            que.push(make_pair(i,j));
          }
        }
      }
    }

    while(!que.empty()) {
      pair<int,int> p = que.front();
      que.pop();
      if(G[p.first][p.second] != INF) continue;

      lli sum;
      bool flag = false;
      if(!flag) {
        flag = true;
        sum = G[p.first][C];
        for(int j = 0; j < C; ++j) {
          if(j == p.second) continue;
          if(G[p.first][j] == INF) {
            flag = false;
            break;
          }
          sum -= G[p.first][j];
        }
      }
      if(!flag) {
        flag = true;
        sum = G[R][p.second];
        for(int i = 0; i < R; ++i) {
          if(i == p.first) continue;
          if(G[i][p.second] == INF) {
            flag = false;
            break;
          }
          sum -= G[i][p.second];
        }
      }

      if(flag) {
        G[p.first][p.second] = sum;
        if(--numR[p.first] == 1) {
          for(int j = 0; j < C; ++j) {
            if(G[p.first][j] == INF) {
              que.push(make_pair(p.first, j));
              break;
            }
          }
        }
        if(--numC[p.second] == 1) {
          for(int i = 0; i < R; ++i) {
            if(G[i][p.second] == INF) {
              que.push(make_pair(i, p.second));
              break;
            }
          }
        }
      }
    }

    vector<lli> ans;
    for(int i = 0; i < v.size(); ++i) {
      if(G[v[i].first][v[i].second] == INF) {
        ans.clear();
        break;
      }
      ans.push_back(G[v[i].first][v[i].second]);
    }

    if(first) {
      first = false;
    } else {
      cout << endl;
    }
    if(ans.size()) {
      for(int i = 0; i < ans.size(); ++i) {
        cout << ans[i] << endl;
      }
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1252
{-# LANGUAGE MultiWayIf #-}

import Data.List
import Control.Applicative

main :: IO ()
main = do
  [n,m] <- map read . words <$> getLine :: IO [Int]
  let mi = min n m
      di = abs (n-m)
      fa = prod [1 .. mi]
  print
   $ if di >= 2 then 0
     else fa `mult` fa
           `mult` if di == 1 then mi+1 else 2 
  

modulus :: Int
modulus = 10^9 + 7

mult :: Int -> Int -> Int
mult x y = (x * y) `mod` modulus

prod :: [Int] -> Int
prod = foldl' mult 1


Measured memory_bytes: 508
n = int(input())
s = input()
mod = 10 ** 9 + 7

ans = 1
mul = 0
for i in range(n * 2):
    if s[i] == "B":
        if mul % 2 == 0:
            mul += 1
        else:
            ans *= mul
            ans %= mod
            mul -= 1
    else:
        if mul % 2 == 1:
            mul += 1
        else:
            ans *= mul
            ans %= mod
            mul -= 1
for i in range(n):
    ans *= (i + 1)
    ans %= mod
if mul != 0:
    ans = 0
print(ans)

Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll mod = 1e9 + 7;
ll powmod(ll a, ll b) { ll res=1; a%=mod; assert(b>=0); for(;b;b>>=1) { if(b&1) res=res*a%mod; a=a*a%mod; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }

int main() {
	int t;
	//cin >> t;
	t = 1;
	while(t--) {
		int n, x;
        cin >> n;
        
        vector<int> arr(n);
        int exor = 0;
        for(int i=0; i<n; i++) {
            cin >> arr[i];
            exor = exor ^ arr[i];
        }
        
        for(int i=0; i<n; i++)
            cout << (exor ^ arr[i]) << " ";
        cout << endl;
	}

	return 0;
}

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

const int  MAX_N = 3001;
const int  MAX_M = 3001;

int dp[MAX_N][MAX_M];

int main(){
    string s, t;
    cin >> s >> t;
    int n = s.size();
    int m = t.size();
    rep(i, n){
        rep(j, m){
            if(s[i] == t[j]) dp[i + 1][j + 1] = dp[i][j] + 1;
            else dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
        }
    }

    int l = dp[n][m];

    string ans = "";
    int i = n, j = m;

    while(i > 0 && j > 0){
        if (s[i - 1] == t[j - 1]){
            ans = s[i - 1] + ans;
            i --;
            j --;
        }
        else if (dp[i][j] == dp[i][j - 1]) j --;
        else i --;
    }

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

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

void judge(bool ok, int cnt) {
   if (!ok) {
      if (cnt&1) {
         puts("First");
      } else {
         puts("Second");
      }
      exit(0);
   }
}

int main() {
   string s;
   cin >> s;

   int n = s.size();
   int cnt = 0;

   while (1) {
      bool ok = false;
      if (n == 2) {
         judge(ok, cnt);
      }
      for (int i = 1; i < n-1; i++) {
         if (s[i-1] != s[i+1]) {
            s.erase(s.begin()+i);
            cnt++;
            n--;
            ok = true;
            break;
         }
      }
      judge(ok, cnt);
   }

   return 0;
}

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

using namespace std;

typedef long long int64;


int main()
{
  int64 L;
  int N;
  int64 S[100000], T[100000], A[200001];
  A[0] = 0;

  cin >> L;
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> S[i] >> T[i];
    A[i + 1] = T[i] - S[i] + A[i];
  }

  int64 ret = 0;
  for(int i = 0; i < N; i++) {
    int64 start = S[i], end = S[i] + L - 1;
    int low = i, high = N - 1;
    while(high - low > 0) {
      int mid = (low + high + 1) >> 1;
      if(end >= S[mid]) low = mid;
      else high = mid - 1;
    }
    ret = max(ret, A[low] - A[i] + max(0LL, min(T[low] - 1, end) - S[low] + 1));
  }
  cout << ret << endl;
}

Measured memory_bytes: 4288
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner();
		int s = sc.nextInt();
		List<Integer> l = new ArrayList<>();
		l.add(s);
		
		int count = 2;
		while(true) {
			int i = function(l.get(count-2));
			if(l.contains(i)) {
				System.out.println(count);
				return;
			}
			
			l.add(i);
			count++;
		}
		
	}
	
	private static int function(int i ) {
		if(i % 2==0) 
			return i/2;
		else
			return 3 * i + 1;
	}
}

class Scanner {
	private static final int SPACE = (int)' ';
	private static final int LINE_END_0 = 13;
	private static final int LINE_END_1 = 10;
	private static final int BEFORE = -1;
	private BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	
	public String next(){
		StringBuilder sb = new StringBuilder();
		
		int length = BEFORE;
		readLoop: while(true) {
			try {
				int value = br.read();
				switch(value) {
				case LINE_END_1:
					if(length == BEFORE)
						break;
					
					if((int)sb.charAt(length) == LINE_END_0)
						sb.deleteCharAt(length);
				case SPACE:
					break readLoop;
				}
				sb.append((char)value);
				length++;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return sb.toString();
	}
	
	public String[] nextArray(int length) {
		String[] array = new String[length];
		for(int i = 0; i < length; i++)
			array[i] = next();
		return array;
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
	
	public double[] nextDoubleArray(int length) {
		double[] array = new double[length];
		for(int i = 0; i < length; i++)
			array[i] = nextDouble();
		return array;
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public int[] nextIntArray(int length) {
		int[] array = new int[length];
		for(int i = 0; i < length; i++)
			array[i] = nextInt();
		return array;
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public long[] nextLongArray(int length) {
		long[] array = new long[length];
		for(int i = 0; i < length; i++)
			array[i] = nextLong();
		return array;
	}
	
	public boolean ready() {
		try {
			return br.ready();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return false;
	}
}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
#define CFS cin.tie(nullptr);ios::sync_with_stdio(false);
#define CST(x) cout<<fixed<<setprecision(x);
using namespace std;
const int IINF = 1 << 30;
const long LINF = 1LL << 60;
const int MOD = (int) 1e9 + 7;
// const int MOD = 998244353;

int main(){
    long n, k;
    cin >> n >> k;
    cout << min(k - (n % k), (n % k)) << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
const int N=1e5+10;
int ans;
char s[N]; 
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	for(int i=1;i<len;++i)
		if(s[i]!=s[i-1])ans++;
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define forit(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define REP(i,f,t) for(int i=f;i<(int)t;++i)
#define pb push_back
#define mp make_pair
#define all(a) begin(a),end(a)
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
const int inf = 1e9+5;


int main(){
    int n,wm,i,j;
	fast_io;
	cin >> n >> wm;
	vector<int> v(n), w(n);
	for(i=0;i<n;++i)cin>>w[i]>>v[i];
	int sumv=0;
	for(int e : v)sumv+=e;

	vector<int> dp(sumv+1, inf);
	dp[0]=0;

    for(i=0;i<n;++i){
        for(j=sumv - v[i]; j>=0; --j){
			if(dp[j]!=inf){
				dp[j+v[i]] = min(dp[j+v[i]], dp[j] + w[i]);
			}
		}
	}

	for(i=sumv;i>=0;--i)
        if(dp[i]<=wm)break;
	cout << i;
}


//1 1000000000
//1000000000 10


Measured memory_bytes: 640
/* ex 9_1
   nnasy */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//スタックに格納するデータの最大数
#define SIZE 100

//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//データの取り出し
char pop(stack *stk){
    char latest;
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}

int main(void){
    //stk: 入出力を管理するスタック
    stack stk;
    //input: 入力文字列
    char input[SIZE];

    //スタックを初期化（ポインタ渡しで関数にわたすこと）
    initialize_stack(&stk);

    //入力の読み取り
    scanf("%s", input);

    //入力文字に対する処理
    for (int i=0; i<strlen(input); i++){
        //'0'または'1'ならその文字をスタックに入れる
        if (input[i]=='0' || input[i]=='1'){
            push(&stk, input[i]);
        //'B'ならスタックの先頭の文字を消去
        }else if (stk.count > 0){
            pop(&stk);
        }
    }

    //スタックに残っている文字列の出力
    for (int i=0; i<stk.count; i++){
        printf("%c", stk.data[SIZE-i-1]);
    }
    printf("\n");
    
    return 0;
}

Measured memory_bytes: 1656
H,W = map(int,input().split())
a = H%2
b = W%2
ans = 10**9
if H%3==0 or W%3==0:
    print(0)
elif H==1 or W==1:
    print(1)
else:
    for i in range(1,W):
        c = (H*i,H//2*(W-i),H*W-H*i-(H//2)*(W-i))
        ans = min(ans,max(c)-min(c))
        c = (H*i,(W-i)//2*H,H*W-H*i-(W-i)//2*H)
        ans = min(ans,max(c)-min(c))
    for i in range(1,H):
        c = (W*i,W//2*(H-i),H*W-W*i-(W//2)*(H-i))
        ans = min(ans,max(c)-min(c))
        c = (W*i,(H-i)//2*W,H*W-W*i-(H-i)//2*W)
        ans = min(ans,max(c)-min(c))
    
    print(ans)

Measured memory_bytes: 43484
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author dyominov
 */
public class Main {
  public static void main(String[] args) {
    InputStream inputStream = System.in;
    OutputStream outputStream = System.out;
    InputReader in = new InputReader(inputStream);
    PrintWriter out = new PrintWriter(outputStream);
    ABeginning solver = new ABeginning();
    solver.solve(1, in, out);
    out.close();
  }

  static class ABeginning {
    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = 4;
      int[] arr = in.nextArray(n);
      Arrays.sort(arr);
      out.println(Arrays.equals(arr, new int[]{1, 4, 7, 9}) ? "YES" : "NO");
    }

  }

  static class InputReader implements AutoCloseable {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
      reader = new BufferedReader(new InputStreamReader(stream), 32768);
      tokenizer = null;
    }

    public String next() {
      while (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

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

    public int[] nextArray(int n) {
      int[] arr = new int[n];
      for (int i = 0; i < n; i++) {
        arr[i] = nextInt();
      }
      return arr;
    }

    public void close() {
    }

  }
}



Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <cstdio>
#include <iomanip>

using namespace std;

#define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define RREP(i,n) for(int (i)=(int)(n)-1;(i)>=0;(i)--)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())

typedef long long ll;


class Source{
private:
    string str;
    int pos;
    
public:
    int peek(){
        if(pos<str.size())return str[pos];
        return -1;
    }
    
    void next(){
        pos++;
    }
    
    void init(string _str){
        str=_str;
        pos=0;
    }
    
};


class Parser{
private:
    Source src;
    
public:
    Parser(string str){
        src.init(str);
    }
    
    bool isDigit(char s){
        if(s>='0'&&s<='9')return true;
        return false;
    }
    
    int number(){
        string res;
        while(src.peek()!=-1&&isDigit(src.peek())){
            res+=src.peek();
            src.next();
        }
        return stoi(res);
    }
    
    int expr(){
        int x=term();
        while(true){
            switch(src.peek()) {
                case '+':
                    src.next();
                    x+=term();
                    continue;
                case '-':
                    src.next();
                    x-=term();
                    continue;
            }
            break;
        }
        return x;
    }
    
    int term(){
        int x=factor();
        while(true){
            switch(src.peek()){
                case '*':
                    src.next();
                    x*=factor();
                    continue;
                case '/':
                    src.next();
                    x/=factor();
                    continue;
            }
            break;
        }
        return x;
    }
    
    int factor(){
        if(src.peek()=='('){
            src.next();
            int res=expr();
            if(src.peek()==')'){
                src.next();
            }
            return res;
        }
        return number();
    }
    
};



int main(){
  
    int n;
    cin>>n;
    
    REP(i,n){
        string s;
        cin>>s;
        
        s=s.substr(0,s.size()-1);
        
        Parser par(s);
        cout<<par.expr()<<endl;
        
    }
    
    return 0;
}

Measured memory_bytes: 3144
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int a,b;
  cin >> a >> b;
  b -= 1;
  cout << a - b << '\n';
  return 0;
}

Measured memory_bytes: 256
import sys
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def lcm(a,b):
	return a*b//gcd(a,b)
	
sets = sys.stdin.readlines()
for line in sets:
    a, b = map(int, line.split())
    print(gcd(a,b), lcm(a, b))

Measured memory_bytes: 7688
n=int(input())
INF=float('inf')

H=[]
for _ in range(n):
  a,b,c=map(int,input().split())
  H.append([a,b,c])
  
dp=[[0 for i in range(3)] for j in range(n+1)]
for i in range(1,n+1):
  dp[i][0]=max(dp[i-1][1]+H[i-1][0],dp[i-1][2]+H[i-1][0])
  dp[i][1]=max(dp[i-1][2]+H[i-1][1],dp[i-1][0]+H[i-1][1])
  dp[i][2]=max(dp[i-1][0]+H[i-1][2],dp[i-1][1]+H[i-1][2])

print(max(dp[n][0],dp[n][1],dp[n][2]))



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

int ABC[3];
int K;

int main() {
    for (int i = 0; i < 3; i++) cin >> ABC[i];
    cin >> K;

    sort(ABC, ABC+3);
    for (int i = 0; i < K; i++) ABC[2] *= 2;
    cout << ABC[0] + ABC[1] + ABC[2] << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
#define INF 1000000000
#define mod 1000000007


int H, W, K;

bool check(int j){
    for(int k=0; k<W-1; k++){
        if(j>>k & 1 && j>>(k+1) & 1) return false;
    }
    return true;
}


int main() {
    cin >> H >> W >> K;
    vector<vector<int>> dp(H+1, vector<int>(W));
    dp[0][0] = 1;
    if(W==1){
        cout << 1 << endl;
        return 0;
    }
    
    for(int i=0; i<H; i++){
        for(int j=0; j<1<<(W-1); j++){
            if(!check(j)) continue;
            
            for(int k=0; k<W-1; k++){
                if(j>>k & 1){
                    dp[i+1][k] += dp[i][k+1];
                    dp[i+1][k+1] += dp[i][k];
                    dp[i+1][k] %= mod;
                    dp[i+1][k+1] %= mod;
                }else{
                    if(k==0){
                        dp[i+1][k] += dp[i][k];
                        dp[i+1][k] %= mod;
                    }else{
                        if(!(j>>(k-1) & 1)){
                            dp[i+1][k] += dp[i][k];
                            dp[i+1][k] %= mod;
                        }
                        if(k==W-2){
                            dp[i+1][k+1] += dp[i][k+1];
                            dp[i+1][k+1] %= mod;
                        }
                    }
                }
            }
        }
    }
    
    cout << dp[H][K-1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int digits(ll n){
    int cnt = 0;
    while(n > 0){
        n /= 10; ++cnt;
    }
    return cnt;
}

int main(){
    ll n; cin >> n;
    
    int ans = digits(n);
    for(ll i = 1LL; i*i <= n; ++i){
        if(n%i) continue;
        ll j = n / i;
        ans = min(ans, max(digits(i), digits(j)));
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#include <random>
#include <unordered_set>
#include <complex>
using namespace std;
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
// typedef complex<double> C;
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 2;
double EPS = 1e-10;

int main() {
	int A, B; cin >> A >> B;
	A = (A + 11) % 13;
	B = (B + 11) % 13;
	if (A > B) cout << "Alice" << endl;
	if (A < B) cout << "Bob" << endl;
	if (A == B) cout << "Draw" << endl;
}


Measured memory_bytes: 764
#include <iostream>

using namespace std;

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

    int count = 0;
    for (int i = a; i <= b; ++i) {
        if (c % i == 0) count++;
    }
    
    cout << count << endl;
    
    return 0;
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
char s[1<<18];
int f[1<<18][2],n,c[1<<18][2];
void trc(int p,int f){
	if(!p)return;
	trc(p-1,c[p][f]);
	putchar(f?'D':'P');
}
int main(){
	scanf(" %s",s+1);n=strlen(s+1);
	memset(f,192,sizeof f);
	if(s[1]!='D')f[1][0]=0;
	if(s[1]!='P')f[1][1]=1;
	for(int i=2;i<=n;i++){
		if(s[i]!='D'){
			if(f[i-1][1]>f[i-1][0])
				f[i][0]=f[i-1][1],c[i][0]=1;
			else f[i][0]=f[i-1][0],c[i][0]=0;
		}
		if(s[i]!='P'){
			if(f[i-1][1]+1>f[i-1][0]+2)
				f[i][1]=f[i-1][1]+1,c[i][1]=1;
			else f[i][1]=f[i-1][0]+2,c[i][1]=0;
		}
	}
	if(f[n][0]>f[n][1])trc(n,0);else trc(n,1);
	return 0;
}

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

using namespace std;
#define N 200010
#define ll long long
#define ld long double

struct line
{
    ll a,b;
};

deque<line>dq;

ld giaoX(line u,line v)
{
    return (ld)(v.b-u.b)/(u.a-v.a);
}

ll vall(line u,ll x)
{
    return u.a*x+u.b;
}

void update(line u)
{
    while(dq.size()>=2&&giaoX(dq[dq.size()-1],u)<=giaoX(dq[dq.size()-2],u))dq.pop_back();
    dq.push_back(u);
}

ll tktp(ll x)
{
    while(dq.size()>=2&&giaoX(dq[0],dq[1])<x)dq.pop_front();
    return vall(dq[0],x);
}

ll h[N],dp[N],C;
int n;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cin>>n>>C;
    for(int i=1;i<=n;i++)cin>>h[i];
    dq.push_back({-2*h[1],dp[1]+h[1]*h[1]});
    for(int i=2;i<=n;i++)
    {
        ll u=tktp(h[i]);
        dp[i]=u+h[i]*h[i]+C;
        update({-2*h[i],dp[i]+h[i]*h[i]});
    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 8464
import java.util.*;

class Main{

	public static void main(String[] args){
	
		Scanner sc = new Scanner(System.in);
		
		String C = sc.next();
		
		char D = C.charAt(0);
		
		int ans = D + 1;
		//char�^��int������ƃL���X�g���N����̂�int�Ōv�Z���čŌ�Ɍ^�ϊ�����΂悢
		
		System.out.println("" + (char)ans);
	}
}

Measured memory_bytes: 23892
#include<iostream>
using namespace std;
int s[105][105];
int c[10005];
int main(){
    int h,w;
    int i,j,k;
    int n;
    int a,b;
    cin>>h>>w;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>c[i];
    }
    b=0,k=0;
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(i%2==1)a=w-j-1;
            else a=j;
            if(k==c[b])b+=1,k=0;
            s[i][a]=b+1;
            k++;
        }
    }
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            cout<<s[i][j];
            if(j==w-1)cout<<endl;
            else cout<<" ";
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;

int a[10000005],k[10000][10000];

int main(){
	int h,w,n;
	cin >> h >> w >> n;
	for(int i = 1;i <= n;i++) cin >> a[i];
	int head = 1,all = 0;
	for(int i = 1;i <= h;i++){
		for(int j = 1;j <= w;j++){
			all++;
			if(all <= a[head] && i % 2 == 1) k[i][j] = head;
			else if(all <= a[head] && i % 2 == 0) k[i][w - j + 1] = head;
			else if(i % 2 == 1){
				all = 0;
				all++;
				head++;
				k[i][j] = head;
			}
			else{
				all = 0;
				all++;
				head++;
				k[i][w - j + 1] = head;
			}
		}
	}
	for(int i = 1;i <= h;i++){
		for(int j = 1;j <= w;j++){
			cout << k[i][j] << ' ';
		}
		cout << endl;
	}
}

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  int ans = 0;
  int val = 0;
  for(int i = 0; i < n-1; i++){
    if(h[i] >= h[i+1]) val++;
    else val = 0;
    ans = max(ans, val);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 640