akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <iterator>
#include <limits>
#include <numeric>
#include <utility>
#include <cmath>
#include <cassert>
#include <cstdio>

using namespace std; using namespace placeholders;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector< int > VI;
typedef vector< vector< int > > VVI;
typedef vector< string > VS;
typedef stringstream SS;
typedef pair< int, int > PII;
typedef vector< pair< int, int > > VPII;
#define VT( T ) vector< T >
#define VVT( T ) vector< vector< T > >
#define LIM( T ) numeric_limits< T >

template < typename T > inline istream& operator>>( istream &s, vector< T > &v ){ for ( T &t : v ) { s >> t; } return s; }
template < typename T > inline ostream& operator<<( ostream &s, const vector< T > &v ){ for ( int i = 0; i < int( v.size() ); ++i ){ s << ( " " + !i ) << v[i]; } return s; }
template < typename T > inline T fromString( const string &s ) { T res; istringstream iss( s ); iss >> res; return res; };
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

#define REP2( i, n ) REP3( i, 0, n )
#define REP3( i, m, n ) for ( int i = ( int )( m ); i < ( int )( n ); ++i )
#define GET_REP( a, b, c, F, ... ) F
#define REP( ... ) GET_REP( __VA_ARGS__, REP3, REP2 )( __VA_ARGS__ )
#define FOR( e, c ) for ( auto &e : c )
#define ALL( c ) ( c ).begin(), ( c ).end()
#define AALL( a, t ) ( t* )a, ( t* )a + sizeof( a ) / sizeof( t )
#define DRANGE( c, p ) ( c ).begin(), ( c ).begin() + p, ( c ).end()

#define SZ( v ) ( (int)( v ).size() )
#define PB push_back
#define EM emplace
#define EB emplace_back
#define BI back_inserter

#define EXIST( c, e ) ( ( c ).find( e ) != ( c ).end() )

#define MP make_pair
#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

bool conflict( const VI &as, const VI &bs, const int D )
{
	const int N = SZ( as ) - 1, M = SZ( bs ) - 1;

	VVI dp( N + 1, VI( M + 1, 0 ) );
	dp[0][0] = 1;

	REP( i, N + 1 )
	{
		REP( j, M + 1 )
		{
			if ( i + 1 <= N && abs( as[ i + 1 ] - bs[j] ) <= D )
			{
				dp[ i + 1 ][j] |= dp[i][j];
			}
			if ( j + 1 <= M && abs( as[i] - bs[ j + 1 ] ) <= D )
			{
				dp[i][ j + 1 ] |= dp[i][j];
			}
		}
	}

	return !dp[N][M];
}

bool solve( const int N, const int D )
{
	VVI csums( N, VI( 1, 0 ) );
	REP( i, N )
	{
		int m;
		cin >> m;

		VI as( m );
		cin >> as;

		partial_sum( ALL( as ), BI( csums[i] ) );
	}

	REP( i, N )
	{
		REP( j, i )
		{
			if ( conflict( csums[i], csums[j], D ) )
			{
				return false;
			}
		}
	}
	return true;
}

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

	for ( int N, D; cin >> N >> D && ( N | D ); cout << ( solve( N, D ) ? "Yes" : "No" ) << endl );

	return 0;
}

Measured memory_bytes: 3972
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;

ll bfs(vector<string> &grid, ll H, ll W, ll x, ll y) {
  queue<pair<ll, ll>> q;
  q.push(make_pair(x, y));

  vector<vector<ll>> distance(H, vector<ll>(W, -1));
  distance[x][y] = 0;

  ll res = 0;
  while (!q.empty()) {
    pair<ll, ll> p = q.front();
    q.pop();
    ll h = p.first;
    ll w = p.second;

    // cout << h << " " << w << endl;
    // cout << distance[h][w] << endl;

    res = max(res, distance[h][w]);

    // down
    if ((h + 1) < H && grid[h + 1][w] == '.' && distance[h + 1][w] == -1) {
      q.push(make_pair(h + 1, w));
      distance[h + 1][w] = distance[h][w] + 1;
    }
    // up
    if ((h - 1) >= 0 && grid[h - 1][w] == '.' && distance[h - 1][w] == -1) {
      q.push(make_pair(h - 1, w));
      distance[h - 1][w] = distance[h][w] + 1;
    }
    // right
    if ((w + 1) < W && grid[h][w + 1] == '.' && distance[h][w + 1] == -1) {
      q.push(make_pair(h, w + 1));
      distance[h][w + 1] = distance[h][w] + 1;
    }

    // left
    if ((w - 1) >= 0 && grid[h][w - 1] == '.' && distance[h][w - 1] == -1) {
      q.push(make_pair(h, w - 1));
      distance[h][w - 1] = distance[h][w] + 1;
    }
  }

  return res;
}

