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

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x) {
  if (x <= 1)
    return false;
  for (ll i = 2; sqrt(i) <= x; i++)
    if (x % i == 0)
      return false;
  return true;
}

int main() {
  int n;
  cin >> n;
  string s;
  FOR(i, 0, n) cin >> s.at(i);

  FOR(i, 0, s.size()) { s.at(i) = (s.at(i) - 'A' + n) % 26 + 'A'; }
  cout << s << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
#define MOD 1e9 + 7
#define PI 3.141592653589793238
#define pb push_back
#define ALL(V) (V).begin(), (V).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long long int lint;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<int> VI;
typedef pair<ll, ll> P;
ll gcd(ll a, ll b) { return (a % b == 0 ? b : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
ll char_to_ll(char c) { return (int)(c - '0'); }
ll string_to_ll(string s) { return char_to_ll(atoi(s.c_str())); }
bool is_prime(ll x) {
  if (x <= 1)
    return false;
  for (ll i = 2; sqrt(i) <= x; i++)
    if (x % i == 0)
      return false;
  return true;
}

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

  FOR(i, 0, s.size()) { s.at(i) = (s.at(i) - 'A' + n) % 26 + 'A'; }
  cout << s << endl;
  return 0;
}
Problem p02848 (C++)

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

#include <string.h>

using namespace std;

typedef long long ll;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main(void) {
  int N;
  cin >> N;
  char s[32];
  cin >> s;
  int len = strlen(s);

  for (int i = 0; i < len; i++) {
    s[i] = ((s[i] - 'A' + N) % 26) + 'A';
  }

  cout << s << endl;

  return 0;
}


Fixed submission:
#include <iostream>

#include <string.h>

using namespace std;

typedef long long ll;

template <class T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

template <class T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int main(void) {
  int N;
  cin >> N;
  char s[10010];
  cin >> s;
  int len = strlen(s);

  for (int i = 0; i < len; i++) {
    s[i] = ((s[i] - 'A' + N) % 26) + 'A';
  }

  cout << s << endl;

  return 0;
}
Problem p02848 (C++)

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

int main() {
  int N, i, len;
  char S[100];

  cin >> N;
  cin >> S;

  len = strlen(S);

  for (i = 0; i < len; i++) {
    S[i] += N;
    if (S[i] > 'Z')
      S[i] -= 26;
  }

  cout << S << endl;
  return 0;
}


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

int main() {
  int N, i, len;
  char S[10000];

  cin >> N;
  cin >> S;

  len = strlen(S);

  for (i = 0; i < len; i++) {
    S[i] += N;
    if (S[i] > 'Z')
      S[i] -= 26;
  }

  cout << S << endl;
  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
#include <string.h>
int main() {
  int n;
  char s[1000];
  scanf("%d\n %s", &n, s);
  int len = strlen(s);
  for (int i = 0; len > i; i++) {
    int x = s[i] - 'A';
    x = (x + n) % 26;
    putchar('A' + x);
  }
  putchar('\n');
}

Fixed submission:
#include <stdio.h>
#include <string.h>
int main() {
  int n;
  char s[10000];
  scanf("%d\n %s", &n, s);
  int len = strlen(s);
  for (int i = 0; len > i; i++) {
    int x = s[i] - 'A';
    x = (x + n) % 26;
    putchar('A' + x);
  }
  putchar('\n');
}
Problem p02848 (C++)

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

typedef long long ll;
typedef long double ld;
typedef string str;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pair<ll, ll>> vpl;
typedef vector<vl> vvl;
typedef vector<vs> vvs;

#define f(i, start, end) for (i = start; i < end; i++)
#define trav(v) for (auto &x : v)
#define deb(x) cerr << #x << ":" << x << "\n"
#define nl cout << "\n"

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios::sync_with_stdio(0);
  ll t = 1;
  // cin >> t;
  while (t--) {
    ll n, i;
    str s;
    cin >> n;
    cin >> s;
    f(i, 0, s.size()) {
      if (s[i] + n > 'Z')
        s[i] = 'A' + (s[i] + n - 1) % 'Z';
      else
        s[i] += n;
    }
    cout << s;
    nl;
  }
  return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef string str;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pair<ll, ll>> vpl;
typedef vector<vl> vvl;
typedef vector<vs> vvs;

#define f(i, start, end) for (i = start; i < end; i++)
#define trav(v) for (auto &x : v)
#define deb(x) cerr << #x << ":" << x << "\n"
#define nl cout << "\n"

int main() {

  ios::sync_with_stdio(0);
  ll t = 1;
  // cin >> t;
  while (t--) {
    ll n, i;
    str s;
    cin >> n;
    cin >> s;
    f(i, 0, s.size()) {
      if (s[i] + n > 'Z')
        s[i] = 'A' + (s[i] + n - 1) % 'Z';
      else
        s[i] += n;
    }
    cout << s;
    nl;
  }
  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int main() {
  int a;
  char b[1000];
  scanf("%d", &a);
  scanf("%s", b);
  int lena = strlen(b);
  for (int i = 0; i < lena; i++) {
    int e = (int)(b[i]);
    //	printf("%d",e);
    if ((e + a) > 90)
      printf("%c", e + a - 90 + 64);
    else
      printf("%c", e + a);
  }
  return 0;
}


Fixed submission:
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
int main() {
  int a;
  char b[10000000];
  scanf("%d", &a);
  scanf("%s", b);
  int lena = strlen(b);
  for (int i = 0; i < lena; i++) {
    int e = (int)(b[i]);
    //	printf("%d",e);
    if ((e + a) > 90)
      printf("%c", e + a - 90 + 64);
    else
      printf("%c", e + a);
  }
  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>

using namespace std;

int mojisu(char s[]) {
  int i = 0;
  while (s[i]) {
    i++;
  }
  return i;
}
int main() {
  char s[26];
  int n;

  cin >> n;
  cin >> s;

  for (int i = 0; i < mojisu(s); i++) {
    if (s[i] + n <= 'Z') {
      s[i] = s[i] + n;
    } else {
      s[i] = s[i] + n - 'Z' + 'A' - 1;
    }
  }
  cout << s << endl;
}


Fixed submission:
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <vector>

using namespace std;

int mojisu(char s[]) {
  int i = 0;
  while (s[i]) {
    i++;
  }
  return i;
}
int main() {
  char s[10000];
  int n;

  cin >> n;
  cin >> s;

  for (int i = 0; i < mojisu(s); i++) {
    if (s[i] + n <= 'Z') {
      s[i] = s[i] + n;
    } else {
      s[i] = s[i] + n - 'Z' + 'A' - 1;
    }
  }
  cout << s << endl;
}
Problem p02848 (C++)

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

int main() {
  char S[1000];
  int N, dem;
  scanf("%d%s", &N, &S);
  dem = strlen(S);
  for (int i = 0; i < dem; i++) {
    if ((int)S[i] + N > 90)
      printf("%c", S[i] + N - 26);
    else
      printf("%c", S[i] + N);
  }
  return 0;
}


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

int main() {
  char S[10001];
  int N, dem;
  scanf("%d%s", &N, &S);
  dem = strlen(S);
  for (int i = 0; i < dem; i++) {
    if ((int)S[i] + N > 90)
      printf("%c", S[i] + N - 26);
    else
      printf("%c", S[i] + N);
  }
  return 0;
}
Problem p02848 (C++)

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

int main() {
  int N;
  cin >> N;
  string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  string S;
  cin >> S;

  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < 26; j++) {
      if (alphabet.at(i) == S.at(j)) {
        cout << alphabet.at((j + N) % 26);
      }
    }
  }
  cout << endl;
}


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

int main() {
  int N;
  cin >> N;
  string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  string S;
  cin >> S;

  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < 26; j++) {
      if (alphabet.at(j) == S.at(i)) {
        cout << alphabet.at((j + N) % 26);
      }
    }
  }
  cout << endl;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  char str[1002];
  scanf("%s", str);
  for (int i = 0; str[i] != '\0'; i++) {
    int temp = n;
    if (str[i] + n > 'Z') {
      temp = temp - ('Z' - str[i]);
      str[i] = 'A' + (temp - 1);
    } else {
      str[i] = str[i] + n;
    }
  }
  printf("%s", str);

  return 0;
}

Fixed submission:
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  char str[10002];
  scanf("%s", str);
  for (int i = 0; str[i] != '\0'; i++) {
    int temp = n;
    if (str[i] + n > 'Z') {
      temp = temp - ('Z' - str[i]);
      str[i] = 'A' + (temp - 1);
    } else {
      str[i] = str[i] + n;
    }
  }
  printf("%s", str);

  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
#include <string.h>

int main() {
  int n;
  char str[1005];

  scanf("%d", &n);
  scanf("%s", str);

  int len = strlen(str);

  for (int i = 0; i < len; i++) {
    if (str[i] + n > 'Z') {
      str[i] -= 26 - n;
    } else {
      str[i] += n;
    }
  }

  printf("%s", str);
  return 0;
}

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

int main() {
  int n;
  char str[100005];

  scanf("%d", &n);
  scanf("%s", str);

  int len = strlen(str);

  for (int i = 0; i < len; i++) {
    if (str[i] + n > 'Z') {
      str[i] -= 26 - n;
    } else {
      str[i] += n;
    }
  }

  printf("%s", str);
  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of " #var " is %d\n", var)
#define PRINT_ARRAY(name, i)                                                   \
  printf("the value of " #name "[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define pr_arr(name, a, b)                                                     \
  for (int i = (a); i < (b); i++) {                                            \
    for (int j = (a); j < (b); j++) {                                          \
      if (j > (a))                                                             \
        printf(" ");                                                           \
      printf("%lld", name[i][j]);                                              \
    }                                                                          \
    printf("\n");                                                              \
  }

#define YES puts("YES")
#define NO puts("NO")
#define Yes puts("Yes")
#define No puts("No")

using namespace std;

typedef long long ll;

int ans, N;
char S[28];

int main(void) {
  scanf("%d", &N);
  scanf("%s", S);

  rep(i, 0, strlen(S)) {
    int t = S[i] - 'A';
    t = (t + N) % 26;
    S[i] = t + 'A';
  }

  printf("%s\n", S);

  return 0;
}


Fixed submission:
#include <algorithm>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define per(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_INT(var) printf("the value of " #var " is %d\n", var)
#define PRINT_ARRAY(name, i)                                                   \
  printf("the value of " #name "[%d] is %d\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define pr_arr(name, a, b)                                                     \
  for (int i = (a); i < (b); i++) {                                            \
    for (int j = (a); j < (b); j++) {                                          \
      if (j > (a))                                                             \
        printf(" ");                                                           \
      printf("%lld", name[i][j]);                                              \
    }                                                                          \
    printf("\n");                                                              \
  }

#define YES puts("YES")
#define NO puts("NO")
#define Yes puts("Yes")
#define No puts("No")

using namespace std;

typedef long long ll;

int ans, N;
char S[100005];

int main(void) {
  scanf("%d", &N);
  scanf("%s", S);

  rep(i, 0, strlen(S)) {
    int t = S[i] - 'A';
    t = (t + N) % 26;
    S[i] = t + 'A';
  }

  printf("%s\n", S);

  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  string a;
  for (int i = 0; i < 10000; i++) {
    cin >> a[i];
    a[i] = a[i] + n;
    if (a[i] > 90)
      a[i] -= 26;
    cout << a[i];
  }
  return 0;
}

Fixed submission:
#include <iostream>
using namespace std;
int main() {
  int n;
  cin >> n;
  string a;
  cin >> a;
  for (int i = 0; i < a.size(); i++) {

    a[i] = a[i] + n;
    if (a[i] > 90)
      a[i] -= 26;
    cout << a[i];
  }
  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <iostream>
#include <string>
using namespace std;
int n;
string s;

int c(char ch, int a) {
  if (a == 1) {
    if (ch == 'Z')
      return 'A';
    return ch + 1;
  }
  return c(c(ch, 1), a - 1);
}

int main() {
  cin >> n >> s;
  for (int i = 0; i < s.size(); ++i) {
    s[i] = c(s[i], n);
    cout << s[i];
  }
  return 0;
}

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

int c(char ch, int a) {
  if (a == 1) {
    if (ch == 'Z')
      return 'A';
    return ch + 1;
  }
  if (a == 0)
    return ch;
  return c(c(ch, 1), a - 1);
}

int main() {
  cin >> n >> s;
  for (int i = 0; i < s.size(); ++i) {
    s[i] = c(s[i], n);
    cout << s[i];
  }
  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>

int main() {
  char s[50];
  int n, c = 0, m;
  scanf("%d", &n);
  scanf("%s", s);
  while (1) {
    if (s[c] == '\0') {
      break;
    }
    c++;
  }
  for (int i = 0; i < c; i++) {
    m = (int)(s[i] + n);
    if (m <= 90) {
      printf("%c", s[i] + n);
    } else {
      printf("%c", 64 + (m - 90));
    }
  }

  return 0;
}


Fixed submission:
#include <stdio.h>

int main() {
  char s[100000];
  int n, c = 0, m;
  scanf("%d", &n);
  scanf("%s", s);
  while (1) {
    if (s[c] == '\0') {
      break;
    }
    c++;
  }
  for (int i = 0; i < c; i++) {
    m = (int)(s[i] + n);
    if (m <= 90) {
      printf("%c", s[i] + n);
    } else {
      printf("%c", 64 + (m - 90));
    }
  }

  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
char c[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", s[1024];
int main() {
  int i, n;
  scanf("%d", &n);
  scanf("%s", s);
  for (i = 0; i < strlen(s); i++) {
    printf("%c", c[(s[i] - 'A' + n) % 26]);
  }
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
char c[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ", s[10010];
int main() {
  int i, n;
  scanf("%d", &n);
  scanf("%s", s);
  for (i = 0; i < strlen(s); i++) {
    printf("%c", c[(s[i] - 'A' + n) % 26]);
  }
  return 0;
}
Problem p02848 (C++)

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

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

  for (int i = 0; i < s.size(); i++) {
    s.at(i) += n;
    if (s.at(i) > 90) {
      s.at(i) = s.at(i % 90 + 65);
    }
  }
  cout << s << endl;

  return 0;
}

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

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

  for (int i = 0; i < s.size(); i++) {
    s.at(i) += n;
    if (s.at(i) > 90) {
      s.at(i) = (char)s.at(i) % 90 + 64;
    }
  }
  cout << s << endl;

  return 0;
}
Problem p02848 (Python)

Buggy submission (status: Runtime Error):
N = int(input())
S = input()
ans = ""
a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

for i in range(len(S)):
    if a.index(S[i]) + N > 26:
        ans += a[a.index(S[i]) + N - 26]
    else:
        ans += a[a.index(S[i]) + N]

print(ans)


Fixed submission:
N = int(input())
S = input()
ans = ""
a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

for i in range(len(S)):
    if a.index(S[i]) + N > 25:
        ans += a[a.index(S[i]) + N - 26]
    else:
        ans += a[a.index(S[i]) + N]

print(ans)
Problem p02848 (Python)

Buggy submission (status: Runtime Error):
def solve(n: int, s: str) -> str:
    def inc(c: str, n: int) -> str:
        tbl = {
            0: "A",
            1: "B",
            2: "C",
            3: "D",
            4: "E",
            5: "F",
            6: "G",
            7: "H",
            8: "I",
            9: "J",
            10: "K",
            11: "L",
            12: "M",
            13: "N",
            14: "O",
            15: "P",
            16: "Q",
            17: "R",
            18: "S",
            19: "T",
            20: "U",
            21: "V",
            23: "W",
            24: "X",
            25: "Y",
            26: "Z",
        }
        rev_tbl = {v: k for k, v in tbl.items()}
        idx = (rev_tbl[c] + n) % len(tbl)
        return tbl[idx]

    return "".join([inc(c, n) for c in s])


n = int(input().strip())
s = input().strip()
print(solve(n, s))


Fixed submission:
def solve(n: int, s: str) -> str:
    def inc(c: str, n: int) -> str:
        tbl = {
            0: "A",
            1: "B",
            2: "C",
            3: "D",
            4: "E",
            5: "F",
            6: "G",
            7: "H",
            8: "I",
            9: "J",
            10: "K",
            11: "L",
            12: "M",
            13: "N",
            14: "O",
            15: "P",
            16: "Q",
            17: "R",
            18: "S",
            19: "T",
            20: "U",
            21: "V",
            22: "W",
            23: "X",
            24: "Y",
            25: "Z",
        }
        rev_tbl = {v: k for k, v in tbl.items()}
        idx = (rev_tbl[c] + n) % len(tbl)
        return tbl[idx]

    return "".join([inc(c, n) for c in s])


n = int(input().strip())
s = input().strip()
print(solve(n, s))
Problem p02848 (Python)

Buggy submission (status: Runtime Error):
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from EmurateInput import input

N, S = int(input()), input()


def rot_encode(n):
    from string import ascii_lowercase as lc, ascii_uppercase as uc

    lookup = str.maketrans(lc + uc, lc[n:] + lc[:n] + uc[n:] + uc[:n])
    return lambda s: s.translate(lookup)


print(rot_encode(N)(S))


Fixed submission:
N, S = int(input()), input()


def rot_encode(n):
    from string import ascii_lowercase as lc, ascii_uppercase as uc

    lookup = str.maketrans(lc + uc, lc[n:] + lc[:n] + uc[n:] + uc[:n])
    return lambda s: s.translate(lookup)


print(rot_encode(N)(S))
Problem p02848 (Python)

Buggy submission (status: Runtime Error):
def main(n: int, s: str):
    ans = ""
    for _s in s:
        ans += ascii[(ascii.index(_s) + n) % 26]

    print(ans)


if __name__ == "__main__":
    n = int(input())
    s = input()

    main(n, s)


Fixed submission:
from string import ascii_uppercase as ascii


def main(n: int, s: str):
    ans = ""
    for _s in s:
        ans += ascii[(ascii.index(_s) + n) % 26]

    print(ans)


if __name__ == "__main__":
    n = int(input())
    s = input()

    main(n, s)
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
#include <cstring>
using namespace std;
int main() {
  int n, l;
  char a[26], s[1010];
  scanf("%d", &n);
  scanf("%s", s);
  l = strlen(s);
  for (int i = 0; i < 26; i++) {
    a[i] = 'A' + (i + n) % 26;
  }
  for (int i = 0; i < l; i++) {
    printf("%c", a[s[i] - 'A']);
  }
  printf("\n");
}

Fixed submission:
#include <cstdio>
#include <cstring>
using namespace std;
int main() {
  int n, l;
  char a[26], s[10010];
  scanf("%d", &n);
  scanf("%s", s);
  l = strlen(s);
  for (int i = 0; i < 26; i++) {
    a[i] = 'A' + (i + n) % 26;
  }
  for (int i = 0; i < l; i++) {
    printf("%c", a[s[i] - 'A']);
  }
  printf("\n");
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
#include <string.h>
int main() {
  int n, a, i, x = 0;
  char s[26];
  scanf("%d %s", &n, s);
  a = strlen(s);
  for (i = 0; i < a; i++) {
    x = s[i] - 'A';
    x = (x + n) % 26;
    printf("%c", x + 'A');
  }
  printf("\n");
  return 0;
}


Fixed submission:
#include <stdio.h>
#include <string.h>
int main() {
  int n, a, i, x = 0;
  char s[10000];
  scanf("%d %s", &n, s);
  a = strlen(s);
  for (i = 0; i < a; i++) {
    x = s[i] - 'A';
    x = (x + n) % 26;
    printf("%c", x + 'A');
  }
  printf("\n");
  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <tuple>
#include <vector>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v, n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a) + (size))
#define REMOVE(v, a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v, a) (reverse((v), (v) + (a)))
#define LOWER_BOUND(v, a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v, a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
// max_element

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

  char ch[100] = {};
  for (int i = 0; i < S.length(); i++) {
    int a = S[i] - 'A';
    a = (a + N) % 26;
    ch[i] = a + 'A';
  }

  cout << ch << endl;
}


Fixed submission:
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <tuple>
#include <vector>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS(v, n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a) + (size))
#define REMOVE(v, a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v, a) (reverse((v), (v) + (a)))
#define LOWER_BOUND(v, a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v, a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }
// max_element

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

  char ch[11000] = {};
  for (int i = 0; i < S.length(); i++) {
    int a = S[i] - 'A';
    a = (a + N) % 26;
    ch[i] = a + 'A';
  }

  cout << ch << endl;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll ss = s.size();
  vector<ll> num(n);
  rep(i, ss) { num[i] = (ll)(s[i] - 'A'); }

  rep(i, ss) { cout << (char)('A' + ((num[i] + n) % 26)); }
  cout << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<P>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T> inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T> inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

int main() {
  ll n;
  cin >> n;
  string s;
  cin >> s;
  ll ss = s.size();
  vector<ll> num(ss);
  rep(i, ss) { num[i] = (ll)(s[i] - 'A'); }

  rep(i, ss) { cout << (char)('A' + ((num[i] + n) % 26)); }
  cout << endl;

  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  string MOMI = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  int N;
  cin >> N;
  string S;
  cin >> S;

  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < 27; j++) {
      if (S.at(i) == MOMI.at(j)) {
        S.at(i) = MOMI.at(j + N);
      }
    }
  }
  cout << S << endl;
  return 0;
}


Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  string MOMI = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  int N;
  cin >> N;
  string S;
  cin >> S;

  for (int i = 0; i < S.size(); i++) {
    for (int j = 0; j < 27; j++) {
      if (S.at(i) == MOMI.at(j)) {
        S.at(i) = MOMI.at(j + N);
        break;
      }
    }
  }
  cout << S << endl;
  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Time Limit Exceeded):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  char s[100001];
  cin >> n >> s;
  int q = strlen(s);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < q; i++) {
      if (s[j] == 'Z') {
        s[j] = 'A';
      } else {
        s[j]++;
      }
    }
  }
  cout << s << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  char s[100001];
  cin >> n >> s;
  int q = strlen(s);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < q; j++) {
      if (s[j] == 'Z') {
        s[j] = 'A';
      } else {
        s[j]++;
      }
    }
  }
  cout << s << endl;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i = 0;
  char s[100];
  string rot;
  rot = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  cin >> n >> s;
  while (s[i] != '\0') {
    s[i] = rot[s[i] - 'A' + n];
    i++;
  }
  cout << s << endl;

  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, i = 0;
  char s[100000];
  string rot;
  rot = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  cin >> n >> s;
  while (s[i] != '\0') {
    s[i] = rot[s[i] - 'A' + n];
    i++;
  }
  cout << s << endl;

  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <vector>
typedef long long ll;
using namespace std;

char S[10];
int main() {
  int c;
  scanf("%d%s", &c, S);
  int len = strlen(S);
  for (int i = 0; i < len; i++) {
    int x = (S[i] - 'A' + c) % 26;
    S[i] = x + 'A';
  }
  printf("%s", S);
  return 0;
}

Fixed submission:
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <vector>
typedef long long ll;
using namespace std;

char S[10010];
int main() {
  int c;
  scanf("%d%s", &c, S);
  int len = strlen(S);
  for (int i = 0; i < len; i++) {
    int x = (S[i] - 'A' + c) % 26;
    S[i] = x + 'A';
  }
  printf("%s", S);
  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
#define int long long
#define MOD 1000000007
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    s[i] = (s[i] - 65 + n) % 26 + 65;
  }
  cout << s;
}

Fixed submission:
#include <bits/stdc++.h>
#define int long long
#define MOD 1000000007
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    s[i] = (s[i] - 65 + n) % 26 + 65;
  }
  cout << s;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
