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

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

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


a_pre,b_pre=[0],[0]

for i in range(n):
	a_pre.append(a_pre[i]+a[i])

for i in range(m):
	b_pre.append(b_pre[i]+b[i])

ans,j=0,m
for i in range(n+1):
	if a_pre[i]>k:
		break
	while b_pre[j]>k-a_pre[i]:
		j-=1

	ans=max(ans,i+j)

print(ans)

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

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


a_pre,b_pre=[0],[0]

for i in range(n):
	a_pre.append(a_pre[i]+a[i])

for i in range(m):
	b_pre.append(b_pre[i]+b[i])

ans,j=0,m
for i in range(n+1):
	if a_pre[i]>k:
		break
	while b[j]>k-a[i]:
		j-=1

	ans=max(ans,i+j)

print(ans)

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

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

if len(a)>len(b):
	a,b=b,a
i=0
j=0
total=0
cnt=0
while total<=k:
	if i<len(a):
		if a[i]<b[j]:
			total+=a[i]
			i+=1
		else:
			total+=b[j]
			j+=1
	elif j<len(b):
		total+=b[j]
		j+=1

	cnt+=1
	if total>k:
		cnt-=1
	if j==len(b) and i==len(a):
		break

print(cnt)
Problem p02629 (python)

Fixed submission:
n=int(input())
s=''
while n:
    n-=1
    s=chr(97+n%26)+s
    n//=26

print(s)

Buggy submission (verdict: Runtime Error):
n=int(input())
s=''
while n:
    n-=1
    s=chr(97+total%26)+s
    n//=26

print(s)
Problem p02723 (python)

Fixed submission:
s=input()

if s[2]==s[3] and s[4]==s[5]:
  print("Yes")
else:
  print("No")

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

for i in range(n-1):
	arr.append(arr[i]+k)

min_=99999999999

for i in range(n):
	if arr[i+n-1]-arr[i]<min_:
		min_=arr[i+n-1]-arr[i]


print(min_)
Problem p02833 (python)

Fixed submission:
import math
n = int(input())
if n % 2 == 1:
  print(0)
  quit()
if n == 0:
  print(0)
  quit()

