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

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
using namespace std;

int main() {
  int i, j, a, b, c, n;
  int count = 0;
  int sum = 0;
  cin >> n;
  for (i = 0; i <= n; i++) {
    for (j = 0; j <= n; j++) {
      if (i % j == 0) {
        count++;
      }
    }
    if (count == 8) {
      sum++;
    }
    count = 0;
  }
  cout << sum;
  return 0;
}

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

int main() {
  int i, j, a, b, c, n;
  int count = 0;
  int sum = 0;
  cin >> n;
  for (i = 1; i <= n; i = i + 2) {
    for (j = 1; j <= n; j++) {
      if (i % j == 0) {
        count++;
      }
    }
    if (count == 8) {
      sum++;
    }
    count = 0;
  }
  cout << sum;
  return 0;
}
Problem p03281 (C++)

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

using namespace std;

using ll = long long;

bool is_prime(int n) {
  if (n % 2 == 0)
    return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return n != 1;
}

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

map<int, int> prime_factor(int n) {
  map<int, int> res;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}

vector<int> sieve(int n) {
  vector<int> res;
  vector<bool> is_prime(n + 1, true);
  is_prime[0] = false;
  is_prime[1] = false;
  for (int i = 2; i <= n; i++) {
    if (!is_prime[i])
      continue;
    res.emplace_back(i);
    for (int j = 2 * i; j <= n; j += i)
      is_prime[j] = false;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> cnt(n + 1, 0);
  for (int i = 1; i <= 200; i += 2) {
    vector<int> d(divisor(i));
    if (d.size() == 8)
      cnt[i]++;
  }

  for (int i = 1; i <= n; i++) {
    cnt[i] += cnt[i - 1];
  }
  cout << cnt[n] << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;

bool is_prime(int n) {
  if (n % 2 == 0)
    return false;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)
      return false;
  }
  return n != 1;
}

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

map<int, int> prime_factor(int n) {
  map<int, int> res;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if (n != 1)
    res[n] = 1;
  return res;
}

vector<int> sieve(int n) {
  vector<int> res;
  vector<bool> is_prime(n + 1, true);
  is_prime[0] = false;
  is_prime[1] = false;
  for (int i = 2; i <= n; i++) {
    if (!is_prime[i])
      continue;
    res.emplace_back(i);
    for (int j = 2 * i; j <= n; j += i)
      is_prime[j] = false;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> cnt(n + 1, 0);
  for (int i = 1; i <= n; i += 2) {
    vector<int> d(divisor(i));
    if (d.size() == 8)
      cnt[i]++;
  }

  for (int i = 1; i <= n; i++) {
    cnt[i] += cnt[i - 1];
  }
  cout << cnt[n] << endl;
  return 0;
}
Problem p03281 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <algorithm>
#include <cmath>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i <= n; i++) {
    for (int j = i; j <= n; j += i) {
      a[j]++;
    }
  }

  ll c = 0;
  for (int i = 1; i <= n; i += 2) {
    if (a[i] == 8)
      c++;
  }
  cout << c << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll n;
  cin >> n;
  vector<ll> a(n + 1);
  for (int i = 1; i <= n + 1; i++) {
    for (int j = i; j <= n; j += i) {
      a[j]++;
    }
  }

  ll c = 0;
  for (int i = 1; i <= n; i += 2) {
    if (a[i] == 8)
      c++;
  }
  cout << c << endl;
}
Problem p03281 (C++)

Buggy submission (status: Runtime Error):
#include <cmath> //これはlogを使うときに必要
#include <iostream>
#include <string>
using namespace std;

int divisor(int n) {
  int a = 0;
  for (int i = 0; i <= n; i++) {
    if (n / i == 0)
      a++;
  }
  return a;
}

int main() {
  int b = 0;
  int n;
  cin >> n;
  for (int i = 1; i < n + 1; i += 2) {
    if (divisor(i) == 8)
      b++;
  }
  cout << b << endl;
}


Fixed submission:
#include <cmath> //これはlogを使うときに必要
#include <iostream>
#include <string>
using namespace std;

int divisor(int n) {
  int a = 0;
  for (int i = 1; i <= n; i++) {
    if (n % i == 0)
      a++;
  }
  return a;
}

int main() {
  int b = 0;
  int n;
  cin >> n;
  for (int i = 1; i < n + 1; i += 2) {
    if (divisor(i) == 8)
      b++;
  }
  cout << b << endl;
}
Problem p03282 (C++)

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

int main() {
  string S;
  long long K;
  cin >> S >> K;
  long long l = 0;
  while (S.at(l) == '1')
    l++;
  if (l + 1 >= K)
    cout << '1' << endl;
  else
    cout << S.at(l) << endl;
}

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

int main() {
  string S;
  long long K;
  cin >> S >> K;
  for (long long i = 0; i < K; i++) {
    if (i >= S.size())
      break;
    if (S.at(i) != '1') {
      cout << S.at(i) << endl;
      return 0;
    }
  }
  cout << '1' << endl;
}
Problem p03282 (C++)

