akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
#include<algorithm>
#define ll long long
#define maxn 55

using namespace std;

ll a[maxn];
ll f[maxn][maxn];
ll ans1,ans2,n,m,k,js,jsq;

ll cmp(ll a,ll b)
{
	return a>b;
}

int main()
{
	f[0][0]=1;
	for(int i=1;i<=50;i++)
	{
		f[i][0]=1;
		f[i][i]=1;
		for(int j=1;j<=i;j++)
		{
			f[i][j]=f[i-1][j]+f[i-1][j-1];
		}
	}
	scanf("%lld%lld%lld",&n,&m,&k);
	for(ll i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+n+1,cmp);
	for(ll i=1;i<=m;i++)
	{
		ans1+=a[i];
	}
	for(ll i=1;i<=n;i++)
	{
		if(a[m]==a[i])
		{
			js++;
		}
	}
	for(ll i=1;i<=m;i++)
	{
		if(a[m]==a[i])
		{
			jsq++;
		}
	}
	if(a[m]==a[1])
	{
		for(ll i=m;i<=min(k,js);i++)
		{
			ans2+=f[js][i];
		}
	}
	if(a[m]!=a[1])
	{
		ans2=f[js][jsq];
	}
	printf("%lf\n%lld",(double)ans1/m,ans2);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    char s;
    cin >> s;

   if (isupper(s))
   {
       cout << "A" << endl;
   }
   else
   {
       cout << "a" << endl;
   }

   return 0;  
}


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

using namespace std;

const int NM_MAX = 502;

int n, m;

bool ma[NM_MAX][NM_MAX];

bool a[NM_MAX][NM_MAX], b[NM_MAX][NM_MAX];

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        string s;
        cin >> s;
        s = " " + s;
        for(int j = 1; j <= m; j++)
            ma[i][j] = a[i][j] = b[i][j] = (s[j] == '#');
    }
    for(int j = 1; j <= m; j++)
        a[1][j] = true;
    for(int i = 2; i < n; i++)
        for(int j = 1; j <= m; j++)
            if(j & 1)
                a[i][j] = true;
            else
                b[i][j] = true;
    for(int j = 1; j <= m; j++)
        b[n][j] = true;
    for(int i = 1; i <= n; i++, cout << "\n")
        for(int j = 1; j <= m; j++)
            if(a[i][j] == true)
                cout << "#";
            else
                cout << ".";
    cout << "\n";
    for(int i = 1; i <= n; i++, cout << "\n")
        for(int j = 1; j <= m; j++)
            if(b[i][j] == true)
                cout << "#";
            else
                cout << ".";
    cout << "\n";
    return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
const ll INF=1e18;
const int MOD=1e9+7;
const double pi=acos(-1);

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <cmath>
#include <ext/pb_ds/assoc_container.hpp>
// #include <boost/multiprecision/cpp_int.hpp> 
// using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define M_PI           	3.14159265358979323846
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    long double a,b;
    cin>>a>>b;

    long double h,m;
    cin>>h>>m;

    long double angle = (30 * h) + (30 * m / 60) - (6 * m);
    if(angle>180) angle -= 360;

    long double radian = (angle/180)*M_PI;
    long double ans = sqrtl((a*a + b*b) - 2*a*b*cosl(radian));
    
    cout<<ps(ans,20);
   	
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

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

int main() {
    
    int A,B,C,D,E;
    cin >> A >> B >> C >> D >> E;
    
    if(A == 0)cout << 1 << endl;
    if(B == 0)cout << 2 << endl;
    if(C == 0)cout << 3 << endl;
    if(D == 0)cout << 4 << endl;
    if(E == 0)cout << 5 << endl;
}


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

int N,M;
long long res=0;

