["i", "j", "k", "l", "n", "s", "c", "a", "x", "y", "p", "r", "v", "m", "b", "d", "t", "N", "h", "f", "g", "w", "e", "u", "q", "C", "L", "A", "B", "R", "K"],
"var2" => ["up", "pos", "idx", "score", "eq", "di", "dj", "dx", "dy", "ni", "nj", "nx", "ny", "finish", "step", "num", "rem", "mask", "nmask", "nmasks", "bit", "graph", "adj", "price", "time", "shy", "shx", "shi", "shj", "area", "result", "weight", "cost", "answer", "res", "dp", "ndp", "wave", "nwave", "width", "height", "ilen", "jlen", "iend", "jend", "len", "M", "ok", "ss", "suffix", "prefix", "level", "even", "odd", "sign", "dir", "digit", "inside"],
"keyword" => ["for", "if", "return", "do", "while", "const", "public", "class", "else", "break", "true", "false", "sizeof", "continue", "static", "switch", "try", "catch", "throw", "enum", "typename", "template", "typedef", "this", "operator", "struct", "unsigned", "case"],
"type" => ["char", "int", "long", "vector", "map", "set", "string", "stringstream", "double", "size_t", "bool", "pair", "iterator", "const_iterator", "void", "bitset", "priority_queue", "npos", "complex", "istringstream"],
"methods" => ["pop_back", "push_back", "size", "length", "erase", "insert", "begin", "end", "find", "first", "second", "substr", "clear", "empty", "assign", "front", "back", "append", "reserve", "resize", "rbegin", "rend", "c_str", "pop", "push", "top"],
"io" => ["cout", "endl", "setfill", "setw"],
"stl" => ["sort", "stable_sort", "unique", "max_element", "min_element", "count", "next_permutation", "accumulate", "make_pair", "numeric_limits", "swap", "ostream_iterator", "istream_iterator", "greater", "copy", "set_intersection", "inserter", "count_if", "find_if", "back_inserter", "upper_bound", "lower_bound", "distance", "reverse"],
"c" => ["sprintf", "memset", "atoi"],
"gcc" => ["__builtin_popcount"],
"math" => ["max", "min", "abs", "sqrt", "pow", "sin", "cos", "conj", "hypot", "atan", "exp", "log", "floor", "ceil"],
"func" => ["get", "dfs", "bfs", "gcd", "check", "solve", "kuhn", "kun", "kuhn_dfs", "isprime", "binomial", "ispali", "fact", "fft", "go", "calc", "calculate"]
];
$fncalls = [];
foreach ($files as $file) {
//echo '' . $file . '
';
if (preg_match('@using namespace std;(.*?)(?:$|// BEGIN KAWIGIEDIT TESTING)@is',
file_get_contents($file), $m)) {
$code = $m[1];
preg_match_all('@[^\d\W]+@is', $code, $words);
foreach ($words[0] as $word) {
if (!array_key_exists($word, $word_count)) $word_count[$word] = 0;
++$word_count[$word];
}
preg_match_all('@[^\d\W]+\(@is', $code, $fns);
foreach ($fns[0] as $fn) {
$fn = substr($fn, 0, -1);
if (!array_key_exists($fn, $fncalls)) $fncalls[$fn] = 0;
++$fncalls[$fn];
}
//echo '' . htmlspecialchars($code) . '
';
} else {
echo 'FAILED';
}
//echo '