Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = list(str(input()))
if n[0]==n[1]==n[2] or n[2]==n[1]==n[3]
    print("Yes")
else:
    print("No")


Fixed submission:
n = input()
if n[0]==n[1]==n[2] or n[2]==n[1]==n[3]:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
N = int(input())

if N == 0:
    print(2)
elif N == 1:
    print(1)
    exit()

L0 = 2; L1 = 1
for _ in range(N-2):
    L2 = L1 + L0
    L1, L0 = L2, L1
print(L2)    


Fixed submission:
N = int(input())

if N == 0:
    print(2)
elif N == 1:
    print(1)
    exit()

L0 = 2; L1 = 1
for _ in range(2, N+1):
    L2 = L1 + L0
    L1, L0 = L2, L1
print(L2)
Buggy python submission (verdict: Runtime Error):
a, b, c = input().split()
if a == b:
    print(C)
elif a == c:
    print(b)
else:
    print(a)


Fixed submission:
a, b, c = map(int,input().split())
if a == b:
    print(c)
elif a == c:
    print(b)
else:
    print(a)
Buggy python submission (verdict: Runtime Error):
n = int(input())
cnt_list = []
for i in range(1, n):
    cnt = 0
    while i % 2 == 0:
        i = i / 2
        cnt += 1
    cnt_list.append(cnt)
print(max(cnt_list))


Fixed submission:
n = int(input())
cnt_list = []
for i in range(1, n+1):
    cnt = 0
    while i % 2 == 0:
        i = i / 2
        cnt += 1
    cnt_list.append(cnt)
print(2**max(cnt_list))
Buggy python submission (verdict: Runtime Error):
strList = [input().split()]
rgb = int(join(strList))
if rgb % 4 == 0:
    print("Yes")
else:
    print("No")


Fixed submission:
r, g, b = input().split()
rgb = r + g + b
if int(rgb) % 4 == 0:
    print("YES")
else:
    print("NO")
Buggy python submission (verdict: Runtime Error):
K, S = map(int,input())
ans = 0
for x in range(K+1):
    for y in range(K+1):
        if 0 <= S - x - y <= K:
            ans += 1
print(ans)


Fixed submission:
K, S = map(int,input().split())
ans = 0
for x in range(K+1):
    for y in range(K+1):
        if 0 <= S - x - y <= K:
            ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
x = ""
for i in range(3):
    S = input()
    char_list = list(S)
    x = x + char_list[i]
print x

Fixed submission:
x = ""
for i in range(3):
    S = input()
    char_list = list(S)
    x = x + char_list[i]
print(x)
Buggy python submission (verdict: Runtime Error):
N = input()
S = input()
char_list = list(S.split(" "))
result = "Three"
for i in range(N):
    if char_list[i] == "Y":
        result = "Four"
print(result)

Fixed submission:
N = int(input())
S = input()
char_list = list(S.split(" "))
result = "Three"
for i in range(N):
    if char_list[i] == "Y":
        result = "Four"
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

a, b, n = map(int, input().replace("\n","").split())

ans = 0

#bがnよりも大きい時
if b > n:
    ans = int(a*n/b)
    print(ans)
    exit()

#b==nのときは、終了間際の2個だけ比較する
elif b == n:
    for i in range(n-1,n+1):
        tmpans = int(a*i/b) - (a*int(i/b))
        if tmpans >= ans:
            ans = tmpans
    print(ans)
    exit()

#これ以外の時は、nはb値ごとにスキップする。
else:
    for i in range(1,n+1,b):
        tmpans = int(a*(i-2)/b) - (a*int((i-2)/b))
        if tmpans >= ans:
            ans = tmpans

print(ans)

Fixed submission:
import sys
input = sys.stdin.readline

a, b, n = map(int, input().replace("\n","").split())

ans = 0

#bがnよりも大きい時
if b > n:
    ans = int(a*n/b)
    print(ans)
    exit()

#b==nのときは、終了間際の2個だけ比較する
elif b == n:
    for i in range(n-1,n+1):
        tmpans = int(a*i/b) - (a*int(i/b))
        if tmpans >= ans:
            ans = tmpans
    print(ans)
    exit()

#これ以外の時は、nはb値ごとにスキップする。
else:
    for i in range(int(n/b),n+1,b):
        tmpans = int(a*(i-2)/b) - (a*int((i-2)/b))
        if tmpans >= ans:
            ans = tmpans

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline

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

