akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <complex>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

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

struct Mod {
    static uint64_t PRIME;
    struct LocalPrime {
        uint64_t backup;
        LocalPrime(uint64_t prime) { backup = exchange(Mod::PRIME, prime); }
        ~LocalPrime() { Mod::PRIME = backup; }
    };
    uint64_t value = 0;
    Mod()
    : value(0) {}
    Mod(ll v) {
        if (v >= 0) {
            value = v % PRIME;
        } else {
            value = PRIME - (-v) % PRIME;
        }
    }
    Mod operator+(const Mod& rhs) const { return Mod(*this) += rhs; }
    Mod& operator+=(const Mod& rhs) {
        value += rhs.value;
        if (value >= PRIME) {
            value -= PRIME;
        }
        return *this;
    }
    Mod operator-(const Mod& rhs) const { return Mod(*this) -= rhs; }
    Mod& operator-=(const Mod& rhs) {
        if (value < rhs.value) {
            value += PRIME;
        }
        value -= rhs.value;
        return *this;
    }
    Mod operator*(const Mod& rhs) const { return Mod(*this) *= rhs; }
    Mod& operator*=(const Mod& rhs) {
        value = (value * rhs.value) % PRIME;
        return *this;
    }
    Mod inv() const { return power(*this, PRIME - 2); }
    Mod operator/(const Mod& rhs) const { return Mod(*this) /= rhs; }
    Mod& operator/=(const Mod& rhs) {
        *this *= rhs.inv();
        return *this;
    }
    static Mod power(Mod rhs, ll exp) {
        Mod ans = 1;
        while (exp > 0) {
            if (exp % 2) {
                ans *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return ans;
    }
};
uint64_t Mod::PRIME = 2019;

int main() {
    vector<ll> s;
    {
        string S;
        cin >> S;
        rep(i,0,S.size()) {
            s.push_back(S[i]-'0');
        }
    }
    reverse(s.begin(), s.end());
    vector<Mod> accum(s.size() + 1);
    Mod pow = 1;
    rep(i,1,s.size()+1) {
        accum[i] = accum[i-1] + Mod(s[i-1]) * pow;
        pow *= 10;
    }
    ll ans = 0;
    unordered_map<ll, ll> cnt;
    cnt[accum[s.size()].value]++;
    rrep(i,s.size(),0) {
        ans += cnt[accum[i].value];
        cnt[accum[i].value]++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 6136
N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]

T.sort()
bus_time = [T[0]+K]
bus_num = [0]
t = 0

for i in range(N) :
    if bus_num[t] <= C - 1 :
        if bus_time[t] >= T[i] :
            bus_num[t] += 1
        else :
            t += 1
            bus_time.append(T[i]+K)
            bus_num.append(1)
    else :
        t += 1
        bus_time.append(T[i]+K)
        bus_num.append(1)

print(len(bus_time))


Measured memory_bytes: 12524
#include<bits/stdc++.h>
using namespace std;
int n;
long long int a[305][305];
int c[305][305];
int main(){
    cin >> n;
    for(int i=0;i<n;i++)for(int j=0;j<n;j++)cin >> a[i][j];
    for (int k = 0; k < n; k++){       // 経由する頂点
        for (int i = 0; i < n; i++) {    // 始点
            for (int j = 0; j < n; j++) {  // 終点
                if(a[i][j]>a[i][k] + a[k][j]){
                    cout << -1;
                    return 0;
                }
                else if(a[i][j] < a[i][k] + a[k][j])c[i][j]++;
            }
        }
    }
    long long int ans=0;
    for (int i = 0; i < n; i++) {    // 始点
        for (int j = 0; j < n; j++) {  // 終点
            if(c[i][j]==n-2)ans+=a[i][j];
        }
    }
    cout << ans/2;
}

Measured memory_bytes: 4732
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;

int c, n, m, S, D;

struct EDGE { int to, cost; };
vector<EDGE> g[100];

struct STATE
{
	int cost, now, num;
	
	bool operator<(const STATE t)const{
		return cost > t.cost;
	}
};

int d[100][11];

void init()
{
	for (int i = 0; i < 100; i++){
		g[i].clear();
	}
	for (int i = 0; i < 100; i++){
		for (int j = 0; j <= 10; j++){
			d[i][j] = INF;
		}
	}
}

void search(int s)
{	
	for (int i = 0; i <= 10; i++){
		d[s][i] = 0;
	}
	
	priority_queue<STATE, vector<STATE> > que;
	que.push({0, s, 0});
	while (!que.empty()){
		STATE st = que.top(); que.pop();
		if (d[st.now][st.num] < st.cost) continue;
		
		for (int i = 0; i < g[st.now].size(); i++){
			EDGE e = g[st.now][i];
			if (d[e.to][st.num] > d[st.now][st.num] + e.cost){
				d[e.to][st.num] = d[st.now][st.num] + e.cost;
				que.push({d[e.to][st.num], e.to, st.num});
			}
		}
		
		if (st.num == c) continue;
		
		for (int i = 0; i < g[st.now].size(); i++){
			EDGE e = g[st.now][i];
			if (d[e.to][st.num + 1] > d[st.now][st.num] + e.cost / 2){
				d[e.to][st.num + 1] = d[st.now][st.num] + e.cost / 2;
				que.push({d[e.to][st.num + 1], e.to, st.num + 1});
			}
		}
	}
}

int main()
{
	while (scanf("%d %d %d %d %d", &c, &n, &m, &S, &D), c){
		S--; D--;
		
		init();
		
		for (int i = 0; i < m; i++){
			int a, b, f;
			scanf("%d %d %d", &a, &b, &f);
			a--; b--;
			
			g[a].push_back({b, f});
			g[b].push_back({a, f});
		}
		
		search(S);
		int mini = INF;
		for (int i = 0; i <= c; i++) mini = min(mini, d[D][i]);
		printf("%d\n", mini);
	}
	
	return 0;
}

Measured memory_bytes: 1252
import sys
s = input()
for bit in range(1 << len(s)-1):
  res = s[0]
  for i in range(len(s)-1):
    if bit & (1<<i):
      res += '+'
    else:
      res += '-'
    res += s[i+1]
  if eval(res) == 7:
    print(res+'=7')
    sys.exit()
      

Measured memory_bytes: 3060
#include <iostream>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int mod = 1000000007;
int n, k;
int a[2000];

signed main() {
	int i, j;
	
	cin >> n >> k;
	rep(i, n) cin >> a[i];
	
	int ans = 0;
	rep(i, n) {
		int x = 0, y = 0;
		for (j = 0; j < i; j++) if (a[j] > a[i]) x++;
		for (j = 0; j < n; j++) if (a[j] > a[i]) y++;
		ans += k * x % mod + (k * (k - 1) / 2) % mod * y % mod;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

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

list_1 = input().split()
list_2 = []
x = 0

for i in range(N):
    list_2.append(i+1)

for i in range(N):
    if int(list_1[i]) == list_2[i]:
        x += 0
    else:
        x += 1

if x == 0 or x == 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	if (a + b < 10) cout << a + b;
	else cout << "error";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>

#define BP 1000000007

using namespace std;

typedef unsigned long long ull;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned int ui;

typedef vector<ull> vull;
typedef vector<ll> vll;
typedef vector<ui> vui;
typedef vector<long> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;

typedef pair<ull, ull> pull;
typedef pair<ll, ll> pll;
typedef pair<ui, ui> pui;
typedef pair<long, long> pl;
typedef pair<int, int> pi;

template <class T>
void printv(vector<T> vc) {
    for (auto e: vc) cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vvc) { 
    for (auto vc: vvc) {
        for (auto e: vc) cout << e << " ";
        cout << endl;
    }
}

int main() {
    string str; cin >> str;
    string code = "CODEFESTIVAL2016";
    int ans = 0;
    for (int i = 0; i < code.size(); ++i) {
        ans += str[i] == code[i] ? 0 : 1;
    }

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

Measured memory_bytes: 888
my $s = <STDIN>;
my @dat = ("a","b","c","d","e","f","g","h","i","j");

@str  = "a";
@strL = 1;
for($i=1;$i<$s;$i++){
  @new = ();
  @newL = ();
  #print "@str\n";
  #print "Lstr $#str \n";
  for($j=0;$j<=$#str;$j++ ){
   
    my $level = $strL[$j];
     #print "j$j level$level $str[$j]\n";
    for(my$k=0;$k<=$level;$k++){
      $newstr = "$str[$j]$dat[$k]";
      
      if($k==$level ){
         $newstrL = $level+1;
      }else{
         $newstrL = $level;
      }
      #print"new $newstr\n";
      push (@new ,$newstr);
      push (@newL ,$newstrL);
    }
  }
  @str  = @new;
  @strL = @newL;
}

#print "@str";

for($i=0;$i<=$#str;$i++){
  print "$str[$i]\n";
}

Measured memory_bytes: 28416
/*
      HET PAGHADAR
      DA-IICT
      @HET262
*/
 
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define oos tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds; 
typedef long double ld;
typedef long long ll;
typedef vector<ll> vec; 
#define inf LLONG_MAX
#define bp __builtin_popcountll
#define pb push_back
#define ff first
#define ss second
#define P pair<ll,ll>
#define N 1000005
#define mod 1000000007
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int32_t main()
{
      
      FAST;
      
      ll n;
      cin>>n;
      
      ll a[10][10]={0};
      for(int i=1;i<=9;i++)
      {
            for(int j=1;j<=9;j++)
            {
                  ll ans=0;
                  for(int k=1;k<=4;k++)
                  {
                        ll tt=pow(10,k)-1;
                        for(int kk=0;kk<=tt;kk++)
                        {
                              ll t1=(i*(tt+1)*10)+(kk*10)+j;
                              if(t1<=n)
                                    ans++;
                        }
                  }
                  a[i][j]=ans;
                  if(i==j && i<=n)
                        a[i][j]++;
                  if(((i*10)+j)<=n)
                        a[i][j]++;
            }
      }
      
      ll ans=0;
      for(int i=1;i<=9;i++)
      {
            for(int j=1;j<=9;j++)
            {
                  ans+=(a[i][j]*a[j][i]);
            }
      }
      
      
      cout<<ans;
      
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define rep_down(i,n) for (int i=n-1; i>=0;--i)
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int N;
int A[200005], L[200005], R[200005];

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

  cin >> N;
  rep(i, N){
    cin >> A[i];
  }

  rep(i, N){
    if (i==0) continue;
    if (i==1){
      L[i] = A[0];
      continue;
    }
    L[i] = max(L[i-1], A[i-1]);
  }

  rep_down(i, N){
    if (i==N-1) continue;
    if (i==N-2){
      R[i] = A[N-1];
      continue;
    }
    R[i] = max(R[i+1], A[i+1]);
  }

  rep(i, N){
    if (i==0){
      cout << R[0] << endl;
      continue;
    }
    if (i==N-1){
      cout << L[N-1] << endl;
      continue;
    }
    int a = max(L[i], R[i]);
    cout << a << endl;
  }
  return 0;
}

Measured memory_bytes: 3968
#include"iomanip"
#include"iostream"
#include"limits"
#include"cmath"
#include"vector"
#include"algorithm"
#include"list"
#include"queue"
#include"stack"
#include"set"
#include"unordered_set"
#include"map"
#include"unordered_map"
#include"string"
#include"cstring"
#include"assert.h"
using namespace std;
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define mset(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll x=2,y=1;
	int n;
	cin>>n;
	for(int i=0;i<n-1;++i)
	{
		ll t=y;
		y=y+x;
		x=t;
	}
	cout<<y<<'\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REP2(i, a, b) for(int i = a;i <= b;i++)
#define REPR(i, a, b) for(int i = a; i >= b; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define PI 3.14159265358979323846
#define vi vector<int>
#define vll vector<ll>
#define vi2 vector<vector<int>>
#define eb emplace_back
#define fi first
#define se second
#define ALL(v) v.begin(), v.end()
#define sz(x) int(x.size())
using namespace std;
using P = pair<ll,ll>;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};
#define INT(name) int name;cin >> name;
#define VEC(type,name,n) vector<type> name(n);REP(i,n) cin >> name[i];

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



int main()
{
  INT(N);
  INT(K);
  if(K>(N-1)*(N-2)/2){
    cout << -1 << endl;
  }else{
    cout << (N-1)*(N-2)/2-K+(N-1) << endl;
    REP2(i,2,N){
      cout << 1 << " " << i << endl;
    }
    int cnt = 0;
    REP2(i,2,N-1){
      REP2(j,i+1,N){
        if(cnt==(N-1)*(N-2)/2-K){
          return 0;
        }
        cout << i << " " << j << endl;
        cnt++;
      }
    }
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>

using namespace std;

string toLower(string input);

int main(void)
{
	string W, T;
	int count = 0;

	cin >> W;
	cin >> T;
	while (T != "END_OF_TEXT")
	{
		W = toLower(W);
		T = toLower(T);

		if (W == T)
			count++;
		cin >> T;
	}
	cout << count << endl;
	return 0;
}

string toLower(string input)
{
	int len = input.length();
	int i;
	for (i = 0; i < len; i++)
	{
		if (input.at(i) <= 'Z' && input.at(i) >= 'A')
		{
			input.at(i) = input.at(i) - 'A' + 'a';
		}
	}
	return input;
}


Measured memory_bytes: 3240
x = input()
y = input()  
 
xnew = sorted(x)
xnew = ''.join(xnew)
 
ynew = sorted(y)
ynew.reverse() 

ynew = ''.join(ynew)
 
if xnew < ynew:
  print("Yes")
else:
  print("No") 

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

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);  
   ll a,b,n;
   cin >> a >> b >> n;
   ll max=0;ll ans=0;ll lol=0;
   ll x=min(b-1,n);
   max=(a*x)/b-a*(x/b);
   cout << max << endl;
    return 0;
}

Measured memory_bytes: 3560
import java.util.Scanner;

public class Main {

	// private static int count = 0;

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int num = scan.nextInt();
		int[] sort_before = new int[num];

		for (int i = 0; i < num; i++) {
			sort_before[i] = scan.nextInt();
		}

		// selectionSortを実行した回数
		int count = selectionSort(sort_before, num);

		System.out.print(sort_before[0]);
		for (int i = 1; i < num; i++) {
			System.out.print(" " + sort_before[i]);
		}
		System.out.println();
		System.out.println(count);

		scan.close();

	}

	/**
	 * セレクションソート。一番小さい値を選択して入れ替える。
	 * 
	 * @param A配列
	 * @param N配列の数
	 * @return入れ替えた回数
	 */
	public static int selectionSort(int[] A, int N) {

		int count = 0;
		for (int i = 0; i < N; i++) {
			int mini = i;
			for (int j = i; j < N; j++) {
				if (A[j] < A[mini]) {
					mini = j;
				}
			}
			if (mini != i) {
				int tmp;
				tmp = A[i];
				A[i] = A[mini];
				A[mini] = tmp;
				count++;
			}

		}

		return count;
	}
}



Measured memory_bytes: 26348
#include <stdio.h>

int main(){

  int i, n, x, m, min, ans;

  scanf("%d %d %d", &n, &x, &m);
  ans=n;
  min=m;
  x-=m;

  for(i=1;i<n;i++){
    scanf("%d", &m);
    x-=m;
    if(min>m) min=m;
  }

  ans+=x/min;
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;

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

    for(int i=1;i<=n;i+=2){
        if(a[i-1]%2!=0){
            cnt += 1;
        }
    }


    cout << cnt << endl;
}



Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
int a,b,c,a1,b1,c1;
signed main()
{
    cin>>a>>b>>c;
	for(int i=0;;i++)
	{
		if(a&1||b&1||c&1)cout<<i,exit(0);
		if(a>b)swap(a,b);
		if(b>c)swap(b,c);
		if(a>b)swap(a,b);
		a1=(b+c)/2,b1=(a+c)/2,c1=(a+b)/2;
		a=a1,b=b1,c=c1;
		if(a==b&&b==c&&a==c)puts("-1"),exit(0);
	}
}

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

typedef long long ll;
typedef pair<double, int> P;
const int N = (int)1e3 + 5;
//const ll INF = (ll)1e18;
const double INF = 1e18;

struct edge{
    int to;
    double cost;
//    edge(int _to, int _cost){
//        to = _to, cost = _cost;
//    }
};

int n;
vector<edge> G[N];
double dis[N];

void dijkstra(){

    fill(dis, dis+N, INF);
    dis[0] = 0;
    priority_queue<P, vector<P>, greater<P> > pque;
    pque.push({0, 0});

    while(!pque.empty()){
        P p = pque.top(); pque.pop();
        int i = p.second;
        double dist = p.first;
        if(dist > dis[i]) continue;

        for(edge e : G[i]){
            if(e.cost + dis[i] < dis[e.to]){
                dis[e.to] = e.cost + dis[i];
                pque.push({dis[e.to], e.to});
            }
        }
    }
}

double sx, sy, tx, ty;
double x[N], y[N], r[N];

int main() {
    cin >> x[0] >> y[0] >> x[1] >> y[1];
    cin >> n; n += 2;
    for(int i = 2; i < n; i++) {
        cin >> x[i] >> y[i] >> r[i];
    }

    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            double dis = max(0.0, sqrt((x[i] - x[j]) * (x[i] - x[j]) + (y[i] - y[j]) * (y[i] - y[j]))
                            - r[i] - r[j]);
            G[i].push_back({j, dis});
            G[j].push_back({i, dis});
        }
    }
    dijkstra();
    cout << fixed << setprecision(10) << dis[1] << endl;
}



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

int main() {
  int A,B,C;
  char D,E;
  cin >> A >> D >> B >> E >> C;
  if(A > 2019){
  cout << "TBD" << endl;
  }
  if(A == 2019 && B > 4){
    cout << "TBD" << endl;
  }
    
    if(A == 2019 && B < 5){
      cout << "Heisei" << endl;
    }
 if(A < 2019){
cout << "Heisei" << endl;
 }

}


Measured memory_bytes: 3608
#define w 200001
i;x;y;p;main(n,m,j,u){
  long int k,a[w],A[w],b[w],B[w];
  for(scanf("%d%d%ld",&n,&m,&k);x<n;x++)scanf("%ld",&a[x]),A[x+1]=A[x]+a[x];
  for(;y<m;y++)scanf("%ld",&b[y]),B[y+1]=B[y]+b[y];
  u=m;
        
  for(;i<=n;i++){
    if(A[i]>k)break;
            
    for(j=u;j>=0;j--){
      if(A[i]+B[j]<=k){
        if(i+j>p)p=i+j;
        u=j;
        break;
      }
    }
  }
  printf("%d",p);
}

Measured memory_bytes: 7964
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

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

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

type Catalog struct {
	name  string
	point int
	id    int
}

var N int

func main() {
	sc.Split(bufio.ScanWords)

	N = nextInt()
	p := make([]Catalog, N)

	for i := 0; i < N; i++ {
		p[i].name = nextStr()
		p[i].point = nextInt()
		p[i].id = i
	}

	sort.Sort(SortBy(p))
	for i := 0; i < N; i++ {
		fmt.Println(p[i].id + 1)
	}
}

type SortBy []Catalog

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i].name < a[j].name {
		return true
	} else if a[i].name == a[j].name {
		return a[i].point > a[j].point
	} else {
		return false
	}
}


Measured memory_bytes: 640
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        // 入力処理
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.nextLine());
        Integer[] nums = Stream.of(sc.nextLine().split(" ")).map(Integer::valueOf).toArray(Integer[]::new);

        Arrays.sort(nums, Comparator.reverseOrder());
        int alice = 0;
        int bob = 0;
        boolean turnAlice = true;
        for (int i = 0; i < n; i++) {
            if (i % 2 == 0) {
                alice+=nums[i];
            } else {
                bob+=nums[i];
            }
        }

        System.out.println(alice - bob);
    }
}


