akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<string>
using namespace std;


int main() {
	long int N;
	cin >> N;
	vector<string> S(N);
	long long int Y = 0;
	long long int M = 0;
	long long int A = 0;
	long long int R = 0;
	long long int C = 0;
	long long int H = 0;

	for (int i = 0; i < N; i++) {
		cin >> S[i];
		if (S[i].at(0) == 'M') {
			M++;
		}
		else if (S[i].at(0) == 'A') {
			A++;
		}
		else if (S[i].at(0) == 'R') {
			R++;
		}
		else if (S[i].at(0) == 'C') {
			C++;
		}
		else if (S[i].at(0) == 'H') {
			H++;
		}
	}

	if (M > 0 && A > 0 && R > 0) {
		Y += M * A*R;
	}
	if (M > 0 && A > 0 && C > 0) {
		Y += M * A*C;
	}if (M > 0 && A > 0 && H > 0) {
		Y += M * A*H;
	}if (M > 0 && R > 0 && C > 0) {
		Y += M * R*C;
	}if (M > 0 && H > 0 && R > 0) {
		Y += M * H*R;
	}if (M > 0 && C > 0 && H > 0) {
		Y += M*C*H;
	}if (A > 0 && C > 0 && R > 0) {
		Y += A * C*R;
	}if (H > 0 && A > 0 && R > 0) {
		Y += H * A*R;
	}if (C > 0 && A > 0 && H > 0) {
		Y += C * A*H;
	}if (H > 0 && C > 0 && R > 0) {
		Y += H * C*R;
	}
	cout << Y << endl;

	return 0;
}






Measured memory_bytes: 6144
program main
implicit none
integer :: i, len
character :: s*3, t*3

read(*,*) s
len = len_trim( s )
if( len== 2 ) then
 t = s
else
 do i = 1, 3
   t(i:i) = s(4-i:4-i)
end do
end if
write(*,'(a)') t
 


end program main


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll  long long
#define Cr7 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define N   100100
ll n,m,x,y,a[N],Res;
vector<ll> my[N];
int main()
{
    Cr7
    cin>>n>>m;
    for(ll i=1 ; i<=n ; i++)    cin>>a[i];
    for(ll i=1 ; i<=m ; i++)
    {
        cin>>x>>y;
        my[x].push_back(y);
        my[y].push_back(x);
    }
    for(ll i=1 ; i<=n ; i++)
    {
        bool Can=1;
        for(ll v : my[i])   Can&=(a[i] > a[v]);
        Res+=Can;
    }
    cout<<Res<<endl;
    return 0;
}


Measured memory_bytes: 10248
#include <bits/stdc++.h>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define EPS (1e-14)
#define _PA(x,N) rep(i,N){cout<<x[i]<<" ";}cout<<endl;
#define _PA2(x,H,W) rep(i,(H)){rep(j,(W)){cout<<x[i][j]<<" ";}cout<<endl;}

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

ll N, A, B;
ll v[55];

set<ll> S, T;
map<ll, ll> freq;

double ave = 0.0;
ll ans;

ll C[1005][1005];
void combination(int size) {
	for (int i = 0; i < size; i++) C[i][0] = 1LL;
	for (int i = 1; i < size; i++) {
		for (int j = 1; j <= i; j++) {
			C[i][j] = (C[i-1][j-1] + C[i-1][j]);
		}
	}
}

void solve() {
	combination(55);
	rep(i, N) {
		freq[v[i]] += 1;
	}
	sort(v, v+N);
	reverse(v, v+N);

	for (int i = 0; i < A; i++) {
		ave += v[i];
		T.insert(-v[i]);
	}
	ave /= A;

	if (T.size() == 1) {
		ll f = freq[-(*T.begin())];
		ans = 0;
		for (ll i = A; i <= min(f, B); i++) {
			ans += C[f][i];
			//printf("C[%lld][%lld]=%lld\n", f, i, C[f][i]);
		}
	} else {
		ans = 1;
		int i = 0, s = 0;
		set<ll>::iterator itr = T.begin();
		for (; i < (int)T.size()-1; i++, itr++) {
			ll x = -(*itr);
			ans = ans * freq[x];
			s += freq[x];
		}
		ll f = freq[-(*itr)];
		ans = ans * C[f][A-s];
	}
	printf("%.12f\n", ave);
	cout << ans << endl;
}

int main() {
	cin >> N >> A >> B;
	rep(i, N) {
		cin >> v[i];
	}
	solve();
	return 0;
}




Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

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

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int dfs(int node, int parent, const vector<vector<int>> &edge) {
  int grundy = 0;
  for (int c : edge[node]) {
    if (c != parent) {
      grundy ^= dfs(c, node, edge) + 1;
    }
  }
  return grundy;
}

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

  vector<vector<int>> edge(N);
  rep(i, N - 1) {
    int u, v;
    cin >> u >> v;
    u--;
    v--;
    edge[u].push_back(v);
    edge[v].push_back(u);
  }

  cout << (dfs(0, 0, edge) != 0 ? "Alice" : "Bob") << "\n";

  return 0;
}

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