for i in range(1,n+1):
    print(a.count(i))

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

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

"""
for i in range(1,n+1):
    print(a.count(i))
"""

S = Counter(a)

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

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
from collections import Counter

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

for i in range(1,n+1):
    print(a.count(i))

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

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

"""
for i in range(1,n+1):
    print(a.count(i))
"""

S = Counter(a)

for i in range(1,n+1):
    print(S[i])
Buggy python submission (verdict: Time Limit Exceeded):
import math
from functools import reduce
import sys
input = sys.stdin.readline  # 改行コード「\n」を呼んでしまうため、文字数など、注意！！


def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

# print(gcd(100,20,10))

k = int(input().replace("\n",""))
ans = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans += gcd(a,b,c)

print(ans)

Fixed submission:
import math
from functools import reduce
import sys
input = sys.stdin.readline  # 改行コード「\n」を呼んでしまうため、文字数など、注意！！


def gcd(*numbers):
    return reduce(math.gcd, numbers)

# print(gcd(100,20,10))

k = int(input().replace("\n",""))
ans = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            ans += gcd(a,b,c)

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline  # 改行コード「\n」を呼んでしまうため、文字数など、注意！！

n = int(input().replace("\n",""))
s = input().replace("\n","")

anslist = []
ans = 0

for i in range(1000):
    if i < 10:
        chk = '00' + str(i)
    elif i < 100:
        chk = '0' + str(i)
    else:
        chk = str(i)

    for j in range(len(s)):
        if s[j] == chk[0]:
            for k in range(j+1, len(s)):
                if s[k] == chk[1]:
                    for l in range(k+1, len(s)):
                        if s[l] == chk[2]:
                            # print(chk)
                            anslist.append(chk)
            continue
ans = len(set(anslist))
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline  # 改行コード「\n」を呼んでしまうため、文字数など、注意！！

n = int(input().replace("\n",""))
s = input().replace("\n","")

ans = 0
for i in range(1000):
    i = str(i).zfill(3)
    x = s.find(i[0])
    y = s.find(i[1], x+1)
    z = s.find(i[2], y+1)
    if x != -1 and y != -1 and z != -1:
        ans += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline  # 改行コード「\n」を呼んでしまうため、文字数など、注意！！

n = int(input().replace("\n",""))
s = input().replace("\n","")

anslist = []
ans = 0

for i in range(1000):
    if i < 10:
        chk = '00' + str(i)
    elif i < 100:
        chk = '0' + str(i)
    else:
        chk = str(i)

    for j in range(len(s)):
        if s[j] == chk[0]:
            for k in range(j+1, len(s)):
                if s[k] == chk[1]:
                    for l in range(k+1, len(s)):
                        if s[l] == chk[2]:
                            # print(chk)
                            anslist.append(chk)
            continue
ans = len(set(anslist))
print(ans)

Fixed submission:
import sys
input = sys.stdin.readline  # 改行コード「\n」を呼んでしまうため、文字数など、注意！！

n = int(input().replace("\n",""))
s = input().replace("\n","")

ans = 0
for i in range(1000):
    i = str(i).zfill(3)
    x = s.find(i[0])
    y = s.find(i[1], x+1)
    z = s.find(i[2], y+1)
    if x != -1 and y != -1 and z != -1:
        ans += 1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math

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

bandc = b // c 
bandd = b // d
bandcd = b // ((c*d) // math.gcd(c,d))

aandc = a // c 
aandd = a // d
aandcd = a // ((c*d) // math.gcd(c,d))

totalb = b - bandc - bandd + bandcd
totala = a - aandc - aandd + aandcd
#print(totalb)
#print(totala)
print(totalb-totala)

Fixed submission:
#最大公約数
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

#最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

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

bandc = b // c 
bandd = b // d
bandcd = b // lcm(c,d)

aandc = a // c 
aandd = a // d
aandcd = a // lcm(c,d)

totalb = b - bandc - bandd + bandcd
totala = a - aandc - aandd + aandcd
#print(totalb)
#print(totala)
if (a % c != 0) and (a % d != 0):
    ans = totalb - totala + 1
else:
    ans = totalb - totala

print(ans)
Buggy python submission (verdict: Runtime Error):

