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

Fixed submission:
def main():
    a, b, c, d, e, f = map(int, input().split())

    maxConcentration = 0
    resSugarWater = 0
    resSugar = 0

    for i in range(31):
        for j in range((29 * a * i // b) + 1):
            water = (i * a + j * b) * 100
            possibleSugar = int(min(f - water, water * e / 100))
            for k in range((possibleSugar // c) + 1):
                for l in range(((possibleSugar - k * c) // d) + 1):
                    sugar = k * c + l * d

                    if water + sugar > f:
                        break

                    if water + sugar == 0:
                        continue

                    concentration = 100 * sugar / (water + sugar)

                    if concentration >= maxConcentration:
                        maxConcentration = concentration
                        resSugarWater = water + sugar
                        resSugar = sugar
    
    print(resSugarWater, resSugar)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    a, b, c, d, e, f = map(int, input().split())

    maxConcentration = 0

    for i in range(31):
        for j in range(i + 1, (29 * a // b) + 1):
            water = (i * a + j * b) * 100
            possibleSugar = int(min(f - water, water * e / 100))
            for k in range((possibleSugar // c) + 1):
                for l in range(((possibleSugar - k * c) // d) + 1):
                    sugar = k * c + l * d

                    if water + sugar > f:
                        break

                    if water + sugar == 0:
                        continue

                    concentration = 100 * sugar / (water + sugar)

                    if concentration > maxConcentration:
                        maxConcentration = concentration
                        resSugarWater = water + sugar
                        resSugar = sugar
    
    print(resSugarWater, resSugar)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    a, b, c, d, e, f = map(int, input().split())

    maxConcentration = 0

    for i in range(31):
        for j in range(31 - i * a):
            water = (i * a + j * b) * 100
            possibleSugar = int(min(f - water, water * e / 100))
            for k in range((possibleSugar // c) + 1):
                for l in range(((possibleSugar - k * c) // d) + 1):
                    sugar = k * c + l * d

                    if water + sugar > f:
                        break

                    if water + sugar == 0:
                        continue

                    concentration = 100 * sugar / (water + sugar)

                    if concentration > maxConcentration:
                        maxConcentration = concentration
                        resSugarWater = water + sugar
                        resSugar = sugar
    
    print(resSugarWater, resSugar)

if __name__ == '__main__':
    main()
Problem p03612 (python)

Fixed submission:
# ALC 005 D

N = int(input())
list_p = list(map(int, input().split()))
swapCount = 0

for i in range(N):
    if list_p[i] == i+1:
        temp = list_p[i]
        
        if i == len(list_p)-1:
            list_p[i] = list_p[i-1]
            list_p[i-1] = temp
        else:
            list_p[i] = list_p[i+1]
            list_p[i+1] = temp
        
        swapCount += 1

print(swapCount)

Buggy submission (verdict: Runtime Error):
# ALC 005 D

N = int(input())
list_p = list(map(int, input().split()))
swapCount = 0

for i in range(N):
    if list_p[i] == i+1:
        temp = list_p[i]
        list_p[i] = list_p[i+1]
        list_p[i+1] = temp
        swapCount += 1

print(swapCount)
Problem p03061 (python)

Fixed submission:
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
    
n = int(input())
a = list(map(int, input().split()))

pre = [0]
for i in range(n - 1):
    pre.append(gcd(pre[-1], a[i]))

post = [0]
for i in range(n - 1):
    post.append(gcd(post[-1], a[n - 1 - i]))

res = 0
for i in range(n):
    res = max(gcd(pre[i], post[n - 1 - i]), res)

print(res)

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

pre = [0]
for i in range(n - 1):
    pre.append(gcd(pre[-1], a[i]))

post = [0]
for i in range(n - 1):
    post.append(gcd(post[-1], a[n - 1 - i]))

res = 0
for i in range(n):
    res = max(gcd(pre[i], post[n - 1 - i]), res)

print(res)
Problem p02755 (python)

Fixed submission:
a, b = map(int, input().split())
for i in range(1, 1001):
    if a == int(i * 0.08) and b == int(i * 0.1):
        print(i)
        break
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import math

a, b = map(int, input().split())
for i in range(1, 101):
    if a == math.floor(i * 0.08):
        for j in range(1, 101):
            if b == math.floor(j * 0.1):
                if i == j:
                    break
        else:
            continue
        break
else:
    print(-1)
print(j)
Problem p02818 (python)

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

if a > k:
    c = a - k
    d = b
elif a + b > k:
    c = 0
    d = a + b - k
else:
    c = 0
    d = 0

print(c, d)

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

if a > k:
    c = a - k
elif a + b > k:
    c = 0
    d = a + b - k
else:
    c = 0
    d = 0

print(c, d)

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

if a > k:
    c = a - k
else:
    c = 0
    d = a + b - k

print(c, d)
Problem p04039 (python)

Fixed submission:
n, k = map(int, input().split())
d = list(input().split())
ans = 100000
for i in range(n, 100001):
    for j in range(k):
        if d[j] in str(i):
            break
    else:
        if ans > i:
            ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
d = list(input().split())
for i in reversed(range(n, 10001)):
    for j in range(k):
        if d[j] in str(i):
            break
    else:
        ans = i
print(ans)
Problem p04043 (python)

Fixed submission:
A, B, C = map(int, input().split())
if A + B + C == 17:
  if A == 5:
    if B + C == 12:
      print("YES")
    else:
      print("NO")
  elif A == 7:
    if B + C == 10:
      print("YES")
    else:
      print("NO")
  else:
    print("NO")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A + B + C == 17:
  if A == 5:
    if B + C == 12:
      print(YES)
    else:
      print(NO)
  if A == 7:
    if B + C == 10:
      print(YES)
    else:
      print(NO)
  else:
    print(NO)
else:
  print(NO)

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input().split())
if A + B + C == 17:
  if A == 5:
    if B + C == 12:
      return YES
    else:
      return NO
  if A == 7:
    if B + C == 10:
      return YES
    else:
      return NO
  else:
    return NO
else:
  return NO

Buggy submission (verdict: Runtime Error):
A, B, C = int(input().split().split())
array = [A, B, C]
sa = sorted[array]
if sa = [5, 5, 7]:
  return YES
else:
  return NO
Problem p03166 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)
def dfs(u):
    if(dp[u]!=-1):
        return dp[u]
    for i in d[u]:
        if(dp[i]!=-1):
            dp[u]=max(dp[u],dp[i]+1)
        else:
            dp[u]=max(dp[u],dfs(i)+1)
    return max(dp[u],0)
from collections import defaultdict as dd
n,m=map(int,input().split())
d=dd(list)
for i in range(m):
    u,v=map(int,input().split())
    d[u].append(v)
dp=dd(lambda: -1)
mx=0
for i in range(1,n+1):
    if(dp[i]==-1):
        dp[i]=dfs(i)
    mx=max(mx,dp[i])
print(mx)

Buggy submission (verdict: Runtime Error):
def dfs(u):
    if(dp[u]!=-1):
        return dp[u]
    for i in d[u]:
        if(dp[i]!=-1):
            dp[u]=max(dp[u],dp[i]+1)
        else:
            dp[u]=max(dp[u],dfs(i)+1)
    return max(dp[u],0)
from collections import defaultdict as dd
n,m=map(int,input().split())
d=dd(list)
for i in range(m):
    u,v=map(int,input().split())
    d[u].append(v)
dp=dd(lambda: -1)
mx=0
for i in range(1,n+1):
    if(dp[i]==-1):
        dp[i]=dfs(i)
    mx=max(mx,dp[i])
print(mx)
Problem p03166 (python)

Fixed submission:
from sys import stdin, setrecursionlimit as srl
from threading import stack_size
srl(int(1e9)+7)
stack_size(int(1e8))

def get(i, value, vis):
    if vis[i]:
        return value[i]
    vis[i] = True
    ans = 0
    for j in adj[i]:
        ans = max(ans, 1+get(j, value, vis))
    value[i] = ans
    return ans


n, m = map(int, input().split())
adj = {}
for i in range(n):
    adj[i] = []
for i in range(m):
    x, y = map(int,input().split())
    adj[x-1].append(y-1)
vis = [False for i in range(n)]
value = [0 for i in range(n)]
for i in range(n):
    value[i] = get(i, value, vis)
x = 0
for i in value:
    x = max(x, i)
print(x)

Buggy submission (verdict: Runtime Error):
def get(i, value, vis):
    if vis[i]:
        return value[i]
    vis[i] = True
    ans = 0
    for j in adj[i]:
        ans = max(ans, 1+get(j, value, vis))
    value[i] = ans
    return ans


n, m = map(int, input().split())
adj = {}
for i in range(n):
    adj[i] = []
for i in range(m):
    x, y = map(int,input().split())
    adj[x-1].append(y-1)
vis = [False for i in range(n)]
value = [0 for i in range(n)]
for i in range(n):
    value[i] = get(i, value, vis)
x = 0
for i in value:
    x = max(x, i)
print(x)
Problem p03169 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
d = [0 for i in range(3)]
dp = [[[0 for i in range(n+1)] for j in range(n+1)] for k in range(n+1)] 
for i in a:
    d[i-1] +=1
for k in range(n+1):
    for j in range(n+1):
        for i in range(n+1):
            if i+j+k==0 or i+j+k>n:
                continue
            ans = n/(i+j+k)
            x = i/(i+j+k)
            if x:
                ans += x*dp[k][j][i-1]
            x = j/(i+j+k)
            if x:
                ans += x*dp[k][j-1][i+1]
            x = k/(i+j+k)
            if x:
                ans += x*dp[k-1][j+1][i]
            dp[k][j][i] = ans
print(dp[d[2]][d[1]][d[0]])

Buggy submission (verdict: Runtime Error):
from sys import stdin, setrecursionlimit as srl
from threading import stack_size, Thread
srl(int(1e9)+7)
stack_size(int(1e8))
 
def f(d):
    ans = 0
    try:
        return stored[(d[0],d[1],d[2])]
    except:
        pass
    ans = ans + n/(d[0]+d[1]+d[2]) + (d[2]/(d[0]+d[1]+d[2]))*x*f([d[0],d[1]+1,d[2]-1]) + (d[1]/(d[0]+d[1]+d[2]))*x*f([d[0]+1,d[1]-1,d[2]]) + (d[0]/(d[0]+d[1]+d[2]))*f([d[0]-1,d[1],d[2]])
    stored[(d[0],d[1],d[2])] = ans
    return ans
 
 
n = int(input())
a = list(map(int,input().split()))
d = [0 for i in range(3)]
stored = {(0,0,0):0}
 
for i in a:
    d[i-1] +=1
 
print(f(d))
Problem p02607 (python)

Fixed submission:
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(0,N,2):
  if A[i]%2==1:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(0,N+1,2):
  if A[i]%2!=0:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(0,N+1,2):
  if A[i]%2==1:
    ans+=1
print(ans)
Problem p02641 (python)

Fixed submission:
X,N=map(int,input().split())
if N==0:
  print(X)
  exit()
n=list(map(int,input().split()))
if X<min(n) or X>max(n):
  print(X)
  exit()

key=min(n)-1
Key=max(n)+1
l=list(range(key,Key+1))
ll=[x for x in l if x not in n]
ll.append(X)
ll.sort()
i=ll.index(X)
if abs(X-ll[i-1])>abs(X-ll[i+1]):
  print(ll[i+1])
else:
  print(ll[i-1])

Buggy submission (verdict: Runtime Error):
X,N=map(int,input().split())
n=list(map(int,input().split()))
if X<min(n) or X>max(n):
  print(X)
  exit()

key=min(n)-1
Key=max(n)+1
l=list(range(key,Key+1))
ll=[x for x in l if x not in n]
ll.append(X)
ll.sort()
i=ll.index(X)
if abs(X-ll[i-1])>abs(X-ll[i+1]):
  print(ll[i+1])
else:
  print(ll[i-1])
Problem p02664 (python)

Fixed submission:
T=list(input())
if len(T)==1:
  print('D')
  exit()
if T[0]=='?' and T[1]=='D':
  T[0]='P'
elif T[0]=='?' and T[1]=='?':
  T[0]='P'
elif T[0]=='?' and T[1]=='P':
  T[0]='D'
for i in range(1,len(T)-1):
  if T[i]=='?' and T[i-1]=='P':
    T[i]='D'
  elif T[i]=='?' and T[i+1]=='D':
    T[i]='P'
  elif T[i]=='?' and T[i+1]=='P':
    T[i]='D'
  elif T[i]=='?' and T[i+1]=='?':
    T[i]='P'
if T[-1]=='?':
  T[-1]='D'
  
print(''.join(T))

Buggy submission (verdict: Runtime Error):
T=list(input())
if T[0]=='?' and T[1]=='D':
  T[0]='P'
elif T[0]=='?' and T[1]=='?':
  T[0]='P'
elif T[0]=='?' and T[1]=='P':
  T[0]='D'
for i in range(1,len(T)-1):
  if T[i]=='?' and T[i+1]=='D'and T[i-1]=='P':
    T[i]='D'
  elif T[i]=='?' and T[i+1]=='D':
    T[i]='P'
  elif T[i]=='?' and T[i+1]=='P':
    T[i]='D'
  elif T[i]=='?' and T[i+1]=='?':
    T[i]='P'
if T[-1]=='?':
  T[-1]='D'
  
print(''.join(T))
Problem p03076 (python)

Fixed submission:
l=list()
L=list()
for i in range(5):
  n=int(input())
  if n%10==0:
    l.append(n)
  else:
    L.append(n)
if len(l)==5:
  print(sum(l))
  exit()
    
LL=list()
for n in L:
  N=n%10
  LL.append(N)
key=min(LL)
LL.remove(key)

x=len(LL)*10

M=list()
for n in L:
  nn=n//10*10
  M.append(nn)
  
  
print(sum(l)+sum(M)+x+key)

Buggy submission (verdict: Runtime Error):
l=list()
L=list()
for i in range(5):
  n=int(input())
  if n%10==0:
    l.append(n)
  else:
    L.append(n)
    
LL=list()
for n in L:
  N=n%10
  LL.append(N)
key=min(LL)
LL.remove(key)

x=len(LL)*10

M=list()
for n in L:
  nn=n//10*10
  M.append(nn)
  
  
print(sum(l)+sum(M)+x+key)
Problem p03293 (python)

Fixed submission:
S=input()
s=list(S)
T=input()
t=list(T)
for i in range(len(s)):
  s.insert(0,s[-1])
  s.pop(-1)
  if s==t:
    print('Yes')
    exit()
  
print('No')

Buggy submission (verdict: Runtime Error):
S=input()
s=list(S)
T=input()
t=list(T)
for i in range(len(s)):
  s.insert(0,s[-1])
  print(s)
  s.pop(-1)
  
  print(s)
  if s==t:
    print('Yes')
    exit()
  
print('N
Problem p04044 (python)

Fixed submission:
N,L=map(int,input().split())
l=list()
for i in range(N):
  S=input()
  l.append(S)
ll=sorted(l)
print(''.join(ll))

Buggy submission (verdict: Runtime Error):
L,N=map(int,input().split())
l=list()
for i in range(N):
  S=input()
  l.append(S)
ll=sorted(l)
print(''.join(ll))

Buggy submission (verdict: Runtime Error):
L,N=map(int,input().split())
l=list()
for i in range(N):
  S=input()
  l.append(S)
ll=sorted(l)
print(''.join(ll))
Problem p02690 (python)

Fixed submission:
import itertools
import numpy as np

X = int(input())
maxs = int(X**(1/5))

l = np.arange(-126, 127)

comb = np.array(list(itertools.combinations_with_replacement(l, 2)))

sum1 = comb[:, 0]**5 - comb[:, 1]**5
sum2 = comb[:, 1]**5 - comb[:, 0]**5

if len(np.where(sum1==X)[0]) != 0:
    result1 = np.where(sum1==X)[0][0]
    print(comb[result1][0], comb[result1][1])
else:
    result2 = np.where(sum2==X)[0][0]
    print(comb[result2][1], comb[result2][0])

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np

X = int(input())
maxs = int(X**(1/5))

l = np.arange(-maxs, maxs+1)

comb = np.array(list(itertools.combinations_with_replacement(l, 2)))

sum1 = comb[:, 0]**5 - comb[:, 1]**5
sum2 = comb[:, 1]**5 - comb[:, 0]**5

if len(np.where(sum1==X)[0]) != 0:
    result1 = np.where(sum1==X)[0][0]
    print(comb[result1][0], comb[result1][1])
else:
    result2 = np.where(sum2==X)[0][0]
    print(comb[result2][1], comb[result2][0])

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np

X = int(input())
#maxs = int(X**(1/5))

l = np.arange(-63, 64)

comb = np.array(list(itertools.combinations_with_replacement(l, 2)))

sum1 = comb[:, 0]**5 - comb[:, 1]**5
sum2 = comb[:, 1]**5 - comb[:, 0]**5

try:
    result1 = np.where(sum1==X)[0][0]
    print(comb[result1][0], comb[result1][1])
except:
    result2 = np.where(sum2==X)[0][0]
    print(comb[result2][1], comb[result2][0])

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np

X = int(input())
maxs = int(X**(1/5))

l = np.arange(-maxs-1, maxs+2)

comb = np.array(list(itertools.combinations_with_replacement(l, 2)))

sum1 = comb[:, 0]**5 - comb[:, 1]**5
sum2 = comb[:, 1]**5 - comb[:, 0]**5

try:
    result1 = np.where(sum1==X)[0][0]
    print(comb[result1][0], comb[result1][1])
except:
    result2 = np.where(sum2==X)[0][0]
    print(comb[result2][1], comb[result2][0])

Buggy submission (verdict: Runtime Error):
import itertools
import numpy as np

X = int(input())
maxs = int(X**(1/5))

l = np.arange(-maxs, maxs+1)

comb = np.array(list(itertools.combinations_with_replacement(l, 2)))

sum1 = comb[:, 0]**5 - comb[:, 1]**5
sum2 = comb[:, 1]**5 - comb[:, 0]**5

try:
    result1 = np.where(sum1==X)[0][0]
    print(comb[result1][0], comb[result1][1])
except:
    result2 = np.where(sum2==X)[0][0]
    print(comb[result2][1], comb[result2][0])
Problem p02934 (python)

Fixed submission:
import numpy as np

N = int(input())
A_array = np.array([int(x) for x in input().split()])

a_array = np.sum(1/A_array)
print(1/a_array)

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A_array = np.array(map(int, input().split()))

a_array = 1/A_array
print(np.sum(a_array))

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A_array = np.array(input().split())

a_array = 1/A_array
print(np.sum(a_array))
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
 
def FizzBuzz(a, b):
  total = a*b
  if total % 2 == 0:
    print('Even')
  else:
    print('Odd')
 
FizzBuzz(a, b)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
 
def FizzBuzz(a, b):
  total = a*b
  if a*b%2 = 0:
    print('Even')
  else:
    print('Odd')
 
FizzBuzz(a, b)

Buggy submission (verdict: Runtime Error):
a, b = int(input())

def FizzBuzz(a, b):
  total = a*b
  if a*b%2 = 0:
    print('Even')
  else:
    print('Odd')

FizzBuzz(a,b)
Problem p03456 (python)

Fixed submission:
a, b = map(str, input().split())
import math
 
def square(a, b):
  total = int(a+b)
  if math.sqrt(total).is_integer() == True:
    print('Yes')
  else:
    print('No')
 
square(a, b)

Buggy submission (verdict: Runtime Error):
a, b = map(str, input().split())
import math

def square(a, b):
  total = int(a+b)
  if math.square(total).is_integer() == True
    print('yes')
  else:
    print('no')
 
square(a, b)
Problem p03845 (python)

Fixed submission:
import numpy as np

N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
    P, X = map(int, input().split())
    
    T_new = T.copy()
    T_new[P-1] = X
    print(np.array(T_new).sum())

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
    P, X = map(int, input().split())
    
    T_new = T
    T_new[P] = X
    print(np.array(T_new).sum())

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
    P, X = map(int, input().split())
    
    T_new = T
    T_new[P = X
    print(np.array(T_new).sum())

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
    P, X = map(int, input().split())
    
    T_new = T
    T_new[P[i]] = X
    print(np.array(T_new).sum())

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(M):
    P, X = map(int(input().split()))
    
    T_new = T
    T_new[P[i]] = X
    print(np.array(T_new).sum())

Buggy submission (verdict: Runtime Error):
import numpy as np

N = int(input())
T = list(map(int, input().split()))
M = int(input())
for i in range(len(M)):
    P, X = map(int(input().split()))
    
    T_new = T
    T_new[P[i]] = X
    print(np.array(T_new).sum())
Problem p03846 (python)

Fixed submission:
import numpy as np

N = int(input())
A = sorted(list(map(int, input().split())))

if len(A)%2 == 0:
    result = (2**(len(A)//2))%(10**9+7)
    a = np.arange(1, len(A), 2).tolist()
    a = sorted(a+a)
    if a == A:
        pass
    else:
        result = 0
else:
    result = 2**(len(A)//2)%(10**9+7)
    a = np.arange(2, len(A), 2).tolist()
    a = sorted([0]+a+a)
    if a == A:
        pass
    else:
        result = 0
print(result)

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

if len(A)%2 == 0:
    result = 2**(len(A)//2)
    a = np.arange(1, len(A), 2).tolist()
    a = sorted(a+a)
    if a == A:
        pass
    else:
        result = 0
else:
    result = 2**(len(A)//2)
    a = np.arange(2, len(A), 2).tolist()
    a = sorted([0]+a+a)
    if a == A:
        pass
    else:
        result = 0
print(result)
Problem p03862 (python)

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

total = 0
for i in range(len(a)-1):
    diff = a[i+1] + a[i] - x
    if diff>0:
        total += diff
        if a[i+1]>=diff:
            a[i+1] = a[i+1]-diff
        else:
            a[i+1] = 0
            a[i] = a[i] -(diff-a[i+1])
    else:
        pass
    
print(total)

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

total = 0
for i in range(len(a)):
    if (a[i+1]+a[i])>=x:
        if (a[i+1]-(x-a[i]))>=0:
            a[i+1] = a[i+1]-(x-a[i])
            total += x-a[i]
        else:
            a[i+1] = 0
            total += x-a[i]
    else:
        pass
    
print(total)
Problem p03944 (python)

Fixed submission:
W, H, N = map(int, input().split())
x = [0] * N
y = [0] * N
a = [0] * N
for i in range(N):
    x[i], y[i], a[i] = map(int, input().split())

x_min = 0
x_max = W
y_min = 0
y_max = H
for i in range(len(a)):
    if a[i] == 1:
        if x_min < x[i]:
            x_min = x[i]
    elif a[i] == 2:
        if x_max > x[i]:
            x_max = x[i]
    elif a[i] == 3:
        if y_min < y[i]:
            y_min = y[i]
    else:
        if y_max > y[i]:
            y_max = y[i]
        
x_len = x_max-x_min
y_len = y_max-y_min
result = x_len*y_len
if (x_len<0)|(y_len<0):
    result = 0

print(result)

Buggy submission (verdict: Runtime Error):
import numpy as np

W, H, N = map(int, input().split())
x = [0] * N
y = [0] * N
a = [0] * N
for i in range(N):
    x[i], y[i], a[i] = map(int, input().split())
    
total = W*H

x_list = np.arange(0, W+1)
y_list = np.arange(0, H+1)
for i in range(len(a)):
    if a[i] == 1:
        x_list = x_list[x[i]:]
    elif a[i] == 2:
        x_list = x_list[:x[i]+1]
    elif a[i] == 3:
        y_list = y_list[y[i]:]
    else:
        y_list = y_list[:y[i]+1]
        
x_len = x_list[-1]-x_list[0]
y_len = y_list[-1]-y_list[0]

print(x_len*y_len)
Problem p03945 (python)

Fixed submission:
S = input()
w = S.split('B')
w = [x for x in w if x != '']
b = S.split('W')
b = [x for x in b if x != '']

print(len(w)+len(b)-1)

Buggy submission (verdict: Runtime Error):
S = input()
w = S.split('B')
w.remove('')
b = S.split('W')
b.remove('')

print(len(w)+len(b)-1)
Problem p03962 (python)

Fixed submission:
total = set(list(map(int, input().split())))

print(len(total))

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

print(len(total))
Problem p03964 (python)

Fixed submission:
# 参考記録
N = int(input())
x, y = 1, 1
for i in range(N):
    a, b = map(int, input().split())
    # 前回の得票数+今回の得票数が今回のやつよりはるかに多い➡その倍数分あればいい？？
    mul = max((x+a-1)//a, (y+b-1)//b)
    x = mul*a
    y = mul*b
print(x+y)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

N = int(input())
t = [0] * N
A = [0] * N
total = []
for i in range(N):
    t[i], A[i] = map(int, input().split())
    total.append(t[i]+A[i])

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

print(lcm_list(total))