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

Fixed submission:
#!python3.8
# -*- coding: utf-8 -*-
# abc171/abc171_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    a = i2s()
    print('A' if a.isupper() else 'a')
    return

main()

Buggy submission (verdict: Runtime Error):
#!python3.8
# -*- coding: utf-8 -*-
# abc171/abc171_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    a = i2s
    print('A' if a.isupper() else 'a')
    return

main()
Problem p02777 (python)

Fixed submission:
#!python3.4
# -*- coding: utf-8 -*-
# abc154/abc154_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    S,T = i2s().split()
    A,B = i2nn()
    U = i2s()
    d = {S:A, T:B}
    d[U] -= 1
    print(d[S], d[T])
    return

main()

Buggy submission (verdict: Runtime Error):
#!python3.4
# -*- coding: utf-8 -*-
# abc154/abc154_a
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    S,T = i2s().split()
    A,B = i2nn()
    U = i2s()
    d = {S:A, T:B}
    d[U] -= 1
    print(d[A], d[B])
    return

main()
Problem p02990 (python)

Fixed submission:
N, K = map(int, input().split())
R = N - K
mod = pow(10, 9) + 7

N += 1

fact = [0] * N
inv = [0] * N
inv_cal = [0] * N

fact[:2] = [1, 1]
inv[1] = 1
inv_cal[:2] = [1, 1]

for i in range(2, N):
    fact[i] = fact[i-1] * i % mod
    inv[i] = mod - (mod // i) * inv[mod % i] % mod
    inv_cal[i] = inv_cal[i-1] * inv[i] % mod

def comb(n, k):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fact[n] * (inv_cal[k] * inv_cal[n-k] % mod) % mod

for k in range(1, K+1):
    print(comb(R+1, k) * comb(K-1, k-1) % mod)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# abc132/abc132_d
import sys
from functools import lru_cache

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
fact = [None] * 2001
fact[0] = 1
for n in range(1, 2001):
    fact[n] = fact[n - 1] * n
mod = 10**9 + 7

def main():
    N, K = i2nn()
    M = N - K
    sum = 0
    for i in range(1, K + 1):
        n = (fact[M + i] / fact[M] / fact[i] - sum) * comb(K - 1, i - 1) % mod
        sum += n
        print(int(n))
    return

def comb(n, r):
    return fact[n] / fact[n - r] / fact[r]

main()
Problem p03038 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# abc127/abc127_d
import sys
from operator import itemgetter

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

      


def main():
    N, M = i2nn()
    A = [(1, x) for x in i2nn()]
    S = [0] * M
    for j in range(M):
        S[j] = tuple(i2nn())
    S.extend(A)
    R = sorted(S, key=itemgetter(1))
    sum = 0
    while True:
        p = R.pop()
        if N - p[0] > 0:
            sum += p[0] * p[1]
            N -= p[0]
        else:
            sum += p[1] * N
            break
    print(sum)
    return

main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# abc127/abc127_d
import sys
from itertools import chain

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N, M = i2nn()
    A = i2nn()
    A.sort()
    for j in range(M):
        B, C = i2nn()
        if A[0] < C:
            for k in range(B):
                A[k] = C
                if A[k + 1] >= C:
                    break
        A.sort()
    print(sum(A))
    return

main()
Problem p02572 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
ans = 0
aa=sum(a)
for i in range(n):
    aa-=a[i]
    ans += a[i]*aa
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
ans = 0
aa=sum(a)
for i in range(n):
    aa-=a[i]
        ans += a[i]*a[j]
ans %= mod
print(ans)
Problem p02726 (python)

Fixed submission:
n, x, y = map(int, input().split())
ans = [0]*n
x -= 1
y -= 1
for i in range(n-1):
    for j in range(i+1, n):
        # print("DFGH")
        ans[min(j-i, abs(x-i)+abs(y-j)+1)] += 1

for i in range(1, n):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
n,x,y=map(int,input().split())
adlist=[[1,2]]
for i in range(n-2):
    adlist.append([i+1,i+2,i+3])
adlist.append([n-1,n])

adlist[x-1].append(y)
adlist[y-1].append(x)


def dfs(start,count,goal,finish,ans):
    finish.add(start)#もう訪れたところ
   
   # print(finish)
    if count==goal:
        #print("DFGH")
        ans+=1
        #print(ans)
        count=0
    for i in adlist[start-1]:
        #print("DFG")
        if i not in finish:#通ったところに入っていないなら通れるということ   
            #print(i)
            dfs(i,count+1,goal,finish,ans)
    return ans

#print(adlist)
global ans
for i in range(1,n):
    
    ans=0
    finish=set()
    print(dfs(1,0,i,finish,0))

#print(adlist)
Problem p02793 (python)

Fixed submission:
import fractions
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

count=a[0]
for i in range(n-1):
    count=lcm(count,a[i+1])
ans=0
for i in range(n):
    ansa=count//a[i]
    ans+=ansa
    
print(ans%mod)

Buggy submission (verdict: Runtime Error):
import fractions
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))

