This file contains 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<bits/stdc++.h> | |
using namespace std; | |
template<class T,ll sz> | |
struct buffer | |
{ | |
array<T,sz>data; | |
ll L=0,R=0,Lm=0,Rm=0; | |
buffer():L(0),R(0),Lm(0),Rm(0){} | |
T& operator[](int i){ll t=Lm+i;if(t>=sz)t-=sz;return data[t];} |
This file contains 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
class Array | |
def rot | |
self.transpose.map(&:reverse) | |
end | |
end | |
def left a | |
ar=a.dup | |
tmp=(1..4).map{[]} | |
merged=(1..4).map{[]} | |
(0..3).each do|i| |
This file contains 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<bits/stdc++.h> | |
#include<ext/pb_ds/assoc_container.hpp> | |
#include<ext/pb_ds/tree_policy.hpp> | |
using namespace std; | |
using namespace __gnu_pbds; | |
using ll=long long; | |
template<class T,class U> | |
using ord_map=tree<T,U,less<T>,rb_tree_tag,tree_order_statistics_node_update>; | |
template<class T,class U> | |
using ord_multimap=tree<T,U,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>; |
This file contains 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
require "bigdecimal" | |
require "bigdecimal/newton" | |
require "bigdecimal/util" | |
include Newton | |
class Function # :nodoc: all | |
def initialize(tval,ineq_constraints,maximize,dim) | |
@zero=BigDecimal("0.0") | |
@one=BigDecimal("1.0") | |
@two=BigDecimal("2.0") |
This file contains 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<iostream> | |
#include<algorithm> | |
#include<vector> | |
#include<stack> | |
using namespace std; | |
using ll=long long; | |
struct path_scc | |
{ | |
stack<int,vector<int>>S,P; |
This file contains 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
class Fenwick | |
def initialize(n) | |
@size=n | |
@data=[0]*(n+1) | |
end | |
def add(idx,v) | |
while idx<=@size | |
@data[idx]+=v | |
idx+=idx&-idx | |
end |
This file contains 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
// ==UserScript== | |
// @name what the f | |
// @namespace http://tampermonkey.net/ | |
// @version 1 | |
// @description everything is f*cking *3500 | |
// @author chromate00 | |
// @match https://codeforces.com/* | |
// @match http://codeforces.com/* | |
// @grant none | |
// @run-at document-end |
This file contains 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
require'prime' | |
def pollard_rho(n) | |
stk=[n] | |
ans=[] | |
while stk.size>0 do | |
cn=stk.pop | |
#p cn | |
next if cn==1 | |
if cn%2==0 |
This file contains 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<bits/stdc++.h> | |
using namespace std; | |
struct Lehmer64 | |
{ | |
using state_t=__uint128_t; | |
using result_type=uint64_t; | |
state_t state; | |
uint64_t sm64(uint64_t x,uint64_t n) | |
{ |
This file contains 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<random> | |
#include<vector> | |
using namespace std; | |
using ll=long long; | |
struct FakeSkipList | |
{ | |
struct NodePack | |
{ | |
int H=1; |
NewerOlder