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

Fixed submission:
print(sum([x for x in range(1,int(input())+1)]))

Buggy submission (verdict: Runtime Error):
print(sum([x for x in range(1,int(input().split())+1)]))
Problem p04043 (python)

Fixed submission:
ABC=input()
if ABC.count('5')==2 and ABC.count('7')==1:
  print('YES')
else:
  print('NO')

Buggy submission (verdict: Runtime Error):
ABC=iuput()
if ABC.count('5')==2 and ABC.count('7')==1:
  print('YES')
else:
  print('NO')
Problem p04044 (python)

Fixed submission:
N,L=[int(x) for x in input().split()]
s=[]
for _ in range(N):
  s.append(input())
s.sort()
print("".join(s))

Buggy submission (verdict: Runtime Error):
N,L=[int(x) for x i input().split()]
s=[]
for _ in range(N):
  s.append(input())
s.sort()
print("".join(s))
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
p = [int(_) for _ in input().split()]

arr = [0] * 1000
for i in p:
    arr[i] = 1

ans1 = 0
for i in range(x, -1, -1):
    if arr[i] == 0:
        ans1 = i
        break

# print(arr)

ans2 = 0
for i in range(x, 102):
    if arr[i] == 0:
        ans2 = i
        break

if abs(ans1 - x) <= abs(x - ans2):
    print(ans1)
else:
    print(ans2)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = [int(_) for _ in input().split()]

arr = [0] * 101
for i in p:
    arr[i] = 1

ans, cnt = 0, 0
for i in range(x, -1, -1):
    if arr[i] == 0:
        ans = i
        break
    else:
        cnt += 1

if cnt == x:
    cnt = 10000

#print(arr)
#print(cnt)

cnt2 = 0
for i in range(x, 102):
    if arr[i] == 0:
        if cnt2 < cnt:
            ans = i
        break
    else:
        cnt2 += 1

print(ans)
Problem p02761 (python)

Fixed submission:
n, m = map(int, input().split())
sc = []
for i in range(m):
    s, c = map(int, input().split())
    sc.append((s, c))

ans = [-1] * n

if m == 0:
    if n == 1:
        print(0)
    elif n == 2:
        print(10)
    else:
        print(100)
    exit()

if n == 1 and m == 1:
    if sc[0][0] == 1 and sc[0][1] == 0:
        print(0)
        exit()

if n == 1:
    for i in range(m):
        if sc[i][1] == 0:
            print(-1)
            exit()
        if ans[0] != sc[i][1] and ans[0] != -1:
            print(-1)
            exit()
        ans[0] = sc[i][1]
    print(sc[0][1])
    exit()

for i in range(m):
    if ans[sc[i][0]-1] != sc[i][1] and ans[sc[i][0]-1] != -1:
        print(-1)
        exit()
    if sc[i][0] == 1 and sc[i][1] == 0:
        print(-1)
        exit()
    ans[sc[i][0]-1] = sc[i][1]

if ans[0] == -1:
    ans[0] = 1

for i in range(n):
    if ans[i] == -1:
        ans[i] = 0

for i in ans:
    print(i, end="")
print()

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

ans = [-1] * n

if n == 1:
    for i in range(m):
        if sc[i][1] == 0:
            print(-1)
            exit()
        if ans[0] != sc[i][1] and ans[0] != -1:
            print(-1)
            exit()
        ans[0] = sc[i][1]
    print(sc[0][1])
    exit()

for i in range(m):
    if ans[sc[i][0]-1] != sc[i][1] and ans[sc[i][0]-1] != -1:
        print(-1)
        exit()
    if sc[i][0] == 1 and sc[i][1] == 0:
        print(-1)
        exit()
    ans[sc[i][0]-1] = sc[i][1]

if ans[0] == -1:
    ans[0] = 1

for i in range(n):
    if ans[i] == -1:
        ans[i] = 0

for i in ans:
    print(i, end="")
print()
Problem p02866 (python)

Fixed submission:
import collections
MOD = 998244353

n = int(input())
d = [int(_) for _ in input().split()]

