Skip to content

Instantly share code, notes, and snippets.

@meooow25
meooow25 / fast_input.py
Last active November 12, 2018 08:34
Super fast input for Python. Can be made faster by sacrificing ease of use and accessing the tokens directly instead of using the ns, nf, ni functions.
def init_input():
import os
from sys import stdin
it = iter(os.read(stdin.fileno(), 10 ** 9).split())
return lambda: next(it).decode(), lambda: int(next(it)), lambda: float(next(it))
ns, ni, nf = init_input()
some_string = ns()
some_int = ni()
some_float = nf()
"""
Checks if a password is pwned using the https://haveibeenpwned.com/ API
Usage: python passcheck.py password
"""
import argparse
import hashlib
import urllib.request
URL = 'https://api.pwnedpasswords.com/range/'
@meooow25
meooow25 / solved.py
Last active October 25, 2019 18:51
Solved plot for duck
import argparse
import json
import urllib.request
from matplotlib import pyplot as plt
STATUS_URL_FMT = 'https://codeforces.com/api/user.status?handle={}'
CONTESTS_URL = 'https://codeforces.com/api/contest.list'
DEFAULT_LO, DEFAULT_HI = 500, 3800
STEP = 100
FIGSIZE = (12, 6)
@meooow25
meooow25 / cf-linemaster.user.js
Last active February 15, 2022 21:58
CF Linemaster
// ==UserScript==
// @name CF Linemaster
// @namespace https://github.com/meooow25
// @match *://*.codeforces.com/*
// @grant GM.setClipboard
// @version 0.9
// @author meooow
// @description Adds supports for line highlighting and copying on Codeforces
// @downloadURL https://gist.github.com/meooow25/8c91d4b111057f225c1d66e46cf00de2/raw/cf-linemaster.user.js
// ==/UserScript==
@meooow25
meooow25 / enter.html
Last active October 2, 2020 21:56
Codeforces login page source on 2020.10.03
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="X-Csrf-Token" content="29a92b8221e77eed6b9ccc6291788d75"/>
<meta id="viewport" name="viewport" content="width=device-width, initial-scale=0.01"/>
<script type="text/javascript" src="//sta.codeforces.com/s/81126/js/jquery-1.8.3.js"></script>
<script type="application/javascript">
window.standaloneContest = false;
@meooow25
meooow25 / p01a.js
Last active January 1, 2021 00:10
Advent of Code 2020
document.body.textContent.trim().split('\n').map(x => Number(x))
.flatMap((x, i, a) => a.flatMap((y, j) => i < j && x + y === 2020 ? [x * y] : []))
@meooow25
meooow25 / p01a.hs
Last active December 1, 2022 23:55
Advent of Code 2021, learning Haskell
countIncrease :: [Int] -> Int
countIncrease xs = length $ filter (uncurry (<)) $ zip xs (tail xs)
main :: IO ()
main = print . countIncrease . map read . lines =<< getContents
@meooow25
meooow25 / nog4g.user.js
Last active February 18, 2022 21:47
NoG4G
// ==UserScript==
// @name NoG4G
// @namespace https://github.com/meooow25
// @match *://www.google.com/search*
// @grant none
// @version 0.3
// @author meooow
// @description Removes G4G from Google search results
// ==/UserScript==
@meooow25
meooow25 / fetch.py
Created May 6, 2022 17:20
Codeforces RCPC cookie bypass in Python with submission fetching example
import re
import requests
from Crypto.Cipher import AES
user_agent = 'Mozilla/5.0 AppleWebKit/537.36 Chrome/102.0.4972.0 Safari/537.36'
home_page = 'https://codeforces.com'
def init_session(s):
s.headers.update({'User-Agent': user_agent})
r = s.get(home_page)
@meooow25
meooow25 / Main.hs
Last active August 19, 2022 22:28
Haskell sort benchmarks, GHC 8.10.7, -O2, n=2e5
{-# LANGUAGE FlexibleContexts, QuantifiedConstraints, ScopedTypeVariables, TupleSections #-}
import Control.Monad
import Control.Monad.ST
import Data.Array.Base
import Data.Array.ST
import Criterion.Main
import Data.Foldable
import qualified Data.IntMap.Strict as IM
import qualified Data.List as L
import qualified Data.Map.Strict as M