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

Fixed submission:
from sys import stdin
import math

n, m = [int(x) for x in stdin.readline().rstrip().split()]

s = [0] * m
c = [0] * m
for i in range(m):
    s[i], c[i] = [int(x) for x in stdin.readline().rstrip().split()]

result = -1
for nn in range(10 ** n):
    ns = str(nn)
    if len(ns) < n:
        continue
    #ns = ns.zfill(n)
    flag = True
    for i in range(m):
        if ns[s[i]-1] == str(c[i]):
            continue
        else:
            flag = False
            break
    if flag:
        result = nn
        if n > 1 and result == 0:
            result = -1
        break

print(result)

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())
li = []
for _ in range(m):
    li.append(list(map(int,input().split())))
li = list(map(list, set(map(tuple, li))))
li = sorted(li)
number = 0
for i in range(len(li)-1):
    if li[i][0] == li[i+1][0]:
        print(-1)
        exit()
    else:
        number += li[i][1] * (10 ** (n-li[i][0])    )
number += li[len(li)-1][1] * (10 ** (n-li[len(li)-1][0])    )
if li[0][0] == 1 and li[0][1] == 0 and n >= 2:
    print(-1)
    exit()
print(number)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
li = []
itg = 0
flag = True
for _ in range(m):
  li.append(list(map(int,input().split())))
li = sorted(li, key = lambda x:x[0], reverse=True)
for i in range(m-1):
  if li[i][0] == li[i+1][0]:
    if li[i][1] != li[i+1][1]:
      print(-1)
      flag = False
    else:
      li[i][1] = 0
if flag:
  k = li[0][0]
  for l in li:
    itg += l[1] * (10 ** (k-l[0]))
  if len(str(itg)) > n:
    print(-1)
  elif itg == 0 and n >= 2:
    print(-1)
  else:
    print(itg)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
li = []
itg = 0
flag = True
for _ in range(m):
  li.append(list(map(int,input().split())))
li = sorted(li, key = lambda x:x[0], reverse=True)
for i in range(m-1):
  if li[i][0] == li[i+1][0]:
    if li[i][1] != li[i+1][1]:
      print(-1)
      flag = False
    else:
      li[i][1] = 0
if flag:
  k = li[0][0]
  for l in li:
    itg += l[1] * (10 ** (k-l[0]))
  print(itg)
Problem p02888 (python)

Fixed submission:
import bisect

n = int(input())
li = list(map(int,input().split()))
li2 = sorted(li)
cnt = 0

for i in range(n-2):
    for j in range(i+1,n-1):
        cnt += bisect.bisect_left(li2,li2[i]+li2[j]) - (j+1) 
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
li = list(map(int,input().split()))
li2 = sorted(li,reverse=True)
cnt = 0

for i in range(n):
    for j in range(i+1,n):
        if li2[i] > li2[j] + li2[j+1]:
            break
        else:
            for k in range(j+1,n):
                if li2[i] < li2[j]+li2[k]:
                    cnt += 1
                else:
                    break
print(cnt)
Problem p02900 (python)

Fixed submission:
from fractions import gcd

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)

    return arr
  
a = factorization(a)
b = factorization(b)
if (len(a)==1 and a[0] == 1) or (len(b)==1 and b[0] == 1):
  print(1)
else:
  print(len(set(a) & set(b)) + 1)

Buggy submission (verdict: Runtime Error):
from fractions import gcd

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
if a == 1 or b == 1:
  print(1)
else:
  print(len(set(factorization(a)) & set(factorization(b))) + 1)

Buggy submission (verdict: Runtime Error):
from fractions import gcd

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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(i)

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

print(len(set(factorization(a)) & set(factorization(b))) + 1)

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

MinNum = 1
MaxNum = gcd(a,b)
PrimeNum_list = []

CheckNum = 0
for i in range(MinNum,MaxNum):
    for j in range(2,i+1):
        if i%j==0: CheckNum+=1
        if CheckNum == 2: break

    if CheckNum == 1 and MaxNum % i == 0:
        PrimeNum_list.append(i)
    CheckNum = 0

