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

Fixed submission:
import sys
input = sys.stdin.readline

def main():
    s = list(input().rstrip())
    k = int(input())


    if len(s) == 1:
        print(k//2)
    else:
        sa = s[:]

        c1 = 0
        c2 = 0

        for i in range(len(s) - 1):
            if sa[i] == sa[i+1]:
                c1 += 1
                sa[i+1] = '1'


        if sa[0] == sa[-1]:
            s[0] = '2'
            c2 += 1

            for i in range(len(s) - 1):
                if s[i] == s[i+1]:
                    c2 += 1
                    s[i+1] = '2'


            if s[-1] == sa[0]:
                print(c1 + c2*(k-1))
            elif s[-1] != sa[0]:
                if k % 2 == 0:
                    x = k // 2
                    print(c1*x + c2*x)
                else:
                    x = k // 2
                    print(c1*(x+1) + c2*x)
        else:
            print(c1*k)

if __name__ == '__main__':
    main()

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

def main():
    s = list(input().rstrip())
    k = int(input())

    c = 0

    if s[0] == s[-1]:
        if s[0] == s[1]:
            s[0] = '2'
        else:
            s[-1] = '2'

        c += 1

    for i in range(len(s) - 1):
        if s[i] == s[i+1]:
            c += 1
            s[i+1] = '1'

    print(c*k)


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

Fixed submission:
X = int(input())
x = 1
while True:
    if X*x % 360  == 0:
        print(x)
        break
    x += 1

Buggy submission (verdict: Runtime Error):
print(360/X)
Problem p02880 (python)

Fixed submission:
n = int(input())
 
def is_product_of_two_digits(n):
  for i in range(1, 10):
    if n % i == 0 and 1 <= n // i <= 9:
      return True
  return False
    
if is_product_of_two_digits(n):
  print('Yes')
else:
  print('No')

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

def is_product_of_two_digits(n):
  for i in range(10):
    if n % i == 0 and 1 <= n // i <= 9:
      return True
  return False
    
if is_product_of_two_digits(n):
  print('Yes')
else:
  print('No')
Problem p02659 (python)

Fixed submission:
from decimal import Decimal
import math
a, b = map(Decimal, input().split())

a *= b

print(math.floor(a))

Buggy submission (verdict: Runtime Error):
import math
a, b = input().split()
a = int(a)
b = float(b)
b = int(b*100)
a *= b
a //= 100
print(a)
Problem p02793 (python)

Fixed submission:
import sys
input = sys.stdin.readline
import fractions
N=int(input())
A=list(map(int,input().split()))
c=1
a=0
w=10**9+7
for A_ in A:
    c=c*A_//fractions.gcd(c,A_)
for A_ in A:
    a+=c//A_
print(int(a%w))

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import fractions
from functools import reduce
n = int(input())
A = []
A = list(map(int, input().split()))
mod = 10**9 + 7
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
Z = lcm_base(A)
ans = sum(Z//a%mod for a in A)%mod
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import fractions
from functools import reduce
n = int(input())
A = []
A = list(map(int, input().split()))
mod = 10**9 + 7
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
Z = lcm(A)
ans = sum(Z//a%mod for a in A)%mod
print(ans)

Buggy submission (verdict: Runtime Error):
def main():
	import sys
	input = sys.stdin.readline
	import fractions
	from functools import reduce
	n = int(input())
	A = []
	A = list(map(int, input().split()))
	mod = 10**9 + 7
	def lcm_base(x, y):
    	return (x * y) // fractions.gcd(x, y)

	def lcm(*numbers):
    	return reduce(lcm_base, numbers, 1)
	Z = lcm(*A)
	ans = sum(Z//a%mod for a in A)%mod
	print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import fractions

import numpy as np
n = int(input())
A = []
A = list(map(int, input().split()))
mod = 10**9 + 7

Z = np.lcm.reduce(np.array(A))
ans = sum(Z//a%mod for a in A)%mod
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions

import numpy as np
n = int(input())
A = []
A = list(map(int, input().split()))
mod = 10**9 + 7

Z = np.lcm.reduce(np.array(A))
ans = sum(Z//a%mod for a in A)%mod
print(ans)
Problem p02935 (python)

Fixed submission:
input()
A = list(map(int, input().split()))
A.sort()
while len(A)>1:
  b = A[0:2]
  c = sum(i for i in b)
  A.append(c/2)
  del(A[0:2])
  A.sort()
z = [str(a) for a in A]
z = ''.join(z)
print(z)

Buggy submission (verdict: Runtime Error):
input()
A = list(map(int, input().split()))
A.sort()
while len(A)>=1:
    A.append((A[0]+A[1])/2)
    del(A[0:2])
    A.sort()
print(A)
Problem p02987 (python)

Fixed submission:
S = input()
A = sorted(S)
if A[0] == A[1] == A[2]:
    print('No')
elif A[0] == A[1] and A[2] == A[3]:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import math
a, b, c, d = map(int, input().split())
e = (c*d)/math.gcd(c,d)
bb = b-(b//c + b//d- b//e)
aa = a-1-((a-1)//c+(a-1)//d-(a-1)//e)
z = bb-aa
print(z)
Problem p02989 (python)

Fixed submission:
n = int(input())
d = list(map(int, input().split()))
d.sort()
if d[int((n/2))] == d[int(n/2)-1]:
    print(0)
else:
    print(d[int(n/2)]-d[int((n/2)-1)])

Buggy submission (verdict: Runtime Error):
import fractions
a, b, c, d = map(int, input().split())
e = (c*d)/fractions.gcd(c,d)
bb = b-((b//c) + (b//d)- (b//e))
aa = a-1-(((a-1)//c)+((a-1)//d)-((a-1)//e))
z = bb-aa
print(int(z))

Buggy submission (verdict: Runtime Error):
import fractions
a, b, c, d = map(int, input().split())
e = (c*d)/fractions.gcd(c,d)
bb = b-(b//c + b//d- b//e)
aa = a-1-((a-1)//c+(a-1)//d-(a-1)//e)
z = bb-aa
print(int(z))
Problem p03013 (python)

Fixed submission:
def Fib(n):
    a, b = 1, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]

flag = True
if M == 1:
    print(Fib(a[0])*Fib(N-a[M-1]))
elif M == 0:
    print(Fib(N+1)%1000000007)
else:
    m = Fib(a[0])*Fib(N-a[M-1])
    for i in range(M-1):
        if a[i] + 1 == a[i+1]:
            print(0)
            flag = False
            break
    if flag:
        for j in range(M-1):
            dev = a[j+1]-a[j]-1
            m = m*Fib(dev)%1000000007
        print(m%1000000007)

Buggy submission (verdict: Runtime Error):
def Fib(n):
    a, b = 1, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
m = Fib(a[0])*Fib(N-a[M-1])
flag = True
for i in range(M-1):
    if a[i] + 1 == a[i+1]:
        print(0)
        flag = False
        break
if flag:
    for j in range(M-1):
        dev = a[j+1]-a[j]
        m = m*Fib(dev)
    print(m%1000000007)

Buggy submission (verdict: Runtime Error):
def Fib(n):
    a, b = 1, 1
    if n == 1:
        return a
    elif n == 2:
        return b
    else:
        for i in range(n-2):
            a, b = b, a + b
        return b
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
m = Fib(a[0])*Fib(N-a[M-1])
flag = True
for i in range(M-1):
  if a[i] + 1 == a[i+1]:
    print(0)
    flag = False
    break
if flag:
    for j in range(M-1):
        dev = a[j+1]-a[j]
        m = m*Fib(dev)
    print(m%1000000007)
Problem p03127 (python)

Fixed submission:
import fractions
n = int(input())
A = list(map(int, input().split()))
min_A = min(A)
B = []
for i in range(n):
  B.append(A[i]%min_A)
if all(B[i] == 0 for i in range(n)):
  print(min_A)
else:
  m = A[0]
  for i in range(1,n):
    m = fractions.gcd(m, A[i])
  print(m)

Buggy submission (verdict: Runtime Error):
import fractions
n = int(input())
A = list(map(int, input().split()))
min_A = min(A)
for i in range(n):
  A[i] = A[i]%min_A
if all(A[i] == 0 for i in range(n)):
  print(min_A)
else:
  print(fractions.gcd(A[j] for j in range(n)))
Problem p02695 (python)

Fixed submission:
import sys
readline = sys.stdin.readline
from collections import deque

def main():
    N, M, Q = map(int, readline().rstrip().split())
    P = [tuple(map(int, readline().rstrip().split())) for _ in range(Q)]
    ans = 0
    l = [[i] for i in range(1, M+1)]
    que = deque(l)
    for i in range(N):
        for _ in range(len(que)):
            ll = que.popleft()
            for j in range(ll[-1], M+1):
                que.append(ll + [j])
    
    for pair in que:
        score = 0
        for a, b, c, d in P:
            if pair[b-1] - pair[a-1] == c:
                score += d
        ans = max(ans, score)
    
    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline
from itertools import combinations_with_replacement

def main():
    N, M, Q = map(int, readline().rstrip().split())
    P = [tuple(map(int, readline().rstrip().split())) for _ in range(Q)]
    ans = 0    
    for pair in combinations_with_replacement([i for i in range(1, M+1)], M):
        score = 0
        for a, b, c, d in P:
            if pair[b-1] - pair[a-1] == c:
                score += d
        ans = max(ans, score)
    
    print(ans)

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

Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
    X = [None] * len(A)
    X[0] = sum(A) - 2 * sum([A[i] for i in range(1, len(A), 2)])
    for i in range(len(A)-1):
        X[i+1] = 2 * A[i] - X[i]
    
    print(' '.join(list(map(str, X))))
    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    A = list(map(int, input().split()))
    mt = [None] * N

    for s in range(A[0] * 2, -1, -2):
        mt[0] = s
        for n in range(N-1):
            if mt[n] > A[n+1] * 2:
                break
            mt[n+1] = (A[n+1] - mt[n]//2) * 2
        if mt[N-1] //2 + mt[0] // 2 == A[0]:
            print(mt[-1], ' '.join(list(map(str, mt[:-1]))))
            return

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

Fixed submission:
from math import factorial

N, K = map(int, input().split())
n_blue, n_red = K, N-K

for k in range(1, K+1):
    if k-1 > n_red:
        print(0)
        continue
    retval = (factorial(n_red+1) // (factorial(n_red-k+1) * factorial(k))) * (factorial(n_blue-1) // (factorial(n_blue-k) * factorial(k-1)))
    print(retval % (10**9 + 7))

Buggy submission (verdict: Runtime Error):
import sys
readline = sys.stdin.readline
from math import factorial
MOD = 10 ** 9 + 7

def main():
    N, K = map(int, readline().rstrip().split())
    f1 = factorial(N-K+1)
    f2 = factorial(K-1)
    f3 = 1
    for i in range(1, K+1):
        ans = f2 // (f3 * factorial(K-i))
        f3 *= i
        ans *= f1 // (f3 * factorial(N-K+1-i))
        print(ans % MOD)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from math import factorial

N, K = map(int, input().split())
n_blue, n_red = K, N-K

for k in range(1, K+1):
    retval = (factorial(n_red+1) // (factorial(n_red-k+1) * factorial(k))) * (factorial(n_blue-1) // (factorial(n_blue-k) * factorial(k-1)))
    print(retval % (10**9 + 7))
Problem p03107 (python)

Fixed submission:
def main():
    S = list(map(int, list(input())))

    cnt1 = sum(S)
    cnt0 = len(S) - cnt1
    print(2 * min(cnt0, cnt1))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
def check(S):
    stop = True
    if len(S) < 2:
        print(base_S_length - len(S))
        sys.exit()
    for i in range(len(S) - 1):
        if (S[i] + S[i + 1]) == 1:
            S[i] = S[i + 1] = 2
            stop = False    
    if stop:
        print(base_S_length - len(S))
        sys.exit()
    S = [i for i in S if i != 2]
    check(S)

S = list(map(int, list(sys.stdin.readline())))
base_S_length = len(S)
check(S)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.input
def check(S, cnt):
    if len(S) < 2:
        print(cnt)
        sys.exit()
    for i in range(len(S) - 1):
        if S[i] != S[i + 1]:
            S = S[:i] + S[i + 2:]
            cnt += 2
            check(S, cnt)
    print(cnt)
    sys.exit()

S = list(map(int, list(input())))
check(S, cnt=0)

Buggy submission (verdict: Runtime Error):
import sys
def check(S, cnt):
    stop = True
    if len(S) < 2:
        print(cnt)
        sys.exit()
    for i in range(len(S) - 1):
        if S[i] != S[i + 1]:
            S = S[:i] + S[i + 2:]
            cnt += 2
            check(S, cnt)
    print(cnt)
    sys.exit()

S = list(map(int, list(input())))
check(S, cnt=0)

Buggy submission (verdict: Runtime Error):
import sys
def check(S, cnt):
    if len(S) < 2:
        print(cnt)
        sys.exit()
    for i in range(len(S) - 1):
        if S[i] ^ S[i + 1]:
            S = S[:i] + S[i + 2:]
            cnt += 2
            check(S, cnt)
    print(cnt)
    sys.exit()

S = list(map(int, list(input())))
check(S, cnt=0)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
def check(S, cnt):
    if len(S) < 2:
        print(cnt)
        sys.exit()
    for i in range(len(S) - 1):
        if S[i] ^ S[i + 1]:
            S = S[:i] + S[i + 2:]
            cnt += 2
            check(S, cnt)
    print(cnt)
    sys.exit()

S = list(map(int, list(input())))
check(S, cnt=0)
Problem p03208 (python)

Fixed submission:
N, K = map(int, input().split())
heights = sorted([int(input()) for _ in range(N)])
ans = max(heights)
for i in range(N - K + 1):
    if abs(heights[i] - heights[i + K - 1]) < ans:
        ans = abs(heights[i] - heights[i + K - 1])
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
heights = sorted([int(input() for _ in range(N)])
ans = float('inf')
for i in range(N - K + 1):
    if abs(heights[i] - heights[i + K - 1]) < ans:
        ans = abs(heights[i] - heights[i + K - 1])
print(ans)
Problem p02659 (python)

Fixed submission:
a, b = input().split()
a = int(a)
b = int(b[0])*100 + int(b[2])*10 + int(b[3])
c = a*b
print(c//100)

Buggy submission (verdict: Runtime Error):
a, b = input().split()
a = int(a)
b = int(b[0])*100 + int(b[1])*10 + int(b[3])
c = a*b
print(c//100)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
print(a*b//1)
Problem p02819 (python)

Fixed submission:
def com(_x):
    _flg = 1
    mx  = int(_x**0.5)
    for i in range(2, mx+1):
        if _x % i == 0:
            _flg = 0
            break
    return _flg


def main():
    x = int(input())
    flg = 0
    while flg == 0:
        #print("a")
        flg = com(x)
        if flg == 0:
            x+=1
    print(x)



if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def com(_x):
    _flg = 1
    mx  = int(_x**0.5)
    for i in range(2, mx+1):
        if _x % i == 0:
            _flg = 0
            break
    return _flg


x = int(input())
flg = 0
while flg == 0:
    #print("a")
    _flg = 1
    mx  = int(_x**0.5)
    for i in range(2, mx+1):
        if _x % i == 0:
            _flg = 0
            break
    fig = _flg
    if flg == 0:
        x+=1
print(x)

Buggy submission (verdict: Runtime Error):
def com(_x):
    _flg = 1
    mx  = int(_x**0.5)
    for i in range(2, mx+1):
        if _x % i == 0:
            _flg = 0
            break
    return _flg


x = int(input())
flg = 0
  while flg == 0:
      #print("a")
      flg = com(x)
      if flg == 0:
          x+=1
print(x)
Problem p02831 (python)

Fixed submission:
import fractions
a, b = map(int, input().split())
print( (a*b)//fractions.gcd(a, b) )

Buggy submission (verdict: Runtime Error):
import math
a, b = map(int, input().split())
print( (a*b)//math.gcd(a, b) )
Problem p02989 (python)

Fixed submission:
cnt = int(input())
in_str = [int(i) for i in input().split()]
in_str.sort()
#print("in_str[cnt // 2-1]",in_str[cnt // 2-1])
#print("in_str[cnt//2]",in_str[cnt//2])
print(in_str[cnt//2] - in_str[cnt // 2-1])

Buggy submission (verdict: Runtime Error):
cnt = int(input())
in_str = [int(i) for i in input().split()]
in_str.sort()
print(in_str[cnt//2+1] - in_str[cnt // 2])
Problem p02682 (python)

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

nokori = K - A - B

wa = 0
while True:
    if A >= K:
        wa += K
        break
    else:
        wa += A
    if C >= nokori:
        wa -= nokori
        break
    else:
        wa -= C
        break

print(wa)

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

nokori = K - A - B

wa = 0
wa += A

if nokori == 0:
    a    
elif C >= nokori:
    wa -= nokori
else:
    wa -= C

print(wa)
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,w=map(it,input().split())
if s<=w:
  print("unsafe")
else:
  print("safe")
Problem p02707 (python)

Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n-1):
    b[a[i]-1]+=1
for i in range(n):
    print(b[i])

Buggy submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=[0]*n
for i in range(n-1):
    b[a[i]-1]+=1
for i in range(n+1):
    print(b[i])
Problem p02847 (python)

Fixed submission:
s=input()
if s=="SUN":
    print(7)
elif s == "MON":
    print(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)

Buggy submission (verdict: Runtime Error):

s=input()
if s=="SUN":
    print(7)
elif s == "MON":
    ptint(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)

Buggy submission (verdict: Runtime Error):
s=input()
if s=="SUN":
    print(7)
elif s == "MON":
    ptint(6)
elif s == "TUE":
    print(5)
elif s == "WED":
    print(4)
elif s == "THU":
    print(3)
elif s == "FRI":
    print(2)
elif s == "SAT":
    print(1)

Buggy submission (verdict: Runtime Error):

S=input()
if s='SUN':
    print(7)
elif s = 'MON':
    ptint(6)
elif s = 'TUE':
    print(5)
elif s = 'WED':
    print(4)
elif s = 'THU':
    print(3)
elif s = 'FRI':
    print(2)
elif s = 'SAT':
    print(1)
Problem p02860 (python)

Fixed submission:
n = int(input())
s = input()
if n%2==0:
    a = s[0:(int(n/2))]
    b = s[(int(n/2)):n]
    if a==b:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
if n%2==0:
    a = s[0:(n/2-1)]
    b = s[(n/2):]
    if a==b:
        print("Yes")
else:
    print("No")
Problem p02881 (python)

Fixed submission:
N = int(input())
lst=[]
for i in range(1,int(N**0.5)+1):
    if N%i==0:
        lst.append(i+N//i-2)
print(min(lst))

Buggy submission (verdict: Runtime Error):
N = int(input())
lst=[]
for i in range(1,int(N**0.5)+1):
    if n%i==0:
        lst.append(i+n//i-2)
print(min(lst))

Buggy submission (verdict: Runtime Error):
N = int(input())
lst=[]
for i in range(1,int(N**0.5)+1):
    if n%i==0:
        lst.append(i+n//i-1)
print(min(lst))

Buggy submission (verdict: Runtime Error):
N = int(input())
min=1000000000000
if N%2==0:
    for i in range(int(N/2),1, -1):
        if N%i==0:
            if min>int(i+N/i-2):
                min=int(i+N/i-2)
    print(min)
else:
    for i in range(int((N-1)/2), 1,-1):
        if N%i==0:
            if min>print(int(i+N/i-2)):
                min=print(int(i+N/i-2))
    print(min)
Problem p02987 (python)

Fixed submission:
s=input()
t=sorted(s)
u=''.join(t)
if u[0]==u[1] and u[1]!=u[2] and u[2]==u[3]:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s=input()
s.sort()
if s[0]==s[1] and s[1]!=s[2] and s[2]==s[3]:
  print("Yes")
else:
  print("No")
Problem p02989 (python)

Fixed submission:
n=int(input())
d=sorted(list(map(int,input().split())))
print(d[int(n/2)]-d[int(n/2-1)])

Buggy submission (verdict: Runtime Error):
n=int(input())
d=sorted(list(map(int,input().split())))
print(d[n/2]-d[n/2-1])
Problem p02623 (python)

Fixed submission:


import sys
import math
import itertools
import collections

def solve(N,M,K,A,B):
    accumA = [0,A.pop(0)]
    accumB = [0,B.pop(0)]
    for a in A:
        accumA.append(accumA[-1] + a)
    for b in B:
        accumB.append(accumB[-1] + b)
    ans = 0
    j = M
    for i in range(N + 1):
        if accumA[i] > K:
            break
        while accumB[j] > K - accumA[i]:
            j -= 1
        ans = max(ans,i + j)
    return ans

def main():
    N,M,K = map(int,input().split())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    # solve()
    print(solve(N,M,K,A,B))

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):


import sys
import math
import itertools
import collections

def solve(N,M,K,A,B):
    accumA = [0,A.pop(0)]
    accumB = [0,B.pop(0)]
    for a in A:
        accumA.append(accumA[-1] + a)
    for b in B:
        accumB.append(accumB[-1] + b)
    ans = 0
    j = M
    for i in range(N + 1):
        if a[i] > K:
            break
        while b[j] > K - a[i]:
            j -= 1
        ans = max(ans,i + j)
    return ans

def main():
    N,M,K = map(int,input().split())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    # solve()
    print(solve(N,M,K,A,B))

if __name__ == "__main__":
    main()
Problem p02754 (python)

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

if(N <= (A+B)):
    if(N<=A):
        print(N)
    else:
        print(A)
else:
    ans = (N//(A+B)) * A
    amari=(N % (A+B))
    tmp=A
    if(amari <= tmp):
        ans+=amari
    else:
        ans+=tmp

    print(ans)

Buggy submission (verdict: Runtime Error):
import math
def myAnswer(N:int, A:int, B:int) -> int:
   counter = math.ceil(N / (A + B))
   string = ("b"*A + "r"*B)*counter
   return list(string)[:N ].count("b")

def modelAnswer():
   tmp=1
def main():
   N,A,B = map(int,input().split())
   print(myAnswer(N,A,B))

if __name__ == '__main__':
   main()

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

ans=""
for i in range(10**100):
    ans+="b"*A
    ans+="r"*B
    if(len(ans)>N):
        break

print(ans[:N].count('b'))
Problem p02773 (python)

Fixed submission:

N = int(input())
C = dict()


for i in range(N):
    a = input()
    if(a not in C.keys()):
        C[a] = 1
    else:
        val = C[a]
        C[a] = val + 1

m=0
for i in C.values():
    if(i > m):
        m=i

ans = sorted(C.items())
for i  in ans:
    if(m==i[1]):
        print(i[0])

Buggy submission (verdict: Runtime Error):

N = int(input())
S = [input() for i in range(N)]
C = dict()


for i in range(N):
    a = input()
    if(a not in C.keys()):
        C[a] = 1
    else:
        val = C[a]
        C[a] = val + 1

maxv=0
for i in C.values():
    if(i > maxv):
        maxv=i

ans = sorted(C.items())
for i  in ans:
    if(maxv==i[1]):
        print(i[0])
Problem p02831 (python)

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

def lcm(x,y):
    return (x*y)//fractions.gcd(x,y)

print(lcm(A,B))

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

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

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

Fixed submission:
N=int(input())
ans=0
if(N%2==0):
  ans=N//2
else:
  ans=N//2 + 1

print(ans/N)

Buggy submission (verdict: Runtime Error):
N=int(input())
ans=0
ans=N//2 if(N%2==0) else ans=N//2 + 1

print(ans/N)