/* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
{
int[] hgram = new int[9];
for (int i = 0; i < 30000; i++) {
int[] a = getRandomSelection( 2, 3, rng );
hgram[3*a[0] + a[1]]++;
}
for (int i = 0; i < hgram.length; i++) {
if (i
> 0) System.
out.
print(", "); }
}
public static int[] getRandomSelection
(int k,
int n,
Random rng
) { "Cannot choose " + k + " elements out of " + n + "."
);
HashMap
<Integer, Integer
> hash
= new HashMap
<Integer, Integer
>(2 * k
); int[] output = new int[k];
for (int i = 0; i < k; i++) {
int j = i + rng.nextInt(n - i);
output[i] = (hash.containsKey(j) ? hash.remove(j) : j);
if (j > i) hash.put(j, hash.containsKey(i) ? hash.remove(i) : i);
}
return output;
}
}
LyogcGFja2FnZSB3aGF0ZXZlcjsgLy8gZG9uJ3QgcGxhY2UgcGFja2FnZSBuYW1lISAqLwoKaW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgovKiBOYW1lIG9mIHRoZSBjbGFzcyBoYXMgdG8gYmUgIk1haW4iIG9ubHkgaWYgdGhlIGNsYXNzIGlzIHB1YmxpYy4gKi8KY2xhc3MgSWRlb25lCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCWludFtdIGhncmFtID0gbmV3IGludFs5XTsKCQlSYW5kb20gcm5nID0gbmV3IFJhbmRvbSgpOwoJCWZvciAoaW50IGkgPSAwOyBpIDwgMzAwMDA7IGkrKykgewoJCQlpbnRbXSBhID0gZ2V0UmFuZG9tU2VsZWN0aW9uKCAyLCAzLCBybmcgKTsKCQkJaGdyYW1bMyphWzBdICsgYVsxXV0rKzsKCQl9CgkJZm9yIChpbnQgaSA9IDA7IGkgPCBoZ3JhbS5sZW5ndGg7IGkrKykgewo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