prithivMLmods/Coder-Stat huggingface dataset:
Problem p00016 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  double x = 0, y = 0, s = 90, a, b;
  while (scanf("%f,%f", &a, &b), a) {
    x += a * cos(s * M_PI / 180);
    y += a * sin(s * M_PI / 180);
    s -= b;
  }
  cout << (int)x << endl;
  cout << (int)y << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  double x = 0, y = 0, s = 90;
  int a, b;
  while (scanf("%d,%d", &a, &b), a) {
    x += a * cos(s * M_PI / 180);
    y += a * sin(s * M_PI / 180);
    s -= b;
  }
  cout << (int)x << endl;
  cout << (int)y << endl;
}
Problem p00017 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  while (getline(cin, str)) {
    while (1) {
      if (str.find("the") != -1 || str.find("that") != -1 ||
          str.find("this") != -1)
        break;
      for (int i = 0; i < str.size(); i++) {
        if (str[i] == '.' || str[i] == ' ') {
        } else
          str[i]--;
      }
    }
    cout << str << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  while (getline(cin, str)) {
    while (1) {
      if (str.find("the") != -1 || str.find("that") != -1 ||
          str.find("this") != -1)
        break;
      for (int i = 0; i < str.size(); i++) {
        if (str[i] == '.' || str[i] == ' ') {
        } else if (str[i] == 'a')
          str[i] = 'z';
        else
          str[i]--;
      }
    }
    cout << str << endl;
  }
  return 0;
}
Problem p00017 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define PUSH(n, v)                                                             \
  for (int i = 0; i < (n); i++) {                                              \
    int j;                                                                     \
    cin >> j;                                                                  \
    v.push_back(j);                                                            \
  }
#define ALL(v) v.begin(), v.end()

void rot1(string &s) {
  string t = "";
  REP(i, s.size()) {
    if (s[i] > 'a' && s[i] < 'z') {
      if (s[i] == 'a')
        t += "z";
      else
        t += s[i] - 1;
    } else {
      t += s[i];
    }
  }
  s = t;
}

