alexjercan/bugnet huggingface dataset:
Problem p00423 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>

using namespace std;

int main() {

  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    int pa = 0, pb = 0;
    for (int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      if (a > b) {
        pa += a + b;
      } else if (a < b) {
        pb += a + b;
      } else {
        pa += a;
        pb += b;
      }
    }
    cout << pa << " " << pb << endl;
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>

using namespace std;

int main() {

  while (true) {
    int n;
    cin >> n;
    int pa = 0, pb = 0;
    int stack = 0;
    for (int i = 0; i < n; i++) {
      int a, b;
      cin >> a >> b;
      if (a > b) {
        pa += stack + a + b;
        stack = 0;
      } else if (a < b) {
        pb += stack + a + b;
        stack = 0;
      } else {
        stack += a + b;
      }
    }
    cout << pa << " " << pb << endl;
  }

  return 0;
}
Problem p00423 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <stdio.h>

int main(void) {
  int a_point, b_point, i, a_card, b_card, n;
  while (0 == 0) {
    scanf("%d", &n);
    if (n == 0)
      break;
    a_point = 0;
    b_point = 0;
    for (i = 0; i < n; i++) {
      scanf("%d %d", &a_card, &b_card);
      if (a_card > b_card)
        a_point += (a_card + b_card);
      else if (a_card < b_card)
        b_point += (a_card + b_card);
      else {
        a_point += a_card;
        b_point += b_card;
      }
    }
    printf("%d %d\\n", a_point, b_point);
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main(void) {
  int a_point, b_point, i, a_card, b_card, n;
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;
    a_point = 0;
    b_point = 0;
    for (i = 0; i < n; n++) {
      scanf("%d %d", &a_card, &b_card);
      if (a_card > b_card)
        a_point += (a_card + b_card);
      else if (a_card < b_card)
        b_point += (a_card + b_card);
      else {
        a_point += a_card;
        b_point += b_card;
      }
    }
    printf("%d %d\\n", a_point, b_point);
  }
  return 0;
}
Problem p00423 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;
int main() {
  int n = 0;
  int aa, bb = 0;
  while (cin >> n, n != 0) {
    aa = 0;
    bb = 0;
    int a[10000] = {};
    int b[10000] = {};

    for (int i = 0; i < n; i++) {
      cin >> a[i] >> b[i];
    }
    for (int j = 0; j < n; j++) {
      if (a[j] > b[j]) {
        aa += a[j] + b[j];
      } else if (a[j] < b[j]) {
        bb += a[j] + b[j];
      } else if (a[j] == b[j]) {
        aa += a[j];
        bb += b[j];
      }
    }
    cout << aa << " " << bb << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;
int main() {
  int n = 0;
  cin >> n;
  int a[10000] = {};
  int b[10000] = {};
  int i = 0;
  int aa, bb = 0;
  while (cin >> a[i] >> b[i]) {
    i++;
  }
  for (int j = 0; j >= i; j++) {
    if (a[j] > b[j]) {
      aa += a[j] + b[j];
    } else if (a[j] < b[j]) {
      bb += a[j] + b[j];
    } else if (a[j] == b[j]) {
      aa += a[j];
      bb += b[j];
    }
  }
  cout << aa << bb << endl;
  return 0;
}
Problem p00423 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
int main() {
  for (;;) {
    int ai, bi, as = 0, bs = 0, n;
    scanf("%d", &n);
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      scanf("%d%d", &ai, &bi);
      if (ai > bi)
        as += ai + bi;
      else if (ai < bi)
        bs += ai + bi;
      else {
        as += ai;
        bs += bi;
      }
    }
    printf("%d %d\\n", as, bs);
  }
}

Error: -11

Fixed submission:

#include <cstdio>
int main() {
  int ai, bi, as = 0, bs = 0, n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", ai, bi);
    if (ai > bi)
      as += ai + bi;
    else if (ai < bi)
      bs += ai + bi;
    else {
      as += ai;
      bs += bi;
    }
  }
  printf("%d %d\\n", as, bs);
}
Problem p00423 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;

int main() {
  while (1) {
    int i, n, x, y;
    cin >> n;

    if (n == 0) {
      break;
    } else {
      x = 0;
      y = 0;

      int a[n], b[n];

      for (i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
        if (a[i] > b[i]) {
          x += a[i] + b[i];
        } else if (a[i] < b[i]) {
          y += a[i] + b[i];
        } else {
          x += a[i];
          y += b[i];
        }
      }
      cout << x << " " << y << "\\n";
    }
  }

  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;

int main() {
  while (1) {
    int i, n, x, y;
    cin >> n;

    if (n = 0) {
      break;
    }
    x = 0;
    y = 0;

    int a[n], b[n];

    for (i = 1; i <= n; i++) {
      cin >> a[i] >> b[i];
      if (a[i] > b[i]) {
        x += a[i] + b[i];
      } else if (a[i] < b[i]) {
        y += a[i] + b[i];
      } else {
        x += a[i];
        y += b[i];
      }
      cout << x << " " << y << "\\n";
    }
  }

  return 0;
}
Problem p00423 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int i;
int a, b;
int n;

int main() {
  while (1) {
    a = 0;
    b = 0;

    scanf("%d", &n);
    if (n == 0)
      return 0;

    for (i = 0; i < n; i++) {
      int l, r;

      scanf("%d %d", &l, &r);
      if (l > r) {
        a += l + r;
      } else if (l < r) {
        b += l + r;
      } else {
        a += l;
        b += r;
      }
    }

    printf("%d %d\\n", a, b);
  }
}

Error: TLE

Fixed submission:

#include <stdio.h>

int main() {
  int i = 0, w = 0, x, a[10000], b[10000], aP[100], bP[100];
  while (i < 10000) {
    aP[i] = bP[i] = 0;
    ++i;
  }
  i = 0;
  while (1) {
    scanf("%d", &x);
    if (x == 0) {
      goto hata;
    }
    while (i < x) {
      scanf("%d%d", &a[i], &b[i]);
      ++i;
    }
    i = 0;
    while (i < x) {
      if (a[i] == b[i]) {
        aP[w] = aP[w] + a[i];
        bP[w] = bP[w] + b[i];
      } else if (a[i] > b[i]) {
        aP[w] = aP[w] + a[i] + b[i];
      } else {
        bP[w] = bP[w] + a[i] + b[i];
      }
      ++i;
    }
    ++w;
  }
hata:
  i = 0;
  while (i < w) {
    printf("%d %d\\n", aP[w], bP[w]);
  }
}
Problem p00424 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
char hantei(char);

int n;
char chana[1000], chanb[1000];

int main() {
  int i, j, m;
  char w;

  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;

    for (i = 0; i < n; i++) {
      scanf(" %c %c", &chana[i], &chanb[i]);
    }

    scanf("%d", &m);
    for (j = 0; j < m; j++) {
      scanf(" %c", &w);
      printf("%c", hantei(w));
    }
    printf("\\n");
  }
  return 0;
}

char hantei(char w) {
  int i;
  for (i = 0; i < n; i++) {
    if (w == chana[i])
      return chanb[i];
  }
  return w;
}

Error: -11

Fixed submission:

#include <stdio.h>
char hantei(char);

int n;
char chana[1000000000], chanb[1000000000];

int main() {
  int i, j, m;
  char w;

  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;

    for (i = 0; i < n; i++) {
      scanf(" %c %c", &chana[i], &chanb[i]);
    }

    scanf("%d", &m);
    for (j = 0; j < m; j++) {
      scanf(" %c", &w);
      printf("%c", hantei(w));
    }
    printf("\\n");
  }
  return 0;
}

char hantei(char w) {
  int i;
  for (i = 0; i < n; i++) {
    if (w == chana[i])
      return chanb[i];
  }
  return w;
}
Problem p00424 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <map>

int main(int argc, char **argv) {
  int n;
  while (std::cin >> n, n) {
    std::map<char, char> trans;
    for (; n > 0; --n) {
      char before, after;
      std::cin >> before >> after;
      trans[before] = after;
    }
    std::cin >> n;
    for (; n > 0; --n) {
      char c;
      std::cin >> c;
      if (trans.count(c) == 1)
        c = trans[c];
      std::cout << c;
    }
    std::cout << std::endl;
  }
}

Error: TLE

Fixed submission:

#include <stdio.h>
#include <stdlib.h>

int main() {
  int n, m, i, j;
  char *before, *after, temp;
  scanf("%d", &n);
  while (n != 0) {
    before = (char *)malloc(sizeof(char) * n);
    after = (char *)malloc(sizeof(char) * n);
    for (i = 0; i < n; i++) {
      scanf("%c %c", before[i], after[i]);
    }
    scanf("%d", &m);
    for (i = 0; i < m; i++) {
      scanf("%c", &temp);
      for (j = 0; j < n; j++) {
        if (before[j] == temp) {
          temp = after[j];
        }
      }
      printf("%c", &temp);
    }
    scanf("%d", &n);
  }
  return 0;
}
Problem p00424 (C++) — buggy submission, verdict: Memory Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <vector>
#define inf 32767
using namespace std;

int main(int argc, char *argv[]) {
  int n, N, i, j;
  char x;
  char tab[50][2];

  while (cin >> n && n) {
    for (i = 0; i < n; i++) {
      for (j = 0; j < 2; j++) {
        while (cin >> x && (x == '\\n' || x == ' ')) {
        }
        tab[i][j] = x;
      }
    }

    cin >> N;
    for (i = 0; i < N; i++) {
      while (cin >> x && (x == '\\n' || x == ' ')) {
      }

      for (j = 0; j < n; j++) {
        if (x == tab[j][0]) {
          x = tab[j][1];
          break;
        }
      }
      printf("%c", x);
    }
    cout << endl;
  }
  return 0;
}

Error: MLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <vector>
#define inf 32767
using namespace std;

int main() {
  int n, m, l;
  int change[1000][2];
  int i;
  vector<int> moji;

  for (;;) {
    cin >> n;
    if (n == 0)
      break;

    memset(change, 0, sizeof(change));
    for (i = 0; i < n; i++) {
      change[i][0] = getchar();
      if (change[i][0] == '\\n' || change[i][0] == ' ')
        change[i][0] = getchar();

      change[i][1] = getchar();
      if (change[i][1] == '\\n' || change[i][1] == ' ')
        change[i][1] = getchar();
    }

    cin >> m;
    for (i = 0; i < m; i++) {
      l = getchar();
      if (l == '\\n' || l == '\\0')
        l = getchar();

      moji.push_back(l);
    }

    for (i = 0; i < m; i++) {
      for (l = 0; l < n; l++) {
        if (moji[i] == change[l][0]) {
          moji[i] = change[l][1];
          break;
        }
      }
    }

    for (i = 0; i < m; i++)
      printf("%c", moji[i]);

    puts("");

    moji.clear();
  }
  return 0;
}
Problem p00424 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define SIZE 100000
int main() {
  int n, m, dp[SIZE], num1, num2;
  char ch1, ch2, ans[SIZE];
  while (1) {
    for (int i = 0; i < SIZE; i++) {
      dp[i] = -1;
    }
    cin >> n;
    if (n == 0) {
      break;
    }
    for (int i = 0; i < n; i++) {
      cin >> ch1 >> ch2;
      num1 = ch1;
      num2 = ch2;
      dp[num1] = num2;
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> ch1;
      num1 = ch1;
      if (dp[num1] != -1) {
        ans[i] = dp[num1];

      } else {
        ans[i] = ch1;
      }
    }
    for (int i = 0; i < m; i++) {
      cout << ans[i];
    }
    cout << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  int n, m, dp[10000], num1, num2;
  char ch1, ch2, ans[10000];
  while (1) {
    for (int i = 0; i < 10000; i++) {
      dp[i] = -1;
    }
    cin >> n;
    if (n == 0) {
      break;
    }
    for (int i = 0; i < n; i++) {
      cin >> ch1 >> ch2;
      num1 = ch1;
      num2 = ch2;
      dp[num1] = num2;
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> ch1;
      num1 = ch1;
      if (dp[num1] != -1) {
        ans[i] = dp[num1];

      } else {
        ans[i] = ch1;
      }
    }
    for (int i = 0; i < m; i++) {
      cout << ans[i];
    }
    cout << endl;
  }
  return 0;
}
Problem p00424 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
#include <map>
using namespace std;
int main() {
  int ConvTblNum;
  while (cin >> ConvTblNum && ConvTblNum) {
    map<string, string> ConvTbl;
    while (ConvTblNum--) {
      string a, b;
      cin >> a >> b;
      ConvTbl.insert(map<string, string>::value_type(a, b));
    }
    int ConvdNum;
    cin >> ConvdNum;
    string result = "";
    while (ConvdNum--) {
      string c;
      cin >> c;
      auto it = ConvTbl.find(c);
      if (it != ConvTbl.end()) {
        c = it->second;
      }
      result += c;
    }
    cout << result << endl;
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <cstdio>
#include <iostream>
#include <map>
using namespace std;
int main() {
  while (true) {
    int ConvTblNum;
    map<string, string> ConvTbl;
    cin >> ConvTblNum;
    if (ConvTblNum == EOF)
      break;
    while (ConvTblNum--) {
      string a, b;
      cin >> a >> b;
      ConvTbl.insert(map<string, string>::value_type(a, b));
    }
    int ConvdNum;
    cin >> ConvdNum;
    string result = "";
    while (ConvdNum--) {
      string c;
      cin >> c;
      auto it = ConvTbl.find(c);
      if (it != ConvTbl.end()) {
        c = it->second;
      }
      result += c;
    }
    cout << result << endl;
  }
  return 0;
}
Problem p00424 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
int main() {
  int n, m;
  static int dict[256];

  char k, v, x;
  while (scanf("%d\\n", &n)) {
    if (!n)
      return 0;
    for (int i = 0; i < 256; i++)
      dict[i] = i;
    for (int i = 0; i < n; i++) {
      scanf("%c %c\\n", &k, &v);
      dict[(int)k] = (int)v;
    }
    scanf("%d\\n", &m);
    for (int i = 0; i < m; i++) {
      scanf("%c\\n", &x);
      printf("%c", dict[(int)x]);
    }
    printf("\\n");
  }
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;

class ConvertTable {
public:
  char before;
  char after;

  ConvertTable(char b, char a);
  ConvertTable(){};
};

int main() {
  int n, m;
  while (cin >> n, n != 0) {
    // cout << n;
    char b, a;
    ConvertTable *converttable_list = new ConvertTable[n];
    for (int i = 0; i < n; i++) {
      cin >> b >> a;
      // cout << b << "  " << a;
      ConvertTable c = ConvertTable(b, a);
      converttable_list[i] = c;
    }

    cin >> m;
    if (m == 0) {
      continue;
    }
    char *result = new char[m];
    char input_char;
    for (int i = 0; i < m; i++) {
      cin >> input_char;
      for (int p = 0; p < n; p++) {
        if (input_char == converttable_list[i].before) {
          input_char = converttable_list[i].after;
          break;
        }
      }
      result[i] = input_char;
    }
    cout << result;
  }
}

ConvertTable::ConvertTable(char b, char a) {
  this->before = b;
  this->after = a;
}
Problem p00424 (C++) — buggy submission, verdict: Runtime Error

#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int n, m;
  string op;
  while (cin >> n && n) {
    char c1[100], c2[100];
    op = "";
    for (int i = 0; i < n; ++i)
      cin >> c1[i] >> c2[i];
    cin >> m;
    for (int i = 0; i < m; ++i) {
      char c;
      cin >> c;
      for (int j = 0; j < n; ++j) {
        if (c == c1[j]) {
          c = c2[j];
          break;
        }
      }
      op += c;
    }
    cout << op << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int n, m;
  string op;
  while (cin >> n && n) {
    char c1[40], c2[40];
    op = "";
    for (int i = 0; i < n; ++i)
      cin >> c1[i] >> c2[i];
    cin >> m;
    for (int i = 0; i < m; ++i) {
      char c;
      cin >> c;
      for (int j = 0; j < n; ++j) {
        if (c == c1[j]) {
          c = c2[j];
          break;
        }
      }
      op += c;
    }
    cout << op << endl;
  }

  return 0;
}
Problem p00424 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
using namespace std;

int main() {
  int n, m;
  char c[128], f;
  string s;
  while (cin >> n && n) {
    s = "";
    for (int i = 0; i < 128; i++)
      c[i] = i;
    for (int i = 0; i < n; i++) {
      cin >> f;
      cin >> c[f];
    }
    cin >> m;
    for (int i = 0; i < m; i++) {
      cin >> f;
      s += c[f];
    }
    cout << s << endl;
  }
}

Error: 0

Fixed submission:

#include <cstdio>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int n, m;
  while (cin >> n && n) {
    char c1[40], c2[40];
    string op;
    op = "";
    for (int i = 0; i < n; ++i)
      cin >> c1[i] >> c2[i];
    cin >> m;
    for (int i = 0; i < m; ++i) {
      char c;
      cin >> c;
      for (int j = 0; j < n; ++j) {
        if (c == c1[j]) {
          c = c2[j];
          break;
        }
      }
      op += c;
    }
    cout << op << endl;
  }

  return 0;
}
Problem p00424 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>
int main() {
  int n, i, j, m, f;
  char a[256], b[256], x;
  while (1) {
    scanf("%d ", &n);
    if (n == 0) {
      break;
    }

    for (i = 0; i < n; i++) {
      scanf("%c %c ", &a[i], &b[i]);
    }

    scanf("%d ", &m);
    for (i = 0; i < m; i++) {
      scanf("%s", &x);
      f = 0;
      for (j = 0; j < n; j++) {
        if (x == a[j]) {
          printf("%c", b[j]);
          f = 1;
          break;
        }
      }
      if (f == 0) {
        printf("%c", x);
      }
    }
    printf("\\n");
  }
  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>
int main() {
  int n, i, j, m, f;
  char a[256], b[256], x;
  while (1) {
    scanf("%d ", &n);
    if (n == 0) {
      break;
    }

    for (i = 0; i < n; i++) {
      scanf("%c %c ", &a[i], &b[i]);
    }

    scanf("%d ", &m);
    for (i = 0; i < m; i++) {
      scanf("%s", &x);
      f = 0;
      for (j = 0; j < n; j++) {
        if (x == a[j]) {
          printf("%c", b[j]);
          f = 1;
          break;
        }
      }
      if (f == 0) {
        printf("%s", x);
      }
    }
    printf("\\n");
  }
  return 0;
}
Problem p00424 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <map>
using namespace std;

int main() {
  int n;
  char a, b;
  map<char, char> list;
  map<char, char>::iterator it;
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> a >> b;
      list.insert(pair<char, char>(a, b));
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a;
      it = list.find(a);
      if (it == list.end()) {
        cout << a;
      } else {
        cout << (*it).second;
      }
    }
    cout << endl;
    list.clear();
  }
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <map>
using namespace std;

int main() {
  int n;
  char a, b;
  map<char, char> list;
  map<char, char>::iterator it;
  while (1) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a >> b;
      list.insert(pair<char, char>(a, b));
    }
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> a;
      it = list.find(a);
      if (it == list.end()) {
        cout << a;
      } else {
        cout << (*it).second;
      }
    }
    cout << endl;
    list.clear();
  }
  return 0;
}
Problem p00424 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>

using namespace std;

int main() {
  int n, m, i, j;
  char chg[1000000], word[100000];
  while (true) {
    cin >> n;
    if (n == 0)
      break;
    for (i = 0; i < n * 2; i++) {
      cin >> chg[i];
    }
    cin >> m;
    for (i = 0; i < m; i++) {
      cin >> word[i];
      for (j = 0; j < m; j++) {
        if (j % 2 == 0) {
          if (word[i] == chg[j]) {
            word[i] = chg[j + 1];
            break;
          }
        }
      }
    }

    for (i = 0; i < m; i++) {
      cout << word[i];
    }
    cout << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <iostream>

using namespace std;

int main() {
  int n, m, i, j;
  char chg[100], word[10000];
  while (true) {
    cin >> n;
    if (n == 0)
      break;
    for (i = 0; i < n * 2; i++) {
      cin >> chg[i];
    }
    cin >> m;
    for (i = 0; i < m; i++) {
      cin >> word[i];
      for (j = 0; j < m; j++) {
        if (j != 0) {
          if (j % 2 == 0) {
            if (word[i] == chg[j]) {
              word[i] = chg[j + 1];
              break;
            }
          }
        }
      }
    }

    for (i = 0; i < m; i++) {
      cout << word[i];
    }
    cout << endl;
  }
  return 0;
}
Problem p00424 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  int n, m;
  int i, j;
  char c[1000000][2];
  char t[1000000];
  int f;
  while (scanf("%d", &n), n) {
    for (i = 0; i < n; i++) {
      scanf("%s", &c[i][0]);
      scanf("%s", &c[i][1]);
    }

    scanf("%d", &m);
    for (i = 0; i < m; i++) {
      scanf(" %s", &t[i]);
    }

    for (i = 0; i < m; i++) {
      f = -1;
      for (j = 0; j < n; j++) {
        if (t[i] == c[j][0]) {
          f = j;
        }
      }

      if (f != -1) {
        printf("%c", c[f][1]);
      } else if (f == -1) {
        printf("%c", t[i]);
      }
    }
    printf("\\n");
  }
  return 0;
}

Error: -11

Fixed submission:

#include <stdio.h>

int main() {
  int n, m;
  int i, j;
  char c[10000000][2];
  char t[10000000];
  int f;
  while (scanf("%d", &n), n) {
    for (i = 0; i < n; i++) {
      scanf("%s", &c[i][0]);
      scanf("%s", &c[i][1]);
    }

    scanf("%d", &m);
    for (i = 0; i < m; i++) {
      scanf(" %s", &t[i]);
    }

    for (i = 0; i < m; i++) {
      f = -1;
      for (j = 0; j < n; j++) {
        if (t[i] == c[j][0]) {
          f = j;
        }
      }

      if (f != -1) {
        printf("%c", c[f][1]);
      } else if (f == -1) {
        printf("%c", t[i]);
      }
    }
    printf("\\n");
  }
  return 0;
}
Problem p00424 (C++) — buggy submission, verdict: Runtime Error

#include <iostream>
#include <map>
using namespace std;

int main() {
  while (true) {
    int n = 0;
    cin >> n;
    if (n == 0) {
      break;
    }
    map<char, char> convert;
    for (int i = 0; i < n; i++) {
      char key, value;
      cin >> key;
      cin >> value;
      convert[key] = value;
    }
    int m = 0;
    cin >> m;
    for (int i = 0; i < m; i++) {
      char val;
      cin >> val;
      if (convert.find(val) != convert.end()) {
        cout << convert[val];
      } else {
        cout << val;
      }
    }
    cout << '\\n';
  }
  return 0;
}

Error: -11

Fixed submission:

#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
  long int n = 0;
  long int m;
  char word;
  while (true) {
    scanf("%d", &n);
    if (n == 0) {
      break;
    } else {
      char *transition;
      for (int i = 0; i < n * 2; i++) {
        scanf("%c%c", &transition[i], &transition[i + 1]);
      }
      cin >> m;
      for (int i = 0; i < m; i++) {
        scanf("%c", word);
        for (int j = 0; j < n * 2; j += 2) {
          if (word == transition[j]) {
            word = transition[j + 1];
            break;
          }
        }
        printf("%c", word);
      }
      printf("\\n");
    }
  }
  return 0;
}