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

Fixed submission:
n, m = map(int, input().split())
queue = []
for i in range(m):
    c, y= map(int, input().split())
    queue.append([c, y, i])

queue = sorted(queue)

index = 0
keep = queue[0][0]
for i in range(m):
    if keep != queue[i][0]:
        index = 0
        keep = queue[i][0]
    index += 1
    queue[i][0] = str(queue[i][0]).zfill(6)
    queue[i][1] = str(index).zfill(6)

queue.sort(key=lambda x: x[2])

for data in queue:
    cn, yn, i = data
    print(cn + yn)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
queue = []
for i in range(m):
    c, y= map(int, input().split())
    queue.append([c, y, i])

queue = sorted(queue)

index = 0
keep = 1
for i in range(m):
    if keep != queue[1][0]:
        index = 0
    index += 1
    queue[i][0] = str(queue[i][0]).zfill(6)
    queue[i][1] = str(index).zfill(6)

queue.sort(key=lambda x: x[2])

for data in queue:
    cn, yn, i = data
    print(cn + yn)
Problem p03286 (python)

Fixed submission:
number = int(input())

def to_bin(n):
    if n == 0:
        return [0]
    
    digits = []
    i = 0
    base = 1
    while n != 0:
        if n % (base * 2) == 0:
            digits.append('0')
        else:
            digits.append('1')
            n -= base
        i+= 1
        base *= -2
    return digits[::-1]

ans_list = to_bin(number)

for ans in ans_list:
    print(ans, end='')

Buggy submission (verdict: Runtime Error):
number = int(input())

def to_bin(n):
    if n == 0:
        return 0
    
    digits = []
    i = 0
    base = 1
    while n != 0:
        if n % (base * 2) == 0:
            digits.append('0')
        else:
            digits.append('1')
            n -= base
        i+= 1
        base *= -2
    return digits[::-1]

ans_list = to_bin(number)

for ans in ans_list:
    print(ans, end='')

Buggy submission (verdict: Runtime Error):
number = int(input())

def to_bin(n):
    if n == 0:
        return 0
    
    digits = []
    i = 0
    base = 1
    while n != 0:
        if n % (base * 2) == 0:
            digits.append('0')
        else:
            digits.append('1')
            n -= base
        i+= 1
        base *= 2
    return digits[::-1]

ans_list = to_bin(number)

for ans in ans_list:
    print(ans, end='')
Problem p03774 (python)

Fixed submission:
N, M = map(int, input().split())

students = []
for i in range(N):
    students.append(input().split())

checkpoints = []
for i in range(M):
    checkpoints.append(input().split())

for x1, y1 in students:
    result = 99999999999
    index = 1
    for x2, y2 in checkpoints:
        val = abs(int(x1) - int(x2)) + abs(int(y1) - int(y2))
        if result > val:
            ans = index
            result = val
        index += 1
    print(ans)

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

students = []
for i in range(N):
    students.append(input().split())

checkpoints = []
for i in range(M):
    checkpoints.append(input().split())

for x1, y1 in students:
    result = 10**8
    index = 1
    for x2, y2 in checkpoints:
        val = abs(int(x1) - int(x2)) + abs(int(y1) - int(y2))
        if result > val:
            ans = index
            result = val
        index += 1
    print(ans)
Problem p02819 (python)

Fixed submission:
import math
def primecheck(x):

    for i in range(2,math.ceil(x*(1/2))):
        if x % i == 0:
            return False
            break 
    return True



x = int(input())
for i in range(x,10**6):
    if primecheck(i):
        break
print(i)

Buggy submission (verdict: Runtime Error):
import math
def primecheck(x):
    primes =[]
    for i in range(2,math.ceil(x)):
        if x % i == 0:
            return False
            break 
    return True


x = int(input())
for i in range(x,10**5):
    if primecheck(i):
        break
print(i)
Problem p02831 (python)

Fixed submission:
import math
def gcd (a,b):
    n = min(a,b)
    m = max(a,b)
    
    b = m % n
    
    while b > 0:
        m = n
        n = b
        b = m % n
    
    return n

a, b = map(int,input().split())
c = math.floor(a * b / gcd(a,b))
print(c)

Buggy submission (verdict: Runtime Error):
import math

a, b = map(int,input().split())
c = math.floor(a * b / math.gcd(a,b))
print(c)

Buggy submission (verdict: Runtime Error):
import math

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

print(a * b / math.gcd(a,b))
Problem p02836 (python)

Fixed submission:
import math
s = input()

