Problem:
問題名 Zero division checker
森下さんは困っていました... 姉原さんにプログラムを書いてもらったのですが、そのプログラムがクラッシュするのです。
姉原さんに書いてもらったのは、逆ポーランド記法の式を読んで、その計算結果を出力するプログラムで、クラッシュログによると、 0 で割り算をしてしまったのが原因のようです。これは、森下さんが間違った式を入力してしまったからかもしれませんし、もしかしたら、もしかしたら、姉原さんの書いたプログラムにバグがあるのかもしれません。
姉原さんの書いたプログラムを読んでみようと思いましたが、姉原さんのプログラムはアセンブリというよくわからないことばで書かれているようで、見ているだけで頭がガンガンしてきます。
そこで、森下さんはあなたに、式が間違っていないかどうか調べるプログラムを書いてもらうことにしました。式が間違っている、とは、その式に従って計算すると、 0 での割り算をしてしまう可能性のあることをいいます。
なお、姉原さんの書いたコードはとてもふるいコンピューターで動くもので、加減乗除は整数で行い、結果は 8 bit の符号なし整数として保存されます。
例えば、
255+1
は 0 になってしまうし、
3/2
は 1 になります。
あ、姉原さんにはないしょですよ。
(参考)逆ポーランド記法で表された式を計算する、擬似コード
s = 空のスタック
n = 式の要素数
for i in 1..n:
  if 式のi番目の要素が整数:
    sにその整数をプッシュする
  if 式のi番目の要素が変数:
    sにその変数の値をプッシュする
  if 式のi番目の要素が演算子:
    sから値をポップし、bとする
    sから値をポップし、aとする
    if 演算子が'+':
      r = (a + b) % 256 とする
    if 演算子が'-':
      r = (a - b + 256) % 256 とする
    if 演算子が'*':
      r = (a * b) % 256 とする
    if 演算子が'/':
      r = (a / b) % 256 とする
    sにrをプッシュする
sから値をポップし、式の計算結果とする
Input
m
name
1
lb
1
ub
1
...
name
m
lb
m
ub
m
n
e
1
e
2
...
e
n
0 ≤ m ≤ 100
0 ≤ lb
i
≤ ub
i
≤ 255
1 ≤ name
i
(1 ≤ i ≤ m) の長さ ≤ 20
1 ≤ n ≤ 100
m
は変数の数、
name
i
,
lb
i
,
ub
i
はそれぞれ変数iの名前、下限、上限を表します。
n
は式に含まれる要素の数を表し、
e
i
は式の
i
番目の要素を表します。
各変数は式の中に高々1回しか現れません。
Output
式が間違っているときには
error
、間違っていないときには
correct
と一行で出力してください。
Sample Input 1
1
a 1 10
3
10 a /
Output for the Sample Input 1
correct
Sample Input 2
2
a 1 10
b 1 10
5
1 a b - /
Output for the Sample Input 2
error
Sample Input 3
1
a 0 255
7
1 a 2 * 1 + /
Output for the Sample Input 3
correct

Submitted solutions:

code_snippet: #include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstddef>
#include <cstdint>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <optional>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

/* macro */

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n - 1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (i64 i = (i64)(a); i < (i64)(n); i++)
#define RRep(i, a, n) for (i64 i = ((i64)(n - i64(1))); i >= (i64)(a); i--)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define Bit(n) (1LL << (n))

/* macro end */

/* template */

namespace ebi {

#ifdef LOCAL
#define debug(...)                                                      \
    std::cerr << "LINE: " << __LINE__ << "  [" << #__VA_ARGS__ << "]:", \
        debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << std::endl; }

template <typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
    std::cerr << " " << h;
    if (sizeof...(t) > 0) std::cout << " :";
    debug_out(t...);
}

template <typename T1, typename T2>
std::ostream &operator<<(std::ostream &os, const std::pair<T1, T2> &pa) {
    return os << pa.first << " " << pa.second;
}

template <typename T1, typename T2>
std::istream &operator>>(std::istream &os, std::pair<T1, T2> &pa) {
    return os >> pa.first >> pa.second;
}

template <typename T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &vec) {
    for (std::size_t i = 0; i < vec.size(); i++)
        os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}

template <typename T>
std::istream &operator>>(std::istream &os, std::vector<T> &vec) {
    for (T &e : vec) std::cin >> e;
    return os;
}

template <typename T>
std::ostream &operator<<(std::ostream &os, const std::optional<T> &opt) {
    if (opt) {
        os << opt.value();
    } else {
        os << "invalid value";
    }
    return os;
}

using std::size_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;

template <class T, T init>
auto make_vector(int n) {
    return std::vector<T>(n, init);
}

template <class T, T init, typename Head, typename... Tail>
auto make_vector(Head n, Tail... ts) {
    return std::vector(n, make_vector<T, init>(ts...));
}

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

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

template <class T>
T pow(T x, i64 n) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = res * x;
        x = x * x;
        n >>= 1;
    }
    return res;
}

template <class T>
T mod_pow(T x, i64 n, i64 mod) {
    T res = 1;
    while (n > 0) {
        if (n & 1) res = (res * x) % mod;
        x = (x * x) % mod;
        n >>= 1;
    }
    return res;
}

template <class T>
T scan() {
    T val;
    std::cin >> val;
    return val;
}

template <class T>
struct Edge {
    int to;
    T cost;
    Edge(int _to, T _cost = 1) : to(_to), cost(_cost) {}
};

template <class T>
struct Graph : std::vector<std::vector<Edge<T>>> {
    using std::vector<std::vector<Edge<T>>>::vector;
    void add_edge(int u, int v, T w, bool directed = false) {
        (*this)[u].emplace_back(v, w);
        if (directed) return;
        (*this)[v].emplace_back(u, w);
    }
};

struct graph : std::vector<std::vector<int>> {
    using std::vector<std::vector<int>>::vector;
    void add_edge(int u, int v, bool directed = false) {
        (*this)[u].emplace_back(v);
        if (directed) return;
        (*this)[v].emplace_back(u);
    }
};

constexpr i64 LNF = std::numeric_limits<i64>::max() / 4;

constexpr int INF = std::numeric_limits<int>::max() / 2;

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

}  // namespace ebi

/*
    reference: https://gist.github.com/draftcode/1357281
*/

namespace ebi {

typedef std::string::const_iterator State;
class ParseError {};

bool expect(State &begin, char expected) {
    if (*begin == expected) {
        return true;
    } else {
        return false;
    }
}

// beginがexpectedを指していたらbeginを一つ進める。
void consume(State &begin, char expected) {
    if (*begin == expected) {
        begin++;
    } else {
        std::cerr << "Expected '" << expected << "' but got '" << *begin << "'"
                  << std::endl;
        std::cerr << "Rest string is '";
        while (*begin) {
            std::cerr << *begin++;
        }
        std::cerr << "'" << std::endl;
        throw ParseError();
    }
}

bool isdigit(char c) { return '0' <= c && c <= '9'; }

bool isAlpha(char c) { return 'A' <= c && c <= 'Z'; }

bool isalpha(char c) { return 'a' <= c && c <= 'z'; }

}  // namespace ebi

namespace ebi {

void main_() {
    int m;
    std::cin >> m;
    std::map<std::string, std::pair<int, int>> map;
    rep(i, 0, m) {
        std::string name;
        int lb, ub;
        std::cin >> name >> lb >> ub;
        map[name] = {lb, ub};
    }
    std::vector<std::set<int>> vset;
    std::stack<int> stack;
    int n;
    std::cin >> n;
    auto isoperator = [](const std::string &s) -> bool {
        if (s == "+" || s == "-" || s == "*" || s == "/")
            return true;
        else
            return false;
    };
    rep(i, 0, n) {
        std::string e;
        std::cin >> e;
        std::set<int> set;

        if (isoperator(e)) {
            auto r = stack.top();
            stack.pop();
            auto l = stack.top();
            stack.pop();
            for (auto lv : vset[l]) {
                for (auto rv : vset[r]) {
                    int ret;
                    if (e == "+") {
                        ret = lv + rv;
                    } else if (e == "-") {
                        ret = lv - rv;
                    } else if (e == "*") {
                        ret = lv * rv;
                    } else if (e == "/") {
                        if (rv == 0) {
                            std::cout << "error\n";
                            return;
                        }
                        ret = lv / rv;
                    } else
                        assert(0);
                    ret = (ret + 256) % 256;
                    set.insert(ret);
                }
            }
        } else {
            if (map.find(e) == map.end()) {
                int num = 0;
                for (auto c : e) {
                    assert('0' <= c && c <= '9');
                    num *= 10;
                    num += c - '0';
                }
                set.insert(num);
            } else {
                auto [lb, ub] = map[e];
                rep(j, lb, ub + 1) { set.insert(j); }
            }
        }
        stack.push(vset.size());
        vset.emplace_back(set);
    }
    assert(stack.size() == 1);
    std::cout << "correct\n";
}

}  // namespace ebi