def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return max(fct)


for i in range(n):
    a[i]=factorize(a[i])

count=a[0]
for i in range(n-1):
    count=count*a[i+1]//fractions.gcd(count, a[i+1])
ans=0


for i in range(n):
    ansa=count//a[i]
    ans+=ansa
    ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):

mod=10**9+7
n=int(input())
a=list(map(int,input().split()))
count=a[0]
for i in range(n-1):
    count=count*a[i+1]//fractions.gcd(count, a[i+1])
ans=0
for i in range(n):
    ansa=count//a[i]
    ans+=ansa
    ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))

count=a[0]
for i in range(n-1):
    count=count*a[i+1]//fraction.gcd(count, a[i+1])
ans=0
for i in range(n):
    ansa=count//a[i]
    ans+=ansa
    ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))

count=a[0]
for i in range(n-1):
    count=count*a[i+1]//fraction.gcd(x, y)
ans=0
for i in range(n):
    ansa=count//a[i]
    ans+=ansa
    ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
mod=10**9+7
n=int(input())
a=tuple(list(map(int,input().split())))

def lcm(x, y):
    return (x * y) // fraction.gcd(x, y)

count=a[0]
for i in range(n-1):
    count=lcm(count,a[i+1])
ans=0
for i in range(n):
    ansa=count//a[i]
    ans+=ansa
    ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))

def lcm(x, y):
    return (x * y) // fraction.gcd(x, y)

count=a[0]
for i in range(n-1):
    count=lcm(count,a[i+1])
ans=0
for i in range(n):
    ansa=count//a[i]
    ans+=ansa%=mod
    ans%=mod
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
mod=10**9+7
n=int(input())
a=list(map(int,input().split()))

def lcm(x, y):
    return (x * y) // fraction.gcd(x, y)

count=a[0]
for i in range(n-1):
    count=lcm(count,a[i+1])
ans=0
for i in range(n):
    ansa=count//a[i]
    ans+=ansa%=mod
    ans%=mod
print(ans)
Problem p02831 (python)

Fixed submission:
import fractions


a,b=map(int,input().split())
print((a*b)//fractions.gcd(a,b))

Buggy submission (verdict: Runtime Error):
import math


a,b=map(int,input().split())
print((a*b)//math.gcd(a,b))
Problem p03013 (python)

Fixed submission:
n,m=map(int,input().split())
mod=10**9+7
t=[int(input()) for i in range(m)] 
dp=[-1]*(n+1)

dp[0]=1
dp[1]=1
for i in range(m):
    dp[t[i]]=0


for i in range(2,n+1):
    if dp[i]==-1:
        dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%mod)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
mod=10**9+7
t=[int(input()) for i in range(m)] 
dp=[-1]*(n+1)

dp[0]=0
dp[1]=1
dp[2]=2

for i in range(m):
    dp[t[i]]=0

for i in range(3,n+1):
    if dp[i]==-1:
        dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%mod)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
mod=10**9+7
t=[int(input()) for i in range(m)] 
dp=[-1]*(n+1)

dp[0]=0
dp[1]=1
dp[2]=1

for i in range(m):
    dp[t[i]]=0

for i in range(3,n+1):
    if dp[i]==-1:
        dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%mod)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
mod=10**9+7
t=[int(input()) for i in range(m)] 
dp=[-1]*(n+1)

dp[0]=0
dp[1]=1
dp[2]=1

for i in range(m):
    dp[t[i]]=0

for i in range(3,n+1):
    if dp[i]==-1:
        dp[i]=dp[i-1]+dp[i-2]
print(dp[-1]%mod)
Problem p03041 (python)

Fixed submission:
a,b=map(int,input().split())
s=list(input())
s[b-1]=s[b-1].lower()
print(''.join(s))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(str(input()))
a[k-1]=chr(ord(a[k-1])+32)

for i in range(s):
    print(a[i],end="")
Problem p03127 (python)

Fixed submission:
"""
import math
n=int(input())
a=list(map(int,input().split()))
m1=min(a)

def a_gcd(t,y):
    return math.gcd(t,y)

if m1==1:
    print(m1)
    exit()
for i in range(n):
    m1=a_gcd(m1,a[i])
    if m1==1:
        break

print(m1)
"""
import fractions
n=int(input())
a=list(map(int,input().split()))
m1=min(a)

