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

Fixed submission:
import math
n = int(input())
m = int(math.sqrt(n)) + 1

ans = n - 1

for a in range(2, m):
  if n % a == 0:
    ans = min(ans, a + n//a - 2)
    
print(ans)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
m = int(math.sqrt(n))

ans = n - 1

for a in range(m):
  if n % a == 0:
    b = n // a
    ans = min(ans, a + b - 2)
    
print(ans)
Problem p02959 (python)

Fixed submission:
import sys
input = sys.stdin.readline
    
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
    
ans = 0
for i in range(n):
  if a[i] <= b[i]:
    ans += a[i]
    b[i] -= a[i]
    if a[i + 1] <= b[i]:
      ans += a[i + 1]
      a[i + 1] = 0
    else:
      ans += b[i]
      a[i + 1] -= b[i]
  else:
    ans += b[i] 
    
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
    
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
    
ans = 0
for i in range(n):
  if a[i] <= b[i]:
    ans += a[i]
    b[i] -= a[i]
  if a[i + 1] <= b[i]:
    ans += a[i + 1]
    a[i + 1] = 0
  else:
    ans += b[i]
    a[i + 1] -= b[i]
  else:
    ans += b[i] 
    
print(ans)
Problem p03041 (python)

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

ans = ""
for i, j in enumerate(list(s)): 
  if i == k - 1:
    ans += j.lower()
  else:
    ans += j

print(ans)

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
s = input()
print(s.replace(s[k],s[k].lower()))
Problem p03107 (python)

Fixed submission:
s = input()

one = s.count("1")
zero = s.count("0")

print(2 * min(one, zero))

Buggy submission (verdict: Runtime Error):
s = list(map(int,input()))

print(2*min(s.count(0), s.count(1))

Buggy submission (verdict: Runtime Error):
s = list(map(int,input()))

print(2*mmin(s.count(0), s.count(1))
Problem p03207 (python)

Fixed submission:
n=int(input())
p=[int(input()) for i in range(n)]
print(sum(p)-int(max(p)/2))

Buggy submission (verdict: Runtime Error):
n=int(input())
p=[input() for i in range(n)]
print(sum(p)-int(max(p)/2))
Problem p03803 (python)

Fixed submission:
a,b=map(lambda x:14 if int(x)==1 else int(x),input().split())
if a>b:s='Alice'
elif a<b:s='Bob'
else:s='Draw'
print(s)

Buggy submission (verdict: Runtime Error):
a,b=map(lambda x:14 if int(x)==1 else int(x),input().split())
if a>b:s='Alice';elif a<b:s='Bob';else:s='Draw';print(s)
Problem p02847 (python)

Fixed submission:
S = {'MON':6, 'TUE':5, 'WED':4, 'THU':3, 'FRI':2, 'SAT':1, 'SUN':7}

s = input()
print(S[s])

Buggy submission (verdict: Runtime Error):
S = {'MON':6, 'TUE':5, 'WED':4, 'THU':3, 'FRI':2, 'STA':1, 'SUN':7}

s = input()
print(S[s])

Buggy submission (verdict: Runtime Error):
S = {'MON':6, 'TUE':5, 'WED':4, 'THU':3, 'FRI':2, 'STA':1, 'SUN':7}

s = (input())
print(S[s])

Buggy submission (verdict: Runtime Error):
S = {'MON':6, 'TUE':5, 'WED':4, 'THU':3, 'FRI':2, 'STA':1, 'SUN':7}

s = str(input())
print = S[s]

Buggy submission (verdict: Runtime Error):
S = {'MON':6, 'TUE':5, 'WED':4, 'THU':3, 'FRI':2, 'STA':1, 'SUN':7}

s = input()
print = S[s]
Problem p02819 (python)

Fixed submission:
import math
N = int(input())
flag = 0
while flag == 0:
  lst = []
  for i in range(1, math.ceil(N**0.5)):
    if N%i == 0:
      if i**2 == N:
        lst.append(i)
      else:
        lst.append(i)
        lst.append(N//i)
  if len(lst) == 2:
    flag = 1
  else:
    N += 1
print(N)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
flag = 0
while flag == 0:
  lst = []
  for i in range(1, math.ceil(N**0.5)):
    if N%i == 0:
      if i**2 = N:
        lst.append(i)
      else:
        lst.append(i)
        lst.append(N//i)
  if len(lst) == 2:
    flag = 1
  else:
    N += 1
print(N)
Problem p02933 (python)

Fixed submission:
a = int(input())
s = str(input())

if a >= 3200:
  print(s)
else:
  print('red')

Buggy submission (verdict: Runtime Error):
N, Q = map(int, input().split())
lst = []
cnt = []
ans = [0]*N
for i in range(N-1):
    lst.append(sorted(list(map(int, input().split()))))
lst = sorted(lst)
print(lst)
for j in range(Q):
    cnt.append(list(map(int, input().split())))
               
for k in cnt:
    ans[k[0]-1] += k[1]
for i in lst:
    ans[i[1]-1] += ans[i[0]-1]
for a in ans:
    print(a, end=" ")
Problem p02989 (python)

Fixed submission:
N = int(input())
lst = list(map(int, input().split()))
mid = int(N/2 - 1)
lst = sorted(lst)
if lst[mid] == lst[mid+1]:
    print(0)
elif lst[mid] < lst[mid+1]:
    print(lst[mid+1]-lst[mid])

Buggy submission (verdict: Runtime Error):
N = int(input())
lst = list(map(int, input().split()))
mid = N/2 - 1
lst = sorted(lst)
if lst[mid] == lst[mid+1]:
    print(0)
elif lst[mid] < lst[mid+1]:
    print(lst[mid+1]-lst[mid]+1)
Problem p03011 (python)

Fixed submission:
lst = list(map(int, input().split()))
lst = sorted(lst)
print(lst[0] + lst[1])

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

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

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

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


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

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

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

Fixed submission:
a, b, c, d = list(input())
a = int(a)
b = int(b)
c = int(c)
d = int(d)
if 0 < 10*a + b <= 12 and 0 < c*10 + d <= 12:
    print('AMBIGUOUS')
elif (10*a + b >= 12 or a + b == 0) and 0 < c*10 + d <= 12:
    print('YYMM')
elif 0 < 10*a + b <= 12 and (c*10 + d >= 12 or c + d == 0):
    print('MMYY')
else:
    print('NA')

Buggy submission (verdict: Runtime Error):
a, b, c, d = list(input())
if 0 < 10*a + b <= 12 and 0 < c*10 + d <= 12:
    print('AMBIGUOUS')
elif 10*a + b >= 12 and 0 < c*10 + d <= 12:
    print('YYMM')
elif 0 < 10*a + b <= 12 and c*10 + d >= 12:
    print('MMYY')
else:
    print('NA')
Problem p03072 (python)

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

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

Fixed submission:
S=input()
a=["0","1"]
count=0
n=len(S)
for i in range(n):
    if S[i] == a[i%2]:
        count+=1
print(min(count,n-count))

Buggy submission (verdict: Runtime Error):
S = list(input())
l = len(S)
if l%2 == 0:
    ans = ['0', '1']*int(l/2)
else:
    ans = ['0', '1']*int(l//2 + 1)
    ans = ans[:-2]

cnt = 0
for i in range(l):
    if ans[i] != S[i]:
        cnt += 1

print(min(cnt, l-cnt))

Buggy submission (verdict: Runtime Error):
S = list(input())
l = len(S)
if l%2 == 0:
    ans = ['0', '1']*int(l/2)
else:
    ans = ['0', '1']*int(l//2 + 1)
    ans = ans1[:-2]

cnt = 0
for i in range(l):
    if ans[i] != S[i]:
        cnt += 1

print(min(cnt, l-cnt))
Problem p03075 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
if ( e - a ) <= k :
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a=input(int)
b=input(int)
c=input(int)
d=input(int)
e=input(int)
k=input(int)
if (e-a) < k :
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a=input(int)
b=input(int)
c=input(int)
d=input(int)
e=input(int)
k=input(int)
if (a-e) < k :
  print("Yay!")
else:
  print(":(")

Buggy submission (verdict: Runtime Error):
a,b,c,d,e,k=map(int,input().split())
if (a-e) < k :
  print("Yay!")
else:
  print(":(")
Problem p03108 (python)

Fixed submission:
def find(x):
    if par[x] == x:
        return x
    else:
        return find(par[x])

def unite(x, y):
    x = find(x)
    y = find(y)

    if x != y:
        if rank[x] < rank[y]:
            par[x] = y
            size[y] += size[x]
        else:
            par[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1

def same(x, y):
    return find(x) == find(y)

#初期化
n, m = map(int, input().split())
par = [0]*n
for i in range(n):
    par[i] = i #まず全ての値を根に置く
rank = [1]*n #深さ
size = [1]*n #根iにおけるグループサイズ

edge = [tuple(map(int, input().split())) for i in range(m)]
edge = edge[::-1]
for i in range(m):
    edge[i] = (edge[i][0]-1, edge[i][1]-1)

res = []
for i in range(m):
    fi = find(edge[i][0])
    se = find(edge[i][1])
    if fi == se:
        res.append(0)
    else:
        res.append(size[fi]*size[se])
        unite(fi, se)
ass = 0
for i in range(m):
    ass += res[m-1-i]
    print(ass)

Buggy submission (verdict: Runtime Error):
def find(x):
    if par[x] == x:
        return x
    else:
        return find(par[x])

def unite(x, y):
    x = find(x)
    y = find(y)

    if x != y:
        if rank[x] < rank[y]:
            par[x] = y
            size[y] += size[x]
        else:
            par[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1

def same(x, y):
    return find(x) == find(y)

#初期化
n, m = map(int, input().split())
par = [0]*n
for i in range(n):
    par[i] = i　#まず全ての値を根に置く
rank = [1]*n #深さ
size = [1]*n #根iにおけるグループサイズ

edge = [tuple(map(int, input().split())) for i in range(m)]
edge = edge[::-1]
for i in range(m):
    edge[i] = (edge[i][0]-1, edge[i][1]-1)

res = []
for i in range(m):
    fi = find(edge[i][0])
    se = find(edge[i][1])
    if fi == se:
        res.append(0)
    else:
        rs.append(size[fi]*size[se])
        unite(fi, se)
ass = 0
for i in range(m):
    ass += res[m-1-i]
    print(ass)
Problem p03135 (python)

Fixed submission:
t, x = map(int, input().split())
print(t/x)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
lst = list(map(int, input().split()))
lst.sort()
lst2 = []
for i in range(1, M):
    lst2.append(lst[i] - lst[i-1])
lst2.sort()
print(sum(lst2[0:(M-N)]))
Problem p03208 (python)

Fixed submission:
N, K = map(int, input().split())
lst = []
for i in range(N):
    x = int(input())
    lst.append(x)
lst.sort()
L = []
for i in range(N - K + 1):
    L.append(lst[i + K -1] - lst[i])
L.sort()
print(L[0])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
lst = []
for i in range(N):
    lst.append(int(input()))
lst.sort()
dif = 10**9
for i in range(N):
    if lst[i+K-1] - lst[i] < dif:
        dif = lst[i+K-1] - lst[i]
print(dif)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
lst = []
for i in range(N):
    lst.append(int(input()))
lst.sort()
dif = 10**9
for i in range(K):
    if lst[i+K-1] - lst[i] < dif:
        dif = lst[i+K-1] - lst[i]
print(dif)
Problem p03250 (python)

Fixed submission:
lst = list(map(int, input().split()))
lst.sort(reverse=True)
n = lst[0] * 10 + lst[1] + lst[2]
print(n)

Buggy submission (verdict: Runtime Error):
from collections import Counter
 
s = input()
t = input()
 
c1 = Counter(s).most_common()
c2 = Counter(t).most_common()

for i, j in zip(c1, c2):
  if i[1] != j[1]:
    print('No')
    break
else:
  print('Yes')
Problem p03315 (python)

Fixed submission:
S = list(input())
cnt = 0
for i in S:
    if i == '+':
        cnt += 1
    else:
        cnt -= 1
print(cnt)

Buggy submission (verdict: Runtime Error):
S = list(input())
cnt = 0
for i in S:
    if i == '+':
        cnt += 1
    else:
        cnt -= 1
@rint(cnt)
Problem p02881 (python)

Fixed submission:
n = int(input())
m = int( n ** 0.5) + 1
a,b = 1, 0
for i in range(2, m):
    if n % i == 0:
        a = n // i
        b = i
if b !=0:
    print(a + b - 2)
else:
    print(n - 1)

Buggy submission (verdict: Runtime Error):
n = int(input())
m = int(n ** 0.5) + 1
j = 1
for i in range(2, m):
  if n % i ==0:
    j = n // i
print(i+j -2)
Problem p03803 (python)

Fixed submission:
a, b = map(int, input().split())
if a==b:
  ans = 'Draw'
elif a==1:
  ans = 'Alice'
elif b==1:
  ans = 'Bob'
elif a>b:
  ans = 'Alice'
else:
  ans = 'Bob'
print(ans)

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
if a==b:
  print("draw")
elif a=1 or a>b
  print("Alice")
elif b=1:
  print("Bob")
else:
  print("Bob")
Problem p03253 (python)

Fixed submission:
from collections import Counter
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**5+1000
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,m=map(int, input().split())
mb=[]
while m>1:
    for i in range(2,int(m**0.5)+1):
        if m%i==0:
            mb.append(i)
            m//=i
            break
    else:
        mb.append(m)
        m//=m
mb2=Counter(mb)
    
mblist=list()
for i in mb2:
    a = cmb(mb2[i]+n-1,mb2[i],mod)
    mblist.append(a)
ans=1
for i in mblist:
    ans=(ans*i)%mod
print(ans)

Buggy submission (verdict: Runtime Error):
def framod(n,mod):
    a=1
    for i in range(1,n+1):
        a=a * i % mod
    return a

def power(n,r,mod):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod
    
def comb(n,k,mod):
    if n<0 or k<0 or n<k: return 0
    if n==0 or k==0: return 1
    a=framod(n,mod)
    b=framod(k,mod)
    c=framod(n-k,mod)
    return (a * power(b, mod-2, mod) * power(c, mod-2, mod)) % mod

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

pf={}
for i in range(2,int(m**0.5)+1):
    while m%i==0:
        pf[i]=pf.get(i,0)+1
        m//=i
if m>1:pf[m]=1
    
mblist=list()
for i in pf:
    a = comb(pf[i]+n-1,pf[i],mod)
    mblist.append(a)
ans=1
for i in mblist:
    ans=(ans*i)%mod
print(ans)
Problem p03295 (python)

Fixed submission:
n,m=map(int, input().split())
a=[list(map(int, input().split())) for i in range(m)]
a.sort()
end=n
ans=0
for i in range(m):
    if a[i][0]>=end:
        ans+=1
        end=n
    end=min(a[i][1],end)
print(ans+1)

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
a=[list(map(int, input().split())) for i in range(m)]
a.sort()
end=n
ans=0
for i in range(m):
    if a[i][0]>=end:
        ans+=1
        end=n
    end=min(a[i][1],end)
    count+=1
    #print(end,ans)
print(ans+1)
Problem p03345 (python)

Fixed submission:
a,b,c,k=map(int,input().split())
if abs(a-b)>10**18: print('Unfair')
else:
    if k%2 ==0:
        print(a-b)
    else:print(b-a)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=[]
for i in range(n):
     a.append([int(input()),i+1])
a=sorted(a,key=lambda x:x[0])

ans=0
count=0
bef=0
for i,j in a:
    if j>bef:
        count+=1
        ans=max(ans,count)
    else:
        count=1
    bef=j
print(n-ans)
Problem p03634 (python)

Fixed submission:
import sys
sys.setrecursionlimit(1000000)

n=int(input())
m=[[] for i in range(n)]
for i in range(n-1):
    a,b,c=map(int, input().split())
    m[a-1].append([b-1,c])
    m[b-1].append([a-1,c])
q,k=map(int, input().split())
    
def reach(m,d,k):
    for i in m[k]:
        if d[i[0]]==-1:
            d[i[0]]=d[k]+i[1]
            reach(m,d,i[0])
d=[-1]*n
d[k-1]=0
reach(m,d,k-1)

for i in range(q):
    x,y=map(int, input().split())
    print(d[x-1]+d[y-1])

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

n=int(input())
m=[[] for i in range(n)]
for i in range(n-1):
    a,b,c=map(int, input().split())
    m[a-1].append([b-1,c])
    m[b-1].append([a-1,c])
q,k=map(int, input().split())
    
def reach(m,d,k):
    for i in m[k]:
        if d[i[0]]==-1:
            d[i[0]]=d[k]+i[1]
            reach(m,d,i[0])
d=[-1]*n
d[k-1]=0
reach(m,d,k-1)

for i in range(q):
    x,y=map(int, input().split())
    print(d[x-1]+d[y-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
m=[[] for i in range(n)]
for i in range(n-1):
    a,b,c=map(int, input().split())
    m[a-1].append([b-1,c])
    m[b-1].append([a-1,c])
q,k=map(int, input().split())
    
def reach(m,d,k):
    for i in m[k]:
        if d[i[0]]==-1:
            d[i[0]]=d[k]+i[1]
            reach(m,d,i[0])
d=[-1]*n
d[k-1]=0
reach(m,d,k-1)

for i in range(q):
    x,y=map(int, input().split())
    print(d[x-1]+d[y-1])
Problem p03725 (python)

Fixed submission:
h,w,k=map(int, input().split())
s=[list(input()) for i in range(h)]
p=[[-1]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j]=='S':
            sta=(i,j)
np=[(1,0),(-1,0),(0,1),(0,-1)]
q={sta}
p[sta[0]][sta[1]]=0
step=0
while step<k and q:
    step+=1
    nq=set()
    while q:
        now=q.pop()
        for i,j in np:
            nx,ny=now[0]+i,now[1]+j
            if nx<0 or nx==h or ny<0 or ny==w:continue
            if s[nx][ny]=='.' and p[nx][ny]==-1:
                p[nx][ny]=step
                nq.add((nx,ny))
    q=nq.copy()

ans=10**9
for i in range(h):
    for j in range(w):
        if p[i][j]>=0:
            an=min(i,j,h-i-1,w-j-1)
            if ans>an:ans=an
print(-(-ans//k)+1)

Buggy submission (verdict: Runtime Error):
#h,w,k=map(int, input().split())
#s=[list(input()) for i in range(h)]
p=[[-1]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j]=='S':
            sta=(i,j)
np=[(1,0),(-1,0),(0,1),(0,-1)]
q={sta}
p[sta[0]][sta[1]]=0
step=0
while step<k and q:
    step+=1
    now=q.pop()
    for i,j in np:
        nx,ny=now[0]+i,now[1]+j
        if nx<0 or nx==h or ny<0 or ny==w:continue
        if s[nx][ny]=='.' and p[nx][ny]==-1:
            p[nx][ny]=step
            q.add((nx,ny))
ans=10**9
for i in range(h):
    for j in range(w):
        if p[i][j]>=0:
            ans=min(ans,i,j,h-i,w-j)
print(-(-ans//k)+1)
Problem p03767 (python)

Fixed submission:
n=int(input())
a=sorted(list(map(int, input().split())))
print(sum(a[n::2]))

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int, input().split()))
a.sort()
m=a[n:2*n]
ans=sum(m)
for i in range(0,n,2):
    if m[i]+m[i+1]<=a[2*n+i]+a[n-i-1]:
        ans+= a[2*n+i]+a[n-i-1]-m[i]-m[i+1]
    else:break
print(ans)
Problem p03776 (python)

Fixed submission:
import math
def f(a,b):
    return math.factorial(a) // (math.factorial(a - b) * math.factorial(b))

n,a,b=map(int, input().split())
v=list(map(int, input().split()))
v.sort(reverse=True)
c=0
if v[0]==v[a-1]:
    for i in range(a,min(b,v.count(v[0]))+1):
        c+=f(v.count(v[a-1]),i)
    print(sum(v[:a])/a)
    print(c)
else: 
    print(sum(v[:a])/a)
    print(f(v.count(v[a-1]),v[:a].count(v[a-1])) )

Buggy submission (verdict: Runtime Error):
import math
from collections import Counter
def f(a,b):
    return math.factorial(a) // (math.factorial(a - b) * math.factorial(b))

n,a,b=map(int, input().split())
v=list(map(int, input().split()))
v.sort(reverse=True)
c=Counter(v)
count=0
if a==1 or v[0]==v[a-1]:
    for i in range(a,min(b,c[v[0]])+1):
        count+=f(min(b,c[v[0]]),i)
    print(v[0])
    print(count)
else: 
    print(sum(v[:a])/a)
    print(f(c[v[a]],a-c[v[0]]))
Problem p02753 (python)

Fixed submission:
status = input()
if 'AB' in status or 'BA' in status:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n, a, b = map(int,input().split())
count = 0
if 1 <= (n/(a+b)):
    if a < n%(a+b):
        print ((n/(a+b)*a) +a)
    else:
        print (int(n/(a+b)*a) + int(n%(a+b)))
else:
    if a < n%(a+b):
        print (a)
    else:
        print (n%(a+b))
Problem p02753 (python)

Fixed submission:
a,b,c = input()
if a == b == c:
  print('No')
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
a,b,c = input()
if a == b && b == c:
  print(No)
else:
  print(Yes)
Problem p02990 (python)

Fixed submission:
from math import factorial as fc

MOD=10**9+7
n,k=map(int,input().split())

for i in range(1,k+1):
    if n-k+1<i:
        print(0)
        continue
    b=fc(n-k+1)//fc(i)//fc(n-k+1-i)
    r=fc(k-1)//fc(i-1)//fc(k-1-(i-1))
    print(b%MOD*r%MOD)

Buggy submission (verdict: Runtime Error):
from math import factorial as fc

MOD=10**9+7
n,k=map(int,input().split())

for i in range(1,k+1):
    b=fc(n-k+1)//fc(i)//fc(n-k+1-i)
    r=fc(k-1)//fc(i-1)//fc(k-1-(i-1))
    print(b%MOD*r%MOD)

Buggy submission (verdict: Runtime Error):
from math import factorial as fc

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

for i in range(1,k+1):
    bl=n-k+1
    br=i
    b=fc(bl)//(fc(br)*fc(bl-br))
    rl=k-1
    rr=i-1
    r=fc(rl)//(fc(rr)*fc(rl-rr))
    print(b*r%(10**9+7))

Buggy submission (verdict: Runtime Error):
from math import factorial as fc

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

for i in range(1,k+1):
    b=fc(n-k+1)//fc(i)//fc(n-k+1-i)
    r=fc(k-1)//fc(i-1)//fc(k-1-(i-1))
    print(b*r%(10**9+7))
Problem p03013 (python)

Fixed submission:
import sys
n,m=map(int,input().split())
a=set(map(int,sys.stdin))
dp=[0]*(n+1)
dp[0]=1
if 1 not in a:dp[1]=1
for i in range(2,n+1):
    if i in a:continue
    if dp[i-1]==dp[i-2]==0:break
    dp[i]=(dp[i-1]+dp[i-2])%1000000007
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
if a[0]==0:
    print(0)
    exit()

dp=[0]*(n+1)
dp[0]=1

for i in range(1,n+1):
    if i in a:
        dp[i]=0
        continue

    dp[i]=dp[i-1]
    if i>1:dp[i]+=dp[i-2]
    dp[i]%=1000000007
print(dp[-1])

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

dp=[0]*(n+1)
dp[0]=1

for i in range(1,n+1):
    if i in a:
        dp[i]=0
        continue
	if dp[i]==d[i-1]==0:break
    dp[i]=dp[i-1]
    if i>1:dp[i]+=dp[i-2]
    dp[i]%=1000000007
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
if a[0]==0:
    print(0)
    exit()

dp=[0]*(n+1)
dp[0]=1

for i in range(1,n+1):
    if i in a:
        dp[i]=0
        continue

    dp[i]=dp[i-1]
    if i>1:dp[i]+=dp[i-2]
    dp[i]%=1000000007
print(dp[-1])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
if a[0]==0:
    print(0)
    exit()

dp=[0]*(n+1)
dp[0]=1

for i in range(1,n+1):
    if i in a:
        dp[i]=0
        continue

    dp[i]=dp[i-1]
    if i>1:dp[i]+=dp[i-2]
    dp[i]%=1000000007
print(dp[-1])
Problem p03038 (python)

Fixed submission:
# 2019/07/20

from heapq import heappop,heappush,heapify

n,m=map(int,input().split())
a=list(map(int,input().split()))
heapify(a)
bc=[]
for i in range(m):
    b,c=map(int,input().split())
    hq=(-c,b)
    heappush(bc,hq)



def cg(res):

    while bc:
        c,b=heappop(bc)
        c=-c
        while b and a:
            b-=1
            v=heappop(a)
            if c>v:res+=c
            else:
                res+=v
                return res
    return res
res=0
res=cg(res)
print(sum(a)+res)

Buggy submission (verdict: Runtime Error):
# 2019/07/20

from heapq import heappop,heappush,heapify

n,m=map(int,input().split())
a=list(map(int,input().split()))
heapify(a)
bc=[]
for i in range(m):
    b,c=map(int,input().split())
    hq=(-c,b)
    heappush(bc,hq)



def cg(res):

    while bc:
        c,b=heappop(bc)
        c=-c
        while b:
            b-=1
            v=heappop(a)
            if c>v:res+=c
            else:
                res+=v
                return res
    return res
res=0
res=cg(res)
print(sum(a)+res)