Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p04015 (python)

Fixed submission:
N, A = map(int, input().split())
X = [int(a) for a in input().split()]
PO = [x-A for x in X if x > A]
NE = [A-x for x in X if x < A]
ZE = N - len(PO) - len(NE)

Y = [1] + [0] * 3000
Z = [1] + [0] * 3000

for i in PO:
    for j in range(2800)[::-1]:
        Y[i+j] += Y[j]
for i in NE:
    for j in range(2800)[::-1]:
        Z[i+j] += Z[j]

ans = -1
for i in range(len(Y)):
    ans += Y[i] * Z[i] * (2**ZE)
print(ans)

Buggy submission (verdict: Runtime Error):
N, A = map(int, input().split())
X = [int(a) for a in input().split()]
PO = [x-A for x in X if x > A]
NE = [A-x for x in X if x < A]
ZE = N - len(PO) - len(NE)

Y = [1] + [0] * 3000
Z = [1] + [0] * 3000

for i in PO:
    for j in range(len(Y) - A)[::-1]:
        Y[i+j] += Y[j]
for i in NE:
    for j in range(len(Z) - A)[::-1]:
        Z[i+j] += Z[j]

ans = -1
for i in range(len(Y)):
    ans += Y[i] * Z[i] * (2**ZE)
print(ans)

Buggy submission (verdict: Runtime Error):
N, A = map(int, input().split())
X = [int(a) for a in input().split()]
PO = [x-A for x in X if x > A]
NE = [A-x for x in X if x < A]
ZE = N - len(PO) - len(NE)

Y = [1] + [0] * (N*50)
Z = [1] + [0] * (N*50)

for i in PO:
    for j in range(len(Y) - A)[::-1]:
        Y[i+j] += Y[j]
for i in NE:
    for j in range(len(Z) - A)[::-1]:
        Z[i+j] += Z[j]

ans = -1
for i in range(len(Y)):
    ans += Y[i] * Z[i] * (2**ZE)
print(ans)
Problem p02536 (python)

Fixed submission:
class UnionFind:
    def __init__(self, n: int) -> None:
        self.forest = [-1] * n

    def union(self, x: int, y: int) -> None:
        x = self.findRoot(x)
        y = self.findRoot(y)
        if x == y:
            return
        if self.forest[x] > self.forest[y]:
            x,y = y,x
        self.forest[x] += self.forest[y]
        self.forest[y] = x
        return

    def findRoot(self, x: int) -> int:
        if self.forest[x] < 0:
            return x
        else:
            self.forest[x] = self.findRoot(self.forest[x])
            return self.forest[x]

    def issame(self, x: int, y: int) -> bool:
        return self.findRoot(x) == self.findRoot(y)

    def size(self,x: int) -> int:
        return -self.forest[self.findRoot(x)]


n,m = map(int,input().split())
uf = UnionFind(n)
s = set()
for i in range(m):
    ai,bi = map(int,input().split())
    uf.union(ai-1,bi-1)

for i in range(n):
    s.add(uf.findRoot(i))
print(len(s)-1)

Buggy submission (verdict: Runtime Error):
from scipy.sparse.csgraph import connected_components
import numpy as np


n,m = map(int,input().split())
g = np.zeros((n,n),dtype=np.int)
for i in range(m):
    ai,bi = map(int,input().split())
    g[ai-1][bi-1] = 1
    g[bi-1][ai-1] = 1
r = connected_components(g,return_labels=False)
print(r-1)
Problem p02582 (python)

Fixed submission:
s = input()
ans = 0
a = 0
for si in s:
    if si == "R":
        a += 1
    else:
        ans = max(ans,a)
        a = 0
print(max(ans,a))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input().split())
p = list(map(int,input().split()))
c = list(map(int,input().split()))

ans = -float("INF")
for i in range(n):
    pi = p[i]
    x = c[pi-1]
    a = x
    for j in range(k-1):
        pi = p[pi-1]
        a = max(a,x+c[pi-1])
        x += c[pi-1]
    ans = max(ans,a)
