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

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

constexpr int MOD = 998244353;
constexpr int INF = 100000;

template<typename T> struct SegmentTree{
private:
    using F = function<T(T, T)>;

    int n;
    vector<T> node;
    F op;
    T id;
    T get(int a, int b, int k, int l, int r){
        if(b <= l || r <= a) { return id; }
        if(a <= l && r <= b) {
            return node[k];
        } else {
            return op(
                get(a, b, 2 * k + 1, l, (l + r) / 2),
                get(a, b, 2 * k + 2, (l + r) / 2, r));
        }
    }
public:
    SegmentTree(int sz, F op, T id): op(op), id(id) {
        n = 1;
        while (n < sz) { n *= 2; }
        node.resize(2 * n - 1, id);
    }
    void update(int i, T x){
        i += n - 1;
        node[i] = x;
        while(i > 0) {
            i = (i - 1) / 2;
            node[i] = op(node[2 * i + 1], node[2 * i + 2]);
        }
    }
    T get(int i){
        return node[i + n - 1];
    }
    T get(int a, int b){
        return get(a, b, 0, 0, n);
    }
};

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

    vector<pair<int, int>> xd(n);
    rep(i, 0, n) {
        int x, d;
        cin >> x >> d;
        xd[i] = make_pair(x, d);
    }
    sort(xd.begin(), xd.end());

    SegmentTree<int> tree(n, [](int a,int b)->int{ return max(a,b); }, -INF);

    rrep(i, 0, n) {
        int upper_bound = lower_bound(
            xd.begin(), xd.end(), make_pair(xd[i].first + xd[i].second, -INF)
            ) - xd.begin();

        if (upper_bound != i + 1) {
            upper_bound = max(upper_bound, tree.get(i + 1, upper_bound));
        }
        tree.update(i, upper_bound);
    }

    vi dp(n + 1, 0);
    dp[n] = 1;

    rrep(i, 0, n) {
        // Stop + Run.
        dp[i] = (dp[i+1] + dp[tree.get(i)]) % MOD;
    }
    cout << dp[0] << endl;

    return 0;
}

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

using namespace std;

int main(){
	int a,b,c,x,y;
	cin >> a >> b >> c >> x >> y;
	long long int ans1 = 0;
	long long int ans2 = 0;
	int z=0;
	ans1 = max(x,y)*c*2;
	if((a+b)/2 >= c){
		z = min(x,y);
		x -= z;
		y -= z;
		ans2 += c*z*2;
	}
	ans2 += a*x;
	ans2 += b*y;
	cout << min(ans1,ans2) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string s[100000];
int main(){
    unsigned long long ans=0;
    int N;
    cin >> N;
    map <string,unsigned long long>maps ;
    for(int i; i<N ; i++){
        cin>>s[i];
        sort(s[i].begin() , s[i].end() );
        maps[s[i]]++;
    }
    for(auto data:maps){
        unsigned long long n =data.second;
        ans +=( n*(n-1) ) / 2;
    }
    cout << ans <<endl;
}


Measured memory_bytes: 18176
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

MOD=10**9+7
MAX_N=10**5
$fact=array(MAX_N+1)
def fact_init()
    $fact[0]=$fact[1]=1
    2.upto(MAX_N) do|i|
        $fact[i]=$fact[i-1]*i%MOD
    end
end
def fact(n)
  return $fact[n]
end
N,M=get_i
fact_init()
if (N-M).abs>=2
    puts 0
elsif (N-M).abs==1
  puts (fact(N)*fact(M))%MOD
elsif (N-M).abs==0
  puts (fact(N)*fact(M)*2)%MOD
end

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


int main()
{
    vector<pair<pair<string,int>,int>> v;
    string s[2000];
    int n,p[2000],i,j,k;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>s[i]>>p[i];
        v.push_back({{s[i],100-p[i]},i});
        
    }
    sort(v.begin(),v.end());
    for(i=0;i<v.size();i++)
        cout<<v[i].second+1<<endl;
    
}


Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var K = parseInt(input[0].split(" ")[1]);
  var V = input[1].split(" ").map(i=>parseInt(i));
  var ans=0;
  var save=[];
  for(var i=0;i<Math.min(K+1,N+1);i++){
    var minus=[...save];
    if(i==0){
      rsub=0;
    }else{
      rsub+=V[i-1];
    }
    if(V[i-1]<0){
      minus.push(V[i-1]);
      minus.sort(function(a,b){return a-b});
    }
    var save = [...minus];
    for(var j=0;j<Math.min(K+1-i,N+1-i);j++){
      if(j==0){
        lsub=0;
      }else{
        lsub+=V[N-j];
      }
      if(V[N-j]<0){
        minus.push(V[N-j]);
        minus.sort(function(a,b){return a-b});
      }
      var asub=rsub+lsub;
      for(var k=0;k<Math.min(K-i-j,minus.length);k++){
        asub-=minus[k];
      }
      ans=Math.max(ans,asub);
    }
  }
  
  

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 20168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=2019;
ll pw(ll a, ll b, ll mod) {
  if (b == 0) return 1;
  if (b % 2 == 1) return pw(a, b-1, mod) * a % mod;
  ll temp = pw(a, b/2, mod);
  return temp * temp % mod;
}
int main(void){
    string s;
    cin>>s;
    ll n=s.size();
    ll dp[200002]={};
    for(int i=n+1;i>1;i--){
        int a=s[i-2]-'0';
        dp[i-1]=(pw(10,n+1-i,mod)*a+dp[i])%mod;
    }
    ll x[2019]={};
    for(int i=1;i<=n;i++) x[dp[i]]++;
    ll ans=0;
    for(int i=0;i<2019;i++){
        ans+=x[i]*(x[i]-1)/2;
    }
    ans+=x[0];
    //for(int i=1;i<=n;i++) cout<<i<<" "<<dp[i]<<endl;
    cout<<ans<<endl;
}

