akhauriyash/Code-Regression huggingface dataset:
n,y = gets.split(' ').map(&:to_i)
y = y/1000
ans = '-1 -1 -1'

for c in 0..y
key = 10 * n - y - 9 * c
	if key % 5 == 0
		b = key / 5
		a = n - b - c
		if b >= 0 && a >= 0
			ans = "#{a} #{b} #{c}"
			break
		end
	end
end
puts ans


Measured memory_bytes: 1788
#include <stdio.h>
typedef long long int ll;
int gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
int main() {
	ll a, b;
	scanf("%lld %lld", &a, &b);
	if (a>=b) {
        ll t=gcd(a, b);
        if(t==b) {printf("-1"); return 0;}
    }
    ll mul=2;
	while (1) {
		if (((a*mul)%b) != 0) {
			printf("%lld", a*mul);
			return 0;
		}
		mul+=1;
	}
}


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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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);

  string s;
  cin >> s;
  int n = sz(s);
  vii p(26);
  rep(i,n) p[s[i]-'a'].push_back(i+1);
  rep(i,26) {
    int m = sz(p[i]);
    rep(j,m-1) {
      if(p[i][j+1]-p[i][j] <= 2) {
        cout << p[i][j] << ' ' << p[i][j+1] << endl;
        return 0;
      }
    }
  }
  cout << -1 << ' ' << -1 << endl;
}

Measured memory_bytes: 1104
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>


using namespace std;

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

  //aとbの最小公倍数を求める
  long long p = a, q = b;
  if ( p < q ) swap( p, q);
  
  while ( true )
  {
    long long yo = p % q;
    if ( yo == 0 ) 
    {
      //最大公約数は q
      cout << (a * b) / q;
      return 0;
    }
    p = q;
    q = yo;
  }
  return 0;
}


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

