Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
count = 0

while all(i % 2 == 0 for i in A):
    a = [j/2 for j in a]
    count += 1
print(count)

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

while all(i % 2 == 0 for i in a):
    a = [j/2 for j in a]
    count += 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
def index(x):
    y = x//2
    return y

n = int(input())
a = list(map(int, input().split()))
count = 0
b = 1
while b >= 1:
    for i in a:
        if i % 2 != 0:
            b = 0
            break
    else:
        a = map(index, a)
        count += 1
print(count)


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

while all(i % 2 == 0 for i in a):
    a = [j/2 for j in a]
    count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
count = 0
while True:
    if a[0]%2 == 0 and a[1]%2==0 and a[2]%2==0:
        a = map(i//2 for i in range(n))
        count += 1
    else:
         break
print(count)

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

while all(i % 2 == 0 for i in a):
    a = [j/2 for j in a]
    count += 1
print(count)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
a_list = list(map(int, input().split()))
counter_list = []
for i in range(1,N+1):
    if a_list.count(i) > 0:
        counter_list.append(a_list.count(i))

counter_list.sort()

count = 0
for i in range(len(counter_list) - K):
    count += counter_list[i]

print(count)


Fixed submission:
N,K = map(int, input().split())
a_list = list(map(int, input().split()))
counter_list = [0]*N
for i in a_list:
    counter_list[i-1] += 1

counter_list.sort(reverse=True)

ans = N - sum(counter_list[:K])    

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int, input().split())
a_list = list(map(int, input().split()))
a_list.sort()
counter_list = []
for i in range(1,N+1):
    if a_list.count(i) > 0:
        counter_list.append(a_list.count(i))

counter_list.sort()

count = 0
for i in range(len(counter_list) - K):
    count += counter_list[i]

print(count)


Fixed submission:
N,K = map(int, input().split())
a_list = list(map(int, input().split()))
counter_list = [0]*N
for i in a_list:
    counter_list[i-1] += 1

counter_list.sort(reverse=True)

ans = N - sum(counter_list[:K])    

print(ans)
Buggy python submission (verdict: Runtime Error):
D = int(input())
T = int(input())
S = int(input())

if D <= T * S:
    print("Yes")
else:
    print("NO")


Fixed submission:
D, T, S = map(int, input().split())

if D <= T * S:
    print("Yes")
else:
    print("No")
