#include <iostream>
void skip(int n) {
}
void print(int n) {
std::cout << n;
}
void (*test(int d, char const* c, void (*k)(int n), int n))(int n) {
if (n % d) {
return k;
}
std::cout << c;
return skip;
}
void fizzbuzz(int n) {
auto k = print;
k = test(3, "fizz", k, n);
k = test(5, "buzz", k, n);
k(n);
}
int main() {
for (int i = 1; i <= 20; ++i) {
fizzbuzz(i);
std::cout << '\n';
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdm9pZCBza2lwKGludCBuKSB7Cn0KCnZvaWQgcHJpbnQoaW50IG4pIHsgCglzdGQ6OmNvdXQgPDwgbjsgCn0KCnZvaWQgKCp0ZXN0KGludCBkLCBjaGFyIGNvbnN0KiBjLCB2b2lkICgqaykoaW50IG4pLCBpbnQgbikpKGludCBuKSB7CglpZiAobiAlIGQpIHsKCQlyZXR1cm4gazsKCX0KCXN0ZDo6Y291dCA8PCBjOyAKCXJldHVybiBza2lwOwp9Cgp2b2lkIGZpenpidXp6KGludCBuKSB7CglhdXRvIGsgPSBwcmludDsKCWsgPSB0ZXN0KDMsICJmaXp6Iiwgaywgbik7CglrID0gdGVzdCg1LCAiYnV6eiIsIGssIG4pOwoJayhuKTsKfQoKaW50IG1haW4oKSB7Cglmb3IgKGludCBpID0gMTsgaSA8PSAyMDsgKytpKSB7CgkJZml6emJ1enooaSk7CgkJc3RkOjpjb3V0IDw8ICdcbic7Cgl9Cn0K