process.stdin.resume();
process.stdin.setEncoding('utf8');
// your code goes here
var console = {
log: function(s) {
process.stdout.write(s+"\n");
},
};
var count_hash = {};
function callcounter(func) {
count_hash[func.name] = 0;
return function() {
count_hash[func.name] += 1;
return func.apply(this, arguments);
};
}
function foo() { } /* カウントしたい関数 */
foo = callcounter(foo); /* fooをクロージャと差し替え */
for (var i = 0; i < 100; i++) {
foo();
}
console.log(count_hash.foo); // 100
cHJvY2Vzcy5zdGRpbi5yZXN1bWUoKTsKcHJvY2Vzcy5zdGRpbi5zZXRFbmNvZGluZygndXRmOCcpOwoKLy8geW91ciBjb2RlIGdvZXMgaGVyZQoKdmFyIGNvbnNvbGUgPSB7Cglsb2c6IGZ1bmN0aW9uKHMpIHsKCQlwcm9jZXNzLnN0ZG91dC53cml0ZShzKyJcbiIpOwoJfSwKfTsKCnZhciBjb3VudF9oYXNoID0ge307CgpmdW5jdGlvbiBjYWxsY291bnRlcihmdW5jKSB7CiAgICBjb3VudF9oYXNoW2Z1bmMubmFtZV0gPSAwOwogICAgcmV0dXJuIGZ1bmN0aW9uKCkgewogICAgICAgIGNvdW50X2hhc2hbZnVuYy5uYW1lXSArPSAxOwogICAgICAgIHJldHVybiBmdW5jLmFwcGx5KHRoaXMsIGFyZ3VtZW50cyk7CiAgICB9Owp9CgpmdW5jdGlvbiBmb28oKSB7ICB9IC8qIOOCq+OCpuODs+ODiOOBl+OBn+OBhOmWouaVsCAqLwoKZm9vID0gY2FsbGNvdW50ZXIoZm9vKTsgIC8qIGZvb+OCkuOCr+ODreODvOOCuOODo+OBqOW3ruOBl+abv+OBiCAqLwoKZm9yICh2YXIgaSA9IDA7IGkgPCAxMDA7IGkrKykgewoJZm9vKCk7Cn0KCmNvbnNvbGUubG9nKGNvdW50X2hhc2guZm9vKTsgLy8gMTAwCg==