Problem:
Problem Statement
Let's consider operations on monochrome images that consist of hexagonal pixels, each of which is colored in either black or white.  Because of the shape of pixels, each of them has exactly six neighbors (e.g. pixels that share an edge with it.)
"
Filtering
" is an operation to determine the color of a pixel from the colors of itself and its six neighbors.  Examples of filterings are shown below.
Example 1: Color a pixel in white when all of its neighboring pixels are white.  Otherwise the color will not change.
Performing this operation on all the pixels simultaneously results in "
noise canceling,
" which removes isolated black pixels.
Example 2: Color a pixel in white when its all neighboring pixels are black. Otherwise the color will not change.
Performing this operation on all the pixels simultaneously results in "
edge detection,
" which leaves only the edges of filled areas.
Example 3: Color a pixel with the color of the pixel just below it, ignoring any other neighbors.
Performing this operation on all the pixels simultaneously results in "
shifting up
" the whole image by one pixel.
Applying some filter, such as "
noise canceling
" and "
edge detection,
" twice to any image yields the exactly same result as if they were applied only once.
We call such filters
idempotent
. The "
shifting up
" filter is not idempotent since every repeated application shifts the image up by one pixel.
Your task is to determine whether the given filter is idempotent or not.
Input
The input consists of multiple datasets.  The number of dataset is less than $100$.
Each dataset is a string representing a filter and has the following format (without spaces between digits).
$c_0c_1\cdots{}c_{127}$
$c_i$ is either '
0
' (represents black) or '
1
' (represents white), which indicates the output of the filter for a pixel when the binary representation of the pixel and its neighboring six pixels is $i$. 
The mapping from the pixels to the bits is as following:
and the binary representation $i$ is defined as $i = \sum_{j=0}^6{\mathit{bit}_j \times 2^j}$,
where $\mathit{bit}_j$ is $0$ or $1$ if the corresponding pixel is in black or white, respectively.
Note that the filter is applied on the center pixel, denoted as bit 3.
The input ends with a line that contains only a single "
#
".
Output
For each dataset, print "
yes
" in a line if the given filter is idempotent, or "
no
" otherwise (quotes are for clarity).
Sample Input
00000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000111111111
10000000111111110000000011111111000000001111111100000000111111110000000011111111000000001111111100000000111111110000000011111111
01010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101
#
Output for the Sample Input
yes
yes
no

Submitted solutions:

code_snippet: #include <iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
char buf[200];
int Make(int a,int b,int c,int d,int e,int f,int g)
{
    return g*64+f*32+e*16+d*8+c*4+b*2+a;
}
int s[22];
bool dfs(int depth)
{
    if(depth==12)
    {
        for(int i=0;i<128;i++)
        {
            int b[8]={0};
            for(int j=0;j<7;j++)
            {
                if(i>>j&1) b[j]=1;
                else b[j]=0;
            }
            int c[8]={0};
            c[0]=buf[Make(s[0],s[1],s[11],b[0],b[1],b[2],b[3])];

            c[1]=buf[Make(s[1],s[2],b[0],b[1],s[3],b[3],b[4])];

            c[2]=buf[Make(s[11],b[0],s[10],b[2],b[3],s[9],b[5])];

            c[3]=buf[Make(b[0],b[1],b[2],b[3],b[4],b[5],b[6])];

            c[4]=buf[Make(b[1],s[3],b[3],b[4],s[4],b[6],s[5])];

            c[5]=buf[Make(b[2],b[3],s[9],b[5],b[6],s[8],s[7])];

            c[6]=buf[Make(b[3],b[4],b[5],b[6],s[5],s[7],s[6])];

            int t=buf[Make(c[0],c[1],c[2],c[3],c[4],c[5],c[6])];

            if(t!=c[3]) return true;
        }
        return false;
    }
    s[depth]=0;
    if(dfs(depth+1))
        return true;
    s[depth]=1;
    if(dfs(depth+1))
        return true;
    return false;
}
int main()
{
    while(1)
    {
        scanf("%s",buf);
        if(buf[0]=='#') break;
        for(int i=0;i<128;i++)
        {
            buf[i]-='0';
        }
        if(dfs(0)){
            printf("no\n");
        }
        else
            printf("yes\n");
    }

    return 0;
}
accuracy: 1
time_ms: 230
memory_kb: 3504
final_rank: 1

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rrep(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) sort(ALL(v)), (v).erase(unique(ALL(v)), (v).end())
#define SZ(v) (int)v.size()
#define MIN(v) *min_element(ALL(v))
#define MAX(v) *max_element(ALL(v))
#define LB(v, x) int(lower_bound(ALL(v), (x)) - (v).begin())
#define UB(v, x) int(upper_bound(ALL(v), (x)) - (v).begin())

using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long;
using i128 = __int128_t;
using u128 = __uint128_t;
const int inf = 0x3fffffff;
const ll INF = 0x1fffffffffffffff;

