akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
   int n;
   pair<pair<string, int>, int> p[110];
   cin >> n;
   imfor(i, n) {
      string name;
      int score;
      cin >> name >> score;
      p[i] = make_pair(make_pair(name, -score), i + 1);
   }
   sort(p, p + n);
   imfor(i, n) {
      cout << p[i].second << endl;
   }
   
}

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

namespace AtCoder05
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] z = Console.ReadLine().Split(' ');
            double a = double.Parse(z[0]);
            double b = double.Parse(z[1]);
            Console.WriteLine(a/b);
        }
    }
}

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

using namespace std;


int main() {
	int N;
	cin >> N;
	vector<int>D( N );
	for( size_t i = 0; i < N; i++ ) {
		cin >> D[i];
	}
	double maxans = 1, minans = 0;
	for( size_t idx = 0; idx < 1000; idx++ ) {
		double midans = ( maxans + minans ) / 2;
		set<int>prev;
		prev.insert( 1 );
		for( size_t i = 0; i < N; i++ ) {
			double minvalue = D[i] * ( 1. - midans );
			double maxvalue = D[i] * ( 1. + midans );
			//cout << fixed << setprecision( 20 ) << minvalue << " " << maxvalue << endl;
			set<int>next;
			for( auto one : prev ) {
				for( int j = minvalue / one + 1; j <= maxvalue / one; j++ ) {
					next.insert( j*one );
				}
			}
			prev = next;
		}
		if( prev.size() ) {
			maxans = midans;
		} else {
			minans = midans;
		}

	}
	cout << fixed << setprecision( 20 ) << minans << endl;
}

Measured memory_bytes: 10772
# AOJ 1018: Cheating on ICPC
# Python3 2018.7.4 bal4u

while True:
	try: n = int(input())
	except: break
	p = sorted(list(map(int, input().split())))
	ans, k = 0, n
	for x in p:
		ans += x*k
		k -= 1
	print(ans)



Measured memory_bytes: 5616
# include <cstdio>
int N ;
int main()
{
scanf ("%d " ,& N );
int res = N ;
for ( int i =0; i <= N ; i ++)
{
int cc =0;
int t = i ;
while (t >0) cc += t %6 , t /=6;
t=N - i ;
while (t >0) cc += t %9 , t /=9;
if ( res > cc ) res = cc ;
}
printf ("%d \n " , res );
}


Measured memory_bytes: 128
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    a,b,k = map(int,input().split())
    if k<a:
        print((a-k),b)
    else:
        k -= a
        if k<b:
            print('0',(b-k))
        else:
            print('0 0')
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 38636
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll N = 1e9+7;


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

	ll t = 1;
	// cin>>t;

	while(t--){
		ll n;
		cin>>n;

		map<pair<ll,ll>,ll>m;
		double a;
		for(ll i=0;i<n;++i){
			cin>>a;
			ll x = llround(a * 1e9);

			ll two = 0, five = 0;
			while(x % 2 == 0){
				++two;
				x /= 2;
			}
			while(x % 5 == 0){
				++five;
				x /= 5;
			}

			m[{two,five}]++;

		}

		ll ans = 0;
		for(auto &x : m){
			for(auto &y : m){
				if(x.first.first + y.first.first >= 18 and x.first.second + y.first.second >= 18){
					if(x == y) ans += x.second * ( x.second -1 ) / 2;
					else if(x < y) ans += x.second * y.second;
				}
			}
		}

		cout<<ans<<"\n";

	}

	return 0;

}


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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define float			double
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vc				vector<char>
#define vb				vector<bool>
#define vf				vector<float>
#define vs				vector<string>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define hashmap         unordered_map
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT64_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

template<class T>
void printV(vector<T> a) {for (auto v : a)cout << v << " ";}
template<class T>
void readV(vector<T>& a) {int n = a.size(); for (int i = 0 ; i < n ; i++)cin >> a[i];}
template<class T>
void printA(T* a , int n) {for (int i = 0; i < n  ; i++)cout << a[i] << " ";}
template<class T>
void readA(T* a , int n) {for (int i = 0 ; i < n ; i++)cin >> a[i];}
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
void run_time() {cout << endl<<"Time elapsed: " << (double)(clock() - clk) / CLOCKS_PER_SEC << endl;}

void aryan_pandeya() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


int32_t main() {
	aryan_pandeya();
	FIO;

	int n , q ;
	cin>>n>>q;

	int x = 0 , y = 0 ;
	
	bool a[n+1];
	for(int i = 0 ; i<=n ; i++){
		a[i] = 0 ;
	}
	int b[n+1];
	for(int i = 0; i<=n ; i++){
		b[i] = 0;
	}
	while(q--){
		int v;
		string s ; 
		cin>>v>>s;

		if(a[v]){
			continue;
		}
		else{
			if(s=="AC"){
				x++;
				a[v] = 1;
				y+=b[v];
			}
			else{
				b[v]++;
			}
		}
	}

	cout<<x<<" "<<y;
	
	return 0;
}


Measured memory_bytes: 4448
#include<stdio.h>
#include<math.h>
 
