[a[0], b[0], ... , a[1], b[1], ..., a[n], b[n] ...]
    >>> alternate([1,4], [2,5], [3,6])
    [1, 2, 3, 4, 5, 6]
427830
def alternate(*iterables):
    
    items = []
    for tup in zip(*iterables):
        items.extend([item for item in tup])
    return items
121388
def rectToArray(self, swapWH = False):
        
        if swapWH == False:
            return [self.x, self.y, self.x + self.width, self.y + self.height]
        else:
            return [self.x, self.y, self.x + self.height, self.y + self.width]
702923
def combination(n)
      raise Erlang::ImproperListError if improper?
      return Erlang::Cons.new(Erlang::Nil) if n == 0
      return self if empty?
      return tail.combination(n - 1).map { |list| list.cons(head) }.append(tail.combination(n))
    end
482259
function swap(values, boxes, indices, i, j) {
    const temp = values[i];
    values[i] = values[j];
    values[j] = temp;

    const k = 4 * i;
    const m = 4 * j;

    const a = boxes[k];
    const b = boxes[k + 1];
    const c = boxes[k + 2];
    const d = boxes[k + 3];
    boxes[k] = boxes[m];
    boxes[k + 1] = boxes[m + 1];
    boxes[k + 2] = boxes[m + 2];
    boxes[k + 3] = boxes[m + 3];
    boxes[m] = a;
    boxes[m + 1] = b;
    boxes[m + 2] = c;
    boxes[m + 3] = d;

    const e = indices[i];
    indices[i] = indices[j];
    indices[j] = e;
}
890454
function vecSub(a, b) {

  return [
  new Fraction(a[0]).sub(b[0]),
  new Fraction(a[1]).sub(b[1])
  ];
}
450239
function transpose (M) {
	return (
		[[M[0][0], M[1][0], M[2][0]],
		 [M[0][1], M[1][1], M[2][1]],
		 [M[0][2], M[1][2], M[2][2]]]
	);
}
1002378
function matrixToOperations (matrix, i, j) {
  if (i === 0 && j === 0) {
    return [];
  } else if (i === 0) {
    return matrixToOperations(matrix, i, j - 1).concat("add");
  } else if (j === 0) {
    return matrixToOperations(matrix, i - 1, j).concat("remove");
  } else {
    var left = matrix[i][j - 1];
    var up = matrix[i - 1][j];
    var upleft = matrix[i - 1][j - 1];

    if (upleft <= up && upleft <= left) {
      if (upleft === matrix[i][j]) {
        return matrixToOperations(matrix, i - 1, j - 1).concat("eq");
      } else {
        return matrixToOperations(matrix, i - 1, j - 1).concat("replace");
      }
    } else if (left <= upleft && left <= up) {
      return matrixToOperations(matrix, i, j - 1).concat("add");
    } else {
      return matrixToOperations(matrix, i - 1, j).concat("remove");
    }
  }
}
1028450
def flat_list(input_list):
    

    """
    x = input_list
    if isinstance(x, list):
        return [a for i in x for a in flat_list(i)]
    else:
        return [x]
128706
def multi_substitute(word, rules):
    
    flags = rules[0]['flags']

    # Create a combined regex from the rules
    tuples = ((p, r['match']) for p, r in enumerate(rules))
    regexes = ('(?P<match_%i>%s)' % (p, r) for p, r in tuples)
    pattern = '|'.join(regexes)
    regex = re.compile(pattern, flags)
    resplit = re.compile('\$(\d+)')

    # For each match, look-up corresponding replace value in dictionary
    rules_in_series = ifilter(itemgetter('series'), rules)
    rules_in_parallel = (r for r in rules if not r['series'])

    try:
        has_parallel = [rules_in_parallel.next()]
    except StopIteration:
        has_parallel = []

    # print('================')
    # pprint(rules)
    # print('word:', word)
    # print('pattern', pattern)
    # print('flags', flags)

    for _ in chain(rules_in_series, has_parallel):
        # print('~~~~~~~~~~~~~~~~')
        # print('new round')
        # print('word:', word)
        # found = list(regex.finditer(word))
        # matchitems = [match.groupdict().items() for match in found]
        # pprint(matchitems)
        prev_name = None
        prev_is_series = None
        i = 0

        for match in regex.finditer(word):
            item = ifilter(itemgetter(1), match.groupdict().iteritems()).next()

            # print('----------------')
            # print('groupdict:', match.groupdict().items())
            # print('item:', item)

            if not item:
                continue

            name = item[0]
            rule = rules[int(name[6:])]
            series = rule.get('series')
            kwargs = {'count': rule['count'], 'series': series}
            is_previous = name is prev_name
            singlematch = kwargs['count'] is 1
            is_series = prev_is_series or kwargs['series']
            isnt_previous = bool(prev_name) and not is_previous

            if (is_previous and singlematch) or (isnt_previous and is_series):
                continue

            prev_name = name
            prev_is_series = series

            if resplit.findall(rule['replace']):
                splits = resplit.split(rule['replace'])
                words = _gen_words(match, splits)
            else:
                splits = rule['replace']
                start = match.start() + i
                end = match.end() + i
                words = [word[:start], splits, word[end:]]
                i += rule['offset']

            # words = list(words)
            word = ''.join(words)

            # print('name:', name)
            # print('prereplace:', rule['replace'])
            # print('splits:', splits)
            # print('resplits:', resplit.findall(rule['replace']))
            # print('groups:', filter(None, match.groups()))
            # print('i:', i)
            # print('words:', words)
            # print('range:', match.start(), '-', match.end())
            # print('replace:', word)

    # print('substitution:', word)
    return word
203472
def p_compound_list(p):
    ''''''
    if len(p) == 2:
        p[0] = p[1]
    else:
        parts = p[2]
        if len(parts) > 1:
            p[0] = ast.node(kind='list', parts=parts, pos=_partsspan(parts))
        else:
            p[0] = parts[0]
646934
def permute(elements):
    
    if len(elements) <= 1:
        return [elements]
    else:
        tmp = []
        for perm in permute(elements[1:]):
            for i in range(len(elements)):
                tmp.append(perm[:i] + elements[0:1] + perm[i:])
        return tmp
1239796
private int trMedian5(int ISAd, int v1, int v2, int v3, int v4, int v5) {
        int t;
        if (SA[ISAd + SA[v2]] > SA[ISAd + SA[v3]]) {
            t = v2;
            v2 = v3;
            v3 = t;
        }
        if (SA[ISAd + SA[v4]] > SA[ISAd + SA[v5]]) {
            t = v4;
            v4 = v5;
            v5 = t;
        }
        if (SA[ISAd + SA[v2]] > SA[ISAd + SA[v4]]) {
            t = v2;
            v2 = v4;
            v4 = t;
            t = v3;
            v3 = v5;
            v5 = t;
        }
        if (SA[ISAd + SA[v1]] > SA[ISAd + SA[v3]]) {
            t = v1;
            v1 = v3;
            v3 = t;
        }
        if (SA[ISAd + SA[v1]] > SA[ISAd + SA[v4]]) {
            t = v1;
            v1 = v4;
            v4 = t;
            t = v3;
            v3 = v5;
            v5 = t;
        }
        if (SA[ISAd + SA[v3]] > SA[ISAd + SA[v4]]) {
            return v4;
        }
        return v3;
    }
405829
function transpose(out, a) {
  // If we are transposing ourselves we can skip a few steps but have to cache some values
  if (out === a) {
    var a1 = a[1]
    out[1] = a[2]
    out[2] = a1
  } else {
    out[0] = a[0]
    out[1] = a[2]
    out[2] = a[1]
    out[3] = a[3]
  }

  return out
}
756707
function add(out, a, b) {
  out[0] = a[0] + b[0];
  out[1] = a[1] + b[1];
  out[2] = a[2] + b[2];
  return out;
}
44546
function fromMat2d(out, a) {
  out[0] = a[0];
  out[1] = a[1];
  out[2] = 0;

  out[3] = a[2];
  out[4] = a[3];
  out[5] = 0;

  out[6] = a[4];
  out[7] = a[5];
  out[8] = 1;
  return out;
}
482288
function(buf, V) {
    var M = Array(8);
    var a = Array(8);
    var b = Array(8);
    M[0] = buf[0];
    M[1] = buf[1];
    M[2] = buf[2];
    M[3] = buf[3];
    M[4] = buf[4];
    M[5] = buf[5];
    M[6] = buf[6];
    M[7] = buf[7];
    o.xORTable(a, V[0], V[1], 8);
    o.xORTable(b, V[2], V[3], 8);
    o.xORTable(a, a, b, 8);
    o.xORTable(a, a, V[4], 8);
    M2(a, a);
    o.xORTable(V[0], a, V[0], 8);
    o.xORTable(V[1], a, V[1], 8);
    o.xORTable(V[2], a, V[2], 8);
    o.xORTable(V[3], a, V[3], 8);
    o.xORTable(V[4], a, V[4], 8);
    M2(b, V[0]);
    o.xORTable(b, b, V[1], 8);
    M2(V[1], V[1]);
    o.xORTable(V[1], V[1], V[2], 8);
    M2(V[2], V[2]);
    o.xORTable(V[2], V[2], V[3], 8);
    M2(V[3], V[3]);
    o.xORTable(V[3], V[3], V[4], 8);
    M2(V[4], V[4]);
    o.xORTable(V[4], V[4], V[0], 8);
    M2(V[0], b);
    o.xORTable(V[0], V[0], V[4], 8);
    M2(V[4], V[4]);
    o.xORTable(V[4], V[4], V[3], 8);
    M2(V[3], V[3]);
    o.xORTable(V[3], V[3], V[2], 8);
    M2(V[2], V[2]);
    o.xORTable(V[2], V[2], V[1], 8);
    M2(V[1], V[1]);
    o.xORTable(V[1], V[1], b, 8);
    o.xORTable(V[0], V[0], M, 8);
    M2(M, M);
    o.xORTable(V[1], V[1], M, 8);
    M2(M, M);
    o.xORTable(V[2], V[2], M, 8);
    M2(M, M);
    o.xORTable(V[3], V[3], M, 8);
    M2(M, M);
    o.xORTable(V[4], V[4], M, 8);
}
608502
function concatenation() {
    var ret = this.seq(
        repetition,
        this.manyf(this.seqf(
            this.many1f(c_wsp),
            repetition)));
    if (ret[2].length === 0) {
        return ret[1];
    }
    var cats = ret[2].map(function(el){ return el[2]; });
    return [].concat(ret[1]).concat(cats);
}