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

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

ll powmod(ll x, ll y) {
  ll res = 1;
  for (ll i = 0; i < y; i++) {
    res = res * x % mod;
  }
  return res;
}
int main() {
  ll n;
  cin >> n;
  ll ans = powmod(10, n) - powmod(9, n) - powmod(9, n) + powmod(8, n);
  ans %= mod;
  ans = (ans + mod) % mod;
  cout << ans << "\\n";
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int, int>;
using ll = long long;
using namespace std;
char in[120];
pair<pair<string, int>, int> p[110];

const ll MAX = 510000;
const ll MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k)
    return 0;
  if (n < 0 || k < 0)
    return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

long long modpow(long long a, long long n, long long mod) {
  long long res = 1;
  while (n > 0) {
    if (n & 1)
      res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  // nC2 * 10^(n-2)

  if (n == 1) {
    cout << 0;
    return 0;
  }
  ll sum = modpow(8, n - 2, MOD);

  COMinit();
  sum *= COM(n, 2) * 2 % MOD;
  sum += COM(n, 2) * 2 % MOD;

  cout << sum % MOD % MOD << endl;

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

#include <bits/stdc++.h>
#define ll long long int
using namespace std;
ll mod = 1e9 + 7;
int add(ll x, ll y) { return ((x % mod) + (y % mod)) % mod; }
int minu(ll x, ll y) { return (((x - y) % mod) + mod) % mod; }
int nine(ll n) {
  ll ans = 1;
  while (n > 0) {
    ans = ((ans % mod) * (9 % mod)) % mod;
    n--;
  }
  return ans;
}
int ten(ll n) {
  ll ans = 1;
  while (n > 0) {
    ans = ((ans % mod) * (10 % mod)) % mod;
    n--;
  }
  return ans;
}
int eight(ll n) {
  ll ans = 1;
  while (n > 0) {
    ans = ((ans % mod) * (8 % mod)) % mod;
    n--;
  }
  return ans;
}
int solve(ll n) {
  ll m = ten(n);
  ll z = nine(n);
  ll l = eight(n);
  return minu(add(m, l), add(z, z));
}
int main() {
  ll n;
  cin >> n;
  ll x = solve(n);
  cout << x << endl;
  return 0;
}


Error: TLE

Fixed submission:

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

int power(ll x, ll y) {
  int res = 1;
  x = x % mod;
  if (x == 0)
    return 0;
  while (y > 0) {
    if (y & 1)
      res = (res * x) % mod;
    y = y >> 1;
    x = (x * x) % mod;
  }
  return res;
}

int main() {
  ll n;
  while (1) {
    cin >> n;
    ll x = power(10, n) - power(9, n) - power(9, n) + power(8, n);
    cout << x << endl;
  }
  return 0;
}
Problem p02554 (C++) — buggy submission, verdict: Runtime Error

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

const long long N = 300001, P = 1e9 + 7;

long long power(long long val, long long st, long long p) {
  if (st == 0) {
    return 1;
  }
  long long temp = power(val, st / 2, p);
  temp = temp * temp;
  temp %= p;
  if (st % 2 == 1) {
    temp *= val;
    temp %= p;
  }
  return temp;
}

long long fact[8000000];

void fct(long long n, long long p) {
  fact[0] = 1;
  for (long long i = 1; i <= n; i++) {
    fact[i] = (fact[i - 1] * i) % p;
  }
}

long long c(long long n, long long k, long long p = -1) {
  if (p == -1) {
    long long x = fact[n];
    long long y = (fact[k] * fact[n - k]);
    return (x / y);
  } else {
    long long x = fact[n];
    long long y = (fact[k] * fact[n - k]) % p;
    x = (x * power(y, p - 2, p)) % p;
    return x;
  }
}

int32_t main() {
  long long n;
  cin >> n;
  fct(n + 1, P);
  long long ans = 0;
  for (int i = 2; i <= n; i++) {
    ans += ((((c(n, i, P) * ((power(2ll, i, P) - 2 + P) % P)) % P) *
             power(8ll, n - i, P)) %
            P);
    ans %= P;
  }
  cout << ans << "\\n";
}


Error: 0

Fixed submission:

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

const long long N = 200001, P = 1e9 + 7;

long long power(long long val, long long st, long long p) {
  if (st == 0) {
    return 1;
  }
  long long temp = power(val, st / 2, p);
  temp = temp * temp;
  temp %= p;
  if (st % 2 == 1) {
    temp *= val;
    temp %= p;
  }
  return temp;
}

long long fact[300000];

void fct(long long n, long long p) {
  fact[0] = 1;
  for (long long i = 1; i <= n; i++) {
    fact[i] = (fact[i - 1] * i) % p;
  }
}

long long c(long long n, long long k, long long p = -1) {
  if (p == -1) {
    long long x = fact[n];
    long long y = (fact[k] * fact[n - k]);
    return (x / y);
  } else {
    long long x = fact[n];
    long long y = (fact[k] * fact[n - k]) % p;
    x = (x * power(y, p - 2, p)) % p;
    return x;
  }
}

int32_t main() {
  long long n;
  cin >> n;
  fct(n + 1, P);
  long long ans = 0;
  for (int i = 2; i <= n; i++) {
    ans += ((((c(n, i, P) * ((power(2ll, i, P) - 2 + P) % P)) % P) *
             power(8ll, n - i, P)) %
            P);
    ans %= P;
  }
  cout << ans << "\\n";
}
Problem p02554 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

#define int long long

using namespace std;

const int N = 1e6 + 5;
const int mod = 1e9 + 7;

int n, dp[N][2][2];

void add(int &x, int y) {
  x += y;
  if (x >= mod)
    x -= mod;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        if (dp[i][j][k]) {
          for (int nxt = 0; nxt <= 9; nxt++) {
            add(dp[i + 1][j | (nxt == 0)][k | (nxt == 9)], dp[i][j][k]);
          }
        }
      }
    }
  }

  cout << dp[n][1][1];
  return 0;
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>

