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
#!/usr/bin/env python | |
def calc(a, n): | |
res = 1 | |
m = 1 | |
for i in xrange(n): | |
m -= 1 | |
for k in xrange(i + m, n): | |
if a[k] > i: | |
break |
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
#!/usr/bin/env python | |
memo = {} | |
def calc(n, m): | |
key = n * 10000 + m | |
if key in memo: | |
return memo[key] | |
if n == 0 or n == m: | |
res = 0 | |
elif m == 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
#!/usr/bin/env python | |
import re | |
def normalise_email(email): | |
email = email.lower() | |
i = email.find("@") | |
prefix = email[:i] | |
j = prefix.find("+") | |
if j != -1: |
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 <algorithm> | |
#include <iostream> | |
#include <set> | |
using namespace std; | |
struct Node { | |
int a; | |
long long w; | |
Node *prev; |
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 <algorithm> | |
#include <cmath> | |
#include <iostream> | |
#include <map> | |
#include <set> | |
#include <vector> | |
using namespace std; | |
struct Topic { |
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
# Start with the setup normally, then select "Shell" at the partitioning step. | |
# Check device names | |
camcontrol devlist | |
# Create a gpt and a bootstrap partition | |
gpart destroy -F ada0 | |
gpart create -s gpt ada0 | |
gpart add -a 4k -t freebsd-boot -s 64k ada0 | |
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0 |
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
#!/usr/bin/env python | |
import collections | |
import itertools | |
import re | |
import sys | |
words = { | |
word | |
for word in re.split(r'\W+', sys.stdin.read().lower()) |