Skip to content

Instantly share code, notes, and snippets.

@rptynan
rptynan / q1.cpp
Created January 20, 2014 15:51
Solutions to AIPO 2012, rushed and silly..
#include <iostream>
using namespace std;
int m, x;
int main(){
cin>>m>>x;
cout<<2*x-m<<endl;
return 0;
@rptynan
rptynan / frog.cpp
Created February 17, 2014 21:54
AOI Troublesome Frog
#include <fstream>
using namespace std;
#define MAXN 100000
ifstream fin ("frogin.txt");
ofstream fout ("frogout.txt");
int N, h[MAXN], best=0, dpl[MAXN]={0}, dpr[MAXN]={0};
#include <iostream>
using namespace std;
int main(){
int N;
int a, b, c;
cin>>N;
@rptynan
rptynan / anagram.cpp
Created February 25, 2014 23:58
AOI Anagram solution
#include <fstream>
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
ifstream wordsin ("words.txt");
ifstream anagin ("anagin.txt");
@rptynan
rptynan / dp.cpp
Created March 19, 2014 20:04
DNI solution, followed by Jumping memoisation and Jumping bottom-up dp
#include <cstdio>
#include <iostream>
#include <cstring>
using namespace std;
int T, N, num[1000];
int dp[1000][2];
(* 1 *)
fun propercuts (x::xs) =
let fun propcut (y::ys) ac = (rev (ac), y::ys) :: (propcut ys (y::ac))
| propcut [] _ = []
in propcut xs [x]
end
| propercuts _ = [];
@rptynan
rptynan / Quicksort.java
Created January 26, 2015 22:44
Quicksort Java
// Quick sort, worst case, O(n^2), average, O(nlogn), unstable
package sorting;
public class Quick extends Sorter {
java.util.Random rand;
private void recurse(int[] a, int L, int R) {
@rptynan
rptynan / gist:fcb4dc445a72525a416a
Created February 10, 2016 21:23
Sample results of IBProject
SQL Query:
SELECT name, title
FROM wikiarticles
INNER JOIN trends_wikiarticles_junction
ON wikiarticles.wikiarticle_id = trends_wikiarticles_junction.wikiarticle_id
INNER JOIN trends
ON trends.trend_id = trends_wikiarticles_junction.trend_id;
Some of the English trends and the articles they had stored under them:
@rptynan
rptynan / stderr
Created April 23, 2017 21:40
Running liballocs/tools/objdumpallocs on libcrunch/test/hello-array/hello-array
all_alloc_descriptors is: malloc(Z)p calloc(zZ)p realloc(pZ)p memalign(zZ)p alloca(Z)p
meta_instr_regexp is: ^([0-9a-f]*) <([^>]*)>.*((call|jmp).*(<((malloc)|(calloc)|(realloc)|(memalign)|(posix_memalign)|(valloc)|(__monalloca_)|( malloc)|(__wrap_malloc)|(calloc)|(__wrap_calloc)|(realloc)|(__wrap_realloc)|(memalign)|(__wrap_memalign)|(alloca)|(__wrap_alloca))|.*\*)|.* 00 00 00 00.*callq)
objdumpmeta has meta_instr_regexp: ^([0-9a-f]*) <([^>]*)>.*((call|jmp).*(<((malloc)|(calloc)|(realloc)|(memalign)|(posix_memalign)|(valloc)|(__monalloca_)|( malloc)|(__wrap_malloc)|(calloc)|(__wrap_calloc)|(realloc)|(__wrap_realloc)|(memalign)|(__wrap_memalign)|(alloca)|(__wrap_alloca))|.*\*)|.* 00 00 00 00.*callq)
Written allocsites output to /tmp/root/tmp.ko6S5mnF
Written objdump output to /tmp/root/tmp.1ccPdjSJ
Found allocation sites:
00000000004005d6 atexit@plt -0xa
00000000004005e0 atexit@plt
00000000004005f0 free@plt
0000000000400600 puts@plt
@rptynan
rptynan / stderr, excerpts
Created April 26, 2017 15:30
root@feast-1 /u/l/s/p/l/test # ❮❮❮ time gmake -B -f tools/Makefile.allocsites /usr/lib/allocsites/usr/obj/usr/src/sys/CRUNCHED/kernel.debug-allocsites.c 1>! ~/allocsites.log 2>! ~/allocsites.errorlog
tools/Makefile.allocsites:13: ALLOCSITES_BASE is /usr/lib/allocsites
all_alloc_descriptors is: malloc(Zpi)p malloc(Z)p calloc(zZ)p realloc(pZ)p memalign(zZ)p alloca(Z)pmeta_instr_regexp is: ^([0-9a-f]*) <([^>]*)>.*((call|jmp).*(<((malloc)|(calloc)|(realloc)|(memalign)|(posix_memalign)|(valloc)|(__monalloca_)|(malloc)|(__wrap_malloc)|(malloc)|(__wrap_malloc)|(calloc)|(__wrap_calloc)|(realloc)|(__wrap_realloc)|(memalign)|(__wrap_memalign)|(alloca)|(__wrap_alloca))|.*\*)|.* 00 00 00 00.*callq)objdumpmeta has meta_instr_regexp: ^([0-9a-f]*) <([^>]*)>.*((call|jmp).*(<((malloc)|(calloc)|(realloc)|(memalign)|(posix_memalign)|(valloc)|(__monalloca_)|(malloc)|(__wrap_malloc)|(malloc)|(__wrap_malloc)|(calloc)|(__wrap_calloc)|(realloc)|(__wrap_realloc)|(memalign)|(__wrap_memalign)|(alloca)|(__wrap_alloca))|.*\*)|.* 00 00 00 00.*callq)Written allocsites output to /tmp/root/tmp.aBS0DEDe
Written objdump output to /tmp/root/tmp.5nWZmKiT
Found allocation sites:·
ffffffff80cc73a7 cam_quirkmatch +0x2a
ffffffff80cc7a4b ca