int main(void)
{
    int n;
    int i;
    int x[100];
    int y[100];
    int z[100];
    double L_1 = 0, L_2 = 0, L_3 = 0, L_inf;
     
    scanf("%d\n", &n);
    for(i = 0; i<n; i++)
        scanf("%d", &x[i]);
    for(i = 0; i<n; i++)
        scanf("%d", &y[i]);
    for(i = 0; i<n; i++) {
        z[i] = (x[i] - y[i]>0)? x[i] - y[i]: y[i] - x[i];
        if(i == 0) L_inf = z[0];
        else {
            if(z[i] > L_inf) L_inf = z[i];
        }
    }
     
    for(i=0; i<n; i++) {
        L_1 += z[i];
        L_2 += z[i] * z[i];
        L_3 += z[i] * z[i] * z[i];
    }
     
    L_2=pow(L_2, 1.0/2);
    L_3=pow(L_3, 1.0/3);
     
    printf("%f\n%f\n%f\n%f\n", L_1, L_2, L_3, L_inf);
     
    return 0;
}


Measured memory_bytes: 2056
using System;

class Program
{
    static void Main(string[] args)
    {
        var inp = Console.ReadLine().Split(' ');
      	var inp2 = Console.ReadLine().Split(' ');	

        int days = int.Parse(inp[0]);
        int homeworks = int.Parse(inp[1]);
		int count = 0;
      	
      	while(homeworks != 0)
        {
      	  	days -= int.Parse(inp2[count]);
            count++;
          	homeworks--;
        }
		
        if (days < 0) days = -1;

        Console.WriteLine(days.ToString());
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 21;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 62;

ll n;
vector<vl> ans;

int main(){
  cin >> n;
  if(n%2 == 0){
    for(ll i = 1;i <= n;i++){
      for(ll j = i+1;j <= n;j++){
        if(i+j-1 == n) continue;
        ans.push_back(vl({i,j}));
      }
    }
  }else{
    for(ll i = 1;i <= n;i++){
      for(ll j = i+1;j <= n;j++){
        if(i+j == n) continue;
        ans.push_back(vl({i,j}));
      }
    }
  }
  cout << ans.size() << endl;
  for(ll i = 0;i < ans.size();i++) cout << ans[i][0] << " " << ans[i][1] << endl;
}


Measured memory_bytes: 640
A,B,K = (int(x) for x in input().split())

while K != 0:
    if A % 2 !=0:
        A -= 1
    A = A/2
    B += A
    K -= 1

    if K ==0:
        break
    if B % 2 !=0:
        B -= 1
    B = B/2
    A += B
    K -= 1

A = int(A)
B = int(B)
print(A,B)

Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
using namespace std;

int main(){
    unsigned long long int savings = 100;
    unsigned long long int goalSavings;
    cin >> goalSavings;
    unsigned year=1;
    while(true){
        savings = floor(savings + savings * 0.01);
        if(savings >= goalSavings){
            cout << year << endl;
            break;
        }
        year++;
    }
    
    return 0;
}

Measured memory_bytes: 3236
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


ll mod_pow(ll a,ll x){
    ll ret=1;
    while(x>0){
        if(x&1){(ret*=a)%=MOD;}
        (a*=a)%=MOD;
        x>>=1;
    }
    return ret;
}


int main(){
    const ll inv=(1+MOD)/2;
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vector<ll> dp(n+1,0);
    dp[0]=1;
    for(int i=0;i<n;i++){
        vector<ll> next(n+1,0);
        for(int t=0;t<=n;t++){
            if(t!=0){next[t-1]+=dp[t]; next[t-1]%=MOD;}
            else{next[t]+=dp[t]; next[t]%=MOD;}
            if(t!=n){next[t+1]+=dp[t]*2; next[t+1]%=MOD;}
        }
        dp=next;
    }
    cout<<dp[s.size()]*mod_pow(inv,s.size())%MOD<<endl;
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define inf 1e18+5
#define mod 1000000007
#define MAXN 100005
#define ll long long
#define pb push_back
#define sortv(v) sort(v.begin(),v.end())
#define tc(t) int t;cin>>t;while(t--)
#define copy copy_n
#define fr(i,a,b) for(long long i=a;i<b;i++)
#define frr(i,a,b) for(long long i=a;i>=b;i--)
#define frn(i,a,b,n) for(long long i=a;i<=b;i=i+n)
#define gcd(x,y) __gcd(x,y)
#define ld long double
#define um unordered_map
#define mkp make_pair
#define b_s binary_search
#define nob __builtin_popcount
#define des greater<ll>()
#define fi first
#define se second
ll mul(ll a, ll b, ll p = mod) {return ((a % p) * (b % p)) % p;}
ll add(ll a, ll b, ll p = mod) {return (a % p + b % p) % p;}
void input(ll a[], ll sz) {fr(i, 0, sz) cin >> a[i];}
void print(ll a[], ll sz) {fr(i, 0, sz) {if (i == sz - 1) cout << a[i] << "\n"; else cout << a[i] << " ";}}
ll maxr(ll a[], ll sz) {ll ma; fr(i, 0, sz) {if (i == 0) ma = a[i]; else if (a[i] > ma) ma = a[i];} return ma;}
ll minr(ll a[], ll sz) {ll mi; fr(i, 0, sz) {if (i == 0) mi = a[i]; else if (a[i] < mi) mi = a[i];} return mi;}
ll isprm(ll n) {
    if (n <= 1)  return 0;
    if (n <= 3)  return 1;
    if (n % 2 == 0 || n % 3 == 0) return 0;

    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return 0;
    return 1;
}
/*ll spf[MAXN];
void sieve()
{
    spf[1]=1;
    for (ll i=2; i<MAXN; i++)
        spf[i] = i;
    for (ll i=4; i<MAXN; i+=2)
        spf[i] = 2;

    for(ll i=3;i*i<MAXN;i+=2)
    {
        if (spf[i]==i)
        {
            for (int j=i*i;j<MAXN;j+=i)
                if (spf[j]==j)
                    spf[j]=i;
        }
    }
}*/
ll power(ll x, ll y, ll p = mod)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p = mod)
{
    return power(n, p - 2, p);
}

ll fac[100005];

ll ncrMod(ll n, ll r, ll p = mod)
{
    if (r == 0)
        return 1;
    return (fac[n] * modInverse(fac[r], p) % p *
            modInverse(fac[n - r], p) % p) % p;
}
//a+b=xor(a,b)+2*(a&b)//
struct comp
{
    bool operator()(const pair<ll, ll> &a,
                    const pair<ll, ll> &b)const
    {
        if (a.fi == b.fi)
        {
            return (a.se > b.se); //second elem in descending
        }
        return (a.first < b.first);//first elem in ascending
    }
};




int main()
{
    fio;
    fac[0]=1;
    for (ll i = 1 ; i <100000; i++)
        fac[i] = fac[i - 1] * i % mod;
    ll s;
    cin>>s;
    ll q=s/3,ans=0;
    fr(i,1,q+1)
    {
        ll r=s-(3*i);
        ans=add(ans,ncrMod(r+i-1,i-1));
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 4436
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N,K,C;
    cin >> N >> K >> C;
    string S;
    cin >> S;
    vector<int> saki_bataraki(K);
    vector<int> ato_bataraki(K);
    int count = C;
    int next = 0;
    rep(i,N){
        if (next == K){
            break;
        }
        else if (count < C || S[i] == 'x'){
            count++;
        }
        else{
            saki_bataraki[next] = i;
            count = 0;
            next++;
        }
    }
    count = C;
    next = K - 1;
    for (int i = N - 1; i >= 0; i--){
        if (next == -1){
            break;
        }
        else if (count < C || S[i] == 'x'){
            count++;
        }
        else{
            ato_bataraki[next] = i;
            count = 0;
            next--;
        }
    }
    vector<int> ans(0);
    rep(i,K){
        if (saki_bataraki[i] == ato_bataraki[i]){
            ans.push_back(saki_bataraki[i] + 1);
        }
    }
    rep(i, ans.size()) cout << ans[i] << endl;
}

Measured memory_bytes: 5924
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

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

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//MIN

bool p_judge(ll p) {

	if (p == 1)return false;
	else if (p == 2)return true;
	else {

		bool flag = true;
		for (int i = 2; i <= sqrt(p); i++) {

			if (p%i == 0) {

				flag = false;
				break;

			}

		}
		return flag;

	}

}
//素数判定,素数=true,合成数=false

int main() {

	int A, B, X;

	cin >> A >> B >> X;

	if (A <= X&&X <= A + B)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
s=input()

children=[0]*len(s)
num_R=0
num_L=0
for i in range(len(s)-1):
    if s[i]=='R':
        num_R+=1
        if s[i+1]=='R':
            continue
        elif s[i+1]=='L':
            R_id=i
            L_id=i+1
            if num_R%2==0:
                children[R_id]+=num_R//2
                children[L_id]+=num_R//2
            else:
                children[R_id]+=num_R//2 + 1
                children[L_id]+=num_R//2
    elif s[i]=='L':
        num_L+=1
        if s[i+1]=='L':
            continue
        elif s[i+1]=='R':
            if num_L%2==0:
                children[R_id]+=num_L//2
                children[L_id]+=num_L//2
            else:
                children[R_id]+=num_L//2
                children[L_id]+=num_L//2 + 1
            num_R=0
            num_L=0

num_L+=1
if num_L%2==0:
    children[R_id]+=num_L//2
    children[L_id]+=num_L//2
else:
    children[R_id]+=num_L//2
    children[L_id]+=num_L//2 + 1

print(*children)


Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iterator>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;

#define rep(i, n, m) for (int i = n; i <= m; i++)
#define Rep(i, n, m) for (int i = m; i >= 1; i--)

typedef long long ll;

int main() {
    string a;
    cin >> a;
    if (a[0] == 'A') cout << "T" << endl;
    if (a[0] == 'C') cout << "G" << endl;
    if (a[0] == 'G') cout << "C" << endl;
    if (a[0] == 'T') cout << "A" << endl;
}

Measured memory_bytes: 256
from collections import deque
import bisect
N = int(input())
A = []

for i in range(N):
    A.append(int(input()))

l = deque([])

for i in range(N):
    if l == []:
        l.append(A[i])
    else:
        index = bisect.bisect_right(l, A[i])
        index2 = bisect.bisect_left(l, A[i])
        if index == 0:
            l.appendleft(A[i])
        elif index != index2:
            if index2 == 0:
                l.appendleft(A[i])
            else:
                l[index2-1] = A[i]
        else:
            l[index-1] = A[i]

print(len(l))

Measured memory_bytes: 56164
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    using namespace std;
    using Graph = vector<vector<int>>;

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    const int dx[4] = {1,0,-1,0};
    const int dy[4] = {0,1,0,-1};
    
    
    
    int main(){
      int n;
      cin>>n;
      VEC(int,h,n);
      int mx = 0;
      int cnt = 0;
      rep(i,n-1){
        if(h[i]>=h[i+1])cnt++;
        else {
          mx = max(mx,cnt);
          cnt = 0;
          continue;
        }
      }
      mx = max(cnt,mx);
      cout <<mx;
    }

      
      

     
    

    

     

Measured memory_bytes: 640
def main(n,k,a):
  for _ in range(k):
    b=[0]*(n+1)
    x=0
    for i,j in enumerate(a):
      b[max(0,i-j)]+=1
      b[min(n,i+j+1)]-=1
    for i in range(n):
      b[i+1]+=b[i]
      if b[i]==n:
        x+=1
    a=b
    if x==n:
      break
  return a
N,K,*A=map(int,open(0).read().split())
r=main(N,K,A)
print(*r[:-1])

Measured memory_bytes: 129348
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int f[10010];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=100;i++)
	{ 
		for(int j=1;j<=100;j++)
		{
			for(int k=1;k<=100;k++)
			{
				long long sum=i*i+j*j+k*k+i*j+i*k+j*k;
				if(sum<=n)
					f[(int)sum]++;
			}
		}
	}
	for(int i=1;i<=n;i++)
		printf("%d\n",f[i]);
	return 0;
}

Measured memory_bytes: 3748
function main(input){
  var line1 = parse(input[0]);
  var n = line1[0];
  var m = line1[1];
  var x = line1[2];
  var line2 = parse(input[1]);
  
  var costN = line2.filter((a) => a>x).length;
  console.log(Math.min(costN, m-costN));
}

function parse(line){
  var ret = [];
  var arr = line.split(' ');
  for (var i = 0; i < arr.length; i++) {
    ret.push(parseInt(arr[i]));
  }
  return ret;
}

var
input = '';

process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  input += chunk;
});
process.stdin.on('end', function() {
  input = input.split('\n');
  main(input);
});


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

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


