alexjercan/bugnet huggingface dataset:
Problem p02381 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main(void) {
  long int n, s[1001], i;
  double m, a2, a;
  cin >> n;

  while (n != 0) {
    m = 0;
    a2 = 0;
    for (i = 0; i < n; i++) {
      cin >> s[i];
      m += s[i];
    }
    m = m / n;
    for (i = 0; i < n; i++) {
      a2 += (s[i] - m) * (s[i] - m);
    }
    a2 = a2 / n;
    a = sqrt(a2);

    cout << fixed << setprecision(5) << a << endl;

    cin >> n;
  }
  return 0;
}


Error: WA

Fixed submission:

#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main(void) {
  int n, s[101], i;
  double m, a2, a;
  cin >> n;

  while (n != 0) {
    m = 0;
    a2 = 0;
    for (i = 0; i < n; i++) {
      cin >> s[i];
      m += s[i];
    }
    m = m / n;
    for (i = 0; i < n; i++) {
      a2 += (s[i] - m) * (s[i] - m);
    }
    a2 = a2 / n;
    a = sqrt(a2);

    cout << fixed << setprecision(5) << a << endl;

    cin >> n;
  }
  return 0;
}
Problem p02381 (C++) — buggy submission, verdict: Runtime Error

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define INF 2147483647

using namespace std;

int main() {
  double s[1005], ave, a;
  int n;

  while (1) {
    cin >> n;
    if (n == 0)
      break;
    ave = 0;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      ave += s[i];
    }
    ave /= n;
    a = 0;
    for (int i = 0; i < n; i++) {
      a += pow((s[i] - ave), 2);
    }
    a /= n;
    cout << fixed << setprecision(8) << sqrt(a) << endl;
  }

  return (0);
}

Error: 0

Fixed submission:

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <queue>
#include <string>
#include <utility>
#include <vector>
#define INF 2147483647

using namespace std;

int main() {
  double s[105], ave, a;
  int n;

  while (1) {
    cin >> n;
    if (n == 0)
      break;
    ave = 0;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      ave += s[i];
    }
    ave /= n;
    a = 0;
    for (int i = 0; i < n; i++) {
      a += pow((s[i] - ave), 2);
    }
    a /= n;
    cout << fixed << setprecision(8) << sqrt(a) << endl;
  }

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

#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    double s[1000], a = 0, m = 0;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      m += s[i];
    }
    m /= n;
    for (int i = 0; i < n; i++)
      a += pow(s[i] - m, 2);
    a /= n;
    a = pow(a, 0.5);
    cout << fixed << setprecision(10) << a << endl;
  }
}


Error: WA

Fixed submission:

#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;

int main() {
  while (true) {
    int n;
    cin >> n;
    if (n == 0)
      break;
    double s[100], a = 0, m = 0;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      m += s[i];
    }
    m /= n;
    for (int i = 0; i < n; i++)
      a += pow(s[i] - m, 2);
    a /= n;
    a = pow(a, 0.5);
    cout << fixed << setprecision(10) << a << endl;
  }
}
Problem p02381 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  vector<int> v(1024, 0);
  int i, n, sum;
  double a = 0;

  while (cin >> n, n != 0) {
    for (i = 0; i < n; i++) {
      cin >> v[i];
      sum += v[i];
    }

    double m = (double)sum / (double)n;

    for (i = 0; i < n; i++) {
      a += pow((v[i] - m), 2) / n;
    }
    printf("%.8f\\n", sqrt(a));
    a = 0;
    sum = 0;
    v.erase(v.begin(), v.end());
  }

  return 0;
}

Error: WA

Fixed submission:

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

