import java.util.*;
import java.util.zip.*;
import java.util.List;
import java.util.regex.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.locks.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.table.*;
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
import java.lang.ref.*;
import java.lang.management.*;
import java.security.*;
import java.security.spec.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
import java.math.*;
//packageName wikify
//mainClassName Wikify
import java.text.NumberFormat;
import java.nio.charset.Charset;
import org.eclipse.collections.impl.map.mutable.primitive.*;
import org.eclipse.collections.impl.set.mutable.primitive.*;
import org.eclipse.collections.api.tuple.primitive.*;
import org.eclipse.collections.api.iterator.*;
import java.nio.*;
import java.nio.channels.*;
import java.text.SimpleDateFormat;
class main {
static class Wikify {
volatile Indexed indexed;
String indexing;
Q q = startQ();
int slowSearches;
static class Indexed {
String text;
LCSearcher_v4_multiFile searcher;
}
int anyIndexOf(String fullText, String pattern) {
if (empty(fullText)) return -1;
Indexed _indexed = indexed;
if (_indexed != null && fullText == _indexed.text)
return _indexed.searcher.singleFileAnyIndexOf(pattern);
// possibly index, do slow search
possiblyIndexText(fullText);
++slowSearches;
return main.indexOf(fullText, pattern);
}
synchronized void possiblyIndexText(String text) {
if (indexing != null) return;
indexing = text;
q.add(new Runnable() { public void run() { try {
try {
print("Indexing " + nChars(text) + ": " + quote(shorten(text)));
Indexed i = new Indexed();
i.text = text;
i.searcher = wikifyString(text);
setIndexed(i);
} finally {
indexing = null;
}
} catch (Exception __e) { throw rethrow(__e); } } public String toString() { return "try {\r\n print(\"Indexing \" + nChars(text) + \": \" + quote(shorten(text))..."; }});
}
synchronized void setIndexed(Indexed i) {
print("Indexed " + nChars(i.text));
indexed = i;
}
}
static Q startQ() {
return new Q();
}
static Q startQ(String name) {
return new Q(name);
}
static boolean empty(Collection c) { return c == null || c.isEmpty(); }
static boolean empty(Iterable c) { return c == null || !c.iterator().hasNext(); }
static boolean empty(CharSequence s) { return s == null || s.length() == 0; }
static boolean empty(Map map) { return map == null || map.isEmpty(); }
static boolean empty(Object[] o) { return o == null || o.length == 0; }
static boolean empty(Object o) {
if (o instanceof Collection) return empty((Collection) o);
if (o instanceof String) return empty((String) o);
if (o instanceof Map) return empty((Map) o);
if (o instanceof Object[]) return empty((Object[]) o);
if (o instanceof byte[]) return empty((byte[]) o);
if (o == null) return true;
throw fail("unknown type for 'empty': " + getType(o));
}
static boolean empty(Iterator i) { return i == null || !i.hasNext(); }
static boolean empty(double[] a) { return a == null || a.length == 0; }
static boolean empty(float[] a) { return a == null || a.length == 0; }
static boolean empty(int[] a) { return a == null || a.length == 0; }
static boolean empty(long[] a) { return a == null || a.length == 0; }
static boolean empty(byte[] a) { return a == null || a.length == 0; }
static boolean empty(short[] a) { return a == null || a.length == 0; }
static boolean empty(MultiMap mm) { return mm == null || mm.isEmpty(); }
static boolean empty(File f) { return getFileSize(f) == 0; }
static boolean empty(IntRange r) { return r == null || r.empty(); }
static boolean empty(IntBuffer b) { return b == null || b.isEmpty(); }
static boolean empty(LongBuffer b) { return b == null || b.isEmpty(); }
static int indexOf(List l, A a, int startIndex) {
if (l == null) return -1;
int n = l(l);
for (int i = startIndex; i < n; i++)
if (eq(l.get(i), a))
return i;
return -1;
}
static int indexOf(List l, int startIndex, A a) {
return indexOf(l, a, startIndex);
}
static int indexOf(List l, A a) {
if (l == null) return -1;
return l.indexOf(a);
}
static int indexOf(String a, String b) {
return a == null || b == null ? -1 : a.indexOf(b);
}
static int indexOf(String a, String b, int i) {
return a == null || b == null ? -1 : a.indexOf(b, i);
}
static int indexOf(String a, char b) {
return a == null ? -1 : a.indexOf(b);
}
static int indexOf(String a, int i, char b) {
return indexOf(a, b, i);
}
static int indexOf(String a, char b, int i) {
return a == null ? -1 : a.indexOf(b, i);
}
static int indexOf(String a, int i, String b) {
return a == null || b == null ? -1 : a.indexOf(b, i);
}
static int indexOf(A[] x, A a) {
int n = l(x);
for (int i = 0; i < n; i++)
if (eq(x[i], a))
return i;
return -1;
}
static volatile StringBuffer local_log = new StringBuffer(); // not redirected
static volatile Appendable print_log = local_log; // might be redirected, e.g. to main bot
// in bytes - will cut to half that
static volatile int print_log_max = 1024*1024;
static volatile int local_log_max = 100*1024;
static boolean print_silent = false; // total mute if set
static Object print_byThread_lock = new Object();
static volatile ThreadLocal