Buggy submission (status: Runtime Error):
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string S;
  cin >> S;
  long long K;
  cin >> K;
  if (S.at(0) == '1')
    cout << S.at(1) << endl;
  else
    cout << S.at(0) << endl;
}


Fixed submission:
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string S;
  cin >> S;
  long long K;
  cin >> K;
  for (long long i = 0; i < K; i++) {
    if (S.at(i) != '1') {
      cout << S.at(i) << endl;
      return 0;
    }
  }
  cout << 1 << endl;
}
Problem p03282 (C++)

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

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

  int count = 0;
  char num = '1';
  while (num == '1') {
    num = S.at(count);
    count++;
  }

  if (K < count)
    cout << '1' << endl;
  else
    cout << num << endl;
}

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

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

  int count = 0;
  char num = '1';
  while (num == '1' && count < K) {
    num = S.at(count);
    count++;
  }

  if (K < count)
    cout << '1' << endl;
  else
    cout << num << endl;
}
Problem p03282 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  string s;
  ll k;
  cin >> s >> k;
  if (k < s.size()) {
    for (ll i = 0; i < k; i++) {
      if (s.at(i) != '1') {
        cout << s.at(i) << endl;
        return 0;
      }
    }
    cout << '1' << endl;
  } else {
    ll x = 0;
    while (x < s.size() && s.at(x) == '1') {
      x++;
    }
    cout << s.at(x) << endl;
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
  string s;
  ll k;
  cin >> s >> k;
  int count = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) != '1')
      break;
    count++;
  }
  if (k <= count) {
    cout << '1' << endl;
  } else {
    ll x = 0;
    while (x < s.size() && s.at(x) == '1') {
      x++;
    }
    cout << s.at(x) << endl;
  }
}
Problem p03282 (C++)

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

int main() {

  string S;
  long long K;
  cin >> S >> K;
  long long count = 1;
  vector<int> vec(S.size(), 0);
  if (K == 1) {
    cout << S.at(0) << endl;
    return 0;
  }
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == '1') {
      vec.at(i)++;
    } else {
      count = S.at(i) - '0';
      break;
    }
  }
  if (K <= 101) {
    if (vec.at(K - 1) == 1) {
      cout << 1 << endl;
    } else {
      cout << count << endl;
    }
  } else {
    cout << count << endl;
  }
}

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

int main() {

  string S;
  long long K;
  cin >> S >> K;
  long long count = 1;
  vector<int> vec(101, 0);
  if (K == 1) {
    cout << S.at(0) << endl;
    return 0;
  }
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) == '1') {
      vec.at(i)++;
    } else {
      count = S.at(i) - '0';
      break;
    }
  }
  if (K <= 101) {
    if (vec.at(K - 1) == 1) {
      cout << 1 << endl;
    } else {
      cout << count << endl;
    }
  } else {
    cout << count << endl;
  }
}
Problem p03282 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define RREP(i, n) for (int(i) = ((int)(n)-1); (i) >= 0; i--)
#define RFOR(i, a, b) for (int(i) = ((int)(b)-1); (i) >= (int)a; i--)
#define ALL(v) (v).begin(), (v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x) (int)x.size()
#define SP(x) setprecision((int)x)

using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } // 最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     // 最小公倍数

//-------------------------------------------------
//
void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }

//-------------------------------------------------
// メモ

//-------------------------------------------------

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  ll k;
  cin >> k;
  ll cnt = 0;
  char c;
  int i = 0;
  while (1) {
    if (s.at(i) == '1') {
      cnt++;
    } else {
      c = s.at(i);
      break;
    }
    i++;
  }

  if (k > cnt) {
    cout << c << endl;
  } else {
    cout << 1 << endl;
  }

  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for (int(i) = a; (i) < (int)b; i++)
#define RREP(i, n) for (int(i) = ((int)(n)-1); (i) >= 0; i--)
#define RFOR(i, a, b) for (int(i) = ((int)(b)-1); (i) >= (int)a; i--)
#define ALL(v) (v).begin(), (v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x) (int)x.size()
#define SP(x) setprecision((int)x)

using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; } // 最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }     // 最小公倍数

//-------------------------------------------------
//
void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }

//-------------------------------------------------
// メモ