int main() {
  vector<int> v(100, 0);
  int i, n, sum;
  double a = 0;

  while (cin >> n, n != 0) {
    for (i = 0; i < n; i++) {
      cin >> v[i];
      sum += v[i];
    }

    double m = (double)sum / (double)n;

    for (i = 0; i < n; i++) {
      a += pow((v[i] - m), 2) / n;
    }
    printf("%.8f\\n", sqrt(a));
    a = 0;
    sum = 0;
    v.erase(v.begin(), v.end());
  }

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

#include <cmath>
#include <cstdio>
int pro[1001];

int main() {
  int n, s[1001];
  while (scanf("%d", &n), n) {
    double m = 0, t = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &s[i]);
      m += s[i];
    }
    m /= n;
    for (int i = 0; i < n; i++) {
      t += (s[i] - m) * (s[i] - m);
    }
    t /= n;
    printf("%f\\n", sqrt(t));
  }
  return 0;
}

Error: WA

Fixed submission:

#include <cmath>
#include <cstdio>
int pro[101];

int main() {
  int n, s[101];
  while (scanf("%d", &n), n) {
    double m = 0, t = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &s[i]);
      m += s[i];
    }
    m /= n;
    for (int i = 0; i < n; i++) {
      t += (s[i] - m) * (s[i] - m);
    }
    t /= n;
    printf("%f\\n", sqrt(t));
  }
  return 0;
}
Problem p02381 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main() {
  int n;
  long double ave;      //??????
  long double sum1 = 0; //????¨????
  long double sum2 = 0;
  int s[1000] = {0}; //??????
  long double a;     //?????£

  while (1) {
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      sum1 += s[i];
    }
    ave = sum1 / n;
    for (int i = 0; i < n; i++)
      sum2 += (s[i] - ave) * (s[i] - ave);

    a = sum2 / n;
    cout << fixed << setprecision(6) << sqrt(a) << endl;
    sum1 = 0;
    sum2 = 0;
    ave = 0;
  }
}


Error: TLE

Fixed submission:

#include <cmath>
#include <iomanip>
#include <iostream>
using namespace std;
int main() {
  int n;
  long double ave;      //??????
  long double sum1 = 0; //????¨????
  long double sum2 = 0;
  int s[100] = {0}; //??????
  long double a;    //?????£

  while (1) {
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      sum1 += s[i];
    }
    ave = sum1 / n;
    for (int i = 0; i < n; i++)
      sum2 += (s[i] - ave) * (s[i] - ave);

    a = sum2 / n;
    cout << fixed << setprecision(6) << sqrt(a) << endl;
    sum1 = 0;
    sum2 = 0;
    ave = 0;
  }
}
Problem p02381 (C++) — buggy submission, verdict: Runtime Error

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

int main(void) {
  int n;
  int s[1000] = {};
  double m, a;

  while (true) {
    m = 0;
    a = 0;
    cin >> n;

    if (n == 0)
      break;

    for (int i = 0; i < n; ++i) {
      cin >> s[i];
      m += s[i];
    }
    m /= n;

    for (int i = 0; i < n; ++i) {
      a += (s[i] - m) * (s[i] - m);
    }
    a = sqrt(a / n);

    printf("%lf\\n", a);
  }

  return 0;
}


Error: WA

Fixed submission:

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

int main(void) {
  int n;
  int s[100] = {};
  double m, a;

  while (true) {
    m = 0;
    a = 0;
    cin >> n;

    if (n == 0)
      break;

    for (int i = 0; i < n; ++i) {
      cin >> s[i];
      m += s[i];
    }
    m /= n;

    for (int i = 0; i < n; ++i) {
      a += (s[i] - m) * (s[i] - m);
    }
    a /= n;

    printf("%lf\\n", sqrt(a));
  }

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

#include <cmath>
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  double point, a, n, s[1000], m; // a標準偏差 n学生の数
  while (1) {
    m = 0;
    point = 0;
    cin >> n;
    if (n == 0)
      break;
    a = 0;

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

    m = point / n;

    for (int i = 0; i < n; i++) {
      a += pow(s[i] - m, 2);
    }
    a = sqrt(a / n);
    printf("%f\\n", a);
  }

  return 0;
}


Error: WA

