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

Fixed submission:
X, Y = input().split()

if int(X, 16) > int(Y, 16):
    print(">")
elif int(X, 16) < int(Y, 16):
    print("<")
else:
    print("=")

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

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

Buggy submission (verdict: Runtime Error):
import math

# 入力
a, b, c = map(int, input().split())
max = math.floor((a + c) / (b + 2*c))
print(max)

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

# 入力
a, b, c = map(int, input().split())
# 計算
if a == (b + 2*c):
    print("1")
else:
    max = math.floor((a + c) / (b + 2*c))
    print(max)

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

# 入力
a, b, c = map(int, input().split())
# 計算
if a < (b + 2*c):
    print("a >= b + 2*cとなるようにしてください")
    sys.exit()
elif a == (b + 2*c):
    print("1")
else:
    max = math.floor((a + c) / (b + 2*c))
    print(max)
Problem p03632 (python)

Fixed submission:
A, B, C, D = map(int, input().split())
value = min(B, D) - max(A, C)
print(value if value > 0 else "0")

Buggy submission (verdict: Runtime Error):
A, B, C, D = input().split()
value = (min(B, D) - max(A, C))
print(value if value > 0 else "0")
Problem p03633 (python)

Fixed submission:
# list: ソート済配列
# n: 参照番号
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

N = int(input())
T = [int(input()) for i in range(N)]
ans = 1

for i in range(N):
    ans = lcm(ans, T[i])

print(ans)

Buggy submission (verdict: Runtime Error):
# list: ソート済配列
# n: 参照番号
@profile
def gcd(list, n):
    if n == 0:
        return list[0]
    else:
        a, b = list[n-1], list[n]
        
        while list[n]:
            list[n-1], list[n] = list[n], list[n-1] % list[n]

        list[n-1] = (a*b)/list[n-1]
        return gcd(list, n-1)

N = int(input())
T = [int(input()) for i in range(N)]
T.sort(reverse=True)
print(int(gcd(T, N-1)))

Buggy submission (verdict: Runtime Error):
A, B, C, D = map(int, input().split())
value = min(B, D) - max(A, C)
print(value if value > 0 else "0")
Problem p03661 (python)

Fixed submission:
def main():
    N = int(input())
    a = list(map(int, input().split()))
    #N = 1000
    #a = [i for i in range(N)]

    #summation = [abs(sum(a[:(i+1)]) - sum(a[(i+1):])) for i in range(len(a)-1)]

    summation = []
    sumtemp = sum(a)
    tmp1 = 0
    for i in range(len(a)-1):
        tmp1 += a[i]
        tmp2 = sumtemp - tmp1
        tmp = abs(tmp1 - tmp2)
        summation.append(tmp)
        
    print(min(summation))

main()

Buggy submission (verdict: Runtime Error):
@profile
def main():
    N = int(input())
    a = list(map(int, input().split()))
    #N = 1000
    #a = [i for i in range(N)]

    #summation = [abs(sum(a[:(i+1)]) - sum(a[(i+1):])) for i in range(len(a)-1)]

    summation = []
    sumtemp = sum(a)
    tmp1 = 0
    for i in range(len(a)-1):
        tmp1 += a[i]
        tmp2 = sumtemp - tmp1
        tmp = abs(tmp1 - tmp2)
        summation.append(tmp)
        
    print(min(summation))

main()

Buggy submission (verdict: Runtime Error):
@profile
def main():
    #N = int(input())
    #a = list(map(int, input().split()))
    N = 1000
    a = [i for i in range(N)]

    #summation = [abs(sum(a[:(i+1)]) - sum(a[(i+1):])) for i in range(len(a)-1)]

    summation = []
    sumtemp = sum(a)
    tmp1 = 0
    for i in range(len(a)-1):
        tmp1 += a[i]
        tmp2 = sumtemp - tmp1
        tmp = abs(tmp1 - tmp2)
        summation.append(tmp)
        
    print(min(summation))

main()
Problem p03761 (python)

Fixed submission:
import collections
n = int(input())
S = [list(input()) for i in range(n)]
Sc = [collections.Counter(i) for i in S]


if n == 1:
    S[0].sort()
    ans = "".join(S[0])
    print(ans)
