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

Fixed submission:
n,m = map(int, input().split()) 
AB = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    a -= 1
    b -= 1 
    AB[a].append(b)
    AB[b].append(a)

for i in range(n):
    print(len(AB[i]))

Buggy submission (verdict: Runtime Error):
n,m = map(int, input().split()) 
AB = [[] for _ in range(n)]
for i in range(m):
    a, b = map(int,input().split())
    a -= 1
    b -= 1 
    AB[a].append(b)
    AB[b].append(a)

for i in range(n)
    print(len(AB[i]))
Problem p03729 (python)

Fixed submission:
A,B,C=map(str,input().split())
if A[-1]==B[0] and B[-1]==C[0]:
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
A=input()
B=input()
C=input()
if A[-1]==B[0] and B[-1]==C[0]:
    print("YES")
else:
    print("NO")
Problem p03734 (python)

Fixed submission:
from collections import defaultdict
import sys
input = sys.stdin.readline


def main():
    N, W = map(int, input().split())
    items = [tuple(map(int, input().split())) for _ in range(N)]
    dd = defaultdict(int)
    dd[0] = 0
    for w, v in items:
        for tw, tv in list(dd.items()):
            if tw + w <= W:
                dd[tw + w] = max(tv + v, dd[tw + w])
    print(max(dd.values()))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
n,w=map(int,input().split())
WV=[]
for i in range(n):
    w,v=map(int,input().split())
    WV.append((w,v))
dp={}
dp[0]=0
for w,v in WV:
    for i in JinA:
        if i+w>w:
            continue 
        temp=dp[i]
        try:
            use=dp[i+w]
            dp[i+w]+=max(temp+v-use,0)
        except:
            dp[i+w]=temp+v 
    
ans=[]
for i in dp:
    heappush(ans,-dp[i])

print(-heappop(ans))

Buggy submission (verdict: Runtime Error):
n,w=map(int,input().split())
WV=[]
for i in range(n):
    w,v=map(int,input().split())
    WV.append((w,v))

dp=[0]*(w*2)
for w,v in WV:
    for i in range(w+1):
        try: dp[i]=max(dp[i],dp[i-w]+v)
        except:
            dp[i]=dp[i]


print(max(dp[:w+1]))
Problem p03763 (python)

Fixed submission:
n=int(input())
#s=input()
#S=list(s)
V="abcdefghijklmnopqrstuvwxyz"
dp=[10000]*26
for i in range(n):
    t=input()
    T=list(t)
    for j in range(26):
        clue=max(0,T.count(V[j]))
        dp[j]=min(dp[j],clue)

ans=""
for j in range(26):
    ans=ans+V[j]*dp[j]

print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
S=list(s)
V="abcdefghijklmnopqrstuvwxyz"
dp=[10000]*26
for i in range(n):
    t=input()
    T=list(t)
    for j in range(26):
        clue=max(0,T.count(V[j]))
        dp[j]=min(dp[j],clue)

ans=""
for j in range(26):
    ans=ans+V[j]*dp[j]

print(ans)
Problem p03854 (python)

Fixed submission:
s = input()
s = s.replace('eraser', '')
s = s.replace('erase', '')
s = s.replace('dreamer', '')
s = s.replace('dream', '')
if len(s) == 0:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
s = input()                    
def search(l):
    if l>=len(s):
        return 1
    a = b = c = d = 0
    if s[l:l+5]=="dream":
        a = search(l+5)
    if s[l:l+5]=="erase":
        b = search(l+5)
    if s[l:l+6]=="eraser":
        c = search(l+6) 
    if s[l:l+7]=="dreamer":
        d = search(l+7) 
    return max(a,b,c,d)

if search(0):
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
def search(l):
    if l>=len(s):
        return 1
    if s[l:l+5]=="dream":
        search(l+5)
    if s[l:l+5]=="erase":
        search(l+5)
    if s[l:l+6]=="eraser":
        search(l+6) 
    if s[l:l+7]=="dreamer":
        search(l+7) 
    else:
        return 0  

