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.*;
import java.text.NumberFormat;
class main {
static String ai_ruleOfThree_solver_2(String db, String input) {
return too_transformInput(input, too -> {
too.addAll(lambdaMap(s -> new Input(s), tlft(db)));
too.addTransformer(new F1, Object>() { public Object get(Input i) { try {
BasicLogicRule r = ai_parseIfThen(i.get());
if (r != null)
too.addTransformer(new F1, Object>() { public Object get(Input i2) { try {
if (match(r.lhs, i2.get()))
return new TransformedInput(r.rhs);
return null;
} catch (Exception __e) { throw rethrow(__e); } }
public String toString() { return "if (match(r.lhs, i2!))\r\n ret new TransformedInput(r.rhs);\r\n ..."; }});
return null;
} catch (Exception __e) { throw rethrow(__e); } }
public String toString() { return "BasicLogicRule r = ai_parseIfThen(i!);\r\n if (r != null)\r\n too...."; }});
});
}
static String too_transformInput(String input, IVF1 code) {
// make too, load input
TransformersOnObjects too = new TransformersOnObjects();
too.add(new Input(input));
// run user code
code.get(too);
// return first transformed input
return too_thinkAndReturnFirstTransformedInput(too);
}
static List lambdaMap(IF1 f, Iterable l) {
return map(l, f);
}
static List lambdaMap(IF1 f, A[] l) {
return map(l, f);
}
static List tlft(String s) { return toLinesFullTrim(s); }
static List tlft(File f) { return toLinesFullTrim(f); }
static BasicLogicRule ai_parseIfThen(String s) {
return matchesToBasicLogicRule(getFlexMatchIC("if *, *", s));
}
static boolean match(String pat, String s) {
return match3(pat, s);
}
static boolean match(String pat, String s, Matches matches) {
return match3(pat, s, matches);
}
static boolean match(String pat, List toks, Matches matches) {
return match3(pat, toks, matches);
}
static RuntimeException rethrow(Throwable t) {
if (t instanceof Error)
_handleError((Error) t);
throw t instanceof RuntimeException ? (RuntimeException) t : new RuntimeException(t);
}
static RuntimeException rethrow(String msg, Throwable t) {
throw new RuntimeException(msg, t);
}
static String too_thinkAndReturnFirstTransformedInput(TransformersOnObjects too) {
TransformedInput i = too_thinkAndReturnFirstObjectOfType(TransformedInput.class, too);
return i == null ? null : (String) i.a;
}
static List map(Iterable l, Object f) { return map(f, l); }
static List map(Object f, Iterable l) {
List x = emptyList(l);
if (l != null) for (Object o : l)
x.add(callF(f, o));
return x;
}
static List map(Iterable l, F1 f) { return map(f, l); }
static List map(F1 f, Iterable l) {
List x = emptyList(l);
if (l != null) for (A o : l)
x.add(callF(f, o));
return x;
}
static List map(IF1 f, Iterable l) { return map(l, f); }
static List map(Iterable l, IF1 f) {
List x = emptyList(l);
if (l != null) for (A o : l)
x.add(f.get(o));
return x;
}
static List map(IF1 f, A[] l) { return map(l, f); }
static List map(A[] l, IF1 f) {
List x = emptyList(l);
if (l != null) for (A o : l)
x.add(f.get(o));
return x;
}
static List map(Object f, Object[] l) { return map(f, asList(l)); }
static List map(Object[] l, Object f) { return map(f, l); }
static List map(Object f, Map map) {
return map(map, f);
}
// map: func(key, value) -> list element
static List map(Map map, Object f) {
List x = new ArrayList();
if (map != null) for (Object _e : map.entrySet()) {
Map.Entry e = (Map.Entry) _e;
x.add(callF(f, e.getKey(), e.getValue()));
}
return x;
}
static List map(Map map, IF2 f) {
return map(map, (Object) f);
}
static List toLinesFullTrim(String s) {
List l = new ArrayList();
for (String line : toLines(s)) if (nempty(line = trim(line))) l.add(line);
return l;
}
static List toLinesFullTrim(File f) {
List l = new ArrayList();
for (String line : linesFromFile(f)) if (nempty(line = trim(line))) l.add(line);
return l;
}
static BasicLogicRule matchesToBasicLogicRule(Matches m) {
return listToBasicLogicRule(matchesToList(m));
}
static Matches getFlexMatchIC(String pat, String s) {
Matches m = new Matches();
return flexMatchIC(pat, s, m) ? m : null;
}
static Matches getFlexMatchIC(String pat, String s, boolean joinBrackets) {
Matches m = new Matches();
return flexMatchIC(pat, s, m, joinBrackets) ? m : null;
}
static Matches getFlexMatchIC(String pat, List tokInput) {
Matches m = new Matches();
return flexMatchIC(pat, tokInput, m) ? m : null;
}
static boolean match3(String pat, String s) {
return match3(pat, s, null);
}
static boolean match3(String pat, String s, Matches matches) {
if (pat == null || s == null) return false;
return match3(pat, parse3_cachedInput(s), matches);
}
static boolean match3(String pat, List toks, Matches matches) {
List tokpat = parse3_cachedPattern(pat);
return match3(tokpat, toks, matches);
}
static boolean match3(List tokpat, List toks, Matches matches) {
String[] m = match2(tokpat, toks);
//print(structure(tokpat) + " on " + structure(toks) + " => " + structure(m));
if (m == null) return false;
if (matches != null) matches.m = m; return true;
}
static void _handleError(Error e) {
call(javax(), "_handleError", e);
}
static A too_thinkAndReturnFirstObjectOfType(Class type, TransformersOnObjects too) {
return withDeepReturn(returnSite -> {
// return first transformed input
too.addTransformer(new F1