using namespace std;

typedef pair<int, int> P_ii;
typedef pair<string, int> P_si;
typedef long long int ll;

const int MOD = 1000000007;

int main() {
    ll S;
    cin >> S;

    const ll MAX = 1000000000;
    ll X_1 = 0, Y_1 = 0, X_2 = MAX, Y_2 = 1;
    for (ll Y_3 = 0; Y_3 <= MAX; ++Y_3) {
        ll X_3 = MAX * Y_3 - S;
        if (X_3 >= 0 && X_3 <= MAX) {
            printf("%lld %lld %lld %lld %lld %lld", X_1, Y_1, X_2, Y_2, X_3, Y_3);
            return 0;
        }
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

    int N; cin >> N;
    vc<tuple<string,int,int>> v;
    rep(i,N){
        string s; int n; cin >> s >> n;
        v.eb(s,-n,i+1);
    }
    sort(all(v));
    for(auto a:v){
        cout << get<2>(a) << endl;
    }
}

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	n, m := readInt(), readInt()
	b := make([]byte, n)
	for i := range b {
		b[i] = 'a'
	}

	for i := 0; i < m; i++ {
		s := readInt() - 1
		c := readBytes()[0]
		if b[s] != 'a' && b[s] != c {
			fmt.Println(-1)
			return
		}
		b[s] = c
	}

	if n == 1 {
		if b[0] == 'a' {
			fmt.Println(0)
		} else {
			fmt.Println(string(b))
		}
		return
	}

	if b[0] == '0' {
		fmt.Println(-1)
		return
	}

	if b[0] == 'a' {
		b[0] = '1'
	}
	for i := 1; i < n; i++ {
		if b[i] == 'a' {
			b[i] = '0'
		}
	}

	fmt.Println(string(b))
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


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

using namespace std;

bool cmp(const pair<long long, long long>& n, const pair<long long, long long> &m)
{
  return n.second > m.second;
}

int main()
{
  int n, m;
  cin >> n >> m;
  
  vector<long long> a;
  vector<pair<long long, long long>> b_c;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
	long long tmp;
	cin >> tmp;
	a.push_back(tmp);
	sum += tmp;
  }

  for (int i = 0; i < m; i++) {
	long long b_tmp, c_tmp;
	cin >> b_tmp >> c_tmp;
	b_c.push_back(make_pair(b_tmp, c_tmp));
  }

  /* sort */
  sort(a.begin(), a.end());
  sort(b_c.begin(), b_c.end(), cmp);

  int id = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < b_c[i].first; j++) {
	  if (a[id] < b_c[i].second) {
		sum = sum -  a[id] + b_c[i].second;
		a[id] = b_c[i].second;
		id++;
		
		if (id >= n) {
		  i = m;
		  break;
		}
	  } else {
		i = m;
		break;
	  }
	}
  }

  cout << sum << endl;



  return 0;
}


Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;

int main(){
	int a;
	string s;
	cin >> a >> s;
	if (a >= 3200) cout << s << endl;
	else cout << "red" << endl;
 	return 0;
}



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

int main(int argc, char *argv[]){
  long long N,T,sum=0;
  cin>>N>>T;
  long long ar[N+2];
  ar[N+1]=10000000000;
  for(int i=1; i<N+1; i++){
    long long t;
    cin>>t;
    ar[i]=t;
  }
  for(int i=1; i<N+1; i++){
    //cout<<ar[i+1]<<endl;
    if(ar[i+1]-ar[i]>=T) sum+=T;
    else{
      long long time=ar[i+1]-ar[i];
      sum+=time;
    }
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <queue>

int main()
{
  int n, q;
  
  std::cin >> n >> q; // n (number of processes), q (quantum length)
  std::queue< std::pair<std::string, int> > Q; // create a queue of pairs (processs)

  std::string name; // name of process
  int time; // time taken for each process
  
  for (int i = 0; i < n; ++i) {
    std::cin >> name >> time;
    Q.push(make_pair(name, time)); // read pairs into queue
  }

  int time_stamp = 0;
  std::pair<std::string, int> candidate;

  while (!Q.empty()) { 
    candidate = Q.front(); // next candidate to process
    if (candidate.second <= q) { // if less than or equal to quantum
      time_stamp += candidate.second;
      std::cout << candidate.first << " " << time_stamp  << std::endl; //output
      Q.pop(); 
    } else { // if more than quantum, have to enqueue
      time_stamp += q;
      candidate.second -= q; // deduct time by quantum
      Q.pop();
      Q.push(candidate); //enqueue
    }
  }
  return 0;
}

Measured memory_bytes: 4400
using System;
class p
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    string[] ipt = Console.ReadLine().Split(' ');
    int[] arr = new int[N];
    for (int i = 0; i < N; i++) {
      arr[i] = int.Parse(ipt[i]);
    }
    int count = 1, min = arr[0];
    for (int i = 1; i < N; i++) {
      if (arr[i] <= min) {
        count++;
      }
      min = Math.Min(min, arr[i]);
    }
    Console.WriteLine(count);
  }
}