if search(0):
    print("YES")
else:
    print("NO")
Problem p03999 (python)

Fixed submission:
S=list(input())
S=[int(i) for i in S]
n=len(S)
ans=0
if n!=1:
    for k in range(1,n+1):#上からk桁目
        for j in range(n-k):#10のj乗（n-k桁まで)
            ans+=S[k-1]*(10**j)*(2**(n-2-j))
        ans+=S[k-1]*(10**(n-k))*(2**(k-1))#n-k+1桁
    print(int(ans))
else:print(S[0])

Buggy submission (verdict: Runtime Error):
S=str(input())
n=len(S)
cnt=0
for i in range(2**(n-1)):
    s=S
    for j in range(n-1):
        if i>>j&1:
            cnt+=int(s[:j+1])
            s=s[j+1:]
    pass
    cnt+=int(s)        
        
print(cnt)
Problem p02658 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
ans =1;
iszero = False

if 0 in A:
  iszero = True
for i in range(N):
  if(iszero):
    ans = 0
    break
  ans *= A[i] 
  if ans>10**18:
    ans = -1
    break

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans =1;
iszero = False

if 0 in A:
  iszero = True

for i in range(N):
  if(iszero):
    ans = 0
    break
    
  ans *= A[i]
  
  if(ans>10**18):
    ans = -1