//-------------------------------------------------

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  ll k;
  cin >> k;
  ll cnt = 0;
  char c;
  int i = 0;
  while (i < SZ(s)) {
    if (s.at(i) == '1') {
      cnt++;
    } else {
      c = s.at(i);
      break;
    }
    i++;
  }

  if (k > cnt) {
    cout << c << endl;
  } else {
    cout << 1 << endl;
  }

  return 0;
}
Problem p03282 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repR(i, n) for (int i = n; i >= 0; ++i)
#define FDS(i, n) for (ll i = 0; i < n; ++i)
#define FDSR(i, n) for (int i = n; i >= 0; ++i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main() {
  string S;
  ll K;
  cin >> S >> K;
  FDS(i, K) {
    if (S[i] != '1') {
      cout << S[i] << endl;
    } else if (i == (K - 1)) {
      cout << 1 << endl;
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define repR(i, n) for (int i = n; i >= 0; ++i)
#define FDS(i, n) for (ll i = 0; i < n; ++i)
#define FDSR(i, n) for (int i = n; i >= 0; ++i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn int
#define ednl endl
using namespace std;
typedef long long ll;
int main() {
  string S;
  ll K;
  cin >> S >> K;
  FDS(i, K) {
    if (S[i] != '1') {
      cout << S[i] << endl;
      break;
    } else if (i == (K - 1)) {
      cout << 1 << endl;
    }
  }
}
Problem p03282 (C++)

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

int main() {
  int count, i;
  long long int k;
  char a[105];
  while (scanf("%s", a) != 0) {
    scanf("%lld", &k);
    for (i = 0; i < strlen(a); i++) {
      if (a[i] != '1') {
        count = i;
        break;
      }
    }
    if (i < strlen(a)) {
      if (count < k) {
        printf("%c\n", a[i]);
      } else
        printf("1\n");
    } else
      printf("1\n");
  }
}

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

int main() {
  int count, i;
  long long int k;
  char a[105];
  while (scanf("%s", a) != -1) {
    scanf("%lld", &k);
    for (i = 0; i < strlen(a); i++) {
      if (a[i] != '1') {
        count = i;
        break;
      }
    }
    if (i < strlen(a)) {
      if (count < k) {
        printf("%c\n", a[i]);
      } else
        printf("1\n");
    } else
      printf("1\n");
  }
}
Problem p03282 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vin = vector<int>;
using vll = vector<long long>;
using vvin = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vstr = vector<string>;
using vvstr = vector<vector<string>>;
using vch = vector<char>;
using vvch = vector<vector<char>>;
using vbo = vector<bool>;
using vvbo = vector<vector<bool>>;
using vpii = vector<pair<int, int>>;
using pqsin = priority_queue<int, vector<int>, greater<int>>;
#define mp make_pair
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define decp(n) cout << fixed << setprecision((int)n)
#define _GLIBCXX_DEBUG
const int inf = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  bool tmp = true;
  rep(i, k) if (s[i] != '1') tmp = false;
  if (tmp) {
    cout << '1' << endl;
    return 0;
  }
  rep(i, s.size()) {
    if (s[i] != '1') {
      cout << s[i] << endl;
      return 0;
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vin = vector<int>;
using vll = vector<long long>;
using vvin = vector<vector<int>>;
using vvll = vector<vector<long long>>;
using vstr = vector<string>;
using vvstr = vector<vector<string>>;
using vch = vector<char>;
using vvch = vector<vector<char>>;
using vbo = vector<bool>;
using vvbo = vector<vector<bool>>;
using vpii = vector<pair<int, int>>;
using pqsin = priority_queue<int, vector<int>, greater<int>>;
#define mp make_pair
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define decp(n) cout << fixed << setprecision((int)n)
#define _GLIBCXX_DEBUG
const int inf = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  bool tmp = true;
  rep(i, k) {
    if (s[i] != '1') {
      tmp = false;
      break;
    }
  }
  if (tmp) {
    cout << '1' << endl;
    return 0;
  }
  rep(i, s.size()) {
    if (s[i] != '1') {
      cout << s[i] << endl;
      return 0;
    }
  }
}
Problem p03282 (C++)

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

int main() {
  string st;
  ll k;
  cin >> st;
  ll suu = 0;
  for (int i = 0; i >= 0; i++) {
    if (st.at(i) != '1')
      break;
    suu++;
  }
  cin >> k;
  if (k <= suu) {
    cout << 1 << endl;
  } else {
    cout << st.at(suu) << endl;
  }
  return 0;
}

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

int main() {
  string st;
  ll k;
  cin >> st;
  ll suu = 0;
  for (int i = 0; i < st.size(); i++) {
    if (st.at(i) != '1')
      break;
    suu++;
  }
  cin >> k;
  if (k <= suu) {
    cout << 1 << endl;
  } else {
    cout << st.at(suu) << endl;
  }
  return 0;
}
Problem p03282 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x, y) (((x) > (y)) ? x : y)
#define min(x, y) (((x) < (y)) ? x : y)
#define FOR(a, b, c) for (b = (c); b < (a); b++)
#define ender                                                                  \
  { return 0; }
#define tosasuretu(a) (a * (a + 1) / 2)
inline ll kaizyo(ll);
ll combination(ll, ll);
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  char ans = '1';
  for (int i = 0; i < k; i++) {
    if (s[i] != '1') {
      ans = s[i];
    }
  }
  cout << ans;
  return 0;
}

inline ll kaizyo(ll x) {
  long ans = 1;
  for (int z = 0; z < x; z++) {
    ans *= (x - z);
  }
  return ans;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x, y) (((x) > (y)) ? x : y)
#define min(x, y) (((x) < (y)) ? x : y)
#define FOR(a, b, c) for (b = (c); b < (a); b++)
#define ender                                                                  \
  { return 0; }
#define tosasuretu(a) (a * (a + 1) / 2)
inline ll kaizyo(ll);
ll combination(ll, ll);
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  char ans = '1';
  for (int i = 0; i < k; i++) {
    if (s[i] != '1') {
      ans = s[i];
      break;
    }
    if (i >= s.size()) {
      break;
    }
  }
  cout << ans;
  return 0;
}

