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
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;
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 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) {
public class LazyOutputStream<T extends OutputStream> extends OutputStream {
private final Factory<T> factory;
private T stream;
public LazyOutputStream(Factory<T> factory) {
this.factory = factory;
View B.cpp
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cmath>
#include <set>
using namespace std;
int T[][501] = {{0,1,1,2,2,2,3,3,3,3,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,24,24,24,24,24,24,24,
juanplopes /
Last active May 19, 2018
Python 2 script that asks github for new application token and saves it on .m2/settings.xml
#!/usr/bin/env python
import httplib, getpass, base64, json, datetime, sys, socket, xml.etree.ElementTree as ET, os.path as path, os
NS = {'n':''}
DEFAULT_REPO_KEY = 'your-repo-key'
def make_auth(username, password):
return base64.b64encode('{}:{}'.format(username, password))
def make_token(repokey, username, password, token2fa):
def cnt(v):
x, y, z, u, w = bool(v&1), bool(v&2), bool(v&4), bool(v&8), bool(v&16)
return ("T" if
(x or y or w) and (z or not w or v) and (not z or not w or not v) and
len(set([x, y, w])) == 2 and
len(set([z, not w, v])) == 2 and
len(set([not z, not w, not v])) == 2
else "F")
import sys
def kmp_init(P):
F = [0] * (len(P)+1)
i, j = 1, 0
while i<len(P):
if P[i] == P[j]:
i += 1; j += 1; F[i] = j
elif j == 0:
i += 1; F[i] = 0
You can’t perform that action at this time.