Skip to content

Instantly share code, notes, and snippets.

View dfyz's full-sized avatar

Ivan Komarov dfyz

View GitHub Profile
@dfyz
dfyz / gist:4590135
Created January 21, 2013 22:32
TRIPLETS from InterviewStreet
using System;
using System.Collections.Generic;
using System.Linq;
interface ISparseSortedArray {
void Set(uint position, ulong value);
ulong Sum(ulong upperBound);
}
class TreapItem {
import Control.Applicative
import Control.Monad
import Data.Array
readInt :: IO Int
readInt = readLn
readIntPair :: IO [Int]
readIntPair = parseLine <$> getLine
where
#include <cstdio>
#include <vector>
int main() {
int n = 0;
scanf("%d", &n);
std::vector<int> v(n + 1);
int k = 0;
for (int i = 0; i < n; i++) {
scanf("%d", &k);
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
in := bufio.NewReader(os.Stdin)
@dfyz
dfyz / gist:4645824
Last active December 11, 2015 18:59
--- 1330_slow.hs 2013-01-27 07:01:28.000000000 +0600
+++ 1330.hs 2013-01-27 07:00:01.000000000 +0600
@@ -1,17 +1,22 @@
import Control.Applicative
import Control.Monad
import Data.Array
+import Data.Maybe
import Data.Time.Clock
import System.IO
import Text.Printf
import Control.Applicative
import Control.Monad
import qualified Data.Map as M
import qualified Data.Set as S
import Data.Maybe
import Data.List
import Text.Printf
nextRng b c r prev = (b * prev + c) `mod` r
class Point {
let x = 0
}
func printPoints(points: [Point?]) {
for maybePoint in points {
if let point = maybePoint {
print(point.x)
}
}
import Control.Applicative
import qualified Data.Text as T
import qualified Data.Text.IO as T
type Vector = (Int, Int)
type Point = Vector
type VectorZipper = ([Vector], [Vector])
data Instruction = Instruction {
rotation :: Char,
trait Foo {}
trait Bar {}
macro_rules! implement_traits {
($type_name:ty) => {
impl Foo for $type_name {}
impl Bar for $type_name {}
};
}
[ 0%] Built target LLVMDemangle
[ 0%] Built target LLVMTableGen
[ 33%] Built target obj.llvm-tblgen
[100%] Built target LLVMSupport
[100%] Built target llvm-tblgen
[100%] Building Attributes.inc...
[100%] Building IntrinsicEnums.inc...
[100%] Building IntrinsicImpl.inc...
[100%] Built target intrinsics_gen
[100%] Building AlphaGenRegisterInfo.inc...