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


const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint(), Q = getint();

	int AC[100000];
	AC[0] = 0;
	rep(i, N - 1) {
		AC[i + 1] = AC[i];
		if (*ci++ == 'A' && *ci == 'C') AC[i + 1]++;
	}
	ci += 2;
	rep(i, Q) {
		int l = getint(), r = getint();
		putint(AC[r - 1] - AC[l - 1]);
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  string s; std::cin >> s;
  int n = s.size();
  vi ans(n);
  rep(i, n) {
    int ni = i;
    while (ni+1 < n && s[i] == s[ni+1]) ni++;
    int cnt = ni - i + 1;
    if (s[i] == 'L') {
      ans[i] += (cnt + 1) / 2;
      ans[i-1] += cnt / 2;
    } else {
      ans[ni] += (cnt + 1) / 2;
      ans[ni+1] += cnt / 2;
    }
    i = ni;
  }
  rep(i, n) std::cout << ans[i] << (i+1 < n ? " " : "\n");
}


Measured memory_bytes: 1104
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-11;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int n=10;
int a[n][n];

bool f(string s){
	int x=0;
	for(int i=0;i<5;i++) x=a[x][s[i]-'0'];
	return x==0;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	while(1){
		for(int i=0;i<n;i++) for(int j=0;j<n;j++) cin>>a[i][j];
		int res=0;
		for(int i=0;i<10000;i++){
			auto s=to_string(i);
			while(s.size()<4) s='0'+s;
			int e=0;
			for(int j=0;j<4;j++) e=a[e][s[j]-'0'];
			s+=(char)(e+'0');
			bool B=1;
			for(int i=0;i<5&&B;i++) for(int j=0;j<10&&B;j++) if(s[i]-'0'!=j){
				auto t=s;
				t[i]=(char)('0'+j);
				if(f(t)) B=0;
			}
			for(int i=0;i<4;i++) if(s[i]!=s[i+1]){
				swap(s[i],s[i+1]);
				if(f(s)) B=0;
				swap(s[i],s[i+1]);
			}
			if(!B){
				res++;
			}
		}
		cout<<res<<endl;
		break;
	}
}


Measured memory_bytes: 3292
from collections import deque
K = int(input())
if K<10:
  print(K)
  exit()
  
q = deque([1,2,3,4,5,6,7,8,9])

cnt = 9
while q:
  n = q.popleft()
  r = n % 10
  n *= 10;
  for i in range(10):
    if abs(r - i) <= 1:
        q.append(n + i)
        cnt += 1
        if cnt == K:
          print(n+i)
          exit()

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    string T;
    cin >> S >> T;
    T.pop_back();
    if(T == S) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3628
def main():
  import sys
  input=sys.stdin.read
  n,*d=map(int,input().split())
  e=tuple(sorted(d))
  l=len(d)
  s=n//2
  if e[s-1]==e[s]:
    print(0)
  else:
    print(e[s]-e[s-1])
      
if __name__=="__main__":
  main()

Measured memory_bytes: 14068
using System;
using System.Collections.Generic;
using System.Linq;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var count = IOUtils.ReadInt();

            var items = new HashSet<string>();
            for (int i = 0; i < count; i++)
            {
                items.Add(Console.ReadLine());
            }

            Console.WriteLine(items.Count);
        }
    }

    static class IOUtils
    {
        public static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        public static ulong ReadUlong()
        {
            return ulong.Parse(Console.ReadLine());
        }
        public static int[] ReadInts()
        {
            return Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray();
        }
        public static long[] ReadLongs()
        {
            return Console.ReadLine().Split(' ').Select(v => long.Parse(v)).ToArray();
        }

        public static void WriteNums(params int[] nums)
        {
            Console.WriteLine(string.Join(" ", nums));
        }
    }
}


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

namespace _0094
{
    class Program
    {
        static void Main(string[] args)
        {
            double a = 0;
            double b = 0;
            const double t = 3.305785;
            string[] ab = new string[2];

            ab = Console.ReadLine().Split(' ');
            a = double.Parse(ab[0]);
            b = double.Parse(ab[1]);

            Console.WriteLine(a * b / t);

        }
    }
}



Measured memory_bytes: 17928
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
lint a[100100];
int main()
{
	int n;cin>>n;a[0]=a[n+1]=0;rep(i,n) cin>>a[i+1];
	lint sum=0;rep(i,n+1) sum+=abs(a[i]-a[i+1]);
	rep(i,n){
		cout<<sum-abs(a[i]-a[i+1])-abs(a[i+1]-a[i+2])+abs(a[i]-a[i+2])<<endl;
	}
}


Measured memory_bytes: 2048
N = int(input())
d = input().split()
for i in range(N):
    d[i] = int(d[i])

d.sort()

if d[int(N/2)]-d[int((N/2)-1)] == 0:
    print("0")