Measured memory_bytes: 33116
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==5&&b==7&&c==5) cout<<"YES";
	 else if(a==5&&b==5&&c==7) cout<<"YES";
	 else if(a==7&&b==5&&c==5) cout<<"YES";
	else cout<<"NO";
	return 0;
	
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int N, K, C;
    string s;

    scan(N, K, C);
    scan(s);

    auto f = new int[](K);
    auto r = new int[](K);
    f[] = inf;
    r[] = -inf;

    int p = -inf;
    int k = 0;
    foreach (i ; 0 .. N) {
        if (k >= K) break;
        if (s[i] == 'x' || i - p <= C) continue;
        f[k] = i;
        k++;
        p = i;
    }

    p = inf;
    k = K - 1;
    foreach_reverse (i ; 0 .. N) {
        if (k < 0) break;
        if (s[i] == 'x' || p - i <= C) continue;
        r[k] = i;
        k--;
        p = i;
    }

    debug {
        writeln(f);
        writeln(r);
    }

    int[] ans;
    foreach (i ; 0 .. K) {
        if (f[i] == r[i]) ans ~= f[i] + 1;
    }

    writefln("%(%s\n%)", ans);
}



void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 4860
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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

  if((a-b)>=c){
    cout<<0<<endl;
  }else{
    cout<<c-(a-b)<<endl;
  }
}



Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
using namespace std;
  
int main(){
  double a, b, c, d, e, f;
  while( cin >> a >> b >> c >> d >> e >> f){
    double y = ( a * f - c * d) / ( a * e - b * d);
    double x = ( c - b * y ) / a;
    cout << fixed << setprecision(3) << x << " " << y << endl;
  }
  return 0;
}


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

int main() {
    int n,t,o1,o2;

    cin >> n;
    cin >> t;
    cin >> o1;
    cin >> o2;

    if ((n - t) <= 0) {
        cout << n * o1;
    } else {
        cout << (t*o1) + ((n-t)*o2);
    }

    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N;
    scan(N);
    auto A = readln.split.to!(int[]);
    auto B = readln.split.to!(int[]);
    auto C = readln.split.to!(int[]);

    auto ans = B.sum();
    foreach (i ; 0 .. N - 1) {
        if (A[i] == N) continue;
        ans += (A[i] + 1 == A[i + 1]) * C[A[i] - 1];
    }
    writeln(ans);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int i,j,k,n,x,y,z,a[100],b[100],c[100],flg,cnt;
	flg=0;
	cin>>n>>x;
	for(i=0;i<x;i++){
		cin>>a[i];
	}
	cin>>y;
	for(i=0;i<y;i++){
		cin>>b[i];
	}
	cin>>z;
	for(i=0;i<z;i++){
		cin>>c[i];
	}
	cnt=z;
	for(i=0;i<x;i++){
		for(j=0;j<z;j++){
			if(a[i]==c[j]) cnt=cnt-1;
			for(k=0;k<y;k++){
				if(c[j]==b[k] && a[i]==c[j]) cnt=cnt+1;
			}
		}
	}

	
	cout<<cnt<<endl;
	return 0;
}

	


Measured memory_bytes: 3116
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <math.h>
#include <bitset>
#include <queue>

using namespace std;

void solve() {
    int n, t;
    cin >> n >> t;
    int oyutime = 0;
    int endtime = 0;
    for(int i = 0; i < n; i++) {
        int time;
        cin >> time;
        // お湯が出ていないときに押したとき
        if(endtime < time) {
            oyutime += t;
            endtime = time+t;

        // お湯が出ているときに押したとき
        } else {
            oyutime += (time+t - endtime);
            endtime = time+t;
        }
    }
    cout << oyutime;
}

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

Measured memory_bytes: 256
#ifdef _DEBUG
#define _CRT_SECURE_NO_WARNINGS
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define MGN 8
#define LINF (LONG_MAX/2)
using namespace std;
typedef long long ll; typedef unsigned long long ull;
typedef vector<int> vi; typedef vector<vi> vvi; 
typedef vector<ll> vl; typedef vector<vl> vvl;
typedef vector<double> vd; typedef vector<string> vs;
typedef pair<int, int> pii; typedef pair<ll, ll> pll;
typedef vector<bool> vb; typedef vector<vb> vvb;
template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
    return left.second > right.second;}
vs split(string str, char sep) {
    vs v; stringstream ss(str); string t;
    while (getline(ss, t, sep)) v.push_back(t);
    return v;}