int main() {
  string s;
  while (getline(cin, s)) {
    while (s.find("the") == string::npos && s.find("this") == string::npos &&
           s.find("that") == string::npos) {
      rot1(s);
    }
    cout << s << endl;
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define PUSH(n, v)                                                             \
  for (int i = 0; i < (n); i++) {                                              \
    int j;                                                                     \
    cin >> j;                                                                  \
    v.push_back(j);                                                            \
  }
#define ALL(v) v.begin(), v.end()

void rot1(string &s) {
  string t = "";
  REP(i, s.size()) {
    if (s[i] >= 'a' && s[i] <= 'z') {
      if (s[i] == 'a')
        t += "z";
      else
        t += s[i] - 1;
    } else {
      t += s[i];
    }
  }
  s = t;
}

int main() {
  string s;
  while (getline(cin, s)) {
    while (s.find("the") == string::npos && s.find("this") == string::npos &&
           s.find("that") == string::npos) {
      rot1(s);
    }
    cout << s << endl;
  }
  return 0;
}
Problem p00017 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  string s;
  for (; getline(cin, s);) {
    cin.ignore();
    bool f = 0;
    for (; !f;) {
      for (int i = 0; i < s.size(); i++) {
        if (s[i] >= 'a' && s[i] <= 'z') {
          s[i]--;
          if (s[i] < 'a')
            s[i] = 'z';
        }
      }
      string t[3] = {"the", "this", "that"};
      for (int i = 0; !f && i < 3; i++) {
        for (int j = 0; !f && j + t[i].size() < s.size(); j++) {
          if (s.substr(j, t[i].size()) == t[i]) {
            cout << s << endl;
            f = 1;
          }
        }
      }
    }
  }
}


Fixed submission:
#include <iostream>
using namespace std;
int main() {
  string s;
  for (; getline(cin, s);) {
    bool f = 0;
    for (; !f;) {
      for (int i = 0; i < s.size(); i++) {
        if (s[i] >= 'a' && s[i] <= 'z') {
          s[i]--;
          if (s[i] < 'a')
            s[i] = 'z';
        }
      }
      string t[3] = {"the", "this", "that"};
      for (int i = 0; !f && i < 3; i++) {
        for (int j = 0; !f && j + t[i].size() < s.size(); j++) {
          if (s.substr(j, t[i].size()) == t[i]) {
            cout << s << endl;
            f = 1;
          }
        }
      }
    }
  }
}
Problem p00017 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>

char chshift(char ch) {
  if (ch >= 'a' && ch <= 'z') {
    return (ch - 'a' + 1) % 26 + 'a';
  } else {
    return ch;
  }
}

std::string strshift(std::string s) {
  for (int i = 0; i < s.length(); i++) {
    s[i] = chshift(s[i]);
  }
  return s;
}

bool valid_text_p(std::string str) {
  return str.find("the") != -1 && str.find("that") != -1 &&
         str.find("this") != -1;
}

int main() {
  std::string s;
  while (std::getline(std::cin, s), !std::cin.eof()) {
    for (;; s = strshift(s)) {
      if (valid_text_p(s)) {
        std::cout << s << std::endl;
        break;
      }
    }
  }
  return 0;
}

Fixed submission:
#include <iostream>
#include <string>

char chshift(char ch) {
  if (ch >= 'a' && ch <= 'z') {
    return (ch - 'a' + 1) % 26 + 'a';
  } else {
    return ch;
  }
}

std::string strshift(std::string s) {
  for (int i = 0; i < s.length(); i++) {
    s[i] = chshift(s[i]);
  }
  return s;
}

bool valid_text_p(std::string str) {
  return str.find("the") != -1 || str.find("that") != -1 ||
         str.find("this") != -1;
}

int main() {
  std::string s;
  while (std::getline(std::cin, s), !std::cin.eof()) {
    for (;; s = strshift(s)) {
      if (valid_text_p(s)) {
        std::cout << s << std::endl;
        break;
      }
    }
  }
  return 0;
}
Problem p00017 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;

void f(string &s) {
  for (char &c : s) {
    if ('a' <= c && c <= 'z')
      c = (c + 25) % 26 + 'a';
  }
}

int main() {
  string s;

  while (getline(cin, s)) {
    if (s.empty())
      break;
    while (s.find("the") == string::npos && s.find("this") == string::npos &&
           s.find("that") == string::npos)
      f(s);
    cout << s << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

void f(string &s) {
  for (char &c : s) {
    if ('a' <= c && c <= 'z')
      c = (c - 'a' + 25) % 26 + 'a';
  }
}

int main() {
  string s;

  while (getline(cin, s)) {
    if (s.empty())
      break;
    while (s.find("the") == string::npos && s.find("this") == string::npos &&
           s.find("that") == string::npos)
      f(s);
    cout << s << endl;
  }
}
Problem p00017 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define REP(i, a, b) for ((i) = (a); (i) < (int)(b); (i)++)
#define rep(i, n) REP(i, 0, n)
// BEGIN CUT HERE
#define foreach(itr, c)                                                        \
  for (typeof((c).begin()) itr = (c).begin(); itr != (c).end(); itr++)
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
// END CUT HERE

int main() {
  string str;

  while (getline(cin, str)) {
    int i, N = str.size();

    while (1) {
      rep(i, N) if ('a' <= str[i] && str[i] <= 'z') str[i]--;
      if (str.find("this") != -1 || str.find("the") != -1 ||
          str.find("that") != -1) {
        cout << str << endl;
        break;
      }
    }
  }

  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define REP(i, a, b) for ((i) = (a); (i) < (int)(b); (i)++)
#define rep(i, n) REP(i, 0, n)
// BEGIN CUT HERE
#define foreach(itr, c)                                                        \
  for (typeof((c).begin()) itr = (c).begin(); itr != (c).end(); itr++)
template <class T> inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}
// END CUT HERE

int main() {
  string str;

  while (getline(cin, str)) {
    int i, N = str.size();

    while (1) {
      rep(i, N) if ('a' <= str[i] && str[i] <= 'z') {
        str[i]--;
        if (str[i] < 'a')
          str[i] = 'z';
      }
      if (str.find("this") != -1 || str.find("the") != -1 ||
          str.find("that") != -1) {
        cout << str << endl;
        break;
      }
    }
  }

  return 0;
}
Problem p00017 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <cstring>
#include <iostream>
using namespace std;

int main(void) {
  while (true) {
    string str;
    if (!getline(cin, str))
      break;
    ;
    while (true) {
      for (int i = 0; i < str.size(); i++) {
        if (isalpha(str[i]) && str[i] == 'z') {
          str[i] = 'a';
        } else if (isalpha(str[i])) {
          str[i]++;
        }
      }
      if (str.find("that") != string::npos || str.find("the") != string::npos ||
          str.find("the") != string::npos)
        break;
    }
    cout << str << endl;
  }
  return 0;
}

Fixed submission:
#include <cstring>
#include <iostream>
using namespace std;

int main(void) {
  while (true) {
    string str;
    if (!getline(cin, str))
      break;
    ;
    while (true) {
      for (int i = 0; i < str.size(); i++) {
        if (isalpha(str[i]) && str[i] == 'z') {
          str[i] = 'a';
        } else if (isalpha(str[i])) {
          str[i]++;
        }
      }
      if (str.find("that") != string::npos ||
          str.find("this") != string::npos || str.find("the") != string::npos)
        break;
    }
    cout << str << endl;
  }
  return 0;
}
Problem p00017 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>

bool NotMatch(const std::string &str) {
  return str.find("the") == std::string::npos &&
         str.find("this") == std::string::npos &&
         str.find("that") == std::string::npos;
}

int main() {
  std::string str;
  while (getline(std::cin, str)) {
    while (NotMatch(str)) {
      for (unsigned i = 0; i < str.length(); ++i) {
        if (str[i] == '.' || str[i] == ' ' || str[i] == '\n') {
          continue;
        }

        if (str[i] == 'z') {
          str[i] = 'a';
        } else {
          --str[i];
        }
      }
    }

    std::cout << str << '\n';
  }
}

Fixed submission:
#include <iostream>
#include <string>

bool NotMatch(const std::string &str) {
  return str.find("the") == std::string::npos &&
         str.find("this") == std::string::npos &&
         str.find("that") == std::string::npos;
}

int main() {
  std::string str;
  while (getline(std::cin, str)) {
    while (NotMatch(str)) {
      for (unsigned i = 0; i < str.length(); ++i) {
        if (str[i] == '.' || str[i] == ' ' || str[i] == '\n') {
          continue;
        }

        if (str[i] == 'z') {
          str[i] = 'a';
        } else {
          ++str[i];
        }
      }
    }

    std::cout << str << '\n';
  }
}
Problem p00017 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctype.h>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
using namespace std;

char c[85];

bool search_th() {
  bool f = false;
  for (int i = 0; i < strlen(c); i++) {
    if ((c[i] == 't' && c[i + 1] == 'h' && c[i + 2] == 'e') ||
        (c[i] == 't' && c[i + 1] == 'h' && c[i + 2] == 'i' &&
         c[i + 3] == 's') ||
        (c[i] == 't' && c[i + 1] == 'h' && c[i + 2] == 'a' &&
         c[i + 3] == 't')) {
      f = true;
      break;
    }
  }
  return f;
}

int main() {
  while (cin.getline(c, sizeof(c))) {
    while (1) {
      if (search_th() == true) {
        cout << c << endl;
        break;
      }
      for (int j = 0; j < strlen(c); j++) {
        if (c[j] >= 'a' && c[j] <= 'y')
          c[j]++;
        if (c[j] == 'z')
          c[j] = 'a';
      }
    }
    for (int i = strlen(c); i < 85; i++) {
      c[i] = '\0';
    }
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <ctype.h>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>
using namespace std;

char c[85];

bool search_th() {
  bool f = false;
  for (int i = 0; i < strlen(c); i++) {
    if ((c[i] == 't' && c[i + 1] == 'h' && c[i + 2] == 'e') ||
        (c[i] == 't' && c[i + 1] == 'h' && c[i + 2] == 'i' &&
         c[i + 3] == 's') ||
        (c[i] == 't' && c[i + 1] == 'h' && c[i + 2] == 'a' &&
         c[i + 3] == 't')) {
      f = true;
      break;
    }
  }
  return f;
}

int main() {
  while (cin.getline(c, sizeof(c))) {
    while (1) {
      if (search_th() == true) {
        cout << c << endl;
        break;
      }
      for (int j = 0; j < strlen(c); j++) {
        if (c[j] >= 'a' && c[j] <= 'y')
          c[j]++;
        else if (c[j] == 'z')
          c[j] = 'a';
      }
    }
    for (int i = strlen(c); i < 85; i++) {
      c[i] = '\0';
    }
  }
  return 0;
}
Problem p00017 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s;
  while (getline(cin, s)) {
    string dec = s;
    while (true) {
      if (dec.find("the") != -1 || dec.find("this") != -1 ||
          dec.find("that") != -1) {
        cout << dec << endl;
        break;
      }
      for (int i = 0; i < dec.size(); i++) {
        if ('a' <= dec[i] && dec[i] < 'z')
          dec[i]++;
        if (dec[i] == 'z')
          dec[i] = 'a';
      }
    }
  }

  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s;
  while (getline(cin, s)) {
    string dec = s;
    while (true) {
      if (dec.find("the") != -1 || dec.find("this") != -1 ||
          dec.find("that") != -1) {
        cout << dec << endl;
        break;
      }
      for (int i = 0; i < dec.size(); i++) {
        if ('a' <= dec[i] && dec[i] < 'z')
          dec[i]++;
        else if (dec[i] == 'z')
          dec[i] = 'a';
      }
    }
  }

  return 0;
}
Problem p00017 (C++)

Buggy submission (status: Runtime Error):
#include <cassert>
#include <iostream>
#include <string>
using namespace std;

bool IncludeKeyWords(const string &Sentence) {
  if (Sentence.find("the") <= 80)
    return true;
  if (Sentence.find("this") <= 80)
    return true;
  if (Sentence.find("that") <= 80)
    return true;
  return false;
}

string OneShift(string Sentence) {
  for (int i = 0; i < Sentence.size(); i++) {
    if (97 < Sentence[i] && Sentence[i] < 123) {
      Sentence[i]--;
    } else if (Sentence[i] == 97) {
      Sentence[i] = 123;
    }
  }
  return Sentence;
}

string Decrypt(string Sentence) {
  int RoopCount = 0;
  while (IncludeKeyWords(Sentence) == false) {
    assert(RoopCount < 26);
    Sentence = OneShift(Sentence);
    RoopCount++;
  }
  return Sentence;
}

int main() {
  while (true) {
    string Sentence;
    getline(cin, Sentence);
    if (cin.eof() == true)
      break;
    string DecryptedSentence = Decrypt(Sentence);
    cout << DecryptedSentence << endl;
  }
  return 0;
}

Fixed submission:
#include <cassert>
#include <iostream>
#include <string>
using namespace std;

bool IncludeKeyWords(const string &Sentence) {
  if (Sentence.find("the") <= 80)
    return true;
  if (Sentence.find("this") <= 80)
    return true;
  if (Sentence.find("that") <= 80)
    return true;
  return false;
}

string OneShift(string Sentence) {
  for (int i = 0; i < Sentence.size(); i++) {
    if (97 < Sentence[i] && Sentence[i] < 123) {
      Sentence[i]--;
    } else if (Sentence[i] == 97) {
      Sentence[i] = 122;
    }
  }
  return Sentence;
}

string Decrypt(string Sentence) {
  int RoopCount = 0;
  while (IncludeKeyWords(Sentence) == false) {
    assert(RoopCount < 26);
    Sentence = OneShift(Sentence);
    RoopCount++;
  }
  return Sentence;
}

int main() {
  while (true) {
    string Sentence;
    getline(cin, Sentence);
    if (cin.eof() == true)
      break;
    string DecryptedSentence = Decrypt(Sentence);
    cout << DecryptedSentence << endl;
  }
  return 0;
}
Problem p00017 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>
using namespace std;

int main() {
  string str;
  while (getline(cin, str)) {
    while (str.find("this", 0) == string::npos ||
           str.find("that", 0) == string::npos ||
           str.find("the", 0) == string::npos) {
      for (int i = 0; i < str.size(); ++i) {
        if (str[i] >= 'a' && str[i] <= 'z') {
          if (str[i] != 'z')
            ++str[i];
          else
            str[i] = 'a';
        }
      }
    }
    cout << str << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
#include <string>
using namespace std;

int main() {
  string str;
  while (getline(cin, str)) {
    while (str.find("this", 0) == string::npos &&
           str.find("that", 0) == string::npos &&
           str.find("the", 0) == string::npos) {
      for (int i = 0; i < str.size(); ++i) {
        if (str[i] >= 'a' && str[i] <= 'z') {
          if (str[i] != 'z')
            ++str[i];
          else
            str[i] = 'a';
        }
      }
    }
    cout << str << endl;
  }
  return 0;
}
Problem p00017 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>

using namespace std;

void f(string &s) {
  for (char &c : s) {
    if ('a' <= c && c <= 'z')
      c = (c - 'a' + 25) % 26 + 'a';
  }
}

int main() {
  string s;

  while (getline(cin, s)) {
    if (s == "")
      break;
    while (s.find("the") == string::npos || s.find("this") == string::npos ||
           s.find("that") == string::npos)
      f(s);
    cout << s << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

void f(string &s) {
  for (char &c : s) {
    if ('a' <= c && c <= 'z')
      c = (c - 'a' + 25) % 26 + 'a';
  }
}

int main() {
  string s;

  while (getline(cin, s)) {
    if (s == "")
      break;
    while (s.find("the") == string::npos && s.find("this") == string::npos &&
           s.find("that") == string::npos)
      f(s);
    cout << s << endl;
  }
}
Problem p00018 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int num[5];

  for (int i = 0; i = 4; i++)
    cin >> num[i];

  sort(num, num + 5);

  for (int i = 4; i = 1; i--)
    cout << num[i] << " ";

  cout << num[0] << "\n";
}

Fixed submission:
#include <algorithm>
#include <iostream>
using namespace std;
int main() {
  int in[5];
  for (int i = 0; i < 5; i++)
    cin >> in[i];
  sort(in, in + 5, greater<int>());
  for (int i = 0; i < 4; i++)
    cout << in[i] << " ";
  cout << in[4] << endl;
}
Problem p00018 (Python)

Buggy submission (status: Runtime Error):
print(*sorted(map(int, input().spilt()))[::-1])


Fixed submission:
print(*sorted(map(int, input().split()))[::-1])
Problem p00019 (C++)

Buggy submission (status: Time Limit Exceeded):
#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class t> using table = vector<vector<t>>;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio
///2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual
///studio 2015\projects\programing_contest_c++\debug\b.answer"
int main() {
  int N;
  cin >> N;
  long long int ans = 1;
  while (1) {
    ans *= N;
    N--;
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include "bits/stdc++.h"
#include <unordered_map>
#include <unordered_set>
#pragma warning(disable : 4996)
using namespace std;
using ld = long double;
template <class t> using table = vector<vector<t>>;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio
///2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual
///studio 2015\projects\programing_contest_c++\debug\b.answer"
int main() {
  int N;
  cin >> N;
  long long int ans = 1;
  while (N) {
    ans *= N;
    N--;
  }
  cout << ans << endl;
  return 0;
}
Problem p00019 (C++)

Buggy submission (status: Time Limit Exceeded):

#include <algorithm>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long int n;
  long long result = 1;
  cin >> n;
  while (n > 1) {
    result *= n;
  }
  cout << result << endl;
  // while(1);
  return 0;
}


Fixed submission:

#include <algorithm>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>

using namespace std;

int main() {
  long long int n;
  long long result = 1;
  cin >> n;
  while (n > 1) {
    result *= n;
    n--;
  }
  cout << result << endl;
  // while(1);
  return 0;
}
Problem p00020 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  char cent[100];
  for (int i = 0;; i++) {
    if (scanf("%c", &cent[i]) == EOF) {
      break;
    }
    if (cent[i] >= 97 && cent[i] <= 122) {
      cent[i] -= 32;
    }
  }
  cout << cent;
  return 0;
}

Fixed submission:
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int main() {
  char cent[10000];
  for (int i = 0;; i++) {
    if (scanf("%c", &cent[i]) == EOF) {
      break;
    }
    if (cent[i] >= 97 && cent[i] <= 122) {
      cent[i] -= 32;
    }
  }
  cout << cent;
  return 0;
}
Problem p00020 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>

int main(void) {
  char a;

  while ((a = getchar()) != '\0') {
    if ('a' <= a && a <= 'z')
      a -= 32;
    putchar(a);
  }

  return 0;
}

Fixed submission:
#include <stdio.h>

int main(void) {
  char a;

  while ((a = getchar()) != EOF) {
    if ('a' <= a && a <= 'z')
      a -= 32;
    putchar(a);
  }

  return 0;
}
Problem p00020 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {

  char ch;

  while (1) {

    scanf("%c", &ch);

    if (ch == '\n') {
      cout << endl;
    }

    ch = toupper(ch);

    cout << ch;
  }

  return 0;
}

Fixed submission:
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {

  char ch;

  while (1) {

    scanf("%c", &ch);

    if (ch == '\n') {
      cout << endl;
      break;
    }

    ch = toupper(ch);

    cout << ch;
  }

  return 0;
}
Problem p00020 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
using namespace std;

int main() {
  char str[100];
  scanf("%[a-z .]", str);
  for (int i = 0; str[i]; i++) {
    if ('a' <= str[i] && str[i] <= 'z')
      str[i] += 'A' - 'a';
  }
  printf("%s\n", str);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <functional>
using namespace std;

int main() {
  static char str[100000];
  scanf("%[a-z .]", str);
  for (int i = 0; str[i]; i++) {
    if ('a' <= str[i] && str[i] <= 'z')
      str[i] += 'A' - 'a';
  }
  printf("%s\n", str);
  return 0;
}
Problem p00020 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>
int main() {
  char c;
  while (scanf("%c", &c)) {
    if (c == ' ')
      printf(" ");
    else if (c == '.')
      printf(".");
    else if (c == '\n')
      printf("\n");
    else
      printf("%c", c - 32);
  }
}

Fixed submission:
#include <stdio.h>
int main() {
  for (char c; scanf("%c", &c) != -1;)
    putchar((c > 96) ? (c - 32) : c);
}
Problem p00022 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>

int maxSum(int *a, int n) {
  int sum, max = a[0];
  for (int num = 1; num <= n; ++num) {
    for (int i = 0; i < n - num + 1; ++i) {
      sum = 0;
      for (int j = 0; j < num; ++j) {
        sum += a[i + j];
      }
      if (sum > max) {
        max = sum;
      }
    }
  }
  return max;
}

int main() {
  int n;
  int *a;
  for (;;) {
    std::cin >> n;
    if (n <= 0) {
      break;
    }
    a = new int[n];
    for (int i = 0; i < n; ++i) {
      std::cin >> a[i];
    }
    std::cout << maxSum(a, n) << '\n';
    delete[] a;
  }
  return 0;
}

Fixed submission:
#include <iostream>

int maxSum(int *a, int n) {
  int sum, max = a[0];
  for (int i = 0; i < n; ++i) {
    sum = 0;
    for (int j = i; j < n; ++j) {
      sum += a[j];
      if (sum > max) {
        max = sum;
      }
    }
  }
  return max;
}

int main() {
  int n;
  int *a;
  for (;;) {
    std::cin >> n;
    if (n <= 0) {
      break;
    }
    a = new int[n];
    for (int i = 0; i < n; ++i) {
      std::cin >> a[i];
    }
    std::cout << maxSum(a, n) << '\n';
    delete[] a;
  }
  return 0;
}
Problem p00022 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i, n) for (i = 0; i < n; ++i)
#define each(itr, c)                                                           \
  for (__typeof(c.begin()) itr = c.begin(); itr != c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

int main(int argc, char const *argv[]) {
  int i, j;

  while (1) {
    int n;
    cin >> n;
    if (n == 0)
      break;

    std::vector<long> a(n + 1);
    rep(i, n) scanf(" %ld", &a[i + 1]);

    std::vector<long> sum(n); // a[1]~a[i]??????
    sum[0] = 0;
    for (i = 1; i <= n; ++i)
      sum[i] = sum[i - 1] + a[i];

    long ans = -5000 * 100000 - 1;
    for (i = 1; i <= n; ++i) {
      for (j = i; j <= n; ++j) {
        ans = max(ans, sum[j] - sum[i - 1]);
      }
    }

    std::cout << ans << std::endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define rep(i, n) for (i = 0; i < n; ++i)
#define each(itr, c)                                                           \
  for (__typeof(c.begin()) itr = c.begin(); itr != c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

int main(int argc, char const *argv[]) {
  int i, j;

  while (1) {
    int n;
    cin >> n;
    if (n == 0)
      break;

    std::vector<long> a(n + 1);
    rep(i, n) scanf(" %ld", &a[i + 1]);

    std::vector<long> sum(n + 1); // a[1]~a[i]??????
    sum[0] = 0;
    for (i = 1; i <= n; ++i)
      sum[i] = sum[i - 1] + a[i];

    long ans = -5000 * 100000 - 1;
    for (i = 1; i <= n; ++i) {
      for (j = i; j <= n; ++j) {
        ans = max(ans, sum[j] - sum[i - 1]);
      }
    }

    std::cout << ans << std::endl;
  }
  return 0;
}
Problem p00022 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
int main() {
  int n, a[5000];
  while (scanf("%d", &n) != EOF) {
    int max = -10001;
    scanf("%d", &n);
    if (n == 0)
      break;
    for (int i = 0; i < n; i++)
      scanf("%d", &a[i]);
    for (int i = 0; i < n; i++) {
      int sum = 0;
      for (int j = i; j < n; j++) {
        sum += a[j];
        if (max < sum)
          max = sum;
      }
    }
    printf("%d\n", max);
  }
  return 0;
}

Fixed submission:
#include <stdio.h>
int main() {
  int n, a[5000];
  while (1) {
    int max = -100001;
    scanf("%d", &n);
    if (n == 0)
      break;
    for (int i = 0; i < n; i++)
      scanf("%d", &a[i]);
    for (int i = 0; i < n; i++) {
      int sum = 0;
      for (int j = i; j < n; j++) {
        sum += a[j];
        if (max < sum)
          max = sum;
      }
    }
    printf("%d\n", max);
  }
  return 0;
}
Problem p00022 (C++)

Buggy submission (status: Runtime Error):
#include <climits>
#include <iostream>

using namespace std;

template <typename Type> long long Maximum_Sum_Sequence(Type N[], int size) {
  long long max = LLONG_MIN;

  for (int i = 0; i < size; i++) {
    long long sum = 0;

    for (int j = i; j < size; j++) {
      sum += N[j];

      if (sum > max) {
        max = sum;
      }
    }
  }

  return max;
}

int main() {
  const int DATASETS = 20000;

  int n[DATASETS], a[DATASETS][5000], c = 0;

  while (true) {
    cin >> n[c];

    if (n[c] == 0) {
      break;
    }

    for (int i = 0; i < n[c]; i++) {
      cin >> a[c][i];
    }

    c++;
  }

  for (int i = 0; i < c; i++) {
    cout << Maximum_Sum_Sequence(a[i], n[i]) << endl;
  }

  return 0;
}

Fixed submission:
#include <climits>
#include <iostream>

using namespace std;

template <typename Type> long long Maximum_Sum_Sequence(Type N[], int size) {
  long long max = LLONG_MIN;

  for (int i = 0; i < size; i++) {
    long long sum = 0;

    for (int j = i; j < size; j++) {
      sum += N[j];

      if (sum > max) {
        max = sum;
      }
    }
  }

  return max;
}

int main() {
  const int DATASETS = 100;

  int n[DATASETS], a[DATASETS][5000], c = 0;

  while (true) {
    cin >> n[c];

    if (n[c] == 0) {
      break;
    }

    for (int i = 0; i < n[c]; i++) {
      cin >> a[c][i];
    }

    c++;
  }

  for (int i = 0; i < c; i++) {
    cout << Maximum_Sum_Sequence(a[i], n[i]) << endl;
  }

  return 0;
}
Problem p00022 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef vector<pair<int, int>> vpii;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define foreach(itr, c)                                                        \
  for (__typeof(c.begin()) itr = c.begin(); itr != c.end(); itr++)
#define dbg(x) cout << #x "=" << (x) << endl
#define mp(a, b) make_pair((a), (b))
#define pb(a) push_back(a)
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;
int sum[2500];
int main() {
  int N;
  int ans = 0;
  while (cin >> N && N) {
    int index = 0;
    ans = INT_MIN;
    FOR(i, 1, N + 1) {
      cin >> sum[i];
      sum[i] += sum[i - 1];
    }
    FOR(i, 1, N + 1) {
      FOR(j, i, N + 1) { ans = max(ans, sum[j] - sum[i - 1]); }
    }
    cout << ans << endl;
  }
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef vector<pair<int, int>> vpii;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define foreach(itr, c)                                                        \
  for (__typeof(c.begin()) itr = c.begin(); itr != c.end(); itr++)
#define dbg(x) cout << #x "=" << (x) << endl
#define mp(a, b) make_pair((a), (b))
#define pb(a) push_back(a)
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;
int sum[3000];
int main() {
  int N;
  int ans = 0;
  while (cin >> N && N) {
    int index = 0;
    ans = INT_MIN;
    FOR(i, 1, N + 1) {
      cin >> sum[i];
      sum[i] += sum[i - 1];
    }
    FOR(i, 1, N + 1) {
      FOR(j, i, N + 1) { ans = max(ans, sum[j] - sum[i - 1]); }
    }
    cout << ans << endl;
  }
}
Problem p00022 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef vector<pair<int, int>> vpii;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define foreach(itr, c)                                                        \
  for (__typeof(c.begin()) itr = c.begin(); itr != c.end(); itr++)
#define dbg(x) cout << #x "=" << (x) << endl
#define mp(a, b) make_pair((a), (b))
#define pb(a) push_back(a)
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;
int sum[2000];
int main() {
  int N;
  int ans = 0;
  while (cin >> N && N) {
    int index = 0;
    ans = INT_MIN;
    FOR(i, 1, N + 1) {
      cin >> sum[i];
      sum[i] += sum[i - 1];
    }
    FOR(i, 1, N + 1) {
      FOR(j, i, N + 1) { ans = max(ans, sum[j] - sum[i - 1]); }
    }
    cout << ans << endl;
  }
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef vector<pair<int, int>> vpii;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define foreach(itr, c)                                                        \
  for (__typeof(c.begin()) itr = c.begin(); itr != c.end(); itr++)
#define dbg(x) cout << #x "=" << (x) << endl
#define mp(a, b) make_pair((a), (b))
#define pb(a) push_back(a)
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;
int sum[3000];
int main() {
  int N;
  int ans = 0;
  while (cin >> N && N) {
    int index = 0;
    ans = INT_MIN;
    FOR(i, 1, N + 1) {
      cin >> sum[i];
      sum[i] += sum[i - 1];
    }
    FOR(i, 1, N + 1) {
      FOR(j, i, N + 1) { ans = max(ans, sum[j] - sum[i - 1]); }
    }
    cout << ans << endl;
  }
}
Problem p00022 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <vector>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

// ?¨±?????????????????
#define EPS (1e-10)

int main() {
  int n;
  while (cin >> n && n != 0) {
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    int ret = 0;
    REP(i, a.size()) {
      FOR(j, i, a.size()) {
        int sum = 0;
        FOR(k, i, j + 1) sum += a[k];
        ret = max(ret, sum);
      }
    }
    cout << ret << endl;
  }
  return 0;
}

Fixed submission:
#include <iostream>
#include <vector>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

// ?¨±?????????????????
#define EPS (1e-10)

int main() {
  int n;
  while (cin >> n && n != 0) {
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    vector<int> sum(n);
    sum[0] = a[0];
    FOR(i, 1, n) sum[i] = sum[i - 1] + a[i];
    int ret = sum[0];
    FOR(i, -1, n)
    FOR(j, i + 1, n) ret =
        i > -1 ? max(ret, sum[j] - sum[i]) : max(ret, sum[j]);
    cout << ret << endl;
  }
  return 0;
}
Problem p00022 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000

int main() {

  while (1) {
    int n;
    cin >> n;
    if (!n)
      break;
    vector<int> a(n);
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      if (i > 0)
        a[i] += a[i - 1];
    }
    a[0] = 0;
    int ans = a[1];
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j <= n; j++) {
        ans = max(ans, a[j] - a[i]);
      }
    }

    cout << ans << endl;
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000

int main() {

  while (1) {
    int n;
    cin >> n;
    if (!n)
      break;
    vector<int> a(n + 1);
    for (int i = 1; i <= n; i++) {
      cin >> a[i];
      if (i > 0)
        a[i] += a[i - 1];
    }
    a[0] = 0;
    int ans = a[1];
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j <= n; j++) {
        ans = max(ans, a[j] - a[i]);
      }
    }

    cout << ans << endl;
  }
  return 0;
}
Problem p00022 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <iostream>
#include <stdio.h>

using namespace std;
int main(void) {
  int n, a[1000];
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    for (int i = 1; i <= n; i++)
      cin >> a[i];
    int goukei = 0, led = -10000000;
    for (int i = 1; i <= n; i++) {
      goukei = 0;
      for (int j = i; j <= n; j++) {
        goukei = goukei + a[j];
        led = max(goukei, led);
      }
    }
    cout << led << endl;
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <iostream>
#include <stdio.h>

using namespace std;
int main(void) {
  int n, a[10000];
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    for (int i = 1; i <= n; i++)
      cin >> a[i];
    int goukei = 0, led = -10000000;
    for (int i = 1; i <= n; i++) {
      goukei = 0;
      for (int j = i; j <= n; j++) {
        goukei = goukei + a[j];
        led = max(goukei, led);
      }
    }
    cout << led << endl;
  }
  return 0;
}
Problem p00022 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <math.h>
#include <stdio.h>
using namespace std;

int main() {
  int n, maximum, sum;
  while (true) {
    scanf("%d", &n);
    if (n == 0)
      break;

    int array[n];
    for (int i = 0; i < n; i++)
      scanf("%d", &array[i]);
    maximum = -600000000;
    for (int k = 0; k < n; k++) {   //?§????????????????
      for (int j = k; j < n; j++) { //??????????????????
        sum = 0;
        for (int p = k; p <= j; p++) { //??????????????????
          sum += array[p];
        }
        maximum = (maximum >= sum) ? maximum : sum;
      }
    }
    printf("%d\n", maximum);
  }

  return 0;
}

Fixed submission:
#include <math.h>
#include <stdio.h>
using namespace std;

int main() {
  int n, maximum, sum;
  while (true) {
    scanf("%d", &n);
    if (n == 0)
      break;

    int array[n];
    for (int i = 0; i < n; i++)
      scanf("%d", &array[i]);
    maximum = -600000000;
    for (int k = 0; k < n; k++) { //?§????????????????
      sum = 0;
      for (int p = k; p <= n - 1; p++) { //??????????????????
        sum += array[p];
        maximum = (maximum >= sum) ? maximum : sum;
      }
    }
    printf("%d\n", maximum);
  }

  return 0;
}
Problem p00022 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n;
  while (cin >> n, n) {
    vector<int> vec;
    for (int i = 0; i < n; i++) {
      int a;
      cin >> a;
      vec.push_back(a);
    }

    int max = vec[0] + vec[1];
    for (int i = 0; i < vec.size(); i++) {
      for (int j = i + 1; j < vec.size(); j++) {
        int add = 0;
        for (int k = i; k <= j; k++) {
          add += vec[k];
        }
        if (max < add)
          max = add;
      }
    }

    cout << max << endl;
  }
}

Fixed submission:
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int n;
  while (cin >> n, n) {
    vector<int> vec;
    for (int i = 0; i < n; i++) {
      int a;
      cin >> a;
      vec.push_back(a);
    }

    int max = vec[0] + vec[1];
    for (int i = 0; i < vec.size(); i++) {
      int add = 0;
      for (int j = i; j < vec.size(); j++) {
        add += vec[j];
        if (max < add)
          max = add;
      }
    }

    cout << max << endl;
  }
}
Problem p00022 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define LOOP(i, x, n) for (int i = x; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long

using namespace std;
const int MOD = 1000000007;
const int INF = 9000000009;
const double eps = 1e-10;

signed main() {
  int n;
  while (cin >> n, n) {
    vector<int> a(n);
    REP(i, n) {
      int x;
      cin >> x;
      a[i + 1] = a[i] + x;
    }
    int ans = -INF;
    REP(i, n + 1) LOOP(j, i + 1, n + 1) ans = max(ans, a[j] - a[i]);
    cout << ans << endl;
  }
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define LOOP(i, x, n) for (int i = x; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long

using namespace std;
const int MOD = 1000000007;
const int INF = 9000000009;
const double eps = 1e-10;

signed main() {
  int n;
  while (cin >> n, n) {
    vector<int> a(n + 100);
    REP(i, n) {
      int x;
      cin >> x;
      a[i + 1] = a[i] + x;
    }
    int ans = -INF;
    REP(i, n + 1) LOOP(j, i + 1, n + 1) ans = max(ans, a[j] - a[i]);
    cout << ans << endl;
  }
  return 0;
}
Problem p00022 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define REP(i, x, y) for (int i = (x); i < (y); ++i)
#define MP(a, b) make_pair((a), (b))
#define F_ first
#define S_ second

typedef long long int lli;
typedef pair<int, int> Pi;

const int INF = 100000000;
const long long int INF_ = 1000000000000000000;

int main() {
  int N;
  while (cin >> N && N) {
    vector<int> A(N + 1);
    REP(i, 1, N + 1) cin >> A[i];
    vector<int> s(N);
    REP(i, 1, N + 1) s[i] = s[i - 1] + A[i];
    lli ans = -INF_;
    REP(i, 0, N + 1)
    REP(j, i + 1, N + 1) if (ans < s[j] - s[i]) ans = s[j] - s[i];
    cout << ans << endl;
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define REP(i, x, y) for (int i = (x); i < (y); ++i)
#define MP(a, b) make_pair((a), (b))
#define F_ first
#define S_ second

typedef long long int lli;
typedef pair<int, int> Pi;

const int INF = 100000000;
const long long int INF_ = 1000000000000000000;

int main() {
  int N;
  while (cin >> N && N) {
    vector<int> A(N + 1);
    REP(i, 1, N + 1) cin >> A[i];
    vector<int> s(N + 1);
    REP(i, 1, N + 1) s[i] = s[i - 1] + A[i];
    lli ans = -INF_;
    REP(i, 0, N + 1)
    REP(j, i + 1, N + 1) if (ans < s[j] - s[i]) ans = s[j] - s[i];
    cout << ans << endl;
  }
  return 0;
}
Problem p00022 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;

int main() {
  int n, i, j, k, max, sum;
  while (1) {
    int max = -100000;
    cin >> n;
    int a[n];
    if (n == 0)
      break;
    for (i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (i = 0; i < n; i++) {
      for (j = 1; j <= n - i; j++) {
        sum = 0;
        for (k = i; k < j; k++) {
          sum = sum + a[k];
        }
        if (max < sum)
          max = sum;
      }
    }
    cout << max << endl;
  }
}

Fixed submission:
#include <iostream>
using namespace std;

int main() {
  int n, i, j, k, max, sum;
  while (1) {
    int max = -100000;
    cin >> n;
    int a[n];
    if (n == 0)
      break;
    for (i = 0; i < n; i++) {
      cin >> a[i];
    }
    for (i = 0; i < n; i++) {
      sum = 0;
      for (j = 0; j < n - i; j++) {
        sum = sum + a[i + j];
        if (max < sum)
          max = sum;
      }
    }
    cout << max << endl;
  }
}
Problem p00023 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

struct circle {
  double r, x, y;
};

int main() {
  int n;
  while (scanf("%d", &n) == 1, n) {
    for (int x = 0; x < n; ++x) {
      circle a, b;
      scanf("%lf %lf %lf %lf %lf %lf", &a.x, &a.y, &a.r, &b.x, &b.y, &b.r);
      double d = sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
      if (d > a.r + b.r) {
        cout << 0 << endl;
      } else if (a.r + d < b.r) {
        cout << -2 << endl;
      } else if (b.r + d < a.r) {
        cout << 2 << endl;
      } else {
        cout << 1 << endl;
      }
    }
  }
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

struct circle {
  double r, x, y;
};

int main() {
  int n;
  scanf("%d", &n);
  for (int x = 0; x < n; ++x) {
    circle a, b;
    scanf("%lf %lf %lf %lf %lf %lf", &a.x, &a.y, &a.r, &b.x, &b.y, &b.r);
    double d = sqrt(pow(a.x - b.x, 2) + pow(a.y - b.y, 2));
    if (d > a.r + b.r) {
      cout << 0 << endl;
    } else if (a.r + d < b.r) {
      cout << -2 << endl;
    } else if (b.r + d < a.r) {
      cout << 2 << endl;
    } else {
      cout << 1 << endl;
    }
  }
  return 0;
}
Problem p00024 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <stdio.h>

int main(void) {
  double N;
  double v;
  while (scanf("%lf", &v)) {
    // 1/2*v^2=g*5(N-1)
    //??????????????§?????????????????¨?????????????????????
    N = v * v / (10.0 * 9.8) + 1.0;
    printf("%d\n", (int)(N) + 1);
  }
  return 0;
}

Fixed submission:
#include <stdio.h>

int main(void) {
  double N;
  double v;
  while (scanf("%lf", &v) != EOF) {
    N = v * v / (10.0 * 9.8) + 1.0;
    printf("%d\n", (int)(N) + 1);
  }
  return 0;
}