akhauriyash/Code-Regression huggingface dataset:
import qualified Data.Vector.Unboxed as U

main = do
  k <- readLn :: IO Int
  print $ solve k

solve :: Int -> Int
solve k = f k $ U.fromList [1..9] where
  f k ll
    | k <= U.length ll = ll U.! pred k
    | otherwise = f (k - U.length ll) $ U.concatMap g ll
    where
      g x = U.fromList $ case mod x 10 of
        0 -> [10*x, 10*x+1]
        9 -> [10*x+8, 10*x+9]
        r -> [10*x+r-1 .. 10*x+r+1]

  


Measured memory_bytes: 5500
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N = lread();
    string[] ST = new string[](2);
    scan(ST[0], ST[1]);
    string ans;
    foreach (i; 0 .. 2 * N)
    {
        ans ~= ST[i & 1][i / 2];
    }
    writeln(ans);
}


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

using namespace std;

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

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

    cin >> n >> k;

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

    dp[0] = 0;
    for (int i = 1; i <= 100; i++)
        dp[i] = abs(h[i] - h[0]);

    for (int i = 1; i < n; i++)
    {
        dp[i] = 2e9;
        for (int j = 1; j <= min(k, i); j++)
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }

    cout << dp[n - 1];

	return 0;
}



Measured memory_bytes: 1024
#include <cstdio>

using namespace std;
int n,d[102][4];
bool ch[102];

int gcd(int a,int b){
  if(b == 0) return a;
  return gcd(b,a % b);
}


int dfs(int x){
  int p = d[x][0];
  int q = d[x][1];
  int w = gcd(p,q);
  
  p /= w;
  q /= w;
  
  if(d[x][2] == 0 && d[x][3] == 0){
    return (p+q);
  }
  
  int red=1,blue=1;
  
  if(d[x][2] != 0) red = dfs(d[x][2]);
  if(d[x][3] != 0) blue = dfs(d[x][3]);
  
  int k = p * red;
  int h = q * blue;
  int i = 0;
  int j = 0;
  while(1){
    i++;
    if(k * i % h == 0){
      j = k * i / h;
      break;
    }
  }
  
  return (i*red+j*blue);
}
  

int main(){
  
while(1){
  
  scanf("%d",&n);
  if(n == 0)break;
  
  for(int i = 1;i <= n;i++){
    ch[i] = false;
  }
  
  for(int i = 1;i <= n;i++){
    for(int j = 0;j < 4;j++){
      scanf("%d",&d[i][j]);
      if(j == 2 || j == 3){
	ch[d[i][j]] = true;
      }
    }
  }
  int ans;
  for(int i = 1;i <= n;i++){
    if(ch[i] == false){
      ans = i;
    }
  }
  
  printf("%d\n",dfs(ans));
  
}
  
  return 0;
  
}
  
  
 


Measured memory_bytes: 1028
def input_n
  gets.to_i               # 単一整数
end

def input_s
  gets.chomp              # 文字列。chompを付けないと改行文字がついてくる
end

def input_a
  gets.split.map(&:to_i)  # スペースで区切られた複数の整数
end

def input_o(num)
  num.times.map { gets.to_i }  # 縦に並んだ複数の整数。たまにある
end

def output_f(num)
  puts sprintf("%.12f", num)
end

d, t, s = input_a

if d > t * s
  puts "No"
else
  puts "Yes"
end