r,g,b,n = map(int,input().split())
ans = 0

for i in range(n+1):
    for j in range(n+1):
            if (r*i + g*j + b*(n+1 - i - j)) == n:
                ans += 1
print(ans)

Fixed submission:
import math

n,k = map(int,input().split())
print(n-k+1)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
h=list(map(int,input().split()))
lis=[]

for i in range(m):
    a,b=map(int,input().split())
    ha=h[a-1]
    hb=h[b-1]
    if ha==hb:
        if a not in lis:
            lis.append(a)
        if b not in lis:
            lis.append(b)
    if ha>hb:
        if b not in lis:
            lis.append(b)
    else:
        if a not in lis:
            lis.append(a)

print(n-len(lis))


Fixed submission:
n,m=map(int,input().split())
h=list(map(int,input().split()))
lis=[]

for i in range(m):
    a,b=map(int,input().split())
    ha=h[a-1]
    hb=h[b-1]
    if ha==hb:
        lis.append(a)
        lis.append(b)
    if ha>hb:
        lis.append(b)
    else:
        lis.append(a)

print(n-len(list(set(lis))))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
lis=[]
for i in range(n):
    a=input()
    if a not in lis:
        lis.append(a)

print(len(lis))


Fixed submission:
n=int(input())
lis=[]
for i in range(n):
    a=input()
    lis.append(a)

m=0
lis.sort()
for i in range(n-1):
    if lis[i]==lis[i+1]:
        m+=1