vs re_search_g(string s, regex re) {
    vs ret; smatch mc; auto it = s.cbegin();
    while (regex_search(it, s.cend(), mc, re)) {
        ret.push_back(mc[0]);
        it += mc.position(0) + mc.length();}
    return ret;}
#endif

void init_global_A() {}


int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int X, A, B; cin >> X >> A >> B;

    string ans = "";
    if (B <= A) ans = "delicious";
    else if (B <= A + X) ans = "safe";
    else ans = "dangerous";

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    string s;
    cin >> s;
    ll n = s.size();

    string ans = "";
    rep(i, n) {
        if(s[i] == '0') {
            ans = ans + "0";
        }
        else if(s[i] == '1') {
            ans = ans + "1";
        }
        else if(s[i] == 'B') {
            if(ans == "") {
                continue;
            }
            ans.pop_back();
        }
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

H.reverse()

ans = 0

now = 0
tmp = 0
for h in H:
    if h >= now and now != 0:
        tmp += 1
    else:
        tmp = 0
    ans = max(ans, tmp)
    now = h

print(ans)


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

using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db double
#define eps 1e-6
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define mp(a, b) make_pair(a, b)
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define pi acos(-1.0)
const ll maxn = 3e5 + 10;
const ll mod = 1e9 + 7;
signed main()
{
    ll a, b;
    cin >> a >> b;
    
    int res = 0;
    while(a){
        res++;
        a/=b;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
a, b, k = map(int, input().split())
takahashi = a
aoki = b
if takahashi > k:
    takahashi -= k
elif takahashi <= k:
    takahashi = 0
    if aoki > k - a:
        aoki -= k - a
    elif aoki <= k - a:
        aoki = 0
print(takahashi, aoki)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define modulo 1000000007
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N=1e6+1;

void solve()
{ 
    int n;
    cin >> n;
    vector<int>a(n),b;
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a.begin(),a.end(),greater<int>());
    for(int i=0;i<n;i++)
    {
        b.emplace_back(a[i]);
        if(i)b.emplace_back(a[i]);
    }
    ll ans=0;
    for(int i=0;i<n-1;i++)ans+=b[i];
    cout << ans << endl;
}

int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    fast;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

using namespace std;

int main()
{

    int n;

    scanf("%d",&n);

    map<string,int> mp;

    string s1,s2;

    while(n--)
    {
        cin>>s1>>s2;

        if(s1[0]=='i')
        {
            mp[s2]++;
        }else if(s1[0]=='f')
        {
            if(mp.find(s2)!=mp.end())
            {
                cout<<"yes"<<endl;
            }else
            {
                cout<<"no"<<endl;
            }
        }
    }



    return 0;
}



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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> A(N+2);
    A[0] = A[N+1] = 0;
    for ( int i = 1; i <= N; i++ ) {
        cin >> A[i];
    }
    ll a_sum = 0;
    for ( int i = 1; i <= N+1; i++ ) {
        a_sum += abs(A[i]-A[i-1]);
    }
    for ( int i = 1; i <= N; i++ ) {
        ll x = a_sum - abs(A[i]-A[i-1]) - abs(A[i+1]-A[i]) + abs(A[i+1]-A[i-1]);
        cout << x << "\n";
    }
    return 0;
}

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

Measured memory_bytes: 2048
K = int(input())

if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    i = 1
    v = 7
    while True:
        if v % K == 0:
            print(i)
            break
        else:
            i += 1
            v = v * 10 + 7
            v %= K


Measured memory_bytes: 63244
#include <stdio.h>

int main(void)
{
  int A,B,K,i,a,b,x,y;

  scanf("%d%d%d",&A,&B,&K);

  a = 0;
  b = 0;
  if (A > B){
    a = B;
  }
  else {
    a = A;
  }
  for (i=a;b<K;i--){
    x = A % i;
    y = B % i;
    if (x==0 && y==0){
      b++;
    }
  }
  printf("%d\n",i+1);
  return 0;
}


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


int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  vector<vector<ll>> dp(n, vector<ll>(n, 0));
  rep(i, n)
  {
    cin >> a[i];
    if (n % 2 == 1)
      dp[i][i] = a[i];
    else
      dp[i][i] = -a[i];
  }
  for (int l = 1; l < n; l++)
    rep(i, n - l)
      if (l % 2 != n % 2)
        dp[i][i+l] = max(a[i] + dp[i+1][i+l], a[i+l] + dp[i][i+l-1]);
      else
        dp[i][i+l] = min(-a[i] + dp[i+1][i+l], -a[i+l] + dp[i][i+l-1]);
  cout <<  dp[0][n-1] << endl;
  return 0;
}

Measured memory_bytes: 70656
N = int(input())

M = N

num_list = []

while M > 26:
    r = M % 26
    
    if r != 0:
        M = M // 26
    
    if r == 0:
        r = 26
        M = M // 26 - 1
    
    num_list.append(r)

if M != 0:    
    num_list.append(M)

num_list.reverse()

result = str()

