#include <iostream>
#include <vector>
using namespace std;
template<typename t_find>
bool contains(const t_find& i_find)
{
return false;
}
template<typename t_find, typename... t_rest>
bool contains(const t_find& i_find, t_find&& i_head, t_rest&&... i_rest)
{
return i_find == i_head ? true : contains(i_find, std::forward<t_rest>(i_rest)...);
}
template<typename t_find, typename t_head, typename... t_rest>
bool contains(const t_find& i_find, t_head&& i_head, t_rest&&... i_rest)
{
return contains(i_find, std::forward<t_rest>(i_rest)...);
}
int main() {
printf("contains 0: %i\n", contains(0, 1,2,3,4) ? 1 : 0);
printf("contains 1: %i\n", contains(1, 1,2,3,4) ? 1 : 0);
printf("contains 2: %i\n", contains(2, 1,2,3,4) ? 1 : 0);
printf("contains 3: %i\n", contains(3, 1,2,3,4) ? 1 : 0);
printf("contains 4: %i\n", contains(4, 1,2,3,4) ? 1 : 0);
printf("contains 5: %i\n", contains(5, 1,2,3,4) ? 1 : 0);
// your code goes here
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdGVtcGxhdGU8dHlwZW5hbWUgdF9maW5kPgpib29sIGNvbnRhaW5zKGNvbnN0IHRfZmluZCYgaV9maW5kKQp7CiAgICByZXR1cm4gZmFsc2U7Cn0KCnRlbXBsYXRlPHR5cGVuYW1lIHRfZmluZCwgdHlwZW5hbWUuLi4gdF9yZXN0Pgpib29sIGNvbnRhaW5zKGNvbnN0IHRfZmluZCYgaV9maW5kLCB0X2ZpbmQmJiBpX2hlYWQsIHRfcmVzdCYmLi4uIGlfcmVzdCkKewogICAgcmV0dXJuIGlfZmluZCA9PSBpX2hlYWQgPyB0cnVlIDogY29udGFpbnMoaV9maW5kLCBzdGQ6OmZvcndhcmQ8dF9yZXN0PihpX3Jlc3QpLi4uKTsKfQoKdGVtcGxhdGU8dHlwZW5hbWUgdF9maW5kLCB0eXBlbmFtZSB0X2hlYWQsIHR5cGVuYW1lLi4uIHRfcmVzdD4KYm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