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

Fixed submission:
a = int(input())
b = int(input())

problem = set([1,2,3])

print((problem - set([a,b])).pop())

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

problem = set(1,2,3)

print(problem - set(a,b))
Problem p02891 (python)

Fixed submission:
s = input()
n = int(input())

def f(s):
    prev = ''
    ct = 0
    for i in s:
        if i == prev:
            ct += 1
            prev = ''
        else:
            prev = i
    return ct
        

if len(set(s)) == 1:
    print(len(s) *n//2)
elif s[0]!=s[-1]:
    print(f(s) * n)
else:
    ans = f(s) + (f(s*2) - f(s)) * (n-1)
    print(ans)

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

def f(s):
    prev = ''
    ct = 0
    for i in s:
        if i == prev:
            ct += 1
            prev = ''
        else:
            prev = i
    return ct
        

if len(set(s)) == 1:
    print(len(s) *n //2)
elif s[0]!=s[-1]:
    print(f(t) * n)
else:
    ct = f(s*2)
    
    ans = ct * (n//2) if n % 2 == 0 else ct*(n//2) + f(s)
    
    print(ans)
Problem p02912 (python)

Fixed submission:
import heapq
n,m = [int(i) for i in input().split()]
l = [int(i) for i in input().split()]
h = []
for i in l:
    i = -1*i
    heapq.heappush(h,i)
    
for _ in range(m):
    v = -heapq.heappop(h)
    heapq.heappush(h,-1*(v//2))
    
print(-sum(h))

Buggy submission (verdict: Runtime Error):
import bisect
n,m = [int(i) for i in input().split()]
l = sorted([int(i) for i in input().split()])
l2 = []
[bisect.insort(l,l.pop()//2,0,n) for _ in range(m)]
print(sum(l[0:n]))
Problem p02915 (python)

Fixed submission:
n = int(input())

print(n**3)

Buggy submission (verdict: Runtime Error):
n = int(input())
bl = [int(i) for i in input().split()]
bl.reverse()

v = bl[0]

for i in range(1,n-1):
    v += min(bl[i],bl[i-1])

v += bl[n-2]

print(v)

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

bl = [int(i) for i in input().split()]
al = []
memo = 0
for idx,i in enumerate(bl[::-1]):
    if idx in (0,len(bl)):
        al.append(i)
    else:
        al.append(min(i,al[idx-1]))
    memo = i
    
al.append(bl[0])
print(sum(al))
Problem p02959 (python)

Fixed submission:
n = int(input())
al = [int(i) for i in input().split()]
bl = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    if al[i] > bl[i]:
        ans += bl[i]
    elif al[i] + al[i+1] > bl[i]:
        ans += bl[i]
        al[i+1] = al[i+1] + al[i] - bl[i]
    else:
        ans += al[i] + al[i+1]
        al[i+1] = 0
        
print(ans)

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

al = [int(i) for i in input().split()]
bl = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    if bl[i] <= al[i]:
        ans += bl[i]
    elif bl[i] > al[i] and bl[i] <= al[i] + al[i+1]:
        ans += bl[i]
        al[i+1] = al[i] + al[i+i] - bl[i]
    else:
        ans += al[i] + al[i+1]
        al[i+1] = 0
        
print(ans)

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

al = [int(i) for i in input().split()]
bl = [int(i) for i in input().split()]

ans = 0
for i in range(n):
    if bl[i] <= al[i]:
        ans += bl[i]
    elif bl[i] > al[i] and bl[i] <= al[i] + al[i+1]:
        ans += bl[i]
        al[i+1] = al[i] + al[i+i] - bl[i]
    else:
        ans += al[i] + al[i+1]
        al[i+1] == 0
        
print(ans)
Problem p02984 (python)

Fixed submission:
n = int(input())

l = [int(i) for i in input().split()]

total = sum(l)

for i in range(1,n,2):
    total -= l[i] * 2

ans = [total]

for i in range(1,n):
    ans.append(2*l[i-1]-ans[i-1])
ans = [str(i) for i in ans]
    
print(' '.join(ans))

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

l = [int(i) for i in input().split()]

total = sum(l)

for i in range(1,n,2):
    total -= l[i] * 2

ans = [total]

for i in range(1,n):
    ans.append(2*l[i-1] - ans[i-1])
    ans = [str(i) for i in ans]
    
print(' '.join(ans))
Problem p03107 (python)

Fixed submission:
s  = input()

one = len([i for i in s if i == '1'])
zero = len(s)- one

print(2*min(one,zero))

Buggy submission (verdict: Runtime Error):
one = len([i for i in s if i == '1'])
zero = len(s)- one

print(2*min(one,zero))
Problem p03127 (python)

Fixed submission:
import fractions
n = int(input())
l = [int(i) for i in input().split()]
ans = l[0]
for i in range(n):
    ans = fractions.gcd(ans,l[i])

print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
n = int(input())
l = [int(i) for i in input().split()]
ans = l[0]
for i in range(n):
    ans = fractions.gcd(ans,a[i])

print(ans)
Problem p03804 (python)

Fixed submission:
import numpy as np
a,b = [int(i) for i in input().split()]

al = np.array([list(input()) for _ in range(a)])
bl = np.array([list(input()) for _ in range(b)])

flg  = False
for i in range(a - b + 1):
    for j in range(a - b + 1):
        if(al[i:i+b,j:j+b] == bl).all():
            flg = True
            
print('Yes' if flg else 'No')

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

al = np.array([list(input()) for _ in range(a)])
bl = np.array([list(input()) for _ in range(b)])

flg  = False
for i in range(a - b + 1):
    for j in range(a - b + 1):
        if(al[i:i+b,j:j+b] == bl).all():
            flg = True
            
print('Yes' if flg else 'No')
Problem p02779 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
if len(set(a)) == n:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split())
if len(set(a)) == n:
         print('YES')
else:
         print('NO')
Problem p02834 (python)

Fixed submission:
from sys import setrecursionlimit
setrecursionlimit(10 ** 5)

n, u, v = map(int, input().split())
ab = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(n-1)]
u -= 1
v -= 1

e = [[] for _ in range(n)]
for a, b in ab:
    e[a].append(b)
    e[b].append(a)

t = [0] * n
a = [0] * n

def dfs(x, p, d, c):
    if len(e[x]) == 1:
        if e[x][0] == p:
            return
    for y in e[x]:
        if y == p:
            continue
        if c == 0:
            t[y] = d
        else:
            a[y] = d
        dfs(y, x, d+1, c)

dfs(u, -1, 1, 0)
dfs(v, -1, 1, 1)
ans = 0
for i in range(n):
    if t[i] < a[i]:
        ans = max(a[i], ans)

print(ans-1)

Buggy submission (verdict: Runtime Error):
n, u, v = map(int, input().split())
ab = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(n-1)]
u -= 1
v -= 1

e = [[] for _ in range(n)]
for a, b in ab:
    e[a].append(b)
    e[b].append(a)

if len(e[u]) == 1:
    if e[u][0] == v:
        print(0)
        exit()

t = [0] * n
a = [0] * n

def dfs(x, p, d, c):
    if len(e[x]) == 1:
        if e[x][0] == p:
            return
    for y in e[x]:
        if y == p:
            continue
        if c == 0:
            t[y] = d
        else:
            a[y] = d
        dfs(y, x, d+1, c)

dfs(u, -1, 1, 0)
dfs(v, -1, 1, 1)
ans = 0
for i in range(n):
    if t[i] < a[i]:
        ans = max(a[i], ans)

print(ans-1)

Buggy submission (verdict: Runtime Error):
n, u, v = map(int, input().split())
ab = [tuple(map(lambda x:int(x)-1, input().split())) for _ in range(n-1)]
u -= 1
v -= 1

e = [[] for _ in range(n)]
for a, b in ab:
    e[a].append(b)
    e[b].append(a)

t = [0] * n
a = [0] * n

def dfs(x, p, d, c):
    if len(e[x]) == 1:
        if e[x][0] == p:
            return
    for y in e[x]:
        if y == p:
            continue
        if c == 0:
            t[y] = d
        else:
            a[y] = d
        dfs(y, x, d+1, c)

dfs(u, -1, 1, 0)
dfs(v, -1, 1, 1)
ans = 0
for i in range(n):
    if t[i] < a[i]:
        ans = max(a[i], ans)

print(ans-1)
Problem p02851 (python)

Fixed submission:
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

n += 1
ans = 0
m = dict()
temp = 0
b = []
for i in range(min(n, k)):
    temp = (temp + a[i]) % k
    c = (temp - (i % k) + k) % k
    b.append(c)
    if c in m.keys():
        ans += m[c]
        m[c] += 1
    else:
        m[c] = 1

for i in range(k, n):
    x = i % k
    m[b[x]] -= 1
    temp = (temp + a[i]) % k
    c = (temp - (i % k) + k) % k
    b[x] = c
    if c in m.keys():
        ans += m[c]
        m[c] += 1
    else:
        m[c] = 1

print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

n += 1
ans = 0
m = dict()
for x in a:
    m[x] = 0
temp = 0
b = []
for i in range(min(n, k)):
    temp = (temp + a[i]) % k
    c = (temp - (i % k) + k) % k
    b.append(c)
    m[c] += 1

for i in range(k, n):
    x = i % k
    m[b[x]] -= 1
    temp = (temp + a[i]) % k
    c = (temp - (i % k) + k) % k
    b[x] = c
    m[c] += 1

print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

ans = 0
#s = []
b = []
temp = 0
for i, x in enumerate(a):
    temp = (temp + x) % k
    c = (temp - (i % k) + k) % k
    b.append(c)
    #if x % k == 1:
    #    ans += 1

#print(s)
#print(b)

m = [0] * k

for i in range(min(k, n+1)):
    ans += m[b[i]]
    m[b[i]] += 1

#print(m)

for i in range(k, n+1):
    m[b[i-k]] -= 1
    ans += m[b[i]]
    m[b[i]] += 1
    #print(m)

print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

ans = 0
#s = []
b = []
temp = 0
for i, x in enumerate(a):
    temp = (temp + x) % k
    c = (temp - (i % k) + k) % k
    b.append(c)
    #if x % k == 1:
    #    ans += 1

#print(s)
#print(b)

m = [0] * k

for i in range(k):
    ans += m[b[i]]
    m[b[i]] += 1

#print(m)

for i in range(k, n+1):
    m[b[i-k]] -= 1
    ans += m[b[i]]
    m[b[i]] += 1
    #print(m)

print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

ans = 0
#s = []
b = []
temp = 0
for i, x in enumerate(a):
    temp = (temp + x) % k
    c = (temp - (i % k) + k) % k
    b.append(c)
    #if x % k == 1:
    #    ans += 1

#print(s)
#print(b)

m = [0] * k

for i in range(k):
    ans += m[b[i]]
    m[b[i]] += 1

#print(m)

for i in range(k, n+1):
    m[b[i-k]] -= 1
    ans += m[b[i]]
    m[b[i]] += 1
    #print(m)

print(ans)
Problem p02864 (python)

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

if k == n:
    print(0)
    exit()

dp = [[0 for _ in range(n)] for _ in range(n-k)]

dp[0] = [] + h

for x in range(1, n-k):
    for y in range(n):
        temp = float('inf')
        for i in range(y):
            temp = min(temp, dp[x-1][i] + max(0, h[y] - h[i]))
        dp[x][y] = temp

#for x in dp: print(x)

print(min(dp[n-k-1]))

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

dp = [[0 for _ in range(n)] for _ in range(n-k)]

dp[0] = [] + h

for x in range(1, n-k):
    for y in range(n):
        temp = float('inf')
        for i in range(y):
            temp = min(temp, dp[x-1][i] + max(0, h[y] - h[i]))
        dp[x][y] = temp

#for x in dp: print(x)

print(min(dp[n-k-1]))
Problem p02873 (python)

Fixed submission:
S = list(input())

n = len(S) + 1

a = [0] * n

for i, x in enumerate(S):
    if x == '<':
        a[i+1] = a[i] + 1
    else:
        a[i+1] = 0

for i, x in enumerate(reversed(S)):
    j = n - i - 1
    if x == '>':
        a[j - 1] = max(a[j] + 1, a[j-1])

print(sum(a))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
LR = [tuple(map(int, input().split())) for _ in range(n)]

def quicksort(x):
    if x==[]: return []

    smallerSorted = quicksort([a for a in x[1:] if a[0] < x[0][0] or (a[0] == x[0][0] and a[1] => x[0][1])])
    biggerSorted = quicksort([a for a in x[1:] if a[0] > x[0][0] or (a[0] == x[0][0] and a[1] < x[0][1])])

    return(smallerSorted+[x[0]]+biggerSorted)

LR = quicksort(LR)

ans = [0] * (n+1)
temp = 10 ** 9
i = 1
for L, R in LR:
    temp = min(temp, R)
    if L > temp:
        break   
    ans[i] = temp - L + 1
    i += 1

temp = 10 ** 9
i = n - 1
L = LR[-1][0]
for x, R in reversed(LR):
    temp = min(temp, R)
    if L > temp:
        break
    ans[i] += temp - L + 1
    i -= 1

res = max(ans)
for L, R in LR:
    res = max(res, R - L + 1)

print(res)
Problem p02897 (python)

Fixed submission:
n = int(input())

if n % 2 == 0:
    print(0.5)
else:
    print(((n+1)//2)/n)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10 ** 6)

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

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

c = [0] * n
def search_path(p, temp):
    c[p] = 1
    for x in e[p]:
        if x in temp:
            ans = [] + temp[temp.index(x):]
            check = 1
            while check == 1:
                check = 0
                #print(ans)
                for i in range(len(ans)-1):
                    for z in e[ans[i]]:
                        if z == ans[i+1]:
                            continue
                        elif z in ans:
                            t = ans.index(z)
                            if t < i:
                                ans = [] + ans[t:i+1]
                            else:
                                ans = [] + ans[i:t+1]
                            #print(ans, z)
                            check = 1
                            break
                    if check == 1:
                        break
                    else:
                        e[ans[i]] = []
                if check == 1:
                    continue
                for z in e[ans[-1]]:
                    if z == ans[0]:
                        continue
                    elif z in ans:
                        ans = [] + ans[ans.index(z):]
                        check = 1
                        #print(z, ans)
                        break
            print(len(ans))
            for z in ans:
                print(z+1)
            exit()
        else:
            search_path(x, temp + [x])


t = 1
for i in range(n):
    if c[i] == 0:
        ans = search_path(i, [i])

print(-1)
Problem p03038 (python)

Fixed submission:
from heapq import heappop, heappush

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(int(x) for x in input().split()) for _ in range(m)]

bc.sort(reverse=True)

h = []

for x in a:
    heappush(h, x)

for b, c in bc:
    for _ in range(b):
        temp = heappop(h)
        if temp >= c:
            heappush(h, temp)
            break
        else:
            heappush(h, c)

print(sum(h))

Buggy submission (verdict: Runtime Error):
from heapq import heappop, heappush

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(int(x) for x in input().split()) for _ in range(m)]

h = []

for x in a:
    heappush(h, x)

for b, c in bc:
    for _ in range(b):
        temp = heappop(h)
        if temp >= c:
            heappush(h, temp)
            break
        else:
            heappush(h, c)

print(sum(h))

from heapq import heappop, heappush

n, m = map(int, input().split())
a = list(map(int, input().split()))
bc = [tuple(int(x) for x in input().split()) for _ in range(m)]

h = []

for x in a:
    heappush(h, x)

for b, c in bc:
    for _ in range(b):
        temp = heappop(h)
        if temp >= c:
            heappush(h, temp)
            break
        else:
            heappush(h, c)

print(sum(h))
Problem p03053 (python)

Fixed submission:
h, w = map(int, input().split())
a = [['*' for _ in range(w+2)]]
for _ in range(h):
    a.append(['*'] + list(input()) + ['*'])
a.append(['*' for _ in range(w+2)])

q = set()

def encode(i, j):
    return i*w + j-1

def decode(x):
    i = x // w
    j = x % w + 1
    return [i, j]

for i in range(1, h+1):
    for j in range(1, w+1):
        if a[i][j] == '#':
            q.add(encode(i, j))

for ans in range(h+w):
    nq = set()
    for x in q:
        i, j = decode(x)
        for k in [-1,1]:
            if a[i+k][j] == '.':
                nq.add(encode(i+k, j))
                a[i+k][j] = '#'
        for k in [-1,1]:
            if a[i][j+k] == '.':
                nq.add(encode(i, j+k))
                a[i][j+k] = '#'
    if len(nq) == 0:
        print(ans)
        exit()
    else:
        q = set()
        q = q | nq

Buggy submission (verdict: Runtime Error):
h, w = map(int, input().split())
a = [['*' for _ in range(w+2)]]
for _ in range(h):
    a.append(['*'] + list(input()) + ['*'])
a.append(['*' for _ in range(w+2)])

q = set()

def encode(i, j):
    return i*w + j

def decode(x):
    i = x // w
    j = x % w
    return [i, j]

for i in range(1, h+1):
    for j in range(1, w+1):
        if a[i][j] == '#':
            q.add(encode(i, j))

for ans in range(h+w):
    nq = set()
    for x in q:
        i, j = decode(x)
        for k in [-1,1]:
            if a[i+k][j] == '.':
                nq.add(encode(i+k, j))
                a[i+k][j] = '#'
        for k in [-1,1]:
            if a[i][j+k] == '.':
                nq.add(encode(i, j+k))
                a[i][j+k] = '#'
    if len(nq) == 0:
        print(ans)
        exit()
    else:
        q = set()
        q = q | nq
Problem p03108 (python)

Fixed submission:
n, m = map(int, input().split())
ab = [tuple(int(x) for x in input().split()) for _ in range(m)]

class UnionFind:
    def __init__(self, size):
        self.rank = [-1 for _ in range(size)]
        self.number = [1 for _ in range(size)]

    def find(self, x):
        while self.rank[x] >= 0:
            x = self.rank[x]
        return x

    def union(self, s1, s2):
        if s1 == s2:
            return
        if self.rank[s1] == self.rank[s2]:
            self.rank[s1] -= 1
            self.rank[s2] = s1
            self.number[s1] += self.number[s2]
        elif self.rank[s1] < self.rank[s2]:
            self.rank[s2] = s1
            self.number[s1] += self.number[s2]
        else:
            self.rank[s1] = s2
            self.number[s2] += self.number[s1]

uft = UnionFind(n)
ans = [0 for _ in range(m)]
temp = n * (n - 1) // 2
ans[m - 1] = temp
for i in range(m-1, 0, -1):
    ra = uft.find(ab[i][0] - 1)
    rb = uft.find(ab[i][1] - 1)
    if ra != rb:
        temp -= uft.number[ra] * uft.number[rb]
        uft.union(ra, rb)
    ans[i - 1] = temp

for x in ans:
    print(x)

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

ans = [n * (n - 1) // 2 for _ in range(m + 1)]

u = [-1 for _ in range(n)]

def root(x):
    if u[x] < 0:
        return x
    else:
        u[x] = root(u[x])
        return u[x]

def unite(x, y):
    rx = root(x)
    ry = root(y)
    if rx == ry:
        return
    if size(x) < size(y):
        x, y = y, x
    u[x] += u[y]
    u[y] = x

def size(x):
    return - u[root(x)]

i = m - 1
for a, b in list(reversed(ab)):
    if root(a - 1) == root(b - 1):
        ans[i] = ans[i + 1]
    else:
        ans[i] = ans[i + 1] - size(a - 1) * size(b - 1)
        unite(a - 1, b - 1)
    i -= 1

for i in range(1, m + 1):
    print(ans[i])
Problem p03127 (python)

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

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

while len(x) > 1:
    i = 0
    next = []
    while i < len(x) - 1:
        next.append(gcd(x[i], x[i+1]))
        i += 2

    x = [] + next

print(x[0])

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

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

while len(x) > 1:
    i = 0
    next = []
    while i < len(x) - 1:
        next.append(gcd(x[i], x[i+1]))
        i += 2

    x = [] + next

print(x[0])

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

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

def numpy_gcd(a, b):
    a, b = np.broadcast_arrays(a, b)
    a = a.copy()
    b = b.copy()
    pos = np.nonzero(b)[0]
    while len(pos) > 0:
        b2 = b[pos]
        a[pos], b[pos] = b2, a[pos] % b2
        pos = pos[b[pos] != 0]
    return a

while len(x) > 1:
    i = 0
    next = []
    while i < len(x) - 1:
        next.append(numpy_gcd(x[i],x[i+1]))
        i += 2

    x = [] + next

print(x[0])
Problem p03250 (python)

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

a = sorted(a)

print(a[2] * 10 + sum(a[:2]))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(100000)

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

MOD = 10 ** 9 + 7

if m == 1:
    print('1')
    exit()

factor = []
temp = 0
x = 2
while m > 1:
    if m % x == 0:
        m //= x
        temp += 1
    elif temp > 0:
        factor.append(temp)
        temp = 0
        x += 1
    else:
        x += 1
factor.append(temp)

nCr = {}
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n;
    if (n, r) in nCr: return nCr[(n, r)]

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p;
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    nCr[(n, r)] = result
    return result;

ans = 1
for x in factor:
    ans *= cmb(x + n - 1, n - 1)
    ans %= MOD

print(ans)
Problem p04005 (python)

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

if x[0] * x[1] * x[2] % 2 == 0:
    print('0')
else:
    x = sorted(x)
    print(x[0] * x[1])

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

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

temp = 0
check = 0
for i in range(1, n):
    if a[i] <= a[i - 1] + x:
        check = 1
        temp = i
        break

if check == 1:
    a = a[temp:] + a[:temp]

check = 1
for i in range(1, n):
    if a[i] >= a[i - check] + x:
        a[i] = a[i - check] + x
        check += 1
    else:
        check = 1

print(sum(a))
Problem p02598 (python)

Fixed submission:
def check(numbers, threshold):
    
    total = 0
    
    for number in numbers:
        d, m = divmod(number, threshold)
        if m == 0:
            d -= 1
        total += d
    return total
    
def main():
    n, k = map(int, input().rstrip().split(" "))
    
    numbers = list(map(int, input().rstrip().split(" ")))
    
    bottom, top = 1, 2 * (10 ** 9)
    
    while bottom < top:
        #print(bottom, top)
        if check(numbers, (bottom + top )// 2) <= k:
            top = (bottom + top )// 2
        else:
            bottom = ((bottom + top )// 2) + 1
    print(top)
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def check(numbers, threshold):
    
    total = 0
    
    for number in numbers:
        d, m = divmod(number, threshold)
        if m == 0:
            d -= 1
        total += d
    return total
    
def main():
    n, k = map(int, input().rstrip().split(" "))
    
    numbers = list(map(int, input().rstrip().split(" ")))
    
    bottom, top = 0, 2 * (10 ** 9)
    
    while bottom < top:
        #print(bottom, top)
        if check(numbers, (bottom + top )// 2) <= k:
            top = (bottom + top )// 2
        else:
            bottom = ((bottom + top )// 2) + 1
    print(top)
    
if __name__ == '__main__':
    main()
Problem p03107 (python)

Fixed submission:
s = input().rstrip("\n")
from collections import Counter
count = Counter(s)
if len(count.values()) < 2:
  print(0)
else:
  print(min(count.values()) * 2)

Buggy submission (verdict: Runtime Error):
s = input().rstrip("\n")
from collections import Counter
count = Counter(s)
print(min(counter.values()) * 2)
Problem p02693 (python)

Fixed submission:
import sys
K = int(input())
A, B = [int(x) for x in input().split()]
for i in range(A, B+1):
  if i%K == 0:
    print("OK")
    sys.exit()
print("NG")

Buggy submission (verdict: Runtime Error):
import sys
K = int(input())
A, B = [int(x) for x in input().split()]
for i in range(A, B+1):
  if i%k == 0:
    print("OK")
    sys.exit()
print("NG")