l = len(s)
cnt = 0
for i in range(math.ceil(l/2)):
    if s[i] != s[l-i-1]:
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
s = input()

l = len(s)
cnt = 0
for i in range(math.ceil(l/2)):
    if s[i] != s[l-i-1]:
        cnt += 1
print(cnt)
Problem p02847 (python)

Fixed submission:
s = input()
d = {"SUN":7,"MON":6,"TUE":5,"WED":4,"THU":3,"FRI":2,"SAT":1}
print(d[s])

Buggy submission (verdict: Runtime Error):
s = input()
d = {"SAN":7,"MAN":6,"TUE":5,"WED":4,"THU":3,"FRI":2,"SAT":1}
print(d[s])

Buggy submission (verdict: Runtime Error):
s = input()
d = {"SAN":7,"MAN":1,"TUE":2,"WED":3,"THU":4,"FRI":5,"SAT":6}
print(d[s])
Problem p02880 (python)

Fixed submission:
n = int(input())
result = "No"

for i in range(1,10):
    if n % i == 0:
        a = n / i
        
        if a in range(1,10):
            result = "Yes"
            break
    else:
        next
print(result)

Buggy submission (verdict: Runtime Error):
n = int(input())
result = "No"

for i in range(2,10):
    if n % i == 0:
        result = "Yes"
         break
    else:
        next
print(result)
Problem p02915 (python)

Fixed submission:
n = int(input())
print(n**3)

Buggy submission (verdict: Runtime Error):
n = int(input)
print(n**3)
Problem p03011 (python)

Fixed submission:
p,q,r = map(int,input().split())
print(min(p+q, p+p+r, q+r, q+q+p, r+p, r+r+q))

Buggy submission (verdict: Runtime Error):
p,q,r = int(input())
print(min(p+q, p+p+r, q+r, q+q+p, r+p, r+r+q))
Problem p03835 (python)

Fixed submission:
k,s = map(int ,input().split())
cnt =0
for x in range(k+1):
	for y in range(k+1):
		z = s - x- y
		if z <= k and 0 <= z:
			cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
k,s = map(int ,input()split())
cnt =0
for x in range(s+1):
	for y in range(s+1):
		z = s - x- y
		if z <= k and 0 <= z:
			cnt += 1

print(cnt)
Problem p02879 (python)

Fixed submission:
a,b=map(int,input().split(' '))
count=0
if (a<=9 and a>=1) and (b<=9 and b>=1) :
    print(a*b)
else:
    print("-1")

Buggy submission (verdict: Runtime Error):
n=int(input())
l=list()
if n<=5:
  print("Yes")
  exit()