int main() {

    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;

    if (W >= V) {
        cout << "NO" << endl;
    }
    else {
        ll diff;
        if (A > B) diff = A - B;
        else diff = B - A;
        if (diff <= T * (V - W)) {
            cout << "YES" << endl;
        }
        else {
            cout << "NO" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3624
# coding: utf-8

num = int(input())
if num >= 64:
    print(64)
elif num >= 32:
    print(32)
elif num >= 16:
    print(16)
elif num >= 8:
    print(8)
elif num >= 4:
    print(4)
elif num >= 2:
    print(2)
elif num == 1:
    print(1)

Measured memory_bytes: 9028
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n;
    cin >> n;
    int k = 0;
    int a[2] = {};
    int cnt[2] = {};
    for (int i = 0; i < n; ++i) {
        int b;
        cin >> b;

        if (b != a[0] && b != a[1]) {
            if (k == 2) {
                cout << "No" << endl;
                return 0;
            } else {
                a[k++] = b;
            }
        }

        if (b == a[0]) {
            ++cnt[0];
        } else {
            ++cnt[1];
        }
    }

    if (k == 1) {
        cout << (2 * a[0] <= n || a[0] == n - 1 ? "Yes" : "No") << endl;
    } else {
        if (a[0] > a[1]) {
            swap(a[0], a[1]);
            swap(cnt[0], cnt[1]);
        }
        if (a[1] - a[0] > 1 || cnt[1] == 1) {
            cout << "No" << endl;
            return 0;
        }

        cout << (cnt[0] <= a[0] && a[1] <= cnt[0] + cnt[1] / 2 ? "Yes" : "No") << endl;
    }
    return 0;
}

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

int main() {

    string S;
    cin >> S;
    int A = 0, B = 0, C = 0;

    for(int i = 0; i < S.size(); i++){
        if(S.at(i) == 'a'){
            A++;
        }else if(S.at(i) == 'b'){
            B++;
        }else{
            C++;
        }
    }

    if(A-2 >= B || B-2 >= A){
        cout << "NO" << endl;
    }else if(B-2 >= C || C-2 >= B){
        cout << "NO" << endl;
    }else if(A-2 >= C || C-2 >= A){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};


void solve() {
  int n;
  cin >> n;
  vector<ll> v(n);
  rep(i,n) cin >> v[i];
  ll ans = 0;
  rep(i,n) ans += v[i] - 1;
  cout << ans << endl;
}

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

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    s += t[t.size()-1];
    cout << (s==t?"Yes":"No");
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b;
    scanf("%d %d", &a, &b);
    
    int d = a/b;
    int r = a%b;
    double f = (double)a/(double)b;
    
    printf("%d %d %lf\n", d, r, f);
    return 0;
}



Measured memory_bytes: 2096
#include <iostream>
#include <iomanip>
#include <vector>
#include <bits/stdc++.h>
#include <math.h>
#include <stack>
#define pb push_back
// #define pop pop_back
#define ll long long int
#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rep2(i, a, b) for (ll i = a; i <= b; i++)
#define repr(i, a, b) for (ll i = a; i >= b; i--)
#define I long_max
#define pii pair<int, int>
#define pll pair<long, long>
#define vpair vector<pair<int, int>>
#define mp make_pair
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define fir first
#define sec second
#define d (int)1e9 + 7
#define INF (int)2e9 + 1
#define el "\n"
#define fs fastscan

#define vrep(vec) for (const auto &value : vec)
#define arep(arrat) for (const auto &value : array)
using namespace std;

bool sortinrev(const pair<int, int> &a,
               const pair<int, int> &b)
{
    return (a.first > b.first);
}
void swap(int *a, int *b)
{
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}

//over

bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;

    // This is checked so that we can skip
    // middle five numbers in below loop
    if (n % 2 == 0 || n % 3 == 0)
        return false;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;

    return true;
}

ll dfs(ll n, vector<vector<ll>> &adj, vector<ll> &dp)
{
    for (ll j = 0; j < adj[n].size(); j++)
    {
        if (dp[adj[n][j]] == -1)
        {
            if (dp[n] == -1)
            {
                dp[n] = 0;
            }
            dp[n] = max(dp[n], 1 + dfs(adj[n][j], adj, dp));
        }
        else
        {
            if (dp[n] == -1)
            {
                dp[n] = 0;
            }
            dp[n] = max(dp[n], 1 + dp[adj[n][j]]);
        }
    }
    if (dp[n] == -1)
    {
        return dp[n] = 0;
    }
    return dp[n];
}


int main()
{
    std::ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //use auto instead of data types
    {
        ll n;
        cin >> n;
        vector<double> a(n);
        rep(i, n)
        {
            cin >> a[i];
        }
        int mid = (n - 1) / 2;
        vector<vector<double>> dp(n+1, vector<double>(mid+1, 1));
        for(int i = 1;i<=n;i++){
            for(int j = 0;j<mid+1;j++){
                dp[i][j] = a[i-1]*dp[i-1][j] + (1-a[i-1])*dp[i-1][j-1];
            }
        }
        double sum = 0;
        // rep(i,mid+1){
        //     sum += dp[n][i];
        // }
        cout<<fixed<<setprecision(10)<<dp[n][mid]<<endl;;
    }
    return 0;
}

Measured memory_bytes: 38652
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;

struct UnionFind{
    vector<lint> g; 
    vector<lint> p; 

    UnionFind(int n):g(n),p(n){
        init(n);
    }
    void init(int n){
        REP(i,n) {g[i] = i; p[i] = 1;}
    }
    int root(int x){
        if(g[x] == x) return x;
        else return g[x] = root(g[x]);
    }
    bool unite(int x,int y){
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(p[x] < p[y]) swap(x,y);
        p[x] += p[y];
        g[y] = x;
        return true;
        
    }
    int len(int x){
        return p[root(x)];
    }
    bool same(int x,int y){
        return root(x) == root(y);
    }
};
int main(){
    int m,n;
    cin >> n >> m;
    UnionFind tree(n);
    int mx = 0;
    REP(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        tree.unite(a,b);
    }
    REP(i,n){
        CMAX(mx,tree.len(i));
    }
    println(mx);
    return 0;
}

Measured memory_bytes: 6408
from collections import deque
k = int(input())
if k < 10:
  print(k)
else:
  queue = deque([[1,1],[2,2],[3,3],[4,4],[5,5],[6,6],[7,7],[8,8],[9,9]])
  n = 9
  while n!=k:
    num,last_n = queue.popleft()
    if last_n-1 > -1:
      new_n = num*10+(last_n-1)
      queue.append([new_n,last_n-1])
      n += 1
    if n >= k:
      ans,_ = queue[-1]
      print(ans)
      break
    new_n = num*10+(last_n)
    queue.append([new_n,last_n])
    n += 1
    if n >= k:
      ans,_ = queue[-1]
      print(ans)
      break
    if last_n+1 < 10:
      new_n = num*10+(last_n+1)
      queue.append([new_n,last_n+1])
      n += 1
    if n >= k:
      ans, _ = queue[-1]
      print(ans)
      break
    
    
      

Measured memory_bytes: 12404
#include<iostream>
using namespace std;
int main()
{
	int N;
	cin>>N;
	int P=N%10;
	if(P==3)
	{
		cout<<"bon";
	}
	if(P==0||P==1||P==6||P==8)
	{
		cout<<"pon";
	}
	if(P==2||P==4||P==5||P==7||P==9)
	{
		cout<<"hon";
	}
}

Measured memory_bytes: 3544
#include<bits/stdc++.h>
using namespace std;
int main(){
    int sx,sy,tx,ty;
    cin>>sx>>sy>>tx>>ty;
    string ans;
    ans+=string(tx-sx,'R');
    ans+=string(ty-sy,'U');
    ans+=string(tx-sx,'L');
    ans+=string(ty-sy,'D');
    ans+=string("DR");
    ans+=string(tx-sx,'R');
    ans+=string(ty-sy,'U');
    ans+=string("ULUL");
    ans+=string(tx-sx,'L');
    ans+=string(ty-sy,'D');
    ans+=string("DR");
    cout<<ans<<endl;
    

    return 0;
}

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

int main(){
    int k, s; cin >> k >> s;
    int ans = 0;
    for(int i=0; i<=k; i++){
        for(int j=0; j<=k; j++){
            if(s-i-j<=k && s-i-j>=0) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int N; cin >> N;
    string s; cin >> s;
    vector<int> W(N, 0), E(N, 0);
    for (int i = 0; i < N; i++)
    {
        if(s[i] == 'W') W[i]++;
        else E[i]++;
    }

    for (int i = 0; i < N; i++)
    {
        if(i > 0){
            W[i] += W[i-1];
            E[i] += E[i-1];
        }
    }

    int ans = min(E[N-1] - E[0], W[N-2]);
    for (int i = 1; i < N-1; i++)
    {
        if(ans > W[i-1] + E[N-1] - E[i]) ans = W[i-1] + E[N-1] - E[i];
    }
    cout << ans << endl;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX;
//const int INF = INT_MAX  ;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

const int mod = 1000000007;

//< ave , a(time), b(manzoku) >
typedef tuple<double, int, int> A;

int gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    if (y == 0) {
        return x;
    }
    return gcd(y, x % y);
}

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

    if (a == b) {
        cout << 2 * a << endl;
        return 0;
    } else {
        if (b > a) {
            swap(a, b);
        }
        cout << a + (a - 1) << endl;
    }

}



Measured memory_bytes: 256
_, _, x, y = map(int, input().split())
x_cities = map(int, input().split())
y_cities = map(int, input().split())

max_x, min_y = max(x_cities), min(y_cities)
if max_x < min_y and x < min_y < y:
  print("No War")
else:
  print("War")

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

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

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	puts((a <= 8 && b <= 8) ? "Yay!" : ":(");

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

using namespace std;

typedef unsigned long long ull;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pii;

const int MAXN = 150;
const int MAXW = 1e5 + 5;
const int MOD = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

int add(int x, int y) { return ((x % MOD)  + (y % MOD)) % MOD;             }
int mul(int x, int y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;   }
int sub(int x, int y) { return add(x, -y + MOD);                           }

ll n, W, w[MAXN], v[MAXN];

ll dp[MAXN][MAXW];

ll solve(ll x, ll curW) {
	if(curW < 0) return -INF;
	if(x == 0 || curW == 0) return 0;
	if(dp[x][curW] != -1) return dp[x][curW];
	return dp[x][curW] = max(v[x] + solve(x - 1, curW - w[x]), solve(x - 1, curW));
}

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

	cin >> n >> W;

	memset(dp, -1, sizeof dp);

	for(int i = 1 ; i <= n ; ++i) {
		cin >> w[i] >> v[i];
	}

	cout << solve(n, W) << endl;



	return 0;
}




Measured memory_bytes: 117504
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
int X[200010];
int R[200010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    
    rep(i, N) cin >> X[i];
    
    rep(i, N) R[i] = X[i];
    sort(R, R + N);
    rep(i, N) {
        if (X[i] > R[(N - 1) / 2]) cout << R[(N - 1) / 2] << endl;
        else cout << R[N/2] << endl;
    }

    return 0;
}


Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ0014
{
    class Program
    {
        static void Main()
        {
            var sums = from dx in ReadInput()
                       select (from i in Enumerable.Range(0, 600 / dx)
                               select i*dx*i*dx*dx)
                           .Sum();

            foreach (var sum in sums)
            {
                Console.WriteLine(sum);
            }
        }

        public static IEnumerable<int> ReadInput()
        {
            string line;
            while ((line = Console.ReadLine()) != null)
            {
                yield return int.Parse(line);
            }
        }
    }
}

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

using namespace std;

int L, A, B, C, D;

int main() {
	int sum;

	cin >> L >> A >> B >> C >> D;
	sum = max(A / C + (A%C == 0 ? 0 : 1), B / D + (B%D == 0 ? 0 : 1));
	cout << L - sum << endl;

	return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define fi first
#define se second
#define sz(a) int(a.size())
#define clr(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
const int inf=1e9;
const ll Inf=1e18;
const int mod=1e9+7;
template<typename T=int>
T gi() {
	T x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}
template<typename T> bool chkmax(T &a,T b) { return a<b?a=b,1:0; };
template<typename T> bool chkmin(T &a,T b) { return a>b?a=b,1:0; };
int add(int a,int b) { return a+b>=mod?a+b-mod:a+b; }
int sub(int a,int b) { return a-b<0?a-b+mod:a-b; }
void inc(int &a,int b) { a=(a+b>=mod?a+b-mod:a+b); }
void dec(int &a,int b) { a=(a-b<0?a-b+mod:a-b); }
string to_string(string s) { return '"'+s+'"'; }
string to_string(const char *s) { return to_string((string)s); }
string to_string(bool b) { return (b?"true":"false"); }
template<typename A,typename B> string to_string(pair<A,B> p) {
	return "("+to_string(p.fi)+","+to_string(p.se)+")";
}
template<typename T> string to_string(T v) {
	int fst=1;string ret="{";
	for(auto x:v) {
		if(!fst) ret+=",";
		fst=0,ret+=to_string(x);
	}
	ret+="}";return ret;
}
void dbg_out() { cerr<<endl; }
template<typename Head,typename... Tail> void dbg_out(Head H,Tail... T) {
	cerr<<" "<<to_string(H);
	dbg_out(T...);
}
#define dbg(...) cerr<<"{"<<#__VA_ARGS__<<"}:",dbg_out(__VA_ARGS__)

template<typename T>
int qpow(int a,T b) {
	int ret=1;
	while(b) {
		if(b&1) ret=1ll*ret*a%mod;
		a=1ll*a*a%mod,b>>=1;
	}
	return ret;
}

const int N=2e5+10;

int n,c[N],f[N],s[N];

int main() {
	n=gi();
	for(int i=1;i<=n;i++) c[i]=gi();
	f[0]=1;
	for(int i=1;i<=n;i++) {
		if(c[i]!=c[i-1]) inc(s[c[i]],f[i-1]);
		f[i]=s[c[i]];
	}
	printf("%d\n",f[n]);
	return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>

int step(int number) {
  int ans = 1;
  for (int i = 2; i <= number; i++) {
    ans *= i;
  }
  return ans;
}

int main(void) {

  int n,m,r;
  scanf("%d %d %d", &n, &m, &r);
  int sr[r+1];
  for (int i = 1; i <= r; i++) {
    scanf("%d", &sr[i]);
  }
  long list[n+1][n+1];
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      list[i][j] = -1;
    }
  }
  int a,b;
  for (int i = 0; i < m; i++) {
    scanf("%d %d", &a, &b);
    scanf("%ld", &list[a][b]);
    list[b][a] = list[a][b];
  }

  int flag;
  while (1) {
    flag = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        for (int k = 1; k <= n; k++) {
          if (list[i][k] != -1 && list[k][j] != -1) {
            if (list[i][j] == -1 || list[i][k]+list[k][j] < list[i][j]) {
              list[i][j] = list[i][k]+list[k][j];
              flag = 1;
            }
          }
        }
      }
    }
    if (flag == 0) {
      break;
    }
  }

  int permutation[r];
  for (int i = 0; i < r; i++) {
    permutation[i] = i+1;
  }
  int check[r+1];
  for (int i = 1; i <= r; i++) {
    check[i] = 1;
  }
  int step_r = step(r);
  long distance;
  long min = -1;
  for (int operation = 1; operation <= step_r; operation++) {
    distance = 0;
    for (int i = 1; i < r; i++) {
      if (list[sr[permutation[i-1]]][sr[permutation[i]]] == -1) {
        distance = -1;
        break;
      }
      distance += list[sr[permutation[i-1]]][sr[permutation[i]]];
    }
    if (distance != -1) {
      if (min == -1 || distance < min) {
        min = distance;
      }
    }
    if (operation == step_r) {
      break;
    }
    for (int i = r-1; i > 0; i--) {
    	check[permutation[i]] = 0;
    	if (permutation[i] > permutation[i-1]) {
    		check[permutation[i-1]] = 0;
    		for (int j = permutation[i-1]+1; j <= r; j++) {
    			if (check[j] == 0) {
    				check[j] = 1;
    				permutation[i-1] = j;
    				break;
    			}
    		}
    		for (int j = i; j < r; j++) {
    			for (int k = 1; k <= r; k++) {
    				if (check[k] == 0) {
    					check[k] = 1;
    					permutation[j] = k;
    					break;
    				}
    			}
    		}
    		break;
    	}
    }
  }
  printf("%ld\n", min);

  return 0;
}