Measured memory_bytes: 29140
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

class Main {
	static int[][] dp;

	@SuppressWarnings("unused")
	public static void main(String[] args) {
		FastScanner in = new FastScanner();
//		int T = in.nextInt();
//		outer: for (int tt = 0; tt < T; tt++) {
//		}
		int n = in.nextInt();
		int a[][] = new int[n][3];
		dp = new int[n][3];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 3; j++) {
				a[i][j] = in.nextInt();
				dp[i][j] = -1;
			}
		}
		int ans = 0;
		for (int i = 0; i < 3; i++) {
			ans = Math.max(ans, hapiness(a, n - 1, i));
		}
		System.out.println(ans);

	}

	public static int hapiness(int a[][], int i, int j) {
		if (i == 0) {
			if (j == 0) {
				return Math.max(a[0][j + 1], a[0][j + 2]);
			}
			if (j == 1) {
				return Math.max(a[0][j - 1], a[0][j + 1]);
			}
			if (j == 2) {
				return Math.max(a[0][j - 2], a[0][j - 1]);
			}
		}
		if (dp[i][j] != -1)
			return dp[i][j];
		int ans1 = 0, ans2 = 0, ans3 = 0;
		if (j == 0) {
			ans1 = a[i][j] + Math.max(hapiness(a, i - 1, j + 1), hapiness(a, i - 1, j + 2));
		}
		if (j == 1) {
			ans2 = a[i][j] + Math.max(hapiness(a, i - 1, j - 1), hapiness(a, i - 1, j + 1));
		}
		if (j == 2) {
			ans3 = a[i][j] + Math.max(hapiness(a, i - 1, j - 2), hapiness(a, i - 1, j - 1));
		}
		int ans = Math.max(ans1, Math.max(ans2, ans3));
		dp[i][j] = ans;
		return ans;
	}

	static void sort(int[] a) {
		ArrayList<Integer> l = new ArrayList<>();
		for (int i : a)
			l.add(i);
		Collections.sort(l);
		for (int i = 0; i < a.length; i++)
			a[i] = l.get(i);
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

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

		int[] readArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

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

}