#include <string.h>
int main() {
  char s[101];
  int N, i, j;
  scanf("%d", &N);
  scanf("%s", s);
  j = strlen(s);
  for (i = 0; i < j; i++) {

    if (s[i] + N > 'Z')
      s[i] = s[i] + N - 26;
    else
      s[i] = s[i] + N;
  }
  printf("%s", s);
  return 0;
}


Fixed submission:
#include <stdio.h>
#include <string.h>
int main() {
  char s[15000];
  int N, i, j;
  scanf("%d", &N);
  scanf("%s", s);
  j = strlen(s);
  for (i = 0; i < j; i++) {

    if (s[i] + N > 'Z')
      s[i] = s[i] + N - 26;
    else
      s[i] = s[i] + N;
  }
  printf("%s", s);
  return 0;
}
Problem p02848 (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() {
  int n;
  cin >> n;
  string s;

  rep(i, n) s[i] = s[i] + '0' + n;
  cout << s << 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() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i, s.size()) { s[i] = (s[i] + 'A' + n) % 26 + 'A'; }
  cout << s << endl;

  return 0;
}
Problem p02848 (C++)

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

int main() {
  int N;
  string S;
  int key = 0;
  int t = 0;

  cin >> N >> S;

  string base;
  base = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";

  for (int i = 0; i < 26; i++) {
    if (S.at(t) == base.at(i)) {
      key = i;
      t++;
      cout << base.at(key + N);
      i = 0;
    }
  }
}

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