ans = 1
if d[0] != 0:
    ans = 0
else:
    D = sorted(collections.Counter(d).most_common())
    if D[0][1] != 1:
        ans = 0
    else:
        cnt = 0
        prev = 1
        for i in D:
            if i[0] == cnt:
                ans = ans * pow(prev, i[1], MOD) % MOD
                prev = i[1]
            else:
                ans = 0
                break
            cnt += 1
print(ans)

Buggy submission (verdict: Runtime Error):
import collections
import math
MOD = 998244353

n = int(input())
d = [int(_) for _ in input().split()]

ans = 1
if not d[0]  == 0:
    ans = 0
else:
    D = sorted(collections.Counter(d).most_common())
    for i in range(1, max(d)+1):
        ans = ans * pow(D[i-1][1], D[i][1], MOD)
print(ans)
Problem p03145 (python)

Fixed submission:
ab, bc, ca = map(int, input().split())
print(int(ab*bc/2))

Buggy submission (verdict: Runtime Error):
ab, bc = map(int, input().split())
print(ab*bc/2)
Problem p03164 (python)

Fixed submission:
N, W = map(int, input().split())
item = [[0] * 2 for _ in range(N)]
for i in range(N):
    w, v = map(int, input().split())
    item[i][0], item[i][1] = w, v