Measured memory_bytes: 640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>


using namespace std;
//typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

class BTrickOrTreat {
public:
void solve(std::istream& cin, std::ostream& cout) {
    int N,K;
    int ans = 0;
    //string ans = "";
    cin >> N >> K;
    int n = N;
    vector<int> vec;
    for(int i = 0;i < K; i++){
        int d;
        cin >> d;
        for(int j = 0; j < d;  j++){
            int tmp;
            cin >> tmp;
            vec.push_back(tmp);
        }
    }

    int a[n];
    for (int i = 0; i <= n; i++){ a[i] = 0; };
    for(int i = 0; i < vec.size(); i++){
        int num = vec.at(i);
        a[num - 1]++;
    }
    ans = count(a, a + N, 0);

    cout << ans << endl;
}
};


int main() {
	BTrickOrTreat solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef unsigned long long ull;
int inf_int=2e9;
ll inf_ll=1e18;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define pb push_back
const double pi=3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz size()

bool debug=0;
const int MAXN=2000;
int mod=1e9+9;


#define rank asfalgalsglasgllzxdgl

vector<pii> g[MAXN];
vector<int> ind[MAXN];
char ans[MAXN];
int d[MAXN];
void solve()
{
    int n;
    cin >> n;
    int m;
    cin >> m;
    for(int i=1;i<=m;++i)
    {
        int a,b,c;
        cin >> a>> b>> c;
        g[a].pb({b,c});
        ind[a].pb(i);
        g[b].pb({a,c});
        ind[b].pb(i);
    }
    for(int st=1;st<=n;++st)
    {
        set<pii> s;
        fill(d,d+n+2,inf_int);
        d[st]=0;
        s.insert({0,st});
        while(!s.empty())
        {
            int v=s.begin()->se; s.erase(s.begin());
            for(int i=0;i<g[v].sz;++i)
            {
                int to=g[v][i].fi;
                int len=g[v][i].se;
                if(d[to]>d[v]+len)
                {
                    s.erase({d[to],to});
                    d[to]=d[v]+len;
                    s.insert({d[to],to});

                }
            }
        }
        for(int v=1;v<=n;++v)
        {
            for(int i=0;i<g[v].sz;++i)
            {
                int to=g[v][i].fi,len=g[v][i].se,in=ind[v][i];
                if(d[v]+len==d[to])
                {
                    ans[in]=1;
                }
            }
        }
    }
    int res=0;
    for(int i=1;i<=m;++i)
    {
        if(!ans[i])
            res++;
    }
    cout << res<<"\n";
}



#define FILE "stupid_rmq"
int main()
{
        #ifdef zxc
            freopen("input.txt","r",stdin);
    //       freopen("output.txt","w",stdout);
        #endif // zxc

    //    freopen(FILE".in","r",stdin);
   //   freopen(FILE".out","w",stdout);

       if(!debug)
       {
            ios_base::sync_with_stdio(0);
            cin.tie(0);
            cout.tie(0);
       }

        int t=1;
         while(t--)
            solve();

        return 0;
}


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

int main() {
    int l,r,d; cin >> l >> r >> d;
    int res = 0;
    for(int i=l; i<=r; ++i) {
        if(i % d == 0) ++res;
    }
    cout << res << '\n';
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For(i, 0, n)
#define rrep(i, n) rFor(i, n, 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
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;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int n, m;

void solve(){
    int score[m+1];
    memset(score, 0, sizeof(score));
    rep(i, n){
        int d, v;
        scanf("%d%d", &d, &v);
        chmax(score[d], v);
    }
    printf("%d\n", accumulate(score, score+m+1, 0));
}

int main(){
    while(scanf("%d%d", &n, &m) && n){
        solve();
    }
}


Measured memory_bytes: 3212
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll a,b,m;
    cin>>a>>b>>m;
    vl one,two,disc;
    ll mini1=INT_MAX;
    ll mini2=INT_MAX;
    rep(i,a)
    {
        ll c;
        cin>>c;
        one.pb(c);
        mini1=min(mini1,c);
    }
    rep(i,b)
    {
        ll c;
        cin>>c;
        two.pb(c);
        mini2=min(mini2,c);
    }
    ll ans=mini1+mini2;
    rep(i,m)
    {
        ll x,y,c;
        cin>>x>>y>>c;
        x--,y--;
        ans=min(ans,one[x]+two[y]-c);
    }
    cout<<ans<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 14324
/// Updated! https://www.youtube.com/watch?v=U07_n9xGIlM
#include<bits/stdc++.h>

using namespace std;
#define ll long long
#define dbug printf("I am here\n");
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int maxn = 2e5+100;

const ll inf = 1e18;
ll arr[maxn];

int main()
{
    fast;
    ll a,b;
    cin >> a >> b;
    if(a<=b){
        for(int i = 1; i<=b; i++)cout << a;
    }
    else for(int i = 1; i<=a; i++)cout << b;
    return 0;
}
/*



*/



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        char[] s = sc.next().toCharArray();

        int[] num = new int[s.length+1];
        int tmp = 0;
        for (int i = 0; i < s.length; i++) {
            if (s[i] == '<') {
                tmp++;
                num[i+1] = tmp;
            } else {
                tmp = 0;
            }
        }

        tmp = 0;
        for (int i = s.length-1; i >= 0; i--) {
            if (s[i] == '>') {
                tmp++;
                num[i] = Math.max(tmp, num[i]);
            } else {
                tmp = 0;
            }
        }

        long ans = 0;
        for (int i : num)
            ans += i;

        System.out.println(ans);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

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

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 29452
#include<stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2
 
int n,i,u,v,M[MAX][MAX];
 
void dij(void);
 
int main(){
  int j,k,c;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=INFTY;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      M[u][v]=c;
    }
  }
  dij();
  return 0;
}
 