Measured memory_bytes: 75692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 10;
const int MAX = 1e5 + 10;
const long double exps = 1e-14;

inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a > b ? b : a; }

int main() {
    long double a, b, c;
    cin >> a >> b >> c;
    if (sqrt(a) + sqrt(b) + exps < sqrt(c)) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int a[105],b[105];
int father[105];
int n,m,s,ans=0;
int find(int x){
    if(father[x]!=x)father[x]=find(father[x]);
    return father[x];
}
void unionn(int x,int y){
    x=find(x);y=find(y);
    father[y]=x;
}
void init(int n){
	for(int i=1;i<=n;i++)father[i]=i;
}
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&a[i],&b[i]);
	}
	for(int i=1;i<=m;i++){
		init(n);
		for(int j=1;j<=m;j++){
			if(i!=j){
				unionn(a[j],b[j]);
			}
		}
		s=find(1);
		for(int j=2;j<=n;j++){
			if(find(j)!=s){
				ans++;
				break;
			}
		}
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long  ll;
//typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set
// this for long double
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<endl; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<-1; return 0;}
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int N = 1010;
const int INF = 1e8;
const ll MOD1=1073741824;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
string bin_rep(int n)
{
          string s="";
      for(int i=31;i>=0;i--)
   {
           if(n&(1<<i)) s+='1';
           else s+='0';
   }
   return s;
}
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 int n,k;
 cin>>n>>k;
 set<int> s;
 while(k--)
 {
           int cnt;
           cin>>cnt;
           int a;
           while(cnt--)
           {
                     cin>>a;
                     s.insert(a);
           }
 }
 cout<<n-(int) s.size();
 
 
 
 
 
    
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

