This file contains hidden or 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
| datatype ('s, 'r) state = S of 's -> ('s * 'r) | |
| infixr $ | |
| fun f $ x = f x | |
| fun return v = S (fn s => (s, v)) | |
| infix >>= | |
| fun (S sf) >>= f = S (fn s => | |
| let |
This file contains hidden or 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 <cmath> | |
| #include <cstdio> | |
| using namespace std; | |
| #define p 1000 | |
| double sigma; | |
| double PI; |
This file contains hidden or 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 <vector> | |
| #include <algorithm> | |
| #include <cmath> | |
| #include <cstdio> | |
| using namespace std; | |
| typedef double T; | |
| const T EPS = 1e-8; |
This file contains hidden or 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 <queue> | |
| using namespace std; | |
| int main() { | |
| double t; | |
| int n; | |
This file contains hidden or 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
| xs = raw_input() | |
| ys = raw_input() | |
| lxs = len(xs) | |
| lys = len(ys) | |
| d = lys - lxs | |
| i = 0 | |
| while True: | |
| if i >= min(lxs, lys): |
This file contains hidden or 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
| ls = [raw_input() for _ in range(5)] | |
| nums = [ | |
| [['*', '*', '*'], | |
| ['*', ' ', '*'], | |
| ['*', ' ', '*'], | |
| ['*', ' ', '*'], | |
| ['*', '*', '*']], | |
| [[' ', ' ', '*'], | |
| [' ', ' ', '*'], |
This file contains hidden or 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
| n = int(raw_input()) | |
| l1 = raw_input() | |
| l2 = raw_input() | |
| flipped = all(x <> y for x, y in zip(l1, l2)) | |
| if n % 2 == 0: | |
| res = l1 == l2 | |
| else: |
This file contains hidden or 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
| import sys | |
| sys.stdin.readline() | |
| line = sys.stdin.readline() | |
| xs = [int(x) for x in line.split()] | |
| xs = sorted(xs)[::-1] | |
| res = max(x + y + 2 for x, y in enumerate(xs)) | |
| print res |
This file contains hidden or 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
| datatype 'a lazylist = Cons of 'a * (unit -> 'a lazylist) | |
| | Nil | |
| fun take (_, 0) = [] | |
| | take (Nil, _) = raise Subscript | |
| | take (Cons (x, xs), n) = x :: take (xs (), n-1) | |
| local | |
| fun primes' 2 ps = Cons(2, fn () => primes' 3 (2 :: ps)) | |
| | primes' n ps = if List.exists (fn p => n mod p = 0) ps |
This file contains hidden or 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 | |
| from urllib import urlopen | |
| from random import randint | |
| id_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" | |
| def gen_id(): | |
| id = "" | |
| for i in range(5): | |
| id += id_chars[randint(0, len(id_chars)-1)] |