Fixed submission:

#include <cmath>
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  double point, a, n, s[100], m; // a標準偏差 n学生の数
  while (1) {
    m = 0;
    point = 0;
    cin >> n;
    if (n == 0)
      break;
    a = 0;

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

    m = point / n;

    for (int i = 0; i < n; i++) {
      a += pow(s[i] - m, 2);
    }
    a = sqrt(a / n);
    printf("%f\\n", a);
  }

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

#include <iomanip>
#include <iostream>
#include <math.h>

using namespace std;

int main() {
  double n, a[1000], sum, sig;
  while (1) {
    sum = 0;
    sig = 0;
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      sum += a[i];
    }
    for (int i = 0; i < n; i++) {
      sig += pow(a[i] - sum / n, 2);
    }
    cout << fixed << setprecision(6) << sqrt(sig / n) << endl;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <iomanip>
#include <iostream>
#include <math.h>

using namespace std;

int main() {
  double n, a[100], sum, sig;
  while (1) {
    sum = 0;
    sig = 0;
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      sum += a[i];
    }
    for (int i = 0; i < n; i++) {
      sig += pow(a[i] - sum / n, 2);
    }
    cout << fixed << setprecision(6) << sqrt(sig / n) << endl;
  }
  return 0;
}
Problem p02381 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <math.h>
#include <stdio.h>

int main() {

  int s[1001];
  long long n, sum = 0, i;
  double ave = 0, ans2, ans1;

  for (;;) {

    scanf("%lld", &n);

    if (n == 0) {
      break;
    }

    for (i = 1; i <= n; i++) {

      scanf("%d", &s[i]);

      sum += s[i];
    }

    ave = (double)sum / n;

    for (i = 1; i <= n; i++) {

      ans1 += (s[i] - ave) * (s[i] - ave);
    }

    ans2 = sqrt(ans1 / n);

    printf("%lf\\n", ans2);

    sum = 0;
    ave = 0;
    ans1 = 0;
    ans2 = 0;
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <math.h>
#include <stdio.h>

int main() {

  int s[101];
  int n, sum = 0, i;
  double ave = 0, ans2, ans1;

  for (;;) {

    scanf("%d", &n);

    if (n == 0) {
      break;
    }

    for (i = 1; i <= n; i++) {

      scanf("%d", &s[i]);

      sum += s[i];
    }

    ave = (double)sum / n;

    for (i = 1; i <= n; i++) {

      ans1 += (s[i] - ave) * (s[i] - ave);
    }

    ans2 = sqrt(ans1 / n);

    printf("%lf\\n", ans2);

    sum = 0;
    ave = 0;
    ans1 = 0;
    ans2 = 0;
  }
  return 0;
}
Problem p02381 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cctype>
#include <math.h>
#include <stdio.h>
#include <string.h>

#define PI 3.1415926

int main() {
  int n, s[2000];
  double sum = 0;
  double a2 = 0;
  while (1) {

    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (int i = 1; i <= n; i++) {
      scanf("%d", &s[i]);
      sum += s[i];
    }

    sum /= n;

    for (int i = 1; i <= n; i++) {
      a2 += (s[i] - sum) * (s[i] - sum);
    }
    printf("%f\\n", sqrt(a2 / n));
    sum = 0;
    a2 = 0;
  }
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cctype>
#include <math.h>
#include <stdio.h>
#include <string.h>

#define PI 3.1415926

int main() {
  int n, s[101];
  double sum = 0;
  double a2 = 0;
  while (1) {

    scanf("%d", &n);
    if (n == 0) {
      break;
    }
    for (int i = 1; i <= n; i++) {
      scanf("%d", &s[i]);
      sum += s[i];
    }

    sum /= n;

    for (int i = 1; i <= n; i++) {
      a2 += (s[i] - sum) * (s[i] - sum);
    }
    printf("%f\\n", sqrt(a2 / n));
    sum = 0;
    a2 = 0;
  }
  return 0;
}
Problem p02381 (C++) — buggy submission, verdict: Time Limit Exceeded

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

int main(void) {
  // Here your code !
  int n, s[1000];
  double m, A;
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    m = 0;
    A = 0;
    for (int i = 0; i < n; i++) {

      cin >> s[i];
      m = m + s[i];
    }
    m = m / n;

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

      A = A + pow((s[i] - m), 2);
    }
    A = A / n;
    A = sqrt(A);
    printf("%f\\n", A);
  }
}

Error: TLE

Fixed submission:

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

int main(void) {
  // Here your code !
  int n, s[100];
  double m, A;
  while (1) {
    cin >> n;
    if (n == 0)
      break;
    m = 0;
    A = 0;
    for (int i = 0; i < n; i++) {

      cin >> s[i];
      m = m + s[i];
    }
    m = m / n;

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

      A = A + pow((s[i] - m), 2);
    }
    A = A / n;
    A = sqrt(A);
    printf("%f\\n", A);
  }
}
Problem p02381 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int n, S[1000] = {};
  while (true) {
    int count = 0;
    double m, sigma = 0, a;
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> S[i];
      count += S[i];
    }
    m = 1.0 * count / n;
    for (int i = 0; i < n; i++) {
      sigma += (S[i] - m) * (S[i] - m);
    }
    a = sqrt(sigma / n);
    printf("%f\\n", a);
  }
  return 0;
}


Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
  int n, s, count = 0;
  double S[100], m, sigma = 0, a;
  cin >> n;
  while (true) {
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> s;
      S[i] = s;
      count += s;
    }
    m = count / n;
    for (int i = 0; i < n; i++) {
      sigma += (S[i] - m) * (S[i] - m);
    }
    a = sqrt(sigma / n);
    printf("%f\\n", a);
  }
  return 0;
}
Problem p02381 (C++) — buggy submission, verdict: Runtime Error