dp = [[1000000001] * (1000*N+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1, N+1):
    for j in range(1000*N+1):
        if item[i-1][1] <= j:
            dp[i][j] = min(dp[i-1][j-item[i-1][1]] + item[i-1][0], dp[i-1][j])
        else:
            dp[i][j] = dp[i-1][j]
ans = 0
for i in range(1000*N+1):
    if dp[N][i] <= W:
        ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
item = [[0] * 2 for _ in range(N)]
for i in range(N):
    w, v = map(int, input().split())
    item[i][0], item[i][1] = w, v
dp = [[0] * (W+1) for _ in range(N+1)]
for n in range(1, N+1):
    for w in range(W+1):
        if item[n-1][0] <= w:
            dp[n][w] = max(dp[n-1][w], dp[n-1][w-item[n-1][0]] + item[n-1][1])
        else:
            dp[n][w] = dp[n-1][w]
print(dp[N][W])
Problem p04043 (python)

Fixed submission:
a, b, c = map(int, input().split())
abc = sorted([a, b, c])
if abc[0] == 5 and abc[1] == 5 and abc[2] == 7:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
dis = [_ for _ in input().split()]
for yen in range(1, 100000):
    if yen < n:
        pass
    else:
        if len(set(list(str(yen))) & set(dis)) == 0:
            print(yen)
            exit()
Problem p02658 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
 
ans = 1
flag = 1
if 0 in A:
    ans = 0
else:
    for i in range(N):
        ans *= A[i]
        if ans > 10 ** 18:
            flag = 0
            break

if flag == 0:
    print(-1)
else:
    print(ans)

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

N = int(input())
A = list(map(int, input().split()))
arr_A = np.array(A)

ans = np.prod(A)

if ans > 10 ** 18:
    print(-1)
else:
    print(ans)
Problem p02945 (python)

Fixed submission:
A,B = map(int, input().split())
print(max(A+B, A-B, A*B))

Buggy submission (verdict: Runtime Error):
from collections import Counter

N = int(input())
s = []
for i in range(N):
    s.append(Counter(input()))

ans = 0
for i in range(N):
  for j in range(i+1, N):
    if(s[i] == s[j]):
      ans += 1
    
print(ans)
Problem p02608 (python)

Fixed submission:
N=int(input())
import math
ans=[0]*(N+1)
n=int(math.sqrt(N))+1
for i in range(1,n+1):
    if i*i +2*i >N:
        break
    for j in range(1,n+1):
        if i*i+j*j+i*j>N:
            break
        for k in range(1,n+1):
            if i*i+j*j+k*k+i*j+j*k+i*k>N:
                break
            else:
                #print(i*i+j*j+k*k+i*j+j*k+i*k,i,j,k)
                ans[i*i+j*j+k*k+i*j+j*k+i*k]+=1
for i in range(len(ans)):
    if i!= 0:
        print(ans[i])

Buggy submission (verdict: Runtime Error):
N=int(input())
import math
ans=[0]*N
n=int(math.sqrt(N))+1
for i in range(1,n+1):
    if i*i +2*i >N:
        break
    for j in range(1,n+1):
        if i*i+j*j+i*j>N:
            break
        for k in range(1,n+1):
            if i*i+j*j+k*k+i*j+j*k+i*k>N:
                break
            else:
                #print(i*i+j*j+k*k+i*j+j*k+i*k,i,j,k)
                ans[i*i+j*j+k*k+i*j+j*k+i*k]+=1
for i in ans:
    print(i)
Problem p02705 (python)

Fixed submission:
import math
R=int(input())
print(2*R*math.pi)

Buggy submission (verdict: Runtime Error):
import math

R=int(input())
print(2*math.pie*R)
Problem p02615 (python)

Fixed submission:
n = int(input())
lis = sorted(list(map(int, input().split())),reverse=True)
idx = 0
res = lis[0]
while True:
    if idx >= n-2:
        break
    res += lis[1+idx//2]
    idx += 1
print(res)

Buggy submission (verdict: Runtime Error):
#以下は上位者のコピー
n, k = map(int, input().split())
mod = 10 ** 9 + 7

from collections import deque

a = list(map(int, input().split()))
a.sort()
minus, zero, plus = 0, 0, 0
for i in range(n):
    if a[i] < 0:
        minus += 1
    elif a[i] == 0:
        zero += 1
    else:
        plus += 1

que = deque(a)

plus_flg = False
tmp = plus - k
if tmp >= 0:
    plus_flg = True
elif tmp*-2 > minus  :
    plus_flg = True

# plus可能
if plus_flg:
    ans = 1
    cnt = 0

    while cnt < k:
        if k - cnt >= 2:
            cnt += 2
            if que[0] * que[1] >= que[-1] * que[-2]:
                ans *= que.popleft()
                ans *= que.popleft()
                ans %= mod
            else:
                ans *= que.pop()
                ans *= que.pop()
                ans %= mod
        else:
            ans *= que.pop()
            ans %= mod
            cnt += 1

    print(ans)



# zero
elif zero > 0:
    print(0)

# minus
else:
    a = [abs(a[i]) for i in range(n)]
    a.sort()
    ans = 1
    for i in range(k):
        ans *= a[i]
        ans %= mod
    ans = -ans % mod
    print(ans)
Problem p02642 (python)

Fixed submission:
n = int(input())
aas = sorted(list(map(int, input().split())))
aas_len = len(aas)
if aas_len == 1:
    print(1)
    exit()
aas_max = aas[-1]
arr = [1]*(aas_max+1)
for i in range(aas_len):
    if arr[aas[i]] == 0:
        continue
    if arr[aas[i]] == 1:
        arr[aas[i]] = 2
    else:
        arr[aas[i]] = 0
        continue
    idx = aas[i]*2
    while idx <= aas_max:
        arr[idx] = 0
        idx += aas[i]
res = 0
for i in aas:
    if arr[i] != 0:
        res += 1
print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
aas = sorted(list(set(list(map(int, input().split())))))
aas_len = len(aas)
if aas_len == 1:
    print(0)
    exit()
aas_max = aas[-1]
arr = [1]*(aas_max+1)
for i in range(aas_len):
    if arr[aas[i]] == 0:
        continue
    idx = aas[i]*2
    while idx <= aas_max:
        arr[idx] = 0
        idx += aas[i]
res = 0
for i in aas:
    if arr[i] == 1:
        res += 1
print(res)

Buggy submission (verdict: Runtime Error):
n = int(input())
aas = list(set(sorted(list(map(int, input().split())))))
if len(aas) == 1:
    print(0)
    exit()
#aas_max = aas[-1]
i = 0
while i != len(aas):
    j = i + 1
    while j != len(aas):
        if aas[j]%aas[i] == 0:
            del aas[j]
        else:
            j += 1
    i += 1
print(len(aas))
Problem p02690 (python)

Fixed submission:
x = int(input())
n=100
tes = [0]
for i in range(-250,250):
    for j in range(-250,250):
        if pow(i,5) - pow(j,5) == x:
            print(str(i)+" "+str(j))
            exit()

Buggy submission (verdict: Runtime Error):
x = int(input())
n=100
tes = [0]
for i in range(-101,101):
    for j in range(-101,101):
        if pow(i,5) - pow(j,5) == x:
            print(str(i)+" "+str(j))
            exit()
print(tes[1])
Problem p02981 (python)

Fixed submission:
n,a,b = map(int,input().split())
print(min(a * n, b))

Buggy submission (verdict: Runtime Error):
n,a,b=map(int, input.split())
print(max(n*a,b))

Buggy submission (verdict: Runtime Error):
n,a,b=map(int input.split())
print(max(n*a,b))
Problem p02999 (python)

Fixed submission:
x,a=map(int, input().split())
print('10' if x>=a else '0')

Buggy submission (verdict: Runtime Error):
x,a=map(int, input.split())
print('10' if x>=a else '0')

Buggy submission (verdict: Runtime Error):
x,a=map(int, input.split())
print(10 if x>=a else 0)
Problem p03032 (python)

Fixed submission:
from itertools import accumulate
n, k = map(int, input().split())
vs = list(map(int, input().split()))
res = 0
for i in range(min(n,k)+1):
    for j in range(min(n-i,k-i)+1):
        res_tmp = 0
        arr = []
        if i > 0:
            arr += vs[:i]
        if j > 0:
            arr += vs[(n-j):]
        if arr != []:
            arr.sort()
            n_len = len(arr)
            for m in range(min(k-i-j,n_len)):
                if arr[m] >= 0:
                    break
                res_tmp -= arr[m]
            res_tmp += sum(arr)
        res = max(res,res_tmp)
print(res)

Buggy submission (verdict: Runtime Error):
import heapq
from itertools import accumulate
n, k = map(int, input().split())
vs = list(map(int, input().split()))
vs_hq = vs.copy()
rsw_l = list(accumulate(vs))
rsw_r = vs.copy()
for i in reversed(range(n-1)):
    rsw_r[i] = rsw_r[i+1] + rsw_r[i]
rsw_l = [0] + rsw_l
rsw_r = rsw_r + [0]
n_minus_l = [0]*n
if vs[0] < 0:
    n_minus_l[0] = 1
for i in range(1,n):
    if vs[i] < 0:
        n_minus_l[i] = n_minus_l[i-1] + 1
    else:
        n_minus_l[i] = n_minus_l[i - 1]
n_minus_l = [0] + n_minus_l
n_minus_r = [0]*n
if vs[n-1] < 0:
    n_minus_r[n-1] = 1
for i in reversed(range(n-1)):
    if vs[i] < 0:
        n_minus_r[i] = n_minus_r[i+1] + 1
    else:
        n_minus_r[i] = n_minus_r[i+1]
n_minus_r = n_minus_r + [0]
res = 0
for i in range(min(n,k)+1):
    for j in range(k-i+1):
        tmp = rsw_l[i] + rsw_r[n-j]
        n_dis = min(k-i-j,n_minus_l[i]+n_minus_r[n-j])
        arr = []
        if i > 0:
            arr += vs[:i]
        if j > 0:
            arr += list(reversed(vs))[:j]
        if arr != []:
            tmp -= sum(sorted(arr)[:n_dis])
        res = max(res,tmp)
print(res)
Problem p03230 (python)

Fixed submission:
n = int(input())
if n == 1:
    print('Yes')
    print(2)
    print("1 1")
    print("1 1")
    exit()
t = [3]
cnt = 3
while t[-1]+cnt <= n:
    t.append(t[-1]+cnt)
    cnt += 1
if t[-1] != n:
    print('No')
    exit()
print('Yes')
try:
    n_cols = t[-1]-t[-2]
except:
    print(3)
    print("2 1 2")
    print("2 3 1")
    print("2 2 3")
    exit()
print(n_cols+1)
t_len = len(t)
t2 = [i+1 for i in t]
t3 = [0 for i in t]
for col in range(n_cols+1):
    out = str(n_cols)
    if col <=2:
        if col == 0:
            out += " 1 2"
        elif col == 1:
            out += " 1 3"
        elif col == 2:
            out += " 2 3"
    else:
        idx = t[col-3]+1
        while idx <= t[col-2]:
            out += " " + str(idx)
            idx += 1
    for i in range(t_len-1):
        if t2[i] != t[i+1]+1:
            out += " " + str(t2[i])
            t2[i] += 1
    print(out)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n == 1:
    print('Yes')
    prnt(2)
    print("1")
    print("1")
    exit()
t = [3]
cnt = 3
while t[-1]+cnt <= n:
    t.append(t[-1]+cnt)
    cnt += 1
if t[-1] != n:
    print('No')
    exit()
print('Yes')
try:
    n_cols = t[-1]-t[-2]
except:
    print(3)
    print("2 1 2")
    print("2 3 1")
    print("2 2 3")
    exit()
print(n_cols+1)
t_len = len(t)
t2 = [i+1 for i in t]
t3 = [0 for i in t]
for col in range(n_cols+1):
    out = str(n_cols)
    if col <=2:
        if col == 0:
            out += " 1 2"
        elif col == 1:
            out += " 1 3"
        elif col == 2:
            out += " 2 3"
    else:
        idx = t[col-3]+1
        while idx <= t[col-2]:
            out += " " + str(idx)
            idx += 1
    for i in range(t_len-1):
        if t2[i] != t[i+1]+1:
            out += " " + str(t2[i])
            t2[i] += 1
    print(out)
Problem p03436 (python)

Fixed submission:
from collections import deque
h, w = map(int, input().split())
chiz = [[] for _ in range(w)]
cnt = 0
for _ in range(h):
    tmp_list = input()
    for i in range(w):
        if tmp_list[i]=='.':
            cnt += 1
        chiz[i].append(tmp_list[i])
dq = deque([(0,0)])
chiz[0][0] = 0
while dq:
    i,j = dq.popleft()
    for e in [(1,0),(-1,0),(0,-1),(0,1)]:
        if i+e[0]>=0 and i+e[0]<w and j+e[1]>=0 and j+e[1]<h:
            if chiz[i+e[0]][j+e[1]] == '.':
                chiz[i+e[0]][j+e[1]] = chiz[i][j] + 1
                dq.append((i+e[0],j+e[1]))
try:
    print(cnt-chiz[w-1][h-1]-1)
except:
    print(-1)

Buggy submission (verdict: Runtime Error):
from collections import deque
h, w = map(int, input().split())
chiz = [[] for _ in range(w)]
cnt = 0
for _ in range(h):
    tmp_list = input()
    for i in range(w):
        if tmp_list[i]=='.':
            cnt += 1
        chiz[i].append(tmp_list[i])
dq = deque([(0,0)])
chiz[0][0] = 0
while dq:
    i,j = dq.popleft()
    for e in [(1,0),(-1,0),(0,-1),(0,1)]:
        if i+e[0]>=0 and i+e[0]<w and j+e[1]>=0 and j+e[1]<h:
            if chiz[i+e[0]][j+e[1]] == '.':
                chiz[i+e[0]][j+e[1]] = chiz[i][j] + 1
                dq.append((i+e[0],j+e[1]))
print(cnt-chiz[w-1][h-1]-1)
Problem p03732 (python)

Fixed submission:
N,W=map(int,input().split())
dp=[[-1]*301 for i in range(N+1)]
dp[0][0]=0

for i in range(N):
    w,v=map(int,input().split())
    if i==0:
        base=w
    for i in range(N)[::-1]:
        for j in range(301)[::-1]:
            if dp[i][j]!=-1:
                dp[i+1][j+w-base]=max(dp[i][j]+v,dp[i+1][j+w-base])

ans=0
for index,item in enumerate(dp):
    if W-index*base+1<=0:
        break
    ans=max(max(item[:W-index*base+1]),ans)

print(ans)

Buggy submission (verdict: Runtime Error):
n, w = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(n)]
if w < items[0][0] :
    print(0)
    exit()
w_sum = 0
v_sum = 0
for i in range(n):
    w_sum += items[i][0]
    v_sum += items[i][1]
if w >= w_sum:
    print(v_sum)
    exit()
dp = {}
#for j in range(items[0][0],w+1):
cnt_l = 1
cnt_r = 0
j = items[0][0] * cnt_l + cnt_r
while j < w+1:
    for i in range(1,n+1):
        if j-items[i-1][0] >= 0:
            if str(i-1)+":"+str(j) not in dp:
                dp[str(i - 1) + ":" + str(j)] = 0
            if str(i-1)+":"+str(j-items[i-1][0]) not in dp:
                dp[str(i - 1) + ":" + str(j - items[i - 1][0])] = 0
            dp[str(i)+":"+str(j)] = max(dp[str(i-1)+":"+str(j)],dp[str(i-1)+":"+str(j-items[i-1][0])]+items[i-1][1])
        else:
            if str(i-1)+":"+str(j) not in dp:
                dp[str(i - 1) + ":" + str(j)] = 0
            dp[str(i)+":"+str(j)] = dp[str(i-1)+":"+str(j)]
    cnt_r += 1
    if cnt_r >= 350:
        cnt_l += 1
        cnt_r = 0
    j = items[0][0] * cnt_l + cnt_r
print(dp[str(n)+":"+str(w)])

Buggy submission (verdict: Runtime Error):
n, w = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(n)]
if w < items[0][0] :
    print(0)
    exit()
