akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds; 
using namespace std;
#define int long long
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define mii map<int,int>
#define mp make_pair
#define pb push_back
#define rep(i,b) for(ll (i)=0;i<(b);i++)
#define all(c) (c).begin(), (c).end()
#define F first
#define S second
#define CLR(p) memset(p, 0, sizeof(p))
#define SET(p) memset(p, -1, sizeof(p))
#define DEBUG true
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
//typedef long long int ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
tree_order_statistics_node_update> new_data_set; 
const int MAX=1e6+5;
#define MOD 1000000007
/*std::cout << std::fixed;
std::cout << std::setprecision(6);*/
//(a%mod-b%mod+mod)%mod



/************************************


 
*************************************/

vector<vector<ll>>v;
ll T=0;
ll cnt1=0,cnt0=0;
vector<ll>dep;
bool visited[MAX];
vector<ll>par;
vector<ll>tin,tout;
vector<ll>col;
ll f=0,k=1;
map<pll,ll>m;
ll dp1[MAX],dp2[MAX];
ll red,blue;
ll ans;
ll dp[MAX];

ll lca(ll u,ll v){
	while(u!=v){
		ll l1,l2;
		l1 = log2(u);
		l2 = log2(v);
		//cout<<l1<<"$$"<<l2<<endl;
		if(l1<l2)
			swap(u,v);
		u /=2;
	}
	return u;
}

bool comp1(const pair<int,pll>&a,const pair<int,pll>&b){
	return (a.F<b.F);
}
// vector<int>r,g,b;
ll sum=INT64_MAX;

// ll s(int x,int y,int z){
// 	return ((ll)((x-y)*(x-y))+(ll)((y-z)*(y-z))+(ll)((z-x)*(z-x)));
// }




signed main(){
	boost;
	int t=1;
	// cin>>t;
	while(t--){
		int n;
		cin>>n;
		map<string,int>m;
		int cnt=0;
		string s;

		for(int i=0;i<n;i++){
			cin>>s;
			if(m[s]==0)
				cnt++;
			m[s]++;
		}
		cout<<cnt<<endl;

	}

	return 0;
}

Measured memory_bytes: 19236
#include <iostream>

using namespace std;
using ll = long long;

int main() {
  ll N, A, B, ans;
  cin >> N >> A >> B;
  ans = abs(A-B)/2;
  if ((A-B)%2) {
    ans += min(min(A,B), min(N-A,N-B)+1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
R = list()
n = int(input().rstrip())
for i in range(n):
    R.append(int(input().rstrip()))
maxv = R[1] - R[0]
minv = R[0]
for i in range(len(R) - 1):
    maxv = max(R[i + 1] - minv, maxv)
    minv = min(minv,R[i + 1])
print(maxv)


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

using namespace std;

struct node
{
	string s;
	int a;
	int id;
}b[105];
int cmp(node a, node b)
{
	if(a.s == b.s)
		return a.a > b.a;
	return a.s < b.s;
}
int main()
{
	int n, c[105];
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> b[i].s >> b[i].a;
		b[i].id = i + 1;
	}
	sort(b, b + n, cmp);
	for(int i = 0; i < n; i++)
		cout << b[i].id << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
// #include <numeric> // gcdとかlcmとか C++17から
#include <time.h> // time_t timer; time(&timer); でtimerに現在時刻が代入される．
#include <unistd.h> // sleep関数．引数は秒単位．
using namespace std;

typedef long long ll;

ll my_gcd(ll a, ll b){
	return (b==0) ? a : my_gcd(b, a%b);
}

ll my_lcm(ll a, ll b){
	return a*b / my_gcd(a,b);
}

ll factorial(ll a){
	ll ans = 1;
	for(ll i=a; i>0; i--){
		ans *= i;
	}
	return ans;
}

ll pow(ll a, ll b) {
	ll a_powered = 1;
	for (int i=0; i<b; i++) { a_powered *= a;
	}
	return a_powered;
}


int main(int argc, char *argv[]){
	ll C = 1000000000 + 7;
	ll N, K;
	cin >> N >> K;
	
	ll A[N];
	for (int i=0; i<N; i++){
		cin >> A[i];
	}

	ll ans = 0;

	ll inversion_num_A = 0;
	for(int i=0; i<N; i++){
		ll x = 0;
		for(int j=0; j<i; j++){
			if(A[j] > A[i]){
				x++;
			}
		}
		inversion_num_A += x;
	}

	ans += inversion_num_A * K;

	sort(A, A+N);
	ll count[2001] = {0};
	for(int i=0; i<N; i++){
		if(A[i] == A[N-1]) break;
		count[A[i]] = N-i-1;
	}

	ll sum_count = 0;
	for(int i=0; i<N; i++){
		sum_count += count[A[i]];
	}

	ll K_seriesed = K*(K-1)/2;

	K_seriesed %= C;
	ans += sum_count * K_seriesed;
	ans %= C;

	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}

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

  string s,t;
  cin>>s>>t;
  int n=s.size(),m=t.size();
  rep(i,n-m+1){
    bool flag=true;
    rep(j,t.size()){
      flag&=(s[i+j]==t[j]);
    }
    if(flag) cout<<i<<endl;
  }



}


Measured memory_bytes: 3216
N = gets.to_i

if  N < 10
	puts N
elsif  N/10 < 10
	puts 9
elsif  N/100 <  10
	puts 9 + N- 99
elsif  N/1000  <  10
	puts  9 + 900
elsif  N/10000  <  10
	puts  909 + N - 9999
else
	puts  90909
end

Measured memory_bytes: 1788
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
func modComb(big, small, mod int) int {
	if big < 0 || small < 0 || big < small {
		return 0
	}
	tmp := modFact(big, mod) * modInv(modFact(small, mod), mod) % mod
	return tmp * modInv(modFact(big-small, mod), mod) % mod
}

func modFact(a, mod int) int {
	res := 1
	for i := a; i > 0; i-- {
		res *= i
		res %= mod
	}
	return res
}

func modInv(a, mod int) int {
	b := mod
	u := 1
	v := 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= mod
	if u < 0 {
		u += mod
	}
	return u
}

const MAX = int(1e+6)
const MOD = int(1e+9) + 7

var fac [MAX]int
var finv [MAX]int
var inv [MAX]int

func COMinit() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1
	for i := 2; i < MAX; 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
	}
}