int main() {
  ll H, W;
  cin >> H >> W;
  vector<string> grid(H);
  for (ll i = 0; i < H; i++) {
    cin >> grid[i];
  }

  ll ans = 0;
  for (ll i = 0; i < H; i++) {
    for (ll j = 0; j < W; j++) {
      if (grid[i][j] == '.') {
        ans = max(ans, bfs(grid, H, W, i, j));
      }
    }
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
int main()
{
	int a;
	std::cin>>a;
	if(a==22)
	{
		std::cout<<"Christmas Eve Eve Eve";
	}
	else if(a==23)
	{
		std::cout<<"Christmas Eve Eve";
	}
	else if(a==24)
	{
		std::cout<<"Christmas Eve";
	}
	else
	{
		std::cout<<"Christmas";
	}
	return 0;
 } 

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define i_inf int(1e9)
#define i_half_inf int(1e5)
#define ll_inf ll(1e9)*ll(1e9)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

map<ll, ll> mp;
ll n;

// 素数列挙
void prime_factor(ll n) {
    for (ll i = 2; i * i <= n; ++i) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }
    if (n != 1) mp[n]++;
}

void solve() {
    repone(i, n) prime_factor(i);

    ll three = 0, five = 0, fifteen = 0, twenty_five = 0, seventy_five = 0;
    each(i, mp) {
        if ((i.second + 1) >= 75) seventy_five++;
        if ((i.second + 1) >= 25) twenty_five++;
        if ((i.second + 1) >= 15) fifteen++;
        if ((i.second + 1) >= 5) five++;
        if ((i.second + 1) >= 3) three++;
    }
    cout << seventy_five + twenty_five * (three - 1) + fifteen * (five - 1) +
            five * (five - 1) / 2 * (three - 2) << endl;
}

int main() {
    cin >> n;
    solve();
    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[]
for i in range(m):
  a.append(int(input()))
a=set(a)
dp=[0]*(n+1)
dp[0]=1
if 1 in a:
  dp[1]=0
else:
  dp[1]=1
for i in range(2,n+1):
  if i in a:
    dp[i]=0
  else:
    dp[i]=(dp[i-1]+dp[i-2])%1000000007
print(dp[n]%1000000007)


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

/*vector<int> p(n);
cin >> p[i]*/

int main(){

    int x, a;
    cin >> x >> a;

    if(x < a) cout << 0 << endl;
    else cout << 10 << endl;

    return 0;
}

Measured memory_bytes: 256
import java.math.BigDecimal;
import java.math.MathContext;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        BigDecimal a = sc.nextBigDecimal();
        BigDecimal b = sc.nextBigDecimal();
        BigDecimal c = sc.nextBigDecimal();
        BigDecimal aa = sqrt(a, 50);
        BigDecimal bb = sqrt(b, 50);
        BigDecimal cc = sqrt(c, 50);
        if (aa.add(bb).compareTo(cc) == -1){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static BigDecimal sqrt(BigDecimal a, int scale){
        BigDecimal x = new BigDecimal(
                Math.sqrt(a.doubleValue()), MathContext.DECIMAL64);
        if(scale < 17) return x;
        BigDecimal b2 = new BigDecimal(2);
        for (int tempScale = 16; tempScale < scale; tempScale *= 2){
            x = x.subtract(
                    x.multiply(x).subtract(a).divide(
                            x.multiply(b2), scale, BigDecimal.ROUND_HALF_EVEN));
        }
        return x;
    }
}


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

const int maxn = 18;
int a[1 << maxn], ans[1 << maxn];
vector<int> dp[1 << maxn];

vector<int> merge(vector<int> a, vector<int> b) {
    vector<int> r(a.begin(), a.end());
    for (int i = 0; i < b.size(); ++i) r.push_back(b[i]);
    sort(r.begin(), r.end(), greater<int>());
    return vector<int>(r.begin(), r.begin() + min(2, (int)r.size()));
}

int main() {
    int n; scanf("%d", &n);
    for (int i = 0; i < (1 << n); ++i) scanf("%d", &a[i]);
    for (int i = 0; i < (1 << n); ++i) dp[i] = { a[i] };
    for (int j = n - 1; j >= 0; --j) {
        for (int i = (1 << n) - 1; i >= 0; --i) {
            if (i >> j & 1) dp[i] = merge(dp[i], dp[i ^ (1 << j)]);
        }
    }
    int ans = 0;
    for (int i = 1; i < (1 << n); ++i) {
        ans = max(ans, accumulate(dp[i].begin(), dp[i].end(), 0));
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 19456
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};

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()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N; cin>>N;
  vector<ll> A(N),B(N),C(N); rep(i,N) cin>>A[i]; rep(i,N) cin>>B[i]; rep(i,N) cin>>C[i];
  
  sort(A.begin(),A.end()); sort(B.begin(),B.end()); sort(C.begin(),C.end());
  vector<ll> vec(N);
  rep(i,N){
    ll b=B[i];
    ll ok=-1,ng=N;
    while(abs(ng-ok)>1){
      ll mid=(ok+ng)/2;
      if(A[mid]<b) ok=mid;
      else ng=mid;
    }
    vec[i]=ok+1;
  }
  //for(auto v:vec) cout<<v<<endl;
  
  vector<ll> cum(N+1,0); rep(i,N) cum[i+1]=cum[i]+vec[i];
  
  ll ans=0;
  rep(i,N){
    ll c=C[i];
    ll ok=-1,ng=N;
    while(abs(ok-ng)>1){
      ll mid=(ok+ng)/2;
      if(B[mid]<c) ok=mid;
      else ng=mid;
    }
    //cout<<ok<<endl;
    ans+=(ok==-1?0:cum[ok+1]);
  }
  
  cout<<ans<<'\n';
  
  return 0;
}

Measured memory_bytes: 7176
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  string s;
  cin >> s;
  int n = s.length();
  string t;
  rep (i, n) {
    if (s[i] != 'x') {
      t += s[i];
    }
  }

  string u = t;
  reverse(all(u));
  int m = t.length();
  rep (i, m) {
    if (t[i] != u[i]) {
      printf("-1\n");
      return 0;
    }
  }

  string r = s;
  reverse(all(r));
  int mm = (m+1) / 2;
  vi s_(mm), r_(mm);
  int cnt = 0;
  int ind = 0;
  rep (i, mm) {
    for (; ; ind += 1) {
      if (s[ind] == 'x') {
        cnt += 1;
      } else {
        ind += 1;
        break;
      }
    }
    s_[i] = cnt;
    cnt = 0;
  }
  ind = 0;
  rep (i, mm) {
    for (; ; ind += 1) {
      if (r[ind] == 'x') {
        cnt += 1;
      } else {
        ind += 1;
        break;
      }
    }
    r_[i] = cnt;
    cnt = 0;
  }

  int ans = 0;
  rep (i, mm) {
    ans += (max(s_[i], r_[i]) - min(s_[i], r_[i]));
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n;
    cin >> n;
    set<string> se;
    rep(i,n){
        string s;
        cin >> s;
        se.insert(s);
    }
    cout << se.size() << endl;
    return 0;
}




Measured memory_bytes: 19200
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;

int main(){
  int cnt[5]={0};
  for(int i=0;i<3;i++){
    int a,b;cin>>a>>b;
    cnt[a]++,cnt[b]++;
  }
  bool ok=1;
  for(int i=1;i<=4;i++)if(cnt[i]==3)ok=0;
  cout<<(ok?"YES":"NO")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define vso(x) sort( x.begin() , x.end() )
#define vre(x) reverse( x.begin() , x.end() ) ;
#define aso(x) sort( x , x + x.size() )
#define are(x) reverse( x , x + x.size() )
#define print(x) cout << x << endl 
#define no cout << "NO\n" 
#define yes cout << "YES\n"
typedef long long ll ; 
typedef unsigned long long ull ;
typedef long double ld ;
typedef pair<ll, ll> pairs ;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("problem_name.out", "w", stdout) ;
    //freopen("problem_name.in", "r", stdin) ;
    //ull h = 798568968205 ; srand(h) ;
    //int t ; cin >> t ; while(t--){}

    string s , t ; cin >> s >> t ;
    t.erase( t.begin() + t.size() - 1 ) ;
    if ( s == t ) cout << "Yes\n" ;
    else cout << "No\n" ;
}

Measured memory_bytes: 3056
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n, a[200100], i;
    map<long long, long long> mp;
    cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i];
    }
    for(i=0;i<n;i++){
        mp[a[i]]++;
        if(mp[a[i]]>=2){
            cout << "NO" <<endl;
            return 0;
        }
    }
    cout << "YES" <<endl;

    return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>    