int main() {
  int N;
  string S;
  int key = 0;
  int t = 0;

  cin >> N >> S;

  string base;
  base = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ";
  for (int t = 0; t < S.size(); t++) {
    for (int i = 0; i < 26; i++) {
      if (S.at(t) == base.at(i)) {
        key = i;
        cout << base.at(key + N);
      }
    }
  }
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <algorithm>
#include <stack>
#include <stdio.h>
#include <string.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  char a[1000];
  scanf("%s", a);
  int m;
  m = strlen(a);
  for (int i = 0; i < m; i++) {
    if (a[i] + n <= 'Z')
      printf("%c", a[i] + n);
    else
      printf("%c", a[i] + n - 26);
  }
}

Fixed submission:
#include <algorithm>
#include <stack>
#include <stdio.h>
#include <string.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  char a[100000];
  scanf("%s", a);
  int m;
  m = strlen(a);
  for (int i = 0; i < m; i++) {
    if (a[i] + n <= 'Z')
      printf("%c", a[i] + n);
    else
      printf("%c", a[i] + n - 26);
  }
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
char a[30];
int n, lenc;
char c[1004];
int main() {
  for (int i = 0; i < 26; i++) {
    a[i] = i + 65;
  }
  cin >> n;
  cin >> c;
  lenc = strlen(c);
  for (int i = 0; i < lenc; i++) {
    cout << a[(c[i] - 65 + n) % 26];
  }
  cout << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
char a[30];
int n, lenc;
char c[10004];
int main() {
  for (int i = 0; i < 26; i++) {
    a[i] = i + 65;
  }
  cin >> n;
  cin >> c;
  lenc = strlen(c);
  for (int i = 0; i < lenc; i++) {
    cout << a[(c[i] - 65 + n) % 26];
  }
  cout << endl;
  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(a) (a).begin(), (a).end()
typedef pair<int, int> P;
typedef long long ll;

int main() {
  int n;
  char s[10010];
  string S;
  cin >> n >> S;
  rep(i, n) {
    s[i] = S[i];
    int x = s[i] - 'A';
    x = (x + n) % 26;
    char ans = 'A' + x;
    cout << ans;
  }
  cout << endl;
  return 0;
}

Fixed submission:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(a) (a).begin(), (a).end()
typedef pair<int, int> P;
typedef long long ll;

int main() {
  int n;
  char s[10010];
  string S;
  cin >> n >> S;
  rep(i, S.size()) {
    s[i] = S[i];
    int x = s[i] - 'A';
    x = (x + n) % 26;
    char ans = 'A' + x;
    cout << ans;
  }
  cout << endl;
  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
/*
Author: Satya R Samal, NIT Sringar
"Everything in this world is magic, except to the magician"
*/
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define faster ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
using namespace std;

int main() {
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  faster;

  int n;
  string s;

  cin >> n >> s;

  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    ans += 'A' + (s[i] - 'A' + n) % 26;
  }
  cout << ans << endl;
}


Fixed submission:
/*
Author: Satya R Samal, NIT Sringar
"Everything in this world is magic, except to the magician"
*/
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define faster ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
using namespace std;

int main() {

  int n;
  string s;

  cin >> n >> s;

  string ans = "";
  for (int i = 0; i < s.size(); i++) {
    ans += 'A' + (s[i] - 'A' + n) % 26;
  }
  cout << ans << endl;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  string S;
  cin >> N >> S;
  for (int i = 0; i < N; i++) {
    S.at(i) = char((S.at(i) - 65 + N) % 26 + 65);
  }
  cout << S << endl;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  string S;
  cin >> N >> S;
  for (int i = 0; i < S.size(); i++) {
    S.at(i) = char((S.at(i) - 65 + N) % 26 + 65);
  }
  cout << S << endl;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <bits/stdc++.h>
using namespace std;
int main() {
  // 整数の入力
  int n;
  cin >> n;

  // 文字列の入力
  char s[1000];
  cin >> s;

  for (int i = 0; s[i] != 0x00; i++) {
    s[i] += n;
    if (s[i] > 0x5a)
      s[i] -= 26;
  }

  cout << string(s) << endl;
  return 0;
}

Fixed submission:
#include <bits/stdc++.h>
using namespace std;
int main() {
  // 整数の入力
  int n;
  cin >> n;

  // 文字列の入力
  char s[100000];
  cin >> s;

  for (int i = 0; s[i] != 0x00; i++) {
    s[i] += n;
    if (s[i] > 0x5a)
      s[i] -= 26;
  }

  cout << string(s) << endl;
  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  char s[2000];
  scanf("%s", s);
  for (int i = 0; s[i] != '\0'; i++) {
    int oldChar = s[i] - 'A';
    int newChar = (oldChar + n) % 26;
    printf("%c", newChar + 'A');
  }
  printf("\n");
}


Fixed submission:
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  char s[10000];
  scanf("%s", s);
  for (int i = 0; s[i] != '\0'; i++) {
    int oldChar = s[i] - 'A';
    int newChar = (oldChar + n) % 26;
    printf("%c", newChar + 'A');
  }
  printf("\n");
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i, n) s[i] += n;
  cout << s << endl;
}


Fixed submission:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, N) for (int i = 0; i < (int)(N); i++)
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  rep(i, s.size()) { s[i] = (s[i] - 'A' + n) % 26 + 'A'; }
  cout << s << endl;
}
Problem p02848 (C++)

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

