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

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

li = list(map(int,(list(str(k)))))
leng = len(li)
mod = 10**9+7

dp1 = [0 for _ in range(d)]
dp2 = [0 for _ in range(d)]

mm1 = li[0]
for i in range(mm1):
    dp2[i%d] += 1

for i in range(1,leng):
    for j in range(0,10):
        for l in range(d):
            #既にk以下であることが確定
            dp1[(l+j)%d] += dp2[l]
            dp1[(l+j)%d] %= mod

        #上からi桁目でk以下が確定
        if j<li[i]:
            dp1[(mm1+j)%d] += 1
            dp1[(mm1+j)%d] %= mod
    #print(dp1,dp2)
    mm1 = (mm1+li[i])%d
    dp2 = [dp1[i] for i in range(d)]
    dp1 = [0 for _ in range(d)]
dp2[sum(li)%d]+=1
print((dp2[0]-1)%mod)

Buggy submission (verdict: Runtime Error):
k = int(input())
d = int(input())

li = list(map(int,(list(str(k)))))
leng = len(li)
mod = 10**9+7

dp1 = [0 for _ in range(d)]
dp2 = dp1.copy()

mm1 = li[0]
for i in range(mm1):
    dp2[i%d] = 1

for i in range(1,leng):
    for j in range(0,10):
        for l in range(d):
            #既にk以下であることが確定
            dp1[(l+j)%d] = (dp1[(l+j)%d]+dp2[l])%mod

        #上からi桁目でk以下が確定
        if j<li[i]:
            dp1[(mm1+j)%d] = (dp1[(mm1+j)%d]+1)%mod
    #print(dp1)
    

    mm1 = (mm1+li[i])%d
    dp2 = dp1.copy()
    dp1 = [0 for _ in range(d)]


print((dp2[0]-1)%mod)
Problem p03219 (python)

Fixed submission:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


n,k = map(int,input().split())

