This file contains 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 <iostream> | |
#include <numeric> | |
// | |
// `ax + b mod n`, where `[0,n)` | |
// `a` must be a coprime with `n`, | |
// `gcd(a, n) = 1` | |
// `a=1` is bad for obvious reasons, so we gonna pick `a` from `[n/2, n)`. | |
// |
This file contains 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 python2.7 | |
import socket | |
import struct | |
import random | |
def int_to_ip(i): | |
return ".".join(map(lambda x: str(x & 0xff), (i >> 24, i >> 16, i >> 8, i))) |
This file contains 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 <algorithm> | |
#include <fcntl.h> | |
#include <iostream> | |
#include <string.h> | |
#include <unistd.h> | |
using namespace std; | |
constexpr int BUFFER_SIZE = 1024 * 1024; | |
size_t line_count(const char *filename) { |
This file contains 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
import os, sys | |
from key import k, random_r | |
import msgpack | |
N = 23927411014020695772934916764953661641310148480977056645255098192491740356525240675906285700516357578929940114553700976167969964364149615226568689224228028461686617293534115788779955597877965044570493457567420874741357186596425753667455266870402154552439899664446413632716747644854897551940777512522044907132864905644212655387223302410896871080751768224091760934209917984213585513510597619708797688705876805464880105797829380326559399723048092175492203894468752718008631464599810632513162129223356467602508095356584405555329096159917957389834381018137378015593755767450675441331998683799788355179363368220408879117131L | |
def egcd(a, b): | |
if a == 0: | |
return (b, 0, 1) |
This file contains 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 python | |
#-*- coding: utf-8 -*- | |
import sys | |
import re | |
import struct | |
import json | |
def findndx(str, data): | |
return [m.start() for m in re.finditer(str, data)] |
This file contains 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
def fibGenMaxVal(maxnum): | |
""" | |
>>> fibGenMaxVal(30) | |
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34] | |
>>> fibGenMaxVal(150) | |
[0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233] | |
""" | |
fibnums = [0, 1, 1] |
This file contains 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
// cl /EHsc /nologo /W4 /MTd deduplicate.cpp /I boost-1.46.1\include /link /libpath:boost-1.46.1\lib bcrypt.lib | |
#pragma warning(disable: 4512) // assignment operator could not be generated | |
#include <stddef.h> | |
#include <fstream> | |
#include <ios> | |
#include <iostream> | |
#include <ostream> | |
#include <regex> |