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.*;
class main {
static IterableIterator iterateUpdatingProgressBar(JProgressBar progressBar, Collection l) {
if (progressBar == null) return iterableIterator(l);
return iteratorFromFunction_withEndMarker_f0(new F0() {
int n = l(l), i;
Iterator it = iterator(l);
NotTooOften nto = onlyTenTimesASecond();
public Object get() {
if (!it.hasNext()) {
setProgressBarValue(progressBar, n, n);
setProgressBarText(progressBar, n + " / " + n);
return endMarker();
}
if (nto.yo()) {
setProgressBarValue(progressBar, i, n);
setProgressBarText(progressBar, i + " / " + n);
}
++i;
return it.next();
}
});
}
static IterableIterator iterableIterator(final Iterator it) {
return it == null ? null : new IterableIterator() {
public boolean hasNext() { return it.hasNext(); }
public A next() { return it.next(); }
public void remove() { it.remove(); }
};
}
static IterableIterator iterableIterator(final Collection it) {
return iterableIterator(iterator(it));
}
static IterableIterator iteratorFromFunction_withEndMarker_f0(final F0 f) {
class IFF2 extends IterableIterator {
A a;
boolean have, done;
public boolean hasNext() {
getNext();
return !done;
}
public A next() {
getNext();
if (done) throw fail();
A _a = a;
a = null;
have = false;
return _a;
}
void getNext() {
if (done || have) return;
a = f.get();
have = true;
if (a == iteratorFromFunction_endMarker)
done = true;
}
};
return new IFF2();
}
static int l(Object[] a) { return a == null ? 0 : a.length; }
static int l(boolean[] a) { return a == null ? 0 : a.length; }
static int l(byte[] a) { return a == null ? 0 : a.length; }
static int l(short[] a) { return a == null ? 0 : a.length; }
static int l(long[] a) { return a == null ? 0 : a.length; }
static int l(int[] a) { return a == null ? 0 : a.length; }
static int l(float[] a) { return a == null ? 0 : a.length; }
static int l(double[] a) { return a == null ? 0 : a.length; }
static int l(char[] a) { return a == null ? 0 : a.length; }
static int l(Collection c) { return c == null ? 0 : c.size(); }
static int l(Iterator i) { return iteratorCount_int_close(i); } // consumes the iterator && closes it if possible
static int l(Map m) { return m == null ? 0 : m.size(); }
static int l(CharSequence s) { return s == null ? 0 : s.length(); }
static long l(File f) { return f == null ? 0 : f.length(); }
static int l(Object o) {
return o == null ? 0
: o instanceof String ? l((String) o)
: o instanceof Map ? l((Map) o)
: o instanceof Collection ? l((Collection) o)
: o instanceof Object[] ? l((Object[]) o)
: o instanceof boolean[] ? l((boolean[]) o)
: o instanceof byte[] ? l((byte[]) o)
: o instanceof char[] ? l((char[]) o)
: o instanceof short[] ? l((short[]) o)
: o instanceof int[] ? l((int[]) o)
: o instanceof float[] ? l((float[]) o)
: o instanceof double[] ? l((double[]) o)
: o instanceof long[] ? l((long[]) o)
: (Integer) call(o, "size");
}
static Iterator iterator(Iterable c) {
return c == null ? emptyIterator() : c.iterator();
}
static NotTooOften onlyTenTimesASecond() {
return new NotTooOften(100);
}
static void setProgressBarValue(JProgressBar bar, int value) {
swingCall(bar, "setValue", value);
}
static void setProgressBarValue(JProgressBar bar, int value, int total) {
setProgressBarTotal(bar, total);
setProgressBarValue(bar, value);
}
static void setProgressBarText(JProgressBar bar, String text) {
swingCall(bar, "setString", text);
}
static Object endMarker() {
return iteratorFromFunction_endMarker;
}
// requires ugly casting when used (O -> A)
static Object iteratorFromFunction_endMarker = new Object();
// f: func -> A | endMarker
static IterableIterator iteratorFromFunction_withEndMarker(final Object f) {
class IFF extends IterableIterator {
A a;
boolean done = false;
public boolean hasNext() {
getNext();
return !done;
}
public A next() {
getNext();
if (done) throw fail();
A _a = a;
a = null;
return _a;
}
void getNext() {
if (done || a != null) return;
a = (A) callF(f);
if (a == iteratorFromFunction_endMarker)
done = true;
}
};
return new IFF();
}
// optimized version for F0 argument
static IterableIterator iteratorFromFunction_withEndMarker(final F0 f) {
return iteratorFromFunction_withEndMarker_f0(f);
}
static RuntimeException fail() { throw new RuntimeException("fail"); }
static RuntimeException fail(Throwable e) { throw asRuntimeException(e); }
static RuntimeException fail(Object msg) { throw new RuntimeException(String.valueOf(msg)); }
static RuntimeException fail(String msg) { throw new RuntimeException(msg == null ? "" : msg); }
static RuntimeException fail(String msg, Throwable innerException) { throw new RuntimeException(msg, innerException); }
static int iteratorCount_int_close(Iterator i) { try {
int n = 0;
if (i != null) while (i.hasNext()) { i.next(); ++n; }
if (i instanceof AutoCloseable) ((AutoCloseable) i).close();
return n;
} catch (Exception __e) { throw rethrow(__e); } }
static Object call(Object o) {
return callF(o);
}
// varargs assignment fixer for a single string array argument
static Object call(Object o, String method, String[] arg) {
return call(o, method, new Object[] {arg});
}
static Object call(Object o, String method, Object... args) {
//ret call_cached(o, method, args);
return call_withVarargs(o, method, args);
}
static Iterator emptyIterator() {
return Collections.emptyIterator();
}
static Object swingCall(final Object o, final String method, final Object... args) {
return swing(new F0