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

Fixed submission:
h, w = map(int, input().split())
lst = []
for i in range(h):
    lst.append(list(input()))

R = [[0]*w for _ in range(h)]
L = [[0]*w for _ in range(h)]
U = [[0]*w for _ in range(h)]
D = [[0]*w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if lst[i][j] == '.':
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1] + 1
        

for i in range(h):
    for j in range(w-1, -1, -1):
        if lst[i][j] == '.':
            if j == w-1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j+1] + 1            


for i in range(h):
    for j in range(w):
        if lst[i][j] == '.':
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i-1][j] + 1

for i in range(h-1, -1, -1):
    for j in range(w):
        if lst[i][j] == '.':
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i+1][j] + 1

ans = 0
x = [[0]*w for _ in range(h)]
for i in range (h):
    for j in range(w):
        x[i][j] = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
    ans = max(ans, max(x[i]))
print(ans)

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
lst = []
for i in range(h):
    lst.append(list(input()))

R = [[0]*w for _ in range(h)]
L = [[0]*w for _ in range(h)]
U = [[0]*w for _ in range(h)]
D = [[0]*w for _ in range(h)]

for i in range(h):
    for j in range(w):
        if lst[i][j] == '.':
            if j == 0:
                L[i][j] = 1
            else:
                L[i][j] = L[i][j-1] + 1
        

for i in range(h):
    for j in range(w-1, -1, -1):
        if lst[i][j] == '.':
            if j == w-1:
                R[i][j] = 1
            else:
                R[i][j] = R[i][j-1] + 1            

     
for i in range(h):
    for j in range(w):
        if lst[i][j] == '.':
            if i == 0:
                U[i][j] = 1
            else:
                U[i][j] = U[i][j-1] + 1

for i in range(h-1, -1, -1):
    for j in range(w):
        if lst[i][j] == '.':
            if i == h-1:
                D[i][j] = 1
            else:
                D[i][j] = D[i][j-1] + 1

