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
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
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
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
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
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
abstract class Query { | |
class Sum { | |
} | |
class Add { | |
} |
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
/** | |
* Executes long running tasks not faster then once in [delayMillis] and makes sure | |
* at most one tasks executes at a time. The task itself may take more than [delayMillis] | |
* to complete. Task may be asynchronous. | |
*/ | |
private class DebouncingQueue( | |
private val delayMillis: Int, | |
parentDisposable: Disposable | |
) { | |
private val alarm = Alarm(Alarm.ThreadToUse.POOLED_THREAD, parentDisposable) |
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
#include <algorithm> | |
#include <cassert> | |
#include <cstddef> | |
#include <cstdint> | |
#include <cstdlib> | |
#include <ctime> | |
#include <forward_list> | |
#include <iostream> | |
#include <list> | |
#include <unordered_set> |
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
fun <T> Sequence<T>.takeWhileInclusive(pred: (T) -> Boolean): Sequence<T> { | |
var shouldContinue = true | |
return takeWhile { | |
val result = shouldContinue | |
shouldContinue = pred(it) | |
result | |
} | |
} |