#include <cstdio>

int ncall;

int call[100];

void solve(int K)

{

if (!K) return;

if (K % 2 == 0) {

call[ncall] = ++ncall;

if (K > 2) solve(K / 2);

} else {

call[ncall++] = -1;

solve(K - 1);

}

}

int main( void )

{

// freopen( "p1278.in", "r", stdin );

int K;

scanf( "%d", &K );

if (K > 1) solve(K);

for (int i = 0; i < ncall; i++)

printf( "CALL %d\n", call[i] < 0 ? ncall : call[i] );

printf( "BELL&RET\n" );

return 0;

}

For test #1, K = 4, and my code output:

CALL 1

CALL 2

BELL&RET

I think it's correct.