inline ll kaizyo(ll x) {
  long ans = 1;
  for (int z = 0; z < x; z++) {
    ans *= (x - z);
  }
  return ans;
}
Problem p03282 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < n; i++)
#define rev(i, n) for (int i = n - 1; i >= 0; i--)
#define REV(i, n) for (int i = n - 1; i > 0; i--)
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1) {
  unsigned day;
  if (dow < dow1)
    dow += 7;
  day = dow - dow1;
  day += 7 * n - 6;
  return day;
}
unsigned DayToWeekNumber(unsigned day) { return (day - 1) / 7 + 1; }
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0) {
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
  string S;
  int K;
  cin >> S >> K;
  rep(i, K) {
    if (S.at(i) == '1' && i == K - 1) {
      cout << 1 << endl;
      return 0;
    } else if (S.at(1) != '1') {
      cout << S.at(i) << endl;
      return 0;
    }
  }
}

Fixed submission:
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < n; i++)
#define rev(i, n) for (int i = n - 1; i >= 0; i--)
#define REV(i, n) for (int i = n - 1; i > 0; i--)
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1) {
  unsigned day;
  if (dow < dow1)
    dow += 7;
  day = dow - dow1;
  day += 7 * n - 6;
  return day;
}
unsigned DayToWeekNumber(unsigned day) { return (day - 1) / 7 + 1; }
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0) {
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
  string S;
  int K;
  cin >> S >> K;
  rep(i, K) {
    if (S.at(i) == '1' && i == K - 1) {
      cout << 1 << endl;
      return 0;
    } else if (S.at(i) != '1') {
      cout << S.at(i) << endl;
      return 0;
    }
  }
}
Problem p03282 (Python)

Buggy submission (status: Runtime Error):
s = input()
k = int(input())
i = 0
while s[i] == "1":
    i += 1
print([1, s[i]][i < k])


Fixed submission:
s = input()
k = int(input())
i = 0
if s.count("1") == len(s):
    print(1)
else:
    while s[i] == "1":
        i += 1
    print([1, s[i]][i < k])
Problem p03282 (Python)

Buggy submission (status: Runtime Error):
S = input()
K = int(input())

answer = S[1]
print(answer)


Fixed submission:
S = input()
K = int(input())

are_all_one = True
for i in range(len(S)):
    if S[i] != "1":
        are_all_one = False
        break

nth = i + 1
if are_all_one or K < nth:
    print(1)
    exit()

answer = S[i]
print(answer)
Problem p03282 (Python)

Buggy submission (status: Runtime Error):
s = input()
k = int(input())

index = 0
while s[index] == "1":
    index += 1
if k <= index:
    print("1")
else:
    print(s[index])


Fixed submission:
s = input()
k = int(input())

index = 0
while s[index] == "1" and index < len(s) - 1:
    index += 1
if k <= index:
    print("1")
else:
    print(s[index])
