akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<math.h>
using namespace std;
int main(void){
	vector<pair<long long,long long> >xy;
	vector<long long>a;
	long long lis[200010];
	long long lsize;
	long long c, d;
	long long k;
	long long n, m;
	long long s, t;
	long long xx, yy;
	long long w, x, y, z;
	long double ans;
	long long l, r;
	long long x1, x2, y1, y2;
	scanf("%lld %lld %lld %lld", &x1, &y1, &x2, &y2);
	scanf("%lld", &n);
	if (y1 > y2){
		k = x1;
		x1 = x2;
		x2 = k;
		k = y1;
		y1 = y2;
		y2 = k;
	}
	for (int i = 0; i < n; i++){
		scanf("%lld %lld", &xx, &yy);
		xy.push_back(make_pair(xx, yy));
	}
	sort(xy.begin(), xy.end());
	yy = y2 - y1;
	if (x1 < x2){
		xx = x2 - x1;
		for (int i = 0; i < xy.size(); i++){
			if (x1 <= xy[i].first&&xy[i].first <= x2&&y1 <= xy[i].second&&xy[i].second <= y2)a.push_back(xy[i].second);
		}
	}
	else{
		xx = x1 - x2;
		for (int i = xy.size()-1; i >=0; i--){
			if (x2 <= xy[i].first&&xy[i].first <= x1&&y1 <= xy[i].second&&xy[i].second <= y2)a.push_back(xy[i].second);
		}
	}
	if (xx < yy)t = xx;
	else t = yy;
	lis[0] = -1;
	lsize = 1;
	for (int i = 0; i < a.size(); i++){
		if (a[i] > lis[lsize - 1]){
			lis[lsize] = a[i];
			lsize++;
		}
		else{
			l = 0;
			r = lsize-1;
			for (; l != r;){
				m = (l + r) / 2;
				if (lis[m] < a[i])l = m + 1;
				else r = m;
			}
			lis[l] = a[i];
		}
	}
	lsize--;
	ans = 0;
	if (lsize == t+1){
		ans = 11.415926535897932384626;
		lsize--;
	}
	ans = ((xx + yy)*100)+ans;
	ans = ans - lsize*(4.2920367320510333807687);

	x = floor(ans);
	printf("%lld.", x);
	ans = ans - x;
	for (int i = 0; i < 20; i++){
		ans = ans * 10;
		x = floor(ans);
		printf("%lld", x);
		ans = ans - x;
	}
	return 0;
}

Measured memory_bytes: 9196
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e18;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};


#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define REP_REV(i, n) for (ll i = n-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) ll(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

using Pair = pair<ll, ll>;



