Skip to content

Instantly share code, notes, and snippets.

#define classify(x) (((x) >= 0.5) ? '+' : '-')
float sigmoid(float x) {
return 1 / (1 + exp((double) -x));
}
main() {
int d, q, i, a, t;
scanf("%d %d\n", &d, &q);
int beta[d+1];
main() {
int n, m, k, t=0, i;
scanf("%d\n", &n);
int s[n][2];
for (i=0; i<n; i++)
scanf("%d %c\n", &s[i][0], &s[i][1]);
scanf("%d\n", &m);
#define eq(X, a) ((X[0] == a[0]) && (X[1] == a[1]))
main() {
int t;
float tp, tn, fp, fn, p, r;
tp = tn = fp = fn = 0;
char c[3];
scanf("%d\n", &t);
while (t--) {
main() {
char c = getchar(), t, p = -1;
int freq[128] = {0};
while ( (t = getchar()) != '\n' ) {
if (p == c)
freq[t] ++;
p = t;
}
def ncr(n, r)
a, b = r, n-r
a, b = b, a if a < b # a is the larger
numer = (a+1..n).inject(1) { |t,v| t*v } # n!/r!
denom = (2..b).inject(1) { |t,v| t*v } # (n-r)!
numer / denom
end
def ncrdigs_naive(n, r, base)
ncr(n, r).to_s(base).length
#include <stdio.h>
int gray_decode(int n) {
int p = n;
while (n >>= 1) p ^= n;
return p;
}
int main() {
int t, c;
a, b = gets.split.map {|x| x.to_i }
data = []
a.times do
data << gets.split.map {|x| x.to_i }
end
gets.to_i.times do
px, py, qx, qy = gets.split.map {|x| x.to_i }
sum = 0
gets.to_i.times do
n = gets.to_i
puts 4*n*n - 3*n
end

Keybase proof

I hereby claim:

  • I am vikhyat on github.
  • I am vikhyat (https://keybase.io/vikhyat) on keybase.
  • I have a public key whose fingerprint is 4B56 5241 D57E 05C0 63FC D8BB 93DF 9F5A 4004 802A

To claim this, I am signing this object:

@vikhyat
vikhyat / gist:5569625983b95f99bcc3
Created June 16, 2014 17:37
Manga Information Importer
require 'nokogiri'
require 'date'
require 'json'
def repair_broken_html(html)
rep = html
# Broken UTF-8 encoding.
rep = rep.unpack('C*').pack('U*') unless rep.valid_encoding?
# "<" is not escaped.
rep = rep.gsub(/<([^A-Za-z!\/])/, '&lt;\1')