akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  int N,L;
  cin >> N >> L;
  vector<string> s(N);
  for(int i=0;i<N;i++){
    cin >>  s.at(i);
  }
  sort(s.begin(),s.end());
  
  for(int i=0;i<N;i++){
    cout<<s.at(i);
  }
   cout << endl;
  
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <utility>
#include <set>
#include <vector>
#include <functional>
#include <map>
#include <queue>
using namespace std;
int main()
{
  int X,t;
  cin>>X>>t;
  cout<<max(0,X-t)<<endl;
  //system("pause");
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s=scan.nextLine();
		int n=s.length();
		if(s.charAt(n-1)=='6' || s.charAt(n-1)=='0'|| s.charAt(n-1)=='1' || s.charAt(n-1)=='8') System.out.println("pon");
		else if(s.charAt(n-1)=='3') System.out.println("bon");
		else System.out.println("hon");
		
	}

}


Measured memory_bytes: 27052
#include<stdio.h>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <iterator>
#include <list>
#include <map>     
#include <numeric>
#include <utility>
#include <queue>
#include <set>
#include <sstream>
#include <iomanip>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define ld long double
#define rep(a,t) for(int a=0;a<t;++a) 
#define forever while(true)
#define Sort(a) sort(a.begin(),a.end())
#define Reverse(a) reverse(a.begin(),a.end())
#define pb push_back
#define int_maxvalue numeric_limits<int>::max()
#define print_double(val,a) cout << fixed << setprecision(a) << val << endl;
ll mod = 1e9 + 7;
bool node[51][51];
int n, m;
bool come[100];
void _DFS(int x) {
	if (come[x]) { return; }
	come[x] = true;
	rep(i, 51) {
		if (node[x][i]) {
			_DFS(i);
		}
	}
}
void DFS(int x) {
//	fill(come, come + 80, false);
	_DFS(x);
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> m;
	vector<int>a(m), b(m);
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--,b[i]--;
		node[a[i]][b[i]] = node[b[i]][a[i]] = true;
	}
	int ans = 0;
	rep(i, m) {
		int island = 0;
		fill(come, come + 80, false);
		node[a[i]][b[i]] = node[b[i]][a[i]] = false;
		rep(j, n) {
			if (!come[j]) {
				DFS(j);
				island++;
			}
		}
		if (island > 1) 
		{ ans++; }
		node[a[i]][b[i]] = node[b[i]][a[i]] = true;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#define COST 1000000000

using namespace std;
const int MAX = 12;


int c[MAX][MAX];
int price[MAX];

int main(){
    int n, m, x;
    cin >> n >> m >> x;
    for (int i = 0; i < n; i++)
    {
        cin >> price[i];
        for (int j = 0; j < m; j++)
        {
            cin >> c[i][j];
        }
    }
    vector<int> ok(m,0);
    auto init = ok;
    int cost = 0;
    int ans = COST;
    for (int bit = 0; bit < (1 << n); bit++)
    {
        ok = init;
        cost = 0;
        for (int i = 0; i < n; i++)
        {
            if (bit & (1 << i))
            {
                for (int j = 0; j < m; j++)
                {
                    ok[j] += c[i][j];    
                }
                cost += price[i];
            }
        }
        bool flag = true;
        for (int check : ok)
        {
            if(check<x)
            {
                flag = false;
                break;
            }
        }
        if(!flag)
        {
            continue;
        }
        ans = min(ans, cost);
    }
    if(ans!=COST)
    {
        cout << ans << endl;
    }
    else
    {
        cout << -1 << endl;
    }
    return 0;
}

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

void solve(string S)
{
    if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3])
    {
        cout << "Bad" << endl;
    }
    else
    {
        cout << "Good" << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    string S;
    cin >> S;
    solve(S);
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<long long> A(26, 0);
    for(int i=0; i<N; ++i) {
        char c;
        cin >> c;
        ++A[(int)(c - 'a')];
    }

    long long res = 1;
    for(int i=0; i<26; ++i) {
        res *= A[i] + 1;
        res %= MOD;
    }
    cout << res - 1 << endl;
}

Measured memory_bytes: 256
S = input()