int main() {
    std::cout << std::fixed << std::setprecision(15);
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int t = 1;
    // std::cin >> t;
    while (t--) {
        ebi::main_();
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3772
final_rank: 17

code_snippet: #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int m; cin >> m;
    map<string,set<int>> mp;
    rep(_,m) {
        string name; int lb,ub; cin >> name >> lb >> ub;
        set<int> s;
        for(int i = lb; i <= ub; i++) s.insert(i);
        mp[name] = s;
    }

    stack<set<int>> s;
    int n; cin >> n;
    bool flag = false;
    rep(_,n) {
        string e; cin >> e;
        if(isdigit(e[0])) {
            set<int> se;
            se.insert(stoi(e));
            s.push(se);
        } else if(mp.count(e)) {
            s.push(mp[e]);
        } else {
            set<int> b = s.top(); s.pop();
            set<int> a = s.top(); s.pop();

            set<int> c;
            for(int xa : a) for(int xb : b) {
                if(e == "+") c.insert((xa + xb) % 256);
                if(e == "-") c.insert((xa - xb + 256) % 256);
                if(e == "*") c.insert((xa * xb) % 256);
                if(e == "/") {
                    if(xb == 0) {
                        flag = true;
                    } else {
                        c.insert((xa / xb) % 256);
                    }
                }
            }
            s.push(c);
        }
    }

    cout << (flag ? "error" : "correct") << endl;
}
accuracy: 1
time_ms: 30
memory_kb: 3608
final_rank: 18

code_snippet: // I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<stack>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,vector<ll>>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
const ll MOD = 256;
signed main(){
  init_io();
  ll m;
  cin >> m;
  map<string, vector<ll>> mp;
  vector<string> name(m);
  vector<ll> lb(m), ub(m);
  for(int i=0;i<m;i++){
    cin >> name[i] >> lb[i] >> ub[i];
    vector<ll> able(MOD, 0);
    for(int j=lb[i];j<=ub[i];j++) {
      able[j] = 1;
    }
    mp[name[i]] = able;
  }
  ll n;
  cin >> n;
  vector<string> e(n);
  for(int i=0;i<n;i++) {
    cin >> e[i];
  }
  stack<vector<ll>> st;
  for(int i=0;i<n;i++) {
    if (e[i] == "+" || e[i] == "*" || e[i] == "-" || e[i] == "/") {
      vector<ll> able(MOD, 0);
      auto y = st.top(); st.pop();
      auto x = st.top(); st.pop();
      for(int p0=0;p0<MOD;p0++) {
        for(int p1=0;p1<MOD;p1++) {
          if (!x[p0] || !y[p1]) continue;
          if (e[i] == "+") {
            able[(p0+p1)%MOD] = 1;
          }
          if (e[i] == "-") {
            able[(p0-p1+MOD)%MOD] = 1;
          }
          if (e[i] == "*") {
            able[(p0*p1)%MOD] = 1;
          }
          if (e[i] == "/") {
            if (p1==0) {
              cout << "error" << endl;
              return 0;
            }
            able[(p0/p1)%MOD] = 1;
          }
        }
      }
      st.push(able);
    } else if (mp.find(e[i])!=mp.end()){
      st.push(mp[e[i]]);
    } else {
      vector<ll> able(MOD, 0);
      able[stoi(e[i])] = 1;
      st.push(able);
    }
  }
  cout << "correct"<<endl;
}
accuracy: 1
time_ms: 10
memory_kb: 3560
final_rank: 14

code_snippet: /*	author:  Kite_kuma
	created: 2021.08.24 22:57:22 */

// #ifdef LOCAL
// #define _GLIBCXX_DEBUG
// #endif
#include <bits/stdc++.h>
using namespace std;

#pragma region macros

#define foa(s, v) for(auto &s : v)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcnt(n) __builtin_popcountll((long long)n)

#define REPname(a, b, c, d, e, ...) e
#define rep(...) REPname(__VA_ARGS__, REP3, REP2, REP1, REP0)(__VA_ARGS__)
#define REP0(x) for(int Counter_in_rep_macro = 0; Counter_in_rep_macro < (x); ++Counter_in_rep_macro)
#define REP1(i, x) for(int i = 0; i < (x); ++i)
#define REP2(i, l, r) for(int i = (l); i < (r); ++i)
#define REP3(i, l, r, c) for(int i = (l); i < (r); i += (c))

#define DREPname(a, b, c, d, e, ...) e
#define drep(...) DREPname(__VA_ARGS__, DREP3, DREP2, DREP1)(__VA_ARGS__)
#define DREP1(i, x) for(int i = (x)-1; i >= 0; --i)
#define DREP2(i, l, r) for(int i = (r)-1; i >= (l); --i)
#define DREP3(i, l, r, c) for(int i = (r)-1; i >= (l); i -= (c))

#pragma endregion

#pragma region aliases

using ll = long long;
using ld = long double;
using ull = unsigned long long;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vvvi = std::vector<std::vector<std::vector<int>>>;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
template <class T = ll>
using V = std::vector<T>;
template <class T = ll>
using VV = V<V<T>>;
template <class T = ll>
using VVV = V<V<V<T>>>;
template <class T = ll>
using pqup = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T = ll>
using pqdn = std::priority_queue<T>;

#pragma endregion

#pragma region constants

const int inf = 1e6;
const long long INF = 1e18;
const long double pi = acos(-1);
const char dl = '\n';
const char sp = ' ';
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

const int mod_1000000007 = 1000000007;
const int mod_998244353 = 998244353;

#pragma endregion

#pragma region basic_operation

template <class T0, class T1, class T2>
inline bool in_range(T0 x, T1 lef, T2 rig) {
	return ((lef <= x) && (x < rig));
}

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

void Yes(bool f = 1) { std::cout << (f ? "Yes" : "No") << '\n'; }
void No() { std::cout << "No\n"; }
void YES(bool f = 1) { std::cout << (f ? "YES" : "NO") << '\n'; }
void NO() { std::cout << "NO\n"; }

template <class T>
void drop(T answer) {
	std::cout << answer << '\n';
	exit(0);
}

void err(bool flag = true) {
	if(!flag) return;
	std::cout << -1 << '\n';
	exit(0);
}

template <class T>
void vout(std::vector<T> const &v, bool vertically = 0) {
	if(vertically) {
		for(auto const &a : v) {
			std::cout << a << '\n';
		}
		return;
	}
	for(auto it = v.begin(); it != v.end(); it++) {
		std::cout << (*it);
		if(it != v.end() - 1) {
			std::cout << ' ';
		}
	}
	std::cout << '\n';
	return;
}

inline void print() { std::cout << '\n'; }
template <class T>
inline void print(T x) {
	std::cout << x << '\n';
	return;
}
template <typename Head, typename... Tail>
void print(Head H, Tail... T) {
	std::cout << H << " ";
	print(T...);
}

template <class T>
void add(std::vector<T> &v, T val) {
	for(auto &a : v) a += val;
	return;
}

template <class T>
T dup(T a, T b) {
	assert(b != 0);
	return (a + b - 1) / b;
}

template <class T>
T greatest_lower_multiple(T x, T d) {
	if(d == 0) return 0;
	if(d < 0) d *= -1;
	T y = x % d;
	if(y < 0) y += d;
	return x - y;
}

template <class T>
T least_upper_multiple(T x, T d) {
	return -greatest_lower_multiple(-x, d);
}

long long POW(long long a, long long n) {
	long long res = 1;
	while(n > 0) {
		if(n & 1) res = res * a;
		a = a * a;
		n >>= 1;
	}
	return res;
}

long long modpow(long long a, long long n, long long mod) {	 // a^n mod
	assert(n >= 0 && mod);
	if(mod == 1) return 0LL;
	long long res = 1;
	a %= mod;
	while(n > 0) {
		if(n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res < 0 ? res + mod : res;
}

// return x which satisfies a * x % mod == gcd(a, mod)
// not (mod | a)
long long modinv(long long a, long long mod) {
	long long b = mod, u = 1, v = 0;
	while(b) {
		long long t = a / b;
		a -= t * b;
		std::swap(a, b);
		u -= t * v;
		std::swap(u, v);
	}
	u %= mod;
	if(u < 0) u += mod;
	return u;
}

template <class T>
int lb(const std::vector<T> &a, const T x) {
	return std::distance(a.begin(), std::lower_bound(a.begin(), a.end(), x));
}
template <class T>
int ub(const std::vector<T> &a, const T x) {
	return std::distance(a.begin(), std::upper_bound(a.begin(), a.end(), x));
}
template <class T>
void unq_sort(std::vector<T> &a) {
	std::sort(a.begin(), a.end());
	a.erase(std::unique(a.begin(), a.end()), a.end());
}
template <class T>
std::vector<int> press(std::vector<T> &a) {
	auto vec = a;
	unq_sort(vec);
	std::vector<int> ret;
	for(auto &v : a) ret.push_back(lb(vec, v));
	return ret;
}

#pragma endregion

#pragma region input
#define VEC(type, name, size) \
	vector<type> name(size);  \
	scanner::INPUT(name)
#define VVEC(type, name, h, w)                     \
	vector<vector<type>> name(h, vector<type>(w)); \
	scanner::INPUT(name)
#define INT(...)     \
	int __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define LL(...)            \
	long long __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define STR(...)        \
	string __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define CHR(...)      \
	char __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define DBL(...)        \
	double __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define LD(...)              \
	long double __VA_ARGS__; \
	scanner::INPUT(__VA_ARGS__)
#define TPL3(type0, type1, type2, name)   \
	std::tuple<type0, type1, type2> name; \
	scanner::INPUT(name);
#define TPL4(type0, type1, type2, type3, name)   \
	std::tuple<type0, type1, type2, type3> name; \
	scanner::INPUT(name);

namespace scanner {
template <class T>
void scan(T &a) {
	std::cin >> a;
}

template <class T, class L>
void scan(std::pair<T, L> &p) {
	scan(p.first);
	scan(p.second);
}

template <class T0, class T1, class T2>
void scan(std::tuple<T0, T1, T2> &p) {
	T0 t0;
	T1 t1;
	T2 t2;
	scan(t0);
	scan(t1);
	scan(t2);
	p = std::make_tuple(t0, t1, t2);
}

template <class T0, class T1, class T2, class T3>
void scan(std::tuple<T0, T1, T2, T3> &p) {
	T0 t0;
	T1 t1;
	T2 t2;
	T3 t3;
	scan(t0);
	scan(t1);
	scan(t2);
	scan(t3);
	p = std::make_tuple(t0, t1, t2, t3);
}

template <class T>
void scan(std::vector<T> &a) {
	for(auto &i : a) scan(i);
}

void INPUT() {}
template <class Head, class... Tail>
void INPUT(Head &head, Tail &... tail) {
	scan(head);
	INPUT(tail...);
}
}  // namespace scanner

template <typename T1, typename T2>
std::istream &operator>>(std::istream &is, std::pair<T1, T2> &p) {
	is >> p.first >> p.second;
	return is;
}
#pragma endregion

#pragma region debug

#pragma region output
template <typename T1, typename T2>
std::ostream &std::operator<<(std::ostream &os, const std::pair<T1, T2> &p) {
	os << p.first << " " << p.second;
	return os;
}
template <class T>
std::ostream &std::operator<<(std::ostream &os, const std::vector<T> &v) {
	for(int i = 0; i < (int)v.size(); i++) {
		if(i) os << " ";
		os << v[i];
	}
	return os;
}
#pragma endregion

#pragma region view

namespace viewer {
void view(const long long e) {
	if(e == INF)
		std::cerr << "INF";
	else if(e == -INF)
		std::cerr << "-INF";
	else
		std::cerr << e;
}

void view(const int e) {
	if(e == inf)
		std::cerr << "inf";
	else if(e == -inf)
		std::cerr << "-inf";
	else
		std::cerr << e;
}

template <typename T>
void view(const T e) {
	std::cerr << e;
}

template <typename T, typename U>
void view(const std::pair<T, U> &p) {
	std::cerr << "(";
	view(p.first);
	std::cerr << ", ";
	view(p.second);
	std::cerr << ")";
}

template <class T0, class T1, class T2>
void view(const std::tuple<T0, T1, T2> &p) {
	std::cerr << "(";
	view(std::get<0>(p));
	std::cerr << ", ";
	view(std::get<1>(p));
	std::cerr << ", ";
	view(std::get<2>(p));
	std::cerr << ")";
}

template <class T0, class T1, class T2, class T3>
void view(const std::tuple<T0, T1, T2, T3> &p) {
	std::cerr << "(";
	view(std::get<0>(p));
	std::cerr << ", ";
	view(std::get<1>(p));
	std::cerr << ", ";
	view(std::get<2>(p));
	std::cerr << ", ";
	view(std::get<3>(p));
	std::cerr << ")";
}

template <typename T>
void view(const std::set<T> &s) {
	if(s.empty()) {
		std::cerr << "{ }";
		return;
	}
	std::cerr << "{ ";
	for(auto &t : s) {
		view(t);
		std::cerr << ", ";
	}
	std::cerr << "\b\b }";
}

template <typename T>
void view(const std::unordered_set<T> &s) {
	if(s.empty()) {
		std::cerr << "{ }";
		return;
	}
	std::cerr << "{ ";
	for(auto &t : s) {
		view(t);
		std::cerr << ", ";
	}
	std::cerr << "\b\b }";
}

template <typename T>
void view(const std::vector<T> &v) {
	if(v.empty()) {
		std::cerr << "{ }";
		return;
	}
	std::cerr << "{ ";
	for(const auto &e : v) {
		view(e);
		std::cerr << ", ";
	}
	std::cerr << "\b\b }";
}

template <typename T>
void view(const std::vector<std::vector<T>> &vv) {
	std::cerr << "{\n";
	for(const auto &v : vv) {
		std::cerr << "\t";
		view(v);
		std::cerr << '\n';
	}
	std::cerr << "}";
}

template <typename T, typename U>
void view(const std::vector<std::pair<T, U>> &v) {
	std::cerr << "{\n";
	for(const auto &c : v) {
		std::cerr << "\t(";
		view(c.first);
		std::cerr << ", ";
		view(c.second);
		std::cerr << ")\n";
	}
	std::cerr << "}";
}

template <class T0, class T1, class T2>
void view(const std::vector<std::tuple<T0, T1, T2>> &v) {
	if(v.empty()) {
		std::cerr << "{ }";
		return;
	}
	std::cerr << '{';
	for(const auto &t : v) {
		std::cerr << "\n\t";
		view(t);
		std::cerr << ",";
	}
	std::cerr << "\n}";
}

template <class T0, class T1, class T2, class T3>
void view(const std::vector<std::tuple<T0, T1, T2, T3>> &v) {
	if(v.empty()) {
		std::cerr << "{ }";
		return;
	}
	std::cerr << '{';
	for(const auto &t : v) {
		std::cerr << "\n\t";
		view(t);
		std::cerr << ",";
	}
	std::cerr << "\n}";
}

template <typename T, typename U>
void view(const std::map<T, U> &m) {
	std::cerr << "{\n";
	for(const auto &t : m) {
		std::cerr << "\t[";
		view(t.first);
		std::cerr << "] : ";
		view(t.second);
		std::cerr << '\n';
	}
	std::cerr << "}";
}

template <typename T, typename U>
void view(const std::unordered_map<T, U> &m) {
	std::cerr << "{\n";
	for(const auto &t : m) {
		std::cerr << "\t[";
		view(t.first);
		std::cerr << "] : ";
		view(t.second);
		std::cerr << '\n';
	}
	std::cerr << "}";
}
}  // namespace viewer

#pragma endregion

// when debugging : g++ foo.cpp -DLOCAL
#ifdef LOCAL
void debug_out() {}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	viewer::view(H);
	std::cerr << ", ";
	debug_out(T...);
}
#define debug(...)                                                \
	do {                                                          \
		std::cerr << __LINE__ << " [" << #__VA_ARGS__ << "] : ["; \
		debug_out(__VA_ARGS__);                                   \
		std::cerr << "\b\b]\n";                                   \
	} while(0)
#define dump(x)                                      \
	do {                                             \
		std::cerr << __LINE__ << " " << #x << " : "; \
		viewer::view(x);                             \
		std::cerr << '\n';                           \
	} while(0)

#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

#pragma endregion

#pragma region graph

struct Edge {
	int to;
	long long cost;
	Edge() = default;
	Edge(int to_, long long cost_) : to(to_), cost(cost_) {}
	bool operator<(const Edge &a) const { return cost < a.cost; }
	bool operator>(const Edge &a) const { return cost > a.cost; }
	friend std::ostream &operator<<(std::ostream &s, Edge &a) {
		s << "to: " << a.to << ", cost: " << a.cost;
		return s;
	}
};

class Graph {
	std::vector<std::vector<Edge>> edges;

   public:
	inline const std::vector<Edge> &operator[](int k) const { return edges[k]; }
	inline std::vector<Edge> &operator[](int k) { return edges[k]; }

	int size() const { return edges.size(); }
	void resize(const int n) { edges.resize(n); }

	Graph() = default;
	Graph(int n) : edges(n) {}
	Graph(int n, int e, bool weight = 0, bool directed = 0, int idx = 1) : edges(n) { input(e, weight, directed, idx); }
	const long long INF = 3e18;

	void input(int e = -1, bool weight = 0, bool directed = false, int idx = 1) {
		if(e == -1) e = size() - 1;
		while(e--) {
			int u, v;
			long long cost = 1;
			std::cin >> u >> v;
			if(weight) std::cin >> cost;
			u -= idx, v -= idx;
			edges[u].emplace_back(v, cost);
			if(!directed) edges[v].emplace_back(u, cost);
		}
	}

	void add_edge(int u, int v, long long cost = 1, bool directed = false, int idx = 0) {
		u -= idx, v -= idx;
		edges[u].emplace_back(v, cost);
		if(!directed) edges[v].emplace_back(u, cost);
	}

	// Ο(V+E)
	std::vector<long long> bfs(int s) {
		std::vector<long long> dist(size(), INF);
		std::queue<int> que;
		dist[s] = 0;
		que.push(s);
		while(!que.empty()) {
			int v = que.front();
			que.pop();
			for(auto &e : edges[v]) {
				if(dist[e.to] != INF) continue;
				dist[e.to] = dist[v] + e.cost;
				que.push(e.to);
			}
		}
		return dist;
	}

	// Ο(V+E)
	// constraint: cost of each edge is zero or one
	std::vector<long long> zero_one_bfs(int s) {
		std::vector<long long> dist(size(), INF);
		std::deque<int> deq;
		dist[s] = 0;
		deq.push_back(s);
		while(!deq.empty()) {
			int v = deq.front();
			deq.pop_front();
			for(auto &e : edges[v]) {
				assert(0LL <= e.cost and e.cost < 2LL);
				if(e.cost and dist[e.to] > dist[v] + 1) {
					dist[e.to] = dist[v] + 1;
					deq.push_back(e.to);
				} else if(!e.cost and dist[e.to] > dist[v]) {
					dist[e.to] = dist[v];
					deq.push_front(e.to);
				}
			}
		}
		return dist;
	}

	// Ο((E+V)logV)
	// cannot reach: INF
	std::vector<long long> dijkstra(int s) {  // verified
		std::vector<long long> dist(size(), INF);
		const auto compare = [](const std::pair<long long, int> &a, const std::pair<long long, int> &b) { return a.first > b.first; };
		std::priority_queue<std::pair<long long, int>, std::vector<std::pair<long long, int>>, decltype(compare)> que{compare};
		dist[s] = 0;
		que.emplace(0, s);
		while(!que.empty()) {
			std::pair<long long, int> p = que.top();
			que.pop();
			int v = p.second;
			if(dist[v] < p.first) continue;
			for(auto &e : edges[v]) {
				if(dist[e.to] > dist[v] + e.cost) {
					dist[e.to] = dist[v] + e.cost;
					que.emplace(dist[e.to], e.to);
				}
			}
		}
		return dist;
	}

	// Ο(VE)
	// cannot reach: INF
	// negative cycle: -INF
	std::vector<long long> bellman_ford(int s) {  // verified
		int n = size();
		std::vector<long long> res(n, INF);
		res[s] = 0;
		for(int loop = 0; loop < n - 1; loop++) {
			for(int v = 0; v < n; v++) {
				if(res[v] == INF) continue;
				for(auto &e : edges[v]) {
					res[e.to] = std::min(res[e.to], res[v] + e.cost);
				}
			}
		}
		std::queue<int> que;
		std::vector<int> chk(n);
		for(int v = 0; v < n; v++) {
			if(res[v] == INF) continue;
			for(auto &e : edges[v]) {
				if(res[e.to] > res[v] + e.cost and !chk[e.to]) {
					que.push(e.to);
					chk[e.to] = 1;
				}
			}
		}
		while(!que.empty()) {
			int now = que.front();
			que.pop();
			for(auto &e : edges[now]) {
				if(!chk[e.to]) {
					chk[e.to] = 1;
					que.push(e.to);
				}
			}
		}
		for(int i = 0; i < n; i++)
			if(chk[i]) res[i] = -INF;
		return res;
	}

	// Ο(V^3)
	std::vector<std::vector<long long>> warshall_floyd() {	// verified
		int n = size();
		std::vector<std::vector<long long>> dist(n, std::vector<long long>(n, INF));
		for(int i = 0; i < n; i++) dist[i][i] = 0;
		for(int i = 0; i < n; i++)
			for(auto &e : edges[i]) dist[i][e.to] = std::min(dist[i][e.to], e.cost);
		for(int k = 0; k < n; k++)
			for(int i = 0; i < n; i++) {
				if(dist[i][k] == INF) continue;
				for(int j = 0; j < n; j++) {
					if(dist[k][j] == INF) continue;
					dist[i][j] = std::min(dist[i][j], dist[i][k] + dist[k][j]);
				}
			}
		return dist;
	}

	// Ο(V) (using DFS)
	// if a directed cycle exists, return {}
	std::vector<int> topological_sort() {  // verified
		std::vector<int> res;
		int n = size();
		std::vector<int> used(n, 0);
		bool not_DAG = false;
		auto dfs = [&](auto self, int k) -> void {
			if(not_DAG) return;
			if(used[k]) {
				if(used[k] == 1) not_DAG = true;
				return;
			}
			used[k] = 1;
			for(auto &e : edges[k]) self(self, e.to);
			used[k] = 2;
			res.push_back(k);
		};
		for(int i = 0; i < n; i++) dfs(dfs, i);
		if(not_DAG) return std::vector<int>{};
		std::reverse(res.begin(), res.end());
		return res;
	}

	bool is_DAG() { return !topological_sort().empty(); }  // verified

	// Ο(V)
	// array of the distance from each vertex to the most distant vertex
	std::vector<long long> height() {  // verified
		auto vec1 = bfs(0);
		int v1 = -1, v2 = -1;
		long long dia = -1;
		for(int i = 0; i < int(size()); i++)
			if(dia < vec1[i]) dia = vec1[i], v1 = i;
		vec1 = bfs(v1);
		dia = -1;
		for(int i = 0; i < int(size()); i++)
			if(dia < vec1[i]) dia = vec1[i], v2 = i;
		auto vec2 = bfs(v2);
		for(int i = 0; i < int(size()); i++) {
			if(vec1[i] < vec2[i]) vec1[i] = vec2[i];
		}
		return vec1;
	}

	// O(V+E)
	// vector<(int)(0 or 1)>
	// if it is not bipartite, return {}
	std::vector<int> bipartite_grouping() {
		std::vector<int> colors(size(), -1);
		auto dfs = [&](auto self, int now, int col) -> bool {
			colors[now] = col;
			for(auto &e : edges[now]) {
				if(col == colors[e.to]) return false;
				if(colors[e.to] == -1 and !self(self, e.to, !col)) return false;
			}
			return true;
		};
		for(int i = 0; i < int(size()); i++)
			if(!colors[i] and !dfs(dfs, i, 0)) return std::vector<int>{};
		return colors;
	}

	bool is_bipartite() { return !bipartite_grouping().empty(); }

	// Ο(V+E)
	// ((v1, v2), diameter)
	std::pair<std::pair<int, int>, long long> diameter() {	// verified
		auto vec = bfs(0);
		int v1 = -1, v2 = -1;
		long long dia = -1;
		for(int i = 0; i < int(size()); i++)
			if(dia < vec[i]) dia = vec[i], v1 = i;
		vec = bfs(v1);
		dia = -1;
		for(int i = 0; i < int(size()); i++)
			if(dia < vec[i]) dia = vec[i], v2 = i;
		std::pair<std::pair<int, int>, long long> res = {{v1, v2}, dia};
		return res;
	}

	// Ο(ElogV)
	long long prim() {	// verified
		long long res = 0;
		std::priority_queue<Edge, std::vector<Edge>, std::greater<Edge>> que;
		for(auto &e : edges[0]) que.push(e);
		std::vector<int> chk(size());
		chk[0] = 1;
		int cnt = 1;
		while(cnt < size()) {
			auto e = que.top();
			que.pop();
			if(chk[e.to]) continue;
			cnt++;
			res += e.cost;
			chk[e.to] = 1;
			for(auto &e2 : edges[e.to]) que.push(e2);
		}
		return res;
	}

	// Ο(ElogE)
	long long kruskal() {  // verified
		std::vector<std::tuple<int, int, long long>> Edges;
		for(int i = 0; i < int(size()); i++)
			for(auto &e : edges[i]) Edges.emplace_back(i, e.to, e.cost);
		std::sort(Edges.begin(), Edges.end(), [](const std::tuple<int, int, long long> &a, const std::tuple<int, int, long long> &b) {
			return std::get<2>(a) < std::get<2>(b);
		});
		std::vector<int> uf_data(size(), -1);
		auto root = [&uf_data](auto self, int x) -> int {
			if(uf_data[x] < 0) return x;
			return uf_data[x] = self(self, uf_data[x]);
		};
		auto unite = [&uf_data, &root](int u, int v) -> bool {
			u = root(root, u), v = root(root, v);
			if(u == v) return false;
			if(uf_data[u] > uf_data[v]) std::swap(u, v);
			uf_data[u] += uf_data[v];
			uf_data[v] = u;
			return true;
		};
		long long ret = 0;
		for(auto &e : Edges)
			if(unite(std::get<0>(e), std::get<1>(e))) ret += std::get<2>(e);
		return ret;
	}

	// O(V)
	std::vector<int> centroid() {
		int n = size();
		std::vector<int> centroid, sz(n);
		auto dfs = [&](auto self, int now, int per) -> void {
			sz[now] = 1;
			bool is_centroid = true;
			for(auto &e : edges[now]) {
				if(e.to != per) {
					self(self, e.to, now);
					sz[now] += sz[e.to];
					if(sz[e.to] > n / 2) is_centroid = false;
				}
			}
			if(n - sz[now] > n / 2) is_centroid = false;
			if(is_centroid) centroid.push_back(now);
		};
		dfs(dfs, 0, -1);
		return centroid;
	}

	// Ο(V+E)
	// directed graph from root to leaf
	Graph root_to_leaf(int root = 0) {
		Graph res(size());
		std::vector<int> chk(size(), 0);
		chk[root] = 1;
		auto dfs = [&](auto self, int now) -> void {
			for(auto &e : edges[now]) {
				if(chk[e.to] == 1) continue;
				chk[e.to] = 1;
				res.add_edge(now, e.to, e.cost, 1, 0);
				self(self, e.to);
			}
		};
		dfs(dfs, root);
		return res;
	}

	// Ο(V+E)
	// directed graph from leaf to root
	Graph leaf_to_root(int root = 0) {
		Graph res(size());
		std::vector<int> chk(size(), 0);
		chk[root] = 1;
		auto dfs = [&](auto self, int now) -> void {
			for(auto &e : edges[now]) {
				if(chk[e.to] == 1) continue;
				chk[e.to] = 1;
				res.add_edge(e.to, now, e.cost, 1, 0);
				self(self, e.to);
			}
		};
		dfs(dfs, root);
		return res;
	}

	// long long Chu_Liu_Edmonds(int root = 0) {}
};

struct tree_doubling {
   private:
	std::vector<std::vector<int>> parent;
	std::vector<int> depth;
	std::vector<long long> dist;
	int max_jump = 1;

	void build() {
		for(int i = 0; i < max_jump - 1; i++) {
			for(int v = 0; v < (int)dist.size(); v++) {
				if(parent[i][v] == -1)
					parent[i + 1][v] = -1;
				else
					parent[i + 1][v] = parent[i][parent[i][v]];
			}
		}
	}

   public:
	tree_doubling() = default;
	tree_doubling(const Graph &g, const int root = 0) : dist(g.size()), depth(g.size()) {
		int n = g.size();
		while((1 << max_jump) < n) max_jump++;
		parent.assign(max_jump, std::vector<int>(n, -1));
		auto dfs = [&](auto self, int now, int per, int d, long long cost) -> void {
			parent[0][now] = per;
			depth[now] = d;
			dist[now] = cost;
			for(auto &e : g[now])
				if(e.to != per) self(self, e.to, now, d + 1, cost + e.cost);
		};
		dfs(dfs, root, -1, 0, 0LL);
		build();
	}

	int lowest_common_ancestor(int u, int v) {
		if(depth[u] < depth[v]) std::swap(u, v);
		int k = parent.size();
		for(int i = 0; i < k; i++)
			if((depth[u] - depth[v]) >> i & 1) u = parent[i][u];
		if(u == v) return u;
		for(int i = k - 1; i >= 0; i--)
			if(parent[i][u] != parent[i][v]) u = parent[i][u], v = parent[i][v];
		return parent[0][u];
	}

	long long length_of_path(const int u, const int v) { return dist[u] + dist[v] - dist[lowest_common_ancestor(u, v)] * 2; }

	int level_ancestor(int v, int level) {
		assert(level >= 0);
		for(int jump = 0; jump < max_jump and level; jump++) {
			if(level & 1) v = parent[jump][v];
			level >>= 1;
		}
		return v;
	}
};

struct strongly_connected_components {
   private:
	enum { CHECKED = -1, UNCHECKED = -2 };
	const Graph &graph_given;
	Graph graph_reversed;
	std::vector<int> order, group_number; /* at the beginning of the building, 'group_number' is used as 'checked' */

	void dfs(int now) {
		if(group_number[now] != UNCHECKED) return;
		group_number[now] = CHECKED;
		for(auto &e : graph_given[now]) dfs(e.to);
		order.push_back(now);
	}

	void rdfs(int now, int group_count) {
		if(group_number[now] != UNCHECKED) return;
		group_number[now] = group_count;
		for(auto &e : graph_reversed[now]) rdfs(e.to, group_count);
	}

	void build(bool create_compressed_graph) {
		for(int i = 0; i < (int)graph_given.size(); i++) dfs(i);
		reverse(order.begin(), order.end());
		group_number.assign(graph_given.size(), UNCHECKED);
		int group = 0;
		for(auto &i : order)
			if(group_number[i] == UNCHECKED) rdfs(i, group), group++;
		graph_compressed.resize(group);
		groups.resize(group);
		for(int i = 0; i < (int)graph_given.size(); i++) groups[group_number[i]].push_back(i);
		if(create_compressed_graph) {
			std::vector<int> edges(group, -1);
			for(int i = 0; i < group; i++)
				for(auto &vertex : groups[i])
					for(auto &e : graph_given[vertex])
						if(group_number[e.to] != i and edges[group_number[e.to]] != i) {
							edges[group_number[e.to]] = i;
							graph_compressed[i].emplace_back(group_number[e.to], 1);
						}
		}
		return;
	}

   public:
	std::vector<std::vector<int>> groups;
	Graph graph_compressed;

	strongly_connected_components(const Graph &g_, bool create_compressed_graph = false)
		: graph_given(g_), graph_reversed(g_.size()), group_number(g_.size(), UNCHECKED) {
		for(size_t i = 0; i < g_.size(); i++)
			for(auto &e : graph_given[i]) graph_reversed[e.to].emplace_back(i, 1);
		build(create_compressed_graph);
	}

	const int &operator[](const int k) { return group_number[k]; }
};

struct low_link {
   private:
	const Graph &graph_given;
	int order_next;

	void build() {
		int n = graph_given.size();
		order.resize(n, -1);
		low.resize(n);
		order_next = 0;
		for(int i = 0; i < n; i++)
			if(order[i] == -1) dfs(i);
	}

	void dfs(int now, int par = -1) {
		low[now] = order[now] = order_next++;
		bool is_articulation = false;
		int cnt = 0, cnt_par = 0;
		for(const auto &ed : graph_given[now]) {
			const int &nxt = ed.to;
			if(order[nxt] == -1) {
				cnt++;
				dfs(nxt, now);
				if(order[now] < low[nxt]) bridge.push_back(std::minmax(now, nxt));
				if(order[now] <= low[nxt]) is_articulation = true;
				low[now] = std::min(low[now], low[nxt]);
			} else if(nxt != par or cnt_par++ == 1) {
				low[now] = std::min(low[now], order[nxt]);
			}
		}
		if(par == -1 and cnt < 2) is_articulation = false;
		if(is_articulation) articulation.push_back(now);
		return;
	}

   public:
	std::vector<int> order, low, articulation;
	std::vector<std::pair<int, int>> bridge;
	low_link() = default;
	low_link(const Graph &g_) : graph_given(g_) { build(); }
};

struct twoedge_connected_components {
   private:
	const Graph &graph_given;
	int group_next;
	low_link li;
	std::vector<int> group_number;

	void build(bool create_compressed_graph) {
		int n = graph_given.size();
		group_number.resize(n, -1);
		group_next = 0;
		for(int i = 0; i < n; i++)
			if(group_number[i] == -1) dfs(i);
		groups.resize(group_next);
		for(int i = 0; i < graph_given.size(); i++) groups[group_number[i]].push_back(i);

		if(create_compressed_graph) {
			graph_compressed.resize(group_next);
			for(const auto &[u, v] : li.bridge) {
				int x = group_number[u], y = group_number[v];
				graph_compressed.add_edge(x, y);
			}
		}
	}

	void dfs(int now, int par = -1) {
		if(par != -1 and li.order[par] >= li.low[now])
			group_number[now] = group_number[par];
		else
			group_number[now] = group_next++;
		for(const auto &e : graph_given[now])
			if(group_number[e.to] == -1) dfs(e.to, now);
	}

   public:
	Graph graph_compressed;
	std::vector<std::vector<int>> groups;
	twoedge_connected_components(const Graph &g_, bool create_compressed_graph = false) : graph_given(g_), li(g_) {
		build(create_compressed_graph);
	}

	const int &operator[](const int k) { return group_number[k]; }
};

#pragma endregion

int solve(int n) {
	map<string, set<int>> variables;
	rep(n) {
		STR(var);
		int low, high;
		cin >> low >> high;
		set<int> s;
		rep(i, low, high + 1) s.insert(i);
		variables[var] = s;
	}

	int len;
	cin >> len;

	stack<set<int>> st;

	auto op = [&](set<int> a, set<int> b, char ope) -> set<int> {
		set<int> ret;
		foa(lef, a) foa(rig, b) {
			if(rig == 0 && ope == '/') {
				return set<int>({});
			}

			int add;
			switch(ope) {
				case '+':
					add = lef + rig;
					break;

				case '-':
					add = lef - rig;
					break;

				case '/':
					add = lef / rig;
					break;

				case '*':
					add = lef * rig;
					break;

				default:
					break;
			}

			ret.insert(((add % 256) + 256) % 256);
		}
		return ret;
	};

	rep(i, len) {
		string nxt;
		cin >> nxt;
		set<int> t;

		set<int> a;
		if(nxt == "+" || nxt == "-" || nxt == "*" || nxt == "/") {
			t = st.top();
			st.pop();
			a = st.top();
			st.pop();
			st.push(op(a, t, nxt.front()));
		} else {
			if(variables.count(nxt)) {
				t = variables[nxt];
			} else {
				t.insert(stoi(nxt));
			}
			st.push(t);
		}
	}

	auto res = st.top();
	return !res.empty();
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout << std::fixed << std::setprecision(15);
	srand((unsigned)time(NULL));

	int n;
	while(cin >> n) {
		cout << (solve(n) ? "correct" : "error");
		cout << dl;
	}
}
accuracy: 1
time_ms: 10
memory_kb: 3664
final_rank: 16

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

const int mod = 256;

int main() {
    int m;
    cin >> m;
    map<string, vector<bool>> mp;
    for (int i = 0; i < m; ++i) {
        string name;
        int lb, ub;
        cin >> name >> lb >> ub;
        mp[name].resize(mod);
        for (int j = lb; j <= ub; ++j) {
            mp[name][j] = true;
        }
    }
    int n;
    cin >> n;
    vector<string> e(n);
    for (auto& ei : e) cin >> ei;

    stack<string> s;
    for (auto& ei : e) {
        if (isdigit(ei[0])) {
            s.push(ei);
        } else if (isalpha(ei[0])) {
            s.push(ei);
        } else {
            string b = s.top(); s.pop();
            string a = s.top(); s.pop();
            if (ei == "+") {
                if (isdigit(a[0])) {
                    if (isdigit(b[0])) {
                        s.push(to_string((stoi(a) + stoi(b)) % mod));
                    } else {
                        vector<bool> check(mod);
                        for (int j = 0; j < mod; ++j) {
                            if (mp[b][j]) check[(stoi(a) + j) % mod] = true;
                        }
                        mp[b] = move(check);
                        s.push(b);
                    }
                } else {
                    if (isdigit(b[0])) {
                        vector<bool> check(mod);
                        for (int j = 0; j < mod; ++j) {
                            if (mp[a][j]) check[(j + stoi(b)) % mod] = true;
                        }
                        mp[a] = move(check);
                        s.push(a);
                    } else {
                        vector<bool> check(mod);
                        for (int j = 0; j < mod; ++j) {
                            if (!mp[a][j]) continue;
                            for (int k = 0; k < mod; ++k) {
                                if (!mp[b][k]) continue;
                                check[(j + k) % mod] = true;
                            }
                        }
                        mp[a] = move(check);
                        s.push(a);
                    }
                }
            } else if (ei == "-") {
                if (isdigit(a[0])) {
                    if (isdigit(b[0])) {
                        s.push(to_string((stoi(a) - stoi(b) + mod) % mod));
                    } else {
                        vector<bool> check(mod);
                        for (int j = 0; j < mod; ++j) {
                            if (mp[b][j]) check[(stoi(a) - j + mod) % mod] = true;
                        }
                        mp[b] = move(check);
                        s.push(b);
                    }
                } else {
                    if (isdigit(b[0])) {
                        vector<bool> check(mod);
                        for (int j = 0; j < mod; ++j) {
                            if (mp[a][j]) check[(j - stoi(b) + mod) % mod] = true;
                        }
                        mp[a] = move(check);
                        s.push(a);
                    } else {
                        vector<bool> check(mod);
                        for (int j = 0; j < mod; ++j) {
                            if (!mp[a][j]) continue;
                            for (int k = 0; k < mod; ++k) {
                                if (!mp[b][k]) continue;
                                check[(j - k + mod) % mod] = true;
                            }
                        }
                        mp[a] = move(check);
                        s.push(a);
                    }
                }
            } else if (ei == "*") {
                if (isdigit(a[0])) {
                    if (isdigit(b[0])) {
                        s.push(to_string((stoi(a) * stoi(b)) % mod));
                    } else {
                        vector<bool> check(mod);
                        for (int j = 0; j < mod; ++j) {
                            if (mp[b][j]) check[(stoi(a) * j) % mod] = true;
                        }
                        mp[b] = move(check);
                        s.push(b);
                    }
                } else {
                    if (isdigit(b[0])) {
                        vector<bool> check(mod);
                        for (int j = 0; j < mod; ++j) {
                            if (mp[a][j]) check[(j * stoi(b)) % mod] = true;
                        }
                        mp[a] = move(check);
                        s.push(a);
                    } else {
                        vector<bool> check(mod);
                        for (int j = 0; j < mod; ++j) {
                            if (!mp[a][j]) continue;
                            for (int k = 0; k < mod; ++k) {
                                if (!mp[b][k]) continue;
                                check[(j * k) % mod] = true;
                            }
                        }
                        mp[a] = move(check);
                        s.push(a);
                    }
                }
            } else if (ei == "/") {
                if (isdigit(a[0])) {
                    if (isdigit(b[0])) {
                        if (stoi(b) == 0) {
                            cout << "error\n";
                            return 0;
                        }
                        s.push(to_string((stoi(a) / stoi(b)) % mod));
                    } else {
                        vector<bool> check(mod);
                        for (int j = 0; j < mod; ++j) {
                            if (mp[b][j]) {
                                if (j == 0) {
                                    cout << "error\n";
                                    return 0;
                                }
                                check[(stoi(a) / j) % mod] = true;
                            }
                        }
                        mp[b] = move(check);
                        s.push(b);
                    }
                } else {
                    if (isdigit(b[0])) {
                        if (stoi(b) == 0) {
                            cout << "error\n";
                            return 0;
                        }
                        vector<bool> check(mod);
                        for (int j = 0; j < mod; ++j) {
                            if (mp[a][j]) check[(j / stoi(b)) % mod] = true;
                        }
                        mp[a] = move(check);
                        s.push(a);
                    } else {
                        vector<bool> check(mod);
                        for (int j = 0; j < mod; ++j) {
                            if (!mp[a][j]) continue;
                            for (int k = 0; k < mod; ++k) {
                                if (!mp[b][k]) continue;
                                if (k == 0) {
                                    cout << "error\n";
                                    return 0;
                                }
                                check[(j / k) % mod] = true;
                            }
                        }
                        mp[a] = move(check);
                        s.push(a);
                    }
                }
            } else {
                assert(false);
            }
        }
    }
    cout << "correct\n";
}
accuracy: 1
time_ms: 10
memory_kb: 3540
final_rank: 13

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

const int UP=256;
int ADD(int a,int b){return (a+b)%UP;}
int SUB(int a,int b){return (a-b+UP)%UP;}
int MUL(int a,int b){return a*b%UP;}
int DIV(int a,int b){return a/b;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m; cin >> m;
    vector<string> name(m);
    vector<int> lb(m),ub(m);
    for (int i=0;i<m;++i) cin >> name[i] >> lb[i] >> ub[i];
    int n; cin >> n;
    vector<string> S(n);
    for (int i=0;i<n;++i) cin >> S[i];

    map<string,int> mp;
    for (int i=0;i<m;++i) mp[name[i]]=i;

    stack<vector<bool>> st;
    for (int i=0;i<n;++i){
        if (isdigit(S[i][0])){
            int res=stoi(S[i]);
            vector<bool> v(UP,false);
            v[res]=true; st.emplace(v);
        } else if (S[i]=="+"||S[i]=="-"||S[i]=="*"||S[i]=="/"){
            vector<bool> v=st.top(); st.pop();
            vector<bool> u=st.top(); st.pop();
            vector<bool> w(UP,false);
            for (int j=0;j<UP;++j){
                for (int k=0;k<UP;++k){
                    if (u[j]&&v[k]){
                        if (S[i]=="+") w[ADD(j,k)]=true;
                        if (S[i]=="-") w[SUB(j,k)]=true;
                        if (S[i]=="*") w[MUL(j,k)]=true;
                        if (S[i]=="/"){
                            if (k==0){
                                cout << "error" << '\n';
                                return 0;
                            }
                            w[DIV(j,k)]=true;
                        }
                    }
                }
            }
            st.emplace(w);
        } else {
            int x=mp[S[i]];
            vector<bool> v(UP,false);
            for (int i=lb[x];i<=ub[x];++i) v[i]=true;
            st.emplace(v);
        }
    }

    cout << "correct" << '\n';
}
accuracy: 1
time_ms: 10
memory_kb: 3224
final_rank: 2

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 int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
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 UP=256;
int ADD(int a,int b){return (a+b)%UP;}
int SUB(int a,int b){return (a-b+UP)%UP;}
int MUL(int a,int b){return a*b%UP;}
int DIV(int a,int b){return a/b;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m; cin >> m;
    vector<string> name(m);
    vector<int> lb(m),ub(m);
    for (int i=0;i<m;++i) cin >> name[i] >> lb[i] >> ub[i];
    int n; cin >> n;
    vector<string> S(n);
    for (int i=0;i<n;++i) cin >> S[i];

    map<string,int> mp;
    for (int i=0;i<m;++i) mp[name[i]]=i;

    stack<vector<bool>> st;
    for (int i=0;i<n;++i){
        if (isdigit(S[i][0])){
            int res=stoi(S[i]);
            vector<bool> v(UP,false);
            v[res]=true; st.emplace(v);
        } else if (S[i]=="+"||S[i]=="-"||S[i]=="*"||S[i]=="/"){
            vector<bool> v=st.top(); st.pop();
            vector<bool> u=st.top(); st.pop();
            vector<bool> w(UP,false);
            for (int j=0;j<UP;++j){
                for (int k=0;k<UP;++k){
                    if (u[j]&&v[k]){
                        if (S[i]=="+") w[ADD(j,k)]=true;
                        if (S[i]=="-") w[SUB(j,k)]=true;
                        if (S[i]=="*") w[MUL(j,k)]=true;
                        if (S[i]=="/"){
                            if (k==0){
                                cout << "error" << '\n';
                                return 0;
                            }
                            w[DIV(j,k)]=true;
                        }
                    }
                }
            }
            st.emplace(w);
        } else {
            int x=mp[S[i]];
            vector<bool> v(UP,false);
            for (int i=lb[x];i<=ub[x];++i) v[i]=true;
            st.emplace(v);
        }
    }

    cout << "correct" << '\n';
}
accuracy: 1
time_ms: 10
memory_kb: 3244
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);
//ここから編集

string solve(){
  int m; cin >> m;
  vector<string> name(m);
  vector<int> lb(m), ub(m);
  REP(i,m) cin >> name[i] >> lb[i] >> ub[i];

  map<string, int> mp;
  REP(i,m) mp[name[i]] = i;

  int n; cin >> n;
  vector<string> ss(n);
  REP(i,n) cin >> ss[i];
  stack<vector<int>> stt;
  REP(i,n){
    string s = ss[i];
    if(s == "/" || s == "*" || s == "+" || s == "-"){
      auto b = stt.top();
      stt.pop();
      auto a = stt.top();
      stt.pop();
      set<int> st;
      if(s == "/"){
        for(int j=0; j<a.size(); j++){
          for(int k=0; k<b.size(); k++){
            if(b[k] == 0) return "error";
            st.insert(a[j]/b[k]);
          }
        }
      }else if(s == "*"){
        for(int j=0; j<a.size(); j++){
          for(int k=0; k<b.size(); k++){
            st.insert(a[j]*b[k]%256);
          }
        }
      }else if(s == "+"){
        for(int j=0; j<a.size(); j++){
          for(int k=0; k<b.size(); k++){
            st.insert(a[j]+b[k] % 256);
          }
        }
      }else if(s == "-"){
        for(int j=0; j<a.size(); j++){
          for(int k=0; k<b.size(); k++){
            st.insert((a[j]-b[k]+256)%256);
          }
        }
      }
      vector<int> tmp;
      for(auto e: st) tmp.push_back(e);
      stt.push(tmp);
    }else if(mp.find(s) != mp.end()){
      int idx = mp[s];
      vector<int> tmp;
      for(int j=lb[idx]; j<=ub[idx]; j++) tmp.push_back(j);
      stt.push(tmp);
    }else{
      int num = stoi(s);
      stt.push({num});
    }
  }
  return "correct";
}
int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(6);

  cout << solve() << endl;
  
  return 0;
}
accuracy: 0.35714285714285715
time_ms: 10
memory_kb: 3280
final_rank: 20

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