ans = 0
x = [[0]*w for _ in range(h)]
for i in range (h):
    for j in range(w):
        x[i][j] = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
    ans = max(ans, max(x[i])
print(ans)
Problem p03029 (python)

Fixed submission:
a, p = map(int, input().split())
print((3*a+p)//2)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
s = []
for i in range(M):
    s.append(list(map(int, input().split())))
p = list(map(int, input().split()))

switch = [['0'], ['1']]

for i in range(N-1):
    tmp = []
    for j in switch:
        tmp.append(j+['0'])
        tmp.append(j+['1'])
    switch = tmp #スイッチのonoffのマップ化

ans = 0

for i in switch:
    false = 0
    for j in range(M):
        cnt = 0 #onの個数
        for k in range(s[j][0]):
            if i[s[j][1+k]-1] == '1':
                cnt += 1
            if cnt%2 != p[j]:
                false += 1 #条件に合っていなかったらfalseに加算する
        if false == 0:
            ans += 1 #全て条件を満たしていたらansに加算する
print(ans)
Problem p03031 (python)

Fixed submission:
N, M = map(int, input().split())
s = []
for i in range(M):
    s.append(list(map(int, input().split())))
p = list(map(int, input().split()))

switch = [['0'], ['1']]

for i in range(N-1):
    tmp = []
    for j in switch:
        tmp.append(j+['0'])
        tmp.append(j+['1'])
    switch = tmp #スイッチのonoffのマップ化

ans = 0

for i in switch:
    false = 0
    for j in range(M):
        cnt = 0 #onの個数
        for k in range(s[j][0]):
            if i[s[j][1+k]-1] == '1':
                cnt += 1
        if cnt%2 != p[j]:
            false += 1 #条件に合っていなかったらfalseに加算する
    if false == 0:
        ans += 1 #全て条件を満たしていたらansに加算する
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
s = []
for i in range(M):
    s.append(list(map(int, input().split())))
p = list(map(int, input().split()))

switch = [['0'], ['1']]

for i in range(n-1):
    tmp = []
    for j in switch:
        tmp.append(j+['0'])
        tmp.append(j+['1'])
    switch = tmp　#スイッチのonoffのマップ化

ans = 0

for i in switch:
    false = 0
    for j in range(M):
        cnt = 0 #onの個数
        for k in range(s[i][0]):
            if i[s[j][1+k]-1] == '1':
                cnt += 1
            if cnt%2 != p[j]:
                false += 1 #条件に合っていなかったらfalseに加算する
        if false == 0:
            ans += 1 #全て条件を満たしていたらansに加算する
print(ans)
Problem p03032 (python)

Fixed submission:
N, K = map(int, input().split())
lst = list(map(int, input().split()))
ans = 0
for l in range(K+1):
    for r in range(K+1-l):
        if l + r > N:
            break
        get = lst[:l]
        get.extend(lst[N-r:])
        cnt = sum(get)
        get.sort()
        for i in range(min(K-l-r, l+r)):
            if get[i] >= 0:
                break
            cnt -= get[i]
        ans = max(ans, cnt)
print(ans)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
lst = list(map(int, input().split()))
ans = 0
for l in range(K+1):
    for r in range(K+1-l):
        if l + r > N:
            break
        get = lst[:l]
        get.extend(lst[N-r:])
        cnt = sum(get)
        get.sort()
        for i in range(min(K-l-r, l+r)):
            if get[i] >= 0:
                break
            tmp -= get[i]
        ans = max(ans, tmp)
print(ans)
Problem p03035 (python)

Fixed submission:
A, B = map(int, input().split())
if A >= 13:
    print(int(B))
elif A <= 12 and A >= 6:
    print(int(B / 2))
else:
    print(0)

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

for i in range(M):
    b, c = map(int, input().split())
    A.extend([c]*b)
A.sort(reverse=True)
ans = A[:N]
print(sum(ans))
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(20000000)

N = int(input())
Tree = [[] for i in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    Tree[u-1].append([v-1, w])
    Tree[v-1].append([u-1, w])

ans = [-1]*N

def dfs(node, dist):
    for next_node, size in Tree[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((dist+size)%2)
            dfs(next_node, dist+size)
dfs(0, 0)
print(*ans, sep='\n')

Buggy submission (verdict: Runtime Error):
N = int(input())
Tree = [[] for i in range(N)]
for i in range(N-1):
    u, v, w = map(int, input().split())
    Tree[u-1].append([v-1, w])
    Tree[v-1].append([u-1, w])

ans = [-1]*N

def dfs(node, dist):
    for next_node, size in Tree[node]:
        if ans[next_node] == -1:
            ans[next_node] = ((dist+size)%2)
            dfs(next_node, dist+size)
dfs(0, 0)
print(*ans, sep='\n')
Problem p03071 (python)

Fixed submission:
A,B=map(int,input().split())
s=0
if A > B:
    s=A+(A-1)
elif A < B:
    s=B+(B-1)
else:
    s=A+B
print(s)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = list(input())
l = len(S)
X = []
cnt0 = 0
cnt1 = 0
for i in S:
    if i == '0':
        if cnt1 != 0:
            X.append(cnt1)
            cnt1 = 0
            cnt0 += 1
        else:
            cnt0 += 1
    else:
        if cnt0 != 0:
            X.append(cnt0)
            cnt0 = 0
            cnt1 += 1
        else:
            cnt1 += 1
if cnt1 != 0:
    X.append(cnt1)
elif cnt0 != 0:
    X.append(cnt0)
ans = []
if S[0] == '1': #Xの奇数は1
    sum0 = sum(X[0:2*K+1])
    ans.append(sum0)
    i = 0
    if 2*K+1 >= len(X):
        ans = sum(X)
    else:
        while 2*K+i+1 < len(X):
            ans.append(ans[i] + X[2*K+i+1] - X[i])
            i += 1
else:
    sum0 = sum(X[0:2*K])
    ans.append(sum0)
    i = 0
    while 2*K+i < len(X):
        ans.append(ans[i] + X[2*K+i] - X[i])
        i += 1
print(max(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
cnt = 1
for i in range(1, N):
    if i == 1:
        if H[0] <= H[1]:
            cnt += 1
    else:
        elif max(H[:i-1]) <= H[i]:
            cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
N=int(input())
H=list(map(int,input().split()))
cnt=1
before=H[0]
for i in range(1,N):
    if before <= H[i]:
        cnt+=1
    before=max(before,H[i])
print(cnt)

Buggy submission (verdict: Runtime Error):
N=int(input())
cnt=1
H=list(map(int,input().split()))
for i in range(N):
    for j in range(i):
        if j-1 > 0:
            if H[i] >= H[j-1]:
                cnt+=1
print(cnt)
Problem p03085 (python)

Fixed submission:
b=input()

if  b == "A":
    print("T")
elif b == "T":
    print("A")
elif b == "G":
    print("C")
elif b == "C":
    print("G")
else:
    print("")

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = list(input())
a_lst = []
for i in range(n-1):
    if s[i] == 'A':
        if s[i+1] == 'C':
            a_lst.append(i)
for i in range(q):
    cnt = 0
    l, r = map(int, input().split())
    for i in range(l-1, r-1):
        if i in a_lst:
            cnt += 1
    print(cnt)

Buggy submission (verdict: Runtime Error):
n, q = map(int, input().split())
s = list(input())
a_lst = []
for i in range(n):
    if s[i] == 'A':
        a_lst.append(i)
for i in range(q):
    cnt = 0
    l, r = map(int, input().split())
    for i in range(l-1, r-1):
        if i in a_lst:
            if s[i+1] == 'C':
                cnt += 1
    print(cnt)

Buggy submission (verdict: Runtime Error):
N,Q=map(int,input().split()) 
S=str(input())
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
Problem p03087 (python)

Fixed submission:
N,Q=map(int,input().split()) 
S=input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Buggy submission (verdict: Runtime Error):
N,Q=map(int,input().split()) 
S=sinput()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])
Problem p03101 (python)

Fixed submission:
H,W=map(int,input().split())
h,w=map(int,input().split())
B=(H-h)*(W-w)
print(B)

Buggy submission (verdict: Runtime Error):
N,M,C=map(int,input().split()) 
B=list(map(int,input().split()))
A =[list(map(int,input().split()))for i in range(N)]
ans=0
for i in range(N):
    X=0
    for j in range(M):
        X += A[i][j]*B[j]
    X=X+C
    if  0 < X:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N,M,C=map(int,input().split()) 
B=list(map(int,input().split()))
A =[list(map(int,input().split()))for i in range(N)]
ans=0
for i in range(N):
    X=0
    for j in range(M):
        X+=(A[i][j]*B[j])
    X=X+C
    if  0 < X:
        ans = ans+1
print(ans)
Problem p03102 (python)

Fixed submission:
n,m,c=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split()))for i in range(n)]
cnt=0
for i in range(n):
    total=0
    for j in range(m):
        total+=B[j]*A[i][j]
    total+=c
    if 0<total:
        cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
N,M,C=map(int,input().split()) 
B=list(map(int,input().split()))
A =[list(map(int,input().split()))for i in range(N)]
ans=0
for i in range(N):
    for j in range(M):
        X+=(A[i][j]*B[j])
    X=X+C
    if  0 < X:
        ans = ans+1
print(ans)

Buggy submission (verdict: Runtime Error):
N,M,C=map(int,input().split()) 
B=list(map(int,input().split()))
A =[list(map(int,input().split()))for i in range(N)]
ans=0
for i in range(N):
    for j in range(M):
        X+=(A[i][j]*B[j])
    X=X+C
    if  0 < X:
        ans = ans+1
    else:
        ans = ans
print(ans)

Buggy submission (verdict: Runtime Error):
N,M,C=map(int,input().split()) 
B=list(map(int,input().split()))
A =[list(map(int,input().split()))for i in range(N)]
ans=0
for i in range(N):
    for j in range(M):
        X+=(A[i][j]*B[j])+C
    if  0 < X:
        ans = ans+1
    else:
        ans = ans
print(ans)

Buggy submission (verdict: Runtime Error):
N,M,C=map(int,input().split()) 
B=list(map(int,input().split()))
A =[list(map(int,input().split()))for i in range(N)]
ans=0
for i in range(N):
    for j in range(M):
        X+=(A[i][j]*B[i])+C
    if  0 < X:
        ans = ans+1
    else:
        ans = ans
print(ans)
Problem p03106 (python)

Fixed submission:
a, b, k = map(int, input().split())
while a != b:
    if a > b:
        a = a - b
    else:
        b = b - a
ans = []
for i in range(1, a+1):
    if a%i == 0:
        ans.append(i)
        ans.sort(reverse=True)
print(ans[k-1])

Buggy submission (verdict: Runtime Error):
a, b, k = map(int, input().split())
while a != b:
    if a > b:
        a = a - b
    else:
        b = b - a
ans = []
for i in range(1, a):
    if a%i == 0:
        ans.append(i)
        ans.sort(reverse=True)
print(ans[k-1])
Problem p03111 (python)

Fixed submission:
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1, a+l[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b+l[cur], c) + 10
    ret3 = dfs(cur+1, a, b, c+l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Buggy submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A) + abs(b-B) + abs(c-C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1, a+l[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b+l[cur], c) + 10
    ret3 = dfs(cur+1, a, b, c+l[cur]) + 10
    return min(rest0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))

Buggy submission (verdict: Runtime Error):
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF = 10 ** 9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a-A) + abs(b-B) + abs(C-C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur+1, a, b, c)
    ret1 = dfs(cur+1, a+l[cur], b, c) + 10
    ret2 = dfs(cur+1, a, b+l[cur], c) + 10
    ret3 = dfs(cur+1, a, b, c+l[cur]) + 10
    return min(rest0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))
