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

Fixed submission:
N = input()
K = int(input())
m = len(N)
dp = [[[0] * (K + 1) for _ in range(2)] for _ in range(m + 1)]
dp[0][0][0] = 1

for i in range(1, m + 1):
    l = int(N[i - 1])
    for k in range(K + 1):
        dp[i][1][k] += dp[i - 1][1][k]
        if l != 0:
            dp[i][1][k] += dp[i - 1][0][k]
        else:
            dp[i][0][k] += dp[i - 1][0][k]
        if k - 1 >= 0:
            dp[i][1][k] += 9 * dp[i - 1][1][k - 1]
            if l != 0:
                dp[i][0][k] += dp[i - 1][0][k - 1]
                dp[i][1][k] += (l - 1) * dp[i - 1][0][k - 1]

print(dp[m][0][K] + dp[m][1][K])

Buggy submission (verdict: Runtime Error):
n=input()
k=int(input())
m=len(n)

DP=[[[0]*(k+1) for _ in range(2)] for _ in range(m+1)]
DP[0][0][0]=1

for i in range(1,m+1):
    for flag in range(2):
        num=9 if flag else int(n[i-1])
        for j in range(k+1):
            for k in range(num+1):
                if k!=0:
                    DP[i][flag or k<=num][j] +=DP[i-1][flag][j-1]
                else:
                    DP[i][flag or k<=num][j] +=DP[i-1][flag][j]
print(DP[-1][0][k]+DP[-1][1][k])
Problem p02833 (python)

Fixed submission:
n=int(input())
if n%2==1:print(0);exit()
A=0
add=10
while n>=add:
    A +=n//add
    add *=5
print(A)

Buggy submission (verdict: Runtime Error):
n=int(input())
if n%2==1:print(0);exit()
A=0
add=10
while n>=add:
    A +=n//add
    add *=5
print(sum(A))
Problem p02891 (python)

Fixed submission:
s=list(input())
k=int(input())
A,B,C=0,0,0
test=s*3
for i in range(len(s)*3-1):
    if test[i]==test[i+1]:
        test[i+1]="A"
A=test[:len(s)].count("A")
B=test[len(s):len(s)*2].count("A")
C=test[len(s)*2:len(s)*3].count("A")