Problem p03282 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
const int MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  ll k;
  cin >> k;
  char ans = '0';
  for (int i = 0; i < 101; i++) {
    if (s.at(i) != '1') {
      ans = s.at(i);
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>
const int MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  ll k;
  cin >> k;
  char ans = '1';
  for (int i = 0; i < s.size(); i++) {
    if (k - 1 <= i && s.at(i) == '1')
      break;
    if (s.at(i) != '1') {
      ans = s.at(i);
      break;
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p03282 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

int main() {
  string s;
  int k;
  cin >> s >> k;
  int n;
  for (int i = 0; i < 100; i++) {
    if (s.at(i) != '1') {
      n = i;
      // cout << n << endl;
      break;
    }
  }
  if (k <= n) {
    cout << 1 << endl;
  } else {
    cout << s.at(n) << endl;
  }
}


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

int main() {
  string s;
  int k;
  cin >> s >> k;
  int n;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) != '1') {
      n = i;
      // cout << n << endl;
      break;
    }
  }
  if (k <= n) {
    cout << 1 << endl;
  } else {
    cout << s.at(n) << endl;
  }
}
Problem p03282 (C++)

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

int main() {
  string s;
  int k;
  cin >> s >> k;
  int sz = s.size();
  vector<char> vec(sz);

  int b = 0;
  for (int i = 0; i < sz; i++) {
    if (b == 0) {
      vec.at(i) = s.at(i);
      if (s.at(i) != '1')
        b = 1;
    } else {
      vec.at(i) = vec.at(i - 1);
    }
  }
  if (k > sz)
    cout << vec.at(sz - 1) << endl;
  else
    cout << vec.at(k) << endl;
}

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

int main() {
  string s;
  int k;
  cin >> s >> k;
  int sz = s.size();
  vector<char> vec(sz);

  int b = 0;
  for (int i = 0; i < sz; i++) {
    if (b == 0) {
      vec.at(i) = s.at(i);
      if (s.at(i) != '1')
        b = 1;
    } else {
      vec.at(i) = vec.at(i - 1);
    }
  }
  if (k > sz)
    cout << vec.at(sz - 1) << endl;
  else
    cout << vec.at(k - 1) << endl;
}
Problem p03282 (C++)

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

int main() {
  string str;
  long long K;
  cin >> str >> K;
  bool flag = true;
  for (long long i = 0; min(K, (long long)str.size()); i++) {
    if (str.at(i) != '1') {
      cout << str.at(i) << endl;
      flag = false;
      break;
    }
  }
  if (flag)
    cout << '1' << endl;
}

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

int main() {
  string str;
  long long K;
  cin >> str >> K;
  bool flag = true;
  for (long long i = 0; i < min(K, (long long)str.size()); i++) {
    if (str.at(i) != '1') {
      cout << str.at(i) << endl;
      flag = false;
      break;
    }
  }
  if (flag)
    cout << '1' << endl;
}
Problem p03282 (C++)

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

int main() {
  cin.tie(0), ios::sync_with_stdio(false);
  string s;
  int64_t k;
  cin >> s >> k;
  int i = 0;
  while (s.at(i) == '1')
    ++i;
  cout << (k <= i ? '1' : s.at(i)) << "\n"s;
}

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

int main() {
  cin.tie(0), ios::sync_with_stdio(false);
  string s;
  int64_t k;
  cin >> s >> k;
  int i = 0;
  while (i < s.size() && s.at(i) == '1')
    ++i;
  cout << (k <= i ? '1' : s.at(i)) << "\n"s;
}
Problem p03282 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int64_t zyou(int a, int b) {
  int i, ans = 1;
  for (i = 0; i < b; i++) {
    ans = ans * a;
  }
  return ans;
}
int main() {
  string s;
  int64_t k, i = 0;
  cin >> s >> k;
  int64_t count = 0;
  while (1) {
    if (s.at(i) != '1') {
      cout << s.at(i);
      return 0;
    }
    i++;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int64_t zyou(int a, int b) {
  int i, ans = 1;
  for (i = 0; i < b; i++) {
    ans = ans * a;
  }
  return ans;
}
int main() {
  string s;
  int64_t k, i = 0;
  cin >> s >> k;
  int64_t count = 0;
  while (1) {
    if (s.at(i) != '1') {
      cout << s.at(i);
      return 0;
    }
    i++;
    if (i == k) {
      cout << 1;
      return 0;
    }
  }
}
Problem p03282 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm> // sort
#include <bits/stdc++.h>
#include <ctype.h>
#include <map> // pair
#include <math.h>
#include <stdio.h>
#include <string>
using namespace std;

int main() {
  long long int n;
  string s;
  cin >> s >> n;
  long long int count = 0;
  long long int i = 0;
  while (s.at(i) == '1') {
    i++;
    count++;
  }
  if (count >= n) {
    cout << "1" << endl;
  } else {
    cout << s.at(i) << endl;
  }
}

Fixed submission:
#include <algorithm> // sort
#include <bits/stdc++.h>
#include <ctype.h>
#include <map> // pair
#include <math.h>
#include <stdio.h>
#include <string>
using namespace std;

int main() {
  long long int n;
  string s;
  cin >> s >> n;
  long long int count = 0;
  long long int i = 0;
  while (s.at(i) == '1') {
    i++;
    count++;
    if (i == s.size()) {
      break;
    }
  }
  if (count >= n) {
    cout << "1" << endl;
  } else {
    cout << s.at(i) << endl;
  }
}
Problem p03282 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define repi(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = (int)(n); i >= 0; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main() {
  string S;
  long K;
  cin >> S >> K;
  repi(i, 100) {
    if (S.at(i) != '1') {
      cout << S.at(i) << endl;
      return 0;
    }
  }
  cout << "1" << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define repi(i, n) for (int i = 0; i < (int)(n); i++)
#define repd(i, n) for (int i = (int)(n); i >= 0; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main() {
  string S;
  long K;
  cin >> S >> K;
  if (K >= 100)
    K = 100;
  repi(i, K) {
    if (S.at(i) != '1') {
      cout << S.at(i) << endl;
      return 0;
    }
  }
  cout << "1" << endl;
  return 0;
}
Problem p03282 (C++)

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

int main() {
  string S;
  int K;
  cin >> S >> K;
  int i = 0;
  while (S.at(i) == '1')
    i++;
  if (K > i)
    cout << S.at(i);
  else
    cout << '1';
  cout << endl;
  return 0;
}


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

int main() {
  string S;
  int K;
  cin >> S >> K;
  int i;
  for (i = 0; i < S.size(); i++) {
    if (S.at(i) != '1')
      break;
  }
  if (K > i)
    cout << S.at(i);
  else
    cout << '1';
  cout << endl;
  return 0;
}
Problem p03282 (C++)

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

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

  long long oneIndex = -1;

  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '1') {
      oneIndex++;
    } else {
      break;
    }
  }

  char ans;

  if (k <= oneIndex) {
    ans = '1';
  } else {
    ans = s.at(oneIndex + 1);
  }

  cout << ans << endl;

  return 0;
}

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

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

  long long oneIndex = -1;

  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == '1') {
      oneIndex++;
    } else {
      break;
    }
  }

  char ans;

  if (k - 1 <= oneIndex) {
    ans = '1';
  } else {
    ans = s.at(oneIndex + 1);
  }

  cout << ans << endl;

  return 0;
}
Problem p03282 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>

