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
test { | |
testLogging { | |
events 'skipped', 'failed' | |
exceptionFormat = 'full' | |
} | |
beforeSuite { suite -> | |
if (suite.className != null) { | |
println() | |
println(suite.className) |
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
def bfs(graph, start): | |
work = {start} | |
dist = {} | |
current_dist = 0 | |
while work: | |
for u in work: | |
dist[u] = current_dist | |
work = {nb for u in work |
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
import heapq | |
import random | |
import time | |
from threading import Thread | |
def alarm(span, count): | |
for _ in range(count): | |
time.sleep(span) | |
print(span) | |
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
package org.rust; | |
import java.util.ArrayList; | |
import java.util.List; | |
public class Main { | |
private static class Base { | |
} | |
private static class Derived extends Base { |
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
int upper = 0; | |
for (int i = 0; i < (1 << n); i++) { | |
if (i == 2^{upper+1}) upper++; | |
function[i] = function[i ^ (1 << upper)] и что-нибудь ещё. | |
} | |
Число единичных бит можно так: f[i] = f[i >> 1] + (i & 1); | |
Сумма элементов: f[i] = f[i ^ (1 << upper)] + weight[upper] |
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
interface I<SELF> { | |
fun base(): V | |
fun reversed(): SELF | |
infix fun add(other: SELF): SELF | |
} | |
abstract class Adapter<SELF : I<SELF>>(val base: V) : I<SELF> { | |
abstract fun ctor(base: V): SELF | |
final override fun reversed(): SELF = ctor(base.reversed()) |
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
import random | |
numbers = (random.randrange(2**32) for _ in range(3 * 10**6)) | |
with open("in.txt", "w") as f: | |
f.write(" ".join(map(str, numbers))) |
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
λ ~/bench/ alias t="/run/current-system/sw/bin/time -f \"%es %MkB\" " | |
λ ~/bench/ javac -version | |
javac 1.8.0_101 | |
λ ~/bench/ java -version | |
java version "1.8.0_101" | |
Java(TM) SE Runtime Environment (build 1.8.0_101-b13) | |
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode) |
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
extern crate time; | |
extern crate rand; | |
use time::precise_time_ns; | |
use rand::Rng; | |
use std::ffi::CString; | |
fn main() { | |
println!("Baseline 1: empty String"); |
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
def parseMany(parse: (String) => Option[(SExpression, String)], input: String): (Seq[SExpression], String) = { | |
parse(input) | |
.map { case (x, r1) => | |
val (xs, r2) = parseMany(parse, r1) | |
(x +: xs, r2) | |
} | |
.getOrElse((Seq(), input)) | |
} |