print(ans)
Problem p02608 (python)

Fixed submission:
import math
n = int(input())
ans = [0] * n
a = math.floor(n**0.5)
b = 0
for x in range(1, a):
    for y in range(1, a):
        for z in range(1, a):
            m = x * x + y * y + z * z + x * y + y * z + z * x
            if m <= n:
                ans[m - 1] += 1

for i in range(n):
    print(ans[i])

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> ans(n+1);
    for (int x = 1; x <= 100; x++)
    {
        for (int y = 1; y <= 100; y++)
        {
            for (int z = 1; z <= 100; z++)
            {
                int m = x * x + y * y + z * z + x * y + y * z + z * x;
                if (m <= n)
                {
                    ans[m]++;
                }
                else
                {
                    break;
                }
            }
        }
    }
    rep(i,n){
        cout << ans[i+1] << "\n";
    }
}
Problem p02628 (python)

Fixed submission:
n,k = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
print(sum(p[:k]))

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

int main() {
    int n,k,ans = 0;
    cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    sort(p.begin(), p.end());
    rep(i,k) ans+=p[i];
    cout << ans << endl;
}
Problem p02675 (python)

Fixed submission:
n = input()
x = int(n[-1])
if x in [2,4,5,7,9]:
    print("hon")
elif x in [0,1,6,8]:
    print("pon")
elif x == 3:
    print("bon")

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

int main()
{
    int n;
    vector<string> s;
    s = {"p","p","h","b","h","h","p","h","p","h"};
    cin >> n;
    int x = n%10;
    cout << s[x] << "on" << endl;
}
Problem p02748 (python)

Fixed submission:
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [tuple(map(int,input().split())) for i in range(m)]
p = min(a)+min(b)
for t in c:
    p = min(p,a[t[0]-1]+b[t[1]-1]-t[2])
print(p)

