Skip to content

Instantly share code, notes, and snippets.

@ramntry
ramntry / main.cpp
Created September 22, 2017 18:41
No virtual member function templates in C++03 through C++14
#include <iostream>
#include <memory>
struct A {
virtual void foo() const {
std::cout << "virtual A::foo()'s called" << std::endl;
}
};
struct B {
@ramntry
ramntry / main.cc
Created November 24, 2015 06:49
cf template
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
@ramntry
ramntry / parse.py
Created November 6, 2015 18:58
codeforces parser
#!/usr/bin/python
# Python 2->3 libraries that were renamed.
try:
from urllib2 import urlopen
except:
from urllib.request import urlopen
try:
from HTMLParser import HTMLParser
except:
@ramntry
ramntry / .vimrc
Last active November 6, 2015 18:58
My Vim config
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
#include <stdio.h>
char buf[32] = "Hello World";
char *bufptr = buf;
void f(char **x) {
printf("%s\n", *x);
}
int main() {
#include <stdio.h>
#include <omp.h>
int main(int argc, char *argv[])
{
char const quote[] = "The greatest enemy will hide in the last place you would ever look.\n";
size_t const size = sizeof(quote);
#pragma omp parallel num_threads(2)
{
for (size_t i = 0; i < size; ++i) {
module type List = sig
type a
type t
val nil : t
val cons : a -> t -> t
val switch : (unit -> 'b) -> (a -> t -> 'b) -> t -> 'b
end
let to_string (type e) (type s) (module Impl : List with type a = e and type t = s) string_of_item l =
let rec inner ys =
import Data.List
ham :: [Integer]
ham = 1 : (map head . group $ merge (map (* 3) ham) (map (* 10) ham)) where
merge l1@(x : xs) l2@(y : ys) | x < y = x : merge xs l2
| otherwise = y : merge l1 ys
main :: IO ()
main = do
num' <- getLine
bench: bench.o main.o
g++ $^ -o $@
bench.o: bench.cpp
g++ -c -o $@ $^
main.o: main.cpp
g++ -c -O3 -o $@ $^
Require Export SfLib.
Require Import Strings.String.
Require Import ZArith.
Module AExp.
Inductive aexp : Type :=
| ANum : nat -> aexp
| APlus : aexp -> aexp -> aexp
| AMinus : aexp -> aexp -> aexp