w_sum = 0
v_sum = 0
for i in range(n):
    w_sum += items[i][0]
    v_sum += items[i][1]
if w >= w_sum:
    print(v_sum)
    exit()
dp2 = [[0]*(w+1) for _ in range(n+1)]
dp = {}
for j in range(1,w+1):
    for i in range(1,n+1):
        if j-items[i-1][0] >= 0:
            if str(i-1)+":"+str(j) not in dp:
                dp[str(i - 1) + ":" + str(j)] = 0
            if str(i-1)+":"+str(j-items[i-1][0]) not in dp:
                dp[str(i - 1) + ":" + str(j - items[i - 1][0])] = 0
            dp[str(i)+":"+str(j)] = max(dp[str(i-1)+":"+str(j)],dp[str(i-1)+":"+str(j-items[i-1][0])]+items[i-1][1])
        else:
            if str(i-1)+":"+str(j) not in dp:
                dp[str(i - 1) + ":" + str(j)] = 0
            dp[str(i)+":"+str(j)] = dp[str(i-1)+":"+str(j)]
print(dp[str(n)+":"+str(w)])
Problem p02556 (python)

Fixed submission:
N = int(input())
a = - (10 ** 9 + 3)  # max(x + y)
b = 10 ** 9 + 3  # min(x + y)
c = - (10 ** 9 + 3)  # max(x - y)
d = 10 ** 9 + 3  # min(x - y)
for i in range(N):
    x, y = map(int, input().split())
    a = max(a, x + y)
    b = min(b, x + y)
    c = max(c, x - y)
    d = min(d, x - y)