def a_gcd(t,y):
    return  fractions.gcd(t,y)

if m1==1:
    print(m1)
    exit()
for i in range(n):
    m1=a_gcd(m1,a[i])
    if m1==1:
        break

print(m1)

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

def a_gcd(t,y):
    return math.gcd(t,y)

if m1==1:
    print(m1)
    exit()
for i in range(n):
    m1=a_gcd(m1,a[i])
    if m1==1:
        break

print(m1)
Problem p03137 (python)

Fixed submission:
n,m=map(int,input().split())
x=list(map(int,input().split()))
if n>=m:
    print("0")
    exit()
x.sort()
a=[0]
for i in range(m-1):
   a.append(x[i+1]-x[i])
a.sort(reverse=True)
for i in range(n-1):
    a[i]=0
print(sum(a))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
a=[0]
for i in range(m-1):
   a.append(x[i+1]-x[i])
a.sort(reverse=True)
for i in range(n-1):
    a[i]=0
print(sum(a))
Problem p03315 (python)

Fixed submission:
a=str(input())
print(a.count("+")-a.count("-"))

Buggy submission (verdict: Runtime Error):
a=str(input())
print(a.cpunt("+")-a.count("-"))
Problem p03745 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
ans=1
now=a[0]
start=1

if n==1:
    print(1)
    exit()

while now==a[start]:
    start+=1
if a[0]<a[start]:#増加
    jugh=1
else:#現象
    jugh=2
#print(start,jugh)
i=start
while i<n:
    if jugh==0:
        while now==a[start]:
            start+=1
        if now<a[start]:#増加
            jugh=1
        else:#現象
            jugh=2
    if jugh==1:
        if a[i-1]>a[i]:
            jugh=0
            ans+=1
            now=a[i]
            start=i+1
            #print(a[i-1],a[i])
                
    else:
        if a[i-1]<a[i]:
            jugh=0
            ans+=1
            now=a[i]
            start=i+1
            #print(a[i-1],a[i])
            
    i+=1   

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
ans=1
now=a[0]
start=1
while now==a[start]:
    start+=1
if a[0]<a[start]:#増加
    jugh=1
else:#現象
    jugh=2
#print(start,jugh)
i=start
while i<n:
    if jugh==0:
        while now==a[start]:
            start+=1
        if now<a[start]:#増加
            jugh=1
        else:#現象
            jugh=2
    if jugh==1:
        if a[i-1]>a[i]:
            jugh=0
            ans+=1
            now=a[i]
            start=i+1
            #print(a[i-1],a[i])
                
    else:
        if a[i-1]<a[i]:
            jugh=0
            ans+=1
            now=a[i]
            start=i+1
            #print(a[i-1],a[i])
            
    i+=1   

print(ans)
Problem p03986 (python)

Fixed submission:
x=list(input())
s=0
t=0
ans=0
for i in range(len(x)):
    if x[i]=="S":
        s+=1

    else:
        if s==0:
            ans+=1
        else:
            s-=1

print(ans+s)

Buggy submission (verdict: Runtime Error):
x=list(input())
s=0
t=0
ans=0
for i in range(len(x)):
    if x[i]="S":
        s+=1

    else:
        if s==0:
            ans+=1
        else:
            s-=1

print(ans+s)

Buggy submission (verdict: Runtime Error):
x=input()
x=list(x)
s=0
t=0
ans=0
for i in range(len(x)):
    if x[i]="S":
        s+=1

    else:
        if s==0:
            ans+=1
        else:
            s-=1

print(ans+s)
Problem p03017 (python)

Fixed submission:
def iwa_check(start, end):
    for i in range(start, end):
        if s[i] == '#' and s[i + 1] == '#':
            return False
    return True


n, a, b, c, d = map(int, input().split())
s = list(input())
s = ['#'] + s + ['#']

# 岩が2個並ぶ
if not iwa_check(a, c) or not iwa_check(b, d):
    print('No')
    exit()

# 追い越す場合
if c > d:
    ok = False
    for i in range(b, d + 1):
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            ok = True
            break
    if not ok:
        print('No')
        exit()

# 追い越さない
print('Yes')

Buggy submission (verdict: Runtime Error):
n, a, b, c, d = map(int, input().split())
s = input()

# c<dの場合
tooi = max(c, d)
for i in range(a, tooi - 1):
    # 二連続石は無理
    if s[i] == '#' and s[i + 1] == '#':
        print('No')
        exit()