int main(){
  cin >> N >> M;
  vector<pair<int, int> > store(N);
  for(int i=0;i<N;i++) cin >> store[i].first >> store[i].second;

  sort(store.begin(),store.end());

  for(int i=0;i<N;i++){
    if(M<=0) break;
    int b=min(M,store[i].second);
    res+=(long long)b*store[i].first;
    M-=b;
  }
  cout << res << endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

using ull = unsigned long long;

int main(int argc, char** argv)
{
    int N;
    std::vector<ull> As;
    ull mul = 1;

    const ull maxV = ull(1000000000000000000);
    const double maxVlog = std::log10(maxV);

    cin >> N;
    for (int i = 0; i < N; ++i)
    {
        ull v;
        cin >> v;
        As.push_back(v);
        if (v == 0)
        {
            cout << "0" << endl;
            return 0;
        }
    }

    for (auto v : As)
    {
        const double mulLog = std::log10(mul);
        const double vLog = std::log10(v);
        if (mulLog + vLog > maxVlog)
        {
            cout << "-1" << endl;
            return 0;
        }

        ull mulRet = mul * v;
        if (mulRet > maxV)
        {
            cout << "-1" << endl;
            return 0;
        }
        mul = mulRet;
    }
    cout << mul << endl;

    return 0;
}

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

int main() {
	int a,b,k;
	cin >> a >> b >> k;
	
	for(int i = 0;i < k;i++) {
		if(i%2 == 0) {
			if(a%2 == 1) {
				a--;
			}
			b+=a/2;
			a/=2;
		} else {
			if(b%2 == 1) {
				b--;
			}
			a+=b/2;
			b/=2;
		}
	}
	cout << a << " " << b << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()

void Calc();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr); cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/

template<class T, class B, class...V>struct Vec {
  typedef Vec<T, V...>A; typedef vector<typename A::t>t; t nvec(B a, V...b) { return t(a, A().nvec(b...)); }
};
template<class T, class B>struct Vec<T, B> { typedef vector<T>t; t nvec(B a) { return t(a); } };
template<class T>tuple<T>Init(T t) { return tuple<T>(t); }
template<class T, class C>struct Vec<T, tuple<C>> { using t = T; T nvec(tuple<C> a) { return get<0>(a); } };
template<class T = int, class...B> typename Vec<T, B...>::t nvec(B...b) { return Vec<T, B...>().nvec(b...); }


ll factorial(int n) {
  ll ret = 1, k = 1;
  while (k < n) ret *= ++k;
  return ret;
}
void Calc() {

  int n, a, b;
  in, n, a, b;
  auto v = in.Array<ll>(n);
  auto dp = nvec<pair<ll, ll>>(n + 1, n + 1, Init<pair<ll, ll>>({ -1,0 }));

  dp[0][0] = { 0, 1 };
  rep(i, n)rrep(j, n) if (dp[i][j].first != -1) {
    if (dp[i + 1][j].first < dp[i][j].first) {
      dp[i + 1][j] = dp[i][j];
    }

    if (dp[i + 1][j + 1].first < (dp[i][j].first + v[i])) {
      dp[i + 1][j + 1] = dp[i][j];
      dp[i + 1][j + 1].first += v[i];
    }
    else if (dp[i + 1][j + 1].first == dp[i][j].first + v[i]) {
      dp[i + 1][j + 1].second += dp[i][j].second;
    }
  }
  pair<ll, ll> ans = { 0,0 };
  ll m = 0;
  int index = 10;
  rep(i, a, b + 1) {
    if (ans.first * i < dp[n][i].first * index) {
      ans = dp[n][i];
      m = dp[n][i].second;
      index = i;
    }
    else if (ans.first*i == dp[n][i].first*index) {
      m += dp[n][i].second;
    }
  }

  cout << (ans.first / (double)index) << endl;
  cout << (m) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <string>
using namespace std;


int gcd(int a, int b) {
	int temp;
	while (b > 0) {
		temp = b;
		b = a % b;
		a = temp;
	}
	return a;
}

int main()
{
	int n, start;
	cin >> n >> start;
	vector<long long int> x(n);

	for (int i = 0; i < n; i++) {
		cin >> x[i];
	}
	x.push_back(start);
	sort(x.begin(), x.end());
	vector<long long int> dist;
	for (int i = 0; i < n ; i++) {
		dist.push_back(x[i + 1] - x[i]);
	}
	int result = dist[0];
	for (int i = 1; i < n; i++) {
		result = gcd(result, dist[i]);
	}
	cout << result << endl;
	return 0;
}

Measured memory_bytes: 2800
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()


a, b, c = na()

if (a * 100 + b * 10 + c) % 4 == 0:
    print("YES")
else:
    print("NO")

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

int n;
int array[100];
int main(){
    int i;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> array[i];
    }
    cout << array[0];
    for(int i=1;i<n;i++){
        cout << ' ' << array[i];
    }
    cout << endl;
    for(int j=1;j<n;j++){
        int key = array[j];
        i = j-1;
        while(i>=0 && array[i] > key){
            array[i+1] = array[i];
            i--;
        }
        array[i+1] = key;
        cout << array[0];
        for(int k=1;k<n;k++){
            cout << ' ' << array[k];
        }
        cout << endl;
    }
}

Measured memory_bytes: 1160
/*Saurav Paul*/
#include<bits/stdc++.h>
using namespace std;

#define ll 					  long long int
#define boost		          ios_base::sync_with_stdio(0);
#pragma GCC optimize("O3")
#define loop(i,a,b)           for(ll i=a;i<=b;++i)
#define eb                    emplace_back
#define itoc(c)               ((char)(((int)'0')+c))
#define ctoi(c)               ((int)(((int)c)-'0'))
#define all(p)                p.begin(),p.end()
#define bug()				  debug() <<

///////////////////////

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef PAUL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define dbg(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#ifdef ONLINE_JUDGE
#define cerr if (false) cerr
#endif
int main() ;
void file(){
	#ifdef PAUL
		freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif
}
void time(){
	#ifdef PAUL
		cerr << "\nTime elapsed: " << (double)(1.0 * (double)clock() / CLOCKS_PER_SEC) << " s.\n";
	#endif
}
///////////////////////
const int INF = 1e9 + 90;
const ll LINF = 1e18 + 90 ;
using pii = pair<int,int >;
using vec = vector<int> ;

int main()
{
	ll x , k;
	cin >> x >> k;
	if(x*500 >= k) cout << "Yes"<<endl;
	else cout <<"No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int D, N;
    cin >> D >> N;
    if (N == 100) N++;
    rep(i,D) N *= 100;

    cout << N << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int N = 1e5 + 50;
char a[105][105];
int main()
{
	IO;
	int aa, bb;
	cin >> aa >> bb;
    for(int i = 0; i < 50; i++)
    {
        for(int j = 0; j < 100; j++)
        {
            a[i][j] = '.';
            if(i % 2 && j % 2 && bb > 1)
                a[i][j] = '#', bb--;
        }
    }
    for(int i = 50; i < 100; i++)
    {
        for(int j = 0; j < 100; j++)
        {
            a[i][j] = '#';
            if(i % 2 && j % 2 && aa > 1)
                a[i][j] = '.', aa--;
        }
    }
    cout << "100 100\n";
    for(int i = 0; i < 100; i++)
    {
        for(int j = 0; j < 100; j++)
            cout << a[i][j];
        cout << '\n';
    }
}



Measured memory_bytes: 256
import sys
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

a = int(input())
myset = set()
for i in range(1,10):
    for j in range(1,10):
        myset.add(i*j)
if a in myset:
    print('Yes')
else:
    print('No')

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

int main()
{
	int64_t a, b, q;
	cin >> a >> b >> q;
	vector<int64_t> ss(a), ts(b), xs(q);
	for (auto &s : ss)
	{
		cin >> s;
	}
	for (auto &t : ts)
	{
		cin >> t;
	}
	for (auto &x : xs)
	{
		cin >> x;
	}

	ss.emplace_back(-(1LL << 60));
	ss.emplace_back(1LL << 60);
	ts.emplace_back(-(1LL << 60));
	ts.emplace_back(1LL << 60);

	sort(ss.begin(), ss.end());
	sort(ts.begin(), ts.end());

	for (auto &x : xs)
	{
		int64_t rs = distance(ss.begin(), upper_bound(ss.begin(), ss.end(), x));
		int64_t ls = rs - 1;
		int64_t rt = distance(ts.begin(), upper_bound(ts.begin(), ts.end(), x));
		int64_t lt = rt - 1;

		rs = abs(x - ss[rs]);
		ls = abs(x - ss[ls]);
		rt = abs(x - ts[rt]);
		lt = abs(x - ts[lt]);

		int64_t ans = min(max(ls, lt), max(rs, rt));
		ans = min(ans, 2 * ls + rt);
		ans = min(ans, ls + 2 * rt);
		ans = min(ans, 2 * lt + rs);
		ans = min(ans, lt + 2 * rs);

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

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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;



int main() {
  ll n;
  	ci(n);
  vll S(4);
  
  FOR(i,0,4){
    ll a=n%10;
    S[i]=a;
    n/=10;
  }
  ll A=(10*S[3]+S[2]);
  ll B=(10*S[1]+S[0]);    
  
  if((0<A&&A<=12)&&(0<B&&B<=12)){
    co("AMBIGUOUS")
  }
  
  else if((0==A||12<A)&&(0<B&&B<=12)){
    co("YYMM")
  }
  
  else if((0<A&&A<=12)&&(12<B||B==0)){
    co("MMYY")
  }
  else{
    co("NA")
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,t;
    cin>>n>>t;
    vi vec(n);
    int now=0;
    int ans=0;
    REP(i,n){
        cin>>vec[i];
        ans+=max(0,vec[i]+t-max(vec[i],now));
        now=vec[i]+t;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdlib>
#include <cmath>

using namespace std;

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  for(int i=1;i<101;i++){
    if((A*i)%B == C){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 256
T = int(input())
for _ in range(T):
  N,a,b,c,d = map(int, input().split())
  
  memo = {}
  def solve(n):
    if n == 0:
      return 0
    if n == 1:
      return d
    if n in memo:
      return memo[n]
    tmp = n * d
    if n % 2 == 0:
      tmp = min(tmp, a + solve(n//2))
    else:
      tmp =  min(tmp, a + d + solve(n//2), a + d + solve(n//2+1))
    if n % 3 == 0:
      tmp = min(tmp, b + solve(n//3))
    else:
      ret1 = n % 3
      ret2 = 3 - ret1
      tmp = min(tmp, b + d*ret1 + solve(n//3), b + d*ret2 + solve(n//3+1))
    if n % 5 == 0:
      tmp = min(tmp, c + solve(n//5))
    else:
      ret1 = n % 5
      ret2 = 5 - ret1
      tmp = min(tmp, c + d*ret1 + solve(n//5), c + d*ret2 + solve(n//5+1))
    memo[n] = tmp
    return memo[n]
    
  print(solve(N))

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

int main(){
  long long H;
  cin >> H;
  //int a = H;
  int log2 = 0;
  while(H > 1){
    H = H/2;
    log2++;
    //cout << H << " ";
  }
  log2++;
  //cout << log2 << endl;
  long long ans = pow(2,log2) - 1;
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
/*input
2 5
2 3
*/
#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;
typedef tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll = long long;
using ld = long double;
using pii = pair<ld,ld>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=4e18;
const int INF=1e6+1;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
ll sub(ll a,ll b){
    ll x=a-b;
    while(x<0) x+=MOD;
    while(x>MOD) x-=MOD;
    return x;
}
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=(res*a);
        if(res>1e10) return 1e11;
        a=(a*a);
        b>>=1;
    }
    return res;
}
const ll maxn=100005;
const ll maxlg=__lg(maxn)+2;
bool dp[maxn];
int a[maxn];
int main(){
    int n,k;
    cin>>n>>k;
    REP(i,n) cin>>a[i];
    REP(i,k+1){
        REP(j,n){
            if(a[j]<=i and !dp[i-a[j]]) dp[i]=true;
        }
    }
    puts(dp[k]?"First":"Second");
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	string s;
	cin >> s;
	ll n = s.size();

	ll ans = 0, cntg = 0, cntp = 0;
	for (ll i = 0; i < n; i++) {
		if (s[i] == 'g') {
			if (cntg > cntp) {
				ans++;
				cntp++;
			}
			else cntg++;
		}
		else {
			if (cntg > cntp) cntp++;
			else {
				ans--;
				cntg++;
			}
		}
	}
	cout << ans << endl;
}


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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, t, a;
    cin >> n >> t >> a;
    double diff = 1e9;
    int ans;
    for(int i = 1, h; i <= n; ++i) {
        cin >> h;
        if(abs(a - (t - 0.006 * h)) < diff) {
            ans = i;
            diff = abs(a - (t - 0.006 * h));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()
void solve(long long N, long long K, std::vector<long long> h){
  sort(all(h));
  ll ans = h[0+K-1] - h[0];
  for (int i = 0; i < N-K+1; i++) {
    ll h_max = h[i+K-1];
    ll h_min = h[i];
    ans = min(ans,h_max-h_min);
  }
  cout << ans << endl;
}

int main(){
    long long N;
	scanf("%lld",&N);
	long long K;
	scanf("%lld",&K);
	std::vector<long long> h(N);
	for(int i = 0 ; i < N ; i++){
		scanf("%lld",&h[i]);
	}
    solve(N, K, std::move(h));
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll	    long long
#define vi      vector <int>
#define vii     vector <pair<int,int>>
#define ii      pair<int,int>
#define loop(n)	for(int i=0;i<n;i++)
const ll mod=1e9+7;
bool is_prime(int n)
{
    if(n==2)
        return true;
    if(n%2==0||n<2)
        return false;
    for(int i=3; i<=sqrt(n); i+=2)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
long long power(ll n, ll k){
    if(k==0) return 1;
    ll sq=(power(n,k/2))%mod;
    sq=(sq*sq)%mod;
    if(k%2==1)
        sq=(sq*n)%mod;
    return sq%mod;
}
long long gcd(long long a,long long b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
// lcm = (a*b)/gcd(a,b)
//freopen("input.txt" ,"r",stdin );
//freopen("output.txt","w",stdout);
int n,m;
char grid[1005][1005];
ll dp[1005][1005];
bool valid(int x,int y)
{
    if(x<0||x>n||y<0||y>m||grid[x][y]=='#')return false;
    return true;
}
ll fun(int x,int y)
{
    if(valid(x,y))
    {
        if(x==n-1&&y==m-1)return 1;
        ll &ret=dp[x][y];
        if(~ret)return ret%=(1000000007),ret;
        ret=fun(x+1,y)%(1000000007)+fun(x,y+1)%(1000000007);
        return ret%=(1000000007);
    }
    else return 0;
}

void fast();
int main()
{
    fast();
    cin>>n>>m;
    loop(n)
        for(int j=0;j<m;j++)cin>>grid[i][j];
    memset(dp,-1,sizeof dp);
    cout<<fun(0,0)%(1000000007);
}
void fast(){
std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
/*

*/


Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String sd = sc.nextLine();
		String t = sc.nextLine();
		int ls = sd.length();
		int lt = t.length();
		String S = "";
		int k = -1;

		LOOP: for (int i = ls - lt; i >= 0; i--) {
			for (int j = 0; j < lt; j++) {
				char sdi = sd.charAt(i + j);
				if (sdi != '?' && sdi != t.charAt(j)) {
					continue LOOP;
				}

			}
			k=i;
			break;
		}
		if(k==-1) {
			System.out.println("UNRESTORABLE");
			return;
		}
		S=S.concat(sd.substring(0, k));
		S=S.concat(t);
		S=S.concat(sd.substring(k + lt));
		S=S.replace('?', 'a');
		System.out.println(S);
	}
}


Measured memory_bytes: 25044
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	final long MOD = (long) (1e9 + 7);

	void run() {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int[][] A = new int[H][W];
		int[][] B = new int[H][W];
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				A[i][j] = sc.nextInt();
			}
		}
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				B[i][j] = sc.nextInt();
			}
		}
		boolean[][][] diff = new boolean[H][W][80 * 80 + 10];
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				for (int k = 0; k < diff[i][j].length; ++k) {
					diff[i][j][k] = false;
				}
			}
		}
		diff[0][0][Math.abs(A[0][0] - B[0][0])] = true;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				for (int cur = 0; cur < diff[i][j].length; ++cur) {
					if (!diff[i][j][cur])
						continue;
					int[] dx = new int[] { 1, 0 };
					int[] dy = new int[] { 0, 1 };
					for (int k = 0; k < 2; ++k) {
						if (i + dx[k] < H && j + dy[k] < W) {
							int add = Math.abs(A[i + +dx[k]][j + dy[k]] - B[i + dx[k]][j + dy[k]]);
							if (diff[0][0].length > Math.abs(cur + add))
								diff[i + dx[k]][j + dy[k]][Math.abs(cur + add)] |= diff[i][j][cur];
							if (diff[0][0].length > Math.abs(cur - add))
								diff[i + dx[k]][j + dy[k]][Math.abs(cur - add)] |= diff[i][j][cur];
						}
					}
				}
			}
		}
		int ans = Integer.MAX_VALUE / 3;
		for (int i = 0; i < diff[H - 1][W - 1].length; ++i) {
			if (diff[H - 1][W - 1][i])
				ans = Math.min(ans, i);
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 283932
#include<iostream>

using namespace std;

int main(void)
{
	int min = 0;
	int input;

	for (int i = 0; i < 4; i++)
	{
		cin >> input;
		min += input;
	}

	cout << (min) / 60 << endl << min % 60 << endl;

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <string>
#include <map>
#include <list>
using namespace std;

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

  bool can=false;
  for(int i = 1; i < 10; ++i){
    for(int j = 1; j < 10; ++j){
      if(i*j == n){
        can=true;
        break;
      }
    }
  }
  if(can){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  
}



Measured memory_bytes: 3600
import itertools

while True:
    n, x = map(int, input().split())
    if (n, x) == (0, 0):
        break
    a = 0
    comb = itertools.combinations(list(range(1, n + 1)), 3)
    for i in comb:
        if sum(i) == x:
            a += 1
    print(a)


Measured memory_bytes: 5640
#include <bits/stdc++.h>
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define INF 1000000000000000003 //1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int N;
  cin>>N;

  int ans=0;
  rep(i,N){
    int l,r;
    cin>>l>>r;
    ans+=r-l+1;
  }

  cout<< ans<<"\n";
}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    int a[1001];

    cin >> n;

    for (int i=0;i<n;i++){
        int ai;
        cin >> ai;
        a[i] = ai;
    }

    int ma = 0;
    int mi = a[0];
    for (int i=0;i<n;i++) {
        ma = max(a[i], ma);
        mi = min(a[i], mi);
    }

    cout << ma - mi << endl;

    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N, K;
ll a[20];
int bitcount(int now) {
    if(now == 0) return 0;
    int tmp = 0;
    if(now % 2 == 1) tmp = 1;
    return tmp + bitcount(now / 2);
}

int main() {
    //cout.precision(10);
    cin >> N >> K;
    for(int i = 0; i < N; i++) cin >> a[i];
    ll ans = 1e18;
    for(int bits = 0; bits < (1<<N); bits++) {
        if(bitcount(bits) < K) continue;
        ll now_ans = 0;
        ll now = 0;
        for(int i = 0; i < N; i++) {
            if((bits >> i) & 1) {
                now_ans += max((ll)0, (now + 1) - a[i]);
                now = max(now + 1, a[i]);
                continue;
            }
            now = max(now, a[i]);
        }
        ans = min(ans, now_ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    string s; cin>>s;
    ll n=s.size();
    ll res=0, tmp=0;
    rep(i,n){
        if(s[i]=='A' || s[i]=='T' || s[i]=='C' || s[i]=='G'){
            tmp++;
        }else{
            chmax(res,tmp);
            tmp=0;
        }
    }
    cout<<max(res,tmp)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool palin(int x)
{
	int digit[5];
  	for (int i = 4; i >= 0; i--){
    	digit[i] = x % 10;
      	x /= 10;
    }
  	if (digit[0] == digit[4] && digit[1] == digit[3]){
    	return true;
    } else {
    	return false;
    }
}
int main()
{
	int a, b, ans = 0;
  	cin >> a >> b;
  	for (int i = a; i <= b; i++){
    	if (palin(i)) ans++;
    }
  	cout << ans;
}

Measured memory_bytes: 256
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}



int main(){
	FIO
	
	deque<int> deq;
	int q;
	cin >> q;
	while(q--){
		int op;
		cin >> op;
		if(op == 0){
			int d, x;
			cin >> d >> x;
			if(d == 0)deq.push_front(x);
			else deq.push_back(x);
		}else if(op == 1){
			int p;
			cin >> p;
			cout << deq[p] << '\n';
		}else{
			int d;
			cin >> d;
			if(d == 0) deq.pop_front();
			else deq.pop_back();
		}
	}
	return 0;
}



Measured memory_bytes: 4616
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    
    if(x + r <= w && x - r >= 0 && y + r <= h && y - r >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
}


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

int N, T, L, B;
bool lose[111], back[111];
double dp[111][111];

void solve() {
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1.0;
	
	for (int t=0; t<T; ++t) for (int x=0; x<N; ++x) {
		for (int d=1; d<=6; ++d) {
			int nx = x + d;
			if (nx > N) nx = N - (nx - N);
			
			if (lose[nx]) dp[t+2][nx] += dp[t][x] / 6.0;
			else if (back[nx]) dp[t+1][0] += dp[t][x] / 6.0;
			else dp[t+1][nx] += dp[t][x] / 6.0;
		}
	}
	
	double ans = 0;
	for (int t=1; t<=T; ++t) ans += dp[t][N];
	printf("%.9lf\n", ans);
}

int main() {
	while (cin >> N >> T >> L >> B, N != 0) {
		memset(lose, 0, sizeof(lose));
		memset(back, 0, sizeof(back));
		
		for (int i=0; i<L; ++i) {
			int x; cin >> x;
			lose[x] = true;
		}
		
		for (int i=0; i<B; ++i) {
			int x; cin >> x;
			back[x] = true;
		}
		
		solve();
	}
}


Measured memory_bytes: 3164
using System;
using System.IO;

class Program
{
    static void Main(string[] args) {
        var scan = new Scanner();
        var writer = new StreamWriter(Console.OpenStandardOutput()) {AutoFlush = false};
        Console.SetOut(writer);
        Console.WriteLine(Solve(scan));
        Console.Out.Flush();
    }
    static int Solve(Scanner scan) {
        double N = scan.NextDouble(), X = scan.NextDouble();
        int T = scan.NextInt();
        return (int) Math.Ceiling(N / X) * T;
    }
}

class Scanner
{
    string[] s;
    int i;
    public Scanner() {
        s = new string[0];
        i = 0;
    }
    public string Next() {
        if (i < s.Length) return s[i++];
        string str = Console.ReadLine();
        while (str == "") str = Console.ReadLine();
        s = str.Split(' ', StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return Next();
        i = 0;
        return s[i++];
    }
    public int NextInt() => int.Parse(Next());
    public double NextDouble() => double.Parse(Next());
}

Measured memory_bytes: 27540
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define setp(x) fixed << setprecision(x)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
 
}
void solve()
{
	string s;
	cin >> s;
	int i = 0;
	bool bad = 0;
	while(i < sz(s)){
		if(i + 5 > sz(s)) {
			bad = 1;
			break;
		}
		string t = s.substr(i, 5);
		if(t != "erase" && t != "dream"){
			bad = 1;
			break;
		}
		if(i + 5 == sz(s)) break;
		if(t == "erase"){
			if(s[i + 5] == 'r') i += 6;
			else if(s[i + 5] == 'd' || s[i + 5] == 'e') i += 5;
			else{
				bad = 1;
				break;
			}
		}
		else{
			if(i + 6 == sz(s)) {
				bad = 1;
				break;
			}
			else{
				if(s[i + 5] == 'd'){
					i += 5;
				}
				else
				if(s[i + 5] != 'e' || s[i + 6] != 'r'){
					bad = 1;
					break;
				}
				else if(i + 7 == sz(s)) break;
				else {
					if(s[i + 7] == 'a') {
						i += 5;
					}
					else if(s[i + 7] == 'e' || s[i + 7] == 'd'){
						i += 7;
					}
					else {
						bad = 1;
						break;
					}
				}
			}
		}
	}
	cout << (!bad ? "YES" : "NO");
}	 

 
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    Red;
  	int T = 1;
  	// cin >> T;
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
  	return 0;

}


Measured memory_bytes: 3724
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void p(vector<int> A){rep(i,A.size()){cout << A[i] << " ";}cout << "\n";}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(n-1);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n-1) cin >> c[i];
    int ans = b[a[0]-1];
    for(int i = 1; i < n; i++){
        ans += b[a[i]-1];
        if (a[i] == a[i-1]+1){
            ans += c[a[i]-2];
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int l, r;
  int ans = 0;
  
  for(int i=0; i<N; i++){
    cin >> l >> r;
    ans += r- l +1;
  }
  cout << ans << endl;
}
  

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

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try{
            StringBuilder sb = new StringBuilder();
            String str = br.readLine();
            String[] s= str.split("",0);
            for(int i=0;i<s.length;i++){
                sb.append(s[s.length-1-i]);
            }
            System.out.println(sb);
        }catch(Exception ex){
            System.exit(0);
        }
    }
}

Measured memory_bytes: 24324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int a, b;
	cin >> a >> b;
	if (a < 0 && 0 < b || a * b == 0) cout << "Zero" << endl;
	else if (0 < a) cout << "Positive" << endl;
	else {
		if ((b - a + 1) % 2 == 0) cout << "Positive" << endl;
		else cout << "Negative" << endl;
	}
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

int main() {
	ll N;
	cin >> N;
	ll cnt[111] = {};
	for (ll i = 2; i <= N; ++i) {
		int t = i;
		for (ll j = 2; t != 1; j++) {
			while (t%j == 0) {
				cnt[j]++;
				t /= j;
			}
		}
	}
	ll ans = 0;
	for (ll i = 2; i < 111; ++i) {
		if (cnt[i] >= 74)ans++;
		for (int j = 2; j < 111; ++j) {
			for (int k = j + 1; k < 111; ++k) {
				if (i == j || i == k)continue;
				if (cnt[i] >= 2 && cnt[j] >= 4 && cnt[k] >= 4) {
					ans++;
				}
			}
		}
	}
	for (int i = 2; i < 111; ++i) {
		for (int j = 2; j < 111; ++j) {
			if (i == j)continue;
			if (cnt[i] >= 4 && cnt[j] >= 14)ans++;
			if (cnt[i] >= 2 && cnt[j] >= 24)ans++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define MAX 1001
void solve(void);
int q,count[MAX][MAX]={},xlength,ylength;
char X[MAX],Y[MAX];
 
void solve(void){
  int i,j;
 
  xlength=strlen(X);
  ylength=strlen(Y);
   
  for(i=1;i<=xlength;i++){
    for(j=1;j<=ylength;j++){
      if(X[i-1]==Y[j-1]) count[i][j]=count[i-1][j-1]+1;
      else if(count[i-1][j]>=count[i][j-1]) count[i][j]=count[i-1][j];
      else count[i][j]=count[i][j-1];
    }
  }
}
     
int main()
{
  int i;
   
  scanf("%d",&q);
 
  for(i=1;i<=q;i++){
    scanf("%s",X);
    scanf("%s",Y);
    solve();
    printf("%d\n",count[xlength][ylength]);
  }
 
  /*for(i=0;i<q;i++){
    printf("%d\n",count[][]);
    }*/
 
  return 0;
}

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

public class Main {
    static ArrayList<Integer>[]ed;
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n=sc.nextInt();
		String s=sc.nextLine();
		long ans=1;
		int []a=new int[26];
		Arrays.fill(a,1);
		for(int i=0;i<n;i++)
			a[s.charAt(i)-'a']++;
		for(int i=0;i<26;i++) {
			ans=(ans*a[i])%mod;
		}
		ans--;
		out.print(ans);
		out.flush();
	}
	static final long mod=(long)1e9+7;
	static long fac(long n) {
		if(n==0 || n==1)
			return 1;
		long a=1;
		while(n>0) {
			a*=n;
			n--;
		}
		return a;
	}
	static boolean io=false;
	static boolean []vis;
    static void dfs(int u,int w) {
    	vis[u]=true;
    	if(u==w)
    		 io=true;
    	for(int v:ed[u]) {
    		if(!vis[v]) {
    	   dfs(v,w);
    		}
    	}
    	//return false;
    }
	static int gcd(int a, int b) {
		if (b == 0) {
			return a;
		}
		return gcd(b, a % b);
	}

	static class pair{
		char a;
	    char b;

		pair(char a,char b) {
			this.a = a;
			this.b = b;
		}

		public String toString() {
			return a + " " + b;
			}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

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

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

Measured memory_bytes: 24532
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>


using namespace std;
int main() {

	int n;
	cin >> n;
	int x = 9999999;
	for (int i = 0; i < n; i++) {
		int t;
		cin >> t;
		int p = 0;
		while (t%2==0) {
			p++;
			t /= 2;
		}
		x = min(x, p);
	}

	cout << x << endl;
	

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define _GLIBCXX_DEBUG
static const int MAX = 50;


int main(){
  int N, p[MAX], sw = 0;
  cin >> N;
  rep(i, N){
    cin >> p[i];
    if(p[i] != i+1) sw++;
  }
  
  cout << (sw <= 2 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
n = int(input())

colors = []

for i in range(n):
  a = int(input())
  if i == 0:
    colors.append(a)
    continue
  if colors[-1] >= a:
    colors.append(a)
  elif a > colors[0]:
    colors[0] = a
  else:
    l, r = 0, len(colors)
    while r-l > 1:
      k = (r+l)//2
      if a > colors[k]:
        r = k
      else:
        l = k
    if a > colors[l]:
      colors[l] = a
    else:
      colors[r] = a

print(len(colors))

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;

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

    ll N; cin >> N;
    ll n = N;
    vector<int> a;
    while (n) {
        a.pb(n % 10);
        n /= 10;
    }
    reverse(all(a));
    if (a.size() == 1) {
        cout << a[0] << endl;
    }
    else {
        bool f = true;
        int m = a.size();
        REP(i, 1, m) {
            if (a[i] != 9) f = false;
        }
        if (!f) {
            cout << (m - 1) * 9 + (a[0] - 1) << endl;
        } else {
            cout << a[0] + (m - 1) * 9 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256