akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(long long i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define rrep(i,n) for(long long i=int(n);i>0;i--)
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+5  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
using PPI=pair<P,int>;
//ll const mod=998244353;
ll const mod=1e9+7;
const ll MAX=1000005;
using vi=vector<int>;
using vl=vector<ll>;
using vc=vector<char>;
using vd=vector<double>;
using vs=vector<string>;
using vp=vector<P>;
using vb=vector<bool>;
using vvi =vector<vector<int>>;
using vvl =vector<vector<ll>>;
using vvd=vector<vector<double>>;
using vvc=vector<vector<char>>;
using vvp =vector<vector<P>>;
using vvb=vector<vector<bool>>;
template <typename T>
bool chmax(T &a, const T b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T b){if(a > b){a = b; return true;} return false;}

int main(){
    int n,h;
    cin>>n>>h;
    vl a(n),b(n);
    rep(i,n)cin>>a[i]>>b[i];
    sort(rall(a));
    sort(rall(b));
    rep(i,n-1){
        b[i+1]+=b[i];
    }
    int ans=(h+a[0]-1)/a[0];
    rep(i,n){
        int t=h;
        int res=i+1;
        t-=b[i];
        if(t<0)t=0;
        res+=(t+a[0]-1)/a[0];
        chmin(ans,res);
        if(t<=0)break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> H(N);
    rep(i, N) cin >> H[i];
    sort(all(H));
    int ans = 1e9;
    for(int n = 0; (n+K-1) < N; n++) ans = min(ans, H[n+K-1] - H[n]);
    cout << ans << endl;
}


Measured memory_bytes: 640
N=int(input())
sum=0

while N > 0:
  ai = N
  if (ai % 3 == 0) and (ai % 5 == 0):
    ai ='FizzBuzz'
  elif (ai % 3 == 0):
    ai = 'Fizz'
  elif (ai % 5 == 0):
    ai == 'Buzz'
  else:
    sum=sum+ai
  N=N-1

print(sum)

Measured memory_bytes: 9160
open Array
let h, w = Scanf.scanf " %d %d" @@ fun a b -> a, b
let css = init h @@ fun _ -> Scanf.scanf " %s" @@ fun s -> s
let is_ok = ref false
let rows, cols = make h false, make w false
let _ =
  for i = 0 to h - 1 do
    is_ok := false;
    for j = 0 to w - 1 do if css.(i).[j] = '#' then is_ok := true done;
    if !is_ok then rows.(i) <- true done;
  for j = 0 to w - 1 do
    is_ok := false;
    for i = 0 to h - 1 do if css.(i).[j] = '#' then is_ok := true done;
    if !is_ok then cols.(j) <- true done;
  for i = 0 to h - 1 do
    is_ok := false;
    for j = 0 to w - 1 do if rows.(i) && cols.(j) then (is_ok := true; print_char css.(i).[j]) done;
    if !is_ok then print_newline () done

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <vector>
#include <cmath>

int main(void){
    int a,b;
    std::cin >> a >> b;
    std::string s;
    std::cin >> s;

    int box = s.find("-");
    int box1 = s.rfind("-");
    if(a == box && box == box1){
        std::cout << "Yes";
    }
    else std::cout << "No";
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int xor(int x, int y){
    int x2len = floor(log2(x)) + 1;
    int y2len = floor(log2(y)) + 1;
    int len;
    if(x2len > y2len) len = x2len;
    else len = y2len;
    int z = 0;
    for(int i = 0;i < len;i++){
        z += pow(2, i) * ((x%(int)pow(2,i+1) >= pow(2, i))!=(y%(int)pow(2,i+1) >= pow(2, i)));
    }
    return z;
}

int main(void){
    int m, k;
    scanf("%d %d", &m, &k);
    if(k >= pow(2, m))printf("-1\n");
    else if(m == 1 && k != 0)printf("-1\n");
    else{
        if(k == 0){
            for(int i = 0;i < pow(2, m);i++){
                printf("%d %d ", i, i);
            }
            printf("\n");
        }else{
            int length = pow(2, m);
            int b[length];
            for(int i = 0;i < length;i++){
                b[i] = 1;
            }
            int count = 0;
            for(int i = 0;i < pow(2, m-2);i++){
                while(1){
                    if(b[count] == 0)count++;
                    else break;
                }
                int a1 = count;
                b[a1] = 0;
                int a2 = xor(a1, k);
                b[a2] = 0;
                while(1){
                    if(b[count] == 0)count++;
                    else break;
                }
                int a3 = count;
                b[a3] = 0;
                int a4 = xor(a3, k);
                b[a4] = 0;
                printf("%d %d %d %d %d %d %d %d ", a1, a3, a4, a1, a2, a4, a3, a2);
            }
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 2432
#include <stdio.h>
#include <string.h>
#define maxn 4010
#define LL long long
LL sum;
char s[maxn];
int r[maxn],g[maxn],b[maxn];
int main(){
	int i,j,k,n;
	scanf("%d%s",&n,s+1);
	for(i=1;i<=n;i++){
		r[i]=r[i-1],g[i]=g[i-1],b[i]=b[i-1];
		if(s[i]=='R')r[i]+=1;
		else if(s[i]=='G')g[i]+=1;
		else if(s[i]=='B')b[i]+=1;
	}
	for(i=1;i<=n;i++)//'R' 'G'
		for(k=i+1;k<=n;k++)
			if(s[i]=='R'&&s[k]=='G'){
				if((i+k)%2==0){
					j=(i+k)/2;
					if(s[j]=='B')sum+=b[k-1]-b[i]-1;
					else sum+=b[k-1]-b[i];
				}else sum+=b[k-1]-b[i];
			}
	for(i=1;i<=n;i++)//'G' 'R'
		for(k=i+1;k<=n;k++)
			if(s[i]=='G'&&s[k]=='R'){
				if((i+k)%2==0){
					j=(i+k)/2;
					if(s[j]=='B')sum+=b[k-1]-b[i]-1;
					else sum+=b[k-1]-b[i];
				}else sum+=b[k-1]-b[i];
			}
	for(i=1;i<=n;i++)//'R' 'B'
		for(k=i+1;k<=n;k++)
			if(s[i]=='R'&&s[k]=='B'){
				if((i+k)%2==0){
					j=(i+k)/2;
					if(s[j]=='G')sum+=g[k-1]-g[i]-1;
					else sum+=g[k-1]-g[i];
				}else sum+=g[k-1]-g[i];
			}
	for(i=1;i<=n;i++)//'B' 'R'
		for(k=i+1;k<=n;k++)
			if(s[i]=='B'&&s[k]=='R'){
				if((i+k)%2==0){
					j=(i+k)/2;
					if(s[j]=='G')sum+=g[k-1]-g[i]-1;
					else sum+=g[k-1]-g[i];
				}else sum+=g[k-1]-g[i];
			}
	for(i=1;i<=n;i++)//'B' 'G'
		for(k=i+1;k<=n;k++)
			if(s[i]=='B'&&s[k]=='G'){
				if((i+k)%2==0){
					j=(i+k)/2;
					if(s[j]=='R')sum+=r[k-1]-r[i]-1;
					else sum+=r[k-1]-r[i];
				}else sum+=r[k-1]-r[i];
			}
	for(i=1;i<=n;i++)//'G' 'B'
		for(k=i+1;k<=n;k++)
			if(s[i]=='G'&&s[k]=='B'){
				if((i+k)%2==0){
					j=(i+k)/2;
					if(s[j]=='R')sum+=r[k-1]-r[i]-1;
					else sum+=r[k-1]-r[i];
				}else sum+=r[k-1]-r[i];
			}
	printf("%lld\n",sum);
	return 0;
}

Measured memory_bytes: 1748
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))
using namespace std;
using namespace __gnu_pbds;
auto random_address = [] { char *p = new char; delete p; return uint64_t(p); };
const uint64_t SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_address() | 1);
mt19937_64 rng(SEED);
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,m,nrcomp;
bool use[200001];
vector<ll> muchii[200001];
void dfs(int nod)
{
    use[nod]=1;
    for(auto j:muchii[nod])
        if(!use[j])
            dfs(j);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
        ll a,b;
        cin>>a>>b;
        muchii[a].push_back(b);
        muchii[b].push_back(a);
    }
    for(int i=1;i<=n;i++)
        if(!use[i])
    {
        nrcomp++;
        dfs(i);
    }
    cout<<nrcomp-1;
    return 0;
}


Measured memory_bytes: 12780
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

int main() {
	int N; cin >> N;
	vector<int> A(N),B,C;
	for (int i = 0; i < N; i++)cin >> A[i];
	sort(A.begin(), A.end());
	int max = A[N - 1], min = A[0];
	for(int i=1;i<N-1;i++) {
		if (A[i] >= 0) {
			B.push_back(min); C.push_back(A[i]);
			min -= A[i];
		}
		else {
			B.push_back(max); C.push_back(A[i]);
			max -= A[i];
		}
		
	}

	cout << max-min << endl;
	for (int i = 0; i < B.size(); i++)cout << B[i] << " " << C[i] << endl;
	cout << max << " " << min << endl;
}




Measured memory_bytes: 3316
s = gets.chop
k = gets.chop.to_i

flag = 0


for i in 0..k-1
  unless s[i] == '1' then
    flag = 1
    break
  end
end

if flag == 1 then
  for i in 0..s.length-1
    unless s[i] == '1' then
      ans = s[i]
      break
    end
  end
  puts ans
else
  puts '1'
end


Measured memory_bytes: 1788
#include <stdio.h>
#include <string.h>
int main(void){
	char a[102],b[102];
	scanf("%s%s",a,b);
	if(strlen(a) > strlen(b)){
		printf("GREATER");
	}else if(strlen(a) < strlen(b)){
		printf("LESS");
	}
	else{
		for(int i=0;i<strlen(a);i++){
			if(a[i] > b[i]){
				printf("GREATER");
				return 0;
			}
			else if(a[i] < b[i]){
				printf("LESS");
				return 0;
			}
		}
		printf("EQUAL");
	}
	return 0;
}

Measured memory_bytes: 128
from functools import reduce


n = int(input())
nums = list(map(int, input().split(" ")))

ans = 0
prev = -1
count = 1 # 1が立ってるビットが一致しない数が連続している個数
left = -1

for i,num in enumerate(nums):
    if i == 0:
        prev = num
        left = 0
        count = 1
        continue
    
    #breakpoint()

    if prev & num > 0:
        # left を1進めたらいけるか？
        while prev & num > 0:
            ans += count
            prev = prev ^ nums[left]
            count -= 1
            left += 1
        count += 1
        prev += num
    else:
        count += 1
        prev = prev + num

#print("count", count)

# 1からcountまでの合計を足す
ans += count*(count+1)//2

print(ans)

Measured memory_bytes: 25336
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
inline long long read(){
	register long long x=0;
	register char ch=getchar();
	while(ch<'0'||ch>'9')	ch=getchar();
	while(ch>='0'&&ch<='9')	x=x*10+(ch^48),ch=getchar();
	return x;
}
int n,q,top;
long long b[N],st[N],res[N];
void solve(long long x,long long val){
	if(x<=n){
		b[x]+=val;
		return ;
	}
	int k=lower_bound(st+1,st+top+1,x)-st-1;
	res[k]+=val*(x/st[k]);
	solve(x%st[k],val);
}
int main(){
	st[top=1]=n=read(),q=read();
	while(q--){
		long long p=read();
		while(top&&st[top]>=p)	--top;
		st[++top]=p;
	}
	res[top]=1,q=n,n=st[1];
	for(int i=top;i;i--)	solve(st[i],res[i]);
	for(int i=q;i;i--)	b[i]+=b[i+1];
	for(int i=1;i<=q;i++)	printf("%lld\n",b[i]);
	return 0;
}


Measured memory_bytes: 4096
#define _CRT_NONSTDC_NO_WARNINGS
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define NL << endl
#define REP(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define Yes cout << "Yes" NL
#define No cout << "No" NL

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr int INTMAX = numeric_limits<int>::max();
constexpr int INTMIN = numeric_limits<int>::min();
constexpr ll LLMAX = numeric_limits<long long>::max();
constexpr ll LLMIN = numeric_limits<long long>::min();
constexpr int MOD = 1000000007;

int map[101][101];
int a[10001];

signed main() {
	int H, W;
	cin >> H >> W;
	int N;
	cin >> N;
	a[0] = 0;
	for(int i = 1; i <= N; i++) {
		int t;
		cin >> t;
		a[i] = a[i - 1] + t;
	}

	int nc = 0;
	int sign = 1;
	int cnt = 0;
	int x = 0;
	for (int y = 0; y < H; y++) {
		for (int c = 0; c < W; c++) {
			if (cnt >= a[nc]) nc++;
			::map[y][x] = nc;
			cnt++;
			x += sign;
		}
		x -= sign;
		sign *= -1;
	}
	for (int y = 0; y < H; y++) {
		for (int x = 0; x < W; x++) {
			cout << ::map[y][x] << ' ';
		}
		cout NL;
	}


	return 0;

}



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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	llong a, p;
	cin >> a >> p;

	cout << (a*3+p)/2 << endl;

	return 0;
}

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

int main() {
  int N;
  cin >> N;
  unordered_map<int,int> A;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    A[a]++;
  }
  int count = 0;
  for (auto i : A) {
    if (i.first > i.second) count += i.second;
    else count += i.second - i.first;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 4260
import sys

atcg = set('ATCG')

s = sys.stdin.readline().rstrip()

def main():
    t = s + '$'
    l = len(t)
    res = 0
    cnt = 0
    for i in range(l):
        if t[i] in atcg:
            cnt += 1
        else:
            res = max(res, cnt)
            cnt = 0
    return res

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 500000
#define INF 1000000000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define IN(a) cin>>(a)
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P;
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
	int n;
	IN(n);
	vector<int> h(n);
	REP(i,n){
		IN(h[i]);
	}
	int ans=0;
	int tmp=0;
	REP(i,n-1){
		if(h[i]>=h[i+1]){
			tmp++;
			}
		else {
			ans=max(ans,tmp);
			tmp=0;
			}
	}
	ans=max(ans,tmp);
	OUT(ans);
	return 0;
}

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

const int N = 200005;

int n, q;
int a[N], b[N];
multiset < pair<long long, int> > sa, sb; // (b - a, p)
long long sum;

void reset() {
	while(sa.size() >= 2) {
		multiset < pair<long long, int> > :: iterator it;
		it = sa.end();
		--it;
		pair<long long, int> x = (*it);
		--it;
		pair<long long, int> y = (*it);

		if (x.first + y.first > 0) {
			sb.insert(x);
			sb.insert(y);
			sum -= a[x.second]; sum += b[x.second];
			sum -= a[y.second]; sum += b[y.second];

			sa.erase(sa.find(x));
			sa.erase(sa.find(y));
		}
		else break;
	}
}

void debug(multiset< pair<long long, int> > &s) {
	for (auto &e : s) printf("[%lld, %d] ", e.first, e.second); printf("\n");
}

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

	cin >> n >> q;

	for (int i = 1; i <= 2 * n; ++i) cin >> a[i];
	for (int i = 1; i <= 2 * n; ++i) cin >> b[i];

	for (int i = 1; i <= 2 * n; ++i) {
		sum += a[i];
		if (i != 1 && i != 2 * n) {
			sa.insert(make_pair(b[i] - a[i], i));
		}
	}

	reset();

	while(q--) {
		int p, x, y; cin >> p >> x >> y;
		if (p != 1 && p != 2 * n) {
			if (sb.find(make_pair(b[p] - a[p], p)) != sb.end()) {
				sb.erase(sb.find(make_pair(b[p] - a[p], p)));
				sum -= b[p];
			}
			else if (sa.find(make_pair(b[p] - a[p], p)) != sa.end()) {
				sa.erase(sa.find(make_pair(b[p] - a[p], p)));
				sum -= a[p];
			}
		} else {
			sum -= a[p];
		}

		a[p] = x;
		b[p] = y;
		sum += a[p];

		if (p != 1 && p != 2 * n) sa.insert(make_pair(y - x, p));

		//printf("sa "); debug(sa);
		//printf("sb "); debug(sb);

		int ndel = 0;
		while(!sb.empty()) {
			if (ndel >= 2 && sb.size() % 2 == 0) break;
			++ndel;
			sum -= b[(*sb.begin()).second];
			sum += a[(*sb.begin()).second];
			sa.insert(*sb.begin());
			sb.erase(sb.begin());
		}

		reset();

		//printf("sa "); debug(sa);
		//printf("sb "); debug(sb);

		printf("%lld\n", sum);
	}
}

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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;