# d<cなら飛び越え必要=b~d区間に3マス連続空きが必要
if d < c:
    for i in range(b, d + 1):
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            print('Yes')
            exit()
    print('No')
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
n, a, b, c, d = map(int, input().split())
s = list(input())

# 岩が2個並ぶ
before = s[0]
for ss in s[1:]:
    if ss == before and ss == '#':
        print('No')
        exit()
    before = ss

# 追い越す場合
if c > d:
    # new_s = s[:d+1]
    # for i in range(b - 1, len(new_s) - 2):
    #     ss = new_s[i:i + 3]
    #     # print(ss)
    #     if len(set(ss)) == 1 and ss[0] == '.':
    #         print('Yes')
    #         exit()
    ok = False
    for i in range(b, d + 1):
        if s[i - 1] == '.' and s[i] == '.' and s[i + 1] == '.':
            ok = True
            break
    if not ok:
        print('No')
        exit()

# 追い越さない
print('Yes')
Problem p03137 (python)

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

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

distance = []

for i in range(len(x) - 1):
    tmp = x[i + 1] - x[i]
    distance.append(tmp)

distance.sort()
if n >= m:
    print(0)
else:
    for i in range(n - 1):
        distance.pop()

    print(sum(distance))

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

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

distance = []

for i in range(len(x) - 1):
    tmp = x[i + 1] - x[i]
    distance.append(tmp)

distance.sort()

for i in range(n - 1):
    distance.pop()

print(sum(distance))
Problem p02622 (python)

Fixed submission:
s=input()
t=input()
u=0
for i in range(0,len(s)):
    if s[i]!=t[i]:
        u+=1
print(u)

Buggy submission (verdict: Runtime Error):
s,t=input().split()
u=0
for i in range(0,len(s)):
    if s[i]!=t[i]:
        u+=1
print(u)
Problem p02659 (python)

Fixed submission:
from decimal import Decimal
a,b = input().split()
a=int(a)
b=Decimal(str(b))
c = a*b

print(int(c))

Buggy submission (verdict: Runtime Error):
import functools
import operator
n = int(input())
a = list(map(int,input().split()))
c = functools.reduce(operator.mul,a)
if c > 10**18:
    print(-1)
else:
    print(c)
Problem p02766 (python)

Fixed submission:
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)
x2 = 0
x10, n = input().split()
x10 = int(x10)
n = int(n)
x2 = Base_10_to_n(x10, n)
print(len(x2))

Buggy submission (verdict: Runtime Error):
def Base_n_to_10(X,n):
    out = 0
    for i in range(1,len(str(X))+1):
        out += int(X[-i])*(n**(i-1))
    return out#int out

N, K = input().split()
N = int(N)
K = int(K)
x = str(len(Base_n_to_10(N,K)))
print(x)
Problem p03072 (python)

Fixed submission:
n = int(input())
h = [int(i) for i in input().split()]
x = 1
if n == 1:
    print(x)
else:
    if h[1] >= h[0]:
        x += 1

    for i in range(2, n):
            hh = h[0:i]
            if h[i] >= max(hh):
                x += 1
    print(x)

Buggy submission (verdict: Runtime Error):
n = int(input())
h = [int(i) for i in input().split()]
x = 1
if n==1:
	print(x)
else:
	if h[1] >= h[0]:
		x += 1
	
	for i in range(2, n):
		hh=h[0:i-1]
    	if h[i] >= max(hh):
        	x += 1
	print(x)

Buggy submission (verdict: Runtime Error):
n = int(input())
h = [int(i) for i in input().split()]
x = 1

if h[1] >= h[0]:
	x += 1

for i in range(2, n):
    hh=h[0:i-1]
    if h[i] >= max(hh):
        x += 1
print(x)
Problem p02623 (python)

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

a, b = [0], [0]
 
for i in range(N):
	a.append(a[i] + A[i])
    
for i in range(M):
	b.append(b[i] + B[i])
    
ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i + j)
print(ans)

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

for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])
ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
	break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i + j)
print(ans)
Problem p02598 (python)

Fixed submission:
def solve():
    n, k = map(int, input().split())
    s = list(map(int, input().split()))

    def is_ok(x):
        res = 0
        for ss in s:
            y = ss // x
            if ss % x == 0:
                y -= 1
            res += y
        return res

    ng = 0
    ok = 10 ** 10
    while ok - ng > 1:
        mid = (ok + ng) // 2
        if is_ok(mid) <= k:
            ok = mid
        else:
            ng = mid

    print(ok)