Measured memory_bytes: 5324
#include<iostream>
#include<cmath>
using namespace std;
//201820130210  
int main()
{
	long long a,b,c;
	cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0)
	{
		cout<<"0";
		return 0; 
	 } 
	long long ans1,ans2,ans3;
	ans1=a*b;ans2=a*c;ans3=b*c;
	long long Min=min(ans1,ans2);
	Min=min(Min,ans3);
	cout<<Min;
	return 0;
 } 

Measured memory_bytes: 256
#include <random>

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cstring>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    vector<int> X, Y;
    int N, K;
    cin >> N >> K;
    vector<pair<int, int> > P;
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        X.push_back(x);
        Y.push_back(y);
        P.emplace_back(x, y);
    }
    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());
    long long ans = 7e18;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int k = 0; k < N; k++) {
                for (int l = k + 1; l < N; l++) {
                    int cnt = 0;
                    for (int m = 0; m < N; m++) {
                        cnt += X[i] <= P[m].first && P[m].first <= X[j] &&
                               Y[k] <= P[m].second && P[m].second <= Y[l];
                    }
                    if (cnt >= K) {
                        ans = min(ans, 1ll * (X[j] - X[i]) * (Y[l] - Y[k]));
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <algorithm>
#define EPS 1e-10
#define EQ(a,b) (abs(a - b) < EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag))
using namespace std;

typedef complex<double> P;

double cross (P a, P b) {
    return (a.real() * b.imag() - a.imag() * b.real());
}

bool is_parallel(P a1, P a2, P b1, P b2) {
    return EQ( cross(a1 - a2, b1 - b2), 0.0);
}

int main(void)
{
    int n;
    cin >> n;
    while (n--) {
	P a1, a2, b1, b2;
	double x1, x2, x3, x4, y1, y2, y3, y4;
	cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
	a1 = P(x1, y1);
	b1 = P(x2, y2);
	a2 = P(x3, y3);
	b2 = P(x4, y4);

	if (is_parallel(a1, b1, a2, b2)) cout << "YES" << endl;
	else cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <cstring>
#include <cctype>
#include <ctime>
#include <climits>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <tuple>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <complex>
#include <random>
#include <cassert>
#include <chrono>
#include <cstdint>
#include <functional>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#ifndef M_PI
#define M_PI 3.141592653589793238462643383279
#endif

#define int long long

#define mp make_pair
#define mt make_tuple
#define fr first
#define sc second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(), x.end()
#define get0 get<0>
#define get1 get<1>
#define get2 get<2>
#define get3 get<3>

#define debug(x) cerr << #x << " = " << x << ", line = " << __LINE__ << endl

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef tuple<long long, long long, long long> tlll;
typedef tuple<int, int, int> tiii;
typedef tuple<int, int, int, int> tiiii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MOD = 1e9 + 7;



int32_t main()
{
#ifdef chikibambony
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#endif
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int j = 0; j < n; ++j) {
        cin >> b[j];
    }
    reverse(all(b));
  	int l = 0;
    int c = -1;
    for (int i = 0; i < n; ++i) {
        if (a[i] == b[i]) {
            c = a[i];
          	l=i;
            break;
        }
    }
    
   int r = -1;
    for (int i = n - 1; i >= 0; --i) {
        if (a[i] == c && b[i] == c) {
            r = i;
            break;
        }
    }

    for (int i = 0; i < n; ++i) {
        if (a[i] != c && b[i] != c && l <= r) {
            swap(b[i], b[l]);
            ++l;
        }
    }

    if (l <= r) {
        cout << "No\n";
        return 0;
    }

    cout << "Yes\n";

    for (int i = 0; i < n; ++i) {
        cout << b[i] << ' ';
        assert(b[i] != a[i]);
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 6352
require 'matrix'
p1x, p1y, p2x, p2y = gets.split.map &:to_i
p1 = Vector[ p1x, p1y ]
p1p2 = Vector[ p2x - p1x, p2y - p1y ]
q = gets.to_i
q.times do
  px, py = gets.split.map &:to_i
  p1p = Vector[ px - p1x, py - p1y ]
  p1t_norm = p1p.inner_product(p1p2) / p1p2.norm
  t = p1 + p1p2 * ( p1t_norm / p1p2.norm )
  puts "%.8f %.8f" % [ t[0], t[1] ] 
end

Measured memory_bytes: 9332
#include <stdio.h>

int main(void)
{
    char s[200005];
    int loop_s, loop_e, e_log = 0;
    scanf ("%s", s);

    for (loop_s = 0; s[loop_s] != '\0'; loop_s++)
    {
        if (s[loop_s] == 'A')
        {
            for (loop_e = loop_s + 1; s[loop_e] != '\0';loop_e++) if (s[loop_e] == 'Z' && e_log < loop_e) e_log = loop_e;

            break;
        }
    }
    printf ("%d", e_log - loop_s + 1);
    return (0);
}


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

using ll = long long;

template<typename T>
T gcd(T a, T b)
{
	if (a < b)	return gcd(b, a);
	T r;
	while ((r = a % b))
	{
		a = b;
		b = r;
	}
	return b;
}

template<typename T>
T lcm(T a, T b)
{
	return a * b / gcd(a, b);
}

template<typename T>
T ext_gcd(T a, T b, T& x, T& y)
{
	x = 1;
	y = 0;
	T x0 = 0, y0 = 1;
	while (b != 0)
	{
		T q = a / b;
		a -= q * b;
		swap(a, b);
		x -= q * x0;
		swap(x, x0);
		y -= q * y0;
		swap(y, y0);
	}
	return a;
}

template<typename T>
T inv_mod(T a, T mod)
{
	T t1, t2;
	ext_gcd(a, mod, t1, t2);
	t1 %= mod;
	if (t1 < 0)		t1 += mod;
	return t1;
}

template<typename T>
T combination_large(T n, T k, T mod)
{
	if (n < k || n < 0 || k < 0)	return 0;
	vector<T> inv(n + 1, 1), fact(n + 1, 1), fact_inv(n + 1, 1);
	for (T i = 2; i <= n; ++i)
	{
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fact[i] = (fact[i - 1] * i) % mod;
		fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
	}
	return fact[n] * (fact_inv[k] * fact_inv[n - k] % mod) % mod;
}

template<typename T>
T combination(T n, T k, T mod = 1)
{
	vector<vector<T>> table(n + 1, vector<T>(k + 1, 1));
	for (T i = 1; i <= n; ++i)
	{
		table[i][0] = 1;
		for (T j = 1; j <= n; ++j)
		{
			table[i][j] = (table[i - 1][j - 1] + table[i - 1][j]) % mod;
		}
	}
}


int main(int, char**)
{
	long long N;
	scanf("%lld",&N);
	long long K;
	scanf("%lld",&K);
	std::vector<long long> H(N);
	for(ll i = 0 ; i < N ; i++){
		scanf("%lld",&H[i]);
	}

	sort(H.begin(), H.end(), greater<ll>());
	ll sum = 0;
	for (ll i = K; i < N; ++i)
	{
		sum += H[i];
	}
	cout << sum << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
#define MAXN 100100
int n, m, x, y;
double u, v, ans;
char s[MAXN];
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%d%d",&x,&y);
	u = (double)x*30 + (double)y*0.5;
	v = y*6;
	if(u >= v) u = u-v;
	else u = v-u;
	u = min(u, 360-u);
	ans = sqrt((double)n*n+(double)m*m-(double)2*n*m*cos(u/180*3.14159265358979));
	printf("%.16lf\n",ans);
	
	return 0;
}

Measured memory_bytes: 4256
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+5;
int n,ans;
int a[N];
char str[N];
int main(){
	scanf("%s",str+1);
	n=strlen(str+1);
	for (register int i=1; i<=n; ++i) a[i]=str[i]-'0';
	for (register int i=n; i>=0; --i)
	{
		if (a[i]>5) a[i-1]++,ans+=10-a[i];
		else if (a[i]<5) ans+=a[i];
		else
		{
			ans+=5;
			if (a[i-1]>=5) a[i-1]++; 
		}
	}
	printf("%d\n",ans);
return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define int long long
#define double long double
#define all(a) a.begin(), a.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int N, A, B;
vector<int> answer;
vector<bool> used;

void dfs(int start, int goal, int bit){
    bit--;
    if (bit == 0) {
        answer.push_back(start);
        answer.push_back(goal);
    } else if ((start ^ goal) & (1 << bit)) {
        int nst = start ^ 1;
        dfs(start, nst, bit);
        int ngo = nst ^ (1 << bit);
        dfs(ngo, goal, bit);
    } else {
        dfs(start, goal, bit);
        answer.pop_back();
        int nst = answer.back() ^ (1 << bit);
        int ngo = goal ^ (1 << bit);
        dfs(nst, ngo, bit);
        answer.push_back(goal);
    }
}

signed main(void){

    cin >> N >> A >> B;

    if (__builtin_popcount(A) % 2 == __builtin_popcount(B) % 2) {
        cout << "NO\n";
        return 0;
    }

    cout << "YES\n";
    
    dfs(A, B, N);
    rep(i, answer.size()){
        if (i == answer.size()-1) cout << answer[i] << '\n';
        else cout << answer[i] << ' ';
    }

}

Measured memory_bytes: 2164
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	 public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(Character.isUpperCase(s.charAt(0))) System.out.println('A');
		else System.out.println('a');
	 }
}

Measured memory_bytes: 35772
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    L = list(map(int, input().split()))

    ans = 0
    for i in range(N - 2):
        a = L[i]
        for j in range(i + 1, N - 1):
            b = L[j]
            for k in range(j + 1, N):
                c = L[k]
                if (a != b) and (b != c) and (c != a) and (a + b > c) and (b + c > a) and (c + a > b):
                    ans += 1

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  int a,b;
  cin >> a >> b;
  if(a >= 13) b = b;
  else if(a >= 6) b = b/2;
  else b = 0;
  cout << b << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define SWAP(type,a,b)do{type temp=a;a=b;b=temp;}while(0)
typedef struct sets{
  int tID;
  int AC;
  int WA[11];
  int Panel;
}hello;

int main(){
  int T,P,R,i,j,a,b,c,d;
  char message[10];
  while(1){
    scanf("%d %d %d",&T,&P,&R);
    if(T==0&&P==0&&R==0)break;
    hello set[T+1];
    for(i=1;i<=T;i++){
      set[i].tID=i;
      set[i].AC=0;
      for(j=0;j<=10;j++) set[i].WA[j]=0;
      set[i].Panel=0;
    }

    for(i=0;i<R;i++){
      scanf("%d %d %d %s",&a,&b,&c,message);
    
      if(strcmp(message,"WRONG")==0){
	set[a].WA[b]++;
      }else{
	set[a].AC++;
	set[a].Panel+=set[a].WA[b]*1200+c;
      }
    }

    for(i=1;i<T;i++){
      for(j=T;j>i;j--){
	if(set[j].AC>set[j-1].AC){
	  SWAP(hello,set[j],set[j-1]);
	}
      }
    }
    for(i=1;i<T;i++){
      for(j=T;j>i;j--){
	if(set[j].AC==set[j-1].AC&&set[j].Panel<set[j-1].Panel){
	  SWAP(hello,set[j],set[j-1]);
	}
      }
    }
    for(i=1;i<T;i++){
      for(j=T;j>i;j--){
	if(set[j].AC==set[j-1].AC && set[j].Panel == set[j-1].Panel){
	  if(set[j].tID<set[j-1].tID){
	    SWAP(hello,set[j],set[j-1]);
	  }
	}
      }
    }

    for(i=1;i<=T;i++){
      printf("%d %d %d\n",set[i].tID,set[i].AC,set[i].Panel);
    }
  }
  return 0;
}

Measured memory_bytes: 608
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
#include<stdlib.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int i = 0, number;
    int a[1010] = {0}, b[1010] = {0};
    string input;

    while(getline(cin, input), !input.empty())
        a[atoi(input.c_str())]++;
    while(getline(cin, input))
        b[atoi(input.c_str())]++;
    rep(i,1010)
        if(a[i] && b[i])
            cout << i << ' ' << a[i] + b[i] << endl;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
const int INF = 1000000000;
typedef pair<int, int> P;
const int MAX_N = 1000000000;
typedef int64_t ll;
template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
	string s;
	cin >> s;
	int A=0, Z=0;
	rep(i, s.size()) {
		if (s.at(i)=='A')
		{
			A = i;
			break;
		}
	}
	
	for (int i = A+1; i < s.size(); i++)
	{
		if (s.at(i)=='Z')
		{
			Z = i;
		}
	}
	cout << Z - A + 1 << endl;
}

Measured memory_bytes: 3696
use std::io;
use std::collections::VecDeque;

fn main() {
    let mut input = Input::new();
    let n: usize = input.next();
    let x: usize = input.next();
    if x == 1 || x == 2 * n - 1 {
        println!("No");
        return;
    }
    if n == 2 && x == 2 {
        println!("Yes");
        println!("1 2 3");
        return;
    }
    let mut b: Vec<usize> = vec![0; 2 * n - 1];
    let mut t = 0;
    if x < n {
        b[n - 1] = x;
        b[n - 2] = x - 1;
        b[n - 3] = x + 1;
        b[n] = x + 2;
        t = x - 2;
    } else {
        b[n - 1] = x;
        b[n - 2] = x + 1;
        b[n - 3] = x - 1;
        b[n] = x - 2;
        t = x - 3;
    }
    println!("Yes");
    for i in 0..(2 * n - 1 - 4) {
        b[i + if i < n - 3 { 0 } else { 4 }] = i + 1 + if i < t { 0 } else { 4 };
    }
    for i in 0..(2 * n - 1) {
        println!("{}", b[i]);
    }
}

struct Input {
    queue: VecDeque<String>,
}

impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }

    fn next<T>(&mut self) -> T
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap().parse::<T>().unwrap();
    }
}



Measured memory_bytes: 7676
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
#define F first
#define S second
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
using priority_queue_small = priority_queue<int, vector<int>, greater<int> >;
template<class T>using vv = vector<T>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

ll n, x;
ll pat[51], ban[51], sum[51];

ll eating(ll l, ll p) {
  if (l <= 1) {
    if (l == 0) {
      if (p > 0) return 1LL;
      else return 0;
    } else if (l == 1) {
      if (p >= 4) return 3LL;
      else if (p >= 3) return 2LL;
      else if (p >= 2) return 1LL;
      else return 0LL;
    } else {
      return 0;
    }
  }
  if (p <= 1) return 0LL;
  ll res = 0LL;
  if ((sum[l]-1) / 2 <= p-1) {
    res += pat[l-1] + 1;
    res += eating(l-1, p-sum[l-1]-2-(sum[l] == p));
  } else {
    res += eating(l-1, p-1);
  }
  return res;
}

int main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n >> x;
  pat[0] = 1, ban[0] = 0, sum[0] = 1; 
  erep(i, 1, n) {
    pat[i] = pat[i-1] * 2 + 1;
    ban[i] = ban[i-1] * 2 + 2;
    sum[i] = pat[i] + ban[i];
  }
  cout << eating(n, x) << endl;
  return 0;
}



Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);