func COM(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N, K := sc.nextInt(), sc.nextInt()
	A := sc.nextIntSlice(N)
	sort.Ints(A)
	COMinit()
	mx, mn := 0, 0
	for i := 0; i <= N-K; i++ {
		//mn += A[i] * modComb(N-1-i, K-1, mod)
		mn += A[i] * COM(N-1-i, K-1)
		mn %= MOD
	}
	for i := K - 1; i < N; i++ {
		//mx += A[i] * modComb(i, K-1, mod)
		mx += A[i] * COM(i, K-1)
		mx %= MOD
	}
	ans := mx - mn
	ans %= MOD
	if ans < 0 {
		ans += MOD
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


Measured memory_bytes: 26496
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m,si,ci,ans;ans=0;
    scanf("%d%d",&n,&m);
    unordered_map<int,int> mp;
    int num[n+1];
    for(int i=1;i<=n;i++)num[i]=10;
    if (m==0&&n==1){
        printf("0\n");
        return 0;
    }
    for(int i=0;i<m;i++){
        cin >> si >> ci;
        if(mp.find(si)!=mp.end()&&mp[si]!=ci)ans=-1;
        mp[si]=ci;
        if(si==1&&ci==0&&n>=2) ans=-1;
        num[si] = ci;
    }
    if (ans==-1) {
        printf("%d\n", ans);
        return 0;
    }
    for(int i=1;i<=n;i++){
        if(num[i]==10){
            if(i==1)num[i]=1;
            else num[i]=0;
        }
        ans+=num[i]*pow(10,n-i);
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 4004
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double eps = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+17 + 10;

int n, m, l, k, a, h;
std::vector<P> g[105]; //to,time
int cost[105][105];
bool isCold[105];

int main() {
	while (true) {
		std::cin >> n >> m >> l >> k >> a >> h;
		if (n + m + l + k + a + h == 0)break;
		rep(i, 105)g[i].clear(), isCold[i] = false;

		rep(i, l) {
			int x;
			std::cin >> x;
			isCold[x] = true;
		}
		rep(i, k) {
			int x, y, t;
			std::cin >> x >> y >> t;
			g[x].push_back(P(y, t));
			g[y].push_back(P(x, t));
		}

		rep(i, 105)rep(j, 105)cost[i][j] = infi;
		cost[a][m] = 0;

		//PP: cost, (time, n)
		std::priority_queue<PP, std::vector<PP>, std::greater<PP> > que;
		que.push(PP(0, P(m, a)));
		while (!que.empty()) {
			PP pp = que.top();
			que.pop();
			int vv = pp.second.second, vm = pp.second.first;
			if (cost[vv][vm] < pp.first)continue;

			if (isCold[vv]) {
				rep(i, m - vm) {
					int nvm = vm + i + 1;
					if (cost[vv][nvm] > cost[vv][vm] + i + 1) {
						cost[vv][nvm] = cost[vv][vm] + i + 1;
						que.push(PP(cost[vv][nvm], P(nvm, vv)));
					}
				}
			}
			rep(i, g[vv].size()) {
				P e = g[vv][i];
				int tt = vm - e.second;
				if (tt >= 0 && cost[e.first][tt] > cost[vv][vm] + e.second) {
					cost[e.first][tt] = cost[vv][vm] + e.second;
					que.push(PP(cost[e.first][tt], P(tt, e.first)));
				}
			}
		}

		int min = infi;
		rep(i, m + 1)min = std::min(min, cost[h][i]);
		if (min == infi)std::cout << "Help!" << std::endl;
		else std::cout << min << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1480
MOD = 10 ** 9 + 7
N = int(input())
S1 = input().strip()
S2 = input().strip()
compress = []
before = 0
for i in range(N):
    if before == 2:
        before = 0
        continue
    if S1[i] == S2[i]:
        compress.append(1)
        before = 1
    else:
        compress.append(2)
        before = 2

if compress[0] == 1:
    ans = 3
else:
    ans = 6
for i in range(1, len(compress)):
    if compress[i - 1] == 1 and compress[i] == 1:
        ans *= 2
    if compress[i - 1] == 1 and compress[i] == 2:
        ans *= 2
    if compress[i - 1] == 2 and compress[i] == 1:
        ans *= 1
    if compress[i - 1] == 2 and compress[i] == 2:
        ans *= 3

print(ans % MOD)


Measured memory_bytes: 3064
#[allow(unused_imports)]
use std::cmp::{max, min};
use std::io::{stdin, stdout, BufWriter, Write};

#[derive(Default)]
struct Scanner {
    buffer: Vec<String>,
}

impl Scanner {
    fn next<T: std::str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buffer.pop() {
                return token.parse().ok().expect("Failed parse");
            }
            let mut input = String::new();
            stdin().read_line(&mut input).expect("Failed read");
            self.buffer = input.split_whitespace().rev().map(String::from).collect();
        }
    }
}

fn bsearch(w: &[i32], k: i32, l: i32, r: i32) -> i32 {
    let m = (l + r) / 2;
    if l == m {
        if can_load(w, k, l) {
            return l;
        } else {
            return r;
        }
    }
    if can_load(w, k, m) {
        bsearch(w, k, l, m)
    } else {
        bsearch(w, k, m, r)
    }
}

fn can_load(w: &[i32], k: i32, p: i32) -> bool {
    let mut i = 0;
    for _ in 0..k {
        let mut load = 0;
        while i < w.len() {
            if load + w[i] > p {
                break;
            }
            load += w[i];
            i += 1;
        }
    }
    i == w.len()
}

fn main() {
    let mut scan = Scanner::default();
    let out = &mut BufWriter::new(stdout());
    let n = scan.next();
    let k = scan.next();
    let mut w = vec![0; n];
    for i in 0..n {
        w[i] = scan.next();
    }

    writeln!(out, "{}", bsearch(&w[..], k, 0, 10_000 * 100_000)).ok();
}



Measured memory_bytes: 5048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi; 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
const int mod = 1e9+7;
const int maxn = 2e5+10;
const int inf = 0x3f3f3f3f;
ll book[maxn],sum;
int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	ll a,b;
	cin>>a>>b;
	a%=b;
	cout<<min(a,b-a)<<'\n';
	return 0;
}


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

int main(){
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if(x+r <= W && y+r <= H && x >= r && y >= r ){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

}



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

int main()
{
  string number;
  bool judge = false;

  cin >> number;

  int n = number.length();

  for (int i = 0; i < n; i++)
  {
    if (number[i] == '7')
    {
      judge = true;
    }
  }

  if (judge)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

  return 0;
}

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

int main(){
    ll k;
    cin >> k;
    vector<ll> a(k);
    for(int i = 0;i < k;i ++){
        cin >> a[i];
    }

    bool isPossible = true;
    ll minN=a[k-1],maxN=2*a[k-1]-1;
    if(minN!=2||maxN!=3) isPossible = false;
    
    for (int i = k-2;i >= 0;i --){
        if(minN/a[i]==maxN/a[i]&&minN%a[i]) {isPossible=false;break;}
        minN = minN%a[i]?(minN/a[i]+1)*a[i]:minN;
        maxN = maxN/a[i]*a[i];
        maxN += a[i]-1;
    }
    if(isPossible) cout << minN << " " << maxN << endl;
    else cout << -1 << endl;
    return 0;
}

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

int main()
{
    ll n;
    cin>>n;
    if( n%2 == 1)
    {
        cout<<0<<endl;
    } else
    {
       ll ans =0;
       ll curr = 10;
       while( n/curr )
       {
           ans += ( n/curr);
           curr = curr * 5;
       }
       cout<<ans;
    }
}

Measured memory_bytes: 3604
#include<iostream>                    
using namespace std;
int main(){
 
  int n,a[10000],i,s(1000000),b(-1000000);
  long long w=0;
  cin>>n;
  for(int i=0;i<n; i++)
  {
         cin>>a[i];
 
           w+=a[i];
		   
         if(s>a[i])
         {
	       s=a[i];
         }
        if(b<a[i])
         {      

	         b=a[i];

		}
  
  }
  cout<<s<<" "<<b<<" "<<w<<endl;


  return 0;
  }  



Measured memory_bytes: 3132
#include <cstdio>
#define ROP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
  int N,M,p=1;
  long q;
  scanf("%d %d",&N,&M);
  if(M<=5){
    ROP(i,M) p=p*2;
    q=(1900*M+100*(N-M))*p;
    printf("%ld\n",q);
  } else if(M>5){
    q=(1900*5+100*(N-5))*32;
    printf("%ld\n",q);
  }
  return 0;
}


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

int main(){
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    vector<unsigned long> dp(N, 1);
    for(unsigned long i = 2; i < N; ++i)for(unsigned long a{min(i, N - i + 1)}, j{a}; j < N; ++j)(dp[j] += dp[j - a]) %= M;
    vector<unsigned long> coef(N);
    iota(coef.rbegin(), coef.rend(), 1UL);
    cout << inner_product(coef.begin(), coef.end(), dp.begin(), 0UL) % M << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<string.h>
int main(){
  int n,x,i,k,Tscore=0,Hscore=0;
  char T[150],H[150];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",T,H);
    x=strcmp(T,H);
    if(x<0)Hscore+=3;
    else if(x>0)Tscore+=3;
    else Hscore++,Tscore++;
  }
  printf("%d %d\n",Tscore,Hscore);
  return 0;
}

Measured memory_bytes: 2624
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define RFOR(i,m,n) for(int i=m;i>=n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


void f(int n){

  int a[1000000];

  rep(i,n){
    cin>>a[i];
  }
  sort(a,a+n);

  int ans=0;
  FOR(i,1,n-1){
    ans+=a[i];
  }

  cout<<ans/(n-2)<<endl;
}


int main(){
  while(1){
    int n;
    cin>>n;
    if(n==0) break;
    f(n);
  }


  return 0;
}


Measured memory_bytes: 3112
#include<cmath>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	string arr;
	char brr[10];
	int n;
	int sum=0;
	cin>>arr;
	n=arr.length();
	for(int i=0;i<n;i++)
	{
		if(arr[i]=='0')
		{
			brr[sum++]='0';
		}
		else if(arr[i]=='1')
		{
			brr[sum++]='1';
			
		}
		else
		{
			if(sum!=0)
			{
				sum--;
			}
		}
	}
	for(int i=0;i<sum;i++)
	{
		cout<<brr[i];
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())
const int N=510;
const int mod=1e9+7;

int gi() {
	int 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;
}

int n,x,C[N][N],cnt[N],f[N][N][N],pw[N][N],fac[N],ifac[N];

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

int getC(int n,int m) {
	if(m<0||n<m) return 0;
	return C[n][m];
}

int main() {//
	cin>>n>>x;
	for(int i=1;i<=n;i++) ++cnt[gi()];
	fac[0]=1;
	for(int i=1;i<N;i++) fac[i]=1ll*fac[i-1]*i%mod;
	ifac[N-1]=qpow(fac[N-1],mod-2);
	for(int i=N-1;i;i--) ifac[i-1]=1ll*ifac[i]*i%mod;
	//for(int i=0;i<N;i++) cerr<<fac[i]<<' '<<ifac[i]<<'\n';
	for(int i=0;i<N;i++) {
		C[i][0]=pw[i][0]=1;
		for(int j=1;j<=i;j++) C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
		for(int j=1;j<N;j++) pw[i][j]=1ll*pw[i][j-1]*i%mod;
	}
	f[x+1][0][0]=1;
	for(int i=x;i;i--)
		for(int j=0;j<=x/i;j++)
			for(int k=0;k<=x;k++)
				for(int l=0;l<=j&&i*l<=k;l++)
					if(f[i+1][j-l][k-i*l]) f[i][j][k]=(f[i][j][k]+1ll*f[i+1][j-l][k-i*l]*ifac[l]%mod*pw[k-(i-1)*j][cnt[i]])%mod;
	int ans=0;
	for(int i=0;i<=x;i++) {
		for(int j=0;j<=x;j++) {
			ans=(ans+1ll*((x-j)&1?mod-1:1)*getC(x-j+1,i)%mod*fac[i]%mod*f[1][i][j])%mod;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 412416
N = int(input())
X = list(map(int, input().split()))
A = [-1]*N*N
sorted_X = sorted(X)
first_empty = 0
last_empty = N*N-1
fail_flag = 0
for i in range(N):
	x = sorted_X[i]
	K = X.index(x)+1
	if A[x-1]==-1:
		A[x-1] = K
	else:
		print("No")
		fail_flag = 1
		break
	K_rest = K-1
	while K_rest>0:
		while True:
			if A[first_empty]==-1:
				break
			first_empty = first_empty+1
		if first_empty<x-1:
			A[first_empty] = K
			K_rest = K_rest-1
			first_empty = first_empty+1
		else:
			print("No")
			fail_flag = 1
			break
	if fail_flag==1:
		break

if fail_flag==0:
	for i in range(N-1,-1,-1):
		x = sorted_X[i]
		K = X.index(x)+1
		K_rest = N-K
		while K_rest>0:
			while True:
				if A[last_empty]==-1:
					break
				last_empty = last_empty-1
			if last_empty>x-1:
				A[last_empty] = K
				K_rest = K_rest-1
				last_empty = last_empty-1
			else:
				print("No")
				fail_flag = 1
				break
		if fail_flag==1:
			break

if fail_flag==0:
	print("Yes")
	for a in A:
		print(str(a), end=" ")

Measured memory_bytes: 7088
import numpy as np
import sys
input = sys.stdin.readline

N, X, T = input().split(" ")
N, X, T = int(N), int(X), int(T)

if N%X == 0:
  use_time = N//X
else:
  use_time = N//X + 1

out = use_time * T

print(out)

Measured memory_bytes: 27140
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<P>> G(10);
    rep(i, 10)rep(j, 10){
        int c;
        cin >> c;
        if(i == j) continue;
        G[i].push_back(make_pair(j, c));
    }

    vector<int> dist(10, 0);
    rep(i, 10){
        if(i == 1) continue;
        vector<int> d(10, -1);

        queue<P> que;
        que.push(make_pair(i, 0));
        d[i] = 0;
        while(!que.empty()){
            P v = que.front();
            que.pop();
            for(P x : G[v.first]){
                if(d[x.first] != -1 && d[x.first] <= v.second + x.second) continue;
                d[x.first] = v.second + x.second;
                que.push(make_pair(x.first, v.second + x.second));
            }
        }
        dist[i] = d[1];
    }
    
    vector<vector<int>> a(h, vector<int>(w));
    rep(i, h)rep(j, w){
        cin >> a[i][j];
    }

    int ans = 0;
    rep(i, h)rep(j, w){
        if(a[i][j] == -1 || a[i][j] == 1) continue;
        ans += dist[a[i][j]];
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
import sys
readline = sys.stdin.readline

def main():
  N, M = map(int, readline().split())
  dist = {}
  pre = {}
  A = {}
  for i in range(N):
    dist[i+1] = -1
    pre[i+1] = -1
    A[i+1] = []
  dist[1] = 0
  pre[1] = 0
  for i in range(M):
    ai, bi = map(int, readline().split())
    A[ai].append(bi)
    A[bi].append(ai)
  cnt = 1
  depth = 1
  D = [1]
  while cnt < N:
    next = []
    for i in range(len(D)):
      for j in range(len(A[D[i]])):
        if dist[A[D[i]][j]] == -1:
          dist[A[D[i]][j]] = depth
          pre[A[D[i]][j]] = D[i]
          next.append(A[D[i]][j])
          cnt += 1
    D = next
    depth += 1
    if len(next) == 0:
      break
    elif depth > N:
      break
  if cnt == N:
    print('Yes')
    for i in range(1, N):
      print(pre[i+1])
  else:
    print('No')

if __name__ == '__main__':
  main()

Measured memory_bytes: 57204
# Aizu Problem 0197: Greatest Common Divisor: Euclidean Algorithm
#
import sys, math, os

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


def extended_gcd(a, b):
    if a < b:
        a, b = b, a
    steps = 0
    s, old_s = 0, 1
    t, old_t = 1, 0
    r, old_r = b, a
    while r != 0:
        steps += 1
        q = old_r // r
        old_r, r = r, old_r - q * r
        old_s, s = s, old_s - q * s
        old_t, t = t, old_t - q * t
    return old_r, steps


while True:
    a, b = [int(_) for _ in input().split()]
    if a == b == 0:
        break
    g, steps = extended_gcd(a, b)
    print(g, steps)

Measured memory_bytes: 7760
#include <stdio.h>
#include <string.h>
char x1[1510];
char x2[1510];
char x3[1510];
int main(){
    int m;
    int a,b;
    int i,j;
    char p;
    scanf("%s",&x1);
    scanf("%d",&m);
    for(i=0;i<m;i++){
        scanf("%s",&x3);
        if(strcmp(x3,"replace")==0){
            scanf("%d %d %s",&a,&b,&x2);
            for(j=0;j<b-a+1;j++){
                x1[a+j]=x2[j];
            }
        }
        else if(strcmp(x3,"reverse")==0){
            scanf("%d %d",&a,&b);
            while(a<b){
                p=x1[a];
                x1[a]=x1[b];
                x1[b]=p;
                a++;
                b--;
            }
        }
        else if(strcmp(x3,"print")==0){
            scanf("%d %d",&a,&b);
            for(j=a;j<=b;j++){
                printf("%c",x1[j]);
            }
            puts("");
        }
    }
    return 0;
}



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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) cout << "x";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
using namespace std;

int main(){
    long long N;
    vector<long long> A,A_sorted;
    map<long long,long long> point,point_s;

    cin>>N;
    for(int i=0;i<N;i++) {long long a;cin>>a;A.push_back(a);point[a]=i;}
    copy(A.begin(), A.end(), back_inserter(A_sorted) );
    long long ans=0;
    sort(A_sorted.begin(),A_sorted.end());

    for(int i=0;i<N;i++) point_s[A_sorted[i]]=i;
    for(int i=0;i<N;i++){
        
        if(point_s[A[i]]%2 != point[A[i]]%2) ans++;
    }
    


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



Measured memory_bytes: 14580
#include <bits/stdc++.h>
using namespace std;
int mod=1e9+7;
void add_self(int& a,int &b)
{
    a+=b;
    if(a>=mod)
    {
        a-=mod;
    }
}
void sub_self(int& a,int b)
{
    a-=b;
    if(a<0)
    {
        a+=mod;
    }
}
int main() {
	// your code goes here
	int n,k;
	cin>>n>>k;
	vector<int> dp(k+1);
	dp[0]=1;
	for(int child=0;child<n;child++)
	{
	    int up_to;
	    cin>>up_to;
	    vector<int> fake(k+1,0);
	   // memset(fake,0,sizeof(fake));
	    for(int used=k;used>=0;--used)
	    {
	        int tmp=dp[used];
	        int L=used+1;
	        int R=used+min(up_to,k-used);
	        if(L<=R)
	        {
	            add_self(fake[L],tmp);
	        }
	        if(R+1<=k)
	        {
	            sub_self(fake[R+1],tmp);
	        }
	    }
	    int prefix_sum=0;
	    for(int i=0;i<=k;i++)
	    {
	        add_self(prefix_sum,fake[i]);
	        add_self(dp[i],prefix_sum);
	    }
	}
	cout<<dp[k]<<endl;
	return 0;
}


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


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(void){
    int i,n,m;
    cin>>n;
    vector<string> u(n);
    for(i=0;i<n;i++)
    cin>>u[i];
    int lock=1;
    cin>>m;
    vector<string> t(m);
    for(i=0;i<m;i++){
cin>>t[i];
int l=0;
for(int j=0;j<n;j++){
    if(t[i]==u[j]){
        l++;
        lock=-lock;
        if(lock==-1)
        cout<<"Opened by "<<t[i]<<endl;
        else
        cout<<"Closed by "<<t[i]<<endl;
        break;
    }
}if(l==0)
    cout<<"Unknown "<<t[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
#include <cstdio>

using namespace std;

int main(){
  float L;
  float ans;
  cin >> L;
  ans = L * L * L / 27;
  cout << fixed << setprecision(10) << ans;
  
}

Measured memory_bytes: 256
import math

def abc176_a():
    n, x, t = map(int, input().split())

    def solve(n, x, t):
        # 1回t分でx個作れる。n個作るには
        ans = math.ceil(n / x) * t
        return ans

    ans = solve(n, x, t)
    print(ans)

if __name__ == '__main__':
    abc176_a()


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, K;
    cin >> N >> K;

    ll ans = pow(N/K, 3);
    if (K%2 == 0) {
        ans += pow((N+K/2)/K, 3);
    }

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


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



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

	int n, k, maxx;
	cin >> n >> k;
	maxx = (n + 1) / 2;
	if (k <= maxx) cout << "YES";
	else cout << "NO";

	return 0;
}



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

int N, M;
string A[50],B[50];

bool search(int h, int w) {
	bool match = true;

	for (int i = 1; i < M; i++) {
		if (B[i] != A[h + i].substr(w, M)) {
			match = false;
			break;
		}
	}
	return match;
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < M; i++) cin >> B[i];

	bool ans = false;
	for (int i = 0; i < N - M + 1; i++) {
		for (int j = 0; j < N - M + 1; j++) {
			if (B[0] == A[i].substr(j, M)) {
				ans = search(i, j);
			}
			if (ans) break;
		}
		if (ans) break;
	}

	if (ans) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

//#include "rubo.h"
//#define mp make_pair
//#define pb push_back
#define in int
#define ll long long
#define vc vector
#define SQ(j) (j)*(j)
//#define x first
//#define y second

//#define ld long double
#define dbl  long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define all(j) j.begin(), j.end()
#define loop(xxx, yyy) for(int xxx = 0; xxx < yyy; xxx++)
//#define printf(fmt, ...) (0)
//#define HOME
//#define y0 ngacaleiebinvoaeu
//#define y1 gnarpipipaigare
#define j1 adsfndnasfafoasp

#define db(x) cout << #x << " = " << x << endl
#define dbCont(x) cout << #x << ": "; for(auto shun: x) cout << shun << ' '; cout << endl;

typedef long double ld;

using namespace std;


const int N = 100*1000+5;

int n;
int a[N][3];
int dp[N][4];
int main() {
    cin >> n;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= 3; j++){
            cin >> a[i][j];
        }
    }

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= 3; j++){
            for(int prev_j = 1; prev_j <= 3; prev_j++){
                if(j != prev_j){
                    dp[i][j] = max(dp[i][j], dp[i-1][prev_j] + a[i][j]);
                }
            }
        }
    }



    int res = max(dp[n][1],max(dp[n][2], dp[n][3]));
    cout << res << endl;


    return 0;
}


Measured memory_bytes: 2944
$inputs = '1222'.split('').map(&:to_i)
$target = 7

def prepare
    $inputs = STDIN.gets.chomp.split('').map(&:to_i)
end

def dfs(depth, value, form)
    if depth == $inputs.count
        if value == $target
            return true, form + '=' + $target.to_s
        else
            return false, form
        end
    end

    result1, form1 = dfs depth + 1, value + $inputs[depth],
        (depth > 0 ? form + '+' : '') + $inputs[depth].to_s
    if result1 == true
        return result1, form1
    end

    result2, form2 = dfs depth + 1, value - $inputs[depth],
        (depth > 0 ? form + '-' : '') + $inputs[depth].to_s
    if result2 == true
        return result2, form2
    end

    return false, ''
end

def solve
    result, form = dfs 0, 0, ''
    if result == true
        puts form
    end
end

prepare
solve


Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;

int like[100];

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

  int n,m;
  cin>>n>>m;
  rep(i,n) {
    int k;
    cin>>k;
    rep(j,k) {
      int a;
      cin>>a;
      like[a]++;
    }
  }
  int ans = 0;
  FOR(i, 1, m+1) {
    if(like[i] == n) {
      ans++;
    }
  }
  cout << ans << endl; 

  return 0;
}


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


int main()
{   int a=0,b=0,c=0,d=0;
    int t; cin>>t; while(t--)
    {
        string s;
        cin>>s;
        if(s=="AC")
          a++;
        else if(s=="WA")
          b++;
        else if(s=="TLE")
         c++;
         else d++;
    }
   string A="AC x ";
   string B="WA x ";
   string C="TLE x ";
   string D="RE x ";
   cout<<A;
   cout<<a<<endl;
   cout<<B;
   cout<<b<<endl;
   cout<<C;
   cout<<c<<endl;
   cout<<D;
   cout<<d<<endl;
    
}


Measured memory_bytes: 3628
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int a = Integer.parseInt(sc.next());
    int b = Integer.parseInt(sc.next());
    int answer = 0;
    int push = 2;
    for (int i = 0; i < push; i++) {
      if (a > b) {
        answer += a;
        a--;
      } else {
        answer += b;
        b--;
      }
    }
    pw.println(answer);
  }
}


Measured memory_bytes: 22484
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int X, Y;
    cin >> X >> Y;

    int t = abs(X-Y);
    if(t<=1) cout << "Brown" << endl;
    else cout << "Alice" << endl;
    
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int sum=0;
  
  int i=0;
  
  while(i<N){
    int a, b;
    cin >> a >> b;
    
    sum += b-a+1;
    
    i++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int c[4][4], a[4], b[4], i, j, jud;
	scanf("%d %d %d",&c[1][1],&c[1][2],&c[1][3]);
	scanf("%d %d %d",&c[2][1],&c[2][2],&c[2][3]);
	scanf("%d %d %d",&c[3][1],&c[3][2],&c[3][3]);
	// we may renormalize so that c[1][1]=0, a[1]=b[1]=0:
	c[1][2]=c[1][2]-c[1][1]; c[1][3]=c[1][3]-c[1][1];
	for(i=2;i<=3;i++){
		for(j=1;j<=3;j++) c[i][j]=c[i][j]-c[1][1];
	} c[1][1]=0;
	a[2]=c[2][1]; a[3]=c[3][1]; b[2]=c[1][2]; b[3]=c[1][3];
	jud = 1;
	for (i=2;i<=3;i++){ for(j=2;j<=3;j++){
	if(c[i][j]==a[i]+b[j]) ; else jud = 0;
		} 
	}
	if(jud==0) printf("No"); else printf("Yes");
 	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;

const int mod = 1e9+7;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int H, W;
  cin >> H >> W;
  int N; cin >> N;

  map<P, int> mp;
  rep(i, N) {
    int a, b; cin >> --a >> --b;
    for(int i=-1; i<=1; i++) {
      for(int j=-1; j<=1; j++) {
        mp[P(a+i, b+j)]++;
      }
    }
  }

  vector<ll> ans(10);
  for(auto e : mp) {
    P pair = e.first;
    int i = pair.first;
    int j = pair.second;
    //debug(i); debug(j); debugln(e.second);
    if (i>1 && i<H && j>1 && j<W) {
      ans.at(e.second)++;
    }
  }

  ll sum = 0;
  for(int i=1; i<=9; i++) {
    sum += ans.at(i);
  }
  ans.at(0) = (ll)(H-2)*(W-2)-sum;

  rep(i, 10) {
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 56576
n = int(input())
s = input()
ans = 0
 
pin = [str(i).zfill(3) for i in range(1000)]
 
for i in pin:
    idx = -1
    for j in i:
        idx = s.find(j,idx+1)
        if idx < 0:
            break
    else:
        ans += 1
 
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define int64 long long
#define uint64 unsigned long long
using namespace std;

int main()
{
	int64 hh, num = 1,sum = 0;
	cin >> hh;
	while(hh >= 1)
	{
		sum += num;
		hh /= 2;
		num *= 2;
	}
	cout << sum;
	return 0;
}


Measured memory_bytes: 3632
/*
 ALDS1_1_A
*/

#include <iostream>

using namespace std;

static const int MAX = 100;

void outArray(int N, const int (&A)[MAX]) {
    for(int i = 0; i < N; i++) {
        cout << A[i];
        if(i < N-1) {
            cout << " ";
        }
    }
    cout << endl;
}

int main() {
    int n, A[MAX];

    cin >> n;

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

    outArray(n, A);

    for(int i = 1; i < n; i++) {
        int v = A[i];
        int j = i-1;
        while( (j >= 0) && (A[j] > v) ) {
            A[j+1] = A[j];
            j--;
        }
        A[j+1] = v;
        outArray(n, A);
    }

}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;

    rep(i, n-1){
        int tmp;
        cin >> tmp;
        mp[tmp-1]++;
    }

    rep(i, n){
        cout << mp[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 13560
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int, int>;

signed main() {
  int n, k;
  cin >> n >> k;
  map<int, int> cnt;
  for (int i = 0; i < n; i++) {
    int w;
    cin >> w;
    cnt[w]++;
  }
  auto v = vector<P>(begin(cnt), end(cnt));
  sort(begin(v), end(v), [&](P x, P y) { return x.second > y.second; });
  int tmp = 0ll;
  for (int i = 0; i < k && i < v.size(); i++) {
    tmp += v[i].second;
  }

  cout << max(n - tmp, 0ll) << endl;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
typedef pair<ll,ll>pi;
vector<pi>adj[100005];
ll dis[100005];
#define inf 100000000000000000
void s_p(ll st,ll n)
{
    for(ll i=0;i<=n;i++)dis[i]=inf;
    dis[st]=0;
    priority_queue<pi,vector<pi>,greater<pi>>q;
    q.push({0,st});
    while(!q.empty())
    {
        ll top=q.top().second;
        ll cost=q.top().first;
        q.pop();
        for(ll i=0;i<adj[top].size();i++)
        {
            ll chi=adj[top][i].second;
            ll ct=adj[top][i].first;
            if(ct+cost<dis[chi])
            {
                dis[chi]=ct+cost;
                q.push({dis[chi],chi});
            }
        }
    }
}

int main()
{
    ll n;cin>>n;
    for(ll i=0;i<n-1;i++)
    {
        ll u,v,w;cin>>u>>v>>w;
        adj[u].pb({w,v});
        adj[v].pb({w,u});
    }
    ll q,k;cin>>q>>k;
    s_p(k,n);
    while(q--)
    {
        ll a,b;cin>>a>>b;
        ll ans=dis[a]+dis[b];
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 11120
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  cout << ((N - 1) / 1000 + 1) * 1000 - N << endl;
  return 0;
}


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

int main(){
    int n,A[1000];
    
    cin >> n;
    for (int i=0; i<n; i++) cin >> A[i];
    
    for (int i=n-1; 0<i; i--) cout << A[i] << " ";
    cout << A[0] << endl;
    
    return 0;
}


Measured memory_bytes: 3116
#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 998244353

int main(){
    int N, L; cin >> N >> L;
    vector<string> S(N);
    for(string &s:S)
        cin >> s;
    
    sort(S.begin(), S.end());
    for(string &s:S)
        cout << s;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(S: str):
    print("".join(["x"*len(S)]))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


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

int main(){
    int n,m;
    cin >> n >>m;
    if(n==m) puts("Yes");
    else puts("No");
    return 0;
}

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


int main(){
  int D, N, ans;
  cin>>D>>N;
  if(D==0){
    ans = N;
    if(N==100)ans++;
  }else if(D==1){
    ans = N*100;
    if(N==100)ans+=100;
  }else if(D==2){
    ans = N*10000;
    if(N==100)ans+=10000;
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
const long long INF=1e9+7;
long long pow(long long a,long long b){
	long long res=1;
	while(b){
		if(b&1) {
			res=res*a%INF;
		}
		a=a*a%INF;
		b>>=1;
	}
	return res;
}
int main(int argc, char** argv) {
	long long n;
	cin>>n;
	cout<<((pow(10ll,n)-2*pow(9ll,n)+pow(8ll,n))%INF+INF)%INF;
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define inf (long long)1e9
using namespace std;

struct data {
  int x, y;
};
bool operator<(const data &l, const data &r) {
  if(l.x != r.x) return l.x < r.x;
  return l.y < r.y;
}

struct cod {
  int s, b, d, c;
};

int x[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int y[8] = {-1, -1, -1, 0, 1, 1, 1, 0};

int n;
vector<string> s;
vector<data> v;
vector<bool> ch;
map<data, int> mp;

long long solve();
bool isvalid(data now) {
  return now.x >= 0 && now.x < 19 && now.y >= 0 &&
         now.y < 15;
}

int main() {
  s.resize(19);
  for(int i = 0; i < 19; ++i) cin >> s[i];
  for(int i = 0; i < 19; ++i)
    for(int j = 0; j < 15; ++j)
      if(s[i][j] == 'X') {
        mp[{i, j}] = v.size();
        v.push_back({i, j});
      }
  n = v.size();
  cout << solve() << endl;
  return 0;
}

long long solve() {
  queue<cod> qu;
  ch.assign((1 << n), 0);
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < 8; ++j) {
      data now = v[i];
      now.x += x[j];
      now.y += y[j];
      if(!isvalid(now)) continue;
      if(s[now.x][now.y] == 'O' && !(ch[(1 << n) - 1])) {
        qu.push({(1 << n) - 1, i, j, 0});
        ch[(1 << n) - 1] = 1;
      }
    }
  while(!qu.empty()) {
    cod now = qu.front();
    qu.pop();
    for(int i = 0; i < 8; ++i) {
      bool jumped = 0;
      cod nextc = now;
      ++nextc.c;
      int nowx = v[nextc.b].x + x[nextc.d],
          nowy = v[nextc.b].y + y[nextc.d];
      nextc.d = i;
      while(nowx >= 0 && nowy >= 0 && nowx < 19 &&
            nowy < 15) {
        nowx += x[i];
        nowy += y[i];
        if(!isvalid({nowx, nowy}) ||
           mp.find({nowx, nowy}) == mp.end() ||
           !(nextc.s >> mp[{nowx, nowy}] & 1))
          break;
        nextc.b = mp[{nowx, nowy}];
        nextc.s -= 1 << nextc.b;
        jumped = 1;
      }
      if(!jumped) continue;
      if(nowx == 19 ||
         (nowx == 18 && isvalid({nowx, nowy})))
        return nextc.c;
      if(nowy == 15 || nowy == -1 || nowx == -1) continue;
      if(!ch[nextc.s]) {
        qu.push(nextc);
        ch[nextc.s] = 1;
      }
    }
  }
  return -1;
}



Measured memory_bytes: 3308
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
void FastInputOutput(){
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}

ll power(ll x, ll p, ll m){
    ll res = 1;
    while(p){
        if(p&1)    res = (res * x)%m;
        x = (x * x)%m;
        p >>= 1;
    }
    return res;
}
long double ModLog(long double base, long double x) {
    return (logl(x) / logl(base));
}

const int N = 1e6 + 5, MX = 1e9;
int cnt(int n){
    int ret = 0;
    while (n) {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

int main(){
    int n = D();
    puts((n % cnt(n) == 0) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <fstream>
#include<string>
#include<sstream>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
#include <math.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const int INF = 1000000007;
const double EPS = 1e-10;
const double PI = 3.14159265359;
const int N = 100005;
//cout << fixed << std::setprecision(9)
//--------------------------

int n, k;
int h[N];
int dp[N];

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

	for (int i = 1; i < n; i++) {
		dp[i] = INF;
		for (int j = 1; j <= k; j++) {
			int pre = i - j;
			if (pre < 0) break;
			dp[i] = min(dp[i], dp[pre] + abs(h[i] - h[pre]));
		}
	}
	
	cout << dp[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 1024