else:
    print(d[int(N/2)]-d[int((N/2)-1)])


Measured memory_bytes: 10612
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; (i) < (int) (n); (i) ++)
using namespace std;
 
struct edge {
	int a, b;
	int len;
};
 
int main() {
	int l;
	scanf("%d", &l);
	int base = 1;
	int n = 0;
	while (base * 2 <= l) {
		base *= 2;
		n ++;
	}
	n ++;
	vector<edge> ans;
	vector<int> p(30);
	p[0] = 1;
	for (int i = 1; i < 30; i ++) {
		p[i] = 2 * p[i - 1];
	}
	for (int i = 0; i < n - 1; i ++) {
		ans.push_back({i, i + 1, 0});
		ans.push_back({i, i + 1, p[n - 2 - i]});
	}
	l -= base;
	int sum = base;
	for (int i = 30; i >= 0; i --) {
		if (l & (1 << i)) {
			ans.push_back({0, n - 1 - i, sum});
			sum += (1 << i);
		}
	}
	printf("%d %d\n", n, (int) ans.size());
	for (int i = 0; i < (int) ans.size(); i ++) {
		printf("%d %d %d\n", ans[i].a + 1, ans[i].b + 1, ans[i].len);
	}
        return 0;
}

Measured memory_bytes: 256
primes = [0, 0] + [1] * 9999
for i in range(2, 101):
    if primes[i]:
        for j in range(i*i, 10001, i):
            primes[j] = 0

while True:
    try:
        N = int(input())
    except:
        break
    print(sum(primes[i] and primes[N-i+1] for i in range(1, N+1)))