Buggy python submission (verdict: Runtime Error):
a = list(input())
n = len(a)-2
print(a[0],n,a[-1],sep=("")
      

Fixed submission:
a = list(input())
n = len(a)-2
print(a[0],n,a[-1],sep=(""))
Buggy python submission (verdict: Runtime Error):
n,x,m=map(int,input().split())
a=[0]*(m+2)
cnt=[0]*(m+2)
a[1],f=x,x
cnt[f]=1
for i in range(2,m+1):
  f=f*f%m
  a[i]=f
  if cnt[f]==0:
    cnt[f]=1
  else:
    break
ind=a[1:].index(f)+1
ans=sum(a[:ind])+sum(a[ind:i])*((n-ind+1)//(i-ind))
p=(n-ind+1)%(i-ind)
ans+=sum(a[ind:ind+p])
print(ans)

Fixed submission:
import sys
n,x,m=map(int,input().split())
a=[0]*(m+2)
cnt=[0]*(m+2)
a[1],f=x,x
cnt[f]=1
if x==0:
  print(0)
  sys.exit()
for i in range(2,m+1):
  f=f*f%m
  a[i]=f
  if cnt[f]==0:
    cnt[f]=1
  else:
    break
ind=a[1:].index(f)+1
ans=sum(a[:ind])+sum(a[ind:i])*((n-ind+1)//(i-ind))
p=(n-ind+1)%(i-ind)
ans+=sum(a[ind:ind+p])
print(ans)

Buggy python submission (verdict: Runtime Error):
n,x,m=map(int,input().split())
a=[0]*(m+2)
cnt=[0]*(m+2)
a[1],f=x,x
cnt[f]=1
for i in range(2,m):
  f=f*f%m
  a[i]=f
  if cnt[f]==0:
    cnt[f]=1
  else:
    break
ind=a[1:].index(f)+1
ans=sum(a[:ind])+sum(a[ind:i])*((n-ind+1)//(i-ind))
p=(n-ind+1)%(i-ind)
ans+=sum(a[ind:ind+p])
print(ans)

Fixed submission:
import sys
n,x,m=map(int,input().split())
a=[0]*(m+2)
cnt=[0]*(m+2)
a[1],f=x,x
cnt[f]=1
if x==0:
  print(0)
  sys.exit()
for i in range(2,m+1):
  f=f*f%m
  a[i]=f
  if cnt[f]==0:
    cnt[f]=1
  else:
    break
ind=a[1:].index(f)+1
ans=sum(a[:ind])+sum(a[ind:i])*((n-ind+1)//(i-ind))
p=(n-ind+1)%(i-ind)
ans+=sum(a[ind:ind+p])
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
n,k=map(int,input().split())
a=list(map(int,input().split()))

left=0
right=10**9+1
while left<right:
  cnt=0
  mid=(left+right)//2
  for i in range(n):
    cnt+=math.ceil(a[i]/mid)-1
  if cnt<=k:
    right=mid
  else:
    left=mid+1
print(left)

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

left=1
right=10**9
while left<right:
  cnt=0
  mid=(left+right)//2
  for i in range(n):
    cnt+=math.ceil(a[i]/mid)-1
  if cnt<=k:
    right=mid
  else:
    left=mid+1
print(left)

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

left=0
right=10**9
while left<right:
  cnt=0
  mid=(left+right)//2
  for i in range(n):
    cnt+=math.ceil(a[i]/mid)-1
  if cnt<=k:
    right=mid
  else:
    left=mid+1
print(left)

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

left=1
right=10**9
while left<right:
  cnt=0
  mid=(left+right)//2
  for i in range(n):
    cnt+=math.ceil(a[i]/mid)-1
  if cnt<=k:
    right=mid
  else:
    left=mid+1
print(left)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().split())
a=list(map(int,input().split()))

left=0
right=10**9
while left<right:
  cnt=0
  mid=(left+right)//2
  for i in range(n):
    cnt+=a[i]//mid
  if cnt<=k:
    right=mid
  else:
    left=mid+1
print(left)

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

left=1
right=10**9
while left<right:
  cnt=0
  mid=(left+right)//2
  for i in range(n):
    cnt+=math.ceil(a[i]/mid)-1
  if cnt<=k:
    right=mid
  else:
    left=mid+1
print(left)
Buggy python submission (verdict: Runtime Error):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
kotei=k
ans=0
cnt=0

if kotei>=sum(a):
  cnt+=len(a)
else:
  x=kotei
  i=0
  while x>=0:
    x-=a[i]
    i+=1
    cnt+=1
  n=i
  ans=max(ans,cnt-1)

for j in range(n):
  i=0
  x+=a[n-1-j]
  cnt-=1
  while x>=0:
    x-=b[i]
    i+=1
    cnt+=1
  ans=max(ans,cnt-1)
  
print(ans)

Fixed submission:
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0

A,B=[0],[0]
for i in range(n):
  A.append(a[i]+A[i])
for i in range(m):
  B.append(b[i]+B[i])

for j in range(n+1):
  K=k-A[j]
  if K<0:
    break
  left=0
  right=m+1
  while left<right:
    mid=(left+right)//2
    if B[mid]>K:
      right=mid
    else:
      left=mid+1
  ans=max(ans,j+left-1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
kotei=k
ans=0
cnt=0

if kotei>=sum(a):
  cnt+=len(a)
  ans=max(ans,cnt)
else:
  x=kotei
  i=0
  while x>=0:
    x-=a[i]
    i+=1
    cnt+=1
  ans=max(ans,cnt-1)

for j in range(m):
  kotei-=b[j]
  if kotei<0:
    break
  cnt=j+1
  if kotei>=sum(a):
    cnt+=len(a)
    ans=max(ans,cnt)
    continue
  else:
    x=kotei
    i=0
    while x>=0:
      x-=a[i]
      i+=1
      cnt+=1
    ans=max(ans,cnt-1)
print(ans)


Fixed submission:
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0

A,B=[0],[0]
for i in range(n):
  A.append(a[i]+A[i])
for i in range(m):
  B.append(b[i]+B[i])

for j in range(n+1):
  K=k-A[j]
  if K<0:
    break
  left=0
  right=m+1
  while left<right:
    mid=(left+right)//2
    if B[mid]>K:
      right=mid
    else:
      left=mid+1
  ans=max(ans,j+left-1)
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
n = int(input())
dp = ["0"]*12

def main(p):
  count = 0
  m = p
  while (m-1)//26 >= 1:
    m = m//26
    count += 1
  dp[(-1)*count-1] = chr(m + 96)
  p -= 26**count*m
  if count == 0:
    #print(dp)
    a = "".join(dp)
    print(a.replace("0","")
    sys.exit()
  else:
    main(p)
main(n)

Fixed submission:
import math
n=a=int(input())
len=0
while a>=1:
  a=math.ceil(a/26)
  a-=1
  len+=1
  n-=26**len
n+=26**len-1
dp=[0]*len

for i in range(len):
  s=26**(len-i-1)
  dp[i]=chr(n//s+ord("a"))
  n-=26**(len-i-1)*(n//s)
print("".join(dp))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
c = [0]*1000001

for i in range(n):
  c[a[i]] -= 1
  for j in range(a[i],1000001,a[i]):
    c[j] += 2

ans=c.count(1)
print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
kmax = sorted(a)[-1]
c = [0]*(kmax+1)

for i in range(n):
  c[a[i]] -= 1
  for j in range(a[i],(kmax+1),a[i]):
    c[j] += 2

ans=c.count(1)
print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a.sort()

def main():
  ans = 0
  for i in range(n):
    for j in range(i+2):
      if a[i] % a[j] == 0 and i != j:
        ans += 1
        break
  print(n-ans)

main()

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
kmax = sorted(a)[-1]
c = [0]*(kmax+1)

for i in range(n):
  c[a[i]] -= 1
  for j in range(a[i],(kmax+1),a[i]):
    c[j] += 2

ans=c.count(1)
print(ans)

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

def main():
  ans = 0
  for i in range(n):
    for j in range(n):
      if a[i] % a[j] == 0 and i != j:
        ans += 1
        break
  print(n-ans)

main()

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
kmax = sorted(a)[-1]
c = [0]*(kmax+1)

for i in range(n):
  c[a[i]] -= 1
  for j in range(a[i],(kmax+1),a[i]):
    c[j] += 2

ans=c.count(1)
print(ans)

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

for i in range(n):
  for j in range(n):
    if a[i] % a[j] == 0 and i != j:
      ans += 1
      break
  
print(n-ans)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
kmax = sorted(a)[-1]
c = [0]*(kmax+1)

for i in range(n):
  c[a[i]] -= 1
  for j in range(a[i],(kmax+1),a[i]):
    c[j] += 2

ans=c.count(1)
print(ans)

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

for i in range(n):
  count = 1
  del b[i]
  for j in range(n-1):
    if a[i] % b[j] == 0:
      count = 0
      break
  ans += count
  count = 1
  b = a.copy()
  
print(ans)


Fixed submission:
n = int(input())
a = list(map(int,input().split()))
kmax = sorted(a)[-1]
c = [0]*(kmax+1)

for i in range(n):
  c[a[i]] -= 1
  for j in range(a[i],(kmax+1),a[i]):
    c[j] += 2

ans=c.count(1)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = map(int, input().split())
multi = 1

for i in a:
  multi *= i

if multi > 1000000000000000000:
  print("-1")
else:
  print(multi)

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

for i in a:
  multi *= i
  if multi > pow(10,18):
    break
if multi > pow(10,18):
  print("-1")
else:
  print(multi)

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

for i in a:
  multi *= i

if multi > pow(10,18):
  print("-1")
else:
  print(multi)

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

for i in a:
  multi *= i
  if multi > pow(10,18):
    break
if multi > pow(10,18):
  print("-1")
else:
  print(multi)
Buggy python submission (verdict: Runtime Error):
n = input()
m = n % 10

if m == 2 or m == 4 or m == 5 or m == 7 or m == 9:
  print(hon)
elif m == 3:
  print(bon)
else:
  print(pon)

Fixed submission:
n = int(input())
m = n % 10

if m == 2 or m == 4 or m == 5 or m == 7 or m == 9:
  print("hon")
elif m == 3:
  print("bon")
else:
  print("pon")

Buggy python submission (verdict: Runtime Error):
n = input()
m = n % 10

if m == 2 or m == 4 or m == 5 or m == 7 or m == 9:
  print("hon")
elif m == 3:
  print("bon")
else:
  print("pon")

Fixed submission:
n = int(input())
m = n % 10

if m == 2 or m == 4 or m == 5 or m == 7 or m == 9:
  print("hon")
elif m == 3:
  print("bon")
else:
  print("pon")

Buggy python submission (verdict: Runtime Error):
n = input()
m = n % 10

if m == 2 or m == 4 or m == 5 or m == 7 or m == 9:
  print("hon")
elif m == 3:
  print("bon")
else:
  print("pon")

Fixed submission:
n = int(input())
m = n % 10

if m == 2 or m == 4 or m == 5 or m == 7 or m == 9:
  print("hon")
elif m == 3:
  print("bon")
else:
  print("pon")

Buggy python submission (verdict: Runtime Error):
n = input()
m = n % 10

if m == 2 or m == 4 or m == 5 or m == 7 or m == 9:
  print("hon")
elif m = 3:
  print("bon")
else:
  print("pon")

Fixed submission:
n = int(input())
m = n % 10

if m == 2 or m == 4 or m == 5 or m == 7 or m == 9:
  print("hon")
elif m == 3:
  print("bon")
else:
  print("pon")
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
  print(Counter(a)[i])


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
dp=[0]*(n+1)
for i in range(n-1):
  dp[a[i]]+=1
for i in range(n):
  print(dp[i+1])
Buggy python submission (verdict: Runtime Error):
import math
n,k = map(int,input().split())

m = math.floor(n/k)
n = n-m*k

print(min(n,abs(n-k))

Fixed submission:
import math
n,k = map(int,input().split())
     
#m = math.floor(n/k)
n = n%k
     
print(min(n,k-n))
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())),reverse=True)
q=sorted(list(map(int,input().split())),reverse=True)
r=deque(sorted(list(map(int,input().split())),reverse=True))
p=deque(p[:x])
q=deque(q[:y])
ans=sum(p)+sum(q)

while p[-1]<r[0] or q[-1]<r[0]:
  if p[-1]<q[-1]:
    ans+=r[0]-p[-1]
    r.popleft()
    p.pop()
  else:
    ans+=r[0]-q[-1]
    r.popleft()
    q.pop()
  if p==deque([]) or q==deque([]) or r==deque([]):
    break
if r==deque([]):
  pass
elif p==deque([]):
  while q[-1]<r[0]:
    ans+=r[0]-q[-1]
    r.popleft
    q.pop
    if q==deque([]) or r==deque([]):
      break
elif q==deque([]):
  while p[-1]<r[0]:
    ans+=r[0]-p[-1]
    r.popleft
    p.pop
    if p==deque([]) or r==deque([]):
      break
  
print(ans)

Fixed submission:
from collections import deque
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())),reverse=True)
q=sorted(list(map(int,input().split())),reverse=True)
r=deque(sorted(list(map(int,input().split())),reverse=True))
p=deque(p[:x])
q=deque(q[:y])
ans=sum(p)+sum(q)

while p[-1]<r[0] or q[-1]<r[0]:
  if p[-1]<q[-1]:
    ans+=r[0]-p[-1]
    r.popleft()
    p.pop()
  else:
    ans+=r[0]-q[-1]
    r.popleft()
    q.pop()
  if p==deque([]) or q==deque([]) or r==deque([]):
    break
if r==deque([]):
  pass
elif p==deque([]):
  while q[-1]<r[0]:
    ans+=r[0]-q[-1]
    r.popleft()
    q.pop()
    if q==deque([]) or r==deque([]):
      break
elif q==deque([]):
  while p[-1]<r[0]:
    ans+=r[0]-p[-1]
    r.popleft()
    p.pop()
    if p==deque([]) or r==deque([]):
      break
  
print(ans)

Buggy python submission (verdict: Runtime Error):
from collections import deque
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())),reverse=True)
q=sorted(list(map(int,input().split())),reverse=True)
r=deque(sorted(list(map(int,input().split())),reverse=True))
p=deque(p[:x])
q=deque(q[:y])
ans=sum(p)+sum(q)