for a in num_list:
    result = result + chr(a + 64).lower()

print(result)

Measured memory_bytes: 9196
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class Main {
	static int[] dx = {-1, 0, 1, 0};
	static int[] dy = {0, -1, 0, 1};

	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		out = new PrintWriter(new BufferedOutputStream(System.out));
		int h = sc.nextInt();
		int w = sc.nextInt();
		int k = sc.nextInt();
		int x1 = sc.nextInt()-1;
		int y1 = sc.nextInt()-1;
		int x2 = sc.nextInt()-1;
		int y2 = sc.nextInt()-1;
		char[][] arr = new char[h][w];
		int[][] dp = new int[h][w];
		int count = 0;
		for (int i = 0; i < h; i++) {
			String s = sc.next();
			for (int j = 0; j < w; j++) {
				arr[i][j] = s.charAt(j);
				if (arr[i][j] == '.') {
					count++;
				}
			}
		}
		int[] q = new int[count];
		q[0] = x1*w+y1;
		dp[x1][y1] = 1;
		int current = 0;
		int size = 1;
		while (current < size) {
			int x = q[current++];
			int a = x/w;
			int b = x%w;
			for (int i = 0; i < 4; i++) {
				for (int j = 1; j <= k; j++) {
					if (a+j*dx[i] < 0 || a+j*dx[i] >= h || b+j*dy[i] < 0 || b+j*dy[i] >= w || arr[a+j*dx[i]][b+j*dy[i]] == '@' || (dp[a+j*dx[i]][b+j*dy[i]] > 0 && dp[a][b]+1 > dp[a+j*dx[i]][b+j*dy[i]])) {
						break;
					}
					if (dp[a+j*dx[i]][b+j*dy[i]] == 0) {
						dp[a+j*dx[i]][b+j*dy[i]] = dp[a][b]+1;
						q[size++] = (w*(a+j*dx[i])+b+j*dy[i]);
					}
				}
			}
		}
		System.out.println(dp[x2][y2]-1);
	}
	
	public static PrintWriter out;
	
	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				}
				catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			}
			catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

}


Measured memory_bytes: 49064
a,b,k=map(int,input().split())
ans=[]
for i in range(a,min(a+k,b+1),1):
    ans.append(i)
for i in range(b,max(a-1,b-k),-1):
    ans.append(i)
ans=list(set(ans)) #重複を削除
ans.sort() #ソート
for i in ans:
    print(i)

Measured memory_bytes: 9144
N,L=map(int,input().split())

ns=[i+L for i in range(N)]

min_idx = -1
mins = None
for idx, n in enumerate(ns):
    if mins is None:
        mins = abs(n)
        min_idx = 0
    else:
        if mins > abs(n):
            min_idx = idx
            mins = abs(n)

ns.pop(min_idx)
print(sum(ns))

Measured memory_bytes: 3064
#include<iostream>
#include<map>

using namespace std;
using ll = long long;

int main() {
	ll  N;
	cin>>N;
	map<ll, ll> sub;
	ll x;
	for (int i = 1;i < N;++i) {
		cin>>x;
		sub[x] += 1;
	}

	for (int i = 1;i <= N;++i) {
		cout<<sub[i]<<endl;
	}

	return 0;
}


Measured memory_bytes: 16132
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit


def main(readline=stdin.readline):
    price_table = (
        0, 0, 380, 550, 760, 850, 1100, 1230, 1400, 1610, 1520, 1950,
        1870, 2070, 2250, 2244, 2620, 2624, 2794, 3004, 3040, 3344,
        3390, 3590, 3740, 3764, 4120, 4114, 4314, 4494, 4488, 4864,
        4868, 5038, 5248, 5284, 5588, 5634, 5834, 5984, 6008, 6364,
        6358, 6558, 6738, 6732, 7108, 7112, 7282, 7492, 7528
        )
    while 1:
        weight = int(readline())
        if not weight:
            exit()
        print(price_table[weight//100])


if __name__ == '__main__':
    main()

Measured memory_bytes: 4240
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    
    int ab = a + b;
    int bc = b + c;
    int ca = c + a;
    
    if ((ab <= bc) && (ab <= ca)) {
      System.out.println(ab);
    } else if ((bc <= ab) && (bc <= ca)) {
      System.out.println(bc);
    } else {
      System.out.println(ca);
    }
  }
}

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

using namespace std;

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

	#ifdef LOCAL
	assert(freopen("input.txt", "r", stdin));
	#endif

	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	vector<int> p(n);
	for (int i = 0; i + 1 < n; i++) {
		if (s[i] == 'A' && s[i + 1] == 'C') {
			p[i] = 1;
		}
	}		
	vector<int> ps(n);
	ps[0] = p[0];
	for (int i = 1; i < n; i++) {
		ps[i] = ps[i - 1] + p[i];
	}
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		l--;
		r--;
		r--;
		int ans = ps[r] - (l == 0 ? 0 : ps[l - 1]);
		ans = max(ans, 0);
		cout << ans << '\n';
	}
}



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