int main() {
  int i, n, value;
  char c;
  char b[27];

  cin >> n;
  cin >> b;
  for (i = 0; b[i] != '\0'; i++) {
    if (n == 0)
      printf("%c", b[i]);
    else if (b[i] + n > 90) {
      printf("%c", 64 + (b[i] + n - 90));
    } else
      printf("%c", b[i] + n);
  }
}


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

int main() {
  int i, n, value;
  char c;
  char b[99999];

  cin >> n;
  cin >> b;
  for (i = 0; b[i] != '\0'; i++) {
    if (n == 0)
      printf("%c", b[i]);
    else if (b[i] + n > 90) {
      printf("%c", 64 + (b[i] + n - 90));
    } else
      printf("%c", b[i] + n);
  }
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <stdio.h>
#include <string.h>

char a[110];
int n;
int len;

int main(void) {
  scanf("%d", &n);
  scanf("%s", a);

  len = strlen(a);

  for (int i = 0; i < len; i++) {
    a[i] += n;

    if (a[i] > 'Z')
      a[i] -= 26;

    printf("%c", a[i]);
  }

  return 0;
}

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

char a[10010];
int n;
int len;

int main(void) {
  scanf("%d", &n);
  scanf("%s", a);

  len = strlen(a);

  for (int i = 0; i < len; i++) {
    a[i] += n;

    if (a[i] > 'Z')
      a[i] -= 26;

    printf("%c", a[i]);
  }

  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int n, m;
int main() {
  char s[100];
  int i, j, k;
  cin >> n;
  cin >> s;
  for (i = 0; i < strlen(s); ++i) {
    int x = s[i] + n;
    if (x > 'Z')
      x -= 26;
    s[i] = x;
  }
  cout << s << endl;
  return 0;
}

Fixed submission:
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
int n, m;
int main() {
  char s[100010];
  int i, j, k;
  cin >> n;
  cin >> s;
  for (i = 0; i < strlen(s); ++i) {
    int x = s[i] + n;
    if (x > 'Z')
      x -= 26;
    s[i] = x;
  }
  cout << s << endl;
  return 0;
}
Problem p02848 (C++)

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

int main() {
  int n;
  char s[1005] = {};
  cin >> n >> s;
  int lung = strlen(s);
  for (int i = 0; i < lung; ++i) {
    s[i] = s[i] + n;
    if (s[i] > 'Z')
      s[i] = 'A' + s[i] - 'Z' - 1;
  }
  cout << s;
  return 0;
}


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

int main() {
  int n;
  char s[10001] = {};
  cin >> n >> s;
  int lung = strlen(s);
  for (int i = 0; i < lung; ++i) {
    s[i] = s[i] + n;
    if (s[i] > 'Z')
      s[i] = 'A' + s[i] - 'Z' - 1;
  }
  cout << s;
  return 0;
}
Problem p02848 (C++)

Buggy submission (status: Runtime Error):
/*
我的心脏怦怦跳，监管者就在附近
*/
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#include <cmath>
#include <cstring>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <unistd.h>
#define random(a, b) (rand() % (b - a + 1) + a)
using namespace std;
bool prime(int x) {
  int i;
  if (x < 2)
    return 0;
  for (i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      return 0;
    }
  }
  return 1;
}
int a[1001];
int main() {
  int x;
  cin >> x;
  string st;
  cin >> st;
  int i;
  for (i = 0; i < st.size(); ++i) {
    a[i] = st[i] - 65;
    a[i] += x;
    a[i] %= 26;
    a[i] += 65;
  }
  for (i = 0; i < st.size(); ++i) {
    cout << char(a[i]);
  }
  return 0;
}


Fixed submission:
/*
我的心脏怦怦跳，监管者就在附近
*/
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#include <cmath>
#include <cstring>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <unistd.h>
#define random(a, b) (rand() % (b - a + 1) + a)
using namespace std;
bool prime(int x) {
  int i;
  if (x < 2)
    return 0;
  for (i = 2; i * i <= x; i++) {
    if (x % i == 0) {
      return 0;
    }
  }
  return 1;
}
int a[10005];
int main() {
  int x;
  cin >> x;
  string st;
  cin >> st;
  int i;
  for (i = 0; i < st.size(); ++i) {
    a[i] = st[i] - 65;
    a[i] += x;
    a[i] %= 26;
    a[i] += 65;
  }
  for (i = 0; i < st.size(); ++i) {
    cout << char(a[i]);
  }
  return 0;
}
Problem p02848 (C++)

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

int main() {
  //
  int num;
  string str;
  vector<string> vec(26);
  vec = {"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"};

  cin >> num >> str;

  for (int i = 0; i < str.size(); i++) {
    int tmp = str.at(i) - 'A';
    if (tmp < 24)
      cout << vec.at(tmp + num);
    else
      cout << vec.at((tmp + num) - 26);
  }
  //
}


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

int main() {
  //
  int num;
  string str;
  vector<string> vec(26);
  vec = {"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"};

  cin >> num >> str;

  for (int i = 0; i < str.size(); i++) {
    int tmp = str.at(i) - 'A';
    if (tmp + num < 26)
      cout << vec.at(tmp + num);
    else
      cout << vec.at((tmp + num) - 26);
  }
  //
}
Problem p02848 (C++)

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

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

  string s;
  cin >> s;
  for (int i = 0; i < sizeof(s); i++) {
    s[i] = s[i] + n;
    if (s[i] > 'Z') {
      s[i] = 64 + (s[i] - 'Z');
    }
  }
  cout << s << endl;
  return 0;
}


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

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

  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    s[i] = s[i] + n;
    if (s[i] > 'Z') {
      s[i] = 64 + (s[i] - 'Z');
    }
  }
  cout << s << endl;
  return 0;
}
Problem p02848 (C++)

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