ans = max([a - b, c - d])
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
xpy_max = 0
xpy_min = 10 ** 9 + 3
xmy_max = 0
xmy_min = 10 ** 9 + 3
for i in range(N):
    x, y = map(int, input().split())
    if x + y <= xpy_min:
        xpy_min = x + y
        a = (x, y)
    if x + y >= xpy_max:
        xpy_max = x + y
        b = (x, y)
    if x - y >= xmy_max:
        xmy_max = x - y
        c = (x, y)
    if x - y <= xmy_min:
        xmy_min = x - y
        d = (x, y)
ans = max(b[0] - a[0] + b[1] - a[1], c[0] - d[0] + c[1] - d[1])
print(ans)
Problem p02582 (python)

Fixed submission:
ans = 0
answer = []
S = input()
for s in S:
    if s == "R":
        ans += 1
    else:
        answer.append(ans)
        ans = 0
answer.append(ans)
print(max(answer))

Buggy submission (verdict: Runtime Error):
ans = 0
answer = []
S = input()
for s in S:
    if s == "R":
        ans += 1
    else:
        answer.append(ans)
        ans = 0
print(max(answer))
Problem p02603 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
strategy = ["stay"] * len(A)

trend = "down"
for i in range(len(A)):
    if i == len(A) - 1:
        new_trend = "down"
        strategy[i] = "sell"
    else:
        if A[i] < A[i+1]:
            new_trend = "up"
            if trend != new_trend:
                strategy[i] = "buy"
        elif A[i] > A[i+1]:
            new_trend = "down"
            if trend != new_trend:
                strategy[i] = "sell"
        else:
            strategy[i] = "stay"
            new_trend = trend
    trend = new_trend