#define int long long
#define endl '\n'
#define eps  1e-9
const double pi=acos(-1);
const int mod=1e9+7;
const int inf=1e15;
//____________________

const int MAXV=1e5+5,N=105;

int dp[MAXV][N],val[N],w[N],n;

int minWeight(int v,int idx)
{

  if(v==0)
    return 0;
  if(v<0)
    return inf;

  if(idx==0)
    return inf;

  int &ans=dp[v][idx];
  if(ans!=-1)
    return ans;

  ans=min(w[idx]+minWeight(v-val[idx],idx-1),minWeight(v,idx-1));
  return ans;
}

int32_t main()
{ 
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
 
  
  int W;
  cin>>n>>W;
  
  for(int i=1;i<=n;i++)
  {
    cin>>w[i]>>val[i];
  }

  memset(dp,-1,sizeof(dp));

  int ans=0;

  for(int vv=1;vv<MAXV;vv++)
  {
    int minwt=minWeight(vv,n);
    if(minwt<=W)
      ans=vv;
  }
  
  cout<<ans;

 return 0;
}

Measured memory_bytes: 82304
// In the name the Allah the Most Merciful.

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int INF = 1e9;

int main(void)
{
    int n , k;
    scanf("%d %d",&n , &k);
    vector<int>v(n);
    for(auto &x : v){
        scanf("%d",&x);
    }
    vector<int>dp(n , INF);
    dp[0] = 0;
    for(int i=0;i<n;i++){

        for(int j=1;j<=k;j++){

            if(j+i<n){

                dp[i+j] = min(dp[i+j] , dp[i]+abs(v[i]-v[i+j]));
            }
        }
    }
    printf("%d\n",dp[n-1]);
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int n,q;
vector<vector<int>> tree(200000, vector<int>());

int main() {
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;

    cout << (char)(s1.front()-0x20) << (char)(s2.front()-0x20) << (char)(s3.front()-0x20) << endl;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int min(int a,int b)
{
    if(a<b)
        return a;
    return b;

}

int main()
{
    int n;
    cin>>n;
    int cost[n];
    for(int i=0;i<n;i++)
        cin>>cost[i];
    int vl[n];
    vl[0]=0;
    vl[1]=abs(cost[1]-cost[0]);
    for(int i=2;i<n;i++)
    vl[i]=min(vl[i-2]+abs(cost[i]-cost[i-2]),vl[i-1]+abs(cost[i]-cost[i-1]));
    cout<<vl[n-1];






    return 0;

}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int M = sc.nextInt();

        int[][] sw = new int[M][];
        for(int i = 0; i < M; i++) {
            sw[i] = new int[sc.nextInt()];
            for (int j=0; j<sw[i].length; j++){
                sw[i][j] = sc.nextInt();
            }
        }
        int[] p = new int[M];
        for (int i=0; i<M; i++){
            p[i] = sc.nextInt();
        }
        sc.close();

        int count = 0;

        for (int i=0; i < Math.pow(2, N); i++){
            String str = Integer.toBinaryString(i);

            str = String.format("%10s", str);
            str.replace("","0");

            String[] strArray = str.split("");

            int num=0;

            for (int j=0; j<M; j++){

                int t = 0;
                for (int k=0; k<sw[j].length; k++){
                    if(strArray[10-sw[j][k]].equals("1")){
                        t++;
                    }
                }

                if(t%2 != p[j]){
                    break;
                }else{
                    num++;
                }
            }
            if (num == M){
                count++;
            }
        }

        System.out.println(count);


    }
}


Measured memory_bytes: 29396
#include <iostream>
#include <string>
#include <complex>
#include <cstdlib>

using namespace std;