Measured memory_bytes: 3664
#include <iostream>
#include <cstdio>
using namespace std;
long long n, m, k;
int main(){
	cin >> n >> m >> k;
	if(n >= k){
		cout << n - k << " " << m << endl;
		return 0;
	}
	else {
		if(m + n - k <= 0){
			cout << "0 0" << endl;
			return 0;
		}
		else
		cout << 0 << " " << n+m-k << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 20
#define M 200
int souatari(int ,int );
int A[N],a_total;
int main(){
  int B[M];
  int i,j,b_total;
  scanf("%d",&a_total);
  for(i=0;i<a_total;++i)
    scanf("%d",&A[i]);

  scanf("%d",&b_total);
  for(j=0;j<b_total;++j){
    scanf("%d",&B[j]);
  if(souatari(0,B[j]))
    printf("yes\n");
  else printf("no\n");
  }
  return 0;
}
int souatari(int ryohu,int karuma){
  int answer;
  if(karuma==0)return 1;
  else if(ryohu>a_total)return 0;
  answer=souatari(ryohu+1,karuma) || souatari(ryohu+1,karuma-A[ryohu]);
    return answer;
}





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

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

	int ans = 10000000;
	for (int a = 1; a < n; a++) {
		int b = n - a;

		string sa = to_string(a);
		string sb = to_string(b);

		int va = 0, vb = 0;
		for (int i = 0; i < sa.size(); i++) {
			va += (sa[i] - '0');
		}
		for (int i = 0; i < sb.size(); i++) {
			vb += (sb[i] - '0');
		}
		if (ans > va + vb) {
			ans = va + vb;
		}

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

Measured memory_bytes: 3672
//long time no ac
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";


#define     SPEED     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	ll          long long int
#define 	pb          push_back
#define 	pii         pair<int,int>
#define 	vi          vector<int>
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	hell        1000000007
#define 	rep(i,n)    for(i=0;i<n;i++)
#define 	repe(i,a,b) for(i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search
#define 	mp          make_pair

ll power(ll a,ll b)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2);
	if(b%2==0)
		return((c%hell)*(c%hell))%hell;
	return ((((c%hell)*(c%hell))%hell)*(a%hell))%hell;
}

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



int main()
{
	SPEED;
	ll n,k,t,c=0,i,j,m,cs=0;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>m>>n;
		// n=s.length();
		ll a[n];
		vector<ll> b(n-1);
		rep(i,n)
		{
			cin>>a[i];
		}
		sort(a,a+n);
		rep(i,n-1)
		{
			b[i]=abs(a[i+1]-a[i]);
		}
		sort(all(b));
		j=0;
		for(i=0;i<n-m;i++)
		{
			// debug(b[i]);
			c+=(b[i]);
		}

		cout<<c;
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
using namespace std;
int main()
{
  string s;
  cin>>s;
  int ta=0,iwa=0;
  for(int i=s.size()-1;i>-1;i--){
      if(s[i]=='A'){
          ta=i;
      }
  }
  for(int i=0;i<s.size();i++){
      if(s[i]=='Z'){
          iwa=i;
      }
  }
  cout<<iwa-ta+1<<endl;
  return 0;
}


Measured memory_bytes: 640
num = int(input())
figx =0
figy =0

count = 0
for i in range(num):
    time,x,y = map(int,input().split())
    distance = x + y - figx - figy
    if distance <= time and (time % 2 == distance %2):
        count += 1
    
    x=figx
    y=figy
        
if count == num:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 43880
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << 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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  string s;
  cin >> s;
  bool res = true;
  for(ll i=0;i<sz(s);i+=2){
    if(s[i]!='h'||s[i+1]!='i'){
      res = false;
    }
  }
  if(res){
    print("Yes");
  }
  else{
    print("No");
  }
}

Measured memory_bytes: 256
s=list(input())
i=1
f=1
w=[s[0]]
while i<len(s)-1:
    if s[i]==s[i-1] and f:
        w.append(s[i]+s[i+1])
        i+=1
        i+=1
        f=0
    else:
        w.append(s[i])
        f=1
        i+=1
if s[-1]!=w[-1] and i<len(s):
    w.append(s[-1])
print(len(w))


Measured memory_bytes: 61936
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define ll long long
#define inf 1<<30
#define min(a,b) (a<b?a:b)
#define max(a,b) (a>b?a:b)
ll read()
{
	ll tmp=0; char f=1,c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1; c=getchar();}
	while('0'<=c&&c<='9'){tmp=tmp*10+c-'0'; c=getchar();}
	return tmp*f;
}
int a,b,n;
int main()
{
	n=read(); a=read(); b=read();
	if(abs(a-b)&1)printf("Borys\n");else printf("Alice\n");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int A, B;
  std::cin >> A >> B;
  std::cout << max(A+B, max(A-B, A*B)) << '\n';
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		long K = sc.nextLong();
		sc.close();
		if (N < K) {
			System.out.println(Math.min(N, Math.abs(N - K)));
		} else {
			System.out.println(Math.min(N % K, Math.abs((N % K) - K)));
		}
	}

}

Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>

