akhauriyash/Code-Regression huggingface dataset:
input = STDIN.gets.chomp.split('')

result = []

input.each do |n|
  if n == '0'
    result << '0'
  end

  if n == '1'
    result << '1'
  end

  if n == 'B'
    if result.length != 0
      result.pop
    end
  end
end

puts result.join("")

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vvvd = vector<vector<vector<double>>>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pint = pair<int, int>;
using Graph = vvi;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

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

    int ans = 0;
    while(n > 0) {
        n /= k;
        ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
//    return *(int*)a - *(int*)b;
    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

long long  factorial(long long n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}

int main()
{
  int a ,b, c, d, e, X, Y;
//  long long  a, b, c, d, e, X, Y;
  //  double  c;
  long long  A[200003]={};
  long long  B[100003]={};
  int  C[100003][11]={};

  int  flag[1003]={};

//  long long  a, b, c, d, X, Y;
  char s[101][101]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k;
  long long p,q;
//  int flag=0;
//  int tmp=0;
  char tmp[101]={};
  long long min=10000000000;
//  long long min=100000001;
  int len=0;
  int l=0;
  int r=1000001;
  int cnt=1;
  long long num=0;
  int num1=0;
  int num2=0;
  long long ans=1;
  int max=0;
  int addr=0;
  int ptn=0;
//  bool on_off[100]={};
  
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
//  scanf("%d%d", &a,&c);
//  cnt = strlen(t);
// printf("%d\n",a);
  scanf("%d%d", &a, &b);
  if(a<b)  printf("0\n");
  else  printf("10\n");

    
//    printf("%s %d %d\n", s[i],C[i][0],C[i][1]);
   // printf("%d\n", C[i][1]);
/*  for(i=0;i<addr;i++){
//  scanf("%lld%lld", &B[0][i],&B[1][i]);
//    ans=ans+A[i];
    printf("%lld ", A[i]);
  }
*/
//    printf("%d ", cnt);
   
//  ans=a*3;
//  ans=(ans+b)/2;
//  printf("%d\n", ans);

  
//  printf("%lf\n",ans);
  //  //  if(flag==0)   printf("TLE\n");
//    if(max < cnt - max)  printf("Yes\n");
//    else  printf("No\n");
  
return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(void) {

    long H = 0;
    long W = 0;

    scanf("%ld %ld", &H, &W);

    long MasuNum = 0;
    MasuNum = H * W;

    long output = 0;
    output = MasuNum / 2;

    if ((H == 1) || (W == 1))
    {
        cout << 1;
    }
    else
    {
        if (MasuNum % 2 == 0)
        {
            cout << output;
        }
        else
        {
            cout << output + 1;
        }
    }

    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    ll X, Y;
    cin >> X >> Y;
    int ans = 0;
    while(X <= Y){
        X *= 2;
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

int main()
{
    //freopen("circus.in", "r", stdin);
    //freopen("circus.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, k;
    cin >> n >> k;
    vector<int> a(n), b(n);
    rep(i, 0, n) {
        cin >> a[i];
    }
    while (k > 0) {
        k--;
        fill(b.begin(), b.end(), 0);
        rep(i, 0, n) {
            int l = max(0, i - a[i]);
            int r = min(n, i + a[i] + 1);
            b[l]++;
            if (r < n) {
                b[r]--;
            }
        }
        rep(i, 1, n) {
            b[i] += b[i - 1];
        }
        if (a == b) {
            break;
        }
        a = b;
    }
    rep(i, 0, n) {
        cout << a[i] << " ";
    }
    cout << "\n";
    return 0;
}



Measured memory_bytes: 4784
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
#include<sstream>
using namespace std;

int main() {

	int N;
	cin >> N;
	list<int> D;
	int v;
	for (int i = 0; i < N; i++) {
		cin >> v;
		D.push_back(v);
	}

	D.sort();

	int M;
	cin >> M;
	list<int> T;
	for (int i = 0; i < M; i++) {
		cin >> v;
		T.push_back(v);
	}

	T.sort();

	bool jdg = true;

	auto pos = D.begin();

	for (auto itr = T.begin(); itr != T.end(); itr++) {
		while (pos != D.end()) {
			if (*pos == *itr) {
				break;
			}
			pos++;
		}
		if (pos == D.end()) {
			jdg = false;
			break;
		}
		else {
			pos++;
		}
	}

	if (jdg == true) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;

	}

	return 0;
}

Measured memory_bytes: 16088
import java.util.*;

public class Main {
	public static void main(String[] args) throws NumberFormatException{
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int r = sc.nextInt();
			if(n == 0 && r == 0) break;
			int[] num = new int[n];
			for(int i = 0; i < n; i++) 
				num[i] = n - i;
			int p, c;
			for(int i = 0; i < r; i++){
				p = sc.nextInt();
				c = sc.nextInt();
				int[] tmp = new int[p - 1];
				for(int j = 0; j < p - 1 ; j++)
					tmp[j] = num[j];
				for(int j = 0; j < c; j++){
					num[j] = num[p - 1 + j];
				}
				for(int j = 0; j < tmp.length; j++){
					num[c + j] = tmp[j];
				}
			}
			System.out.println(num[0]);
		}

	}
}

Measured memory_bytes: 37308
def dfs(visited, s):
    visited = visited[:]  # このような渡し方をすることで、もしそのルートが不正解だった時に分岐まで戻ることができる
    global ans
    visited[s] = True
    for t in graph[s]:  # startとtarget
        if not visited[t]:  # 未訪問なら
            dfs(visited, t)

    # 自身から伸びているノードが全て訪問済みなら以下の処理をする
    if all(visited):
        ans += 1


N, M = map(int, input().split())

graph = [[] for _ in range(N)]
visited = [False]*N

for _ in range(M):
    a, b = map(lambda x: int(x)-1, input().split())
    graph[a].append(b)
    graph[b].append(a)

ans = 0
dfs(visited, 0)

print(ans)


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

using namespace std;
using ll = long long int;
using P = pair<int, int>;

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

int main(void){

    int n;
    cin >> n;

    string s;
    cin >> s;

    vector<vector<int>> a(n, vector<int>(3));
    int r = 0, g = 0, b = 0;
    roop(i, n){
        if(s[i] == 'R') r++;
        else if(s[i] == 'G') g++;
        else b++;

        a[i][0] = r;
        a[i][1] = g;
        a[i][2] = b;
    }

    ll ans = 0;

    int temp = 0;
    for(int i = 0;i < n-2;i++){
        for(int j = i+1;j < n-1;j++){
            if(s[i] != s[j]){
                if(s[i] == 'R' || s[j] == 'R') temp += 1;
                if(s[i] == 'G' || s[j] == 'G') temp += 2;
                if(s[i] == 'B' || s[j] == 'B') temp += 4;

                if(j+(j-i) < n){
                    if(7 - temp == 1 && s[j+(j-i)] == 'R') ans--;
                    if(7 - temp == 2 && s[j+(j-i)] == 'G') ans--;
                    if(7 - temp == 4 && s[j+(j-i)] == 'B') ans--;
                }

                if(7 - temp == 1) ans += a[n-1][0]-a[j][0];
                if(7 - temp == 2) ans += a[n-1][1]-a[j][1];
                if(7 - temp == 4) ans += a[n-1][2]-a[j][2];
            }
            temp = 0;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3780
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static long N;

        static void Main(string[] args)
        {
            N = int.Parse(Console.ReadLine());

            Console.WriteLine(Dfs("0"));
        }

        static long Dfs(string s)
        {
            if (long.Parse(s) > N) return 0;

            bool is357 = true;
            foreach (var c357 in "357")
            {
                if (!s.Contains(c357))
                {
                    is357 = false;
                    break;
                }
            }

            var ret = is357 ? 1L : 0L;

            foreach (var item in "357")
            {
                ret += Dfs(s + item);
            }

            return ret;
        }
    }
}


Measured memory_bytes: 17360
#include <iostream>
#include <sstream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

typedef long long ll;

#define PrintLn(X) cout << X << endl
#define Loop(n) for(int loop_ = n; loop_; --loop_)
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define For(i, a, b) for(int i = a; i < (int)(b); ++i)

int main(void)
{
	int N;
	cin >> N;
	map<ll, int> m;
	vector<ll> v;

	Rep(i, N){
		ll a;
		cin >> a;
		m[a]++;
	}
	for(auto x: m){
		if(x.second >= 2){
			v.push_back(x.first);
		}
	}

	ll ans = 0;
	if(v.size() > 0){
		sort(v.begin(), v.end());
		reverse(v.begin(), v.end());

		if(m[v[0]] >= 4){
			ans = v[0] * v[0];
		}else if(v.size() > 1){
			ans = v[0] * v[1];
		}
	}
	PrintLn(ans);
	return 0;
}


Measured memory_bytes: 6528
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define trep(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main()
{
    string s;
    cin >> s;
    int i, j;
    for (i = 0; i < s.size(); i++)
    {
        if (s[i] == 'A')
        {
            break;
        }
    }
    for (j = s.size(); j >= 0; j--)
    {
        if (s[j] == 'Z')
        {
            break;
        }
    }
    cout << j - i + 1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int h,w,n;
    cin >> h >> w >> n;
    vector<int> a(n);
    for (int i=0; i<n; i++) cin >> a[i];
    vector<int> colors;

    for (int i=0; i<n; i++) {
        for (int j=0; j<a[i]; j++) colors.push_back(i+1);
    }

    vector<vector<int>> ans(h, vector<int> (w, -1));

    for (int i=0; i<h; i++) {
        if (i % 2 == 0) {
            for (int j = 0; j < w; j++) {
                ans[i][j] = colors.back();
                colors.pop_back();
            }
        } else {
            for (int j = w - 1; j >= 0; j--) {
                ans[i][j] = colors.back();
                colors.pop_back();
            }
        }
    }

    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) cout << ans[i][j] << " ";
        cout << endl;
    }
}

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

int main() {
    char a, b; cin >> a >> b;
    if (a == 'H' && b == 'H') puts("H");
    if (a == 'H' && b == 'D') puts("D");
    if (a == 'D' && b == 'H') puts("D");
    if (a == 'D' && b == 'D') puts("H");

}

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

c = 0
for i in range(n):
    m = la[i] + la[i+1]
    if la[i] >= lb[i]:
        c += lb[i]
    elif m > lb[i]:
        la[i+1] = m - lb[i]
        c += lb[i]
    else:
        la[i+1] = 0
        c += m

print(c)


Measured memory_bytes: 19156
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;

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

    int m = n - n % 2;
    vector<int> g[100];
    for (int i = 1; i <= n / 2; ++i)
    {
        g[i].push_back(i);
        g[i].push_back(m - i + 1);
    }
    if (n & 1)
        g[n / 2 + 1].push_back(n);

    int sz = n / 2 + (n & 1);

    vector< pair<int,int> > out;
    for (int i = 1; i <= sz; ++i)
    {
        for (int j = i + 1; j <= sz; ++j)
        {
            for (int x : g[i])
                for (int y : g[j])
                    out.push_back({x, y});
        }
    }

    printf("%d\n", (int)out.size());
    for (auto pr : out)
        printf("%d %d\n", pr.first, pr.second);

}


Measured memory_bytes: 384
package main

import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "sort"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

type VoE [][]int
func (E VoE) Len() int { return len(E) }
func (E VoE) Less(i, j int) bool { return E[i][1] < E[j][1] }
func (E VoE) Swap(i, j int) { E[i], E[j] = E[j], E[i] }

func Solve() {
  RCN := NextIntVec()
  R, C, N := RCN[0], RCN[1], RCN[2]
  E := make([][]int, 0)
  for i := 0; i < N; i++ {
    Axis := NextIntVec()
    r1, c1, r2, c2 := Axis[0], Axis[1], Axis[2], Axis[3]
    e1, e2 := []int{i, -1}, []int{i, -1}
    if r1 == 0 {
      e1[1] = c1
    } else if c1 == C {
      e1[1] = C + r1
    } else if r1 == R {
      e1[1] = C + R + C - c1
    } else if c1 == 0 {
      e1[1] = C + R + C + R - r1
    } else {
      continue
    }
    if r2 == 0 {
      e2[1] = c2
    } else if c2 == C {
      e2[1] = C + r2
    } else if r2 == R {
      e2[1] = C + R + C - c2
    } else if c2 == 0 {
      e2[1] = C + R + C + R - r2
    } else {
      continue
    }
    E = append(E, e1, e2)
  }
  sort.Sort(VoE(E))
  V := make([]int, N)
  ans := "YES"
  cnt := 0
  for _, e := range E {
    if V[e[0]] == 0 {
      cnt++
      V[e[0]] = cnt
    } else {
      if V[e[0]] != cnt {
        ans = "NO"
      }
      cnt--
    }
  }
  Write(ans)
  return
}

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 24320
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
typedef long long ll;
 
int main() {
	int N,T;
	cin >> N >> T;
	int t[N],a=T;
	for (int i=0;i<N;i++) cin >> t[i];
	for (int i=0;i<N-1;i++) {
		a+=min(T,t[i+1]-t[i]);
	}
	cout << a;
}

Measured memory_bytes: 1024
#include<stdio.h>

int LIS(void);

int h[201],r[201],m,n;

int main(void)
{
  int i,j,t;
  while(1)
    {
      scanf("%d",&n);
      if(n==0)break;

      for(i=0;i<n;i++)
	scanf("%d%d",&h[i],&r[i]);

      scanf("%d",&m);

      for(i=n;i<n+m;i++)
	scanf("%d%d",&h[i],&r[i]);


       for(i=0;i<n+m;i++){
	  for(j=0;j<n+m;j++){
	      if(h[i]<h[j]){
		  t=h[i];
		  h[i]=h[j];
		  h[j]=t;
		  t=r[i];
		  r [i]=r[j];
		  r[j]=t;
		}

	      if(h[i]==h[j] && r[i]<r[j]){
		  t=h[i];
		  h[i]=h[j];
		  h[j]=t;
		  t=r[i];
		  r [i]=r[j];
		  r[j]=t;
		}
	    }
	}
       printf("%d\n",LIS());

    }
  return 0;
}

int LIS(void){
  int i,j,k,L[201],max=0;
  
  for(i=0;i<201;i++)
    L[i]=1;

  for(i=1;i<n+m;i++){
      j=i-1;

	  for(k=0;k<i;k++){
	      if(r[k]<r[i] && h[k]<h[i] && L[k]>=L[i])L[i]=L[k]+1;
	    }
    }
  
  for(i=0;i<n+m;i++)
    if(max<L[i])max=L[i];

  return max;
}

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

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;
typedef vector<pi> vpi;
typedef vector<string> vsi;
typedef map<ll, ll> mape;
#define rep(i, a, b) for(ll i=(ll)a;i<=(ll)b;i++)
#define per(i, a, b) for(ll i=(ll)a;i>=(ll)b;i--)
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
#define N 2100
#define MAX 1234567890
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define MOD 1000000007

int main()
{
    fastio;

    ll n;
    cin >> n;
    string s = "";
    while(n > 26){
        ll rem = n % 26;
        if(rem == 0) {
            s += 'z';
            rem = 26;
        }
        else s += ('a' + rem - 1);
        n = (n - rem) / 26;
    }
    s += ('a' + n - 1);
    reverse(s.begin(), s.end());

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 3612
n = int(input())
m = n
a = []

for _ in range(400):
    if n > 0:
        if n % 2 == 1:
            n = - (n // 2)
            a.append(1)
        else:
            n = -(n // 2)
            a.append(0)
    elif n < 0:
        if (-n) % 2 == 1:
            n = n // (-2) + 1
            a.append(1)
        else:
            n = n // (-2)
            a.append(0)
    
a.reverse()
ans = ''.join([str(i) for i in a])

if m != 0:
    print(ans)
else:
    print(0)

Measured memory_bytes: 38384
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	static int N,K;
	static int min=1000000000;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		N=sc.nextInt();
		K=sc.nextInt();
		int h[]=new int[N];
		for(int i=0;i<N;i++) h[i]=sc.nextInt();
		Arrays.sort(h);
		for(int i=0;i<=N-K;i++) {
			if(min>h[i+K-1]-h[i])min=h[i+K-1]-h[i];
		}
		System.out.println(min);
	}
}


Measured memory_bytes: 50564
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<sstream>

using namespace std;

int main(){
	while(1){
		int n;
		string a;
		
		cin>>n;
		
		if(n==0){break;}
		
		cin>>a;
		string nex="";
		
		for(int i=0;i<n;i++){
			int num;
			int cont=0;
			while(1){
				if(cont>=a.size()){break;}
				
				num=a[cont];
				
				int v=0;
				while(1){
					if(a[cont]!=num){break;}
					v++;
					cont++;
				}
				
				stringstream ss;
				ss<<v;
				
				nex+=ss.str();
				nex+=num;
			}
			a=nex;
			nex="";
		}
			cout<<a<<endl;
	}
}

Measured memory_bytes: 1052
// Amsal Shoma Ro Gaedan Ye Amal Pasandidas !

#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ll Mod = 1000000007LL;
const int N = 3e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

const int L = 100010;
const int K = 1024;

int n, dp[12][L];
int ans[N], v[N], w[N];

vector< pair<pll, ll> > Q[N];

vector<pll> V;
int lb[K];
int sv[K], sw[K];

void Build(){
	int nn = V.size();
	for(int mk = 1; mk < (1 << nn); mk ++){
		sv[mk] = sv[mk ^ (1 << lb[mk])] + V[lb[mk]].F;
		sw[mk] = sw[mk ^ (1 << lb[mk])] + V[lb[mk]].S;
	}
}

void Solve(int u, int d){
	if(u >= K) return ;
	if(u > n) return ;
	if(d == 0) memset(dp[d], 0, sizeof dp[d]);
	else memcpy(dp[d], dp[d - 1], sizeof dp[d - 1]);
	for(int i = L - 1; i >= w[u]; i--) dp[d][i] = max(dp[d][i], dp[d][i - w[u]] + v[u]);
	Solve(u << 1, d + 1);
	Solve(u << 1 | 1, d + 1);

	int vv, lp;
	for(auto x : Q[u]){
		vv = x.F.F; lp = x.F.S;
		V.clear();
		while(vv != u){
			V.pb({v[vv], w[vv]});
			vv /= 2;
		}
		int nn = V.size();
		Build();
		for(int mk = 0; mk < (1 << nn); mk ++){
			if(sw[mk] <= lp) ans[x.S] = max(ans[x.S], dp[d][lp - sw[mk]] + sv[mk]);
		}
	}
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	for(int i = 1; i < K; i++){
		for(int j = 0; j < 10; j++) if(i >> j & 1) lb[i] = j;
	} 
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> v[i] >> w[i];
	int q, u, up, l;
	cin >> q;
	for(int i = 1; i <= q; i++){
		cin >> u >> l;
		up = u;
		while(up >= K) up /= 2;
		Q[up].pb({{u, l}, i});
	}
	Solve(1, 0);

	for(int i = 1; i <= q; i++) cout << ans[i] << '\n';
	return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

ll n, k;
ll a[2 * 100000];
const ll tens = 1e9;

template <typename T>
T BinarySearch(T lo, T hi, std::function<bool(T)> pred) {
  while (lo + 1 < hi) {
    // T mid = (lo + hi) / 2;
    T mid = (hi - lo) / 2 + lo;
    if (pred(mid)) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  return lo;
}

// Returns the number of pairs whose values are equal to or less than x.
ll count(ll x) {
  ll cnt = 0;
  for (int i = 1; i < n; ++i) {
    if (a[i] < 0) {
      if (a[i-1] * a[i] <= x) {
        if (a[0] * a[i] <= x) {
          cnt += i;
          continue;
        }
        int j = BinarySearch<int>(0, i, [&](int idx) { return a[i] * a[idx] > x; });
        cnt += i - (j + 1);
      }
    } else {
      if (a[0] * a[i] <= x) {
        int j = BinarySearch<int>(0, i, [&](int idx) { return a[i] * a[idx] <= x; });
        cnt += j + 1;
      }
    }
  }
  return cnt;
}

int main() {
  cin >> n >> k;
  rep(i, n) cin >> a[i];
  sort(a, a + n);

  ll x = BinarySearch<ll>(-tens * tens - 1, tens * tens + 1, [&](ll x) {
    return count(x) < k;
  });
  dbg(x, count(x - 1), count(x), count(x + 1));
  out(x + 1);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;

int main(){
    iosetup;
    ll X, Y; IN(X,Y);
    if(abs(X - Y)>1) puts("Alice");
    else puts("Brown");
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  bool sei;
  bool muzu=true;
  cin>>H>>W;
  vector<vector<char>>vec(H,vector<char>(W));
  vector<vector<bool>>ve(H,vector<bool>(W,true));
  for (int X=0;X<H;X++){
    sei=true;
    for (int Y=0;Y<W;Y++){
      cin>>vec.at(X).at(Y);
      if(vec.at(X).at(Y)=='#'){
        sei=false;
      }
    }
    if(sei==true){
      for (int L=0;L<W;L++){
        ve.at(X).at(L)=false;
      }
    }
  }  
  for (int Y=0;Y<W;Y++){
    sei=true;
    for (int X=0;X<H;X++){
      if(vec.at(X).at(Y)=='#'){
        sei=false;
      }
    }
    if(sei==true){
      for (int L=0;L<H;L++){
        ve.at(L).at(Y)=false;
      }
    }
  }
  for (int X=0;X<H;X++){
    muzu=true;
    for (int Y=0;Y<W;Y++){
      if (ve.at(X).at(Y)==true){
        cout<<vec.at(X).at(Y);
      }
    }
    for (int Y=0;Y<W;Y++){
      if (ve.at(X).at(Y)==true){
        muzu=false;
      }
    }
    if(muzu==false){
      cout<<endl;
    }
  }
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int X = sc.nextInt();
		if (X>=A&&(A+B)>=X) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 24020
#include <iostream>

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

using namespace std;

	int n, m;
int s[205];
void solve(){
		rep(i,n) rep(j,m){
			int sum=0;
			rep(k,n+m){
				if( k != i && ( k<n || k == n+j ) ){
					sum += s[k];
				}else{
					sum -= s[k];
				}
			}
			if( sum == 0 ){
				cout << s[i] << " " << s[n+j] << endl;
				return;
			}
		}
		cout << -1 << endl;
}

int main(){
	while(cin>>n>>m, n|m){
		rep(i,n+m) cin >> s[i];
		solve();
	}
	return 0;
}

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

const int maxn = 1e5 + 10;
int a[maxn], b[maxn];

int main() {
	int A, B, m;
	scanf("%d%d%d", &A, &B, &m);
	for(int i = 1;i <= A;++i) scanf("%d", &a[i]);
	for(int i = 1;i <= B;++i) scanf("%d", &b[i]);
	int ans = *min_element(a + 1, a + 1 + A) + *min_element(b + 1,b + 1 + B);
	for(int i = 1;i <= m;++i) {
		int x, y, d;
		scanf("%d%d%d", &x, &y, &d);
		ans = min(ans, a[x] + b[y] - d);
	}
	printf("%d\n", ans);
}

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

typedef long long ll;
const int maxn = 1000005, mod = 998244353;

int T, n, m;
int inv[maxn], fac[maxn], ifac[maxn];

int C(int n, int m)
{
	return (ll)fac[n] * ifac[n - m] % mod * ifac[m] % mod;
}

int main()
{
	scanf("%d%d", &n, &m);

	if (n < m) swap(n, m);
	
	inv[1] = 1;
	for (int i = 2; i <= n + m; ++i) inv[i] = (ll)(mod - mod / i) * inv[mod % i] % mod;
	fac[0] = ifac[0] = 1;
	for (int i = 1; i <= n + m; ++i) fac[i] = (ll)fac[i - 1] * i % mod;
	for (int i = 1; i <= n + m; ++i) ifac[i] = (ll)ifac[i - 1] * inv[i] % mod;
	
	int ans = (ll)2 * n * C(n + m, n) % mod;
	for (int i = 1; i <= m; ++i)
		ans = (ans + (ll)C(i + i, i) * C(n + m - i - i, n - i)) % mod;
	
	printf("%lld\n", (ll)ans * ifac[n + m] % mod * fac[m] % mod * fac[n] % mod * inv[2] % mod);
	
	return 0;
}



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

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)


typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  int N, H, W;
  cin >> N >> H >> W;
  cout << (N - H + 1) * (N - W + 1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE


template<typename T>
class CumulativeSum{
public:
  Int n;
  vector<T> sum;
  vector<T> A;
  Int added;
  CumulativeSum():n(-1),added(0){}
  CumulativeSum(Int n):n(n), sum(n+1), A(n+1),added(0){}
  CumulativeSum(const vector<T> &B):n(B.size()), sum(n+1), A(n+1),added(0){
    for(Int i=1;i<=n;i++) sum[i] = sum[i-1] + B[i-1];
  }

  void apply(){
    for(Int i=1;i<=n;i++) A[i] = A[i] + A[i-1];
    for(Int i=1;i<=n;i++) A[i] = A[i] + A[i-1];
    for(Int i=1;i<=n;i++) sum[i] = sum[i] + A[i-1];
    added = 0; A.clear(); A.resize(n+1);
  }

  //[l, r)にxを加算
  void add(Int l, Int r, T x){
    added = 1;
    assert(l <= r && 0 <= l && r <= n);
    A[l] = A[l] + x;
    A[r] = A[r] - x;
  }

  //[l, r)の和を得る
  T get(Int l,Int r){
    assert(l<=r && 0<=l && r<=n);
    if(added) apply();
    return sum[r] - sum[l];
  }
};


signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int N;
  cin>>N;
  vector<Int> A(N);
  cin>>A;

  vector<Int> C(N+10);
  for(Int a:A) C[a]++;

  CumulativeSum <Int> sum(N+10);
  CumulativeSum <Int> sum2(N+10);
  for(Int c:C) if(c) sum.add(c, c+1, 1), sum2.add(c, c+1, c);

  //X回になる最大の長さ。
  auto calc = [&](Int X){
    Int a = sum.get(X, N+1);
    Int b = sum2.get(1, X) / X;
    return a + b;
  };


  vector<Int> ans(N+1, 0);
  for(Int i=1;i<=N;i++){
    Int len = calc(i);
    Max(ans[len], i);
  }

  for(Int i=N-1;i>=0;i--) Max(ans[i], ans[i+1]);
  for(Int i=1;i<=N;i++) cout<<ans[i]<<endl;



  return 0;
}


Measured memory_bytes: 17280
n,m=map(int,input().split())
for i in range(n):
    if i==0:
        a0=list(map(int,input().split()))	
        b0=a0[1:]
    else:
        a=list(map(int,input().split()))
        b=a[1:]
        c=[]
        for j in b0:
            if not j in b:
                c.append(j)
        for x in c:
            b0.remove(x)
print(len(b0))
    




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

int main(){
    int i,j,k;
    int N,M;
    int a,b;

    cin >> N >> M;

    vector<int> A(2500);
    vector<int> B(2500);

    for(i=0;i<M;i++){
        cin >> a >> b;
        A.at(a) ++;
        A.at(b) ++;
    }

    for(i=1;i<=N;i++)cout << A.at(i) << endl;

}

Measured memory_bytes: 256
import math
a, b, h, m = map(int, input().split())
# 角度を求める
H = 30 * h + (m/2)
M = 6 * m
theta = abs(H-M)
if theta == 0 or theta == 360:
  print(abs(a-b))
  exit()
if theta > 180:
  theta = 360 - theta
#print(a, b, H, M, theta, math.sin(theta), math.cos(theta), math.tan(theta), math.sin(math.radians(theta)), math.cos(math.radians(theta)), math.tan(math.radians(theta)))
l = a * a + b * b - 2 *a*b* math.cos(math.radians(theta))
print(math.sqrt(l))


Measured memory_bytes: 62484
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> T(N);
  int sum=0;
  for(int i=0;i<N;i++){
    cin>>T.at(i);
    sum = sum+T.at(i);
  }
  int M;
  cin>>M;
  vector<int> P(M),X(M);
  for(int i=0;i<M;i++){
    cin>>P.at(i)>>X.at(i);
  }
  for(int i=0;i<M;i++){
    int Y=sum;
    cout<<Y-T.at(P.at(i)-1)+X.at(i)<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
using namespace std;
int main()
{
  string s;
  cin >> s;
  string m=s.substr(5,6);
  string d=s.substr(8,9);
  if(stoi(m)<=4)
    cout << "Heisei" << endl;
  else
    cout << "TBD" << endl;
  return 0;
}

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

A = [None] * N
B = [None] * N

for n in range(N):
    A[n], B[n] = map(int, input().split())

C = zip(A, B)
C = sorted(C, key=lambda x: [x[0], x[1]], reverse=False)
A, B = map(list, zip(*C))

m = 0
r = 0

for i in range(N):
    a = A[i]
    b = B[i]
    if m + b < M:
        m += b
        r += a * b
    else:
        r += a * (M - m)
        break

print(r)


Measured memory_bytes: 29140
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e18;

int w[101], v[101], dp[101][301];
signed main(){
	int n, W;
	scanf("%lld%lld", &n, &W);
	for(int i = 0;i < n;i++){
		scanf("%lld%lld", &w[i], &v[i]);
	}
	
	int s = w[0];
	for(int i = 0;i < n;i++)w[i] -= s;
	for(int i = 0;i < n;i++){
		for(int j = 300;j >= 0;j--){
			for(int k = n;k >= 1;k--){
				dp[k][j] = max(dp[k][j], dp[k-1][j]);
				if(j-w[i] < 0)continue;
				dp[k][j] = max(dp[k][j], dp[k-1][j-w[i]]+v[i]);
			}
		}
	}
	
	int ans = 0;
	for(int i = 1;i <= n;i++){
		int mx = min((int)300, W-s*i);
		if(mx < 0)break;
		ans = max(ans, dp[i][mx]);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 512
data=str(input())
one=int(data[:2])
two=int(data[2:])
if 0<one<13 and 0<two<13:
  print("AMBIGUOUS")
elif 0<one<13:
  print("MMYY")
elif 0<two<13:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3060
// Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int t[5];
		cin >> t[0];

		if(t[0]==0)
			break;

		for(int i=1; i<5; i++){
			cin >> t[i];
		}

		int s[4] = {0};
		for(int i=0; i<5; i++){
			s[t[i]]++;
		}

		int r[5];
		if((s[2]==0&&s[3]==0)
		 ||(s[3]==0&&s[1]==0)
		 ||(s[1]==0&&s[2]==0)
		 ||(s[1]!=0&&s[2]!=0&&s[3]!=0)){
			for(int i=0; i<5; i++){
				r[i] = 3;
			}
		}
		else if(s[3]==0){
			for(int i=0; i<5; i++){
				if(t[i]==1){
					r[i] = 1;
				}
				else{
					r[i] = 2;
				}
			}
		}
		else if(s[1]==0){
			for(int i=0; i<5; i++){
				if(t[i]==2){
					r[i] = 1;
				}
				else{
					r[i] = 2;
				}
			}
		}
		else if(s[2]==0){
			for(int i=0; i<5; i++){
				if(t[i]==3){
					r[i] = 1;
				}
				else{
					r[i] = 2;
				}
			}
		}

		for(int i=0; i<5; i++){
			cout << r[i] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>

#define FOR(i, a, b) for(decltype(b) i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

using namespace std;

int main()
{
	int n, a, b;
	cin >> n >> a >> b;

    if ((ll)a * b < n || a + b > n + 1)
    {
        cout << -1 << endl;
        return 0;
    }

	vector<int> v(n);
    REP (i, n)
        v[i] = i + 1;
    
    int rem = a;
    auto it = v.begin();
    auto end = v.end();

    while (rem && rem < end - it)
    {
        auto tip = it + min(b, static_cast<int>(end - it) - (rem - 1));
        reverse(it, tip);
        it = tip;
        --rem;
    }
    
    REP (i, n)
        cout << (i ? " " : "") << v[i];
    cout << endl;

	return 0;
}


Measured memory_bytes: 3328
def main():

    import numpy as np

    X, N = map(int, input().split())
    p = np.array([int(x) for x in input().split()])
    #並び替えて差分の絶対値をとった後に並び替え
    p_sorted = np.sort(p)
    p_X_index = np.argsort(abs(p_sorted - X))
    p_sorted = p_sorted[p_X_index]

    i = 0
    while True :
        if np.count_nonzero(p_sorted == X - i) == 0:
            print(X - i)
            break
        elif np.count_nonzero(p_sorted == X + i) == 0:
            print(X + i)
            break
        i += 1

if __name__ == '__main__':
    main()

Measured memory_bytes: 27216
#include<iostream>
#include<cstring>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(n);++i)

int w,h;
int ans;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool visit[10][10];


inline bool check(int y,int x){
	return 0<=y&&y<h&&0<=x&&x<w;
}
int neighbor(int y,int x,char color,char panel[10][10]){
	int res=0;
	if(!check(y,x) || visit[y][x])return 0;
	if(panel[y][x]!=color){
		if(panel[y][x]=='R')return 1;
		if(panel[y][x]=='G')return 2;
		if(panel[y][x]=='B')return 4;
	}
	visit[y][x] = true;
	rep(i,4){
		res |= neighbor(y+dy[i],x+dx[i],color,panel);
	}
	return res;
}
void change(int y,int x,char from,char to,char panel[10][10]){
	if(!check(y,x) || from!=panel[y][x])return;
	panel[y][x] = to;
	rep(i,4){
		change(y+dy[i],x+dx[i],from,to,panel);
	}
}
void search(int depth,char panel[10][10]){
	if(ans<=depth)return;
	memset(visit,false,sizeof(visit));
	int diff = neighbor(0,0,panel[0][0],panel);
	if(diff==0){
		ans = depth;
		return;
	}
	char buf[10][10];
	rep(i,3){
		if((diff&1<<i)==0)continue;
		memcpy(buf,panel,sizeof(buf));
		change(0,0,buf[0][0], (i==0?'R':(i==1?'G':'B')),buf);
		search(depth+1,buf);
		if(ans <= depth+1)return;
	}
}
int main(){
	char panel[10][10];
	while(cin>>w>>h,w|h){
		rep(i,h)rep(j,w)cin>>panel[i][j];
		ans = INF;
		search(0,panel);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 872
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

const double EPS=1e-8;
bool EQ(double a,double b){
  return abs(a-b)<EPS;
}

int N,M;
double Dx[101];
double Dy[101];
double Dv[101];
double FPx[1001];
double FPy[1001];
double FVx[1001];
double FVy[1001];
double DVx[101];
double DVy[101];
int frbsCnt[1001];
bool isActive[101];
int main(){
  while(cin>>N>>M&&(N|M)){
    memset(frbsCnt,0,sizeof(frbsCnt));
    for(int i=0;i<N;i++)cin>>Dx[i]>>Dy[i]>>Dv[i];
    for(int i=0;i<M;i++)cin>>FPx[i]>>FPy[i]>>FVx[i]>>FVy[i];
    int getDog=-1;
    for(int f=0;f<M;f++){
      memset(isActive,0,sizeof(isActive));
      // tの最小値を計算
      double minT=1000000000;
      for(int i=0;i<N;i++){
	double a=FVy[f]*FVy[f]+FVx[f]*FVx[f]-Dv[i]*Dv[i];
	double b=FPy[f]*FVy[f]-Dy[i]*FVy[f]+FPx[f]*FVx[f]-Dx[i]*FVx[f];
	double c=FPx[f]*FPx[f]+FPy[f]*FPy[f]+Dx[i]*Dx[i]+Dy[i]*Dy[i]-2*FPy[f]*Dy[i]-2*FPx[f]*Dx[i];
	if(!EQ(a,0)&&a<0){
	  a*=-1;
	  b*=-1;
	  c*=-1;
	}
	//cout<<a<<" "<<b<<" "<<c<<endl;
	if(!EQ(b*b-a*c,0)&&b*b-a*c<0)continue;
	double t=(-b+sqrt(b*b-a*c))/a;
	if(!EQ(t,0)&&t<0)continue;
	if(EQ(0,(-b-sqrt(b*b-a*c))/a)||(0<(-b-sqrt(b*b-a*c))/a))
	  if(t>(-b-sqrt(b*b-a*c))/a)
	    t=(-b-sqrt(b*b-a*c))/a;
	isActive[i]=true;
	if(minT>t){
	  minT=t;
	  getDog=i;
	}
	DVx[i]=(FPx[f]-Dx[i]+t*FVx[f])/t;
	DVy[i]=(FPy[f]-Dy[i]+t*FVy[f])/t;
      }
      if(getDog!=-1)frbsCnt[getDog]++;
      // minTに基づいてそれぞれ移動
      for(int i=0;i<N;i++){
	if(!isActive[i])continue;
	Dx[i]=Dx[i]+DVx[i]*minT;
	Dy[i]=Dy[i]+DVy[i]*minT;
      }
    }
    for(int i=0;i<N;i++){
      cout<<frbsCnt[i];
      if(i!=N-1)cout<<" ";
      else cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1004
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
  double x=0,y=0,vec=90,dis,angle;
  for(;;){
    scanf("%lf,%lf",&dis,&angle);
    if(dis == 0 && angle == 0){break;}
    x+=dis*cos(vec*M_PI/180.0);
    y+=dis*sin(vec*M_PI/180.0);
    vec-=angle;
  }
  cout <<(int)x<<endl<<(int)y<<endl;
  return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;

int main()
{
    int N, p[100010];
    vector<int> v;
    cin >> N;
    REP(i, N)
    {
        cin >> p[i];
        if (p[i] == i + 1)
        {
            v.push_back(i);
        }
    }

    int ans = 0;
    REP(i, N)
    {
        if (i + 1 == p[i])
        {
            ans++;
            if (i == 0)
            {
                p[i] = p[i + 1];
                p[i + 1] = i + 1;
                continue;
            }
            if (i == N - 1)
            {
                p[i] = p[i - 1];
                p[i - 1] = i + 1;
                continue;
            }
            if (p[i + 1] == i + 1)
            {
                p[i] = p[i - 1];
                p[i - 1] = i + 1;
            }
            else
            {
                p[i] = p[i + 1];
                p[i + 1] = i + 1;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	int n, s;
	while (cin >> n >> s, n, s) {
		int a[22000];
		for (int i = 0;i < n;i++)cin >> a[i];
		int ans = 0;
		for (int i = 0;i < n;i++)
		for (int j = i + 1;j < n;j++)
		if (s < a[i] + a[j])ans++;
		cout << ans << endl;
	}
}

Measured memory_bytes: 3004
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=200111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


struct UnionFind {
	vector<int> par;
	UnionFind(int n) : par(n, -1) { }

	int root(int x) {
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool same(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y) {
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y); // merge technique
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x) {
		return -par[root(x)];
	}
};

vvl comb(int n, int r) {
	vvl v(n + 1,vl(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v;
}

void sosu(ll x,bool f[]){
	ll y=x;
	for(ll i=2;i<=sqrt(y);i++){
		if(x%i==0){
			x/=i;
			f[i]=true;
			i--;
		}
	}
}

ll __gcd(ll x,ll y){
	if(x<y)swap(x,y);
	while(1){
		ll tmp=x%y;
		x=y;
		y=tmp;
		if(y==0)break;
	}
	return x;
}

int keta(ll a){
	int ke=1;
	while(a/=10)ke++;
	return ke;
}

int n,a,b,cnt=0;
int flag[M];
int dist1[M]={},distn[M]={};
vi g[M];

void __dist(int node,int y[]){
	flag[node]=true;
	for(auto x:g[node])
		if(!flag[x]){
			y[x]=(y[node]+1);
			__dist(x,y);
		}
}

int main(){
	ll n,k;
	cin>>n>>k;
	print(min(n%k,k-n%k));
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    if(k <= 200000) {
        int q = 0;
        while(k) {
            q = a[q];
            k--;
        }
        cout << q + 1 << endl;
        return 0;
    }
    vector<int> visited(n, 0);
    vector<int> last(n, 0);
    int p = 0, c = 0;
    for(int i = 0; i < last.size(); i++) {
        visited[p]++;
        if(visited[p] == 2) {
            c = i - last[p];
            break;
        }
        last[p] = i;
        p = a[p];
    }
    // cout << c << endl;
    k -= last[p];
    k %= c;
    while(k) {
        p = a[p];
        k--;
    }
    cout << p + 1 << endl;
}

Measured memory_bytes: 6428
#include<iostream>

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    int cnt;
    if(b<=a){
        cnt++;
    }else if(b%a==0){
        cnt=b/a;
    }else{
        cnt=b/a+1;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3104