int main(int argc, char *argv[]) {
  std::string s;
  long k;
  std::cin >> s >> k;
  long i = 0;
  char c = s.at(0);

  if (c > '1') {
    std::cout << c << std::endl;
    return 0;
  }

  while (i < (int)s.size()) {
    if (c != '1')
      break;
    ++i;
    c = s.at(i);
  }

  if (i >= k) {
    std::cout << 1 << std::endl;
    return 0;
  }
  std::cout << s.at(i) << std::endl;
}


Fixed submission:
#include <iostream>

int main(int argc, char *argv[]) {
  std::string s;
  long k;
  std::cin >> s >> k;
  long i = 0;
  char c = s.at(0);

  if (c > '1') {
    std::cout << c << std::endl;
    return 0;
  }

  while (i + 1 < (int)s.size()) {
    if (c != '1')
      break;
    ++i;
    c = s.at(i);
  }

  if (i >= k) {
    std::cout << 1 << std::endl;
    return 0;
  }
  std::cout << s.at(i) << std::endl;
}
Problem p03282 (C++)

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

using namespace std;

string s;
long long k;

int main() {
  cin >> s >> k;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != '1') {
      cout << s[i] << endl;
      return 0;
    }
    if (i == k) {
      cout << s[i] << endl;
      return 0;
    }
  }
  assert(false);
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>

using namespace std;

string s;
long long k;

int main() {
  cin >> s >> k;
  k--;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != '1') {
      cout << s[i] << endl;
      return 0;
    }
    if (i == k) {
      cout << s[i] << endl;
      return 0;
    }
  }
  assert(false);
  return 0;
}
Problem p03282 (C++)

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

int main() {
  string s;
  int64_t n;
  cin >> s >> n;
  n--;
  int z = 0;
  while (s.at(z) == '1')
    z++;
  int ans = 0;
  if (z > n)
    ans = 1;
  else
    ans = s.at(z) - 48;
  cout << ans << endl;
  return 0;
}

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

int main() {
  string s;
  int64_t n;
  cin >> s >> n;
  n--;
  int z = 0;
  while (z < s.size() && s.at(z) == '1')
    z++;
  int ans = 0;
  if (z > n)
    ans = 1;
  else
    ans = s.at(z) - 48;
  cout << ans << endl;
  return 0;
}
Problem p03282 (C++)

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

int main() {
  string s;
  int k, i = 0;
  cin >> s >> k;
  while (i < s.size() && s.at(i) == '1')
    i++;
  // cout << i << '/';
  if (i > k)
    cout << 1 << endl;
  else
    cout << s.at(i) << endl;
  return 0;
}

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

int main() {
  string s;
  int k, i = 0;
  cin >> s >> k;
  k--;
  while (i < s.size() && s.at(i) == '1')
    i++;
  // cout << i << '/';
  if (i > k)
    cout << 1 << endl;
  else
    cout << s.at(i) << endl;
  return 0;
}
Problem p03282 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
#include <string>
using namespace std;

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

  int count = 0;
  for (int i = 0; i <= s.length(); i++) {
    if (s.at(i) == '1') {
      count++;
    } else {
      break;
    }
  }

  if (count >= n) {

    cout << '1' << endl;
  } else {
    cout << s.at(count) << endl;
  }

  return 0;
}

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

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

  int count = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s.at(i) == '1') {
      count++;
    } else {
      break;
    }
  }

  if (count >= n) {

    cout << '1' << endl;
  } else {
    cout << s.at(count) << endl;
  }

  return 0;
}
Problem p03282 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;

string s;
int n, i;

int main() {
  cin >> s >> n;
  while (n--) {
    if (s[i] != '1') {
      printf("%s\n", s[i]);
      return 0;
    }
    i++;
  }
  puts("1");
}

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

string s;
int n, i;

int main() {
  cin >> s >> n;
  while (n--) {
    if (s[i] != '1') {
      printf("%c\n", s[i]);
      return 0;
    }
    i++;
  }
  puts("1");
}
Problem p03282 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  long long int k;
  cin >> k;
  if (s.at(0) == '1') {
    cout << s.at(1) << endl;
  } else {
    cout << s.at(0) << endl;
  }
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  long long int k;
  cin >> k;
  if (s.at(0) == '1') {
    if (s.size() == 1) {
      cout << s.at(0) << endl;
    } else {
      int tmp = 1;
      for (int i = 1; i < s.size(); i++) {
        if (s.at(i) != '1') {
          tmp = i;
          break;
        }
      }
      if (k <= tmp) {
        cout << 1 << endl;
      } else {
        cout << s.at(tmp) << endl;
      }
    }
  } else {
    cout << s.at(0) << endl;
  }
}
Problem p03282 (C++)

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