Problem p03128 (python)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))

dp = [-1] * (N+1)
need = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp[0] = 0

for i in range(N+1):
    for j in A:
        if i + need[j] > N:
            continue
        dp[i+need[j]] = max(dp[i+need[j]], dp[i]*10+j)
print(dp[N])

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

dp = [-1] * (N+1)
need = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp[0] = 0

for i in range(N+1):
    for j in A:
        if i + need[j] > N:
            continue
        dp[i+need[j]] = max(dp[i+need[j]], dp[i]*10+j])
print(dp[N])
Problem p03145 (python)

Fixed submission:
a, b, c = map(int, input().split())
print(int(a*b/2))

Buggy submission (verdict: Runtime Error):
from heapq import heappop, heappush, heapify
n, k = map(int, input().split())
lst = [list(map(int, input().split())) for i in range(n)]
lst = sorted(lst, reverse=True, key=lambda x:x[1])
q = []
v = set()
cnt = 0
for t, d in lst[:k]:
    cnt += d
    if t in v:
        heappush(q, d)
    else:
        v.add(t)
cnt += len(v)**2
ans = cnt
for t, d in lst[k:]:
    if t not in v and len(q)!=0:
        x = heappop(q)
        cnt += d + 2*len(v) + 1 - x
        ans = max(ans, cnt)