#include <unordered_map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cerr<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define endl "\n"
#define fo(i,n) for(int i=0;i<n;i++)
#define foo(i,x,n) for(int i=x;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define w(x) int x;cin>>x;while(x--)
#define display(a,n) {fo(i,n) {cout<<a[i]<<" ";}cout<<endl;}
#define fil(a,n,val) {fo(i,n) a[i]=val; }
const ll MOD   = 1000*1000*1000+7;
const ll MOD2  = 998244353;
const ll N = 1000*1000+5;
const double PI  = 3.14159265;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
ll search(vl arr, ll l, ll r, ll x){if (r >= l) {ll mid = l + (r - l) / 2;if (arr[mid] == x)return mid;if (arr[mid] > x)return search(arr, l, mid - 1, x);return search(arr, mid + 1, r, x);} return -1;}
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll lcm(ll a , ll b){return (a*b)/ gcd(a,b);}
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p; y = y>>1;x = (x*x) % p; } return res; }
ll modInverse(ll n, ll p){return power(n, p-2, p);}
const int maxn=3e5+5;

vi g[maxn];
int dp[maxn];
int n,m;

int solve(int src){
	if(dp[src]!=-1)
		return dp[src];
	int flag=1;
	int best=0;
	for(int child:g[src]){
		flag=0;
		best=max(best,solve(child));
	}
	return dp[src]=flag?0:1+best;
}

