akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

char s[200002];
vector<int> a[32];
int d[200002];
pair<int, int> b[200002];

int main() {
	long long r = 0;
	int i, j, n, m, t = 0;
	scanf("%s", s);
	for (i = 0; s[i]; i++) a[s[i] & 31].push_back(i);
	m = i;
	for (i = 0; i < 32; i++) if (a[i].size() & 1) t++;
	if (t > 1) {
		puts("-1");
		return 0;
	}
	for (i = n = 0; i < 32; i++) {
		for (j = 0; j + j < a[i].size(); j++) {
			b[n].first = a[i][j];
			b[n].second = a[i][a[i].size() - j - 1];
			n++;
		}
	}
	sort(b, b + n);
	for (i = 0; i < n; i++) {
		if (b[i].first == b[i].second) {
			for (j = b[i].first + 1; j; j &= j - 1) r += d[j];
			for (j = b[i].second + 1; j <= 200000; j += j & -j) d[j]++;
		}
		else {
			for (j = b[i].first + 1; j; j &= j - 1) r += d[j];
			for (j = b[i].second + 1; j; j &= j - 1) r += d[j];
			for (j = b[i].second + 1; j <= 200000; j += j & -j) d[j] += 2;
		}
	}
	printf("%lld\n", r >> 1);
	return 0;
}


Measured memory_bytes: 2680
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
#define NIL -1
//#define INFTY 1000000000000000000