while p[-1]<r[0] or q[-1]<r[0]:
  if p[-1]<q[-1]:
    ans+=r[0]-p[-1]
    r.popleft()
    p.pop()
  else:
    ans+=r[0]-q[-1]
    r.popleft()
    q.pop()
  if p==[] or q==[] or r==[]:
    break
print(ans)

Fixed submission:
from collections import deque
x,y,a,b,c=map(int,input().split())
p=sorted(list(map(int,input().split())),reverse=True)
q=sorted(list(map(int,input().split())),reverse=True)
r=deque(sorted(list(map(int,input().split())),reverse=True))
p=deque(p[:x])
q=deque(q[:y])
ans=sum(p)+sum(q)

while p[-1]<r[0] or q[-1]<r[0]:
  if p[-1]<q[-1]:
    ans+=r[0]-p[-1]
    r.popleft()
    p.pop()
  else:
    ans+=r[0]-q[-1]
    r.popleft()
    q.pop()
  if p==deque([]) or q==deque([]) or r==deque([]):
    break
if r==deque([]):
  pass
elif p==deque([]):
  while q[-1]<r[0]:
    ans+=r[0]-q[-1]
    r.popleft()
    q.pop()
    if q==deque([]) or r==deque([]):
      break
elif q==deque([]):
  while p[-1]<r[0]:
    ans+=r[0]-p[-1]
    r.popleft()
    p.pop()
    if p==deque([]) or r==deque([]):
      break
  
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import deque
s=deque(input())
q=int(input())
for i in range(q):
  query=input()
  if len(query)==1:
    s.reverse()
  else:
    if query[2]=="1":
      s.appendleft(query[4])
    else:
      s.append(query[4])