print(ans)
Problem p03147 (python)

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
ans = 0
H.append(0)
for i in range(max(H)):
    cnt = 0
    for k in range(N):
        if H[k] != 0 and H[k+1] == 0:
            cnt += 1
    ans += cnt
    H = list(map(lambda x:(x-1, 0)[x == 0], H))
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
max_lst = []
min_lst = []
max_h = H[0]
min_h = H[0]
s = 0
for i in range(1, N):
    if H[i-1] <= H[i]:
        if H[0] not in max_lst and H[0] not in min_lst:
            min_lst.append(H[0])
        if max_h == 0:
            min_lst.append(min_h)
        if i == N-1:
            max_lst.append(H[i])
        max_h = H[i]
        min_h = 0
    elif H[i-1] >= H[i]:
        if H[0] not in max_lst and H[0] not in min_lst:
            max_lst.append(H[0])
            s = 1
        if min_h == 0:
            max_lst.append(max_h)
        if i == N-1:
            min_lst.append(H[i])
        min_h = H[i]
        max_h = 0
cnt = 0
if s == 0:
    for i in range(len(min_lst)-1):
        cnt += max_lst[i] - min(min_lst[i], min_lst[i+1])
    cnt += max_lst[-1] - min_lst[-1]
else:
    for i in range(1, len(max_lst)):
        cnt += max_lst[i] - min(min_lst[i-1], min_lst[i])
    cnt += max_lst[0] - min_lst[0]
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
lst = list(map(int, input().split()))
cnt = 0
for i in range(N-1):
    if lst[i] < lst[i+1]:
        cnt += 