money = 1000
stock = 0
for s in range(len(strategy)):
    if strategy[s] == "sell":
        money = money + stock * A[s]
        stock = 0
    elif strategy[s] == "buy":
        stock = money // A[s]
        money = money - A[s] * stock
    else:
        continue
print(money)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
strategy = ["stay"] * len(A)

trend = "down"
for i in range(len(A)):
    if i == len(A) - 1:
        new_trend = "down"
        strategy[i] = "sell"
    else:
        if A[i] < A[i+1]:
            new_trend = "up"
            if trend != new_trend:
                strategy[i] = "buy"
        elif A[i] > A[i+1]:
            new_trend = "down"
            if trend != new_trend:
                strategy[i] = "sell"
        else:
            strategy[i] = "stay"
    trend = new_trend


money = 1000
stock = 0
for s in range(len(strategy)):
    if strategy[s] == "sell":
        money = money + stock * A[s]
        stock = 0
    elif strategy[s] == "buy":
        stock = money // A[s]
        money = money - A[s] * stock
    else:
        continue
print(money)
Problem p02608 (python)

Fixed submission:
N = int(input())
A = [0] * 10001
for x in range(1, int(pow(N, 0.5))):
    for y in range(1, int(pow(N, 0.5))):
        for z in range(1, int(pow(N, 0.5))):
            value = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if value > 10000:
                break
            A[value] += 1
