akhauriyash/Code-Regression huggingface dataset:
(defun head (lst n)
  (labels ((f (lst n acc)
              (if (> n 0)
                (f (cdr lst) (- n 1) (cons (first lst) acc))
                (reverse acc))))
    (f lst n ())))

(defun tail (lst n)
  (reverse (head (reverse lst) n)))

(defun solve (s)
  (labels ((f (s acc)
              (let ((l (length s)))
                (if s
                  (loop for i from 1 to l 
                        sum (f (tail s (- l i))
                              (+ acc 
                                 (parse-integer 
                                   (concatenate 'string (head s i))))))
                  acc))))
    (f s 0)));(parse-integer (concatenate 'string  s)))))

(defparameter s (concatenate 'list (read-line)))

(princ 
  (solve s))


Measured memory_bytes: 13028
#include<bits/stdc++.h>
using namespace std;
#define ff(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    ll n,m;
        cin>>n;
        vector<ll> hh(100000,0);
        vector<ll> hhh(100000,0);
        for(int i=0;i<n;i++){
            cin>>hh.at(i);
        }
        hhh.at(1)=abs(hh.at(0)-hh.at(1));
        for(int i=2;i<n;i++){
                hhh.at(i)=min(hhh.at(i-2)+abs(hh.at(i)-hh.at(i-2)),hhh.at(i-1)+abs(hh.at(i)-hh.at(i-1)));
        }
    cout<<hhh.at(n-1)<<'\n';
}

Measured memory_bytes: 4756
s = gets.chomp
k = gets.to_i
n = s.size

remain = k
ans = s.dup
n.times do |i|
  if i == n - 1
    remain %= 26
    if s[i].ord + remain > 'z'.ord
      d = s[i].ord + remain - 'z'.ord
      ans[i] = ('a'.ord + d - 1).chr
    else
      ans[i] = (s[i].ord + remain).chr
    end
  else
    t = 'z'.ord - s[i].ord + 1
    if s[i] != 'a' && t <= remain
      ans[i] = 'a'
      remain -= t
    end
  end
end

puts ans


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

using namespace std;
long long modpow(long long x, long long y, long long mod)
{
	long long result = 1;
	while (y != 0) {
		if (y%2 != 0) {
			result *= x;
			result %= mod;
			y -= 1;
		}	
		x *= x;
		x %= mod;
		y /= 2;
	}
	return result;
}
int main(void)
{
	const long long p = (long long)1e9+7;
	int n;
	cin >> n;
	vector<long long> zeros(60, 0);
	vector<long long> ones(60, 0);

	for (int i = 0; i < n; i++) {
		uint64_t a;
		cin >> a;
		for (int j = 0; j < 60; j++) {
			if (((a>>j)&1) == 1)
				ones[j]++;
			else
				zeros[j]++;
		}
	}

	long long ans = 0;
	for (int i = 0; i < 60; i++) {
		ans += (((zeros[i]*ones[i])%p)* modpow(2, i, p))%p;
		ans %= p;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;
const double PI=acos(-1);



int main() {
    ios_base::sync_with_stdio(false); 

    ll n,k;
    cin >> n >> k;
    bitset<42> kk(k);
    vector<int> bit(42);
    vector<ll> pow_two(42),a(n);
    pow_two[0]=1;
    rep(i,41) pow_two[i+1]=pow_two[i]*2;
    rep(i,n) {
        cin >> a[i];
        bitset<42> aa(a[i]);
        rep(j,42) {
            if (aa[j]==1) ++bit[j];
        }
    }
    bool flag=0;
    ll x=0;
    invrep(i,42) {
        if (!flag) {
            if (kk[i]>0) {
                if (bit[i]>=(n+1)/2) flag=1;
                else x+=pow_two[i];
            }
        } else {
            if (bit[i]<(n+1)/2) x+=pow_two[i]; 
        }
    }
    ll ans=0;
    rep(i,n) ans+=x^a[i];
    cout << ans << endl;
     
    return 0;
}


Measured memory_bytes: 4020
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
#include <map>

int main()
{
  char str[6];

  for (int i = 0; i < 6; ++i)
    std::cin >> str[i];

  if (str[2] == str[3] && str[4] == str[5])
    std::cout << "Yes\n";
  else
    std::cout << "No\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>

using namespace std;

const int maxi = 1e9;

int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;

	if (h * w == 1) {
		cout << "No" << endl;
		return 0;
	}

	vector<vector<long long>> mat(H, vector<long long>(W, 0));
	for (int i = 0; i < H; i += h) {
		for (int j = 0; j < W; j += w) {
			mat[i][j] = maxi - 1;
		}
	}
	for (int i = h - 1; i < H; i += h) {
		for (int j = w - 1; j < W; j += w) {
			mat[i][j] = -maxi;
		}
	}

	long long sum = 0;
	for (auto v : mat) {
		sum += accumulate(v.begin(), v.end(), 0LL);
	}

	if (sum <= 0) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
		for (auto v : mat) {
			cout << v[0];
			for (int i = 1; i < W; i++) {
				cout << " " << v[i];
			}
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 4864
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#include<queue>
#include<cstdio>
#define rep(i,n) for (int i=0;i<(n);++i)
using ll = long long;
using namespace std;
using P = pair<int,int>;

int main(){
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    rep(i,k){
        if(a>=b){
            b = 2*b;
        }else if(b>=c){
            c = 2*c;
        }

        if(a<b&&b<c){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdlib.h>
#include <iostream>
#include <climits>
using namespace std;

struct weight{
	int val;
	int id;
	weight(){
		val = 0;
		id  = 0;
	}
	weight(weight *w){
		val = w->val;
		id  = w->id;
	}
	void set(weight *w){
		val = w->val;
		id  = w->id;
	}
};

void merge_sort(weight *array, int left, int right);
void merge(weight *array, int left, int mid, int right);
void swap_id(weight *a, weight *b);
void swap(weight *a, weight *b);
int cal_min_swap(weight *original, weight *sorted, int num);
int linear_search(weight *array, int size, int num);

int main(){
	int n;

	cin >> n;

	weight* original = (weight*)malloc(n * sizeof(weight));
	weight* sorted   = (weight*)malloc(n * sizeof(weight));
	int result = 0;

	if(n < 1){
		return 0;
	}

	for(int i = 0; i < n; i++){
		cin >> original[i].val;
		original[i].id = i;
		sorted[i].set(&original[i]);
	}

	merge_sort(sorted, 0, n);
	cout << cal_min_swap(original, sorted, n) << endl;
	return 0;
}

void merge_sort(weight *array, int left, int right){
	if(left+1 < right){
		int mid = (left + right) >> 1;
		merge_sort(array, mid, right);
		merge_sort(array, left, mid);
		merge(array, left, mid, right);
	}

}

void merge(weight *array, int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;

	weight* L = (weight*)malloc((n1+1) * sizeof(weight));
	weight* R = (weight*)malloc((n2+1) * sizeof(weight));

	for(int i = 0; i < n1; ++i){
		L[i].set(&array[left+i]);
	}
	L[n1].val = INT_MAX;
	for(int i = 0; i < n2; ++i){
		R[i].set(&array[mid+i]);
	}
	R[n2].val = INT_MAX;

	int i = 0;
	int j = 0;
	for(int k = left; k < right; ++k){
		if(L[i].val <= R[j].val){
			array[k].set(&L[i]);
			++i;
		}else{
			array[k].set(&R[j]);
			++j;
		}
		// array[k].id = k;
	}
}
void swap_id(weight *a, weight *b){
	int temp = b->id;
	b->id = a->id;
	a->id = temp;
}
void swap(weight *a, weight *b){
	weight *temp = new weight(b);
	b->set(a);
	a->set(temp);
	free(temp);
}

int cal_min_swap(weight *original, weight *sorted, int num){
	int total_swap_w = 0;
	int temp_i = 0;
	bool is_swap = false;
	int swap_num = 0;
	int min = sorted[0].val;
	int this_min = 0;
	int this_total_swap_num = 0;
	string test;
	for(int i = 0; i < num; ++i){
		if(original[i].id != sorted[i].id){
			if(!is_swap){
				temp_i = i;
				swap_num = 0;
				this_min = sorted[i].val;
				this_total_swap_num = 0;
			}
			this_total_swap_num += original[i].val;
			int swap_i = linear_search(sorted, num, original[i].val);
			swap(&sorted[i], &sorted[swap_i]);
			i = swap_i - 1;
			is_swap = true;
			swap_num++;
		}else{
			if(is_swap){
				if(swap_num != 1){
					if(min*swap_num + 2*(min + this_min) < this_min*swap_num){
						this_total_swap_num += min*swap_num + 2*(min + this_min);
					}else{
						this_total_swap_num += this_min*swap_num;
					}
				}else{
					this_total_swap_num += this_min;
				}
				total_swap_w += this_total_swap_num;
				this_total_swap_num = 0;
				i = temp_i;
				is_swap = false;
			}
		}
	}
	return total_swap_w;
}
int linear_search(weight *array, int size, int num){
	for(int i = 0; i < size; ++i){
		if(array[i].val == num){
			return i;
		}
	}
	return -1;
}

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

int main() {
  int N, K, distance=0;
  cin >> N >> K;

  for (int i = 0; i < N; i++)
  {
    int x;
    cin >> x;
    
    if (x < (K - x))
    {
      distance += 2 * x;
    } 
    else 
    {
      distance += 2 * (K - x);
    }
  }
  cout << distance << endl;  

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int D;
    cin >> D;
    vector<ll> C(26);
    rep(i, 26) cin >> C[i];
    vector<vector<ll>> S(D, vector<ll>(26));
    rep(i, D) rep(j, 26) cin >> S[i][j];
    vector<ll> T(D);
    rep(i, D) {
        cin >> T[i];
        T[i]--;
    }
    
    ll ans = 0;
    vector<ll> pen(26);
    rep(i, D) {
        ans += S[i][T[i]];
        rep(j, 26) pen[j] += C[j];
        pen[T[i]] = 0;
        rep(j, 26) {
            ans -= pen[j];
        }
        output(ans);
    }
    
    
    
    return 0;
}


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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

void solve() {
    int N, T;
    cin >> N >> T;

    int c, t, min_c = 1e9;
    rep(0, N) {
        cin >> c >> t;
        if (t <= T) {
            min_c = min(min_c, c);
        }
    }

    cout << (min_c != 1e9 ? to_string(min_c) : "TLE") << endl;
}

int main() {
    solve();

    return 0;
}


Measured memory_bytes: 256
<?php
  $root = [];
  $size = [];

  fscanf(STDIN, "%d %d", $n, $m);

  for ($i=1; $i<=$n; $i++) {
    $root[$i] = $i;
    $size[$i] = 1;
  }

  function root($a) {
    global $root;
    if ($root[$a] == $a) return $a;
	$root[$a] = root($root[$a]);
    return $root[$a];
  }

  function unite($a, $b) {
    global $root;
    global $size;
    
    $a = root($a);
    $b = root($b);
    if ($a == $b) return;
    if ($size[$b] > $size[$a]) {
      $t = $a;
      $a = $b;
      $b = $t;
    }
    $root[$b] = $a;
    $size[$a] += $size[$b];
  }

  function uni_size($a) {
    global $size;
    
    $a = root($a);
    return $size[$a];
  }
  
  for ($i=0; $i<$m; $i++) {
    fscanf(STDIN, "%d %d", $a, $b);
    unite($a, $b);
  }

  $ans = 0;
  for ($i=1; $i<=$n; $i++) {
    $ans = max($ans, uni_size($i));
  }
  echo $ans . "\n";
?>

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

const int mod = 998244353;
const int IMAX = 100000;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

ll dp[3001];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N, S;
	cin >> N >> S;

	int A[3000];
	rep(i, N) cin >> A[i];
	sort(A, A + N);

	ll k2 = modpow(2, mod - 2);
	dp[0] = modpow(2, N);
	int s = 0;
	rep(i, N) {
		s = min(S, s + A[i]);
		for (int j = s; j >= A[i]; j--) {
			dp[j] = (dp[j] + dp[j - A[i]] * k2) % mod;
		}
	}

	co(dp[S] % mod);

	Would you please return 0;
}

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

using namespace std;

int main(void) {
    int n;
    while (cin >> n, n) {
        int T[86410] = {};
        for (int i = 0; i < n; i++) {
            int h[2], m[2], s[2], t[2];
            for (int j = 0; j < 2; j++) {
                scanf("%d:%d:%d", &h[j], &m[j], &s[j]);
                t[j] = h[j] *3600 + m[j]*  60 + s[j];
                if (!j) T[t[j]]++;
                else T[t[j]]--;
            }
        }

        int ans = 0;
        for (int i = 0; i < 86400; i++) {
            if (i) T[i] += T[i - 1];
            ans = max(ans, T[i]);
        }
        
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3484
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product, combinations_with_replacement
import sys
import bisect
import string
import math
import time
from decimal import *


def I(): return int(input())
def S(): return input()
def MI(): return map(int, input().split())
def MS(): return map(str, input().split())
def LI(): return [int(i) for i in input().split()]
def LI_(): return [int(i)-1 for i in input().split()]
def StoI(): return [ord(i)-97 for i in input()]
def ItoS(nn): return chr(nn+97)
def input(): return sys.stdin.readline().rstrip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def print_matrix(mat):
    for i in range(len(mat)):
        print(*['IINF' if v == IINF else "{:0=4}".format(v) for v in mat[i]])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**19
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
# show_flg = True


def main():
    A, B = MS()
    getcontext().prec = 28

    a = Decimal(A) * Decimal(B)

    print(a.quantize(Decimal('0'), rounding=ROUND_DOWN))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10500
n = int(input())

past_words = []
for i in range(n):
    s = input()
    if s in past_words:
        print("No")
        exit(0)
    if past_words and past_words[-1][-1] != s[0]:
        print("No")
        exit(0)
    past_words.append(s)
print("Yes")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define P pair<ll,ll>
#define Graph vector<vector<ll>>
#define INF (1ll<<60)
#define mod 1000000007
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;}

vector<ll> sum;
void pre_process(vector<ll> &a,vector<ll> &s){//累積和のvector
    ll n=(ll)a.size();
    s.assign(n+1,0);
    for(ll i=0;i<n;i++){
        s[i+1]=s[i]+a[i];
    }
}
ll query(ll i,ll j,vector<ll> &s){//区間[i,j]の和
    return (s[j]-s[i]);
}

int main(){
	ll n,k;cin>>n>>k;
	vector<ll> a(n),ans(n+2,0);//0,n+1は範囲外になった時用
	rep(i,n){
		cin>>a[i];
	}
	
	rep(l,k){
		rep(i,n){
			if(i+1-a[i]<0){
				ans[0]++;//範囲外
			}else{
				ans[i+1-a[i]]++;//範囲内
			}

			if(i+1+a[i]+1>n){
				ans[n+1]--;//範囲外
			}else{
				ans[i+1+a[i]+1]--;//範囲内
			}
		}

		pre_process(ans,sum);

		bool alln=true;
		rep(j,n){
			a[j]=sum[j+2];
			if(a[j]!=n) alln=false;
		}
		ans.assign(n+2,0);

		if(alln) break;
	}

	rep(i,n){
		cout<<a[i]<<" ";
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 7952
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> pi;
#define f first
#define s second
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int maxn = 200010;

int n,a,b,c;
string query[maxn];
int movei[maxn];
//int ab[maxn], ac[maxn],bc[maxn];

vector <char> ans;
bool debug = false;

void act(int curmovei, int x) {
	if (curmovei == 1) {
		if (x == 1) {
			a++;b--;
			ans.push_back('A');
		} else {
			a--;b++;
			ans.push_back('B');
		}
	} else if (curmovei == 2) {
		if (x == 1) {
			a++;c--;
			ans.push_back('A');
		} else {
			c++; a--;
			ans.push_back('C');
		}
	} else {
		if (x == 2) {
			b++; c--;
			ans.push_back('B');
		} else {
			c++; b--;
			ans.push_back('C');
		}
	}
}

void fail() {
	cout << "No\n";
	//ans.push_back('Z');
	exit(0);
}

int32_t main() {
	FAST	
	cin >> n >> a >> b >> c;
	
	for (int i =0;i<n;i++) {
		cin >> query[i];
		if (query[i] == "AB") movei[i] = 1;
		if (query[i] == "AC") movei[i] = 2;
		if (query[i] == "BC") movei[i] = 3;
	}
	
	for (int i =0;i<n;i++) {
		if (movei[i] == 1) { //AB
			if (movei[i+1] != movei[i] and i != n-1) {
				if (movei[i+1] == 2) { //AC
					if (c == 0 and a <= 1 and b >= 1) act(1,1);
					else if (a >= 1) act(1,2);
					else if (b >= 1) act(1,1);
					else fail();
				} else { //BC
					if (c == 0 and b <= 1 and a >= 1) act(1,2);
					else if (b >= 1) act(1,1);
					else if (a >= 1) act(1,2);
					else fail();
				}
			} else {
				if (a >= 1) act(1,2);
				else if (b >= 1) act(1,1);
				else fail();
			}				
		} else if (movei[i] == 2) { //AC
			if (movei[i+1] != movei[i] and i != n-1) {
				if (movei[i+1] == 1) { //AB
					if (b == 0 and a <= 1 and c >= 1) act(2,1);
					else if (a >= 1) act(2,3);
					else if (c >= 1) act(2,1);
					else fail();
				} else { //BC
					if (b == 0 and c <= 1 and a >= 1) act(2,3);
					else if (c >= 1) act(2,1);
					else if (a >= 1) act(2,3);
					else fail();
				}
			} else {
				if (a >= 1) act(2,3);
				else if (c >= 1) act(2,1);
				else fail();
			}
		} else { //BC
			if (movei[i+1] != movei[i] and i != n-1) {
				if (movei[i+1] == 1) { // AB
					if (a == 0 and b <= 1 and c >= 1) act(3,2);
					else if (b >= 1) act(3,3);
					else if (c >= 1) act(3,2);
					else fail();
				} else { //AC
					if (a == 0 and c <= 1 and b >= 1) act(3,3);
					else if (c >= 1) act(3,2);
					else if (b >= 1) act(3,3);
					else fail();
				}
			} else {
				if (b >= 1) act(3,3);
				else if (c >= 1) act(3,2);
				else fail();
			}
		}
		
	}
	cout << "Yes\n";
	int co =0;
	for (auto i:ans) {
		if (debug) cout << movei[co++] << " ";
		cout << i << "\n";
	}
	
}



Measured memory_bytes: 10832
use std::cmp::*;
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: isize = read();
    let b: isize = read();
    let c: isize = read();

    println!("{}", max(0, c - (a - b)));
}


Measured memory_bytes: 4352
// 解説pdfの通りに実装
// 数列を10 20 30 40 30 20 10, 平均値を26とする
// まず、数列の各値から平均値を引く　-16 -6 4 14 4 -6 -16 （数列Aとおく）
// 累積和の配列を作成する　0 -16 -22 -18 -4 0 -6 -22 (数列Bとおく)
// 累積和の配列にて i<jとして b_jからb_iを引くと、数列Aにおけるa_(i+1)からb_jまでの累積和になっている
// b_j >= b_i であるような i, jのペアの数が、求める範囲の数になる。
// 数列Bに座標圧縮を行い、5 2 0 1 4 5 3 0  (数列Cとおく)
// BITなどを用いて、c_j >= c_iであるようなペアの数を求める

#include <iostream>
#include <sstream>
#include <string>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdio>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple


ll N, K;

// 1 originなので注意!!
class Bit
{
private:
	int m_n;
	vector<int> m_bit;

public:
	void init(int n) {
		m_n = n;
		m_bit.resize(n + 1);
	}

	int sum(int i) {
		int s = 0;
		while (i > 0) {
			s += m_bit[i];
			i -= i & -i;
		}
		return s;
	}

	void add(int i, int x) {
		while (i <= m_n) {
			m_bit[i] += x;
			i += i & -i;
		}
	}
};

int main(void)
{
    cin.sync_with_stdio(false);
    cin >> N >> K;
    vector<ll> As(N);
    REP(n, N) {
        cin >> As[n];
        As[n] -= K;
    }

	// 累積和をとる　初項は0なのに注意
    vector<ll> Bs(N+1);
    REP(n, N) {
	    Bs[n+1] = Bs[n] + As[n];
    }

	// 座標圧縮のためのテーブル作成
	set<ll> nums;
	for (auto b : Bs) nums.insert(b);
	map<ll, int> table;
	int idx = 0;
	for (auto n : nums) {
		table[n] = idx;
		++idx;
	}

	// 座標圧縮
	vector<ll> Cs(N+1);
	REP(i, SIZE(Bs)) {
		Cs[i] = table[Bs[i]];
	}

	// BIT
	Bit bit;
	bit.init(idx+1);
	ll ans = 0;
	for (auto c : Cs) {
		ans += bit.sum(c + 1);
		bit.add(c + 1, 1);
	}

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


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

int main() {
    int n, m, x, ans = 12345678;
    cin >> n >> m >> x;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> c(n), alg(m);
    rep(i, n) {
        cin >> c[i];
        rep(j, m) { cin >> a[i][j]; }
    }

    for(int bit = 0; bit < (1 << n); bit++) {
        int money = 0;
        vector<int> alg(m);
        rep(i, n) {
            if(bit & (1 << i)) {
                rep(j, m) alg[j] += a[i][j];
                money += c[i];
            }
        }
        bool flag = true;
        rep(i, m) {
            if(alg[i] < x) {
                flag = false;
            }
        }
        if(flag) {
            ans = min(ans, money);
        }
    }

    if(ans == 12345678) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
    return 0;
}

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

#define ll long long
#define ss second
#define ff first
#define pb push_back

using namespace std;

const int N = 1e6 + 69;

ll n, answer, w;

ll dp[N], W[N], V[N];

int main(){

        ios :: sync_with_stdio(0);

        cin >> n >> w;

        for(int i = 0; i <= w; i++){
                dp[i] = -1;
        }

        dp[0] = 0;

        for(int i = 1; i <= n; i++){
                cin >> W[i] >> V[i];
                for(int j = w; j >= 0; j--){
                        if(j - W[i] >=0 && dp[j - W[i]] != -1){
                                dp[j] = max(dp[j - W[i]] + V[i],dp[j]);
                                answer = max(dp[j], answer);
                        }
                }
        }

        cout << answer << endl;
}


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

ll k, m, ans, a, b;
ll t[1 << 17], d[1 << 17];
vector<ll> u, v;

int main(){
    cin >> k >> a >> b;
    ans = 1;
    if (a + 1 >= b || a > k - 1){
        cout << k + 1 << endl;
        return 0;
    }
    else{
        ans = b;
        k -= a + 1;
        ans += (b - a) * (k / 2) + k % 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import bisect
#D2
n = int(input())
a = [int(input()) for j in range(n)]
 
dp = [a[0]]
for i in range(1,n):
    if dp[-1] < a[i]:
        dp.append(a[i])
        #print(0,dp)
 
    else:
        dp[bisect.bisect_left(dp, a[i])] = a[i]
        #print(1,bisect.bisect_left(dp, a[i]),dp)
print(len(dp))

Measured memory_bytes: 12468
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int MAX = 510000;
const int MOD = 1e17;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




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

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}



/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> v(n);
  rep(i,n) cin>>v[i];
  ll ans=MOD,tmp=Svec(v);
  vector<ll> sum(n);
  sum[0]=v[0];
  rep(i,n-1){
    sum[i+1]=sum[i]+v[i+1];
  }
  rep(i,n){
    ans=min(ans,(ll)abs(tmp-2*sum[i]));
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3428
# n, q = map(int, input().split())

# edge = [[] for _ in range(n)]

# counter = [0] * n

# for _ in range(n-1):
#     a, b = map(int, input().split())
#     edge[a-1].append(b-1)
#     edge[b-1].append(a-1)

# for _ in range(q):
#     a, b = map(int, input().split())
#     counter[a-1] += b

# parent = [0]
# visited = []

# for i in parent:
#     visited.append(i)
#     for v in edge[i]:
#         if v in visited:
#             continue
#         parent.append(v)
#         counter[v] += counter[i]
        
# for i in range(n):
#     print(counter[i], end=" ")
# print("")

import sys
input = sys.stdin.readline
 
N, Q = [int(x) for x in input().split()]
 
edge = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = [int(x) for x in input().split()]
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)
 
cost = [0] * N
for _ in range(Q):
    p, x = [int(x) for x in input().split()]
    cost[p - 1] += x
 
next = [0]
s_next = {0}
for i in next:
    for v in edge[i]:
        if v in s_next:
            continue
        s_next.add(v)
        next.append(v)
        cost[v] += cost[i]
 
print(" ".join(map(str, cost)))
 

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

int main() {
  int n,k;
  cin >> n >> k;
  int ans = 0;
  for(int i = 0; i < n; i++){
    int temp;
    cin >> temp;
    if(temp >= k){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
    int n;
    double d1=0,d2=0,d3=0,d4=0;
    cin >> n;
    int x[n],y[n];
    
    //xを入力
    for(int i=0;i<n;i++){
        cin >> x[i];
    }
    
    //yを入力
    for(int i=0;i<n;i++){
        cin >> y[i];
    }
    
    //d1(p=1)を計算
    for(int i=0;i<n;i++){
        d1 += fabs(x[i]-y[i]);
    }
    cout << fixed << d1 << endl;
    
    //d2(p=2)を計算
    for(int i=0;i<n;i++){
        d2 += fabs(x[i]-y[i]) * fabs(x[i]-y[i]);
    }
    
    d2 = sqrt(d2);
    cout << fixed << d2 << endl;
    
    //d3(p=3)を計算
     for(int i=0;i<n;i++){
        d3 += fabs(x[i]-y[i]) * fabs(x[i]-y[i]) * fabs(x[i]-y[i]);
    }
    d3 = pow(d3,1.0/3.0);
    cout << fixed << d3 << endl;
    
    //d4(p=∞)を計算
     for(int i=0;i<n;i++){
         if(d4<fabs(x[i]-y[i])){
             d4 = fabs(x[i]-y[i]);
         }
    }
    cout << fixed << d4 << endl;
}


Measured memory_bytes: 3416
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int r, g;
  cin >> r >> g;
  int res = g * 2 - r;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

void _main() {
    int L;
    cin >> L;
    int L2 = L, N = 0;
    while (L2) ++N, L2 >>= 1;
    using P = tuple<int, int, int>;
    vector<P> ans;
    REP (i, N - 1) {
        ans.emplace_back(i + 1, i + 2, 0);
        ans.emplace_back(i + 1, i + 2, 1LL << i);
    }
    int rem = L - (1LL << (N - 1));
    int last = 1LL << (N - 1);
    for (int i = N - 1; i >= 1; --i) {
        int num = 1LL << (i - 1);
        if (rem >= num) {
            ans.emplace_back(i, N, last);
            last += num;
            rem -= num;
        }
    }
    cout << N << " " << ans.size() << endl;
    REP (i, ans.size()) {
        int u, v, w;
        tie(u, v, w) = ans[i];
        cout << u << " " << v << " " << w << endl;
    }
}

signed main(signed argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

int n,m;
ll a[5005],b[5005][205],sum[5005][5005];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>m;
	for(int i=0;i<n-1;++i) cin>>a[i];
	for(int i=1;i<n-1;++i) a[i]+=a[i-1];
	for(int i=0;i<n;++i)
		for(int j=0;j<m;++j) 
			cin>>b[i][j];
	for(int i=0;i<m;++i){
		vector<int> dq,l(n),r(n);
		for(int j=0;j<n;++j){
			while(!dq.empty()&&b[j][i]>b[dq.back()][i]) dq.pop_back();
			l[j]=!dq.empty()?dq.back()+1:0;
			dq.push_back(j);
		}
		dq.clear();
		for(int j=n-1;~j;--j){
			while(!dq.empty()&&b[j][i]>b[dq.back()][i]) dq.pop_back();
			r[j]=!dq.empty()?dq.back()-1:n-1;
			dq.push_back(j);
		}
		for(int j=0;j<n;++j){
			sum[l[j]][j]+=b[j][i];
			sum[j+1][j]-=b[j][i];
			sum[l[j]][r[j]+1]-=b[j][i];
			sum[j+1][r[j]+1]+=b[j][i];
		}
	}
	ll res=0;
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j){
			sum[i][j]+=(i?sum[i-1][j]:0)+(j?sum[i][j-1]:0)-((i&&j)?sum[i-1][j-1]:0);
			ll dist=0;
			if(i>j) continue;
			if(j) dist+=a[j-1];
			if(i) dist-=a[i-1];
			res=max(res,-dist+sum[i][j]);
		}
	cout<<res<<'\n';
}



Measured memory_bytes: 207208
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#define PI			2*acos(0.0)
int main()
{
    int n,i;
    cin >>n;
    int a[n+1],b[n+1];
    for(i=1;i<=n;i++)
    {
        cin >>a[i];
        b[a[i]]=i;
    }
    for(i=1;i<=n;i++)
    {
        cout <<b[i]<<' ';
    }
    return 0;
}

Measured memory_bytes: 4304
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

int main() {
	set<int> A, B;
	int n;
	cin >> n;
	Rep(i, n) {
		int a;
		cin >> a;
		A.insert(a);
	}
	int m;
	cin >> m;
	Rep(i, m) {
		int b;
		cin >> b;
		B.insert(b);
	}
	set<int> res;
	Set_symmetric_difference(A, B, res);
	for (auto v : res) {
		cout << v << endl;
	}
	return 0;
}


Measured memory_bytes: 40548
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <bitset>
#include <list>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
bool pairCompare(const P& firstElof,const P& secondElof){
    return firstElof.first<secondElof.first;
}
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll a,b,c;cin>>a>>b>>c;
    if(min(a,b)<=c&&c<=max(a,b))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


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

int main() {
    ll n,k;
    std::cin >> n>>k;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    
    ll l = 0;
    ll r = 1e12;
    while(r-l>1){
        ll mid = (l+r)/2;
        ll cost = 0;
        for (int i = 0; i < n; i++) {
            cost += (a[i]+mid-1)/mid-1;
        }

        if(cost>k){
            l = mid;
        }else{
            r = mid;
        }
    }
    std::cout << r << std::endl;
}


Measured memory_bytes: 4764
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
#include<tuple>
#include<string.h>
#include <numeric> 
#include<unordered_map>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define pp1(...) "\033[1;47;35m" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "]\033[0m"
#define dg(x) debug() << pp1(x)
#define dg1(x) debug() << "[line : " << __LINE__ <<"]"<< pp(x)
#define dg2(x,y) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y)
#define dg3(x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << "[line : " << __LINE__ <<"]"<< pp(w) pp(x) pp(y) pp(z)
#define int long long
#define all(x) x.begin() , x.end()
#define clr(x , y) memset(x , y , sizeof x);
#define sz(x) (int)x.size()
template<typename T> void db(T x ){ debug() <<">>> " <<  x; }
template<typename T> void db(T x , T y){ debug() <<">>> " <<  x <<" , "<< y; }
template<typename T> void db(T x , T y , T z){ debug() <<">>> "<< x <<" , "<< y <<" , "<< z; }
template<typename T> void db(T x , T y , T z , T a){ debug() <<">>> "<< x <<" , " << y <<" , "<< z <<" , "<< a; }
const int xx = 2e5;
const int Mod = 1e9 + 7;
const int inf = 1e18;
const int Maxn = 20010;
int cnt = 0;
vector<vector<int>> g;
vector<int> vis;

void dfs(int v) {
  if(vis[v]) return ;
  vis[v] = 1;
  cnt++;
  for(auto i: g[v]){
    if(!vis[i]) {
      dfs(i);
    }
  }
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n , m;
  cin >> n >> m;
  g = vector<vector<int>>(n);
  vis = vector<int>(n, 0);
  for(int i = 0; i < m; i++) {
    int u , v;
    cin >> u >> v;
    u--,v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int ans = 0;
  for(int i = 0; i < n; i++) {
    if(!vis[i]) {
      cnt = 0;
      dfs(i);
      ans = max(ans , cnt);
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 21824
import math
from functools import reduce
from collections import deque
import itertools
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n = int(input())
p = input()
q = input()

p_count = 1
q_count = 1

def kaijo(n):
    ret = 1
    for i in range(n):
        ret *= n
    return ret

for rrr in itertools.permutations(map(str,range(1,n+1))):
    s = " ".join(rrr)
    if s < p:
        p_count += 1
    if s < q:
        q_count += 1


print(abs(p_count - q_count))

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

int main()
{

	int n, m;
	int A[1000];
	cin >> n >> m;
	double asum = 0;

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

	sort(A, A + n);

	bool ok = true;
	double th = asum / (m * 4);
	for (int i = 0; i < m; i++) {

		if (A[n - 1 - i] < th) {
			ok = false;
			break;
		}
	}

	if (ok)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;



}


Measured memory_bytes: 3600
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string S, T;
    cin >> S >> T;
    cout << T + S << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import math 

def be_able_to_convey(w, k, p):
	counter = 0
	cur_weight = 0
	for wi in w:
		if wi > p:
			return False

		cur_weight += wi
		if(cur_weight > p):
			cur_weight = wi
			counter += 1
			if(counter >= k):
				return False

	return True

#fin = open("test.txt", "r")
fin = sys.stdin

n, k = map(int, fin.readline().split())
w = [0 for i in range(n)]

for i in range(n):
	w[i] = int(fin.readline())
	
pmin = 1
pmax = int(10e9)

while pmin < pmax:
	p = math.ceil((pmin + pmax) / 2)
	if p == pmin or p == pmax:
		if be_able_to_convey(w, k, pmin):
			p = pmin
		else:
			#if not be_able_to_convey(w, k, pmax):
			#	print("error")
			p = pmax
		break

	if not be_able_to_convey(w, k, p):
		pmin = p
	else:
		pmax = p

print(p)

Measured memory_bytes: 11632
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;

int main(){
  double n,d,x;cin>>n>>d>>x;
  int ans = x;
  rep(i,n){
    int a;cin>>a;
    ans += ceil(d/a);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repd(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>; // グラフ型
using pint = pair<int, int>;

int main()
{
    string a, b;
    cin >> a >> b;
    int con = stoi(a + b);
    // int con = a * pow(10, c.size()) + b;
    bool ok = false;
    rep(i, 1001)
    {
        if (i * i == con)
        {
            ok = true;
        }
    }
    if (ok)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    cout << a*b/2 << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
def test():
    n = int(input())
    a = sorted(list(map(int,input().split())))
    b = a[n//2]; c = a[n//2-1]
    count = 0
    if sum(i<b for i in a) == sum(i>=b for i in a):
        print(b-c)
    else:
        print(0)


if __name__ == "__main__":
    test()


Measured memory_bytes: 14428
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n,m;cin>>n>>m;
    priority_queue<ll>q;
    for(int i=0;i<n;i++){
        ll d;cin>>d;
        q.push(d);
    }
    while(m--){
        ll a=q.top();
        q.pop();
        q.push(a/2);
    }
    ll sum=0;
    while(q.size()){
        sum+=q.top();
        q.pop();
    }
    cout<<sum<<"\n";
}


Measured memory_bytes: 1400
sx, sy, gx, gy = map(int, input().split())

print("U"*(gy-sy)+"R"*(gx-sx)+"D"*(gy-sy)+"L"*(gx-sx)+"L"+"U"*(gy-sy+1)+"R"*(gx-sx+1)+"D"+"R"+"D"*(gy-sy+1)+"L"*(gx-sx+1)+"U")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cerr << #x <<"->" << x << " , " ;
#define mod 1000000007


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

    int s   ; cin >> s ; 
    
    vector<long long> dp(s+1 , 0) ;

    dp[0] = 1 ;

    for(int i = 3 ; i <= s ; i++){
       for(int j = i-3; j >= 0 ; j--){
           (dp[i]+= dp[j])%= mod ;
       }
    }
    
    cout << dp[s] ;


    return 0;
}

Measured memory_bytes: 3644
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
var mod = 1e9+7;

console.log(main());
function main(){
  var k = o.a(1);
  var d = o.a();
  var dp = Array(d).fill(0).map(a=>Array(2).fill(0));
  dp[0][0] = 1;
  for(var i = 0; i < k.length; i++){
    var dp2 = Array(d).fill(0).map(a=>Array(2).fill(0));
    for(var j = 0; j < d; j++){
      for(var x = 0; x < k[i]; x++){
        var d2 = ((j-x)%d+d)%d;
        dp2[j][1] += dp[d2][0] + dp[d2][1];
      }
      var d2 = ((j-k[i])%d+d)%d;
      dp2[j][0] += dp[d2][0];
      dp2[j][1] += dp[d2][1];
      for(x = +k[i] + 1; x < 10; x++){
        var d2 = ((j-x)%d+d)%d;
        dp2[j][1] += dp[d2][1];
      }
    }
    dp = dp2.map(a=>a.map(a=>a%mod));
  }
  return (dp[0][0] + dp[0][1] + mod - 1) % mod;
}

Measured memory_bytes: 21064
#include <iostream>
using namespace std;
#include<math.h>
int main()
{
    int N,x;

    cin>>N;
    if(N>0 && N<10 && N!=5){
        x=pow(N,3);
        cout<<x;
    }

    else if(N==5){
        x=125;
        cout<<x;
    }

    else
        cout<<"Out of constraint";

        return 0;

}

Measured memory_bytes: 4044
#include <stdio.h>
 
int main(void){
	int yoko,tate;
	int kari1,kari2;
	while(1){
		scanf("%d %d",&tate,&yoko);
		if(yoko == 0 && tate == 0){
			break;
		}else{
			kari1 = 0,kari2 = 0;
			 for ( kari2 = 0; kari2 < yoko; kari2++ ){
                printf("#");
				}
			printf("\n");
            for ( kari1 = 0; kari1 < tate-2; kari1++ ){
				printf("#");
                for ( kari2 = 0; kari2 < yoko-2; kari2++ ){
                printf(".");
				}
				printf("#");
				printf("\n");
			}
		}
		 for ( kari2 = 0; kari2 < yoko; kari2++ ){
                printf("#");
				}
		printf("\n\n");
	}
    return(0);
}

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

using namespace std;

int main (void){
    string s;
    cin >> s;
    if (s == "MON") {cout << "6" << endl;}
    if (s == "TUE") {cout << "5" << endl;}
    if (s == "WED") {cout << "4" << endl;}
    if (s == "THU") {cout << "3" << endl;}
    if (s == "FRI") {cout << "2" << endl;}
    if (s == "SAT") {cout << "1" << endl;}
    if (s == "SUN") {cout << "7" << endl;}
}

Measured memory_bytes: 256