#define SIZE 200005
//#define rep(i,N) for(long long  i=0;i<N;i++)

//long long  INF=1000000000000000000;
long long MOD=mod;
using namespace std;
long long ans;

long long fac[SIZE],finv[SIZE],inv[SIZE];

void make() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
long long C(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main(){
    int N,K;
    cin>>N>>K;
    
    vector<long long >A(N);

    rep(i,N){
        cin>>A[i];
    }
    make();

    sort(A.begin(),A.end());
    long long ans=0;
    if(K==1){
    cout<<"0"<<endl;
    return 0;
    }
    else{
        for(int i=K-1;i<=N-1;i++){
            long long p=A[i]*C((i+1)-1,K-1);
            p%=mod;
            ans+=p;
            if(ans>=mod)ans%=mod;
            else if(ans<0){
                ans+=mod;
            }
        }

        for(int i=0;i<N-(K-1);i++){
            long long p=A[i]*C(N-(i+1),K-1);
            p%=mod;

            ans-=p;
            if(ans>=mod)ans%=mod;
            else if(ans<0){
                ans+=mod;
            }
        }
    }
    cout<<ans<<endl;





    return 0;

}
/*


*/


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

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

    vpint X(N);
    rep(i,N)cin>>X[i].fi>>X[i].se;
    vpint Y(N);
    rep(i,N)cin>>Y[i].fi>>Y[i].se;

    sort(all(X));
    sort(all(Y));

    multiset<int>ei;
    int cur=0;
    int ans=0;
    rep(i,N){
        while(cur<N&&X[cur].fi<Y[i].fi){
            ei.insert(X[cur].se);
            cur++;
        }
        auto it=ei.lower_bound(Y[i].se);
        if(it!=ei.begin()){
            it--;
            ei.erase(it);
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	//input
	int N, M;
	cin >> N >> M;

	vector<int> H(N);
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}

	vector<int> A(M);
	vector<int> B(M);
	for (int i = 0; i < M; i++) {
		cin >> A[i] >> B[i];
		A[i]--;
		B[i]--;
	}

	//calculation
	vector<priority_queue<int>> road(N);
	for (int i = 0; i < M; i++) {
		road[A[i]].push(H[B[i]]);
		road[B[i]].push(H[A[i]]);
	}

	int output = 0;
	for (int i = 0; i < N; i++) {
		int flag = 1;
		if (road[i].size() == 0) {
			output++;
		} else {
			if (H[i] > road[i].top()) {
				output++;
			}
		}
	}

	//output
	cout << output << endl;


	return 0;
}


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

using namespace std;

long long a[55];
long long res;
long long n;

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  
  while (1) {
    long long mx = -1, idx = -1;
    for (int i = 0; i < n; i++) {
      if (a[i] > mx) {
        mx = a[i];
        idx = i;
      }
    }
    if (mx < n) break; 
    long long tmp = a[idx] / n;
    res += tmp;
    a[idx] -= tmp * n;
    for (int i = 0; i < n; i++) {
      if (i == idx) continue;
      a[i] += tmp;
    }  
  }
  cout << res << "\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    string S; cin >> S;
    ll K; cin >> K;
    for (int i=0;i<K;i++){
        if (S[i]!='1') {
            cout << S[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main() {
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;
    vector<int> X, Y;
    int n = 0;
    for (int i = 0; i<s.size(); i++) {
        if (s[i] == 'T') {
            (X.size() == Y.size() ? X : Y).push_back(n);
            n = 0;
        }
        else {
            n++;
        }
    }
    (X.size() == Y.size() ? X : Y).push_back(n);
    int b = X[0], c = 0;
    sort(X.begin() + 1, X.end());
    sort(Y.begin(), Y.end());

    for (int i = X.size() - 1; i >= 1; i--) {
        b += X[i] * (b>x ? -1 : 1);
    }
    for (int i = Y.size() - 1; i >= 0; i--) {
        c += Y[i] * (c>y ? -1 : 1);
    }
    printf("%s\n", ((b == x && c == y) ? "Yes" : "No"));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
using namespace std;

int main(){
	int n,m,d,h,i,j,r;
	string str;
	for(;cin>>n,n;cout<<r<<endl){
		vector<int>monster(n);
		for(h=i=0;i<n;i++){
			cin>>monster[i];
			if(h<monster[i])h=monster[i];
		}
		vector<pair<int,int> >_all,_single;
		vector<int>all(h+1),single(h+1);
		map<int,int>all_iter;
		all_iter[0]=0;
		for(cin>>i;i--;){
			cin>>str>>m>>str>>d;
			if(d){
				if(str[0]=='A')_all.push_back(make_pair(m,d));
				else _single.push_back(make_pair(m,d));
			}
		}
		for(i=1;i<=h;i++){
			all[i]=9999999;
			single[i]=9999999;
			for(j=0;j<_all.size();j++){
				all[i]=min(all[i],all[max(0,i-_all[j].second)]+_all[j].first);
			}
			for(j=0;j<_single.size();j++){
				single[i]=min(single[i],single[max(0,i-_single[j].second)]+_single[j].first);
			}
			all_iter[all[i]]=i;
		}

		r=9999999;
		for(map<int,int>::iterator it=all_iter.begin();it!=all_iter.end();it++){
			h=it->first;
			for(j=0;j<monster.size();j++)h+=single[max(0,monster[j]-it->second)];
			if(r>h)r=h;
		}
	}
}

Measured memory_bytes: 2120
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int main(void){
    int n,k;
    int h,i,j,ans=0;
    int a[100][100],d[100],flag[100];
    scanf("%d %d\n",&n,&k);
    for(i=0; i<k;i++){
        scanf("%d\n",&d[i]);
        for(j=0; j<d[i]; j++){
            scanf("%d\n",&a[i][j]);
        }
    }
    for(h=1; h<=100; h++){
        for(i=0; i<k; i++){
            for(j=0; j<d[i]; j++){
                if(a[i][j]==h)flag[h-1]=1;
            }
        }
    }
    for(i=0; i<100; i++)ans+=flag[i];
    printf("%d",n-ans);
    return 0;
}

Measured memory_bytes: 1740
from collections import deque
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
c=1
for i in range(h):
    row=deque()
    for j in range(w):
        if i%2==0:
            row.append(c)
            a[c-1]-=1
            if a[c-1]==0:
                c+=1
        else:
            row.appendleft(c)
            a[c-1]-=1
            if a[c-1]==0:
                c+=1
    print(*row)

Measured memory_bytes: 3956
use std::io::*;
use std::str::FromStr;

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

fn main(){
    let l: u64 = read();
    let r: u64 = read();
    let d: u64 = read();

    println!("{}", (l..=r).fold(0, |b, i| if i % d == 0 {b + 1} else {b}));
}


Measured memory_bytes: 2156
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  ll N;
  int ans = 0;

  cin >> N;

  for (ll i = 2; i * i <= N; i++) {
    int counter = 0;
    while (N % i == 0) {
      N /= i;
      counter++;
    }
    for (int j = 1; j * (j + 1) / 2 <= counter; j++) {
      ans++;
    }
  }

  if (N > 1) ans++;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3600
#include"bits/stdc++.h"
using namespace std;

int main() {

	string N;
	cin >> N;

	int t = 0;

	if (N[0] == '2') {
		t++;
	}

	if (N[1] == '2') {
		t++;
	}

	if (N[2] == '2') {
		t++;
	}

	if (N[3] == '2') {
		t++;
	}

	cout << t << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
int main(){
    int n, q;
  	cin >> n >> q;
    dsu d(n);
    for(int i = 0; i < q; i++){
        int t, u, v; 
      	cin >> t >> u >> v;
        if(t == 0){
            d.merge(u, v);
        }
        else{
            if(d.same(u, v)){
                cout << 1 << endl;
            }
            else{
                cout << 0 << endl;
            }
        }
    }
  	return 0;
}

Measured memory_bytes: 3944
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n; cin >> n;
  int cand[] = {3, 5, 7};
  int ans = 0;
  auto dfs = [&](auto dfs,
                 int i, ll val,
                 bool used3, bool used5, bool used7) -> void {
    if(val > n) return;
    if(val && used3 && used5 && used7) ans++;
    dfs(dfs, i+1, val+3*pow(10, i), true, used5, used7);
    dfs(dfs, i+1, val+5*pow(10, i), used3, true, used7);
    dfs(dfs, i+1, val+7*pow(10, i), used3, used5, true);
  };
  dfs(dfs, 0, 0, false, false, false);
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 4080
A, B, H, M = map(int, input().split())

import math

M_rad = math.radians(360 * (M / 60))
H_rad = math.radians(30 * (M / 60) + 360 * (H / 12))

AB = abs(M_rad - H_rad)
tmp = A ** 2 + B ** 2 - 2 * A * B * math.cos(AB)
ans = math.pow(tmp, 1 / 2)
print(ans)


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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    while(true){
        c -= b;
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }

        a -= d;
        if(a <= 0){
            cout << "No" << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long i,j,k,l,m,n,o,p,q;
    while(cin>>m>>n)

    {
        i=m+n;
        j=m-n;
        k=m*n;
        cout<<max(i,max(j,k))<<endl;

    }
    return 0;
}


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

#define YOKO 0
#define TATE 1

char field[2010][2010];
int cnt[2][2010][2010];

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

    for (int i=0; i<H; i++) cin >> field[i];

    // 横
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            if (field[i][j] == '.') {
                cnt[YOKO][i][j] = 1;
                if (j > 0) cnt[YOKO][i][j] += cnt[YOKO][i][j - 1];
            }
        }

        for (int j=W-1; j>=0; j--) {
            if (field[i][j] == '.') {
                if (j < W-1 && field[i][j + 1] == '.') {
                    cnt[YOKO][i][j] = cnt[YOKO][i][j + 1];
                }
            }
        }
    }

    // tate
    for (int j=0; j<W; j++) {
        for (int i=0; i<H; i++) {
            if (field[i][j] == '.') {
                cnt[TATE][i][j] = 1;
                if (i > 0) cnt[TATE][i][j] += cnt[TATE][i - 1][j];
            }
        }

        for (int i=H-1; i>=0; i--) {
            if (field[i][j] == '.') {
                if (i < H-1 && field[i + 1][j] == '.') {
                    cnt[TATE][i][j] = cnt[TATE][i + 1][j];
                }
            }
        }
    }

    int ans = 0;
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            if (field[i][j] == '.') {
                ans = max(ans, cnt[YOKO][i][j] + cnt[TATE][i][j] - 1);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 35712
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int a;
    int b;
    int c;
    cin >> a >> b >> c;
    if (c > b)
    {
        if (b > a)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        };
    }
    else
    {
        cout << "No" << endl;
    };
}


Measured memory_bytes: 3096
import math

def check(A, x, k):
    cut_count = 0
    for number in A:
        cut_count += (math.ceil(number / x)) -1
    return cut_count <= k

n, k = map(int,input().split())
a = list(map(int, input().split()))
ans = 0

l = 0
r = 10 ** 9
 
while r - l > 1:
    x = (r + l) // 2
  
    if check(a, x, k):
        r = x
    else:
        l = x   
print(r)

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

const int N = 505;

int n, m, q;
int f[N][N];

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> m >> q;
	while (m--) {
		int l, r; cin >> l >> r;
		f[l][r]++;
	}
	for (int l = n; l >= 1; --l) {
		for (int r = l; r <= n; ++r) {
			f[l][r] += f[l + 1][r];
			f[l][r] += f[l][r - 1];
			f[l][r] -= f[l + 1][r - 1];
		}
	}
	while (q--) {
		int l, r; cin >> l >> r;
		cout << f[l][r] << '\n';
	}
}

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

int main() {
  
  string S;
  cin >> S;
  
  if (S.at(0) == S.at(1) && S.at(2) == S.at(3) && S.at(0) != S.at(2)) {
    cout << "Yes" << endl;
  }
  else if (S.at(0) == S.at(2) && S.at(1) == S.at(3) && S.at(0) != S.at(1)) {
    cout << "Yes" << endl;
  }
  else if (S.at(0) == S.at(3) && S.at(2) == S.at(1) && S.at(0) != S.at(1)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
  

return 0;
}

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

int main(void){
  long long sosu[50001],i,j,n;

  sosu[0]=1;
  sosu[1]=1;

  for(i=2;i<50001;i++)
    sosu[i]=0;

  for(i=2;i<50001;i++){
    if(sosu[i]==0){
      for(j=i*i;j<50001;j+=i)
	sosu[j]=1;
    }
  }

  while(1){
    int count=0;
    cin >> n;
    if(n==0)break;    

    for(i=0;i<n/2+1;i++){
      if(sosu[i]==0 && sosu[n-i]==0)count++;
}

    /*   for(i=0;i<n;i++){
      for(j=0;j<n/2+1;j++){
	if(sosu[i]==0&&sosu[j]==0&&n==i+j)count++;
      }
      }*/
    cout << count << endl;
  }
  return 0;
}

Measured memory_bytes: 1252
N = int(input())
S = input()

count = {}
for c in S:
  if c not in count:
    count[c] = 1
  else:
    count[c] = count[c] + 1

a = 1
for k in count:
  a = a * (1 + count[k])
a = a - 1
a = a % (10 ** 9 + 7)

print(a)


Measured memory_bytes: 3188
/****************************
*  Developer : joshi08
*  Date  :  05-07-2020
*  Year  :  2020
****************************/

#include <bits/stdc++.h>

#define lli long long int
#define mod 1000000007
#define fi first
#define se second
#define ii pair<lli, lli>
#define mp make_pair
#define endl '\n'
const double PI = 3.141592653589793238460;
lli gcd(lli a, lli b) { if (a == 0) return b; return gcd(b % a, a);}
lli max(lli a, lli b) {if (a > b) return a; else return b;}
lli min(lli a, lli b) {if (a < b) return a; else return b;}
lli power(lli a, lli n){ lli res = 1; while(n){ if(n%2==0){ a *= a; n /= 2; } else{ res *= a; n--; } } return res; }

using namespace std;

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

	lli n,k;
	cin>>n;
	
	n = 1000 - (n%1000);
	n = n%1000;
	
	cout<<n;

    return 0;
}



Measured memory_bytes: 3648
s = gets.chomp
t = gets.chomp

ans = "Yes"
s_arr = Array.new(26, -1)
t_arr = Array.new(26, -1)
abc = 'a'..'z'
for i in 0..(s.size - 1) do
  s_i = abc.find_index(s[i])
  t_i = abc.find_index(t[i])

  if s_arr[s_i] != -1 || t_arr[t_i] != -1
    if s_arr[s_i] != t_i || t_arr[t_i] != s_i
      ans = "No"
      break
    end
  end
  s_arr[s_i] = t_i
  t_arr[t_i] = s_i
end

puts ans

Measured memory_bytes: 3836
#include <cstdio>

int main() {
  int A, B;
  scanf("%d %d", &A, &B);

  if (A == 1) A += 13;
  if (B == 1) B += 13;

  if (A < B) {
    puts("Bob");
  } else if (B < A) {
    puts("Alice");
  } else {
    puts("Draw");
  }
}

Measured memory_bytes: 128
function Main(input) {
    input = input.trim();
    let sum = 0;
    for (let i=0; i < input.length; i++){
        sum += parseInt(input[i]);
    }
 
    if (sum % 9 == 0) {
        console.log('Yes');
    } else {
        console.log('No');
    }
}

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

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

double a, b;

int main() {
	cin >> a >> b;
	double x = ceil(a / 0.08);
	while ((int) (x * 0.08) == a) {
		if ((int) (x * 0.1) == b) {
			cout << x << '\n';
			return 0;
		}
		x++;
	}
	cout << -1 << '\n';
}

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

int n, max1 = -2e9, min1 = 2e9;

int main(){
	int i, a;
	scanf("%d", &n);
	for(i = 0; i < n; i++) scanf("%d", &a), max1 = max(max1, a), min1 = min(min1, a);
	printf("%d", max1 - min1);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int64_t ans = 0;
    int64_t mn, mx;
    for(int64_t j=1; j*j<=N; j++) {
        mn = N/(j+1);
        mx = N/j;
        ans += (mx*(mx+1)/2 - mn*(mn+1)/2) * (j*(j+1)/2);
    }

    for(int64_t i=1; i<=mn; i++) {
        int64_t j = N/i;
        ans += i*j*(j+1)/2;
    }

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


Measured memory_bytes: 3604
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
def load_list(seplator=" ", vtype=int):
    return [vtype(v) for v in input().strip().split(seplator)]
def exit():
    import sys
    sys.exit(0)
def perm_sub(li, used):
    if len(li) == len(used):
        return [deque()]
    k = []
    for i in range(len(li)):
        if i in used:
            continue
        used.add(i)
        sub_list = perm_sub(li, used)
        for sub in sub_list:
            sub.appendleft(li[i])
        k.extend(sub_list)
        used.discard(i)
    return k
def perm_li(li):
    return perm_sub(li, set())
def perm_n(n):
    return perm_sub(list(range(n)), set())
def join_i(li, sep=""):
    return sep.join([str(e) for e in li])
def li2n(li):
    n, base = 0, 1
    for i in range(len(li)-1, -1, -1):
        n += li[i] * base
        base *= 10
    return n
def sli2ili(li):
    return [int(s) for s in li] 
def prime_list(n):
    li = [i for i in range(2, n+1)]
    for i in range(len(li)):
        if li[i] >= int(math.sqrt(n)):
            break
        if li[i] == -1:
            continue
        for j in range(i+1, len(li)):
            if li[j] % li[i] == 0:
                li[j] = -1
    return [n for n in li if n != -1]
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while True:
        r = a % b
        if r == 0: return b
        a, b = b, r
def lcm(a, b):
    return int(a * b / gcd(a,b))
def all_subset(li):
    s = []
    n = len(li)
    for bit in range(0, (1<<(n+1))):
        ss = set()
        for i in range(0, n):
            if (bit & (1 << i)):
                ss.add(li[i])
        s.append(ss)
    return s
def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
def mCn(m, n):
    def factorial_ntimes(m, n):
        r = 1
        while n:
            r *= m
            m -= 1
            n -= 1
        return r
    return int(factorial_ntimes(m, n) / factorial(n))

n = load()
A = load_list()

d = defaultdict(int)

for a in A:
    d[a] += 1

for i in range(1,n+1):
    print(d[i])


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

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

  int n; cin >> n;
  string s; cin >> s;

  int open = 0, close = 0, prepend = 0;
  rep(i, n) {
    if(s[i] == '(') {
      open++;
    } else {
      close++;
    }
    prepend = max(prepend, close - open);
  }

  rep(i, prepend) cout << '(';

  cout << s;

  rep(i, open + prepend - close) cout << ')';
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author hakamada
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC113_1 solver = new ABC113_1();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC113_1 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int X = in.nextInt();
            int Y = in.nextInt();
            out.println(X + (Y / 2));
        }

    }
}