int main() {
  string s;
  long long int k;
  cin >> s >> k;
  long long int x = 0;
  while (s.at(x) == '1') {
    x++;
  }
  if (x >= k) {
    cout << '1' << endl;
  } else {
    cout << s.at(x) << endl;
  }
}

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

int main() {
  string s;
  long long int k;
  cin >> s >> k;
  long long int x = 0;
  for (long long int i = 0; i < s.size(); i++) {
    if (s.at(x) == '1') {
      x++;
    } else {
      break;
    }
  }
  if (x >= k) {
    cout << '1' << endl;
  } else {
    cout << s.at(x) << endl;
  }
}
Problem p03282 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define forx(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
  string s;
  ll k, a = 0;
  cin >> s >> k;
  if (s[0] != '1')
    cout << s[0] << endl;
  else {
    while (s[a] = '1')
      a++;
    if (k <= a)
      cout << 1 << endl;
    else
      cout << s[a] << endl;
  }
  return 0;
}

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

int main() {
  string s;
  ll k, a = 0;
  cin >> s >> k;
  if (s[0] != '1')
    cout << s[0] << endl;
  else {
    for (a; a < s.size(); a++) {
      if (s[a] != '1')
        break;
    }
    if (k <= a)
      cout << 1 << endl;
    else
      cout << s[a] << endl;
  }
  return 0;
}
Problem p03282 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9 + 7;