#include <math.h>
#include <stdio.h>
#include <string.h>
#define rep(i, a, n) for (int i = a; i < n; i++)

int main() {
  int n;
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;
    double s[1001] = {0}, ave = 0, a = 0;
    rep(i, 0, n) {
      scanf("%lf", &s[i]);
      ave += s[i];
    }
    ave /= (double)n;
    rep(i, 0, n) { a += pow(s[i] - ave, 2); }
    a /= (double)n;
    a = sqrt(a);
    printf("%.10lf\\n", a);
  }
  return 0;
}

Error: WA

Fixed submission:

#include <math.h>
#include <stdio.h>
#include <string.h>
#define rep(i, a, n) for (int i = a; i < n; i++)

int main() {
  int n;
  while (1) {
    scanf("%d", &n);
    if (n == 0)
      break;
    double s[101] = {0}, ave = 0, a = 0;
    rep(i, 0, n) {
      scanf("%lf", &s[i]);
      ave += s[i];
    }
    ave /= (double)n;
    rep(i, 0, n) { a += pow(s[i] - ave, 2); }
    a /= (double)n;
    a = sqrt(a);
    printf("%.10lf\\n", a);
  }
  return 0;
}
Problem p02381 (C++) — buggy submission, verdict: Runtime Error

#include <math.h>
#include <stdio.h>

int main() {
  while (1) {
    int n;
    scanf("%d", &n);
    if (n == 0)
      break;
    int i, score[1001];
    for (i = 0; i < n; i++) {
      scanf("%d", &score[i]);
    }
    int alltotal = 0;
    for (i = 0; i < n; i++) {
      alltotal += score[i];
    }
    double avrage = 1.0 * alltotal / n;
    double bload[1001];
    for (i = 0; i < n; i++) {
      bload[i] = powl(score[i] - avrage, 2);
    }
    double allbload = 0.0;
    for (i = 0; i < n; i++) {
      allbload += bload[i];
    }
    double bunsan = allbload / n;
    printf("%lf\\n", sqrt(bunsan));
  }
  return 0;
}