int main(void) {
	char str[81];
	int secnum = 0;
	int num;
	int number;
	int i;
	while (scanf("%s", str) != EOF) {
		number = strlen(str);
		for (i = 0, num = 0; i < number; i++) {
			if (str[i] >= '0' && str[i] <= '9') {
				if (num == 0)
					num = str[i] - '0';
				else
					num = num * 10 +  (str[i] - '0');
			}
			else if (num) {
				secnum += num;
				num = 0;
			}
		}
		if (num)
			secnum += num;
	}
	printf("%d\n", secnum);
	return 0;
}

Measured memory_bytes: 540
// abc112_b
// #include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void) {
	int N, T;
	cin >> N >> T;
	vector<pair<int, int>> vc(N);
	for (int i = 0; i < N; i++) {
		// cost, time
		pair<int, int> route;
		cin >> route.second >> route.first;
		vc[i] = route;
	}
	// sort(vc.begin(), vc.end(),std::greater<pair<int,int>>());
	sort(vc.begin(), vc.end());
	if (vc[0].first > T) {
		cout << "TLE" << endl;
		return 0;
	}
	int min = vc[0].second;
	for (int i = 0; i < N; i++) {
		if (vc[i].first > T) {
			break;
		}
		if (min > vc[i].second) {
			min = vc[i].second;
		}
	}
	cout << min << endl;

	return 0;
}

