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

Fixed submission:
N, K = map(int, input().split())
S = input()
K -= 1
answer = S[:K] + S[K].lower() + S[K+1:]
print(answer)

Buggy submission (verdict: Runtime Error):
b=int(input())
c=input()
c=c.replace(c[b-1],c[b-1].lower())
print(c)

Buggy submission (verdict: Runtime Error):
c=c.replace(c[b-1],c[b-1].upper())

Buggy submission (verdict: Runtime Error):
a=int(input())
b=int(input())
c=input()
c=c.replace(c[b-1],c[b-1].lower())
print(c)
Problem p02753 (python)

Fixed submission:
s=input()
s=list(s)
if "A" not in s or "B" not in s:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
s=map(str,input().split())
if A not in s or B not in s:
  print("No")
else:
  print("Yes")
Problem p02771 (python)

Fixed submission:
a,b,c=map(int,input().split())
s=set([a,b,c])
if len(s)==2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
a,b,c=map(map(int,input().split()))
s=set(a,b,c)
if len(s)==2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import sys
myset=set()
for n in range(3):
	myset[n-1].add(sys.argv[n])
if len(myset)==2:
	print("Yes")
else:
	print("No")
Problem p02860 (python)

Fixed submission:
x=int(input())
t=int(x/2)
y=str(input())
if x%2!=0:
  print("No")
  exit()
for i in range(t):
  if y[i]!=y[i+t]:
    print("No")
    exit()
print("Yes")

Buggy submission (verdict: Runtime Error):
x=int(input())
t=int(x/2)
y=str(input())
if x%2!=0:
  print("No")
  exit()
for i in range(x):
  if y[i]!=y[i+x]:
    print("No")
    exit()
print("Yes")
Problem p02779 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
print("YES" if len(set(a))==len(a) else "NO")

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
print(len(set(a)==len(a))
Problem p02629 (python)

Fixed submission:
N = int(input())
set_index = ''
while N > 0:
    N -= 1
    index = (N % 26) + ord('a')
    set_index += chr(index)
    N //= 26
print(set_index[::-1])

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


set_index = ''
while N > 0:
    N -= 1
    index = (N % 26) + ord('a')
    set_index += chr(index)
    N //= 26
print(set_index[::-1])
Problem p02779 (python)

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]
B = sorted(A)
NO = False
for i in range(0,len(B)-1):
    if B[i+1] - B[i] == 0:
        NO = True
if NO == True:
    print('NO')
else:
    print('YES')

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split]
for i in A:
    for j in A:
        if i == j:
            print('NO')
        else:
            print('YES')
Problem p02785 (python)

Fixed submission:
h, n = [int(x) for x in input().split()]
listk = [int(x) for x in input().split()]
listk.sort()
if n <= h:
    for i in range(0,n):
        listk.pop()
else:
    for i in range(0,h):
        listk.pop()
print(sum(listk))

Buggy submission (verdict: Runtime Error):
h, n = [int(x) for x in input().split()]
listk = [int(x) for x in input().split()]
listk.sort()
count = 0
for i in range(0,n):
    listk.pop()
print(sum(listk))
Problem p02622 (python)

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

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
c=0
for i in range(len(s)):
	if s[i]!=t[i]:
      c+=1
print(c)
Problem p02623 (python)

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

p, q = [0], [0]
for i in range(n):
	p.append(p[i] + a[i])
for i in range(m):
	q.append(q[i] + b[i])

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

	while q[j] > k - p[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()))

p, q = [0], [0]
for i in range(n):
	p.append(p[i] + a[i])
for i in range(m):
	q.append(q[i] + b[i])

j, ans = m, 0
for i in range(N+1):
	if a[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()))
j = 0
l = 0
c = 0
ans = 0
for i in range(n*k):
	if j >= n and l >=m:
		#print("test3")
		break

	if l >= n:
		#print("test1")
		if  k > c+a[j]:
			c += a[j]
			j += 1
			ans +=1
		else:
			break

	elif j >= m:
		#print("test2")
		if k > c + b[l]:
			c += b[l]
			l += 1
			ans +=1
		else:
			break

	else:
		if a[j] > b[l]:
			if k > c + b[l]:
				c += b[l]
				l += 1
				ans +=1
			else:
				break

		else:
			if  k > c+a[j]:
				c += a[j]
				j += 1
				ans +=1
			else:
				break