using namespace std;
#define ll long long
#define ld long double
#define P pair<ll, ll>
#define FOR(i, n, m) for (ll i = n; i < (ll)m; i++)
#define FORr(i, m, n) for (ll i = n; i >= (ll)m; i--)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define sortAl(v) sort(v.begin(), v.end())
#define sortAlr(v)                                                             \
  sort(v.begin(), v.end());                                                    \
  reverse(v.begin(), v.end())
#define cout(n) cout << fixed << setprecision(n)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  string s;
  cin >> s;
  vector<char> v(50);
  FOR(i, 0, 70) { v[i] = (i % 26 + 'A'); }

  FOR(i, 0, s.size()) { cout << v[s[i] - 'A' + n]; }
  cout << endl;
}

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

using namespace std;
#define ll long long
#define ld long double
#define P pair<ll, ll>
#define FOR(i, n, m) for (ll i = n; i < (ll)m; i++)
#define FORr(i, m, n) for (ll i = n; i >= (ll)m; i--)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)
#define sortAl(v) sort(v.begin(), v.end())
#define sortAlr(v)                                                             \
  sort(v.begin(), v.end());                                                    \
  reverse(v.begin(), v.end())
#define cout(n) cout << fixed << setprecision(n)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  string s;
  cin >> s;
  vector<char> v(70);
  FOR(i, 0, 70) { v[i] = (i % 26 + 'A'); }

  FOR(i, 0, s.size()) { cout << v[s[i] - 'A' + n]; }
  cout << endl;
}
Problem p02848 (C++)

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