int main(){
	fastio();
	cin>>n>>m;
	int x,y;
	while(m--){
		cin>>x>>y;
		g[x].pb(y);
	}
	fill(dp,-1);
	int ans=0;
	foo(i,1,n+1){
		ans=max(ans,solve(i));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 16912
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define  REP(i, n) for(int i=0; i<(n); ++i)
#define  ALL(obj) (obj).begin(), (obj).end()
#define ll long long
#define ul unsigned long

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  double A[N];
  REP(i,N) cin >> A[i];
  double res = 0.0;
  REP(i,N) res += 1.0/A[i];
  cout << 1.0/res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define g(i,j,k) (((i)-1)*6+(j)*3+(k)+1)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
const int N=4004000;
int n,m,Q,P,z,d,s,t,r,ans,fd[N],a[N],b[N],w[N],ck[2][N];
int fi(int x){return x==fd[x]?x:fd[x]=fi(fd[x]);}
void mrg(int u,int v){fd[fi(u)]=fi(v);}
int main(){
	//freopen("1.in","r",stdin);
	scanf("%d%d%d%d",&n,&m,&Q,&P);
	FOR(i,1,m) scanf("%d%d%d",&a[i],&b[i],&w[i]),d=__gcd(d,abs(w[i]-w[1]));
	P=__gcd(P,3*d);z=d?w[1]%d:(d=P,w[1]);
	FOR(i,1,6*n) fd[i]=i;
	FOR(i,1,m) w[i]=(w[i]-z)/d;
	FOR(i,1,m)FOR(j,0,1)FOR(k,0,2){
		mrg(g(a[i],j,k),g(b[i],!j,(k*2+w[i])%3));
		mrg(g(b[i],j,k),g(a[i],!j,(k*2+w[i])%3));
	}
	FOR(i,0,1)for(int x=(1<<i)*z%P;!ck[i][x];(x<<=2)%=P) ck[i][x]=1;
	FOR(i,1,Q){
		scanf("%d%d%d",&s,&t,&r);ans=0;
		FOR(j,0,1)FOR(k,0,2) ans|=fi(g(t,0,0))==fi(g(s,j,k)) && ck[j][(z+r+(3-k)*d)%P];
		puts(ans?"YES":"NO");
	}
} 

Measured memory_bytes: 20864
from collections import defaultdict

N,K = map(int, input().split())
A = list(map(int, input().split()))
BMAX = 40
"""
・K以下の非負整数の範囲で〜：桁DP感ある
・XORをとる：桁ごとに確認できる
・Xを選んで、f = X xor A1 + X xor A2 + ... + X xor AN
　 -> それぞれのAと毎回 xor 取るのではなく、桁ごとに xor を取ることができる　←　超重要のはず
　 -> A1 ~ AN の各桁（2進数の時の）に1が立っているのが何個あるか数えておく


遷移
dp[i][1] -> dp[i+1][1] : i-1桁目まででK未満が確定していれば、i桁目に1,0どちらを選んでもK未満
dp[i][0] -> dp[i+1][1]  : i-1桁目まででKと一致している場合、Kのi桁目が1なら、Xで0を選べば遷移できる
dp[i][0] -> dp[i+1][0]  : i桁目まで一致させる場合
"""

d = [0] * BMAX
for a in A:
  for i in range(BMAX):
    if a & (1 << i):
      d[i] += 1

# dp[i+1][0] : Xをi桁目まで決めた時に、Kのi桁目までと厳密に一致する　ときの最大値
# dp[i+1][1] : Xをi桁目まで決めた時に、Kのi桁目までと厳密に一致しないときの最大値

dp = [[-1 for _ in range(2)] for _ in range(BMAX+1)]


dp[0][0] = 0

for i in range(BMAX):
  now = BMAX-1-i
  # Xの左からnow桁目に1,0を設定した時にfが増加する量
  p0 = (2**now) * d[now]
  p1 = (2**now) * (N - d[now])
  
  # Kの左からnow番目に1が立ってるかどうか
  if K & (1 << now):
    is_one = True
  else:
    is_one = False

  # dp[i][1] -> dp[i+1][1] はXのi桁目に1,0を使えるから、より多い方を採用
  if dp[i][1] != -1:
    dp[i+1][1] = dp[i][1] + max(p1, p0)

  # dp[i][0] -> dp[i+1][1] はKのi桁目が1なら可能
  if dp[i][0] != -1 and is_one:
    dp[i+1][1] = max(dp[i+1][1], dp[i][0] + p0)

  # dp[i][0] -> dp[i+1][0] 
  if dp[i][0] != -1:
    dp[i+1][0] = dp[i][0] + (p1 if is_one else p0)    

print(max(dp[-1]))


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

int main(void)
{
    // 左からl個ひっくり返したあとに左からk+1個ひっくり返すとk+1個目だけ反転できる。
    // より大きな数字は自由に使えるので、k+1番目以降は自由に操作できる。
    // 右からでも同じ。
    // lが文字列の半分より大きいと左から、右からのどちらにも当てはまらない領域が中央に現れる。
    // 〇〇〇◎◎〇〇〇
    // k=5のとき◎は自由に操作できない。なので揃ってないといけない。
    
    string s;
    cin >> s;

    
    int l = ( s.length() - 1) / 2;  
    int r = ( s.length()) / 2; 
    int k = ( s.length()) / 2; 
    int center = s[l];
    while(1){
        if((s[l] == center) && (s[r] == center)){
            k++;
            if(0 == l) break;
            l--;
            r++;
        }else{
            break;
        }
    }


    cout << k << endl;    
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define fi first
#define se second
#define forn(i,n) for(int i=0; i< (int)n; ++i)
#define for1(i,n) for(int i=1; i<= (int)n; ++i)
#define fore(i,l,r) for(int i=(int)l; i<= (int)r; ++i)
#define ford(i,n) for(int i=(int)(n) - 1; i>= 0; --i)
#define fored(i,r,l) for(int i=(int)r; i>= (int)l; --i)
#define pb push_back
#define el '\n'
#define d(x) cout<< #x<< " " << x<<el
#define INF (1LL<<62)

using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
const double PI = atan(1)*4;
const int MAXN = 1e5+20;
const double EPS = 1e-9;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<< setprecision(2)<< fixed;
    int n;
    cin>>n;
    ll a[n], b[n], c[n], maxA[n], maxB[n], maxC[n];
    forn(i,n){
        cin>>a[i]>>b[i]>>c[i];
    }
    maxA[0]=a[0];
    maxB[0]=b[0];
    maxC[0]=c[0];
    for1(i,n-1){
        maxA[i]=max(maxB[i-1],maxC[i-1])+a[i];
        maxB[i]=max(maxA[i-1],maxC[i-1])+b[i];
        maxC[i]=max(maxB[i-1],maxA[i-1])+c[i];
    }
    cout<<max(maxA[n-1],max(maxB[n-1],maxC[n-1]))<<el;
}


Measured memory_bytes: 4992
import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.System.exit;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	static void solve() throws Exception {
		int n = scanInt();
		int ca = 0, ans = 0, ansInc = 1, ansInc2 = 1;
		for (int i = 0; i < n; i++) {
			int na = scanInt();
			if (na > ca) {
				ansInc2 = max(ansInc2, ansInc + na - ca);
			} else {
				ansInc2 = min(max(ansInc, ansInc2 - (ca - na)), na + 1);
				ansInc -= ca - na;
				if (ansInc <= 0) {
					++ans;
					ansInc = ansInc2;
					ansInc2 = na + 1;
				}
			}
			ca = na;
		}
		if (ansInc <= ca) {
			++ans;
		}
		out.print(ans);
	}

	static int scanInt() throws IOException {
		return parseInt(scanString());
	}

	static long scanLong() throws IOException {
		return parseLong(scanString());
	}

	static String scanString() throws IOException {
		while (tok == null || !tok.hasMoreTokens()) {
			tok = new StringTokenizer(in.readLine());
		}
		return tok.nextToken();
	}

	static BufferedReader in;
	static PrintWriter out;
	static StringTokenizer tok;

	public static void main(String[] args) {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			solve();
			in.close();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			exit(1);
		}
	}
}