solve()

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

    def is_ok(x):
        res = 0
        for ss in s:
            y = ss // x
            if ss % x == 0:
                y -= 1
            res += y
        return res

    ok = -1
    ng = 10 ** 10
    while ng - ok > 1:
        mid = (ok + ng) // 2
        if is_ok(mid) > k:
            ok = mid
        else:
            ng = mid

    print(ok + 1)


solve()
Problem p02860 (python)

Fixed submission:
n = int(input())
d = input()
if n % 2 == 1:
    print("No")
elif d[:n//2] == d[n//2:]:
    print("Yes")
else:
    print("No")

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

if d[:n//2] == d[n/2:]:
    print("Yes")
else:
    print("No")
Problem p02880 (python)

Fixed submission:
m = int(input())
a = {}
for i in range(1, int(m**0.5)+1):
    if m % i == 0:
        n = m // i
        a[i] = n
b = min(a.values())
if b < 10: print("Yes")
else: print("No")

Buggy submission (verdict: Runtime Error):
m = int(input())
a = {}
for i in range(2, int(m**0.5)+1):
    if m % i == 0:
        n = m // i
        a[i] = n
b = min(a.values())
if b < 10: print("Yes")
else: print("No")
Problem p02912 (python)

Fixed submission:
import heapq

n,m=map(int,input().split())
a=list(map(int,input().split()))
b=[-int(i) for i in a]

heapq.heapify(b)

for i in range(m):
    x=-heapq.heappop(b)//2
    heapq.heappush(b,-x)

print(-sum(b))

Buggy submission (verdict: Runtime Error):
import heapq

n,m=map(int,input().split())
a=list[map(int,input().split())]
b=[-int(i) for i in a]

heapq.heapify(b)

for i in range(m):
    x=heapq.heappop(b)//2
    heapq.heappush(b,x)

print(-sum(b))

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

for i in range(M):
  money[money.index(max(money))]//=2

print(sum(modey))
Problem p02915 (python)

Fixed submission:
N=int(input())
print(N**3)

Buggy submission (verdict: Runtime Error):
print(N^3)

Buggy submission (verdict: Runtime Error):
def pwd(N):
  return N^3

pwd(N)
Problem p02916 (python)

Fixed submission:
List=[list(map(int,input().split())) for i in range(4)]

a=sum(List[2])
b=int(len(List[1]))

for i in range(b-1):
  if List[1][i+1]-List[1][i] == 1:
    a+=List[3][List[1][i]-1]

print(a)

Buggy submission (verdict: Runtime Error):
List=[list(map(int,input().split())) for i in range(4)]

a=sum(List[2])
b=int(len(List[1]))

for i in range(b-1):
  if List[1][i+1]-List[1][i] == 1:
    a+=List[3][i+1]

print(a)

Buggy submission (verdict: Runtime Error):
Row=int(input())
List=[list(map(int,input().split())) for i in range(Row)]

a=0

for i in List[0]:
  a+=List[1][i-1]

for i in range(len(List[0])-1):
  if List[1][i]-List[1][i+1] == 1:
    a+=List[2][i-1]

print(a)
Problem p02948 (python)

Fixed submission:
import heapq

n, m = map(int, input().split())
lis = []
for i in range(m + 1):
    lis.append([])

for i in range(n):
    a, b = map(int, input().split())
    if a <= m:
        lis[a].append(-b)

cnd = []
heapq.heapify(cnd)
res = 0

for j in range(1, m + 1):
    for e in lis[j]:
        heapq.heappush(cnd, e)
    if cnd:
        res += -heapq.heappop(cnd)
print(res)

Buggy submission (verdict: Runtime Error):
import heapq

n, m = map(int, input().split())
lis = []
for i in range(n + 1):
    lis.append([])

for i in range(n):
    a, b = map(int, input().split())
    if a <= m:
        lis[a].append(-b)

cnd = []
heapq.heapify(cnd)
res = 0

for j in range(1, m + 1):
    for e in lis[j]:
        heapq.heappush(cnd, e)
    if cnd:
        res += -heapq.heappop(cnd)
print(res)

Buggy submission (verdict: Runtime Error):
import heapq

n, m = map(int, input().split())
lis = []
for i in range(n + 1):
    lis.append([])

for i in range(n):
    a, b = map(int, input().split())
    if a <= m:
        lis[a].append(-b)

cnd = []
heapq.heapify(cnd)
res = 0

for j in range(1, m + 1):
    for e in lis[j]:
        heapq.heappush(cnd, e)
    if cnd:
        res += -heapq.heappop(cnd)
print(res)