substring-ab-program-frontier-cs-algorithmic-23

A=B Substring Program

Synthesize a short A=B rewriting program for substring detection test families.

Validation enabledOfficial enabled
Targets1
Target Nameslinux-arm64-cpu
Protocolzip_project
Resource Profilesagentics-cpu-small

A=B Substring Program

Synthesize a short A=B rewriting program for substring detection test families.

Solution Interface

Submit a zip_project solution. The run command is executed once per case, reads the case from standard input, and writes the answer to standard output. The trusted separated evaluator runs the migrated Frontier-CS Testlib checker against the submitted output and the case's evaluator-only answer or scoring metadata.

Scoring

The leaderboard score is the average checker ratio scaled to 0..100 across official cases. Invalid outputs receive zero for the affected case. The public validation case is intentionally tiny and deterministic; official scoring uses the source-derived Frontier-CS cases packaged as private benchmark data.

Original Statement

A=B

Input file: standard input
Output file: standard output
Time limit: 1 second
Memory limit: 512 megabytes

Marisa has learned an interesting language called A=B. She finds that this language has the advantages of simple syntax, easy to learn and convenient to code.

Here is the user manual of A=B:

(Note that it may differ from the original game “A=B”. So please read the statement carefully.)


Instruction set

A=B’s instruction set includes:

  1. string1=string2
    Find the leftmost occurrence of string1 in the string and replace it with string2.

  2. string1=(return)string2
    If string1 is found, replace the entire string with string2 and end the program immediately.


Program structure

  • An A=B program consists of several lines of instructions.
  • Each line must include exactly one equal sign (=).
  • Following characters are reserved: =, (, ).

Execution order

  1. Read the input string.
  2. Starting from the topmost line, find the first line that can be executed.
  3. If found, execute that line and go to step 2.
  4. If none is found, return the current string as output.

Marisa once introduced A=B to Alice. However, “You called this a programming language? You can’t even write a program that can check if string t is a substring of string s!” said Alice.

Now Marisa comes to you for help. She wants you to design an A=B program for this problem and show A=B’s efficiency.


Requirements

Your program needs to meet the following requirements:

  • Read the input string (the input format is sSt. S is the separator. s and t are two non-empty strings consisting of characters a, b, c).
  • If t is a substring of s, the program should return 1 as output, else return 0 as output.
  • The character set that your program can use is {a–z, A–Z, 0–9, =, (, )}.
    • Remember: =, (, ) are reserved characters in A=B and you can’t use them in string1 or string2.
  • In the instruction format, the length of string1 and string2 should be at most 3.
  • Suppose the length of the input string is L, then:
    • The number of instruction executions can’t exceed max(2L^2, 50).
    • The length of the string during execution can’t exceed 2L + 10.
  • The number of instructions in your A=B program can’t exceed 100.

Input

Input an integer Tid (0 ≤ Tid ≤ 2×10^9). It is used for generating test sets and may be no use to you.


Output

Output your A=B program containing several lines of instructions.

The number of tests will not exceed 20. In each test, the checker will use Tid in the input file to generate several lines of input strings and their corresponding answers.
Your A=B program is considered correct iff for each input string in all tests, your A=B program gives the correct output.

It’s guaranteed that for each input string in all tests, the length L satisfies 3 ≤ L ≤ 1000.


Examples

Example 1

Input


114514

Output


514=(return)1
=514


Example 2

Input


1919810

Output


S=Sakuya
=(return)0


Example 3

Input


caba

Output


aabc

Input


cbacab

Output


aabbcc

Program


ba=ab
ca=ac
cb=bc


Example 4

Input


bababb

Output


b

Input


aababbaa

Output


a

Program


ba=ab
ab=
bb=b
aa=a


Example 5

Input


abc

Output


true

Input


cabc

Output


false

Input


ca

Output


false

Program


b=a
c=a
aaaa=(return)false
aaa=(return)true
=(return)false


Example 6

Input


10111+111

Output


11110

Input


101+10110

Output


11011

Program


A0=0A
A1=1A
B0=0B
B1=1B
0A=a
0B=b
1A=b
1B=ca
A=a
B=b
ac=b
bc=ca
0+=+A
1+=+B
+=
0c=1
1c=c0
c=1
a=0
b=1


Note

  • The first and second examples show how you should submit your answer.
  • Examples 3–6 provide sample problems and their corresponding A=B programs to help you get familiar with the A=B language. Not all of them satisfy the problem’s constraints.

Configuration

Manifestagentics.solution.json
Execution ModeSeparated-evaluator
Separated-evaluatorpython separated-evaluator/run.py
EligibilityOpen
Rank MetricScore

Metrics

Scorescore · higher is better
Public
Accepted Casesaccepted_cases · higher is better · cases
Public
Average Ratioaverage_ratio · higher is better
Public
Unbounded Scoreunbounded_score · higher is better
Public

Latest Submissions

View all →

Nothing here yet

Top Rankings

View all →

Nothing here yet