Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
lenL = len(L)
combi = set()
v2i = {v:i for i, v in enumerate(L)}

for i in range(lenL-2):
    a = L[i]
    for j in range(i+1, lenL-1):
        b = L[j]
        for k in range(j+1, lenL):
            c = L[k]
            if c >= (a+b): break
            if a < (b+c) and b < (c+a) and c < (a+b): combi.add((a,b,c))

print(len(combi))

Fixed submission:
import bisect

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
ct = 0

for i in range(N-1):
    a = L[i]
    for j in range(i+1, N):
        b = L[j]
        up_bound = bisect.bisect_left(L, a+b)
        ct += max(0, up_bound - (j+1))

print(ct)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
lenL = len(L)
combi = set()
for i in range(lenL-2):
    a = L[i]
    for j in range(i+1, lenL-1):
        b = L[j]
        for k in range(j+1, lenL):
            c = L[k]
            if a < (b+c) and b < (c+a) and c < (a+b): combi.add((a,b,c))

print(len(combi))

Fixed submission:
import bisect

N = int(input())
L = list(map(int, input().split()))
L = sorted(L)
ct = 0

for i in range(N-1):
    a = L[i]
    for j in range(i+1, N):
        b = L[j]
        up_bound = bisect.bisect_left(L, a+b)
        ct += max(0, up_bound - (j+1))

print(ct)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A, B, C = [], [], []
for _ in range(N):
    a, b, c = map(int, input().split())
    A.append(a)
    B.append(b)
    C.append(c)

def helper(idx, happy, last):
    if idx >= N:
        return happy
    if last == 'a':
        return max(helper(idx+1, happy+B[idx], 'b'), helper(idx+1, happy+C[idx], 'c'))
    elif last == 'b':
        return max(helper(idx+1, happy+A[idx], 'a'), helper(idx+1, happy+C[idx], 'c'))
    else:
        return max(helper(idx+1, happy+A[idx], 'a'), helper(idx+1, happy+B[idx], 'b'))


happy_a = helper(1, A[0], 'a')
happy_b = helper(1, B[0], 'b')
happy_c = helper(1, C[0], 'c')

print(max(happy_a, happy_b, happy_c))

Fixed submission:
N = int(input())
H = []
for _ in range(N):
    a, b, c = map(int, input().split())
    H.append([a, b, c])