Measured memory_bytes: 14440
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import defaultdict
def main():
    n, x, y= map(int, input().split())
    edges = {e:[] for e in range(n)}
    for i1 in range(1, n - 1):
        edges[i1].append(i1-1)
        edges[i1].append(i1+1)
    edges[0].append(1)
    edges[n-1].append(n-2)
    edges[x-1].append(y-1)
    edges[y-1].append(x-1)

    dis = defaultdict(int)
    for j1 in range(n):
        seen = set()
        cnt = 0
        dis_each = [n] * n
        nexts = [j1]
        nextnext = []
        while len(seen) < n:
            for next in nexts:
                if next not in seen:
                    seen.add(next)
                    dis_each[next] = cnt
                    nextnext += edges[next]
            nexts = nextnext
            nextnext = []
            cnt += 1
        for d in dis_each:
            dis[d] += 1
    for k1 in range(1, n):
        print(dis[k1]//2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 10364
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  int n, ma, mb;
  cin >> n >> ma >> mb;
  int a[n],b[n],c[n];
  REP(i,n) cin >> a[i] >> b[i] >> c[i];
  ll dp[n+1][500][500];
  fill(dp[0][0],dp[n+1][0],INF); //i+1種類まで考えて、重さj,kのときのコストの最小値
  dp[0][0][0] = 0;
  REP(i,n){
    REP(j,500){
      REP(k,500){
        if(j>=a[i]&&k>=b[i])
        dp[i+1][j][k] = min(dp[i][j][k],dp[i][j-a[i]][k-b[i]]+c[i]);
        else dp[i+1][j][k] = dp[i][j][k];
      }
    }
  }
  ll ans = INF;
  int i = 1;
  for(;i*ma<500&&i*mb<500;i++) ans = min(ans,dp[n][i*ma][i*mb]);
  if(ans==INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 80384
Y,N = map(int,input().split())
def check():
    for i in range(N//10000,-1,-1):
        for j in range((N-10000*i)//5000,-1,-1):
            cy = Y - i - j
            if cy >= 0 and 10000*i+5000*j+1000*cy == N:
                return i,j,cy
    return -1,-1,-1
x,y,z = check()
print(x,y,z)


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

#define ll long long
#define ar array

const int M=1e9+7;
ll iv[400000], f1[400000], f2[400000];

ll nck(int n, int k) {
	/*
	ll ans=1;
	for(int i=1; i<=k; ++i)
		ans=ans*(n-i+1)%M*iv[i]%M;
	return ans;
	*/
	return f1[n]*f2[n-k]%M*f2[k]%M;
}

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

	iv[1]=1;
	for(int i=2; i<4e5; ++i)
		iv[i]=M-M/i*iv[M%i]%M;
	f1[0]=f2[0]=1;
	for(int i=1;i <4e5; ++i) {
		f1[i]=f1[i-1]*i%M;
		f2[i]=f2[i-1]*iv[i]%M;
	}
	int n, k;
	cin >> n >> k;
	ll ans=nck(2*n-1, n-1);
	for(++k; k<=n-1; ++k) {
		//k zeros
		//k fit in n-k
		ans=(ans+M-nck(n, k)*nck(n-1, n-k-1)%M)%M;
	}
	cout << ans;
}

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

int main()
{
    vector<int> vec(3);
    for (int i = 0; i < 3; i++)
    {
        cin >> vec.at(i);
    }

    int cnt_5 = 0;
    int cnt_7 = 0;

    for (int i = 0; i < 3; i++)
    {
        if (vec.at(i) == 5)
        {
            cnt_5++;
        }
        if (vec.at(i) == 7)
        {
            cnt_7++;
        }
    }

    string res = "NO";

    if (cnt_5 == 2 && cnt_7 == 1)
    {
        res = "YES";
    }

    cout << res << endl;
}

Measured memory_bytes: 256
N,M=list(map(int,input().split()))
A=[list(map(int,input().split())) for i in range(M)]
import sys
S=[-1 for i in range(N)]
visited=[[] for i in range(N)]

for i in A:
    S[i[0]-1]=i[1]
    visited[i[0]-1].append(i[1])
for i in visited:
    if len(set(i))>1:
        print(-1)
        sys.exit()
if len(S)>1:
    if S[0]==0:
        print(-1)
        sys.exit()
    if S[0]==-1:
        S[0]=1

for i,value in enumerate(S):
    if value==-1:
        S[i]=0

print(*S,sep='')

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define ff first
#define ss second
#define se set<ll>
#define vec vector<ll>
#define inf 10000000000000000
#define pri 100000000007
bool mark[100005];
vec adj[100005];
ll counter;
vec cnt;
vector<string> forsubs;

         
   



int main()
{    
 

   #ifdef APNA_IO
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
   #endif
          ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 

   ll n;
   cin>>n;
   ll a[n+1]={0};
   ll b[n+1]={0};

   for(ll i=1;i<=n;i++)
   {
    cin>>a[i];
    b[i]=a[i];
   }

   sort(b,b+n+1);

   ll max1=b[n];
   ll max2=b[n-1];

   for(ll i=1;i<=n;i++)
   {
    if(a[i]==max1)
      cout<<max2<<"\n";
    else
      cout<<max1<<"\n";
   }




}

Measured memory_bytes: 7040
# ビンゴを用意x3行
A = [list(map(int, input().split())) for _ in range(3)]
# N個呼ぶ
N = int(input())

for _ in range(N):
    b = int(input())
    for y in range(3):
        for x in range(3):
            # リストAの数字の10の桁yと1桁xがbと一緒なら-1とする
            if A[y][x] == b:
                A[y][x] = -1
# 10の桁が合っているかの処理
for y in range(3):
    f = True
    for x in range(3):
        # 上の処理で-1がビンゴとして
        if A[y][x] != -1:
            f = False
    if f:
        print('Yes')
        exit()
# 1の桁が合っているかの処理
for x in range(3):
    f = True
    for y in range(3):
        if A[y][x] != -1:
            f = False
    if f:
        print('Yes')
        exit()

f = True
for x in range(3):
    if A[x][x] != -1:
        f = False
if f:
    print('Yes')
    exit()

f = True
for x in range(3):
    if A[2 - x][x] != -1:
        f = False
if f:
    print('Yes')
    exit()

print('No')

Measured memory_bytes: 3064
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000
#define NIL -1
#define MOD 1000000007

typedef int _loop_int;
#define rep(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define debug(x) cout<<#x<<": "<<x<<endl
#define debig_vec(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) rep(i, h) { rep(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

int main() {
    int n,m;
    cin >> n >> m;
    print((n-1)*(m-1));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N;
  cin >> N;

  if (N == 2) {
    int A, B;
    cin >> A >> B;
    cout << A + B << endl;
  } else {
    cout << "Hello World" << endl;
  }
 
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;
const ll m=1LL<<32;

int main(){

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

  rep(i,0,700000){
    if(a==(ll)(i*0.08)&&b==(ll)(i*0.1)){
      out(i);
      return 0;
    }
  }

  out(-1);

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int ans=0;
  char s[4],t[4];
  scanf("%s%s",s,t);
  for(int i=0;i<3;i++){
    if(s[i]==t[i]){
      ans++;
    }
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,count=0;
    cin>>n>>k;
    int arr[n+1];
    arr[0]=1;
    for(int i=1;i<=n;i++)
    arr[i]=0;
    int d,temp=0;
    while(cin>>d)
    {
        while(d--)
        {
        cin>>temp;
        arr[temp]++;
        }
    }
    for(int i=0;i<=n;i++)
    {
        if(arr[i]==0)
        count++;
    }
    cout<<count;
}

Measured memory_bytes: 3624
//shivamkr21
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
int main()
{
	int n,l;
	cin>>n>>l;
	int ar[n+1],pp[n];
	ar[0]=l;
	pp[0]=abs(ar[0]);
	for(int i=1;i<n;i++)
	{
		ar[i]=ar[i-1]+1;
		pp[i]=abs(ar[i]);
	}
	int minx=1000000009,mini=0,sum=0;
	for(int i=0;i<n;i++)
	{
		if(minx>pp[i])
		{
			minx=pp[i];
			mini=i;
		}
	}
	for(int i=0;i<n;i++)
	{
		if(i==mini)
			continue;
		else
			sum+=ar[i];
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<stack>
using namespace std;
typedef long long ll;
#define MAX 200000


int main(){
  int N,Q,A[MAX]={0};
  string S;
  cin>>N>>Q>>S;
  for(int i=0;i<S.size()-1;i++){
    if(S[i]=='A' && S[i+1]=='C'){
      A[i+1]=A[i]+1;
    }else A[i+1]=A[i];
  }
  int l,r;
  for(int i=0;i<Q;i++){
    cin>>l>>r;
    l--;
    r--;
    cout<<A[r]-A[l]<<endl;
  }
  
}


Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};

const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};


ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};

ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

/*
//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}
*/


int main(){
  ll N;
  cin >> N;
  cout << N * (N-1) / 2 << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please



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


	int N;
	scanf("%d ", &N);
	int sL[1001] = {}, sR[1001] = {};
	pair<int, int> RR[500], LL[500];
	int rr = 0, ll = 0;
	int tot = 0;
	rep(i, N) {
		char c;
		int l = 0, r = 0;
		while((c = getchar_unlocked()) >= '(') {
			if (c == '(') r++;
			else {
				if (r > 0) r--;
				else l++;
			}
		}
		tot += r - l;
		if (l < r) {
			if (l <= 1000) sR[l] += r;
			else RR[rr++] = { l,r };
		}
		else {
			if (r <= 1000) sL[r] += l;
			else LL[ll++] = { r,l };
		}
	}

	if (tot != 0) {
		printf("No");
		return 0;
	}

	sort(RR, RR + rr);
	sort(LL, LL + ll);

	int OK = 1;
	int k = 0;
	rep(i, 1001) {
		if (sR[i]) {
			if (k < i) OK = 0;
			k += sR[i];
		}
	}
	rep(i, rr) {
		if (k < RR[i].first) OK = 0;
		k += RR[i].second - RR[i].first;
	}
	k = 0;
	rep(i, 1001) {
		if (sL[i]) {
			if (k < i) OK = 0;
			k += sL[i];
		}
	}
	rep(i, ll) {
		if (k < LL[i].first) {
			OK = 0;
		}
		k += LL[i].second - LL[i].first;
	}

	if (OK) printf("Yes");
	else printf("No");

	Would you please return 0;
}

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

using namespace std;
using ll = long long;

int main(){
    int l, r, d;
    cin >> l >> r >> d;
    int cnt = 0;
    for(int i = l; i <= r; i++){
        if(i % d == 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


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

int main() {
    int n; long long k;
    cin >> n >> k;
    int a[200010] = {};
    int vis[200010] = {};
    for (int i = 1; i <= n; i++) cin >> a[i];
    int current = 1;
    vis[current] = 1;
    vector<int> route;
    while (true) {
        vis[current] = 1;
        route.push_back(current);
        if (vis[a[current]] == 0) {
            current = a[current];
        } else {
            break;
        }
    }
    int loop_start = 0;
    for (int i = 0; i < route.size(); i++) {
        if (route[i] == a[current]) {
            loop_start = i;
        }
    }
    if (loop_start > k) {
        cout << route[k] << endl;
    } else {
        int loop_size = route.size() - loop_start;
        k -= loop_start;
        k %= loop_size;
        cout << route[loop_start+k] << endl;
    }
    return 0;
}


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

const int M = 1000000007;
long long dp[13];

int main() {
  string s; cin >> s;

  dp[0] = 1;

  reverse(s.begin(), s.end());
  int mul = 1;
  for(int i=0; i<s.size(); ++i){
    long long dp2[13] = {};
    if(s[i] == '?'){
      for(int k=0; k<10; ++k){
        int x = k;
        for(int j=0; j<13; ++j){
          dp2[(x*mul + j) % 13] = (dp2[(x*mul + j) % 13] + dp[j]) % M;
        }
      }
    }else{
      int x = s[i] - '0';
      for(int j=0; j<13; ++j){
        dp2[(x*mul + j) % 13] = (dp2[(x*mul + j) % 13] + dp[j]) % M;
      }
    }

    for(int k=0; k<13; ++k) dp[k] = dp2[k];
    mul = (int)((long long)mul*10 % 13);
  }

  cout << dp[5] << endl;
}


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

int main()
{
	int M, K;
	scanf("%d%d", &M, &K);
	if ((1 << M) <= K)
		puts("-1");
	else if (M == 0)
		puts("0 0");
	else if (M == 1)
	{
		if (K == 0)
			puts("0 0 1 1");
		else
			puts("-1");
	}
	else
	{
		for (int i{}; i < (1 << M); i++)
			if (i != K)
				printf("%d ", i);
		printf("%d", K);
		for (int i{(1 << M) - 1}; i >= 0; i--)
			if (i != K)
				printf(" %d", i);
		printf(" %d\n", K);
	}

	return 0;
}

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

int main() {
    int k,s;
    cin >> k >> s;
    int sum = 0;
    for(int x = 0; x <= k; x++) {
        for(int y = 0; y <= k; y++) {
            if(s-(x+y) <= k && s-(x+y) >= 0) {
                sum++;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;

constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;

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

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

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

    ll L;
    cin >> L;
    V<V<ll>> dp(L + 1, V<ll>(5, inf));
    dp[0] = V<ll>(5, 0);
    rep(i, L) {
        ll a;
        cin >> a;
        ll mn = inf;
        rep(j, 5) {
            chmin(mn, dp[i][j]);
            if(abs(j - 2) == 2) dp[i + 1][j] = mn + a;
            if(abs(j - 2) == 1) dp[i + 1][j] = mn + (a ? a & 1 : 2);
            if(abs(j - 2) == 0) dp[i + 1][j] = mn + (a + 1 & 1);
        }
    }
    ll mn = inf;
    rep(j, 5) chmin(mn, dp[L][j]);
    cout << mn << endl;

    return 0;
}

Measured memory_bytes: 14336
#include <iostream>

using namespace std;

int main()
{
    int N;
    cin>>N;
    if(  N%10==2||  N%10==4||  N%10==5|| N%10==7||  N%10==9)
    {
        cout<<"hon";

    }
    else if(  N%10==0||  N%10==1||  N%10==6|  N%10==8)
    {
        cout<<"pon";

    }
    else

    {
    cout<<"bon";
    }
    return 0;
}


Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */


void in(){
    
}

void solve(){

    int n; string s;
    cin >> n >> s;
    int ans = 0;

    rep(i,0,n){
        int cnt = 0;
        string a, b;
        a = cut(s, 0, i); b = cut(s, i,n);
        set<char> s;
        for(char e : a) s.insert(e);
        set<char> inb; for(char e : b) inb.insert(e);
        for(auto e : inb) if(exist(s, e)) cnt++;
        chmax(ans, cnt);
    }
    cout << ans << endl;
}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

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


long long int validTuplesNew(int N, const std::vector<char>& vec) {
	int G = std::count(vec.begin(), vec.end(), 'G');
	int R = std::count(vec.begin(), vec.end(), 'R');
	int B = std::count(vec.begin(), vec.end(), 'B');

	long long int count = 0;

	for (int i = 1; i < N - 1; i++) {
		if (vec[i-1] == 'G') {
			G--;
		} else if (vec[i-1] == 'R') {
			R--;
		} else {
			B--;
		}
		int g = G;
		int r = R;
		int b = B;
		for (int j = i+1; j < N; j++) {
			if (vec[j-1] == 'G') {
				g--;
			} else if (vec[j-1] == 'R') {
				r--;
			} else {
				b--;
			}
			if (vec[i-1] == vec[j-1]) {
				continue;
			}

			if (vec[i-1] != 'G' && vec[j-1] != 'G') {
				// last one is G
				if (vec[j + j - i - 1] == 'G') {
					count += (g - 1);
				} else {
					count += g;
				}
			}

			if (vec[i-1] != 'R' && vec[j-1] != 'R') {
				// last one is R
				if (vec[j + j - i - 1] == 'R') {
					count += (r - 1);
				} else {
					count += r;
				}
			}

			if (vec[i-1] != 'B' && vec[j-1] != 'B') {
				// last one is B
				if (vec[j + j - i - 1] == 'B') {
					count += (b - 1);
				} else {
					count += b;
				}
			}

		}
	}

	return count;
}


void populate(int N) {
	std::vector<char> vec = std::vector<char>(N);

	for (int i = 0; i < N; i++) {
		std::cin >> vec[i];
	}

	std::cout << validTuplesNew(N, vec) << std::endl;
}




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

	populate(N);
}


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

#pragma GCC diagnostic warning "-Wconversion"

#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) begin(a), end(a)
#define has(a, b) (a.find(b) != a.end())
#define fora(i, n) for(int i = 0; i < n; i++)
#define forb(i, n) for(int i = 1; i <= n; i++)
#define forc(a, b) for(const auto &a : b)
#define ford(i, n) for(int i = n; i >= 0; i--)
#define maxval(t) numeric_limits<t>::max()
#define minval(t) numeric_limits<t>::min()
#define imin(a, b) a = min(a, b)
#define imax(a, b) a = max(a, b)

#define dbgs(x) #x << " = " << x
#define dbgs2(x, y) dbgs(x) << ", " << dbgs(y)
#define dbgs3(x, y, z) dbgs2(x, y) << ", " << dbgs(z)
#define dbgs4(w, x, y, z) dbgs3(w, x, y) << ", " << dbgs(z)

using ll = long long;

ll po[60];
ll e[2];

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

        po[0] = 1;
        fora(i, 59)
        {
                po[i + 1] = 2 * po[i];
        }

        int n, p;
        cin >> n >> p;

        fora(i, n)
        {
                ll l;
                cin >> l;
                e[l % 2]++;
        }

        ll res = po[e[0]] * po[max(0LL, e[1] - 1)];

        if (p == 1 && e[1] == 0)
                res = 0;

        cout << res << endl;
}


Measured memory_bytes: 256
import Data.List
import Data.Int

main = do
   [n,m] <- map (read) . words <$> getLine :: IO [Int64]
   as <- map (half . read) . words <$> getLine :: IO [Int64]
   putStrLn $ show (ans m as)

ans :: Int64 -> [Int64] -> Int64
ans m as = f (foldl1 (lcm1 m) as) m

lcm1 :: Int64 -> Int64 -> Int64 -> Int64
lcm1 m a b
  | lcm a b > m = m+1
  | (orde a) /= (orde b) = m+1 
  | otherwise = lcm a b

half :: Int64 -> Int64
half a = a `div` 2

f :: Int64 -> Int64 -> Int64
f a m = (m + a) `div` (2 * a)

orde :: Int64 -> Int64
orde n 
  | n `mod` 2 == 1 = 0
  | otherwise = orde (n `div` 2) + 1


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

main()
{

  int n;
  int a,b;

  cin >> n >> a >> b;

  int f=b-a;

  if(f%2==0)
    cout << "Alice" << endl;
  else
    cout << "Borys" << endl;
  
  return (0);
  
}

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

int main(void){
    string s;
    cin>>s;
    bool isbad=0;
    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3])isbad=1;
    if(isbad){
        cout<<"Bad"<<endl;
    }else{
        cout<<"Good"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
fn b() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    let pattern = input.trim_right();

    let nm = input.trim_right().split_whitespace().
        map(|c| c.parse::<u32>().unwrap()).
        collect::<Vec<u32>>();

    let mut input = String::new();
    std::io::stdin().read_line(&mut input).unwrap();
    let mut p = input.trim_right().split_whitespace().
        map(|c| c.parse::<u32>().unwrap()).
        collect::<Vec<u32>>();

    p.sort();
    println!("{}", p.iter().take(nm[1] as usize).sum::<u32>());
}

fn main() {
    b();
}


Measured memory_bytes: 2108
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var N, A, B int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d %d", &N, &A, &B)

	ma := min(A, B)
	mi := max(A+B-N, 0)
	fmt.Println(ma, mi)
}

func min(ns ...int) int {
	ret := math.MaxInt64
	for _, n := range ns {
		if n < ret {
			ret = n
		}
	}
	return ret
}

func max(ns ...int) int {
	ret := math.MinInt64
	for _, n := range ns {
		if n > ret {
			ret = n
		}
	}
	return ret
}


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

using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  
  vector<long long> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  
  for(int i = K; i < N; i++){
    if(A[i - K] < A[i]) puts("Yes");
    else puts("No");
  }
  
  return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        int a, b; cin >> a >> b;
        int h, m; cin >> h >> m;
        double w = (h * 60 + m) / 2. - m * 6.;
        cout << fixed << setprecision(10) << sqrt(a * a + b * b - 2 * a * b * cos(w * M_PI / 180));
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<int> freqs(1e5 + 5, 0);
  int a = -1;
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a);
    ++freqs[a];
  }

  int ans = 0, cnt = 0;
  for (int i = 0; i <= 1e5; ++i) {
    if (freqs[i] > 0) {
      ++ans;
      if (freqs[i] % 2 == 0) { ++cnt; }
    }
  }
  ans -= (cnt % 2);
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 640
#include <iostream>

int main() {

  char C11;
  char C12;
  char C13;
  char C21;
  char C22;
  char C23;

  std::cin >> C11 >> C12 >> C13;
  std::cin >> C21 >> C22 >> C23;

  if (C11 == C23 && C12 == C22 && C13 == C21) {
    std::cout << "YES" << std::endl;
  } else {
    std::cout << "NO" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A = LIST()
print(max(A)-min(A))

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

using T = tuple<string,int,int>;

bool restcomp(const T &a, const T &b) {
    if(get<0>(a) != get<0>(b)) return get<0>(a) < get<0>(b);
    if(get<1>(a) != get<1>(b)) return get<1>(a) > get<1>(b);
    return get<2>(a) < get<2>(b);
}
int main(void) {
    int N;
    string s;
    int p;

    cin >> N;
    vector<T> restaurant(N);
    for(int i=0;i<N;i++) {
        cin >> s >> p;
        restaurant[i] = make_tuple(s,p,i+1);
    }

    sort(restaurant.begin(),restaurant.end(), restcomp);

    for(int i=0;i<N;i++) {
        cout << get<2>(restaurant[i]) << endl;
    }
    return 0;
}


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

using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n, m, d;
  cin >> n >> m >> d;

  int diff = (d == 0) ? n : (n - d) * 2;
  printf("%.12lf", 1.0 * diff * (m - 1) / n / n);
}


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


using namespace std;

#define int long long
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define ff first 
#define ss second 
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<string> vs;
typedef map<int,int> mii;
typedef map<char,int> mci;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpii;
template<class T>
istream &operator>>(istream &in, vector<T> &arr){
	for(auto &x: arr) in >> x;
	return in;
}


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
	cin >> n;
	vi a(n);
	cin >> a;
	int ans = 0;
	for(int i = 0; i < n - 1;++i){
		int cur = 0;
		if(a[i + 1] <= a[i]){
			while(i + 1 < n && a[i + 1] <= a[i]){
				cur++;
				++i;
			}
			ans = max(ans,cur);
		}
	}
	cout << ans;
}

Measured memory_bytes: 1024
//#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main()
{
	int y, m, d;
	char c;
	cin >> y >> c >> m >> c >> d;
	if (m <= 4 &&d <= 30) cout << "Heisei" << endl;
	else cout << "TBD" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    int a[n],c[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    c[0]=0,c[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        c[i]=c[i-1]+abs(a[i]-a[i-1]);
        // cout<<c[i]<<endl;
        for(int j=2;j<=k&&i>=j;j++){
            c[i]=min(c[i],c[i-j]+abs(a[i]-a[i-j]));
        }
    }
    cout<<c[n-1]<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)

int ord(char x) {
    return x - 'a';
}
signed main() {
    string S;
    cin >> S;
    int N = S.size();
    map<char, int> cnt;
    int neg = 0;
    rep(i, 0, N) {
        neg += cnt[S[i]];
        cnt[S[i]]++;
    }
    cout << N * (N - 1) / 2 + 1 - neg << endl;
}




Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	private static void p(String s) {System.out.println(s);}
	static Scanner sc = new Scanner(System.in);
	static int a,b,c,n,m;
	public static void main(String[] args) {
		a=sc.nextInt();
		b=sc.nextInt();
		int max=Math.max(a, b);
		int min=Math.min(a,b);
		int ans=max+Math.max(max-1, min);
		p(""+ans);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef unsigned int INT;
typedef unsigned long long LONG;
typedef long long LL;
typedef pair<int, int> PII;
const int N = 1e5 + 10;
const int mod = 1e9 + 7;
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define FW freopen("data2.txt", "w", stdout);
//快速读入输出，只适用于整数，使用时流同步打开，C语言不准关流
// getchar()<<cin(关流)<<scanf()<<cin
template <class T>
inline bool Read(T& ret)
{
    char c;
    int sgn;
    if (static_cast<void>(c = getchar()), c == EOF)
        return 0;
    while (c != '-' && (c < '0' || c > '9'))
        c = getchar();
    sgn = (c == '-') ? -1 : 1;
    ret = (c == '-') ? 0 : (c - '0');
    while (static_cast<void>(c = getchar()), c >= '0' && c <= '9')
        ret = ret * 10 + (c - '0');
    ret *= sgn;
    return 1;
}
//输出只能用于整数
template <class T>
inline void Write(T x)
{
    if (x < 0)
        putchar('-'), x = -x;
    if (x > 9)
        Write(x / 10);
    putchar(x % 10 + '0');
}

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


int main()
{
    int num = 1;
    // cin >> num;
    for (int i = 1; i <= num; ++i) {
        slove(i);
    }
    // system("pause");
    return 0;
}

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

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x)                                         \
  cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
       << " " << __FILE__ << endl;

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

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

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

  string s;
  lint k;
  cin >> s >> k;
  lint res = 0, r = 0, m = 0, l = 0, tmp = 0;
  vector<lint> M;
  bool flag = true;
  rep(i, s.size()) {
    if (s.size() <= i + 1) {
      if (flag) {
        l++;
      } else {
        r = tmp;
        r++;
      }
      continue;
    }
    if (s[i] == s[i + 1]) {
      if (flag) {
        l++;
      } else {
        tmp++;
      }
    } else {
      if (flag) {
        flag = false;
        l++;
      } else {
        if (tmp == 0) continue;
        // m += tmp;
        // m++;
        tmp++;
        M.push_back(tmp);
        tmp = 0;
      }
    }
  }

  // cout << "l = " << l << endl;
  // cout << "m = " << m << endl;
  // cout << "r = " << r << endl;

  if (s.front() == s.back()) {
    for (auto x : M) res += (x / 2) * k;
    res += (r / 2) + (l / 2);
    res += (r + l) / 2 * (k - 1);
  } else {
    for (auto x : M) res += (x / 2) * k;
    res += (r / 2) * k + (l / 2) * k;
  }

  if (flag) {
    if (l % 2) {
      res = (l / 2) * (k + 1) / 2;

      if (1 < k) res += (l + 1) / 2 * (k / 2);
    } else {
      res = (l / 2) * k;
    }
  }

  if (s.size() == 1) {
    res = k / 2;
  }

  cout << res << endl;

  return 0;
}

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

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

using namespace std;

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

struct Data{
  int L,R;//[L,R]
  long long sum;
  Data(int L=0,int R=0,long long sum=0):L(L),R(R),sum(sum){}
  bool operator < (const Data& data)const{
    if( sum != data.sum ) return sum < data.sum;
    return L > data.L;
  }
};


const int IINF = INT_MAX, MAX = 4010;

int n,pre[MAX][MAX],dp[MAX];
ll sum[MAX];

int main(){
  cin >> n;
  vector<ll> A(n);
  rep(i,n){
    cin>>A[i];
    if( i == 0 ) sum[i] = A[i];
    else         sum[i] = sum[i-1] + A[i];
  }

  vector<Data> buf;
  rep(i,n+1)REP(j,i+1,n+1)buf.push_back(Data(i,j,sum[j-1]-((i-1>=0)?sum[i-1]:0LL)));
  sort(buf.begin(),buf.end());
  rep(i,MAX)dp[i] = -IINF;
  rep(i,MAX)rep(j,MAX)pre[i][j] = IINF;

  dp[0] = 0LL;

  int maxcost = -IINF;
  rep(i,buf.size()){
    int cur = buf[i].L, next = buf[i].R;
    //cout << "buf[" << i << "] = " << cur << "," << next << " " << buf[i].sum << endl;
    if( dp[cur] == -IINF ) continue;
    if( dp[next] < dp[cur] + 1 ){
      //cout << "update dp[" << next << "] = " << dp[cur] + 1 << " pre[" << next << "] = " << cur << endl;
      dp[next] = dp[cur] + 1;
      pre[dp[next]][next] = cur;
      maxcost = max(maxcost,dp[next]);
    }
  }


  int cur = n,cnt = IINF;
  vector<int> path;

  for(int i = MAX-1; i >= 0; i-- ) if( pre[i][cur] != IINF ){
      cnt = i;
      break;
    }

  assert( cnt != IINF );
  while( cnt >= 0 && pre[cnt][cur] != IINF ){
    path.push_back(cur);
    cur = pre[cnt][cur];
    cnt--;
  }

  if( !path.empty() )reverse(path.begin(),path.end());
  if( path.size() >= 1)path.erase(path.end()-1);

  cout << path.size() + 1 << endl;
  rep(i,path.size()) {
    if( i ) cout << ' ';
    cout << path[i];
  } cout << endl;

  return 0;
}

Measured memory_bytes: 191256
const chunk = require('fs').readFileSync('/dev/stdin', 'utf8');

const existCard = chunk.split('\n').slice(1);

['S','H','C','D'].forEach(function(suit) {
    for (var rank = 1; rank <= 13; rank++) {
        var card = suit + ' ' + rank;
        if (existCard.indexOf(card) === -1) {
            console.log(card);
        }
    }
});

Measured memory_bytes: 15552
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
string l;
ll dp[100001][2];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>l;
    int n=l.length();
    dp[0][0]=2;
    dp[0][1]=1;
    rep(i,1,n){
        if(l[i]=='1'){
            dp[i][0]=dp[i-1][0]*2%MOD;
            dp[i][1]=(dp[i-1][0]+dp[i-1][1]*3)%MOD;
        }
        else{
            dp[i][0]=dp[i-1][0];
            dp[i][1]=dp[i-1][1]*3%MOD;
        }
    }
    cout <<(dp[n-1][0]+dp[n-1][1])%MOD<<"\n";
}

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

using namespace std;

//////////////////////////
#define int long long
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sync ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define file freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
typedef vector <int> vi;
typedef pair <int , int> pii;
const int inf = INT_MAX;
int gcd(int a, int b) { return (b ? gcd(b, a % b) : a); }
int power(int a, int b) { return (!b ? 1 : power(a, b / 2) * power(a, b / 2) * (b % 2 ? a : 1)); }
//////////////////////////

const int N = 2e5 + 10, MOD = 1e9 + 7;
set <int> adj[N];
vector < pair < pair <int, pii>, int> > edge;
long long ans[N], par[N], weight[N], MST, pw[N];

//functions
void init(int n)
{
    for (int i = 1; i <= n; i ++){par[i] = i;}
}

int root (int i)
{
    while(par[i] != i){
        i = par[i];
        par[i] = par[par[i]];
    }
    return i;
}

void Union(int u, int v, int w, int id)
{
    int root_u = root(u);
    int root_v = root(v);
    if (root_u == root_v) return;
    ans[id] = weight[id];
    if (adj[root_u].size() > adj[root_v].size()) swap(root_u, root_v);
    par[root_u] = root_v;
    for (auto i : adj[root_u]){
        if (adj[root_v].find(i) != adj[root_v].end()) {adj[root_v].erase(i); ans[i] = w;}
        else adj[root_v].insert(i);
    }
    adj[root_u].clear();
    MST += w;
}
int32_t main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, m, x; cin >> n >> m >> x;
    pw[0] = 1;
    for (int i = 1; i <= m; i++) pw[i] = (2 * pw[i - 1]) % MOD;
    init(n);
    for (int i = 0; i < m; i ++){
        int u, v, w; cin >> u >> v >> w;
        edge.push_back({{w, {u, v}}, i});
        weight[i] = w;
        adj[u].insert(i);
        adj[v].insert(i);
    }
    sort(all(edge));
    for (auto e : edge){
        int id = e.second, w = e.first.first, u = e.first.second.first, v = e.first.second.second;
        Union(u, v, w, id);
    }
    int cnt1 = 0, cnt2 = 0, cnt3 = 0;
    for (int i = 0; i < m; i ++) {
        cnt3 += (MST - ans[i] + weight[i]) > x;
        cnt2 += (MST - ans[i] + weight[i]) == x;
        cnt1 += (MST - ans[i] + weight[i]) < x;
    }
    if (cnt2 == 0) return cout << 0 << "\n", 0;
    if (cnt1 == 0) return cout << ((pw[cnt2] - 2 + MOD) * pw[cnt3]) % MOD << "\n", 0;
    cout << 2 * (((pw[cnt2] - 1 + MOD) * pw[cnt3]) % MOD) % MOD << "\n";


    return 0;
}


Measured memory_bytes: 14208
/*
Author : Xinyuan
*/
#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 pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef long long int  ll;
const int INF = 1e9 + 7;
const int mod = 1e9 + 7;
ll powmod(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;}
int nxt() {int x;scanf("%d", &x);return x;}


int main(){
    int cost;
    cin >> cost;
    if (cost % 1000 != 0) {
         cout << ((cost / 1000) + 1) * 1000 - cost;
    }
    else {
        cout << 0;
    }
   
    return 0;
}



Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<map>

using namespace std;

int N,S,W,Q;

int a[100000];

void solve(){

	unsigned int res=0;
	map<int,int> M;
	M.clear();

    int g = S;
    for(int i=0; i<N; i++) {
        a[i] = (g/7) % 10;
        if( g%2 == 0 ) { g = (g/2); }
        else           { g = (g/2) ^ W; }
    }

	if(Q==2 || Q==5){
		int count=0;
		for(int i=N-1;i>=0;i--){
			if(a[i]%Q==0)
				count++;
			if(a[i]!=0)
				res+=count;
		}
		cout<<res<<endl; return;
	}


	res=0;
	int mul=1;
	int bef=0;

	for(int i=N-1;i>=0;i--){
		bef=(a[i]*mul+bef)%Q;
		if(a[i]!=0){
			if(bef==0) res++;
			res+=M[bef];
		}
		if(!M.count(bef)) M[bef]=1;
		else
			M[bef]++;
	
		mul=(10*mul)%Q;
	}
	cout<<res<<endl;
}

int main(){

	while(cin>>N>>S>>W>>Q){
		if(N==0 && S==0 && W==0 && Q==0) break;
		solve();
	}
	return 0;
}

Measured memory_bytes: 0
a, b, k = map(int, input().split())

if a+k-1 >= b-k+1:
    for i in range(a, b+1):
        print(i)
else:
    for i in range(a, a+k):
        print(i)
    for i in range(b-k+1, b+1):
        print(i)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
 
long long N;
long long mod = 1000000007;
long long zero_bit[60];
long long one_bit[60];
 
int main() {
    std::cin >> N;
 
    std::vector<long long> A(N);
    for (long long i = 0; i < N; i++) {
        std::cin >> A[i];
        for (long long bit = 0; bit < 60; bit++) {
            ((A[i] >> bit) & 1) ? one_bit[bit]++ : zero_bit[bit]++;
        }
    }
 
    long long result = 0;
    for (long long bit = 0; bit < 60; bit++) {
        long long tmp = 1;
        tmp *= (1LL << bit);
        tmp %= mod;
        tmp *= one_bit[bit];
        tmp %= mod;
        tmp *= zero_bit[bit];
        tmp %= mod;
        result += tmp;
        result %= mod;
    }
 
    std::cout << result << std::endl;
    return 0;
}


Measured memory_bytes: 2560