l = int(math.log10(n))+1
cnt = 0
for i in range(1,10*l):
  cnt += (n // 5 ** i) // 2
print(cnt)

Buggy submission (verdict: Runtime Error):
import math
n = int(input())
if n % 2 == 1:
  print(0)
  quit()

l = int(math.log10(n))+1
cnt = 0
for i in range(1,10*l):
  cnt += (n // 5 ** i) // 2
print(cnt)
Problem p02753 (python)

Fixed submission:
s = input()

if 'A' in s and 'B' in s:
  	print('Yes')
else:
  	print('No')

Buggy submission (verdict: Runtime Error):
package main

import (
	"fmt"
)

func answer158A(s string) string {
	if s == "AAA" || s == "BBB" {
		return "No"
	} else {
		return "Yes"
	}
}

func main() {
	var s string
	fmt.Scan(&s)
	
	fmt.Println(answer158A(s))
}

Buggy submission (verdict: Runtime Error):
def actual(n, a, b):
    n_op_least = n // (a + b)

    n_blue_least = a * n_op_least
    adjustment = min(n % (a + b), a)

    return n_blue_least + adjustment

n, a, b = map(int, input().split())
print(actual(n, a, b))

Buggy submission (verdict: Runtime Error):
import math


def actual(n, a, b):
    _少なくとも必要な操作回数_もしかすると1回足りない = n // (a + b)
    _少なくとも存在する青ボールの数 = a * _少なくとも必要な操作回数_もしかすると1回足りない

    # 操作回数が足りている == 余り0 => 0 だし
    # 操作回数が不足している => 1回だけ追加で操作をすれば良いので、 a追加

    _端数 = min(n % (a + b), a)

    return _少なくとも存在する青ボールの数 + _端数

n, a, b = map(int, input().split())
print(actual(n, a, b))
Problem p02754 (python)

Fixed submission:
def actual(n, a, b):
    n_op_least = n // (a + b)

    n_blue_least = a * n_op_least
    adjustment = min(n % (a + b), a)

    return n_blue_least + adjustment

n, a, b = map(int, input().split())
print(actual(n, a, b))

Buggy submission (verdict: Runtime Error):
import math


def actual(n, a, b):
    # 文字列の長さがN以上になるために必要な操作の回数
    required_operations = math.ceil(n / (a + b))

    s = ''

    for _ in range(required_operations):
        s += '青' * a + '赤' * b

    return s[:n].count('青')


n, a, b = map(int, input().split())
print(actual(n, a, b))

Buggy submission (verdict: Runtime Error):
def actual(n, a, b):
    s = ''

	for _ in range(10**100):
        s += '青' * a + '赤' * b

        if len(s) >= n:
            return s[:n].count('青')

n, a, b = map(int, input().split())
print(actual(n, a, b))

Buggy submission (verdict: Runtime Error):
def actual(n, a, b):
    s = ''

    # 無限ループにはならない前提
    while True:
        s += '青' * a + '赤' * b

        if len(s) >= n:
            return s[:n].count('青')

n, a, b = map(int, input().split())
print(actual(n, a, b))
Problem p02835 (python)

Fixed submission:
a1, a2, a3 = map(int, input().split())

total = a1 + a2 + a3

if total >= 22:
	print('bust')
else:
	print('win')

Buggy submission (verdict: Runtime Error):
a1, a2, a3 = map(int, input().split())

total = sum(a1, a2, a3)

if total >= 22:
	print('bust')
else:
	print('win')
Problem p03265 (python)

Fixed submission:
def actual(x1, y1, x2, y2):
    a = x2 - x1
    b = y2 - y1

    x3, y3 = x2 - b, y2 + a
    x4, y4 = x3 - a, y3 - b

    # return f'{x3} {y3} {x4} {y4}'
    return '{} {} {} {}'.format(x3, y3, x4, y4)

x1, y1, x2, y2 = map(int, input().split())
print(actual(x1, y1, x2, y2))

Buggy submission (verdict: Runtime Error):
def actual(x1, y1, x2, y2):
    a = x2 - x1
    b = y2 - y1

    x3, y3 = x2 - b, y2 + a
    x4, y4 = x3 - a, y3 - b

    return f'{x3} {y3} {x4} {y4}'

x1, y1, x2, y2 = map(int, input().split())
print(actual(x1, y1, x2, y2))
Problem p03272 (python)

Fixed submission:
def actual(n, i):
    return n - i + 1

n, i = map(int, input().split())
print(actual(n, i))

Buggy submission (verdict: Runtime Error):
def actual(n, i):
    return n - i + 1

n, i = map(int, input())
print(actual(n, i))
Problem p03041 (python)

Fixed submission:
change_K = int(input().split(" ")[-1])
word_S = list(input())
S = list(word_S)
word1 = ""
for i in range(change_K - 1):
    word1 = word1 + S[i]
word2 = S[change_K - 1]
word3 = ""
count = 0
while True:
    try:
        word3 = word3 + S[change_K + count]
        count += 1
    except IndexError:
        break
word2 = word2.swapcase()
print(word1 + word2 + word3)

Buggy submission (verdict: Runtime Error):
word_S = input().split(" ")[-1]
S = list(word_S)
change_K = int(input())
word1 = ""
for i in range(change_K - 1):
    word1 = word1 + S[i]
word2 = S[change_K - 1]
word3 = ""
count = 0
while True:
    try:
        word3 = word3 + S[change_K + count]
        count += 1
    except IndexError:
        break
word2 = word2.swapcase()
print(word1+word2+word3)
Problem p03042 (python)

Fixed submission:
x = list(input())
first = 10 * int(x[0]) + int(x[1])
second = 10 * int(x[2]) + int(x[3])


def mc(num):
    if 1 <= num <= 12:
        return True
    else:
        return False


def yc(num):
    if 0 <= num <= 99:
        return True
    else:
        return False


if yc(first):
    if mc(second):
        if yc(second):
            if mc(first):
                print("AMBIGUOUS")
            else:
                print("YYMM")
        else:
            print("YYMM")
    elif yc(second):
        if mc(first):
            print("MMYY")
        else:
            print("NA")
    else:
        print("NA")
elif yc(second):
    if mc(first):
        print("MMYY")
    else:
        print("NA")
else:
    print("NA")

Buggy submission (verdict: Runtime Error):
x = list(input())
first = 10 * int(x[0]) + int(x[1])
second = 10 * int(x[2]) + int(x[3])


def mc(num):
    if 1 <= num <= 12:
        return True
    else:
        return False


def yc(num):
    if 1 <= num <= 99:
        return True
    else:
        return False


if yc(first):
    if mc(second):
        if yc(second):
            if mc(first):
                print("AMBIGUOUS")
            else:
                print("YYMM")
        else:
            print("YYMM")
    elif yc(second):
        if mc(first):
            print("MMYY")
        else:
            print("NA")
    else:
        pirnt("NA")
elif yc(second):
    if mc(first):
        print("MMYY")
    else:
        print("NA")
else:
    print("NA")

Buggy submission (verdict: Runtime Error):
x = list(input())
first = 10 * x[0] + x[1]
second = 10 * x[2] + x[3]


def mc(num):
    if 1 <= num <= 12:
        return True
    else:
        return False


def yc(num):
    if 1 <= num <= 99:
        return True
    else:
        return False


if yc(first):
    if mc(second):
        if yc(second):
            if mc(first):
                print("AMBIGUOUS")
            else:
                print("YYMM")
        else:
            print("YYMM")
    elif yc(second):
        if mc(first):
            print("MMYY")
        else:
            print("NA")
    else:
        pirnt("NA")
elif yc(second):
    if mc(first):
        print("MMYY")
    else:
        print("NA")
else:
    print("NA")
Problem p02699 (python)

Fixed submission:
S, W = map(int, input().split())
print('unsafe') if W>= S else print('safe')

Buggy submission (verdict: Runtime Error):
S = int(input())
W = int(input())
print('unsafe') if W>= S else print('safe')
Problem p02685 (python)

Fixed submission:
## coding: UTF-8
#N, M, K = 9, 3, 4
N, M, K = map(int,input().split())
p = 998244353


# 返り値: a と b の最大公約数
# 返り値: ax + by = gcd(a, b) を満たす (x, y) が格納される
def aug_gcd(a, b):
    lq = []
    while b > 0:
        q = int(a/b)
        r = a % b
        a = b
        b = r
        lq.append(q)
    x = 1
    y = 0
    for i in range(len(lq)):
        tmp = x
        x = y
        y = tmp - lq[(-1)*(i+1)] * y
    return a, x, y

#拡張ユークリッドの互除法による逆元計算
#拡張ユークリッドの方が二分累乗法より高速/mが素数でなくとも良い
def modinv(a, p):
    inv = aug_gcd(a, p)[1] #ax == 1(mod p) <==> ax + py == 0, xの値が逆元
    if(inv < 0):
        inv += p #pがマイナスだったらプラスに書き換える
    return inv


#[NC0, NC1, NC2, NC3, ..., NCN % p]
def N_Combination_k(N, p):
    #NCkのリストを作ります
    l = [1]
    res = 1
    for i in range(1, N+1):
        res *= (N+1-i)
        res %= p
        res *= modinv(i, p)
        res %= p
        l.append(res)
    return l


combination_N_1 = N_Combination_k(N-1, p)
#print(combination_N_1)
Cumulative = [0] #累積和
s = 0
tod = 1 #(M-1) ** (N-1-i)
for i in range(N):
    s += M * tod * combination_N_1[(-1)*(i+1)]
    s %= p
    tod *= (M-1)
    tod %= p
    Cumulative.append(s)
    #print(s)
#print(Cumulative)

ans = Cumulative[-1] - Cumulative[(-1)*(K+2)]
if(ans < 0):
    ans += p
print(ans)

Buggy submission (verdict: Runtime Error):
## coding: UTF-8

#ダブリングを利用した実装

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

#2**59 < 10**18< 2**60より2**60まで格納する
l = [0] * (N*61)

for j in range(N):
    l[j] = A[j]


for i in range(1,61):
#for i in range(1, 4):
    for j in range(N):
        p = l[(i-1)*N+j] #一段上を参照(2**(i-1)回移動した時の移動先)
        q = l[(i-1)*N+(p-1)] #pから2**(i-1)回移動した時の移動先を参照　＝　2**i 回移動した時の移動先
        l[i*N+(j)] = q
    #print(l)
#print(l)

bin_str = format(K, 'b')
#print(bin_str)
s = bin_str[::-1]
#print(s)
now = 1 #start地点
for i in range(len(s)):
    if(s[i] == '1'):
        now = l[(i)*N + (now-1)]
        #print(now)

        '''
        next_index = i*N + l[i*N + (now-1)]-1
        nex = l[next_index]
        now = nex
        print(now)
        '''
print(now)
Problem p02594 (python)

Fixed submission:
rawtemp = input()
temp = int(rawtemp)

if temp < 30:
    print("No")
else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
import math
 
i = input().split()
n = int(i[0])
D = int(i[1])
num_list = []
count = 0
for i in range(n):
	num_list.append(list(map(int,input().split())))
 
for j in num_list:
    x = j[0]
    y = j[1]
    dist = math.sqrt(x ** 2 + y ** 2)
    if dist <= D:
        count += 1
 
print(count)
Problem p02595 (python)

Fixed submission:
import math
 
i = input().split()
n = int(i[0])
D = int(i[1])
num_list = []
count = 0
for i in range(n):
	num_list.append(list(map(int,input().split())))
 
for j in num_list:
    x = j[0]
    y = j[1]
    dist = math.sqrt(x ** 2 + y ** 2)
    if dist <= D:
        count += 1
 
print(count)

Buggy submission (verdict: Runtime Error):
import math

i = input().split()
n = int(i[1])
D = int(i[0])
num_list = []
count = 0
for i in range(n):
	num_list.append(list(map(int,input().split())))

for j in num_list:
    x = j[0]
    y = j[1]
    dist = math.sqrt(x ** 2 + y ** 2)
    if dist <= D:
        count += 1

print(count)
Problem p02682 (python)

Fixed submission:
a,b,c,x=map(int,input().split())
 
if x<a:
  print(x)
elif x<a+b:
  print(a)
else:
  print(2*a+b-x)

Buggy submission (verdict: Runtime Error):
a,b,c,x=map(int,input().split())
 
if:
  print(x)
elif x<a+b:
  print(int(a))
else:
  print(int(2*a+b-x))
Problem p02711 (python)

Fixed submission:
n=input()
 
if n[0]=='7' or n[1]=='7' or n[2]=='7':
  print('Yes')
else:
  print('No')

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

if s[0]=='7' or s[1]=='7' or s[2]=='7':
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
s=input()
c=0
for i in range(len(s)):
	if s[i]==7:
    	c=c+1
    
if c>0:
  print('Yes')
else:
  print('No')
Problem p03041 (python)

Fixed submission:
n,k=map(int,input().split())
s=input()
s=s[:k-1]+s[k-1].lower()+s[k:]
print(s)

Buggy submission (verdict: Runtime Error):
n,k=input().split()
k=int(k)
x=n.replace(n[k-1],n[k-1].upper())
print(x)
Problem p03075 (python)

Fixed submission:
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

x=max(a,b,c,d,e)
y=min(a,b,c,d,e)


if x-y>k:
    print(':(')
else:
    print('Yay!')

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

if b-a>k or c-b>k or d-c>k or e-d>k or f-e>k:
    print(':(')
else:
    print('Yay!')

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
f=int(input())
k=int(input())

if b-a>k or c-b>k or d-c>k or e-d>k or f-e>k:
    print(':(')
else:
    print('Yay!')
Problem p03774 (python)

Fixed submission:
n,m=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
x=[]
y=[]
l=[]
p=[]

for i in range(n):
    ai,bi=map(int,input().split())
    a.append(ai)
    b.append(bi)
    
for j in range(m):
    ci,di=map(int,input().split())
    c.append(ci)
    d.append(di)
    
for i in range(n):
    for j in range(m):
        x.append(abs(a[i]-c[j]))
        y.append(abs(b[i]-d[j]))
        l.append(x[j+i*m]+y[j+i*m])
    
    p.append(l.index(min(l))+1)   
    l=[]
    #x=[]
    #y=[]
    
for i in range(n):
    print(p[i])

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
a=[]
b=[]
c=[]
d=[]
x=[]
y=[]
l=[]
p=[]

for i in range(n):
    ai,bi=map(int,input().split())
    a.append(ai)
    b.append(bi)
    
for j in range(m):
    ci,di=map(int,input().split())
    c.append(ci)
    d.append(di)
    
for i in range(n):
    for j in range(m):
        x.append(abs(a[i]-c[j]))
        y.append(abs(b[i]-d[j]))
        l.append(x[i]+y[i])
    
    p.append(l.index(min(l))+1)   
    l=[]
    x=[]
    y=[]
    
for i in range(n):
    print(p[i])
Problem p02546 (python)

Fixed submission:
s = input()
a = 's'
if s[-1] == 's':
    a = 'es'
s = s + a
print(s)

Buggy submission (verdict: Runtime Error):
s = input()
a = 's'
if s[-1] == 's':
    a = 'es'
s.append(a)
Problem p02550 (python)

Fixed submission:
N,X,M = map(int,input().split())
R = [X]
dr = {}
for i in range(M):
    dr[i] = 0
m = min(N,M)
for i in range(m):
    r = R[-1]
    r = r**2%M
    if dr[r] == 1:
        break
    R.append(r)
    dr[r] = 1
for i in range(len(R)):
    if r == R[i]:
        break
a = 0
b = sum(R)
for j in range(i):
    a += R[j]
    b -= R[j]
n = len(R) - i
t = N - i
p = t // n
q = t % n
c = 0
for j in range(q):
    c += R[i+j]
ans = a + b*p + c
print(ans)

Buggy submission (verdict: Runtime Error):
N,X,M = map(int,input().split())
R = [X]
m = min(X,M)
for i in range(m):
    r = R[-1]
    r = r**2%M
    if r in R:
        break
    R.append(r)
for i in range(len(R)):
    if r == R[i]:
        break
a = 0
b = sum(R)
for j in range(i):
    a += R[j]
    b -= R[j]
n = len(R) - i
t = N - i
p = t // n
q = t % n
c = 0
for j in range(q):
    c += R[i+j]
ans = a + b*p + c
print(ans)

Buggy submission (verdict: Runtime Error):
N,X,M = map(int,input().split())
R = [X]
m = min(X,M)
for i in range(m):
    r = R[-1]
    r = r**2%M
    if r in R:
        break
    R.append(r)
for i in range(len(R)):
    if r == R[i]:
        break
a = 0
b = sum(R)
for j in range(i):
    a += R[j]
    b -= R[j]
n = len(R) - i
t = N - i
p = t // n
q = t % n
c = 0
for j in range(q):
    c += R[i+j]
ans = a + b*p + c
print(ans)
Problem p02546 (python)

Fixed submission:
word = list(input())


if word[-1] == "s":
    word.append("es")
else:
    word.append("s")
    
word_comp = "".join(word)

print(word_comp)

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

count = 0
for i in range(n - 1):
    c = i + 1
    a_b = n - c
    for j in range(a_b):
        a = j + 1
        if a_b % a == 0:
            count += 1

print(count)
Problem p02546 (python)

Fixed submission:
x= str(input())
a=list(x)
l=len(a)
if a[l-1]=='s':
    print(x+'es')
else:
    print(x+'s')

Buggy submission (verdict: Runtime Error):
 x= str(input())
a=list(x)
l=len(a)
if a[l-1]=='s':
    print(x+'es')
else:
    print(x+'s')
Problem p02552 (python)

Fixed submission:
N=int(input())
if N == 1:
    print(0)
elif N==0:
    print(1)

Buggy submission (verdict: Runtime Error):
N=int(input())
if N == 1:
    print(0)
elif N==o:
    print(1)
Problem p02549 (python)

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

mod = 998244353

m_list = []

for _ in range(k):
    m_list.append(list(map(int, input().split())))

dp = [0]*n
dp[0] = 1

dp_sum = [0]*n
dp_sum[0] = 1

for i in range(1, n):
    for j in range(k):
        l, r = m_list[j]
        il = i-l
        ir = i-r-1
        if il < 0:
            continue
        else:
            if ir < 0 :
                dp[i] += dp_sum[il]
            else:
                dp[i] += dp_sum[il] - dp_sum[ir]
            dp[i] %= mod
    dp_sum[i] = dp_sum[i-1] + dp[i]
    dp_sum[i] %= mod

print(dp[n-1] % mod)

Buggy submission (verdict: Runtime Error):
 import itertools

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

mod = 998244353

m_list = []

for _ in range(k):
    l, r = map(int, input().split())
    t_list = list(range(l,r+1))
    m_list.append(t_list)

m_list = list(itertools.chain.from_iterable(m_list))

dp = [0]*n
dp[0] = 1

for i in range(n):
    for j in range(len(m_list)):
        dp[i] += dp[i-m_list[j]]

print(dp[n-1] % mod)
Problem p02622 (python)

Fixed submission:
s = input()
t = input()
n = len(s)
ans = 0
for i in range(n):
  if s[i] != t[i]:
    ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
s=list(input())
t=list(input())
for m in range(len(m)):
    if m >= 2*10**5:
        break
    elif s != t:
        print(s[m])
Problem p02627 (python)

Fixed submission:
a=input()
if a.isupper():
    print('A')
elif a.lower():
    print('a')

Buggy submission (verdict: Runtime Error):
a = str(input())
if a = ('A'-'Z'):
    print('A')
elif a = ('a'-'z'):
    print('a')

Buggy submission (verdict: Runtime Error):
a = str(input())
if a == isupper():
    print('A')
elif a == islower():
    print('a')
Problem p02676 (python)

Fixed submission:
k=int(input())
s=input()

if len(s) <= k:
  print(s)
else:
  print(s[:k] + '...')

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

if len(s) ,= k:
  print(s)
else:
  print(s[:k] + '...')
Problem p02951 (python)

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

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

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split)
print(c-a+b)
Problem p03207 (python)

Fixed submission:
n=int(input())
p=[int(input()) for i in range(n)]
print(int(sum(p)-(max(p)/2)))

Buggy submission (verdict: Runtime Error):
n=int(input())
p=[int(input()) for i in range(n)]
print(int(sum(p)-(max(p)/2))
Problem p02785 (python)

Fixed submission:
#!/usr/bin/env python3

n, k = map(int, input().split())
h = sorted(map(int, input().split()), reverse=True)

print(sum(h[k:]))

Buggy submission (verdict: Runtime Error):
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;

  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }
  sort(h.begin(), h.end(), greater<int>());

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i < k) {
      ans++;
    } else {
      ans += h[i];
    }
  }
  cout << ans << endl;
  return 0;
}
Problem p02793 (python)

