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

#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second

using namespace std;

#define error(args...)                                                         \\
  {                                                                            \\
    string _s = #args;                                                         \\
    replace(_s.begin(), _s.end(), ',', ' ');                                   \\
    stringstream _ss(_s);                                                      \\
    istream_iterator<string> _it(_ss);                                         \\
    err(_it, args);                                                            \\
  }

void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}

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

  string S;
  cin >> S;

  if (S.size() <= N) {
    cout << S << endl;
  } else {
    cout << S.substr(0, N) << "...\\n";
  }

  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define pb push_back
#define f first
#define s second

using namespace std;

#define error(args...)                                                         \\
  {                                                                            \\
    string _s = #args;                                                         \\
    replace(_s.begin(), _s.end(), ',', ' ');                                   \\
    stringstream _ss(_s);                                                      \\
    istream_iterator<string> _it(_ss);                                         \\
    err(_it, args);                                                            \\
  }

void err(istream_iterator<string> it) {}
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}

int main() {
  string S;
  cin >> S;

  if (S[S.size() - 1] == '3') {
    cout << "bon" << endl;
  } else if (S[S.size() - 1] == '0' or S[S.size() - 1] == '1' or
             S[S.size() - 1] == '6' or S[S.size() - 1] == '8') {
    cout << "pon" << endl;
  } else
    cout << "hon" << endl;

  return S.size() - 1;
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string S;
  int K;
  cin >> K;
  cin >> S;
  int a = S.size();
  if (a > K) {
    S.erase(K);
    S += "...";
  }
  cout << S << endl;
  return 0;
}

Error: WA

Fixed submission:

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