print(ans)
Problem p02688 (python)

Fixed submission:
n, k = map(int,input().split())
c = [0]*n

for i in range(k):
	d = int(input())
	a = list(map(int, input().split()))
	for k in range(len(a)):
		c[a[k]-1] +=1

print(c.count(0))

Buggy submission (verdict: Runtime Error):
n, k = map(int,input().split())
c = [0]*k

for i in range(k):
	d = int(input())
	for j in range(d):
		d = list(map(int, input().split()))
		for k in range(len(d)):
			c[d[k]] +=1

print(c.count(0))
Problem p02688 (python)

Fixed submission:
N,K=(map(int,input().split()))
a=[i for i in range(1,N+1)]
d=[]
A=[]
b=[]
count=0
for i in range(K):
    d.append(int(input()))
    A.append(list(map(int,input().split())))
for i in A:
    for j in i:
        b.append(j)
b1=list(dict.fromkeys(b))
for i in b1:
    if i in a:
        count+=1
print(N-count)

Buggy submission (verdict: Runtime Error):
N,K=(map(int,input().split()))
a=[i for i in range(1,N+1)]
d=[]
A=[]
b=[]
count=0
for i in (0,K):
    d.append(int(input()))
    A.append(list(map(int,input().split())))
for i in range(1,len(d)+1):
        if i in d:
            x=d.index(i)
            y=A[i-1]
            for j in range(0,len(y)):
                z=y[j]
                b.append(z)
b1=list(dict.fromkeys(b))
for i in b1:
    if i in a:
        count+=1
print(N-count)
Problem p02879 (python)

Fixed submission:
a1=input()
a2=[i for i in a1.split()]
x,y=float(a2[0]),float(a2[1])
v,v1=x.is_integer(),y.is_integer()
if 1<=x<=20 and 1<=y<=20 and v==v1==True:
    if 1<=x<=9 and 1<=y<=9:
        print(int(x*y))
    else:
        print('-1')

Buggy submission (verdict: Runtime Error):
a1=input()
a2=[i for i in a1.split()]
x,y=float(a2[0]),float(a2[1])
v,v1=x.is_integer(),y.is_integer()
if 1<=(x and y)<=20 and v1==v2==True:
    if 1<=(x and y)<=9:
        print(int(x*y))
    else:
        print('-1')
Problem p03041 (python)

Fixed submission:
import sys
a=sys.stdin.readline()
res = [int(i) for i in a.split() if i.isdigit()] 
N,K = [res[i] for i in (0,1)]
S=sys.stdin.readline(N)
K-=1
if N<0 or N>50:
  print("Error")
else:
  x=S[:K]
  y=S[K].lower()
  z=S[K+1:]
  print(x+y+z)

Buggy submission (verdict: Runtime Error):
import sys
a=sys.stdin.readline()
res = [int(i) for i in a.split() if i.isdigit()] 
N,K = [res[i] for i in (0,1)]
S=sys.stdin.readline(3)
K-=1
if N<0 or N>50:
  print("Error")
else:
  x=S[:K]
  y=S[K].lower()
  z=S[K+1:]
  print(x+y+z)

Buggy submission (verdict: Runtime Error):
S=input("Enter String: ")
N=len(S)
B=int(input("Enter K: "))
K=B-1
if N<0 or N>50:
  print("Error")
else:
  A=S[:K]+S[K].lower()+S[K+1:]
  print(A)
Problem p03041 (python)

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

newS = s[:k-1]+s[k-1].lower()+s[k:]

print(newS)

Buggy submission (verdict: Runtime Error):
n, k = [int(s) for s in input().split()]
s = input()

print(s[:k-1] + lower(s[k-1]) + s[k:])

