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

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <array>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long int ll;

vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i * i != n)
        res.push_back(n / i);
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}

ll GetDigit(ll num) { return std::to_string(num).length(); }

int main(int argc, char const *argv[]) {
  ll n;
  cin >> n;

  vector<ll> v = divisor(n);

  ll _min = 100000;
  for (auto e : v) {
    ll temp = max(GetDigit(e), GetDigit(n / e));

    if (temp < _min) {
      _min = temp;
    }
  }

  cout << _min << endl;
}


Fixed submission:
#include <algorithm>
#include <array>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long int ll;

vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i * i != n)
        res.push_back(n / i);
    }
  }
  return res;
}

ll GetDigit(ll num) { return std::to_string(num).length(); }

int main(int argc, char const *argv[]) {
  ll n;
  cin >> n;

  vector<ll> v = divisor(n);

  ll _min = 100000;
  for (auto e : v) {
    ll temp = max(GetDigit(e), GetDigit(n / e));

    if (temp < _min) {
      _min = temp;
    }
  }

  cout << _min << endl;
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for (ll i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for (auto i : mp)
#define FOR(i, m, n) for (int i = m; i < n; i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll N;
int MAX_N = 10;

// 1234 -> 4 3 2 1
vector<int> each_digit(ll S) {
  int n_len = 0, n_dig[MAX_N];
  while (S > 0) {
    n_dig[n_len++] = S % 10;
    S /= 10;
  }
  vector<int> ret(n_dig, n_dig + n_len);
  return ret;
}

void solve() {
  ll ans = INF;
  int n_dig = each_digit(N).size();
  REPONE(i, pow(10, 9)) {
    if (N % i == 0)
      ans = min(ans, max(i, N / i));
  }
  vector<int> v = each_digit(ans);
  cout << v.size() << endl;
}

int main() {
  cin >> N;
  solve();
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <unordered_map>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for (ll i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for (auto i : mp)
#define FOR(i, m, n) for (int i = m; i < n; i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll N;
int MAX_N = 10;

// 1234 -> 4 3 2 1
vector<int> each_digit(ll S) {
  int n_len = 0, n_dig[MAX_N];
  while (S > 0) {
    n_dig[n_len++] = S % 10;
    S /= 10;
  }
  vector<int> ret(n_dig, n_dig + n_len);
  return ret;
}

void solve() {
  ll ans = INF;
  int n_dig = each_digit(N).size();
  REPONE(i, pow(10, 6)) {
    if (N % i == 0)
      ans = min(ans, max(i, N / i));
  }
  vector<int> v = each_digit(ans);
  cout << v.size() << endl;
}

int main() {
  cin >> N;
  solve();
  return 0;
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for (int i = m; i < (int)(n); i++)
typedef pair<long long, long long> pint;
typedef long long ll;
const int inf = 1 << 29;
const ll longinf = 1LL << 60;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int calc(ll x) {
  int a = 0;
  while (x >= 1) {
    a++;
    x /= 10;
  }
  return a;
}

int main() {
  ll n;
  cin >> n;
  int ans = inf;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0)
      ans = min(ans, calc(n / i));
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for (int i = m; i < (int)(n); i++)
typedef pair<long long, long long> pint;
typedef long long ll;
const int inf = 1 << 29;
const ll longinf = 1LL << 60;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int calc(ll x) {
  int a = 0;
  while (x >= 1) {
    a++;
    x /= 10;
  }
  return a;
}

int main() {
  ll n;
  cin >> n;
  int ans = inf;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0)
      ans = min(ans, calc(n / i));
  }
  cout << ans << endl;
  return 0;
}
Problem p03775 (C++)

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

int keta(long long n) { return n < 10 ? 1 : 1 + keta(n / 10); }

int main() {
  long long N;
  cin >> N;
  long long a;
  for (long long i = 1; i * i < N; i++) {
    if (N % i == 0)
      a = i;
  }
  long long b = N / a;
  cout << keta(b) << endl;
}


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

int keta(long long n) { return n < 10 ? 1 : 1 + keta(n / 10); }

int main() {
  long long N;
  cin >> N;
  long long a = 1;
  for (long long i = 1; i * i <= N; i++) {
    if (N % i == 0)
      a = i;
  }
  long long b = N / a;
  cout << keta(b) << endl;
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int f(ll n) {
  int sum = 0;
  while (n) {
    n /= 10;
    sum++;
  }
  return sum;
}

int main() {
  ll n;
  cin >> n;
  int ans = 1e9;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ans = min(ans, f(n / i));
    }
  }
  cout << ans << endl;
  return 0;
}


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

int f(ll n) {
  int sum = 0;
  while (n) {
    n /= 10;
    sum++;
  }
  return sum;
}

int main() {
  ll n;
  cin >> n;
  int ans = 1e9;
  for (int i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      ans = min(ans, f(n / i));
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
typedef long long lint;
using namespace std;

lint gcd(lint x, lint y) {
  if (x == 0) {
    return y;
  } else {
    return gcd(y % x, x);
  }
}

lint lcm(lint x, lint y) { return x / gcd(x, y) * y; }

lint C(lint n, lint k) {
  if (n == k) {
    return 1;
  } else if (n < k) {
    return 0;
  } else if (k == 0) {
    return 1;
  } else if (k == 1) {
    return n;
  } else
    return C(n - 1, k - 1) + C(n - 1, k);
}

lint P(lint n, lint k) {
  if (k == 1) {
    return n;
  }
  return (n * (P(n - 1, k - 1) % 1000000007) % 1000000007);
}

int main() {
  lint n;
  cin >> n;

  lint ans = 10;
  for (lint i = 1; i * i <= n; i++) {
    for (lint j = i; i * j <= n; j++) {
      if (i * j == n) {
        stringstream ss;
        ss << j;
        ans = min(ans, (lint)ss.str().size());
      }
    }
  }

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


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

lint gcd(lint x, lint y) {
  if (x == 0) {
    return y;
  } else {
    return gcd(y % x, x);
  }
}

lint lcm(lint x, lint y) { return x / gcd(x, y) * y; }

lint C(lint n, lint k) {
  if (n == k) {
    return 1;
  } else if (n < k) {
    return 0;
  } else if (k == 0) {
    return 1;
  } else if (k == 1) {
    return n;
  } else
    return C(n - 1, k - 1) + C(n - 1, k);
}

lint P(lint n, lint k) {
  if (k == 1) {
    return n;
  }
  return (n * (P(n - 1, k - 1) % 1000000007) % 1000000007);
}

int main() {
  lint n;
  cin >> n;

  lint ans = 10;
  for (lint i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      stringstream ss;
      ss << n / i;
      ans = min(ans, (lint)ss.str().size());
    }
  }

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

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

int main() {
  long long N;
  cin >> N;
  long long m = 0;
  for (long long i = 1; i++; i * i <= N) {
    if (N % i == 0)
      m = i;
  }
  long long r = N / m;
  int res = 0;
  while (r > 0) {
    r /= 10;
    res++;
  }
  cout << res << endl;
}


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

int main() {
  long long N;
  cin >> N;
  long long m = 0;
  for (long long i = 1; i * i <= N; i++) {
    if (N % i == 0)
      m = i;
  }
  long long r = N / m;
  int res = 0;
  while (r > 0) {
    r /= 10;
    res++;
  }
  cout << res << endl;
}
Problem p03775 (C++)

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

signed main() {
  int N;
  cin >> N;
  int res;
  for (int i = 1; i * i < N; i++) {
    if (N % i == 0)
      res = i;
  }
  int res2 = N / res;
  int ans = 0;
  while (res2 != 0) {
    res2 /= 10;
    ans++;
  }
  cout << ans << endl;
}


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

signed main() {
  int N;
  cin >> N;
  int res;
  for (int i = 1; i * i <= N; i++) {
    if (N % i == 0)
      res = i;
  }
  int res2 = N / res;
  int ans = 0;
  while (res2 != 0) {
    res2 /= 10;
    ans++;
  }
  cout << ans << endl;
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

long long f(long long i, long long j) {
  long long ans;
  string s1, s2;

  s1 = to_string(i);
  s2 = to_string(j);
  if (s1.size() >= s2.size())
    ans = s1.size();
  else
    ans = s2.size();

  //    cout << ans <<"=" << s1 << ":" << s2 << endl;
  return (ans);
}

int main() {
  long long n, m;
  long long ans;

  cin >> n;

  ans = 100000000000;
  for (long i = 1; i <= n; ++i) {
    m = n / i;
    if (m <= 0)
      break;
    if (i * m == n) {
      long j = f(m, i);
      if (ans > j) {
        ans = j;
      }
    }
  }

  cout << ans << endl;
}


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

long long f(long long i, long long j) {
  long long ans;
  string s1, s2;

  s1 = to_string(i);
  s2 = to_string(j);
  if (s1.size() >= s2.size())
    ans = s1.size();
  else
    ans = s2.size();

  //    cout << ans <<"=" << s1 << ":" << s2 << endl;
  return (ans);
}

int main() {
  long long n, m;
  long long ans;

  cin >> n;

  ans = 100000000000;
  for (long i = 1; i <= n; ++i) {
    m = n / i;
    if (m <= 0)
      break;
    if (m < i)
      break;
    if (i * m == n) {
      long j = f(m, i);
      if (ans > j) {
        ans = j;
      }
    }
  }

  cout << ans << endl;
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) a.begin(), a.end()

int F(ll a, ll b) {
  int dig_a = log10(a) + 1;
  int dig_b = log10(b) + 1;
  return max(dig_a, dig_b);
}

int main() {
  ll n;
  cin >> n;
  int sq = sqrt(n);
  int i = sq;
  while (n % i > 0) {
    i++;
  }
  cout << F(i, n / i) << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef long long ll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<char>> vvc;
typedef vector<vector<bool>> vvb;
typedef vector<vector<int>> vvi;

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(a) a.begin(), a.end()

int F(ll a, ll b) {
  int dig_a = log10(a) + 1;
  int dig_b = log10(b) + 1;
  return max(dig_a, dig_b);
}

int main() {
  ll n;
  cin >> n;
  int sq = sqrt(n);
  int i = sq;
  while (n % i > 0) {
    i--;
  }
  cout << F(i, n / i) << endl;
  return 0;
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define itrfor(itr, A) for (auto itr = A.begin(); itr != A.end(); itr++)
typedef long long llong;
char moji[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
char moji2[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
                  'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
                  'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
char moji3[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
#define Sort(a) sort(a.begin(), a.end());
#define Reverse(a) reverse(a.begin(), a.end());

int main() {
  llong n;
  cin >> n;
  int ans = 1;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0)
      ans = i;
  }
  ans = n / ans;
  int keta = 0;
  llong tmp = 1;
  while (1) {
    keta += 1;
    tmp *= 10;
    if (ans < tmp)
      break;
  }
  cout << keta << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define itrfor(itr, A) for (auto itr = A.begin(); itr != A.end(); itr++)
typedef long long llong;
char moji[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
                 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
char moji2[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
                  'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
                  'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
char moji3[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
#define Sort(a) sort(a.begin(), a.end());
#define Reverse(a) reverse(a.begin(), a.end());

int main() {
  llong n;
  cin >> n;
  llong ans = 1;
  for (llong i = 1; i * i <= n; i++) {
    if (n % i == 0)
      ans = i;
  }
  ans = n / ans;
  int keta = 0;
  llong tmp = 1;
  while (1) {
    keta += 1;
    tmp *= 10;
    if (ans < tmp)
      break;
  }
  cout << keta << endl;
}
Problem p03775 (C++)

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

using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

ll n, k, m, M = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;

  ll f;
  for (ll i = 1; i * i < n; i++) {
    if (n % i == 0)
      f = i;
  }

  f = n / f;

  ll num = 0, prd = 1;
  while (prd <= f) {
    prd *= 10;
    num++;
  }

  cout << num << endl;
}

Fixed submission:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

ll n, k, m, M = 1e9 + 7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;

  ll f;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0)
      f = i;
  }

  f = n / f;

  ll num = 0, prd = 1;
  while (prd <= f) {
    prd *= 10;
    num++;
  }

  cout << num << endl;
}
Problem p03775 (C++)

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

#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstring>
#include <map>
#include <string>
#include <vector>

using namespace std;

int calc(long long num) {

  int keta = 0;

  while (num > 0) {
    num = num / 10;
    keta++;
  }

  return keta;
}

int main() {
  long long n;
  cin >> n;

  int ans = 100;

  long long i = 1;
  while (i <= n) {
    if (n % i == 0) {
      long long b = n / i;

      int c = max(calc(i), calc(b));

      if (ans > c)
        ans = c;
      if (ans < c)
        break;
    }
    i++;
  }

  cout << ans << endl;

  return 0;
}

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

#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstring>
#include <map>
#include <string>
#include <vector>

using namespace std;

int calc(long long num) {

  int keta = 0;

  while (num > 0) {
    num = num / 10;
    keta++;
  }

  return keta;
}

int main() {
  long long n;
  cin >> n;

  int ans = 100;

  long long i = 1;
  while (i * i <= n) {
    if (n % i == 0) {
      long long b = n / i;

      int c = max(calc(i), calc(b));

      if (ans > c)
        ans = c;
      if (ans < c)
        break;
    }
    i++;
  }

  cout << ans << endl;

  return 0;
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
using namespace std;
int main() {
  long N;
  cin >> N;
  long a = 1;
  for (int i = 1; i * i <= N; ++i)
    if (N % i == 0)
      a = i;
  a = N / a;
  int ans = 1;
  while (a /= 10)
    ++ans;
  cout << ans;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  long N;
  cin >> N;
  long a = 1;
  for (long i = 1; i * i <= N; ++i)
    if (N % i == 0)
      a = i;
  a = N / a;
  int ans = 1;
  while (a /= 10)
    ++ans;
  cout << ans;
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long LL;
double PI = acos(-1);

LL n;

int f(LL s) {
  int i = 0;
  while (s >= 1) {
    i++;
    s /= 10;
  }
  return i;
}

int main() {
  while (cin >> n) {

    int s = sqrt(n * 1.0);
    while (s >= 1) {
      if (n % s == 0) {
        break;
      }
    }
    cout << f(n / s) << endl;
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define INF 0x3f3f3f3f
typedef long long LL;
double PI = acos(-1);

LL n;

int f(LL s) {
  int i = 0;
  while (s >= 1) {
    i++;
    s /= 10;
  }
  return i;
}

int main() {
  while (cin >> n) {

    int s = sqrt(n * 1.0);
    while (s >= 1) {
      if (n % s == 0) {
        break;
      }
      s--;
    }
    cout << f(n / s) << endl;
  }
  return 0;
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

int main(void) {
  ll n;
  cin >> n;

  ll a, b, m = n;
  for (ll i = 1; i < n / 2; i++) {
    a = i;
    if (n % a != 0) {
      continue;
    } else {
      b = n / a;
      ll tmp;
      if (a <= b) {
        tmp = max(a, b);
      } else {
        break;
      }
      if (tmp < m) {
        m = tmp;
      }
    }
  }
  int ans = 0;
  while (m > 0) {
    ans++;
    m /= 10;
  }

  cout << ans << endl;
}

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

int main(void) {
  ll n;
  cin >> n;

  ll a, b, m = n;
  for (ll i = 1; i <= sqrt(n); i++) {
    a = i;
    if (n % a != 0) {
      continue;
    } else {
      b = n / a;
      ll tmp;
      if (a <= b) {
        tmp = max(a, b);
      } else {
        break;
      }
      if (tmp < m) {
        m = tmp;
      }
    }
  }
  int ans = 0;
  while (m > 0) {
    ans++;
    m /= 10;
  }

  cout << ans << endl;
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp, -1, sizeof(dp))
const ll mod = 1e9 + 7;
void _IOS() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin.sync_with_stdio(0);
}
#define PI 3.14159265359
int sx, sy, tx, ty;
// 8c:1a:bf:89:66:b6
struct threeElements {
  int _1st, _2nd, _3rd;
};
vector<vector<int>> adj(10);
ll solve(int a, int b) {
  int f = 0, s = 0;
  while (a) {
    a /= 10;
    f++;
  }
  while (b) {
    b /= 10;
    s++;
  }
  return max(f, s);
}
int main() {
  // freopen ("jumping.in","r",stdin);
  _IOS();
  // 18:52
  ll n;
  cin >> n;
  ll ans = oo;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ans = min(ans, solve(i, n / i));
    }
  }
  cout << ans;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp, -1, sizeof(dp))
const ll mod = 1e9 + 7;
void _IOS() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin.sync_with_stdio(0);
}
#define PI 3.14159265359
int sx, sy, tx, ty;
// 8c:1a:bf:89:66:b6
struct threeElements {
  int _1st, _2nd, _3rd;
};
vector<vector<int>> adj(10);
ll solve(int a, int b) {
  int f = 0, s = 0;
  while (a) {
    a /= 10;
    f++;
  }
  while (b) {
    b /= 10;
    s++;
  }
  return max(f, s);
}
int main() {
  // freopen ("jumping.in","r",stdin);
  _IOS();
  // 18:52
  ll n;
  cin >> n;
  ll ans = oo;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ans = min(ans, solve(i, n / i));
    }
  }
  cout << ans;
}
Problem p03775 (Python)

Buggy submission (status: Time Limit Exceeded):
import math

num = int(input())
num_sqrt = int(math.sqrt(num))

A = num_sqrt
while num % A != 0:
    A += 1
B = int(num / A)
A, B = str(A), str(B)
ans = max(len(A), len(B))
print(ans)


Fixed submission:
import math

num = int(input())
num_sqrt = int(math.sqrt(num))

ans = 11
for A in range(1, num_sqrt + 1):
    if num % A == 0:
        B = int(num / A)
        A, B = str(A), str(B)
        now_ans = max(len(A), len(B))
        ans = min(ans, now_ans)
print(ans)
Problem p03775 (Python)

Buggy submission (status: Time Limit Exceeded):
import math

N = int(input())
A = int(math.sqrt(N))
for i in range(A, N + 1):
    if N % i == 0 or len(str(i)) == len(str(N)):
        print(len(str(i)))
        break


Fixed submission:
import math

N = int(input())
for i in range(int(math.sqrt(N)) + 1, 0, -1):
    q, m = divmod(N, i)
    if m == 0:
        print(len(str(q)))
        break
Problem p03775 (C++)

Buggy submission (status: Runtime Error):
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <unordered_map>
#include <vector>
#define mod 998244353
#define int long long
#define ld long double
#define pb push_back
#define dbg(x) cerr << #x << " = " << x << '\n'
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define pii pair<int, int>
using namespace std;

inline void solve() {
  int n, l = 0;
  cin >> n;
  vector<int> a(1000), b(1100);
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      a[l] = i;
      b[l] = n / i;
      l++;
    }
  }
  int ans = 1000;
  for (int i = 0; i < l; i++) {
    string s1 = to_string(a[i]);
    string s2 = to_string(b[i]);
    int l = max(sz(s1), sz(s2));
    ans = min(ans, l);
  }
  cout << ans << endl;
}

signed main() {
  int n = 1; // cin>>n;
  while (n--)
    solve();
  return 0;
}


Fixed submission:
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdio.h>
#include <unordered_map>
#include <vector>
#define mod 998244353
#define int long long
#define ld long double
#define pb push_back
#define dbg(x) cerr << #x << " = " << x << '\n'
#define sz(x) (int)x.size()
#define ff first
#define ss second
#define pii pair<int, int>
using namespace std;

inline void solve() {
  int n, l = 0;
  cin >> n;
  vector<int> a(10000), b(10000);
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      a[l] = i;
      b[l] = n / i;
      l++;
    }
  }
  int ans = 1000;
  for (int i = 0; i < l; i++) {
    string s1 = to_string(a[i]);
    string s2 = to_string(b[i]);
    int l = max(sz(s1), sz(s2));
    ans = min(ans, l);
  }
  cout << ans << endl;
}

signed main() {
  int n = 1; // cin>>n;
  while (n--)
    solve();
  return 0;
}
Problem p03775 (Python)

Buggy submission (status: Runtime Error):
from math import sqrt, ceil, floor, log10

N = int(input())

min_f = ceil(log10(N))
for A in range(1, ceil(sqrt(N))):
    if N % A != 0:
        continue
    else:
        B = N // A
        f = floor(max(log10(A), log10(B))) + 1
        if f < min_f:
            min_f = f

print(f)


Fixed submission:
from math import sqrt, ceil, floor, log10

N = int(input())

min_f = floor(log10(N)) + 1
for A in range(1, ceil(sqrt(N)) + 1):
    if N % A != 0:
        continue
    else:
        B = N // A
        f = floor(max(log10(A), log10(B))) + 1
        if f < min_f:
            min_f = f

print(f)
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(), (x).end()

ll combination(ll n, ll r) {
  if (n < r)
    return 0;
  if (r == 0 || r == n)
    return 1;
  else if (r == 1)
    return n;
  return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str) {
  string checkStr = str;
  reverse(checkStr.begin(), checkStr.end());
  if (str == checkStr)
    return true;
  else
    return false;
}

int keta(ll num) {
  int digits = 0;
  while (num > 0) {
    num /= 10;
    digits++;
  }
  return digits;
}

int main() { // どこかを境目に同じaとbが出てきそう
  ll N;
  cin >> N;
  bool flag = false;
  ll ans = 10000000000;
  for (ll a = 1; a <= N; a++) {
    if (N % a == 0) {
      ll b = N / a;
      if (b < a)
        flag = true;
      else {
        int tmp = max(keta(a), keta(b));
        if (ans > tmp)
          ans = tmp;
      }
    }
    if (flag == true)
      break;
  }
  cout << ans << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(), (x).end()

ll combination(ll n, ll r) {
  if (n < r)
    return 0;
  if (r == 0 || r == n)
    return 1;
  else if (r == 1)
    return n;
  return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str) {
  string checkStr = str;
  reverse(checkStr.begin(), checkStr.end());
  if (str == checkStr)
    return true;
  else
    return false;
}

int keta(ll num) {
  int digits = 0;
  while (num > 0) {
    num /= 10;
    digits++;
  }
  return digits;
}

int main() { // どこかを境目に同じaとbが出てきそう
  ll N;
  cin >> N;
  bool flag = false;
  ll ans = 10000000000;
  for (ll a = 1; a * a <= N; a++) {
    if (N % a == 0) {
      ll b = N / a;
      if (b < a)
        flag = true;
      else {
        int tmp = max(keta(a), keta(b));
        if (ans > tmp)
          ans = tmp;
      }
    }
    if (flag == true)
      break;
  }
  cout << ans << endl;
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
long ma(long a, long b) {
  long r1 = 0, r2 = 0, ret;
  while (a) {
    a /= 10;
    r1++;
  }
  while (b) {
    b /= 10;
    r2++;
  }
  ret = (r1 > r2 ? r1 : r2);
  return ret;
}
int main() {
  long n, c, ans = 13;
  cin >> n;
  map<long, long> pair;
  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      pair.insert(make_pair(i, n / i));
    }
  }
  for (auto it = pair.begin(); it != pair.end(); it++) {
    c = ma((*it).first, (*it).second);
    ans = (ans < c ? ans : c);
  }
  cout << ans;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
long ma(long a, long b) {
  long r1 = 0, r2 = 0, ret;
  while (a) {
    a /= 10;
    r1++;
  }
  while (b) {
    b /= 10;
    r2++;
  }
  ret = (r1 > r2 ? r1 : r2);
  return ret;
}
int main() {
  long n, c, ans = 13;
  cin >> n;
  map<long, long> pair;
  for (long i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      pair.insert(make_pair(i, n / i));
    }
  }
  for (auto it = pair.begin(); it != pair.end(); it++) {
    c = ma((*it).first, (*it).second);
    ans = (ans < c ? ans : c);
  }
  cout << ans;
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

int F(int a, int b);

int main() {
  ll N;
  cin >> N;
  vector<int> FF;
  for (ll i = 0; i < N; i++) {
    if (N % (i + 1) == 0)
      FF.push_back(F((i + 1), N / (i + 1)));
  }
  cout << (int)*min_element(FF.begin(), FF.end()) << endl;
  return 0;
}

int F(int a, int b) {
  string sa = to_string(a);
  string sb = to_string(b);
  return max(sa.size(), sb.size());
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
using ll = long long;

int F(int a, int b);

int main() {
  ll N;
  cin >> N;
  vector<int> FF;
  if (N == 1) {
    cout << 1 << endl;
    return 0;
  }

  for (ll i = 0; i <= sqrt(N); i++) {
    if (N % (i + 1) == 0)
      FF.push_back(F((i + 1), N / (i + 1)));
  }
  cout << (int)*min_element(FF.begin(), FF.end()) << endl;
  return 0;
}

int F(int a, int b) {
  string sa = to_string(a);
  string sb = to_string(b);
  return max(sa.size(), sb.size());
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
  ll n;
  cin >> n;
  ll a = 1;
  for (int i = 1; i * i <= n; i++)
    if (n % i == 0)
      a = i;
  a = max(a, n / a);
  string s = to_string(a);
  cout << s.size() << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
int main() {
  ll n;
  cin >> n;
  ll a = 1;
  for (ll i = 1; i * i <= n; i++)
    if (n % i == 0)
      a = i;
  a = max(a, n / a);
  string s = to_string(a);
  cout << s.size() << endl;
  return 0;
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  long N;
  cin >> N;
  long ans = LONG_MAX;
  for (int i = 1; i * i <= N; i++) {
    if (N % i != 0)
      continue;
    long A = i;
    long B = N / i;
    ans = min(ans, max((long)log10(A) + 1, (long)log10(B) + 1));
  }
  cout << ans << endl;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  long N;
  cin >> N;
  long ans = LONG_MAX;
  for (long i = 1; i * i <= N; i++) {
    if (N % i != 0)
      continue;
    long A = i;
    long B = N / i;
    ans = min(ans, max((long)log10(A) + 1, (long)log10(B) + 1));
  }
  cout << ans << endl;
}
Problem p03775 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool PN(T x) {
  if (x <= 1)
    return false;
  if (x == 2)
    return true;
  for (int i = 2; i < sqrt(x) + 1; i++)
    if (x % i == 0)
      return false;
  return true;
}

void solve() {
  long long x;
  cin >> x;
  if (PN(x)) {
    int order = 0;
    while (x) {
      x /= 10;
      order++;
    }
    cout << order << endl;
    return;
  } else {
    int target = 0;
    int target_order = 0;
    for (int i = 2; i <= sqrt(x); ++i) {
      if (x % i == 0)
        target = i;
    }
    int another = x / target;
    int another_order = 0;
    while (another) {
      another /= 10;
      another_order++;
    }
    while (target) {
      target /= 10;
      target_order++;
    }
    int ans = max(target_order, another_order);
    cout << ans << endl;
  }
}

int main() {
  solve();
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
template <typename T> bool PN(T x) {
  if (x <= 1)
    return false;
  if (x == 2)
    return true;
  for (int i = 2; i < sqrt(x) + 1; i++)
    if (x % i == 0)
      return false;
  return true;
}

void solve() {
  long long x;
  cin >> x;
  if (PN(x)) {
    int order = 0;
    while (x) {
      x /= 10;
      order++;
    }
    cout << order << endl;
    return;
  } else {
    int target = 1;
    int target_order = 0;
    for (int i = 2; i <= sqrt(x); ++i) {
      if (x % i == 0)
        target = i;
    }
    int another = x / target;
    int another_order = 0;
    while (another) {
      another /= 10;
      another_order++;
    }
    while (target) {
      target /= 10;
      target_order++;
    }
    int ans = max(target_order, another_order);
    cout << ans << endl;
  }
}

int main() {
  solve();
  return 0;
}
Problem p03775 (C++)

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

int main() {
  long long n;
  cin >> n;

  int m = floor(sqrt(n));
  while (n % m)
    ++m;

  int digit = 0;
  while (m) {
    ++digit;
    m /= 10;
  }

  cout << digit << endl;
}

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

int main() {
  long long n;
  cin >> n;

  int max = 1;
  for (long long i = 2; i * i <= n; ++i)
    if (n % i == 0)
      max = i;

  int m = n / max;

  int digit = 0;
  while (m) {
    ++digit;
    m /= 10;
  }

  cout << digit << endl;
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
// https://atcoder.jp/contests/abc120/tasks/abc120_b
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main() {
  ll n, a, b;

  ll ans = 100000;
  cin >> n;

  for (int i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ll cnt_A = 0, cnt_B = 0;
      a = n / i;
      b = i;
      while (a > 0) {
        a /= 10;
        cnt_A++;
      }
      while (b > 0) {
        b /= 10;
        cnt_B++;
      }

      ll f = max(cnt_A, cnt_B);
      if (ans > f)
        ans = f;
    }
  }
  cout << ans << endl;
}

Fixed submission:
// https://atcoder.jp/contests/abc120/tasks/abc120_b
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main() {
  ll n, a, b;

  ll ans = 100000;
  cin >> n;

  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ll cnt_A = 0, cnt_B = 0;
      a = n / i;
      b = i;
      while (a > 0) {
        a /= 10;
        cnt_A++;
      }
      while (b > 0) {
        b /= 10;
        cnt_B++;
      }

      ll f = max(cnt_A, cnt_B);
      if (ans > f)
        ans = f;
    }
  }
  cout << ans << endl;
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main() {
  ll n;
  cin >> n;

  int mi = 1e9;
  for (int i = 1; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    int A = i, B = n / i;

    int cntA = 0, cntB = 0;
    while (A != 0) {
      A /= 10;
      cntA++;
    }
    while (B != 0) {
      B /= 10;
      cntB++;
    }
    mi = max(cntA, cntB);
  }
  cout << mi << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main() {
  ll n;
  cin >> n;

  int mi = 1e9;
  for (ll i = 1LL; i * i <= n; i++) {
    if (n % i != 0)
      continue;
    int A = i, B = n / i;

    int cntA = 0, cntB = 0;
    while (A != 0) {
      A /= 10;
      cntA++;
    }
    while (B != 0) {
      B /= 10;
      cntB++;
    }
    mi = max(cntA, cntB);
  }
  cout << mi << endl;
  return 0;
}
Problem p03775 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define MOD 1000000007
int main() {
  ll n;
  cin >> n;
  ll mx = 0;
  ll i;
  for (i = 1; i * i < n; i++) {
    if (n % i == 0)
      mx = i;
  }
  ll t = n / mx;
  ll cnt = 0;
  while (t > 0) {
    t = t / 10;
    cnt++;
  }
  cout << cnt;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define MOD 1000000007
int main() {
  ll n;
  cin >> n;
  ll mx = 0;
  ll i;
  for (i = 1; i * i <= n; i++) {
    if (n % i == 0)
      mx = i;
  }
  ll t = n / mx;
  ll cnt = 0;
  while (t > 0) {
    t = t / 10;
    cnt++;
  }
  cout << cnt;
  return 0;
}
Problem p03775 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
int digit(long long n) {
  int d = 0;
  while (n > 0) {
    n /= 10;
    ++d;
  }
  return max(1, d);
}
int main() {
  long long n;
  int a = 1e9;
  cin >> n;
  rep(i, sqrt(n)) if (n % (i + 1) == 0) a =
      min(a, digit(n / (i + 1)) - digit(n / i));
  cout << a << "\n";
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using namespace std;
int digit(long long n) {
  int d = 0;
  while (n > 0) {
    n /= 10;
    ++d;
  }
  return max(1, d);
}
int main() {
  long long n;
  int a = 1e9;
  cin >> n;
  rep(i, sqrt(n)) if (n % (i + 1) == 0) a = min(a, digit(n / (i + 1)));
  cout << a << "\n";
  return 0;
}
Problem p03775 (C++)

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

int f(int a, int b) {
  int a_keta = 1, b_keta = 1;
  while (a / 10 != 0) {
    a_keta++;
    a /= 10;
  }
  while (b / 10 != 0) {
    b_keta++;
    b /= 10;
  }
  if (a_keta < b_keta)
    return b_keta;
  else
    return a_keta;
}

pair<int64_t, int64_t> yakusuu(int64_t n) {
  pair<int64_t, int64_t> ret;
  double start;
  start = sqrt(n);

  for (int64_t i = (int64_t)start; true; i++) {
    if (n % i == 0) {
      ret = make_pair(i, n / i);
      break;
    }
  }
  return ret;
}

int main() {
  int64_t n;
  cin >> n;
  pair<int64_t, int64_t> r = yakusuu(n);
  cout << f(r.first, r.second) << endl;
}

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

int f(int a, int b) {
  int a_keta = 1, b_keta = 1;
  while (a / 10 != 0) {
    a_keta++;
    a /= 10;
  }
  while (b / 10 != 0) {
    b_keta++;
    b /= 10;
  }
  if (a_keta < b_keta)
    return b_keta;
  else
    return a_keta;
}

pair<int64_t, int64_t> yakusuu(int64_t n) {
  pair<int64_t, int64_t> ret;
  double start;
  start = sqrt(n);

  for (int64_t i = (int64_t)start + 1; true; i--) {
    if (n % i == 0) {
      ret = make_pair(i, n / i);
      break;
    }
  }
  return ret;
}

int main() {
  int64_t n;
  cin >> n;
  pair<int64_t, int64_t> r = yakusuu(n);
  cout << f(r.first, r.second) << endl;
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, j, n) for (int i = (j); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define INF 1e9

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll ans = INF;
  repp(i, 1, n + 1) {
    if (n % i != 0)
      continue;
    ll a = i;
    ll b = n / i;
    if (a > b)
      break;
    ans = min(ans, (ll)max(to_string(a).length(), to_string(b).length()));
  }
  cout << ans << endl;
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repp(i, j, n) for (int i = (j); i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define INF 1e9

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<ll, ll>> vpl;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll ans = INF;
  repp(i, 1, (ll)sqrt(n) + 1) {
    if (n % i != 0)
      continue;
    ll a = i;
    ll b = n / i;
    if (a > b)
      break;
    ans = min(ans, (ll)max(to_string(a).length(), to_string(b).length()));
  }
  cout << ans << endl;
  return 0;
}
Problem p03775 (Python)

Buggy submission (status: Time Limit Exceeded):
N = int(input())
ans = 100000
for i in range(1, 2 * 10**7):
    if N % i == 0:
        ans = min(ans, max(len(str(i)), len(str(N // i))))

print(ans)


Fixed submission:
N = int(input())
ans = 100000
for i in range(1, 13 * 10**6):
    if N % i == 0:
        ans = min(ans, max(len(str(i)), len(str(N // i))))

print(ans)
Problem p03775 (Python)

Buggy submission (status: Runtime Error):
import math

N = int(input())
tmp = math.isqrt(N)
while N % tmp:
    tmp -= 1
print(len(str(N // tmp)))


Fixed submission:
import math

N = int(input())

tmp = math.floor(math.sqrt(N))
while N % tmp:
    tmp -= 1
print(len(str(N // tmp)))
Problem p03775 (C++)

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

using namespace std;

int main() {
  long long int N;
  cin >> N;

  long long int result = N;
  for (long long int i = 1; i <= N / 2; ++i) {
    if (N % i == 0) {
      result = max(N / i, i);
    }

    if (i == result) {
      break;
    }
  }

  cout << (result > 0 ? (int)log10((double)result) + 1 : 1);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  long long int N;
  cin >> N;

  long long int result = N;
  for (long long int i = 1; i <= ceil(sqrt(N)); ++i) {
    if (N % i == 0) {
      result = max(N / i, i);
    }

    if (i == result) {
      break;
    }
  }

  cout << (result > 0 ? (int)log10((double)result) + 1 : 1);
  return 0;
}
Problem p03775 (C++)

Buggy submission (status: Time Limit Exceeded):
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void) {

  ll N;
  cin >> N;
  ll minimum = 1000000000;
  for (int i = 1; i * i <= N; ++i) {
    if (N % i == 0) {
      ll b = N / i;
      minimum = min(minimum, max(ll(i), b));
    }
  }
  cout << ll(log10(minimum)) + 1 << endl;

  return 0;
}


Fixed submission:
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void) {

  ll N;
  cin >> N;
  ll minimum = 1000000000;
  for (int i = 1; (double)i * (double)i <= N; ++i) {
    if (N % i == 0) {
      ll b = N / i;
      minimum = min(minimum, max(ll(i), b));
    }
  }
  cout << ll(log10(minimum)) + 1 << endl;

  return 0;
}
Problem p03775 (C++)

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

typedef long long ll;

int digits(ll d) {
  int siz = 1;
  while (d / 10) {
    siz++;
  }

  return siz;
}

int main() {
  ll N;
  cin >> N;
  int ans = digits(N);

  for (ll A = 1LL; A * A <= N; ++A) {
    if (N % A != 0)
      continue;
    const ll B = N / A;

    const int cur = max(digits(A), digits(B));

    if (ans > cur) {
      ans = cur;
    }
  }
  cout << ans << endl;

  return 0;
}

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

typedef long long ll;

int digits(ll d) {
  int siz = 0;
  while (d > 0) {
    d /= 10;
    siz++;
  }

  return siz;
}

int main() {
  ll N;
  cin >> N;
  int ans = digits(N);

  for (ll A = 1LL; A * A <= N; ++A) {
    if (N % A != 0)
      continue;
    const ll B = N / A;

    const int cur = max(digits(A), digits(B));

    if (ans > cur) {
      ans = cur;
    }
  }
  cout << ans << endl;

  return 0;
}
Problem p03775 (C++)

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

void fnInput(int64_t &rnNum) { cin >> rnNum; }

int fnDigitsCheck(int64_t nDivisor) {
  int nDigitCnt = 0;
  while (nDivisor) {
    nDigitCnt++;
    nDivisor /= 10;
  }

  return nDigitCnt;
}

int fnMultiplCheck(int64_t nNum) {
  int nMinDigit = fnDigitsCheck(nNum);

  for (int n = 2; n * n <= nNum; n++) // int型 n だとうまく行かない
  { // nNum の平方根を超えない整数～nNum
    if (nNum % n != 0)
      continue; // を左記の検査を行うと TLE となる
    int64_t nOtr = nNum / n;
    nMinDigit = min(nMinDigit, fnDigitsCheck(nOtr));
  }
  return nMinDigit;
}

int main() {
  int64_t nNum;

  fnInput(nNum);
  cout << fnMultiplCheck(nNum) << endl;

  return 0;
}

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

void fnInput(int64_t &rnNum) { cin >> rnNum; }

int fnDigitsCheck(int64_t nDivisor) {
  int nDigitCnt = 0;
  while (nDivisor) {
    nDigitCnt++;
    nDivisor /= 10;
  }

  return nDigitCnt;
}

int fnMultiplCheck(int64_t nNum) {
  int nMinDigit = fnDigitsCheck(nNum);

  for (int64_t n = 2; n * n <= nNum; n++) // int型 n だとうまく行かない
  { // nNum の平方根を超えない整数～nNum
    if (nNum % n != 0)
      continue; // を左記の検査を行うと TLE となる
    int64_t nOtr = nNum / n;
    nMinDigit = min(nMinDigit, fnDigitsCheck(nOtr));
  }
  return nMinDigit;
}

int main() {
  int64_t nNum;

  fnInput(nNum);
  cout << fnMultiplCheck(nNum) << endl;

  return 0;
}