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

Fixed submission:
n=int(input())
l=list(map(int,input().split()))
u=max(l)
d=0
i=0
while l[i]!=u:
  if l[i]>l[i+1]:
    d=d+abs(l[i+1]-l[i])
    l[i+1]=l[i] 
  i=i+1
r=i
for b in range(r,n):
    d=d+(u-l[b])
print(d)

Buggy submission (verdict: Runtime Error):
n=int(input())l=list(map(int,input().split()))
u=max(l)
d=0
i=0
while l[i]!=u:
  if l[i]>l[i+1]:
    d=d+abs(l[i+1]-l[i])
    l[i+1]=l[i] 
  i=i+1
r=i
for b in range(r,n):
    d=d+(u-l[b])
print(d)

Buggy submission (verdict: Runtime Error):
l=list(map(int,input().split()))
u=max(l)
d=0
i=0
while l[i]!=u:
  if l[i]>l[i+1]:
    d=d+abs(l[i+1]-l[i])
  i=i+1
r=i
else:
  for b in range(r,len(l)):
    d=d+(u-l[b])
print(d)

Buggy submission (verdict: Runtime Error):
l=list(map(int,input().split()))
u=max(l)
d=0
i=0
while l[i]!max:
  if l[i]>l[i+1]:
    d=d+abs(l[i+1]-l[i])
  i=i+1
r=i
else:
  for b in range(r,len(l)):
    d=d+(u-l[b])
print(d)

Buggy submission (verdict: Runtime Error):
l=list(map(int,input().split()))
u=max(l)
d=0
i=0
while l[i]!max:
  if l[i]<l[i+1]:
    pass
  else:
    d=d+abs(l[i+1]-l[i])
  i=i+1
r=i
else:
  for b in range(r,len(l)):
    d=d+(u-l[b])
print(d)

Buggy submission (verdict: Runtime Error):
l=list(map(int,input().split()))
u=max(l)
d=0
while l[i]!max:
  if l[i]<l[i+1]:
    pass
  else:
    d=d+abs(l[i+1]-l[i])
  i=i+1
r=i
else:
  for b in range(r,len(l)):
    d=d+(u-l[b])
print(d)
Problem p02598 (python)

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

ng = 0
ok = max(A)