void dij(void){
  int minv;
  int d[MAX],color[MAX];
for(i=0;i<n;i++){
  d[i]=INFTY;
  color[i]=WHITE;
  }
d[0]=0;
color[0]=GRAY;
while(1){
  minv=INFTY;
  u=-1;
  for(i=0;i<n;i++){
    if(minv>d[i]&&color[i]!=BLACK){
      u=i;
      minv=d[i];
    }
  }
  if(u==-1)break;
  color[u]=BLACK;
  for(v=0;v<n;v++){
    if(color[v]!=BLACK&&M[u][v]!=INFTY){
      if(d[v]>d[u]+M[u][v]){
        d[v]=d[u]+M[u][v];
        color[v]=GRAY;
      }
    }
  }
}
for(i=0;i<n;i++){
  printf("%d %d\n",i,d[i]==INFTY?-1:d[i]);
}
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fod(i,a,b) for(int i=a;i>=b;i--)
#define me0(a) memset(a,0,sizeof(a))
#define me1(a) memset(a,-1,sizeof(a))
#define op freopen("in.txt", "r", stdin)
#define pii pair<int,int>
#define mp(x,y) make_pair(x,y)
using namespace std;
const int INF = 0x3f3f3f3f;
typedef long long LL;
void read(int& val) { int x = 0; int bz = 1; char c; for (c = getchar(); (c<'0' || c>'9') && c != '-'; c = getchar()); if (c == '-') { bz = -1; c = getchar(); }for (; c >= '0' && c <= '9'; c = getchar()) x = x * 10 + c - 48; val = x * bz; }
const int mod=998244353;
const int maxn = 1e7+7;

LL cnt[maxn];

void init(){
    fo(i,2,maxn-1){
        for(int j=i;j<maxn;j+=i){
            cnt[j]++;
        }
    }
}


int main(){
    init();

    int n;read(n);
    LL ans=0;
    fo(i,1,n){
        ans += 1LL*i*(cnt[i]+1);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 81768
n = int(input())
max_x = int(n/4) + 1
max_y = int(n/7) + 1
for x in range(max_x + 1):
    for y in range(max_y + 1):
        if (4*x + 7*y) == n:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 3060
from itertools import accumulate
def solve():
    N,M,Q = map(int,input().split())
    cnt = [[0] * (N+1) for _ in range(N+1)]

    for _ in range(M):
        l,r = map(int,input().split())
        cnt[l][r] += 1
    
    acc = []
    for i in range(N+1):
        acc.append(list(accumulate(cnt[i])))
    
    answers = []
    for _ in range(Q):
        p, q = map(int,input().split())
        ans = 0
        for l in range(p, q+1):
            ans += acc[l][q] - acc[l][p-1]
    
        answers.append(ans)

    print(*answers, sep='\n')

if __name__ == '__main__':
    solve()

Measured memory_bytes: 87872
n = input()

#print(n[0] , n[1] , n[2])
answer = 0
if n[0] =="1":
	answer = answer + 900
else:
    answer = answer + 100

if n[1] =="1":
	answer = answer + 90
else:
	answer = answer + 10

if n[2] =="1":
	answer = answer + 9
else:
	answer = answer + 1

print(answer)

Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <list>
#include <numeric>
#include <cstdio>
#include <queue>


using namespace std;

int main() {

    int N;
    cin >> N;

    vector<int> L(N);
    vector<int>::iterator itr;
    int l;
    for (int i = 0; i < N; i++) {
        scanf("%d", &l);
        L[i] = l;
    }
    
    sort(L.begin(), L.end());
    int ans = 0;

    for (int i = 0; i < N-2; i++) {
        for (int j = i+1; j < N-1; j++) {
            int tmp = L[i] + L[j];

            itr = lower_bound(L.begin(), L.end(), tmp);
            // cout << *itr << '\n';
            int idx = distance(L.begin(), itr);
            // cout << idx << '\n';
            ans += idx - j - 1;

        }
    }

    cout << ans << '\n';

}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n;
  cin >> n;
  vecint a(n), b(n);
  REP(i, n) { cin >> a[i] >> b[i]; }
  if (n % 2 == 1) {
    sort(all(a));
    sort(all(b));
    cout << b[(n + 1) / 2 - 1] - a[(n + 1) / 2 - 1] + 1 << endl;
  } else {
    sort(all(a));
    sort(all(b));
    ll x = ((ll)a[(n / 2) - 1] + (ll)a[n / 2]);
    ll y = ((ll)b[(n / 2) - 1] + (ll)b[n / 2]);
    // cout << x << " " << y << endl;
    cout << y - x + 1LL << endl;
  }
}
//////////////////////////////////////////////


Measured memory_bytes: 4784
fun main(args: Array<String>) {
    val (h, w) = readIntList()
    val s = List(h) { readString() }

    for (i in 0 until h) {
        for (j in 0 until w) {
            if (s[i][j] == '.') {
                continue
            }
            var ok = false
            if (i - 1 >= 0 && s[i - 1][j] == '#') ok = true
            if (i + 1 < h && s[i + 1][j] == '#') ok = true
            if (j - 1 >= 0 && s[i][j - 1] == '#') ok = true
            if (j + 1 < w && s[i][j + 1] == '#') ok = true
            if (!ok) {
                println("No")
                return
            }
        }
    }
    println("Yes")
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 37960
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ll long long
#define ii pair<int, int>
#define vi vector<int>
#define ld long double
#define vii vector<ii>
#define vll vector<ll>
#define maxn 111

template<typename T>
void trace(T a){ cout << a << '\n';}
template<typename T, typename... Args>
void trace(T a, Args ...args){ cout << a << ' '; trace(args...);}

ii a[maxn];
ii op = {0, 10000000};

int cross(ii a, ii b) {
	return a.fi*b.se - a.se*b.fi;
}

bool cmp (ii x, ii y) {
	return atan2(x.second, x.first) < atan2(y.second, y.first);
}

int32_t main(){
	int n,x,y;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> x >> y;
		a[i] = {x, y};
	}
	sort(a,a+n, cmp);
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		int j = i, left = n, dx = 0, dy = 0;
		while (left--) {
			dx += a[j].fi;
			dy += a[j].se;
			ans = max(ans, dx*dx + dy*dy);
			j = (j+1) % n;
		}
	}
	cout << fixed << setprecision(40) << sqrt(ans) << '\n';
 	return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int answer = 0;

        for(int i = a;i<=n;i++){
            int tmp = i;
            int tmp2 = 0;
            while(tmp >= 10){
                tmp2 += tmp%10;
                tmp = tmp/10;
            }
            tmp2 += tmp;
            if(tmp2 >= a && tmp2 <= b){
                answer += i;
            }
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 23636
#include "bits/stdc++.h"

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define int long long
#define ll long long

ll INF = (1LL << 60);
int mod = 998244353;

struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
using P = pair<int, int>;
mint dp[200010];
signed main() {
	int n, k; cin >> n >> k;
	vector<int>l(k), r(k);
	for (int i = 0; i < k; i++) {
		cin >> l[i] >> r[i];
	}
	vector<mint>sum(n + 2);
	dp[1] = 1;
	sum[0] = 0;
	for (int i = 2; i <= n; i++) {
		sum[i] = sum[i-1] + dp[i - 1];
		mint now = 0;
		for (int j = 0; j < k; j++) {
			now += sum[max(1LL, i - l[j] + 1)] - sum[max(1LL, i - r[j])];
		}
		dp[i] = now;
	}
	cout << dp[n] << endl;
	return 0;
}


Measured memory_bytes: 6380
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  //cout<<fixed<<setprecision(10);
  ll n,ans=0;
  cin>>n;
  ll t=1;
  while(n){
    ans+=t;
    n/=2;
    t*=2;
  }
  cout<<ans<<endl;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A.at(i);

  int l = 0, r = 1e9;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    auto f = [&](int x) {
      ll now = 0;
      rep(i, N) {
        now += (A.at(i) - 1) / x;
      }
      return now <= K;
    };
    if (f(mid)) r = mid;
    else l = mid;
  }
  cout << r << endl;
  return 0;
}

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

typedef long long ll;

int main() {
  int N,M; cin >> N >> M;
  int P[100001],Y[100001];
  vector<int> yd[100001];
  for ( int i = 0; i < M;i++ ) {
    cin >> P[i] >> Y[i];
    yd[P[i]].push_back(Y[i]);
  }
  for ( int i = 0; i < N; i++ )
    sort ( yd[i+1].begin(),yd[i+1].end() );

  for ( int i = 0; i < M; i++ ) {
    printf("%06d%06d\n",P[i],lower_bound(yd[P[i]].begin(),yd[P[i]].end(),Y[i])-yd[P[i]].begin()+1);
  }
  return 0;
}


Measured memory_bytes: 7808
//ysh_gpta
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
typedef long long ll;
#define vb vector<bool>
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define mkp make_pair
#define pb push_back
#define INF 1000000000000000
#define MOD 1000000007
#define ff first
#define ss second
#define FastIO ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
//ll gcd( ll a, ll b ){if(b==0) return a; else return gcd( b, a%b );}
//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}
//void printArray(vi &v){for(int i=0;i<v.size();i++) cout<<v[i]<<endl; cout<<endl; }
int main(){
   FastIO
   ll n,k;
   cin>>n>>k;
   vi dp(100005,0);
   vi v(n);
   for(int i=0;i<n;i++)
   cin>>v[i];
   for(int i=0;i<k+1;i++){
       if(dp[i])
       continue;
       for(int j=0;j<n;j++)
       if(i+v[j]<=k)
       dp[i+v[j]]=1;
   }
   if(dp[k])
   cout<<"First";
   else
   cout<<"Second";
//    for(int i=0;i<=k;i++)
//    cout<<i<<" "<<dp[i]<<endl;
   return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
  int n,i,j,count,q=0;
  scanf("%d",&n);
  int x[n+1];
  for(i=0;i<n;i++)
    scanf("%d",&x[i]);
  for(i=1;i<100;i++){
    count=0;
    for(j=0;j<n;j++)
      count+=(x[j]-i)*(x[j]-i);
    if(count<q || i==1){
      q=count;
    }
  }
  printf("%d\n",q);
  return 0;
}


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

public class Main {

    public static void main(String[] args) {
        //System.setIn(Main.class.getClassLoader().getResourceAsStream("input"));
        Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long n = sc.nextLong();
        long sol = solve(n);
        System.out.println(sol);
    }

    private static long solve(long n) {
        long racine = (int) (Math.sqrt(n) + 1);
        for(long i = racine; i >= 2; i--) {
            if(n %i == 0) return (i-1) + (n/i - 1);
        }
        return n - 1;
    }
}


Measured memory_bytes: 22608
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

//sは初めの点、vは頂点size、dは最短距離を求める(初期化はINF),Gは有向グラフ
void dijkdtra(int s, int v, vector<int>& d, whei(edge)& G) {
	priority_queue<Pint, vector<Pint>, greater<Pint>> que;//firstが距離、secondが頂点
	d[s] = 0;//スタートの距離はもちろんzero
	que.push(Pint(0, s));
	while (!que.empty()) {
		Pint p = que.top();
		que.pop();
		int V = p.second;
		if (d[V] < p.first)continue;
		for (int i = 0; i < G[V].size(); i++) {
			edge e = G[V][i];
			if (d[e.to] > d[V] + e.cost) {
				d[e.to] = d[V] + e.cost;
				que.push(Pint(d[e.to], e.to));
			}
		}
	}
}

int main() {
	int n,m=0;
	cin >> n;
	hei(int) a(n+1),b(n+1,0),ans;
	rep(i, 1,n+1)cin >> a[i];
	for (int i = n; i > 0; i--) {
		int x = 0;
		for (int j = i; j<= n; j+=i) {
			x += b[j];
		}
		if (x % 2 != a[i]) {
			b[i]++;
			m++;
			ans.push_back(i);
		}
	}
	reverse(ans);
	cout << m << endl;
	rep(i, 0, m)cout << ans[i] << endl;
	return 0;
}

Measured memory_bytes: 3064
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,a[100000],mi = INF;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	for(int j = 0;j < 2;j++){
		int ope = j * 2 - 1,sum = 0,res = 0;
		for(int i = 0;i < n;i++){
			sum += a[i];
			if(sum * ope <= 0){
				res += abs(ope - sum);
				sum = ope;
			}
			ope *= -1;
		}
		mi = min(res,mi);
	}
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
a_list = list(map(int, input().split()))
counts = [0] * 3
for a in a_list:
	if a%4 == 0:
		counts[0] += 1 		 
	elif a%2 == 0:
		counts[1] += 1
	else:
		counts[2] += 1
r = 'Yes' if counts[2] <= counts[0]+1 else 'No'
if r == 'Yes':
	two_v = counts[1]
	four_v = counts[0] - counts[2]
	mod = two_v%2	
	if mod == 0 or mod - four_v < 2:
		r = 'Yes'
	else:
		r = 'No'
print(r)

Measured memory_bytes: 62576
# https://atcoder.jp/contests/aising2019/tasks/aising2019_b

N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

f = 0
s = 0
t = 0

for p in P:
    if p <= A:
        f += 1
    elif p <= B:
        s += 1
    else:
        t += 1

print(min(f,s,t))


Measured memory_bytes: 3060