for a in A[1:N+1]:
    print(a)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [0] * 10000
for x in range(1, int(pow(N, 0.5))):
    for y in range(1, int(pow(N, 0.5))):
        for z in range(1, int(pow(N, 0.5))):
            value = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if value > 10000:
                break
            A[value] += 1
for a in A[:N]:
    print(a)
Problem p02683 (python)

Fixed submission:
from itertools import combinations
import numpy as np
ans = -1

N, M, X = map(int, input().split())
A = np.ndarray(shape=(N, M), dtype=int)
C = np.ndarray(shape=(N, ), dtype=int)
ans = []
costs = []
money = []
for i in range(N):
    inp = list(map(int, input().split()))
    C[i] = inp[0]
    A[i] = inp[1:]
for r in range(N):
    for c in combinations(range(N), r + 1):
        if min(np.sum(A[list(c)], axis=0)) >= X:
            costs.append(np.sum(C[list(c)]))
if len(costs) == 0:
    print(-1)
else:
    print(min(costs))

Buggy submission (verdict: Runtime Error):
from itertools import combinations
import numpy as np
ans = -1

N, M, X = map(int, input().split())
A = np.ndarray(shape=(N, M), dtype=int)
C = np.ndarray(shape=(N, ), dtype=int)
ans = []
costs = []
money = []
for i in range(N):
    inp = list(map(int, input().split()))
    C[i] = inp[0]
    A[i] = inp[1:]
for r in range(N):
    for c in combinations(range(N), r + 1):
        if min(np.sum(A[list(c)], axis=0)) >= X:
            costs.append(np.sum(C[list(c)]))
if len(costs) == 0:
    print(-1)
else:
    print(min(costs))