Fixed submission:
N = input()
A = map(int, raw_input().split())
 
MOD = 10 ** 9 + 7

def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

def lcm(x, y):
    return x/gcd(x, y)*y
 
l = A[0]
for a in A:
    l = lcm(l, a)
 
res = 0
for a in A:
    res = (res + (l * pow(a, MOD - 2, MOD)) % MOD) % MOD
 
print(res)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

MOD = int(1e9)+7

def extgcd(a, b):
    if b == 0:
        return [1, 0, a]
    x, y, g = extgcd(b, a%b)
    return [y, x - a//b * y, g]


def mod_inverse(a, m):
    x, y, _ = extgcd(a, m)
    return (m+x%m) % m


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

maxf = 2*n + 10
f = [1 for _ in range(maxf)]
invf = [1 for _ in range(maxf)]

for i in range(1, maxf):
    f[i] = (i * f[i - 1]) % MOD
 
invf[maxf-1] = pow(f[maxf - 1], MOD-2, MOD)
for i in range(maxf-1, 0, -1):
    invf[i-1] = (i*invf[i]) % MOD
 
def comb(a, b):
    if b > a:
        return 0
    return (((f[a]*invf[b]) % MOD) * invf[a-b]) % MOD

a = [ int(x) for x in input().split() ]
a.sort(reverse=True)

ans = 0

for i, v in enumerate(a):
    ans += v*comb(n-i-1, k-1)
    ans %= MOD
    ans -= v*comb(i, k-1)
    ans %= MOD
    
print(ans)
Problem p02819 (python)

Fixed submission:
#!/usr/bin/env python3

def is_prime(x):
    i = 2
    while i*i <= x:
        if x%i == 0: return False
        i += 1
    return x != 1

x = int(input())

while True:
    if is_prime(x):
        print(x)
        break
    x += 1

Buggy submission (verdict: Runtime Error):
#include <iostream>

using namespace std;

bool is_prime(long long x) {
  for (long long i = 2; i*i <= x; i++) {
    if (x % i == 0) { return false; }
  }
  return x != 1;
}

int main() {
  int x; cin >> x;

  for (int i = x; ; i++) {
    if (is_prime(i)) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}
Problem p02879 (python)

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

Buggy submission (verdict: Runtime Error):
a, b = map(int, input.split())
if a < 10 and b < 10:
  print(a*b)
else:
  print(-1)
Problem p02987 (python)

Fixed submission:
s = input()
d = {}
for ss in s:
    d[ss] = d.get(ss, 0) + 1

print("Yes" if len(d) == 2 and list(d.items())[0][1] == 2 else "No")

Buggy submission (verdict: Runtime Error):
s = input()
d = {}
for ss in s:
    d[ss] = d.get(ss, 0) + 1

print("Yes" if len(d) == 2 and d.items()[0][1] == 2 else "No")