else:
    counter = Sc[0] & Sc[1]
    for i in range(2, len(Sc)):
        counter = counter & Sc[i]

    Sclist = list(counter.elements())
    Sclist.sort()
    ans = "".join(Sclist)

    print(ans)

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
S = [list(input()) for i in range(n)]
Sc = [collections.Counter(i) for i in S]


if n == 1:
    ans = "".join(S[0].sort())
    print(ans)
else:
    counter = Sc[0] & Sc[1]
    for i in range(2, len(Sc)):
        counter = counter & Sc[i]

    Sclist = list(counter.elements())
    Sclist.sort()
    ans = "".join(Sclist)

    print(ans)

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
S = [list(input()) for i in range(n)]
Sc = [collections.Counter(i) for i in S]


if n == 1:
    ans = "".join(S[0])
    ans.sort()
    print(ans)
else:
    counter = Sc[0] & Sc[1]
    for i in range(2, len(Sc)):
        counter = counter & Sc[i]

    Sclist = list(counter.elements())
    Sclist.sort()
    ans = "".join(Sclist)

    print(ans)

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
S = [list(input()) for i in range(n)]
Sc = [collections.Counter(i) for i in S]

counter = Sc[0] & Sc[1]
for i in range(2, len(Sc)):
    counter = counter & Sc[i]

Sclist = list(counter.elements())
Sclist.sort()
ans = "".join(Sclist)

if n == 1:
    print(S[0])
else:
    print(ans)

Buggy submission (verdict: Runtime Error):
import collections
n = int(input())
S = [list(input()) for i in range(n)]
Sc = [collections.Counter(i) for i in S]

counter = Sc[0] & Sc[1]
for i in range(2, len(Sc)):
    counter = counter & Sc[i]

Sclist = list(counter.elements())
Sclist.sort()
ans = "".join(Sclist)
print(ans)
Problem p03779 (python)

Fixed submission:
X = int(input())

count, addition = 0, 0
while 1:
    if X <= count:
        break

    addition += 1
    count += addition

print(addition)

Buggy submission (verdict: Runtime Error):
https://www.lifehacker.jp/2017/11/171127_kakei_17.html?utm_source=dlvr.it&utm_medium=twitter
Problem p03799 (python)

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