template <typename T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T, typename U> T ceil(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? (x + y - 1) / y : x / y);
}
template <typename T, typename U> T floor(T x, U y) {
    assert(y != 0);
    if (y < 0)
        x = -x, y = -y;
    return (x > 0 ? x / y : (x - y + 1) / y);
}
template <typename T> int popcnt(T x) {
    return __builtin_popcountll(x);
}
template <typename T> int topbit(T x) {
    return (x == 0 ? -1 : 63 - __builtin_clzll(x));
}
template <typename T> int lowbit(T x) {
    return (x == 0 ? -1 : __builtin_ctzll(x));
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "P(" << p.first << ", " << p.second << ")";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &map_var) {
    os << "{";
    for (auto itr = map_var.begin(); itr != map_var.end(); itr++) {
        os << "(" << itr->first << ", " << itr->second << ")";
        itr++;
        if (itr != map_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
template <typename T> ostream &operator<<(ostream &os, const set<T> &set_var) {
    os << "{";
    for (auto itr = set_var.begin(); itr != set_var.end(); itr++) {
        os << *itr;
        ++itr;
        if (itr != set_var.end())
            os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
#ifdef LOCAL
#define show(...) _show(0, #__VA_ARGS__, __VA_ARGS__)
#else
#define show(...) true
#endif
template <typename T> void _show(int i, T name) {
    cerr << '\n';
}
template <typename T1, typename T2, typename... T3>
void _show(int i, const T1 &a, const T2 &b, const T3 &...c) {
    for (; a[i] != ',' && a[i] != '\0'; i++)
        cerr << a[i];
    cerr << ":" << b << " ";
    _show(i + 1, a, c...);
}

#include <unistd.h>

namespace fastio {
static constexpr uint32_t SZ = 1 << 17;
char ibuf[SZ];
char obuf[SZ];
char out[100];
// pointer of ibuf, obuf


uint32_t pil = 0, pir = 0, por = 0;

struct Pre {
    char num[10000][4];
    constexpr Pre() : num() {
        for (int i = 0; i < 10000; i++) {
            int n = i;
            for (int j = 3; j >= 0; j--) {
                num[i][j] = n % 10 | '0';
                n /= 10;
            }
        }
    }
} constexpr pre;

inline void load() {
    memmove(ibuf, ibuf + pil, pir - pil);
    pir = pir - pil + fread(ibuf + pir - pil, 1, SZ - pir + pil, stdin);
    pil = 0;
    if (pir < SZ)
        ibuf[pir++] = '\n';
}

inline void flush() {
    fwrite(obuf, 1, por, stdout);
    por = 0;
}

void rd(char &c) {
    do {
        if (pil + 1 > pir)
            load();
        c = ibuf[pil++];
    } while (isspace(c));
}

void rd(string &x) {
    x.clear();
    char c;
    do {
        if (pil + 1 > pir)
            load();
        c = ibuf[pil++];
    } while (isspace(c));
    do {
        x += c;
        if (pil == pir)
            load();
        c = ibuf[pil++];
    } while (!isspace(c));
}

template <typename T> void rd_real(T &x) {
    string s;
    rd(s);
    x = stod(s);
}

template <typename T> void rd_integer(T &x) {
    if (pil + 100 > pir)
        load();
    char c;
    do
        c = ibuf[pil++];
    while (c < '-');
    bool minus = 0;
    if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
        if (c == '-') {
            minus = 1, c = ibuf[pil++];
        }
    }
    x = 0;
    while ('0' <= c) {
        x = x * 10 + (c & 15), c = ibuf[pil++];
    }
    if constexpr (is_signed<T>::value || is_same_v<T, i128>) {
        if (minus)
            x = -x;
    }
}

void rd(int &x) {
    rd_integer(x);
}
void rd(ll &x) {
    rd_integer(x);
}
void rd(i128 &x) {
    rd_integer(x);
}
void rd(uint &x) {
    rd_integer(x);
}
void rd(ull &x) {
    rd_integer(x);
}
void rd(u128 &x) {
    rd_integer(x);
}
void rd(double &x) {
    rd_real(x);
}
void rd(long double &x) {
    rd_real(x);
}

template <class T, class U> void rd(pair<T, U> &p) {
    return rd(p.first), rd(p.second);
}
template <size_t N = 0, typename T> void rd_tuple(T &t) {
    if constexpr (N < std::tuple_size<T>::value) {
        auto &x = std::get<N>(t);
        rd(x);
        rd_tuple<N + 1>(t);
    }
}
template <class... T> void rd(tuple<T...> &tpl) {
    rd_tuple(tpl);
}

template <size_t N = 0, typename T> void rd(array<T, N> &x) {
    for (auto &d : x)
        rd(d);
}
template <class T> void rd(vector<T> &x) {
    for (auto &d : x)
        rd(d);
}

void read() {}
template <class H, class... T> void read(H &h, T &...t) {
    rd(h), read(t...);
}

void wt(const char c) {
    if (por == SZ)
        flush();
    obuf[por++] = c;
}
void wt(const string s) {
    for (char c : s)
        wt(c);
}
void wt(const char *s) {
    size_t len = strlen(s);
    for (size_t i = 0; i < len; i++)
        wt(s[i]);
}

template <typename T> void wt_integer(T x) {
    if (por > SZ - 100)
        flush();
    if (x < 0) {
        obuf[por++] = '-', x = -x;
    }
    int outi;
    for (outi = 96; x >= 10000; outi -= 4) {
        memcpy(out + outi, pre.num[x % 10000], 4);
        x /= 10000;
    }
    if (x >= 1000) {
        memcpy(obuf + por, pre.num[x], 4);
        por += 4;
    } else if (x >= 100) {
        memcpy(obuf + por, pre.num[x] + 1, 3);
        por += 3;
    } else if (x >= 10) {
        int q = (x * 103) >> 10;
        obuf[por] = q | '0';
        obuf[por + 1] = (x - q * 10) | '0';
        por += 2;
    } else
        obuf[por++] = x | '0';
    memcpy(obuf + por, out + outi + 4, 96 - outi);
    por += 96 - outi;
}

template <typename T> void wt_real(T x) {
    ostringstream oss;
    oss << fixed << setprecision(15) << double(x);
    string s = oss.str();
    wt(s);
}

void wt(int x) {
    wt_integer(x);
}
void wt(ll x) {
    wt_integer(x);
}
void wt(i128 x) {
    wt_integer(x);
}
void wt(uint x) {
    wt_integer(x);
}
void wt(ull x) {
    wt_integer(x);
}
void wt(u128 x) {
    wt_integer(x);
}
void wt(double x) {
    wt_real(x);
}
void wt(long double x) {
    wt_real(x);
}

template <class T, class U> void wt(const pair<T, U> val) {
    wt(val.first);
    wt(' ');
    wt(val.second);
}
template <size_t N = 0, typename T> void wt_tuple(const T t) {
    if constexpr (N < std::tuple_size<T>::value) {
        if constexpr (N > 0) {
            wt(' ');
        }
        const auto x = std::get<N>(t);
        wt(x);
        wt_tuple<N + 1>(t);
    }
}
template <class... T> void wt(tuple<T...> tpl) {
    wt_tuple(tpl);
}
template <class T, size_t S> void wt(const array<T, S> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
        if (i)
            wt(' ');
        wt(val[i]);
    }
}
template <class T> void wt(const vector<T> val) {
    auto n = val.size();
    for (size_t i = 0; i < n; i++) {
        if (i)
            wt(' ');
        wt(val[i]);
    }
}

void print() {
    wt('\n');
}
template <class Head, class... Tail> void print(Head &&head, Tail &&...tail) {
    wt(head);
    if (sizeof...(Tail))
        wt(' ');
    print(forward<Tail>(tail)...);
}
void __attribute__((destructor)) _d() {
    flush();
}
} // namespace fastio


using fastio::flush;
using fastio::print;
using fastio::read;

inline void first(bool i = true) {
    print(i ? "first" : "second");
}
inline void Alice(bool i = true) {
    print(i ? "Alice" : "Bob");
}
inline void Takahashi(bool i = true) {
    print(i ? "Takahashi" : "Aoki");
}
inline void yes(bool i = true) {
    print(i ? "yes" : "no");
}
inline void Yes(bool i = true) {
    print(i ? "Yes" : "No");
}
inline void No() {
    print("No");
}
inline void YES(bool i = true) {
    print(i ? "YES" : "NO");
}
inline void NO() {
    print("NO");
}
inline void Yay(bool i = true) {
    print(i ? "Yay!" : ":(");
}
inline void Possible(bool i = true) {
    print(i ? "Possible" : "Impossible");
}
inline void POSSIBLE(bool i = true) {
    print(i ? "POSSIBLE" : "IMPOSSIBLE");
}

/**
 * @brief Fast IO
 */

int A[128] = {};

int f(int a0, int a1, int a2, int a3, int a4, int a5, int a6) {
    return A[a0+a1*2+a2*4+a3*8+a4*16+a5*32+a6*64];
}

bool Solve() {
    rep(i,0,1<<19) {
        int B[19] = {};
        rep(j,0,19) if (i & (1<<j)) B[j] = 1;
        if (f(f(B[0],B[1],B[2],B[4],B[6],B[7],B[9]),
              f(B[1],B[3],B[4],B[6],B[8],B[9],B[11]),
              f(B[2],B[4],B[5],B[7],B[9],B[10],B[12]),
              f(B[4],B[6],B[7],B[9],B[11],B[12],B[14]),
              f(B[6],B[8],B[9],B[11],B[13],B[14],B[16]),
              f(B[7],B[9],B[10],B[12],B[14],B[15],B[17]),
              f(B[9],B[11],B[12],B[14],B[16],B[17],B[18])) != f(B[4],B[6],B[7],B[9],B[11],B[12],B[14])) return false;
    }
    return true;
}

int main() {
while(1) {
    string S;
    cin >> S;
    if (S == "#") return 0;
    rep(i,0,128) A[i] = S[i] - '0';
    cout << (Solve() ? "yes" : "no") << endl;
}
}
accuracy: 1
time_ms: 1260
memory_kb: 3380
final_rank: 2

code_snippet: #line 2 "cp-library/src/cp-template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull  = unsigned long long;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128_t;
template < class T > bool chmin(T& a, T b) { if(a > b) { a = b; return true; } return false; }
template < class T > bool chmax(T& a, T b) { if(a < b) { a = b; return true; } return false; }
template < class T, class U > T ceil (T x, U y) { return (x > 0 ? (x + y - 1) / y :           x / y); }
template < class T, class U > T floor(T x, U y) { return (x > 0 ?           x / y : (x - y + 1) / y); }
int popcnt(i32 x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(i64 x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }

#line 2 "cp-library/src/utility/rep_itr.hpp"
template < class T > struct itr_rep {
    T i, d;
    constexpr itr_rep(const T i) noexcept : i(i), d(1) {}
    constexpr itr_rep(const T i, const T d) noexcept : i(i), d(d) {}
    void operator++() noexcept { i += d; }
    constexpr int operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr_rep x) const noexcept { return d > 0 ? i < x.i : i > x.i; }
};

template < class T > struct rep {
    const itr_rep< T > s, t;
    constexpr rep(const T t) noexcept : s(0), t(t) {}
    constexpr rep(const T s, const T t) noexcept : s(s), t(t) {}
    constexpr rep(const T s, const T t, const T d) noexcept : s(s, d), t(t, d) {}
    constexpr auto begin() const noexcept { return s; }
    constexpr auto end  () const noexcept { return t; }
};

template < class T > struct revrep {
    const itr_rep < T > s, t;
    constexpr revrep(const T t) noexcept : s(t - 1, -1), t(-1, -1) {}
    constexpr revrep(const T s, const T t) noexcept : s(t - 1, -1), t(s - 1, -1) {}
    constexpr revrep(const T s, const T t, const T d) noexcept : s(t - 1, -d), t(s - 1, -d) {}
    constexpr auto begin() const noexcept { return s; }
    constexpr auto end  () const noexcept { return t; }
};
#line 3 "cp-library/src/utility/io.hpp"

/* 128bit integer */
istream& operator>>(istream& is, i128& x) {
    std::string s; is >> s;
    int pm = (s[0] == '-');
    x = 0;
    for(int i : rep(pm, int(s.size()))) x = x * 10 + (s[i] - '0');
    if(pm) x *= -1;
    return is;
}
ostream& operator<<(ostream& os, const i128& x) {
    if(x == 0) return os << '0';
    i128 y = x;
    if(y < 0) { os << '-'; y *= -1; }
    std::vector<int> ny;
    while(y > 0) { ny.push_back(y % 10); y /= 10; }
    for(int i : revrep(ny.size())) os << ny[i];
    return os;
}

template < class S, class T > istream& operator>>(istream& is,       std::pair< S, T >& x) { is >> x.first        >> x.second; return is; }
template < class S, class T > ostream& operator<<(ostream& os, const std::pair< S, T >& x) { os << x.first << " " << x.second; return os; }

namespace scanner {
    struct sca {
        template < class T > operator T() {
            T s; std::cin >> s; return s;
        }
    };
    struct vec {
        int n;
        vec(int n) : n(n) {}
        template < class T > operator std::vector< T >() {
            std::vector< T > v(n);
            for(T& x : v) std::cin >> x;
            return v;
        }
    };
    struct mat {
        int h, w;
        mat(int h, int w) : h(h), w(w) {}
        template < class T > operator std::vector< std::vector< T > >() {
            std::vector m(h, std::vector< T >(w));
            for(std::vector< T >& v : m) for(T& x : v) std::cin >> x;
            return m;
        }
    };
    struct speedup {
        speedup() {
            std::cin.tie(0);
            std::ios::sync_with_stdio(0);
        }
    } speedup_instance;
}
scanner::sca in() { return scanner::sca(); }
scanner::vec in(int n) { return scanner::vec(n); }
scanner::mat in(int h, int w) { return scanner::mat(h, w); }

namespace printer {
    void precision(int d) { std::cout << std::fixed << std::setprecision(d); }
    void flush() { std::cout.flush(); }
}

template < class T >
ostream& operator<<(ostream& os, const std::vector< T > a) {
    int n = a.size();
    for(int i : rep(n)) { os << a[i]; if(i != n - 1) os << ' '; }
    return os;
}

int print() { std::cout << '\n'; return 0; }
template < class head, class... tail > int print(head&& h, tail&&... t) {
    std::cout << h; if(sizeof...(tail)) std::cout << ' ';
    return print(std::forward<tail>(t)...);
}
template < class T > int print_n(const std::vector< T > a) {
    int n = a.size();
    for(int i : rep(n)) std::cout << a[i] << "\n";
    return 0;
}


#line 2 "cp-library/src/utility/key_val.hpp"

template < class K, class V >
struct key_val {
    K key; V val;
    key_val() {}
    key_val(K key, V val) : key(key), val(val) {}
    template < std::size_t Index >
    std::tuple_element_t< Index, key_val >& get() {
        if constexpr (Index == 0) return key;
        if constexpr (Index == 1) return val;
    }
};

namespace std {

template < class K, class V > struct tuple_size < key_val< K, V > > : integral_constant< size_t, 2 > {};
template < class K, class V > struct tuple_element < 0, key_val< K, V > > { using type = K; };
template < class K, class V > struct tuple_element < 1, key_val< K, V > > { using type = V; };

}
#line 2 "cp-library/src/utility/vec_op.hpp"
template < class T > key_val< int, T > max_of(const vector< T >& a) {
    int i = std::max_element(a.begin(), a.end()) - a.begin();
    return {i, a[i]};
}
template < class T > key_val< int, T > min_of(const vector< T >& a) {
    int i = std::min_element(a.begin(), a.end()) - a.begin();
    return {i, a[i]};
}
template < class S, class T > S sum_of(const vector< T >& a) {
    S sum = 0;
    for(const T x : a) sum += x;
    return sum;
}
template < class S, class T > vector< S > freq_of(const vector< T >& a, T L, T R) {
    vector< S > res(R - L, S(0));
    for(const T x : a) res[x - L] += 1;
    return res;
}
template < class S, class T > struct prefix_sum {
    vector< S > s;
    prefix_sum(const vector< T >& a) : s(a) {
        s.insert(s.begin(), S(0));
        for(int i : rep(a.size())) s[i + 1] += s[i];
    }
    // [L, R)
    S sum(int L, int R) { return s[R] - s[L]; }
};
#line 3 "cp-library/src/utility/heap.hpp"

template < class T > using heap_min = std::priority_queue< T, std::vector< T >, std::greater< T > >;
template < class T > using heap_max = std::priority_queue< T, std::vector< T >, std::less< T > >;

#line 27 "cp-library/src/cp-template.hpp"

#line 1 "cp-library/src/algorithm/bin_search.hpp"
template < class T, class F >
T bin_search(T ok, T ng, F f) {
    while(abs(ng - ok) > 1) {
        T mid = (ok + ng) / 2;
        (f(mid) ? ok : ng) = mid;
    }
    return ok;
}

template < class T, class F >
T bin_search_real(T ok, T ng, F f, int step = 80) {
    while(step--) {
        T mid = (ok + ng) / 2;
        (f(mid) ? ok : ng) = mid;
    }
    return ok;
}
#line 2 "cp-library/src/algorithm/argsort.hpp"

template < class T > std::vector< int > argsort(const std::vector< T > &a) {
    std::vector< int > ids((int)a.size());
    std::iota(ids.begin(), ids.end(), 0);
    std::sort(ids.begin(), ids.end(), [&](int i, int j) {
        return a[i] < a[j] || (a[i] == a[j] && i < j);
    });
    return ids;
}
#line 1 "macro.hpp"
namespace macro {

using size_type = int;
template < class container > void  sort(container& a) { std::sort(std:: begin(a), std:: end(a)); }
template < class container > void rsort(container& a) { std::sort(std::rbegin(a), std::rend(a)); }
template < class container > void reverse(container& a) { std::reverse(std::begin(a), std::end(a)); }
template < class container > void unique(container& a) {
    std::sort(std::begin(a), std::end(a));
    a.erase(std::unique(std::begin(a), std::end(a)), std::end(a));
}
template < class container > container  sorted(const container& a) { container b = a;  sort(b); return std::move(b); }
template < class container > container rsorted(const container& a) { container b = a; rsort(b); return std::move(b); }
template < class container, class compare > void sort(container& a, const compare& cmp) { std::sort(std::begin(a), std::end(a), cmp); }
template < class container, class compare > container sorted(const container& a, const compare& cmp) { container b = a; sort(b, cmp); return std::move(b); }
template < class container, class value > size_type lower_bound(const container& a, const value& x) { return std::lower_bound(std::begin(a), std::end(a), x) - std::begin(a); }
template < class container, class value > size_type upper_bound(const container& a, const value& x) { return std::upper_bound(std::begin(a), std::end(a), x) - std::begin(a); }

const std::vector<std::pair<size_type, size_type>> dir4 = { {+1,  0}, {-1,  0}, { 0, +1}, { 0, -1} };
const std::vector<std::pair<size_type, size_type>> dir8 = { {-1, -1}, {-1,  0}, {-1, +1}, { 0, -1}, { 0, +1}, {+1, -1}, {+1,  0}, {+1, +1} };

#ifdef _DEBUG
#define debug(x) std::cout << "[" << __LINE__ << "] " << #x << ": " << x << std::endl
#else
#define debug(x)
#endif

template < class container > void concat(container& a, const container& b) {
    a.insert(std::end(a), std::begin(b), std::end(b));
}
std::vector<size_type> iota(const size_type n) {
    std::vector<size_type> I(n);
    std::iota(std::begin(I), std::end(I), 0);
    return I;
}
template < class container > std::vector<size_type> sort_idx(const container& a) {
    const size_type n = a.size();
    std::vector<size_type> I = iota(n);
    std::sort(std::begin(I), std::end(I), [&](size_type i, size_type j) { return a[i] < a[j] or (a[i] == a[j] and i < j); });
    return I;
}
template < class container, class compare > std::vector<size_type> sort_idx(const container& a, const compare& cmp) {
    const size_type n = a.size();
    std::vector<size_type> I = iota(n);
    std::sort(std::begin(I), std::end(I), [&](size_type i, size_type j) { return cmp(a[i], a[j]) or (a[i] == a[j] and i < j); });
    return std::move(I);
}

struct grid {
    using size_type = int;
    size_type H, W;
    grid(const size_type H, const size_type W) : H(H), W(W) {}
    bool contains(const size_type i, const size_type j) {
        return 0 <= i and i < H and 0 <= j and j < W;
    }
};

} // namespace macro

using namespace macro;
#line 3 "A.cpp"

string solve(string c_) {
    vector<int> c(128);
    for(int i : rep(128)) c[i] = (c_[i] == '1');

    for(int S : rep(1 << 19)) {
        auto I = [&](const vector<int>& a) {
            int res = 0;
            for(int i : rep(7)) res += ((S >> a[i]) & 1) << i;
            return res;
        };

        int b0 = c[I({13, 14, 12,  4,  5,  3,  0})];
        int b1 = c[I({14, 15,  4,  5, 16,  0,  6})];
        int b2 = c[I({12,  4, 11,  3,  0, 10,  2})];
        int b3 = c[I({ 4,  5,  3,  0,  6,  2,  1})];
        int b4 = c[I({ 5, 16,  0,  6, 17,  1, 18})];
        int b5 = c[I({ 3,  0, 10,  2,  1,  9,  8})];
        int b6 = c[I({ 0,  6,  2,  1, 18,  8,  7})];
        int bb3 = c[(b0 << 0) + (b1 << 1) + (b2 << 2) + (b3 << 3) + (b4 << 4) + (b5 << 5) + (b6 << 6)];
        if(b3 != bb3) return "no";
    }

    return "yes";
}

int main() {
    while(true) {
        string c = in();
        if(c == "#") return 0;
        print(solve(c));
    }
}
accuracy: 1
time_ms: 2890
memory_kb: 3316
final_rank: 9

code_snippet: #line 2 "cp-library/src/cp-template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull  = unsigned long long;
using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128_t;
template < class T > bool chmin(T& a, T b) { if(a > b) { a = b; return true; } return false; }
template < class T > bool chmax(T& a, T b) { if(a < b) { a = b; return true; } return false; }
template < class T, class U > T ceil (T x, U y) { return (x > 0 ? (x + y - 1) / y :           x / y); }
template < class T, class U > T floor(T x, U y) { return (x > 0 ?           x / y : (x - y + 1) / y); }
int popcnt(i32 x) { return __builtin_popcount(x); }
int popcnt(u32 x) { return __builtin_popcount(x); }
int popcnt(i64 x) { return __builtin_popcountll(x); }
int popcnt(u64 x) { return __builtin_popcountll(x); }

#line 2 "cp-library/src/utility/rep_itr.hpp"
template < class T > struct itr_rep {
    T i, d;
    constexpr itr_rep(const T i) noexcept : i(i), d(1) {}
    constexpr itr_rep(const T i, const T d) noexcept : i(i), d(d) {}
    void operator++() noexcept { i += d; }
    constexpr int operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr_rep x) const noexcept { return d > 0 ? i < x.i : i > x.i; }
};

template < class T > struct rep {
    const itr_rep< T > s, t;
    constexpr rep(const T t) noexcept : s(0), t(t) {}
    constexpr rep(const T s, const T t) noexcept : s(s), t(t) {}
    constexpr rep(const T s, const T t, const T d) noexcept : s(s, d), t(t, d) {}
    constexpr auto begin() const noexcept { return s; }
    constexpr auto end  () const noexcept { return t; }
};

template < class T > struct revrep {
    const itr_rep < T > s, t;
    constexpr revrep(const T t) noexcept : s(t - 1, -1), t(-1, -1) {}
    constexpr revrep(const T s, const T t) noexcept : s(t - 1, -1), t(s - 1, -1) {}
    constexpr revrep(const T s, const T t, const T d) noexcept : s(t - 1, -d), t(s - 1, -d) {}
    constexpr auto begin() const noexcept { return s; }
    constexpr auto end  () const noexcept { return t; }
};
#line 3 "cp-library/src/utility/io.hpp"

/* 128bit integer */
istream& operator>>(istream& is, i128& x) {
    std::string s; is >> s;
    int pm = (s[0] == '-');
    x = 0;
    for(int i : rep(pm, int(s.size()))) x = x * 10 + (s[i] - '0');
    if(pm) x *= -1;
    return is;
}
ostream& operator<<(ostream& os, const i128& x) {
    if(x == 0) return os << '0';
    i128 y = x;
    if(y < 0) { os << '-'; y *= -1; }
    std::vector<int> ny;
    while(y > 0) { ny.push_back(y % 10); y /= 10; }
    for(int i : revrep(ny.size())) os << ny[i];
    return os;
}

template < class S, class T > istream& operator>>(istream& is,       std::pair< S, T >& x) { is >> x.first        >> x.second; return is; }
template < class S, class T > ostream& operator<<(ostream& os, const std::pair< S, T >& x) { os << x.first << " " << x.second; return os; }

namespace scanner {
    struct sca {
        template < class T > operator T() {
            T s; std::cin >> s; return s;
        }
    };
    struct vec {
        int n;
        vec(int n) : n(n) {}
        template < class T > operator std::vector< T >() {
            std::vector< T > v(n);
            for(T& x : v) std::cin >> x;
            return v;
        }
    };
    struct mat {
        int h, w;
        mat(int h, int w) : h(h), w(w) {}
        template < class T > operator std::vector< std::vector< T > >() {
            std::vector m(h, std::vector< T >(w));
            for(std::vector< T >& v : m) for(T& x : v) std::cin >> x;
            return m;
        }
    };
    struct speedup {
        speedup() {
            std::cin.tie(0);
            std::ios::sync_with_stdio(0);
        }
    } speedup_instance;
}
scanner::sca in() { return scanner::sca(); }
scanner::vec in(int n) { return scanner::vec(n); }
scanner::mat in(int h, int w) { return scanner::mat(h, w); }

namespace printer {
    void precision(int d) { std::cout << std::fixed << std::setprecision(d); }
    void flush() { std::cout.flush(); }
}

template < class T >
ostream& operator<<(ostream& os, const std::vector< T > a) {
    int n = a.size();
    for(int i : rep(n)) { os << a[i]; if(i != n - 1) os << ' '; }
    return os;
}

int print() { std::cout << '\n'; return 0; }
template < class head, class... tail > int print(head&& h, tail&&... t) {
    std::cout << h; if(sizeof...(tail)) std::cout << ' ';
    return print(std::forward<tail>(t)...);
}
template < class T > int print_n(const std::vector< T > a) {
    int n = a.size();
    for(int i : rep(n)) std::cout << a[i] << "\n";
    return 0;
}


#line 2 "cp-library/src/utility/key_val.hpp"

template < class K, class V >
struct key_val {
    K key; V val;
    key_val() {}
    key_val(K key, V val) : key(key), val(val) {}
    template < std::size_t Index >
    std::tuple_element_t< Index, key_val >& get() {
        if constexpr (Index == 0) return key;
        if constexpr (Index == 1) return val;
    }
};

namespace std {

template < class K, class V > struct tuple_size < key_val< K, V > > : integral_constant< size_t, 2 > {};
template < class K, class V > struct tuple_element < 0, key_val< K, V > > { using type = K; };
template < class K, class V > struct tuple_element < 1, key_val< K, V > > { using type = V; };

}
#line 2 "cp-library/src/utility/vec_op.hpp"
template < class T > key_val< int, T > max_of(const vector< T >& a) {
    int i = std::max_element(a.begin(), a.end()) - a.begin();
    return {i, a[i]};
}
template < class T > key_val< int, T > min_of(const vector< T >& a) {
    int i = std::min_element(a.begin(), a.end()) - a.begin();
    return {i, a[i]};
}
template < class S, class T > S sum_of(const vector< T >& a) {
    S sum = 0;
    for(const T x : a) sum += x;
    return sum;
}
template < class S, class T > vector< S > freq_of(const vector< T >& a, T L, T R) {
    vector< S > res(R - L, S(0));
    for(const T x : a) res[x - L] += 1;
    return res;
}
template < class S, class T > struct prefix_sum {
    vector< S > s;
    prefix_sum(const vector< T >& a) : s(a) {
        s.insert(s.begin(), S(0));
        for(int i : rep(a.size())) s[i + 1] += s[i];
    }
    // [L, R)
    S sum(int L, int R) { return s[R] - s[L]; }
};
#line 3 "cp-library/src/utility/heap.hpp"

template < class T > using heap_min = std::priority_queue< T, std::vector< T >, std::greater< T > >;
template < class T > using heap_max = std::priority_queue< T, std::vector< T >, std::less< T > >;

#line 27 "cp-library/src/cp-template.hpp"

#line 1 "cp-library/src/algorithm/bin_search.hpp"
template < class T, class F >
T bin_search(T ok, T ng, F f) {
    while(abs(ng - ok) > 1) {
        T mid = (ok + ng) / 2;
        (f(mid) ? ok : ng) = mid;
    }
    return ok;
}

template < class T, class F >
T bin_search_real(T ok, T ng, F f, int step = 80) {
    while(step--) {
        T mid = (ok + ng) / 2;
        (f(mid) ? ok : ng) = mid;
    }
    return ok;
}
#line 2 "cp-library/src/algorithm/argsort.hpp"

template < class T > std::vector< int > argsort(const std::vector< T > &a) {
    std::vector< int > ids((int)a.size());
    std::iota(ids.begin(), ids.end(), 0);
    std::sort(ids.begin(), ids.end(), [&](int i, int j) {
        return a[i] < a[j] || (a[i] == a[j] && i < j);
    });
    return ids;
}
#line 1 "macro.hpp"
namespace macro {

using size_type = int;
template < class container > void  sort(container& a) { std::sort(std:: begin(a), std:: end(a)); }
template < class container > void rsort(container& a) { std::sort(std::rbegin(a), std::rend(a)); }
template < class container > void reverse(container& a) { std::reverse(std::begin(a), std::end(a)); }
template < class container > void unique(container& a) {
    std::sort(std::begin(a), std::end(a));
    a.erase(std::unique(std::begin(a), std::end(a)), std::end(a));
}
template < class container > container  sorted(const container& a) { container b = a;  sort(b); return std::move(b); }
template < class container > container rsorted(const container& a) { container b = a; rsort(b); return std::move(b); }
template < class container, class compare > void sort(container& a, const compare& cmp) { std::sort(std::begin(a), std::end(a), cmp); }
template < class container, class compare > container sorted(const container& a, const compare& cmp) { container b = a; sort(b, cmp); return std::move(b); }
template < class container, class value > size_type lower_bound(const container& a, const value& x) { return std::lower_bound(std::begin(a), std::end(a), x) - std::begin(a); }
template < class container, class value > size_type upper_bound(const container& a, const value& x) { return std::upper_bound(std::begin(a), std::end(a), x) - std::begin(a); }

const std::vector<std::pair<size_type, size_type>> dir4 = { {+1,  0}, {-1,  0}, { 0, +1}, { 0, -1} };
const std::vector<std::pair<size_type, size_type>> dir8 = { {-1, -1}, {-1,  0}, {-1, +1}, { 0, -1}, { 0, +1}, {+1, -1}, {+1,  0}, {+1, +1} };

#ifdef _DEBUG
#define debug(x) std::cout << "[" << __LINE__ << "] " << #x << ": " << x << std::endl
#else
#define debug(x)
#endif

template < class container > void concat(container& a, const container& b) {
    a.insert(std::end(a), std::begin(b), std::end(b));
}
std::vector<size_type> iota(const size_type n) {
    std::vector<size_type> I(n);
    std::iota(std::begin(I), std::end(I), 0);
    return I;
}
template < class container > std::vector<size_type> sort_idx(const container& a) {
    const size_type n = a.size();
    std::vector<size_type> I = iota(n);
    std::sort(std::begin(I), std::end(I), [&](size_type i, size_type j) { return a[i] < a[j] or (a[i] == a[j] and i < j); });
    return I;
}
template < class container, class compare > std::vector<size_type> sort_idx(const container& a, const compare& cmp) {
    const size_type n = a.size();
    std::vector<size_type> I = iota(n);
    std::sort(std::begin(I), std::end(I), [&](size_type i, size_type j) { return cmp(a[i], a[j]) or (a[i] == a[j] and i < j); });
    return std::move(I);
}

struct grid {
    using size_type = int;
    size_type H, W;
    grid(const size_type H, const size_type W) : H(H), W(W) {}
    bool contains(const size_type i, const size_type j) {
        return 0 <= i and i < H and 0 <= j and j < W;
    }
};

} // namespace macro

using namespace macro;
#line 3 "A.cpp"

string solve(string c_) {
    vector<int> c(128);
    for(int i : rep(128)) c[i] = (c_[i] == '1');

    for(int S : rep(1 << 19)) {
        auto I = [&](vector<int> a) {
            int res = 0;
            for(int i : rep(7)) res += ((S >> a[i]) & 1) << i;
            return res;
        };

        int b0 = c[I({13, 14, 12,  4,  5,  3,  0})];
        int b1 = c[I({14, 15,  4,  5, 16,  0,  6})];
        int b2 = c[I({12,  4, 11,  3,  0, 10,  2})];
        int b3 = c[I({ 4,  5,  3,  0,  6,  2,  1})];
        int b4 = c[I({ 5, 16,  0,  6, 17,  1, 18})];
        int b5 = c[I({ 3,  0, 10,  2,  1,  9,  8})];
        int b6 = c[I({ 0,  6,  2,  1, 18,  8,  7})];
        int bb3 = c[(b0 << 0) + (b1 << 1) + (b2 << 2) + (b3 << 3) + (b4 << 4) + (b5 << 5) + (b6 << 6)];
        if(b3 != bb3) return "no";
    }

    return "yes";
}

int main() {
    while(true) {
        string c = in();
        if(c == "#") return 0;
        print(solve(c));
    }
}
accuracy: 1
time_ms: 2880
memory_kb: 3316
final_rank: 8

code_snippet: #include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; --i)

#define all(c) std::begin(c), std::end(c)

#ifdef LOCAL
#define debug(...) debug_impl(#__VA_ARGS__, __VA_ARGS__)
template <class T, class ...Args> void debug_impl(string s, T&& f, Args &&...args) {
    cerr << "(" << s << "): " << "(" << forward<T>(f);
    ((cerr << ", " << forward<Args>(args)), ..., (cerr << ")\n"));
}
#else
#define debug(...) void(0)
#endif

template <class T> bool chmax(T& a, const T& b) { return b > a ? (a = b, true) : false; }
template <class T> bool chmin(T& a, const T& b) { return b < a ? (a = b, true) : false; }


template <class T> istream& operator>>(istream& in, vector<T>& v) {
    for (auto& e : v) in >> e;
    return in;
}
template <class ...Args> void read(Args&... args) {
    (cin >> ... >> args);
}

template <class T> ostream& operator>>(ostream& out, vector<T>& v) {
    int n = v.size();
    rep(i, n) {
        out << v[i];
        if (i + 1 != n) out << ' ';
    }
    return out;
}

template <class T, class ...Tails> void print(T&& h, Tails &&... tails) {
    cout << h, ((cout << ' ' << forward<Tails>(tails)), ..., (cout << '\n'));
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    while (true) {
        string cmd;
        cin >> cmd;

        if (cmd == "#") break;

        int idx[7][7] = {
            { 7, 8, 10, 0, 1, 2, 3 },
            { 8, 9, 0, 1, 11, 3, 4 },
            { 10, 0, 12, 2, 3, 14, 5 },
            { 0, 1, 2, 3, 4, 5, 6 },
            { 1, 11, 3, 4, 13, 6, 15 },
            { 2, 3, 14, 5, 6, 16, 17 },
            { 3, 4, 5, 6, 15, 17, 18 }
        };

        auto nxt_bit = [&](int s, int i) {
            int d = 0;
            rep(j, 7) {
                d |= ((s >> idx[j][i]) & 1) << j;
            }
            return cmd[d] - '0';
        };

        bool b = true;
        rep(s, 1 << 19) {
            int ns = 0;
            rep(i, 7) {
                ns |= nxt_bit(s, i) << i;
            }
            b &= ((ns >> 3) & 1) == nxt_bit(ns, 3);
            if (not b) break;
        }
        
        print(b ? "yes" : "no");
    }
}
accuracy: 1
time_ms: 1340
memory_kb: 3460
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;
string S;

pair<int, int> pos1[19] = {{-2, 0}, {-2, 1}, {-2, 2},
                          {-1, -1}, {-1, 0}, {-1, 1}, {-1, 2},
                          {0, -2}, {0, -1}, {0, 0}, {0, 1}, {0, 2},
                          {1, -2}, {1, -1}, {1, 0}, {1, 1},
                          {2, -2}, {2, -1}, {2, 0}};

pair<int, int> pos2[7] = {{-1, 0}, {-1, 1},
                         {0, -1}, {0, 0}, {0, 1},
                         {1, -1}, {1, 0}};
                         
int di[7] = {0, 1, -1, 0, 1, -1, 0};
int dj[7] = {-1, -1, 0, 0, 0, 1, 1};
int dp1[10][10];
int dp2[10][10];
const int N = 19;

void solve(){
    for(int bit = 0; bit < (1 << N); bit++){
        for(int i = 0; i < N; i++){
            dp1[pos1[i].first + 2][pos1[i].second + 2] = bit >> i & 1;
        }
        for(auto tmp: pos2){
            int i = tmp.first + 2;
            int j = tmp.second + 2;
            int p = 0;
            for(int k = 0; k < 7; k++){
                if(dp1[i + di[k]][j + dj[k]]) p |= 1 << k;
            }
            dp2[i][j] = S[p] - '0';
        }
        int p = 0;
        for(int k = 0; k < 7; k++){
            if(dp2[di[k] + 2][dj[k] + 2]) p |= 1 << k;
        }
        if(dp2[2][2] != (S[p] - '0')){
            cout << "no\n";
            return;
        }
    }
    cout << "yes\n";
}

int main(void){
    while(1){
        cin >> S;
        if(S == "#") break;
        solve();
    }
    
}
accuracy: 1
time_ms: 3730
memory_kb: 3236
final_rank: 11

code_snippet: #include <bits/stdc++.h>
using namespace std;

string s;

bool solve();

int main() {
  while (1) {
    cin >> s;
    if (s == "#") break;
    if (solve())
      cout << "yes" << endl;
    else
      cout << "no" << endl;
  }
  return 0;
}

bool solve() {
  for (int i = 0; i < (1 << 19); ++i) {
    int now = i, nxt;
    auto calc = [](int b, int ofst, const vector<int> v) {
      int mask = 0;
      for (int i = 0; i < 7; ++i) mask |= (b >> (ofst + v[i]) & 1) << i;
      return s[mask] & 1;
    };
    auto f = [&](int bf) {
      int res = bf & 497871;
      for (auto id : {4, 5})
        res |= calc(bf, id, {5, 1, 4, 0, -3, -1, -4}) << id;
      for (auto id : {8, 9, 10})
        res |= calc(bf, id, {5, 1, 4, 0, -4, -1, -5}) << id;
      for (auto id : {13, 14})
        res |= calc(bf, id, {4, 1, 3, 0, -4, -1, -5}) << id;
      return res;
    };
    nxt = f(now);
    swap(nxt, now);
    nxt = f(now);
    if ((now ^ nxt) >> 9 & 1) return 0;
  }
  return 1;
}
accuracy: 1
time_ms: 6010
memory_kb: 3344
final_rank: 18

code_snippet: // #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(v) v.begin(), v.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
const array<string, 2> YESNO = {"NO", "YES"};
const array<string, 2> YesNo = {"No", "Yes"};
const array<string, 2> yesno = {"no", "yes"};
void YES(bool b = true) { cout << YESNO[b] << '\n'; }
void Yes(bool b = true) { cout << YesNo[b] << '\n'; }
void yes(bool b = true) { cout << yesno[b] << '\n'; }
template<typename T, typename U>
inline bool chmax(T& a, const U& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U>
inline bool chmin(T& a, const U& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
T MAX(const vector<T>& v) { return *max_element(v.begin(), v.end()); }
template<typename T>
T MIN(const vector<T>& v) { return *min_element(v.begin(), v.end()); }
template<typename T>
T SUM(const vector<T>& v) { return accumulate(v.begin(), v.end(), T()); }
template<typename T>
void UNIQUE(vector<T>& v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
}
template<typename T>
T POW(T a, int n) {
    T res = 1;
    for (; n > 0; n >>= 1, a *= a) if (n & 1) res *= a;
    return res;
}
template<typename T>
int lb(const vector<T>& v, T x) {
    return distance(v.begin(), lower_bound(v.begin(), v.end(), x));
}
template<typename T>
int ub(const vector<T>& v, T x) {
    return distance(v.begin(), upper_bound(v.begin(), v.end(), x));
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    for (auto it = v.begin(); it != v.end(); ++it) {
        if (it == v.begin()) os << *it;
        else os << ' ' << *it;
    }
    return os;
}
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << p.first << ' ' << p.second;
    return os;
}
__attribute__((constructor))
void setup() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
}
// #include <atcoder/all>
// using namespace atcoder;
// using mint = modint1000000007;
// using mint = modint998244353;

int solve() {
    string s;
    cin >> s;
    if (s == "#") return 1;

    auto subtract = [](int bit, const vector<int>& pos) {
        int nbit = 0;
        for (size_t i = 0; i < pos.size(); ++i) {
            nbit |= (bit >> pos[i] & 1) << i;
        }
        return nbit;
    };

    auto filter = [&](int bit) {
        int resbit = 0;
        for (int i = 0; i < 19; ++i) {
            if (i <= 3) {
                resbit |= (bit >> i & 1) << i;
            } else if (i <= 5) {
                resbit |= (s[subtract(bit, {i-4, i-3, i-1, i, i+1, i+4, i+5})] - '0') << i;
            } else if (i <= 7) {
                resbit |= (bit >> i & 1) << i;
            } else if (i <= 10) {
                resbit |= (s[subtract(bit, {i-5, i-4, i-1, i, i+1, i+4, i+5})] - '0') << i;
            } else if (i <= 12) {
                resbit |= (bit >> i & 1) << i;
            } else if (i <= 14) {
                resbit |= (s[subtract(bit, {i-5, i-4, i-1, i, i+1, i+3, i+4})] - '0') << i;
            } else {
                resbit |= (bit >> i & 1) << i;
            }
        }
        return resbit;
    };

    rep(bit, 1<<19) {
        int nbit = filter(bit);
        if ((nbit >> 9 & 1) == (filter(nbit) >> 9 & 1)) continue;
        yes(false);
        return 0;
    }
    yes();
    return 0;
}

int main() {
    while (!solve());
}
accuracy: 1
time_ms: 7580
memory_kb: 3464
final_rank: 19

code_snippet: #include <iostream>
using namespace std;

const int d[7][7] = {{0, 1, 3, 4, 5, 8, 9},
                     {1, 2, 4, 5, 6, 9, 10},
                     {3, 4, 7, 8, 9, 12, 13},
                     {4, 5, 8, 9, 10, 13, 14},
                     {5, 6, 9, 10, 11, 14, 15},
                     {8, 9, 12, 13, 14, 16, 17},
                     {9, 10, 13, 14, 15, 17, 18}};

void ch(int b, int *p){
    for(int i = 0; i < 7; i++){
        for(int j = 0; j < 7; j++) p[i] += ((b >> d[i][j]) & 1) << j;
    }
}

bool nch(int *p, string &s){
    int r = 0;
    for(int i = 0; i < 7; i++) r += ((s[p[i]] - '0') << i);
    return s[p[3]] == s[r];
}

int p[530000][8];

int main()
{
    for(int b = 0; b < (1 << 19); b++) ch(b, p[b]);
    while(true){
        string s;
        cin >> s;
        if(s == "#") break;
        bool f = true;
        for(int b = 0; b < (1 << 19); b++) f &= nch(p[b], s);
        if(f) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}
accuracy: 1
time_ms: 470
memory_kb: 19552
final_rank: 20

code_snippet: #include <bits/stdc++.h>
using namespace std;
const int dx[7]={1,0,1,0,-1,0,-1},dy[7]={0,1,-1,0,1,-1,0};

void solve(string S){

    vector<vector<int>> f(5,vector<int>(5,-1)),num(5,vector<int>(5));
    vector<pair<int,int>> pos;
    queue<pair<int,int>> que;
    f[2][2]=0; que.emplace(2,2);

    for (int i=0;!que.empty();){
        auto p=que.front(); que.pop();
        int x=p.first,y=p.second;
        pos.emplace_back(x,y);
        num[x][y]=i++;
        if (f[x][y]>=2) continue;
        for (int i=0;i<7;++i){
            if (i==3) continue;
            int nx=x+dx[i],ny=y+dy[i];
            if (~f[nx][ny]) continue;
            f[nx][ny]=f[x][y]+1;
            que.emplace(nx,ny);
        }
    }

    vector<vector<int>> a(5,vector<int>(5));
    auto get=[&](int x,int y){
        int mask=0;
        for (int i=0;i<7;++i){
            mask|=a[x+dx[i]][y+dy[i]]<<i;
        }
        return S[mask]-'0';
    };
    auto check=[&](int mask){
        for (int i=0;i<19;++i) a[pos[i].first][pos[i].second]=(mask&1<<i)>>i;
        vector<int> v;
        for (int i=0;i<7;++i) v.emplace_back(get(2+dx[i],2+dy[i]));
        for (int i=0;i<7;++i) a[2+dx[i]][2+dy[i]]=v[i];
        return get(2,2)==a[2][2];
    };

    for (int mask=0;mask<(1<<19);++mask){
        if (!check(mask)){
            cout << "no" << '\n';
            return;
        }
    }

    cout << "yes" << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    while (cin >> S,S!="#"){
        solve(S);
    }
}
accuracy: 1
time_ms: 4920
memory_kb: 3204
final_rank: 14

code_snippet: #include <bits/stdc++.h>
using namespace std;
const long long MOD=1000000007;
// const long long MOD=998244353;
#define LOCAL
#pragma region Macros
typedef long long ll;
typedef __int128_t i128;
typedef unsigned int uint;
typedef unsigned long long ull;
#define ALL(x) (x).begin(),(x).end()
const int INF=1e9;
const long long IINF=1e18;
const char dir[4]={'D','R','U','L'};

template<typename T>
istream &operator>>(istream &is,vector<T> &v){
    for (T &x:v) is >> x;
    return is;
}
template<typename T>
ostream &operator<<(ostream &os,const vector<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const pair<T,U> &p){
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template<typename T,typename U,typename V>
ostream&operator<<(ostream &os,const tuple<T,U,V> &t){
    os << '(' << get<0>(t) << ',' << get<1>(t) << ',' << get<2>(t) << ')';
    return os;
}
template<typename T,typename U,typename V,typename W>
ostream&operator<<(ostream &os,const tuple<T,U,V,W> &t){
    os << '(' << get<0>(t) << ',' << get<1>(t) << ',' << get<2>(t) << ',' << get<3>(t) << ')';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
    }
    os << '}';
    return os;
}
template<typename T,typename U>
ostream &operator<<(ostream &os,const unordered_map<T,U> &m){
    os << '{';
    for (auto itr=m.begin();itr!=m.end();){
        os << '(' << itr->first << ',' << itr->second << ')';
        if (++itr!=m.end()) os << ',';
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();){
        os << *itr;
        if (++itr!=s.end()) os << ',';
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const multiset<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();){
        os << *itr;
        if (++itr!=s.end()) os << ',';
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const unordered_set<T> &s){
    os << '{';
    for (auto itr=s.begin();itr!=s.end();){
        os << *itr;
        if (++itr!=s.end()) os << ',';
    }
    os << '}';
    return os;
}
template<typename T>
ostream &operator<<(ostream &os,const deque<T> &v){
    for (int i=0;i<v.size();++i){
        os << v[i] << (i+1==v.size()?"": " ");
    }
    return os;
}

void debug_out(){cerr << '\n';}
template<class Head,class... Tail>
void debug_out(Head&& head,Tail&&... tail){
    cerr << head;
    if (sizeof...(Tail)>0) cerr << ", ";
    debug_out(move(tail)...);
}
#ifdef LOCAL
#define debug(...) cerr << " ";\
cerr << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << '\n';\
cerr << " ";\
debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<typename T> T gcd(T x,T y){return y!=0?gcd(y,x%y):x;}
template<typename T> T lcm(T x,T y){return x/gcd(x,y)*y;}

template<class T1,class T2> inline bool chmin(T1 &a,T2 b){
    if (a>b){a=b; return true;} return false;
}
template<class T1,class T2> inline bool chmax(T1 &a,T2 b){
    if (a<b){a=b; return true;} return false;
}
#pragma endregion

const int dx[7]={1,0,1,0,-1,0,-1},dy[7]={0,1,-1,0,1,-1,0};

void solve(string S){

    vector<vector<int>> f(5,vector<int>(5,-1)),num(5,vector<int>(5));
    vector<pair<int,int>> pos;
    queue<pair<int,int>> que;
    f[2][2]=0; que.emplace(2,2);

    for (int i=0;!que.empty();){
        auto p=que.front(); que.pop();
        int x=p.first,y=p.second;
        pos.emplace_back(x,y);
        num[x][y]=i++;
        if (f[x][y]>=2) continue;
        for (int i=0;i<7;++i){
            if (i==3) continue;
            int nx=x+dx[i],ny=y+dy[i];
            if (~f[nx][ny]) continue;
            f[nx][ny]=f[x][y]+1;
            que.emplace(nx,ny);
        }
    }

    vector<vector<int>> a(5,vector<int>(5));
    auto get=[&](int x,int y){
        int mask=0;
        for (int i=0;i<7;++i){
            mask|=a[x+dx[i]][y+dy[i]]<<i;
        }
        return S[mask]-'0';
    };
    auto check=[&](int mask){
        for (int i=0;i<19;++i) a[pos[i].first][pos[i].second]=(mask&1<<i)>>i;
        vector<int> v;
        for (int i=0;i<7;++i) v.emplace_back(get(2+dx[i],2+dy[i]));
        for (int i=0;i<7;++i) a[2+dx[i]][2+dy[i]]=v[i];
        return get(2,2)==a[2][2];
    };

    for (int mask=0;mask<(1<<19);++mask){
        if (!check(mask)){
            cout << "no" << '\n';
            return;
        }
    }

    cout << "yes" << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    while (cin >> S,S!="#"){
        solve(S);
    }
}
accuracy: 1
time_ms: 4920
memory_kb: 3108
final_rank: 13

code_snippet: #include <bits/stdc++.h>
using namespace std;

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

template <typename F>
class
FixPoint : private F
{
public:
  explicit constexpr FixPoint(F&& f) noexcept
    : F{std::forward<F>(f)}
  {}

  template <typename... Args>
  constexpr decltype(auto)
  operator()(Args&&... args) const
  {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};  // class FixPoint


namespace
{
  template <typename F>
  inline constexpr decltype(auto)
  makeFixPoint(F&& f) noexcept
  {
    return FixPoint<F>{std::forward<F>(f)};
  }
}  // namespace

template<typename T>
class Matrix{
private:
  using size_type = ::std::size_t;
  using Row = ::std::vector<T>;
  using Mat = ::std::vector<Row>;

  size_type R, C; // row, column
  Mat A;

  void add_row_to_another(size_type r1, size_type r2, const T k){ // Row(r1) += Row(r2)*k
    for(size_type i = 0;i < C;i++)
      A[r1][i] += A[r2][i]*k;
  }

  void scalar_multiply(size_type r, const T k){
    for(size_type i = 0;i < C;i++)
      A[r][i] *= k;
  }

  void scalar_division(size_type r, const T k){
    for(size_type i = 0;i < C;i++)
      A[r][i] /= k;
  }

public:
  Matrix(){}
  Matrix(size_type r, size_type c) : R(r), C(c), A(r, Row(c)) {}
  Matrix(const Mat &m) : R(m.size()), C(m[0].size()), A(m) {}
  Matrix(const Mat &&m) : R(m.size()), C(m[0].size()), A(m) {}
  Matrix(const Matrix<T> &m) : R(m.R), C(m.C), A(m.A) {}
  Matrix(const Matrix<T> &&m) : R(m.R), C(m.C), A(m.A) {}
  Matrix<T> &operator=(const Matrix<T> &m){
    R = m.R; C = m.C; A = m.A;
    return *this;
  }
  Matrix<T> &operator=(const Matrix<T> &&m){
    R = m.R; C = m.C; A = m.A;
    return *this;
  }
  static Matrix I(const size_type N){
    Matrix m(N, N);
    for(size_type i = 0;i < N;i++) m[i][i] = 1;
    return m;
  }

  const Row& operator[](size_type k) const& { return A.at(k); }
  Row& operator[](size_type k) & { return A.at(k); }
  Row operator[](size_type k) const&& { return ::std::move(A.at(k)); }

  size_type row() const { return R; } // the number of rows
  size_type column() const { return C; }

  T determinant(){
    assert(R == C);
    Mat tmp = A;
    T res = 1;
    for(size_type i = 0;i < R;i++){
      for(size_type j = i;j < R;j++){ // satisfy A[i][i] > 0
        if (A[j][i] != 0) {
          if (i != j) res *= -1;
          swap(A[j], A[i]);
          break;
        }
      }
      if (A[i][i] == 0) return 0;
      res *= A[i][i];
      scalar_division(i, A[i][i]);
      for(size_type j = i+1;j < R;j++){
        add_row_to_another(j, i, -A[j][i]);
      }
    }
    swap(tmp, A);
    return res;
  }

  Matrix inverse(){
    assert(R == C);
    assert(determinant() != 0);
    Matrix inv(Matrix::I(R)), tmp(*this);
    for(size_type i = 0;i < R;i++){
      for(size_type j = i;j < R;j++){
        if (A[j][i] != 0) {
          swap(A[j], A[i]);
          swap(inv[j], inv[i]);
          break;
        }
      }
      inv.scalar_division(i, A[i][i]);
      scalar_division(i, A[i][i]);
      for(size_type j = 0;j < R;j++){
        if(i == j) continue;
        inv.add_row_to_another(j, i, -A[j][i]);
        add_row_to_another(j, i, -A[j][i]);
      }
    }
    (*this) = tmp;
    return inv;
  }

  Matrix& operator+=(const Matrix &B){
    assert(column() == B.column() && row() == B.row());
    for(size_type i = 0;i < R;i++)
      for(size_type j = 0;j < C;j++)
        (*this)[i][j] += B[i][j];
    return *this;
  }

  Matrix& operator-=(const Matrix &B){
    assert(column() == B.column() && row() == B.row());
    for(size_type i = 0;i < R;i++)
      for(size_type j = 0;j < C;j++)
        (*this)[i][j] -= B[i][j];
    return *this;
  }

  Matrix& operator*=(const Matrix &B){
    assert(column() == B.row());
    Matrix M(R, B.column());
    for(size_type i = 0;i < R;i++) {
      for(size_type j = 0;j < B.column();j++) {
        M[i][j] = 0;
        for(size_type k = 0;k < C;k++) {
          M[i][j] += (*this)[i][k] * B[k][j];
        }
      }
    }
    swap(M, *this);
    return *this;
  }

  Matrix& operator/=(const Matrix &B){
    assert(C == B.row());
    Matrix M(B);
    (*this) *= M.inverse();
    return *this;
  }

  Matrix operator+(const Matrix &B) const { return (Matrix(*this) += B); }
  Matrix operator-(const Matrix &B) const { return (Matrix(*this) -= B); }
  Matrix operator*(const Matrix &B) const { return (Matrix(*this) *= B); }
  Matrix operator/(const Matrix &B) const { return (Matrix(*this) /= B); }

  bool operator==(const Matrix &B) const {
    if (column() != B.column() || row() != B.row()) return false;
    for(size_type i = 0;i < row();i++)
      for(size_type j = 0;j < column();j++)
        if ((*this)[i][j] != B[i][j]) return false;
    return true;
  }
  bool operator!=(const Matrix &B) const { return !((*this) == B); }

  Matrix pow(size_type k, int64 m){
    assert(R == C);
    Matrix M(Matrix::I(R));
    while(k){
      if (k & 1) M *= (*this);
      k >>= 1;
      (*this) *= (*this);
      REP(i, R) {
        REP(j, C) {
          A[i][j] %= m;
          M[i][j] %= m;
        }
      }
    }
    A.swap(M.A);
    return *this;
  }

  friend ::std::ostream &operator<<(::std::ostream &os, Matrix &p){
    for(size_type i = 0;i < p.row();i++){
      for(size_type j = 0;j < p.column();j++){
        os << p[i][j] << " ";
      }
      os << ::std::endl;
    }
    return os;
  }
};

class UnionFind{
private:
  ::std::vector<int_fast32_t> par;
  size_t n;

public:
  UnionFind(){}
  UnionFind(size_t n):n(n){
    par.resize(n, -1);
  }

  uint_fast32_t find(uint_fast32_t x){
    return par[x] < 0 ? x : par[x] = find(par[x]);
  }

  size_t size(uint_fast32_t x){
    return -par[find(x)];
  }

  bool unite(uint_fast32_t x, uint_fast32_t y){
    x = find(x);
    y = find(y);
    if(x == y) return false;
    if(size(x) < size(y)) std::swap(x, y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }

  bool same(uint_fast32_t x, uint_fast32_t y){
    return find(x) == find(y);
  }
};

vector<PII> cen({{1, 2}, {1, 1}, {1, 3}, {2, 1}, {2, 2}, {2, 3}, {3, 2}});
int dx[2][7] = {{0, 1, -1, 0, 1, -1, 0}, {0, 1, -1, 0, 1, -1, 0}};
int dy[2][7] = {{1, 0, 0, 0, -1, -1, -1}, {1, 1, 1, 0, 0, 0, -1}};
int tmp[7] = {};

void filter(const string& s, vector<vector<int>>& f) {
  int i = 0;
  for (auto [y, x] : cen) {
    int bit = 0;
    REP(k, 7) {
      int yy = y + dy[x%2][k], xx = x + dx[x%2][k];
      bit |= f[yy][xx] << k;
    }
    tmp[i] = s[bit] - '0';
    i++;
  }
  REP(i, cen.size()) {
    f[cen[i].fs][cen[i].sc] = tmp[i];
  }
//  REP(i, 5) {
//    REP(j, 5) {
//      cout << res[i][j] << " ";
//    }
//    cout << endl;
//  }
//  cout << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);

  string s;
  vector<PII> pos;
  int p[5][5] = {{0, 1, 1, 1, 0},
                 {1, 1, 1, 1, 1},
                 {1, 1, 1, 1, 1},
                 {1, 1, 1, 1, 1},
                 {0, 0, 1, 0, 0}};
  REP(i, 5) REP(j, 5) {
    if (p[i][j] == 1) pos.emplace_back(i, j);
  }

  auto now = make_v<int>(5, 5);
  while (cin >> s && s != "#") {
    bool ok = 1;
    REP(i, 1 << 19) {
      REP(j, pos.size()) {
        now[pos[j].fs][pos[j].sc] = i >> j & 1;
      }
      filter(s, now);
      int luz = now[2][2];
      int bit = 0;
      REP(k, 7) {
        int yy = 2 + dy[0][k], xx =dx[0][k] + 2;
        bit |= now[yy][xx] << k;
      }
      if (s[bit] - '0' != luz) ok = 0;
    }
    if (ok) cout << "yes" << endl;
    else cout << "no" << endl;
  }
}
accuracy: 1
time_ms: 4020
memory_kb: 3340
final_rank: 12

code_snippet: #include <bits/stdc++.h>
using namespace std;

using ll = long long;
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template <typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template <typename T> void chmax(T &a, const T &b) { a = max(a, b); }

const ll INF = 1LL << 60;

struct FastIO {
    FastIO() {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
} fastiofastio;

int adj[7][7] = {{7, 8, 18, 0, 1, 2, 3},   {8, 9, 0, 1, 10, 3, 4},
                 {18, 0, 17, 2, 3, 16, 5}, {0, 1, 2, 3, 4, 5, 6},
                 {1, 10, 3, 4, 11, 6, 12}, {2, 3, 16, 5, 6, 15, 14},
                 {3, 4, 5, 6, 12, 14, 13}};

int to[128];

int main() {
    while (1) {
        string S;
        cin >> S;
        if (S == "#")
            break;
        for (int i = 0; i < 128; i++)
            to[i] = S[i] - '0';
        bool ok = 1;
        for (int bit = 0; bit < (1 << 19); bit++) {
            int nxt = 0;
            for (int i = 0; i < 7; i++) {
                int now = 0;
                for (int j = 0; j < 7; j++) {
                    if (bit & (1 << adj[i][j]))
                        now |= (1 << j);
                }
                if (to[now])
                    nxt |= (1 << i);
            }
            if (((nxt >> 3) & 1) != to[nxt]) {
                ok = 0;
                break;
            }
        }
        if (ok)
            cout << "yes\n";
        else
            cout << "no\n";
    }
}
accuracy: 1
time_ms: 3480
memory_kb: 3360
final_rank: 10

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define reps(i, s, n) for(int i = (s); i < n; ++i)
#define rep(i, n) reps(i, 0, n)
#define ALL(v) v.begin(), v.end()

using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using P = pair<int, int>;

const int N = 3;
string S;

const vector<int> dx = {-1, 0, -1, 0, 1, 0, 1};
const vector<int> dy = {-1, -1, 0, 0, 0, 1, 1};

vector<P> find_xy;
vector<vector<int> > to;

void init(){
    rep(y, 5){
        reps(x, max(0, y - 2), min(5, y + 3)){
            find_xy.emplace_back(x, y);
        }
    }
    assert((int)find_xy.size() == 19);
    to.resize(5);
    rep(i, 5) to[i].resize(5, -1);
    rep(i, 19){
        P p = find_xy[i];
        to[p.first][p.second] = i;
    }
}

bool change(int color){
    int nxt(0);
    for(int id : {4, 5, 8, 9, 10, 13, 14}){
        int S_id(0);
        auto [x, y] = find_xy[id];
        rep(i, 7){
            int nx = x + dx[i], ny = y + dy[i];
            S_id |= ((color>>to[nx][ny])&1)<<i;
        }
        nxt |= (int)(S[S_id] == '1')<<id;
    }
    
    int S_id(0);
    auto [x, y] = find_xy[9];
    rep(i, 7){
        int nx = x + dx[i], ny = y + dy[i];
        S_id |= ((nxt>>to[nx][ny])&1)<<i;
    }
    return (S[S_id] == '1') != ((nxt>>9)&1);
}

int main(){
    init();
    while(cin>>S, S[0] != '#'){
        bool ok = true;
        rep(i, 1<<19){
            if(change(i)){
                ok = false;
                break;
            }
        }
        cout<<(ok ? "yes" : "no")<<endl;
    }
}
accuracy: 1
time_ms: 2130
memory_kb: 3448
final_rank: 7

code_snippet: //https://onlinejudge.u-aizu.ac.jp/problems/2599

#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

constexpr int MAX = (1<<7);

int cal2(int a, int b, int c, int n){
    int res = 0;
    
    res |= (n>>(c+1))&1; res<<=1;
    res |= (n>>(c+0))&1; res<<=1;
    res |= (n>>(b+2))&1; res<<=1;
    res |= (n>>(b+1))&1; res<<=1;
    res |= (n>>(b+0))&1; res<<=1;
    res |= (n>>(a+1))&1; res<<=1;
    res |= (n>>(a+0))&1;
    
    return res;
}

int cal(vector<int> &filter, int n){
    int res = 0;
    
    res |= filter[cal2(9,13,17,n)]; res <<= 1;
    res |= filter[cal2(8,12,16,n)]; res <<= 1;
    res |= filter[cal2(5,9,14,n)]; res <<= 1;
    res |= filter[cal2(4,8,13,n)]; res <<= 1;
    res |= filter[cal2(3,7,12,n)]; res <<= 1;
    res |= filter[cal2(1,4,9,n)]; res <<= 1;
    res |= filter[cal2(0,3,8,n)];
    
    return res;
}

bool solve(){
    vector<int> filter(MAX);
	vector<int> pos(MAX);
    string c;
    bool ans = true;
    
    cin>>c;
    
    if(c == "#") return false;
    
    for(int i = 0; i < MAX; i++){
        filter[i] = c[i] - '0';
    }
    
    for(int i = 0; i < 1<<19; i++){
        pos[cal(filter, i)]++;
    }
    
    for(int i = 0; i < MAX; i++){
        if(pos[i] && filter[i] != ((i>>3)&1)) ans = false;
    }
    
    if(ans) cout<<"yes"<<endl;
    else cout<<"no"<<endl;
    
    return true;
}

signed main(){
	cout<<fixed<<setprecision(10);
	
    while(solve()){
    }
	
	return 0;
}
accuracy: 1
time_ms: 1470
memory_kb: 3140
final_rank: 3

code_snippet: #include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a) * (a))
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define MOD 1000000007

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
const double EPS = 1e-7, PI = acos(-1);
//ここから編集
int pows[10];
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(8);

  string s;
  pows[0] = 1;
  for(int i=0; i<10-1; i++) pows[i+1] = pows[i]*2;  
  while(cin >> s){
    if(s == "#") break;

    vector<vector<int>> v;
    v.push_back({9, 5, 8, 4, 1, 3, 0});
    v.push_back({13, 9, 12, 8, 4, 7, 3});
    v.push_back({17, 14, 16, 13, 9, 12, 8});
    v.push_back({18, 15, 17, 14, 10, 13, 9});
    v.push_back({15, 11, 14, 10, 6, 9, 5});
    v.push_back({10, 6, 9, 5, 2, 4, 1});
    v.push_back({14, 10, 13, 9, 5, 8, 4});

    bool ok = true;
    for(int bit=0; bit<(1<<19); bit++){

      int t1=0,t2=0,t6=0,t4=0,t5=0,t0=0, init=0;
      for(int i=0; i<7; i++){
        t6 += pows[i] * (bit >> v[0][i] & 1); /* 6 */
        t5 += pows[i] * (bit >> v[1][i] & 1); /* 5 */ 
        t2 += pows[i] * (bit >> v[2][i] & 1); /* 2 */
        t0 += pows[i] * (bit >> v[3][i] & 1); /* 0 */
        t1 += pows[i] * (bit >> v[4][i] & 1); /* 1 */
        t4 += pows[i] * (bit >> v[5][i] & 1); /* 4 */
        init += pows[i] * (bit >> v[6][i] & 1); /* 4 */
      }

      init = s[init] - '0';
      t0 = s[t0] - '0';
      t1 = s[t1] - '0';
      t2 = s[t2] - '0';
      t6 = s[t6] - '0';
      t4 = s[t4] - '0';
      t5 = s[t5] - '0';

      int now = t0*pows[0]+t1*pows[1]+t2*pows[2]+init*pows[3]+t4*pows[4]+t5*pows[5]+t6*pows[6];
      now = s[now] - '0';
      if(init != now) ok = false;
    }
    
    if(ok) cout << "yes" << endl;
    else cout << "no" << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 1740
memory_kb: 3212
final_rank: 5

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int p[7][7]={
    {18,17,16,14,12,11,9},
    {17,15,14,12,10,9,7},
    {16,14,13,11,9,8,6},
    {14,12,11,9,7,6,4},
    {12,10,9,7,5,4,2},
    {11,9,8,6,4,3,1},
    {9,7,6,4,2,1,0}
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s;
    while(cin >> s,s!="#"){
        bool ok=true;
        for(int i=0;i<(1<<19);i++){
            vector<int> a(7,0);
            int c=0;
            for(int j=0;j<7;j++){
                for(int k=0;k<7;k++){
                    a[j]+=(((i>>p[j][k])&1)<<k);
                }
                c+=(s[a[j]]-'0')<<j;
            }
            if(s[c]!=s[a[3]]){
                ok=false; break;
            }
        }
        if(ok)printf("yes\n");
        else printf("no\n");
    }
}
accuracy: 1
time_ms: 2010
memory_kb: 3060
final_rank: 6

code_snippet: #include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000300
vector<vector<int>> nxt = {
	{7,8,9,0,1,2,3},{8,10,0,1,12,3,4},{9,0,11,2,3,13,5},{0,1,2,3,4,5,6},{1,12,3,4,14,6,16},{2,3,13,5,6,15,17},{3,4,5,6,16,17,18}
};
string S;

int get(int x){
	int y = 0;
	rep(i,7){
		int temp = 0;
		rep(j,7){
			if((x>>nxt[i][j])&1)temp |= (1<<j);
		}
		if(S[temp]=='1')y |= (1<<i);		
	}
	return y;
}

int main(){
	
	while(true){
		cin>>S;
		if(S=="#")break;
		bool f = true;
		
		rep(i,(1<<19)){
			int x = get(i);
			int t = (x>>3)&1;
			x = get(x);
			int t2 = (x>>3)&1;
			if(t!=t2){
				f=false;
				break;
			}

		}
		
		if(f)cout<<"yes"<<endl;
		else cout<<"no"<<endl;
		
	}
	
	
	
    return 0;
}
accuracy: 1
time_ms: 5140
memory_kb: 3340
final_rank: 16

code_snippet: #include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

constexpr long long INF = 1LL << 60;
constexpr int inf = 1000000007;
//constexpr long long mod = 1000000007LL;
constexpr long long mod = 998244353LL;

using namespace std;
typedef long long ll;

string s;
array<int, 7> cnv = { 6,4,1,0,2,5,3 };
int f(array<int, 7> v) {
	int idx = 0;
	for (int i = 0; i < v.size(); i++) {
		if (v[i]) idx |= (1 << (cnv[i]));
	}
	return (int)(s[idx] - '0');
}

void solve() {
	cin >> s; if (s == "#") exit(0);
	bool ok = true;
	for (int S = 0; S < (1 << 19); S++) {
		int fr[19] = {};
		for (int i = 0; i < 19; i++) if (S >> i & 1) fr[i] = true;
		int sc[7] = {};
		sc[0] = f({ fr[4],fr[5],fr[6],fr[1],fr[2],fr[3] , fr[0] });
		sc[1] = f({ fr[0],fr[6],fr[18],fr[7],fr[8],fr[2], fr[1] });
		sc[2] = f({ fr[3],fr[0],fr[1],fr[8],fr[9],fr[10], fr[2] });
		sc[3] = f({ fr[12],fr[4],fr[0],fr[2],fr[10],fr[11], fr[3] });
		sc[4] = f({ fr[13],fr[14],fr[5],fr[0],fr[3],fr[12], fr[4] });
		sc[5] = f({ fr[14],fr[15],fr[16],fr[6],fr[0],fr[4], fr[5] });
		sc[6] = f({ fr[5],fr[16],fr[17],fr[18],fr[1],fr[0], fr[6] });
		int fin = f({ sc[4], sc[5], sc[6], sc[1], sc[2], sc[3], sc[0]});
		if (fin != sc[0]) {
			ok = false;
			break;
		}
	}
	if (ok) cout << "yes" << "\n";
	else cout << "no" << "\n";
}
int main()
{

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int kkt = 89;
	while (kkt) solve();
}
accuracy: 1
time_ms: 5520
memory_kb: 3036
final_rank: 17

code_snippet: #include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;

//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	string s;
	vector<vector<int>>v({ { 7,8,9,0,1,2,3 },{ 8,10,0,1,12,3,4 },{ 9,0,11,2,3,13,5 },{ 0,1,2,3,4,5,6 },{ 1,12,3,4,14,6,16 },{ 2,3,13,5,6,15,17 },{ 3,4,5,6,16,17,18 } });
	while (cin >> s, s != "#") {
		bool ans = true;
		for (int i = 0; i < 1 << 19; i++) {
			int nx = 0;
			int a = 0;
			for (int j = 0; j < 7; j++) {
				nx <<= 1;
				nx += (i >> j) & 1;
			}
			for (auto j : v) {
				a <<= 1;
				int b = 0;
				for (auto k : j) {
					b <<= 1;
					b |= (i >> k) & 1;
				}
				a |= s[b] == '1';
			}
			if (s[a] != s[nx]) {
				ans = false;
				break;
			}
		}
		if (ans)cout << "yes\n";
		else cout << "no\n";
	}
}
accuracy: 1
time_ms: 5140
memory_kb: 3100
final_rank: 15