int main() {

  char s[1001];
  int n;
  cin >> n;
  cin >> s;

  for (int i = 0; i < strlen(s); i++) {
    int diff = s[i] - 'A';
    putchar('A' + (diff + n) % 26);
  }

  putchar('\n');
}

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

int main() {

  char s[10010];
  int n;
  cin >> n;
  cin >> s;

  for (int i = 0; i < strlen(s); i++) {
    int diff = s[i] - 'A';
    putchar('A' + (diff + n) % 26);
  }

  putchar('\n');
}
Problem p02848 (C++)

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

int main() {
  int N;
  cin >> N;
  string S,
      T = {'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',
           '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'};
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    bool flag = true;
    for (int j = 0; j < T.size(); j++) {
      if (T.at(j) == S.at(i) && flag == true) {
        S.at(i) = T.at(j + N);
        flag = false;
      }
    }
  }
  cout << S << endl;
}


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

int main() {
  int N;
  cin >> N;
  string S,
      T = {'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',
           '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'};
  cin >> S;
  for (int i = 0; i < S.size(); i++) {
    bool flag = true;
    for (int j = 0; j < T.size(); j++) {
      if (T.at(j) == S.at(i) && flag == true) {
        S.at(i) = T.at(j + N);
        flag = false;
      }
    }
  }
  cout << S << endl;
}