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

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

# (i)XがLバーガーの半分より上かどうか？を計算
# (ii-i)上の場合: sumに下半分のパティの数を加算。下半分を切り捨てて、L-1バーガに対して、
#        再度X = (X-(Lバーガーの半分の枚数))で(i)から計算
# (ii-ii)下の場合: 上半分を切り捨てて、L-1バーガに対して再度X = (X-(Lバーガーの半分の枚数))で(i)から計算

patty_num_map = {}
size_map = {}
patty_num_map[0] = 1
size_map[0] = 1
for i in range(1, 51):
    patty_num_map[i] = 1+patty_num_map[i-1]*2
    size_map[i] = 3+size_map[i-1]*2

L = N
patty_sum = 0
L1_map = {}
L1_map[0] = 0
L1_map[1] = 0
L1_map[2] = 1
L1_map[3] = 2
L1_map[4] = 3
L1_map[5] = 3
L1_map[6] = 3
for i in range(7, 10000):
    L1_map[i] = 3
while True:
    half = size_map[L]//2+1
    if L < 2:
        patty_sum += L1_map[X]
        break
    if X > half:
        patty_sum += patty_num_map[L-1]+1  # 真ん中のpattyの分
        # X -= half+1  # 一番上のバティの分
        X -= half
        L -= 1
    elif X < half:
        X -= 1  # 一番下のバンの分
        L -= 1
    else:  # ちょうど半分
        patty_sum += patty_num_map[L-1]+1
        break
print(patty_sum)

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

# (i)XがLバーガーの半分より上かどうか？を計算
# (ii-i)上の場合: sumに下半分のパティの数を加算。下半分を切り捨てて、L-1バーガに対して、
#        再度X = (X-(Lバーガーの半分の枚数))で(i)から計算
# (ii-ii)下の場合: 上半分を切り捨てて、L-1バーガに対して再度X = (X-(Lバーガーの半分の枚数))で(i)から計算

patty_num_map = {}
size_map = {}
patty_num_map[0] = 1
size_map[0] = 1
for i in range(1, 51):
    patty_num_map[i] = 1+patty_num_map[i-1]*2
    size_map[i] = 3+size_map[i-1]*2

L = N
patty_sum = 0
L1_map = {}
L1_map[0] = 0
L1_map[1] = 0
L1_map[2] = 1
L1_map[3] = 2
L1_map[4] = 3
L1_map[5] = 3
L1_map[6] = 3
while True:
    half = size_map[L]//2+1
    if L < 2:
        patty_sum += L1_map[X]
        break
    if X > half:
        patty_sum += patty_num_map[L-1]+1  # 真ん中のpattyの分
        # X -= half+1  # 一番上のバティの分
        X -= half
        L -= 1
    elif X < half:
        X -= 1  # 一番下のバンの分
        L -= 1
    else:  # ちょうど半分
        patty_sum += patty_num_map[L-1]+1
        break
print(patty_sum)

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

# (i)XがLバーガーの半分より上かどうか？を計算
# (ii-i)上の場合: sumに下半分のパティの数を加算。下半分を切り捨てて、L-1バーガに対して、
#        再度X = (X-(Lバーガーの半分の枚数))で(i)から計算
# (ii-ii)下の場合: 上半分を切り捨てて、L-1バーガに対して再度X = (X-(Lバーガーの半分の枚数))で(i)から計算

patty_num_map = {}
size_map = {}
patty_num_map[0] = 1
size_map[0] = 1
for i in range(1, 51):
    patty_num_map[i] = 1+patty_num_map[i-1]*2
    size_map[i] = 3+size_map[i-1]*2

L = N
patty_sum = 0
L1_map = {}
L1_map[0] = 0
L1_map[1] = 0
L1_map[2] = 1
L1_map[3] = 2
L1_map[4] = 3
L1_map[5] = 3
while True:
    half = size_map[L]//2+1
    if L < 2:
        patty_sum += L1_map[X]
        break
    if X > half:
        patty_sum += patty_num_map[L-1]+1  # 真ん中のpattyの分
        # X -= half+1  # 一番上のバティの分
        X -= half
        L -= 1
    elif X < half:
        X -= 1  # 一番下のバンの分
        L -= 1
    else:  # ちょうど半分
        patty_sum += patty_num_map[L-1]+1
        break
print(patty_sum)
Problem p03127 (python)

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

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


ans = 0
for ai in a:
    ans = gcd(ans, ai)

print(ans)

