import java.io.*;
public class Main {
static String Calculate(String s, String var) {
StringBuilder sb = new StringBuilder();
int N = s.length();
s += '#';
sb.append('(').append('0');
for (int i = 0; i < N; i++) {
char c = s.charAt(i);
if (c == '.') {
sb.append("+1");
} else if (c == ',') {
sb.append(-1);
} else if (c == ' ') {
sb.append(")*(");
} else if (c == '식') {
++i;
sb.append('+').append(var);
} else if (c == '어') {
char next = s.charAt(i+1);
if (next == '어') continue;
int idx = 0;
if (i > 0 && s.charAt(i-1) == '어') {
++idx;
if (i > 1 && s.charAt(i-1) == '어') {
++idx;
}
}
sb.append('+').append("arr[").append(idx).append(']');
} else {
// Do nothing
}
}
sb.append(')');
return sb.toString();
}
static String Printf(String s, char fmt) {
if (fmt == 'ㅋ') fmt = 'c';
else fmt = 'd';
return "\tprintf(\"%"+fmt+"\", " + Calculate(s, "") + ");\n";
}
static String Scanf(String var) {
return "\tscanf(\"%d\", &" + var + ");\n";
}
static String Um(String var, String s) {
String sik = "";
if (s.contains("식?")) sik = Scanf(var);
return sik + '\t' + var + " = " + Calculate(s, var) + ";\n";
}
public static void main(String[] args) throws IOException {
File umf = new File("./test.umm"), cf = new File("./test.c");
BufferedReader br = new BufferedReader(new FileReader(umf));
BufferedWriter bw = new BufferedWriter(new FileWriter(cf));
bw.write("#include <stdio.h>\n\n");
bw.write("int main() {\n");
bw.write("\tint arr[3];\n");
bw.write("\tarr[0] = 0; ");
bw.write("arr[1] = 0; ");
bw.write("arr[2] = 0;\n\n");
String s;
while ((s = br.readLine()) != null) {
if (s.equals("어떻게") || s.equals("이 사람이름이냐ㅋㅋ")) continue;
int N = s.length();
if (s.contains("엄")) {
int idx = s.charAt(0) == '엄' ? 0 : s.charAt(1) == '엄' ? 1 : 2;
bw.write(Um("arr["+idx+"]", s.substring(idx+1, N)));
} else if (s.contains("식")) {
bw.write(Printf(s.substring(1, N-1), s.charAt(N-1)));
} else {
// Do nothing
}
}
bw.write("\n\treturn 0;\n");
bw.write("}");
bw.flush();
bw.close();
br.close();
}
}