L = len(S)
left = S[:L//2]
right = S[L//2:]
S_re = S[::-1]
re_left = S_re[:L//2]
re_right = S_re[L//2:]

answer = 0
for s,s_re in zip(S, S_re):
    if s != s_re:
        answer += 1 
print(answer//2)
        









#if L % 2 == 0:
#    answer = len(list(set(left) ^ set(re_left)))
#else:
#    set(left) ^

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

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

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    string s;
    ll k;
    cin >> s >> k;
    ll n = s.size();
    s = s + s + s;
    for(ll i = 1; i < 3 * n; i++) {
        if(s[i - 1] == s[i]) s[i] = '$';
    }
    ll cnt0 = 0, cnt1 = 0, cnt2 = 0;
    for(ll i = 0; i < n; i++) if(s[i] == '$') ++cnt0;
    for(ll i = n; i < 2 * n; i++) if(s[i] == '$') ++cnt1;
    for(ll i = 2 * n; i < 3 * n; i++) if(s[i] == '$') ++cnt2;
    ll ans;
    if(cnt0 == cnt1 && cnt1 == cnt2) ans = cnt0 * k;
    else if(cnt0 == cnt1 && cnt1 != cnt2) ans = cnt0 * (k-1) + cnt2;
    else if(cnt0 != cnt1 && cnt1 == cnt2) ans = cnt0 + (k-1) * cnt2;
    else ans = cnt0 * (k-k/2) + cnt1 * (k/2);
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin>>s;
	vs ss={"SUN","MON","TUE","WED","THU","FRI","SAT","SUN"} ;
	rep(i,7){
		if(s==ss[i]){
			cout<<7-i<<endl;
			return 0;
		}
	}

}


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

s = input()

res = 0

search = [("00"+str(s))[-3:] for s in range(0,1000)]

for v in search:
    tmp = s
    if v[0] in tmp:
        tmp = tmp[tmp.index(v[0])+1:]
    else:
        continue
    if v[1] in tmp:
        tmp = tmp[tmp.index(v[1])+1:]
    else:
        continue
    if v[2] in tmp:
        res += 1
print(res)            


Measured memory_bytes: 9208
#include <bits/stdc++.h>
 
using namespace std;
 
typedef pair<short, short> P;
 
const int INF = 1 << 29;
 
inline int dist(const P& a, const P& b){
  return abs(a.first - b.first) + abs(a.second - b.second);
}

int dp[6][1024];

int main()
{
  int w, h;
  while (scanf("%d %d", &w, &h), w){
    vector<P> ps[5];

    P start, goal;
    for (int y = 0; y < h; y++){
      char line[1024];
      scanf("%s", line);
      for (int x = 0; x < w; x++){
        if (line[x] == 'S') start = P(x, y);
        else if (line[x] == 'G') goal = P(x, y);
        else if (line[x] != '.') {
          int id = line[x] - '1';
          ps[id].push_back(P(x, y));
        }
      }
    }
    int mini = INF;
    int mini_id = -1;
    for (int init = 0; init < 5; init++){
      for (int i = 0; i < 6; i++) for (int j = 0; j < 1024; j++) dp[i][j] = INF;
      int nxt = (init + 1) % 5;
      for (int i = 0; i < ps[nxt].size(); i++){
        dp[0][i] = dist(start, ps[nxt][i]);
      }
      for (int i = 1; i < 4; i++){
        int nnxt = (nxt + 1) % 5;
        for (int j = 0; j < ps[nxt].size(); j++){
          for (int k = 0; k < ps[nnxt].size(); k++){
            dp[i][k] = min(dp[i][k], dp[i - 1][j] + dist(ps[nxt][j], ps[nnxt][k]));
          }
        }
        nxt = nnxt;
      }
      for (int i = 0; i < ps[nxt].size(); i++){
        int value = dp[3][i] + dist(ps[nxt][i], goal);
        if (mini > value){
          mini = dp[3][i] + dist(ps[nxt][i], goal);
          mini_id = init;
        }
      }
    }
    if (mini == INF) printf("NA\n");
    else printf("%d %d\n", mini_id + 1, mini);
  }
  return 0;
}

Measured memory_bytes: 1232
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

const int MAX = 2e5 + 5;
const int MOD = 1e9 + 7;
int fat[MAX];

inline int add(int a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
    return a;
}

inline int mult(int a, int b) {
    return (1LL * a * b) % MOD;
}

int f_exp(int x, int e) {
    if (e == 0) return 1;
    if (e & 1) return mult(x, f_exp(x, e - 1));
    return f_exp(mult(x, x), e / 2);
}

inline int inv(int x) {
    return f_exp(x, MOD - 2);
}

inline int comb(int n, int k) {
    return mult(fat[n], mult(inv(fat[n - k]), inv(fat[k])));
}

void preprocess() {
    fat[0] = 1;
    fori (i, 1, MAX) {
        fat[i] = mult(fat[i - 1], i);
    }
}

void solve() {
    preprocess();
    int n, k;
    cin >> n >> k;
    int ans = 0;
    fori (i, 0, min(k, n - 1) + 1) {
        int zeros_comb = comb(n, i);
        int rest = n - i;
        int c = comb(i + (rest - 1), i);
        ans = add(ans, mult(zeros_comb, c));
    }
    cout << ans << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    solve();
    return 0;
}



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

using namespace std;

int main() {
	#ifdef HOME
		freopen("input.txt", "rt", stdin);
	#endif
	int n, r;
	cin >> n >> r;
	if (n >= 10) {
		r = r;
	} else {
		r += (10 - n) * 100;
	}
	cout << r;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int n,m,x,y,c=1;
	cin>>n>>m>>x>>y;
	int a[205],b[205];
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<m;i++){
		cin>>b[i];
	}
	sort(b,b+m);
	if(a[n-1]<b[0] && b[0]>x && b[0]<=y && a[n-1]>x && a[n-1]<=y)
	cout<<"No War"<<endl;
	else
	cout<<"War"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(snip_i, h) cin >> s.at(snip_i);
	int dx[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy[] = {0, 1, 1,  1,  0, -1, -1, -1};
	vector<vector<char>> ans(h, vector<char>(w));
	rep(i, h)rep(j, w){
		int add = 0;
		if(s.at(i).at(j) == '#'){
			ans.at(i).at(j) = '#';
			continue;
		}
		rep(snip_i, 8){
			int nj = j + dx[snip_i], ni = i + dy[snip_i];
			if(ni < 0 || h <= ni || nj < 0 || w <= nj) continue;
			if(s.at(ni).at(nj) == '#') add++;
		}
		ans.at(i).at(j) = add + '0';
	}
	rep(i, h){
		rep(j, w){
			cout << ans.at(i).at(j);
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <limits>
#include <initializer_list>
#include <utility>
#include <bitset>
#include <tuple>
#include <type_traits>
#include <functional>
#include <string>
#include <array>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <algorithm>
#include <complex>
#include <random>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <regex>
#include <cassert>
#include <cstddef>
#include <variant>
#define endl codeforces
#define ALL(v) std::begin(v), std::end(v)
#define ALLR(v) std::rbegin(v), std::rend(v)
using ll = std::int64_t;
using ull = std::uint64_t;
using pii = std::pair<int, int>;
using tii = std::tuple<int, int, int>;
using pll = std::pair<ll, ll>;
using tll = std::tuple<ll, ll, ll>;
template <typename T> using vec = std::vector<T>;
template <typename T> using vvec = vec<vec<T>>;
template <typename T> const T& var_min(const T &t) { return t; }
template <typename T> const T& var_max(const T &t) { return t; }
template <typename T, typename... Tail> const T& var_min(const T &t, const Tail&... tail) { return std::min(t, var_min(tail...)); }
template <typename T, typename... Tail> const T& var_max(const T &t, const Tail&... tail) { return std::max(t, var_max(tail...)); }
template <typename T, typename... Tail> void chmin(T &t, const Tail&... tail) { t = var_min(t, tail...); }
template <typename T, typename... Tail> void chmax(T &t, const Tail&... tail) { t = var_max(t, tail...); }
template <typename T> T make_v(T init) { return init; }
template <typename T, typename... Tail> auto make_v(T init, std::size_t s, Tail... tail) { auto v = std::move(make_v(init, tail...)); return vec<decltype(v)>(s, v); }
template <typename T, std::size_t Head, std::size_t... Tail> struct multi_dem_array { using type = std::array<typename multi_dem_array<T, Tail...>::type, Head>; };
template <typename T, std::size_t Head> struct multi_dem_array<T, Head> { using type = std::array<T, Head>; };
template <typename T, std::size_t... Args> using mdarray = typename multi_dem_array<T, Args...>::type;
namespace init__ { struct InitIO { InitIO() { std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); std::cout << std::fixed << std::setprecision(30); } } init_io; }

int main() {
    ll x;
    std::cin >> x;
    ll cur = 100;
    ll i = 1;
    for (;; i++) {
        cur = cur + cur / 100;
        if (x <= cur) break;
    }
    std::cout << i << "\n";
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>

int compar(const int  *val1,const int *val2){
    return *val1-*val2;
}

int main(void){
    int num,field,i,card,sign,o;
    while(1){
        int line[10]={0};
        field=0;
        sign=1;
        i=-1;
        scanf("%d",&num);
        if(num == 0)
            break;
        for(card=getchar();card != '\n' || sign != 0;card=getchar(),i++){
            if(card == 'S'){
                field+=++line[i];
                line[i]=0;
            }
            if(card == 'M'){
                line[i]++;
            }
            if(card == 'L'){
                line[i]+=++field;
                field=0;
            }
            if(i == num-1)
                i=-1;
            sign=0;
        }
        qsort(line,num,sizeof(int),(int (*)(const void *,const void *))compar);
        for(i=0;i<num;i++){
            printf("%d ",line[i]);
        }
        printf("%d\n",field);
        }
    return 0;
}

Measured memory_bytes: 608
$<.gets.to_i.times do
  splited = $<.gets.chomp.scan(/([0-9\.]+|\+|\-|\*|\/|\(|\)|=)/)
  output = []
  stack = []
  a = nil
  until (token = splited.shift) == ["="]
    token = token.first
    case token
    when "(" then stack << token
    when ")" then
      output << a until (a = stack.pop) == "("
    when "*", "/"
      loop do
        a = stack.last
        break unless %w(* /).include?(a)
        output << stack.pop
      end
      stack << token
    when "+", "-"
      loop do
        a = stack.last
        break unless %w(+ - * /).include?(a)
        output << stack.pop
      end
      stack << token
    else
      output << token.to_r
    end
  end
  output << a while (a = stack.pop)
  
  stack = []
  while (x = output.shift)
    if %w(+ - * /).include?(x)
      a, b = stack.pop, stack.pop
      if x == "/" and ((a < 0) ^ (b < 0))
        stack << -(b.abs / a.abs)
      else
        stack << eval("#{b.to_i} #{x} #{a.to_i}").to_i
      end
    else
      stack << x
    end
  end
  puts stack.first.to_i
end


Measured memory_bytes: 6952
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n), b(n); for (int i = 0; i < n; ++i) cin >> a[i] >> b[i];
  V<> id(2 * n); iota(begin(id), end(id), 0);
  sort(begin(id), end(id), [&](int i, int j) { return (i < n ? a[i] : b[i - n]) < (j < n ? a[j] : b[j - n]); });
  V<> c(2 * n);
  for (int i = 0; i < n; ++i) ++c[id[i]];
  int s = accumulate(begin(c), next(begin(c), n), 0);
  bool ok = false;
  for (int i = 0; i < n; ++i) if (c[i] and c[i + n]) ok = true;
  lint res = 0;
  for (int i = 0; i < n; ++i) res += id[i] < n ? a[id[i]] : b[id[i] - n];
  if (s != 0 and s != n and !ok) {
    V<lint> tmp(2, res);
    for (int m = n; m < n + 2; ++m) {
      if (id[m] < n) {
        tmp[m - n] += a[id[m]];
        for (int i = n - 1; i >= 0; --i) if (id[i] != id[m] + n) {
          tmp[m - n] -= id[i] < n ? a[id[i]] : b[id[i] - n];
          break;
        }
      } else {
        tmp[m - n] += b[id[m] - n];
        for (int i = n - 1; i >= 0; --i) if (id[i] != id[m] - n) {
          tmp[m - n] -= id[i] < n ? a[id[i]] : b[id[i] - n];
          break;
        }
      }
      res = min(tmp[0], tmp[1]);
    }
  }
  cout << res << '\n';
}

Measured memory_bytes: 2560
N, X, Y = [int(_) for _ in input().split()]
# X = int(input())
cnt = [0 for i in range(1, N+1)]
for i in range(1, N+1):
    for j in range(i+1, N+1):
        d = min(j-i, abs(X-i) + 1 + abs(j-Y))
        cnt[d] += 1
for i in range(1, N):
    print(cnt[i])




Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,outcnt=0,out=0,i=0,flag[3]={0};
  cin>>n;
  int ining[n]={0};
  while(out!=(n*3)){
    string jugde;
    cin>>jugde;
    if(jugde=="OUT"){
      outcnt++;out++;
      if(outcnt==3){
	for(int j=0;j<3;j++)
	  flag[j]=0;
	i++;
	outcnt=0;
      }
    }
    if(jugde=="HIT"){
      if(flag[2]==1)
	ining[i]++;
      if(flag[1]==1)
	flag[2]=1;
      if(flag[0]==1)
	flag[1]=1;
      flag[0]=1;
    }
    if(jugde=="HOMERUN"){
      int point=0;
      for(int j=0;j<3;j++){
	if(flag[j]==1)
	  point++;
	flag[j]=0;
      }
      ining[i]+=(point+1);
    }
  }
  for(int j=0;j<n;j++){
    cout<<ining[j]<<endl;
  }
  return 0;
}

Measured memory_bytes: 3120
#include<iostream>
#include<queue>
using namespace std;
typedef struct{
  int x,y;
}Point;
 
int dx[4]={0,1,0,-1};
int dy[4]={-1,0,1,0};
char mp[51][51];
int d[51][51];
#define INF 100000
int main(){
  int h,w,sx,sy,gx,gy,cnt=0;
  cin>>h>>w;
  gx=w-1;
  gy=h-1;
  sx=0;
  sy=0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>mp[i][j];
      d[i][j]=INF;
      if(mp[i][j]=='.'){
	cnt++;
      }

    }
  }
  queue<Point>que;
  que.push((Point){sx,sy});
  d[sy][sx]=0;
  while(!que.empty()){
    Point p=que.front();
    que.pop();
    int x=p.x;
    int y=p.y;
    if(x==gx && y==gy){
      break;
    }
    for(int i=0;i<4;i++){
      int nx=x+dx[i];
      int ny=y+dy[i];
      if(nx>=0&&nx<w&&ny>=0&&ny<h&&mp[ny][nx]!='#'&&d[ny][nx]==INF){
        d[ny][nx]=d[y][x]+1;
        que.push((Point){nx,ny});
      }
    }
  }
  if(d[gy][gx]==INF){
    cout<<-1<<endl;
  }else{
    cout<<cnt-d[gy][gx]-1<<endl;
  }
  return(0);
}


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

typedef vector<int> veci;
typedef pair<int, int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9 + 7)
#define fi first
#define se second
#define endl '\n'

void solve() {
    int h, n;
    cin >> h >> n;

    int a;
    int sum = 0;
    for (int i=0; i<n; ++i) {
        cin >> a;
        sum += a;
    }

    cout << (sum>=h?"Yes":"No") << endl;
}

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST
    (void)argc;
    const string strpath = string(argv[0]) + string("-test.in");
    freopen(strpath.c_str(), "r", stdin);
    int tcs;
    cin >> tcs;
    while (tcs-- > 0)
#endif
        solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
typedef long long ll;
using namespace std;

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

int main() {
	int n, m;
	priority_queue<int, vector<int>, greater<int>> a;
	vector<pair<int, int>> b(100000);
	cin >> n >> m;

	int temp;
	for (int i = 0; i < n; i++) {
		cin >> temp;
		a.push(temp);
	}

	int tempb, tempc;
	for (int i = 0; i < m; i++) {
		cin >> tempb >> tempc;
		b[i] = make_pair(tempb, tempc);
	}

	sort(b.begin(), b.end(), pairCompare);

	for (int i = 0; i < m; i++) {
		while (a.top() < b[i].second && b[i].first) {
			a.pop();
			a.push(b[i].second);
			b[i].first--;
		}
	}

	ll sum = 0;
	while (!a.empty()) {
		sum += a.top();
		a.pop();
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1660
import java.util.Scanner;

class Main{
	static public void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long money=sc.nextLong();//入力値
		long m=100;
		int year=0;
		while(m<money){
			m*=1.01;
			year++;
		}
		System.out.println(year);
	}
}

Measured memory_bytes: 35604
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n,s;
    cin>>n>>s;
    ll b=0;
    for(ll i=2;i<=sqrt(n);i++){
        ll a=0;
        ll k=n;
        while(k>0){
            a+=(k%i);
            k/=i;
        }
        if(a==s){
            cout<<i<<endl;
            b=i;
            break;
        }
    }
    if(n==s){
        b=n+1;
        cout<<b<<endl;
    }
    else if(s>n){
        b=-1;
        cout<<b<<endl;
    }
    if(b==0){
        for(ll p=sqrt(n);p>0;p--){
            ll i=(n-s)/p+1;
            if(i==1)
                continue;
            ll a=0;
            ll k=n;
            while(k>0){
                a+=(k%i);
                k/=i;
            }
            if(a==s){
                cout<<i<<endl;
                b=i;
                break;
            }
        }
    }
    if(b==0)
        cout<<-1<<endl;
    return 0;
}


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

typedef long long ll;

ll n,c2,c5;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n;
    if(n&1){
        cout<<0<<endl;
        return 0;
    }
    for(ll i=2;i<=n;i*=2){
        c2+=n/i;
    }
    for(ll i=10;i<=n;i*=5){
        c5+=n/i;
    }
    cout<<min(c2,c5)<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
typedef struct{
    int w;
    int h;
}Cake;
Cake cake[100];
int comp(const void *a,const void *b){
    Cake c=*(Cake *)a;
    Cake d=*(Cake *)b;
    if((c.w*c.h)<(d.w*d.h)) return -1;
    else return 1;
}
int main(void){
    while(1){
        int n,w,h;
        int s,p;
        scanf("%d%d%d",&n,&w,&h);
        if(n+w+h==0) break;
        cake[0].w=w; cake[0].h=h;
        for(int i=0;i<n;i++){
            scanf("%d%d",&p,&s);
            p=p-1;
            w=cake[p].w; h=cake[p].h;
            s=s%(w+h);
            //printf("p:%d s:%d\n",p,s);
            Cake small,big;
            if(s<w){
                if(s<=w/2){
                    small.w=s,small.h=cake[p].h;
                    big.w=cake[p].w-s,big.h=cake[p].h;
                }
                else{
                    small.w=cake[p].w-s,small.h=cake[p].h;
                    big.w=s,big.h=cake[p].h;
                }
            }
            else{
                s=s-w;
                if(s<=h/2){
                    small.w=cake[p].w,small.h=s;
                    big.w=cake[p].w,big.h=cake[p].h-s;
                }
                else{
                    small.w=cake[p].w,small.h=cake[p].h-s;
                    big.w=cake[p].w,big.h=s;
                }
            }
            //printf("w:%d h:%d\n",small.w,small.h);
            for(int j=p;j<i;j++){
                cake[j]=cake[j+1];
            }
            cake[i]=small; cake[i+1]=big;
        }
        qsort(cake,n+1,sizeof(Cake),comp);
        for(int i=0;i<n;i++) printf("%d ",cake[i].w*cake[i].h);
        printf("%d\n",cake[n].w*cake[n].h);
    }
}



Measured memory_bytes: 2036
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

signed main(){
	int m,d,mm,dd;
	cin >> m >> d >> mm >> dd;
	cout << (m!=mm) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string a,b,c;cin >> a >> b >> c;
	char A=a.at(0)-'a'+'A',B=b.at(0)-'a'+'A',C=c.at(0)-'a'+'A';
	cout << A << B << C << endl;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
dx=[1,1,1,0,0,-1,-1,-1]
dy=[-1,0,1,1,-1,-1,0,1]
for i in range(h):
    for j in range(w):
        if s[i][j]==".":
            cnt=0
            for k in range(8):
                x=i+dx[k]
                y=j+dy[k]
                if x>=0 and x<h and y>=0 and y<w and s[x][y]=="#":
                    cnt+=1
            s[i][j]=str(cnt)
for i in s:
    print ("".join(i))



Measured memory_bytes: 3188
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

type TrieNode struct {
  depth int
  children []*TrieNode
}
func InitTrieNode(d int) *TrieNode {
  c := make([]*TrieNode, 2)
  t := TrieNode{d, c}
  return &t
}

func Solve() {
  var N, L, _s int
  var t *TrieNode
  NextInt(&N, &L)
  T := make([]*TrieNode, 0)
  T = append(T, InitTrieNode(0))
  for i := 0; i < N; i++ {
    t = T[0]
    for i, s := range NextLine() {
      _s = int(s) - int('0')
      if (*t).children[_s] == nil {
        T = append(T, InitTrieNode(i + 1))
        (*t).children[_s] = T[len(T) - 1]
      }
      t = (*t).children[_s]
    }
  }
  cnt := 0
  for _, t = range T {
    if ((*t).children[0] == nil) != ((*t).children[1] == nil) { cnt ^= (L - (*t).depth) & ((*t).depth - L) }
  }
  if cnt > 0 {
    Write("Alice")
  } else {
    Write("Bob")
  }
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 8448
h, w, k = map(int, input().split())
ccc = [input() for _ in range(h)]
ans = 0
for bit_h in range(2 ** h):
    for bit_w in range(2 ** w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if (bit_h >> i) & 1 == 0 and (bit_w >> j) & 1 == 0:
                    if ccc[i][j] == '#':
                        cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, pre[101];
string s;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> s;
	s = ' ' + s;
	int init = 0, end = 0;
	for(int i = 1; i <= n; i++){
		if(s[i] == '(') pre[i] = pre[i - 1] + 1;
		else pre[i] = pre[i - 1] - 1;
		if(pre[i] < 0) init++, pre[i] = 0;
	}
	if(pre[n] > 0)
		for(int i = 0; i < pre[n]; i++) end++;
	for(int i = 0; i < init; i++) cout << '(';
	for(int i = 1; i <= n; i++) cout << s[i];
	for(int i = 0; i < end; i++) cout << ')';
	cout << "\n";
	return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!size_t;
  foreach (_; n.iota) {
    auto rd = readln.split.to!(int[]);
    writeln(isRightTriangle(rd[0], rd[1], rd[2]) ? "YES" : "NO");
  }
}

bool isRightTriangle(int a, int b, int c)
{
  return
    a ^^ 2 == b ^^ 2 + c ^^ 2 ||
    b ^^ 2 == c ^^ 2 + a ^^ 2 ||
    c ^^ 2 == a ^^ 2 + b ^^ 2;
}

Measured memory_bytes: 2440
using System;
using System.Collections.Generic;

class Player
{
    public int score {get; set;}
    public List<int> card = new List<int>();
    public List<int> stat = new List<int>();
}

class Example
{
    static void Main()
    {
        int num_card = 0;
        Player A = new Player();
        Player B = new Player();
        A.score = 0;
        B.score = 0;
        
        int input = int.Parse(Console.ReadLine());
        while(input != 0)
        {
            num_card = input;
            for(int i=0; i<num_card; i++)
            {
                string data = Console.ReadLine();
                string[] num_pair = data.Split(' ');
                A.card.Add(int.Parse(num_pair[0]));
                B.card.Add(int.Parse(num_pair[1]));
            }
            Game(A,B,num_card);
            A.stat.Add(A.score);
            B.stat.Add(B.score);
            A.card.Clear();
            B.card.Clear();
            A.score = 0;
            B.score = 0;

            input = int.Parse(Console.ReadLine());
        }

        for(int j=0;j<A.stat.Count; j++)
        {
            Console.WriteLine("{0} {1}", A.stat[j], B.stat[j]);
        }
    }

    static void Game(Player A, Player B, int n)
    {
        for(int i=0; i<n; i++)
        {
            if(A.card[i] - B.card[i] > 0)
            {
                A.score += A.card[i] + B.card[i];
            }
            else if(A.card[i] - B.card[i] < 0)
            {
                B.score += A.card[i] + B.card[i];
            }
            else if(A.card[i] - B.card[i] == 0)
            {
                A.score += A.card[i];
                B.score += B.card[i];
            }
        }
    }
}

Measured memory_bytes: 9500
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>
#include <memory>
#include <stack>
#include <numeric>
#include <climits>
#include <cfloat>
#include <bitset>

struct Edge {
	int from, to, coin;
};
int main() {
	int n, m, p; std::cin >> n >> m >> p;
	std::vector<Edge> edges(m);
	std::vector<std::vector<int>> from_path(n);
	for (auto& e : edges) {
		std::cin >> e.from >> e.to >> e.coin;
		e.from--; e.to--;
		from_path[e.to].push_back(e.from);
	}
	std::vector<bool> can_reach(n, false);
	can_reach[n - 1] = true;
	std::stack<int> stack; stack.push(n - 1);
	while (!stack.empty()) {
		auto current = stack.top(); stack.pop();
		for (const auto& next : from_path[current]) if (!can_reach[next]) {
			can_reach[next] = true;
			stack.push(next);
		}
	}
	std::vector<long long int> max_earn(n, LLONG_MIN);
	max_earn[0] = 0;
	for (auto t = 1; t <= n; ++t) {
		for (const auto& e : edges) {
			if (max_earn[e.from] != LLONG_MIN && can_reach[e.to] && can_reach[e.from] && max_earn[e.to] < max_earn[e.from] + e.coin - p) {
				max_earn[e.to] = max_earn[e.from] + e.coin - p;
			}
		}
	}
	if (max_earn[n - 1] == LLONG_MIN || std::any_of(edges.begin(), edges.end(), [&max_earn, &can_reach, p](const Edge& e) {return max_earn[e.from] != LLONG_MIN && can_reach[e.to] && can_reach[e.from] && max_earn[e.to] < max_earn[e.from] + e.coin - p; })) {
		std::cout << -1 << std::endl;
	}
	else {
		std::cout << std::max(0LL, max_earn[n - 1]) << std::endl;
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;
#define int LL

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 2e5 + 5;
int a[MAXN];
int f[2][MAXN][2];

signed main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n; read(n);
  for (RI i = 1; i <= n; ++i) read(a[i]);
  memset(f, -0x7f, sizeof(f));
  f[0][0][0] = 0;
  int cur = 0, last = 1;
  for (RI i = 1; i <= n; ++i) {
    swap(cur, last);
    int R = (i + 1) / 2 + 1, L = (n / 2) - ((n - i) / 2) - 1;
    for (RI j = R; j >= L; --j) {
      f[cur][j][0] = max(f[last][j][0], f[last][j][1]);
      f[cur][j][1] = f[last][j - 1][0] + a[i];
    }
  }
  printf("%lld\n", max(f[cur][n / 2][0], f[cur][n / 2][1]));

  return 0;
}

// created by Daniel yuan


Measured memory_bytes: 12556
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner scan = new Scanner(System.in);
    int[] x = new int[2];
    int[] y = new int[2];
    for(int i = 0; i < 2;i++){
      x[i] = scan.nextInt();
      y[i] = scan.nextInt();
    }
    int tx = x[1] - x[0];
    int ty = y[1] - y[0];
    int x3 = x[1] - ty;
    int y3 = y[1] + tx;
    int x4 = x3 - tx;
    int y4 = y3 - ty;
    System.out.println(x3+" "+y3+" "+x4+" "+y4);
  }
}


Measured memory_bytes: 23764
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
int main()
{
	int a, b;
	cin >> a >> b;
	if (a <= 8 && b <= 8) {
		cout << "Yay!" << endl;
	} else {
		cout << ":(" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
#define REP(i,n) for(int i=0;i<(int)n;++i)
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
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; }
template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
string num2bit(ll num, ll len){
    string bit = "";
    REP(i, len){
    bit += char('0'+(num>>i & 1));
    }
    return bit;
}

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

    ll X, Y;
    cin >> X >> Y;

    ll now = X;
    ll res = 1;
    while(1){
        now = now * 2;
        if(now>Y) break;
        res++;
    }
    cout << res << endl;
    return 0;
}

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

int main(){

	int n;
	while (std::cin >> n, n){

		std::string str;
		std::vector<int>player(n, 0);
		int center = 0;

		std::cin >> str;

		for (int i = 0, now = 0; i < 100; i++, now++){
			if (now == n)now -= n;

			player[now]++;

			if (str[i] == 'S'){
				center += player[now];
				player[now] = 0;
			}
			else if (str[i] == 'L'){
				player[now] += center;
				center = 0;
			}
		}

		std::sort(player.begin(), player.end());

		for (int i = 0; i < n; i++)std::cout << player[i] << " ";

		std::cout << center << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1228
import numpy as np

N = int(input())
h = np.array(list(map(int, input().split())))

ans = 0
while h.sum() > 0:
    # 引くべき値を求める
    minus = h[np.where(h > 0)].min()

    # 引くべきindexを求める
    target = np.where(h >= minus)[0]

    # 水やりが必要なブロックが何個あるか数える
    diff = np.diff(target)
    cnt = np.where(diff > 1)[0].shape[0] + 1
    
    # ansに引くべき値×ブロック数を加える
    ans += minus * cnt

    # 引く
    h[target] -= minus

print(ans)

Measured memory_bytes: 19604
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define REP_AB(i, a, b) for (ll i = ll(a); i < ll(b); i++)
#define REP_IN(i, n, x) for (ll i = 0; i < n; i++)in>>x;
#define REP_OUT(i, n, x) for (ll i = 0; i < n; i++)out<<x<<endl;
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
// template end
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll A, B, C, D, ans, ansA, ansB, CDgcd, CDlcm;
    in >> A >> B >> C >> D;

    CDlcm = lcm(C, D);
    ansA = (A-1) - ((A-1)/C) - ((A-1)/D) + ((A-1)/CDlcm);
    ansB = B - (B/C) - (B/D) + (B/CDlcm);
    ans = ansB - ansA;
    out << ans << endl;
    
 
    //vector<ll> X(N);

}

Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    N = int(input())
    C = [None] * N
    ans = 0
    for i in range(N):
        a, b = map(int, input().split())
        C[i] = a+b
        ans -= b
    C.sort(reverse=True)
    print(ans + sum(C[::2]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 13648
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    cout << (N / 2) * ((N + 1) / 2) << endl;
    return 0;
};


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int m[101][101]={0},i,j,r,c;
	scanf("%d %d",&r,&c);
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&m[i][j]);
		}
	}
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			m[i][c]+=m[i][j];
			m[r][j]+=m[i][j];
			m[r][c]+=m[i][j];
		}
	}
	for(i=0;i<=r;i++){
		for(j=0;j<=c;j++){
			printf("%d",m[i][j]);
			if(j==c) printf("\n");
			else printf(" ");
		}
	}
	return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <string.h>