Buggy submission (verdict: Runtime Error):
n, k = [int(s) for s in input().split()]
s = input()

print(s[:k-1] + lower(s[k-1]) + s[k])
Problem p02693 (python)

Fixed submission:
K = int(input())
A, B  = map(int, input().split())
X = B//K - A//K

if B%K == 0 or A%K == 0:
    print("OK")

elif X == 0 :
    print("NG")

else :
    print("OK")

Buggy submission (verdict: Runtime Error):
K=int(input())
A=int(input())
B=int(input())
largest=(B/K)*K
if A<=largest:
  print("OK")
else:
  print("NG")

Buggy submission (verdict: Runtime Error):
K=int(input())
A=int(input())
B=int(input())
if B-A>=7:
  print("OK")
elif K=="1":
  print("OK")
else:
  print("NG")
Problem p02699 (python)

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

Buggy submission (verdict: Runtime Error):
S=int(input())
W=int(input())
if W>=S:
  print("unsafe")
else:
  print("safe")

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

Fixed submission:
A = int(input())
B = int(input())
print(6-A-B)

Buggy submission (verdict: Runtime Error):
A,B=map(int, input().split())
if (A==1 and B==2) or (A==2 and B==1):
  print(3)
elif (A==2 and B==3) or (A==3 and B==2):
  print(1)
elif (A==1 and B==3) or (A==3 and B==1):
  print(2)
Problem p02847 (python)

Fixed submission:
D = input()
W = ['SUN','MON','TUE','WED','THU','FRI','SAT'] 
print(7 - W.index(D))

Buggy submission (verdict: Runtime Error):
D = input()
W = ['SUN','MON','TUE','WED','THU','FRI','SAT'] 
print(7 - l.index(D))
Problem p02951 (python)