Error: -11

Fixed submission:

#include <math.h>
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  int i, score[1001];
  for (i = 0; i < n; i++) {
    scanf("%d", score[i]);
  }
  int alltotal = 0;
  for (i = 0; i < n; i++) {
    alltotal += score[i];
  }
  double avrage = 1.0 * alltotal / n;
  double bload[1001];
  for (i = 0; i < n; i++) {
    bload[i] = powl(score[i] - avrage, 2);
  }
  double allbload = 0.0;
  for (i = 0; i < n; i++) {
    allbload += bload[i];
  }
  double bunsan = allbload / n;
  printf("%lf\\n", sqrt(bunsan));
}
Problem p02381 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, d, i, j, k;

  float hudai, hudai2;
  int x[1002];

  while (1)

  {
    double sum = 0;
    double avg = 0;
    double total = 0;
    double devt = 0;
    cin >> a;
    if (a == 0) {
      break;
    }

    for (i = 0; i < a; i++) {
      cin >> x[i];
      sum = sum + x[i];
    }
    hudai2 = a * 1.0;
    avg = (sum / a);

    for (i = 0; i < a; i++) {
      total = total + ((x[i] - avg) * (x[i] - avg));
    }
    hudai = total / a;
    devt = sqrt(hudai);

    printf("%.8f\\n", devt);
  }
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <string.h>
using namespace std;
int main() {
  int n;
  while (scanf("%d", &n) != EOF) {
    if (n == 0)
      break;
    double a[100];
    double m = 0;
    for (int i = 0; i < n; i++) {
      scanf("%lf", &a[i]);
      m = m + a[i];
    }
    m = m / n;
    double b = 0;
    for (int i = 0; i < n; i++) {
      b = b + (a[i] - m) * (a[i] - m);
    }
    printf("%.8lf\\n", sqrt(b / n));
  }
}
Problem p02381 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int n, s[1001];
  while (1) {
    double a = 0;
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      a += s[i];
    }
    double b = a / n;
    double c = 0;
    for (int i = 0; i < n; i++) {
      c += pow(b - s[i], 2.0);
    }
    double d = 0;
    d = sqrt(c / n);
    printf("%.8f\\n", d);
  }
  return 0;
}

Error: 0

Fixed submission:

#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
  int n, s[100];
  while (1) {
    double a = 0;
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> s[i];
      a += s[i];
    }
    double b = a / n;
    double c = 0;
    for (int i = 0; i < n; i++) {
      c += pow(b - s[i], 2.0);
    }
    double d = 0;
    d = sqrt(c / n);
    printf("%.8f\\n", d);
  }
  return 0;
}
Problem p02381 (C++) — buggy submission, verdict: Runtime Error

// class point	の練習（クラスの高度な実装）
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <vector>

typedef long long llong;
using namespace std;

int main() {
  int n;
  int score[1100];
  double mean, var;
  while (1) {
    scanf("%d", &n);
    if (!n)
      break;
    mean = 0;
    var = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &score[i]);
      mean += (double)score[i];
    }
    mean /= n;
    for (int i = 0; i < n; i++) {
      var += ((double)score[i] - mean) * ((double)score[i] - mean);
    }
    var /= n;
    cout << fixed << setprecision(10) << sqrt(var) << endl;
  }
  return 0;
}


Error: WA

Fixed submission:

// class point	の練習（クラスの高度な実装）
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <vector>

typedef long long llong;
using namespace std;