int main()
{
  int N;
  cin >> N;
  int t, x, y;
  int pos_x = 0;
  int pos_y = 0;
  int diffsum = 0;
  int now_t = 0;
  for (int i = 0; i < N; i++) {
    cin >> t >> x >> y;
    diffsum = t - now_t;
    // cerr << "diffsum: " << diffsum << endl;
    if ( (diffsum >= abs(pos_x - x) + abs(pos_y - y)) && ((diffsum - abs(pos_x - x) - abs(pos_y - y))%2== 0)) {
      pos_x = x;
      pos_y = y;
      now_t = t;
      continue;
    }
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;


  return 0;
}

Measured memory_bytes: 256
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline-------------------------------------------
    H,W = map(int,input().split())
    N = int(input())
    a = list(map(int,input().split()))
    p = [[]*W for i in range(H)]
    psub = []
    for i in range(N):
        for j in range(a[i]):
            psub.append(i+1)
    for i in range(H):
        for j in range(W):
            p[i].append(psub[i*W+j])
        if i % 2 != 0:
            p[i] = p[i][::-1]
    for i in range(H):
        print(*p[i],sep = " ")


if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 6036
#include <iostream>
#include <cassert>
#include <algorithm>
#include <functional>
using namespace std;

int main(){
    long long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;

    long long m;
//    m= min( min( min( min(A, B), C), D), E);
    m=min({A, B, C, D, E});
    long long t = (N+m-1)/m; //一番遅い人がBまでいく時間

    cout << t+4 << endl;
}

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Scanner;
import java.awt.Point;

class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int h = in.nextInt();
		int w = in.nextInt();
		String[][] map = new String[h][w];
		String[][] copy = new String[h][w];
		for (int i = 0; i < map.length; i++) {
			map[i] = in.next().split("");
			copy[i] = Arrays.copyOf(map[i], map[i].length);
		}
		int max = 0;
		for (int l = 0; l < w; l++) {
			for (int m = 0; m < h; m++) {
				for (int n = 0; n < w; n++) {
					for (int o = 0; o < h; o++) {
						Point start = new Point(l, m);
						Point goal = new Point(n, o);
						int move = bfs(h, w, start, goal, map);
						if (max < move) {
							max = move;
						}
						for (int i = 0; i < map.length; i++) {
							map[i] = Arrays.copyOf(copy[i], copy[i].length);
						}
					}
				}
			}
		}
		System.out.println(max);
	}

	static int bfs(int h, int w, Point start, Point goal, String[][] map) {
		ArrayDeque<Point> dq = new ArrayDeque<>();
		dq.add(start);
		int[][] moves = new int[h][w];
		if(map[(int) start.getY()][(int) start.getX()].equals("#") || 
		   map[(int) goal.getY()][(int) goal.getX()].equals("#")){
			return 0;
		}
		map[(int) start.getY()][(int) start.getX()] = "#";
		Point[] D4 = { new Point(0, -1), new Point(1, 0), new Point(0, 1), new Point(-1, 0) };
		while (dq.size() > 0) {
			Point p = dq.removeFirst();
			for (int i = 0; i < 4; i++) {
				int x = (int) p.getX() + (int) D4[i].getX();
				int y = (int) p.getY() + (int) D4[i].getY();
				if (x > -1 && x < w && y > -1 && y < h && map[y][x].equals(".")) {
					dq.addLast(new Point(x, y));
					map[y][x] = "#";
					moves[y][x] = moves[(int) p.getY()][(int) p.getX()] + 1;
					if(y == (int)goal.getY() && x == (int)goal.getX()){
						return moves[(int) goal.getY()][(int) goal.getX()];
					}
				}
			}
		}
		return 0;
	}
}


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i, n) for(int i = 0; i < (n); ++i)
const ll mod = 1e9 + 7;

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;
}

bool pairCompare(const P &firstElof, const P &secondElof) {
    return firstElof.second < secondElof.second;
}