using namespace std;
using pi=pair<int,int>;
int main() {
    int m;
    cin>>m;
    map<string,vector<int>> mp;
    for(int i = 0; i < m; ++i){
        string a;
        cin>>a;
        int l,u;
        cin>>l>>u;
        vector<int> vb(256,0);
        for(int j = l; j <= u; ++j){
            vb[j]=1;
        }
        mp[a]=vb;
    }
    stack<string> st;
    int n;
    cin>>n;
    string s;
    bool av,bv;
    string a,b;
    for(int i = 0; i < n; ++i){
        cin>>s;
        //cout<<s<<endl;
        //cerr<<i<<endl;
        switch (s[0]) {
        case '+':
            b=st.top();
            st.pop();
            a=st.top();
            st.pop();
            bv=isalpha(b[0]);
            av=isalpha(a[0]);//変数名はたぶんアルファベットから始まる
            if(!bv) {
                if(!av) {
                    int res=stoi(b)+stoi(a);
                    res%=256;
                    st.push(to_string(res));
                }
                else {
                    int bn=stoi(b);
                    for(int j = 0; j < 256; ++j){
                        if(mp[a][j]%2!=1)continue;
                        mp[a][(j+bn)%256]+=2;
                    }
                    for(int j = 0; j < 256; ++j){
                        if(mp[a][j]>=2)mp[a][j]=1;
                        else mp[a][j]=0;
                    }
                    st.push(a);
                }
            }
            else {
                if(!av) {
                    int an=stoi(a);
                    for(int j = 0; j < 256; ++j){
                        if(mp[b][j]%2!=1)continue;
                        mp[b][(j+an)%256]+=2;
                    }
                    for(int j = 0; j < 256; ++j){
                        if(mp[b][j]>=2)mp[b][j]=1;
                        else mp[b][j]=0;
                    }
                    st.push(b);
                }
                else {
                    for(int j = 0; j < 256; ++j){
                        if(mp[b][j]%2!=1)continue;
                        for(int k = 0; k < 256; ++k){
                            if(mp[a][k]%2!=1)continue;
                            mp[b][(j+k)%256]+=2;
                        }
                    }
                    for(int j = 0; j < 256; ++j){
                        if(mp[b][j]>=2)mp[b][j]=1;
                        else mp[b][j]=0;
                    }
                    st.push(b);
                }
            }
            break;
        case '-':
            b=st.top();
            st.pop();
            a=st.top();
            st.pop();
            bv=isalpha(b[0]);
            av=isalpha(a[0]);//変数名はたぶんアルファベットから始まる
            if(!bv) {
                if(!av) {
                    int res=stoi(a)-stoi(b)+256;
                    res%=256;
//cerr<<res<<endl;
                    st.push(to_string(res));
                }
                else {
                    int bn=stoi(b);
                    for(int j = 0; j < 256; ++j){
                        if(mp[a][j]%2!=1)continue;
                        mp[a][(j-bn+256)%256]+=2;
                    }
                    for(int j = 0; j < 256; ++j){
                        if(mp[a][j]>=2)mp[a][j]=1;
                        else mp[a][j]=0;
                    }
                    st.push(a);
                }
            }
            else {
                if(!av) {
                    int an=stoi(a);
                    for(int j = 0; j < 256; ++j){
                        if(mp[b][j]%2!=1)continue;
                        mp[b][(an-j+256)%256]+=2;
                    }
                    for(int j = 0; j < 256; ++j){
                        if(mp[b][j]>=2)mp[b][j]=1;
                        else mp[b][j]=0;
                    }
                    st.push(b);
                }
                else {
                    for(int j = 0; j < 256; ++j){
                        if(mp[b][j]%2!=1)continue;
                        for(int k = 0; k < 256; ++k){
                            if(mp[a][k]%2!=1)continue;
                            mp[b][(k-j+256)%256]+=2;
                        }
                    }
                    for(int j = 0; j < 256; ++j){
                        if(mp[b][j]>=2)mp[b][j]=1;
                        else mp[b][j]=0;
//if(mp[b][j]==1)cerr<<j<<" ";
                    }
//cerr<<endl;
                    st.push(b);
                }
            }
            break;
        case '*':
            b=st.top();
            st.pop();
            a=st.top();
            st.pop();
            bv=isalpha(b[0]);
            av=isalpha(a[0]);//変数名はたぶんアルファベットから始まる
            if(!bv) {
                if(!av) {
                    int res=stoi(b)*stoi(a);
                    res%=256;
                    st.push(to_string(res));
                }
                else {
                    int bn=stoi(b);
                    for(int j = 0; j < 256; ++j){
                        if(mp[a][j]%2!=1)continue;
                        mp[a][(j*bn)%256]+=2;
                    }
                    for(int j = 0; j < 256; ++j){
                        if(mp[a][j]>=2)mp[a][j]=1;
                        else mp[a][j]=0;
                    }
                    st.push(a);
                }
            }
            else {
                if(!av) {
                    int an=stoi(a);
                    for(int j = 0; j < 256; ++j){
                        if(mp[b][j]%2!=1)continue;
                        mp[b][(j*an)%256]+=2;
                    }
                    for(int j = 0; j < 256; ++j){
                        if(mp[b][j]>=2)mp[b][j]=1;
                        else mp[b][j]=0;
                    }
                    st.push(b);
                }
                else {
                    for(int j = 0; j < 256; ++j){
                        if(mp[b][j]%2!=1)continue;
                        for(int k = 0; k < 256; ++k){
                            if(mp[a][k]%2!=1)continue;
                            mp[b][(j*k)%256]+=2;
                        }
                    }
                    for(int j = 0; j < 256; ++j){
                        if(mp[b][j]>=2)mp[b][j]=1;
                        else mp[b][j]=0;
                    }
                    st.push(b);
                }
            }
            break;
        case '/':
            b=st.top();
            st.pop();
            a=st.top();
            st.pop();
            bv=isalpha(b[0]);
            av=isalpha(a[0]);//変数名はたぶんアルファベットから始まる
            if(!bv) {
                if(stoi(b)==0) {
                        cout<<"error"<<endl;
                        return 0;
                    }
                if(!av) {
                    int res=stoi(a)/stoi(b);
                    res%=256;
                    st.push(to_string(res));
                }
                else {
                    int bn=stoi(b);
                    for(int j = 0; j < 256; ++j){
                        if(mp[a][j]%2!=1)continue;
                        mp[a][(j/bn)%256]+=2;
                    }
                    for(int j = 0; j < 256; ++j){
                        if(mp[a][j]>=2)mp[a][j]=1;
                        else mp[a][j]=0;
                    }
                    st.push(a);
                }
            }
            else {
                if(mp[b][0]==1) {
                        cout<<"error"<<endl;
                        return 0;
                }
                if(!av) {
                    int an=stoi(a);
                    
                    for(int j = 0; j < 256; ++j){
                        if(mp[b][j]%2!=1)continue;
                        mp[b][(an/j)%256]+=2;
                    }
                    for(int j = 0; j < 256; ++j){
                        if(mp[b][j]>=2)mp[b][j]=1;
                        else mp[b][j]=0;
                    }
                    st.push(b);
                }
                else {
                    for(int j = 0; j < 256; ++j){
                        if(mp[b][j]%2!=1)continue;
                        for(int k = 0; k < 256; ++k){
                            if(mp[a][k]%2!=1)continue;
                            mp[b][(k/j+256)%256]+=2;
                        }
                    }
                    for(int j = 0; j < 256; ++j){
                        if(mp[b][j]>=2)mp[b][j]=1;
                        else mp[b][j]=0;
                    }
                    st.push(b);
                }
            }
            break;
        default:
            st.push(s);
            break;
        }
    }
    cout<<"correct"<<endl;
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3344
final_rank: 11

code_snippet: #include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

int main() {

  const int mod = 256;
  
  int m; cin >> m;
  map<string, pair<int, int>> mp;
  for (int i = 0; i < m; i++) {
    string name; cin >> name;
    int l, r; cin >> l >> r;
    mp[name] = {l, r};
  }

  stack<set<int>> stk;
  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s == "+" || s == "-" || s == "*" || s == "/") {
      // 演算子の場合
      auto b = stk.top();
      stk.pop();
      auto a = stk.top();
      stk.pop();

      // 0 division checker
      if (s == "/") {
        for (auto bb : b) {
          if (bb == 0) {
            cout << "error" << endl;
            return 0;
          }
        }
      }

      set<int> st;
      // 全探索
      for (auto aa : a) {
        for (auto bb : b) {
          int num;
          if (s == "+") {
            num = (aa + bb) % mod;
          }
          if (s == "-") {
            num = (aa - bb + mod) % mod;
          }
          if (s == "*") {
            num = (aa * bb) % mod;
          }
          if (s == "/") {
            num = (aa / bb) % mod;
          }

          st.insert(num);
        }
      }

      stk.push(st);

    } else if (mp.find(s) != mp.end()) {
      // 変数の場合
      int l, r;
      tie(l, r) = mp[s];
      set<int> st;
      for (int i = l; i <= r; i++) {
        st.insert(i);
      }
      stk.push(st);
    } else {
      // 整数の場合
      int num = stoi(s);
      set<int> st;
      st.insert(num);
      stk.push(st);
    }
  }

  cout << "correct" << endl;

  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3272