print(len(PrimeNum_list)+1)
Problem p02911 (python)

Fixed submission:
n,k,q = map(int,input().split())
li = [k-q] * n
numli = [int(input()) for i in range(q)]
for a in numli:
    li[a-1] += 1
for i in li:
    if i > 0:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
n,k,q = map(int,input().split())
li = [k-q] * n
numli = [int(input()) for i in range(q)]
for a in numli:
    li[a-1] += 1
for i in li:
    if i > 0
        print("Yes")
    else:
        print("No")
Problem p02924 (python)

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

Buggy submission (verdict: Runtime Error):
i = int(input())
print(int(n*(n-1)/2))
Problem p02947 (python)

Fixed submission:
N = int(input())
s_dict = {}
ans = 0
for i in range(N):
  string = list(input())
  string.sort(reverse=False)
  if tuple(string) in s_dict:
    s_dict[tuple(string)] += 1
  else:
    s_dict[tuple(string)] = 1

for i in s_dict.values():
  if i != 1:
    ans += sum([i for i in range(1,i)])

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = {}
total = 0

for i in range(n):
    string = list(input())
    string.sort(reverse = False)
    if tuple(string) in s:
        s[tuple(string)] += 1
    else:
        s[tuple(string)] = 1

for i in s:
    if i != 1:
        total += sum([i for i in range(1,i)])

print(total)
Problem p02957 (python)

Fixed submission:
a,b = map(int,input().split())
if(a % 2 != b % 2):
    print("IMPOSSIBLE")
else:
    print(int((a+b)/2))

Buggy submission (verdict: Runtime Error):
a,b = int(input().split())
if(a % 2 != b % 2):
    print("IMPOSSIBLE")
else:
    print((a+b)/2)
Problem p03001 (python)

Fixed submission:
W, H, x, y = map(int, input().rstrip().split())
 
max_area = W * H / 2.0
if x == W / 2 and y == H / 2:
    print(max_area, 1)
else:
    print(max_area, 0)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def lcm(a, b):
	return a * b // gcd (a, b)