int main() {
  string S;
  int K;
  cin >> K;
  cin >> S;
  int a = S.size();
  if (a > K) {
    for (int i = K; i < a; i++)
      S.at(i) = '\\0';
    for (int i = K; i < K + 3; i++)
      S.at(i) = '.';
  }
  cout << S << endl;

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

#include <cstring>
#include <iostream>

using namespace std;

int main(void) {
  int k, length;
  cin >> k;
  char s[101];
  scanf("%s", s);
  length = strlen(s);

  if (length > k) {
    for (int i = 0; i < k; i++) {
      printf("%c", s[i]);
    }
    cout << "..." << endl;
  } else {
    cout << s << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

#include <cstring>
#include <iostream>

using namespace std;

int main(void) {
  int k, length;
  cin >> k;
  char s[k + 1];
  scanf("%s", s);
  length = strlen(s);

  if (length > k) {
    for (int i = 0; i < k; i++) {
      cout << s[i];
    }
    cout << "..." << endl;
  } else {
    cout << s << endl;
  }
  return 0;
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  long long a = s.size();
  if (a < k + 1) {
    cout << s << endl;
  } else {
    for (int i = 0; i < k; i++) {
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
  return 0;
}


Error: 0

Fixed submission:

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

int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  long long a = s.size();
  if (a < k + 1) {
    cout << s << endl;
  } else {
    for (int i = 0; i < 7; i++) {
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
  return 0;
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int K = 0;
  string S;

  cin >> K >> S;

  if (S.size() <= K)
    cout << S;

  else {
    for (int i = 0; i < K; i++) {
      cout << S.at(i);
    }
    cout << "...";
  }
}


Error: WA

Fixed submission:

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

int main() {
  int K = 0;
  string S;

  cin >> K >> S;

  if (S.size() <= K)
    cout << S;

  else {
    for (int i = 0; i < 7; i++) {
      cout << S.at(i);
    }
    cout << "...";
  }
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  int l = s.size();
  if (l <= n) {
    cout << s;
  } else {
    for (int i = 0; i < l - n; i++) {
      s.pop_back();
    }
    for (int i = 0; i < 3; i++) {
      s.push_back('.');
    }
    cout << s;
  }
}

Error: -6
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::at: __n (which is 0) >= this->size() (which is 0)


Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  string s;
  cin >> n >> s;
  int l = s.size();
  if (l <= n) {
    cout << s;
  } else {
    string s1;
    for (int i = 0; i < n; i++) {
      s1.at(i) = s.at(i);
    }
    for (int i = n; i < n + 3; i++) {
      s1.at(i) = '.';
    }
    cout << s1;
  }
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int k;
  string s;
  cin >> k;
  cin >> s;
  vector<string> o;

  if (k >= s.size())
    cout << s << endl;
  else {
    for (int i = 0; i < k; ++i)
      cout << s.at(i);
    cout << "..." << endl;
  }
}

Error: WA

Fixed submission:

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

int main() {
  int k;
  string s;
  cin >> k;
  cin >> s;
  string o;

  if (k > s.size())
    cout << s << endl;
  else {
    for (int i = 0; i < k; ++i)
      o[i] = s[i];
    cout << o + "..." << endl;
  }
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error


// Problem : B - ... (Triple Dots)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i <= (int)n; i++)
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long
#define mod 1000000007
int lcm(int x, int y) { return x / __gcd(x, y) * y; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int d = s.length();
  if (d <= n) {
    cout << s << endl;
  } else {
    cout << s.substr(0, n) + "..." << endl;
  }
  return 0;
}


Error: 0

Fixed submission:


// Problem : B - ... (Triple Dots)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 1; i <= (int)n; i++)
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long
#define mod 1000000007
int lcm(int x, int y) { return x / __gcd(x, y) * y; }
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int d = s.length();
  if (d <= n) {
    cout << s << endl;
  } else {
    s.erase(n, d);
  }
  s.insert(n, "...");
  cout << s << endl;
  return 0;
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int X;
  cin >> X;
  string A;
  cin >> A;
  int B = 0;
  if (A.size() <= X) {
    cout << A << endl;
  } else {
    B = X - A.size();
    for (int i = 0; i < X; i++) {
      cout << A.at(i);
    }
    cout << "..." << endl;
  }
}

Error: 0

Fixed submission:

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

int main() {
  int X;
  cin >> X;
  string A;
  cin >> A;
  int B = 0;
  if (A.size() <= X) {
    cout << A << endl;
  } else {
    B = X - A.size();
    cout << A.at(0) << A.at(1) << A.at(2) << A.at(3) << A.at(4) << A.at(5)
         << A.at(6) << "..." << endl;
  }
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  int k;
  string s;
  cin >> k;
  cin >> s;

  if (s.size() <= k) {
    cout << s;
  } else {
    for (int i = 0; i < k; i++) {
      cout << s.at(i);
    }
    cout << "...";
  }
}


Error: WA

Fixed submission:

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

int main() {
  int k;
  string s;
  cin >> k;
  cin >> s;

  if (s.size() <= k) {
    cout << s;
  } else {

    cout << s.at(0) << s.at(1) << s.at(2) << s.at(3) << s.at(4) << s.at(5)
         << s.at(6) << "...";
  }
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll)(1e9)
#define mod (ll)(1e9 + 7)
#define endl "\\n"
#define tt                                                                     \\
  ll testcase;                                                                 \\
  cin >> testcase;                                                             \\
  while (testcase--)

const int mxn = 1e5 + 5;
ll n;

void solve() {
  cin >> n;
  string s;
  cin >> s;
  ll k = s.size();
  if (k <= n) {
    cout << s;
  } else {
    // string t = s.substr(0, n);
    cout << s.substr(0, n) << "...";
  }
}

int main() {
  fast;
  ll testcase;
  testcase = 1;
  // cin>>testcase;
  while (testcase--) {
    solve();
  }
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ff first
#define ss second
#define INF (ll)(1e9)
#define mod (ll)(1e9 + 7)
#define endl "\\n"
#define tt                                                                     \\
  ll testcase;                                                                 \\
  cin >> testcase;                                                             \\
  while (testcase--)

const int mxn = 1e5 + 5;
ll n;

int solve() {
  cin >> n;
  string s;
  cin >> s;
  ll k = s.size();
  if (k <= n) {
    cout << s;
  } else {
    // string t = s.substr(0, n);
    cout << s.substr(0, n) << "...";
  }
}

int main() {
  fast;
  ll testcase;
  testcase = 1;
  // cin>>testcase;
  while (testcase--) {
    solve();
  }
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int K;
  string S;
  cin >> K >> S;
  if (S.size() <= K) {
    cout << S << endl;
  } else {
    for (int i = 0; i < K; i++) {
      cout << S.at(i);
    }
    cout << "..." << endl;
  }
}


Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int K;
  string S;
  cin >> K >> S;
  if (sizeof(S) <= K) {
    cout << S << endl;
  } else {
    vector<string> Z(K);
    for (int i = 0; i < K; i++) {
      Z.at(i) = S.at(i);
    }
    for (int i; i < K; i++) {
      cout << Z.at(i);
    }
    cout << "..." << endl;
  }
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  string s, t;
  int k;
  cin >> k >> s;

  if (s.size() <= k)
    cout << s << endl;
  if (s.size() > k) {
    for (int i = 0; i < k; i++) {
      t.push_back(s.at(i));
    }
    cout << t + "..." << endl;
  }
}

Error: 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;
const int inf = 1001001001;

int main() {
  string s, t;
  int k;
  cin >> k >> s;

  if (s.size() <= k)
    cout << s << endl;
  if (s.size() > k) {
    for (int i = 0; i < 7; i++) {
      t.push_back(s.at(i));
    }
    cout << t + "..." << endl;
  }
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
int main() {
  int K;
  string S;
  cin >> K >> S;
  string sum; // 出力する文字列

  if (S.size() > K) { // SがKを上回ったら
    for (int i = 0; i < K; i++) {
      sum += S.at(i);
    }
    cout << sum << "..." << endl;
  } else {
    cout << S << endl;
  }
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
int main() {
  int K;
  string S;
  cin >> K >> S;
  string sum; // 出力する文字列

  for (int i = 0; i < K; i++) {
    sum += S.at(i);
  }

  cout << sum << "…" << endl;
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <numeric>
#define fastio                                                                 \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);
using namespace std;

int main() {
  fastio;
  int k;
  cin >> k;
  char s[101];
  cin >> s;
  int len = strlen(s);
  if (len <= k)
    cout << s;
  else {
    for (int i = 0; i < k; i++)
      cout << s[i];
    cout << "...";
  }
  return 0;
}

Error: WA

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <numeric>
#define fastio                                                                 \\
  ios_base::sync_with_stdio(0);                                                \\
  cin.tie(0);
using namespace std;

int main() {
  fastio;
  int k;
  cin >> k;
  char s[103];
  cin >> s;
  int len = strlen(s);
  if (len > k) {
    char cs[103];
    strncpy(cs, s, k);
    strcat(cs, "...");
    cout << cs;
  } else {
    cout << s;
  }

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

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
  int k;
  string s;
  cin >> k >> s;
  if (s.length() <= k) {
    cout << s << endl;
  } else {
    for (int i = 0; i < k; i++) {
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
  return 0;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <string>
#include <vector>
using namespace std;
int main() {
  int k;
  string s;
  cin >> k >> s;
  for (int i = 0; i < k; i++) {
    cout << s.at(i);
  }
  cout << "..." << endl;
  return 0;
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define LOOP(i, N) for (int i = 1; i <= (int)N; i++)
#define RREP(i, N) for (int i = (int)N - 1; i >= 0; i--)
#define RLOOP(i, N) for (int i = (int)N; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main() {
  int k;
  string s;
  cin >> k >> s;
  int len = s.size();
  if (k >= len) {
    cout << s << endl;
  } else {
    s.erase(k);
    s += '.';
    s += '.';
    s += '.';
    cout << s << endl;
  }
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define LOOP(i, N) for (int i = 1; i <= (int)N; i++)
#define RREP(i, N) for (int i = (int)N - 1; i >= 0; i--)
#define RLOOP(i, N) for (int i = (int)N; i > 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

int main() {
  int k;
  string s;
  cin >> k >> s;
  int len = s.size();
  if (k >= len) {
    cout << s << endl;
  } else {
    for (int i = k; i < k + 3; i++) {
      s[i] = '.';
    }
    s.erase(k + 3);
    cout << s << endl;
  }
}
Problem p02676 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define int long long
#define int32 int32_t

using namespace std;

int32 main() {
  ios_base::sync_with_stdio(false);
  int k;
  string s;
  cin >> k >> s;
  if (k >= s.size()) {
    cout << s;
    return 0;
  } else {
    cout << s.substr(0, k) + "...";
  }
  return 0;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
#define int long long
#define int32 int32_t

using namespace std;

int32 main() {
  ios_base::sync_with_stdio(false);
  int k;
  string s;
  cin >> k >> s;
  if (k >= s.size()) {
    cout << s;
    return 1;
  } else {
    cout << s.substr(0, k) + "...";
  }
  return 0;
}
Problem p02677 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1e9 + 7;
const long double Pi = acos(-1);
long double nature(long double a) {
  if (a >= 0) {
    return a;
  } else {
    return -1 * a;
  }
}
int main() {
  long double A, B, H, M;
  cin >> A >> B >> H >> M;
  long double time = 60.0 * H + M;
  long double hour = time / 12.0;
  long double minute = M;
  long double sa = nature(hour - minute);
  // cout<<sa<<endl;
  if (sa >= 30) {
    sa = 60.0 - sa;
  }
  // cout<<sa<<endl;
  long double kakudo = sa * 6.0;
  // cout<<kakudo<<endl;
  // cout<<cos(kakudo*Pi/180)<<endl;
  long double answer = A * A + B * B - 2 * A * B * cos(Pi * kakudo / 180);
  long double left = 0, right = A + B;
  long double mid = 0;
  // cout<<answer<<endl;
  while (right >= left) {
    mid = left + (right - left) / 2;
    if (mid * mid == answer)
      return mid;
    else if (mid * mid > answer)
      right = mid - 0.0000000001;
    else if (mid * mid < answer)
      left = mid + 0.0000000001;
  }
  // cout<<mid<<endl;
  cout << fixed << setprecision(9) << mid << endl;
}

Error: WA

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1e9 + 7;
const long double Pi = acos(-1);
long double nature(long double a) {
  if (a >= 0) {
    return a;
  } else {
    return -1 * a;
  }
}
int main() {
  long double A, B, H, M;
  cin >> A >> B >> H >> M;
  long double time = 60.0 * H + M;
  long double hour = time / 12.0;
  long double minute = M;
  long double sa = nature(hour - minute);
  // cout<<sa<<endl;
  if (sa >= 30) {
    sa = 60.0 - sa;
  }
  // cout<<sa<<endl;
  long double kakudo = sa * 6.0;
  // cout<<kakudo<<endl;
  // cout<<cos(kakudo*Pi/180)<<endl;
  long double answer = A * A + B * B - 2 * A * B * cos(Pi * kakudo / 180);
  long double left = 0, right = A + B;
  long double mid = 0;
  // cout<<answer<<endl;
  while (right >= left) {
    mid = left + (right - left) / 2;
    if (mid * mid == answer)
      return mid;
    else if (mid * mid > answer)
      right = mid - 0.000000000000001;
    else if (mid * mid < answer)
      left = mid + 0.000000000000001;
  }
  // cout<<mid<<endl;
  cout << fixed << setprecision(20) << mid << endl;
}
Problem p02677 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#define PI 3.1415926535
#define eps 1.0e-18
using namespace std;
int main() {
  int a, b, h, m;
  long double s, c, x;
  cin >> a >> b >> h >> m;
  s = (h * 60 + m) / 360.0 - m / 30.0;
  x = abs(a * a + b * b - 2 * a * b * cos(s * PI));
  c = sqrtl(x);
  cout << fixed << setprecision(10) << c;
  return 0;
}

Error: TLE

Fixed submission:

#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#define PI 3.1415926535
#define eps 1.0e-18
using namespace std;
int main() {
  int a, b, h, m;
  long double s, c, x;
  cin >> a >> b >> h >> m;
  s = (h * 60 + m) / 360.0 - m / 30.0;
  x = abs(a * a + b * b - 2 * a * b * cos(s * PI));
  c = sqrtl(x);
  while (abs(x - c * c) > eps)
    c = (c + x / c) / 2.0;
  cout << fixed << setprecision(10) << c;
  return 0;
}
Problem p02677 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define multitest 0
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pqgreater(x) x, vector<x>, greater<x>
const ll mod = 998244353;
int solve();
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  if (multitest)
    cin >> t;
  while (t--)
    solve();
  return 0;
}
ld pi = acos(-1.0);
int solve() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  ld angleh = 0.5 * ((ld)h * 60.0 + (ld)m);
  ld anglem = 6 * (ld)m;
  ld diff = fabs(angleh - anglem);
  ld ans = (ld)sqrt((ld)pow((ld)a, 2) + (ld)pow((ld)b, 2) -
                    2.0 * (ld)a * (ld)b * cos(pi * diff / 180.0));
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define multitest 0
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define pqgreater(x) x, vector<x>, greater<x>
const ll mod = 998244353;
int solve();
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  if (multitest)
    cin >> t;
  while (t--)
    solve();
  return 0;
}
ld pi = acos(-1.0);
int solve() {
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  ld angleh = 0.5 * ((ld)h * 60.0 + (ld)m);
  ld anglem = 6 * (ld)m;
  ld diff = fabs(angleh - anglem);
  ld ans = (ld)sqrt((ld)pow((ld)a, 2) + (ld)pow((ld)b, 2) -
                    2.0 * (ld)a * (ld)b * cos(pi * diff / 180.0));
  cout << fixed << setprecision(10) << ans << endl;
}