<?xml version="1.0" encoding="UTF-8"?>
<quiz>
<!-- question: 0  -->
  <question type="category">
    <category>
        <text>top/CR_PROTOTYPES</text>

    </category>
  </question>

<!-- question: 21100  -->
  <question type="coderunner">
    <name>
      <text>BUILT_IN_PROTOTYPE_c_function</text>
    </name>
    <questiontext format="html">
      <text>Built-in prototypes are documented in the language strings.</text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>c_function</coderunnertype>
    <prototypetype>1</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>33.3, 66.7, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template><![CDATA[#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#define SEPARATOR "#<ab@17943918#@>#"

{{ STUDENT_ANSWER }}

int main() {
{% for TEST in TESTCASES %}
   {
    {{ TEST.testcode }};
   }
    {% if not loop.last %}printf("%s\n", SEPARATOR);{% endif %}
{% endfor %}
    return 0;
}]]></template>
    <iscombinatortemplate>1</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre><![CDATA[|#<ab@17943918#@>#\n|ms]]></testsplitterre>
    <language>C</language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams>{"linkargs": ["-lm"]}</sandboxparams>
    <templateparams></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>ace</uiplugin>
    <testcases>
    </testcases>
  </question>

<!-- question: 21101  -->
  <question type="coderunner">
    <name>
      <text>BUILT_IN_PROTOTYPE_c_program</text>
    </name>
    <questiontext format="html">
      <text>Built-in prototypes are documented in the language strings.</text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>c_program</coderunnertype>
    <prototypetype>1</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>33.3, 66.7, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template>{{ STUDENT_ANSWER }}</template>
    <iscombinatortemplate>0</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre></testsplitterre>
    <language>C</language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams>{"linkargs": ["-lm"]}</sandboxparams>
    <templateparams></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>ace</uiplugin>
    <testcases>
    </testcases>
  </question>

<!-- question: 21102  -->
  <question type="coderunner">
    <name>
      <text>BUILT_IN_PROTOTYPE_cpp_function</text>
    </name>
    <questiontext format="html">
      <text>Built-in prototypes are documented in the language strings.</text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>cpp_function</coderunnertype>
    <prototypetype>1</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>33.3, 66.7, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template><![CDATA[#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
#define SEPARATOR "#<ab@17943918#@>#"

{{ STUDENT_ANSWER }}

int main() {
{% for TEST in TESTCASES %}
   {
    {{ TEST.extra }};
    {{ TEST.testcode }};
   }
    {% if not loop.last %}cout << SEPARATOR << endl;{% endif %}
{% endfor %}
    return 0;
}]]></template>
    <iscombinatortemplate>1</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre><![CDATA[|#<ab@17943918#@>#\n|ms]]></testsplitterre>
    <language>cpp</language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams>{"linkargs": ["-lm"]}</sandboxparams>
    <templateparams></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>ace</uiplugin>
    <testcases>
    </testcases>
  </question>

<!-- question: 21103  -->
  <question type="coderunner">
    <name>
      <text>BUILT_IN_PROTOTYPE_cpp_program</text>
    </name>
    <questiontext format="html">
      <text>Built-in prototypes are documented in the language strings.</text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>cpp_program</coderunnertype>
    <prototypetype>1</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>33.3, 66.7, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template>{{ STUDENT_ANSWER }}</template>
    <iscombinatortemplate>0</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre></testsplitterre>
    <language>cpp</language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams>{"linkargs": ["-lm"]}</sandboxparams>
    <templateparams></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>ace</uiplugin>
    <testcases>
    </testcases>
  </question>

<!-- question: 21104  -->
  <question type="coderunner">
    <name>
      <text>BUILT_IN_PROTOTYPE_directed_graph</text>
    </name>
    <questiontext format="html">
      <text>Built-in prototypes are documented in the language strings.</text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>directed_graph</coderunnertype>
    <prototypetype>1</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template><![CDATA[import json

student_answer = """{{ STUDENT_ANSWER | e('py') }}"""
SEPARATOR = "#<ab@17943918#@>#"

error_count = 0
def error(s):
    global error_count
    print(s)
    error_count += 1

try:
    graph_rep = json.loads(student_answer)
    node_id_to_name_map = {}
    for i, node in enumerate(graph_rep['nodes']):
        node_id_to_name_map[i] = node[0] if node[0] != '' else ('#' + str(i))
    #print("Nodes:", nodes)
    edges = graph_rep['edges']
    #print("Edges:", edges)
    graph = {}
    for node_id, node_name in sorted(node_id_to_name_map.items()):
        edges = []
        for id0, id1, edge_label, *loc in graph_rep['edges']:
            if id0 == node_id:
                edges.append((node_id_to_name_map[id1], edge_label))
        edges.sort()
        graph[node_name] = edges

except json.JSONDecodeError as e:
    raise Exception("Oops. Illegal graph received (exception {}). Please report (unless you did something silly yourself)".format(e))

{% for TEST in TESTCASES %}
{{ TEST.testcode }}
{{ TEST.extra }}
{% if not loop.last %}
print(SEPARATOR)
{% endif %}
{% endfor %}]]></template>
    <iscombinatortemplate>1</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre><![CDATA[|#<ab@17943918#@>#\n|ms]]></testsplitterre>
    <language>python3</language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams><![CDATA[{"isdirected": true, "isfsm": false}]]></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>graph</uiplugin>
    <testcases>
    </testcases>
  </question>

<!-- question: 21105  -->
  <question type="coderunner">
    <name>
      <text>BUILT_IN_PROTOTYPE_java_class</text>
    </name>
    <questiontext format="html">
      <text>Built-in prototypes are documented in the language strings.</text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>java_class</coderunnertype>
    <prototypetype>1</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>33.3, 66.7, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template>{{ STUDENT_ANSWER | replace({'public class ': 'class '}) }}

public class __tester__ {

    public static void main(String[] args) {
        __tester__ main = new __tester__();
        main.runTests();
    }

    public void runTests() {
        {{ TEST.testcode }};
    }
}
</template>
    <iscombinatortemplate>0</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre></testsplitterre>
    <language>Java</language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb>2000</memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>ace</uiplugin>
    <testcases>
    </testcases>
  </question>

<!-- question: 21106  -->
  <question type="coderunner">
    <name>
      <text>BUILT_IN_PROTOTYPE_java_method</text>
    </name>
    <questiontext format="html">
      <text>Built-in prototypes are documented in the language strings.</text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>java_method</coderunnertype>
    <prototypetype>1</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>33.3, 66.7, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template><![CDATA[public class __tester__ {
    static String SEPARATOR = "#<ab@17943918#@>#";
    {{ STUDENT_ANSWER }}

    public static void main(String[] args) {
        __tester__ main = new __tester__();
        main.runTests();
    }

    public void runTests() {
{% for testCase in TESTCASES %}
    {
    {{ testCase.testcode }};
    {% if not loop.last %}
    System.out.println(SEPARATOR);
    {% endif %}
    }
{% endfor %}
    }
}]]></template>
    <iscombinatortemplate>1</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre><![CDATA[|#<ab@17943918#@>#\n|ms]]></testsplitterre>
    <language>Java</language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb>2000</memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>ace</uiplugin>
    <testcases>
    </testcases>
  </question>

<!-- question: 21107  -->
  <question type="coderunner">
    <name>
      <text>BUILT_IN_PROTOTYPE_java_program</text>
    </name>
    <questiontext format="html">
      <text>Built-in prototypes are documented in the language strings.</text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>java_program</coderunnertype>
    <prototypetype>1</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>33.3, 66.7, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template>{{ STUDENT_ANSWER }}</template>
    <iscombinatortemplate>0</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre></testsplitterre>
    <language>Java</language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb>2000</memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>ace</uiplugin>
    <testcases>
    </testcases>
  </question>

<!-- question: 21108  -->
  <question type="coderunner">
    <name>
      <text>BUILT_IN_PROTOTYPE_octave_function</text>
    </name>
    <questiontext format="html">
      <text>Built-in prototypes are documented in the language strings.</text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>octave_function</coderunnertype>
    <prototypetype>1</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>33.3, 66.7, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template><![CDATA[1; % Dummy statement to make a script
{{ STUDENT_ANSWER }}

format free

{% for TEST in TESTCASES %}
{{ TEST.testcode }};
{% if not loop.last %}
disp('#<ab@17943918#@>#');
{% endif %}
{% endfor %}
]]></template>
    <iscombinatortemplate>1</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre><![CDATA[|#<ab@17943918#@>#\n|ms]]></testsplitterre>
    <language>octave</language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs>3</cputimelimitsecs>
    <memlimitmb>1000</memlimitmb>
    <sandboxparams>{"sourcefilename": "prog"}</sandboxparams>
    <templateparams></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>ace</uiplugin>
    <testcases>
    </testcases>
  </question>

<!-- question: 21109  -->
  <question type="coderunner">
    <name>
      <text>BUILT_IN_PROTOTYPE_pascal_function</text>
    </name>
    <questiontext format="html">
      <text>Built-in prototypes are documented in the language strings.</text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>pascal_function</coderunnertype>
    <prototypetype>1</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>33.3, 66.7, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template>{{ STUDENT_ANSWER }}

begin
    {{ TEST.testcode }};
end.
</template>
    <iscombinatortemplate>0</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre><![CDATA[|#<ab@17943918#@>#\n|ms]]></testsplitterre>
    <language>pascal</language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>ace</uiplugin>
    <testcases>
    </testcases>
  </question>

<!-- question: 21110  -->
  <question type="coderunner">
    <name>
      <text>BUILT_IN_PROTOTYPE_pascal_program</text>
    </name>
    <questiontext format="html">
      <text>Built-in prototypes are documented in the language strings.</text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>pascal_program</coderunnertype>
    <prototypetype>1</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>33.3, 66.7, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template>{{ STUDENT_ANSWER }}</template>
    <iscombinatortemplate>0</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre></testsplitterre>
    <language>pascal</language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>ace</uiplugin>
    <testcases>
    </testcases>
  </question>

<!-- question: 21111  -->
  <question type="coderunner">
    <name>
      <text>BUILT_IN_PROTOTYPE_php</text>
    </name>
    <questiontext format="html">
      <text>Built-in prototypes are documented in the language strings.</text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>php</coderunnertype>
    <prototypetype>1</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>33.3, 66.7, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template><![CDATA[{{ STUDENT_ANSWER }}

define('SEPARATOR', "#<ab@17943918#@>#\n");

{% for TEST in TESTCASES %}
{{ TEST.testcode }};
{% if not loop.last %}
echo SEPARATOR;
{% endif %}
{% endfor %}]]></template>
    <iscombinatortemplate>1</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre><![CDATA[|#<ab@17943918#@>#\n|ms]]></testsplitterre>
    <language>php</language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb>500000</memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>ace</uiplugin>
    <testcases>
    </testcases>
  </question>

<!-- question: 21112  -->
  <question type="coderunner">
    <name>
      <text>BUILT_IN_PROTOTYPE_python2</text>
    </name>
    <questiontext format="html">
      <text>Built-in prototypes are documented in the language strings.</text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>python2</coderunnertype>
    <prototypetype>1</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>33.3, 66.7, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template><![CDATA[{{ STUDENT_ANSWER }}

__student_answer__ = """{{ STUDENT_ANSWER | e('py') }}"""

SEPARATOR = "#<ab@17943918#@>#"

{% for TEST in TESTCASES %}
{{ TEST.testcode }}
{% if not loop.last %}
print(SEPARATOR)
{% endif %}
{% endfor %}]]></template>
    <iscombinatortemplate>1</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre><![CDATA[|#<ab@17943918#@>#\n|ms]]></testsplitterre>
    <language>python2</language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>ace</uiplugin>
    <testcases>
    </testcases>
  </question>

<!-- question: 21113  -->
  <question type="coderunner">
    <name>
      <text>BUILT_IN_PROTOTYPE_python3</text>
    </name>
    <questiontext format="html">
      <text>Built-in prototypes are documented in the language strings.</text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>python3</coderunnertype>
    <prototypetype>1</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>33.3, 66.7, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template><![CDATA[{{ STUDENT_ANSWER }}

__student_answer__ = """{{ STUDENT_ANSWER | e('py') }}"""

SEPARATOR = "#<ab@17943918#@>#"

{% for TEST in TESTCASES %}
{{ TEST.testcode }}
{% if not loop.last %}
print(SEPARATOR)
{% endif %}
{% endfor %}]]></template>
    <iscombinatortemplate>1</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre><![CDATA[|#<ab@17943918#@>#\n|ms]]></testsplitterre>
    <language>python3</language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>ace</uiplugin>
    <testcases>
    </testcases>
  </question>

<!-- question: 21165  -->
  <question type="coderunner">
    <name>
      <text>BUILT_IN_PROTOTYPE_sql</text>
    </name>
    <questiontext format="html">
      <text>Built-in prototypes are documented in the language strings.</text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>sql</coderunnertype>
    <prototypetype>1</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template><![CDATA[import subprocess, os, shutil

# Use Twig to get students answer and the columnwidth template parameter
student_answer = """{{ STUDENT_ANSWER | e('py') }}""".rstrip()
column_widths = []
{% for width in QUESTION.parameters.columnwidths %}
column_widths.append({{width}})
{% endfor %}

if not student_answer.endswith(';'):
    student_answer = student_answer + ';'
db_files = [fname for fname in os.listdir() if fname.endswith('.db')]
if len(db_files) == 0:
    raise Exception("No DB files found!")
elif len(db_files) == 1:
    db_working = db_files[0][:-3]  # Strip .db extension
else:
    raise Exception("Multiple DB files not implemented yet, sorry!")

SEPARATOR = "#<ab@17943918#@>#"
controls = [".mode column", ".headers on"]
if column_widths: # Add column width specifiers if given
    controls.append(".width " + ' '.join(str(width) for width in column_widths))
prelude = '\n'.join(controls) + '\n'

{% for TEST in TESTCASES %}
shutil.copyfile(db_files[0], db_working)  # Copy clean writeable db file
testcode = """{{ TEST.testcode | e('py') }}"""
extra = """{{ TEST.extra | e('py') }}"""
code_to_run = '\n'.join([prelude, extra, student_answer, testcode])
with open('commands', 'w') as sqlite_commands:
    sqlite_commands.write(code_to_run)

with open('commands') as cmd_input:
    text_input = cmd_input.read()
    try:
        output = subprocess.check_output(['sqlite3', db_working], input=text_input,
                 universal_newlines=True)
        print(output)
    except Exception as e:
        raise Exception("sqlite3 error: " + str(e))

{% if not loop.last %}
print(SEPARATOR)
{% endif %}
{% endfor %}]]></template>
    <iscombinatortemplate>1</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre><![CDATA[|#<ab@17943918#@>#\n|ms]]></testsplitterre>
    <language>python3</language>
    <acelang>sql</acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb>500</memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>ace</uiplugin>
    <testcases>
    </testcases>
  </question>

<!-- question: 21114  -->
  <question type="coderunner">
    <name>
      <text>BUILT_IN_PROTOTYPE_undirected_graph</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Built-in prototypes are documented in the language strings.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>undirected_graph</coderunnertype>
    <prototypetype>1</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template><![CDATA[import json

student_answer = """{{ STUDENT_ANSWER | e('py') }}"""
SEPARATOR = "#<ab@17943918#@>#"

error_count = 0
def error(s):
    global error_count
    print(s)
    error_count += 1

try:
    graph_rep = json.loads(student_answer)
    node_id_to_name_map = {}
    for i, node in enumerate(graph_rep['nodes']):
        node_id_to_name_map[i] = node[0] if node[0] != '' else ('#' + str(i))
    #print("Nodes:", nodes)
    edges = graph_rep['edges']
    #print("Edges:", edges)
    graph = {}
    for node_id, node_name in sorted(node_id_to_name_map.items()):
        edges = []
        for id0, id1, edge_label, *loc in graph_rep['edges']:
            if id0 == node_id:
                edges.append((node_id_to_name_map[id1], edge_label))
            elif id1 == node_id:
                edges.append((node_id_to_name_map[id0], edge_label))
        edges.sort()
        graph[node_name] = edges

except json.JSONDecodeError as e:
    raise Exception("Oops. Illegal graph received (exception {}). Please report (unless you did something silly yourself)".format(e))

{% for TEST in TESTCASES %}
{{ TEST.testcode }}
{{ TEST.extra }}
{% if not loop.last %}
print(SEPARATOR)
{% endif %}
{% endfor %}]]></template>
    <iscombinatortemplate>1</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre><![CDATA[|#<ab@17943918#@>#\n|ms]]></testsplitterre>
    <language>python3</language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams><![CDATA[{"isdirected": false, "isfsm": false}]]></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>graph</uiplugin>
    <testcases>
    </testcases>
  </question>

<!-- question: 21115  -->
  <question type="coderunner">
    <name>
      <text>BUILTIN_PROTOTYPE_nodejs</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Built-in prototypes are documented in the language strings.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>nodejs</coderunnertype>
    <prototypetype>1</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>33.3, 66.7, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template><![CDATA[{{ STUDENT_ANSWER }}

var SEPARATOR = "#<ab@17943918#@>#";

{% for TEST in TESTCASES %}
{{ TEST.testcode }}
{% if not loop.last %}
console.log(SEPARATOR);
{% endif %}
{% endfor %}]]></template>
    <iscombinatortemplate>1</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre><![CDATA[|#<ab@17943918#@>#\n|ms]]></testsplitterre>
    <language>nodejs</language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb>1000</memlimitmb>
    <sandboxparams>{"sourcefilename": "__tester__.js"}</sandboxparams>
    <templateparams></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>ace</uiplugin>
    <testcases>
    </testcases>
  </question>

<!-- question: 21116  -->
  <question type="coderunner">
    <name>
      <text>BUILTIN_PROTOTYPE_python3_w_input</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Built-in prototypes are documented in the language strings.</p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>python3_w_input</coderunnertype>
    <prototypetype>1</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>33.3, 66.7, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template><![CDATA[__saved_input__ = input
def input(prompt=''):
    s = __saved_input__(prompt)
    print(s)
    return s

{{ STUDENT_ANSWER }}
SEPARATOR = "#<ab@17943918#@>#"

{% for TEST in TESTCASES %}
{{ TEST.testcode }}
{% if not loop.last %}
print(SEPARATOR)
{% endif %}
{% endfor %}]]></template>
    <iscombinatortemplate>1</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre><![CDATA[|#<ab@17943918#@>#\n|ms]]></testsplitterre>
    <language>python3</language>
    <acelang></acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb></memlimitmb>
    <sandboxparams></sandboxparams>
    <templateparams></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>ace</uiplugin>
    <testcases>
    </testcases>
  </question>

<!-- question: 21117  -->
  <question type="coderunner">
    <name>
      <text>BUILT_IN_PROTOTYPE_multilanguage</text>
    </name>
    <questiontext format="html">
      <text><![CDATA[<p>Built-in prototypes are documented in the language strings.<br></p>]]></text>
    </questiontext>
    <generalfeedback format="html">
      <text></text>
    </generalfeedback>
    <defaultgrade>1.0000000</defaultgrade>
    <penalty>0.0000000</penalty>
    <hidden>0</hidden>
    <coderunnertype>multilanguage</coderunnertype>
    <prototypetype>2</prototypetype>
    <allornothing>1</allornothing>
    <penaltyregime>10, 20, ...</penaltyregime>
    <precheck>0</precheck>
    <showsource>0</showsource>
    <answerboxlines>18</answerboxlines>
    <answerboxcolumns>100</answerboxcolumns>
    <answerpreload></answerpreload>
    <useace>1</useace>
    <resultcolumns></resultcolumns>
    <template><![CDATA["""The template for a "write a program" question type that accepts answers
    in C, C++, Java or Python3 according to the value in the language select
    dropdown menu.
"""

import subprocess
import re
student_answer = """{{ STUDENT_ANSWER | e('py') }}"""
language = """{{ ANSWER_LANGUAGE | e('py') }}""".lower()
language_extension_map = {'c':'c', 'cpp':'cpp', 'java':'java', 'python3':'py'}

if language not in language_extension_map.keys():
    raise Exception('Error in question. Unknown/unexpected language ({})'.format(language))

if language == 'java':
    # Need to determine public class name in order to name output file. Sigh.
    # The best I can be bothered to do is to use a regular expression match.
    match = re.search(r'public\s+class\s+([_a-zA-Z][_a-zA-Z0-9]*)', student_answer, re.DOTALL | re.MULTILINE)
    if match is None:
        raise Exception("Unable to determine class name. Does the file include 'public class name'?")
    classname = match.group(1)
    filename = classname + '.java'
else:
    filename = '__tester__.' + language_extension_map[language]

# Write the student code to a file

with open(filename, "w") as src:
    print(student_answer, file=src)

# Compile C, C++ and Java
if language == 'c':
    cflags = "-std=c99 -Wall -Werror"
    return_code = subprocess.call("gcc {0} -o __tester__ __tester__.c".format(cflags).split())
    if return_code != 0:
        raise Exception("** Compilation failed. Testing aborted **")
    exec_command = ["./__tester__"]
elif language == 'cpp':
    cppflags = "-Wall -Werror"
    return_code = subprocess.call("g++ {0} -o __tester__ __tester__.cpp".format(cppflags).split())
    if return_code != 0:
        raise Exception("** Compilation failed. Testing aborted **")
    exec_command = ["./__tester__"]
elif language == 'java':
    return_code = subprocess.call(['javac', "-J-Xss64m", "-J-Xmx4g", filename])
    if return_code != 0:
        raise Exception("** Compilation failed. Testing aborted **")
    exec_command = ["java", "-Xss16m", "-Xmx500m", classname]
else: # Python doesn't need a compile phase
    exec_command = ["python3", "./__tester__.py"]

# Now run the code. Since this is a per-test template,
# stdin is already set up for the stdin text specified in the test case,
# so we can run the compiled program directly.

try:
    output = subprocess.check_output(exec_command, universal_newlines=True)
    print(output)
except subprocess.CalledProcessError as e:
    if e.returncode > 0:
        # Ignore non-zero positive return codes
        if e.output:
            print(e.output)
    else:
        # But negative return codes are signals - abort
        if e.output:
            print(e.output, file=sys.stderr)
        if e.returncode < 0:
            print("Task failed with signal", -e.returncode, file=sys.stderr)
        print("** Further testing aborted **", file=sys.stderr)]]></template>
    <iscombinatortemplate>0</iscombinatortemplate>
    <allowmultiplestdins>0</allowmultiplestdins>
    <answer></answer>
    <validateonsave>0</validateonsave>
    <testsplitterre></testsplitterre>
    <language>python3</language>
    <acelang>c,cpp,java,python3</acelang>
    <sandbox></sandbox>
    <grader>EqualityGrader</grader>
    <cputimelimitsecs></cputimelimitsecs>
    <memlimitmb>16000</memlimitmb>
    <sandboxparams>{"numprocs": 50}</sandboxparams>
    <templateparams></templateparams>
    <hoisttemplateparams>0</hoisttemplateparams>
    <twigall>0</twigall>
    <uiplugin>ace</uiplugin>
    <testcases>
    </testcases>
  </question>

</quiz>