int main() {
  int n;
  int score[150];
  double mean, var;
  while (1) {
    scanf("%d", &n);
    if (!n)
      break;
    mean = 0;
    var = 0;
    for (int i = 0; i < n; i++) {
      scanf("%d", &score[i]);
      mean += (double)score[i];
    }
    mean /= n;
    for (int i = 0; i < n; i++) {
      var += ((double)score[i] - mean) * ((double)score[i] - mean);
    }
    var /= n;
    cout << fixed << setprecision(10) << sqrt(var) << endl;
  }
  return 0;
}
Problem p02381 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int n;
  const int max_n = 1000;
  double a[max_n];
  while (cin >> n, n) {
    double s = 0.0;
    double sum = 0.0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      sum += a[i];
    }
    double m = sum / n;
    for (int i = 0; i < n; i++) {
      s += pow(a[i] - m, 2);
    }
    s /= n;
    s = sqrt(s);
    printf("%.6f\\n", s);
  }
  return 0;
}

Error: WA

Fixed submission:

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

int main() {
  int n;
  const int max_n = 100;
  double a[max_n];
  while (cin >> n, n) {
    double s = 0.0;
    double sum = 0.0;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      sum += a[i];
    }
    double m = sum / n;
    for (int i = 0; i < n; i++) {
      s += pow(a[i] - m, 2);
    }
    s /= n;
    s = sqrt(s);
    printf("%.6f\\n", s);
  }
  return 0;
}
Problem p02381 (C++) — buggy submission, verdict: Runtime Error

#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;
typedef long long ll;

int main() {
  int n;
  int score[1000];
  double stdev;

  double a;

  while (true) {
    double sum1 = 0, sum2 = 0, ave = 0;

    cin >> n;
    if (n == 0) {
      break;
    } else {
      for (int i = 0; i < n; ++i) {
        cin >> score[i];
        sum1 = sum1 + score[i];
      }
      ave = sum1 / n;
      for (int i = 0; i < n; ++i) {
        a = score[i] - ave;
        a = a * a;
        sum2 = sum2 + a;
      }
      stdev = sum2 / n;
      stdev = sqrt(stdev);
    }
    printf("%.15lf\\n", stdev);
  }
}

Error: WA

Fixed submission:

#include <cmath>
#include <cstdio>
#include <iostream>

using namespace std;
typedef long long ll;

int main() {
  int n;
  int score[100];
  double stdev;

  double a;

  while (true) {
    double sum1 = 0, sum2 = 0, ave = 0;

    cin >> n;
    if (n == 0) {
      break;
    } else {
      for (int i = 0; i < n; ++i) {
        cin >> score[i];
        sum1 = sum1 + score[i];
      }
      ave = sum1 / n;
      for (int i = 0; i < n; ++i) {
        a = score[i] - ave;
        a = a * a;
        sum2 = sum2 + a;
      }
      stdev = sum2 / n;
      stdev = sqrt(stdev);
    }
    printf("%.15lf\\n", stdev);
  }
}
Problem p02381 (C++) — buggy submission, verdict: Runtime Error

#include <iomanip>
#include <iostream>
#include <math.h>

#define PI 3.14159265

double standard_deviation(double *s, double m, double n) {
  double sum_ = 0;
  for (int i = 0; i < n; i++) {
    sum_ += pow((s[i] - m), 2);
  }
  return sum_ / n;
}

int main() {
  double n;
  double s[1000] = {0};
  double m = 0;

  while (true) {
    m = 0;
    std::cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      std::cin >> s[i];
      m += s[i];
    }
    m /= n;

    std::cout << std::fixed << std::setprecision(8)
              << sqrt(standard_deviation(s, m, n)) << std::endl;
  }

  return 0;
}


Error: 0

Fixed submission:

#include <iomanip>
#include <iostream>
#include <math.h>

#define PI 3.14159265

double standard_deviation(double *s, double m, double n) {
  double sum_ = 0;
  for (int i = 0; i < n; i++) {
    sum_ += pow((s[i] - m), 2);
  }
  return sum_ / n;
}

int main() {
  double n;
  double s[100] = {0};
  double m = 0;

  while (true) {
    m = 0;
    std::cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      std::cin >> s[i];
      m += s[i];
    }
    m /= n;

    std::cout << std::fixed << std::setprecision(8)
              << sqrt(standard_deviation(s, m, n)) << std::endl;
  }

  return 0;
}