int main(){
    LL n;
    LL x;
    LL m;
    cin >> n >> x >> m;
    vector<bool> is_visit(m, false);
    vector<LL> visit_idx(m, NIL);
    is_visit[x]=true;
    visit_idx[x]=1;
    LL first_visit_idx=NIL;
    LL second_visit_val=NIL;
    LL second_visit_idx=NIL;
    LL ans=0;
    LL tmp_x;
    if(n<=m){
        tmp_x=x;
        for(LL i=1; i<=n; i++){
            ans+=tmp_x;
            tmp_x=(tmp_x*tmp_x)%m;
        }
    }else{
        LL tmp_x=x;
        if(m==1){
            second_visit_val=n%m;
            ans=0;
        }else{
            for(LL i=2; i<=m; i++){
                tmp_x=(tmp_x*tmp_x)%m;
                if(is_visit[tmp_x]==true){
                    second_visit_val=tmp_x;
                    second_visit_idx=i;
                    break;
                }else{
                    is_visit[tmp_x]=true;
                    visit_idx[tmp_x]=i;
                }
            }
            first_visit_idx=visit_idx[second_visit_val];
            tmp_x=x;
            for(LL i=1; i<first_visit_idx; i++){
                ans+=tmp_x;
                tmp_x=(tmp_x*tmp_x)%m;
            }
            tmp_x=second_visit_val;
            LL tmp_ans=0;
            for(LL i=first_visit_idx; i<second_visit_idx; i++){
                tmp_ans+=tmp_x;
                tmp_x=(tmp_x*tmp_x)%m;
            }
            LL res=n-(first_visit_idx-1);
            ans=ans+tmp_ans*(res/(second_visit_idx-first_visit_idx));
            res=res%(second_visit_idx-first_visit_idx);
            tmp_x=second_visit_val;
            for(LL i=0; i<res; i++){
                ans+=tmp_x;
                tmp_x=(tmp_x*tmp_x)%m;            
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3996
N = int(input())
mod = 10**9 + 7

b = {i+j+k:1 for i in "AGCT" for j in "AGCT" for k in "AGCT" if i+j+k not in ("AGC", "ACG", "GAC")}
t = {}

def isOk(last4):
    if last4[1:] in ("AGC", "ACG", "GAC"):
        return False
    if last4[0] == 'A' and "G" in (last4[1], last4[2]) and last4[3] == "C":
        return False
    return True

for _ in range(N-3):
    t = {}
    for w, j in b.items():
        for a in "AGCT":
            x = w + a
            if isOk(x):
                if x[1:] not in t:
                    t[x[1:]] = j
                else:
                    t[x[1:]] += j
    b = t

a = 0
for i, j in b.items():
    a += j
print(a % mod)

Measured memory_bytes: 3064
import java.util.*;

class Main {
        public static void main(String args[]) {
                try (Scanner sc = new Scanner(System.in)) {
                        int N = sc.nextInt(), K = sc.nextInt();
                        PriorityQueue<Integer> que = new PriorityQueue<Integer>((a,b) -> b - a);
                        Set<String>SS = new TreeSet<String>();
                        for (int i = 0; i < N; i++) {
                                SS.add(sc.next());
                        }
                        int[] chr = new int[26];
                        String[] ss = SS.toArray(new String[0]);
                        for (int i = 0; i < SS.size(); i++) {
                                chr[ss[i].charAt(0) - 'A']++;
                        }
                        for (int i = 0; i < 26; i++) {
                                if (chr[i] != 0) {
                                        que.add(chr[i]);
                                }
                        }

                        int count = 0;
                        while (que.size() >= K) {
                                ArrayList<Integer> x = new ArrayList<Integer>();
                                for (int i = 0; i < K; i++) {
                                        int now = new Integer(que.poll());
                                        x.add(now);
                                }
                                count++;
                                for (int i = 0; i < K; i++) {
                                        if (x.get(i) - 1 != 0) {
                                                que.add(x.get(i) - 1);
                                        }
                                }
                        }
                        System.out.println(count);
                }
        }
}

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

int main()
{
    int N, M,sum=0;
    cin >> N;
    vector<int> nx(N);
    for (int i = 0; i < N;i++){
        cin >> nx.at(i);
    }
    cin >> M;
    vector<vector<int>> mx(M, vector<int>(2));
    for (int i = 0; i < M;i++){
        cin >> mx.at(i).at(0) >> mx.at(i).at(1);
    }
    vector<int> nx3 = nx;
    for (int i = 0; i < M;i++){
        vector<int> nx2 = nx;
        nx2.at(mx.at(i).at(0)-1) = mx.at(i).at(1);
        for (int j = 0; j < N; j++)
        {
            sum += nx2.at(j);
            //cout << nx2.at(j) << endl;
        }
        cout << sum << endl;
        sum = 0;
        nx = nx3;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
     int n,m,c;
     cin >> n >> m >> c;
     vector<int> B(m);
     for(int i = 0; i < m; i++){
          cin >> B[i];
     }
     vector<vector<int>> A(n,vector<int>(m));
     for(int i = 0; i < n; i++){
          for(int j = 0; j < m; j++){
               cin >> A[i][j];
          }
     }

     int ans = 0;
     for(int i = 0; i < n; i++){
          int x = 0;
          for(int j = 0; j < m; j++){
               x += A[i][j]*B[j];
          }

          if(x + c > 0) ans++;
     }

     cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    int antena[5];
    int K;

    for(int j = 0; j < 5; j++){
        cin >> antena[j];
    }
    cin >> K;
    bool flag = true;
    for(int i = 0; i < 5; i++){
        for(int k = i; k < 4; k++){
            if((antena[k+1] - antena[i]) > K ){
                flag = false;
                break;
            }
        }
    }

    if(flag)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
}

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

int main(void) {
    unsigned long long A;
    double B;
    unsigned long long result;
    scanf("%lld %lf", &A, &B);

    unsigned long long BLL = (unsigned long long)floor(B * 100.0 + 0.5);

    result = A * BLL / 100ULL;

    printf("%lld\n", result);
    return 0;
}


Measured memory_bytes: 2228
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ll inf = 1LL << 60;
const ld pi = (acos(-1));
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  
  int n,m; cin >> n >> m;
  vector<int> h(n);
  vector<bool> ok(n,true);
  rep(i,0,n) cin >> h[i];
  rep(i,0,m){
    int a,b;
    cin >> a >> b;
    --a;--b;
    if(h[a]<=h[b])ok[a]=false;
    if(h[b]<=h[a])ok[b]=false;
  }
  int ans=0;
  rep(i,0,n){
    if(ok[i])ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3712
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Tue Apr  3 00:41:46 2018
//
package main

import (
	"fmt"
	"strings"
)

var s string

func main() {
	fmt.Scan(&s)

	fmt.Println(strings.Join(strings.Split(s, ","), " "))
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        HashMap<Integer,Integer> hash = new HashMap<>();
        int n = sc.nextInt();
        for (int i=0;i<n;i++){
            int j = sc.nextInt();
            if (hash.containsKey(j))hash.put(j,2);
            else hash.put(j,1);
        }
        boolean b = true;
        for (int a : hash.values()){
            if (a > 1) {
                b = false;
                break;
            }
        }
        if (b)System.out.println("YES");
        else System.out.println("NO");
    }
}


Measured memory_bytes: 69992
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl toInt
  solve <$> getl (wrds toInt) >>= print

solve :: [Int] -> Int
solve = sum . map snd . filter (\x -> odd (fst x)) . zip [1..] . sort

toInt :: String -> Int
toInt = read

wrds :: (String -> a) -> String -> [a]
wrds f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine


Measured memory_bytes: 1020
H, W = map(int, input().split())
mass = [input() for _ in range(H)]
for i in range(H):
    for j in range(W):
        if mass[i][j] == '.':
            count = 0
            if 0 <= i - 1:
                if 0 <= j - 1:
                    if mass[i - 1][j - 1] == '#':
                        count += 1
                if mass[i - 1][j] == '#':
                    count += 1
                if j + 1 < W:
                    if mass[i - 1][j + 1] == '#':
                        count += 1

            if 0 <= j - 1:
                if mass[i][j - 1] == '#':
                    count += 1
            if mass[i][j] == '#':
                count += 1
            if j + 1 < W:
                if mass[i][j + 1] == '#':
                    count += 1

            if i + 1 < H:
                if 0 <= j - 1:
                    if mass[i + 1][j - 1] == '#':
                        count += 1
                if mass[i + 1][j] == '#':
                    count += 1
                if j + 1 < W:
                    if mass[i + 1][j + 1] == '#':
                        count += 1
            print(count, end='')
        else:
            print('#', end='')
    print()


Measured memory_bytes: 3444
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int solve(string& name,map<string,int>& prices,map<string,vs>& needs)
{
	if(needs.count(name)==0)
		return prices[name];
	int res=0;
	foreach(i,needs[name])
		res+=solve(*i,prices,needs);
	return min(prices[name],res);
}

int main()
{
	for(int n;cin>>n,n;){
		map<string,int> prices;
		rep(i,n){
			string name;
			int price;
			cin>>name>>price;
			prices[name]=price;
		}
		map<string,vs> needs;
		int m;
		cin>>m;
		rep(i,m){
			string name;
			int k;
			cin>>name>>k;
			rep(j,k){
				string elem;
				cin>>elem;
				needs[name].push_back(elem);
			}
		}
		
		string name;
		cin>>name;
		cout<<solve(name,prices,needs)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

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

using namespace std;

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

int n,k,card[10],digit[10];
bool use[10];
set<ll> S;

void rec(ll num,int depth)
{
	if(depth==0)
	{
		S.insert(num); return;
	}
	rep(i,n)if(!use[i])
	{
		use[i]=1;
		rec(num*digit[i]+card[i],depth-1);
		use[i]=0;
	}
}

int main()
{
	while(cin>>n>>k,n)
	{
		rep(i,n)
		{
			cin>>card[i];
			digit[i]=card[i]>9?100:10;
		}
		fill_n(use,n,0); S.clear();
		rec(0,k);
		cout<<S.size()<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.util.BitSet;

public class Main{
	
	static final int N = 100000 + 10, mod = 1000000007;
	static int n;
	static int cnt[] = new int[30];
	static String s;
	
	public static void main(String[] args) {
		Scanner inp = new Scanner(System.in);
		n = inp.nextInt();	
		s = inp.next();
		for(int i = 0; i < s.length(); ++i) {
			cnt[ s.charAt(i) - 'a' ] ++;
			//System.out.println(s.charAt(i) + " " + (s.charAt(i) - 'a'));
		}
		long res = 1;
		for(int i = 0; i < 26; ++i) {
			res = res * (cnt[i] + 1) % mod;
		}
		System.out.print((res + mod - 1) % mod);
	}
}

Measured memory_bytes: 25376
#include <bits/stdc++.h> // only for GCC
using namespace std;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef pair<int, int> pii;
typedef long long ll;
typedef unsigned long long ull;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair

#define loop(i,a,b) for(int i=(a);i<ull(b);++i)
#define rep(i,n) loop(i,0,n)

vs v;
set<string> a;
bool used[10];
int n, m;
void bfs(string s, int num){
    if(m == num){
        a.insert(s);
    }
    else {
        rep(i, n){
            if(!used[i]){
                used[i] = true;
                bfs(s+v[i], num+1);
                used[i] = false;
            }
        }
    }
}

int main(){
    while(cin >> n >> m, n+m){
        v.clear(); a.clear();
        rep(i, n){
            string s;
            cin >> s;
            v.pb(s);
        }
        fill(used, used+10, false);
        bfs("", 0);
        cout << a.size() << endl;
    }
}

Measured memory_bytes: 1460
import math

a,b,x = map(int,input().split())

if (a**2)*b/2 <= x:
    memo = (((a**2)*b - x) / (a**3))*2
    rad = math.atan(memo)
    deg = math.degrees(rad)


else:
    memo = (a*(b**2))/(2*x)
    rad = math.atan(memo)
    deg = math.degrees(rad)   

print(deg) 



Measured memory_bytes: 3060
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }


int
main(void){  
  int a, b, c, n;
  string s;
  cin >> a >> b;

  cout << a*b - a - b + 1 << endl;
  
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<ll, ll>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 45;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

// h(n, r) = c(n+r-1, r)

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main()
{
  int n, a, b;
  cin >> n >> a >> b;
  auto C = [&](int n, int r) {
    mint res = 1;
    rep(i, r) res *= n-i;
    rep(i, r) res /= r-i;
    return res;
  };
  mint ans = modpow(2, n);
  --ans;
  ans -= C(n, a) + C(n, b);
  cout << ans.x << endl;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

N, A, B = map(int, readline().split())
S = list(str(input()))

l = 0
l2 = 0
for s in S:
    if s == "a":
        if l < A + B:
            l += 1
            print('Yes')
            continue
    elif s == "b":
        if (l < A + B) and (l2 < B):
            l += 1
            l2 += 1
            print('Yes')
            continue
    print('No')

Measured memory_bytes: 4740
#include <iostream>
#include <vector>
#include <map>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define vec vector
#define pb push_back

int main(void)
{
  string s;
  cin >> s;
  int m = 0;
  rep(i, s.length()) {
    int j;
    for (j = i; j < s.length(); j++) {
      if (s[j] != 'A' && s[j] != 'C' && s[j] != 'G' && s[j] != 'T') {
        break;
      }
    }
    if (m < j - i) {
      m = j - i;
    }
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

const int MaxN = 501234;

int n, K, P[MaxN];
int seg[MaxN << 2]; vector<int> af[MaxN];

void modify(int p, int l, int r, int x, int v) {
	if(l == r) {
		seg[p] = v;
	} else {
		if(x <= (l + r >> 1))
			modify(p << 1, l, l + r >> 1, x, v);
		else
			modify(p << 1 | 1, (l + r >> 1) + 1, r, x, v);
		seg[p] =max(seg[p << 1], seg[p << 1 | 1]);
	}
}

int query(int p, int l, int r, int a, int b) {
	if(r < l) return 0;
	if(r < a || l > b) return 0;
	if(a <= l && r <= b) return seg[p];
	return max(query(p << 1, l, l + r >> 1, a, b), query(p << 1 | 1, (l + r >> 1) + 1, r, a, b));
}

int pos[MaxN], ans[MaxN], an = -1;

void getans(int x) {
	ans[++an] = x;
	sort(af[x].begin(), af[x].end());
	for(int i = 0; i < af[x].size(); i++)
		getans(af[x][i]); 
}

int main() {
	int i; scanf("%d %d", &n, &K);
	for(i = 1; i <= n; i++) scanf("%d", P + i);
	for(i = 1; i <= n; i++) pos[P[i]] = i; pos[n + 1] = n + 1;
	for(i = 1; i <= n; i++) {
		int prev = query(1, 1, n, pos[i] + 1, min(pos[i] + K - 1, n));
		if(!prev) prev = n + 1;
		af[pos[prev]].push_back(pos[i]);
		modify(1, 1, n, pos[i], i); 
	}
	getans(n + 1);	
	for(i = 1; i <= n; i++) P[ans[i]] = i;
	for(i = 1; i <= n; i++) printf("%d\n", P[i]);
	return 0;
}

Measured memory_bytes: 66048
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

ll n, s;

ll f (ll a, ll b) {
   if (a == 0) return 0;
   return f (a / b, b) + (a % b);
}

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> n >> s;
   if (n == s) cout << n + 1, exit (0);
   for (ll i = 2; i * i <= n; i ++) {
      if (f (n, i) == s)
         cout << i, exit (0);
   }
   for (ll i = 1; i * i <= n - s; i ++) {
      if ((n - s) % i == 0) {
         if (f (n, i + 1) == s)
            cout << i + 1, exit (0);
      }
   }
   for (ll i = sqrtl (n - s); i >= 1; i --) {
      if ((n - s) % i == 0) {
         if (f (n, (n - s) / i + 1) == s)
            cout << (n - s) / i + 1, exit (0);
      }
   }
   cout << -1;
}               
 
signed main () {                                       
  // #ifdef QWERTY
  //    freopen("input", "r", stdin);
  // #endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

Measured memory_bytes: 3584
#!/usr/bin/env python3
import sys

def delete(larger, move):
    for i in move:
        larger.remove(i)
    return larger

def solve(N: int, d: "List[int]"):
    ABC = []
    ARC = sorted(d)

    count = 0

    for K in range(10**6):
        move = []
        for i in ARC:
            if i < K:
                move.append(i)
            else:
                break
        ABC += move
        delete(ARC, move)

        if len(ABC) == len(ARC):
            count += 1
        elif len(ABC) > len(ARC):
            break
        
    print(count)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, d)

if __name__ == '__main__':
    main()


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var dict = new Dictionary<char, List<int>>();
            for (var i = 0; i < s.Length; i++) {
               if (dict.ContainsKey(s[i]))
                   dict[s[i]].Add(i);
               else {
                  dict[s[i]] = new List<int>();
                  dict[s[i]].Add(-1);
                  dict[s[i]].Add(i); 
               } 
            }
            
            var ans = int.MaxValue;
            foreach (var d in dict) {
                d.Value.Add(s.Length);
                var max = 0;
                //Console.WriteLine(d.Key);
                for (var i = 1; i < d.Value.Count; i++) {
                    max = Math.Max(max, d.Value[i] - d.Value[i - 1] - 1);
                    //Console.WriteLine(max);
                }
                
                ans = Math.Min(ans, max);
            }
            
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13152
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    cout << (s.length() >= 4 && s.substr(0, 4) == "YAKI" ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(int i = 0; i < N; i++)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    int a,b,c;cin>>a;
    if(a%2==0) cout<<a/2<<endl;
    else cout<<a/2+1<<endl;
    return 0;
}

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

int main() {
  priority_queue<int> que;
  for (int i = 0; i < 10; i++) {
    int height;
    cin >> height;
    que.push(height);
  }
  cout << que.top() << endl; que.pop();
  cout << que.top() << endl; que.pop();
  cout << que.top() << endl; que.pop();
  return 0;
}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	int sum = 100000;
	for(int i = 0; i < n; ++i)
	{
		sum *= 1.05;
		int temp = sum % 1000;
		if(temp)
		{
			sum = sum - temp + 1000;
		}
	}
	cout << sum << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 10;

ll x, k, d;

int main() {
#ifdef ACM_LOCAL
    freopen("input.in", "r", stdin);
    freopen("output.out", "w", stdout);
#endif
    scanf("%lld%lld%lld", &x, &k, &d);
    if (x < 0) x = -x;
    ll y = min(x / d, k);
    x -= y * d; k -= y;
    if (k & 1) printf("%lld\n", abs(x - d));
    else printf("%lld\n", abs(x));


    return 0;
}

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

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

using ll = long long;
using P = pair<int,int>;
using grid = vector<vector<int>>;

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

struct BellmanFord{
    struct edge {int from, to, cost;};
    vector<edge> es;
    vector<int> d;
    int V=0,E=0;
    bool nloop = false;

    BellmanFord(int v, int e){
        V = v;
        E = e;
        es.resize(E);
        d.resize(V);
    }

    void fnloop(){
        rep(i,V) d[i] = 0;
        rep(i,V){
            rep(j,E){
                edge e = es[j];
                if(d[e.to] > d[e.from] + e.cost){
                    d[e.to] = d[e.from] + e.cost;
                    if(i==V-1) nloop = true;
                }
            }
        }
    }

    void shortest(int s){
        rep(i,V) d[i] = INF;
        d[s] = 0;
        int cnt = 0;

        while(true){
            bool update = false;
            rep(i,E){
                edge e = es[i];
                if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost){
                    d[e.to] = d[e.from] + e.cost;
                    update = true;
                }
            }
            if(!update) break;
            cnt++;
            if(cnt == V) {
                nloop = true;
                break;
            }
        }
    }
};

int main() {
    int N,M,T;
    cin>>N>>M>>T;
    vector<vector<P>> g(N);
    rep(i,M){
        int a,b,c;
        cin>>a>>b>>c;
        a--;
        b--;
        c = T-c;
        g[b].push_back(make_pair(a,c));
    }
    vector<bool> seen(N);
    queue<int> bfs;
    seen[N-1] = true;
    bfs.push(N-1);
    while(!bfs.empty()){
        int x = bfs.front();
        bfs.pop();
        for(auto nx:g[x]){
            if(seen[nx.first])continue;
            seen[nx.first] = true;
            bfs.push(nx.first);
        }
    }
    int cnt = 0;
    rep(i,N){
        if(!seen[i])continue;
        for(auto nx:g[i]){
            if(seen[nx.first]) cnt++;
        }
    }
    int t = 0;
    BellmanFord B(N,cnt);
    rep(i,N){
        if(!seen[i])continue;
        for(auto nx:g[i]){
            if(seen[nx.first]) {
                B.es[t].from = nx.first;
                B.es[t].to = i;
                B.es[t].cost = nx.second;
                t++;
            }
        }
    }
    B.shortest(0);
    if(B.nloop) cout<<-1<<endl;
    else{
        if(-B.d[N-1]<0) cout<<0<<endl;
        else cout<<-B.d[N-1]<<endl;
    }
}

Measured memory_bytes: 3840
#include<iostream>
#include<algorithm>

using namespace std;

int num(char c){
    if(c == 'J')return 0;
    if(c == 'O')return 1;
    if(c == 'I')return 2;
}

int dp[1050][8];

int main(){
    int n;
    char c;
    cin >> n;
    dp[0][1] = 1;
    for(int i = 1;i <= n;i++){
	cin >> c;
	int ad = num(c);
	for(int j = 0;j < 8;j++){
	    if((j & (1 << ad)) == 0)continue;
	    for(int k = 0;k < 8;k++){
		if((j & k) == 0)continue;
		dp[i][j] += dp[i - 1][k];
	    }
	    dp[i][j] %= 10007;
	}
    }
    int res = 0;
    for(int i = 0;i < 8;i++){
	res += dp[n][i];
	res %= 10007;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1192
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

bool comp(string A, string B) {
    if (sz(A) != sz(B)) return sz(A) < sz(B);
    return A < B;
}
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
    vector<string> res; 
    vector<string> cur;
    F0R(i, 10) {
        string S; S.pb((char) '0'+i);
        cur.pb(S); if (i != 0) res.pb(S);
    }
    vector<string> nxt;
    while (sz(res) < 200000) {
        nxt.clear();
        F0R(i, sz(cur)) {
            F0R(j, 3) {
                int k = sz(cur[i])-1;
                if (j == 0 && cur[i][k] != '0') {
                    nxt.pb(cur[i]);
                    nxt[sz(nxt)-1].pb((char) cur[i][k]-1);
               } else if (j == 2 && cur[i][k] != '9') {
                    nxt.pb(cur[i]);
                    nxt[sz(nxt)-1].pb((char) cur[i][k]+1);
                } else if (j == 1) {
                    nxt.pb(cur[i]); 
                    nxt[sz(nxt)-1].pb((char) cur[i][k]);
                }
            }
        }

        cur = nxt;

        F0R(i, sz(nxt)) {
            if (nxt[i][sz(nxt[i])-1] != '0') {
                reverse(all(nxt[i])); res.pb(nxt[i]);
            }
        }
    }

    sort(all(res), comp);



    int K; cin >> K;
    cout << res[K-1] << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 86464
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.trim().split(" ");
	input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var N = parseInt(input[0]);
  var list = input[1].split(" ").map((a)=>Number(a));
  var output = 0;
  while(true){
  	for(var i = 0; i < N; i++){
   	 if(list[i] % 2 == 0){
        list[i] /= 2;
        }else{
         myout(output);
          return;
        }
	}
    output++;
  }
}

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


Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define FOR(i,s,e) for(int i=(s);i<(e);i++)
#define REP(i,n) FOR(i,0,n)
#define all(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long LL;
typedef pair<int, int> P;

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

    int n;
    cin >> n;
    if(n == 1){
        cout << "Yes\n2\n1 1\n1 1" << endl;
    }else{
        LL x = 1;
        LL ct = 2;
        while(x < n){
           x+=ct;
           ct++;
        }
        if(x != n) cout << "No" << endl;
        else{
            ct--;
            cout << "Yes" << endl;
            cout << ct+1 << endl;
            vector<LL> st(ct+2, 1);
            st[0] = 0;
            int fi = 1;
            cout << ct << " ";
            REP(i, ct){
                cout << fi+i << " ";
            }
            cout << endl;
            
            st[fi] = ct;
            REP(i, ct){
                cout << ct << " ";
                LL now = fi;
                REP(j, ct){
                    cout << now+st[j] << " ";
                    now += st[j];
                }
                cout << endl;
                st[fi]--;
                st[fi+1] = st[fi];
                fi++;
            }
        }
    }

    return 0;
}


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

const int N = 2e5 + 5;

int n;
string str[N];
char res[N];

void dfs(int i, int a, int b, int c) {
    if (i >= n) {
        cout << "Yes" << endl;
        rep(i,n) {
            cout << res[i] << endl;
        }
        exit(0);
    }
    if (str[i] == "AB") {
        if (a) res[i] = 'B', dfs(i + 1, a - 1, b + 1, c);
        if (b) res[i] = 'A', dfs(i + 1, a + 1, b - 1, c);
    } else if (str[i] == "AC") {
        if (a) res[i] = 'C', dfs(i + 1, a - 1, b, c + 1);
        if (c) res[i] = 'A', dfs(i + 1, a + 1, b, c - 1);
    } else {
        if (b) res[i] = 'C', dfs(i + 1, a, b - 1, c + 1);
        if (c) res[i] = 'B', dfs(i + 1, a, b + 1, c - 1);
    }
}

int main() {
    int a, b, c;
    cin >> n >> a >> b >> c;
    rep(i,n) cin >> str[i];
    dfs(0, a, b, c);
    cout << "No" << endl;
    exit(0);
}


Measured memory_bytes: 17824
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cmath>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int a,b;
	cin>>a>>b;
	cout<<(b-a)*(b-a+1)/2-b<<endl;
	return 0;
}



Measured memory_bytes: 256
n = int(input())
a = []
for _ in range(n):
  s,p = input().split()
  a.append((s,p))
b = sorted(a,key=lambda x:-int(x[1]))
b = sorted(b,key=lambda x:x[0])
for _ in range(n):
  for i in range(n):
    if b[_] == a[i]:
      print(i+1)
      break

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main()
{
    int n, u, k, v;
    cin >> n;

    int adj_matrix[n][n];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            adj_matrix[i][j] = 0;
        }
    }
    
    for (int i = 0; i < n; i++) {
        cin >> u;
        cin >> k;
        for (int j = 0; j < k; j++) {
            cin >> v;
            adj_matrix[u-1][v-1] = 1;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - 1; j++) {
            cout << adj_matrix[i][j] << " ";
        }
        cout << adj_matrix[i][n-1] << endl;
    }

    return 0;
}

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

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

int main() {
int64_t A,B;
  cin >> A >> B;
  int64_t ans = A*B/gcd(A,B);
  cout << ans << endl;

  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cstring>

// ref : http://kyopro.hateblo.jp/entry/2018/12/25/174720

using ll = long long;
/*
dp[d][smaller][leadingZero][num]
numは3, 5, 7を少なくとも1回選んだかどうかのフラグとする
具体的には3bit(つまり0 ~ 7)のうち各bitで管理する
leadingZero = 0 はまだ0が続いている状態
*/
ll dp[11][2][2][8];

int main(){
    std::string S;
    std::cin >> S;

    memset(dp, 0, sizeof dp);
    dp[0][0][0][0] = 1;
    for(int d = 0; d < S.size(); d++){
        for(int smaller = 0; smaller < 2; smaller++){
            for(int leadingZero = 0; leadingZero < 2; leadingZero++){
                for(int num = 0; num < 8; num++){
                    if(dp[d][smaller][leadingZero][num] == 0) continue; // 足す意味なし

                    int val; // 次に入れられる数字の最大値
                    if(smaller == 1){
                        val = 9;
                        if(leadingZero == 0){
                            // まだ0が続いている状態
                            // 必ず小さいのでsmallerは1
                            // dp[d + 1][1][leadingZero][0] += dp[d][smaller][leadingZero][num];
                            dp[d + 1][1][leadingZero][0] = 1;
                        }
                    }else{
                        val = S[d] - '0';
                        if(leadingZero == 0){
                            // まだ0が続いている状態
                            // 必ず小さいのでsmallerは1
                            //dp[d + 1][1][leadingZero][0] += dp[d][smaller][leadingZero][num];
                            dp[d + 1][1][leadingZero][0] = 1;
                        }
                    }

                    // valの値に応じてsmallerを切り替えて計算
                    if(val == 3) dp[d + 1][0][1][num | 1] += dp[d][smaller][leadingZero][num];
                    if(val > 3) dp[d + 1][1][1][num | 1] += dp[d][smaller][leadingZero][num];
                    if(val == 5) dp[d + 1][0][1][num | 2] += dp[d][smaller][leadingZero][num];
                    if(val > 5) dp[d + 1][1][1][num | 2] += dp[d][smaller][leadingZero][num];;
                    if(val == 7) dp[d + 1][0][1][num | 4] += dp[d][smaller][leadingZero][num];;
                    if(val > 7) dp[d + 1][1][1][num | 4] += dp[d][smaller][leadingZero][num];
                }
            }
        }
    }

    std::cout << dp[S.size()][0][1][7] + dp[S.size()][1][1][7] << std::endl;
    return 0;
}


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

namespace ABC073A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n;
            n = int.Parse(Console.ReadLine());
            if ((n % 10 == 9) || (n / 10 == 9))
            {
                Console.WriteLine("Yes");
            }
            else
                Console.WriteLine("No");
            Console.ReadKey();
        }
    }
}


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


int n;
int ans = 1000000000;
signed main() {

  cin >> n;

  for(int i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      int a = n / i; int b = i;
       int ans2 = 0; int ans3 = 0;
      while(a > 0) {
	a /= 10;
	ans2++;
      }
      while(b > 0) {
	b /= 10;
	ans3++;
      }
      ans = min(ans,max(ans2,ans3));
    }
  }
  cout << ans <<endl;
}


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

int main(){
	string a,b;
	cin >> a >> b;
	
	if(a.length()-b.length()==0){
		for(int i=0; i < a.length(); i++){
			cout << a[i] << b[i];
		}
	}
	else{
		for(int i=0; i<a.length(); i++){
			cout << a[i];
			if(i!=a.length()-1)cout << b[i];
		}
	}
cout << endl;
}



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

#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
using namespace std;

int main(){
    int n;
    int b;
    int f;
    int r;
    int v;
    int house[4][3][10];
    cin>>n;
    rep(i,4)rep(j,3)rep(k,10)house[i][j][k]=0;
    rep(i,n){
        cin>>b>>f>>r>>v;
        house[b-1][f-1][r-1]+=v;
    }
        rep(i,4){
        rep(j,3){
        rep(k,10){
        cout space house[i][j][k];
        }
        cout<<endl;
        }
        if(i!=3)cout<<"####################"<<endl;
        }
    }





Measured memory_bytes: 3076
#include"bits/stdc++.h"

using namespace std;

int main() {
	int N;
	cin >> N;
	char S[100];
	cin >> S;
	int x = 0;
	int ans = 0;

	for (int i = 0; i < N; i++) {
		if (S[i] == 'I') {
			x++;
			ans = max(x, ans);
		}
		else {
			x--;
			ans = max(x, ans);
		}
	}

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

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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int h[1001];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  if (stream2 == NULL) return 0;
#endif
  int n;
  int t, a;
  cin >> n;
  cin >> t >> a;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  int tmp = (t - a) * 500;
  int ans = 0;
  int now = abs(tmp - 3 * h[0]);
  for (int i = 0; i < n; i++) {
    if (now > abs(tmp - 3 * h[i])) {
      ans = i;
      now = abs(tmp - 3 * h[i]);
    }
  }
  cout << ans + 1 << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  fclose(stream2);
#endif
  return 0;
}

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

int l[10];
int v1, v2;

void solve(void)
{
    int s = 0;
    int i;
    for (i = 0; i < 10; i++) s += l[i];
    double meet_point = (double)s / (double)(v1 + v2) * v1;
    int v1_run = 0;
    i = 0;
    while (v1_run < meet_point) {
        v1_run += l[i++];
    }
    cout << i << endl;
}

int main(void)
{
    char c;
    while (cin >> l[0] >> c >> l[1] >> c >> l[2] >> c 
               >> l[3] >> c >> l[4] >> c >> l[5] >> c
               >> l[6] >> c >> l[7] >> c >> l[8] >> c
               >> l[9] >> c >>  v1  >> c >> v2) {
        solve();
    }
    return 0;
}

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

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

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

    int tmp;
    for(int i=0; i<N-1; i++){
        for(int j=N-1; j>i; j--){
            if(P[j]<P[j-1]){
                tmp=P[j];
                P[j]=P[j-1];
                P[j-1]=tmp;
            }
        }
    }

    int sum=0;
    for(int i=0; i<K; i++){
        sum+=P[i];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3572
(defn Partition2 [N M]
  (loop [d (unchecked-divide-int M N)]
    (if (zero? (unchecked-remainder-int M d))
      d
      (recur (unchecked-dec-int d)))))
(println (Partition2 (unchecked-int (read)) (unchecked-int (read))))

Measured memory_bytes: 64508
#include<iostream>
using namespace std;
int main(){
    string S;
    cin >> S;
    int len = S.size();
    int flag=0;
    for(int i=0;i<len-1;i++){
        if(S.at(i)==S.at(i+1)){
            flag=1;
            break;
        }
    }
    if(flag==1) cout << "Bad" << endl;
    else cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256