#define int long long

using namespace std;

const int N = 2e5 + 5;
const int mod = 1e9 + 7;

int n, dp[N][2][2];

void add(int &x, int y) {
  x += y;
  if (x >= mod)
    x -= mod;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      for (int k = 0; k < 2; k++) {
        if (dp[i][j][k]) {
          for (int nxt = 0; nxt <= 9; nxt++) {
            add(dp[i + 1][j | (nxt == 0)][k | (nxt == 9)], dp[i][j][k]);
          }
        }
      }
    }
  }

  cout << dp[n][1][1];
  return 0;
}
Problem p02554 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
int MOD = 1e9 + 7;

ll mod(ll val, ll m) {
  ll res = val % m;
  if (res < 0)
    res += m;
  return res;
}
ll pow_kai(int a, int n) { // aのn乗を計算します。
  ll x = 1;
  rep(i, n) {
    x *= a;
    x %= MOD;
  }
  return x;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;

  ll Ans = pow_kai(10, N);
  ll temp = pow_kai(9, N);
  Ans -= (temp * 2);

  Ans += pow_kai(8, N);
  Ans = mod(Ans, MOD);
  cout << Ans << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
int MOD = 1e9 + 7;
int factorial(int n) {
  int f = 1;

  while (n > 1) // 階乗を計算します
  {
    f *= n--;
    f %= MOD;
  }
  return f; // 計算結果を戻り値とします
}
int pow_kai(int a, int n) { // aのn乗を計算します。
  ll x = 1;
  while (n > 0) { // 全てのbitが捨てられるまで。
    if (n & 1) {  // 1番右のbitが1のとき。
      x = x * a;
      x %= MOD;
    }
    a = a * a;
    n >>= 1; // bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  ll Ans = 0;

  // 1個ずつ
  for (int i = 2; i <= N; i++) {
    ll numerial = 1;
    ll denominater = 1;
    ll valiablue = 1;
    ll zeroorninecount = pow_kai(2, i) - 2;
    int count = 0;

    valiablue = pow_kai(8, N - i);
    for (int j = N; j > i; j--) {
      count++;
      numerial *= j;
      denominater *= count;
    }
    ll temp = 0;
    temp = numerial * valiablue;
    temp %= MOD;
    temp *= zeroorninecount;
    temp %= MOD;

    temp /= denominater;
    Ans += temp;
    Ans %= MOD;
  }
  cout << Ans << endl;
}
Problem p02554 (C++) — buggy submission, verdict: Runtime Error

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

ll power(ll x, ll y) {
  ll temp;
  if (y == 0)
    return 1;
  temp = power(x, y / 2);
  if (y % 2 == 0)
    return ((temp % mod) * (temp % mod)) % mod;
  else
    return ((((x % mod) * (temp % mod)) % mod) * (temp % mod)) % mod;
}

int main() {
  ll n;
  cin >> n;
  ll ans;
  if (n == 1) {
    cout << 0;
  } else {
    ans = power(10, n) - (2 * power(9, n));
    ans += power(8, n);
    ans = ans % mod;
    if (ans < 0) {
      ans = ans + mod;
    }
    cout << ans;
  }
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
long long fact(long long n) {
  long long i = 1;
  for (long long j = 1; j <= n; j++) {
    i = i * j;
  }
  return i;
}
int main() {
  long long n;
  cin >> n;
  long long res = 0;

  if (n == 1) {
    res += 0;
  } else {
    res += (fact(n) / fact(n - 2));
  }
  cout << res % MOD;
}
Problem p02554 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7, N = 1e6 + 10;
ll n, f[N], po[N];
ll ksm(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
ll c(int n, int m) {
  return po[n] * ksm(po[m], mod - 2) % mod * ksm(po[n - m], mod - 2) % mod;
}
int main() {
  cin >> n;
  if (n == 1) {
    cout << 0;
    return 0;
  }
  ll ans = 0;
  po[0] = 1;
  for (int i = 1; i <= n; i++)
    po[i] = po[i - 1] * i % mod;
  ll x = 4, y = ksm(8, n - 2), p = ksm(8, mod - 2);
  for (int i = 2; i <= n; i++) {
    ans = (ans + c(n, i) * (((x - 2) % mod + mod) % mod) % mod * y % mod) % mod;
    x = x * 2 % mod;
    y = y * p % mod;
  }
  cout << ans;

  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7, N = 1e6 + 10;
ll n, f[N], po[N];
ll ksm(ll a, ll b) {
  ll res = 1;
  while (b) {
    if (b & 1)
      res = res * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return res;
}
ll c(int n, int m) {
  return po[n] * ksm(po[m], mod - 2) % mod * ksm(po[n - m], mod - 2) % mod;
}
int main() {
  cin >> n;
  ll ans = 0;
  po[0] = 1;
  for (int i = 1; i <= n; i++)
    po[i] = po[i - 1] * i % mod;
  ll x = 4, y = ksm(8, n - 2), p = ksm(8, mod - 2);
  for (int i = 2; i <= n; i++) {
    ans = (ans + c(n, i) * (((x - 2) % mod + mod) % mod) % mod * y % mod) % mod;
    x = x * 2 % mod;
    y = y * p % mod;
  }
  cout << ans;

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

#include <iostream>
int main() {
  int N = 0;
  scanf("%d", &N);
  long long abc = 1;
  for (int a = 0; a < N; a++) {
    abc = abc * 10;
    abc = abc % 1000000007;
  }
  long long def = 1;
  for (int a = 0; a < N; a++) {
    def = def * 8;
    def = def % 1000000007;
  }
  long long ghi = 1;
  for (int a = 0; a < N; a++) {
    ghi = ghi * 9;
    ghi = ghi % 1000000007;
  }
  long long A = 0;
  if (ghi >= def)
    A = ghi - def;
  else
    A = 1000000007 + ghi - def;
  A = ((A * 2) + def) % 1000000007;
  if (abc >= A) {
    long long ans = abc - A;
    printf("%lld", ans);
  } else {
    long long ans = (abc + 1000000007) - A;
    printf("%lld", ans);
  }
}


Error: -11

Fixed submission:

#include <iostream>
int main() {
  int N = 0;
  scanf("%d", N);
  long long abc = 1;
  for (int a = 0; a < N; a++) {
    abc *= 10;
    abc %= 1000000007;
  }
  long long def = 1;
  for (int a = 0; a < N; a++) {
    def *= 8;
    def %= 1000000007;
  }
  if (abc >= def) {
    long long ans = abc - def;
    printf("%lld", ans);
  } else {
    long long ans = abc + 1000000007 - def;
    printf("%lld", ans);
  }
}
Problem p02554 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1.0), eps = 1e-8;
const ll mod = 1e9 + 7;
const int inf = 1e18;
const int maxn = 1e6 + 5;
ll POW(ll a, ll b) {
  ll ans = 1;
  b %= (mod - 1);
  while (b) {
    if (b & 1)
      ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
ll inv(ll a) { return POW(a, mod - 2); }
ll fac[maxn], ifac[maxn];
void init() {
  fac[0] = fac[1] = 1;
  for (int i = 2; i < maxn; i++)
    fac[i] = fac[i - 1] * i % mod;
  ifac[maxn - 1] = inv(fac[maxn - 1]);
  for (int i = maxn - 2; i >= 0; i--)
    ifac[i] = ifac[i + 1] * (i + 1) % mod;
}
ll getc(int n, int m) {
  if (n < m || m < 0)
    return 0;
  return fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}
int main() {
  int n;
  cin >> n;
  init();
  if (n == 1)
    cout << 0 << endl;
  else if (n == 2)
    cout << 2 << endl;
  else {
    ll ans = POW(10, n);
    ans = (ans + mod - POW(8, n)) % mod;
    ll res = 1;
    for (int i = 1; i <= n; i++) {
      res = (res + getc(n, i) % mod * POW(8, n - i) % mod) % mod;
    }
    ans = (ans + mod - res * 2 % mod) % mod;
    cout << (ans + 2) % mod << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define ll long long
using namespace std;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1.0), eps = 1e-8;
const ll mod = 1e9 + 7;
const int inf = 1e18;
const int maxn = 5e5 + 5;
ll POW(ll a, ll b) {
  ll ans = 1;
  b %= (mod - 1);
  while (b) {
    if (b & 1)
      ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
ll inv(ll a) { return POW(a, mod - 2); }
ll fac[maxn], ifac[maxn];
void init() {
  fac[0] = fac[1] = 1;
  for (int i = 2; i < maxn; i++)
    fac[i] = fac[i - 1] * i % mod;
  ifac[maxn - 1] = inv(fac[maxn - 1]);
  for (int i = maxn - 2; i >= 0; i--)
    ifac[i] = ifac[i + 1] * (i + 1) % mod;
}
ll getc(int n, int m) {
  if (n < m || m < 0)
    return 0;
  return fac[n] * ifac[m] % mod * ifac[n - m] % mod;
}
int main() {
  int n;
  cin >> n;
  init();
  if (n == 1)
    cout << 0 << endl;
  else if (n == 2)
    cout << 2 << endl;
  else {
    ll ans = POW(10, n);
    ans = (ans + mod - POW(8, n)) % mod;
    ll res = 1;
    for (int i = 1; i <= n; i++) {
      res = (res + getc(n, i) % mod * POW(8, n - i) % mod) % mod;
    }
    ans = (ans + mod - res * 2 % mod) % mod;
    cout << (ans + 2) % mod << endl;
  }
  return 0;
}
Problem p02554 (C++) — buggy submission, verdict: Runtime Error

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
ll mod = 1000000000 + 7;

ll powmod(ll x, ll y) {
  ll res = 1;
  for (int i = 0; i < y; i++) {
    res = (res * x) % mod;
  }
  return res;
}

int main() {
  ll n;
  cin >> n;
  ll ans = powmod(10, n) - 2 * powmod(9, n) + powmod(8, n);
  ans %= mod;
  ans = (ans + mod) % mod;
  cout << ans << endl;
  return 0;
}

Error: 0

Fixed submission:

#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#include <boost/multiprecision/cpp_int.hpp>

namespace mp = boost::multiprecision;

int main() {
  mp::cpp_int n;
  cin >> n;
  mp::cpp_int mod = 1000000000 + 7;
  mp::cpp_int ans = 0;
  mp::cpp_int x = 1;
  mp::cpp_int pow2 = 1;
  for (int i = 1; i <= n; i++) {
    x *= i;
    x %= mod;
    pow2 *= 2;
    pow2 %= mod;
  }
  mp::cpp_int y = 1;
  mp::cpp_int z = x;

  mp::cpp_int pow8 = 1;
  ans += (pow2 - 2);
  ans %= mod;
  mp::cpp_int count = 2;
  for (mp::cpp_int i = 1; i <= n - 1; i++) {
    pow2 /= 2;
    pow2 %= mod;
    pow8 *= 8;
    pow8 %= mod;
    z /= (n - i);
    z %= mod;
    y *= i;
    y %= mod;
    ans += ((pow2 - 2) * pow8 * x / (y * z));
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}
Problem p02554 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll mod(ll n, ll m) {
  ll ans = 1;
  for (ll i = 1; i <= n; i++) {
    ans = (ans * m) % 1000000007;
  }
  return ans;
}
int main() {
  ll n;
  cin >> n;
  ll ans =
      (((mod(n, 10) - 2 * mod(n, 9) + mod(n, 8)) % 1000000007) + 1000000007) %
      1000000007;
  cout << ans << endl;
  return 0;
}


Error: -11

Fixed submission:

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

string getString() {
  string x;
  cin >> x;
  if (x.size() < 3 || x.size() > 99) {
    return getString();
  }
  if (x.size() % 2 == 0) {
    return getString();
  }
  int tama = static_cast<int>(x.size());
  for (int i = 0; i < tama; i++) {
    if (x[i] < 96 || x[i] > 122) {
      return getString();
    }
  }

  return x;
}

bool check_palindrome(string caso) {
  int tama = static_cast<int>(caso.size());
  int ptr1 = 0;
  int ptr2 = tama - 1;
  for (int i = 0; i < tama / 2; i++) {
    if (caso[ptr1] != caso[ptr2]) {
      return false;
    }
    ptr1++;
    ptr2--;
  }

  return true;
}

int main() {
  string caso{getString()};
  int tama = static_cast<int>(caso.size());
  if (check_palindrome(caso)) {
    int first_case{((tama - 1) / 2)};
    string caso1{caso[0]};
    for (int i = 1; i < first_case; i++) {
      caso1 += caso[i];
    }
    if (check_palindrome(caso1)) {
      int second_case{(tama + 3) / 2};
      string caso2{caso[second_case - 1]};
      for (int j = second_case; j < caso.size(); j++) {
        caso2 += caso[j];
      }
      if (check_palindrome(caso2)) {
        cout << "YES";
        return 0;
      }
      cout << "NO";
      return 0;
    }
    cout << "NO";
    return 0;
  } else {
    cout << "NO";
  }

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

#include <iostream>
using namespace std;

#define MOD 1000000007
long long n;

long long fast_pow(long long base, long long pow) {
  if (pow == 0)
    return 1;
  if (pow % 2)
    return (fast_pow(base, pow - 1) * base) % MOD;
  else {
    long long a = fast_pow(base, pow / 2);
    return (a * a) % MOD;
  }
}

signed main() {
  cin.tie(0);
  cout.sync_with_stdio(0);
  cin >> n;
  if (n < 2) {
    cout << "0\\n";
    return 0;
  }
  long long ans = fast_pow(10, n) - 2 * fast_pow(9, n) + fast_pow(8, n);
  while (ans < 0)
    ans += MOD;
  cout << ans << '\\n';
}

Error: WA

Fixed submission:

#include <iostream>
using namespace std;

#define MOD 1000000007
int n;

long long fast_pow(int base, int pow) {
  if (pow == 0)
    return 1;
  if (pow % 2)
    return (fast_pow(base, pow - 1) * base) % MOD;
  else {
    long long a = fast_pow(base, pow / 2);
    return (a * a) % MOD;
  }
}

signed main() {
  cin.tie(0);
  cout.sync_with_stdio(0);
  cin >> n;
  cout << (2 * n * (n - 1) % MOD) * fast_pow(10, n - 2) % MOD << '\\n';
}
Problem p02554 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch,
 * system("pause") or input loop */
const long long INF = 1e9 + 7;
long long pow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = res * a % INF;
    }
    a = a * a % INF;
    b >>= 1;
  }
  return res;
}
int main(int argc, char **argv) {
  long long n;
  cin >> n;
  cout << ((pow(10ll, n) - 2 * pow(9ll, n) + pow(8ll, n)) % INF + INF) % INF;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
using namespace std;
const int mod = 1e9 + 7;
typedef long long ll;
ll KS(ll a, ll b) {
  ll x = 1;
  while (b) {
    if (b & 1) {
      x = x * a % mod;
    }
    a = a * a % mod;
    b >> 1;
  }
  return x;
}
int main() {
  ll n;
  cin >> n;
  ll sum;
  sum = (KS(10, n) - 2 * (KS(9, n)) + KS(8, n)) % mod;
  sum = (sum + mod) % mod;
  cout << sum << endl;
}
Problem p02556 (C++) — buggy submission, verdict: Runtime Error

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

typedef long long LL;

void setIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int SZ = 200005;
int n, m;
int x[SZ], y[SZ];

int main() {
  setIO();
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  vector<int> sums(n);
  for (int i = 0; i < n; i++) {
    sums[i] = x[i] + y[i];
  }
  int r1 = *max_element(sums.begin(), sums.end()) -
           *min_element(sums.begin(), sums.end());

  for (int i = 0; i < n; i++) {
    sums[i] = x[i] - y[i];
  }
  int r2 = *max_element(sums.begin(), sums.end()) -
           *min_element(sums.begin(), sums.end());

  cout << max(r1, r2) << endl;

  return 0;
}

Error: 0

Fixed submission:

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

typedef long long LL;

void setIO() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}

const int SZ = 100005;
int n, m;
int x[SZ], y[SZ];

int main() {
  setIO();
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }
  vector<int> sums(n);
  for (int i = 0; i < n; i++) {
    sums[i] = x[i] + y[i];
  }
  sort(sums.begin(), sums.end());
  int r1 = *max_element(sums.begin(), sums.end()) -
           *min_element(sums.begin(), sums.end());

  for (int i = 0; i < n; i++) {
    sums[i] = x[i] - y[i];
  }
  int r2 = *max_element(sums.begin(), sums.end()) -
           *min_element(sums.begin(), sums.end());

  cout << max(r1, r2) << endl;

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

#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
using ll = long long int;

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++)
    cin >> x[i] >> y[i];
  vector<ll> memo(n);
  for (int i = 0; i < n; i++)
    memo[i] = (ll)x[i] + y[i];
  sort(memo.begin(), memo.end());
  ll ans = abs(memo[n - 1] - memo[0]);
  for (int i = 0; i < n; i++)
    memo[i] = (ll)x[i] - y[i];
  sort(memo.begin(), memo.end());
  if (ans < abs(memo[n - 1] - memo[0]))
    ans = abs(memo[n - 1] - memo[0]);
  cout << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
using P = pair<int, map<int, int>>;

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  for (int i = 0; i < n; i++)
    cin >> x[i] >> y[i];

  map<int, map<int, int>> za;
  for (int i = 0; i < n; i++) {
    if (za.count(x[i]) == 0) {
      map<int, int> za2;
      za[x[i]] = za2;
      za[x[i]][y[i]] = 1;
    } else {
      za[x[i]][y[i]] = 1;
    }
  }

  int ans = 0;
  vector<P> za2;
  for (auto xza : za)
    za2.push_back(make_pair(xza.first, xza.second));

  for (int i = 0; i < za2.size(); i++) {
    int xnum = za2[i].first;
    int ymin = za2[i].second.begin()->first;
    int ymax = za2[i].second.rbegin()->first;
    for (int j = i + 1; j < za2.size(); j++) {
      int jxnum = za2[j].first;
      int jymin = za2[j].second.begin()->first;
      int jymax = za2[j].second.rbegin()->first;
      if (abs(xnum - jxnum) + abs(ymax - jymin) > ans) {
        ans = abs(xnum - jxnum) + abs(ymax - jymin);
      }
      if (abs(xnum - jxnum) + abs(ymin - jymax) > ans) {
        ans = abs(xnum - jxnum) + abs(ymin - jymax);
      }
    }
  }
  cout << ans << endl;
  return 0;
}