Measured memory_bytes: 56060
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for(int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 2000005
ll dp[MAX_N] = {};
ll sum[MAX_N] = {};
int main() {
    ll n;
    cin >> n;
    ll MOD = 1000000007;
 

    drep(i,n+1){
        if(i==0)break;
        if(i==n){
            dp[i] = n;
        }else if(i>=n-10){
            dp[i] = (n-1)*(n-1) + dp[i+1];
            dp[i] %= MOD;
            srep(j,2,n+1){
                if(i+j+1<=n) dp[i] += dp[i+j+1];
                else dp[i] += 1;
            }
        } else{
            dp[i] = (n-1)*(n-1) + dp[i+1];
            dp[i] %= MOD;
            dp[i] += sum[i+3];
            dp[i] += i+1;
        }
        
        dp[i] %= MOD;
        sum[i] = dp[i];
        if(i<n)sum[i] += sum[i+1];
        sum[i]%=MOD;
    }

    cout << dp[1] << endl;
    return 0;
}




Measured memory_bytes: 19204
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 998244353;

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

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}


int main(){
    int n, s;
    cin >> n >> s;
    vll a(n);
    rep(i,n) cin >> a[i];
    vector<vll> dp(n+1, vll(s+1, 0));
    dp[0][0] = 1;
    rep(i,n){
        rep(j, s+1){
            dp[i+1][j] += 2*dp[i][j];
            if(j-a[i] >= 0) dp[i+1][j] += dp[i][j-a[i]];
            dp[i+1][j] %= mod;
        }
    }

    cout << dp[n][s]%mod << endl;
}



Measured memory_bytes: 73708
let N = stdin.ReadLine()
let a = stdin.ReadLine().Split() |> Array.map int

a
|> Array.mapi (fun i x -> (i + 1, x))
|> Array.filter (fun y -> fst y % 2 <> 0 && snd y % 2 <> 0)
|> Array.length
|> stdout.WriteLine


Measured memory_bytes: 28552
/////////////////////////////////TEST CASES////////////////////////////////////
/*
*/
/////////////////////////////////////CODE//////////////////////////////////////		
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORD(i, a, b) for (ll i = a ; i > b ; i--)
#define fastio ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PI 3.14159265
typedef long long ll;
#define vl vector<ll> 
#define IN(inp) ll inp;cin>>inp;
#define pb push_back
#define all(a) a.begin(),a.end()
#define FR(i,a) for(auto i:a)
#define what(A) cout<<#A<<" is "<<A<<endl;
ll MAX = 100000000000;
ll MOD = 1000000007;
ll dp[100010][3];
void solve()
{
	IN(n);
	vl a,b,c;
	FOR(i, 0, n)
	{
		IN(in1)IN(in2)IN(in3);
		a.pb(in1);
		b.pb(in2);
		c.push_back(in3);
	}
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	FOR(i, 1, n)
	{
		dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = c[i] + max(dp[i - 1][1], dp[i - 1][0]);
	}
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2]));
}
int main()
{
	fastio
		//freopen("input.txt", "rt", stdin);
		//freopen("output.txt", "wt", stdout);
		ll test = 1;
	//cin >> test;
	while (test--)
	{
		solve();
	}
}

