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 "big_int.h" | |
| std::vector <int64> read_big_int(std::string s) | |
| { | |
| std::vector <int64> res; | |
| for (int i = (int)s.length(); i > 0; i-=9) | |
| if (i < 9) | |
| { | |
| res.push_back(atoi(s.substr (0, i).c_str())); | |
| } |
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 <cstdio> | |
| #include <iostream> | |
| using namespace std; | |
| static union | |
| { | |
| double use; | |
| char output[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
| import java.util.TreeMap; | |
| public class Main { | |
| // Expression type definitions | |
| static abstract class Expression implements Comparable<Expression> { | |
| @Override | |
| public int compareTo(Expression arg0) { | |
| return this.toString().compareTo(arg0.toString()); |
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
| drop table if exists InfoSource; | |
| create table InfoSource( | |
| id int primary key not null, | |
| title varchar(100), | |
| description text, | |
| website varchar(400) | |
| ); | |
| drop table if exists Article; | |
| create table Article( |
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
| def merge(ls, left, mid, right): | |
| it1 = 0 | |
| it2 = 0 | |
| result = [0] * (right - left) | |
| while left + it1 < mid and mid + it2 < right: | |
| if ls[left + it1] < ls[mid + it2]: | |
| result[it1 + it2] = ls[left + it1] | |
| it1 += 1 | |
| else: | |
| result[it1 + it2] = ls[mid + it2] |
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
| # This code is in public domain. | |
| # Written by Andrew Shulayev, 2012 | |
| from pprint import pprint | |
| test_tree = ([0, 0, 1, 0, 2, 3, 0, 3, 2, 4, 5, 6, 8], 0) | |
| def print_tree(tree): | |
| par, root = tree | |
| n = len(par) |
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
| # This code is in public domain. | |
| # Written by Andrew Shulayev, 2012 | |
| # Implementation of Karp-Miller-Rosenberg algorithm | |
| # Builds suffix array of a string with length n | |
| # in O(n log^2 n) time | |
| def count_classes(arr, key = lambda x : x): | |
| result = [] | |
| for i, x in enumerate(arr): |
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
| // This code is in public domain. | |
| // Written by Andrew Shulayev, 2012 | |
| import java.util.*; | |
| import java.io.*; | |
| // current version doesn't work properly | |
| public class LinearTimeRMQ | |
| { |
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
| #lang racket | |
| (require plot) | |
| (plot-new-window? #t) | |
| (define (flatmap f ls) | |
| (if (null? ls) '() | |
| (append (f (car ls)) (flatmap f (cdr ls))))) | |
| (define (range 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
| {-# LANGUAGE MultiParamTypeClasses #-} | |
| import System.IO (readLn) | |
| data Request = ReadInt Int | WriteInt Int Int | Halt | Fork | Pipe | |
| newtype Program = Program { runProgram :: Int -> (Request, Program) } | |
| mainP :: Program | |
| mainP = undefined |
OlderNewer