This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc -shared -fPIC -O2 pathguard.c -o libpathguard.so -ldl | |
// ALLOW_PATHS="/proc:/dev/null:/usr:." LD_PRELOAD="$PWD/libpathguard.so" ./program | |
#define _GNU_SOURCE | |
#include <dlfcn.h> | |
#include <errno.h> | |
#include <fcntl.h> | |
#include <limits.h> | |
#include <pthread.h> | |
#include <stdarg.h> | |
#include <stdbool.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Helper library to give the DSL a nicer syntax. See e.g. sum-loop.py for example usage.""" | |
from collections import Counter | |
import inspect | |
import typing | |
ctr = 0 | |
def name(tp): | |
global ctr | |
ctr += 1 | |
return f"{tp}_{ctr}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Topological sort algorithm based on DFS: | |
/// https://en.wikipedia.org/wiki/Topological_sorting#Depth-first_search | |
/// Finds either an ordering of the vertices such that all edges go from | |
/// lower to higher indexed nodes, or a cycle. | |
fn toposort(graph: &[Vec<usize>]) -> Result<Vec<usize>, Vec<usize>> { | |
let n = graph.len(); | |
#[derive(Copy, Clone)] | |
enum State { | |
Unvisited, | |
Active(usize, usize), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef USE_AVX256 | |
#pragma GCC target ("avx2") | |
#else | |
#define NDEBUG | |
#pragma GCC target ("avx512f,avx512bw") | |
#endif | |
#pragma GCC optimize ("unroll-loops") | |
#pragma GCC optimize ("O4") | |
#include <bits/stdc++.h> | |
#include <immintrin.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
#include <immintrin.h> | |
using namespace std; | |
#define rep(i, from, to) for (int i = from; i < (to); ++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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace ttmath{typedef unsigned int U;typedef signed int sint;typedef uint64_t ulint;typedef int64_t slint;}namespace ttmath{enum LibTypeCode{asm_vc_32=0,asm_gcc_32,asm_vc_64,asm_gcc_64,no_asm_32,no_asm_64};enum ErrorCode{err_ok=0,err_nothing_has_read,err_unknown_character,err_unexpected_final_bracket,err_stack_not_clear,err_unknown_variable,err_division_by_zero,err_interrupt,err_overflow,err_unknown_function,err_unknown_operator,err_unexpected_semicolon_operator,err_improper_amount_of_arguments,err_improper_argument,err_unexpected_end,err_internal_error,err_incorrect_name,err_incorrect_value,err_variable_exists,err_variable_loop,err_functions_loop,err_must_be_only_one_value,err_object_exists,err_unknown_object,err_still_calculating,err_in_short_form_used_function,err_percent_from};struct Conv{U base;bool scient;sint scient_from;bool base_round;sint round;bool trim_zeroes;U comma;U comma2;U group;U group_digits;U group_exp;Conv(){base=10;scient=false;scient_from=15;base_round=true;round=-1;trim_zeroes=true; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
commands = {} | |
commands['seq'] = { | |
# non-arg commands | |
0xff: ['end'], | |
0xfe: ['delay1'], | |
0xfd: ['delay', 'var'], | |
0xfc: ['call', 'addr'], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef long long ll; | |
typedef unsigned long long ull; | |
typedef __uint128_t L; | |
struct Barrett { | |
ull d, m; | |
Barrett(ull d) : d(d), m(ull((L(1) << 64) / d)) {} | |
ull reduce(ull a) { | |
ull q = (ull)((L(m) * a) >> 64); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef unsigned long long ull; | |
struct FastMod { | |
ull multiplier; | |
ull divisor; | |
int shift_size; | |
int mode = 0; | |
FastMod(ull divisor) : divisor(divisor) { | |
shift_size = 64 - __builtin_clzll(divisor) - 1; | |
if (divisor & (divisor - 1)) { | |
auto a = (__uint128_t)1 << (shift_size + 64); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ----------------------------------------------------------------- | |
# pycparser: __init__.py | |
# | |
# This package file exports some convenience functions for | |
# interacting with pycparser | |
# | |
# Eli Bendersky [https://eli.thegreenplace.net/] | |
# License: BSD | |
# ----------------------------------------------------------------- | |
__all__ = ["c_parser", "c_ast"] |
NewerOlder