Measured memory_bytes: 22612
import Control.Applicative
import Control.Monad
import Data.Functor
import Data.List

insertList :: (Ord a) => [a] -> a -> [a]
insertList [] a = [a]
insertList xxs@(x:xs) a
  | a < x = a : xxs
  | otherwise = x : insertList xs a


f xs = tail $ zipWith (++) (scanl insertList [] xs) (scanr (:) [] xs)

main = getLine >> map (read :: String -> Int) . words <$> getLine >>= putStr . unlines . map (unwords . map show) . f


Measured memory_bytes: 4096
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <unistd.h>

using namespace std;

typedef long long ll;

void maxHeapify(ll A[], int i, int len) {
	int l = i * 2;
	int r = i * 2 + 1;
	int largest;
	if (l <= len && A[l] > A[i]) {
		largest = l;
	}
	else {
		largest = i;
	}
	if (r <= len && A[r] > A[largest]) {
		largest = r;
	}

	if (largest != i) {
		swap(A[i], A[largest]);
		maxHeapify(A, largest, len);
	}
}

void buildMaxHeap(ll A[], int len) {
	for (int i = len / 2; i >= 1; --i)
		maxHeapify(A, i, len);
}

int main() {
	int n;
	cin >> n;
	ll *nodes = new ll[n+1];
	for (int i = 1; i <= n; ++i)
		cin >> nodes[i];
	buildMaxHeap(nodes, n);
	for (int i = 1; i <= n; ++i)
		cout << " " << nodes[i];
	cout << endl;
	delete[] nodes;
	return 0;
}