Fixed submission:
A, B, C = map(int, input().split())
water = C-(A-B)
print(water if water > 0 else 0)

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
water = c-(a-b)
print(water if water > 0 else 0
Problem p03785 (python)

Fixed submission:
import sys
N, C, K = map(int, input().split())
A = list(map(int, sys.stdin.readlines()))+[10**10]
A.sort()
a, c, t = 0, 1, A[0]+K
for i in A[1:]:
    if i <= t and c < C:
        c += 1
    else:
        t, c = i + K, 1
        a += 1
 
print(a)

Buggy submission (verdict: Runtime Error):
import sys
N, C, K = map(int, input().split())
A = list(map(int, sys.stdin.readlines()))+[10**10]
A.sort()
a, c, t = 0, 1, a[0]+k
for i in A[1:]:
    if i <= t and c < C:
        c += 1
    else:
        t, c = i + K, 1
        a += 1
 
print(a)
Problem p02659 (python)

Fixed submission:
A, B = map(str, input().split())
A = int(A)
B = int(B.replace('.', ''))
print(A * B // 100)

Buggy submission (verdict: Runtime Error):
A, B = map(str, input().split())
A = int(A)
B = int(B.replace(',', ''))
print(A * B / 100)

Buggy submission (verdict: Runtime Error):
A, B = map(str, input())
A = int(A)
B = int(B.replace(',', ''))
print(A * B / 100)
Problem p02699 (python)

Fixed submission:
s,w=map(int,input().split())

if s>w:
  print("safe")
else:
  print("unsafe")

Buggy submission (verdict: Runtime Error):
S=input(sheeps:)
W=input(wolfs:)

if S>W:
  print("safe")
else:
  print("unsafe")
Problem p02712 (python)

Fixed submission:
N=int(input())

print(sum(i for i in range(1,N+1) if i%3 and  i%5))

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

print(sum(i for i in range(1,N+1) if i%3==0 or  i%5==0))
Problem p02771 (python)

Fixed submission:
A,B,C=map(int,input().split())

if A==B==C or A!=B!=C!=A:
  print("No")
else:
  print("Yes")

Buggy submission (verdict: Runtime Error):
A,B,C=map(int,input().split())

if A=B=C or A!=B!=C:
  print("No")
else:
  print("Yes")
Problem p02629 (python)

Fixed submission:

def main():
    n = int(input())
    ans = ''
    
    for i in range(1, 99):
        if n <= 26 ** i:
            n -= 1
            for j in range(i):
                ans += chr(ord('a') + n % 26)
                n //= 26
            break
        else:
            n -= 26 ** i
    
    print(ans[::-1])
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
    #print(len(alphabet))
    ans = ''
    
    i = 1
    length = 1
    while (26 ** (i-1)) + (26 ** i) < n:
        length += 1
        i += 1
        #print(length)
    
    #print(length)
    for j in reversed(range(1, length+1)):
        r = n // 26 **(j-1)
        n -= (26 ** (j - 1))* r
        ans = alphabet[r-1] + ans
        #print(j)
    
    
    print(ans)
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

def main():
    n = int(input())
    alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
    #print(len(alphabet))
    exponent_list = [0]
    for i in range(1, 12):
        exponent_list.append(exponent_list[i-1] + 26**i)
    #print(exponent_list)
    index = 0
    n_index = 0
    ans = ''
    

    
    while exponent_list[index] < n:
        n_index = index
        index += 1
    #print(n_index)
    r_list = []
    r = 27
    b = 0
    while r > 27:
        tmp = n - exponent_list[n_index]
        r = int(tmp/26)
        b = tmp % 26
    
    ans = alphabet[r] + alphabet[b]
    print(ans)
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):

def main():
    n = int(input())
    alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
    #print(len(alphabet))
    exponent_list = [0]
    for i in range(1, 12):
        exponent_list.append(exponent_list[i-1] + 26**i)
    #print(exponent_list)
    index = 0
    n_index = 0
    ans = ''
    

    
    while exponent_list[index] < n:
        n_index = index
        index += 1
    #print(n_index)
    r_list = []
    r = 27
    b = 0
    while r > 27:
        tmp = n - exponent_list[n_index]
        r = int(tmp/26)
        b = tmp % 26
    
    ans = alphabet[r] + alphabet[b]
    print(ans)
    
if __name__ == '__main__':
    main()
Problem p02693 (python)

Fixed submission:
def we_love_golf():
    K = int(input())
    condition = input()
    condition_list = condition.split()
    A = int(condition_list[0])
    B = int(condition_list[1])
    
    for i in range(A, B+1):
        if i % K == 0:
            print('OK')
            return
    
    print('NG')
    return

we_love_golf()

Buggy submission (verdict: Runtime Error):
from decimal import Decimal

def main():
    a, b, n = list(map(int, input().split()))
    
    floor_list = []
    
    for i in range(n+1):
        floor_1 = int(Decimal(a*i/b))
        floor_2 = a * int(Decimal(i/b))
        floor_list.append(floor_1 - floor_2)
    
    print(max(floor_list))

if __name__ == '__main__':
    main()
Problem p02862 (python)

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

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

MOD = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % MOD )
    inverse.append( ( -inverse[MOD % i] * (MOD//i) ) % MOD )
    g2.append( (g2[-1] * inverse[-1]) % MOD )

Z=X+Y
if Z%3 == 0:
    D=int(Z/3)
    d=min(X,Y)
    print(cmb(D,d-D,MOD))
else:
    print(0)

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

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

MOD = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

Z=X+Y
if Z%3 == 0:
    D=int(Z/3)
    print(cmb(D,abs(D-X),MOD))
else:
    print(0)
Problem p02873 (python)

Fixed submission:
S=input()
S_rev=S[::-1]

import numpy as np

arr_rev=[]
cnt=0
for s_rev in S_rev:
    if s_rev==">":
        cnt+=1
    else:
        cnt=0
    arr_rev.append(cnt)

A=np.array(arr_rev[::-1]+[0])

arr=[]
cnt=0
for s in S:
    if s=="<":
        cnt+=1
    else:
        cnt=0
    arr.append(cnt)

B=np.array([0]+arr)

print(sum(np.maximum(A,B)))

Buggy submission (verdict: Runtime Error):
import numpy as np
S=input();T=S[::-1];a=[];c=0
for t in T:
    if t==">":
        c+=1
    else:
        c=0
    a.append(c)
A=np.array(a[::-1]+[0])
b=[];c=0
for s in S:
    if s=="<":
        c+=1
    else:
        c=0
    b.append(c)
B=np.array([0]+b)
print(np.maximum(A,B).sum())
Problem p02912 (python)

Fixed submission:
from heapq import heappop,heappush,heapify
n,m=map(int,input().split())
A=list(map(int,input().split()))
A_m=list(map(lambda x: -x,A))
heapify(A_m)
pop=lambda: -heappop(A_m)
push=lambda x: heappush(A_m,-x)
for _ in range(m):
    x=pop()
    push(x//2)
print(-sum(A_m))

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

N,M=map(int,input().split())
A=list(map(int,input().split()))
queue=deque(A)
for i in range(M):
    queue.append([max(queue)//2])
    queue.remove(max(queue))
print(sum(queue))

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

from collections import deque
queue=deque(A)
for i in range(M):
    queue.extend([max(queue)//2])
    A.remove(max(queue))
print(sum(queue))
Problem p03013 (python)

Fixed submission:
MOD=10**9+7
N,M=map(int,input().split())
dp=[0]*(N+1)
dp[0]=1
A=set(int(input()) for _ in range(M))
for i in range(1,N+1):
    if i in A:
        continue
    x=dp[i-1]
    if i>1:
        x+=dp[i-2]
    dp[i]=x%MOD
print(dp[N])

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
a = []
for _ in range(M):
    a.append(int(input()))

arr=[0]*N

if 1 in a:
    arr[0]=0
else:
    arr[0]=1

if 2 in a:
    arr[1]=0
else:
    arr[1]=1+arr[0]
    
for i in range(2,N):
    if i+1 in a:
        arr[i]=0
    else:
        arr[i]=arr[i-1]+arr[i-2]

print(arr[-1]%(10**9+7))
Problem p03127 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a
ans=10**10
for i,j in zip(a,a[1:]):
    ans=min(ans,gcd(i,j))
print(ans)

Buggy submission (verdict: Runtime Error):
n=int(input())
a=sorted(list(map(int,input().split())))
ans=10**7
m=a[-1]
for i in range(len(a)-1):
    t=m%(a[i+1]-a[i])
    s=a[i+1]%a[i]
    if t!=0:
        ans=min(ans,t)
    if s!=0:
        ans=min(ans,s)
print(ans)
Problem p03250 (python)

Fixed submission:
x=sorted(input().replace(' ',''))
print(int(''.join(x[:-3:-1]))+int(x[0]))

Buggy submission (verdict: Runtime Error):
x=sorted(input())
print(int(''.join(x[:-3:-1]))+int(x[0]))
Problem p03803 (python)

Fixed submission:
a,b=map(int,input().split())
if a>1:
    a=a
else:
    a=14
if b>1:
    b=b
else:
    b=14
print('Draw' if a==b else 'Alice' if a>b else 'Bob')

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split().replace(1,14)
print('Draw' if a==b else 'Alice' if a>b else 'Bob')
Problem p02622 (python)

Fixed submission:
s = input()
t = input()

ans = 0
for i in range(len(s)):
    if s[i] != t[i]:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
t = input()
ans = 0
for i in range(lne(s)):
  ans +=(s[i]!=t[i])
  
print(ans)
Problem p02771 (python)

Fixed submission:
l = input().split()
print( "Yes" if (len(set(l)) == 2) else "No")

Buggy submission (verdict: Runtime Error):
l = input().split()
print( "Yes" (len(set(l)) == 2) else "No")
Problem p02831 (python)

Fixed submission:

A, B = map(int, input().split())

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

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

print(lcm(A,B))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())

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

print(lcm(A,B))

Buggy submission (verdict: Runtime Error):
import math
A, B = map(int, input().split())

def gcd(a,b):
    return math.gcd(a,b)

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

print(lcm(A,B))

Buggy submission (verdict: Runtime Error):
import math as m
A, B = map(int, input().split())

def gcd(a,b):
    return m.gcd(a,b)

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

print(lcm(A,B))
Problem p02959 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

res = 0
rem = 0

for i in range(N):
    mobs_rem = min(A[i], rem)
    A[i] -= mobs_rem
    mobs = min(A[i], B[i])
    rem = B[i] - mobs
    res += (mobs+mobs_rem)

res += min(A[N], rem)
print(res)

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


# Imperative solution
# res = 0
# rem = 0

# for i in range(N):
#     mobs_rem = min(A[i], rem)
#     A[i] -= mobs_rem
#     mobs = min(A[i], B[i])
#     rem = B[i] - mobs
#     res += (mobs+mobs_rem)

# res += min(A[N], rem)
# print(res)

# Functional
def rec(idx, res, rem):
    if idx == N:
        res += min(A[idx], rem)
        return res
    mobs_rem = min(A[idx], rem)
    mobs = min(A[idx] - mobs_rem, B[idx])
    rem = B[idx] - mobs
    res += (mobs + mobs_rem)
    return rec(idx+1, res, rem)


print(rec(0, 0, 0))
Problem p03137 (python)

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

if (N>= M) or (M == 1):
    print(0)
else:
    l.sort()
    l_dist =[]

    for i in range(1, M):
        l_dist.append(abs(l[i]-l[i-1]))

    l_dist.sort()

    ans = sum(l_dist[:len(l_dist) - (N-1)])

    print(ans)

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

if M == 1:
    print(0)
else:
    l.sort()
    l_dist =[]

    for i in range(1, M):
        l_dist.append(abs(l[i]-l[i-1]))

    l_dist.sort()

    for i in range(N-1):
       del l_dist[-1]

    print(sum(l_dist))

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

if M == 1:
    print(0)
else:
    l.sort()
    l_dist =[]
    
    for i in range(1, M):
        l_dist.append(abs(l[i]-l[i-1]))

    l_dist.sort()

    for i in range(N-1):
        l_dist.pop()

    print(sum(l_dist))

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

if M == 1:
    print(0)
else:
    l.sort()
    l_dist =[]
    for i in range(1, M):
        l_dist.append(abs(l[i]-l[i-1]))

    l_dist.sort()

    for i in range(N-1):
        l_dist.pop()

    print(sum(l_dist))

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

if M == 1:
    print(1)
else:
    l.sort()
    l_dist =[]
    for i in range(1, M):
        l_dist.append(abs(l[i]-l[i-1]))

    l_dist.sort()

    for i in range(N-1):
        l_dist.pop()

    print(sum(l_dist))
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 = [0]
B = [0]
for i in range(n):
	A.append(A[i]+a[i])
for j in range(m):
	B.append(B[j]+b[j])

#print(A,B)

maxij = 0
l = m
for i in range(n+1):
	for j in range(m):
#		print(i,l,A[i],B[l],k)
		if(l == -1):
			break
		elif((A[i]+B[l]) <= k):
		 	maxij=max(maxij,i+l)
#		 	print("mm",maxij)
		 	break
		else:
		 	l-=1
print(maxij)

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 = [0]
B = [0]
for i in range(n):
	A.append(A[i]+a[i])
for j in range(m):
	B.append(B[j]+b[j])

#print(A,B)

maxij = 0
l = m
for i in range(n+1):
	for j in range(m):
#		print(i,l,A[i],B[l],k)
		if((A[i]+B[l]) <= k):
		 	maxij=max(maxij,i+l)
#		 	print("mm",maxij)
		 	break
		else:
		 	l-=1
print(maxij)

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 = [0]
B = [0]
for i in range(n):
	A.append(A[i]+a[i])
for j in range(m):
	B.append(B[j]+b[j])

print(A,B)

maxij = 0
l = m
for i in range(n+1):
	for j in range(m):
#		print(i,l,A[i],B[l],k)
		if((A[i]+B[l]) <= k):
		 	maxij=max(maxij,i+l)
#		 	print("mm",maxij)
		 	break
		else:
		 	l-=1
print(maxij)