int sz;
string S;
char add(char c, int d){
  d = (d+26*5) % 26;
  while(c+d > 'Z')
	d -= 26;
  return c+d;
}

string conv(int s, int e){
  if(s >= e) return "";
  
  if(S[s] == '['){
	int cnt = 0, j = s;
	for(;j<e;++j){
	  if(S[j] == '[') ++cnt;
	  else if(S[j] == ']'){
		if(--cnt == 0) break;
	  }
	}
	string res1 = conv(s+1,j);
	string res2 = conv(j+1, e);
	reverse(ALL(res1));
	return res1 + res2;
  }

  int d = 0;
  for(;;++s){
	if('A' <= S[s] && S[s] <= 'Z'){
	  string res(1, add(S[s],d));
	  res += conv(s+1,e);
	  return res;
	}
	else if(S[s] == '+') ++d;
	else --d;
  }
}

string dfs(int i){
  if(i == SZ(S)){
	return conv(0, sz);
  }
  if(S[i] != '?') return dfs(i+1);

  string res(100, 'Z');
  for(char c='A';c<='Z';++c){
	S[i] = c;
	res = min(res, dfs(i+1));
  }
  S[i] = '?';

  return res;
}

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

  while(cin>>S, S!="."){
	sz = SZ(S);
	cout << dfs(0) << endl;
  }
  
  return 0;
}

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