Measured memory_bytes: 7924
// AOJ 2424 "かけざん" (JAG夏合宿 2012 day 2 Problem A)
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            int n = sc.nextInt();
            Set<Integer> is = new HashSet<Integer>();
            int count = 0;
            while (n >= 10) {
                count++;
                String tmp = Integer.toString(n);
                int max = 0;
                for (int j = 1; j < tmp.length(); j++) {
                    int n1 = Integer.parseInt(tmp.substring(0, j));
                    int n2 = Integer.parseInt(tmp.substring(j));
                    max = Math.max(max, n1 * n2);
                }
                n = max;
                if (!is.add(n)) {
                    count = -1;
                    break;
                }
            }
            
            System.out.println(count);
        }
    }
}

Measured memory_bytes: 23408
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int x,y;
  cin >> x >> y;
  cout << x + (y/2) << endl;
}


Measured memory_bytes: 256
/*
    Author: Nguyen Tan Bao
    Status:
    Idea:
*/
 
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x
 
using namespace std;
using ll = long long;
using ld = double;
typedef pair<ll, ll> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;
 
const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 1000;
const int MAXK = 16;
const int MAXQ = 200010;

int n, k, r, s, p, f[MAXN], g[MAXN];
string st;

int get(char ch) {
    if (ch == 'r') return p;
    if (ch == 's') return r;
    return s;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> st;
    FOR(i,0,n-1) {
        if (i < k) {
            f[i] += get(st[i]);
            g[i] = 1;
        }
        else {
            int e = i % k;
            if (st[i] == st[i-k]) {
                if (!g[e]) f[e] += get(st[i]);
                g[e] = 1-g[e];
            }
            else {
                f[e] += get(st[i]);
                g[e] = 1;
            }
        }
    }
    int res = 0;
    FOR(i,0,k-1) res += f[i];
    cout << res;
    return 0;
}


Measured memory_bytes: 1232
import sys

input = sys.stdin.readline

lis = [int(input()) for _ in range(6)]

ret = True

for i in range(6):
    for j in (range(i+1, 6)):
        if (abs(lis[i] - lis[j]) > lis[5]):
            ret = False
            break


if (ret == True):
    print('Yay!')
else:
    print(':(')


Measured memory_bytes: 2940
import sys
sys.setrecursionlimit(200000)

N=int(input())
ab=[list(map(int, input().split())) for _ in range(N-1)]
to=[[] for _ in range(N)]
color=[0 for _ in range(N-1)]
for i in range(N-1):
    a, b=ab[i]
    a-=1
    b-=1
    to[a].append([b, i])
    to[b].append([a, i])

def dfs(v, p=-1, c=-1):
    k=1
    for i in range(len(to[v])):
        u, index=to[v][i]
        if u==p:
            continue
        if k==c:
            k+=1
        color[index]=k
        dfs(u, v, k)
        k+=1

dfs(0)
print(max(color))
for i in range(N-1):
    print(color[i])

Measured memory_bytes: 127832
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define endl '\n'
int M = 1e9 + 7;
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int k, a, b;
  cin >> k >> a >> b;
  for (int i = a; i <= b; ++i)
  {
    if (i % k == 0)
    {
      cout << "OK";
      exit(0);
    }
  }
  cout << "NG";
}

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

using namespace std;

int main(){
	string x;
	int n, a, b;
	int count = 0;
	int counto = 0;
	int B = 0;
	cin>>n>>a>>b;
	cin>>x;
	for(int i = 0; i<(int)x.size(); i++){
		if(x[i]=='a'){
			if(count < a+b){
				cout<<"Yes\n";
				count++;
				}
				else{
			cout<<"No\n";
			}
			}
		else if(x[i] == 'b'){
			if(count< a+b and counto< b){
				cout<<"Yes\n";
				count++;
				
				counto++;
				}
				else{
			cout<<"No\n";
			}
			}
		else{
			cout<<"No\n";
			}		
		}
		return 0;
	}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    for (int i = 0; i <= n / 4; i++) {
        int left = n - i * 4;
        if (left % 7 == 0) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii  = pair<int,int>;
const int INF=1001001001;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}    //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);}   //最小公倍数
const ll MAXN = 1001024; // b-a < MAXN, sqrt(b) < MAXN