print("".join(s))

Fixed submission:
from collections import deque
s=deque(input())
q=int(input())
flag=0
for i in range(q):
  query=input()
  if len(query)==1:
    flag+=1
  else:
    if query[2]=="1" and flag%2==0 or query[2]=="2" and flag%2==1:
      s.appendleft(query[4])
    else:
      s.append(query[4])
if flag%2==1:
  s.reverse()
print("".join(s))
Buggy python submission (verdict: Time Limit Exceeded):
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=[0]*n
for i in range(n):
  a[i]=(p[i]+1)/2
ans=0
for i in range(n-k+1):
  ans=max(ans,sum(a[i:k+i]))
print(ans)

Fixed submission:
n,k=map(int,input().split())
p=list(map(int,input().split()))
a=[0]*n
b=[0]*n
for i in range(n):
  a[i]=(p[i]+1)/2
b[0]=a[0]
for i in range(1,n):
  b[i]=b[i-1]+a[i]
ans=b[k-1]
for i in range(1,n-k+1):
  ans=max(ans,b[i+k-1]-b[i-1])
print(ans)
Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
dp=[0]*(n+1)
cnt=0
for i in range(m):
  q=input()
  if dp[int(q[:-3])]!="A" and q[-2]=="W":
    dp[int(q[:-3])]="W"
    cnt+=1
  elif dp[int(q[i])]!="A" and q[-2]=="A":
    dp[int(q[:-3])]="A"