a,b,c,d = map(int,input().split())
ac_can = int((a-1)//c)
ad_can = int((a-1)//d)
acd_can = int((a-1)//lcm(c,d))
bc_can = int(b//c)
bd_can = int(b//d)
bcd_can = int(b//lcm(c,d))
print(b-a+1-(bc_can+bd_can-bcd_can-(ac_can+ad_can-acd_can)))
Problem p03029 (python)

Fixed submission:
a,p = map(int,input().split())
print(int((a*3+p)/2))

Buggy submission (verdict: Runtime Error):
a,p = map(int,input().split()
print(int((a*3+p)/2))

Buggy submission (verdict: Runtime Error):
a,p = map(int,input().split()
print((a*3+p)/2
Problem p03037 (python)

Fixed submission:
n,m = map(int,input().split())
li = [list(map(int,input().split())) for _ in range(m)]
maxl = max(li, key=lambda x:x[0])[0]
minr = min(li, key=lambda x:x[1])[1]
if maxl <= minr:
    print(minr-maxl+1)
else:
    print(0)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
li = [list(map(int,input().split())) for _ in range(m)]
maxl = max(li, key=lambda x:x[0])[0]
minr = min(li, key=lambda x:x[1])[1]
if maxl <= minr:
    print(r-l+1)
else:
    print(0)
Problem p03062 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(n):
    if a[i] == 0:
        cnt -= 1000000000000
        break
    elif a[i] < 0:
        cnt += 1
a = [abs(a[i]) for i in range(n)]
if cnt < 0 or cnt % 2 == 0:
    print(sum(a))
else:
    print(sum(a) - 2*min(a))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
cnt = 0
for i in range(n):
    if a[i] == 0:
        cnt -= 1000000000000
        break
    elif a[i] < 0:
        cnt += 1
a = [abs(a[i]) for i in range(n)]
if cnt < 0 or num % 2 == 0:
    print(sum(a))
else:
    print(sum(a) - 2*min(a))
Problem p03076 (python)

Fixed submission:
import itertools
C = []
for i in range(5):
    C.append(int(input()))

ans = float("inf")
for order in itertools.permutations(C, 5):
    total = 0
    for c in order:
        if total % 10 != 0:
            total = (total // 10 + 1) * 10
        total += c

    ans = min(total, ans)

print(ans)

Buggy submission (verdict: Runtime Error):
li = []
lis = []
time = 0
for i in range(5):
    li.append(int(input()))
    lis.append(li[i] % 10)
lista = sorted(lis)
a = lista
for i in range(5):
    if lista[i] != 0:
        a = lista[i]
        break
last = lis.index(a)
for i in range(5):
    if i == last:
        continue
    elif lis[i] == 0:
        time += li[i]
    elif 1 <= li[i] <= 9:
        time += 10
    else:
        time += int(li[i] / 10) * 10 + 10
print(time + li[last])

Buggy submission (verdict: Runtime Error):
li = []
lis = []
time = 0
for i in range(5):
    li.append(int(input()))
    lis.append(li[i] % 10)
lista = sorted(lis)
for i in range(5):
    if lista[i] != 0:
        a = lista[i]
        break
last = lis.index(a)
for i in range(5):
    if i == last:
        continue
    elif lis[i] == 0:
        time += li[i]
    elif 1 <= li[i] <= 9:
        time += 10
    else:
        time += int(li[i] / 10) * 10 + 10
print(time + li[last])
Problem p03145 (python)

Fixed submission:
a,b,c = map(int,input().split())
print(int(a*b/2))

Buggy submission (verdict: Runtime Error):
n = int(input())
h = list(map(int,input().split()))
ans = h[0]
for i in range(1,n):
    if h[i-1] < h[i]:
        ans += h[i]-h[i-1]
print(ans)
Problem p03220 (python)

Fixed submission:
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
dif = 1000
for i in range(N):
    Tx = T - H[i] * 0.006
    if  abs(Tx - A) < dif:
        dif = abs(Tx - A)
        ans = i + 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
t,a = map(int,input().split())
li = list(map(int,input().split()))
nearest = 0
for i in li:
    if abs(nearest - a) < abs((t - i * 0.006) - a):
        nearest = i
print(li.index(nearest) + 1)

Buggy submission (verdict: Runtime Error):
n = int(input())
t,a = map(int,input().split())
li = list(map(int,input().split()))
nearest = 0
for i in li:
    if abs(nearest - a) > abs((t - i * 0.006) - a):
        nearest = i
print(li.index(nearest))

Buggy submission (verdict: Runtime Error):
n = int(input())
t,a = map(int,input().split())
li = list(map(int,input().split()))
nearest = 0
for i in li:
    if abs(nearest - a) > abs((t - i * 0.006) - a):
        nearest = i
print(l.index(nearest) + 1)
Problem p03285 (python)

Fixed submission:
n = int(input())
max_f = int(n / 4)
max_s = int(n / 7)
switch = 0
for i in range(max_s + 1):
    for j in range(max_f + 1):
        if (7 * i + 4 * j) == n:
            switch = 1
if switch == 1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
max_f = int(n / 4)
max_s = int(n / 7)
switch = 0
for i in range(max_s + 1):
    for j in range(max_f + 1):
        if (7 * i + 4 * j) == n:
            switch = 1
if switch == 1:
    print(Yes)
else:
    print(No)
Problem p03316 (python)

Fixed submission:
n = input()
li = []
for i in n:
  li.append(int(i))
if int(n) % sum(li) == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
n = input()
li = []
for i in n:
  li.append(int(i))
if n % sum(li) == 0:
  print("Yes")
else:
  print("No")
Problem p03436 (python)

Fixed submission:
from collections import deque

def bfs():
    d = [[inf]*(w+1) for _ in range(h+1)]
    que = deque()
    que.append((0,0))
    d[0][0] = 0

    while que:
        cx,cy = que.popleft()
        if cx == w and cy == h:
            break
        for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
            nx, ny = cx+dx, cy+dy
            if 0 <= nx <= h and 0 <= ny <= w and s[nx][ny] != "#" and d[nx][ny] == inf:
                que.append((nx,ny))
                d[nx][ny] = d[cx][cy] + 1
    return d[h][w]

h,w = map(int,input().split())
s = [list(input()) for _ in range(h)]
inf = float("inf")
h,w = h-1,w-1
cnt = bfs()
dot = 0
for i in s:
    dot += i.count(".")
if 0 < cnt < inf:
  print(dot-cnt-1)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
from collections import deque

def bfs():
    d = [[inf]*(w+1) for _ in range(h+1)]
    que = deque()
    que.append((0,0))
    d[0][0] = 0

    while que:
        cx,cy = que.popleft()
        if cx == w and cy == h:
            break
        for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
            nx, ny = cx+dx, cy+dy
            if 0 <= nx <= w and 0 <= ny <= h and s[nx][ny] != "#" and d[nx][ny] == inf:
                que.append((nx,ny))
                d[nx][ny] = d[cx][cy] + 1
    return d[w][h]

h,w = map(int,input().split())
s = [list(input()) for _ in range(h)]
inf = float("inf")
h,w = h-1,w-1
cnt = bfs()
dot = 0
for i in s:
    dot += i.count(".")
if 0 < cnt < inf:
  print(dot-cnt-1)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
from collections import deque

def bfs():
    d = [[inf]*(w+1) for _ in range(h+1)]
    que = deque()
    que.append((0,0))
    d[0][0] = 0

    while que:
        cx,cy = que.popleft()
        if cx == w and cy == h:
            break
        for dx,dy in [[1,0],[-1,0],[0,1],[0,-1]]:
            nx, ny = cx+dx, cy+dy
            if 0 <= nx <= w and 0 <= ny <= h and s[nx][ny] != "#" and d[nx][ny] == inf:
                que.append((nx,ny))
                d[nx][ny] = d[cx][cy] + 1
    return d[w][h]

h,w = map(int,input().split())
s = [list(input()) for _ in range(h)]
inf = float("inf")
h,w = h-1,w-1
cnt = bfs()
sharp = 0
for i in s:
    sharp += i.count("#")
print((h+1)*(w+1)-sharp-cnt)
Problem p03455 (python)

Fixed submission:
a = list(map(int, input().split()))
if a[0] % 2 == 0 or a[1] % 2 == 0:
	print("Even")
else:
	print("Odd")

Buggy submission (verdict: Runtime Error):
li = list(map(int,input().split())
if li[0] % 2 == 0 or li[1] & 2 == 0:
    print("Evem")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
li = list(map(int(input().split()))
if li[0] % 2 == 0 or li[1] & 2 == 0:
    print("Evem")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
li = list(map(intinput().split())
if li[0] % 2 == 0 or li[1] & 2 == 0:
    print("Evem")
else:
    print("Odd")

Buggy submission (verdict: Runtime Error):
a,b = int(input().split())
if a % 2 == 0 or b & 2 == 0:
    print("Evem")
else:
    print("Odd")
Problem p03610 (python)

Fixed submission:
s = input()
cnt = 0
strings = ""
for i in s:
    if cnt % 2 == 0:
        strings = strings + i
    cnt += 1
print(strings)

Buggy submission (verdict: Runtime Error):
s = input()
cnt = 0
strings = ""
for i in s:
    if cnt % 2 == 0:
        strings.= strings + i
print(strings)
Problem p03962 (python)

Fixed submission:
li = list(map(int,input().split()))
cnt = 3
if li[0] == li[1]:
	cnt -= 1
if li[0] == li[2]:
	cnt -= 1
if li[1] == li[2]:
	cnt -= 1
if li[0] == li[1] and li[1] == li[2]:
	cnt = 1
print(cnt)

Buggy submission (verdict: Runtime Error):
li ~ list(map(int,input().split()))
cnt = 3
if li[0] == li[1]:
	cnt -= 1
if li[0] == li[2]:
	cnt -= 1
if li[1] == li[2]:
	cnt -= 1
if li[0] == li[1] and li[1] == li[2]:
	cnt = 1
print(cnt)
Problem p04001 (python)

Fixed submission:
def dfs(i, f):
    if i == len(s) - 1:
        return sum(list(map(int,f.split("+"))))

    return dfs(i+1, f + s[i+1]) + dfs(i+1, f + "+" + s[i+1])

s = input()
print(dfs(0,s[0]))

Buggy submission (verdict: Runtime Error):
def dfs(i, sum):
    if i == len(s) - 1:
        return sum(list(map(int,sum.split("+"))))

    return dfs(i+1, sum + s[i+1]) + dfs(i+1, sum + "+" + s[i+1])

s = input()
print(dfs(0,s[0]))
Problem p02721 (python)

Fixed submission:
from sys import stdin
def main():
    input = stdin.readline
    n, k, c = map(int, input().split())
    s = input()

    l, r = [], []
    cur = 0
    count = 0

    while cur <= n:
        if s[cur] == "o":
            count += 1
            l.append((count, cur+1))
            cur += c

        cur += 1

    cur = n
    count = k

    while cur >= 0:
        if s[cur] == "o":
            r.append((count, cur+1))
            count -= 1
            cur -= c

        cur -= 1

    ans = (i[1] for i in set(l) & set(r))
    for i in sorted(ans):
        print(i)


if __name__ == '__main__':
    main()

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

l, r = [], []
cur = 0
count = 0

while cur <= n:
    if s[cur] == "o":
        count += 1
        l.append((count, cur+1))
        cur += c

    cur += 1

cur = n
count = k

while cur >= 0:
    if s[cur] == "o":
        r.append((count, cur+1))
        count -= 1
        cur -= c

    cur -= 1

ans = (i[1] for i in set(l) & set(r))
for i in sorted(ans):
    print(i)
Problem p02743 (python)

Fixed submission:
from decimal import *
a, b, c = map(int, input().split())

print("Yes" if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt() else "No")

Buggy submission (verdict: Runtime Error):
from decimal import *
a, b, c = map(int, input().split())

print("Yes" if sqrt(Decimal(a)) + sqrt(Decimal(b)) < sqrt(Decimal(c)) else "No")

Buggy submission (verdict: Runtime Error):
from decimal import *
a, b, c = map(int, input().split())

print("Yes" if Decimal(a)) + sqrt(Decimal(b)) < sqrt(Decimal(c)) else "No")

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
print("Yes" if sqrt(a*10000000) + sqrt(b*10000000) < sqrt(c*10000000) else "No")

Buggy submission (verdict: Runtime Error):
from decimal import *
from math import *

getcontext().prec = 1000
a, b, c = map(int, input().split())

print("Yes" if Decimal(a) ** 0.5 + Decimal(b) ** 0.5 < Decimal(c) ** 0.5 else "No")
Problem p02761 (python)

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

if n == 1 and m == 0:
  print(0)
  exit()

ans = [-1] * n


for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if ans[s] != -1 and ans[s] != c:
        print(-1)
        exit()

    else:
        ans[s] = c

if ans[0] == 0 and n >= 2:
    print(-1)
    exit()

elif ans[0] == -1:
    ans[0] = 1

a = ""
for i in ans:
    a += str(i) if i != -1 else "0"
print(a)

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

if n == 1 and m == 0:
  print(0)
  exit()

ans = [-1] * n


for i in range(m):
    s, c = map(int, input().split())
    s -= 1
    if ans[s] != -1 and ans[s] != c:
        print(-1)
        exit()

    else:
        ans[s] = c
        
elif ans[0] == 0 and n >= 2:
    print(-1)
    exit()
    
elif ans[0] == -1:
    ans[0] = 1

a = ""
for i in ans:
    a += str(i) if i != -1 else "0"
print(a)
Problem p02952 (python)

Fixed submission:
n = int(input())

count = 0
for i in range(1,n+1):
    if len(str(i)) % 2 == 1:
        count += 1

print(count)

Buggy submission (verdict: Runtime Error):
count = 0
for i in range(1,n+1):
    if len(str(i)) % 2 == 1:
        count += 1

print(count)
Problem p02958 (python)

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

for i in range(n):
    for j in range(n):
        temp = p.copy()
        temp[i], temp[j] = temp[j], temp[i]
        sorted_temp = sorted(temp)

        if sorted_temp  == temp:
            print("YES")
            exit()

print("NO")

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


for i in range(n):
    for j in range(n):
        temp = list(copy(p))
        temp[i], temp[j] = temp[j], temp[i]
        sorted_temp = sorted(temp)

        if sorted_temp  == temp:
            print("YES")
            exit()

print("NO")
Problem p02993 (python)

Fixed submission:
s = input()
print("Bad" if s[0] == s[1] or s[1] == s[2] or s[2] == s[3] else "Good")

Buggy submission (verdict: Runtime Error):
a, b, c, d = map(int, input().split())
print("Bad" if a == b or b == c or c == d else "Good")
Problem p03030 (python)

Fixed submission:
from operator import itemgetter

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

sorted_sp = sorted(sp,key = lambda x: int(x[1]), reverse=True)
sorted_sp = sorted(sorted_sp,key = itemgetter(0))

for i in range(n):
    for j in range(n):
        if sp[j] == sorted_sp[i]:
            print(j+1)

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

sorted_sp = sorted(sp,key = lambda x: int(x[1]), reverse=True)
sorted_sp = sorted(sorted_sp,key = itemgetter(0))

for i in range(n):
    for j in range(n):
        if sp[j] == sorted_sp[i]:
            print(j+1)
Problem p03037 (python)

Fixed submission:
n, m = map(int, input().split())
lr = [list(map(int, input().split())) for i in range(m)]

max_l = float("-inf")
min_r = float("inf")

for l, r in lr:
    max_l = max(max_l, l)
    min_r = min(min_r, r + 1)

ans = min_r-max_l
print("0" if ans <= 0 else ans if ans < n else n)

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

n, m = map(int, input().split())
a = sorted(list(map(int, input().split())))
bc = sorted([list(map(int, input().split())) for i in range(m)], key = itemgetter(1), reverse=True)

ans = 0
for i in range(n):
    now = a[i]
    for rep, con in enumerate(bc):
        if now < con[1] and bc[rep][0] != 0:
            ans += con[1]
            bc[rep][0] -= 1
            break

    else:
        ans += now + sum(a[i+1:])
        break

print(ans)
Problem p03071 (python)

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

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

Fixed submission:
order = [int(input()) for i in range(5)]
diff = (sorted(map(lambda x: (x % 10), order)))
diff = [i for i in diff if i != 0]

sum_order = sum(list(map(lambda x: -(-x //10), order))) * 10

if diff != []:
    sum_order += (-10 + diff[0])
    
print (sum_order)

Buggy submission (verdict: Runtime Error):
order = [int(input()) for i in range(5)]
diff = (sorted(map(lambda x: (x % 10), order)))
diff = [i for i in diff if i != 0]

sum_order = sum(list(map(lambda x: -(-x //10), order)))
print ((sum_order * 10) - 10 + diff[0])
Problem p03095 (python)

Fixed submission:
from collections import *
from operator import *

n = int(input())
s = input()

counter_s = Counter(s).most_common()
ans = 1
for i in counter_s:
    ans = (ans * (i[1] + 1)) % (10 ** 9 + 7)

ans -= 1
print(ans)

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

counter_s = Counter(s).most_common()
ans = 1
for i in counter_s:
    ans *= i[1] + 1

ans -= 1
print(ans)
Problem p03164 (python)

Fixed submission:
import numpy as np

n, W = map(int, input().split())
w, v = [],[]
for i in range(n):
    temp = list(map(int, input().split()))
    w.append(temp[0])
    v.append(temp[1])

table = np.full(sum(v)+1, np.inf)
table[0] = 0

for i in range(n):
    l = table[:-v[i]]
    r = table[v[i]:]
    np.minimum(l + w[i], r, out = r)
    
print(np.max(np.where(table <= W)))

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

n, w = map(int, input().split())
wv = [list(map(int, input().split())) for i in range(n)]
table = np.zeros(w+1, dtype=np.int64)

for i in range(n):
    l = table[:-wv[i][0]]
    r = table[wv[i][0]:]
    np.maximum(l + wv[i][1], r, out = r)

print(table[w])