while ok - ng > 1:
    cnt = 0
    l = (ok + ng) // 2
    for a in A:
        cnt += (a // l) + (a % l != 0) - 1

    if cnt <= K:
        ok = l
    else:
        ng = l
print(ok)

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

ng = 0
ok = max(a)

while ok - ng > 1:
    cnt = 0
    l = (ok + ng) // 2
    for a in A:
        cnt += (a // l) + (a % l != 0) - 1

    if cnt <= k:
        ok = l
    else:
        ng = l
print(ok)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import heapq

N, K = map(int, input().split())
a = map(int, input().split())

log_dict = defaultdict(int)
log_list = []
for i in a:
    log[i] += 1
    if -i not in log_list:
        log_list.append(-i)
        
heapq.heapify(log_list)


while True:
    l = heapq.heappop(log_list)
    if K > log_dict[l]:
        K -= log_dict[l]
        log_dict[l//2] += log_dict[l] * 2
        log_dict[l] = 0
        if l//2 not in log_list:
            heapq.heappush(log_list, l//2)

    else:
        print(int(log_dict/(K+1)))
        exit()
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_sum = [0]
for i in range(len(A)):
    a_sum.append(a_sum[-1]+A[i])
    
b_sum = [0]
for i in range(len(B)):
    b_sum.append(b_sum[-1]+B[i])

max_time = 0
b_idx = M
for i in range(len(a_sum)):
    if a_sum[i] > K:
        break
    for j in range(b_idx, -1, -1):
        if a_sum[i]+b_sum[j] <= K:
            max_time = max(max_time, i + j)
            b_idx = j
            break
print(max_time)

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

cnt = 0
while K >= 0:
    if len(a)==0 or len(b)==0:
        if len(a)==0 and len(b)==0:
            cnt += 1
            break
        elif len(a) == 0:
            K -= b.pop(0)
        elif len(b) == 0:
            K -= a.pop(0)
    else:
        if a[0] >= b[0]:
            K -= b.pop(0)
        else:
            K -= a.pop(0)
    cnt += 1
print(cnt - 1)

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

while K >= 0:
    if K < min(a[0], b[0]):
        cnt += 1
        break
        
    if len(a)==0 or len(b)==0:
        if len(a) == 0:
            K -= b.pop(0)
        elif len(b) == 0:
            K -= a.pop(0)
        else:
            cnt += 1
            break
    else:
        if a[0] <= b[0]:
            K -= a.pop(0)
        elif a[0] > b[0]:
            K -= b.pop(0)
    cnt += 1
print(cnt-1)

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

while K >= 0:
    if len(a)==0 or len(b)==0:
        if len(a) == 0:
            K -= b.pop(0)
        elif len(b) == 0:
            K -= a.pop(0)
        else:
            cnt += 1
            break
    else:
        if a[0] <= b[0]:
            K -= a.pop(0)
        elif a[0] > b[0]:
            K -= b.pop(0)
    cnt += 1
print(cnt-1)
Problem p02659 (python)

Fixed submission:
from decimal import Decimal as dec

x0, x1 = list(map(dec, input().split()))
print(int(x0*x1))

Buggy submission (verdict: Runtime Error):
x0, x1 = list(map(flaot, input().split()))
print(int(x0*x1))
Problem p02661 (python)

Fixed submission:
N = int(input())
t = N // 2
a_list = []
b_list = []
for i in range(N):
    ab = list(map(int, input().split()))
    a_list.append(ab[0])
    b_list.append(ab[1])

a_list = sorted(a_list)
b_list = sorted(b_list)

if N%2 == 1:
    a_median = a_list[t]
    b_median = b_list[t]
    print(b_median-a_median+1)
elif N%2 == 0:
    a_median = (a_list[t-1]+a_list[t])/2
    b_median = (b_list[t-1]+b_list[t])/2
    print(int(2*(b_median-a_median)+1))

Buggy submission (verdict: Runtime Error):
from decimal import Decimal

N = Decimal(input())
t = N // 2
a_list = []
b_list = []
for i in range(N):
    ab = list(map(int, input().split()))
    a_list.append(ab[0])
    b_list.append(ab[1])

if N%2 == 1:
    a_median = a_list[t]
    b_median = b_list[t]
    print(b_median-a_median+1)
elif N%2 == 0:
    a_median = (a_list[t-1]+a_list[t])/2
    b_median = (b_list[t-1]+b_list[t])/2
    print(int(2*(b_median-a_median)+1))

Buggy submission (verdict: Runtime Error):
N = int(input())
t = N // 2
a_list = []
b_list = []
for i in range(N):
    ab = list(map(int, input().split()))
    a_list.append(ab[0])
    b_list.append(ab[1])

if N%2 == 1:
    a_med = a_list[t]
    b_median = b_list[t]
    print(b_list-a_list+1)
elif N%2 == 0:
    a_median = (a_list[t-1]+a_list[t])/2
    b_median = (b_list[t-1]+b_list[t])/2
    print(int(2*(b_median-a_median)+1))

Buggy submission (verdict: Runtime Error):
N = int(input
med = N // 2
a_list = []
b_list = []
for i in range(N):
    ab = list(map(int, input().split()))
    a_list.append(ab[0])
    b_list.append(ab[1])

if N%2 == 1:
    a_med = a_list[t]
    b_median = b_list[t]
    print(b_list-a_list+1)
elif N%2 == 0:
    a_median = (a_list[t-1]+a_list[t])/2
    b_median = (b_list[t-1]+b_list[t])/2
    print(int(2*(b_median-a_median)+1))
Problem p02699 (python)

Fixed submission:
S, W = map(int, input().split())
if S <= W:
    print('unsafe')
else:
    print('safe')

Buggy submission (verdict: Runtime Error):
s, w = input()
if s <= w:
  print('unsafe')
else:
  print('safe')
Problem p02793 (python)

Fixed submission:
from functools import reduce

def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        r = x % y
        x = y
        y = r
    return y

def inv(x):
    return pow(x, MOD-2, MOD)

def lcm(a, b):
    return a * b // gcd(a, b)

def lcm_list(l:list):
    return reduce(lcm, l, 1)
  
N = int(input())
a_list = list(map(int, input().split()))
MOD = 10 ** 9 + 7

num = lcm_list(a_list) % MOD
ans = 0
for a in a_list:
    ans += (num * pow(a, MOD-2, MOD)) % MOD

print(ans%MOD)

Buggy submission (verdict: Runtime Error):
from functools import reduce

def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        r = x % y
        x = y
        y = r
    return y

def inv(x):
    return pow(x, MOD-2, MOD)

def lcm(a, b):
    return a * b * // gcd(a, b)

def addmod(a, b):
    return (a+b) % MOD
  
  
N = int(input())
a_list = list(map(int, input().split()))
MOD = 10 ** 9 + 7

l = reduce(lcm, a_list) % MOD
ans = reduce(addmod, (l//a for a in a_list))

print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        r = x % y
        x = y
        y = r
    return y

def inv(x):
    return pow(x, MOD-2, MOD)

    
N = int(input())
a_list = list(map(int, input().split()))
MOD = 10 ** 9 + 7
 
if N == 1:
    print(a_list[0])
    exit()
div = gcd(a_list[0], a_list[1])
lcm = (a_list[0] * a_list[1]) * inv(div)
 
for i in range(2, N):
    div = gcd(lcm, a_list[i])
    lcm = (lcm * a_list[i]) * inv(div)
    
ans = 0
for i in range(N):
    ans = (ans + lcm * inv(a_list[i]) % MOD
 
print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        r = x % y
        x = y
        y = r
    if y == 0:
        return 1
    return y

N = int(input())
a_list = list(map(int, input().split()))
MOD = 10 ** 9 + 7

div = gcd(a_list[0], a_list[1])
lcm = (a_list[0] * a_list[1]) // div

for i in range(2, N):
    div = gcd(lcm, a_list[i])
    lcm = (lcm * a_list[i]) // div
    
ans = 0
for i in range(N):
    ans = (ans + lcm//a_list[i]) % MOD

print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(x, y):
    if x < y:
        x, y = y, x
    if y == 1:
        return 1
    while x % y != 0:
        r = x % y
        x = y
        y = r
    return y

N = int(input())
a_list = list(map(int, input().split()))
MOD = 10 ** 9 + 7

div = gcd(a_list[0], a_list[1])
lcm = (a_list[0] * a_list[1]) // div

for i in range(2, N):
    div = gcd(lcm, a_list[i])
    lcm = (lcm * a_list[i]) // div
    
ans = 0
for i in range(N):
    ans = (ans + lcm//a_list[i]) % MOD

print(ans)

Buggy submission (verdict: Runtime Error):
def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        r = x % y
        x = y
        y = r
    return y

N = int(input())
a_list = list(map(int, input().split()))
MOD = 10 ** 9 + 7

div = gcd(a_list[0], a_list[1])
lcm = (a_list[0] * a_list[1]) // div

for i in range(2, N):
    div = gcd(lcm, a_list[i])
    lcm = (lcm * a_list[i]) // div
    
ans = 0
for i in range(N):
    ans = (ans + lcm//a_list[i]) % MOD

print(ans)
Problem p03013 (python)

Fixed submission:
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
MOD = 10**9 + 7
 
dp = [0] * (N+1)
dp[0] = 1
dp[1] = 1 if 1 not in a else 0
 
a = set(list(range(2,N+1))) - set(a)
for i in a:
    dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[N] % MOD)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
MOD = 10**9 + 7

dp = [0] * (N+1)
dp[0] = 1
dp[1] = 1 if 1 not in a else 0

a = list(set(range(2, N+2)) - set(a))
for i in a:
    dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[N] % MOD)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
MOD = 10**9 + 7

dp = [0] * (N+1)
dp[0] = 1
dp[1] = 1 if 1 not in a else 0

a = set(range(2, N+2)) - set(a)
for i in a:
    dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[N] % MOD)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
a.sort()
MOD = 10**9 + 7

dp = [0] * (N+1)
dp[0] = 1
dp[1] = 1 if a[0]!=1 else 0

a = [i for i in range(2, N+1) if i not in a]
for i in a:
    dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[N] % MOD)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
a.sort()
MOD = 10**9 + 7

dp = [0] * (N+1)
dp[0] = 1
dp[1] = 1 if a[0]!=1 else 0

a = [i for i in range(2, N+1) if i in a]
for i in a:
    dp[i] = (dp[i-1] + dp[i-2]) % MOD
print(dp[N] % MOD)
Problem p02580 (python)

Fixed submission:
h,w,m=map(int,input().split())
g=[0]*h
l=[0]*w
b=[]
for i in range(m):
  x,y=map(int,input().split())
  g[x-1]+=1
  l[y-1]+=1
  b.append((x-1,y-1))
mxg=max(g);mxl=max(l)
mg=set([i for i,x in enumerate(g) if x==mxg])
ml=set([i for i,x in enumerate(l) if x==mxl])
c=0
for x,y in b:
  if x in mg and y in ml:
    c+=1
print(mxg+mxl-(c==(len(mg)*len(ml))))

Buggy submission (verdict: Runtime Error):
h,w,m=map(int,input().split())
g=[0]*h
l=[0]*w
b=[[0]*w for i in range(h)]
for i in range(m):
  x,y=map(int,input().split())
  g[x-1]+=1
  l[y-1]+=1
  b[x-1][y-1]=1
mg=[i for i,x in enumerate(g) if x==max(g)]
ml=[i for i,x in enumerate(l) if x==max(l)]
for i in mg:
  for j in ml:
    if b[i][j]==0:
      print(max(g)+max(l))
      exit()
print(max(g)+max(l)-1)

Buggy submission (verdict: Runtime Error):
h,w,m=map(int,input().split())
g=[0]*h
l=[0]*w
b=[[0]*w for i in range(h)]
for i in range(m):
  x,y=map(int,input().split())
  g[x-1]+=1
  l[y-1]+=1
  b[x-1][y-1]=1
mg=[i for i,x in enumerate(g) if x==max(g)]
ml=[i for i,x in enumerate(l) if x==max(l)]
for i in mg:
  for j in ml:
    if b[i][j]==0:
      print(max(g)+max(l))
      exit()
print(max(g)+max(l)-1)
Problem p02659 (python)

Fixed submission:
from fractions import Fraction
a,b=input().split()
a=Fraction(int(a),1)
b=Fraction(int(b[0]+b[2:]),100)
print(int(a*b))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
print(int(a*b))
Problem p02759 (python)

Fixed submission:
n=int(input())
print(n//2+n%2)

Buggy submission (verdict: Runtime Error):
n=int(input()
print(n//2+n%2)
Problem p02766 (python)

Fixed submission:
n,k=map(int,input().split())
c=0
while n:
  c+=1
  n=n//k
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
k=int(input())
c=0
while n:
  c+=1
  n=n//k
print(c)
Problem p02781 (python)

Fixed submission:
n=int(input())
k=int(input())
d=len(str(n))
from math import factorial as f
def c(n):
  if n<2:
    return 0
  else:
    return f(n)//(f(n-2)*f(2))
def kk(n):
  dd=len(str(n))
  s=9*(dd-1)
  s+=int(str(n)[0])
  return s
def kkk(n):
  d=len(str(n))
  s=81*(d-1)*(d-2)//2
  s+=9*(d-1)*(int(str(n)[0])-1)
  s+=kk(int(str(n)[1:]))
  return s

if d==1 and k!=1:
  print(0)
else:
  if k==1:
    ans=kk(n)
  elif k==2:
    ans=kkk(n)
  else:
    t=0
    for i in range(2,d-1):
      t+=c(i)
    ans=729*t
    ans+=81*c(d-1)*(int(str(n)[0])-1)
    ans+=kkk(int(str(n)[1:]))
  print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
k=int(input())
d=len(str(n))
from math import factorial as f
def c(n):
  if n<2:
    return 0
  else:
    return f(n)//(f(n-2)*f(2))
def kk(n):
  dd=len(str(n))
  s=9*(dd-1)
  s+=int(str(n)[0])
  return s
def kkk(n):
  d=len(str(n))
  s=81*(d-1)*(d-2)//2
  s+=9*(d-1)*(int(str(n)[0])-1)
  s+=kk(int(str(n)[1:]))
  return s

if k==1:
  ans=kk(n)
elif k==2:
  ans=kkk(n)
else:
  t=0
  for i in range(2,d-1):
    t+=c(i)
  ans=729*t
  ans+=81*c(d-1)*(int(str(n)[0])-1)
  ans+=kkk(int(str(n)[1:]))
print(ans)
Problem p02785 (python)

Fixed submission:
n,k=map(int,input().split())
h=list(map(int,input().split()))
if n<=k:
  print(0)
else:
  h.sort()
  print(sum(h[:n-k]))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
if n<=k:
  print(0)
else:
  h.sort()
  print(sum(h[:n-k])
Problem p02948 (python)

Fixed submission:
import heapq as h
n,m=map(int, input().split())
a=[list(map(int, input().split())) for _ in range(n)]
a.sort(key=lambda x:x[0])
hq=[]
x=0;d=0
for i in range(1,m+1):
  while d<n and a[d][0]<=i:
    h.heappush(hq,-a[d][1])
    d+=1
  if len(hq):
    x+=-h.heappop(hq)
print(x)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
l=[]
for i in range(n):
  a,b=map(int,input().split())
  if a<=m:
    l.append([a,b])
n=len(l)
l.sort()
p=0
t=l[0][0]
for i in range(n):
  if l[i][0]!=t:
    p+=l[i-1][1]
    t=l[i][0]
print(p)
Problem p02959 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=0
for i in range(n):
  c+=min(a[i],b[i])
  d=b[i]-a[i]
  if d>0:
    c+=min(d,a[i+1])
  a[i+1]=min(a[i+1],max(0,a[i+1]-d))
print(c)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=0
for i in range(n-1):
  if a[i]<=b[i]:
    c+=a[i]
    d=b[i]-a[i]
    b[i+1]+=d
  else:
    c+=b[i]
if b[n-1]=>a[n-1]:
  c+=a[n-1]
  x=b[n-1]-a[n-1]
  c+=min(a[n],x)
else:
  c+=b[n-1]
print(c)
Problem p02987 (python)

Fixed submission:
import collections as c
s=input()
a=c.Counter(s)
if str(a.values())=='dict_values([2, 2])':
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
import collections as c
s=input()
a=c.Counter(s)
if a.value()==[2,2]:
  print('Yes')
else:
  print('No')
Problem p02989 (python)

Fixed submission:
n=int(input())
d=sorted(list(map(int,input().split())))
print(d[n//2]-d[n//2-1])

Buggy submission (verdict: Runtime Error):
n=int(input())
d=sorted(list(map(int,input().split())))
print(d[n]-d[n-1])
Problem p02990 (python)

Fixed submission:
n,k=map(int,input().split())
import math as m
def c(t,r):
    if t>=r:
      return (m.factorial(t)//(m.factorial(t-r)*m.factorial(r)))%(10**9+7)
    else:
      return 0
for i in range(1,k+1):
  a=c(k-1,i-1)
  b=c(n-k+1,i)
  print((a*b)%(10**9+7))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
import math as m
def c(t,r):
    return (m.factorial(t)//(m.factorial(t-r)*m.factorial(r)))%(10**9+7)
for i in range(1,k+1):
  a=c(k-1,i-1)
  b=c(n-k+1,i)
  print((a*b)%(10**9+7))
Problem p03013 (python)

Fixed submission:
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=10**9+7
d=[mod]*(n+1)
d[0]=1;d[1]=1
for i in a:
  d[i]=0
for i in range(2,n+1):
  d[i]=min(d[i],(d[i-1]+d[i-2])%mod)
print(d[n])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=10**9+7
d=[mod]*(n+1)
d[0]=1;d[1]=1
for i in a:
  d[a]=0
for i in range(2,n+1):
  d[i]=min(d[i],(d[i-1]+d[i-2])%mod)
print(d[n])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
mod=10**9+7
d=[0]*(n+1)
d[0]=1 
if a[0]==1:
  d[1]=0
else:
  d[1]=1
for i in range(2,n+1):
  if i not in a:
    d[i]=(d[i-1]+d[i-2])%mod
print(d[n])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[int(input()) for i in range(m)]
d=[0]*(n+1)
d[0]=1 
if a[0]==1:
  d[1]=0
else:
  d[1]=1
for i in range(2,n+1):
  if i in a:
    d[i]=0
  else:
    d[i]=d[i-1]+d[i-2]
print(d[n])
Problem p03038 (python)

Fixed submission:
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
b=[list(map(int,input().split())) for i in range(m)]
b.sort(key=lambda x:x[1])
p=0
c=[]
for i in b[::-1]:
  if p>n:
    break
  c+=[i[1]]*i[0]
  p+=i[0]
n=min(len(c),n)
c=c[:n]
m=sum(a)
x=m
for i in range(n):
  m=m-a[i]+c[i]
  x=max(x,m)
print(x)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
b=[list(map(int,input().split())) for i in range(m)]
b.sort(key=lambda x:x[1])
p=0
c=[]
for i in b:
  if p>n:
    break
  c+=[i[1]]*i[0]
  p+=i[0]
c=c[:n]
m=sum(a)
x=m
for i in range(n):
  m=m-a[i]+c[i]
  x=max(x,m)
print(x)
Problem p03072 (python)

Fixed submission:
n=int(input())
h=list(map(int,input().split()))
c=1
if len(h)>1 and h[0]<=h[1]:
  c=2
for i in range(2,n):
  if h[i]>=max(h[0:i]):
    c+=1
print(c)

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

Buggy submission (verdict: Runtime Error):
n=int(input())
h=list(map(int,input().split()))
c=1
for i in range(1,n):
  if h[i]>=max(h[0:i-1]):
    c+=1
print(c)
Problem p03073 (python)

Fixed submission:
s=input()
l=len(s)
a=[]
b=[]
i=0
for _ in range(l//2):
  a.append(s[i])
  b.append(s[i+1])
  i+=2
if l%2==1:
  a.append(s[l-1])
a0=a.count('0')
a1=a.count('1')
b0=b.count('0')
b1=b.count('1')
x=max(a0+b1,a1+b0)
print(l-x)

Buggy submission (verdict: Runtime Error):
s=input()
l=len(s)
a=[]
b=[]
i=0
for _ in range(l//2):
  a.append(s[i])
  b.append(s[i+1])
  i+=2
if l%2==1:
  a.append(s[l-1])
a0=a.count('0)
a1=a.count('1')
b0=b.count('0')
b1=b.count('1')
x=max(a0+b1,a1+b0)
print(l-x)
Problem p03107 (python)

Fixed submission:
s=input()
print(2*min(s.count('0'),s.count('1')))

Buggy submission (verdict: Runtime Error):
s=input()
c=0
while n>0:
  n=s.count('01')
  s=s.replace('01','')
  c=c+n
  n=s.count('10')
  s=s.replace('10','')
  c=c+n
print(c)

Buggy submission (verdict: Runtime Error):
s=input()
c=0
while n>0:
  n=s.count('01')
  s.replace('01','')
  c=c+n
  n=s.count('10')
  s.replace('10','')
  c=c+n
print(c)
Problem p03127 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
while len(a)>1:
  a.sort()
  for i in range(1,n):
    a[i]=a[i]%a[0]
  a=[i for i in a if not i==0]
  n=len(a)
print(a[0])

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
while len(a)>1:
  a.sort()
  for i in range(1,n):
    a[i]=a[i]%a[0]
  a.replace(0,'')
  n=len(a)
print(a[0])
Problem p03186 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a+b>=c-1:
  print(b+c)
else:
  print(2*b+a+1)

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

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
a.append(0)
b=[]
for i in range(n):
  if a[i]!=a[i+1]:
    b.append(a[i])
n=len(b)
s=n
for i in range(n-1):
  if b[i]!=b[i+1]:
    s=i
    if b[s]<b[s+1]:
      f=0
    else:
      f=1
    break
p=1
for i in range(s+1,n-1):
  if f==0:
    if b[i]>b[i+1]:
      p+=1
      if i==n-2 or b[i+1]>b[i+2]:
        f=1
      else:
        f=0
  else:
    if b[i]<b[i+1]:
      p+=1
      if i==n-2 or b[i+1]>b[i+2]:
        f=1
      else:
        f=0
print(p)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
s=n
for i in range(n-1):
  if a[i]!=a[i+1]:
    s=i
    f=0 if a[s]<a[s+1] else f=1
    break
p=0
for i in range(s+1,n-1):
  if f==0:
    if a[i]>a[i+1]:
      p+=1
      f=1
  else:
    if a[i]<a[i+1]:
      p+=1
      f=0
print(p)
Problem p03774 (python)

Fixed submission:
n,m=map(int, input().split())
s=[list(map(int, input().split())) for _ in range(n)]
o=[list(map(int, input().split())) for _ in range(m)]
for a,b in s:
  k=[]
  for c,d in o:
    k.append(abs(a-c)+abs(b-d))
  print(k.index(min(k))+1)

Buggy submission (verdict: Runtime Error):
n,m=map(int, input().split())
s=[list(map(int, input().split())) for _ in range(n)]
c=[list(map(int, input().split())) for _ in range(m)]
for a,b in s:
  k=[]
  for c,d in c:
    k.append(abs(a-c)+abs(b-d))
  print(k.index(min(k))+1)
Problem p03785 (python)

Fixed submission:
n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]+[10**10]
t.sort()
b=1
p=0
if c==1:
  print(n)
  exit()
while p<n:
  l=t[p]+k
  pp=1
  f=1
  while pp<c and f:
    p+=1
    if t[p]<=l:
      pp+=1
      if pp==c:
        p+=1
    else:
      f=0
  if p<n:
    b+=1
print(b)

Buggy submission (verdict: Runtime Error):
n,c,k=map(int,input().split())
t=[int(input()) for _ in range(n)]+[10**9]
t.sort()
b=1
p=0
while p<n:
  l=t[p]+k
  pp=1
  f=1
  while pp<c and f:
    p+=1
    if t[p]<=l:
      pp+=1
      if pp==c:
        p+=1
    else:
      f=0
  if p<n:
    b+=1
print(b)
Problem p03804 (python)

Fixed submission:
n,m=map(int,input().split())
x='No'
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
def c(i,j):
  global m
  global a
  global b
  for k in range(m):
    for l in range(m):
      if b[k][l]!=a[i+k][j+l]:
        return 0
  return 1
for i in range(n-m+1):
  for j in range(n-m+1):
    if c(i,j)==1:
      x='Yes'
      break
print(x)

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
x='No'
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
def c(i,j):
  global m,global a, global b
  for k in range(m):
    for l in range(m):
      if b[k][l]!=a[i+k][j+l]:
        return 0
  return 1
for i in range(n-m+1):
  for j in range(n-m+1):
    if c(i,j)==1:
      x='Yes'
      break
print(x)