int main() {
    string s, t;
    cin >> s >> t;
    if(s == t.substr(0, s.length())) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	string s;
	while(cin>>a>>b){
		cin>>s;
		int cnt=0;
		for(int i=0;i<s.length();++i){
			if(s[i]=='-')cnt++;	
		}
		if(s[a]=='-'&&cnt==1) cout<<"Yes";
		else cout<<"No";	
	}
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

int main(){
    ll n,k;cin>>n>>k;
    ll a[n];rep(i,n)cin>>a[i];
    ll kbi[40];
    memset(kbi,0,sizeof(kbi));
    int p=0;
    while(k>1){
        if(k%2==1){
            kbi[p]=1;
        }
        k/=2;
        ++p;
    }
    if(k)kbi[p]=1;
    ll ideal[40];
    memset(ideal,0,sizeof(ideal));
    rep(i,n){
        rep(j,40){
            if((1LL<<j)&a[i])ideal[j]++;
        }
    }
    ll dp[2][41];
    memset(dp,0,sizeof(dp));
    dp[0][0]=-1;
    rep(i,40){
        if(kbi[39-i]==0){
            if(dp[0][i]==-1)dp[0][i+1]=-1;
            else dp[0][i+1]=dp[0][i]+max(n-ideal[39-i],ideal[39-i])*(1LL<<(39-i));
            dp[1][i+1]=dp[1][i]+ideal[39-i]*(1LL<<(39-i));
        }
        else{
            dp[1][i+1]=dp[1][i]+(n-ideal[39-i])*(1LL<<(39-i));
            if(dp[0][i]==-1)dp[0][i+1]=dp[1][i]+ideal[39-i]*(1LL<<(39-i));
            else dp[0][i+1]=max(dp[1][i]+ideal[39-i]*(1LL<<(39-i)),dp[0][i]+max(n-ideal[39-i],ideal[39-i])*(1LL<<(39-i)));
        }
    }
    cout<<max(dp[0][40],dp[1][40])<<endl;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s; cin>>s;
	if (s=="A") cout<<"T";
	else if (s=="T") cout<<"A";
	else if (s=="C") cout<<"G";
	else if (s=="G") cout<<"C";
	else cout<<endl;
	return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	cout << a / b << " " << a % b << " ";
	cout << fixed << setprecision(10) << (double)a / b << endl;
}


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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)
#define fi first
#define se second

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int a[100000], b[100000], c[100000];

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

    int n;
    cin >> n;
    rep(i, n) cin >> a[i];
    rep(j, n) cin >> b[j];
    rep(k, n) cin >> c[k];
    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);
    int res = 0;
    rep(i, n) {
        int a_it = lower_bound(a, a + n, b[i]) - a;
        int c_it = upper_bound(c, c + n, b[i]) - c;
        res += a_it * (n - c_it);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
const int maxn = 3e5+7;
const int mod = 1e9+7;
typedef long long ll;

int n,m;

int ar[maxn], cnt[maxn];
int main()
{
    vector<int> ans;
    scanf("%d", &n);
    for(int i=1;i<=n;i++)scanf("%d", &ar[i]);
    for(int i=n;i>=1;i--){
        int ins=0;
        for(int j=i*2;j<=n;j+=i){
            ins+=cnt[j];
        }
        if(ins%2 == ar[i]);
        else{
            cnt[i] = 1;
            ans.push_back(i);
        }
    }
    printf("%d\n", ans.size());

    for(int i=0;i<ans.size();i++){
        printf("%d%c", ans[i], i==ans.size()-1 ? '\n':' ');
    }
    return 0;
}


Measured memory_bytes: 2936
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vll vector<ll>
#define vpll vector<pll>
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(),x.end()
#define mod 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	string s;
	cin>>s;
	for(ll i=0;i<s.length();i++){
		s[i]-='A';
		s[i]+=n;
		s[i]%=26;
		s[i]+='A';
	}
	cout<<s;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define int long long
#define F first
#define S second
#define P pair
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define V vector
#define RE return
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
#define PF push_front
#define FILL(a,b) memset(a,b,sizeof(a))
using namespace std;
int n,a[200005],used[200005];char c[200005];
int v[30][200005],l[30];
inline void add(int x,int d){while(x<=n){a[x]+=d;x+=x&-x;}}
inline int get(int x){int re=0;while(x){re+=a[x];x-=x&-x;}RE re;}
signed main(){
    scanf("%s",c+1);
    n=strlen(c+1);
    int x;
	FOR(i,1,n){
		x=c[i]-'a';
		v[x][++l[x]]=i;
		a[i]=i&-i;
	}
	int f=0;
	FOR(i,0,25)if(l[i]&1)f++;
	if(f>=2){
		puts("-1");RE 0;
	}
	int ans=0;
	FOR(i,1,n){
		if(used[i])continue;
		x=c[i]-'a';
		int r=v[x][l[x]--];
		if(i==r){
			ans+=(get(n)-get(i))>>1;
		}else{
			ans+=get(n)-get(r);
		}
		used[r]=used[i]=1;add(r,-1);add(i,-1);
	}
	printf("%lld",ans);
	RE 0;
}




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

int main(){
	int k = 0;
	int a[4], b[4];
	int hitto[1000] = {0}, buro[1000] = {0};
	while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]){
		for(int i = 0; i < 4; i++){
			if(a[i] == b[i]){
				hitto[k]++;
			}
		}
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < 4; j++){
				if(a[i] == b[j]){
					buro[k]++;
				}
			}
		}
		buro[k] = buro[k]-hitto[k];
		k++;
	}
	for(int i = 0; i < k; i++){
		cout << hitto[i] << " " << buro[i] << endl;
	}
}

Measured memory_bytes: 1168
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<math.h>
using namespace std;
int a[114514];
int main() {
	int n;
	cin >> n;
	int t, k;
	cin >> t >> k;
	int q = 0, w = 0, e = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		if (a[i] <= t) { q++; }
		else if (a[i] <= k) { w++; }
		else { e++; }
	}
	int ans = min(q, w);
	int sum = min(ans, e);
	cout << sum << endl;
}

Measured memory_bytes: 256
import numpy
N = int(input())
A = []

for i in range(0, N):
    tmp = int(input())
    A.append(tmp)

MAX = max(A)
MAX_i = numpy.argmax(A)
tmp = A.pop(MAX_i)
MAXsecond = max(A)
A.insert(MAX_i, tmp)

for i in range(0, N):
    if A[i] == MAX:
        print(MAXsecond)
    else:
        print(MAX)

Measured memory_bytes: 21856
#include<iostream>

using namespace std;

int main() {
	int N, X;
	int L[100];
	int sum = 0;
	int ans = 0;
	cin >> N >> X;
	for (int i = 0;i < N;i++) {
		cin >> L[i];
	}
	for (int i = 0;i < N;i++) {
		sum += L[i];
		if (sum > X) {
			break;
		}
		ans += 1;
	}
	cout << ans + 1 << endl;
	return 0;
}

Measured memory_bytes: 256