final_rank: 8

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
    int r;
    cin >> r;
    map<string,pair<int,int>> m;
    map<string,vector<int>> mm;
    rep(i,r){
        string s;
        int a,b;
        cin >> s >> a >> b;
        m[s]=mk(a,b);
    }
    int n;
    cin >> n;
    stack<string> w;
    rep(i,n){
        string s;
        cin >> s;
        if (s=="+" || s=="-" || s=="*" || s=="/"){
            string a=w.top();
            w.pop();
            string b=w.top();
            w.pop();
            int c=0,d=0;
            if (a[0]-'0'<=9 && a[0]-'0'>=0){
                rep(j,a.size()){
                    int u=a[j]-'0';
                    c*=10;
                    c+=u;
                }
            }
            if (b[0]-'0'<=9 && b[0]-'0'>=0){
                rep(j,b.size()){
                    int u=b[j]-'0';
                    d*=10;
                    d+=u;
                }
            }
            vector<int> oo(256,0);
            if (m.find(b)!=m.end()){
                int f=m[b].first,g=m[b].second;
                for (int j=f;j<=g;j++){
                    if (m.find(a)!=m.end()){
                        int ff=m[a].first,gg=m[a].second;
                        for (int k=ff;k<=gg;k++){
                            if (s=="+") oo[(j+k)%256]=1;
                            if (s=="-") oo[(256+j-k)%256]=1;
                            if (s=="*") oo[(j*k)%256]=1;
                            if (s=="/"){
                                if (k==0){
                                    cout << "error" << endl;
                                    return 0;
                                }
                                else oo[(j/k)%256]=1;
                            } 
                        }
                    }
                    else if (mm.find(a)!=mm.end()){
                        for (int k=0;k<256;k++){
                            if (mm[a][k]==0) continue;
                            if (s=="+") oo[(j+k)%256]=1;
                            if (s=="-") oo[(256+j-k)%256]=1;
                            if (s=="*") oo[(j*k)%256]=1;
                            if (s=="/"){
                                if (k==0){
                                    cout << "error" << endl;
                                    return 0;
                                }
                                else oo[(j/k)%256]=1;
                            } 
                        }
                    }
                    else {
                        int k=c;
                        if (s=="+") oo[(j+k)%256]=1;
                        if (s=="-") oo[(256+j-k)%256]=1;
                        if (s=="*") oo[(j*k)%256]=1;
                        if (s=="/"){
                            if (k==0){
                                cout << "error" << endl;
                                return 0;
                            }
                            else oo[(j/k)%256]=1;
                        } 
                    }
                }
            }
            else if (mm.find(b)!=mm.end()){
                rep(j,256){
                    if (mm[b][j]==0) continue;
                    if (m.find(a)!=m.end()){
                        int ff=m[a].first,gg=m[a].second;
                        for (int k=ff;k<=gg;k++){
                            if (s=="+") oo[(j+k)%256]=1;
                            if (s=="-") oo[(256+j-k)%256]=1;
                            if (s=="*") oo[(j*k)%256]=1;
                            if (s=="/"){
                                if (k==0){
                                    cout << "error" << endl;
                                    return 0;
                                }
                                else oo[(j/k)%256]=1;
                            } 
                        }
                    }
                    else if (mm.find(a)!=mm.end()){
                        for (int k=0;k<256;k++){
                            if (mm[a][k]==0) continue;
                            if (s=="+") oo[(j+k)%256]=1;
                            if (s=="-") oo[(256+j-k)%256]=1;
                            if (s=="*") oo[(j*k)%256]=1;
                            if (s=="/"){
                                if (k==0){
                                    cout << "error" << endl;
                                    return 0;
                                }
                                else oo[(j/k)%256]=1;
                            } 
                        }
                    }
                    else {
                        int k=c;
                        if (s=="+") oo[(j+k)%256]=1;
                        if (s=="-") oo[(256+j-k)%256]=1;
                        if (s=="*") oo[(j*k)%256]=1;
                        if (s=="/"){
                            if (k==0){
                                cout << "error" << endl;
                                return 0;
                            }
                            else oo[(j/k)%256]=1;
                        } 
                    }
                }
            }
            else {
                int j=d;
                if (m.find(a)!=m.end()){
                        int ff=m[a].first,gg=m[a].second;
                        for (int k=ff;k<=gg;k++){
                            if (s=="+") oo[(j+k)%256]=1;
                            if (s=="-") oo[(256+j-k)%256]=1;
                            if (s=="*") oo[(j*k)%256]=1;
                            if (s=="/"){
                                if (k==0){
                                    cout << "error" << endl;
                                    return 0;
                                }
                                else oo[(j/k)%256]=1;
                            } 
                        }
                    }
                    else if (mm.find(a)!=mm.end()){
                        for (int k=0;k<256;k++){
                            if (mm[a][k]==0) continue;
                            if (s=="+") oo[(j+k)%256]=1;
                            if (s=="-") oo[(256+j-k)%256]=1;
                            if (s=="*") oo[(j*k)%256]=1;
                            if (s=="/"){
                                if (k==0){
                                    cout << "error" << endl;
                                    return 0;
                                }
                                else oo[(j/k)%256]=1;
                            } 
                        }
                    }
                    else {
                        int k=c;
                        if (s=="+") oo[(j+k)%256]=1;
                        if (s=="-") oo[(256+j-k)%256]=1;
                        if (s=="*") oo[(j*k)%256]=1;
                        if (s=="/"){
                            if (k==0){
                                cout << "error" << endl;
                                return 0;
                            }
                            else oo[(j/k)%256]=1;
                        } 
                    }
            }
            string h;
            rep(j,i+1) h.push_back('?');
            w.push(h);
            mm[h]=oo;
        }
        else w.push(s);
    }
    cout << "correct" << endl;
}
accuracy: 1
time_ms: 20
memory_kb: 3480
final_rank: 15

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main(){
  int m;
  cin >> m;
  map<string, vector<bool>> mp;
  for (int i = 0; i < m; i++){
    string name;
    int lb, ub;
    cin >> name >> lb >> ub;
    mp[name] = vector<bool>(256, false);
    for (int j = lb; j <= ub; j++){
      mp[name][j] = true;
    }
  }
  int n;
  cin >> n;
  bool ok = true;
  stack<vector<bool>> st;
  for (int i = 0; i < n; i++){
    string S;
    cin >> S;
    if (mp.count(S)){
      st.push(mp[S]);
    } else if ('0' <= S[0] && S[0] <= '9'){
      vector<bool> tmp(256, false);
      tmp[stoi(S)] = true;
      st.push(tmp);
    } else {
      vector<bool> b = st.top();
      st.pop();
      vector<bool> a = st.top();
      st.pop();
      if (S == "/" && b[0]){
        ok = false;
        break;
      }
      vector<bool> r(256, false);
      for (int i = 0; i < 256; i++){
        for (int j = 0; j < 256; j++){
          if (a[i] && b[j]){
            if (S == "+"){
              r[(i + j) % 256] = true;
            }
            if (S == "-"){
              r[(i - j + 256) % 256] = true;
            }
            if (S == "*"){
              r[i * j % 256] = true;
            }
            if (S == "/"){
              r[i / j] = true;
            }
          }
        }
      }
      st.push(r);
    }
  }
  if (ok){
    cout << "correct" << endl;
  } else {
    cout << "error" << endl;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 3244
final_rank: 3

code_snippet: #define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 4LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll

void solve(){
	int n;
	cin >> n;
	map<string, pair<int, int>> variables;
	REP(i, n) {
		string a;
		int b, c;
		cin >> a >> b >> c;
		variables[a] = mp(b, c);
	}
	stack<set<int>> now_stack;
	int m;
	cin >> m;
	REP(te, m) {
		string s;
		cin >> s;
		if (s[0] >= '0' && s[0] <= '9') {
			now_stack.push(set<int>{stoll(s)});
		}
		else if(variables.find(s) != variables.end()) {
			set<int> geko;
			for (int q = variables[s].first; q <= variables[s].second; ++q) {
				geko.insert(q);
			}
			now_stack.push(geko);
		}
		else {
			set<int> now[2];
			now[0] = now_stack.top();
			now_stack.pop();
			now[1] = now_stack.top();
			now_stack.pop();
			set<int> result;
			for (auto x : now[1]) {
				for (auto y : now[0]) {
					if (s == "+") {
						result.insert((x + y) % 256);
					}
					else if (s == "-") {
						result.insert((x - y + 256) % 256);
					}
					else if (s == "*") {
						result.insert((x * y) % 256);
					}
					else {
						if (y == 0) {
							cout << "error" << endl;
							return;
						}
						result.insert((x / y) % 256);
					}
				}
			}
			now_stack.push(result);
		}
	}
	cout << "correct" << endl;
}

#undef int
int main() {
	init();

	solve();
}
accuracy: 1
time_ms: 20
memory_kb: 3304
final_rank: 9

code_snippet: #include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0, 0,-1,1,-1, 1,-1};
int dy[]={0,1,-1, 0,1,-1,-1, 1};



int main(){
    int m;cin >> m;
    vector<string> s(m);
    vector<int> l(m),r(m);
    unordered_map<string,vector<bool>> val;
    for (int i = 0; i < m; i++) {
        cin >> s[i] >> l[i] >> r[i];
        r[i]++;
        vector<bool> v(256,false);
        for (int j = l[i]; j < r[i]; j++) {
            v[j] = true;
        }
        val[s[i]] = v;
    }
    int n;cin >> n;
    stack<string> st;
    bool f = false;
    vector<int> c(10,0);
    for (int i = 0; i < n; i++) {
        string t;cin >> t;
        if(t[0]=='+'){
            string q = st.top();st.pop();
            string p = st.top();st.pop();
            vector<bool> v(256,false);
            for (int j = 0; j < 256; j++) {
                if(!val[p][j]) continue;
                for (int k = 0; k < 256; k++) {
                    if(!val[q][k]) continue;
                    v[(j+k)%256] = true;
                }
            }
            val[p] = v;
            st.push(p);
        }
        else if(t[0]=='-'){
            string q = st.top();st.pop();
            string p = st.top();st.pop();
            vector<bool> v(256,false);
            for (int j = 0; j < 256; j++) {
                if(!val[p][j]) continue;
                for (int k = 0; k < 256; k++) {
                    if(!val[q][k]) continue;
                    v[(j-k+256)%256] = true;
                }
            }
            val[p] = v;
            st.push(p);
        }
        else if(t[0]=='*'){
            string q = st.top();st.pop();
            string p = st.top();st.pop();
            vector<bool> v(256,false);
            for (int j = 0; j < 256; j++) {
                if(!val[p][j]) continue;
                for (int k = 0; k < 256; k++) {
                    if(!val[q][k]) continue;
                    v[(j*k)%256] = true;
                }
            }
            val[p] = v;
            st.push(p);
        }
        else if(t[0]=='/'){
            string q = st.top();st.pop();
            string p = st.top();st.pop();
            vector<bool> v(256,false);
            for (int j = 0; j < 256; j++) {
                if(!val[p][j]) continue;
                for (int k = 0; k < 256; k++) {
                    if(!val[q][k]) continue;
                    if(k==0){
                        puts("error");
                        return 0;
                    }
                    v[j/k] = true;
                }
            }
            val[p] = v;
            st.push(p);
        }
        else{
            if(0<=t[0]-'0'&&t[0]-'0'<10){
                vector<bool> v(256,false);
                v[stoi(t)] = true;
                t += to_string(c[t[0] - '0']++);
                val[t] = v;
            }
            st.push(t);
        }
    }
    puts("correct");
    return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3320
final_rank: 10

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

long long m, n;
vector<string> e;
map<string, set<int>> mp;
stack<set<int>> st;

bool solve();

int main() {
  cin >> m;
  for(int i = 0; i < m; ++i) {
    string s;
    int l, r;
    cin >> s >> l >> r;
    for(int i = l; i <= r; ++i) mp[s].insert(i);
  }
  cin >> n;
  e.resize(n);
  for(int i = 0; i < n; ++i) cin >> e[i];
  if(solve())
    cout << "correct" << endl;
  else
    cout << "error" << endl;
  return 0;
}

bool solve() {
  for(int i = 0; i < n; ++i) {
    set<int> a, b, c;
    if(e[i] == "+") {
      b = st.top();
      st.pop();
      a = st.top();
      st.pop();
      for(int x : a)
        for(int y : b) c.insert((x + y) % MOD);
      st.push(c);
    }
    else if(e[i] == "-") {
      b = st.top();
      st.pop();
      a = st.top();
      st.pop();
      for(int x : a)
        for(int y : b) c.insert((x - y + MOD) % MOD);
      st.push(c);
    }
    else if(e[i] == "*") {
      b = st.top();
      st.pop();
      a = st.top();
      st.pop();
      for(int x : a)
        for(int y : b) c.insert((x * y) % MOD);
      st.push(c);
    }
    else if(e[i] == "/") {
      b = st.top();
      st.pop();
      a = st.top();
      st.pop();
      for(int x : a)
        for(int y : b) {
          if(y == 0) return 0;
          c.insert((x / y) % MOD);
        }
      st.push(c);
    }
    else if(isdigit(e[i][0])) {
      a.insert(stoi(e[i]) % MOD);
      st.push(a);
    }
    else
      st.push(mp[e[i]]);
  }
  return 1;
}
accuracy: 1
time_ms: 10
memory_kb: 3356
final_rank: 6

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
map<string, set<int> > mp;

int f(string s) {
    //cerr << s << endl;
    if(s.size() == 1) return s[0] - '0';
    return 10 * f(s.substr(0, s.size() - 1)) + s.back() - '0';
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m;
    cin >> m;
    while(m--) {
        string s;
        cin >> s;
        int l, u;
        cin >> l >> u;
        for(int i = l; i <= u; i++) mp[s].insert(i);
    }
    string NEWVAL;
    for(int i = 1; i <= 21; i++) NEWVAL.push_back('A');
    int n;
    cin >> n;
    stack<string> sta;
    while(n--) {
        string s;
        cin >> s;
        NEWVAL[0]++;
        if(s == "+" || s == "-" || s == "*" || s == "/") {
            string a = sta.top();
            sta.pop();
            string b = sta.top();
            sta.pop();
            for(auto itr = mp[a].begin(); itr != mp[a].end(); itr++) {
                for(auto itr2 = mp[b].begin(); itr2 != mp[b].end(); itr2++) {
                    if(s == "/" && *itr == 0) {
                        cout << "error" << endl;
                        return 0;
                    }
                    if(s == "+") mp[NEWVAL].insert((*itr2 + *itr) % 256);
                    if(s == "-") mp[NEWVAL].insert((*itr2 - *itr + 256) % 256);
                    if(s == "*") mp[NEWVAL].insert(*itr * *itr2 % 256);
                    if(s == "/") mp[NEWVAL].insert(*itr2 / *itr % 256);
                }
            }
            sta.push(NEWVAL);
            continue;
        }
        if(!mp[s].empty()) {
            sta.push(s);
        } else {
            /*
            cerr << "nmb: " << s << endl;
            cerr << f(s) << endl;
            */
            mp[NEWVAL].insert(f(s));
            sta.push(NEWVAL);
        }
    }
    cout << "correct" << endl;
    return 0;
}
accuracy: 1
time_ms: 50
memory_kb: 3528
final_rank: 19

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

bool solve() {
	int m; cin >> m;
	map<string, pair<int, int>> range;
	while(m--) {
		string name; cin >> name;
		int lb, ub; cin >> lb >> ub;
		range[name] = {lb, ub};
	}
	int n; cin >> n;
	stack<set<int>> num;
	while(n--) {
		string e; cin >> e;
		set<int> st;
		if(range.count(e)) {
			for(int i = range[e].first; i <= range[e].second; ++i) {
				st.insert(i);
			}
		} else if(e == "+" or e == "-" or e == "*" or e == "/") {
			auto st2 = num.top();
			num.pop();
			auto st1 = num.top();
			num.pop();
			for(auto lhs : st1) {
				for(auto rhs : st2) {
					if(e == "+") st.insert((lhs + rhs) % 256);
					if(e == "-") st.insert((lhs - rhs + 256) % 256);
					if(e == "*") st.insert((lhs * rhs) % 256);
					if(e == "/") {
						if(rhs == 0) return false;
						st.insert((lhs / rhs) % 256);
					}
				}
			}
		} else {
			int tmp = 0;
			for(char c : e) {
				tmp *= 10;
				tmp += c - '0';
			}
			st.insert(tmp);
		}
		num.push(st);
	}
	return true;
}

int main() {
	cout << (solve() ? "correct" : "error") << "\n";
	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3240
final_rank: 7

code_snippet: #include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<stack>
using namespace std;
int n,m;
map<string,int>M;
vector<int>a[100];
bool flag;
int cal(int x,int y,char c)
{
	if(c=='+')return(x+y)%256;
	else if(c=='-')return(x-y+256)%256;
	else if(c=='*')return x*y%256;
	else
	{
		if(y)return x/y%256;
		else return flag=true;
	}
}
main()
{
	cin>>m;
	for(int i=0;i<m;i++)
	{
		string s;int L,R;
		cin>>s>>L>>R;
		M[s]=i;
		for(int j=L;j<=R;j++)a[i].push_back(j);
	}
	cin>>n;
	stack<int>S;
	for(;n--;)
	{
		string s;cin>>s;
		if(s[0]>='0'&&s[0]<='9')
		{
			int now=0;
			for(int i=0;i<s.size();i++)now=(now*10+s[i]-48)%256;
			S.push(now);
		}
		else if(M.find(s)!=M.end())
		{
			S.push(~M[s]);
		}
		else
		{
			int x,y;
			y=S.top();S.pop();
			x=S.top();S.pop();
			if(x>=0&&y>=0)S.push(cal(x,y,s[0]));
			else
			{
				vector<int>tmp;
				if(x>=0)
				{
					for(int Y:a[~y])tmp.push_back(cal(x,Y,s[0]));
					sort(tmp.begin(),tmp.end());
					tmp.erase(unique(tmp.begin(),tmp.end()),tmp.end());
					a[~y]=tmp;
					S.push(y);
				}
				else if(y>=0)
				{
					for(int X:a[~x])tmp.push_back(cal(X,y,s[0]));
					sort(tmp.begin(),tmp.end());
					tmp.erase(unique(tmp.begin(),tmp.end()),tmp.end());
					a[~x]=tmp;
					S.push(x);
				}
				else
				{
					for(int X:a[~x])for(int Y:a[~y])tmp.push_back(cal(X,Y,s[0]));
					sort(tmp.begin(),tmp.end());
					tmp.erase(unique(tmp.begin(),tmp.end()),tmp.end());
					a[~x]=tmp;
					S.push(x);
				}
			}
		}
	}
	cout<<(flag?"error":"correct")<<endl;
}
accuracy: 1
time_ms: 10
memory_kb: 3488
final_rank: 12

code_snippet: #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>

using namespace std;

using lint = long long;
using ldouble = long double;

int main() {
    int M;
    cin >> M;

    map<string, set<int>> trans;
    for (int i = 0; i < M; ++i) {
        string name;
        int l, r;
        cin >> name >> l >> r;
        for (int a = l; a <= r; ++a) {
            trans[name].insert(a);
        }
    }

    int N;
    cin >> N;
    stack<set<int>> st;
    for (int i = 0; i < N; ++i) {
        string S;
        cin >> S;

        if (S == "+" || S == "-" || S == "*" || S == "/") {
            auto s = st.top();
            st.pop();
            auto t = st.top();
            st.pop();

            st.push(set<int>());
            for (auto b : s) {
                for (auto a : t) {
                    if (S == "+") {
                        st.top().insert((a + b) % 256);
                    } else if (S == "-") {
                        st.top().insert((a - b + 256) % 256);
                    } else if (S == "*") {
                        st.top().insert((a * b) % 256);
                    } else if (S == "/") {
                        if (b == 0) {
                            cout << "error" << endl;
                            return 0;
                        }
                        st.top().insert((a / b) % 256);
                    }
                }
            }
        } else if (trans.count(S)) {
            st.push(trans[S]);
        } else {
            st.push(set<int>({stoi(S)}));
        }
    }

    cout << "correct" << endl;
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3348
final_rank: 5

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

#pragma GCC optimize("O3")
#pragma GCC target("tune=native")
#pragma GCC target("avx")
// #pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = i64(1e18)+MOD;

template <typename T = i64>
struct Range{
    struct iterator{
        T value;
        const T step, last;
        const T& operator*(){return value;}
        iterator(T value, T step, T last) :
            value(step < static_cast<T>(0) ? max(last, value) : min(last, value)),
            step(step),
            last(last)
        {
        }
        iterator operator++(){value = step < static_cast<T>(0) ? max(value + step, last) : min(value + step, last); return *this;}
        bool operator!=(const iterator& x){return value != x.value;}
    };
    const T start, last, step;

    Range(const T start, const T last, const T step = static_cast<T>(1)) :
        start(start),
        last(last),
        step(step)
    {
    }

    Range(const T last) :
        start(0),
        last(last),
        step(1)
    {
    }

    iterator begin(){return iterator(start, step, last);}
    iterator end(){return iterator(last, step, last);}
};

template <typename F>
struct FixPoint{
    const F _f;
    FixPoint(F&& f) : _f(forward<F>(f)){}

    template<typename... Types>
    decltype(auto) operator()(Types&&... args) const{
        return _f(*this, forward<Types>(args)...);
    }
};

template <typename F>
static decltype(auto) makeRec(F&& f){
    return FixPoint<F>(forward<F>(f));
}

template <typename T, T Value = T()>
vector<T> makeVector(size_t x){
    return vector<T>(x, T(Value));
}

template <typename T, T Value = T(), typename... Types>
auto makeVector(size_t x, Types... args){
    return vector<decltype(makeVector<T, Value>(args...))>(x, makeVector<T, Value>(args...));
}

template <typename T = i64>
bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}

template <typename T = i64>
bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}

#define dump(x) fprintf(stderr, "line =%4d, name =%7s , ", __LINE__, #x); clog << "value = " << x << endl;

#define vecdump(x) fprintf(stderr, "line =%4d, name =%7s\n", __LINE__, #x); _dump_macro(x);

void _dump(int, string& x){
    clog << x << endl;
}

template <typename T>
void _dump(bool, T& x){
    clog << x << " ";
}

template <typename T, typename U = typename T::iterator>
void _dump(int, T& x){

    for(auto& elm : x)
        _dump(0, elm);

    clog << endl;
}

template <typename T>
void _dump_macro(T& x){
    _dump(0, x);
}

void _input(int, string& x){
    cin >> x;
}

template <typename T>
void _input(bool, T& x){
    cin >> x;
}

template <typename T, typename U = typename T::iterator>
void _input(int, T& x){

    for(auto& elm : x)
        _input(0, elm);
}

template <typename T>
void input_single(T& x){
    _input(0, x);
}

auto input(){}

template <typename T, typename... Types>
void input(T& value, Types&&... args){
    input_single(value);
    input(forward<Types>(args)...);
};

void _pararell_input(size_t){}

template <typename T, typename... Types>
void _pararell_input(size_t index, T& value, Types&&... args){
    input(value[index]);
    _pararell_input(index, forward<Types>(args)...);
}

template <typename... Types>
void pararell_input(size_t count, Types&&... args){
    for(const auto& i : Range<>(count))
        _pararell_input(i, forward<Types>(args)...);
}


bool solve(){

    int m;
    input(m);
    vector<string> c(m);
    vector<int> l(m), r(m);
    unordered_map<string, pair<int,int>> ma;
    pararell_input(m, c, l, r);
    for(auto& x : r)
        ++x;
    for(int i = 0; i < m; ++i)
        ma[c[i]] = make_pair(l[i], r[i]);
    int n;
    input(n);
    vector<string> v(n);
    input(v);
    vector<string> op{"+", "-", "*", "/"};

    using bs = bitset<256>;
    stack<bs> st;

    for(int i = 0; i < n; ++i){
        if(ma.find(v[i]) != ma.end()){
            bs s;
            auto p = ma[v[i]];
            for(int j = p.first; j < p.second; ++j)
                s.set(j);
            st.push(s);
        }else if(find(op.begin(), op.end(), v[i]) != op.end()){

            if(st.size() < 2){
                cout << "error" << endl;
                return 0;
            }
            bs b = st.top();
            st.pop();
            bs a = st.top();
            st.pop();

            bs ans;

            for(int j = 0; j < 256; ++j)
                for(int k = 0; k < 256; ++k){
                    if(!a[j] || !b[k])
                        continue;
                    if(v[i] == "+"){
                        int val = (j + k) % 256;
                        ans.set(val);
                    }
                    if(v[i] == "-"){
                        int val = (j - k + 256) % 256;
                        ans.set(val);
                    }
                    if(v[i] == "*"){
                        int val = (j * k) % 256;
                        ans.set(val);
                    }
                    if(v[i] == "/"){
                        if(k == 0){
                            cout << "error" << endl;
                            return 0;
                        }
                        int val = j / k;
                        ans.set(val);
                    }
                }

            st.push(ans);

        }else{
            int val = stoi(v[i]);
            bs s;
            s.set(val);
            st.push(s);
        }
    }

    if(st.size() == 1)
        cout << "correct" << endl;
    else
        cout << "error" << endl;

    return false;
}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    while(solve());

}
accuracy: 1
time_ms: 10
memory_kb: 3216
final_rank: 1