akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int h,w;
  cin >> h >> w;
  char s[h][w];
  rep(i,h){
    rep(j,w){
      cin >> s[i][j];
    }
  }
  vector<bool> h_is(h),w_is(w);
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#'){
        h_is.at(i)=true;
        w_is.at(j)=true;
      }
    }
  }
  rep(i,h){
    if(h_is.at(i)){
      rep(j,w){
        if(w_is.at(j)){
          cout << s[i][j];
        }
      }
      cout <<endl;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

void solve()
{
	bool flag[31];
	for(int i = 0; i < 31; ++i)
	{
		flag[i] = false;
	}
	for(int i = 0; i < 28; ++i)
	{
		int a;
		cin >> a;
		flag[a] = true;
	}
	for(int i = 1; i < 31; ++i)
	{
		if(!flag[i])
		{
			cout << i << endl;
		}
	}
}

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

Measured memory_bytes: 1160
package main

import (
	"fmt"
)

func ReverseBytes(b []byte) {
	for i, j := 0, len(b)-1; i < j; i, j = i+1, j-1 {
		b[i], b[j] = b[j], b[i]
	}
}

func main() {
	var n int
	fmt.Scan(&n)

	rep := make([]byte, 0)

	if n == 0 {
		rep = append(rep, '0')
	}
	for n != 0 {
		if n%2 == 0 {
			rep = append(rep, '0')
		} else {
			rep = append(rep, '1')
			n--
		}
		n /= -2
	}

	ReverseBytes(rep)
	fmt.Println(string(rep))
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
bool tr[4][20];
int main() {
    init();
    map<char, ll> s;
    s['S'] = 0, s['H'] = 1, s['C'] = 2, s['D'] = 3;
    vc<char> ss = {'S', 'H', 'C', 'D'};

    ll N;
    cin >> N;
    rep(i,N){
        char c;
        ll a;
        cin >> c >> a;
        tr[s[c]][a] = true;
    }

    rep(i,4)repe(j,1,13+1){
        if(!tr[i][j]){
            cout << ss[i] << " " << j << endl;
        }
    }
    
}


Measured memory_bytes: 3156
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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

const ll mod = 1000000007;
const int INF = 1<<29;

int main(){
  int N; cin >> N;
  if (N % 2 == 0) cout << N / 2 << endl;
  else cout << N / 2 + 1 << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
char s[19];int l;
long long int sum;
void dfs(int i,long long int now){
	if(i==l){
		sum+=now;
		return;
	}
	long long int cur = 0;
	for(int j=i; j<l; j++){
		cur = cur * 10+s[j];
		dfs(j+1,now+cur);
	}
}
int main(){
	scanf("%s",s);
	l=strlen(s);
	for(int i=0; i<l; i++)
		s[i]-='0';
	dfs(0,0);
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstring>

std::vector<std::pair<long long , long long >> items;

long long dp[101][100000];

long long solv(std::size_t idx, long long curr_cap) {
    if(idx == items.size() || curr_cap == 0) return 0;

    if(dp[idx][curr_cap] != -1) return dp[idx][curr_cap];

    if(items[idx].first > curr_cap) {
        return solv(idx + 1, curr_cap);
    }

    long long  tmp1 = solv(idx + 1, curr_cap - items[idx].first) + items[idx].second;
    long long  tmp2 = solv(idx + 1, curr_cap);


    return dp[idx][curr_cap] = std::max(tmp1, tmp2);
}

int main() {
    long long  N, W;
    std::cin >> N >> W;
    items.resize(N);
    for(std::pair<long long , long long> &p : items) {
        std::cin >> p.first >> p.second;
    }
    memset(dp, -1, sizeof dp);
    std::cout << solv(0, W);



    return 0;
}

Measured memory_bytes: 79104
#include <stdio.h>
#define N 10000
#define Q 500 
main(){
  int s,t,i,j,count=0;
  int a[N],b[Q];
  scanf("%d", &s);
  for(i=0;i<s;i++)
  {
    scanf("%d", &a[i]);
  }
  scanf("%d", &t);
  for(i=0;i<t;i++)
  {
    scanf("%d", &b[i]);
  }
for(j=0;j<t;j++)
  {
  for(i=0;i<s;i++)
     {
      if(a[i] == b[j])
	{
        count+=1;
        break;
	}
     }
   }
  printf("%d\n", count);
  return 0;
}     

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

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

int n, m;
vector<vector<int>> g;

int dfs(int n, vector<bool> v){
	int ret = 0;
	v[n] = true;

	bool end = true;
	rep(i, v.size()){
		end &= v[i];
	}
	if(end) return 1;

	rep(i, g[n].size()){
		if(!v[g[n][i]]) ret += dfs(g[n][i], v);
	}

	return ret;
}

int main() {

	cin >> n >> m;
	g.resize(n);

	rep(i, m){
		int p, q;
		cin >> p >> q;
		p--;q--;
		g[p].push_back(q);
		g[q].push_back(p);
	}

	vector<bool> v(n, false);

	cout << dfs(0, v) << endl;

	return 0;
}


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

int main()
{
    int n;
    int w, h;
    int x, y;
    int a;
    int sx, sy;
    int gx, gy;

    
    cin >> w >> h >> n;

    sx = sy = 0;
    gx = w, gy = h;
    
    for (int i = 0; i < n; i++) {
        cin >> x >> y >> a;

        switch(a) {
        case 1:
            sx = max(sx, min(gx, x));
            break;
        case 2:
            gx = min(gx, max(x, sx));
            break;
        case 3:
            sy = max(sy, min(gy, y));
            break;
        case 4:
            gy = min(gy, max(sy, y));
            break;
        }
    }

    cout << (gy - sy) * (gx - sx) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
int main() {
  cin.tie(0);
  cout << fixed << setprecision(10);
  int n; cin >> n;
  vector<P> p(n);
  for(int i=0;i<n;++i) {
    int tmp; cin >> tmp;
    p[i] = {tmp, i};
  }
  sort(p.begin(), p.end());
  reverse(p.begin(), p.end());
  multiset<int> ms;
  ms.insert(-1);
  ms.insert(-1);
  ms.insert(n);
  ms.insert(n);
  ll su = 0;
  for(int i=0;i<n;++i) {
    ll val = p[i].first;
    int pos = p[i].second;
    auto it = ms.lower_bound(pos);
    int l1, l2, r1, r2;
    r1 = *it++;
    r2 = *it--;
    it--;
    l1 = *it--;
    l2 = *it;
    su += val * (l1 - l2) * (r1 - pos);
    su += val * (r2 - r1) * (pos - l1);
    ms.insert(pos);
  }
  cout << su << endl;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>

using namespace std;
#define EPS 1e-9
#define MAX 505
#define pb push_back
#define mp make_pair
#define ins insert
#define fi first
#define se second
#define pi acos(-1.0)
#define mod 100000007
#define inf 2147483647
#define ll long long int
#define sss stringstream
#define oss ostringstream
#define iss istringstream
#define llu long long unsigned

#define _sq(a) (a)*(a)
#define sz(a) ((int)a.size())
#define gcd(a,b)    __gcd(a,b)
#define lcm(a,b) ((a)*((b)/gcd(a,b)))
#define _max3(a,b,c) max(a, max(b,c))
#define _min3(a,b,c) min(a, min(b,c))
#define FOR(i, n) for(i=0; i<(int)n; i++)
#define FOR1(i, n) for(i=1; i<=(int)n; i++)
#define mem(a) memset(a, 0, sizeof(a))
#define _set(a) memset(a,-1,sizeof(a))
#define FORI(i, a, b) for(i=a; i>=(int)b; i--)
#define FORab(i, a, b) for(i=a; i<=(int)b; i++)
#define popcount(n) __builtin_popcount(n)
#define popcountl(n) __builtin_popcountll(n)
#define sort_rev(a) sort(a.rbegin(), a.rend())
#define sort_all(a) sort(a.begin(), a.end())
#define dis_twopoints(x1,y1,x2,y2) sqrt(_sq(x1-x2) + _sq(y1-y2))
#define foreach(i,n) for(__typeof((n).begin())i =(n).begin();i!=(n).end();i++)

//If Long Long (mask & (1LL << k))
#define check(mask, k) (mask & (1 << k))
#define set1(mask, k) (mask | (1 << k))
#define set0(mask ,k) (mask & (~(1<<k)))

#define SD(a) scanf("%d",&a)
#define SLF(a) scanf("%lf",&a)
#define SC(a) scanf("%c",&a)
#define SS(a) scanf("%s",a)
#define SLLD(a) scanf("%lld", &a)
#define Si64(a) scanf("%I64d", &a)

#define READ(f) freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)
int f[60];
int main()
{
    int a,b,s,t;
    while(cin>>a>>b)
    {
        t=1;
        int n=10;
        s=a+b;
        while(s/n)
        {
            t++;
            n=n*10;

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

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

int main(){
    int N,K; cin>>N>>K;
    int p[N]; CINA(p,N);
    sort(p,p+N);
    int ans = 0;
    REP(i,K){
        ans += p[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3628
#include<cstdio>
using namespace std;
int main()
{
	int N, c;
	scanf("%d", &N);

		c=N%10;

	if(c==3) printf("bon");
	if(c==2||c==4||c==5||c==7||c==9) printf("hon");
	if(c==0||c==1||c==6||c==8) printf("pon");
	return 0;
 } 

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

using namespace std;
using ll = long long int;
#define long ll

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

    vector<ll> v(3);
    for(auto &e: v) cin >> e;

    ll r = 0;
    for(; ; r++) {
        sort(v.begin(), v.end());
        if(v[0]+1 >= v[2]) break;
        v[0] += 2;
    }
    
    if(v[0] != v[2]) r++;
    if(v[0] != v[1]) r++;

    cout << r << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define ll long long int 
#define pii pair<int, int>
#define fi first
#define se second
#define maxn (1 << 19)
#define lowbit(x) (x & -x)
using namespace std;

int n, m, w[maxn], v[maxn], d[maxn];

int A[25], B[25];
pii SA[1 << 10], SB[1 << 10]; 

int c[maxn], st[maxn], cs = 0;
void add(int x, int y){
	while (x < maxn){
		if (!c[x]) st[++cs] = x;
		c[x] = max(c[x], y);
		x += lowbit(x);
	}
}
int get(int x){
	int ans = 0;
	while (x){
		ans = max(ans, c[x]);
		x -= lowbit(x);
	}
	return ans;
}
void recover(){
	while (cs) c[st[cs--]] = 0;
}

int play(int x, int y){	
	int a = (d[x] + 1) >> 1, _a = a, b = d[x] - a, _b = b;
	while (a){
		A[--a] = x;
		x >>= 1;
	}
	while (b){
		B[--b] = x;
		x >>= 1;
	}
	/*
	a = _a, b = _b;
	srep(i, 0, (1 << a)){
		int sw = 0, sv = 0;
		srep(j, 0, a){
			if (i & (1 << j)) sw += w[A[j]], sv += v[A[j]];
		}
		SA[i] = pii(sw, sv);
	}
	srep(i, 0, (1 << b)){
		int sw = 0, sv = 0;
		srep(j, 0, b){
			if (i & (1 << j)) sw += w[B[j]], sv += v[B[j]];
		}
		SB[i] = pii(sw, sv);
	}
	*/
	a = _a, b = _b;
	int ca = 0, cb = 0, mx = 0;
	SA[ca++] = pii(0, 0), SB[cb++] = pii(0, 0);
	srep(i, 0, a){
		int _ca = ca;
		srep(j, 0, _ca){
			SA[ca++] = pii(SA[j].fi + w[A[i]], SA[j].se + v[A[i]]);
			if (SA[ca - 1].fi) add(SA[ca - 1].fi, SA[ca - 1].se);
		}
	}
	srep(i, 0, b){
		int _cb = cb;
		srep(j, 0, _cb) {
			SB[cb++] = pii(SB[j].fi + w[B[i]], SB[j].se + v[B[i]]);
			if (y >= SB[cb - 1].fi) mx = max(mx, get(y - SB[cb - 1].fi) + SB[cb - 1].se);
		}
	}
	mx = max(mx, get(y));
	recover();
	return mx;
	/*
	sort(SA, SA + (1 << a)); 
	sort(SB, SB + (1 << b));
	mxB[0] = SB[0].se;
	srep(i, 1, (1 << b)) mxB[i] = max(mxB[i - 1], SB[i].se);
	int mx = 0, ptr = (1 << b) - 1;
	srep(i, 0, (1 << a)){
		int noww = SA[i].fi;
		while (ptr > -1 && noww + SB[ptr].fi > y) ptr--;
		if (ptr > -1) mx = max(mx, SA[i].se + mxB[ptr]);
		else return mx;
	}
	return mx;
	*/
}
int main(){ 
	int x, y;
	scanf("%d", &n);
	rep(i, 1, n) d[i] = d[i >> 1] + 1, scanf("%d%d", v + i, w + i);
	scanf("%d", &m);
	rep(i, 1, m) scanf("%d%d", &x, &y), printf("%d\n", play(x, y));
	return 0;
}



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

using namespace std;

int main() {
  string s;
  cin >> s;
  if (s == "Sunny") {
    cout << "Cloudy" << '\n';
  } if (s == "Cloudy") {
    cout << "Rainy" << '\n';
  } if (s == "Rainy") {
    cout << "Sunny" << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
import sys

raw_input()

key = ['.,!? ', 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqrs', 'tuv', 'wxyz']

for line in sys.stdin:
    state = -1
    line = line.strip()
    result = ''
    count = 0
    for c in line:
        c = int(c) - 1
        if c == -1 and state != -1:
            result += key[state][count % len(key[state])]
            state = -1
        elif state == c:
            count += 1
        else:
            state = c
            count = 0
    print result

Measured memory_bytes: 4256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
//Function
lli combi(lli n, lli r)
{
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	int a, b, x;
	cin >> a >> b >> x;
	bool ans = true;
	if(a > x) ans = false;
	if(a+b < x) ans = false;

	if(ans) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i,a,b); for(ll i=(a); i<=ll(b); i++) 
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
const ll MOD = 1e9+7;
int gcd(int a, int b){ //a>=0,b>=0,￢(a=b=0)
  while(min(a,b)>0){if(a<b)swap(a,b);a=a%b;}return max(a,b);
}
//int:~2e9   小数:double



int main(){
  int h,n;
  cin >>h>>n;
  int a=0;
  rep(i,n){
    int s;cin>>s;
    a+=s;
  }
  if(a>=h){
  cout << "Yes" << endl;
  }else{
  cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
a,b,x=gets.split.map(&:to_i)
half=a*a*b/2.0
if x>=half
  h=(a*a*b-x.to_f)/(a*a)*2
  p Math.atan2(h,a) * 180 / Math::PI
else
  h=x.to_f/(a*b)*2
  p 90 - Math.atan2(h,b) * 180 / Math::PI
end

Measured memory_bytes: 14604
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<array>

using namespace std;
 
int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int x = c-a,y = d-b;
    cout << c - y << " " << d + x  << " " << a - y << " " << b + x << endl;
}


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

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

  vector<char> C(N);
  int Ridx = -1;
  int Widx = -1;
  int Rcount = 0;
  int Wcount = 0;

  for (int n = 0; n < N; n++){
    char c;
    cin >> c;
    C.at(n) = c;
    if (c == 'W'){
      Wcount++;
      if (Widx == -1){
	Widx = n;
      }
    }
    if (c == 'R'){
      Ridx = n;
      Rcount++;
    }
  }

  //cout << "Widx=" << Widx << " Ridx=" << Ridx << "Wc=" << Wcount << " Rc=" << Rcount << endl;

  // Wが無い or Rが無いなら終了条件を満たしている
  if (Wcount == 0 || Rcount == 0){
    cout << "0" << endl;
    return 0;
  }

  int c = 0;
  while(Widx < Ridx){
    C.at(Widx) = 'R';
    C.at(Ridx) = 'W';
    c++;
    // 次の'W'を探す
    while(Widx < N){
      Widx++;
      if (C.at(Widx) == 'W'){
	break;
      }
    }
    // 次の'R'を探す
    while(Ridx > 0){
      Ridx--;
      if (C.at(Ridx) == 'R'){
	break;
      }
    }
  }
  cout << c << endl;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, X;
  cin >> K >> X;
  for (int i = 0; i < K; i++) {
    cout << X - K + 1 + i << endl;
  }
  for (int j = 2; j < K + 1; j++) {
    cout << X - 1 + j << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve
{
    public static int Main()
    {
        int n = int.Parse(Console.ReadLine());

        if(n==1)
        {
            Console.WriteLine(1);
            return 0;
        }

        int a = 2;
        int olda = a;

        while (true)
        {
            a *= 2;
            if (a > n)
            {
                Console.WriteLine(olda);
                return 0;
            }
            olda = a;
        }


        return 0;
    }
}

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

#define pii pair<int, int>
#define mp make_pair

const int maxN = 3e5 + 100;

int n, m;
int p[maxN + 1], c[maxN + 1];
bool flag[maxN + 1], vis[maxN + 1];

pii num[maxN + 1];

vector<pii> G[maxN + 1];

inline int read()
{
	int num = 0, f = 1;
	char ch = getchar();
	while( !isdigit( ch ) ) { if(ch == '-') f = -1; ch = getchar(); }
	while( isdigit( ch ) ) num = (num << 3) + (num << 1) + (ch ^ 48), ch = getchar();
	return num * f;
}

inline int dfs(int u)
{
	vis[u] = true;
	int t = c[u];
	for(int i = 0; i < G[u].size(); i++)
	{
		int v = G[u][i].first, id = G[u][i].second;
		if(vis[v]) continue;
		int tmp = dfs(v);
		if(tmp) flag[id] = true;
		t ^= tmp;
	}
	return t;
}

int main()
{
	n = read(), m = read();
	for(int i = 1; i <= n; i++) num[i].first = read(), num[i].second = read();
	sort(num + 1, num + n + 1);
	for(int i = 1; i <= n; i++) p[i] = num[i].first, c[i] = num[i].second ^ num[i - 1].second;
	c[n + 1] = num[n].second;
	for(int i = 1; i <= m; i++)
	{
		int L = read(), R = read();
		L = lower_bound(p + 1, p + n + 1, L) - p;
		R = upper_bound(p + 1, p + n + 1, R) - p;
		if(L >= R) continue;
		G[L].push_back( mp(R, i) );
		G[R].push_back( mp(L, i) );
	}

	for(int i = 1; i <= n + 1; i++)
		if(!vis[i])
			if(dfs(i)) { puts("-1"); return 0; }

	int ans = 0;
	for(int i = 1; i <= m; i++)
		if(flag[i]) ans ++;
	printf("%d\n", ans);
	for(int i = 1; i <= m; i++)
		if(flag[i]) printf("%d ", i);
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  int val = N;
  int ans = 0;
  while (val > 0) {
    ans += val % 10;
    val /= 10;
  }

  if (N % ans == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3600
// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

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

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


fn main() {
    input! {
        n: usize
    }
    let ans = (n / 500) * 1000 + (n % 500 / 5) * 5;
    println!("{}", ans);
}



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

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

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

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

const int MOD = 1e9+7;

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


void solve()
{
    int k;
    cin >> k;
    
    queue<int> q;
    for(int i=1;i<=9;i++) q.push(i);
    
    while(1)
    {
        auto x = q.front();
        q.pop();
        
        k--;
        
        if(k == 0)
        {
            cout << x;
            return;
        }
        
        int last = (x%10);
        if(last > 0) q.push((10*x) + last - 1);
        q.push((10*x) + last);
        if(last < 9) q.push((10*x) + last + 1);
            
    }
    
}

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

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;

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

vector<int> edge[1010];
int match[1010];
bool used[1010];

bool dfs(int v){
  used[v] = true;
  rep(i,edge[v].size()){
    int u = edge[v][i];
    int w = match[u];
    if( w<0 || !used[w]&&dfs(w) ){
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}
int solve(int sz){
  int ret = 0;
  memset(match,-1,sizeof(match));
  rep(i,sz)if( match[i]<0 ){
    memset(used,false,sizeof(used));
    if( dfs(i) )ret++;
  }
  return ret;
}


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

int main(){
  int n,m;
  int blue[500],red[500];

  while(cin>>n>>m, n|m){
    // init
    rep(i,1010)edge[i].clear();

    
    rep(i,n)cin>>blue[i];
    rep(i,m)cin>>red[i];
    rep(i,n){
      rep(j,m){
        if( gcd(blue[i], red[j])!=1 ){
          edge[i].push_back(j+n);
          edge[j+n].push_back(i);
        }
      }
    }
    cout << solve(n+m) << endl;
  }
  return 0;
}

Measured memory_bytes: 3064
import qualified Data.ByteString.Char8 as B
import           Data.Char
import           Data.List

main :: IO ()
main = do
    n <- readLn
    as <- sortBy (flip compare) <$> readInts
    print $ solve n as

readInts :: IO [Int]
readInts = unfoldr (B.readInt . B.dropWhile isSpace) <$> B.getLine

solve :: Int -> [Int] -> Int
solve 0 _        = 0
solve n (a:b:as) = b + solve (n - 1) as

Measured memory_bytes: 47484
#include<stdio.h>
int main(){
 int a,b,c,x;
 scanf("%d %d %d",&a,&b,&c);
 if(a>b){
  x=a;
  a=b;
  b=x;
  }if(b>c){
  x=b;
  b=c;
  c=x;
  }
 if(a>b){
  x=a;
  a=b;
  b=x;
}
 printf("%d %d %d\n",a,b,c);
return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define N 5001
#define INF 1e9
using namespace std;
int n,m;
int G[N][N];
int C[N],R[N];
vector<int> g[N];
typedef pair<int,int> P;

vector<int> bfs(int start){
  vector<int>res,D(N,R[start]+1);
  queue<int> Q;
  Q.push(start);
  D[start]=0;
  while(!Q.empty()){
    int pos = Q.front();Q.pop();
    for(int i=0;i<g[pos].size();i++) {
      int nx=g[pos][i];
      if(D[nx]>D[pos]+1){
	Q.push(nx),D[nx]=D[pos]+1;
	res.push_back(nx);
      }
    }
  }
  return res;
}

int dijkstra(){
  vector<int>D(N,INF); 
  priority_queue<P,vector<P>,greater<P> > Q;
  Q.push(P(0,0));
  D[0] = 0;
  while(!Q.empty()){
    P t=Q.top();Q.pop();
    int pos=t.second;
    int cost=t.first;
    if(pos==n-1) return cost;
    vector<int> nx=bfs(pos);

    for(int i=0;i<nx.size();i++){
      int npos=nx[i];
      int ncost=cost+C[pos];
      if(D[npos]>ncost){
	Q.push(P(ncost,npos));
	D[npos] = ncost;
      }
    }
  }
  return -1;
}


int main(){
  cin>>n>>m;
  for(int i=0;i<n;i++)cin>>C[i]>>R[i];
  
  for(int i=0,a,b;i<m;i++){
    cin>>a>>b;
    a--,b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  
  cout<<dijkstra()<<endl;
  return 0;
}

Measured memory_bytes: 3672
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define out(str) cout << str << endl

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

int a,b,c,d;

int main(){
    cin >> a >> b >> c >> d;
    out((abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)?"Yes":"No"));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
int main(void){
    int N;
    cin>>N;
    bool judge=false;
    
    rep(i,9){
        if(N%(9-i)==0&&N/(9-i)<=9){
            judge=true;
            break;
        }
    }
    if(judge==true){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
   
}




Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
#define p 1000000007
using namespace std;
ll f[200005],ni[200005];
ll quickpow(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)
		res=res*a%p;
		a=a*a%p;
		b>>=1;
	}return res;
}
ll zuhe(ll n,ll m)
{		ll sum;
	sum=f[n]*ni[n-m]%p*ni[m]%p;
	return sum;
}
int main()
{
	ll n,k;scanf("%lld%lld",&n,&k);
	ll a=min(k,n-1);ll sum=1;
	f[0]=1;ni[0]=quickpow(f[0],p-2)%p;
	for(int i=1;i<=n;++i) 
	{
	f[i]=f[i-1]*i%p;ni[i]=quickpow(f[i],p-2)%p;	
	}
	for(int i=1;i<=a;++i)
	{
	sum=(sum+zuhe(n,i)*zuhe(n-1,i)%p)%p;
		
	}
	printf("%lld",sum);
}

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

int main() {
  string s,ans;

  cin >> s;

  if(s == "Sunny") {ans = "Cloudy";}
  else if(s == "Cloudy") {ans = "Rainy";}
  else if(s == "Rainy") {ans = "Sunny";}

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
from collections import Counter
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
c = Counter(A)
k = set(A)
r = set(range(1, N + 1))

for key in r - k:
    c[key] = 0


for key in r:
    print(c[key])


Measured memory_bytes: 58460
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")

# X = int(sys.stdin.readline())
#
# beki = {1}
# for i in range(2, 1001):
#     e = 2
#     while i ** e <= X:
#         beki.add(i ** e)
#         e += 1
# print(max(beki))
#


ABC = list(map(int, sys.stdin.readline().split()))
K = int(sys.stdin.readline())

print(max(ABC) * 2 ** K + sum(ABC)- max(ABC))


Measured memory_bytes: 13660
#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>;

const ll MOD = 1e9+7;

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  
  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  vector<string> b(n);
  
  rep(i, n) cin >> a[i];
  rep(i, m) cin >> b[i];
  
  if(n < m) {
    cout << "No" << endl;
    return 0;
  }
  
  bool ok = false;
  rep(i, n) rep(j, n) {
    int cnt = 0;
    rep(k, m) {
      if(i+k > n-1) continue;
      rep(l, m) {
        if(j+l > n-1) continue;
        
        if(a[i+k][j+l] == b[k][l]) {
          ++cnt;
        }
      }
    }
    if(cnt == m*m) ok = true;
  }
  if(ok) {
    cout << "Yes" << endl;
    return 0;
  }
  else {
    cout << "No" << endl;
    return 0;
  }
}

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

int main()
{
    unsigned long a;
    double b;
    unsigned long long ans;
    

    cin >> a >> b;
    

    ans = (unsigned long long )a * b;
    cout << ans << endl;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define PB push_back
#define MP make_pair
#define Mod 998244353
#define MOD 1000000007
using namespace std;
using lint = long long;
using vi = vector<lint>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;

// cout << fixed << setprecision(12)

int main(){
  
  lint D; cin >> D;
  vi c(26); // contest 0-25
  for(lint i=0; i<26; i++) cin >> c[i];
  vvi s(D+1, vi(26)); // day 0-D
  for(lint d=1; d<=D; d++){
    for(lint j=0; j<26; j++){
      cin >> s[d][j];
    }
  }
  
  vi t(D+1); // day 0-D
  /*
  for(lint d=1; d<=D; d++){
    cin >> t[d];
    t[d]--;
  }
  */
  
  vi last(26,0);
  
  // lint ans = 0;
  
  // lint incr = 2;
  
  for(lint d=1; d<=D-1; d+=2){// 2days!!!!!
    vvi diff(26, vi(26));
    
    for(lint i=0; i<26; i++){ // if contest i (0-25)
      for(lint ii=0 ;ii<26; ii++){
        // ans += s[d][t[d]];
        lint plus = s[d][i];
    
        // last[t[d]] = d;
        lint oldlast = last[i];
        last[i] = d;
    
        lint minus = 0;
    
        for(lint j=0; j<26; j++){
          // ans -= c[j] * (d - last[j]);
          minus += c[j] * (d - last[j]);
        }
      
        // last[i] = oldlast;
        // diff[i] = plus - minus;
        
        ////////////////////
        
        // ans += s[d][t[d]];
        lint pluss = s[d+1][ii];
    
        // last[t[d]] = d;
        lint oldlastt = last[ii];
        last[ii] = d+1;
    
        lint minuss = 0;
    
        for(lint j=0; j<26; j++){
          // ans -= c[j] * (d - last[j]);
          minuss += c[j] * (d+1 - last[j]);
        }
      
        // last[i] = oldlast;
        // diff[i] = plus - minus;
        
        ////////////////////
        
        diff[i][ii] = plus + pluss - minus - minuss;
        last[i] = oldlast;
        last[ii] = oldlastt;
      }
    }
    
    vi soto (0);
    for(lint i=0; i<26; i++){
      for(lint ii=0; ii<26; ii++){
        soto.PB(diff[i][ii]);
      }
    }
    sort(ALL(soto));
    // reverse(ALL(soto));
    lint t = -1;
    lint tt = -1;
    for(lint i=0; i<26; i++){
      for(lint ii=0; ii<26; ii++){
        if(diff[i][ii] == soto[0]){
          t = i;
          tt = ii;
        }
      }
    }
    cout << t+1 << endl;
    cout << tt+1 << endl;
    last[t] = d;
    last[tt] = d+1;
    
  }
  
  // 364 days so far
  // last one day
  
  vi dif(26);
  for(lint i=0; i<26; i++){
    lint plu = s[D][i];
    // lint oldlas = last[i];
    last[i] = D;
    
    lint minu = 0;
    
    for(lint j=0; j<26; j++){
    minu += c[j] * (D - last[j]);
    }
    
    dif[i] = plu - minu;
  }
  
  vi sot(0);
    for(lint i=0; i<26; i++){
      sot.PB(dif[i]);
    }
    sort(ALL(sot));
    lint tl = -1;
    for(lint i=0; i<26; i++){
      if(dif[i] == sot[sot.size()-1]){
        tl = i;
      }
    }
  cout << tl+1 << endl;
}
 
  
  
  
  

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

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

const ll mod  = 1e9+7;
const db eps  = 1e-9 ;
const ll maxn = 1e5+1;
const ll inf  = LLONG_MAX;
const ll minf = LLONG_MIN;

#define mp make_pair
#define pb push_back
#define endl "\n"
#define deb(x) cerr << #x << " " << x << endl

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

    ll k,a,b;
    cin >> k >> a >> b;

    ll rem1,rem2;

    rem1 = a%k , rem2 = b%k;
    if(rem1==0 || rem2==0) 
    {
        cout << "OK" << endl; return 0;
    }

    else if( (a+k-rem1)/k < (b+k-rem2)/k) 
          {
        cout << "OK" << endl; return 0;
    }

    cout << "NG" << endl;

    return 0;
} 

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
long double pi = acos(-1.0);
int main()
{
      ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
long double a,b;cin>>a>>b;
    int h,m;cin>>h>>m;
    long double ans;
    h*=60;
    h+=m;
    long double hd = h/720.0*2*pi;
    long double md = m/60.0*2*pi;
    long double d = fabs(hd-md);
    if(d>pi)d = 2*pi-d;
    ans = sqrtl(a*a+b*b-2*a*b*cos(d));
    cout<<fixed<<setprecision(15)<<ans;
	return 0;}


Measured memory_bytes: 4180
S = input()
ans = [0]*(len(S) + 1)
temp = 0
for i, s in enumerate(S):
    if s == '<':
        ans[i+1] = ans[i] + 1
for i, s in reversed(list(enumerate(S))):
    if s == '>' :
        ans[i] = max(ans[i+1] + 1, ans[i])
print(sum(ans))

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

void solve(){
  ll a,b;
  cin>>a;
  b=360;
  while(b%a != 0)
    b+=360;

  cout<<b/a;
}
int main()
{
     
     int t=1; 
     // cin >> t;
     while (t--) solve();
 
     return 0;
}



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

int main(){
  int m,n;
  for(;;){
    cin>>m>>n;
    if(m==0&&n==0) break;
    vector<int> year;
    for(int i=0;i<n*15;i++)
      year.push_back(0);
    int cnt=0;
    for(int i=m;;i++){
      if(year[i]==0){
	if(n==cnt){
	  cout<<i<<endl; break;
	}
	for(int j=i;j<n*15;j+=i)
	  year[j]=1;
	cnt++;
      }   
    }
  }
}


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

int n, m;
int p[100000];
int x[100000], y[100000];
vector<int> et[100000];
bool used[100000];

signed main() {
	int i, j;
	
	cin >> n >> m;
	rep(i, n) { cin >> p[i]; p[i]--; }
	rep(i, m) { cin >> x[i] >> y[i]; x[i]--; y[i]--; }
	rep(i, m) { et[x[i]].push_back(y[i]); et[y[i]].push_back(x[i]); }
	
	int ans = 0;
	queue<int> que;
	rep(i, n) {
		if (used[i]) continue;
		
		vector<int> pos;
		used[i] = true; pos.push_back(i);
		que.push(i);
		while(!que.empty()) {
			int v = que.front(); que.pop();
			for (j = 0; j < et[v].size(); j++) {
				int nv = et[v][j];
				if (!used[nv]) {
					used[nv] = true; pos.push_back(nv);
					que.push(nv);
				}
			}
		}
		
		//posとp[pos]でマッチング
		vector<int> val;
		rep(j, pos.size()) val.push_back(p[pos[j]]);
		sort(val.begin(), val.end());
		
		rep(j, pos.size()) {
			int id = lower_bound(val.begin(), val.end(), pos[j]) - val.begin();
			if (id == val.size() || val[id] != pos[j]) continue;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8184
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>

using namespace std;

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

	int n; cin >> n;
	int x[n],y[n],t[n];
	
	int dis;
	for(int i=0;i<n;i++){
		cin >> t[i] >> x[i] >> y[i];
		if((x[i] + y[i] - t[i]) % 2 != 0){
			cout << "No\n";
			return 0;
		}
		if(i==0) dis = x[i]+y[i];
		else dis = abs(x[i]-x[i-1]) + abs(y[i]-y[i-1]);
	
		if(dis > t[i]-t[i-1]){
			cout << "No\n";
			return 0;
		}
	}
	cout << "Yes\n";

	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int maxA = Integer.valueOf(sc.nextLine());
        int maxB = Integer.valueOf(sc.nextLine());
        int maxC = Integer.valueOf(sc.nextLine());
        int x = Integer.valueOf(sc.nextLine());
        int count = 0;
        for(int numA = 0; numA <= maxA; numA++){
            for(int numB = 0; numB <= maxB; numB++){
                int numC = (x - 500*numA - 100*numB) / 50;
                if(maxC >= numC && numC >= 0){
                    count++;
                }
            }
        }
        System.out.println(count);
        sc.close();
    }
}

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


int main(){
  
  int N,K,X;
  
  X = 1;
  
  cin >> N;
  cin >> K;
  
  for (int i = 0; i < N; i++){
    
    if(X >= K){
      X += K;
    }
    
    else{
      X += X;
    }
  }
  
  cout << X << endl;
  
}

Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
l = list(range(1, N+1))

import itertools
L = list(itertools.permutations(l))

jisyo = []
for i in range(len(L)):
  n = 0
  for j in range(N):
    n = n * 10 + L[i][j]
  jisyo.append(n)

p = 0
q = 0
for x in range(N):
  p = p * 10 + P[x]
  q = q * 10 + Q[x]

print(abs(jisyo.index(p) - jisyo.index(q)))

Measured memory_bytes: 9548
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll rd()
{
	ll rx=0,fx=1;char c=getchar();
	while(c<48||c>57)
	{
		if(c=='-') fx=-1;
		c=getchar();
	}
	while(c>=48&&c<=57)
	{
		rx=rx*10+c-48;
		c=getchar();
	}
	return rx*fx;
}
const ll N=2e5+50,E=N<<1;
ll n,m,cnt=1,tag,ans=0,tot,num;
ll he[N],col[N],vis[N],h[3];
struct Edge
{
	ll v,nxt;
}e[E];
void eadd(ll u,ll v)
{
	cnt++;e[cnt].v=v;e[cnt].nxt=he[u];he[u]=cnt;
	cnt++;e[cnt].v=u;e[cnt].nxt=he[v];he[v]=cnt;
}
void dfs(ll x)
{
	ll i,v,w;
	vis[x]=1;
	tot++;
	h[col[x]]++;
	for(i=he[x];i;i=e[i].nxt)
	{
		v=e[i].v;
		num++;
		if(i&1ll) w=col[x]-1;
		else w=col[x]+1;
		if(w<0) w+=3;
		if(w>=3) w-=3;
		if(vis[v])
		{
			if(col[v]!=w) tag=0;
		}
		else
		{
			col[v]=w;
			dfs(v);
		}
	}
}
int main()
{
	ll i,u,v;
	n=rd();m=rd();
	for(i=1;i<=m;i++)
	{
		u=rd();v=rd();
		eadd(u,v);
	}
	for(i=1;i<=n;i++)
	{
		if(vis[i]) continue;
		tag=1;tot=0;num=0;
		memset(h,0,sizeof(h));
		dfs(i);
		//printf("U%lld %lld\n",i,tag);
		if(tag==1)
		{
			if(h[0]&&h[1]&&h[2]) ans+=h[0]*h[1]+h[1]*h[2]+h[2]*h[0];
			else ans+=(num>>1);
		}
		else ans+=tot*tot;
	}
	printf("%lld",ans);
	return 0;
}

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

int dp[55], N, L[55], minx = (1 << 30);

int solve(int pos) {
	for (int i = 0; i < 55; i++) dp[i] = (1 << 30);
	dp[0] = 0;
	for (int i = 0; i < N; i++) {
		int sum = 0;
		for (int j = i + 1; j <= N; j++) {
			sum += L[j];
			if (sum >= pos && !(i == 0 && j == N)) dp[j] = min(dp[j], max(dp[i], sum));
		}
	}
	return dp[N];
}

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> L[i];
	vector<int>vec;
	for (int i = 1; i <= N; i++) {
		int sum = 0;
		for (int j = i; j <= N; j++) {
			sum += L[j]; if (!(i == 1 && j == N)) vec.push_back(sum);
		}
	}
	for (int i = 0; i < vec.size(); i++) {
		minx = min(minx, solve(vec[i]) - vec[i]);
	}
	cout << minx << endl;
	return 0;
}


Measured memory_bytes: 3164
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def print_list(l): print(*l, sep='\n')
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def No(): print('No')

def sieves_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime

N = iin()
A = iln()
cnt = collections.Counter(A)

def c2(n): return n*(n-1)//2

total = 0
for value in cnt.values():
    if value >= 2:
        total += c2(value)

for i in range(N):
    if A[i] in cnt.keys() and cnt[A[i]] >= 2:
        print(total-c2(cnt[A[i]])+c2(cnt[A[i]]-1))
    else:
        print(total)




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

public final class Main
{
    public static void main (String[] args) throws java.lang.Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        for(int i =0; i<n-1; i++){
          int v = in.nextInt();
          arr[v-1]++;
        }
       
       for(int i =0; i< n; i++)
         System.out.println(arr[i]);


    }
}

Measured memory_bytes: 69580
N, M, K = map(int, input().split(' '))
A_ls = [0] + list(map(int, input().split(' ')))
for i in range(N):
    A_ls[i + 1] += A_ls[i]
B_ls = [0] + list(map(int, input().split(' ')))
for i in range(M):
    B_ls[i + 1] += B_ls[i]
b_cnt, rst = M, 0
for a_cnt in range(N + 1):
    if A_ls[a_cnt] > K:
        break
    while A_ls[a_cnt] + B_ls[b_cnt] > K:
        b_cnt -= 1
    rst = max(rst, a_cnt + b_cnt)
print(rst)

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

//#define int long long
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
#define X first
#define Y second
#define endl '\n'
#define all(o) o.begin(), o.end()
#define IOS ios::sync_with_stdio(0), cin.tie(0)
const int maxn = 5000 + 10;
int l[maxn], r[maxn];
int32_t main(){
    string s;
    cin >> s;
    string t = "CODEFESTIVAL2016";
    int ans = 0;
    for(int i=0; i<t.size(); i++)
        ans += (t[i] != s[i]);
    cout << ans << endl;
}


Measured memory_bytes: 256
/*********************************************************************************\
*  _________  _      _  ________  _       _       __       ________               *
* |___   ___|| |    | ||  ______|| |     | |     /  \     |  ____  |              *
*     | |    | |    | || |______ | |_____| |    / /\ \    | |____| |              *
*     | |    | |    | ||______  ||  _____  |   / /__\ \   |  __  __|              *
*     | |    | |____| | ______| || |     | |  / ______ \  | |  \ \                *
*     |_|    |________||________||_|     |_| /_/      \_\ |_|   \_\               *
*                                                                                 *
*   Department of Computer Science & Engineering                                  *
*   Student ID : 18CSE035                                                         *
*   Bangabnadhu Sheikh Mujibur Rahman Science & Technology University,Gopalgonj.  *
*                                                                                 *
\*********************************************************************************/

//Now Write to Code ___________________________


#include <bits/stdc++.h>
using namespace std ;
 
 
typedef long long                ll;
typedef long double              ld;
typedef unsigned long long       ull;
typedef pair <int,int>           pii;
typedef pair <ll,ll>             pll;
typedef vector <int>             vi;
typedef vector <ll>              vll;
typedef vector <vector <int> >   vvi;
 
inline int    Int(){int x; cin >> x; return x;}
inline ll     Long(){ll x; cin >> x; return x;}
inline float  Float(){float x; cin >> x; return x;}
inline double Double(){double x; cin >> x; return x;}
inline void   Yes(){cout << "Yes" << endl;}
inline void   No(){cout << "No" << endl;}
inline void   YES(){cout << "YES" << endl;}
inline void   NO(){cout << "NO" << endl;}
 
const int N             =(int)2e5 + 5;
const int maxN          =(int)1e6 + 6;
const ll  Mod           =(ll)1e9 + 7;
const int inf           =(int)2e9;
const ll  Inf           =(ll)1e18;
 
#define     T           int t,q; cin >> t; for(q=1;q<=t;q++)
#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i=(b); i!=(e+1)-2*(b > e); i =i+1-2*(b > e))
#define     Int         Int()
#define     Long        Long()
#define     Float       Float()
#define     Double      Double()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)
#define     biday       return 0 
 
 
int main(){
	int N;
	double PI = 3.141592653589793;
	cin >> N;

	cout << showpoint;
	cout << fixed;
	cout << setprecision(20);
	cout << 2*PI*(double)N << endl;


    biday;
}
 
//...............BYE BYE................

Measured memory_bytes: 3788