Skip to content

Instantly share code, notes, and snippets.

/+dub.sdl:+/
// Siarhei Siamashka - Programming Challange from Erann Gat:
// http://www.flownet.com/ron/papers/lisp-java/
// This work is marked with CC0 1.0. To view a copy of this license, visit
// http://creativecommons.org/publicdomain/zero/1.0
@safe:
import std.stdio, std.file, std.conv, std.ascii, std.algorithm, std.string;
import core.bitop, std.bigint;
// Can be changed to 'long' for more speed, but will overflow in extreme cases
/+dub.sdl:+/
// Siarhei Siamashka - Programming Challange from Erann Gat:
// http://www.flownet.com/ron/papers/lisp-java/
// This work is marked with CC0 1.0. To view a copy of this license, visit
// http://creativecommons.org/publicdomain/zero/1.0
@safe:
import std.stdio, std.file, std.conv, std.ascii, std.algorithm, std.string;
import core.bitop;
immutable letter2digit = (){
/+dub.sdl:+/
// Siarhei Siamashka - Programming Challange from Erann Gat:
// http://www.flownet.com/ron/papers/lisp-java/
// This work is marked with CC0 1.0. To view a copy of this license, visit
// http://creativecommons.org/publicdomain/zero/1.0
@safe:
import std.stdio, std.file, std.conv, std.ascii, std.algorithm, std.string;
immutable letter2digit = (){
char[256] tmp;
@ssvb
ssvb / dlangchecker.d
Created September 14, 2022 03:46
D compiler configuration test for competitive programming online judge platforms.
import std.stdio, std.range, std.algorithm, std.compiler, core.bitop;
// Optimizing compilers should do tail call optimization here, so
// 0xBADF00D magic constant won't be found in stack if optimizations
// are enabled. Is there a cleaner way to detect optimizations?
bool detect_opt() {
int[100] filler;
bool detect_tail_call_opt(int depth, int magic) {
if (depth > 100) {
int x; foreach (i ; 20 .. 80) if (*(&x + i) == magic) return false;
#!/usr/bin/env ruby
$data = {}
$func_name = nil
# binutils confuses the sizes of the first and the second arguments
# this function contains a fixup workaround
def fixup_vshll(l)
if l =~ /(.*vshll.u16\s+)d(\d+),\s*q(\d+)(.*)/
reg1 = $2.to_i
@ssvb
ssvb / bench_ahash.cr
Created February 20, 2022 17:47
Benchmark AHash vs. FxHash vs. FunnyHash in Crystal language (can be run at https://atcoder.jp/contests/practice/custom_test for example)
require "benchmark"
# Access two 64-bit random seed values
struct Crystal::Hasher
def self.get_seed
@@seed
end
end
# Implementation of FunnyHash from
@ssvb
ssvb / codeforces_ratings.md
Created December 2, 2021 22:42
codeforces ratings

The real starting rating is 1400 (but displayed as 0). Your rating delta after your first contest was -110 and your real rating changed to 1290 (displayed as 390). Your rating delta after your second contest was -43 and your real rating changed to 1247 (displayed as 697).

The following Python code can be used to convert your display rating to your real rating and the other way around:

def get_display_rating(real_rating, number_of_contests):
  if number_of_contests >= 6:
    return real_rating
  display_delta = [1400, 900, 550, 300, 150, 50]
 return real_rating - display_delta[number_of_contests]

Deactivated jsimd_h2v1_downsample_dspr2 and jsimd_h2v2_downsample_dspr2

Running tests...
Test project /tmp/libjpeg-turbo.bigendian/build
        Start   1: tjunittest-static
  1/151 Test   #1: tjunittest-static .................................***Failed   73.19 sec
        Start   2: tjunittest-static-alloc
  2/151 Test   #2: tjunittest-static-alloc ...........................***Failed   72.38 sec
        Start   3: tjunittest-static-yuv

Little endian MIPS74K @480MHz without FPU, GCC 7.2.0

Without DSP r2:

# JSIMD_FORCENONE=1 ./tjbench-static test-image.ppm 75 -fastdct

Using fastest DCT/IDCT algorithm

>>>>>  BGR (Top-down) <--> JPEG GRAY Q75  <<<<<
<< MIPSELo32 >> OpenWrt ~/libjpeg-turbo/build # JSIMD_FORCENONE=1 ./tjbench-static test-image.ppm 95
>>>>> BGR (Top-down) <--> JPEG GRAY Q95 <<<<<
Image size: 2592 x 1944
Compress --> Frame rate: 0.448023 fps
Output image size: 1225591 bytes
Compression ratio: 12.334085:1
Throughput: 2.257520 Megapixels/sec
Output bit stream: 4.392744 Megabits/sec