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

Fixed submission:
import math

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

A_max = max(A)

D = [i for i in range(1+A_max)]

for i in range(2,1+int(A_max**(1/2))):
    if D[i] == i:
        for j in range(2,1+A_max//i):
            D[i*j] = i

prime = {}

for i in range(2,1+A_max):
    if D[i] == i:
        prime[i] = 0

for a in A:
    X = []
    aa = a
    while aa > 1:
        X.append(D[aa])
        aa //= D[aa]
    
    X = set(X)

    for x in X:
        prime[x] += 1

if all([v<=1 for v in prime.values()]):
    print('pairwise coprime')

else:
    g = A[0]
    for i in range(1,N):
        g = math.gcd(g,A[i])
    if g == 1:
        print('setwise coprime')
    else:
        print('not coprime')

Buggy submission (verdict: Runtime Error):
import math

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

D = [i for i in range(1000001)]

for i in range(2,1001):
    if D[i] == i:
        for j in range(2,1+100000//i):
            D[i*j] = i

###
#print(D[:10])
###

det = True
P = []

for a in A:
    Q = []
    aa = a
    while aa > 1:
        Q.append(D[aa])
        aa //= D[aa]
    P = P + list(set(Q))
    ###
    #print(P)
    #print(Q)
    ###
    if len(P) != len(set(P)):
        det = False
        break
    P = set(P)

if det:
    print('pairwise coprime')

else:
    g = A[0]
    for i in range(1,N):
        g = math.gcd(g,A[i])
    if g == 1:
        print('setwise coprime')
    else:
        print('not coprime')

Buggy submission (verdict: Runtime Error):
import sys
from collections import deque

prime = []

for i in range(2,1001):
    det = 0
    for j in range(2,int(i**(1/2))+1):
        if i%j==0:
            det = -1
            break
    if det == 0:
        prime.append(i)

N = int(input())
A = list(map(int,input().split()))
B = []###Aのうち1ではないもの
det = False###Aが1を含んでいたか否か

for i in range(N):
    if A[i] == 1:
        det = True
    else:
        B.append(A[i])

if len(B) <= len(prime):

    m = 1

    for p in prime:
        count = 0
        for b in B:
            if b%p==0:
                count += 1
        m = max(m,count)
        if m >= 2:
            break
    
    if m == 1:
        print('pairwise coprime')
        sys.exit(1)

if det:
    print('setwise coprime')

else:
    pp = prime[:]
    
    for b in B:
        pp_ = []
        for p in pp:
            if b%p == 0:
                pp_.append(p)
        pp = pp_[:]


        if pp == []:
            print('setwise coprime')
            sys.exit(1)
    
    print('not coprime')
Problem p02686 (python)

Fixed submission:
def score(a,b):
    if b-a >= 0:
        return a
    else:
        return 10**6+1-b

N = int(input())

A = [0]*N
B = [0]*N

for i in range(N):
    S = input()
    a = 0
    b = 0
    for j in range(len(S)):
        if S[j] == ')':
            a += 1
        else:
            a -= 1
        A[i] = max(A[i],a)

        if S[-j-1] == '(':
            b += 1
        else:
            b -= 1
        B[i] = max(B[i],b)

#print('S',S)
#print('A',A)
#print('B',B)

L = sorted(list(range(N)),key = lambda i:score(A[i],B[i]))

SA = 0
SB = 0

#print('L',L)

for i in range(N):
    if SB > A[L[i]]:
        SB += B[L[i]] - A[L[i]]
    else:
        SA += A[L[i]]-SB
        SB = B[L[i]]
    #print(SA,SB)

if SA == 0 and SB == 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import heapq
import sys

#input = sys.stdin.readline

def main():
    N = int(input())

    data = [0]*N
    for i in range(N):
        S = list(str(input()))
        s = 0
        m = 0
        for j in range(len(S)):
            if S[j] == "(":
                s += 1
            else:
                s -= 1
                m = min(m,s)
        data[i] = (-m,-s)


    heapq.heapify(data)
    x = 0
    valid = []
    heapq.heapify(valid)

    det = 0

###
#print("data",data)
#print("valid",valid)
#print(x)
###

    while data or valid:
        while data and x - data[0][0] >= 0:
            y = heapq.heappop(data)
            heapq.heappush(valid,(y[1],y[0]))
    
        while valid and x >= 0:
            z = heapq.heappop(valid)
            if x - z[0] >= 0:
                x -= z[0]
            else:
                heappush(valid,z)
    
        if data and x - data[0][0] < 0:
            det = -1
            break

    if det == 0 and x == 0:
        print("Yes")
    else:
        print("No")

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

Fixed submission:
###草

import math

N = int(input())

Klist = [0]*(int(N**(1/2))+1)
count = 1###int(N**(1/2))+1以上についてカウント
###あらかじめK=Nはカウント

for i in range(1,int((N-1)**(1/2))+1):
    if (N-1) % i == 0:
        Klist[i] = 1
        count += 1
        ###
        #print(i,(N-1)//i)
        ###

if  (N-1)**(1/2) - int((N-1)**(1/2)) < 1e-10 or 1 + int((N-1)**(1/2)) - ((N-1)**(1/2)) < 1e-10:
    count -= 1

M = int(math.log2(N))

for m in range(1,M+1):
    if m >= 2 and (N**(1/m) - int(N**(1/m)) < 1e-10 or 1+int(N**(1/m))-N**(1/m) < 1e-10):###m=1のときはK=Nの話なのでpass
        Klist[round(N**(1/m))] = 1
    for K in range(2,int(N**(1/(m+1))+1)):
        if (N-K**m)%(K**(m+1)) == 0:
            Klist[K] = 1
###
#print("count",count)
#print(Klist[:100])
###
print(sum(Klist)+count-Klist[1])

Buggy submission (verdict: Runtime Error):
import math

N = int(input())

Klist = [0]*(int(N**(1/2))+1)
count = 1###int(N**(1/2))+1以上についてカウント
###あらかじめK=Nはカウント

for i in range(1,int((N-1)**(1/2))+1):
    if (N-1) % i == 0:
        Klist[i] = 1
        count += 1
        ###
        #print(i,(N-1)//i)
        ###

if int((N-1)**(1/2)) == (N-1)**(1/2):
    count -= 1

M = int(math.log2(N))

for m in range(1,M+1):
    if m >= 2 and N**(1/m) == int(N**(1/m)):###m=1のときはK=Nの話なのでpass
        Klist[int(N**(1/m))] = 1
    for K in range(2,int(N**(1/(m+1))+1)):
        if (N-K**m)%(K**(m+1)) == 0:
            Klist[K] = 1
###
#print("count",count)
#print(Klist)
###
print(sum(Klist)+count-Klist[1])
Problem p02788 (python)

Fixed submission:
from bisect import bisect_right

N, D, A = map(int, input().split())
xh = sorted([list(map(int, input().split())) for _ in range(N)])
ds = [0]*(N+2)
b = 0
for i, (x, h) in enumerate(xh, 1):
  ds[i] += ds[i-1]###(*)
  ###これまでのやつに与えたダメージは引き継がれるものとする
  d = ds[i]
  if d>=h:
    continue###すでに体力以上のダメージを与えた敵
  h -= d###ダメージを与える
  times = h//A if h%A==0 else h//A+1
  ds[i] += times*A
  ds[bisect_right(xh, [x+2*D, float('inf')])+1] -= times*A
  ###(*)のせいで, 2Dよりも向こう側にも、今考えたダメージの影響が
  ###出てしまうので. それを打ち消すために与えるダメージを引いておく
  b += times
print(b)

Buggy submission (verdict: Runtime Error):
from bisect import besect_left

N,D,A = map(int,input().split())
data = []
for i in range(N):
    X,H = map(int,input().split())
    if H % A == 0:
        data.append([X,H//A])
    else:
        data.append([X,H//A + 1])

data.sort()

X = []
H = []
for i in range(N):
    X.append(data[i][0])
    H.append(data[i][1])

count = 0
for i in range(N):
    if H[i] <= 0:
        continue
    count += H[i]
    p = bisect_left(X,X[i]+2*D+1)
    for j in range(i+1,min(p,N)):
        H[j] -= H[i]

print(count)
Problem p02804 (python)

Fixed submission:
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


N_,K = map(int,input().split())

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

A.sort()

ans = 0

for i in range(K-1,N_):
    ans += cmb(i,K-1,mod) * A[i]
    ans %= mod
    #print(ans)

for i in range(K-1,N_):
    ans -= cmb(i,K-1,mod) * A[N_-i-1]
    ans %= mod
    #print(ans)

print(ans)

Buggy submission (verdict: Runtime Error):
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**4
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


N_,K = map(int,input().split())

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

A.sort()

ans = 0

for i in range(K-1,N_):
    ans += cmb(i,K-1,mod) * A[i]
    ans %= mod
    #print(ans)

for i in range(K-1,N_):
    ans -= cmb(i,K-1,mod) * A[N_-i-1]
    ans %= mod
    #print(ans)

print(ans)
Problem p02939 (python)

Fixed submission:
s = str(input())

l = list(s)

info = [1]

for i in range(1,len(l)):
    if l[i] == l[i-1]:
        info[-1] += 1
    else:
        info.append(1)

ans = 0
for j in range(0,len(info)):
    if info[j] % 3 == 0:
        ans += 2*(info[j]//3)
    elif info[j] % 3 == 1:
        ans += 2*(info[j]//3) + 1
    else:
        if j < len(info)-1:
            ans += 2*(info[j]//3) + 2
            info[j+1] -= 1
        else:
            ans += 2*(info[j]//3) + 1

print(ans)

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

l = list(s)

info = [0]

for i in range(1,len(l)):
    if l[i] == l[i-1]:
        info[-1] += 1
    else:
        info.append(1)

ans = 0
for j in range(0,len(info)):
    if info[j] % 3 == 0:
        ans += 2*(info[j]//3)
    elif info[j] % 3 == 1:
        ans += 2*(info[j]//3) + 1
    else:
        if j < len(info):
            ans += 2*(info[j]//3) + 2
            info[j+1] -= 1
        else:
            ans += 2*(info[j]//3) + 1

print(ans)
Problem p02960 (python)

Fixed submission:
MOD = 10 ** 9 + 7
 
s = str(input())
 
s = list(s)
 
cur = [0] * 13
 
if s[0] != "?":
    cur[int(s[0])] = 1
else:
    for j in range(10):
        cur[j] = 1
 
for i in range(1,len(s)):
    pre = cur[:]
    cur = [0] * 13
    if s[i] != "?":
        for j in range(13):
            q = (j * 10 + int(s[i])) % 13
            cur[q] += pre[j] % MOD
    else:
        for j in range(13):
            for k in range(10):
                p = (j * 10 + k) % 13
                cur[p] += pre[j] % MOD
 
print(cur[5] % MOD)

Buggy submission (verdict: Runtime Error):
MOD = 10 ** 9 + 7

s = str(input())
sl = list(s)
si = list(map(int,s))

cur = [0] * 13

if s[0] != "?":
    cur[si[0]] = 1
else:
    for j in range(10):
        cur[j] = 1

for i in range(1,len(s)):
    pre = cur[:]
    cur = [0] * 13
    if s[i] != "?":
        for j in range(13):
            q = (j * 10 + si[i]) % 13
            cur[q] += pre[j] % MOD
    else:
        for j in range(13):
            for k in range(10):
                p = (j * 10 + k) % 13
                cur[p] += pre[j] % MOD

print(cur[5] % MOD)
Problem p02972 (python)

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

info = [0] * (n+1)

for i in range(0,n):
    count = 0
    for j in range(2,n//(n-i) + 1):
        count += info[(n-i)*j]
    if count % 2 != a[n-i]:
        info[n-i] = 1

ans = []

for k in range(1,n+1):
    if info[k] == 1:
        ans.append(k)

print(len(ans))
print(" ".join(map(str,ans)))

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

info = [0] * (n+1)

for i in range(0,n):
    count = 0
    for j in range(n-i,n+1):
        count += info[j]
    if count != a[n-i]:
        info[n-i] = 1

ans = []

for k in range(1,n+1):
    if info[k] == 1:
        ans.append(k)

print(len(ans))
print(ans)

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

info = [0] * (n+1)

for i in range(0,n):
    count = 0
    for j in range(n-i,n+1):
        count += info[j]
    if count != a[n-i]:
        info[n-i] = 1

ans = []

for k in range(1,n+1):
    if info[k] == 1:
        ans.append(k)

print(len(ans))
print(ans)
Problem p02995 (python)

Fixed submission:
import fractions

def antidiv(x,l,c,d):
    if x == l or x < 0:
        return l - (l // c) - (l // d) + 1
    else:
        return x - (x // c) - (x // d) 

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

l = (c*d)//fractions.gcd(c,d)


aq = a // l
ar = a % l
bq = b // l
br = b % l
#print(br)

qq = bq - aq - 1
r1 = antidiv(l,l,c,d) - antidiv(ar-1,l,c,d)
r2 = antidiv(br,l,c,d)

if ar!=0:
    ans = qq * antidiv(l,l,c,d) + r1 + r2
else:
    ans = (qq+1) * antidiv(l,l,c,d) + r1 + r2


print(ans)

Buggy submission (verdict: Runtime Error):
import math

def antidiv(x,l,c,d):
    if x == l:
        return l - (l // c) - (l // d) + 1
    else:
        return x - (x // c) - (x // d) 

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

l = (c*d)//math.gcd(c,d)


aq = a // l
ar = a % l
bq = b // l
br = b % l

qq = bq - aq - 1
r1 = antidiv(l,l,c,d) - antidiv(ar-1,l,c,d)
r2 = antidiv(br,l,c,d)

ans = qq * antidiv(l,l,c,d) + r1 + r2

print(ans)
Problem p03061 (python)

Fixed submission:
import fractions

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

left = [0] * N
right = [0] * N

left[0] = A[0]
for i in range(1,N):
    left[i] = fractions.gcd(left[i-1],A[i])

right[N-1] = A[N-1]
for j in range(N-2,0,-1):
    right[j] = fractions.gcd(A[j],right[j+1])

can = [0] * N
can[0] = right[1]
for k in range(1,N-1):
    can[k] = fractions.gcd(left[k-1],right[k+1])
can[N-1] = left[N-2]

print(max(can))

Buggy submission (verdict: Runtime Error):
import fraction

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

left = [0] * N
right = [0] * N

left[0] = A[0]
for i in range(1,N):
    left[i] = fraction.gcd(left[i-1],A[i])

right[N-1] = A[N-1]
for j in range(N-2,0,-1):
    right[j] = fraction.gcd(A[j],right[j+1])

can = [0] * N
can[0] = right[1]
for k in range(1,N-1):
    can[k] = fraction.gcd(left[k-1],right[k+1])
can[N-1] = left[N-2]

print(max(can))
Problem p03078 (python)

Fixed submission:
import heapq

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)

l = []

for p in range(0,x):
    for q in range(0,y):
        for r in range(0,z):
            if len(l) > k and a[p]+b[q]+c[r] <= l[0]:
                break
            elif len(l) > k:
                heapq.heappushpop(l,a[p]+b[q]+c[r])
            else:
                heapq.heappush(l,a[p]+b[q]+c[r])

l.sort()

for i in range(1,k+1):
    print(l[-i])

Buggy submission (verdict: Runtime Error):
import heapq

x,y,z,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

a.sort(reverse = True)
b.sort(reverse = True)
c.sort(reverse = True)

l = []

for p in range(0,x):
    for q in range(0,y):
        for r in range(0,z):
            if a[p]+b[q]+c[r] <= l[0]:
                break
            elif len(l) > k:
                heapq.heappushpop(l,a[p]+b[q]+c[r])
            else:
                heapq.heappush(l,a[p]+b[q]+c[r])

l.sort()

for i in range(1,k+1):
    print(l[-i])
Problem p03087 (python)

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

l = [0] * q
r = [0] * q

for i in range(0,q):
    l[i], r[i] = map(int,input().split())
    l[i] = l[i] -1
    r[i] = r[i] -1

s_list = list(s)

ac_list = [0] * (n-1)

for i in range(0,n-1):
    if s_list[i] == "A" and s_list[i+1] == "C":
        ac_list[i] = 1

#print(ac_list)

w = [0] * (n-1)

w[0] = ac_list[0]

for i in range(1,n-1):
    w[i] = w[i-1] + ac_list[i]

#print(w)

for i in range(0,q):
    if l[i] == 0:
        print(w[r[i]-1])
    else:
        print(w[r[i]-1]-w[l[i]-1])

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

l = [0] * q
r = [0] * q

for i in range(0,q):
    l[i], r[i] = map(int,input().split())
    l[i] = l[i] -1
    r[i] = r[i] -1

s_list = list(s)

ac_list = [0] * (n-1)

for i in range(0,n-1):
    if s_list[i] == "A" and s_list[i+1] == "C":
        ac_list[i] = 1

for i in range(0,q):
Problem p03088 (python)

Fixed submission:
n, MOD = int(input()), 10 ** 9 + 7

memo = [{} for _ in range(n+1)]
def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i], t[i-1] = t[i-1], t[i]
        if "".join(t).count("AGC") != 0:
            return False
    return True

def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == n:
        return 1
    ret = 0
    for c in "AGCT":
        if ok(last3 + c):
            ret = (ret + dfs(cur+1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret

print(dfs(0,"TTT"))

Buggy submission (verdict: Runtime Error):
n, MOD = int(input()), 10 ** 9 + 7

memo = [{} for _ in range(n+1)]
def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i], t[i-1] = t[i-1], t[i]
        if "".join(t).count("AGC") != 0:
            return False
    return True

def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in "AGCT":
        if ok(last3 + c):
            ret = (ret + dfs(cur+1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret

print(dfs(0,"TTT"))

Buggy submission (verdict: Runtime Error):
n, MOD = int(input()), 10 ** 9 + 7

memo = [{} for _ in range(n+1)]
def ok(last4):
    for i in range(4):
        t = list(last4)
        if i >= 1:
            t[i], t[i-1] = t[i-1], t[i]
        if "".join(t).count("AGC") != 0:
            return False
    return True

def dfs(cur, last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret = 0
    for c in "AGCT":
        if ok(last3) + c:
            ret = (ret + dfs(cur+1, last3[1:] + c)) % MOD
    memo[cur][last3] = ret
    return ret

print(dfs(0,"TTT"))
Problem p03125 (python)

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

if b % a == 0:
    print(b+a)
else:
    print(b-a)

Buggy submission (verdict: Runtime Error):
import fraction

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

x = math.gcd(a[0],a[1])

if n != 2:
    for i in range(2,n):
        x = math.gcd(x,a[i])
        
print(x)
Problem p03287 (python)

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

total = 0
info = {}
info[0] = 1

for i in range(1,N+1):
    total = (total + a[i]) % M
    if total in info:
        info[total] += 1
    else:
        info[total] = 1

#print(info)

ans = 0

for j in info:
    ans += (info[j] * (info[j] - 1)) // 2
    #print(ans)

print(ans)

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

total = 0
info = [0] * M
info[0] = 1

for i in range(1,N+1):
    total = (total + a[i]) % M
    info[total] += 1

#print(info)

ans = 0

for j in range(M):
    ans += (info[j] * (info[j] - 1)) // 2
    #print(ans)

print(ans)

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

total = 0
info = [0] * M
info[0] = 1

for i in range(1,N+1):
    total = (total + a[i]) % M
    info[total] += 1

#print(info)

ans = 0

for j in range(M):
    ans += (info[j] * (info[j] - 1)) // 2
    #print(ans)

print(ans)
Problem p03699 (python)

Fixed submission:
n = int(input())
s = [0] * n
for i in range(0,n):
    s[i] = int(input())

#print(s)

l0 = []
l1 = []
for i in range(0,n):
    if s[i] % 10 == 0:
        l1.append(s[i])
    else:
        l0.append(s[i])

#print(l)

w = sum(s)

if w % 10 != 0:
    ans = w

elif l0 == []:
    ans = 0

else:

    l0.sort()
    
    #print(l)
    
    ans = w - l0[0]

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = [0] * n
for i in range(0,n):
    s[i] = int(input())

#print(s)

l0 = []
l1 = []
for i in range(0,n):
    if s[i] % 10 == 0:
        l1.append(s[i])
    else:
        l0.append(s[i])

#print(l)

w = sum(s)

if w % 10 != 0:
    ans = w

elif l[0] == []:
    ans = 0

else:

    l0.sort
    
    #print(l)
    
    ans = w - l0[0]

print(ans)
Problem p03700 (python)

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

h = []

for i in range(N):
    h.append(int(input()))

def det(num):
    count = 0
    for i in range(N):
        H = h[i]-B*num
        count += max(0,H//(A-B) + min(1,H%(A-B)))
    if count <= num:
        return True
    else:
        return False

x = 1###False
y = max(h)###True

while y - x > 1:
    if det((x+y)//2):
        y = (x+y)//2
    else:
        x = (x+y)//2
    #print(x,y)

print(y)

Buggy submission (verdict: Runtime Error):
def roof(x):
    if x == int(x):
        return x
    else:
        return int(x)+1

def ans(n,a,b,h):
    
    m = max(h)

    M = roof(m / b)
    
    x = M
    y = 0
    
    if x == 1:
        return x
    
    while x - y > 1:
        half = int((x+y)/2)
        s_half = 0
        for i in range(0,n):
            s_half = s_half +roof((h[i] - b * half) / (a - b))
        if s_half <= half:
            x = half
        else:
            y = half
        #print(x,y)
    
    return x
    
n, a, b = map(int,input().split())

h = [0] * n

for i in range(0,n):
    h[i] = int(input())

print(int(ans(n,a,b,h))
Problem p03713 (python)

Fixed submission:
h, w = map(int,input().split())

if w % 3 == 0 or h % 3 == 0:
    print(0)

else:
    s = h * w
    l = [h,w]
    for i in range(0,2):
        if w == 2 and i == 0:
            continue
        a = (int(w/3) + i) * h
        b = (w - (int(w/3) + i)) * int(h/2)
        c = s - a - b
        #print([a,b,c])
        l.append(max([a,b,c])-min([a,b,c]))
    for j in range(0,2):
        if h == 2 and j == 0:
            continue
        a = (int(h/3) + j) * w
        b = (h - (int(h/3) + j)) * int(w/2)
        c = s - a - b
        #print([a,b,c])
        l.append(max([a,b,c])-min([a,b,c]))
    print(min(l))

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

if w % 3 == 0 or h % 3 == 0:
    print(0)

else:
    s = h * w
    l = []
    for i in range(0,2):
        if w == 2 and i == 0:
            break
        a = (int(w/3) + i) * h
        b = (w - (int(w/3) + i)) * int(h/2)
        c = s - a - b
        l.append(max([a,b,c])-min([a,b,c]))
    for j in range(0,2):
        if h == 2 and j == 0:
            break
        a = (int(h/3) + j) * w
        b = (h - (int(h/3) + j)) * int(w/2)
        c = s - a - b
        l.append(max([a,b,c])-min([a,b,c]))
    print(min(l))
Problem p02582 (python)

Fixed submission:
s=list(input())
if 'R' in s:
  if s.count('R')==3:
    print(3)
  elif s[0]==s[1]=='R' or s[2]==s[1]=='R':
    print(2)
  else:
    print(1)
else:
  print(0)

Buggy submission (verdict: Runtime Error):
s=list(input())
if 'R' in s:
  if s.count('R')==3:
    print(3)
  if s[0]==s[1]=='R' and s[2]==s[1]=='R':
    print(2)
  else:
    print(1)]
else:
  print(0)
Problem p02606 (python)

Fixed submission:
l,r,d=map(int,input().split())
c=0
for x in range(l,r+1):
  if x%d==0:
    c=c+1
print(c)

Buggy submission (verdict: Runtime Error):
l,r,d=map(int,input().split())
for x in range(l,r+1):
  if x%d==0:
    c=c+1
print(c)