Buggy submission (verdict: Runtime Error):
import math

n = int(input())
a = [int(i) for i in input().split()]

ans = 10 ** 9
for ai in a:
    ans = math.gcd(ans, ai)

print(ans)
Problem p03775 (python)

Fixed submission:
n = int(input())
import math as ms
dic = []
for i in range(1,ms.floor(ms.sqrt(n)) + 1):
    if n % i == 0:
        dic.append([i,n // i]) 
f = []
for i in range(len(dic)):
    a = ms.floor(ms.log10(dic[i][0])) + 1
    b = ms.floor(ms.log10(dic[i][1])) + 1
    f.append(max(a,b))
    
print(min(f))

Buggy submission (verdict: Runtime Error):
n = int(input())
import math as ms
dic = []
for i in range(1,ms.floor(n / 2) + 1):
    if n % i == 0:
        dic.append([i,n // i])
    
f = []
for i in range(len(dic)):
    a = ms.floor(ms.log10(dic[i][0])) + 1
    b = ms.floor(ms.log10(dic[i][1])) + 1
    f.append(max(a,b))
    
print(min(f))
Problem p03135 (python)

Fixed submission:
t,x = map(int,input().split())
print(t/x)

Buggy submission (verdict: Runtime Error):
T = int(T)
X = int(X)
t = T / X

Buggy submission (verdict: Runtime Error):
T = input("T")
T = int(T)
X = input("X")
X = int(X)
t = T / X
Problem p03327 (python)

Fixed submission:
n = int(input())
if n <= 999:
    print("ABC")
else:
    print("ABD")

Buggy submission (verdict: Runtime Error):
n = int(input())
if n <= 999:
    print(ABC)
else:
    print(ABD)
Problem p03127 (python)

Fixed submission:
#N, M = map(int, input().split())
#
#ans = [0 for i in range(M)]
#
#for i in range(N):
#    tmp = list(map(int, input().split()))
#    for j in range(tmp[0]):
#        ans[tmp[j]]+=1
#        
#now = 0
#        
#for i in range(M):
#    if ans[i]==N:
#        now+=1
#        
#print(now)

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

def gcd(a, b):
    if a<b:
        b,a = a,b
        
    while b:
        a, b = b, a%b
    
    return a


ans = 0
now = a[0]

for i in range(N-1):
    tmp = gcd(now, a[i+1])
    now = tmp

    
print(now)

Buggy submission (verdict: Runtime Error):
#N, M = map(int, input().split())
#
#ans = [0 for i in range(M)]
#
#for i in range(N):
#    tmp = list(map(int, input().split()))
#    for j in range(tmp[0]):
#        ans[tmp[j]]+=1
#        
#now = 0
#        
#for i in range(M):
#    if ans[i]==N:
#        now+=1
#        
#print(now)
import math

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

        
ans = 0
now = a[0]

for i in range(N-1):
    now = math.gcd(now, a[i+1])

    
print(now)
Problem p03345 (python)

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

if N % 2 == 0:
    ans = a - b
else:
    ans = b - a

if abs(ans) > 10**18:
    print('Unfair')
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
a, b, c, N = map(int, raw_input().split())

if N % 2 == 0:
    ans = a - b
else:
    ans = b - a

if abs(ans) > 10^18:
    print('Unfair')
else:
    print(ans)
Problem p03631 (python)

Fixed submission:
N=int(input())

if N//100==N%10:
  print("Yes")
else:
  print("No")

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

if N//100=N%10:
  print("Yes")
else:
  print("No")
Problem p03774 (python)

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

N_ab = []
M_cd = []

for i in range(n):
  a, b = map(int, input().split())
  N_ab.append([a, b])
  
for i in range(m):
  c, d = map(int, input().split())
  M_cd.append([c, d])
  
for i in range(n):
  Mi = abs(N_ab[i][0]-M_cd[0][0]) + abs(N_ab[i][1]-M_cd[0][1])
  #print(Mi)
  num = 0
  for j in range(1, m):
    tmp = abs(N_ab[i][0]-M_cd[j][0]) + abs(N_ab[i][1]-M_cd[j][1])
    #print(tmp)
    if tmp<Mi:
      Mi=tmp
      num=j
  print(num+1)

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

N_ab = []
M_cd = []

for i in range(n):
  a, b = map(int, input().split())
  N_ab.append([a, b])
  
for i in range(n):
  c, d = map(int, input().split())
  M_cd.append([c, d])
  
for i in range(n):
  Mi = abs(N_ab[i][0]-M_cd[0][0]) + abs(N_ab[i][1]-M_cd[0][1])
  #print(Mi)
  num = 0
  for j in range(1, m):
    tmp = abs(N_ab[i][0]-M_cd[j][0]) + abs(N_ab[i][1]-M_cd[j][1])
    #print(tmp)
    if tmp<Mi:
      Mi=tmp
      num=j
  print(num+1)
Problem p03135 (python)

Fixed submission:
t,x = map(int,input().split())
print(t/x)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
a = []
ans = 0
for i in range(m-1):
  a.append(x[i+1]-x[i])
a.sort()
if n >= m:
  print(0)
else:
  for i in range(m-n):
    ans += a[i]
  print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
a = []
ans = 0
for i in range(m-1):
  a.append(x[i+1]-x[i])
a.sort()
if n >= m:
  print(0)
else:
  for i in range(m-n+1):
    ans += a[i]
  print(ans)
Problem p03137 (python)

Fixed submission:
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
a = []
ans = 0
for i in range(m-1):
  a.append(x[i+1]-x[i])
a.sort()
if n >= m:
  print(0)
else:
  for i in range(m-n):
    ans += a[i]
  print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
a = []
ans = 0
for i in range(m-1):
  a.append(x[i+1]-x[i])
if n >= m:
  print(0)
else:
  for i in range(m-n+1):
    ans += a[i]
  print(ans)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
a = []
for i in range(m-1):
  a.append(x[i+1]-x[i])
if n >= m:
  print(0)
  else:
    for i in range(n-1):
      a.remove(max(a))
    print(sum(a))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
x = list(map(int,input().split())).sorted()
a = []
for i in range(m-1):
  a.append(x[i+1]-x[i])
if n >= m:
  print(0)
  else:
    for i in range(n-1):
      a.remove(max(a))
    print(sum(a))
Problem p03208 (python)

Fixed submission:
n,k = map(int,input().split())
a = [int(input()) for i in range(n)]
a.sort()
ans = []
for i in range(n-k+1):
 ans.append(a[i+k-1] - a[i])
print(min(ans))

Buggy submission (verdict: Runtime Error):
n,k = map(int,input())
a = [int(input()) for i in range(n)]
a.sort()
ans = []
for i in range(n-k+1):
 ans.append(a[i+k-1] - a[i])
print(min(ans))
Problem p03250 (python)

Fixed submission:
a = list(map(int,input().split()))
a.sort(reverse=True)
print(a[0]*10 + a[1] + a[2])

Buggy submission (verdict: Runtime Error):
a, = list(map(int,input().split()))
a.sort(reverse=True)
print(10*a[0] + a[1] +a[2])
Problem p03265 (python)

Fixed submission:
x1,y1,x2,y2 = map(int,input().split())
d1 = x2-x1
d2 = y2-y1
x3 = x2 - d2
y3 = y2 + d1
x4 = x1 - d2
y4 = y1 + d1
print(x3,y3,x4,y4)

Buggy submission (verdict: Runtime Error):
x1,y1,x2,y2 = map(int,input().split())
d1 = abs(x2-x1)
d2 = abs(y2-y1)
x3 = x2 + d2
y3 = y2 + d1
x4 = x1 + d1
y4 = y1 + d2
print(x3 y3 x4 y4)
Problem p03631 (python)

Fixed submission:
N =list(input())
if N[0] == N[2]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
ans = 0
for i in range(101):
  if a <= i < b and c <= i < d:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
ans = 0
for i in range(101):
  if a < i < b and c < i < d:
    ans += 1
print(ans+1)

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input().split())
ans = 0
for i in range(101):
  if a < i < b and c < i < d
  ans += 1
print(ans+1)
Problem p03803 (python)

Fixed submission:
a,b = map(int,input().split())
if a == 1:
  a += 13
if b == 1:
  b += 13
if a > b:
  print("Alice")
if a < b:
  print("Bob")
if a == b:
  print("Draw")

Buggy submission (verdict: Runtime Error):
a,b = int(input())
if a == 1:
  a += 13
if b == 1:
  b += 13
if a > b:
  print("Alice")
if a < b:
  print("Bob")
if a == b:
  print("Drow")
Problem p03834 (python)

Fixed submission:
s =input()
print(s.replace(","," "))

Buggy submission (verdict: Runtime Error):
print(input().replace(","," ")
Problem p03295 (python)

Fixed submission:
n,m = [int(i) for i in input().split()]
e = [[int(j) for j in input().split()] for i in range(m)]
new_e =sorted(e,key= lambda x : x[1])
s=[]
for i in new_e:
  if s!= [] and i[0]<=s[-1]:
    pass
  else:
    s.append(i[1]-1)

print(len(s))

Buggy submission (verdict: Runtime Error):
n,m = [int(i) for i in input().split()]
e = [[int(j) for j in input().split()] for i in range(m)]
sorted(e,key= lambda x : x[1])
s=[]
for i in e:
  if i[0]<=s[-1] and s!=[]:
    pass
  else:
    s.append(i[1]-1)
    
print(len(s))

Buggy submission (verdict: Runtime Error):
n,m = [int(i) for i in input().split()]
e = [[int(j) for j in input().split()] for i in range(m)]
sorted(e,key= lambda x : x[1])
s=[]
for i in e:
  if i[0]<=s[-1]:
    pass
  else:
    s.append(i[1]-1)
    
print(len(s))

Buggy submission (verdict: Runtime Error):
n,m = (int(i) for i in input().split())
e = [[int(i) for i in input.split()] for i in range(n)]

s =[]
for cmd in e:
  if s==[]:
    s.append(cmd)
  else:
    found = False
    for tmp in s:
      if cmd[0]>=tmp[0] and cmd[0]<tmp[1]:
        tmp[0]=cmd[0]
        found = True
      if cmd[1]>tmp[0] and cmd[1]<=tmp[0]:
        tmp[1]=cmd[1]
        found = True
    if found == False:
      s.append(cmd)
      
print(len(size))
Problem p03137 (python)

Fixed submission:

import sys

N, M = [int(x) for x in input().split()]
nums = list(set([int(x) for x in input().split()]))

if not nums:
    print(0)
    sys.exit()

if N >= M:
    print(0)
    sys.exit()

nums.sort()

rank = [(abs(nums[i] - nums[i-1]), (i-1, i)) for i in range(1, len(nums))]
rank = sorted(rank, reverse=True)[:N-1]

pos = [0] + [pos[1] for dis, pos in rank]
pos.sort()
ans = 0
for i in range(len(pos)):
    if i == len(pos)-1:
        ans += abs(nums[pos[i]] - nums[-1])
    else:
        ans += abs(nums[pos[i]] - nums[pos[i+1]-1])

print(ans)

Buggy submission (verdict: Runtime Error):

import sys

N, M = [int(x) for x in input().split()]
nums = [int(x) for x in input().split()]

if not nums:
    print(0)
    sys.exit()

if N >= M:
    print(0)
    sys.exit()

mem = {}
nums.sort()

def find_max(pivot, places):

    if (pivot, len(places)) in mem:
        return mem[(pivot, len(places))]

    if len(places) == N:
        mem[(pivot, len(places))] = abs(nums[pivot] - nums[-1])
        return mem[(pivot, len(places))]

    local_min = float('inf')
    for i in range(pivot+1, len(nums) - (N - len(places) - 1)):
        tmp = abs(nums[pivot] - nums[i-1]) + find_max(i, places + [i])
        if tmp < local_min:
            local_min = tmp
    mem[(pivot, len(places))] = local_min
    return mem[(pivot, len(places))]

ans = find_max(0, [0])

print(ans)

Buggy submission (verdict: Runtime Error):

import sys

N, M = [int(x) for x in input().split()]
nums = [int(x) for x in input().split()]
nums.sort()

ans = [float('inf')]

if N >= M:
    print(0)
    sys.exit()

mem = {}

def find_max(pivot, places):

    if (pivot, len(places)) in mem: return mem[(pivot, len(places))]

    if len(places) == N:
        mem[(pivot, len(places))] = abs(nums[pivot] - nums[-1])
        return mem[(pivot, len(places))]

    local_min = float('inf')
    for i in range(pivot+1, len(nums) - (N - len(places) - 1)):
        tmp = abs(nums[pivot] - nums[i-1]) + find_max(i, places + [i])
        if tmp < local_min:
            local_min = tmp
    mem[(pivot, len(places))] = local_min
    return mem[(pivot, len(places))]

ans = find_max(0, [0])

print(ans)

Buggy submission (verdict: Runtime Error):

import sys

N, M = [int(x) for x in input().split()]
nums = [int(x) for x in input().split()]
nums.sort()

ans = [float('inf')]

if N >= M:
    print(0)
    sys.exit()


def find_max(pivot, places, s):
    if len(places) == N:
        s += abs(nums[places[-1]] - nums[-1])
        if s < ans[0]:
            ans[0] = s
        return

    for i in range(pivot+1, len(nums) - (N - len(places) - 1)):
        tmp = s + abs(nums[pivot] - nums[i-1])
        if tmp > ans[0]: continue
        find_max(i, places + [i], tmp)

find_max(0, [0], 0)

print(ans[0])
Problem p03135 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
a,b = map(int, input().split())
# 出力
print(a/b)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# Nの取得
index = int(input('input num : '))
 
# n回ループして配列に入れる
maximum = 0
other = 0
inputList = input().split()
for i in range(index):
    tmp = int(inputList[i])
    if tmp > maximum:
        maximum = tmp
        other = other + maximum
    else:
        other = other + tmp
 
if maximum <= tmp - maximum :
    print("Yes")
else:
    print("No")
Problem p03805 (python)

Fixed submission:
num = list(map(int,raw_input().split()))
point = num[0]
line = num[1]
total = 0
d = {}
for i in range (point):
    d[i+1] = []
for i in range(line):
    pair = list(map(int,raw_input().split()))
    d[pair[0]].append(pair[1])
    d[pair[1]].append(pair[0])
old_list = []
new_list = [[1]]
for i in range (point-1):
    old_list = new_list[:]
    new_list =[]
    for j in old_list:
        for k in d[j[-1]]:
            if k in j:
                pass
            else:
                j.append(k)
                new_list.append(j[:])
                j.pop()
print len (new_list)

Buggy submission (verdict: Runtime Error):
num = list(map(int,raw_input().split()))
point = num[0]
line = num[1]

d = {}
for i in range (point):
    d[i+1] = []
for i in range(point):
    pair = list(map(int,raw_input().split()))
    d[pair[0]].append(pair[1])
    d[pair[1]].append(pair[0])
old_list = []
new_list = [[1]]
for i in range (point-1):
    old_list = new_list[:]
    new_list =[]
    for j in old_list:
        for k in d[j[-1]]:
            if k in j:
                pass
            else:
                j.append(k)
                new_list.append(j[:])
                j.pop()
print len (new_list)
Problem p03137 (python)

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

Xi.sort()

Li = [Xi[i] - Xi[i-1] for i in range(1,len(Xi))]
Li.sort()

if N == M or N > M:
    print(0)
else:
    for _ in range(N-1):
        Li.pop(-1)
    print(sum(Li))

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

Xi.sort()

Li = [Xi[i] - Xi[i-1] for i in range(1,len(Xi))]
Li.sort()

if N == M:
    print(0)
else:
    for _ in range(N-1):
        Li.pop(-1)
print(sum(Li))
Problem p03137 (python)

Fixed submission:
n, m = list(map(int, input().split()))
xxx = list(map(int, input().split()))
 
if n >= m:
    print(0)
    exit()
xxx.sort()
ddd = [b - a for a, b in zip(xxx, xxx[1:])]
ddd.sort()
print(sum(ddd[:m - n]))

Buggy submission (verdict: Runtime Error):
nm = [int(i) for i in input().split()]
points = sorted([int(i) for i in input().split()])
n, m = nm[0], nm[1]

if n >= m:
    print(0)
elif n == 1:
    print(max(points) - min(points))
else:
    list_diff = [points[i+1] - points[i] for i in range(m-1)]
    list_th = []
    for i in range(n-1):
        max_index = list_diff.index(max(list_diff))
        list_th.append(max_index)
        list_diff[max_index] = 0
        
    x = points[0]
    th = 0
    count = 0
    print(list_th)
    while x < points[-1]:
        if x == points[list_th[th]]:
            x = points[list_th[th]+1]
            th += 1
        else:
            x += 1
            count += 1
            if x == points[-1]:
                break
    print(count)
Problem p03201 (python)

Fixed submission:
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


n = int(input())
a = list(map(int, input().split()))
a.sort()
max_a = a[-1]
m = 0
while True:
    if 2**m > max_a:
        break
    m += 1
used = [False] * n


def bisect(val, start, end):
    if start >= end:
        return None
    elif start + 1 == end:
        if a[start] == val:
            if used[start]:
                return None
            used[start] = True
            return start
        else:
            return None
    mid = (start + end) // 2
    if a[mid] == val:
        if used[mid]:
            res = bisect(val, start, mid)
            return res
        else:
            res = bisect(val, mid+1, end)
            if res is not None:
                return res
            used[mid] = True
            return mid
        # if used[mid]:
        #     res = bisect(val, mid+1, end)
        #     if res is not None:
        #         return res
        #     res = bisect(val, start, mid)
        #     return res
        # else:
        #     used[mid] = True
        #     debug("fuga", used)
        #     return mid
    elif a[mid] > val:
        return bisect(val, start, mid)
    else:
        return bisect(val, mid, end)
    # for i in reversed(range(end)):
    #     if (not used[i]) and (a[i]  == val):
    #         used[i] = True
    #         return i
    return None


def _find(b, end, e):
    "slow!!!!"
    # debug(b, end, e)
    val = 2**e - b
    if val <= 0:
        return None
    return bisect(val, 0, end)
    # for i in reversed(range(end)):
    #     if (not used[i]) and (a[i] + b == 2**e):
    #         used[i] = True
    #         return i
    # return None


def find(b, end):
    for e in reversed(range(m+1)):
        res = _find(b, end, e)
        if res is not None:
            return True
    return False


ans = 0
for j in reversed(range(n)):
    if used[j]:
        continue
    b = a[j]
    used[j] = True
    res = find(b, j)
    if res:
        ans += 1


print(ans)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import os
def debug(*args): print(*args, file=sys.stderr)# os.environ.get("USER")
N=int(input())
A=[int(i) for i in input().split()]
dd=defaultdict(int)
for a in A:
    dd[a]+=1
#print(dd)
B=sorted(A,reverse=True)
ans=0
for x in B:
    debug(A)
    #print(x)
    if dd.get(x,-1)==0:
        continue
    s=len(bin(x))-3
    if x==1<<s:
        t=dd.get(x,-1)
        if t!=-1:
            ans+=t//2
            dd[x]-=(t//2)*2
            #print(ans)
            #print(dd)
    else:
        s+=1
        #print((1<<s)-x)
        t=dd.get((1<<s)-x,-1)
        if t>=1:
            ans+=1
            dd[x]-=1
            dd[(1<<s)-x]-=1
            #print(ans)
            #print(dd)
print(ans)
Problem p03776 (python)

Fixed submission:
from math import factorial as f

N, A, B = map(int, input().split())
v = list(map(int, input().split()))

v.sort()


sum_v = 0
for i in range(N-A+1, N):
    sum_v += v[i]

i_max = N+1
count_max = 1
sum_max = 0

max_nums = []
if A == 1:
    current_num = -1
    current_count = 0
else:
    current_num = v[N-A+1]
    current_count = v[N-A+1:].count(v[N-A+1])
for i in range(N-A, N-B-1, -1):
    if v[i] == current_num:
        current_count += 1
    else:
        current_num = v[i]
        current_count = 1
    count = N-i
    sum_v += v[i]
    if sum_v * count_max > sum_max * count:
        count_max = count
        sum_max = sum_v
        max_nums = [(v[i], current_count)]
    elif sum_v * count_max == sum_max * count:
        if v[i] not in max_nums:
            max_nums.append((v[i], current_count))

def count(vi):
    return v.count(vi)

def c(n, k):
    return f(n)//(f(k)*f(n-k))

ans = 0
for vi, cc in max_nums:
    ans = ans + c(count(vi), cc)
    # print(vi, count(vi), cc)

print(sum_max/count_max)
print(ans)

Buggy submission (verdict: Runtime Error):
# from math import inf
inf = 10**50

N, M = map(int, input().split())
edges = []
for j in range(M):
    edges.append(list(map(int, input().split())))

d = [0] + ([-inf]*(N-1))
pred = [None] * N

for i in range(N-1):
    for j in range(M):
        u = edges[j][0]-1
        v = edges[j][1]-1
        w = edges[j][2]
        if (d[v] < d[u] + w) and (d[u] != -inf):
            d[v] = d[u] + w
            pred[v] = u

positive_loop = False
for i in range(N):
    for j in range(M):
        u = edges[j][0]-1
        v = edges[j][1]-1
        w = edges[j][2]
        if (v == N-1) and (d[u] + w > d[v]) and (d[u] != -inf):
            positive_loop = True
            break
    if positive_loop:
        break

if positive_loop:
    print("inf")
else:
    print(d[N-1])
Problem p03186 (python)

Fixed submission:
a,b,c = map(int,input().split())
print(b + min(a+b+1,c))

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input.split())
print(b+min(a+b+1,c))