print(dp.count("A"),cnt)

Fixed submission:
n,m=map(int,input().split())
dp=[0]*(n+1)
charge=[0]*(n+1)
cnt=0
ans=0
for i in range(m):
  q=input()
  if dp[int(q[:-3])]!="A" and q[-2]=="W":
    dp[int(q[:-3])]="W"
    charge[int(q[:-3])]+=1
  elif dp[int(q[:-3])]!="A" and q[-2]=="A":
    dp[int(q[:-3])]="A"
    ans+=1
    cnt+=charge[int(q[:-3])]
    charge[int(q[:-3])]=0
print(ans,cnt)

Buggy python submission (verdict: Runtime Error):
n,m=map(int,input().split())
dp=[0]*(n+1)
cnt=0
for i in range(m):
  q=input()
  if dp[int(q[i])]!="A" and q[-2]=="W":
    dp[int(q[:-3])]="W"
    cnt+=1
  elif dp[int(q[i])]!="A" and q[-2]=="A":
    dp[int(q[:-3])]="A"
print(dp.count("A"),cnt)

Fixed submission:
n,m=map(int,input().split())
dp=[0]*(n+1)
charge=[0]*(n+1)
cnt=0
ans=0
for i in range(m):
  q=input()
  if dp[int(q[:-3])]!="A" and q[-2]=="W":
    dp[int(q[:-3])]="W"
    charge[int(q[:-3])]+=1
  elif dp[int(q[:-3])]!="A" and q[-2]=="A":
    dp[int(q[:-3])]="A"
    ans+=1
    cnt+=charge[int(q[:-3])]
    charge[int(q[:-3])]=0
print(ans,cnt)
Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
ans=0
for i in range(n-1):
  if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
    ans+=1
print(ans)

