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

#include <bits/stdc++.h>
using namespace std;
#define ll long long int

ll nCr(ll n, ll r) {
  ll ans = 1;
  for (int i = n; i > n - r; --i) {
    ans = ans * i;
  }
  for (int i = 1; i < r + 1; ++i) {
    ans = ans / i;
  }
  return ans;
}

int main() {
  ll N, M;
  cin >> N >> M;

  cout << nCr(N, 2) + nCr(M, 2) << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int C(ll n, ll r) {
  ll a = 1, b = 1, c = 1;
  for (int i = 1; i <= n; i++) {
    a = a * i;
  }
  for (int i = 1; i <= r; i++) {
    b = b * i;
  }
  for (int i = 1; i <= n - r; i++) {
    c = c * i;
  }
  // cout<<a<<" "<<b<<" "<<c<<endl;
  return a / (b * c);
}

int main() {
  ll N, M;
  cin >> N >> M;

  cout << C(N, 2) + C(M, 2) << endl;
}
Problem p02729 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using P = pair<int, int>;

int main() {

  int n, m;
  cin >> n >> m;
  vector<int> data(n + m);

  if (n == 0 & m == 0) {
    cout << "0" << endl;
    return 0;
  }

  for (int i = 0; i < n; i++) {
    data.at(i) = (i + 1) * 2;
  }

  int index = 0;
  for (int i = n; i < n + m; i++) {
    data.at(i) = index * 2 + 1;
  }

  int counter = 0;
  rep(i, n + m) {
    for (int j = i; j < n + m; j++) {
      if (i != j & (data.at(i) + data.at(j)) % 2 == 0)
        counter++;
    }

    // cout << data.at(i) << endl;
  }

  cout << counter << endl;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using P = pair<int, int>;

int main() {

  int n, m;
  cin >> n >> m;
  vector<int> data(n + m);

  if (n == 0 & m == 0) {
    cout << "0" << endl;
    return 0;
  }

  for (int i = 0; i < n + 1; i++) {
    data.at(i) = (i + 1) * 2;
  }

  int index = 0;
  for (int i = n; i < n + m; i++) {
    data.at(i) = index * 2 + 1;
  }

  int counter = 0;
  rep(i, n + m) {
    for (int j = i; j < n + m; j++) {
      if (i != j & (data.at(i) + data.at(j)) % 2 == 0)
        counter++;
    }

    // cout << data.at(i) << endl;
  }

  cout << counter << endl;
}
Problem p02729 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
// using P = pair<int, int>;

int factorial(int x) {
  if (x == 0)
    return 1;
  else if (x < 0)
    return 0;
  int ans = 1;
  for (int i = 1; i <= x; ++i) {
    ans *= i;
  }
  return ans;
}

ll combination1(int m, int n) { // mCn
  if (m < n)
    swap(m, n);
  ll ans = factorial(m) / (factorial(n) * factorial(m - n));
  return ans;
}

int combination2(int m, int n) {
  if (m < n)
    swap(m, n);
  int mom = 1;
  int son;
  for (int i = m; i > m - n; --i)
    mom *= i;
  son = factorial(n);
  int ans = mom / son;
  return ans;
}

int main() {
  int n, m;
  cin >> n >> m;
  int ans;
  ans = combination2(n + m, 2) - n * m;
  cout << ans << endl;

  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
// using P = pair<int, int>;

ll factorial(int x) {
  if (x == 0)
    return 1;
  else if (x < 0)
    return 0;
  ll ans = 1;
  for (int i = 1; i <= x; ++i) {
    ans *= i;
  }
  return ans;
}

ll combination(int m, int n) { // mCn
  if (m < n)
    swap(m, n);
  ll ans = factorial(m) / (factorial(n) * factorial(m - n));
  return ans;
}

int main() {
  int n, m;
  cin >> n >> m;
  ll ans;
  ans = combination(n + m, 2) - n * m;
  cout << ans << endl;

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

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M;
  cin >> N >> M;
  int a = 1, b = 1, c = 1, d = 1;
  for (int i = 1; i < N + 1; i++)
    a *= i;
  for (int i = N; i > 0; i--) {
    if (N <= 1)
      b = 0;
    else
      b *= i;
  }
  for (int j = 1; j < M + 1; j++)
    c *= j;
  for (int j = M; j > 0; j--) {
    if (M <= 1)
      d = 0;
    else
      d *= j;
  }
  cout << b / a + d / c << endl;
}
Problem p02729 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define Rep(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;

int main() {
  Long a, b;
  cin >> a >> b;
  cout << (a * (a - 1)) / 2 + (b * (b - 1)) / 2 << '\\n';
  return 0;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define Rep(i, a, b) for (int i = a, to = b; i < to; i++)
#define all(v) v.begin(), v.end()
#define SZ(v) (int)v.size()
#define pb push_back
typedef long long Long;

Long memo[105];
Long f(Long x) {
  if (x < 2)
    return 1;
  if (memo[x] != -1)
    return memo[x];
  Long &ans = memo[x] = 0;
  ans = x * f(x - 1);
  return ans;
}
int main() {
  Long a, b;
  cin >> a >> b;
  memset(memo, -1, sizeof memo);
  Long k1 = f(a) / (f(a - 2) * 2);
  memset(memo, -1, sizeof memo);
  Long k2 = f(b) / (f(b - 2) * 2);
  cout << k1 + k2 << '\\n';
  return 0;
}
Problem p02729 (C++) — buggy submission, verdict: Runtime Error


#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;

/*long long int f(long long int n)
{
        if(n==1 || n==0)
        return 1;
        long long int fact=1;
        for(int i=2;i<=n;i++)
        fact*=i;
        return fact;
}*/

long long int C(long long int n) {
  if (n == 1 || n == 0)
    return 0;
  long long int x;
  x = (n * (n - 1)) / 2;
  return x;
}
int main() {
  long long int N, M, c;
  cin >> N >> M;
  c = C(M) + C(N);
  cout << c << "\\n";
  // cout<<C(13)+C(3);
  return 0;
}


Error: 0

Fixed submission:


#include <bits/stdc++.h>
#include <stdio.h>
using namespace std;

long long int f(long long int n) {
  if (n == 1 || n == 0)
    return 1;
  long long int fact = 1;
  for (int i = 2; i <= n; i++)
    fact *= i;
  return fact;
}

long long int C(long long int n) {
  if (n == 1 || n == 0)
    return 0;
  long long int x;
  x = f(n) / (f(n - 2) * 2);
  return x;
}
int main() {
  long long int N, M, c;
  cin >> N >> M;
  c = C(M) + C(N);
  cout << c << "\\n";
  // cout<<C(13)+C(3);
  return 0;
}
Problem p02729 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;

Bint factorial(Bint n) {
  Bint fct = 1;
  for (int i = 2; i <= n; i++) {
    fct *= i;
  }
  return fct;
}

int main() {
  Bint n, m;
  cin >> n >> m;
  n = factorial(n) / (factorial(n - 2) * factorial(2));
  m = factorial(m) / (factorial(m - 2) * factorial(2));
  cout << n + m << endl;
}

Error: -11

Fixed submission:

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

int64_t factorial(int64_t n) {
  if (n == 0)
    return 1;
  else
    return n * factorial(n - 1);
}

int64_t nPr(int64_t n, int64_t r) { return factorial(n) / factorial(n - r); }

int64_t nPr(int64_t n) { return factorial(n) / factorial(n - 2); }

// int64_t nCr(int64_t n, int64_t r) {
//     return nPr(n, r) / factorial(r);
// }

int main() {
  int64_t n, m;
  cin >> n >> m;
  cout << (nPr(n) / 2) + (nPr(m) / 2) << endl;
}
Problem p02729 (C++) — buggy submission, verdict: Runtime Error

// #include <fsociety>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// end of libraries ;
#define INF 999999
#define N 3000003
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
using namespace std;
ll n, m;
int main() {
  fcin;
  cin >> n >> m;
  ll ans1 = n * (n - 1) / 2;
  ll ans2 = m * (m - 1) / 2;
  cout << ans1 + ans2 << endl;
}

Error: 0

Fixed submission:

// #include <fsociety>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// end of libraries ;
#define INF 999999
#define N 3000003
#define F first
#define S second
#define pb push_back
#define ll long long
#define fcin ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
using namespace std;
ll n, m;
ll fact(ll a) {
  ll cur = 1;
  for (ll i = a; i >= 2; i--) {
    cur *= i;
  }
  return cur;
}
int main() {
  fcin;
  cin >> n >> m;
  ll ans1 = fact(n) / (fact(n - 2) * 2);
  ll ans2 = fact(m) / (fact(m - 2) * 2);
  cout << ans1 + ans2 << endl;
}
Problem p02729 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //PBDS
#include <ext/pb_ds/tree_policy.hpp>     //PBDS
#define int long long int
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pi pair<int, int>
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define pb push_back
#define pf push_front
#define F first
#define S second
#define mi map<int, int>
#define PI 3.141592653589
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define f(n) for (int i = 0; i < n; i++)
#define rf(n) for (int i = n - 1; i >= 0; i--)
#define check(x) cerr << #x << " : " << x << endl;
#define ordered_set                                                            \\
  tree<int, null_type, less_equal<int>, rb_tree_tag,                           \\
       tree_order_statistics_node_update>
#define fbo find_by_order // return iterator PBDS
#define ook order_of_key  // return number :)) PBDS
#define baar exit(0)
using namespace __gnu_pbds;
using namespace std;
signed main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  if (n >= 1) {
    ans += (n * (n - 1)) / 2;
  }
  if (m >= 1) {

    ans += (m * (m - 1)) / 2;
  }
  cout << ans;
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //PBDS
#include <ext/pb_ds/tree_policy.hpp>     //PBDS
#define int long long int
#define vi vector<int>
#define vii vector<pair<int, int>>
#define pi pair<int, int>
#define fast                                                                   \\
  ios_base::sync_with_stdio(false);                                            \\
  cin.tie(NULL);                                                               \\
  cout.tie(NULL);
#define pb push_back
#define pf push_front
#define F first
#define S second
#define mi map<int, int>
#define PI 3.141592653589
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define f(n) for (int i = 0; i < n; i++)
#define rf(n) for (int i = n - 1; i >= 0; i--)
#define check(x) cerr << #x << " : " << x << endl;
#define ordered_set                                                            \\
  tree<int, null_type, less_equal<int>, rb_tree_tag,                           \\
       tree_order_statistics_node_update>
#define fbo find_by_order // return iterator PBDS
#define ook order_of_key  // return number :)) PBDS
#define baar exit(0)
using namespace __gnu_pbds;
using namespace std;
int fact(int n) {
  int res = 1;
  for (int i = 2; i <= n; i++)
    res = res * i;
  return res;
}
signed main() {
  int n, m;
  cin >> n >> m;
  int ans = 0;
  if (n >= 2) {
    ans += ((fact(n)) / (fact(n - 2) * 2));
  }

  if (m >= 2) {
    ans += ((fact(m)) / (fact(m - 2) * 2));
  }
  cout << ans;
  return 0;
}
Problem p02729 (C++) — buggy submission, verdict: Runtime Error

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

int min(int a, int b);

// Returns value of Binomial Coefficient C(n, k)
int nCr(int n, int k) {
  int C[k + 1];
  memset(C, 0, sizeof(C));

  C[0] = 1; // nC0 is 1

  for (int i = 1; i <= n; i++) {
    // Compute next row of pascal triangle using
    // the previous row
    for (int j = min(i, k); j > 0; j--)
      C[j] = C[j] + C[j - 1];
  }
  return C[k];
}

// A utility function to return
// minimum of two integers
int min(int a, int b) { return (a < b) ? a : b; }

int main() {
  int n, m;
  cin >> n >> m;

  int x, y;
  x = nCr(n, 2);
  y = nCr(m, 2);

  cout << x + y;

  return 0;
}


Error: WA

Fixed submission:

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

int fact(int n);

int nCr(int n, int r) { return fact(n) / (fact(r) * fact(n - r)); }

// Returns factorial of n
int fact(int n) {
  int res = 1;
  for (int i = 2; i <= n; i++)
    res = res * i;
  return res;
}
int main() {
  int n, m;
  cin >> n >> m;

  int x, y;
  x = nCr(n, 2);
  y = nCr(m, 2);

  cout << x + y;

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

#include "bits/stdc++.h"
using namespace std;
#define test                                                                   \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)
#define fast                                                                   \\
  ios::sync_with_stdio(NULL);                                                  \\
  cin.tie(NULL)
#define mod 1000000007
#define endl "\\n"
#define GCD(m, n) __gcd(m, n)
#define LCM(m, n) m *(n / GCD(m, n))
#define ALL(v) v.begin(), v.end()
#define ll long long
typedef vector<ll> vecll;
typedef vector<int> veci;
typedef vector<char> vecc;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define time 1.0 * clock() / CLOCKS_PER_SEC

int main() {
  fast;

  // test{}
  ll m, n;
  cin >> m >> n;
  cout << ((m * (m - 1)) / 2) + ((n * (n - 1)) / 2);
  return 0;
}


Error: WA

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
#define test                                                                   \\
  int t;                                                                       \\
  cin >> t;                                                                    \\
  while (t--)
#define fast                                                                   \\
  ios::sync_with_stdio(NULL);                                                  \\
  cin.tie(NULL)
#define mod 1000000007
#define endl "\\n"
#define GCD(m, n) __gcd(m, n)
#define LCM(m, n) m *(n / GCD(m, n))
#define ALL(v) v.begin(), v.end()
#define ll long long
typedef vector<ll> vecll;
typedef vector<int> veci;
typedef vector<char> vecc;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define time 1.0 * clock() / CLOCKS_PER_SEC

int main() {
  fast;

#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  // freopen("output.txt","w",stdout);
  cout << "TIME ESCAPED: " << time << endl;
#endif

  // test{}
  ll m, n;
  cin >> m >> n;
  cout << ((m * (m - 1)) / 2) + ((n * (n - 1)) / 2);
  return 0;
}
Problem p02729 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string n;
  string m;

  cin >> n >> m;

  int iN = atoi(n.c_str());
  int iM = atoi(m.c_str());

  int retVal = 0;

  // 偶数から2個とる場合の数
  if (iN > 1) {
    retVal += iN * (iN - 1) / 2;
  }
  // 奇数から2個とる場合の数
  if (iM > 1) {
    retVal += iM * (iM - 1) / 2;
  }

  cout << retVal << endl;

  return 0;
}


Error: 1

Fixed submission:

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

int main() {
  string n;
  string m;

  cin >> n >> m;

  int iN = atoi(n.c_str());
  int iM = atoi(m.c_str());

  int retVal = 0;

  // 偶数から2個とる場合の数
  if (iN > 1) {
    retVal += iN * (iN - 1) / 2;
  }
  // 奇数から2個とる場合の数
  if (iM > 1) {
    retVal += iM * (iM - 1) / 2;
  }

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

#include <bits/stdc++.h>
using namespace std;
typedef long long Long;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  Long n, m;
  cin >> n >> m;
  Long resp = 0;
  resp = (n * (n - 1)) / 2 + ((m) * (m - 1)) / 2, cout << resp;
}

Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define ll long long
using namespace std;

ll fact[1000006], inv[1000006];

void calcFacAndInv(ll n) {
  fact[0] = inv[0] = 1;
  for (ll i = 1; i <= n; i++) {
    fact[i] = (i * fact[i - 1]);
    //  inv[i] = fp(fact[i], mod - 2);
  }
}

int main() {
  calcFacAndInv(110);

  int even, odd;
  cin >> even >> odd;
  int sum = 0;
  //  cout << fact[4] << " " << fact[2] << endl;
  if (even >= 2)
    sum += fact[even] / (fact[2] * fact[even - 2]);
  if (odd >= 2)
    sum += fact[odd] / (fact[2] * fact[odd - 2]);
  cout << sum << endl;

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

#include <stdio.h>

int main() {
  int m, n;
  scanf("%d %d", &m, &n);

  int totalm = (m * (m - 1)) / 2;
  int totaln = (n * (n - 1)) / 2;
  printf("%d\\n", totalm + totaln);

  return 0;
}

Error: 0

Fixed submission:

#include <stdio.h>

int main() {
  int n, m, pass[105], temp1 = 2, temp2 = 1, idx = 0, ans, ctr = 0;

  scanf("%d %d", &n, &m);

  for (int i = 0; i < n; i++) {
    pass[idx++] = temp1;
    temp1 += 2;
  }
  for (int i = 0; i < m; i++) {
    pass[idx++] = temp2;
    temp2 += 2;
  }

  for (int i = 0; i < n + m; i++) {
    for (int j = i; j < n + m; j++) {
      if (i != j) {
        ans = pass[i] + pass[j];
        if (ans % 2 == 0) {
          ++ctr;
        }
      }
    }
  }
  if (ctr == 0) {
    printf("0\\n");
  } else {
    printf("%d\\n", ctr);
  }
}
Problem p02729 (C++) — buggy submission, verdict: Runtime Error

#include <stdio.h>

int main() {
  int N, M;
  scanf("%d %d", &N, &M);

  int x = 0;
  for (int a = 1; a < N; a++) {
    x = x + a;
  }

  int y = 0;
  for (int b = 1; b < M; b++) {
    y = y + b;
  }

  if (N + M >= 2) {
    printf("%d", x + y);
  }

  return 0;
}

Error: -6
*** stack smashing detected ***: terminated


Fixed submission:

#include <stdio.h>

int main() {
  char S[8];
  scanf("%s", &S[8]);
  getchar();
  if (S[2] == S[3] && S[4] == S[5]) {
    printf("Yes\\n");
  } else {
    printf("No\\n");
  }
  return 0;
}
Problem p02729 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n, m;
  cin >> n >> m;
  cout << (n - 1) * n / 2 + (m - 1) * m / 2;

  return 0;
}


Error: 0

Fixed submission:

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

unsigned long long int fact(unsigned long long int n);

unsigned long long int nCr(unsigned long long int n, unsigned long long int r) {
  return fact(n) / (fact(r) * fact(n - r));
}

unsigned long long int fact(unsigned long long int n) {
  unsigned long long int res = 1;
  for (unsigned long long int i = 2; i <= n; i++)
    res = res * i;
  return res;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  unsigned long long int n, m;
  cin >> n >> m;
  unsigned long long int t1, t2;
  if (n <= 1)
    t1 = 0;
  else
    t1 = nCr(n, 2);
  if (m <= 1)
    t2 = 0;
  else
    t2 = nCr(m, 2);

  cout << t1 + t2 << endl;
}
Problem p02729 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int N, M;
  cin >> N >> M;
  cout << N * (N - 1) / 2 + M * (M - 1) / 2;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
long long int kaijo[101];
long long int comb(int n, int k) { return kaijo[n] / kaijo[n - k] / kaijo[k]; }

int main() {
  int N, M;
  cin >> N >> M;
  long long int ans = 0;
  kaijo[0] = 1;
  for (int i = 1; i < 101; i++) {
    kaijo[i] = kaijo[i - 1] * i;
  }
  if (N > 1) {
    ans += comb(N, 2);
  }
  if (M > 1) {
    ans += comb(M, 2);
  }
  cout << ans;
}
Problem p02729 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
long long fun(long long a) { return (a + 1) * a / 2; }
int main() {
  long long n, m;
  cin >> n >> m;
  cout << fun(n - 1) + fun(m - 1);
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
using namespace std;
long long fun(long long a) {
  if (a == 1)
    return 1;
  return a + fun(a - 1);
}
int main() {
  long long n, m;
  cin >> n >> m;
  cout << fun(n - 1) + fun(m - 1);
  return 0;
}
Problem p02729 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fo(i, n) for (ll i = 0; i < n; i++)
#define fok(i, k, n) for (ll i = k; i < n; i++)
#define ci(x) cin >> x
#define ci2(x, y) cin >> x >> y
#define co(x) cout << x << "\\n"
#define co2(x, y) cout << x << " " << y << "\\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define deb1(x) cout << #x << " " << x << endl
#define deb2(x, y) cout << #x << " " << x << " " << #y << " " << y << "\\n"
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
const int mod = 1000000007;
constexpr ll INF = static_cast<ll>(1e18);

ll nc2(int n) { return (n * (n - 1) / 2); }

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a, b;
  ci2(a, b);
  ll ans = 0;
  if (a >= 2) {
    ans += nc2(a);
  }
  if (b >= 2) {
    ans += nc2(b);
  }
  co(ans);
}


Error: -11

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fo(i, n) for (ll i = 0; i < n; i++)
#define fok(i, k, n) for (ll i = k; i < n; i++)
#define ci(x) cin >> x
#define ci2(x, y) cin >> x >> y
#define co(x) cout << x << "\\n"
#define co2(x, y) cout << x << " " << y << "\\n"
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define deb1(x) cout << #x << " " << x << endl
#define deb2(x, y) cout << #x << " " << x << " " << #y << " " << y << "\\n"
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
const int mod = 1000000007;
constexpr ll INF = static_cast<ll>(1e18);

ll facto(int n) {
  if (n == 1) {
    return 1;
  }
  return n * facto(n - 1);
}

ll nc2(int n) { return ((facto(n)) / (2 * facto(n - 2))); }

int main() {
  int a, b;
  ci2(a, b);
  ll ans = 0;
  if (a >= 2) {
    ans += nc2(a);
  }
  if (b >= 2) {
    ans += nc2(b);
  }
  co(ans);
}
Problem p02729 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;
#define ll long long int

/*ll fact(ll n)
{
  ll f=1,i;
  for(i=1;i<=n;i++)
  {
    f=f*i;
  }
  return f;
}*/
// #define FOR(i,0,n) for(int i=0;i<n;i++)
int main() {
  // your code goes here
  /* int t;
   cin>>t;
   while (t--)
   {*/

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ll n, m, z, k;
  cin >> n >> m;
  z = n * (n - 1) / 2;
  k = m * (m - 1) / 2;
  cout << z + k;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>

using namespace std;
#define ll long long int

ll fact(ll n) {
  ll f = 1, i;
  for (i = 1; i <= n; i++) {
    f = f * i;
  }
  return f;
}
// #define FOR(i,0,n) for(int i=0;i<n;i++)
int main() {
  // your code goes here
  /* int t;
   cin>>t;
   while (t--)
   {*/

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  ll n, m, z, k;
  cin >> n >> m;
  z = fact(n) / (2 * fact(n - 2));
  k = fact(m) / (2 * fact(m - 2));
  cout << z + k;
}