if N >= (M // 2):
    print(M // 2)
else:
    print(N + ((M - 2 * N) // 4))

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

if N >= 2 * M:
print(M // 2)
else:
print(N + ((M - 2 * N) // 4))

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

if N >= 2 * M:
    print(M // 2)
else:
    print(N + ((M - 2 * N) // 4)
Problem p02801 (python)

Fixed submission:
a = input()

print(chr(ord(a) + 1))

Buggy submission (verdict: Runtime Error):
 print(chr(ord(input()) + 1))
Problem p03000 (python)

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

ns=0
ans = 1

for i in range(n):
	ns += l[i]
	if ns <= x:
		ans += 1
	else:
		break
print(ans)

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

ns=0
ans = 1

for i in range(n):
  ns += l[i]
  if ns <= x:
    ans++
  else:
    break
print(ans)
Problem p03001 (python)

Fixed submission:
w,h,x,y = map(int, input().split())
if  w/2 == x and h/2 == y:
	ans = 1
else:
	ans = 0
print (w*h/2.0,ans)

Buggy submission (verdict: Runtime Error):
w,h,x,y = map(double, input().split())
if  w/2 == x and h/2 == y:
	ans = 1
else:
	ans = 0
print (w*h/2.0,ans)

Buggy submission (verdict: Runtime Error):
w,h,x,y = map(double, input().split())
if  w/2 == x and h/2 == y:
	ans = 1
else:
	ans = 0
print (w*h/2,ans)

Buggy submission (verdict: Runtime Error):
w,h,x,y = map(double, input().split())
if  w/2 = x and h/2 = y:
	ans = 1
else:
	ans = 0
print (w*h/2,ans)

Buggy submission (verdict: Runtime Error):
w,h,x,y = map(double, input().split())
if  w/2 = x && h/2 = y:
	ans = 1
else:
	ans = 0
print (str(w*h/2) + " " + str(ans))
Problem p02801 (python)

Fixed submission:
asc = 'abcdefghijklmnopqrstuvwxyz'
t=input()
for i in range(25):
    if t == asc[i]:
        print(asc[i+1])

Buggy submission (verdict: Runtime Error):
import itertools

N,K = map(int,input().split())
A = sorted(list(map(int,input().split())))

def fun(a):
    return max(a)-min(a)
def fun1(a):
    return sum(a) % (1000000007)
_1 = [fun(i) for i in itertools.combinations([int(i) for i in A], K)]    
print(fun1(_1))

mod = 10**9 + 7
 
def nCr(n,r):
  if n < r:
    return 0
  if n < 0 or r < 0:
    return 0
  return (fac[n] * facinv[r] * facinv[n - r]) % mod
Problem p02804 (python)

Fixed submission:
MOD = 10**9 + 7

N, K = map(int, raw_input().split())
A = map(int, raw_input().split())

factorial = [1]
for i in range(1, N+1):
    factorial.append((i * factorial[-1]) % MOD)

def nCk(n, k):
    numerator = factorial[n]
    denominator = factorial[n-k] * factorial[k]
    return numerator * pow(denominator, MOD - 2, MOD)

ans = 0

A.sort()
for i in range(N-K+1):
    best = A[i]
    contribution = (best * nCk(N-i-1, K-1))
    ans = (ans - contribution) % MOD

A = A[::-1]
for i in range(N-K+1):
    best = A[i]
    contribution = (best * nCk(N-i-1, K-1))
    ans = (ans + contribution) % MOD

print ans

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
typedef long long ll;

ll MOD = 1e9 + 7;

vector<ll> factorial;
ll mod_exp(ll x, ll exp) {
    ll res = 1;
    ll base = x % MOD;
    while (exp) {
        if (exp % 2 == 1) {
            res = (res * base) % MOD;
        }
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res;
}

ll nCk(ll n, ll k) {
    if (n < k) return 0;
    ll numerator = factorial[n];
    ll denominator = (factorial[n-k] * factorial[k]) % MOD;
    ll ans = (numerator * mod_exp(denominator, MOD-2)) % MOD;
    return ans;
}

int main() {
    ll N, K; cin >> N >> K;
    vector<ll> nums(N);
    for (ll& x : nums) {
        cin >> x;
    }

    factorial = {1};
    for (int i = 1; i <= N; i++) {
        factorial.push_back((factorial.back() * i) % MOD);
    }

    ll ans = 0;

    sort(begin(nums), end(nums), [](int a, int b){return a > b;});
    for (int i = 1; i <= N-K+1; i++) {
        ll best = nums[i-1];
        ll contribution = (best * nCk(N-i, K-1)) % MOD;
        ans = (ans + contribution) % MOD;
    }

    sort(begin(nums), end(nums));
    for (int i = 1; i <= N-K+1; i++) {
        ll best = nums[i-1];
        ll contribution = (best * nCk(N-i, K-1)) % MOD;
        ans = (ans - contribution) % MOD;
    }

    cout << ans << endl;
}
Problem p02852 (python)

Fixed submission:
N, M = map(int, input().split())
S = input().strip()
T = S[::-1]

l = []
i = 0
while i < N:
  t = T[i+1: i+M+1][::-1]
  if '0' not in t:
    print(-1)
    exit()
  else:
    x = min(M - t.index('0'), len(t))
    l.append(x)
    i += x
print(*l[::-1])

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

# stdin = open("testdata.txt", "r")

def input():
	return stdin.readline().strip()

from collections import deque

n, m = map(int, input().split())

s = input()

def bfs(src):
	que = deque([[src, []]])
	visited = {src, }

	while que:
		u, path = que.popleft()
		if u == 0:
			return path
		for i in range(m, 0, -1):
			next_pos = u - i
			if next_pos not in visited and next_pos <= n and s[next_pos]=='0':
				visited.add(next_pos)
				que.append((next_pos, path+[i]))
	return -1

ans = bfs(n)
if ans == -1:
	print(ans)
else:
	print(*ans)

Buggy submission (verdict: Runtime Error):
from sys import stdin
sys.setrecursionlimit(pow(10, 9))

# stdin = open("testdata.txt", "r")

def input():
	return stdin.readline().strip()

from collections import deque

n, m = map(int, input().split())

s = input()

def bfs(src):
	que = deque([[src, []]])
	visited = {src, }

	while que:
		u, path = que.popleft()
		if u == n:
			return path
		for i in range(1, m+1):
			next_pos = u + i
			if next_pos not in visited and next_pos <= n and s[next_pos]=='0':
				visited.add(next_pos)
				que.append((next_pos, path+[i]))
	return -1

ans = bfs(0)
if ans == -1:
	print(ans)
else:
	print(*ans)
Problem p02910 (python)

Fixed submission:
import sys

s = sys.stdin.readline().strip()

def solve(s):
	n = len(s)
	for i in range(n):
		if i%2==0:
			if s[i] == "L":
				return False
		else:
			if s[i] == "R":
				return False
	return True

print("Yes" if solve(s) else "No")

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

def solve(s):
	for i in range(len(s)):
  		if i%2==0:
          if s[i] == "L":
          	return False
       	else:
          if s[i]=="R":
            return False
	return True
  
print("Yes" if solve(s) else "No")
Problem p02924 (python)

Fixed submission:
N = int(input())

ans = N*(N-1)//2
print(ans)

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

ans = N*(N-1)//2
print(ans)
Problem p02934 (python)

Fixed submission:
from functools import reduce

n = int(input())

arr = list(map(int, input().split()))

numerator = prod = reduce(lambda x, y: x*y, arr)
denomenator = sum(prod//ele for ele in arr)

ans = numerator/denomenator
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
arr = [0]*n

prod = 1
for i in range(n):
	ele = int(input())
	prod *= ele
	arr[i] = ele

numerator = prod

denomenator = sum(prod//ele for ele in arr)

ans = numerator/denomenator
print(ans)
Problem p02936 (python)

Fixed submission:
import sys
from collections import defaultdict

n , q = map(int, sys.stdin.readline().split())

lazy = [0]*(n+1)

graph = defaultdict(lambda:list([]))
for i in range(n-1):
	x, y = map(int, sys.stdin.readline().split())
	# x, y = arr[i]
	graph[x].append(y)
	graph[y].append(x)

def dfs(src):
	visited ={src, }
	stack = [src]

	while stack:
		v = stack.pop()
		for next_v in graph[v]:
			if not next_v in visited:
				visited.add(next_v)
				lazy[next_v] += lazy[v]
				stack.append(next_v)

# queries = [(1, 1), (2, 2)]
for i in range(q):
	idx, val = map(int, sys.stdin.readline().split())
	# idx, val = queries[i]
	lazy[idx] += val
dfs(1)
print(*lazy[1:])

Buggy submission (verdict: Runtime Error):
import sys
from collections import defaultdict

n , q = map(int, sys.stdin.readline().split())
# n, q = 3, 2
# arr = [(1, 3), (2, 3)]

graph = defaultdict(list)
for i in range(n-1):
	x, y = map(int, sys.stdin.readline().split())
	# x, y = arr[i]
	graph[x].append(y)
	graph[y].append(x)

visited =set()
def dfs(src):
	global graph, lazy, visited
	visited.add(src)
	for neighbour in graph[src]:
		if neighbour not in visited:
			lazy[neighbour] += lazy[src]
			dfs(neighbour)

lazy = [0]*(n+1)
queries = [(1, 1), (2, 2)]
for i in range(q):
	idx, val = map(int, sys.stdin.readline().split())
	# idx, val = queries[i]
	lazy[idx] += val
dfs(1)
print(*lazy[1:])

Buggy submission (verdict: Runtime Error):
import sys
from collections import defaultdict

n , q = map(int, sys.stdin.readline().split())

graph = defaultdict(list)
for i in range(n-1):
	x, y = map(int, sys.stdin.readline().split())
	graph[x].append(y)
	graph[y].append(x)

def dfs(src, p):
	global graph, lazy

	for neighbour in graph[src]:
		if neighbour != p:
			lazy[neighbour] += lazy[src]
			dfs(neighbour, src)

lazy = [0]*(n+1)
for _ in range(q):
	idx, val = map(int, sys.stdin.readline().split())
	lazy[idx] += val
dfs(1, -1)
print(*lazy[1:])

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import sys

# n, q = 4, 3
# arr = [(1, 2), (3, 2), (2, 4)]

n , q = map(int, sys.stdin.readline().split())

graph = defaultdict(list)

for i in range(n-1):
	x, y = map(int, sys.stdin.readline().split())
	graph[x].append(y)
	graph[y].append(x)

def dfs(src, p):
	global graph, lazy

	for neighbour in graph[src]:
		if neighbour != p:
			lazy[neighbour] += lazy[src]
			dfs(neighbour, src)


lazy = [0]*(n+1)

for _ in range(q):
	idx, val = map(int, sys.stdin.readline().split())
	lazy[idx] += val
dfs(1, -1)


print(*lazy[1:])
Problem p02937 (python)

Fixed submission:
import sys
from collections import defaultdict

def bs(arr, val):
	l, h = 0, len(arr)-1
	ans = -1
	while l <= h:
		m = l + h >> 1
		if arr[m] > val:
			ans = m
			h = m - 1
		else:
			l = m + 1
	return ans

s = sys.stdin.readline().strip()
n = len(s)

t = sys.stdin.readline().strip()

occurence = defaultdict(list)
for i in range(n):
	occurence[s[i]].append(i+1)

def solve():
	folds = 0
	cur_ptr = 0

	for ele in t:
		indexes = occurence[ele]
		if not indexes: return -1

		idx = bs(indexes, cur_ptr)
		if idx != -1: 
			cur_ptr = indexes[idx]
		else:
			folds += 1
			cur_ptr = indexes[0]
		# print(ele, cur_ptr, folds)
	ans = folds*(n) + cur_ptr
	return ans

print(solve())

Buggy submission (verdict: Runtime Error):
import sys
from collections import defaultdict

def bs(arr, val):
	l, h = 0, len(arr)-1
	ans = -1
	while l <= h:
		m = l + h >> 1
		if arr[m] > val:
			ans = m
			h = m - 1
		else:
			l = m + 1
	return ans

s = sys.stdin.readline()
n = len(s)

t = sys.stdin.readline()

occurence = defaultdict(list)
for i in range(n):
	occurence[s[i]].append(i+1)

folds = 0
cur_ptr = 0
for ele in t:
	indexes = occurence[ele]
	idx = bs(indexes, cur_ptr)
	if idx != -1: 
		cur_ptr = indexes[idx]
	else:
		folds += 1
		cur_ptr = indexes[0]
ans = folds*(n) + cur_ptr
print(ans)
Problem p02947 (python)

Fixed submission:
import math
from collections import Counter, defaultdict

def ncr(n, r):
	f = math.factorial
	return f(n)//f(r)//f(n-r)

n = int(input())

dct = defaultdict(int)

for i in range(n):
	counter = Counter(input().strip())
	tpl = tuple(sorted(counter.items()))
	dct[tpl] += 1


ans = sum(ncr(val, 2) for val in dct.values() if val>1)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
from collections import Counter, defaultdict

def ncr(n, r):
	f = math.factorial
	return f(n)//f(r)//f(n-r)

n = int(input())

dct = defaultdict(int)

for i in range(n):
	counter = Counter(input().strip())
	tpl = tuple(sorted(counter.items()))
	dct[tpl] += 1
ans = sum(ncr(val, 2) for val in dct.values())

print(ans)
Problem p02972 (python)

Fixed submission:
n = int(input())

a = list(map(int, input().split()))
box = [0]*n
for i in range(n,0,-1):
    sum_box = 0
    for j in range(i,n+1,i):
        sum_box+=box[j-1]
    if sum_box%2!=a[i-1]:
        box[i-1]+=1
 
print(sum(box))
if sum(box):
    ans = []
    for i, x in enumerate(box):
        if x:
            ans.append(i+1)
    print(*ans)

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

arr = [0]*n
suffix_arr = [0]*(n+1)
# arr = [0, 2, 0, 4, 2]
for i in range(n):
	arr[i] = int(input())

conditional_flag = True

for i in range(1, n+1):
	for j in range(i, n+1, i):
		suffix_arr[i] += arr[j-1]
	if suffix_arr[i]%2 != arr[i-1]%2:
		conditional_flag = False
		break

if conditional_flag:
	b = [i+1 for i in range(i) if arr[i]]
	length = len(b)
	print(length)
	if length: print(*b)
else:
	print(-1)

Buggy submission (verdict: Runtime Error):
import heapq

n = int(input())
# n = 3

arr = [0]*n

pq = []
for i in range(n):
	arr[i] = int(input())
	heapq.heappush(pq, (-arr[i], i))
heapq.heapify(pq)
lg = heapq.heappop(pq)
slg = heapq.heappop(pq)
print(lg, slg)
lg, slg = lg[1], slg[1]

for i in range(n):
	if i==lg:
		print(arr[slg])
	else:
		print(arr[lg])
Problem p02995 (python)

Fixed submission:
from fractions import gcd 
import sys

l, r, c, d = map(int, sys.stdin.readline().split())

count = 0

first = (l + c - 1)//c 
last = r//c 

count += last - first + 1

first = (l + d - 1)//d 
last = r//d 
count += last - first + 1

lcm = c*d//gcd(c, d)

first = (l + lcm - 1)//lcm 
last = r // lcm
count -= last - first + 1


print(r - l - count + 1)

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

l, r, c, d = map(int, sys.stdin.readline().split())

count = 0

first = (l + c - 1)//c 
last = r//c 

count += last - first + 1

first = (l + d - 1)//d 
last = r//d 
count += last - first + 1

lcm = c*d//math.gcd(c, d)

first = (l + lcm - 1)//lcm 
last = r // lcm
count -= last - first + 1


print(r - l - count + 1)

Buggy submission (verdict: Runtime Error):
import math

l, r, c, d = map(int, input().split())
# numbers = [True]*(r+1)


count = 0

first = (l + c - 1)//c 
last = r//c 

count += last - first + 1

first = (l + d - 1)//d 
last = r//d 
count += last - first + 1

lcm = c*d//math.gcd(c, d)

first = (l + lcm - 1)//lcm 
last = r // lcm
count -= last - first + 1


print(r - l - count + 1)

Buggy submission (verdict: Runtime Error):
import math

l, r, c, d = map(int, input().split())
# numbers = [True]*(r+1)


count = 0

first = (l + c - 1)//c 
last = r//c 

count += last - first + 1

first = (l + d - 1)//d 
last = r//d 
count += last - first + 1

lcm = c*d//math.gcd(c, d)

first = (l + lcm - 1)//lcm 
last = r // lcm
count -= last - first + 1


print(r - l - count + 1)
Problem p03030 (python)

Fixed submission:
n = int(input())

arr= [0]*n

for i in range(n):
	city, score = input().split()
	arr[i] = [city, int(score), i+1]

arr.sort(key = lambda x:(x[0],-x[1]))

for ele in arr:
	print(ele[2])

Buggy submission (verdict: Runtime Error):
n = int(input())
arr = [0]*n

for i in range(n):
	city, score = input().split()
    arr[i] = [city, int(score), i+1]
arr.sort(key = lambda x: (x[0], -x[1]))
for ele in arr:
  print(arr[2])
Problem p02814 (python)

Fixed submission:
def p_d():
    from fractions import gcd
    n, m = map(int, input().split())
    *A, = map(lambda x: int(x) // 2, input().split())

    c = 0
    for a in A:
        if c == 0:
            while a & 1 == 0:
                c += 1
                a >>= 1
        else:
            ne = 0
            while a & 1 == 0:
                ne += 1
                a >>= 1
            if c != ne:
                print(0)
                exit()

    lcm = A[0]
    for i in range(1, n):
        lcm = lcm * A[i] // gcd(lcm, A[i])
    print((m // lcm + 1) // 2)
    
p_d()

Buggy submission (verdict: Runtime Error):
def p_d():
    import math
    from functools import reduce
    n, m = map(int, input().split())
    *A, = map(lambda x: int(x) // 2, input().split())

    def lcm_base(x, y):
        return (x * y) // math.gcd(x, y)

    def lcm_list(numbers):
        return reduce(lcm_base, numbers, 1)

    lcm = lcm_list(A)
    print((m // lcm + 1) // 2)
    
p_d()
Problem p02898 (python)

Fixed submission:
from sys import stdin

input = stdin.readline


def p_a():
    n = int(input())
    print(((n + 1) // 2) / n)


def p_b():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))

    print(sum(map(lambda x: x >= k, h)))


if __name__ == '__main__':
    p_b()

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

input = stdin.readline


def p_a():
    n = int(input())
    print(((n + 1) // 2) / n)


def p_b():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))

    print(sum(map(lambda x: x >= k)))


if __name__ == '__main__':
    p_b()