ll fac[MAXN], finv[MAXN], inv[MAXN];

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

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAXN; i++){
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
 
// 二項係数計算
long long COM(int n, int k){
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
    ll x, y;
    cin >> x >> y;
    ll n, m;
    if((x+y)%3!=0)
        cout << 0 << endl;
    else{
        n = (2 * y - x) / 3;
        m = y - 2 * n;
        if(n<0||m<0){
            cout << 0 << endl;
        }
        else{
            //cout << "n=" << n << "  m=" << m << endl;
            COMinit();
            cout<<COM(n + m, n)<<endl;
        }
    }
}



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


int main()
{
  char s;
  cin>>s;
  switch (s) {
    case 'A':
      cout << 'T';
      break;
    case 'T':
      cout << 'A';
      break;
    case 'G':
      cout << 'C';
      break;
    case 'C':
      cout << 'G';
      break;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int n;
double p[3030];
double dp[3030][3030];

signed main() {

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

    dp[0][0] = 1.0;
    
    for(int i = 0; i < n; i++) {
        dp[i+1][0] = dp[i][0] * (1-p[i]);
        for(int j = 0; j <= i; j++) {
            dp[i+1][j+1] = dp[i][j] * p[i] + dp[i][j+1] * (1-p[i]);
        }
    }
    double ans = 0.0;
    for(int i = n/2+1; i <= n; i++)
        ans += dp[n][i];

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



Measured memory_bytes: 70272
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int n, m, ok = 0;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  vector<bool> ac(n, false);//acしたかどうか
  vector<int> ac_num(n, 0);//初めてacしたのはいつか
  rep(i, m) {
    cin >> p[i] >> s[i];
    p[i]--;
    if (s[i] == "AC" && !ac[p[i]])  {
      ok++;
      ac[p[i]] = true;
      ac_num[p[i]] = i;
    }
  }
  
  int pnt = 0;
  rep(i, m) {
    if (ac[p[i]] && i < ac_num[p[i]] && s[i] == "WA") {//ac出していて、初めのacより前でWAなら
      pnt++;
    }
  }
  printf("%d %d\n", ok, pnt);
  return 0;
}

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


ll mod = 998244353;
ll dp[301][100010];
ll dp2[301][100010];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    

    ll n;
    cin>>n;
    ll a[n],sum=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum += a[i];
    }
    dp[0][0]=1;
    dp2[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=sum-a[i];j>=0;j--){
            dp[i+1][j] += dp[i][j]*2;
            dp[i+1][j] %= mod;
            dp[i+1][j+a[i]] += dp[i][j];
            dp[i+1][j+a[i]] %= mod;

            dp2[i+1][j] += dp2[i][j];
            dp2[i+1][j]%=mod;
            dp2[i+1][j+a[i]] += dp2[i][j];
            dp2[i+1][j]%=mod;
        }
    }
    ll ans = 1;
    for(int i=0;i<n;i++){
        ans = (ans*3)%mod;
    }
    for(int i=(sum+1)/2;i<=sum;i++){
        ans += mod - dp[n][i]*3;
        ans %= mod;
    }
    if(sum%2==0){
        ans += dp2[n][sum/2]*3;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 469632
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(void){
int a,b;
int i;
scanf("%d %d",&a,&b);

for(i=1;i<=150000;i++){
    if((int)i*8/100==a&&(int)i*10/100==b){printf("%d",i);return 0;}
}
printf("-1");
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, ans, a[1000], res;

int main(){
	while (cin >> n&&n){
		res = 0;
		fill(a, a + 1000, 0);
		REP(i, n)cin >> a[i];
		cin >> ans;
		int lb = -1, ub = n;
		while (ub - lb > 1){
			/*cout << ub << " " << lb << endl;*/
			int mid = (ub + lb) / 2;
			if (a[mid] < ans){
				lb = mid;
				res++;
			}
			else if (a[mid] > ans){
				ub = mid;
				res++;
			}
			else{
				res++;
				break;
			}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 1164
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

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

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    int n, r;
    cin >> n >> r;

    if (n >=10) {
        cout << r  << "\n";
    } else {
        cout << r + 100*(10-n) << "\n";
    }
}

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

typedef long long LL;

string s;

void work(){
  cin>>s;
  if (s[s.size()-1]=='s') s=s+"es";
  else s=s+'s';
  cout<<s<<endl;
}

int main(){
  int T=1;
  for (;T--;) work();
  return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
int main(void){
	int i,j,N;
	int minj,temp,count,flg;
	scanf("%d",&N);
	int a[N];
	count=0;
	for(i=0;i<N;i++){
		scanf("%d",&a[i]);
	}

	count=0;
	for(i=0;i<N-1;i++){
		minj=i;
		flg=0;
		for(j=i;j<N;j++){
			if(a[j]<a[minj]){
				minj=j;
				flg=1;			
			}
		}
		if(flg==1){
			count++;
			temp=a[i];
			a[i]=a[minj];
			a[minj]=temp;
		}
	}
	for(i=0;i<N-1;i++){
		printf("%d ",a[i]);
	}
	printf("%d\n",a[N-1]);
	printf("%d\n",count);

	return 0;
}

Measured memory_bytes: 600
//g++ -std=c++11 -Wall -O2 -o main.exe main.cpp

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <complex>

using namespace std;

template <typename T>
void in(T &t){ //標準入力
    cin >> t;
    return;
}

template <typename T>
void sortasc(vector<T> &v){ //vectorを昇順にソート
    sort(v.begin(), v.end(), std::greater<int>());
    return;
}

template <typename T>
void sortdesc(vector<T> &v){ //vectorを降順にソート
    sort(v.begin(), v.end(), std::less<int>());
    return;
}

int main(){
    string s, t;

    cin >> s >> t;

    for(int i = 0; i < (int)s.length(); i++){
        if(s == t){
            printf("Yes\n");
            return 0;
        }
        else{
            s = s[s.length() - 1] + s.substr(0, s.length() - 1);
        }
    }

    printf("No\n");
    return 0;
}


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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<int> maxByMatches(8, -1);
    vector<int> numAndMatches{-1, 2, 5, 5, 4, 5, 6, 3, 7, 6};
    for (int i = 0; i < M; i++)
    {
        int A;
        cin >> A;
        maxByMatches.at(numAndMatches.at(A)) = max(maxByMatches.at(numAndMatches.at(A)), A);
    }
    vector<int> dp(N + 7, -1);
    dp.at(0) = 0;
    for (int i = 0; i < N; i++)
    {
        if (dp.at(i) == -1)
        {
            continue;
        }
        for (int j = 2; j <= 7; j++)
        {
            if (maxByMatches.at(j) == -1)
            {
                continue;
            }
            dp.at(i + j) = max(dp.at(i + j), dp.at(i) + 1);
        }
    }
    vector<int> answers;
    int currentKeta = dp.at(N);
    int remainMatches = N;
    for (int i = 0; i < N; i++)
    {
        int maxNum = 0;
        int matchNum;
        for (int j = 2; j <= 7; j++)
        {
            if (remainMatches - j >= 0 && dp.at(remainMatches - j) == currentKeta - 1 && maxNum < maxByMatches.at(j))
            {
                matchNum = j;
                maxNum = maxByMatches.at(j);
            }
        }
        answers.push_back(maxNum);
        remainMatches -= matchNum;
        if (remainMatches == 0)
        {
            break;
        }
        currentKeta--;
    }
    for (int i = 0; i < answers.size(); i++)
    {
        cout << answers.at(i);
    }
    cout << endl;
    return 0;
}


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

int main()
{
	string s;
	cin >> s;
	int t = 0;
	for(int i = 0; i < s.length()/2; i++){
		if(s[i] != s[s.length() - i - 1])
			t++;
	}
	cout << t << endl;
 } 

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

char s[15];
int n,x,y,z,ans;

signed main(){
	read(n);
	for(int i=1;i<=n;i++){
		scanf("%s",s+1);
		if(s[1]=='B') y++;
		if(s[strlen(s+1)]=='A') x++;
		if(s[1]=='B'&&s[strlen(s+1)]=='A') z++;
		for(int i=2;s[i];i++) if(s[i-1]=='A'&&s[i]=='B') ans++;
	}
	x-=z;y-=z;
	if(z) ans+=z-1;
	if(x&&z) x--,ans++;
	if(y&&z) y--,ans++;
	ans+=min(x,y);
	write(ans);
}

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    ll N, K, S; cin >> N >> K >> S;
    vector<ll> A(N, S);
    rep(i, N-K) {
       if (S != 1) A[i] = S-1;
       else A[i] = S + 10;
    }
    rep(i, N) cout << A[i] << ' ';
    cout << endl;
}

Measured memory_bytes: 2176
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read 
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines 
MOD = 10**9+7

S = inpS()
N = len(S)
dp = [[0]*13 for _ in range(N+1)]
dp[0][0] = 1

mul = 1
for n in range(N):
    s = S[-(n+1)] # 後方から
    if s == "?":
        for i in range(10):
            for mo in range(13):
                ind = (i * mul + mo) % 13
                dp[n+1][ind] += dp[n][mo]
                dp[n+1][ind] %= MOD
    else:
        i = int(S[-(n+1)])
        for mo in range(13):
            ind = (i * mul + mo) % 13
            dp[n+1][ind] += dp[n][mo]
            dp[n+1][ind] %= MOD
    mul *= 10
    mul %= 13

print(dp[N][5])

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

int main()
{
  int A, B;
  cin >> A >> B;
  int result = 0;
  for (int i = A; i <= B; i++)
  {
    string s = to_string(i);
    bool isPalindromic = true;
    for (int j = 0; j < s.length() / 2; j++)
    {
      if (s[j] != s[s.length() - j - 1])
      {
        isPalindromic = false;
        break;
      }
    }
    if (isPalindromic)
    {
      result++;
    }
  }
  cout << result << endl;
}

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

using namespace std;
int sum=0,n,a,b,ans=0,temp;

int main(){
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++){
        sum=0;
        int k=i;
        while(k>9){
            temp=k%10;
            k=k/10;
            sum=sum+temp;
        }
        sum=sum+k;
       //cout<<sum<<endl;
        if(sum>=a && sum<=b){
            ans=ans+i;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
import bisect

# from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]

    return outputDataList


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = int(input())

d = []
d.append(1)
d.append(1)
for i in range(2,n+1):
    d.append(d[i-1]+d[i-2])

print(d[n])






Measured memory_bytes: 6896