signed main() {
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    string s;
    cin >> n >> s;
    vector<ll> cr(n+1), cg(n + 1), cb(n + 1);
    REP(i, n) cr[i+1] = cr[i] + (s[i] == 'R'? 1: 0);
    REP(i, n) cg[i+1] = cg[i] + (s[i] == 'G'? 1: 0);
    REP(i, n) cb[i+1] = cb[i] + (s[i] == 'B'? 1: 0);
    auto count = [&] (char a, char b, const vector<ll> & c, char d) {
        ll ans = 0;
        REP(i, n) {
            REP_FROM(j, i+1, n) {
                if(s[i] != a || s[j] != b) continue;
                ans += c[i];
                if(i - (j - i) >= 0 && s[i - (j - i)] == d) ans--;
            }
        }
        return ans;
    };
    ll ans = count('R', 'G', cb, 'B');
    ans += count('G', 'R', cb, 'B');
    ans += count('B', 'G', cr, 'R');
    ans += count('G', 'B', cr, 'R');
    ans += count('B', 'R', cg, 'G');
    ans += count('R', 'B', cg, 'G');

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


Measured memory_bytes: 3748
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ITP1_2_B
{
    class Program
    {
        static void Main(string[] args)
        {
            //3つの整数a,b.cを読み込み、a<b<cならYes、そうでなければNoを出力する

            string[] x = Console.ReadLine().Split();
            int a = int.Parse(x[0]);
            int b = int.Parse(x[1]);
            int c = int.Parse(x[2]);

            if (a < b)
            {
                if (b<c)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
            else
            {
                Console.WriteLine("No");
            }

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 15956
/*
 *  author : Atul Anand   
 *  created on : Tue Mar 31 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        int K = in.nextInt();
        int ans = 0;
        while(N > 0){
            N = N/K;
            ans++;
        }
        println(ans);
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 21204
# -*- coding: utf-8 -*-
n = int(input())
hl = list(map(int, input().split()))

dp = [0]*n
dp[1] = abs(hl[1]-hl[0])

for i in range(2,n):
    dp[i] = min(
        dp[i-1] + abs(hl[i]-hl[i-1]),
        dp[i-2] + abs(hl[i]-hl[i-2])
    )

print(dp[n-1])


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

a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))

ans = 0
for i in range(n):
    
    ans += b_list[a_list[i]-1]
    #print(b_list[a_list[i]-1])
    if i == 0:
        continue
    else:
        if a_list[i] == a_list[i-1]+1:
            #print(a_list[i-1]-1)
            #print(c_list[a_list[i-1]-1])
            ans += c_list[a_list[i-1]-1]

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
#define mod 200003
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
using pl = pair<ll,ll>;
using vvb=vector<vector<bool>>;
using vb= vector<bool>;
ll f(ll a,ll b,ll p){
	if(b==0) return 1;
	if(b%2==0){
		ll t=f(a,b/2,p);
		return t*t%p;
	}
	return a*(f(a,b-1,p))%p;
} 

//__builtin_popcount()
signed main(){
	ll n; cin>>n;
	ll x,y; cin>>x>>y;
	--x; --y;
	vl ans(n+10);
	vvl g(n,vl(0));
	rep(i,0,n-1){
		g[i].push_back(i+1);
		g[i+1].push_back(i);
	}
	g[x].push_back(y);
	g[y].push_back(x);
	rep(i,0,n){
		queue<pl> q;
		q.push(make_pair(i,0));
		vector<bool> seen(n);
		seen[i]=1;
		while(!q.empty()){
			pl p=q.front(); q.pop();
			ll a,b; tie(a,b)=p;
			for(auto c:g[a]){
				if(seen[c])continue;
				seen[c]=1;
				ans[b]++;
				q.push(make_pair(c,b+1));
			}
		}
	}
	rep(i,0,n-1)cout<<ans[i]/2<<endl;


	return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;
 
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x;
    return is;
}

int main(){
    int n,k;
    cin >> n >> k;
    int x[n];
    REP(i,n){
        cin >> x[i] ;
    }

    vector<int> ans(n-k+1);

    REP(i,n-k+1){
        ans[i] = min(abs(x[i])+abs(x[i+k-1]-x[i]), abs(x[i+k-1])+abs(x[i+k-1]-x[i]));
    }

    cout << *min_element(ans.begin(), ans.end()) << endl;

    return 0;
}

Measured memory_bytes: 768
import sys
n, m, x = map(int,input().split())
c=[list(map(int,input().split())) for i in range(n)]
mn=10**18
for mask in range(1<<n):
    l=[0]*(m+1)
    for i in range(n):
        if ((mask>>i)&1)==0:
            for j in range(m+1):
                l[j]+=c[i][j]
    count=0
    for k in range(1,m+1):
        if l[k]>=x:
            count+=1
    if count==m:
        mn=min(mn,l[0])

if mn==10**18:
    mn=-1
print(mn)


Measured memory_bytes: 9188
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

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

	auto ans = 0;
	while (N > 0)
	{
		++ans;
		N /= K;
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

public class Program
{

    public void Proc()
    {
        int inputCount = int.Parse(Reader.ReadLine());
        int score1 = 0;
        int score2 = 0;
        for (int i = 0; i < inputCount; i++) {
            string[] tmp = Reader.ReadLine().Split(' ');
            int cmp = tmp[0].CompareTo(tmp[1]);
            if(cmp == 0) {
                score1++;
                score2++;
            } else if(cmp <0) {
                score2 += 3;
            } else {
                score1 += 3;
            }
        }
		Console.WriteLine(score1 + " " + score2);

	}


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"






3
cat dog
fish fish
lion tiger





";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}

Measured memory_bytes: 9940
#include <stdio.h>

int main(void)
{
    int sum = 0;
    int i;
    int a[6];
    
    for (i = 0; i < 6; i++){
        scanf("%d", &a[i]);
    } 
    
    sum += a[0] + a[1] * 5 + a[2] * 10 + a[3] * 50 + a[4] * 100 + a[5] * 500;
    
    if (sum >= 1000){
        printf("1\n");
    }
    else {
        printf("0\n");
    }
    
    return (0);
}

Measured memory_bytes: 584
n_k = list(map(int, input().split()))
n,a,b = n_k[0],n_k[1],n_k[2]
max,min = 0,0
if n > a+b:
    min=0
    if a<b:
        max=a
    else:
        max=b
else:
    min=a+b-n
    if a<b:
        max=a
    else:
        max=b
print(str(max)+' '+str(min))


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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, m, v[3000], s[3000], t[3000];

int main(){
	cin >> n >> m;
	rep(i, n) cin >> v[i] >> s[i] >> t[i];
	rep(it, n){
		vector<ll> x;
		vi next;
		rep(i, n) x.pb(v[i] * (ll)1e9 + v[s[i]] * 10000 + v[t[i]]);
		sort(all(x)); x.erase(unique(all(x)), x.end());
		rep(i, n) next.pb(lower_bound(all(x), v[i] * (ll)1e9 + v[s[i]] * 10000 + v[t[i]]) - x.begin());
		rep(i, n) v[i] = next[i];
	}
	unordered_map<int, int> cnt;
	rep(i, n) cnt[v[i]]++;
	rep(i, m){
		int q; cin >> q;
		cout << cnt[v[q]] << endl;
	}
	return 0;
}

Measured memory_bytes: 3296
use std::io;


fn main() {
    let (mut a, mut b, k) = {
        let i = read::<usize>();
        (i[0], i[1], i[2])
    };
    for i in 0..k {
        if i % 2 == 0 { // takahashi
            if a % 2 != 0 {
                a -= 1;
            }
            b += a / 2;
            a /= 2;
        } else { // aoki
            if b % 2 != 0 {
                b -= 1;
            }
            a += b / 2;
            b /= 2;
        }
    }
    println!("{} {}", a, b);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
import java.util.*;
import java.io.*;

public class Main {	
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int a = ni();
		int b = ni();
		long result = power(2, n) - 1;
		result = ((result - combiWithMod(n, a)) % mod + mod) % mod;
		result = ((result - combiWithMod(n, b)) % mod + mod) % mod;
		System.out.println(result);
	}



	static int mod = 1000000007;

	/**
	 * nCk with mod calculation. "mod" is instance variable.
	 * @param n
	 * @param k
	 * @return nCk with mod calculation.
	 */
	static long combiWithMod(int n, int k) {
		long[] x = new long[k];
		long[] y = new long[k];
		x[0] = n;
		y[0] = k;
		for(int i = 1; i < k; i++) {
			x[i] = (x[i - 1] * (n - i)) % mod; 
			y[i] = (y[i - 1] * (k - i)) % mod; 
		}
		return modMul(x[k - 1], modInverse(y[k - 1]));
	}
	/**
	 * Mod multiply calculation
	 * @param a
	 * @param b
	 * @return
	 */
	static long modMul(long a, long b) {
		return ((a % mod) * (b % mod)) % mod;
	}
	static long modInverse(long n) {
		return power(n, mod-2);
	}
	static long power(long a, long b) {
		long result = 1;
		a = a % mod;
		while (b > 0) {
			if (b % 2 == 1)
				result = (result * a) % mod;
			b = b >> 1;
			a = (a * a) % mod;
		}
		return result;
	}

	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


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

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define F0R(i, n) for (int i = 0; i < (n); i++)
#define print(x) cout << x << '\n'
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;

const int INF = 1e9 + 5;
const int MAX_N = 1e5 + 5;
ll dp[MAX_N];

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int N,W;
  cin >> N >> W;

  int items[N][2];
  for (int i = 0; i < N; i++){
      for (int j :{0,1}){
          cin >> items[i][j];
      }
  }
  ll maxV = 0;


for (int obj = 0; obj < N; obj ++){
    int weight = items[obj][0];
      for (int i = W - weight; i >= 0; i--){
              dp[i + weight] = max(dp[i + weight], dp[i] + items[obj][1]);
              if (dp[i + weight] > maxV) maxV = dp[i + weight];
          }
            
      }



  cout << maxV <<endl;

  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod

int n, k;
int a[100000 + 5], b[100000 + 5];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    rep(i, n) {
        cin >> a[i] >> b[i];
    }
    int ans = 0;
    rep(i, n) {
        if (a[i] > k) continue;
        bool ok = true;
        rep(j, 33) {
            if ((a[i]>>j) & 1) {
                if (!((k>>j) & 1)) {
                    ok = false;
                    break;
                }
            }
        }
        if (ok) ans += b[i];
    }
    int mask = (1 << 31) - 1LL;
    rep(i, 33) {
        if (!((k>>i) & 1)) continue;
        int tmp = k;
        tmp ^= (1<<i);
        tmp |= (1<<i) - 1LL;
        tmp &= mask;
        int v = 0;
        rep(l, n) {
            if (a[l] > tmp) continue;
            bool ok = true;
            rep(j, 33) {
                if ((a[l]>>j) & 1) {
                    if (!((tmp>>j) & 1)) {
                        //cout << j << endl;
                        ok = false;
                        break;
                    }
                }
            }
            if (ok) {
                v += b[l];
            }
        }
        ans = max(ans, v);
    }
    cout << ans << endl;
}


Measured memory_bytes: 1920
import java.util.*;
public class Main {

   static String ans = "";


    private static void triplet(String first, String rest){

        int first_digit = Integer.parseInt(first);
        int second_digit = Integer.parseInt(rest.substring(0,1));

        if(first_digit < second_digit){

            int d = first_digit+1;
            ans = ans.concat(Integer.toString(d));
            ans = ans.concat(Integer.toString(d));
            ans = ans.concat(Integer.toString(d));
            return;

        }else if(first_digit == second_digit){

            if(rest.length() == 1){

                ans = ans.concat(Integer.toString(first_digit));
                ans = ans.concat(Integer.toString(first_digit));
                ans = ans.concat(Integer.toString(first_digit));
                return;

            }else{

                triplet(rest.substring(0,1), rest.substring(1));
                return;
            }

        }else if(first_digit > second_digit){

            int d = first_digit;
            ans = ans.concat(Integer.toString(d));
            ans = ans.concat(Integer.toString(d));
            ans = ans.concat(Integer.toString(d));
            return;
        }

    }

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        String N = scan.next();

        triplet(N.substring(0,1), N.substring(1));

        System.out.println(ans);
    }
}

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

using namespace std;

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb push_back
#define endl '\n'
#define dokme(x) return(cout << x , 0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
#define file_init freopen("input.txt", "r+", stdin); freopen("output.txt", "w+", stdout);
ll pw(ll a, ll b, ll md = mod){ll res = 1;while(b){if(b&1){res=(a*res)%md;}a=(a*a)%md;b>>=1;}return(res);}

ll fact[maxn] , inv[maxn];
ll n , a, b , c;

ll C(ll n ,ll r){
    return(fact[n] * inv[r] % mod * inv[n-r] % mod);
}

ll solve (){
    ll ans = 0;
    for(int i = n ; i <= 2*n - 1 ; i ++)
        ans = (ans + fact[i] * inv[n-1] %mod* inv[i-n] %mod* pw(b , i-n)%mod * pw(pw((1-c + mod)%mod , mod-2) , i + 1 ) %mod )%mod;
    ans = ans * pw(a , n) % mod;
    swap(a , b);
    return (ans);
}

int main(){
    migmig
    fact[0] = inv[0] =1;
    for(ll i = 1;  i <= 1000000 ; i ++)
        fact[i] = (i * fact[i-1])%mod , inv[i] = pw(fact[i] , mod - 2);
    cin >> n >> a >> b >> c;
    a = a * pw(100 , mod - 2) % mod;
    b = b * pw(100 , mod - 2) % mod;
    c = c * pw(100 , mod - 2) % mod;
    cout << (solve() + solve())%mod;
    return(0);
}

Measured memory_bytes: 19292
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1000000000;
const long INF64 = 1000000000000000ll;
const int MOD = 1000000007;
int main(){
	int n;
	std::cin >> n;
	std::vector<string> s(n);
	rep(i,n)std::cin >> s[i];
	sort(all(s));
	std::vector<ll>  counter(5,0);
	if(s[0].at(0)=='M')counter[0]++;
	if(s[0].at(0)=='A')counter[1]++;
	if(s[0].at(0)=='R')counter[2]++;
	if(s[0].at(0)=='C')counter[3]++;
	if(s[0].at(0)=='H')counter[4]++;
	for (int i = 1; i < n; i++) {
		/* code */
		if(s[i]!=s[i-1]){
			if(s[i].at(0)=='M')counter[0]++;
			if(s[i].at(0)=='A')counter[1]++;
			if(s[i].at(0)=='R')counter[2]++;
			if(s[i].at(0)=='C')counter[3]++;
			if(s[i].at(0)=='H')counter[4]++;
		}
		
	}
	ll ans=0;
	std::vector<int> v={0,1,2,3,4};
	do {
    ans+=counter[v[0]]*counter[v[1]]*counter[v[2]];
  } while (std::next_permutation(v.begin(), v.end()));
  std::cout << ans/12 << std::endl;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
const int N = 5e5;
int n, x;
int a[N];
int main() {
    ios_base::sync_with_stdio(0);
    cin >> n >> x;
    for (int i = 1; i <= n; i++) cin >> a[i];
    sort(a + 1, a + n + 1);
    long long s = 0; int ans = 0;
    for (int i = 1; i <= n; i++)
        if (s + a[i] <= x) {
            ans++;
            s += a[i];
        }
        else {
            s = x + 1;
            break;
        }
    if (s < x) ans--;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

const int MAX_N = 200050;

long long A[MAX_N];
long long K;

long long AC[MAX_N];

/*
long long pow(const long long base, const long long n) {
    long long ret = 1;
    for (int i = 0; i < n; i++) {
        ret = ret * base;
    }
    return ret;
}
*/

long long func_S(long long n) {
    long long ret = 0;
    while(true) {
        ret = ret + n % 10;
        n = n / 10;
        if (n == 0) { 
            break;
        }
    }
    return ret;
}

bool condition(long long n1, long long n2) {
    return n1 * func_S(n2) < n2 * func_S(n1);
}

long long vec_to_num(const std::vector<int>& vec) {
    long long ret = 0;
    long long tmp = 1;
    for (int i = 0; i < vec.size(); i++) {
        ret += vec[i] * tmp;
        tmp = tmp * 10;
    }
    return ret;
}

std::vector<long long> cand_list(const long long n) {
    std::vector<int> tmp_vec;
    long long tmp = n;
    while(true) {
        if (tmp == 0) {
            break;
        }
        tmp_vec.push_back(tmp % 10);
        tmp = tmp / 10;
    }

    std::vector<long long> ret;
    ret.push_back(n);
    for (int i = 0; i < tmp_vec.size(); i++) {
        tmp_vec[i] = 9;
        long long cand = vec_to_num(tmp_vec);
        //std::cout << "cand:" << cand << std::endl;
        ret.push_back(cand);
    }
    return ret;
}

long long get_next_from_cand(const std::vector<long long>& cand) {
    assert(0 < cand.size());
    long long ret = cand[0];
    for (int i = 1; i < cand.size(); i++) {
        if (condition(cand[i], ret)) {
            ret = cand[i];
        }
    }
    return ret;
}

long long get_next(const long long n) {
    std::vector<long long> cand = cand_list(n);
    return get_next_from_cand(cand);
}

int main(int argc, char **argv) {
    std::cin >> K;
    
    long long num = 0;
    long long tmp = 0;
    //std::cout << get_next(10) << std::endl;

    while (true) {
        tmp = get_next(tmp + 1);
        std::cout << tmp << std::endl;
        num++;
        if (num == K) {
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <set>
#include <map>


using namespace std;


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

    vector<int> a;
    for( int i = 0; i < N; ++i ){
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
    }


    int ans = 0;

    for( int i = 0; i < N; ++i ){
        int j = a[i]-1;
        if( i == a[j]-1 ){
            ++ans;
            a[j] = -1;
        }
    }


    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 892
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		final int N = sc.nextInt();
		
		long[] difficults = new long[N];
		long[] partial_sum = new long[N];
		for(int i = 0; i < N; i++){
			final long a = sc.nextLong();
			
			difficults[i] = a;
		}
		Arrays.sort(difficults);
		for(int i = 0; i < N; i++){
			partial_sum[i] = difficults[i] + (i == 0 ? 0 : partial_sum[i - 1]);
		}
		
		
		final int M = sc.nextInt();
		int[] solver = new int[M];
		for(int i = 0; i < M; i++){
			final int b = sc.nextInt();
			solver[i] = b;
		}
		
		for(int i = 0; i < M; i++){
			final long purpose = sc.nextLong();
			final int rate = solver[i];
			
			if(difficults[0] > rate){
				System.out.println(purpose <= 0 ? "Yes" : "No");
			}else{
				int lower = 0;
				int higher = N;
				
				// [lower, higher)
				while(lower + 1 != higher){
					final int mid = (lower + higher) / 2;
					//System.out.println(lower + ", " + higher + ", " + mid + " => " + difficults[mid] + " " + solver[i]);
					
					if(difficults[mid] <= solver[i]){
						lower = mid;
					}else{
						higher = mid;
					}
				}
				//System.out.println(lower);
				
				final long score = partial_sum[lower];
			
				System.out.println(score >= purpose ? "Yes" : "No");
			}
		}
		
	}
	
} 

Measured memory_bytes: 266696
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

  string s;
  cin >> s;
  REP(i, s.size() - 1){
    if(s[i] == 'A' && s[i + 1] == 'C'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
unordered_set<int>a[200003];
bool vis[200003];
int dfs(int k){
   vis[k]=true;
   int sz=1;
   for(auto c:a[k]){
        if(!vis[c]){
    vis[c]=true;
    sz+=dfs(c);}
   }
   return sz;
}
int main(){
   int n,m;
   cin>>n>>m;
   while(m--){
    int x,y;
    cin>>x>>y;
    a[x].insert(y);
    a[y].insert(x);
   }
   int sz,ans=0;
   for(int i=1;i<=n;i++){
    if(!vis[i]){
        sz=dfs(i);
        ans=max(ans,sz);
    }
   }
   cout<<ans;
}


Measured memory_bytes: 39656
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
//s.order_of_key(), *s.find_by_order()

using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

int32_t main(){
   boost;
   int x,L,R; cin>>L>>R>>x;
   int res=0;
   for(int i=L; i<=R; i++){
      if(i%x==0) res++;
   }
   cout << res << endl;


   return 0;
}



Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;


int main(void)
{
	string S; cin >> S;
	vector<int> digit(10);
	rep(i, 0, S.length())digit[i] = (int)S[i] - '0'; 
	//rep(i, 0, S.length())cout << digit[i] << endl;
	lli ans = 0;
	if (S.length() > 1) {
		for (int bit = 0; bit < (1 << S.length() - 1); bit++) {
			lli tmp = digit[0];
			rep(i, 0, S.length() - 1) {
				if (bit&(1 << S.length() - 2 - i)) {
					ans += tmp;
					tmp = digit[i + 1];
				}
				else {
					tmp *= 10;
					tmp += digit[i + 1];
				}
				if (i == S.length() - 2)ans += tmp;
			}
		}
	}
	else ans = digit[0];

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for x in range(A + 1):
    for y in range(B + 1):
        for z in range(C + 1):
            if X == 500 * x + 100 * y + 50 * z:
                count = count + 1

print(count)


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

int main(){
	int n,f=1,i;
	cin>>n;
	int a[n+1];
	
	for(i=1;i<=n;i++) cin>>a[i];
	
	for(i=1;i<=n;i++)
		if(a[i]%2==0)
		{
			if(a[i]%3==0 || a[i]%5==0)
				continue;
			else if(a[i]%3!=0 || a[i]%5!=0)
			{
				f=0;
				break;
			}
		}
		
	if(f==0)
		cout<<"DENIED"<<endl;
	else
		cout<<"APPROVED"<<endl;
		
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

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

    int h, w; cin>>h>>w;
    vector<string> s(h);
    for(int i=0; i<h; i++) cin>>s[i];

    vector<vector<ll>> dp(h+1, vector<ll>(w+1, 0));
    dp[1][1] = 1;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(s[i][j] == '#') continue;
            
            dp[i+1][j+1] += dp[i][j+1] + dp[i+1][j];
            dp[i+1][j+1] %= MOD;
        }
    }

    cout << dp[h][w] << endl;

    return 0;
}

Measured memory_bytes: 9216
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.container;
import std.datetime;

void main()
{
  auto pat = ['z', '.', '?', '!', ' '];
  foreach (line; stdin.byLine) {
    auto str = line.chomp;
    if (str.length % 2) {
      writeln("NA");
      continue;
    }
    int c;
    string res = "";
    foreach (i, s; str) {
      if (i % 2) {
        if (s >= '1' && s <= '5') {
          if (c == 'z') {
            c = pat[s - '1'];
          } else {
            c += s - '1';
          }
          res ~= c.to!char;
        } else {
          res = "NA";
          break;
        }
      } else {
        if (s >= '1' && s <= '6') {
          c =  'a' + (s - '1') * 5;
        } else {
          res = "NA";
          break;
        }
      }
    }
    res.writeln;
  }
}

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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

int main() {
  int n;
  cin >> n;
  map<string, int> mp;
  rep(i, n) {
    string s;
    cin >> s;
    ++mp[s];
  }

  cout << "AC x " << mp["AC"] << endl;
  cout << "WA x " << mp["WA"] << endl;
  cout << "TLE x " << mp["TLE"] << endl;
  cout << "RE x " << mp["RE"] << endl;
  return 0;
}


Measured memory_bytes: 3632
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let n : i32 = read();
    let k : i32 = read();
    let xi : Vec<i32> = read_vec();
    let mut ans = 0;
    for i in 0..xi.len() {
        let n_div = (xi[i as usize] - 0).abs();
        let k_div = (xi[i as usize] - k).abs();
        if n_div >= k_div {
            ans += k_div * 2;
        } else {
            ans += n_div * 2;
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<random>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}


int main() {
	init();
	
	int R; cin >> R;
	cout << 2 * R * PI << "\n";


	return 0;
}

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

int gcd(int a, int b) {

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


int main(){
  int N,M;
  cin>>N>>M;
  if(N==1){
    cout<<M<<endl;
    return 0;
  }
  if(N==2){
    int ans=0;
    for(int i=1;i<=M/2+1;i++){
      ans=max(ans,gcd(i,M-i));
    }
    cout<<ans<<endl;
    return 0;
  }
    
  while(N<=M/2){
    if(M%N==0){
      cout<<M/N<<endl;
      return 0;
    }
    N++;
  }
  cout<<1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    int n,m;
    cin >> n >> m;
    vector<int> p(m);
    vector<bool> s(m);
    for(int i = 0; i < m; i++){
        string tmp;
        cin >> p[i] >> tmp;
        p[i]--;
        if(tmp == "AC") s[i] = true;
        else s[i] = false;
    }

    vector<pair<bool, int> > cnt(n,make_pair(false, 0));

    for(int i = 0; i < m; i++){
        if(cnt[p[i]].first == true) continue;
        if(s[i] == false) cnt[p[i]].second++;
        if(s[i] == true) cnt[p[i]].first = true;
    }

    int ans1 = 0;
    int ans2 = 0;
    for(int i = 0; i < n; i++){
        if(cnt[i].first == true){
            ans1++;
            ans2 += cnt[i].second;
        }
    }

    cout << ans1 << " " << ans2 << endl;
    
    return 0;
}

Measured memory_bytes: 4428
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
int n;
vector<ll> h;
int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    h.assign(n, 0);
    F0R(i, n) cin >> h[i];
    int cur = h[0];
    FOR(i, 1, n)
    {
        if(h[i] > cur) h[i]--;
        if(h[i] < cur)
        {
            cout << "No";
            return 0;
        }
        cur = h[i];
    }
    cout << "Yes";
    return 0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n;

vector<pair<int, int>> a_ind;

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 1; i <= n; ++i) {
    int a;
    scanf("%d", &a);

    a_ind.push_back(make_pair(a, i));
  }

  sort(a_ind.begin(), a_ind.end());

  for (auto &e : a_ind) {
    printf("%d ", e.second);
  }

  printf("\n");

  return 0;
}


Measured memory_bytes: 1780
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

class Main {
    public static void main(String[] args){
        try{
            BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
            String[] ss=br.readLine().split(" ");
            int n=Integer.parseInt(ss[0]);
            int m=Integer.parseInt(ss[1]);
            ss=br.readLine().split(" ");
            int[] arr=new int[m];
            long sum=0;
            for(int j=0;j<m;j++){
                arr[j]=Integer.parseInt(ss[j]);
                sum+=arr[j];
            }
            if(sum>n){
                System.out.println(-1);
            }else{
                System.out.println(n-sum);
            }



        }catch(Exception e){
            System.out.println("KKKK "+e.getMessage());
        }
    }
    static boolean check(int[] arr){
        int odd=0;
        for(int i=0;i<arr.length;i++){
            if(arr[i]%2!=0){
                odd++;
            }
        }
        if(odd<=1){
            return true;
        }
        return false;
    }
}

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

int main() {
  long long A, B, C, K; cin >> A >> B >> C >> K;

  
  if(K%2 == 0) cout << A-B << endl;
  else cout << B-A << endl;
}

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

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

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
	if (ch =='A') return 1;
	else if (ch =='C') return 2;
	else if (ch =='G') return 3;
	else if (ch =='T') return 4;
	else return 0;
}

long long getKey(char str[]){
	long long sum=0, p = 1, i;
	for (i=0;i < strlen(str); i++){
		sum += p*(getChar(str[i]));
		p *=5;
	}
	return sum;
}

int h1(int key){return key % M;}
int h2(int key){return 1 + (key % (M-1));}

int find(char str[]){
	long long key,i,h;
	key=getKey(str);
	for(i=0;;i++){
		h = (h1(key) + i * h2(key)) % M;
		if (strcmp(H[h],str)==0) return 1;
		else if ( strlen(H[h]) == 0) return 0;
	}
	return 0;
}

int insert(char str[]){
	long long key,i,h;
	key=getKey(str);
	for(i=0;;i++){
		h = (h1(key) + i * h2(key)) % M;

		if (strcmp(H[h],str)==0) return 1;
		else if ( strlen(H[h]) == 0) {
		  strcpy(H[h],str);
		  return 0;
	}
	}
	return 0;
}

int main(){
	int i,n,h;
	char str[L],com[9];
	for(i=0;i<M;i++) H[i][0]='\0';
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%s %s",com,str);
		if (com[0] == 'i'){
			insert(str);
		}else{
			if (find(str)){
				printf("yes\n");
			}else{
				printf("no\n");
			}
		}
	}
}

Measured memory_bytes: 17056
#include <iostream>
using namespace std;
int main (void) {
    int a;
    int b;
    int c;
    int d;

    cin >> a >> b >> c >> d;

    if (a + b > c + d) cout << "Left" << endl;
    else if (a + b == c + d) cout << "Balanced" << endl;
    else cout << "Right" << endl;

    return 0;
}

Measured memory_bytes: 256
def min(a,b); a < b ? a : b; end

N, M = gets.split.map(&:to_i)
G = Array.new(N + 1){ [] }
Q = Array.new(N + 1, 0.0); Q[1] = 1.0
D = Array.new(N + 1, 0.0)

M.times do
  s,t = gets.split.map(&:to_i)
  G[s] << t
end

(1 ... N).each do |s|
  q = Q[s] / G[s].size
  G[s].each{|t| Q[t] += q }
end

dmin = 0.0
(1 ... N).reverse_each do |s|
  d = G[s].inject(0.0){|sum, t| sum + D[t] }
  D[s] = d / G[s].size + 1.0
  
  next unless G[s].size > 1
  G[s].each do |t|
    dmin = min(dmin, ((d - D[t]) / (G[s].size - 1) - d / G[s].size) * Q[s])
  end
end

puts D[1] + dmin


Measured memory_bytes: 4732
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int n, k;
  cin >> n >> k;
  double ans = 0;
  for(int i = 1; i <= n; i++) {
    double t = 1;
    ll tmp = i;
    while(tmp < k) tmp *= 2, t *= .5;
    ans += t;
  }
  cout << fixed << setprecision(20);
  cout << ans / n << endl;
  return 0;
}


Measured memory_bytes: 256