print(cnt)




#139 c
N = int(input())
H = list(map(int, input().split()))
max_lst = []
min_lst = []
max_h = H[0]
min_h = H[0]
s = 0
for i in range(1, N):
    if H[i-1] <= H[i]:
        if H[0] not in max_lst and H[0] not in min_lst:
            min_lst.append(H[0])
        if max_h == 0:
            min_lst.append(min_h)
        if i == N-1:
            max_lst.append(H[i])
        max_h = H[i]
        min_h = 0
    elif H[i-1] >= H[i]:
        if H[0] not in max_lst and H[0] not in min_lst:
            max_lst.append(H[0])
            s = 1
        if min_h == 0:
            max_lst.append(max_h)
        if i == N-1:
            min_lst.append(H[i])
        min_h = H[i]
        max_h = 0
cnt = 0
if s == 0:
    for i in range(len(min_lst)-1):
        cnt += max_lst[i] - min(min_lst[i], min_lst[i+1])
    cnt += max_lst[-1] - min_lst[-1]
else:
    for i in range(1, len(max_lst)):
        cnt += max_lst[i] - min(min_lst[i-1], min_lst[i])
    cnt += max_lst[0] - min_lst[0]
print(cnt)
Problem p03164 (python)

Fixed submission:
N, W = map(int, input().split())
lstW = []
lstV = []
for i in range(N):
    w, v = map(int, input().split())
    lstW.append(w)
    lstV.append(v)

dp = [[10**9]*(10**5+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    for j in range(10**5+1):
        dp[i+1][j] = min(dp[i+1][j], dp[i][j])
        if dp[i][j] + lstW[i] <= W:
            dp[i+1][j+lstV[i]] = min(dp[i+1][j+lstV[i]], dp[i][j]+lstW[i])
ans = []
for i in range(max(lstV)*N+1):
    if dp[-1][i] <= W:
        ans.append(i)
print(max(ans))

Buggy submission (verdict: Runtime Error):
N, W = map(int, input().split())
lst = [[0, 0]] 
for i in range(N):
    lst.append(list(map(int, input().split())))
dp = [[0]*(W+1) for i in range(N+1)]
for i in range(1, N+1):
    for j in range(1, W+1):
        if j - lst[i][0] >= 0:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-lst[i][0]]+lst[i][1])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[N][W])
Problem p03206 (python)

Fixed submission:
D = int(input())
print('Christmas' + ' Eve' * (25 - D))

Buggy submission (verdict: Runtime Error):
D = int(input())
a = 'Christmas'
if D = 22:
    print(a + ' Eve Eve Eve')
elif D = 23:
    print(a + ' Eve Eve')
elif D = 24:
    print(a + ' Eve')
else:
    print(a)
Problem p03238 (python)

Fixed submission:
N = int(input())
if N == 1:
  print('Hello World')
else:
  A = int(input())
  B = int(input())
  print(A + B)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
x = M//N
max = 1
for i in range(x+1, 1, -1):
    mod = M - (N-1)*i
    if mod%i == 0:
        max = i
        break
print(max)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
x = M//N
max = 1
for i in range(x+1, 1, -1):
    mod = M - (N-1)*i
    if mod%i == 0:
        max = i
        break
print(max)

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
ans = []
for i in range(N):
  c, t = map(int, input().split())
  if t <= T:
    ans.append(c)
if not ans:
  print('TLE')
else:
  ans.sort()
  print(ans[0])
Problem p03239 (python)

Fixed submission:
N, T = map(int, input().split())
ans = []
for i in range(N):
  c, t = map(int, input().split())
  if t <= T:
    ans.append(c)
if not ans:
  print('TLE')
else:
  ans.sort()
  print(ans[0])

Buggy submission (verdict: Runtime Error):
N, T = map(int, input().split())
ans = []
for i in range(N):
  c, t = map(int, input().split())
  if t <= T:
    ans.append(c)