#include<vector>

using namespace std;

int main()
{
	int N, K;
	int i,j,ans=0;
	cin >> N >> K;
	vector<int>d(K);
	vector<vector<int>>who(K, vector<int>(N,0));
	vector<int>sum(N, 0);
	vector<bool>ok(N,0); 
	for (i = 0; i < K; i++)
	{
		cin >> d[i];
		for (j = 0; j < d[i]; j++) {
			cin >> who[i][j];
			ok[who[i][j] - 1] = true;
		}
	}
	for (j = 0; j < N; j++)
	{
		if (!ok[j]) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
long long fun(long long x)
{
    while(x/10)
    {
        x=x/10;
    }
    return x;
}
int main()
{
    long long n;
    cin>>n;
    map<pair<long long,long long>,long long>mp;
    long long f,l;
    for(long long i=1;i<=n;i++)
    {
        l=i%10;
        f=fun(i);
        mp[{f,l}]++;
    }
    long long ans=0;
    for(auto it:mp)
    {
        f=it.ff.ff;
        l=it.ff.ss;
        ans+=mp[{f,l}]*mp[{l,f}];
    }
    cout<<ans<<"\n";
    return 0;
}

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

using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
#define HYPP(x) hypot(x.first,x.second)

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int N;
	cin >> N;
	int ans = 0;
	for (int i = 1; i <= N / 2; i++) {
		if (i != N - i)ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e2+3;
const int K = 1e5+5;
bool dp[K];
int a[N];
int main() {
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; ++i)
		cin >> a[i];
	for(int j = 0; j <= k; ++j)
		for(int i = 0; i < n; ++i)
			if(j - a[i] >= 0)
				dp[j] |= !dp[j-a[i]];
	cout << ((dp[k]) ? "First" : "Second");

	return 0;
}


Measured memory_bytes: 384