Measured memory_bytes: 4892
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
ll dp[90]={};

int main(){
  int n;
  cin >> n;
  rep(i,n+1){
    if(i==0)dp[i]=2;
    if(i==1)dp[i]=1;
    if(i>=2)dp[i]=dp[i-1]+dp[i-2];
  }
  cout << dp[n] << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <cassert>
#include <iterator>
using namespace std;
using VI = vector<long>;

long cnt[101010];
long sum = 0;

struct item {
    long a, i, is_target;
};

int main() {
    int n;
    cin >> n;
    vector<item> as;
    for (int i = 0; i < n; i++) {
        long a;
        cin >> a;
        sum += a;
        as.push_back({a, i + 1, 0});
    }
    sort(as.begin(), as.end(), [](auto a, auto b) { return a.a == b.a ? a.i < b.i : a.a > b.a; });
    long target_ind = as.front().i;
    as.front().is_target = 1;
    for (int i = 1; i < n; i++) {
        if (as[i].i < target_ind) {
            target_ind = as[i].i;
            as[i].is_target = 1;
        }
    }

    long used = 0;
    target_ind = as.front().i;
    int prev_i = 0;
    for (int i = 1; i < n; i++) {
        if (as[i].is_target) {
            long tmp = 0;
            tmp += (as.front().a - as[i].a) * prev_i;
            for (int j = prev_i; j < i; j++) {
                tmp += as[j].a - as[i].a;
                as.front().a = as[i].a;
            }
            prev_i = i;
            cnt[target_ind] = tmp;
            target_ind = as[i].i;
            used += tmp;
        }
    }
    
    cnt[target_ind] = sum - used;
    for (int i = 1; i <= n; i++) {
        cout << cnt[i] << endl;
    }
}


Measured memory_bytes: 4852
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y, ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        if(y%2==0)
         return (p*p)%z;
        else
        return (x*((p*p)%z))%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
ll po(ll x)
{
    ll c=0;
    while(x>0)
    {
        x=x&(x-1);
        c++;
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll n,m;
    cin>>n>>m;
    char a[n][m];
    for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
    cin>>a[i][j];}}
    for(int i=0;i<m+2;i++)
    cout<<"#";
    cout<<"\n";
    for(int i=0;i<n;i++)
    {
        cout<<"#";
        for(int j=0;j<m;j++)
        cout<<a[i][j];
        cout<<"#";
        cout<<"\n";
    }
    for(int i=0;i<m+2;i++)
    cout<<"#";}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace ConsoleApp9
{   
    class Program
    {
        public static void Main(string[] args) {
            while (true)
            {
                string[] sss = Console.ReadLine().Split(' ');
                int a = int.Parse(sss[0]); int b = int.Parse(sss[1]);
                if (a == 0 && b == 0) { break; }
                for (int c = 1; c <= a; c++)
                {
                    for (int d = 1; d <= b; d++)
                    {
                        if (c == 1 || c == a || d == 1 || d == b)
                        {
                            Console.Write("#");
                        }
                        else { Console.Write("."); }
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 8984
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
#define Mod 1e9+7
vector<string> Data;
ll dp[1001][1001];
ll recurse(ll row,ll col,ll n,ll m){
    if(row==n&&col==m){
        return 1;
    }
    if(dp[row][col]!=-1)
        return dp[row][col];
    ll ans = 0;
    if(row+1<=n&&Data[row][col-1]=='.')
        ans = (ans+recurse(row + 1, col, n, m))%1000000007;
     if(col+1<=m&&Data[row-1][col]=='.')
         ans = (ans+recurse(row, col + 1, n, m))%1000000007;
     return dp[row][col] = ans;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, i, j, k, l, m;
    cin >> n >> m;
    memset(dp, -1, sizeof(dp));
    for (i = 1; i <= n;i++){
        string s;
        cin >> s;
        Data.pb(s);
    }
    cout << recurse(1, 1, n, m) << "\n";
    return 0;
}

Measured memory_bytes: 9216
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

void precalc() {
}

const int maxn = (int) 1e5 + 10;
int n, m, k;

int ps[maxn][3];
long long mn[maxn];

vector<pair<int, int> >  qs[maxn];

int read() {
  if (scanf("%d%d%d", &n, &m, &k) < 3) {
    return 0;
  }
  for (int i = 0; i < m; ++i) {
    mn[i] = 1e18;
  }
  for (int i = 0; i < n; ++i) {
    qs[i].clear();
  }
  for (int i = 0; i < k; ++i) {
    scanf("%d%d%d", ps[i], ps[i] + 1, ps[i] + 2);
    --ps[i][0], --ps[i][1];
    qs[ps[i][0]].pb(mp(ps[i][1], ps[i][2]));
    mn[ps[i][1]] = min(mn[ps[i][1]], (long long) ps[i][2]);
  }
  return 1;
}

long long val[maxn];

vector<vector<int> > es, cs;
int used[maxn];


long long minadd;
long long minzero;

int dfs(int v) {
  used[v] = 1;
  minadd = min(minadd, val[v]);
  minzero = min(minzero, mn[v] - val[v]);

  for (int it = 0; it < sz(es[v]); ++it) {
    int u = es[v][it];
    long long nval = val[v] + cs[v][it];
    if (used[u]) {
      if (val[u] != nval) {
        return 1;
      }
      continue;
    }
    val[u] = nval;
    if (dfs(u)) {
      return 1;
    }
  }
  return 0;
}

void solve() {
  es = cs = vector<vector<int> >(m);
  for (int i = 0; i < n; ++i) {
    for (int j = 1; j < sz(qs[i]); ++j) {
      int s = qs[i][0].first, t = qs[i][j].first;
      int diff = qs[i][j].second - qs[i][0].second;
      es[s].pb(t), cs[s].pb(diff);
      es[t].pb(s), cs[t].pb(-diff);
    }
  }
  for (int i = 0; i < m; ++i) {
    used[i] = 0;
  }

  for (int i = 0; i < m; ++i) {
    if (used[i]) {
      continue;
    }
    minzero = minadd = 1e18;
    val[i] = 0;
    if (dfs(i) || (minzero + minadd < 0)) {
      printf("No\n");
      return;
    }
  }
  printf("Yes\n");
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 16640