Problem p02705 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  double p = 6.28, n;
  cin >> n;
  cout << (n * p);
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;

typedef tree<long long, null_type, less<long long>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;

// defines
typedef long long ll;
typedef long double ld;
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define prev _prev
#define y0 _y0
#define kill _kill
#define MAX 10000

// permanent constants
const ld pi = acos(-1.0);
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int digarr[10] = {6, 2, 5, 5, 4, 5, 6, 3, 7, 6};
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
const int dxo[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dyo[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
const int alf = 26;
const int dig = 10;
const int two = 2;
const int th = 3;
const ll prost = 239;
const ll btc = 30;
const ld eps = 1e-10;
const ll INF = (ll)(1e18 + 239);
const int BIG = (int)(1e9 + 239);
const long long MOD = (long long)(1e9 + 7); //(int)(1e9 + 7); //998244353;
const ll MOD2 = (ll)MOD * (ll)MOD;

// random
mt19937 rnd(
    239); //(chrono::high_resolution_clock::now().time_since_epoch().count());

// constants
const int M = (int)(2e5 + 239);
const int N = (int)(2e3 + 239);
const int L = 20;
const int T = (1 << 20);
const int B = 500;
const int X = 1e4 + 239;

// for finding trailing zeros in factorial of a number like zero in 5!(120) is 1
long long findTrailingZeros(long long n) {
  long long count = 0;

  for (long long i = 5; n / i >= 1; i *= 5)
    count += n / i;

  return count;
}

long long power(long long a, unsigned long long n) {
  long long res = 1; // Initialize result
  a = a % MOD;       // Update 'a' if 'a' >= p

  while (n > 0) {
    // If n is odd, multiply 'a' with result
    if (n & 1)
      res = (res * a) % MOD;

    // n must be even now
    n = n >> 1; // n = n/2
    a = (a * a) % MOD;
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a < b)
    return gcd(b, a);
  else if (a % b == 0)
    return b;
  else
    return gcd(b, a % b);
}

long long fact(long long n) {
  if (n <= 1)
    return 1;
  return n * fact(n - 1);
}

long long nPr(long long n, long long r) { return fact(n) / fact(n - r); }
long long nCr(long long n, long long r) {
  return fact(n) / (fact(r) * fact(n - r));
}
long long nCrModp(long long n, long long r, long long p) {
  long long C[r + 1];
  memset(C, 0, sizeof(C));

  C[0] = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long j = min(i, r); j > 0; j--)
      C[j] = (C[j] + C[j - 1]) % p;
  }
  return C[r];
}

/*// If n is prime, then always returns true, If n is
// composite than returns false with high probability
// Higher value of k increases probability of correct
// result.
int isPrime2(long long n, long long  k)
{
   // Corner cases
   if (n <= 1 || n == 4)  return 0;
   if (n <= 3) return 1;

   // Try k times
   while (k>0)
   {
       // Pick a random number in [2..n-2]
       // Above corner cases make sure that n > 4
       long long  a = 2 + rand()%(n-4);

       // Checking if a and n are co-prime
       if (gcd(n, a) != 1)
          return 0;

       // Fermat's little theorem
       if (power(a, n-1, n) != 1)
          return 0;

       k--;
    }

    return 1;

for(long long i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)return 0;
    }return 1;
} */

long long isPrime1(long long n) {

  if (n <= 1)
    return 0;
  if (n == 2 || n == 3)
    return 1;
  if (n % 2 == 0 || n % 3 == 0)
    return 0;

  for (long long i = 5; i * i <= n; i += 6)
    if (n % i == 0 || n % (i + 2) == 0)
      return 0;

  return 1;
}
// An interval has start time and end time
struct Interval {
  long start, end;
};

/*// Compares two intervals according to staring times.
bool compareInterval(Interval a, Interval b) {
    if (a.end == b.end) return a.start < b.start;
    return a.end < b.end;
}*/

// Compares numbers taken in pair (Final Sorting)
bool compareInterval(Interval a, Interval b) {
  if (a.end == b.end)
    return (a.start < b.start);
  else if (a.start == b.start)
    return a.end < b.end;

  else
    return a.start < b.start;
}
/*
int n,matches=1;cin>>n;vector<Interval> v(n);
   for (int i = 0; i < n; i++) {
       cin >> v[i].start >> v[i].end;
       v[i].end+=v[i].start;
   }
   sort(v.begin(),v.end(),compareInterval);
   long prev = v[0].end;
   for (int i = 1; i < n; i++) {
       if (v[i].start > prev) {
           prev = v[i].end;
           matches++ ;
       }
   }
*/
// countsquares between range or having odd number of divisors
long long countSquares(long long a, long long b) {
  return (floor(sqrt(b)) - ceil(sqrt(a)) + 1);
}
long long OR(long long v[], long long n) {
  long long ans = v[0];
  for (long long i = 1; i < n; i++) {
    ans = (ans | v[i]) - v[i];

    if (ans < 0) {
      ans = 0;
      break;
    }
  }

  return ans;
}
// return powers of 2 (2^0+2^1+2^2+...... and this function returns 0+1+2+.....)
long long block(long long x) {
  vector<long int> v;
  long long sum = 0;
  // Converting the decimal number
  // into its binary equivalent.

  while (x > 0) {
    v.push_back(x % 2);
    // sum+=x%2;
    x = x / 2;
  }

  // Displaying the output when
  // the bit is '1' in binary
  // equivalent of number.
  for (long long i = 0; i < v.size(); i++) {
    if (v[i] == 1) {
      sum += i;
      // if (i != v.size() - 1)
      //  cout << ", ";
    }
  }
  // cout << endl;
  return sum;
}
// long int l=10000;
//  return greatest possible number we can make placing all of them together
//   [3,9,22,0] -> 93220
bool cmp(long long a, long long b) {
  return to_string(a) + to_string(b) > to_string(b) + to_string(a);
}
// LEFT SHIFT AND RIGHT SHIFT IN CASE OF STRING
string leftrotate(string s, int d) {
  reverse(s.begin(), s.begin() + d);
  reverse(s.begin() + d, s.end());
  reverse(s.begin(), s.end());
  return s;
}
string rightrotate(string s, int d) { return leftrotate(s, s.length() - d); }
// BACKSPACE STRING
string newString(string S) {
  deque<char> q;
  int h = 0;
  for (int i = S.size() - 1; i >= 0; i--) {

    if (S[i] != '#' && h == 0)
      q.push_back(S[i]);
    else if (S[i] == '#')
      h++;
    else if (S[i] != '#' && h != 0)
      h--;
  }

  string ans = "";

  while (!q.empty()) {
    ans += q.front();
    q.pop_front();
  }
  reverse(ans.begin(), ans.end());
  return ans;
}
// Maximum Subarray Sum
long long maxSubArraySum(vector<long long> &a, long long size) {
  long long max_so_far = INT_MIN, max_ending_here = 0;

  for (long long i = 0; i < size; i++) {
    max_ending_here = max_ending_here + a[i];
    if (max_so_far < max_ending_here)
      max_so_far = max_ending_here;

    if (max_ending_here < 0)
      max_ending_here = 0;
  }
  return max_so_far;
}
long long solve(long long t) {
  double p = 3.14, k;
  cin >> k;
  cout << (k * p);

  if (t > 0)
    cout << "\\n";
}

int32_t main() {
#ifdef ONPC
  freopen("input.txt", "r", stdin);
#endif
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve(t);
  }

  return 0;
}