Measured memory_bytes: 256
# ABC168 C : (Colon)
import math

a, b, h, m = map(int, input().split())

_b = m*6
_a = (h*60+m)/2

_k = abs(_a - _b)

ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(_k)))

print(ans)

Measured memory_bytes: 9444
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn = (int)1e5 + 10;
int r[maxn], g[maxn], c[maxn];
int cmp(int a, int b){
    return a > b;
}
int main(){
    ios::sync_with_stdio(false);
    int X, Y, A, B, C; cin>>X>>Y>>A>>B>>C;
    priority_queue <int> cll;
    for(int i = 1; i <= A; i++) cin>>r[i];
    for(int i = 1; i <= B; i++) cin>>g[i];
    for(int i = 1; i <= C; i++) cin>>c[i], cll.push(c[i]);
    sort(r + 1, r + A + 1, cmp);
    sort(g + 1, g + B + 1, cmp);
    priority_queue <int> les;
    LL ans = 0;
    for(int i = 1; i <= X; i++){
        ans += r[i];
        les.push(-r[i]);
    }
    for(int i = 1; i <= Y; i++) les.push(-g[i]), ans += g[i];
    while(!les.empty() && !cll.empty() && -les.top() < cll.top()){
        ans -= (-les.top()); les.pop();
        ans += cll.top(); cll.pop();
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 5872
#include <algorithm>
#include <climits>
#include <cmath>
#include <functional>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using namespace std;
using ll = long long;
using AB = pair<int, int>;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int N, A, B;
    cin >> N;
    vector<AB> vec;
    for(int i = 0; i < N; i++) {
        cin >> A >> B;
        vec.emplace_back(A, B);
    }

    sort(vec.begin(), vec.end(),
         [](const AB &ab1, const AB &ab2) { return ab1.second < ab2.second; });
    ll time = 0;
    for(const auto &ab : vec) {
        time += ab.first;
        if(time > ab.second) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 2420
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
 
# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev
 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    A = inputList()
    
    tmp = {}
    for i, val in enumerate(A):
        if val in tmp:
            tmp[val] += 1
        else:
            tmp[val] = 1
            
    ans = []
    for k, v in tmp.items():
        if v >= 4:
            ans.append(k)
            ans.append(k)
        elif v >= 2:
            ans.append(k)
            
    if len(ans) == 0:
        print(0)
        sys.exit()
    ans.sort()
    print(ans[-1] * ans[-2])
    
    
if __name__ == "__main__":
	main()


Measured memory_bytes: 72556
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,k;
    cin >> n >> k;

    vector<ll> a(n);
    ll maxa = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        maxa = max(maxa,a[i]);
    }

    ll m = 1;
    ll b = 0;
    while(m <= maxa || m <= k){
        m *= 2;
        b++;
    }

    m /= 2;

    vector<vector<vector<ll>>> dp(b+1,vector<vector<ll>>(2,vector<ll>(2,-1)));

    dp[b][0][1] = 0;

    b--;

    for(ll i = b; i >= 0; i--){
        ll tbit = 0;
        for(int j = 0; j < n; j++){
            if(a[j]&(1LL << i)){
                tbit++;
            }
        }
        if(dp[i+1][0][0] >= 0){
            dp[i][1][0] = max(dp[i][1][0],dp[i+1][0][0] + (n - tbit) * (1LL << i));
            dp[i][0][0] = max(dp[i][0][0],dp[i+1][0][0] + tbit * (1LL << i));
        }
        if(dp[i+1][1][0] >= 0){
            dp[i][1][0] = max(dp[i][1][0],dp[i+1][1][0] + (n - tbit) * (1LL << i));
            dp[i][0][0] = max(dp[i][0][0],dp[i+1][1][0] + tbit * (1LL << i));
        }
        if(k&(1LL << i)){
            dp[i][1][1] = max(dp[i+1][0][1],dp[i+1][1][1]) + (n - tbit)* (1LL << i);
            dp[i][0][0] = max(dp[i][0][0],max(dp[i+1][0][1],dp[i+1][1][1]) + tbit * (1LL << i));
        }else{
            dp[i][0][1] = max(dp[i+1][0][1],dp[i+1][1][1]) + tbit * (1LL << i);
        }
    }

    cout << max(max(dp[0][0][0],dp[0][0][1]),max(dp[0][1][0],dp[0][1][1])) << endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  double N,K;
  cin >> N >> K;
  double ans = 0;
  for(double i=1; i<=N; i++){
    double temp = i;
    double res = 1.0;
    res /= N;
    int cnt = 0;
    while(temp < K){
      temp *= 2;
      cnt++;
    }
    for(int j=1; j<=cnt; j++){
      res *= 0.5;
    }
    ans += res;
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import math
import fractions

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

def ValueToBits(x,digit):
    res = [0 for i in range(digit)]
    now = x
    for i in range(digit):
        res[i]=now%2
        now = now >> 1
    return res

def BitsToValue(arr):
    n = len(arr)
    ans = 0
    for i in range(n):
        ans+= arr[i] * 2**i
    return ans

#a = list(map(int, input().split()))


n,m = list(map(int, input().split()))
a = list(map(int, input().split()))

if(n>sum(a)):
    print("No")
else:
    print("Yes")

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

#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i, n) for( int i = 0; i < (n); i++ )
#define Rrep(i, a, n) for( int i = (a); i < (n); i++ )
#define All(v) v.begin(), v.end()

typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;
int a[1000000];
int ans[1000000];
signed main()
{
  int n;
 
  int cnt1 = 0, cnt2 = 0;

  cin >> n;
  Rep(i, n) cin >> a[i];

  for ( int i = n - 1; i >= 0; i -= 2 ) {
    ans[cnt1] = a[i];
    cnt1++;
    if ( cnt1 + cnt2 >= n ) break;
    ans[n - 1 - cnt2] = a[i - 1];
    cnt2++;
  }

  Rep(i, n) cout << ans[i] << " ";
  cout << endl;
}


Measured memory_bytes: 7808
#include <stdio.h>
int main(void){
    int a1, a2, a3;
    
    scanf("%d %d %d", &a1, &a2, &a3);
    
    if(a1 + a2 + a3 <= 21){
        printf("win\n");
    } else  if(a1 + a2 + a3 >= 22){
        printf("bust\n");
    }
    
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.regex.Pattern;
public class Main {
	public static boolean hantei(String str) {
        return Pattern.matches("^[a-z]+$", str);
    }
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		String S;
		String T;
		int N = 0;
		do {
			N = stdIn.nextInt();
			S = stdIn.next();
			T = stdIn.next();
		}while(hantei(S)==false||hantei(T)==false||N<1||N>100);
		String[] aS = S.split("");
		 
		  String[] aT = T.split("");
		 
		for(int i=0; i<N ; i++) {
				System.out.print(aS[i]+""+aT[i]);
			}
	}
}


Measured memory_bytes: 21844
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
    vi a(3);

    rep(i, 3) cin>>a[i];

    sort(all(a));

    cout<<a[0]+a[1]<<endl;
}


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

int main(){
    int n,b,f,r,v;
    int data[5][4][11];
    cin>>n;
    //initialize
    for(int i=0;i<5;i++){
        for(int j=0;j<4;j++){
            for(int k=0;k<11;k++){
                data[i][j][k]=0;
            }
        }
    }
    //insert
    for(int i=0;i<n;i++){
        cin>>b>>f>>r>>v;
        data[b][f][r]+=v;
    }
    //output
    for(int i=1;i<5;i++){
        for(int j=1;j<4;j++){
            for(int k=1;k<11;k++){
                cout<<" "<<data[i][j][k];
            }
            cout<<endl;
        }
        if(i==4){
            continue;
        }
        for(int l=0;l<20;l++){
            cout<<"#";
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3088