if s.count(s[0])==len(s):
    print((len(s)*k)//2)
else:
    if k==1:print(A)
    elif k==2:print(A+B)
    else:print(A+B*(k-2)+C)

Buggy submission (verdict: Runtime Error):
s=list(input())
k=int(input())
A,B,C=0,0,0
test=s*3
for i in range(len(s)*3-1):
    if test[i]==test[i+1]:
        test[i+1]="A"
A=test[:len(s)].count("A")
B=test[len(s):len(s)*2].count("A")
C=test[len(s)*2:len(s)*3].count("A")

flag=0
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        flag=1
        break
if flag==0:print((s*k+1)//2)
if k==1:print(A)
elif k==2:print(A+B)
else:
    print(A+B*(k-2)+C)

Buggy submission (verdict: Runtime Error):
s=list(input())
k=int(input())
count=0
word=""
for i in range(1,len(s)):
    if s[i]==s[i-1]:
        if i==len(s)-1:
            word=s[i]
        s[i]="A"
        count +=1

if s[0]==s[-1]:
    word=s[-1]
    s[-1]="A"
    count +=1

print((count*k)-1 if (s[-1]=="A")and(s[-2]!=word) else count*k)

Buggy submission (verdict: Runtime Error):
s=list(input())
k=int(input())
count=0
re=""
for i in range(1,len(s)):
    if s[i]==s[i-1]:
        if i==len(s)-1:
            re=s[-1]
        s[i]="A"
        count +=1

if s[0]==s[-1]:
    count +=1
    re=s[-1]
    s[-1]="A"

if (s[-1]=="A") and (s[-2]!=re):
    print((count*k)-1)
    exit()
print(count*k)

Buggy submission (verdict: Runtime Error):
s=list(input())
k=int(input())
count=0
re=""
for i in range(1,len(s)):
    if s[i]==s[i-1]:
        if i==len(s)-1:
            re=s[-1]
        s[i]="A"
        count +=1

if s[0]==s[-1] and s[-1]!="A":
    count +=1
    re=s[-1]
    s[-1]="A"

if s[-1]=="A" and s[-2]!=re:print((count*k)-1)
else:print(count*k)

Buggy submission (verdict: Runtime Error):
s=list(input())
k=int(input())
count=0
re=""
for i in range(1,len(s)):
    if s[i]==s[i-1]:
        if i == len(s) - 1: re += s[-1]
        s[i]="A"
        count +=1

if s[0]==s[-1] and s[-1]!="A":
    count +=1
    re +=s[-1]
    s[-1]="A"

if s[-1]=="A" and s[-2]!=re:print((count*k)-1)
else:print(count*k)
Problem p03013 (python)

Fixed submission:
n,m=map(int,input().split())
A=list(int(input()) for i in range(m))+[-1]
dp=[0]*(n+1)
dp[0]=1
j=0
for i in range(1,n+1):
    if i==A[j]:
        dp[i]=0
        j +=1
    else:
        dp[i]=(dp[i-1]+dp[i-2])

print(dp[n]%1000000007)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
A=list(int(input()) for i in range(m))
dp=[0]*(n+1)
dp[0]=1
j=0
for i in range(1,n+1):
    if i==A[j]:
        dp[i]=0
        j +=1
    else:
        dp[i]=(dp[i-1]+dp[i-2])

print(dp[n]%1000000007)
Problem p03038 (python)

Fixed submission:
from collections import deque
n,m=map(int,input().split())
A=sorted(list(map(int,input().split())))
BC=sorted([list(map(int,input().split())) for i in range(m)],key=lambda x:x[1])

A=deque(A)
for b,c in BC[::-1]:
    if len(A)==0:break
    for i in range(b):
        if A[0]<c:
            A.append(c)
            A.popleft()
        else:break
print(sum(A))

Buggy submission (verdict: Runtime Error):
from collections import deque
n,m=map(int,input().split())
A=sorted(list(map(int,input().split())))
BC=sorted([list(map(int,input().split())) for i in range(m)],key=lambda x:x[1])

cnt=0
A=deque(A)
for b,c in BC[::-1]:
    if len(A)==0:break
    for i in range(b):
        if A[0]<c:
            cnt +=c
            A.popleft()
        else:break
print(cnt+sum(A))

Buggy submission (verdict: Runtime Error):
from collections import deque
n,m=map(int,input().split())
A=sorted(list(map(int,input().split())))
BC=sorted([list(map(int,input().split())) for i in range(m)],key=lambda x:x[1])

cnt,flag=0,True
A=deque(A)
for b,c in BC[::-1]:
    if not flag:break
    for i in range(b):
        if A[0]<c:
            cnt +=c
            A.popleft()
        else:
            flag=False
print(cnt+sum(A))

Buggy submission (verdict: Runtime Error):
from collections import deque
n,m=map(int,input().split())
A=sorted(list(map(int,input().split())))
BC=sorted([list(map(int,input().split())) for i in range(m)],key=lambda x:x[1])

cnt=0
for b,c in BC[::-1]:
    for i in range(b):
        if A[0]<c:
            cnt +=c
            del A[0]
        else:break
print(cnt+sum(A))

Buggy submission (verdict: Runtime Error):
from collections import deque
n,m=map(int,input().split())
A=sorted(list(map(int,input().split())))
BC=sorted([list(map(int,input().split())) for i in range(m)],key=lambda x:x[1])

cnt=0
A=deque(A)
for b,c in BC[::-1]:
    for i in range(b):
        if A[0]<c:
            cnt +=c
            A.popleft()
        else:break
print(cnt+sum(A))
Problem p03041 (python)

Fixed submission:
N,K = map(int,input().split())
S = list(input())
if S[K-1] == 'A':
    S[K-1] = 'a'
elif S[K-1] == 'B':
    S[K-1] = 'b'
else:
    S[K-1] = 'c'
print(''.join(S))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
S=input()
if S[m]=="A":S[m]="a"
elif S[m]=="B":S[m]="b"
else:S[m]="c"
print(S)
Problem p03326 (python)

Fixed submission:
n,m=map(int,input().split())
box=list(list(map(int,input().split())) for i in range(n))
ans = 0
for i in (1,-1):
    for j in (1,-1):
        for k in (1,-1):
            cost=list(i*x+j*y+z*k for x,y,z in box)
            cost.sort(reverse=True)
            ans=max(ans,sum(cost[:m]))
print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
box=list([map(int,input().split())] for i in range(n))
ans = 0
for i in (1,-1):
    for j in (1,-1):
        for k in (1,-1):
            cost=sorted(list(i*x+j*y+z*k for x,y,z in box))
            ans=max(ans,sum(cost[-m:]))
print(ans)
Problem p03805 (python)

Fixed submission:
from itertools import permutations
n,m=map(int,input().split())

M=[[] for _ in range(n)]
for i in range(m):
    a,b=map(int,input().split())
    M[a-1].append(b-1)
    M[b-1].append(a-1)

ans=0
for A in permutations(range(n),n):
    if A[0]==0:
        for i in range(n):
            if i==n-1:
                ans +=1
                break
            if A[i+1] not in M[A[i]]:break

print(ans)

Buggy submission (verdict: Runtime Error):
def DFS(num):
    global ans,color
    color[num]="black"
    if "white" not in color:
        ans +=1
    for i in M[num]:
        DFS(i)
    color[num]="white"


n,m=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(m)]

M=[[] for _ in range(n)]
color=["white" for _ in range(n)]
for a,b in AB:
    M[a-1].append(b-1)
    M[b-1].append(a-1)

ans=0
DFS(0)
print(ans)
Problem p03986 (python)

Fixed submission:
from collections import deque
s=list(input())
A=deque([])
for i in s:
    if i=="S":A.append(i)
    elif i=="T":
        if len(A)==0 or A[-1]=="T":A.append(i)
        else:A.pop()
print(len(A))

Buggy submission (verdict: Runtime Error):
s=list(input())
word,cnt=s[0],0
n=len(s)
S=""
for i in range(n):
    if word!=s[i]:
        S +=word+str(cnt)
        cnt=1
        word=s[i]
    else:
        cnt +=1
S +=word+str(cnt)
S +="G"
S=list(S)
cnt=0
for i in range(0,len(S)-1,2):
    if S[i]+S[i+2]=="ST":
        cnt +=(min(int(S[i+1]),int(S[i+3])))*2
print(n-cnt)
Problem p02571 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(S, T):
    buf = []
    for i in range(len(S) - len(T) + 1):
        diff = 0
        for j in range(len(T)):
            if S[i + j] != T[j]:
                diff += 1
        buf.append(diff)
    return min(buf)


def main():
    # parse input
    S = input().strip()
    T = input().strip()
    print(solve(S, T))


# tests
T1 = """
cabacc
abc
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
1
"""

T2 = """
codeforces
atcoder
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
6
"""

T3 = """
aaa
bbb
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
3
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
INF = 10 ** 9 + 1  # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7


def debug(*x):
    print(*x, file=sys.stderr)


def solve(S, T):
    buf = []
    for i in range(len(S) - len(T)):
        diff = 0
        for j in range(len(T)):
            if S[i + j] != T[j]:
                diff += 1
        buf.append(diff)
    return min(buf)


def main():
    # parse input
    S = input().strip()
    T = input().strip()
    print(solve(S, T))


# tests
T1 = """
cabacc
abc
"""
TEST_T1 = """
>>> as_input(T1)
>>> main()
1
"""

T2 = """
codeforces
atcoder
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
6
"""


def _test():
    import doctest
    doctest.testmod()
    g = globals()
    for k in sorted(g):
        if k.startswith("TEST_"):
            doctest.run_docstring_examples(g[k], g, name=k)


def as_input(s):
    "use in test, use given string as input file"
    import io
    f = io.StringIO(s.strip())
    g = globals()
    g["input"] = lambda: bytes(f.readline(), "ascii")
    g["read"] = lambda: bytes(f.read(), "ascii")


input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read

if sys.argv[-1] == "-t":
    print("testing")
    _test()
    sys.exit()

main()
Problem p02659 (python)

Fixed submission:
A, B = input().split()
A = int(A)
B = int(B.replace(".", ""))
print(A * B // 100)

Buggy submission (verdict: Runtime Error):
a, b, c = [int(x) for x in input().split()]
d = c - a - b

if d <= 0:
    print("No")
else:
    if 4 * a * b < d * d:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
a, b, c = [int(x) for x in input().split()]
d = c - a - b

if d <= 0:
    print("No")
else:
    if 4 * a * b < d * d:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
const fs = require('fs');
const input = fs.readFileSync('/dev/stdin', 'utf8');

const [a, b, c] = input.split(" ").map((s) => parseInt(s, 10));

// ya + vb < Vc
// a + 2yab + b < c
// 2/ab < c - a - b
// c - a - b A5 false
// 4ab < (c - a - b)^2

// console.log(Number.MAX_SAFE_INTEGER);
// expected output: 9007199254740991

//const [a, b, c] = [249999999, 250000000, 999999998];

const d = BigInt(c - a - b);
if (d <= 0) {
  console.log("No");
} else {
  console.log((4 * a) * b < d * d ? "Yes" : "No");
}
Problem p02695 (python)

Fixed submission:
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]

cand = [[1]]
for i in range(N-1):
    tmp = []
    while cand:
        x = cand.pop()
        for i in range(x[-1], M + 1):
            tmp.append(x + [i])
    cand = tmp

ans = 0
for X in cand:
    score = 0
    for a, b, c, d in abcd:
        if X[b - 1] - X[a - 1] == c:
            score += d
    ans = max(ans, score)
print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
from itertools import product, combinations
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]

cand = [[1]]
for i in range(M-1):
    tmp = []
    while cand:
        x = cand.pop()
        for i in range(x[-1], M + 1):
            tmp.append(x + [i])
    cand = tmp

ans = 0
for X in cand:
    score = 0
    for a, b, c, d in abcd:
        if X[b - 1] - X[a - 1] == c:
            score += d
    ans = max(ans, score)
print(ans)
Problem p02726 (python)

Fixed submission:
from scipy.sparse.csgraph import dijkstra
import numpy as np
N, X, Y = map(int, input().split())
X -= 1
Y -= 1

g = np.zeros((N, N), dtype=int)
a = np.arange(N - 1)
np.add.at(g, (a, a + 1), 1)
np.add.at(g, (a + 1, a), 1)
np.add.at(g, (X, Y), 1)
np.add.at(g, (Y, X), 1)
fw = dijkstra(g, directed=False)
fw = (fw + 0.5).astype(int)
fw = np.tril(fw).ravel()
fw = fw[fw > 0]

cnt = np.bincount(fw).tolist()
ans = [0] * (N - 1)
for i, c in enumerate(cnt[1:]):
    ans[i] = c

print(*ans, sep="\n")

Buggy submission (verdict: Runtime Error):
from collections import deque
N, X, Y = map(int, input())
edge = [[] for _ in range(N)]
for i in range(N - 1):
    edge[i].append(i + 1)
    edge[i + 1].append(i)
edge[X-1].append(Y-1)
edge[Y-1].append(X-1)

cnt = [0] * (N - 1)


def search(i):
    node = deque([i])
    seen = [-1] * N
    seen[i] = 0

    while node:
        s = node.popleft()
        d = seen[s]
        for t in edge(s):
            if seen[t] == -1:
                seen[t] = d + 1
                if s < t:
                    cnt[d] += 1
                node.append(t)


for i in range(N - 1):
    search(i)
print(*cnt, sep="\n")
Problem p02925 (python)

Fixed submission:
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
pair = N * (N - 1) // 2
ptoi = dict()

i = 0
for x in range(1, N):
    for y in range(x + 1, N + 1):
        ptoi[(x, y)] = i
        ptoi[(y, x)] = i
        i += 1

edge = [[] for _ in range(pair)]
indeg = [0] * pair
for i in range(1, N+1):
    inp = list(map(int, input().split()))
    for s, t in zip(inp[:-1], inp[1:]):
        edge[ptoi[(i, s)]].append(ptoi[(i, t)])
        indeg[ptoi[(i, t)]] += 1


now = [i for i, d in enumerate(indeg) if d == 0]
day = 0
while now:
    nxt = []
    while now:
        s = now.pop()
        for t in edge[s]:
            if indeg[t] <= 0:
                continue
            indeg[t] -= 1
            if indeg[t] == 0:
                nxt.append(t)
    day += 1
    now = nxt

if all(i <= 0 for i in indeg):
    print(day)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline

N = int(input())
A = [list(map(int, input().split()))[::-1] for _ in range(N)]

ans = 0
match = N*(N-1)//2
player = set(range(N))
seen = [False]*N

while True:
    update = False
    checked = seen.copy()
    ans += 1

    for x in player:
        if checked[x] or not A[x]:
            continue
        y = A[x][-1] - 1
        if A[y][-1]-1 == x and not checked[y]:
            A[x].pop()
            A[y].pop()
            checked[x] = True
            checked[y] = True
            update = True
            match -= 1

    if match <= 0:
        break

    if not update:
        ans = -1
        break

print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
 
N = int(input())
A = [[int(x)-1 for x in row.split()][::-1] for row in sys.stdin.readlines()]

total_match=n*(n-1)//2
match=0
day=0


for _ in range(total_match):
    day+=1
    today_match=[]

    for i in range(n):
        try:
            m=league[i][-1]-1
            if not i in today_match and not m in today_match:
                if league[m][-1]-1==i:
                    today_match.extend((i,m))
                    league[i].pop()
                    league[m].pop()
        except:
            continue
    if not today_match:
        day=-1
        break
    match+=len(today_match)//2
    if match>=total_match:
        break

print(day)

Buggy submission (verdict: Runtime Error):
inf=10**9+7
n=int(input())
size=n*(n-1)//2

graph=[[] for _ in range(size)]

idx={}
cnt=0
for i in range(n-1):
    for j in range(i+1, n):
        idx[(i,j)]=cnt
        cnt+=1

for i in range(n):
    a=tuple(map(int,input().split()))
    l=(min(i, a[0]-1), max(i,a[0]-1))
    for j in a[1:]:
        r=(min(i, j-1), max(i, j-1))
        graph[idx[l]].append(idx[r])
        l=r

def dfs(start, node, depth):
    next=graph[node]
    if len(next)==0:
        return depth
    if start in next:
        return inf
    for i in next:
        return max(dfs(start, i, depth+1), depth)

ans=-1
for i in range(n):
    ans=max(ans, dfs(i, i, 1))

ans=-1 if ans>=inf else ans
print(ans)
Problem p02948 (python)

Fixed submission:
import heapq
N, M = map(int, input().split())

fee = [[] for _ in range(10**5+10)]  # i日後に収入がもらえるバイトの価値
for _ in range(N):
    a, b = map(int, input().split())
    fee[a].append(-b)

task = []
ans = 0

# 締め切り日からさかのぼっていって、できるバイトで最大の収入をもらえるやつを実行する感じ
for i in range(1, M + 1):
    for f in fee[i]:
        heapq.heappush(task, f)

    if task:
        ans -= heapq.heappop(task)

print(ans)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
day_pay=[[0] for _ in range(m)]
for _ in range(n):
    a,b=map(int,input().split())
    day_pay[a-1].append(b)
    day_pay[a-1].sort()

ans=0
for d in range(0, m):
    best=0
    idx=m+2
    for i in range(d+1):
        if day_pay[i][-1]>best:
            best=day_pay[i][-1]
            idx=i
    if idx<len(day_pay):
        day_pay[i].pop()
    ans+=best
print(ans)
Problem p03003 (python)

Fixed submission:
mod = 10 ** 9 + 7

N, M = map(int, input().split())
S = input().split()
T = input().split()

dp = [[0] * (M + 2) for _ in range(N + 2)]
for i in range(N+1):
    dp[i][0] = 1
for j in range(M+1):
    dp[0][j] = 1

for i, s in enumerate(S, 1):
    for j, t in enumerate(T, 1):
        dp[i][j] += dp[i - 1][j]
        dp[i][j] += dp[i][j - 1]
        if s == t:
            dp[i][j] += dp[i - 1][j - 1]
        dp[i][j] -= dp[i - 1][j - 1]
        dp[i][j] += mod
        dp[i][j] %= mod

print(dp[N][M])

Buggy submission (verdict: Runtime Error):
mod = 10 ** 9 + 7

N, M = map(int, input().split())
S = input().split()
T = input().split()

dp = [[0] * (N + 2) for _ in range(M + 2)]
for i in range(N+1):
    dp[i][0] = 1
for j in range(M+1):
    dp[0][j] = 1

for i, s in enumerate(S, 1):
    for j, t in enumerate(T, 1):
        dp[i][j] += dp[i - 1][j]
        dp[i][j] += dp[i][j - 1]
        if s == t:
            dp[i][j] += dp[i - 1][j - 1]
        dp[i][j] -= dp[i - 1][j - 1]
        dp[i][j] += mod
        dp[i][j] %= mod

print(dp[N][M])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
S = list(map(int, input().split())) + [0]
T = list(map(int, input().split())) + [0]
mod = 10 ** 9 + 7

dp0 = [[0]*(N+5) for _ in range(M+5)]  # i方向に進める
dp1 = [[0]*(N+5) for _ in range(M+5)]  # j方向に進める
dp0[0][0] = 1

for i in range(N + 1):
    for j in range(M + 1):
        dp0[i + 1][j] = (dp0[i + 1][j] + dp0[i][j]) % mod
        dp1[i][j] = (dp1[i][j] + dp0[i][j]) % mod
        dp1[i][j + 1] = (dp1[i][j + 1] + dp1[i][j]) % mod
        if S[i] == T[j]:
            dp0[i + 1][j + 1] = (dp0[i + 1][j + 1] + dp1[i][j]) % mod

ans = dp1[N][M]
print(ans)
Problem p03107 (python)

Fixed submission:
s=input()
n0=0
n1=0
for i in s:
    if i=="0":
        n0+=1
    else:
        n1+=1
print(2*min(n0,n1))

Buggy submission (verdict: Runtime Error):
s=input()
lis=[]
n=1
output=0
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        lis.append(n)
        n=1
    else:
        n+=1

    if i==len(s)-2:
        lis.append(n)
#print(lis)
if len(lis)==1:
    output=0
else:
    loop=True
    while loop:
        a=lis[0]
        b=lis[1]
        if a==b:
            output+=a+b
            del lis[0]
            del lis[0]
        elif a<b and len(lis)>2:
            output+=a*2
            lis[1]-=a
            del lis[0]
        elif a>b and len(lis)>2:
            output+=b*2
            lis[2]+=a-b
            del lis[0]
            del lis[0]
        elif len(lis)<=2:
            output+=min(a,b)*2
            del lis[0]

        if len(lis)==0 or len(lis)==1:
            loop=False

print(output)

Buggy submission (verdict: Runtime Error):
s=input()
lis=[]
n=1
output=0
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        lis.append(n)
        n=1
    else:
        n+=1

    if i==len(s)-2:
        lis.append(n)
#print(lis)

loop=True
while loop:
    a=lis[0]
    b=lis[1]
    if a==b:
        output+=a*2
        del lis[0]
        del lis[0]
    elif a<b:
        output+=a*2
        lis[1]-=a
        del lis[0]
    elif a>b:
        if len(lis)<2:
            output+=b*2
            loop=False
        else:
            lis[2]+=abs(b-a)
            output+=b*2
            del lis[0]
            del lis[0]
    if len(lis)==0 or len(lis)==1:
        loop=False
print(output)

Buggy submission (verdict: Runtime Error):
s=input()
lis=[]
n=1
output=0
for i in range(len(s)-1):
    if s[i]!=s[i+1]:
        lis.append(n)
        n=1
    else:
        n+=1

    if i==len(s)-2:
        lis.append(n)
print(lis)

loop=True
while loop:
    a=lis[0]
    b=lis[1]
    if a==b:
        output+=a*2
        del lis[0]
        del lis[0]
    elif a<b:
        output+=a*2
        lis[1]-=a
        del lis[0]
    elif a>b:
        if len(lis)<2:
            output+=b*2
            loop=False
        else:
            lis[2]+=abs(b-a)
            output+=b*2
            del lis[0]
            del lis[0]
    if len(lis)==0 or len(lis)==1:
        loop=False
print(output)
Problem p03315 (python)

Fixed submission:
s=input()
p=s.count("+")
m=s.count("-")
print(p-m)

Buggy submission (verdict: Runtime Error):
S=input()
print(S.count("+")-S.count("-")