Skip to content

Instantly share code, notes, and snippets.

It's probably about Segment Trees

Juan Lopes juanplopes

It's probably about Segment Trees
Block or report user

Report or block juanplopes

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View settings.groovy
import javax.servlet.http.*
import org.springframework.web.util.*
juanplopes /
Last active Dec 5, 2019
Update tzdata
# On Ubuntu: make sure you have lzip and gawk installed
tmp_dir=$(mktemp -d -t tzdata-XXXXXXXXXX)
cd $tmp_dir
tar zfxv ziupdater*.tar.gz
tar lfxv tzdb-2019c.tar.lz
cd tzdb-2019c/
import net.intelie.introspective.ObjectSizer;
import java.lang.ref.WeakReference;
import java.util.*;
import java.util.concurrent.atomic.AtomicLong;
public class TestSizeUtils {
public static String formatBytes(double value) {
String[] NAMES = {"B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"};
int name = 0;
juanplopes / A.cpp
Created Nov 7, 2019
Codeforces Round #595 (Div. 3)
View A.cpp
#include <iostream>
#include <algorithm>
using namespace std;
int T[200];
int main() {
int test; cin >> test;
int N;
juanplopes /
Last active Oct 19, 2019
RSA by example
from random import randint
#----Step 1
# First, choose two random primes.
# In real world, they should be really big primes (hundreds of digits).
p, q = 41, 47
#----Step 2
# From them we have n=p*q and phi(n)=(p-1)*(q-1).
juanplopes / gist:2295119
Created Apr 3, 2012
Quick Sort in python
View gist:2295119
def quicksort(V):
if len(V) <= 1:
return V
pivot = V[0]
equal = [x for x in V if x == pivot]
lesser = [x for x in V if x < pivot]
greater = [x for x in V if x > pivot]
return quicksort(lesser) + equal + quicksort(greater)
juanplopes /
Last active Aug 13, 2019
simple dfa in python
class Automaton:
def __init__(self, nstates):
self.transitions = [{} for i in range(nstates)]
self.accept_states = [False] * nstates
def register(self, source_state, char, target_state):
self.transitions[source_state][char] = target_state
def register_accept(self, state):
self.accept_states[state] = True
View gist:93e687e65dca1eeb44640c122dbdcb0d
(async () => {
var get = async(url, prop, dataless) => {
var data = (await (await fetch(url)).json());
if (!dataless) data =;
var result = {};
data.forEach(element => {
result[element[prop]] = element;
return result;
View gist:558a46c06eb52aeff5c64a3861943105
def push(stack, el): stack+(el,);
def pop(stack): (stack:take(len(stack)-1), stack:get(len(stack)-1));
def memset(state, key, value): (state |> @filter({0}!=key)) + ((key, value),);
def memget(state, key): state |> last({1}):if({0}==key)# ?? 0;
def memadd(state, key, value): memset(state, key, memget(state, key)+value);
def findclosing(code, i):
(1, i+1):unfold(fun(count, i):
i >= len(code) or count == 0 ? null,
code:get(i) == '[' ? (i, (count+1, i+1)),
View 1579.cpp
#include <iostream>
using namespace std;
int X[200];
int trucks(int P, int maximum) {
int count = 0, current = 0;
for(int i=0; i<P; i++) {
if (X[i] > maximum) return 10000000;
if (current + X[i] > maximum) {
You can’t perform that action at this time.