print(n+k//2)

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


n,k = map(int,input().split())

print(x+y//2)
Problem p03243 (python)

Fixed submission:
n = int(input())
li =[111,222,333,444,555,666,777,888,999]

for i in range(9):
    if n <= li[i]:
        print(li[i])
        break

Buggy submission (verdict: Runtime Error):
n = int(input())
li = list(111,222,333,444,555,666,777,888,999)

for i in range(9):
    if n <= li[i]:
        print(li[i])
        break
Problem p03244 (python)

Fixed submission:
n=int(input())
v = list(map(int,input().split()))

dic0 = [0 for i in range(10**5+1)]
dic1 = [0 for i in range(10**5+1)]
for i in range(n):
    if i%2==0:    
        dic0[v[i]] += 1
    if i%2==1:
        dic1[v[i]] += 1

MX0_1 = max(dic0)
MX1_1 = max(dic1)

li0 = []
li1 = []


for i in range(10**5+1):
    # if dic0[i]>10:
    #     print(i,dic0[i])
    # if dic1[i]>10:
    #     print(i,dic1[i],"\n")
    
    if dic0[i] == MX0_1:
        li0.append(i)
        dic0[i] = 0
    if dic1[i] == MX1_1:
        li1.append(i)
        dic1[i] = 0

# print(li0,li1)
# print(MX0_1,MX0_1)

if len(li0)>=2 or len(li1)>=2:
    print(n-MX0_1-MX1_1)
elif li0[0] == li1[0]:
    print(min(n-MX0_1-max(dic1), n-MX1_1-max(dic0)))
elif li0[0] != li1[0]:
    print(n-MX0_1-MX1_1)

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

dic0 = [0 for i in range(10**5+1)]
dic1 = [0 for i in range(10**5+1)]
for i in range(n):
    if i%2==0:    
        dic0[v[i]] += 1
    if i%2==1:
        dic1[v[i]] += 1

MX0_1 = max(dic0)
MX1_1 = max(dic1)

li0 = []
li1 = []


for i in range(10**5+1):
    # if dic0[i]>10:
    #     print(i,dic0[i])
    # if dic1[i]>10:
    #     print(i,dic1[i],"\n")
    
    if dic0[i] == MX0_1:
        li0.append(i)
        dic0[i] = 0
    if dic1[i] == MX1_1:
        li1.append(i)
        dic1[i] = 0

# print(li0,li1)
# print(MX0_1,MX0_1)

if len(li0)>=2 or len(li1)>=2:
    print(n-MX0_1-MX1_1)
elif li0[0] == li1[0]:
    if MX0_1+max(dic1) >= MX1_1+max(dic0):
        print(n-MX0_1-max(dic1))
    else:
        print(n-MX1_1-max(dic0))
        print(1/0)

elif li0[0] != li1[0]:
    print(n-MX0_1-MX1_1)

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

dic0 = [0 for i in range(10**5+1)]
dic1 = [0 for i in range(10**5+1)]
for i in range(n):
    if i%2==0:    
        dic0[v[i]] += 1
    if i%2==1:
        dic1[v[i]] += 1

MX0_1 = max(dic0)
MX1_1 = max(dic1)

li0 = []
li1 = []


for i in range(10**5+1):
    if dic0[i]>10:
        #print(i,dic0[i])
    if dic1[i]>10:
        #print(i,dic1[i],"\n")
    
    if dic0[i] == MX0_1:
        li0.append(i)
        dic0[i] = 0
    if dic1[i] == MX1_1:
        li1.append(i)
        dic1[i] = 0

# print(li0,li1)
# print(MX0_1,MX0_1)

if len(li0)>=2 or len(li1)>=2:
    print(n-MX0_1-MX1_1)
elif li0[0] == li1[0]:
    if MX0_1+max(dic1) >= MX1_1+max(dic0):
        print(n-MX0_1-max(dic1))
    else:
        print(n-MX1_1-max(dic0))
        print(1/0)

elif li0[0] != li1[0]:
    print(n-MX0_1-MX1_1)
Problem p03266 (python)

Fixed submission:
n,k = map(int,input().split())

mm1=0
mm2=0
for i in range(1,n+1):
    if i%k==0:
        mm1+=1
    if i%k==k//2 and k%2==0:
        mm2+=1

print(mm1**3+mm2**3)

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

mm=0
for i in range(1,n+1):
    if i%k==0:
        mm1+=1
    if i%k==k//2 and k%2==0:
        mm2+=1

print(mm1**3+mm2**3)

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

mm=0
for i in range(1,n+1):
    if i%k==0:
        mm+=1
    if i%k==k//2 and k%2==0:
        mm+=1

print(C(mm**3))
Problem p03284 (python)

Fixed submission:
n,k = map(int,input().split())

if n%k==0:
    print(0)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
if n%k==0:
    print(0)
else:
    print(1)
Problem p03289 (python)

Fixed submission:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


s = list(input())
ans = True
li = list("abcdefghijklmnopqrstuvwxyzC")

if s[0]!="A":
    ans = False
memo = s[2:-1]
if not("C" in memo):
    ans = False
C_cnt = 0
for i in range(1,len(s)):
    if not(s[i] in li):
        ans = False
    if s[i] == "C":
        C_cnt += 1

if ans and C_cnt==1:
    print("AC")
else:
    print("WA")

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


s = list(input())
ans = True
li = list("abcdefghijklmnopqrstuvwxyzC")

if s[0]!="A":
    ans = False
memo = s[2:-1]
if not("C" in memo):
    ans = False
C_cnt = 0
for i in range(1,len(li)):
    if not(memo[i] in li):
        ans = False
    if memo[i] == "C":
        C_cnt += 1

if ans and C_cnt==1:
    print("AC")
else:
    print("WA")
Problem p03290 (python)

Fixed submission:
d,g = map(int,input().split())
li = []

for i in range(d):
    p,c = map(int,input().split())
    li.append([p,c])

ans = 10**9
for i in range(1<<d):
    ttl = 0
    cnt = 0
    memo = [0 for i in range(d)]
    for j in range(d):
        if (i>>j)&1:
            ttl += li[j][1]+(j+1)*li[j][0]*100
            cnt += li[j][0]
            memo[j] = 1
    #print(memo,ttl)
    if ttl < g:
        memo2 = g- ttl
        for j in range(d-1,-1,-1):
            if memo[j] == 0:
                if memo2%(100*(j+1)) == 0:
                    cnt2 = min(memo2//(100*(j+1)),li[j][0]-1)
                    cnt += cnt2
                    ttl += cnt2*(100*(j+1))
                    #print(44444444)
                else:
                    cnt2 = min(((memo2//(100*(j+1)))+1),li[j][0]-1)
                    #print(((memo2//(100*(j+1)))+1))
                    cnt += cnt2
                    ttl += cnt2*(100*(j+1))
                break
    if ttl >= g:
        ans = min(ans,cnt)
"""   
    if ans == cnt:
        print(memo,ttl,111111)
"""   
    

print(ans)

Buggy submission (verdict: Runtime Error):
d,g = map(int,input().split())
li = []

for i in range(d):
    p,c = map(int,input().split())
    li.append([p,c])

ans = 10**9
for i in range(1<<d):
    ttl = 0
    cnt = 0
    memo = [0 for i in range(d)]
    for j in range(d):
        if (i>>j)&1:
            ttl += li[j][1]+(j+1)*li[j][0]*100
            cnt += li[j][0]
            memo[j] = 1

    if ttl < g:
        memo2 = g- ttl
        for j in range(d-1,-1,-1):
            if memo[j] == 0:
                if memo2%(100*(j+1)) == 0:
                    cnt2 = min(memo2//(100*(j+1)),p[j]-1)
                    cnt += cnt2
                    ttl += cnt2*(100*(j+1))
                else:
                    cnt += memo2//(100*(j+1))+1
                    ttl += (memo2//(100*(j+1))+1)*(100*(j+1))
                break
    if ttl >= g:
        ans = min(ans,cnt)
    

    
    

print(ans)

Buggy submission (verdict: Runtime Error):
d,g = map(int,input().split())
li = []

for i in range(d):
    p,c = map(int,input().split())
    li.append([p,c])

ans = 10**9
for i in range(1<<d):
    ttl = 0
    cnt = 0
    memo = [0 for i in range(d)]
    for j in range(d):
        if (i>>j)&1:
            ttl += li[j][1]+(j+1)*li[j][0]*100
            cnt += li[j][0]
            memo[j] = 1
    #print(memo,ttl)
    if ttl < g:
        memo2 = g- ttl
        for j in range(d-1,-1,-1):
            if memo[j] == 0:
                if memo2%(100*(j+1)) == 0:
                    cnt2 = min(memo2//(100*(j+1)),li[j][0]-1)
                    cnt += cnt2
                    ttl += cnt2*(100*(j+1))
                    #print(44444444)
                else:
                    cnt2 = min(memo2//(100*(j+1)+1),li[j][0]-1)
                    cnt += cnt2
                    ttl += cnt2*(100*(j+1))
                break
    if ttl >= g:
        ans = min(ans,cnt)
    
    if ans == cnt:
        #print(memo,ttl,111111)
    
    

print(ans)
Problem p03309 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))

li = []

for i in range(n):
    memo = a[i]-(i+1)
    li.append(memo)

li.sort()
#print(li)
memo = len(li)
memo2 = li[memo//2]

li2 = [-(memo2) for i in range(len(li))]
for i in range(n):
    li[i] = li[i] + li2[i]
#print(li)
ttl = 0
for i in range(n):
    ttl += abs(li[i])

print(ttl)

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

li = []

for i in range(n):
    memo = a[i]-(i+1)
    li.append(memo)

li.sort()

memo = len(li)
memo2 = li[memo//2]

li2 = [memo2 for i in range(len(li))]
li = li - li2

ttl = 0
for i in range(n):
    ttl += abs(li[i])

print(ttl)
Problem p03337 (python)

Fixed submission:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))
 
 
n,k = map(int,input().split())
print(max(n+k,n-k,n*k))

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


n,k = map(int,input().split())
print(max(m+k,n-k,n*k))
Problem p03361 (python)

Fixed submission:
H,W = map(int,input().split())
s = [list(input()) for _ in range(H)]

bre = False
for h in range(H):
    for w in range(W):
        if s[h][w] == "#":
            if h>0 and s[h-1][w]=="#":
                continue
            elif h<H-1 and s[h+1][w]=="#":
                continue
            elif w>0 and s[h][w-1]=="#":
                continue
            elif w<W-1 and s[h][w+1]=="#":
                continue
            else:
                #print(h,w)
                print("No")
                bre = True
                break
    if bre:
        break
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
H,W = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(H)]

for h in range(H):
    for w in range(W):
        if s[h][w] == "#":
            if h>0 ans s[h-1][w]=="#":
                continue
            elif h<H-1 ans s[h+1][w]=="#":
                continue
            elif w>0 ans s[h][w-1]=="#":
                continue
            elif h<W-1 ans s[h][w+1]=="#":
                continue
            else:
                print("No")
                break
else:
    print("Yes")
Problem p03369 (python)

Fixed submission:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


s = list(input())

cnt = 700
for i in range(3):
    if s[i] == "o":
        cnt += 100

print(cnt)

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


s = list(input())

cnt = 700
for i in range(3):
    if s[i] == "o"
    cnt += 100

print(cnt)
Problem p03379 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))

li = sorted(a)
memo = li[n//2-1]

for i in range(n):
    if a[i] > memo:
        print(li[(n//2)-1]) 
    else:
        print(li[(n//2)])

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

li = sorted(a)
memo = li[n//2]

for i in range(n):
    if a[i] > memo:
        print(li[(n//2)]) 
    else:
        print(li[(n//2)+1])
Problem p03424 (python)

Fixed submission:
n = int(input())
s = list(input().split())

for i in range(n):
    if s[i] == "Y":
        print("Four")
        break
    elif i == n-1:
        print("Three")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = list(input().split())

for i in range(n):
    if s[i] == "Y":
        print("four")
        break
        elif i == n-1:
            print("Tree")
Problem p03427 (python)

Fixed submission:
N = list(input())

flg = 0
for i in range(1,len(N)):
    if N[i]=="9":
        continue
    else:
        flg = 1
        break

if flg:
    print((len(N)-1)*9+int(N[0])-1)
else:
    print((len(N)-1)*9+int(N[0]))

Buggy submission (verdict: Runtime Error):
N = list(input())
print(len(N)*9+N[0]-1)
Problem p03477 (python)

Fixed submission:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

a,b,c,d =map(int,input().split())

m = a +b -c-d

if m>0:
    print("Left")
elif m ==0:
    print("Balanced")
else:
    print("Right")

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

a,b,c,d =map(int,input().split())

m = a +b -c-d

if m>0:
    print("Left")
elif m =0:
    print("Balanced")
else:
    print("Right")
Problem p03547 (python)

Fixed submission:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

a = list(input().split())
li = ["A","B","C","D","E","F"]



if a[0] > a[1]:
    print(">")
elif a[0] == a[1]:
    print("=")
else:
    print("<")

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

a = list(input())
li = ["A","B","C","D","E","F"]

for i in range(6):
    if a[0] == li[i]:
        a[0] = i
    if a[1] == li[i]:
        a[1] = i

if a[0] > a[1]:
    print(">")
elif a[0] == a[1]:
    print("=")
else:
    print("<")
Problem p03548 (python)

Fixed submission:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

x,y,z = map(int,input().split())

ans = 1
memo = y+2*z

while(memo<=x):
    ans += 1
    memo += y+z

print(ans-1)

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

x,y,z map(int,input().split())

ans = 1
memo = y+2*z

while(memo<=x):
    ans += 1
    memo += y+z

print(ans-1)
Problem p03605 (python)

Fixed submission:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

n = int(input())



if (n//10 == 9) or (n%10==9):
    print("Yes")
else:
    print("No")

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

n = map(int,input().split())

if (n//10 == 9) or (n%10==9):
    print("Yes")
else:
    print("No")
Problem p03611 (python)

Fixed submission:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

n = int(input())
a = list(map(int,input().split()))

li = [0 for i in range(10**5)]
for i in range(n):
    li[a[i]] += 1

x = 0
for i in range(1,10**5-1):
    x = max(li[i-1]+li[i]+li[i+1],x)

print(x)

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

li = [0 for i in range(n)]
for i in range(n):
    li[a[i]] += 1

x = 0
for i in range(1,n-1):
    x = max(li[i-1]+li[i]+li[i+1])

print(x)
Problem p03635 (python)

Fixed submission:
n,m = map(int,input().split())
print((n-1)*(m-1))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().spliy())
print((n-1)*(m-1))
Problem p03645 (python)

Fixed submission:
n,m = map(int,input().split())
li1 = [0 for _ in range(n)]
li2 = [0 for _ in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    if a==0:
        li1[b] = 1
    elif b==n-1:
        li2[a] = 1

ans = False
for i in range(1,n-1):
    if li1[i] and li2[i]:
        ans = True
        break

if ans:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
n,m = int(input())
li = [[0 for _ in range(n)] for _ in range(n)]
for i in range(m):
    a,b = map(int,input())
    a-=1
    b-=1
    li[a][b] = 1
    li[b][a] = 1

ans = False
for i in range(1,n-1):
    if li[0][i] and li[i][n-1]:
        ans = True
        break

if ans:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
Problem p03659 (python)

Fixed submission:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


n = int(input())
a = list(map(int,input().split()))

memo = sum(a)



q=a[0]
b=memo-a[0]

ans = abs(q-b)
for i in range(1,n-1):
    q += a[i]
    b -= a[i]

    ans = min(ans,abs(q-b))
    
print(ans)

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


n = int(input())
a = list(map(int,input().split()))

memo = sum(a)

a=a[0]
b=memo-a[0]

ans = abs(a-b)
for i in range(1,n-1):
    a += a[i]
    b -= a[i]

    ans = min(ans,abs(a-b))
    
print(ans)
Problem p03697 (python)

Fixed submission:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

a,b =  map(int,input().split())

if a+b >= 10:
    print("error")
else:
    print(a+b)

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

a = int(input())
b = int(input())

if a+b >= 10:
    print("error")
else:
    print(a+b)
Problem p03719 (python)

Fixed submission:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))

a,b,c = map(int,input().split())

if (a <= c) and (c <= b):
    print("Yes")
else:
    print("No")

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

a,b,c = input().split()

if (c-a >=0) and (b-c >= 0):
    
    print("Yes")
else:
    print("No")
Problem p03720 (python)

Fixed submission:
n,m = map(int,input().split())
ab = [[0 for i in range(n)] for j in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ab[a][b] += 1
    ab[b][a] += 1

for i in range(n):
    cnt = 0
    for j in range(n):
        cnt += ab[i][j]
    print(cnt)

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

for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ab[a][b] += 1
    ab[b][a] += 1

for i in range(n):
    cnt = 0
    for j in range(m):
        cnt += ab[i][j]
    print(cnt)

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

for i in range(m):
    a,b = map(int,input().split())
    ab[a][b] += 1
    ab[b][a] += 1

for i in range(n):
    cnt = 0
    for j in range(m):
        cnt += ab[i][j]
    print(cnt)
Problem p03739 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))

def wh(cst,ttl,flg):
    for i in range(n):
        ttl += a[i]

        if ttl*flg < 0:
            flg *= -1
        else:
            if flg > 0:
                memo = abs(ttl)+1
                ttl -= memo
                cst += memo
            elif flg < 0:
                memo = abs(ttl)+1
                ttl += memo
                cst += memo
            flg *= -1

        
    return cst




ttl = 0
cst = 0



cst = wh(cst,ttl,1)
ttl = 0
cst2 = 0
cst2 = wh(cst2,ttl,-1)
   

print(min(cst,cst2))

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

ttl = a[0]
cst = 0

if a[0]>0:
    flg = 1

elif a[0]<0:
    flg = -1

for i in range(1,n):
    ttl += a[i]
    

    if ttl*flg < 0:
        flg *= -1
    else:
        if flg > 0:
            memo = abs(ttl)+1
            ttl -= memo
            cst += memo
        elif flg < 0:
            memo = abs(ttl)+1
            ttl += memo
            cst += memo
        flg *= -1
   


ttl = a[0]
cst2 = 0


   

print(min(cst,cst2))

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

ttl = a[0]
cst = 0

if a[0]>0:
    flg = 1

elif a[0]<0:
    flg = -1

for i in range(1,n):
    ttl += a[i]
    

    if ttl*flg < 0:
        flg *= -1
    else:
        if flg > 0:
            memo = abs(ttl)+1
            ttl -= memo
            cst += memo
        elif flg < 0:
            memo = abs(ttl)+1
            ttl += memo
            cst += memo
        flg *= -1
   


ttl = a[0]
cst2 = 0

if a[0]>0:
    flg = -1
    cst2 += abs(ttl)+1
    ttl += 0-ttl-1 

elif a[0]<0:
    flg = 1
    cst2 += abs(ttl)+1
    ttl += 0-ttl+1 

for i in range(1,n):
    ttl += a[i]
    

    if ttl*flg < 0:
        flg *= -1
    else:
        if flg > 0:
            memo = abs(ttl)+1
            ttl -= memo
            cst2 += memo
        elif flg < 0:
            memo = abs(ttl)+1
            ttl += memo
            cst2 += memo
        flg *= -1
   

print(min(cst,cst2))

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

ttl = a[0]
cst = 0

if a[0]>0:
    flg = 1

elif a[0]<0:
    flg = -1

for i in range(1,n):
    ttl += a[i]
    

    if ttl*flg < 0:
        flg *= -1
    else:
        if flg > 0:
            memo = abs(ttl)+1
            ttl -= memo
            cst += memo
        elif flg < 0:
            memo = abs(ttl)+1
            ttl += memo
            cst += memo
        flg *= -1
    


ttl = a[0]
cst2 = 0

if a[0]>0:
    flg = -1
    cst2 += abs(ttl)+1
    ttl += 0-ttl-1 

elif a[0]<0:
    flg = 1
    cst2 += abs(ttl)+1
    ttl += 0-ttl+1 

for i in range(1,n):
    ttl += a[i]
    

    if ttl*flg < 0:
        flg *= -1
    else:
        if flg > 0:
            memo = abs(ttl)+1
            ttl -= memo
            cst2 += memo
        elif flg < 0:
            memo = abs(ttl)+1
            ttl += memo
            cst2 += memo
        flg *= -1
    print(cst2," ",ttl)
Problem p03777 (python)

Fixed submission:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


a,b = input().split()
if a==b:
    print("H")
else:
    print("D")

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


a,b = map(int,input().split())
if a==b:
    print("H")
else:
    print("D")
Problem p03827 (python)

Fixed submission:
#n,l = map(int,input().split())
#l = kist(input())

n = int(input())
l = list(input())
cnt=0
ans=0

for i in range(n):
    if l[i]=='I':
        cnt+=1
    else:
        cnt-=1
    ans = max(ans,cnt)

print(ans)

Buggy submission (verdict: Runtime Error):
#n,l = map(int,input().split())
#l = kist(input())

l = list(input())
cnt=0
ans=0

for i in range(n):
    if l[i]=='I':
        cnt+=1
    else:
        cnt-=1
    ans = max(ans,cnt)

print(ans)

Buggy submission (verdict: Runtime Error):
#n,l = map(int,input().split())
#l = kist(input())

l = kist(input())
cnt=0
ans=0

for i in range(n):
    if l[i]=='I':
        cnt+=1
    else:
        cnt-=1
    ans = max(ans,cnt)

print(ans)
Problem p03844 (python)

Fixed submission:
s = list(input().split())

a = int(s[0])
b = int(s[2])

op = s[1]

if op == "+":
    print(a+b)
else:
    print(a-b)

Buggy submission (verdict: Runtime Error):
s = list(input())

a = int(s[0])
b = int(s[2])

op = a[1]

if op == "+":
    print(a+b)
else:
    print(a-b)