int main()
{
    vector<int> n(3);
    bool ok = false;
    for(int i = 0; i < 3; i++)
    {
        cin>>n[i];
    }
    
    for(int i = 0; i < 3; i++)
    {
        if(n[i%3] == n[(i+1)%3] + n[(i+2)%3])
        {
            ok = true;
        }
    }
    
    if(ok) cout << "Yes"<<endl;
    else cout <<"No" <<endl; 
 
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int flag;

int solve(int table[16], int cur_index) {
	int table_cp[16];

	if(cur_index == 10)
		return 1;

	memcpy(table_cp, table, sizeof(int) * 16);
	switch(table[cur_index]) {
		case 0:
			return solve(table_cp, ++cur_index);

		case 1:
			if(table_cp[cur_index + 1] && table_cp[cur_index + 2]) {
				table_cp[cur_index]--; table_cp[cur_index + 1]--; table_cp[cur_index + 2]--;
				if(solve(table_cp, ++cur_index))
					return 1;
			}

			return 0;

		case 2:
			if(table_cp[cur_index + 1] > 1 && table_cp[cur_index + 2] > 1) {
				table_cp[cur_index] -= 2; table_cp[cur_index + 1] -= 2; table_cp[cur_index + 2] -= 2;
				if(solve(table_cp, ++cur_index))
					return 1;
				cur_index--;
				memcpy(table_cp, table, sizeof(int) * 16);
			}

			if(!flag) {
				flag = 1;
				table_cp[cur_index] -= 2;
				if(solve(table_cp, ++cur_index))
					return 1;
				flag = 0;
			}

			return 0;

		case 3:
			table_cp[cur_index] -= 3;
			if(solve(table_cp, ++cur_index))
				return 1;
			memcpy(table_cp, table, sizeof(int) * 16);
			cur_index--;

			if(table_cp[cur_index + 1] && table_cp[cur_index + 2] && !flag) {
				flag = 1;
				table_cp[cur_index] -= 3; table_cp[cur_index + 1]--; table_cp[cur_index + 2]--;
				if(solve(table_cp, ++cur_index))
					return 1;
				memcpy(table_cp, table, sizeof(int) * 16);
				flag = 0;
			}	

			return 0;

		case 4:
			if(table_cp[cur_index + 1] > 1 && table_cp[cur_index + 2] > 1 && !flag) {
				flag = 1;
				table_cp[cur_index] -= 4; table_cp[cur_index + 1] -= 2; table_cp[cur_index + 2] -= 2;
				if(solve(table_cp, ++cur_index))
					return 1;
				memcpy(table_cp, table, sizeof(int) * 16);
				cur_index--;
				flag = 0;
			}

			if(table_cp[cur_index + 1] && table_cp[cur_index + 2]) {
				table_cp[cur_index] -= 4; table_cp[cur_index + 1]--; table_cp[cur_index + 2]--;
				if(solve(table_cp, ++cur_index))
					return 1;
				memcpy(table_cp, table, sizeof(int) * 16);
			}

			return 0;

		default:
			fprintf(stderr, "ERROR\n");
			exit(1);

	}
}

int main(void) {
	int table_cp[16];
	char input[16];
	int table[16];
	int flag_;
	int i;

	while(scanf("%s", input) != EOF) {
		flag_ = 0;
		memset(table, 0, sizeof(table));
		for(i = 0; input[i]; i++)
			table[input[i] - '0']++;
		memcpy(table_cp, table, sizeof(table));

		for(i = 1; i < 10; i++) {
			table_cp[i]++;
			if(table_cp[i] > 4) {
				memcpy(table_cp, table, sizeof(table));
				continue;
			}
			flag = 0;
			if(solve(table_cp, 0)) {
				if(flag_)
					printf(" %d", i);
				else {
					printf("%d", i);
					flag_ = 1;
				}
			}
			memcpy(table_cp, table, sizeof(table));
		}

		if(!flag_)
			putchar('0');
		putchar('\n');
	}

	return 0;
}

Measured memory_bytes: 544
#include <iostream>

using namespace std;

int dist(int x, int y, int a, int b){
	int res = 0;
	res += x>a ? x-a : a-x;
	res += y>b ? y-b : b-y;

	return res;
}


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

	int x = 0;
	int y = 0;
	int t = 0;

	for(int i=0;i<n;i++){
		int ti, xi, yi;
		cin >> ti >> xi >> yi;

		int d = dist(x,y,xi,yi);

		if(d > ti-t || (d-ti+t)%2){
			cout << "No" << endl;
			return 0;
		}
	
	}
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstring>
#include <string>
#include <bitset>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <assert.h>
using namespace std;
#define e exp(1.0)
typedef long long ll;
#define MAXN 55
#define mod 998244353
#define INF 0x3f3f3f3f3f3f3f
#define fe(i,st,en) for(i = (st);i <= (en);++i)
#define fne(i,st,en) for(i = (st);i < (en);++i)
#define ri register int
#define db double
int v[MAXN], a[MAXN];
priority_queue<int, vector<int>, greater<int> > q;
int main() {
	int n, K;
	cin >> n >> K;
	ri i, j, k;
	fe(i, 1, n) cin >> v[i];
	int ans = 0;
	fe(i, 0, min(n, K)) {
		fe(j, 0, min(n - i, K - i)) {
			int s = 0;
			for (k = 1; k <= i; ++k) {
				if (v[k] < 0)q.push(v[k]);
				s += v[k];
			}
			for (k = n; k > n - j; --k) {
				if (v[k] < 0)q.push(v[k]);
				s += v[k];
			}
			k = K - i - j;
			while (k-- && !q.empty()) {
				s -= q.top();
				q.pop();
			}
			ans = max(ans, s);
			while (!q.empty()) q.pop();
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int gcd(int a,int b) { return b ? gcd(b,a%b) : a;}
int lcm(int a,int b) { return a/gcd(a,b)*b;}
void printb(unsigned int v) {
  unsigned int mask = (int)1 << (sizeof(v) * CHAR_BIT - 1);
  do putchar(mask & v ? '1' : '0');
  while (mask >>= 1);
}
void putb(unsigned int v) {putchar('0'), putchar('b'), printb(v), putchar('\n');}
#define ALL(W) (W).begin(),(W).end()

int M,D,ans=0;

signed main(){
  cin >> M >> D;
  for(int i=1;i<=M;i++){
    for(int j=1;j<=D;j++){
      if(j%10>=2 && (j-j%10)/10>=2){
        if((j%10)*(j-j%10)/10==i){
          //cout << i << " " << j << endl;
          ans++;
        }
      }
    }
  }
  cout << ans << endl;


  return 0;
}


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

namespace ABC_D
{
    class D048
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n = s.Length;
            string r;
            if(s.First()==s.Last())
            {
                if (n % 2 == 1) r = "Second"; else r = "First";
            }
            else
            {
                if (n % 2 == 0) r = "Second"; else r = "First";
            }
            Console.WriteLine(r);
        }

    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define ll long long
 
	
 
 
int main(){
    while(1){
        int n;
        cin >> n;
        if(n==0) break;
        vector<char> c(n);
        for(int i=0;i<n;i++){
            cin >> c[i];
        }
        //1位―2位が残り票以上になれば終了
        map<char,int> mp;
        char fir,sec = 'a';
        for(int i=0;i<n;i++){
            if(mp[c[i]]==0){
                mp[c[i]]=1;
            }else{
                mp[c[i]]+=1;
            }
            if(i==0) fir = c[i];
            if(sec=='a'&&fir!=c[i]) sec = c[i];
            if(mp[c[i]]>mp[fir]){
                sec = fir; fir=c[i];
            }
            if(c[i]!=fir&&mp[c[i]]>mp[sec]){
                sec = c[i];
            }
            if(mp[fir]-mp[sec]>n-i-1){
                cout << fir << " " << i+1 << endl;
                break;
            }
            if(i==n-1){
                cout << "TIE" << endl;
            }

        }

        
    }
}




Measured memory_bytes: 3008
/*
h s, d't skp th si tll i's sved
 * ABC141 E
 * ABC145 D
 * ABC147 F
*/
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
ll n,d;
cin>>n>>d;
ll ans=0;
ll a,b;
for(ll i=0;i<n;i++)
{
cin>>a>>b;
long double k=(long double)sqrt(a*a+b*b);
if(k<=d)
{
ans++;
}
}
cout<<ans<<endl;
}




/*
 * ||||


 */

Measured memory_bytes: 3672
n, m = map(int, input().split())
ps = [list(input().split()) for _ in range(m)]
wa = [0] * n
ac = [0] * n

for p, s in ps:
  p = int(p) - 1
  if s == "AC":
    ac[p] = 1
  else:
    if ac[p] == 0:
      wa[p] += 1
wasum = 0
for i, j in zip(ac, wa):
  if i > 0:
    wasum += j
print(sum(ac), wasum)

Measured memory_bytes: 27444
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    A = list(map(int, lines.pop(0).split(' ')))
    c = 0
    for i, x in enumerate(A):
        if ( i + 1 != x ):
            c += 1

    if ( c <= 2 ):
        print('YES')
    else:
        print('NO')

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int a[1000000];
int ret[1000000];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    vector<int> vec;
    for (int i=1;i<=n;i++)cin>>a[i];
    for (int i=n;i>=1;i--) {
        int sum = 0;
        for (int j=i;j<=n;j+=i)sum+=ret[j];
        if ((sum%2)!=a[i]){
            ret[i]=1;
            vec.push_back(i);
        }
    }
    for (int i=1;i<=n;i++) {
        int sum = 0;
        for (int j=i;j<=n;j+=i)sum+=ret[j];
        if ((sum%2)!=a[i]) {
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<vec.size()<<endl;
    for (auto x:vec)cout<<x<<' ';

}

Measured memory_bytes: 6392
#include<stdio.h>

int main() {
  int i, j, k, n, a[1000], v;

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &a[i]);
  }
  for(i = 1; i < n; i++){
    for(k = 0; k < n; k++){
      printf("%d",a[k]);
      if(k != n - 1) printf(" ");
      else printf("\n");
    }
    v = a[i];
    j = i - 1;
      while(j >= 0 && a[j] > v){
	a[j+1] = a[j];
	j--;
      }
    a[j+1] = v;
    
  }
  for(k = 0; k < n; k++){
      printf("%d",a[k]);
      if(k != n - 1) printf(" ");
      else printf("\n");
    }
  return 0;
}



Measured memory_bytes: 2072
// Gaurav Aggarwal
 
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii > vii;
typedef vector<pll > vll;
#define pb push_back
#define mp make_pair 
#define mod 1000000007
#define F first
#define S second
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define For(i, a, b) for(__typeof (a) i=a; i<=b; i++)
#define inp_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
 
ll power(ll x, ll y) 
{ 
    ll res = 1;   
    while (y > 0) { 
        if (y & 1) 
            res = (res*x)%mod; 
        y = y>>1;
        x = (x*x)%mod;
    } 
    return res%mod; 
}

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

    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("out.txt", "w", stdout); 
    // #endif  

    int n;
    int q;
    cin>>n>>q;

    vector<int> graph[n];
    for(int i=0;i<n-1;++i) {
        int a,b;
        cin>>a>>b;
        graph[a-1].pb(b-1);
    }

    int size[n] = {0};

    while(q--) {
        int x,p;
        cin>>x>>p;
        size[x-1] += p;
    }

    queue<int> qq;
    qq.push(0);

    int visited[n] = {0};
    visited[0] = 1;
    while(!qq.empty()) {
        int s = qq.front();
        qq.pop();

        for(int i: graph[s]) {
            if(visited[i] == 0) {
                visited[i] = 1;
                qq.push(i);
                size[i] += size[s];
            }
        }
    }

    debug_arr(size,n);

    return 0;
}

Measured memory_bytes: 14976
X = int(input())

def is_Prime(x):
  for i in range(2, x+1):
    if i * i + 1 > x:
      return True
    if x % i == 0:
      return False

for i in range(X, 2*X+1):
  if is_Prime(i):
    print(i)
    break


Measured memory_bytes: 9168
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main()
{
  string S;
  cin >> S;
  int N = S.size(), red = 0, blue = 0;

  rep(i, N) {
    if (S[i] == '0') ++red;
    else ++blue;
  }

  cout << min(red, blue) * 2 << endl;
}


Measured memory_bytes: 512
// -> limitless <- //
#include<iostream>
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define PB push_back
#define MP make_pair
#define f(i, x, n) for (int i = x; i < (int)(n); ++i)
#define lp(i, n) for (int i = 0; i < (int)(n); ++i)
#define read(n) scanf ("%d", &n)
using namespace std;
typedef unsigned long long ll;
    const int N = 1e5 + 2;
    const int mod = 1e9 + 7;

int main()
{
    int n, t;
    read(n), read(t);
    int ans = 1;
    pair<int, int> p[N];
    lp(i, t){scanf("%d%d", &p[i].first, &p[i].second);}
    sort(p, p+t);
    int last = p[t-1].first;
    for(int i = t-2; i >= 0; i--){
        if( p[i].second > last)continue;
        ans++;
        last = p[i].first;
    }
    printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1152
n=int(input())
check=False;
i=1
while i<10:
    j=1
    while j<10:
        if (i*j==n):
            print('Yes')
            check=True
            break;
        j+=1;
    if check:
        break
    i+=1
 
 
if not check:
    print("No")

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int gcd(int a,int b) {

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

int main() {
	int num;
	int sum=0;
	cin >> num;

	for (int i = 1; i < num + 1; i++) {

		for (int j = 1; j < num + 1; j++) {

			for (int k = 1; k < num + 1; k++) {
				sum += gcd(gcd(i,j),k);
			}
		}
	}
	cout << sum<<endl;

	return 0;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov

int main(){
    string s;
    cin >> s;
    if(s[1]=='B') cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

struct Edge{
    int to, cap, rev;
    Edge() = default;
    Edge(int to, int cap, int rev) : to(to), cap(cap), rev(rev) {}
};

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

    int V, E;
    cin >> V >> E;
    vector<vector<Edge>> graph(V);
    for(int i = 0; i < E; ++i){
        int u, v, c;
        cin >> u >> v >> c;
        graph[u].emplace_back(v, c, graph[v].size());
        graph[v].emplace_back(u, 0, (int)graph[u].size() - 1);
    }

    vector<bool> visited(V);
    auto dfs = [&](auto&& self, int s, int t, int flow) -> int {
        if(s == t)  return flow;
        visited[s] = true;
        for(auto& e : graph[s]){
            if(!visited[e.to] && e.cap > 0){
                int f = self(self, e.to, t, min(e.cap, flow));
                if(f > 0){
                    e.cap -= f;
                    graph[e.to][e.rev].cap += f;
                    return f;
                }
            }
        }
        return 0;
    };
    auto max_flow = [&](int s, int t){
        int res = 0;
        for(;;){
            for(int i = 0; i < V; ++i)  visited[i] = false;
            int f = dfs(dfs, s, t, INF);
            if(f <= 0)  break;
            res += f;
        }
        return res;
    };

    cout << max_flow(0, V - 1) << endl;
}


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

int main(){
	for(int i=0; i<9; i++){
		for(int j=0; j<9; j++){
			cout << i+1 << "x" << j+1 << "=" << (i+1)*(j+1) << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1116
/*input
20 3
5 15 20
*/
#include "bits/stdc++.h"
#define pb push_back
#define ll long long
using namespace std;
#define N 400005
#define int long long


signed main()
{
	int k, n;
	cin>> k>> n;

	vector<int> A(n), pre(n), post(n);
	for(int i=0;i<n; i++) cin>> A[i];

	int round = k - A[n-1];// + A[0];

	int ans = 0;
	pre[0] = round + A[0];
	for(int i=1;i<n;i++) { ans+=A[i]- A[i-1];
		pre[i] = pre[i-1] + A[i] - A[i-1];}

	post[n-1] = 0;
	for(int i=n-2;i>=0;i--) {
		post[i] = post[i+1] + A[i+1] - A[i];
	}

	for(int i=1;i<n;i++) {
		ans = min(ans, pre[i-1] + post[i]);
	}
	cout<<ans<<endl;


}

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<vector<char>> grid(h+2, vector<char>(w+2, '.'));
    rep(i,h)rep(j,w) cin >> grid[i+1][j+1];
    for(int i = 1; i <= h; ++i){
        for(int j = 1; j <= w; ++j){
            if(grid[i][j] == '#'){
                cout << "#";
                continue;
            }
            int cnt = 0;
            rep(k,8){
                int ny = i + dy[k];
                int nx = j + dx[k];
                if(grid[ny][nx] == '#') ++cnt;
            }
            cout << cnt;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

d = {}
for ai in a:
    if ai in d:
        d[ai] += 1
    else:
        d[ai] = 1

s0 = sum([d[k] * (d[k] - 1) // 2 for k in d.keys()])

def c2(i):
    if i == 1:
        return 0
    else:
        return i * (i-1) // 2


for i in range(n):
    v = d[a[i]]
    print(s0 - c2(v) + c2(v-1))


Measured memory_bytes: 92364
h ,w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))

ind = 0
counter = 0
ans = [[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
    if i%2 == 0:
        for j in range(w):
            ans[i][j] = ind+1
            counter += 1
            if counter == a[ind]:
                ind += 1
                counter = 0
    else:
        for j in range(w):
            ans[i][w-j-1] = ind+1
            counter += 1
            if counter == a[ind]:
                ind += 1
                counter = 0
for i in range(h):
    for j in range(w):
        print(ans[i][j], end=' ')
    print()


Measured memory_bytes: 3920
#include <iostream>
#include <cmath>
typedef long long ll;
using namespace std;

int arr[105];

ll ways(int N, int P, int even, int odd) {
    if(even == N) {
        if(P == 0) return pow(2, N);
        else if(P == 1) return 0;
    }
    return pow(2, N-1);     // at least 1 odd
}

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

    int N, P, odd, even;
    cin >> N >> P;
    for(int i=0; i<N; i++) {
        cin >> arr[i];
        if(arr[i]%2 == 0) even++;
    }
    odd = N-even;
    
    cout << ways(N, P, even, odd) << endl;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }

const int MAX_N = 100000;
int n,m;
pli ab[MAX_N];

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

  forn(i,n) {
    cin >> ab[i].snd >> ab[i].fst;
  }

  sort(ab,ab+n,greater<pli>());

  set<int> d;
  forn1(i,m) d.insert(i);

  ll res = 0;
  forn(i,n) {
    auto it = d.lower_bound(ab[i].snd);
    if (it != d.end()) {
      d.erase(it);
      res += ab[i].fst;
    }
  }

  cout << res << endl;

  return 0;
}


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

public class Main{

	public static void main(String[] args){

		//??\??????????????????
		BufferedReader reader= new BufferedReader(new InputStreamReader(System.in));

		String s;

		try{
		s=reader.readLine();
		try{
			int x=Integer.parseInt(s);

			System.out.println(cubeX(x));

		}catch(NumberFormatException e){
			System.out.println("??????:"+e);

		}


		}catch(IOException e){
			System.out.println("??????:"+e);
		}


	}//main??¢??°

	public static int cubeX(int x){

		return x*x*x;
	}

}

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

int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    multiset<ll> st;
    for(ll i=0;i<n;i++){
         cin >> a[i];
         a[i]*=-1;
    }
    for(ll i=0;i<n;i++){
        auto itr = st.upper_bound(a[i]);
        if(st.end()!=itr){
            st.erase(itr);
            st.insert(a[i]);
        }
        else st.insert(a[i]);
    }
    cout << st.size() << endl;
    return 0;
} 

Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main(){

   string s;
   cin>>s;
   int i,c=0;
   int l=s.size();
    for(i=0;i<l-1;i++){
        if(s.at(i)==s.at(i+1)){
            c++;
        }
    }
    if(c==0){
        cout<<"Good"<<endl;
    }
    else{
        cout<<"Bad"<<endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

long long int n;

int main() {
  cin >> n;
  long long int sqrt_n = (long long int) ceil(sqrt(n));
  long long int ans = (long long int) (2e12);
  for (long long int i = 1; i <= sqrt_n; i++) {
    if(n%i == 0) {
      ans = min(ans, i+n/i);
    }
  }
  
  //cout << sqrt_n << endl;
  cout << ans-2;

}

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

using namespace std;

#define sz(c) ((int)c.size())
#define	pb push_back

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

constexpr int MAX_N = 510;
constexpr ll INF = 5'000'000'000'000'000'000LL;
constexpr ll P = 9'982'443'53;
constexpr int SIGMA = 28;
constexpr double PI = 3.14159265359;
constexpr double toRad = PI/180.;

struct Edge {
	ll np, cost;

	bool operator<(const Edge & o)const{
		if(cost != o.cost){
			return cost < o.cost;
		}
		return np < o.np;
	}
};

ll N, D;
map<ll,ll> costs;
ll brute(){
	set<Edge> q;
	set<ll> vis;
	q.insert(Edge({N,0}));	
	while(q.size()){
		auto e = q.begin();
		if(e->np == 0) {
			return e->cost;
		}
		
		if(vis.find(e->np) != vis.end()) {
			q.erase(e); 
			continue;	
		}

		vis.insert(e->np);		
		if(e->np*D + e->cost > 0){
			q.insert(Edge({
				0,
				e->cost + e->np*D
			}));
		}
		
		for(auto c : costs){			
			ll r = e->np % c.first;
			if(r == 0){
				q.insert(Edge({
					e->np / c.first,
					e->cost + c.second
				}));
				continue ;
			}

			q.insert(Edge({
				(e->np - r) / c.first,
				e->cost + c.second + r*D
			}));
		
			ll m = e->np - r + c.first;
			q.insert(Edge({
				m / c.first,
				e->cost + c.second + (m  - e->np)*D
			}));		
		}
		q.erase(e); 
	}
	return -1;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int T;
	cin >> T;
	costs[2] = costs[3] = costs[5] = 0;
	while(T--){
		cin >> N >> costs[2] >> costs[3] >> costs[5] >> D;
		cout << brute() << "\n";
	}
	
	return 0;
}


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

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

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

  int a, b, x;
  cin >> a >> b >> x;
  if (a <= x && x <= (a + b)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256