ans.sort()
print(ans[0])
Problem p03241 (python)

Fixed submission:
N, M = map(int, input().split())
x = M//N
max = 1
for i in range(x, 0, -1):
    mod = M - (N-1)*i
    if mod%i == 0:
        max = i
        break
print(max)

Buggy submission (verdict: Runtime Error):
import math
N, M = map(int, input().split())
x = M//N
mid = int(math.sqrt(M))
if x >= mid:
    ans = []
    for i in range(1, mid+1):
        ans.append(i)
        if M%i == 0:
            ans.append(i)
            if M//i <= x:
                ans.append(M//i)
    print(max(ans))
else:
    for i in rreversed(range(1, x+1)):
        if M%i == 0:
            print(i)
            break
Problem p03251 (python)

Fixed submission:
N, M, X, Y = map(int, input().split())
lstX = list(map(int, input().split()))
lstY = list(map(int, input().split()))
lstX.sort(reverse=True)
lstY.sort()
#print(lstX)
#print(lstY)
if lstX[0] > X and lstX[0] + 1 <= lstY[0] and lstX[0] + 1 <= Y:
    print('No War')
elif lstX[0] < X and X + 1 <= lstY[0] and X + 1 <= Y:
    print('No War')
else:
    print('War')

Buggy submission (verdict: Runtime Error):
N, M, X, Y = map(int, input().split())
lstX = list(map(int, input(split()))).sort(reverse=True)
lstY = list(map(int, input(split()))).sort()
if lstX[0] > X and lstX[0] + 1 <= lstY[0] and lstX[0] + 1 <= Y:
    print('No War')
elif lstX[0] < X and X + 1 <= lstY[0] and X + 1 <= Y:
    print('No War')
else:
    print('War')
Problem p03282 (python)

Fixed submission:
S = list(input())
S.append('0')
K = int(input())
i = 0
while S[i] == '1':
    i += 1
if K > i:
    print(int(S[i]))
else:
    print(1)

Buggy submission (verdict: Runtime Error):
S = list(input())
K = int(input())
i = 0
while S[i] == '1':
    i += 1
if K > i:
    print(int(S[i]))
else:
    print(1)
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):
from itertools import accumulate
N, M = map(int, input().split())
A = list(map(int, input().split()))

B = [0] + A
C = {}
B = list(accumulate(B))
for i in range(1, len(B)):
    if B[i]%M not in C:
        C[B[i]%M] = 1
    else:
        C[B[i]%M] += 1
ans = 0
for i in C.values():
    ans += i*(i-1)//2
if 0 in C:
    ans += C[0]
print(ans)
Problem p03287 (python)

Fixed submission:
from itertools import accumulate
N, M = map(int, input().split())
A = list(map(int, input().split()))

B = [0] + A
C = {}
B = list(accumulate(B))
for i in range(1, len(B)):
    if B[i]%M not in C:
        C[B[i]%M] = 1
    else:
        C[B[i]%M] += 1
ans = 0
for i in C.values():
    ans += i*(i-1)//2
if 0 in C:
    ans += C[0]
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
N, M = map(int, input().split())
A = list(map(int, input().split()))

B = [0] + A
C = {}
B = list(accumulate(B))
for i in range(1, len(B)):
    if B[i]%M not in C:
        C[B[i]%M] = 1
    else:
        C[B[i]%M] += 1
ans = 0
for i in C.values():
    ans += i*(i-1)//2
ans += C[0]
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
N, M = map(int, input().split())
A = list(map(int, input().split()))

B = [0] + A
C = {}
B = list(accumulate(B))
for i in range(1, N+1):
    if B[i]%M not in C:
        C[B[i]%M] = 1
    else:
        C[B[i]%M] += 1
ans = 0
for i in C.values():
    ans += i*(i-1)//2
ans += C[0]
print(ans)
Problem p03292 (python)

Fixed submission:
A = list(map(int, input().split()))
A.sort()
print(A[2] - A[0])

Buggy submission (verdict: Runtime Error):
A = list(map(int, input().split())
A.sort()
print(-A[0] + A[2])