Buggy submission (verdict: Runtime Error):
a,b,m = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = [tuple(map(int,input().split())) for i in range(m)]
p = [min(a)+min(b)]
for t in c:
    p.append((p,a[t[0]-1]+b[t[1]-1]-t[2])
print(min(p))
Problem p02761 (python)

Fixed submission:
n,m = map(int,input().split())
x = [tuple(map(int,input().split())) for i in range(m)]
f=True
for i in range(0,1001):
    i = str(i)
    if len(i)==n:
        if all([i[t[0]-1]==str(t[1]) for t in x]):
            print(i)
            f=False
            break
if f:
    print(-1)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
sc = [tuple(map(int,input().split())) for i in range(m)]
l = [0]*n
for t in sc:
    l[t[0]-1] = t[1]
if sc[0][0]!=1 and sc[0][1]==0:
    l[0]=1
    print("".join([str(s) for s in l]))
elif l[0]==0:
    print(-1)
else:
    print("".join([str(s) for s in l]))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
sc = [tuple(map(int,input().split())) for i in range(m)]
l = [0]*n
for t in sc:
    l[t[0]-1] = t[1]
if sc[0][0]!=1 and sc[0][1]==0:
    l[0]=1
    print("".join([str(s) for s in l]))
else:
    if l[0]==0:
        print(-1)

Buggy submission (verdict: Runtime Error):
a = -1
n,m = map(int, input().split())
s_and_c = [tuple(map(int,input().split())) for i in range(m)]
s = []
c = []
l = [0]*m
for t in s_and_c:
  l[t[0]-1] = t[1]
for _ in s_and_c:
  s.append(_[0])
  c.append(_[1])
if max(s) == n and l[0] == len(l)-1 or l[0] != 0:
  a = "".join([str(i) for i in l])
else:
  pass
print(a)

Buggy submission (verdict: Runtime Error):
a = -1
n,m = map(int, input().split())
s_and_c = [tuple(map(int,input().split())) for i in range(m)]
s = []
c = []
l = [0]*m
for t in s_and_c:
  l[t[0]-1] = t[1]
for _ in s_and_c:
  s.append(_[0])
  c.append(_[1])
if max(s) == n and l[0] != 0:
  a = "".join([str(i) for i in l])
else:
  pass
print(a)

Buggy submission (verdict: Runtime Error):
a = -1
n,m = map(int, input().split())
s_and_c = [tuple(map(int,input().split())) for i in range(m)]
s = []
c = []
l = [0]*m
for t in s_and_c:
  l[t[0]-1] = t[1]
for _ in s_and_c:
  s.append(_[0])
  c.append(_[1])
if max(s) == n:
  a = "".join([str(i) for i in l])
else:
  pass
print(a)

Buggy submission (verdict: Runtime Error):
a = -1
n,m = map(int, input().split())
s_and_c = [tuple(map(int,input().split())) for i in range(m)]
l = [0]*m
for t in s_and_c:
  l[t[0]-1] = t[1]
if len(l) == n:
  a = "".join([str(i) for i in l])
else:
  pass
print(a)
Problem p02789 (python)

Fixed submission:
N, M = map(int, input().split())
if N == M:
  print("Yes")
elif N != M:
  print("No")

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
if N == M:
  print(Yes)
elif N != M:
  print(No)
Problem p02802 (python)

Fixed submission:
n,m = map(int,input().split())
ac,wa = 0,0
d = {}
for i in range(m):
  p,s = input().split()
  if p in d:
    if d[p][1]:
      pass
    else:
      if s=="WA":
          d[p][0]+=1
      elif s=="AC":
          d[p][1]=True
          ac+=1
          wa+=d[p][0]
  else:
    if s=="WA":
      d[p]=[1,False]
    elif s=="AC":
      d[p]=[0,True]
      ac+=1
print(ac,wa)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
ac,wa = 0,0
d = {}
for i in range(m):
  p,s = input().split()
  if p in d:
    if s=="WA":
      if d[p]:
        pass
      else:
        WA+=1
    elif s=="AC":
      if d[p]:
        pass
      else:
        d[p]=True
        ac+=1
  else:
    if s=="WA":
      d[p]=False
      wa+=1
    else:
      d[p]=True
      ac+=1
print(ac,wa)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
up = [input().split() for i in range(m)]

wa,ac = 0,0
if m==0:
    print(0,0)
else:
    k = [[] for i in range(2)]
    f=0
    temp=up[0]
    for t in up:
        if not temp[0]==t[0]:
            f+=1
        k[f].append(t)
        temp=t
    temp = False
    for qrs in k:
        for qr in qrs:
            if qr[1] == "WA":
                wa+=1
            elif qr[1] == "AC" and not temp:
                ac+=1
                break
    print(ac,wa)

Buggy submission (verdict: Runtime Error):
up = [input().split() for i in range(m)]

wa,ac = 0,0
if m==0:
    print(0,0)
else:
    k = [[] for i in range(2)]
    f=0
    temp=up[0]
    for t in up:
        if not temp[0]==t[0]:
            f+=1
        k[f].append(t)
        temp=t
    temp = False
    for qrs in k:
        for qr in qrs:
            if qr[1] == "WA":
                wa+=1
            elif qr[1] == "AC" and not temp:
                ac+=1
                break
    print(ac,wa)
Problem p02917 (python)

Fixed submission:
n = int(input())
b = list(map(int,input().split()))
a = [0]*n
a[0] = b[0]
a[-1] = b[-1]
for i in range(1,n-1):
    a[i] = min(b[i-1],b[i])
print(sum(a))

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int a[n];
    int b[n-1]; rep(i,n-1) cin >> b[i];

    a[0] = b[0];
    a[n-1] = b[n-2];
    for (int i = 1; i<(n-1); i++) {
        a[i] = min(b[i-1],b[i]);
    }
    ll ans = 0;
    rep(i,n) ans += a[i];
    cout << ans << "\n";
}
Problem p02936 (python)