print(ans

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans =1;
iszero = False

for 0 in range A:
  if(A[i]==0):
    iszero = True

for i in range(N):
  if(iszero):
    ans = 0
    break
    
  ans *= A[i]
  
  if(ans>10**18):
    ans = -1

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans =1;
iszero = False

for 0 in range A:
  if(A[i]==0):
    iszero = True

for i in range(N):
  if(iszero):
    ans = 0
    break
    
  ans *= A[i]
  
  if(ans>10**18):
    ans = -1

print(ans
Problem p02675 (python)

Fixed submission:
N = input()
N = N[::-1]
a = int(N[0])
ans = []
if a==2 or a==4 or a==5 or a==7 or a==9:
  ans = "hon"
if a==0 or a==1 or a==6 or a==8:
  ans = "pon"
if a==3:
  ans = "bon"
  
print(ans)

Buggy submission (verdict: Runtime Error):
N = input()
N.reverse()
a = int(N[0])
ans = []
if a==2 || a==4 || a==5 || a==7 || a==9:
  ans = "hon"
if a==0 || a==1 || a==6 || a==8:
  ans = "pon"
if a==3:
  ans = "bon"
  
print(ans)
Problem p02582 (python)

Fixed submission:
S = input()
s = list(S)
if S == "RSR":
    print(1)
else:
    print(s.count('R'))

Buggy submission (verdict: Runtime Error):
X,K,D = map(int,input().split())
X = abs(X)
#0またがない
if X > K*D:
    ans = X - K*D
#0またぐ
else:
    while X >= 0 :
        X = X - D
        K -= 1
    if K % 2 == 0:
        ans = abs(X)
    if K % 2 != 0:
        ans = X+D

print(ans)

Buggy submission (verdict: Runtime Error):
X,K,D = map(int,input().split())
X = abs(X)
#0またがない
if X > K*D:
    ans = X - K*D
#0またぐ
else:
    while X >= 0 :
        X = X - D
        K -= 1
    if K % 2 == 0:
        ans = abs(X)
    else:
        ans = X+D

print(ans)
Problem p02583 (python)

Fixed submission:
l=int(input())
n= list(map(int, input().split()))
ans=0
for i in range(l-2):
    for j in range(i+1,l-1):
        if n[i]==n[j]:
            pass
        else:
            for k in range(j+1,l):
                if n[i]==n[k] or n[j]==n[k]:
                    pass
                else:
                    z=max(n[i],n[j],n[k])
                    if n[i]+n[k]+n[j]-z>z:
                        ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(inout())
i = list(map(int, input().split()))
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        if n[i]==n[j]:
            pass
        else:
            for k in range(j+1,n):
                if n[i]==n[k] and n[j]==n[k]:
                    pass
                else:
                    z=max(n[i],n[j],n[k])
                    if n[i]+n[k]+n[j]-z>z:
                        ans+=1
pint(ans)
Problem p02584 (python)

Fixed submission:
x,k,d= list(map(int, input().split()))
x=abs(x)
a=x//d
if k>=a:
    if (k-a)%2==0:
        print(x%d)
    else:
        print(d-(x%d))
else:
    print(x-(k*d))

Buggy submission (verdict: Runtime Error):
x,k,d= list(map(int, input().split())
x=abs(x)
a=x//d
if k>=a:
    if (k-a)%2==0:
        print(x%d)
    else:
        print(d-(x%d))
else:
    print(x-(k*d))
Problem p02681 (python)

Fixed submission:
n=input()
s=input()
l=len(n)
if n+s[l]==s:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a,b,c,d = list(map(int, input().split()))
if a+b>=d:
    print(a)
else:
    print(a-(d-a-b)
Problem p02714 (python)

Fixed submission:
n=int(input())
s=input()
B=s.count("B")
R=s.count("R")
G=s.count("G")
ans=R*G*B
for i in range(n-2):
    for j in range(i+1,n-1):
        k=j-i+j
        if k<n:
            if s[i]!=s[j] and s[j]!=s[k] and s[i]!=s[k]:
                ans-=1
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=input()
cnt=0
a=["R","G","B"]
for i in range(n):
    x=a.remove(s[i])
    for j in range(i+1,n):
        if s[i]!=s[j]:
            qw=s
            x.remove(s[j])
            k=j-1
            if j+k<n:
               qw[j+k]="P"
            q=x.pop(0)
            cnt+=qw.count(q)
print(cnt)
Problem p02719 (python)

Fixed submission:
x,y= list(map(int, input().split()))
if x%y==0:
    print(0)
else:
    z=min((x%y),(y-(x%y)))
    print(z)

Buggy submission (verdict: Runtime Error):
x,y= list(map(int, input().split()))
if x%y==0:
    print(0)
else:
    print(min((x%y),(y-(x%y)))
Problem p02720 (python)

Fixed submission:
n=int(input())
from collections import deque
k=deque([])
z=9
m=0
if n<10:
    print(n)
    exit()
for i in range(1,10):
    k.append(i)
while z!=n:
    m=k.popleft()
    if m%10!=0:
        ans=10*m+(m%10)-1
        k.append(ans)
        z+=1
        if z==n:
            print(ans)
            exit()
    ans=10*m+(m%10)    
    k.append(ans)
    z+=1
    if z==n:
        print(ans)
        exit()
    if m%10!=9:
        ans=10*m+(m%10)+1
        k.append(ans)
        z+=1
        if z==n:
            print(ans)
            exit()

Buggy submission (verdict: Runtime Error):
n=int(input())
from collections import deque
k=deque([])
z=0
for i in range(1,10):
    k.append(i)
while z<n:
    m=k.pop
    k.popleft
    if m%10!=0:
        k.append(10*m+(m%10)-1)
    k.append(10*m+(m%10))
    if m%10!=9:
        k.append(10*m+(m%10)+1)
print(m)
Problem p02756 (python)

Fixed submission:
S = input()
Q = int(input())
reverseCount = 0
pre = ""
pro = ""
for _ in range(Q):
    query = input()
    if len(query) == 1:
        reverseCount += 1
    else:
        _, F, C = query.split(" ")
        if (int(F) + reverseCount) % 2 == 1:
            pre = C + pre
        else:
            pro = pro + C
S = pre + S + pro
if reverseCount % 2 == 0:
    print(S)
else:
    print(S[::-1])

Buggy submission (verdict: Runtime Error):
s=input()
n=int(input())
for i in range(n):
    k= input().split()
    if k=="1":
        s = s[::-1] 
    else:
        if k[1]=="2":
            s=s+k[2]
        else:
            s=k[2]+s
print(s)
Problem p02767 (python)

Fixed submission:
import numpy as np
n=int(input())
i = list(map(int, input().split()))
ia=np.array(i)
ave=np.mean(ia)
ans=0
for k in range(n):
  ans+=(round(ave, 0)-i[k])**2
print(int(ans))

Buggy submission (verdict: Runtime Error):
from decimal import Decimal, ROUND_HALF_UP, ROUND_HALF_EVEN
n=int(input())
i = list(map(int, input().split()))
ave=sum(i) / n
ans=0
as=Decimal(str(f)).quantize(Decimal('0'), rounding=ROUND_HALF_UP)
for k in range(n):
  ans+=(as-i[k])**2
print(ans)
Problem p02772 (python)

Fixed submission:
n=int(input())
l = list(map(int, input().split()))
count=0
kount=0
for i in range(n):
    if l[i]%2==0:
        count+=1
        if l[i]%3==0:
            kount+=1 
        elif l[i]%5==0: 
          kount+=1
if count==kount:
         print("APPROVED")
else:
         print("DENIED")

Buggy submission (verdict: Runtime Error):
n=int(input())
l = list(map(int, input().split())
i= [k for k in l if l[k]%2==0 or l[k]%5==0]        
j = [k for k in i if i[k]%3==0 or i[k]%5==0]   
if len[i]==len[j]:
         print("APPROVED")
else:
         print("DENIED")
Problem p02780 (python)

Fixed submission:
n,k= list(map(int, input().split()))
j = list(map(int, input().split()))
s=0
sumlist=[0]*(n+1)
anslist=[0]*(n-k+1)
for i in range(n):
    s+=j[i]
    sumlist[i+1]=s
for i in range(len(anslist)):
     z=sumlist[i+k]-sumlist[i]
     anslist[i]=z
ans=max(anslist)
ans+=k
ans=ans/2
print(ans)

Buggy submission (verdict: Runtime Error):
n,k= list(map(int, input().split()))
j = list(map(int, input().split()))
s=0
sumlist=[0]*n
anslist=[0]*(n-k+1)
for i in range(n):
    s+=j[i]
    sumlist[i]=s
for i in range(len(anslist)):
    if i==0:
        z=sumlist[k-1]
        anslist[i]=z
    else:
        z=sumlist[i+k]-sumlist[i]
        anslist[i]=z
ans=max(anslist)
ans+=k
ans=ans/2
print(ans)

Buggy submission (verdict: Runtime Error):
n,k= list(map(int, input().split()))
j = list(map(int, input().split()))
s=0
sumlist=[0]*n
anslist=[0]*(n-k+1)
for i in range(n):
    s+=j[i]
    sumlist[i]=s
for i in range(len(anslist)):
    z=sumlist[i+k]-sumlist[i]
    anslist[i]=z
ans=max(anslist)
ans+=k
ans=ans/2
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
q = list(map(int, input().split()))
w= list(map(int, input().split()))
memo=0
a=0
x=np.array(w)
k=max(np.sum(x[i:i+q[1]]))
 
print((a+q[1])/2)
Problem p02783 (python)

Fixed submission:
i = list(map(int, input().split()))
if i[0]%i[1]==0:
  print(i[0]//i[1])
else:
  print((i[0]//i[1])+1)

Buggy submission (verdict: Runtime Error):
n=int(input())
z=0
while n>0:
  z+=n
  n=n//2
print(z)
Problem p02784 (python)

Fixed submission:
i = list(map(int, input().split()))
j = list(map(int, input().split()))
if i[0]<=sum(j):
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
i = list(map(int, input().split()))
j = list(map(int, input().split()))
if i[0]<=sum(j):
	print(Yes)
else:
	print(No)

Buggy submission (verdict: Runtime Error):
i = list(map(int, input().split()))
j = list(map(int, input().split()))
if i[0]=<sum(j):
  print(Yes)
else:
  print(No)

Buggy submission (verdict: Runtime Error):
i = list(map(int, input().split()))
j = list(map(int, input().split()))
sumj=0
for k in range(len(j)):
  sumj+=j[k]
if i[0]<=sumj:
  print(Yes)
else:
  print(No)

Buggy submission (verdict: Runtime Error):
i = list(map(int, input().split()))
j = list(map(int, input().split()))
if i[0]<=sum(j):
  print(Yes)
else:
  print(No)
Problem p02802 (python)

Fixed submission:
n,m= list(map(int, input().split()))
ans_box=[0]*n
wa=[0]*n
ac=0
wa_cnt=0
for j in range(m):
    k,l=input().split()
    h=int(k)-1
    if ans_box[h]==0:
        if l=="AC":
            ac+=1
            ans_box[h]+=1
            wa_cnt+=wa[h]
        else:
            wa[h]+=1
print(ac,wa_cnt)

Buggy submission (verdict: Runtime Error):
n,m= list(map(int, input().split()))
ans_box=[0]*n
wa=[0]*m
ac=0
wa_cnt=0
for j in range(m):
    k,l=input().split()
    h=int(k)-1
    if ans_box[h]==0:
        if l=="AC":
            ac+=1
            ans_box[h]+=1
            wa_cnt+=wa[h]
        else:
            wa[h]+=1
print(ac,wa_cnt)

Buggy submission (verdict: Runtime Error):
n,m= list(map(int, input().split()))
ans_box=[0]*n
wa=[0]*m
ac=0
wa_cnt=0
for j in range(m):
    k,l=input().split()
    h=int(k)-1
    if ans_box[h]==0:
        if l=="AC":
            ac+=1
            ans_box[h]+=1
            wa_cnt+=wa[h]
        else:
            wa[h]+=1
print(ac,wa_cnt)
Problem p02817 (python)

Fixed submission:
s = input().split()
print(s[1]+s[0])

Buggy submission (verdict: Runtime Error):
s=str(input())
for i in range(len(s)):
  if s[i]==" ":
    s[i]=""
print[s]
Problem p02848 (python)

Fixed submission:
k=int(input())
s=input()
n=len(s)
temp=""
for i in range(n):
    z=ord(s[i])+k
    if z>90:
        z-=26
    temp+=chr(z)
print(temp)

Buggy submission (verdict: Runtime Error):
k=int(input())
s=input()
n=len(s)
for i in range(n):
    z=ord(s[i]+k)
    if z>123:
        z-=27
    s[i]=chr(z)
print(s)
Problem p02911 (python)

Fixed submission:
n,k,q= list(map(int, input().split()))
lis=[k-q]*n
for i in range(q):
    a=int(input())
    a-=1
    lis[a]+=1
    
for i in range(n):
    if lis[i]>0:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
n,k,q= list(map(int, input().split()))
lis=[k]*n
for i in range(q):
    a=int(input())
    a-=1
    lis=map(lambda x: x-1, lis)
    lis[a]+=1
for i in range(n):
    if lis[i]>0:
        print("Yes")
    else:
        print("No")
Problem p03262 (python)

Fixed submission:
import fractions
a,b= list(map(int, input().split()))
i= list(map(int, input().split()))

ans=0
l=[]
for j in range(a):
    l.append(abs(b-i[j]))
for k in range(0,a):
    if k==0:
        ans=l[0]
    else:
        ans=fractions.gcd(ans,l[k])
print(ans)

Buggy submission (verdict: Runtime Error):
import math
a,b= list(map(int, input().split()))
i= list(map(int, input().split()))
i.append(b)
ans=0
l=[]
for j in range(1,a+1):
    l.append(abs(i[j]-i[j-1]))
for k in range(1,a):
    if k==1:
        ans=l[1]-l[0]
    else:
        ans=math.gcd(ans,l[k]-l[k-1])
print(ans)
Problem p03607 (python)

Fixed submission:
import collections
s=int(input())
k = [input() for i in range(s)]
c = collections.Counter(k)
z=c.values()
lst=[ e for e in z if e%2==1]
print(len(lst))

Buggy submission (verdict: Runtime Error):
s=int(input())
k=[]
for i in range(s):
    j=int(input())
    if j in k:
        k=k-j
    else:
        k.append(j)
print(len(k))
Problem p03644 (python)

Fixed submission:
n=int(input())
i=1
if n==1:
  print(1)
else:
  while n>=2**i:
  	i+=1
  print(2**(i-1))

Buggy submission (verdict: Runtime Error):
count=0
n=int(input())
while n%2=!1:
  n=n/2
  count+=1
print(count)

Buggy submission (verdict: Runtime Error):
count=0
n=int(input())
while n%2=!1:
  n=n/2
  count+=1
Problem p02719 (python)

Fixed submission:
# -*- coding: utf-8 -*-
from sys import stdin, stdout


def read():
    x0 = stdin.readline().rstrip()
    return x0


def __main__():

    n, k = map(int, read().split())

    if n == 0 or k == 1:
        r = 0
    else:
        r = n % k
        if abs(r-k) < r:
            r = abs(r-k)

    print(r)
    
__main__()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
from sys import stdin, stdout


def read():
    x0 = stdin.readline().rstrip()
    return x0


def __main__():

    n, k = map(int, read().split())

    if n == 0 or k == 1:
        r = 0
    else:
        d = abs(n-k)
        r = n % d
        if abs(r-d) < r:
            r = abs(r-d)

    print(r)

__main__()
Problem p02866 (python)

Fixed submission:
# -*- coding: utf-8 -*-
n1 = int(input()) - 1
d = list(map(int, input().strip().split()))
mod = 998244353
if d[0] != 0 or 0 in d[1:]:
    print(0)
else:
    max_path = max(d)
    flag = True
    v = [0 for i in range(max_path)]
    for i in d[1:]:
        v[i-1] += 1

    if 0 in v:
        flag = False

    if flag:
        num = 1
        hh = 1

        for h in v:
            num *= hh ** h
            num = num % mod
            hh = h

        print(num)

    else:
        print(0)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n1 = int(input()) - 1
d = list(map(int, input().strip().split()))
mod = 998244353
if d[0] != 0:
    print(0)
else:
    max_path = max(d)
    flag = True
    v = [0 for i in range(max_path)]
    for i in d[1:]:
        v[i-1] += 1

    if 0 in v:
        flag = False

    if flag:
        num = 1
        hh = 1
        import math
        for h in range(len(v)):
            if hh == 1:
                pass
            elif v[h] == 1:
                num *= hh
            elif h < hh:
                num *= hh * (v[h] + 1)
            else:
                cnk = 0
                for i in range(hh):
                    cnk += math.factorial(hh)/math.factorial(h)/math.factorial(hh - h)

                num *= int(cnk)

            hh = v[h]

            num = num % mod

        print(num)

    else:
        print(0)
Problem p02882 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import math
a, b, x = map(int, input().split())
if x <= a*a*b/2: print(90 - math.degrees(math.atan(2*x/(a*b*b))))
elif x == a*a*b: print('0')
else: print(90 - math.degrees(math.atan(a**3/(2*(a*a*b-x)))))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import math
a, b, x = map(int, input().split())
if x <= a*a*b/2: print(90 - math.degrees(math.atan(2*x/(a*b*b))))
else: print(90 - math.degrees(math.atan(a**3/(2*(a*a*b-x)))))
Problem p02883 (python)

Fixed submission:
# -*- coding: utf-8 -*-
 
n, k = map(int, input().split())
A = [int(i) for i in input().split()]
A.sort(reverse = True)
F = [int(i) for i in input().split()]
F.sort()
"""
n = 11
k = 14
A = [1,1,2,3,3,4,5,5,5,6,9]
F = [9,9,8,8,7,6,4,3,3,2,2]
"""

 
P = [A[i]*F[i] for i in range(n)]
sum_A = sum(A)
 
def b(p):
    result = 0
    for i in range(n):
        if P[i] > p:
            r = (P[i] - p) // F[i]
            if P[i] - r * F[i] > p:
                r += 1
            result += r
    return result
 
if sum_A <= k: print('0')
else: 
    left = 0
    right = max(P)
    middle = int((left + right) / 2)
    bm = b(middle)
    
    
    
    while right - left > 1:
        
        if bm > k: left = middle
        else: right = middle
            
        middle = int((left + right) / 2)
        bm = b(middle)
 
    if b(left) <= k: print(left)
    else: print(right)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
A = sorted([int(i) for i in input().split()])
F = sorted([int(i) for i in input().split()], reverse = True)
 
P = [A[i]*F[i] for i in range(n)]
 
def b(p):
    result = 0
    for i in range(n):
        result += A[i] - p / F[i]
    return result
 
if sum(A) <= k: print('0')
else: 
    left = 0
    right = max(P)
    middle = (left + right) / 2
    bm = b(middle)
    while right - left > 1:
        
        if bm > k: left = middle
        else: right = middle
        
        middle = (left + right) / 2
        bm = b(middle)
    
    if b(int(left)) == k: print(int(left))
    elif: b(int(right)) <= k: print(int(right))
    else: print(int(right) + 1)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
n, k = map(int, input().split())
A = sorted([int(i) for i in input().split()])
F = sorted([int(i) for i in input().split()], reverse = True)
P = [A[i]*F[i] for i in range(n)]
min_list = sorted(list(set(P)))
if sum(A) <= k: print('0')
else:
    new_P = [0 for i in range(n)]
    i=0
    while k > sum(new_P):
        print(new_P)
        new_min = min_list[i]
        i += 1
        for j in range(n):
            if (P[j] - new_min) > 0: new_P[j] = (P[i] - new_min) // F[j] + 1
    print(new_min)
Problem p02642 (python)

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]

K = 10**6+1
num = [0] * K
l = [False] * K
for i in range(N):
    num[A[i]]+=1
    l[A[i]] = True

for i in range(1, K):
    if num[i]>0:
        if num[i]>1:
            l[i] = False
        j = 2
        while i*j < K:
            l[i*j] = False
            j += 1

ans = 0
for i in range(N):
    if l[A[i]]:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]

A.sort()

ans = 0

if A[0]!=A[1]:
    ans += 1

for i in range(1, N):
    flag = True
    for j in range(0, i):
        if i==j:
            continue
        if A[i] % A[j] == 0:
            flag = False
            break
    
    if flag:
        # print(i)
        ans += 1

print(ans)
Problem p02780 (python)

Fixed submission:
str_N = input().split()
N = int(str_N[0])
K = int(str_N[1])
str_p = input().split()
p = [float(str_p[i]) for i in range(N)]

ans = 0
e_sum = 0

for j in range(K):
  e_sum = e_sum + (p[j]+1)/2

ans = e_sum
for i in range(K,N):
  e_sum = e_sum + (p[i]+1)/2
  e_sum = e_sum - (p[i-K]+1)/2
  if ans<e_sum:
    ans=e_sum

print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
K = int(input())
p[N] = int(input().split())

ans = 0
e_sum = 0

for j in range(K):
  e_sum = e_sum + (p[j]+1)/2

ans = e_sum
for i in range(K,N):
  e_sum = e_sum + (p[i]+1)/2
  e_sum = e_sum - (p[i-K]+1)/2
  if ans<e_sum:
    ans=e_sum

print(ans)