print(int(n-m))
Buggy python submission (verdict: Time Limit Exceeded):
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]=-a[i]
for i in range(m):
    heapq.heapify(a)
    a[0]=-(-a[0]//2)
ans=0
for i in range(n):
    ans+=a[i]
print(-ans)


Fixed submission:
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
lis=[]
for i in range(n):
    heapq.heappush(lis,-a[i])
for i in range(m):
    b=(heapq.heappop(lis)*(-1)//2)*(-1)
    heapq.heappush(lis,b)
    #print(lis)
ans=0
#print(lis)
for i in range(n):
    ans+=lis[i]
print(-ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(m):
    a.sort()
    a[n-1]=a[n-1]//2
ans=0
for i in range(n):
    ans+=a[i]
print(ans)


Fixed submission:
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
lis=[]
for i in range(n):
    heapq.heappush(lis,-a[i])
for i in range(m):
    b=(heapq.heappop(lis)*(-1)//2)*(-1)
    heapq.heappush(lis,b)
    #print(lis)
ans=0
#print(lis)
for i in range(n):
    ans+=lis[i]
print(-ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(m):
    a.sort()
    a[n-1]=a[n-1]//2
ans=0
for i in range(n):
    ans+=a[i]
print(ans)


Fixed submission:
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
lis=[]
for i in range(n):
    heapq.heappush(lis,-a[i])
for i in range(m):
    b=(heapq.heappop(lis)*(-1)//2)*(-1)
    heapq.heappush(lis,b)
    #print(lis)
ans=0
#print(lis)
for i in range(n):
    ans+=lis[i]
print(-ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(m):
    a.sort()
    a[n-1]=a[n-1]//2

ans=0
for i in range(n):
    ans+=a[i]
print(ans)


Fixed submission:
import heapq
n,m=map(int,input().split())
a=list(map(int,input().split()))
lis=[]
for i in range(n):
    heapq.heappush(lis,-a[i])
for i in range(m):
    b=(heapq.heappop(lis)*(-1)//2)*(-1)
    heapq.heappush(lis,b)
    #print(lis)
ans=0
#print(lis)
for i in range(n):
    ans+=lis[i]
print(-ans)
Buggy python submission (verdict: Runtime Error):
a=input().split()
for i in range(3):
    a[i]=int(a[i])

b=int(a[2]-a[0]+a[1])
if b>0:
    print(b):
else:
    print(0)


Fixed submission:
a=input().split()
for i in range(3):
    a[i]=int(a[i])

b=a[2]-a[0]+a[1]
if b>0:
    print(int(b))
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
a=int(input())
b=len(str(a))

ans=0

if b%2==0:
    for i in range(int(b/2)):
        c=1+i*2
        ans+=(10**c-1)

else:
    ans+=(a-(10**(b-1)))
    for i in range((b-1)/2):
        e=1+i*2
        ans+=(10**c-1)

print(int(ans))


Fixed submission:
a=int(input())
b=len(str(a))

ans=0

if b%2==0:
    for i in range(int(b/2)):
        c=1+i*2
        ans+=(10**c-(10**(c-1)))

else:
    ans+=(a-(10**(b-1))+1)
    for i in range(int((b-1)/2)):
        e=1+i*2
        ans+=(10**e-(10**(e-1)))

print(int(ans))
Buggy python submission (verdict: Runtime Error):
lis=list(map(int,input().split())
a=lis[0]+lis[1]
if a%2==0:
    print(int(a/2))
else:
    print("IMPOSSIBLE")


Fixed submission:
lis=list(map(int,input().split()))
a=lis[0]+lis[1]
if a%2==0:
    print(int(a/2))
else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Time Limit Exceeded):
lr=input().split()
l=int(lr[0])
r=int(lr[1])

mod=2018
for i in range(r-l):
    x=r-l-i
    for j in range(x):
        a=(l+j)*(r-i)
        b=a%2019
        if b<mod:
            mod=b

print(mod)


Fixed submission:
lr=input().split()
l=int(lr[0])
r=int(lr[1])

mod=2018
for i in range(r-l):
    x=r-l-i
    if mod==0:
        break
    for j in range(x):
        if (l+j)%2019==0 or (r-i)%2019==0:
            mod=0
            break
        else:
            a=(l+j)*(r-i)
            b=a%2019
            if b<mod:
                mod=b

print(mod)

Buggy python submission (verdict: Time Limit Exceeded):
lr=input().split()
l=int(lr[0])
r=int(lr[1])

mod=2018
for i in range(r-l):
    x=r-l-i
    for j in range(x):
        a=(l+j)*(r-i)
        b=a%2019
        if b<mod:
            mod=b


print(mod)


Fixed submission:
lr=input().split()
l=int(lr[0])
r=int(lr[1])

mod=2018
for i in range(r-l):
    x=r-l-i
    if mod==0:
        break
    for j in range(x):
        if (l+j)%2019==0 or (r-i)%2019==0:
            mod=0
            break
        else:
            a=(l+j)*(r-i)
            b=a%2019
            if b<mod:
                mod=b

print(mod)
Buggy python submission (verdict: Runtime Error):
import math as mt
NK=input().split()
N=int(NK[0])
K=int(NK[1])
P=N-K

print(P+1)

for i in range(1,K):
    Q=(mt.factorial(N-K+1)*mt.factorial(K-1))//(mt.factorial(K-i-1)*mt.factorial(i)*mt.factorial(N-K-i)*mt.factorial(i+1))
    print(Q%int(1e9+7))


Fixed submission:
import math as mt
NK=input().split()
N=int(NK[0])
K=int(NK[1])
P=N-K

print(P+1)


for i in range(1,K):
    if i<=N-K:
        Q=(mt.factorial(N-K+1)*mt.factorial(K-1))//(mt.factorial(K-i-1)*mt.factorial(i)*mt.factorial(N-K-i)*mt.factorial(i+1))
        print(Q%int(1e9+7))
    else:
        print(0)
Buggy python submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split())

ans1=w*h/2
if w/x==2 and h/y==2:
    a=1
else:
    a=0
print(ans1,a)


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

ans1=w*h/2
if w/2==x and h/2==y:
    a=1
else:
    a=0
print(ans1,a)
Buggy python submission (verdict: Runtime Error):
a,b,c=map(int,input().split())

lis=[]
if a>b:
    for i in range(b):
        if a%(b-i)==0 and b%(b-i)==0:
            lis.append(b-i)

else:
    for i in range(a):
        if a%(b-i)==0 and b%(b-i)==0:
            lis.append(b-i)

print(lis[c-1])


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

lis=[]
if a>b:
    for i in range(b):
        if a%int(b-i)==0 and b%int(b-i)==0:
            lis.append(int(b-i))

else:
    for i in range(a):
        if a%(a-i)==0 and b%(a-i)==0:
            lis.append(int(a-i))

#print(lis)
print(lis[c-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,m = map(int, input().split())
h = list(map(int, input().split()))
cnt = n
ng = []
for i in range(m):
  a,b = map(int, input().split())   
  if h[a-1] >= h[b-1] and b not in ng:
    cnt -= 1
    ng.append(b)
  if h[a-1] <= h[b-1] and a not in ng:
    cnt -= 1
    ng.append(a)
print(n -len(ng))

Fixed submission:
n,m = map(int, input().split())
h = list(map(int, input().split()))
cnt = n
ng = {}
for i in range(m):
  a,b = map(int, input().split())   
  if h[a-1] >= h[b-1]:
    ng[b] = 1
  if h[a-1] <= h[b-1]:
    ng[a] = 1
print(n -len(ng))
Buggy python submission (verdict: Runtime Error):
r = int(input())
import math
print(math.pi * R * 2)

Fixed submission:
r = int(input())
import math
print(math.pi * r * 2)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

for i in range(1,n+1):
  cnt = 0
  for ai in a:
    if ai == i:
      cnt += 1
  print(cnt)

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

d = {}
for i in range(0,n-1):
  if a[i] in d:
    d[a[i]] += 1
  else:
    d[a[i]] = 1
    
for i in range(1,n+1):
  if i in d.keys():
    print(d[i])
  else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
import math

n = int(input())

total = 0
for i in range(1, n + 1):
    for j in range(1, n + 1):
        for k in range(1, n + 1):
            total += math.gcd(i, math.gcd(j, k))
print(total)

Fixed submission:
import math

n = int(input())

total1 = 0
for i in range(1, n + 1):
    for j in range(i+1, n + 1):
        for k in range(j+1, n + 1):
            total1 += math.gcd(i, math.gcd(j, k))
total1 = 6*total1

total2 = 0
for i in range(1, n + 1):
    for j in range(i+1, n + 1):
        total2 += math.gcd(i, j)
total2 = 6*total2

total3 = 0
for i in range(1, n + 1):
    total3 += i

print(total1 + total2 + total3)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

r = 0
g = 0
b = 0
for c in s:
    if c == 'R':
        r += 1
    if c == 'G':
        g += 1
    if c == 'B':
        b += 1

total = r*g*b

for i in range(0, n-2):
    for j in range(i+1, n-1):
        for k in range(j+1, n):
            if j - i == k - j:
                if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
                    total -= 1
print(total)

Fixed submission:
n = int(input())
s = input()

r = 0
g = 0
b = 0
for c in s:
    if c == 'R':
        r += 1
    if c == 'G':
        g += 1
    if c == 'B':
        b += 1

total = r*g*b

for i in range(0, n-2):
    for j in range(i+1, n-1):
        k = j - i + j
        if k >= n:
            break
        elif s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            total -= 1
print(total)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()

total = 0
for i in range(0, n):
    if i == n-2:
        print(total)
        exit()
    for j in range(i+1, n):
        if s[j] == s[i]:
            if j == n-1:
                break
            continue
        for k in range(j+1, n):
            if s[k] == s[i] or s[k] == s[j]:
                continue
            elif j - i != k - j:
                total += 1

Fixed submission:
n = int(input())
s = input()

r = 0
g = 0
b = 0
for c in s:
    if c == 'R':
        r += 1
    if c == 'G':
        g += 1
    if c == 'B':
        b += 1

total = r*g*b

for i in range(0, n-2):
    for j in range(i+1, n-1):
        k = j - i + j
        if k >= n:
            break
        elif s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            total -= 1
print(total)
Buggy python submission (verdict: Runtime Error):
s, t = input().split()
a, b = int(input().split())
u = input()
if s == u:
  print(a-1, b)
else:
  print(a,b-1)


Fixed submission:
s, t = input().split(' ')
a, b = map(int, input().split(' '))
u = input()

if u == s:
  print(a-1,b)
else:
  print(a,b-1)

Buggy python submission (verdict: Runtime Error):
s, t = input().split()
a, b = int(input().split())
u = input()
if s == u:
  print(s-1,t)
else:
  print(s,t-1)

Fixed submission:
s, t = input().split(' ')
a, b = map(int, input().split(' '))
u = input()

if u == s:
  print(a-1,b)
else:
  print(a,b-1)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
p = list(map(int, input().split()))

dp = [0] * n
for i in range(n):
  dp[i] = p[i] / 2 + 0.5
  
max = 0
for i in range(0,n-k + 1):
  if sum(dp[i:i+k]) > max:
    max = sum(dp[i:i+k])
print(max)

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

dp = [0] * n
for i in range(n):
  dp[i] = p[i] / 2 + 0.5
  
m = sum(dp[0:k])
max = m
for i in range(1,n-k + 1):
  m = m - dp[i-1] + dp[i+k-1]
  if m > max:
    max = m
print(max)
Buggy python submission (verdict: Time Limit Exceeded):
h,n = map(int, input().split())
a = list(map(int, input().split())) 

def max_pop(ary):
  max = 0
  ind = 0
  for i,a in enumerate(ary):
    if max < a:
      max = a
      ind = i
  del ary[i]
  return ary

def sum_ary(ary):
  total = 0
  for a in ary:
    total += a
  return total

if n >= len(a):
  print(0)
  exit()
for _ in range(n):
  a = max_pop(a)
print(sum_ary(a))


Fixed submission:
h,n = map(int, input().split())
a = list(map(int, input().split())) 

a = sorted(a, reverse=True)

def sum_ary(ary):
  total = 0
  for a in ary:
    total += a
  return total

if n >= len(a):
  print(0)
  exit()
del a[:n]
print(sum_ary(a))

Buggy python submission (verdict: Time Limit Exceeded):
h,n = map(int, input().split())
a = list(map(int, input().split())) 

def max_pop(ary):
  max = 0
  for a in ary:
    if max < a:
      max = a
  ary.remove(max)
  return ary

def sum_ary(ary):
  total = 0
  for a in ary:
    total += a
  return total

if n >= len(a):
  print(0)
  exit()
for _ in range(n):
  a = max_pop(a)
print(sum_ary(a))

Fixed submission:
h,n = map(int, input().split())
a = list(map(int, input().split())) 

a = sorted(a, reverse=True)

def sum_ary(ary):
  total = 0
  for a in ary:
    total += a
  return total

if n >= len(a):
  print(0)
  exit()
del a[:n]
print(sum_ary(a))
Buggy python submission (verdict: Runtime Error):
import math

def dic(s):
  len(s)= l
  tmp = 1
  for i,c in enumerate(s):
    tmp += (int(c) - i -1) * math.factorial(l - i -1)
  return tmp

n = input()
s1 = list(map(int, input().split()))
s2 = list(map(int, input().split()))

print(abs(dic(s1)-dic(s2))

Fixed submission:
import math
 
def dic(s):
  l = len(s)
  if l == 0:
    return 0
  c = s[0]
  tmp = ((sorted(s)).index(c)-1) * math.factorial(l -1)
  return tmp + dic(s[1:])
 
n = input()
s1 = list(map(int, input().split()))
s2 = list(map(int, input().split()))
 
print(abs(dic(s1)-dic(s2)))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int, input().split()))

la = len(a)
tmp = 1
cnt = 0
for num in range(n):
  for i,ai in enumerate(a):
    if ai == tmp:
      a = a[i:]
      tmp += 1
      cnt += 1
      break
if cnt == 0:
  print(-1)
else:
  print(la - cnt)

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

la = len(a)
tmp = 1
cnt = 0
for i in range(n):
  if a[i] == tmp:
    tmp += 1
    cnt += 1
if cnt == 0:
  print(-1)
else:
  print(la - cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

if n % 2 == 1 or n==0:
  print(0)
else:
  total = 1
  cnt = 0
  for i in range(n, 0, -2):
    if str(i)[-1] == '0':
      cnt += 1
      e = i // 10
      total *= e
    else:
      total *= i
    if str(total)[-1] == '0':
      cnt += 1
      total = total // 10    
  print(cnt)

Fixed submission:
n = int(input())

if n % 2 == 1 or n==0:
  print(0)
else:
  total = 0
  div = 5
  while True:
    total += n // (div * 2)
    div *= 5
    if div > n:
      break
  print(total)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

if n % 2 == 1 or n==0:
  print(0)
else:
  total = 1
  cnt = 0
  for i in range(n, 0, -2):
    total *= i
    if str(total)[-1] == '0':
      cnt += 1
      total = total // 10    
  print(cnt)

Fixed submission:
n = int(input())

if n % 2 == 1 or n==0:
  print(0)
else:
  total = 0
  div = 5
  while True:
    total += n // (div * 2)
    div *= 5
    if div > n:
      break
  print(total)