Measured memory_bytes: 7752
//Zory-2020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define mem(x,val) memset(x,val,sizeof x)
#define Swap(a,b,n) for(int I=0;I<=n;I++) swap(a[I],b[I])
#define PC __builtin_popcountll
#ifdef DEBUG
#define DD 1
#else
#define DD 0
#endif
#define Debug if(DD) printf("line %d\n",__LINE__)
#define deb(x) if(DD) cerr<<#x<<'='<<x<<endl
#define debug if(DD) printf
namespace mine
{
	ll qread()
	{
		ll ans=0,f=1;char c=getchar();
		while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
	void write1(ll num){write(num);putchar(' ');}
	void write2(ll num){write(num);putchar('\n');}
	template<typename T>inline bool chmax(T&a,const T&b){return a<b?a=b,1:0;}
	template<typename T>inline bool chmin(T&a,const T&b){return a>b?a=b,1:0;}
	ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
	bool IN(ll x,ll l,ll r){return l<=x and x<=r;}
	void gg1(){write2(-1);exit(0);}
	void gg2(){puts("NO");exit(0);}
	
	const double eps=1e-8;
	const int INF=0x3f3f3f3f;
	const int MOD=1e9+7;
	int mm(const int x){return x>=MOD?x-MOD:x;}
	template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
	ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
	ll invm(ll x){return qpower(x,MOD-2);}
	const int N=2e6+10;
	
	struct Nod{ int pos,val,id;
		friend bool operator < (Nod a,Nod b){ return (a.pos<b.pos) or (a.pos==b.pos and a.val<b.val); }
	}a[N];
	
	vc<pii> to[N];vc<int> ans;
	bool err;int n;bool vis[N];
	void solve(int x,int fa)
	{
		vis[x]=1;
		for(auto t:to[x])
		{
			int y=t.FR,id=t.SE;if(y==fa or vis[y])continue;solve(y,x);
			if(a[y].val) a[y].val^=1,a[x].val^=1,ans.PB(id);
		}
	}
	void main()
	{
		n=qread();int m=qread();fo(i,1,n) a[i].pos=qread(),a[i].val=qread();
		sort(a+1,a+n+1);fd(i,n+1,2) a[i].val^=a[i-1].val;
		 fo(i,1,m)
		 {
			 int l=qread(),r=qread();l=lower_bound(a+1,a+n+1,(Nod){l,0,0})-a;r=upper_bound(a+1,a+n+1,(Nod){r,INF,0})-a-1;if(l>r) continue;
			 to[l].PB({r+1,i}),to[r+1].PB({l,i});
			 debug("i=%d %d,%d\n",i,l,r);
		 }
		 bool err=0;fd(i,n+1,1) if(!vis[i]) { solve(i,0);if(i!=n+1 and a[i].val) err=1; }
		 if(err) write(-1); else{ sort(all(ans));write2(sz(ans));for(auto in:ans) write1(in); }
	}
};//变量重名！
signed main()
{
	#ifdef DEBUG
	//freopen("b.in","r",stdin);
	freopen("z.txt","r",stdin);
	#endif
	srand(time(0));
	mine::main();
	if(DD) cerr<<"Time: " <<1.0*clock()/CLOCKS_PER_SEC<<"s";
}


Measured memory_bytes: 61948
/* 

*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <string>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define LSOne(S) (S & (-S))
#define EPS 1e-9
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pd;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;

const int MOD = 1e9+7;

int ModAdd(int& x, int y)
{
    x += y;
    if(x >= MOD) x -= MOD;
    return x;
}

int ModSub(int x, int y)
{
    x -= y;
    if(x < 0) x += MOD;
    return x;
}

int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0); // FOR QUERY PROBLEM DON'T FORGET TO UNCOMMENT THIS
    int n;
    cin >> n;
    string str;
    cin >> str;
    vector<vector<int>> dp(n, vector<int>(n)); // answer for prefix length i, last number has j smaller element than it
    vector<vector<int>> psum(n, vector<int>(n));
    dp[0][0] = psum[0][0] = 1;

    for(int i = 1; i < n; ++i)
    {
        for(int j = 0; j <= i; ++j)
        {
            if(str[i-1] == '<')
            {
                if(j > 0) ModAdd(dp[i][j], psum[i-1][j-1]);
            }
            else
            {
                ModAdd(dp[i][j], ModSub(psum[i-1][i-1], (j-1 >= 0 ) ? psum[i-1][j-1] : 0));
            }   
        }

        for(int j = 0; j <= i; ++j)
        {
            psum[i][j] = dp[i][j];
            if(j > 0) ModAdd(psum[i][j], psum[i][j-1]);
        }
    }
    cout << psum[n-1][n-1] << "\n";
    return 0;  
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const int MN = 3010;

ll mod_pow(ll x, ll k, ll m) {
	ll res = 1;
	for (; k; x = x * x % m, k /= 2) {
		if (k & 1) {
			res = res * x % m;
		}
	}
	return res;
}

int N;
ll m;
ll dp[MN][MN];
ll comb[MN][MN];

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

	rep(i, MN) {
		comb[i][0] = comb[i][i] = 1;
		for (int j = 1; j < i; ++j) {
			comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % m;
		}
	}
    dp[0][0] = 1;
    for (int i = 1; i < MN; ++i) {
    	for (int j = 1; j < MN; ++j) {
            dp[i][j] += dp[i-1][j] * j;
            dp[i][j] += dp[i-1][j-1];
            dp[i][j] %= m;
    	}
    }

	ll ret = 0;

	for (int p = 0; p <= N; ++p) {
		ll p2 = mod_pow(2, N - p, m);
		ll b2 = mod_pow(2, N - p, m-1);
		ll f2 = mod_pow(2, b2, m);
		ll t = 0;
		ll ac = 1;

		for (int num = 0; num <= p; ++num) {
			ll c = dp[p][num+1] * f2 % m * ac % m * (num+1) % m;
			t = (t + c) % m;
			c = dp[p][num] * f2 % m * ac % m;
			t = (t + c) % m;
			ac = ac * p2 % m;
		}

		t = t * comb[N][p] % m;

		if (p & 1) {
			t = m - t;
		}

		ret = (ret + t) % m;
	}

	cout << ret << endl;

	return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

vector<int> PermutationComposite(const vector<int>& ps, const vector<int>& qs) {
  int n = ps.size();
  vector<int> rs(n);
  for (int i = 0; i < n; i++) {
    rs[i] = ps[qs[i]];
  }
  return rs;
}

vector<int> PermutationPower(const vector<int>& ps, int64 power) {
  if (power == 0) {
    int n = ps.size();
    vector<int> qs(n);
    for (int i = 0; i < n; i++) qs[i] = i;
    return qs;
  } else if (power == 1) {
    return ps;
  } else if (power % 2 == 1) {
    return PermutationComposite(PermutationPower(ps, power - 1), ps);
  } else {
    auto qs = PermutationPower(ps, power / 2);
    return PermutationComposite(qs, qs);
  }
}

// Vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
	for (int i = 0; i < len; i++) {
    if (i > 0) s << ", ";
		s << v[i];
  }
  s << "]";
  return s;
}

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

  int n;
  cin >> n;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }
  vector<int64> ds(n - 1);
  for (int i = 0; i < n - 1; i++) {
    ds[i] = xs[i + 1] - xs[i];
  }

  vector<int> ps(n - 1);
  for (int i = 0; i < n - 1; i++) {
    ps[i] = i;
  }

  int m;
  int64 k;
  cin >> m >> k;
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    a--;
    swap(ps[a - 1], ps[a]);
  }

  // cout << "ps: " << ps << endl;
  auto qs = PermutationPower(ps, k);
  // cout << "qs: " << ps << endl;

  vector<int64> es(n - 1);
  for (int i = 0; i < n - 1; i++) {
    es[i] = ds[qs[i]];
  }

  vector<int64> ys(n);
  ys[0] = xs[0];
  for (int i = 1; i < n; i++) {
    ys[i] = ys[i - 1] + es[i - 1];
  }

  for (int i = 0; i < n; i++) {
    cout << ys[i] << "\n";
  }
}


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

int main()
{
    int a, b, c, res1, res2;
    cin >> a >> b >> c;
    res1 = abs(a-b);
    res2 = abs(a-c);
    if(res1 <= res2) cout << "A" << endl;
    else cout << "B" << endl;
    return 0;
}

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

#define int long long
int mod = 1000000007;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    set<string> s;
    vector<pair<pair<string, int>, int> > v;
    for(int i=0; i<n; i++)
    {
        string a;
        int b;
        cin>>a>>b;
        v.push_back({{a,b}, i+1});
        s.insert(a);
    }
    auto it = s.begin();
    vector<pair<int, int> > alpha[s.size()];
    int cnt=0;
    for(it; it!=s.end(); it++)
    {
        for(int i=0; i<v.size(); i++)
        {
            if(v[i].first.first == *it)
            {
                alpha[cnt].push_back({v[i].first.second, v[i].second});
            }
        }
        sort(alpha[cnt].begin(), alpha[cnt].end());
        for(int i=alpha[cnt].size()-1; i>=0; i--)
        {
            cout<<alpha[cnt][i].second<<endl;
        }
        cnt++;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<vector>
using namespace std;
const int INF = 200000005;
int ts(long long int a) {
	int ka = 0;
	while (a % 2 == 0) {
		a /= 2;
		ka++;
	}
	return ka;
}
int main()
{
	int n;
	cin >> n;
	long long int a[10005] = { 0 };
	long long int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ans+=ts(a[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
def calc(grid, h, w)
  count = 0
  d = [[1, 0], [-1, 0], [0, 1], [0, -1]]
  stack = []

  for j in 0...h
    for i in 0...w
      next if grid[j][i] == 0

      count += 1
      stack << [i, j]

      until stack.empty?
        t = stack.pop
        v = grid[t[1]][t[0]]
        grid[t[1]][t[0]] = 0

        for k in 0...4
          m = t[1] + d[k][1]
          n = t[0] + d[k][0]
          if 0 <= n && n < w && 0 <= m && m < h && grid[m][n] != 0 && grid[m][n] == v
            stack << [n, m]
          end
        end
      end
    end
  end

  count
end

while line = gets
  h, w = line.chomp.split.map(&:to_i)
  break if h == 0 && w == 0

  grid = []

  h.times do
    grid << gets.chomp.split('')
  end

  puts calc(grid, h, w)
end

Measured memory_bytes: 8940
N, M = map(int, input().split())

a = []
for _ in range(M):
    a.append(int(input()))

val = [0,1]
for i in range(1, N + 1):
    ans = (val[0] + val[1]) % (10**9 +7)
    val[0] = val[1]
    val[1] = ans
    if len(a) > 0:
        if i == a[0]:
            val[1] = 0
            a.pop(0)

print(ans)

Measured memory_bytes: 7056
/*input

*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;

		b>>=1;
	}
	return res;
}

int main(){
	IOS;
	int a,b;
	cin>>a>>b;
	cout<<(3*a+b)/2<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define rep(i,q) for(int i = 0; (q) > i; i++)
int main(){
  int n;cin>>n;
  int a[n];
  long long kekka = 0;
  rep(i,n)cin >> a[i];
  cout << endl;
  for(int i = 0; n > i; i++){
    if(i != 0){
      if(a[i-1]%2 == 1 && a[i] > 0)a[i]--,a[i-1]--,kekka++;
    }
    kekka += a[i]/2;
  }
  cout << kekka << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define ull unsigned long long
#define db long double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <int> vi;
typedef vector <ll> vll;

typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll L, R;

const int MOD = 1e9 + 7, K = 60;
int dp[2][2][2][K], l[K], r[K];

void add(int & x, int y) {
	x += y;
	if (x >= MOD) {
		x -= MOD;
	}
}

int calc(int f0, int f1, int f2, int len) {
	if (len == K) {
		return 1;
	}
	int & res = dp[f0][f1][f2][len];
	if (res != -1) {
		return res;
	}
	res = 0;
	// x = 0, y = 0
	if (!f1 || (f1 && l[len] == 0)) {
		add(res, calc(f0, f1 && (l[len] == 0), f2 && (r[len] == 0), len + 1));
	}
	if (f0 == 0) {
		// x = 0, y = 1
		if ((!f1 || (f1 && l[len] == 0)) && (!f2 || (f2 && r[len] == 1))) {
			add(res, calc(0, f1 && (l[len] == 0), f2 && (r[len] == 1), len + 1));
		}
	}
	// x = 1, y = 1
	if (!f2 || (f2 && r[len] == 1)) {
		add(res, calc(0, f1 && (l[len] == 1), f2 && (r[len] == 1), len + 1));
	}
	return res;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	cin >> L >> R;
	for (int i = 0; i < K; i++) {
		l[i] = (L >> (K - i - 1) & 1);
		r[i] = (R >> (K - i - 1) & 1);
	}
	memset(& dp, -1, sizeof(dp));
	cout << calc(1, 1, 1, 0);
}


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

int main() {
  int x,y;
  cin >> x >> y;
  if(y%2 == 0 && 4*x >= y && y >= 2*x) cout << "Yes" << endl;
  else cout << "No" << endl;
  
	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;

int main() {
    int n,i,j,x,y,mh[15][15];
	while(cin >> n) {
		if (n==0) break;
		memset(mh,0,sizeof(mh));
		x=n/2; y=n/2+1; 
		for (i=1;i<=n*n;i++) {
			while(true) {
				if (mh[y][x]==0) { mh[y][x]=i; break;}
				else { x=(x+(n-1)) % n; y=(y+1) % n; }
			}
				x=(x+1) % n;
				y=(y+1) % n;
		}
		for (i=0;i<n;i++) {
			for (j=0;j<n;j++) printf("%4d",mh[i][j]);
			cout << endl;
		}
	}
   
	return 0;
}

Measured memory_bytes: 1192
n,k = map(int, input().split())
H = [int(input()) for i in range(n)]
H.sort()
ans = max(H)
for i in range(n-k+1):
  p = H[i+k-1] - H[i]
  ans = min(ans,p)
  if ans == 0:
    print(0)
    exit()
  
print(ans)

Measured memory_bytes: 7384
#include <bits/stdc++.h>
using namespace std;
const int N = 200000;

bool a[N],b[N];

int main(){

  int n,m; cin >> n >> m;

  for(int i = 0; i < m; i++){
    int x,y; cin >> x >> y;
    if(x == 1) a[y] = 1;
    if(y == n) b[x] = 1;
  }

  bool flag = 0;
  for(int i = 0; i < N; i++){
    if( a[i] && b[i] ) flag = 1;
  }
  cout << ( (flag)?"POSSIBLE":"IMPOSSIBLE" ) << endl;

  return 0;
}

Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    ll N,M; cin>>N>>M;
    vector<bool>b(N,true);
    ll ans=0,pena=0;
       vector<ll>pen(N,0);
    rep(i,M){
        ll p; string s;
        cin>>p>>s;
     
        if(b[p-1]){
            if(s=="WA")pen[p-1]++;
            else{
                ans++;
                b[p-1]=false;
            }
        }
    }
    rep(i,N){
        if(!b[i])pena+=pen[i];
    }
    cout<<ans<<" "<<pena<<endl;
}


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

int main()
{
	long long int N, minr, maxp = -2000000000;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		long long int r;
		cin >> r;
		if (i == 0)
		{
			minr = r;
			continue;
		}
		maxp = max(r - minr, maxp);
		minr = min(r, minr);
	}
	cout << maxp << endl;
}


Measured memory_bytes: 3116
// (c) 2020, redotter
// The grass was greener...

#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#pragma comment(linker, "/stack:200000000")
#endif

#define pb push_back
#define the(a) (a).begin(), (a).end()
#define ft first
#define sd second
#define endl "\n"
#define forn(i, n) for (int i = 0; i < (n); i++)
#define forr(i, s, n) for (int i = (s); i < (n); i++)

using i64 = long long;
using i32 = int;
using f64 = long double;

template <class T> using vec = vector<T>;
using str = string; using p64 = pair<i64, i64>;
using v64 = vec<i64>; using vv64 = vec<v64>;
using s64 = set<i64>; using m64 = map<i64, i64>;
template <size_t Size1> using a64 = array<i64, Size1>;
template <size_t Size1, size_t Size2> using aa64 = array<a64<Size2>, Size1>;
template <class T> using hash_set = unordered_set<T>;
template <class T, class U> using hash_map = unordered_map<T, U>;

mt19937 gen(998244353);
const i64 inf = numeric_limits<i64>::max() / 2;

template <class T> inline i64 len(const T& a) { return (i64)(a.size()); }
inline void fast() { ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0); }
template <class T, class S>
inline bool check_min(T& a, S b) { if (a > b) return a = b, 1; return 0; }
template <class T, class S>
inline bool check_max(T& a, S b) { if (a < b) return a = b, 1; return 0; }

void read() {}
template<class T, class ...U>
void read(T& a, U& ...b) { cin >> a; read(b...); }
void print() {}
template<class T, class ...U>
void print(const T& a, const U& ...b) { cout << a << " "; print(b...); }
void println() { cout << "\n"; }
template<class T, class ...U>
void println(const T& a, const U& ...b) { cout << a << " "; println(b...); }

struct Problem {
	void files(str in, str out) {
#ifdef ONLINE_JUDGE
		freopen(in.c_str(), "r", stdin), freopen(out.c_str(), "w", stdout);
#endif
	}
	void solve(), input();
	void many() { i64 t; cin >> t; while (t--) input(), solve(); }
	void make(bool mt = 0) { if (mt) many(); else input(), solve(); }
} problem;

signed main() {
	fast();
	problem.make();
#ifdef _DEBUG
	println(); println("[finished]"); system("pause > nul");
#endif
	return 0;
}

const i64 R = 998244353;

i64 n, s;
v64 a;

void Problem::solve() {
	vv64 dp(n + 1, v64(s + 1, 0));
	dp[0][0] = 1;
	forr(i, 1, n + 1) {
		forr(j, 0, s + 1) {
			dp[i][j] += dp[i - 1][j];
			dp[i][j] %= R;
			dp[i][j] += dp[i - 1][j];
			dp[i][j] %= R;
			if (j < a[i]) {
				continue;
			}
			dp[i][j] += dp[i - 1][j - a[i]] % R;
			dp[i][j] %= R;
		}
	}
	i64 ans = dp[n][s];
	println(ans);
}

void Problem::input() {
	read(n, s);
	a.resize(n + 1);
	forr(i, 1, n + 1) read(a[i]);
}


Measured memory_bytes: 73688
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  ll N,M;
  cin >> N >> M;

  if(N==1 && M==1) cout << 1 << endl;
  else if(N==1 || M==1) cout << max(N,M)-2 << endl;
  else cout << (N-2)*(M-2) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define pob(x) pop_back(x)
#define output(x) cout<<x<<endl
#define ERASE(x, n) x.erase(x.begin()+n)
// #define int long long
#define P pair<int, int>
typedef long long ll;

const long long int MOD = 1e9+7;
const int INF = -1;
ll dp[100005][13];

signed main(void) {
	int N;
	cin >> N;
	vector<int> v;
	rep(i, N) {
		float tmp;
		cin >> tmp;
		v.pb(tmp);
	}

	SORT(v);

	float ans = 0;
	rep(i, N) {
		if (i == 0) {
			ans = v[i];
		} else {
			ans += v[i];
			ans /= 2;
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

d,g = LI()
pc = [LI() for _ in range(d)]
ans = inf
for i in permutations(range(d)):
    score = 0
    count = 0
    for j in list(i):
        p,c = pc[j]
        if score + p*(j+1)*100 + c < g:
            score += p*(j+1)*100 + c
            count += p
            continue
        elif score + p*(j+1)*100 >= g:
            count += (g-score-1)//((j+1)*100)+1
            break
        elif score + p*(j+1)*100 + c >= g:
            count += p
            break
    ans = min(ans,count)
print(ans)


Measured memory_bytes: 41964
N = int(input())
B = list(map(int, input().split()))
ans = []
for i in range(N):
    last = 0
    for j, b in enumerate(B, 1):
        if b == j:
            last = b
    if last == 0:
        print(-1)
        exit()
    else:
        ans.append(B.pop(last - 1))
[print(a) for a in ans[::-1]]

Measured memory_bytes: 3060
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x) * -1, input().split()))
heapq.heapify(a)

for i in range(m):
    a_min = heapq.heappop(a)
    heapq.heappush(a, int(a_min / 2))

print(-1 * sum(a))

Measured memory_bytes: 14180
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  int x,a,b;
  C3(x,a,b);

  if(abs(x-a) <= abs(x-b))
    P("A");
  else
    P("B");
  ret 0;
}

Measured memory_bytes: 256
N=int(input())
T=list(map(int,input().split()))
M=int(input())
A=[]
for i in range(M):
    u=list(map(int,input().split()))
    A.append(u)

import copy
for i in range(M):
    UU=copy.deepcopy(T)
    UU[A[i][0]-1]=A[i][1]
    print(sum(UU))

Measured memory_bytes: 3444
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f

#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

class Node {
public:
  int to;
  int dist;
  Node() {}
  Node(int _t,int _d) : to(_t),dist(_d){}
};

bool is_LPG[3005];
bool dp[3005][2005]; //dp[city_id][remaining_LPG] = dist;

int get_city_id(map<string,int>& cities,const string& city){
  if(cities.find(city) == cities.end()){
    int idx = cities.size();
    cities[city] = idx;
  }
  return cities[city];
}

class State {
public:
  int city_id;
  int dist;
  int remaining_LPG;
  State(int _city_id,int _dist,int _con){
    city_id = _city_id;
    dist = _dist;
    remaining_LPG = _con;
  }

  bool operator <(const State& s) const{
    return (dist < s.dist);
  }

  bool operator >(const State& s) const{
    return (dist > s.dist);
  }
};

int main(){
  int total_roads;
  int total_LPG_stations;
  int capacity;
  while(cin >> total_roads >> total_LPG_stations >>capacity){
    if(total_roads == 0
       && total_LPG_stations == 0
       && capacity == 0) break;

    map<string,int> cities;
    memset(is_LPG,false,sizeof(is_LPG));
    memset(dp,false,sizeof(dp));

    string src,dst;
    cin >> src >> dst;
    get_city_id(cities,src);
    get_city_id(cities,dst);

    vector<Node> nodes[6001];
    for(int road_idx = 0; road_idx < total_roads; road_idx++){
      string from_str,to_str;
      int dist;

      cin >> from_str >> to_str >> dist;
      int from_num = get_city_id(cities,from_str);
      int to_num = get_city_id(cities,to_str);

      nodes[from_num].push_back(Node(to_num,dist));
      nodes[to_num].push_back(Node(from_num,dist));
    }

    for(int LPG_idx = 0; LPG_idx < total_LPG_stations; LPG_idx++){
      string city;
      cin >> city;
      is_LPG[get_city_id(cities,city)] = true;
    }

    priority_queue<State,vector<State>, greater<State> > que;
    que.push(State(get_city_id(cities,src),0,10*capacity));

    int dst_id = get_city_id(cities,dst);

    int res = INF;
    while(!que.empty()){
      State s = que.top();
      que.pop();

      if(s.city_id == dst_id){
	res = s.dist;
	goto found;
      }
      if(dp[s.city_id][s.remaining_LPG]) continue;
      dp[s.city_id][s.remaining_LPG] = true;

      for(int to_idx=0;to_idx<nodes[s.city_id].size();to_idx++){
	int to = nodes[s.city_id][to_idx].to;
	int dist = nodes[s.city_id][to_idx].dist;
	if(s.remaining_LPG < dist) continue;

	int next_remaining_LPG = (is_LPG[to] ? 10 * capacity : s.remaining_LPG - dist);

	que.push(State(to,s.dist + dist,next_remaining_LPG));
      }
    }
  found:;
    printf("%d\n",res >= INF ? -1 : res);
  }
  return 0;
}

Measured memory_bytes: 58840
S  = list(input())

a = "Yes"
for i,s in enumerate(S):
    if i % 2 == 0:
        if s in ["R", "U", "D"]:
            pass
        else:
            a = "No"
            break
    else:
        if s in ["L", "U", "D"]:
            pass
        else:
            a = "No"
            break
            
print(a)
      

Measured memory_bytes: 2940
#pragma region

#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define _rep3(i, begin, end) for (register int i = (begin), i##_end = (end); i < i##_end; i++)
#define _irep3(i, begin, end) for (register int i = (end)-1, i##_begin = (begin); i >= i##_begin; i--)
#define _rep2(i, n) _rep3(i, 0, n)
#define _irep2(i, n) _irep3(i, 0, n)
#define _overload3(_1, _2, _3, name, ...) name
#define rep(...) _overload3(__VA_ARGS__, _rep3, _rep2, )(__VA_ARGS__)
#define irep(...) _overload3(__VA_ARGS__, _irep3, _irep2, )(__VA_ARGS__)
#define out(x) cout << (x) << '\n';
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<long long>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;
using vvb = vector<vector<bool>>;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &pair) {
  cin >> pair.first >> pair.second;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[ ";
  rep(i, vec.size()) i == 0 ? os << vec[i] : os << ", " << vec[i];
  os << " ]";
  return os;
}

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

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

void init() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);
}

#pragma endregion

#define MOD 1000000007
#define INF 2147483647

int main() {
  init();

  int N;
  cin >> N;
  vl A(N + 1);
  cin >> A;

  vl sum(N + 1);
  sum[N] = A[N];
  irep(i, N) {
    sum[i] = sum[i + 1] + A[i];
  }

  if (N==0) {
    if (A[0]== 1) {
      out(1);
    }else {
      out(-1);
    }
    return 0;
  }

  if (A[0] != 0) {
    out(-1);
    return 0;
  }

  ll ans = 1, width = 1;
  rep(i, 1, N + 1) {
    width = min(width * 2, sum[i]);
    ans += width;
    if (width < A[i]) {
      out(-1);
      return 0;
    }
    width -= A[i];
  }

  out(ans);
}


Measured memory_bytes: 4732
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int i, no=1;

		StringBuilder sb = new StringBuilder();
		while(true){
			i = Integer.parseInt(br.readLine());
            if (i == 0) {
                break;
            }
            sb.append("Case ").append(no).append(": ").append(i).append("\n");
            no++;


		}
		System.out.print(sb);
	}
}

Measured memory_bytes: 30032
n,k = map(int, input().split())

dic = {}
for _ in range(n):
    a,b = map(int, input().split())
    if a not in dic:
        dic[a] = 0
    dic[a] += b

idx = 0
for key in sorted(dic.keys()):
    idx += dic[key]
    if idx >= k:
        print(key)
        break

Measured memory_bytes: 10596
using System;

class Divisors
{
    public static void Main()
    {
        String[] s = Console.ReadLine().Split();

        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);
        int c = int.Parse(s[2]);

        int count = 0;

        for(int i = a;i <= b; i++)
        {
            if (c%i == 0)
            {
                count++;
            }
        }

        Console.WriteLine(count);
    }
}


Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define fi first
#define se second


int main() {
    int n,k;
    cin>>n>>k;
    vector<ll>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans=100000000000;
    for(ll bit=0;bit<(1<<n);bit++){
        if(__builtin_popcount(bit)<k)continue;
        ll cnt=0;
        ll tmp_max=0;
        for(ll i=0;i<n;i++){
            if(a[i]>tmp_max){
                tmp_max=a[i];
                continue;
            }
            if(bit&(1<<i)){
                cnt+=(tmp_max-a[i]+1);
                tmp_max++;
            }
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;




    return 0;
}


Measured memory_bytes: 256
use proconio::marker::*;
use proconio::{fastout, input};

#[fastout]
fn main() {
   input! {
      a: usize,
      b: Bytes,
   }
   let b = (b[0] - b'0') as usize * 100 + (b[2] - b'0') as usize * 10 + (b[3] - b'0') as usize;
   let ans = (a * b) / 100;
   println!("{}", ans);
}


Measured memory_bytes: 2200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

int ans[4][4];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n,m;
    bool flag = false;
    cin>>n>>m;
    vector<int>s(m),c(m);
    map<pair<int,int>,int>mp;
    map<int,int>check;
    rep(i,m){
        cin>>s[i]>>c[i];
        if(s[i] == 1 && c[i] == 0 && n != 1)flag = true;
        mp[{s[i],c[i]}]++;
        check[s[i]]++;
        if(mp[{s[i],c[i]}] != check[s[i]])flag = true;
    }
    if(flag)cout<<-1<<endl;
    else{
        string ans(n,'0');
        rep(i,m){
            ans[s[i] - 1] = '0' + c[i];
        }
        if(ans[0] == '0' && n != 1)ans[0] = '1';
        cout<<ans<<endl;
    }

}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	for {
		var h, w int
		fmt.Scan(&h, &w)

		if h == 0 && w == 0 {
			return
		}

		for i := 0; i < h; i++ {
			for j := 0; j < w; j++ {
				if (i+j)%2 == 0 {
					fmt.Print("#")
				} else {
					fmt.Print(".")
				}
			}
			fmt.Println()
		}
		fmt.Println()
	}
}



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

int main(){
 string s;
cin >> s ;
int ans=0;
for(int i=0;i<4;++i){
if(s.at(i) == '+') ans++ ;
if(s.at(i) == '-') ans-- ;
}
cout << ans << endl;

}


Measured memory_bytes: 256
def solve():
    N = int(input())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    C = list(map(int,input().split()))

    A.sort()
    C.sort()

    cnt = 0
    for i in range(N):
        a_cnt = binSearch(B[i],A)
        c_cnt = N - binSearch(B[i]+1, C)
        cnt += a_cnt * c_cnt
    
    print(cnt)

def binSearch(target,lst):
    left = -1
    right = len(lst)

    while right - left > 1:
        mid = (right+left) // 2
        if lst[mid] < target:
            left = mid
        else:
            right = mid
    
    return right

if __name__ == '__main__':
    solve()

Measured memory_bytes: 105444
//#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
using LL = int_fast64_t;
LL n,m;
int main(){
    ____();
    cin >> n >> m;
    LL sum = 0;
    for(int i = 1; i <= m; i++){
        LL x; cin >> x;
        sum += x;
    }
    if(sum>n) cout << -1 << endl;
    else cout << n - sum << endl;
    return 0;
}

Measured memory_bytes: 3616
h,w,a,b = map(int,input().split())
ans = [''] * h
for i in range(h):
  if i < b :
    ans[i] = '0'*a + '1'*(w-a)
  else:
    ans[i] = '1'*a + '0'*(w-a)
for s in ans:
  print(s)


Measured memory_bytes: 4980
s = list(input())
s_num = len(s)
t = list(input())
t_num = len(t)
s.sort()
t.sort(reverse=True)
nagasa = min(s_num, t_num)
hantei = False
onaji = True
for i in range(nagasa):
    S = ord(s[i])
    T = ord(t[i])
    if S < T:
        hantei = True
        break
    if S != T:
        onaji = False
if onaji and nagasa < t_num:
    hantei = True
print("Yes" if hantei else "No")


Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <math.h>
#include <map>
#include <set>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
using namespace std;

const int MOD = 1000000007;


int main(){
    int n,res;
    cin >> n;
    res = (1 + n)  * (n/2);
    if(n % 2 == 1)res += (n/2) + 1;

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256