dp = [[float('inf')] * 3 for _ in range(N+1)]
dp[0] = [0, 0, 0]
for i in range(1, N+1):
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + H[i-1][0] 
    dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + H[i-1][1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + H[i-1][2]
print(max(dp[N]))
Buggy python submission (verdict: Time Limit Exceeded):
k,n=map(int,input().split())
x=list(map(int,input().split()))
xx=[]
for i in x:
    xx.append(i)
    xx.append(i-k)
y=sorted(xx)
z=[]
for i in range(n+1):
    z.append(max(y[i:i+n])-min(y[i:i+n]))
print(min(z))

Fixed submission:
k,n=map(int,input().split())
x=list(map(int,input().split()))
xx=[]
for i in x:
    xx.append(i)
    xx.append(i-k)
y=sorted(xx)
z=[]
for i in range(n+1):
    z.append(y[i+n-1]-y[i])
print(min(z))
Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
x=n%(a+b)
y=n//(a+b)
c=list(i for i in range(1,a+1))
if x in c:
    print(a*y+x)
elif x==0:
    print(a*y)
else:
    print(a*(y+1))

Fixed submission:
n,a,b=map(int,input().split())
x=int(n/(a+b))
y=n%(a+b)
if a==0:
    print(0)
elif y==0:
    print(a*x)
elif 0<y<a+1:
    print(a*x+y)
else:
    print(a*(x+1))

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n,a,b=map(int,input().split())
    x=n%(a+b)
    y=n//(a+b)
    if x in list(i for i in range(1,a+1)):
        print(a*y+x)
    elif x==0:
        print(a*y)
    else:
        print(a*(y+1))
main()

Fixed submission:
n,a,b=map(int,input().split())
x=int(n/(a+b))
y=n%(a+b)
if a==0:
    print(0)
elif y==0:
    print(a*x)
elif 0<y<a+1:
    print(a*x+y)
else:
    print(a*(x+1))

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
x=n%(a+b)
y=n//(a+b)
if x in list(i for i in range(1,a+1)):
    print(a*y+x)
elif x==0:
    print(a*y)
else:
    print(a*(y+1))

Fixed submission:
n,a,b=map(int,input().split())
x=int(n/(a+b))
y=n%(a+b)
if a==0:
    print(0)
elif y==0:
    print(a*x)
elif 0<y<a+1:
    print(a*x+y)
else:
    print(a*(x+1))

Buggy python submission (verdict: Time Limit Exceeded):
n,a,b=map(int,input().split())
x=n%(a+b)
if x in list(i for i in range(1,a+1)):
    print(a*(n//(a+b))+x)
elif x==0:
    print(a*(n//(a+b)))
else:
    print(a*((n//(a+b))+1))

Fixed submission:
n,a,b=map(int,input().split())
x=int(n/(a+b))
y=n%(a+b)
if a==0:
    print(0)
elif y==0:
    print(a*x)
elif 0<y<a+1:
    print(a*x+y)
else:
    print(a*(x+1))
Buggy python submission (verdict: Runtime Error):
if x<1200:
    print("ABC")
elif 1200<=x and x<2800:
    print("ARC")
else:
    print("AGC")

Fixed submission:
x=int(input())
if x<1200:
    print("ABC")
elif 1200<=x and x<2800:
    print("ARC")
else:
    print("AGC")
Buggy python submission (verdict: Runtime Error):
mochi_list = []
N = int(input())

for i in range(N):
    mochi_list.append(int(input()))

last_mochi = 101
count = 0

for mochi in sorted(mochi_list, reverse=True):
    if mochi < last_mochi:
        count += 1
    last_mochi = mochi

print(count)


Fixed submission:
# -*- coding: utf-8 -*-

from datetime import datetime, timedelta

S = str(input())
wrong_day = datetime.strptime(S, '%Y/%m/%d')
correct_day = wrong_day + timedelta(days=365)
print(correct_day.strftime('%Y/%m/%d'))
Buggy python submission (verdict: Runtime Error):
from collections import Counter

N = int(input())
counter = Counter(map(int, input().split()))

sum = 0

for a, cnt in counter.items():
    if a > cnt:
        sum += cnt
    else:
        sum += cnt - a

print(sum)


Fixed submission:
from math import ceil

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

print(ceil((a + b) / 2))
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a_list = list(map(int, sorted(input().split())))

sum = 0

for a in set(a_list):
    cnt = a_list.count(a)
    if a > cnt:
        sum += cnt
    else:
        sum += cnt - a

print(sum)


Fixed submission:
from collections import Counter

N = int(input())
counter = Counter(map(int, input().split()))

sum = 0

for a, cnt in counter.most_common():
    if a > cnt:
        sum += cnt
    else:
        sum += cnt - a

print(sum)

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

sum = 0

for a in set(a_list):
    cnt = a_list.count(a)
    if a > cnt:
        sum += cnt
    else:
        sum += cnt - a

print(sum)


Fixed submission:
from collections import Counter

N = int(input())
counter = Counter(map(int, input().split()))

sum = 0

for a, cnt in counter.most_common():
    if a > cnt:
        sum += cnt
    else:
        sum += cnt - a

print(sum)
Buggy python submission (verdict: Runtime Error):
import sys
from math import factorial

N, M = (int(s) for s in sys.stdin.split(' '))

total = 0
if N > 1:
  total += factorial(N) / factorial(N - 2) / 2
if M > 1:
  total += factorial(M) / factorial(M - 2) / 2
  
print(total)

Fixed submission:
import sys
from math import factorial

line = input()
N, M = (int(s) for s in line.split(' '))

total = 0
if N > 1:
  total += factorial(N) / factorial(N - 2) / 2
if M > 1:
  total += factorial(M) / factorial(M - 2) / 2

print(int(total))
Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
N = int(input())
line = input()
l = []
counts = {}
for n in line.split(' '):
  n = int(n)
  if n not in counts:
    counts[n] = 0
  counts[n] += 1
  l.append(n)

results = {}

for n in counts:
  results[n] = 0
  for m in counts:
    count = counts[m]
    if m == n:
      count -= 1
    if count > 1:
      results[n] += int(factorial(count)) // 2 // int(factorial(count - 2))

for n in l:
  print(results[n])

Fixed submission:
from math import factorial
N = int(input())
line = input()
l = []
counts = {}
for n in line.split(' '):
  n = int(n)
  if n not in counts:
    counts[n] = 0
  counts[n] += 1
  l.append(n)

comb = {}

for n in counts:
  comb[n] = 0
  count = counts[n]
  if count > 1:
    comb[n] += int(factorial(count)) // 2 // int(factorial(count - 2))

total = sum([comb[n] for n in comb])

for n in l:
  count = counts[n]
  result = total - comb[n]
  if count - 1 > 1:
    result += comb[n] * (count - 2) // count
  print(result)

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial

N = int(input())
line = input()
l = []
counts = {}
for n in line.split(' '):
  n = int(n)
  if n not in counts:
    counts[n] = 0
  counts[n] += 1
  l.append(n)

results = {}

for n in counts:
  results[n] = 0
  for m in counts:
    count = counts[m]
    if m == n:
      count -= 1
    if count > 1:
      results[n] += int(factorial(count)) // 2 // int(factorial(count - 2))

for n in l:
  print(results[n])

Fixed submission:
from math import factorial
N = int(input())
line = input()
l = []
counts = {}
for n in line.split(' '):
  n = int(n)
  if n not in counts:
    counts[n] = 0
  counts[n] += 1
  l.append(n)

comb = {}

for n in counts:
  comb[n] = 0
  count = counts[n]
  if count > 1:
    comb[n] += int(factorial(count)) // 2 // int(factorial(count - 2))

total = sum([comb[n] for n in comb])

for n in l:
  count = counts[n]
  result = total - comb[n]
  if count - 1 > 1:
    result += comb[n] * (count - 2) // count
  print(result)

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

N = int(input())
line = input()
l = []
counts = {}
for n in line.split(' '):
  n = int(n)
  if n not in counts:
    counts[n] = 0
  counts[n] += 1
  l.append(n)

results = {}

for n in counts:
  results[n] = 0
  for m in counts:
    count = counts[m]
    if m == n:
      count -= 1
    if count > 1:
      results[n] += factorial(count) / 2 / factorial(count - 2) 

for n in l:
  print(int(results[n]))

Fixed submission:
from math import factorial
N = int(input())
line = input()
l = []
counts = {}
for n in line.split(' '):
  n = int(n)
  if n not in counts:
    counts[n] = 0
  counts[n] += 1
  l.append(n)

comb = {}

for n in counts:
  comb[n] = 0
  count = counts[n]
  if count > 1:
    comb[n] += int(factorial(count)) // 2 // int(factorial(count - 2))

total = sum([comb[n] for n in comb])

for n in l:
  count = counts[n]
  result = total - comb[n]
  if count - 1 > 1:
    result += comb[n] * (count - 2) // count
  print(result)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = list(map(int, input().split()))
li = sorted(li)
count = 1
if not (1 in li and 0 in li):
    count = 0
else:
    for i in range(2,max(li) + 1):
        a = li.count(i-1)
        b = li.count(i)
        count *= a ** b
print(count % 998244353)


Fixed submission:
n = int(input())
li = list(map(int, input().split()))
box = [0 for x in range(max(li)+1)]
for i in li:
    box[i] += 1
count = 1

if len(box) > 2:
    for i in range(1, len(box)-1):
        count *= box[i] ** box[i+1]
        count %= 998244353
else:
    count = 1
    
if box[0] != 1 or li[0] != 0:
    count = 0

print(count % 998244353)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
li = list(map(int, input().split()))
li = sorted(li)
count = 1
if  not (1 in li and 0 in li) :
    count = 0
else:
    for i in range(2,max(li) + 1):
        a = li.count(i-1)
        b = li.count(i)
        count *= a ** b
print(count % 998244353)

Fixed submission:
n = int(input())
li = list(map(int, input().split()))
box = [0 for x in range(max(li)+1)]
for i in li:
    box[i] += 1
count = 1

if len(box) > 2:
    for i in range(1, len(box)-1):
        count *= box[i] ** box[i+1]
        count %= 998244353
else:
    count = 1
    
if box[0] != 1 or li[0] != 0:
    count = 0

print(count % 998244353)

Buggy python submission (verdict: Runtime Error):
n = int(input())
li = list(map(int, input().split()))
li = sorted(li)
count = 1
if  not (1 in li and 0 in li) :
    count = 0
else:
    for i in range(2,max(li) + 1):
        a = li.count(i-1)
        b = li.count(i)
        count *= a ** b
print(count % 998244353)A

Fixed submission:
n = int(input())
li = list(map(int, input().split()))
box = [0 for x in range(max(li)+1)]
for i in li:
    box[i] += 1
count = 1

if len(box) > 2:
    for i in range(1, len(box)-1):
        count *= box[i] ** box[i+1]
        count %= 998244353
else:
    count = 1
    
if box[0] != 1 or li[0] != 0:
    count = 0

print(count % 998244353)
Buggy python submission (verdict: Runtime Error):
import math
def gcd(x,y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    if  x % y == 0:
        return y
    else:
        return gcd(y, x%y)

def f(n):
    li = []
    m = n
    while True:
        for i in range(2, n + 1):
            if m % i == 0:
                if not i in li:
                    li.append(i)
                    n = n // i
                    break
                else:
                    n = n // i
                    continue
        else:
            break
    return li

a, b = list(map(int, input().split()))
d = gcd(a, b)
print(len(set(f(d))) + 1)


Fixed submission:
n = int(input())
a = list(map(int, input().split()))
li = [0 for i in range(n)]
for i in range(n):
    x = a[i]
    li[x-1] = i + 1
for i in range(n):
    print(li[i], end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(x,y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    if  x % y == 0:
        return y
    else:
        return gcd(y, x%y)
     
def f(n):
    li = []
    while True:
        for i in range(2, n+1):
            if n % i == 0:
                n = n // i
                li.append(i)
                break
            else:
                continue
        else:
            break
    return li
     
a, b = list(map(int, input().split()))
d = gcd(a, b)
print(len(set(f(d))) + 1)

Fixed submission:
import math
def gcd(x,y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    if  x % y == 0:
        return y
    else:
        return gcd(y, x%y)


a, b = list(map(int, input().split()))
d = gcd(a, b)
if d == 1:
    print(1)
    quit()
li = []
while True:
    for i in range(2, int(math.sqrt(d)) + 1):
        if d % i == 0:
            if not i in li:
                li.append(i)
                d = d // i
                break
            else:
                d = d // i
                break
    else:
        if d != 1:
            li.append(d)
            break

print(len(set(li)) + 1)

Buggy python submission (verdict: Time Limit Exceeded):
def gcd(x,y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    if  x % y == 0:
        return y
    else:
        return gcd(y, x%y)

def f(n):
    li = []
    while True:
        for i in range(2, n+1):
            if n % i == 0:
                n = n // i
                li.append(i)
                break
            else:
                continue
        else:
            break
    return li

a, b = list(map(int, input().split()))
d = gcd(a, b)
print(len(set(f(d))) + 1)

Fixed submission:
import math
def gcd(x,y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    if  x % y == 0:
        return y
    else:
        return gcd(y, x%y)


a, b = list(map(int, input().split()))
d = gcd(a, b)
if d == 1:
    print(1)
    quit()
li = []
while True:
    for i in range(2, int(math.sqrt(d)) + 1):
        if d % i == 0:
            if not i in li:
                li.append(i)
                d = d // i
                break
            else:
                d = d // i
                break
    else:
        if d != 1:
            li.append(d)
            break

print(len(set(li)) + 1)
Buggy python submission (verdict: Runtime Error):
    a,b,c = list(map(int, input().split()))
    print(max(0, c-(a-b)))

Fixed submission:
a,b,c = list(map(int, input().split()))
print(max(0, c-(a-b)))

Buggy python submission (verdict: Runtime Error):
a,b,c = list(map(int, input().split()))
print(max(0, c-(a-b))

Fixed submission:
a,b,c = list(map(int, input().split()))
print(max(0, c-(a-b)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
         
if n == 1:
	print("Yes")
else:
	for i in range(n-1):
		if h[i+1] < h[i]:
		h[i+1] -= 1
	for i in range(n-1):
		if h[i+1] < h[i]:
  			print("No")
  			break
	else:
		print("Yes")

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
             
if n == 1:
      print("Yes")
else:
      for i in range(n-1):
            if h[i] < h[i+1]:
                  h[i+1] -= 1
      for i in range(n-1):
            if h[i+1] < h[i]:
                  print("No")
                  break
      else:
            print("Yes")

Buggy python submission (verdict: Runtime Error):
n = int(input())
h = list(map(int, input().split()))
     
if n == 1:
	print("Yes")
else:
    for i in range(n-1):
    	if h[i+1] < h[i]:
        h[i+1] -= 1
    for i in range(n-1):
        if h[i+1] < h[i]:
          print("No")
          break
    else:
        print("Yes")

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
             
if n == 1:
      print("Yes")
else:
      for i in range(n-1):
            if h[i] < h[i+1]:
                  h[i+1] -= 1
      for i in range(n-1):
            if h[i+1] < h[i]:
                  print("No")
                  break
      else:
            print("Yes")

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

if n == 1:
  print("Yes")
else:
  for i in range(n):
    if h[i+1] < h[i]:
      h[i+1] -= 1
  for i in range(n):
    if h[i+1] < h[i]:
      print("No")
      break
  else:
    print("Yes")

Fixed submission:
n = int(input())
h = list(map(int, input().split()))
h[0] -= 1
             
if n == 1:
      print("Yes")
else:
      for i in range(n-1):
            if h[i] < h[i+1]:
                  h[i+1] -= 1
      for i in range(n-1):
            if h[i+1] < h[i]:
                  print("No")
                  break
      else:
            print("Yes")
Buggy python submission (verdict: Runtime Error):
a,b,t = list(map(int,input().split()))
printf(t//a * b)

Fixed submission:
a,b,t = list(map(int, input().split()))
c = t // a
print(c*b)
Buggy python submission (verdict: Runtime Error):
    a,b = list(map(int, input().split()))
    if a == b:
      print(2 * a)
    else:
      print(max(a,b) * 2 - 1)

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

Buggy python submission (verdict: Runtime Error):
a,b = list(map(int, input().split()))
if a == b:
  print(2 * a)
else:
  printf(max(a,b) * 2 - 1)

Fixed submission:
a, b = list(map(int,input().split()))
if a == b:
  print(2 * a)
else:
  print(max(a,b) * 2 -1)
Buggy python submission (verdict: Runtime Error):
li = [int(input()) for i in range(5)]
for i in range(1,10):
    for j in range(5):
        if li[j] % 10 == i:
            a = li[j]
            del li[j]
            break
    else:
        continue
    break

for i in range(4):
    if li[i] % 10 != 0:
        li[i] = (li[i] // 10 + 1) * 10
print(sum(li) + a)

Fixed submission:
li = [int(input()) for i in range(5)]
flag = True
for i in range(5):
    if li[i] % 10 == 0:
        flag = True
    else:
        flag = False
        break

if flag:
    print(sum(li))
else: 
    for i in range(1,10):
        for j in range(5):
            if li[j] % 10 == i:
                a = li[j]
                del li[j]
                break
        else:
            continue
        break

    for i in range(4):
        if li[i] % 10 != 0:
            li[i] = (li[i] // 10 + 1) * 10
    print(sum(li) + a)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a,b,c,d,e = [int(input()) for i in range(5)]
li = [n,0,0,0,0,0]
t = 0

while li[5] < n:
    a_1 = min(li[0],a)
    li[0] -= a_1
    b_1 = min(li[1], b)
    li[1] -= b_1
    c_1 = min(li[2], c)
    li[2] -= c_1
    d_1 = min(li[3], d)
    li[3] -= d_1
    e_1 = min(li[4], e)
    li[4] -= e_1

    li[1] += a_1
    li[2] += b_1
    li[3] += c_1
    li[4] += d_1
    li[5] += e_1

    t += 1

print(t)

Fixed submission:
n = int(input())
li = sorted([int(input()) for i in range(5)])

if n % li[0] == 0:
    a = n // li[0]
else:
    a = n // li[0] + 1

print(a + 4)
Buggy python submission (verdict: Time Limit Exceeded):
N, Q = list(map(int, input().split()))
S = input()
li = [list(map(int, input().split())) for i in range(Q)]
t = [0] * N

for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        t[i] = 1

for i in range(Q):
    kazu = t[li[i][0] - 1 : li[i][1] -1]
    print(kazu.count(1))

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
	t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = list(map(int, input().split()))
S = input()
li = [list(map(int, input().split())) for i in range(Q)]

for num in range(Q):
    st = S[li[num][0] - 1:li[num][1]]
    if not "AC" in st:
        print(0)
    else:
        count = 0
        for i in range(len(st)-1):
            if st[i] == "A":
                if st[i+1] == "C":
                    count += 1
        print(count)

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
	t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = list(map(int, input().split()))
S = input()
li = [list(map(int, input().split())) for i in range(Q)]

for num in range(Q):
    st = S[li[num][0] - 1:li[num][1]]
    count = 0
    for i in range(len(st)-1):
        if st[i] == "A":
            if st[i+1] == "C":
                count += 1
    print(count)

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
	t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
	l, r = map(int, input().split())
	print(t[r-1] - t[l-1])
Buggy python submission (verdict: Runtime Error):
n = int(input())
b = list(map(int, input().split()))

def main():
    b.sort()
    for i in range(n):
        print(b[i])

for i in range(n):
    if b[i] < n-i:
        main()
        break
    elif b[i] == n-i:
        continue
    if i == n - 1 and b[i] <= n
        main()
        break
else:
    print("-1")

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

ans = []
while True:
    num = 0
    for i in range(len(b)):
        if b[i] == i + 1:
            num = i + 1
    else:
        if num == 0:
            print("-1")
            quit()
        else:
            ans.append(b[num - 1])
            del b[num - 1]
    if b == []:
        break


for i in ans[::-1]:
    print(i)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
count = 0
while True:
    for i in range(len(s)-1):
        if s[i] != s[i+1]:
            del s[i]
            del s[i]
            count += 2
            break
    else:
        break
print(count)

Fixed submission:
s = list(input())
a = s.count("1")
b = s.count("0")
print(len(s) - (max(a,b) - min(a,b)))
Buggy python submission (verdict: Runtime Error):
if n % 2 == 0:
    if n//2 >= k :
        print("YES")
    else:
        print("NO")
else:
    if (n+1)//2 >= k:
        print("YES")
    else:
        print("NO")

Fixed submission:
n,k = list(map(int,input().split()))
if n % 2 == 0:
    if n//2 >= k :
        print("YES")
    else:
        print("NO")
else:
    if (n+1)//2 >= k:
        print("YES")
    else:
        print("NO")