int N;
char field[300][300];

char Get(int y, int x) {
  int a = (N+y%N)%N;
  int b = (N+x%N)%N;
  return field[a][b];
}

bool Check(int A, int B) {
  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      if (Get(i-A, j-B) != Get(j-A, i-B)) return false;
    }
  }
  return true;
}

int main() {
  scanf("%d", &N);
  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      scanf(" %c", &field[i][j]);
    }
  }

  int ans = 0;
  for (int i=0; i<N; i++) {
    if (Check(i, 0)) ans += N-i;
  }

  for (int i=1; i<N; i++) {
    if (Check(0, i)) ans += N-i;
  }
  printf("%d\n", ans);
}


Measured memory_bytes: 512
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
      	String s = scan.next();
      	int counter = 0;
      	if(s.charAt(0) == 'o'){
        	counter++;
        }
      	if(s.charAt(1) == 'o'){
        	counter++;
        }
      	if(s.charAt(2) == 'o'){
        	counter++;
        }
      	System.out.print(700 + counter * 100);
    }
}

Measured memory_bytes: 21844
function Main(input) {
    input = input.split(' ');
    const A = Number(input[0]);
    const B = Number(input[1]);
    const K = Number(input[2]);

    for (let i = A; i < A + K && i <= B; i++) {
        console.log(i);
    }

    for (let i = B - K + 1; i <= B && i > A; i++) {
        if (i < A + K) continue;
        console.log(i);
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9136
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){
        IsPrime.resize(max+1,true);
    } 
    IsPrime[0] = false;
    IsPrime[1] = false;

    for(size_t i=2; i*i<=max; ++i){
        if(IsPrime[i]){
            for(size_t j=2; i*j<=max; ++j){
                IsPrime[i*j] = false;
            }
        }
    }
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;++i){
        cin>>a[i];
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    if(n == 2){
        cout<<a[0]<<endl;
        return 0;
    }
    
    ll ans = 0;
    priority_queue<ll> b;
    b.push(a[0]);
    for(ll i=1;i<n;++i){
        ans += b.top();
        b.pop();
        b.push(a[i]);
        b.push(a[i]);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 6940
# -*- coding: utf-8 -*-
import sys

N, M = map(int, input().split())
a_list = list(map(int, input().split()))

# lcm & gcd not math
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(x, y):
    return (x * y) // gcd(x, y)

from functools import reduce
def lcm_multi(num_list):
    return reduce(lcm, num_list, 1)

# number of being able to divide by 2 in all of list
def get_num_can_divide_two(num_list):
    bin_num_or = 0
    for now_num in num_list:
        bin_num_or |= now_num

    num_can_divide_two = 0
    while bin_num_or > 0:
        can_divede_two = bin_num_or & 1
        if can_divede_two:
            break
        bin_num_or >>= 1
        num_can_divide_two += 1

    return(num_can_divide_two)

num_can_divide_two = get_num_can_divide_two(a_list)

for i in range(N):
    if (a_list[i] // (2 ** num_can_divide_two)) % 2 == 0:
        print(0)
        sys.exit()
        

lcm_num =  lcm_multi(a_list)

print((M - lcm_num // 2) // lcm_num + 1)

Measured memory_bytes: 14244
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    //dp[i][j] Xのi文字目までとYのj文字目までのLCS
    int q;
    cin >> q;
    rep(i, q) {
        string X, Y;
        cin >> X >> Y;
        int m = X.size(), n = Y.size();
        vector<vector<int>> dp(m + 1, vector<int>(n + 1, 0));
        rep(j, m) {
            rep(k, n) {
                if (X[j] == Y[k]) {
                    dp[j + 1][k + 1] = dp[j][k] + 1;
                } else {
                    dp[j + 1][k + 1] = max(dp[j][k + 1], dp[j + 1][k]);
                }
            }
        }
        cout << dp[m][n] << "\n";
    }
}


Measured memory_bytes: 6804
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node {
  int key;
  Node *next, *prev;
};

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next; // ??????????¬????????´?????????????
  while ( cur != nil && cur->key != key ) {
    cur = cur->next;
  }
  return cur;
}

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList() {
  Node *cur = nil->next;
  int isf = 0;
  while ( 1 ) {
    if ( cur == nil ) break;
    if ( isf++ > 0 ) printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if (t == nil ) return; // t ??????????????´?????????????????????
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  // ????´¢????????????????????????
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  // ???????????´??????????´??????????
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main() {
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ) {
    scanf("%s%d", com, &key); // ?????????????????\?????¢??°????????¨
    if ( com[0] == 'i' ) { insert(key); np++; size++; }
    else if ( com[0] == 'd' ) {
      if ( strlen(com) > 6 ) {
        if ( com[6] == 'F' ) deleteFirst();
        else if ( com[6] == 'L' ) deleteLast();
      } else {
        deleteKey(key); nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}

Measured memory_bytes: 33876
// クイックソート

#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ) {
    if ( L[i].value <= R[j].value ) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[], int n, int left, int right) {
  int mid;
  if ( left + 1 < right ) {
    mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int partition(struct Card A[], int n, int p, int r) {
  int i, j;
  struct Card t, x;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ ) {
    if ( A[j].value <= x.value ) {
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  }
  t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
  return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  int q;
  if ( p < r ) {
    q = partition(A, n, p, r);
    quickSort(A, n, p, q - 1);
    quickSort(A, n, q + 1, r);
  }
}

int main() {
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  // 入力
  for ( i = 0; i < n; i++ ) {
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n - 1);

  for ( i = 0; i < n; i++ ) {
    if ( A[i].suit != B[i].suit ) stable = 0;
  }

  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for ( i = 0; i < n; i++ ) {
    // printf("%c %d\n", A[i].suit, A[i].value);
    printf("%c %d\n", B[i].suit, B[i].value);
  }

  return 0;
}


Measured memory_bytes: 5072
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main()
{
  int N;
  cin >> N;
  vector <pair<int,int>> X(N);
  for( int i=0;i<N;i++ )
    {
      int t;
      cin >> t;
      X[i] = make_pair(t,i);
    }

  sort(X.begin(), X.end(), [](auto &lhs, auto &rhs) {return lhs.first < rhs.first;});

  int lm = X[N/2].first;
  int rm = X[N/2-1].first;

  for( int i=0;i<N;i++ )
    {
      if(i<N/2)
	X[i].first = lm;
      else
	X[i].first = rm;
    }
  sort(X.begin(), X.end(), [](auto &lhs, auto &rhs) {return lhs.second < rhs.second;});
  for( int i=0;i<N;i++ )
    cout << X[i].first << endl;
  
}


Measured memory_bytes: 3712
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)

//string s = to_string(i);

//char→小文字のほうが大きい数値　　&&　その差は32

//大文字→小文字 文字列のn文字目を大文字で出力→ (char)toupper(a[0])

int a = 0, b = 0, c = 0,d=0, x = 0, y = 0, z = 0, n = 0, sum = 0, i = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> n >> x;
	vint m(n);
	int cmin = 100000;
	rep(i, n) {
		cin >> m[i];
		sum += m[i];
		cmin = min(cmin, m[i]);
	}
	x -= sum;
	cnt = x / cmin;
	cnt += n;
	cout << cnt << rt;
	please AC;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int []pos=new int [n];
		for(int i=0;i<n;i++)
			pos[sc.nextInt()-1]=i;
		int ans=1;
		int s=1;
		for(int i=1;i<n;i++)
		{	
			if(pos[i]>pos[i-1])
			{
				s++;
			}
			else
				s=1;
			ans=Math.max(ans, s);
		}
		System.out.println(n-ans);
		

	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		public Scanner(InputStream s)
		{
			br=new BufferedReader(new InputStreamReader(s));
		}
		public Scanner(String s) throws FileNotFoundException
		{
			br=new BufferedReader(new FileReader(s));
		}
		public String nextLine() throws IOException
		{
			return br.readLine();
		}
		public String next() throws IOException
		{
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int nextInt() throws IOException
		{
			return Integer.parseInt(next());
			
		}
		public double nextDouble() throws IOException
		{
			return Double.parseDouble(next());
		}
		public boolean ready() throws IOException
		{
			return br.ready();
		}
		public long nextLong() throws IOException
		{
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 46104
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;
const long double EPS = 0.00000001;

long long int N, M, K, W, H, L, R;
long long int ans;

int main() {
	ios::sync_with_stdio(false);
	cin >> H >> W >> L >> R;
	bool flag[2][1000] = {};
	for (int i = H; i < W; i++)flag[0][i] = true;
	for (int i = L; i < R; i++)flag[1][i] = true;
	for (int i = 0; i < 100; i++)if (flag[0][i] && flag[1][i])ans++;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n;
ll h[200009],a[200009];
ll g[200009];
int update(int x,ll val){
    for(;x<=n;x+=x&-x)g[x]=max(g[x],val);
}
ll ask(int x){
   ll ans=0;
   for(;x;x-=x&-x)ans=max(ans,g[x]);
   return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;i++)cin>>h[i];
    for(int i=1;i<=n;i++)cin>>a[i];
    ll answer=0;
    for(int i=1;i<=n;i++){
        ll aa=ask(h[i]-1);
        answer=max(answer,aa+a[i]);
        update(h[i],aa+a[i]);
    }
    cout<<answer<<endl;
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,a; cin>>x>>a;
    if (x<a){
        cout<<0<<endl;
    }else{
        cout<<10<<endl;
    }
    return 0;
}


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

struct Dinic {
    struct edge {
        int to, cap, rev;
    };

    int n;
    vector<vector<edge>> G;
    vector<int> level;
    vector<int> iter;

    void bfs(int s) {
        level.assign(n, -1);
        queue<int> que;
        que.push(s);
        level[s] = 0;
        while (que.size()) {
            int v = que.front();
            que.pop();
            for (int i = 0; i < G[v].size(); i++) {
                edge &e = G[v][i];
                if (e.cap > 0 && level[e.to] < 0) {
                    level[e.to] = level[v] + 1;
                    que.push(e.to);
                }
            }
        }
    }

    int dfs(int v, int t, int f) {
        if (v == t) return f;
        for (int i = iter[v]; i < G[v].size(); i++) {
            edge &e = G[v][i];
            if (e.cap > 0 && level[v] < level[e.to]) {
                int d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }

    Dinic(int n) : n(n), G(n), level(n), iter(n) {}

    void add_edge(int from, int to, int cap) {
        G[from].push_back({to, cap, (int) G[to].size()});
        G[to].push_back({from, 0, (int) G[from].size() - 1});
    }

    int max_flow(int s, int t) {
        int flow = 0;
        while (1) {
            bfs(s);
            if (level[t] < 0) return flow;
            iter.assign(n, 0);
            int f;
            while ((f = dfs(s, t, 1e18)) > 0) {
                flow += f;
            }
        }
    }
};

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

    int n;
    cin >> n;
    int sum = 0;
    Dinic dinic(n + 2);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (a > 0) sum += a;
        if (a < 0) {
            dinic.add_edge(n, i, -a);
        } else {
            dinic.add_edge(i, n + 1, a);
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 2; i * j <= n; j++) {
            dinic.add_edge(i - 1, i * j - 1, 1e18);
        }
    }
    cout << sum - dinic.max_flow(n, n + 1) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int main(void) {
    long long N;
    cin >> N;
    int h, n, w;
    REP (h,1,3500) REP (n,1,3500) {
        long long x = N * h * n;
        long long y = 4 * h * n - N * n - N * h;
        if (y > 0 && x % y == 0) {
            printf("%d %d %d\n",h,n,x/y);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>
using namespace std;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n>>k;
	long double ans = 0;
	for(int i=1;i<=n;i++){
		int x = i, pw = 0;
		while(x<k){
			x*=2;
			pw++;
		}
		long double pow = 1;
		for(int j=0;j<pw;j++){
			pow = pow/2;
		}
		ans += pow;
	}
	ans /= n;
	cout<<fixed<<setprecision(10)<<ans;
	return 0;
}
//.........

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

using namespace std;

int main(int argc, char *argv[]) {
  set<int> se;
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (se.count(x)) {
      se.erase(x);
    } else {
      se.insert(x);
    }
  }
  cout << se.size() << endl;
  return 0;
}


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


int main(){
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    int answ,anss;
    double ratio=-1.0;
    for(int na=0;na*100*a<=3000;na++){
        for(int nb=0;100*na*a+100*nb*b<=f;nb++){
            int water=100*a*na+100*b*nb;
            int max_sugar=(a*na+b*nb)*e;

            for(int nc=0;nc*c<=max_sugar;nc++){
                for(int nd=0;(nc*c+nd*d)<=max_sugar && ((nc*c+nd*d)+water)<=f;nd++){
                    int sugar=c*nc+d*nd;
                    double r=100.0*sugar/(water+sugar);
                    if(ratio<r){ratio=r;answ=water+sugar;anss=sugar;}
                }
            }
        }
    }
   
cout<<answ<<" "<<anss<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<string>
#include<string.h>
#include<map>
#include<vector>
#include<set>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s[0]=='Y'&&s[1]=='A'&&s[2]=='K'&&s[3]=='I')
	cout<<"Yes"<<endl;
	else
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
x,y = (int(x) for x in input().split())
l1 = [1,3,5,7,8,10,12]
l2 = [4,6,9,11]
l3 = [2]
n = 0
if x in l1:
  if y in l1:
    print ('Yes')
    n = 1
elif x in l2:
  if y in l2:
    print ('Yes')
    n = 1
else:
  if y in l3:
    print ('Yes')
    n = 1
if n == 0:
  print ('No')

Measured memory_bytes: 9016
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <cmath>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define all(x) x.begin(),x.end()
#define mkpr(x1,x2) make_pair(x1,x2)
typedef long long int ll;


//stack<char> stk;
//set<ll> sll;
set<pair<ll,ll>> spll;
//map<string,ll> mp;
//map<pair<ll,ll>,ll>::iterator iter;
//map<ll,ll> mp;
//deque<ll> deq;
//vector<ll> vll;
ll num[10][10];
//priority_queue<ll> pq;          //decreasing

int main(void)
{
    long long int m,n,i,j,k,sum=0,l,r;
    cin>>l>>r>>n;
    cout<<(r/n)-(l-1)/n;
    return 0;
}





Measured memory_bytes: 3616
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static int e;
    public static void main(String[] args) {
        while(read()){
            solve();
        }
    }

    static boolean read(){
        e = sc.nextInt();
        if(e == 0)return false;
        return true;
    }

    static void solve(){
        int x = 0, y = 0, z = 0;
        int m = Integer.MAX_VALUE;
        for(z = 0; z*z*z  <= e; z++){
            for(y = 0; z*z*z + y * y <= e; y++){
                m = Math.min(m, z + y + (e - y * y - z*z*z));
            }
        }
        System.out.println(m);
    }

}

Measured memory_bytes: 12000