Fixed submission:
from collections import defaultdict, deque
import sys
sys.setrecursionlimit(10**9)


N, Q = map(int, input().split())
count = [0] * N
parent = defaultdict(int)
t = [[] for i in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    t[a - 1].append(b)
    t[b - 1].append(a)

for i in range(Q):
    p, x = map(int, input().split())
    count[p - 1] += x


f = [False] * N
q = deque([1])
while(q):
    n = q.popleft()
    f[n-1] = True
    for i in t[n-1]:
        if f[i-1]:
            continue
        q.append(i)
        count[i-1]+=count[n-1]
        f[i-1] = True
#for i in range(1, N):
#    count[i] += count[parent[i + 1] - 1]
#print(parent)
print(*count)

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
c = [0] * n
l = {}
for i in range(n - 1):
    a, b = map(int, input().split())
    l[b] = a
for i in range(q):
    p, x = map(int, input().split())
    c[p - 1] += x
for i in range(2, n + 1):
    c[i - 1] += c[l[i] - 1]
print(*c)
Problem p02953 (python)

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
x = h[-1]
ans = "Yes"
for i in reversed(range(n - 1)):
    hi = h[i]
    if hi <= x:
        pass
    else:
        if abs(x - hi) >= 2:
            ans = "No"
        else:
            h[i] -= 1
    x = h[i]
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
x = h[-1]
ans = "Yes"
for i in reversed(range(n - 1)):
    print(h)
    hi = h[i]
    if hi <= x:
        pass
    else:
        if abs(x - hi) >= 2:
            ans = "No"
        else:
            h[i] -= 1
    x = hi
print(ans)
Problem p02957 (python)

Fixed submission:
a,b = map(int,input().split())
f=True
if a%2 == b%2:
  print((a+b)//2)
else:
  print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
a,b = map(int,input(),split())
f=True
for i in range(max(a,b)):
  if abs(a-i)==abs(b-i):
    print(i)
    f=False
    break
if f:
  print("IMPOSSIBLE")
Problem p02981 (python)

Fixed submission:
n,a,b = map(int,input().split())
if b > n*a:
  print(a*n)
elif b < a*a:
  print(b)
else:
  print(b)

Buggy submission (verdict: Runtime Error):
n,a,b = map(int,input().split())
if b > n*a:
  print(a*c)
elif b < a*a:
  print(b)
else:
  print(b)
Problem p03000 (python)

Fixed submission:
n,x = map(int,input().split())
l = list(map(int,input().split()))
m = 1
a = 0
for i in l:
    a+=i
    if a<=x:
        m+=1
print(m)

Buggy submission (verdict: Runtime Error):
n,x = map(int,input().split())
l = list(map(int,input().split()))
m = 0
a = 0
while(a<=x):
    a+=l.pop(0)
    m+=1
print(m)
Problem p03086 (python)

Fixed submission:
a="".join(["1" if s in ["A","C","G","T"] else "0" for s in input()])
ans=[len(s) for s in a.split("0")]
print(max(ans))

Buggy submission (verdict: Runtime Error):
print(max([len(s) for s in "".join(["1" if s in ["A","C","G","T"] else " " for s in input()]).split()]))
Problem p03164 (python)

Fixed submission:
n,W = map(int,input().split())
w,v = [],[]
for i in range(n):
    wi,vi = map(int,input().split())
    w.append(wi)
    v.append(vi)
mv = sum(v)
INF = float("INF")
dp = [[INF]*(mv+100) for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
    for sv in range(mv+100):
        if sv-v[i] >= 0:
            dp[i+1][sv] = min(dp[i+1][sv],dp[i][sv-v[i]]+w[i])
        dp[i+1][sv] = min(dp[i+1][sv],dp[i][sv])
    #print(dp)
ans = 0
for i in range(mv+100):
    #print(dp[n][i])
    if dp[n][i] <= W:
        ans = max(ans,i)
print(ans)

Buggy submission (verdict: Runtime Error):
from requests import api

n,W = map(int,input().split())
w,v = [],[]
for i in range(n):
    wi,vi = map(int,input().split())
    w.append(wi)
    v.append(vi)
sv = sum(v)
INF = float("INF")
dp = [[INF]*sv for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
    for j in range(sv):
        if j-v[i] >= 0:
            dp[i+1][j] = min(dp[i+1][j],dp[i][j-v[i]]+w[i])
        dp[i+1][j] = min(dp[i+1][j],dp[i][j])
    #print(dp)
ans = 0
for i in range(sv):
    #print(dp[n][i])
    if dp[n][i] <= W:
        ans = max(ans,i)
print(ans)

Buggy submission (verdict: Runtime Error):
from requests import api

n,W = map(int,input().split())
w,v = [],[]
for i in range(n):
    wi,vi = map(int,input().split())
    w.append(wi)
    v.append(vi)
sv = sum(v)
INF = float("INF")
dp = [[INF]*sv for i in range(n+1)]
dp[0][0] = 0
for i in range(n):
    for j in range(sv):
        if j-v[i] >= 0:
            dp[i+1][j] = min(dp[i+1][j],dp[i][j-v[i]]+w[i])
        dp[i+1][j] = min(dp[i+1][j],dp[i][j])
    #print(dp)
ans = 0
for i in range(sv):
    print(dp[n][i])
    if dp[n][i] <= W:
        ans = max(ans,i)
print(ans)
Problem p03244 (python)

Fixed submission:
from collections import Counter
n = int(input())
v = list(map(int,input().split()))

if len(set(v)) == 1:
    print(n//2)
else:

    c1 = Counter(v[::2])
    c2 = Counter(v[1::2])
    o = c1.most_common(2)
    e = c2.most_common(2)
    o.append((0,0))
    e.append((0,0))
    if o[0][0] == e[0][0]:
        print(min(n-o[1][1]-e[0][1],n-o[0][1]-e[1][1]))
    else:
        print(n-o[0][1]-e[0][1])

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
v = list(map(int,input().split()))

if len(set(v)) == 1:
    print(n//2)
else:

    c1 = Counter(v[::2])
    c2 = Counter(v[1::2])
    o = c1.most_common(2)
    e = c2.most_common(2)
    o.append((0,0))
    e.append((0,0))
    if o[0][0] == e[0][0]:
        print(min(n-o[1][1]-e[0][1],n-o[0][1]-e[1][1]))
    else:
        print(n-o(2)[0][1]-e(2)[0][1])
Problem p03493 (python)

Fixed submission:
a = 0
s = input()
for i in s:
    if i == '1':
        a = a + 1
print(a)

Buggy submission (verdict: Runtime Error):
n = input()
A = list(map(int, input().split()))

_ = 0
while all(a % 2 == 0 for a in A):
    A = [i/2 for i in A]
    _ += 1
print(_)
Problem p03565 (python)

Fixed submission:
sd = input()
t = input()
oks = []
if len(sd) < len(t):
    print("UNRESTORABLE")
else:
    for i in range(len(sd)-len(t)+1):
        sdd = sd[i:i+len(t)]
        f = True
        for j,sddj in enumerate(sdd):
            if sddj == "?":
                continue
            elif sddj != t[j]:
                f = False
                break
        if f:
            oks.append(i)
    if oks:
        k = oks[-1]
        print((sd[:k]+t+sd[k+len(t):]).replace("?","a"))
    else:
        print("UNRESTORABLE")

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
w = []
for i in range(len(s) - len(t) + 1):
    f = True
    sx = s[i:i + len(t)]
    for si, ti in zip(sx, t):
        if si != ti and si != "?":
            f = False
        else:
            pass
    if f:
        w.append((s[:i] + t).replace("?", "a"))
if w == []:
    print("UNRESTORABLE")
else
w.sort()
print(w[0])
Problem p03597 (python)

Fixed submission:
n=int(input())
m=int(input())
print((n*n)-m)

Buggy submission (verdict: Runtime Error):
n=int(input())
m=int(input())
print((i*i)-m)
Problem p03607 (python)

Fixed submission:
from collections import Counter
n = int(input())
a = [int(input()) for i in range(n)]
ans = 0
c = Counter(a)
for i in c.values():
    if i%2!=0:
        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[int(input()) for i in range(n)]
cx=[0]*max(a)
for ai in a:
  cx[ai-1]+=1
ans=0
for ci in cx:
  if ci%2!=0:
    ans+=1
print(ans)
Problem p03611 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
an = [0]*(max(a)+2)
for i in a:
  if i!=0:
    an[i-1]+=1
  an[i+1]+=1
  an[i]+=1
print(max(an))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
an = [0]*(max(a)+1)
for i in a:
  an[i-1]+=1
  an[i-2]+=1
  an[i]+=1
print(max(an))
Problem p03807 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
if sum(a)%2==0:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
n=int(input().split())
a=list(map(int,input().split()))
if sum(a)%2==0:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
if len(a)%3 == 0
  print("YES")
else:
  print("NO")
Problem p03937 (python)

Fixed submission:
def search(y,x,oy,ox,r):
    if y == h-1 and x == w-1:
        return r
    l = []
    for i,j in t:
        ny,nx = y+i,x+j
        if (0 <= ny < h and 0 <= nx < w) and not (ny == oy and nx == ox):
            if a[ny][nx] == "#":
                l.append((ny,nx))

    if 1 < len(l) or len(l) == 0:
        return r
    else:
        r.add((l[0][0],l[0][1]))
        return search(l[0][0],l[0][1],y,x,r)

h,w = map(int,input().split())
a = [list(input()) for i in range(h)]
t = ((0,1),(1,0))

s = search(0,0,0,0,set([(0,0),(h-1,w-1)]))
f = True
for i in range(h):
    for j in range(w):
        if a[i][j] == "#" and not (i,j) in s:
            print("Impossible")
            exit(0)
print("Possible")

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    short h,w,ans = 0;
    cin >> h >> w;
    char ai[10];
    rep(i,h) {
        cin >> ai;
        rep(j,8) if (ai[j] == '#') ans ++;
    }
    if (ans == h+w-1) cout << "Possible\n";
    else cout << "Impossible\n";
}
Problem p03945 (python)

Fixed submission:
s = input()
ans = 0
p = s[0]
for si in s:
    ans += p != si
    p = si
print(ans)

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <string>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int ans = 0;
    cin >> s;
    rep(i,s.size()-1) {
        if (s[i] != s[i+1]) {
            ans++;
        }
    }
    cout << ans << "\n";
}

Buggy submission (verdict: Runtime Error):
#include <iostream>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int ans = 0;
    cin >> s;
    rep(i,s.size()-1) {
        if (s[i] != s[i+1]) {
            ans++;
        }
    }
    cout << ans << "\n";
}
Problem p02621 (python)

Fixed submission:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a = I()
    print(a+a**2+a**3)
    return

#Solve
if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
mem = defaultdict(lambda : None)
mem[(0,0,0)] = 0
def dp(a,b,s):
  if mem[(a,b,s)] is not None:
    return mem[(a,b,s)]
  x = a&1
  y = b&1
  xor = s&1
  res = float("inf")
  if x^y != xor:
    mem[(a,b,s)] = res
    return res
  else:
    res = 2*dp(a>>1,b>>1,s>>1)
    if a > 1:
      pants = 2*dp((a-1)>>1,(b+1)>>1,s>>1)+1
      if pants < res:
        res = pants
  mem[(a,b,s)] = res
  return res

n = int(input())
a = list(map(int, input().split()))
s = 0
for i in a[2:]:
  s ^= i
b = a[1]
a = a[0]
ans = dp(a,b,s)
if ans == float("inf"):
  ans = -1
print(ans)