int main() {
  int k;
  string s;
  cin >> s >> k;
  int non_one;
  if (s[0] != '1') {
    cout << s[0] << endl;
    return 0;
  }

  rep(i, s.size()) {
    if (s[i] != '1') {
      non_one = i;
      break;
    }
  }
  // non_one++;
  if (non_one + 1 > k)
    cout << 1 << endl;
  else
    cout << s[non_one] << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9 + 7;

int main() {
  ll k;
  string s;
  cin >> s >> k;
  int non_one;
  if (s[0] != '1') {
    cout << s[0] << endl;
    return 0;
  }

  rep(i, s.size()) {
    if (s[i] != '1') {
      non_one = i;
      break;
    }
  }
  // non_one++;
  if (non_one + 1 > k)
    cout << 1 << endl;
  else
    cout << s[non_one] << endl;
  return 0;
}
Problem p03282 (Python)

Buggy submission (status: Runtime Error):
s = list(input())
k = int(input())
number = 0
count = 0
for i in range(k):
    if s[i] == "1":
        count += 1
        if count == k - 1:
            number = 1
    elif s[i] != "1" and number == 0:
        number = s[i]
print(number)


Fixed submission:
s = list(input())
k = int(input())
for i in range(min(len(s), k)):
    if s[i] != "1":
        print(s[i])
        exit()
print(1)
Problem p03282 (Python)

Buggy submission (status: Runtime Error):
def solve(string):
    s, k = string.split()
    if len(s) == 1:
        return s
    counter = 0
    for _s in str(s):
        if _s == "1":
            counter += 1
            continue
        break
    return "1" if len(k) < 4 and int(k) < counter else s[counter]


if __name__ == "__main__":
    print(solve("\n".join([input(), input()])))


Fixed submission:
def solve(string):
    s, k = string.split()
    if len(s) == 1:
        return s
    counter = 0
    for _s in str(s):
        if _s == "1":
            counter += 1
            continue
        break
    return "1" if len(k) < 4 and int(k) <= counter else s[counter]


if __name__ == "__main__":
    print(solve("\n".join([input(), input()])))
Problem p03282 (Python)

Buggy submission (status: Runtime Error):
s = input()
k = int(input())
idx = 0
while idx < len(s) and s[idx] == "1":
    idx += 1
if k < idx:
    print(1)
else:
    print(s[idx])


Fixed submission:
s = input()
k = int(input())
idx = 0
while idx < len(s) and s[idx] == "1":
    idx += 1
if k <= idx or idx == len(s):
    print(1)
else:
    print(s[idx])
Problem p03282 (Python)

Buggy submission (status: Runtime Error):
s = input()
k = int(input())

while True:
    if s[0] == "1":
        s = s[1:]
    elif s[0] != "1":
        ans = s[0]
        break
    if s == []:
        ans = 1
        break
print(ans)


Fixed submission:
s = input()
k = int(input())

if s[0] != "1":
    print(s[0])
else:
    len_1 = 0
    while True:
        if s == "1":
            len_1 = 1
            ans = 1
            break
        if s[0] == "1":
            s = s[1:]
            len_1 += 1
        elif s[0] != "1":
            ans = s[0]
            break
    if k > len_1:
        print(ans)
    else:
        print("1")
Problem p03282 (Python)

Buggy submission (status: Runtime Error):
S = input()
K = int(input())
firstNot1 = [i for i in range(len(S)) if S[i] != "1"][0]

print("1" if firstNot1 >= K else S[firstNot1])


Fixed submission:
S = input()
K = int(input())
firstNot1 = ([i for i in range(len(S)) if S[i] != "1"] + [len(S)])[0]

print("1" if firstNot1 >= K else S[firstNot1])
Problem p03282 (Python)

Buggy submission (status: Runtime Error):
S = input()
k = input()

if S[0] == "1":
    cnt = 0
    for s in S:
        if s == "1":
            cnt += 1
        else:
            not1 = s
            break
    if k <= cnt:
        print(1)
    else:
        print(not1)
else:
    print(S[0])


Fixed submission:
S = input()
k = int(input())

if S[0] == "1":
    cnt = 0
    for s in S:
        if s == "1":
            cnt += 1
        else:
            not1 = s
            break
    if k <= cnt:
        print(1)
    else:
        print(not1)
else:
    print(S[0])
Problem p03282 (Python)

Buggy submission (status: Runtime Error):
s = input()
k = int(input())
i = 0
while i < k and s[i] == "1":
    i += 1
print(s[i])


Fixed submission:
s = input()
k = int(input()) - 1
i = 0
while i < k and s[i] == "1":
    i += 1
print(s[i])
Problem p03282 (Python)

Buggy submission (status: Runtime Error):
# -*- coding: utf-8 -*-


def main():
    s = input()
    k = int(input())
    one_count = 0

    for si in s:
        if si == "1":
            one_count += 1
        else:
            break

    if s[0] == "1":
        if k == 1:
            print(s[0])
        elif one_count >= k:
            print(1)
        elif one_count < k:
            print(s[k - 1])
        else:
            print(s[1])
    else:
        print(s[0])


if __name__ == "__main__":
    main()


Fixed submission:
# -*- coding: utf-8 -*-


def main():
    s = input()
    k = int(input())
    one_count = 0

    for si in s:
        if si == "1":
            one_count += 1
        else:
            break

    if s[0] == "1":
        if k == 1:
            print(s[0])
        elif one_count >= k:
            print(1)
        elif one_count < k:
            print(s[one_count])
        else:
            print(s[1])
    else:
        print(s[0])


if __name__ == "__main__":
    main()
Problem p03282 (Python)

Buggy submission (status: Runtime Error):
def solve():
    s = input()
    return [c for c in s if c != "1"][0]


if __name__ == "__main__":
    print(solve())


Fixed submission:
def solve():
    s = input()
    k = int(input())
    head_ones = 0
    for c in s:
        if c != "1":
            break
        else:
            head_ones += 1

    return "1" if head_ones >= k else [c for c in s if c != "1"][0]


if __name__ == "__main__":
    print(solve())
Problem p03282 (Python)

Buggy submission (status: Runtime Error):
list_s = list(str(input()))
k = int(input())
for i in range(len(list_s)):
    if list_s[i] != "1":
        bord = i
        break
if k <= bord:
    print(1)
else:
    print(list_s[i])


Fixed submission:
list_s = list(str(input()))
k = int(input())
bord = 10**9
for i in range(len(list_s)):
    if list_s[i] != "1":
        bord = i
        break
if k <= bord:
    print(1)
else:
    print(list_s[i])
Problem p03282 (Python)

Buggy submission (status: Runtime Error):
s = input()
k = int(input())

for i in range(min(k, len(s))):
    if s[i] != "1":
        ans = s[i]
        break

print(ans)


Fixed submission:
s = input()
k = int(input())

ans = s[0]
for i in range(min(k, len(s))):
    if s[i] != "1":
        ans = s[i]
        break

print(ans)
Problem p03282 (C++)

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

using namespace std;

const ll mod = 1000000007;
const ll inf = 1e18;

int main() {

  string s;
  string t;
  cin >> s >> t;

  if (t.size() >= 4) {
    for (ll i = 0; i < s.size(); i++) {
      if (s[i] != '1') {
        cout << s[i] << endl;
        return s[i];
      }
    }
  }
  ll k = stoi(t);
  if (k <= s.size()) {
    for (ll i = 0; i < k; i++) {
      if (s[i] != '1') {
        cout << s[i] << endl;
        return 0;
      }
    }
    cout << 1 << endl;
    ;
  } else {
    for (ll i = 0; i < s.size(); i++) {
      if (s[i] != '1') {
        cout << s[i] << endl;
        return 0;
      }
    }
  }
}

Fixed submission:
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod = 1000000007;
const ll inf = 1e18;

int main() {

  string s;
  string t;
  cin >> s >> t;

  if (t.size() >= 4) {
    for (ll i = 0; i < s.size(); i++) {
      if (s[i] != '1') {
        cout << s[i] << endl;
        return 0;
      }
    }
  }
  ll k = stoi(t);
  if (k <= s.size()) {
    for (ll i = 0; i < k; i++) {
      if (s[i] != '1') {
        cout << s[i] << endl;
        return 0;
      }
    }
    cout << 1 << endl;
    ;
  } else {
    for (ll i = 0; i < s.size(); i++) {
      if (s[i] != '1') {
        cout << s[i] << endl;
        return 0;
      }
    }
  }
}