for i in range(2, n//2+1):
    if n % i == 0: 
        if (n//i,i) not in l:
            l.append((i,n//i))
flag=0
for i in l:
    if i[0]<=9 and i[1]<=9:
        flag=1
        print("Yes")
        exit()
if not flag:
    print("No")
Problem p02729 (python)

Fixed submission:
N,M = map(int,input().split())
if N <= 1:
  N = 1
if M <= 1:
  M = 1
print(int(N*(N-1)/2+M*(M-1)/2))

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
if N <= 1:
  N = 2
if M <= 1:
  M = 2
print(N(N-1)/2+M(M-1)/2)
Problem p02879 (python)

Fixed submission:
A,B = map(int, open(0).read().split())
if (A < 10) and (B < 10):
  print(A*B)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
A,B = int(input())
if (A < 10) and (B < 10):
  print(A*B)
else:
  print(-1)
Problem p02916 (python)

Fixed submission:
N=int(input())
Ai = list(map(int,input().split()))
Bi = list(map(int,input().split()))
Ci = list(map(int,input().split()))

ans = sum(Bi)

for i in range(N-1):
  if Ai[i] + 1 == Ai[i+1]:
    ans += Ci[Ai[i]-1]

print(ans)

Buggy submission (verdict: Runtime Error):
N=int(input())
Ai = list(map(int,input().split()))
Bi = list(map(int,input().split()))
Ci = list(map(int,input().split()))

ans ~ sum(Bi)

for i in range(N-1):
  if Ai[i] + 1 == Ai[i+1]:
    ans += Ci[Ai[i]-1]

print(ans)
Problem p02970 (python)

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

Buggy submission (verdict: Runtime Error):
import math
N,D = map(int,input().split())
print(math.cell(N/(2*D)))

Buggy submission (verdict: Runtime Error):
import math
N,D = map(int,input().split())
print(math.floor(N/(2D)))
Problem p02597 (python)

Fixed submission:
import sys
from collections import Counter
n = int(input())
c = list(input())
s = Counter(c)
if s['R'] == 0 or s['W'] == 0:
  print('0')
  sys.exit()
pos_w=0
pos_r=n-1
count = 0
for i in range(pos_w, n):
  if c[i] != 'W':
    continue
  pos_w = i
  for j in range(pos_r, -1, -1):
    if c[j] != 'R':
      continue
    pos_r = j
    if pos_w > pos_r:
      print(count)
      sys.exit()
    c[i] = 'R'
    c[j] = 'W'
    count += 1
    break

Buggy submission (verdict: Runtime Error):
from collections import Counter
n = int(input())
c = input()
s = Counter(c)
if s['W'] == 0:
  print('0')
elif c.index('R') == 0 and c.index('W') == s['R']:
  print('0')
elif s['R'] > c.index('R'):
  print(s['R'] - (c.index('R')+1) + c.index('R'))
else:
  print(s['R'])
Problem p02629 (python)

Fixed submission:
alpha=[s for s in 'abcdefghijklmnopqrstuvwxyz']
num=int(input())
ans=[]
while num > 0:
  ans.append(alpha[num%26-1])
  num//=26
  if ans[-1]=='z':
    num-=1
print(''.join(ans[::-1]))

Buggy submission (verdict: Runtime Error):
import sys
alpha=[s for s in 'abcdefghijklmnopqrstuvwxyz']
num=int(input())
digit=1
check=26
while num > check:
  digit+=1
  check+=26**digit
digit-=1
if digit == 0:
  print(alpha[num-1])
  sys.exit()
ans=[]
while digit > 1:
  if num % 26**digit == 0:
    ans.append(alpha[num//(26**digit)-2])
  else:
  	ans.append(alpha[num//(26**digit)-1])
  num%=26**digit
  digit-=1
if num % 26 == 0:
  ans.append(alpha[num//26-2])
else:
  ans.append(alpha[num//26-1])
ans.append(alpha[num%26-1])
print(''.join(ans))

Buggy submission (verdict: Runtime Error):
import sys
alpha=[s for s in 'abcdefghijklmnopqrstuvwxyz']
num=int(input())
digit=1
check=26
while num > check:
  digit+=1
  check+=26**digit
digit-=1
if digit == 0:
  print(alpha[num-1])
  sys.exit()
ans=[]
while digit > 1:
  ans.append(alpha[num//(26**digit)-1])
  num%=26**digit
  digit-=1
ans.append(alpha[num//26-1])
ans.append(alpha[num%26-1])
print(''.join(ans))
Problem p02880 (python)

Fixed submission:
n = int(input())
for i in range(1,10):
  for j in range(i, 10):
    if i*j==n:
      print('Yes')
      exit()
print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(1,10):
  for j in range(i, 10):
    if i*j==n:
      print('Yes')
      return
print('No')
Problem p02951 (python)

Fixed submission:
a,b,c = [int(x) for x in input().split()]
print(b+c-a if b+c-a > 0 else 0)

Buggy submission (verdict: Runtime Error):
a,b,c = [int(x) for x in inpput().split()]
print(b+c-a if b+c-a > 0 else 0)
Problem p03041 (python)

Fixed submission:
(a,b)=list(map(int, input().split()))
s=input()
print(''.join([c if i!=b-1 else c.lower() for i,c in enumerate(s)]))

Buggy submission (verdict: Runtime Error):
(a,b)=list(map(int, input().split()))
print(''.join([c if i!=b-1 else c.lower() for i,c in enumerate(s:=input())]))
Problem p02595 (python)

Fixed submission:
import numpy

N, D = map(int, input().split())
number = 0

for i in range(N):
    X,Y = map(int, input().split())
    distance = numpy.sqrt(X*X+Y*Y)
    if distance <= D:
        number += 1
print(number)

Buggy submission (verdict: Runtime Error):
N, D = map(int, input().split())
number = 0

for i in range(N):
    X,Y = map(int, input().split())
    distance = sqrt(X*X+Y*Y)
    if distance <= D:
        number += 1

Buggy submission (verdict: Runtime Error):
N, D = map(int, input().strip().split())
number = 0

for i in range(N):
    X,Y = map(int, input().split())
    distance = sqrt(X*X+Y*Y)
    if distance <= D:
        number += 1
Problem p02596 (python)

Fixed submission:
K = int(input())
seven_number = 0
ality = 0
for ans in range(1,10**7):
        if ans > K:
            print("-1")
            break
        else:
            seven_number = (seven_number*10+7) % K
            if seven_number ==0:
                print(ans)
                break

Buggy submission (verdict: Runtime Error):
import math
import time
import sys

sys.setrecursionlimit(5000)
def judge_debisible(K, seven_number):
    gcd_number = math.gcd(K,seven_number)
    elapsed_time = time.time() - start_time
    print(elapsed_time)
    if elapsed_time > 0.1:
        print("-1")
    elif gcd_number == 1 :
        judge_debisible(K, seven_number*10+7)
    else:
        print(len(str(seven_number)))

K = int(input())
start_time = time.time()
judge_debisible(K, 7)
Problem p02897 (python)

Fixed submission:
N = int(input())
print(1 - (N//2)/N)

Buggy submission (verdict: Runtime Error):

s = input().split()
n=int(s[0])

s=(input().split())

list=[[0 for i in range(2)] for j in range(n)]


for i in range(n):
    list[i][1]=i
    list[i][0]=int(s[i])

list.sort()

#print('list = {}'.format(list))
answer=[]
for i in range(n):
    print(list[i][1]+1)
    #list.append(list[i][1]+1)

#print(answer)
Problem p02790 (python)

Fixed submission:
a, b = input().split()
l = [str(a) * int(b), str(b) * int(a)]
l.sort()
print(l[0])

Buggy submission (verdict: Runtime Error):
a, b = input().split()
l = [str(a) * int(b), str(b) * int(a)].sort()
print(l[0])
Problem p02688 (python)

Fixed submission:
def main():
  n, k = map(int, input().split())
  a = set()
  for i in range(k):
    input()
    a |= set(list(map(int, input().split())))
  print(n-len(a))

if __name__ == "__main__":
  main()

Buggy submission (verdict: Runtime Error):
def main():
  N,K=map(int,input().split())
  for i in range(K):
    input()
    a |= set(list(map(int,input.split())))
  print(n-len(a))
  
 
if __name__ == "__main__":
  main()
Problem p03208 (python)

Fixed submission:
from sys import stdin
import numpy as np
import sys

N, K = [int(x) for x in stdin.readline().rstrip().split()]
h = np.array(list(map(int, [stdin.readline().rstrip() for _ in range(N)])))

h.sort()
hmin = 2**30

for i in range(0, N-K+1):
    hdiff = h[i+K-1] - h[i]
    if hdiff < hmin:
        hmin = hdiff

print(hmin)

Buggy submission (verdict: Runtime Error):
from sys import stdin
import numpy as np
import sys

N, K = [int(x) for x in stdin.readline().rstrip().split()]
h = np.array(map(int, [stdin.readline().rstrip() for _ in range(N)]))

hs = h.sort()
hmin = sys.maxint

for i in range(0, N-K):
    hdiff = hs[i+K] - hs[i]
    if hdiff < hmin:
        hmin = hdiff

print(hmin)
Problem p02689 (python)

Fixed submission:
N,M= map(int,input().split())

h = [int(i) for i in input().split()]
judge = [True]*N

for i in range (M):
    a,b= map(int,input().split())
    if h[a - 1] > h[b - 1]:
        judge[b-1] = False
    if h[a - 1] < h[b - 1]:
        judge[a - 1] = False
    if h[a - 1] == h[b - 1]:
        judge[b-1] = False
        judge[a - 1] = False

print(judge.count(True))

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

h = [int(i) for i in input().split()]
judge = [True]*N

for i in range (M):
    a,b= map(int,input().split())
    if h[a - 1] > h[b - 1]:
        judge[b-1] = False
    if h[a - 1] < h[b - 1]:
        judge[a - 1] = False
    if h[a - 1] == h[b - 1]:
        judge[b-1] = False
        judge[a - 1] = False

print(jadge.count(True))
Problem p02990 (python)

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

MOD=10**9+7

fac = [0] * 2001
ifac = [0] * 2001
fac[0] = 1
ifac[0] = 1

def mpow(x, n):
  ans = 1
  while n != 0:
    if n&1:
      ans = ans*x % MOD
    x = x*x % MOD
    n = n >> 1
  return ans

def comb(a, b):
  if a == 0 and b == 0:
    return 1
  if a < b or a < 0:
    return 0
  tmp = ifac[a-b]* ifac[b] % MOD
  return tmp * fac[a] % MOD


for i in range(2000):
  fac[i+1] = fac[i]*(i+1) % MOD
  ifac[i+1] = ifac[i]*mpow(i+1, MOD-2) % MOD

N, K = map(int, input().split())
anssub=[]
for i in range(K):
  a = comb(N-K+1,i+1)%MOD
  b = comb(K-1,i)%MOD
  c = a * b % MOD
  anssub.append(c)
anssub = map(str,anssub)
print('\n'.join(anssub))

#print(ans)

Buggy submission (verdict: Runtime Error):
import sys
import math
input = sys.stdin.readline

def P(n, r):
  return math.factorial(n)//math.factorial(n-r)
def C(n, r):
  return P(n, r)//math.factorial(r)

MOD=10**9+7
N, K = map(int, input().split())
anssub=[]
for i in range(K):
  a = C(N-K+1,i+1)%MOD
  b = C(K-1,i)%MOD
  c = a * b % MOD
  anssub.append(c)
anssub = map(str,anssub)
print('\n'.join(anssub))

#print(ans)
Problem p02594 (python)

Fixed submission:
X = int(input())

if X >= 30:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
X = int(input())

if X >= 30:
    print(Yes)
else:
    print(No)
Problem p02676 (python)

Fixed submission:
K=int(input())
S=str(input())


if K>=len(S):
  print(S)
  
else:
  print(S[:K]+ "...")

Buggy submission (verdict: Runtime Error):
K=input()
S=input()

len_S=len(S)

if K<=len_S:
  print(S)
  
else:
  print(S[K:], "...")
Problem p02711 (python)

Fixed submission:
N=input()
if '7' in N:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
in=input()
for i in range(len(in)):
  if(in[i]=="7"):
    print("Yes")
    exit(0)
print("No")
s = input()
for i in range(len(s)):
  if(s[i]=='7'):
    print("Yes")
    exit(0)
print("No")
Problem p02712 (python)

Fixed submission:
n=int(input())
sum=0
for i in range(1,n+1):
  if i%3!=0 and i%5 !=0:
    sum+=i
print(sum)

Buggy submission (verdict: Runtime Error):
N=int(input())
ans=0

for i in range(N):
  if (N+1)% !=3 and (N+1)% !=5:
    ans+=i
print(ans)
Problem p02729 (python)

Fixed submission:
from scipy.misc import comb
N, M = [int(i) for i in input().split()]
ans = comb(N,2,exact=True) + comb(M,2,exact=True)
print(ans)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
def combinations_count(n, r):
  	if n==1 or n==0:
      return 0
    else:
      return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

print(combinations_count(N, 2)+combinations_count(M, 2))
Problem p02790 (python)

Fixed submission:
a, b = input().split()
pre=a*int(b)
post=b*int(a)
print(pre if pre<=post else post)

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
pre=a*int(b)
post=b*int(a)
print(pre if pre<=post else post)
Problem p02676 (python)

Fixed submission:
K = int(input())
S = input()

if len(S) <= K:
    print(S)
else:
    for i in range(K):
        print(S[i],end="")
    print("...")

Buggy submission (verdict: Runtime Error):
K = int(input())
S = input()

for i in range(K):
    print(S[i],end="")
if len(S) > K:
    print("...")
Problem p02594 (python)

Fixed submission:
X = int(input())
if X >= 30:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
X = input()
if X >= 30:
  print('Yes')
else:
  print('No')
Problem p02627 (python)

Fixed submission:
α = input()
if α.isupper():
  print('A')
else:
  print('a')

Buggy submission (verdict: Runtime Error):
α = int(input())
if α.isupper():
  print('A')
else:
  print('a')

Buggy submission (verdict: Runtime Error):
α = int(input())
if str.isupper(α):
  print('A')
else:
  print('a')

Buggy submission (verdict: Runtime Error):
α = int(input())
if str.isupper():
  print('A')
else:
  print('a')
Problem p02688 (python)

Fixed submission:
n,k=map(int,input().split())
l=[0 for _ in range(n)]
for _ in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for x in a:
        l[x-1]+=1
print(l.count(0))

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
l=[0 for _ range(n)]
for _ in range(k):
    d=int(input())
    a=list(map(int,input().split()))
    for x in a:
        l[x-1]+=1
print(l.count(0))
Problem p02863 (python)

Fixed submission:
n,t=map(int,input().split())
ab=[tuple(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[0])
ab.insert(0,(0,0))
dp=[[0]*t for _ in range(n+1)]
for i in range(1,n+1):
    a,b=ab[i]
    if a<t:
        dp[i][a]=max(dp[i-1][a],b)
    for j in range(t):
        if dp[i-1][j]==0:
            continue
        if j+a<t:
            dp[i][j+a]=max(dp[i][j+a],dp[i-1][j]+b)
        dp[i][j]=max(dp[i-1][j],dp[i][j])
ans=0
p=[j for i,j in ab]
for i in range(1,n):
    ans=max(ans,max(dp[i])+max(p[i+1:]))
ans=max(ans,max(dp[n]))
print(ans)

Buggy submission (verdict: Runtime Error):
n,t=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
ans=0
ab.sort(key=lambda x:x[0])
ab.sort(key=lambda x:x[1], reverse=True)
g=[]
f=[]
for i in range(n):
    a,b=ab[i]
    c=0
    now=0
    ok=[]
    no=[]
    for j in range(n):
        if i==j:
            continue
        now+=ab[j][0]
        if now<t:
            c+=ab[j][1]
            ok.append(ab[j])
        else:
            now-=ab[j][0]
            no.append(ab[j])
    if ans<c+b:
        ans=c+b
        g=ok
        f=no

g.sort(key=lambda x:x[1])
f.sort(key=lambda x:x[1],reverse=True)
ans2=ans
if f:
    ans2+=f[0][1]-g[0][1]

print(max(ans,ans2))

Buggy submission (verdict: Runtime Error):
n,t=map(int,input().split())
ab=[tuple(map(int,input().split())) for _ in range(n)]
ab.sort(key=lambda x:x[1],reverse=True)
ab.sort(key=lambda x:x[0])
ans=0
now=0
t-=0.5
x=0
while now<=t:
    ans+=ab[x][1]
    now+=ab[x][0]
    x+=1

ab.sort(key=lambda x:x[1],reverse=True)
ans2=0
now=0
t-=0.5
x=0
while now<=t:
    ans2+=ab[x][1]
    now+=ab[x][0]
    x+=1

print(max(ans,ans2))
Problem p02933 (python)

Fixed submission:
a=int(input())
s=input()
if a>=3200:
    print(s)
else:
    print("red")

Buggy submission (verdict: Runtime Error):
import sys
input=sys.stdin.readline
sys.setrecursionlimit(100000)
n,q=map(int,input().split())
g=[[i] for i in range(n+1)]

for _ in range(n-1):
    a,b=map(int,input().split())
    g[a].append(b)

c=[0]*(n+1)
def dfs(p,x):
    for i in g[p]:
        if r[i]:
            r[i]=0
            c[i]+=x
            dfs(i,x)

for _ in range(q):
    r=[1]*(n+1)
    p,x=map(int,input().split())
    dfs(p,x)


print(*c[1:])
Problem p03017 (python)

Fixed submission:
n,a,b,c,d=map(int,input().split())
s=list(input())
fa=True
fb=True
ff=False
for i in range(a,c-1):
    if s[i]=="#" and s[i+1]=="#":
        fa=False
for i in range(b,d-1):
    if s[i]=="#" and s[i+1]=="#":
        fb=False
if c>d:
    for i in range(b-2,d-1):
        if s[i]=="." and s[i+1]=="." and s[i+2]==".":
            ff=True
if c<d:
    if fa and fb:
        print("Yes")
    else:
        print("No")
else:
    if fa and fb and ff:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
n,a,b,c,d=map(int,input().split())
s=list(input())
fa=True
fb=True
ff=False
for i in range(a,c-1):
    if s[i]=="#" and s[i+1]=="#":
        fa=False
for i in range(b,d-1):
    if s[i]=="#" and s[i+1]=="#":
        fb=False
if c>d:
    for i in range(a,d):
        if s[i]=="." and s[i+1]=="." and s[i+2]==".":
            ff=True
if c<d:
    if fa and fb:
        print("Yes")
    else:
        print("No")
else:
    if fa and fb and ff:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
n,a,b,c,d=map(int,input().split())
s=list(input())
fa=True
fb=True
ff=False
for i in range(a,c-1):
    if s[i]=="#" and s[i+1]=="#":
        fa=False
for i in range(b,d-1):
    if s[i]=="#" and s[i+1]=="#":
        fb=False

for i in range(a,d-1):
    if s[i]=="." and s[i+1]=="." and s[i+2]==".":
        ff=True
if c<d:
    if fa and fb:
        print("Yes")
    else:
        print("No")
else:
    if fa and fb and ff:
        print("Yes")
    else:
        print("No")