Fixed submission:
n=int(input())
s=input()
ans=0
for i in range(n-2):
  if s[i]=="A" and s[i+1]=="B" and s[i+2]=="C":
    ans+=1
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
if a>=k:
  print(a-k.b)
elif a+b>=k:
  print(0,a+b-k)
else:
  print(0,0)

Fixed submission:
a,b,k=map(int,input().split())
if a>=k:
  print(a-k,b)
elif a+b>=k:
  print(0,a+b-k)
else:
  print(0,0)
Buggy python submission (verdict: Time Limit Exceeded):
def main():
  n = int(input())
  a = list(map(int,input().split()))

  for i in range(n):
    print(a.index(i+1)+1,end=" "),

main()

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

for i,name in enumerate(a):
  ans[name-1]=i+1

print(*ans)

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

for i in range(1,n+1):
  print(a.index(i)+1,end=" "),


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

for i,name in enumerate(a):
  ans[name-1]=i+1

print(*ans)

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

for i in range(n):
  print(a.index(i+1)+1,end=" "),


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

for i,name in enumerate(a):
  ans[name-1]=i+1

print(*ans)
Buggy python submission (verdict: Runtime Error):
S=input()
T=input()
print(sum(s==t for s,t in zip(s,t)))

Fixed submission:
S=input()
T=input()
print(sum(s==t for s,t in zip(S,T)))
Buggy python submission (verdict: Time Limit Exceeded):
n=int(input())
s=[0]*n
for i in range(n):
  s[i]=sorted(input())
s.sort()
#print(s)
ans=0
for j in range(1,n):
  cnt=1
  while s[j]==s[j-cnt] and j-cnt>=0:
    cnt+=1
    ans+=1
print(ans)

Fixed submission:
n=int(input())
dict={}
ans=0
for i in range(n):
  s=str(sorted(input()))
  if s in dict:
    dict[s]+=1
    ans+=(dict[s]-1)
  else:
    dict[s]=1
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
n,d=map(int,input().split())
print(math.ceil(n/(2d+1)))

Fixed submission:
import math
n,d=map(int,input().split())
print(math.ceil(n/(d*2+1)))

Buggy python submission (verdict: Runtime Error):
import math
n,d=map(int,input().split())
print(math.ceil(n/(2d-1)))

Fixed submission:
import math
n,d=map(int,input().split())
print(math.ceil(n/(d*2+1)))
Buggy python submission (verdict: Runtime Error):
l=int(input())%2019
r=int(input())%2019+1
ans=2018
for i in range(l):
  if ans == 0:
    break
  for j in range(i+1,r):
    min(ans,i*j%2019)
    if ans == 0:
      break
print(ans)

Fixed submission:
import sys
l,r = map(int,input().split())
if l+2019<=r:
  print(0)
  sys.exit()
l=l%2019
r=r%2019
if l>=r:
  print(0)
  sys.exit()

ans=2018
for i in range(l,r):
  if ans == 0:
    break
  for j in range(i+1,r+1):
    ans = min(ans,i*j%2019)
    if ans == 0:
      break
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
a=[0]*(n+1)
for i in range(n):
  a[i+1]=i+1
l,r=map(int,input().split())
s=set(a[l:r+1])
for i in range(1,m):
  l,r=map(int,input().split())
  s=s&set(a[l:r+1])
print(len(s))

Fixed submission:
n,m = map(int,input().split())
count = 0
lmax = 0
rmin = 100000
for i in range(m):
  l,r = map(int,input().split())
  lmax = max(l,lmax)
  rmin = min(r,rmin)
print(max(rmin-lmax+1,0))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
s={k for k in range(1,100001)}
for i in range(m):
  l,r=map(int,input().split())
  b={j for j in range(l,r+1)}
  s=s&b
print(len(s))

Fixed submission:
n,m = map(int,input().split())
count = 0
lmax = 0
rmin = 100000
for i in range(m):
  l,r = map(int,input().split())
  lmax = max(l,lmax)
  rmin = min(r,rmin)
print(max(rmin-lmax+1,0))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())
s={k for k in range(1,100001)}
for i in range(m):
  l,r=map(int,input().split())
  b=set()
  for j in range(l,r+1):
    b.add(j)
  s=s&b
print(len(s))

Fixed submission:
n,m = map(int,input().split())
count = 0
lmax = 0
rmin = 100000
for i in range(m):
  l,r = map(int,input().split())
  lmax = max(l,lmax)
  rmin = min(r,rmin)
print(max(rmin-lmax+1,0))