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

Fixed submission:
from operator import itemgetter
import sys
input = sys.stdin.readline

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = []
for _ in range(m):
    tb, tc = map(int, input().split())
    b.append([tb, tc])
a.sort()
b.sort(key=itemgetter(1), reverse=True)

c = 0
flag = False
for j in range(m):
    if (flag):
        break
    for i in range(b[j][0]):
        if (c >= len(a) or a[c] >= b[j][1]):
            flag = True
            break
        a[c] = b[j][1]
        c += 1

print(sum(a))

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

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = []
for _ in range(m):
    tb, tc = map(int, input().split())
    b.append([tb, tc])
a.sort()
b.sort(key=itemgetter(1), reverse=True)

c = 0
flag = False
for j in range(m):
    if (flag):
        break
    for i in range(b[j][0]):
        if (c > len(a) or a[c] >= b[j][1]):
            flag = True
            break
        a[c] = b[j][1]
        c += 1

print(sum(a))

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

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = []
for _ in range(m):
    tb, tc = map(int, input().split())
    b.append([tb, tc])
a.sort()
b.sort(key=itemgetter(1), reverse=True)

c = 0
flag = True
for j in range(m):
    if (not flag):
        break
    for i in range(b[j][0]):
        if (a[c] >= b[j][1]):
            flag = False
            break
        a[c] = b[j][1]
        c += 1

print(sum(a))

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

n, m = map(int, input().split())
a = list(map(int, input().split()))
b = []
for _ in range(m):
    tb, tc = map(int, input().split())
    b.append([tb, tc])
a.sort()
b.sort(key=itemgetter(1), reverse=True)

c = 0
flag = True
for j in range(m):
    for i in range(b[j][0]):
        if (a[c] < b[j][1]):
            a[c] = b[j][1]
            c += 1
            continue
        flag = False
    if (flag):
        continue
    break
print(sum(a))
Problem p03127 (python)

Fixed submission:
# ABC118c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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


def solve(l):
    m = min(l)
    nl = list()
    for i in l:
        if i % m != 0:
            nl.append(i % m)
    nl.append(m)
    # print(nl)
    if len(nl) == 1:
        return m
    return solve(nl)


print(solve(a))

Buggy submission (verdict: Runtime Error):
# ABC118c
from fractions import gcd
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

n = int(input())
a = list(map(int, input().split()))
#from functools import reduce


def gcds(*numbers):
    return reduce(gcd, numbers)


print(gcds(a))
exit(0)


def solve(l):
    m = min(l)
    nl = list()
    for i in l:
        if i % m != 0:
            nl.append(i % m)
    nl.append(m)
    # print(nl)
    if len(nl) == 1:
        return m
    return solve(nl)


print(solve(a))
Problem p02688 (python)

Fixed submission:
import numpy as np

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

cnt = np.array(list([0]*n))

for _ in range(k):
    d = int(input())
    a = np.array(list(map(int, input().split())))
    for i in a:
        cnt[i-1] += 1

print(np.count_nonzero(cnt==0))

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

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

cnt = np.array(list([0]*n))

for i in range(k):
    d = int(input())
    a = np.array([list(map(int, input().split()))])
    if d != n:
        a = np.append(a,[0]*(n-d))
    cnt += a

print(np.count_nonzero(cnt==0))

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

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

cnt = np.array(list([0]*n))

for i in range(k):
    d = int(input())
    a = np.array([list(map(int, input().split()))])
    a = np.append(a,[0]*(n-d))
    cnt += a

print(np.count_nonzero(cnt==0))
Problem p02836 (python)

Fixed submission:
s=input()
l=len(s)
n=l//2
count=0
for num in range(n):
  if(s[num]==s[l-num-1]):
    pass
  else:
    count+=1
print(count)

Buggy submission (verdict: Runtime Error):
s=input()
l=len(s)
n=l//2
count=0
for num in range(n):
  if(s[num]==s[l-num-]):
    pass
  else:
    count+=1
print(count)
Problem p02689 (python)

Fixed submission:
NM=list(map(int,input().split()))
H=list(map(int,input().split()))
A=[0 for i in range(NM[0])]
for i in range(NM[1]):
    ab=list(map(int,input().split()))
    A[ab[0]-1]=max(A[ab[0]-1],H[ab[1]-1])
    A[ab[1]-1]=max(A[ab[1]-1],H[ab[0]-1])
d=0
for i in range(NM[0]):
    if(H[i]>A[i]):
        d+=1
print(d)

Buggy submission (verdict: Runtime Error):
NM=list(map(int,input().split()))
person=[0 for i in range(NM[0])]
for i in range(NM[1]):
    d=input() 
    snack=list(map(int,input().split()))
    for i in snack:
        person[i-1]=1
d=0
for i in range(len(person)):
    if person[i]==0:
        d+=1
print(d)
Problem p02777 (python)

Fixed submission:
# -*- coding: utf-8 -*-

#入力
S, T = map(str, input().split())
A, B = map(int, input().split())
U = str(input())

#処理
if S == U:
    A -= 1
else:
    B -= 1

#出力
print('{} {}'.format(A, B))

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

#入力
n = int(input())

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

result = 'YES'

#処理
for i in range(n):
    for j in range(n):
        if j == i:
            continue
        else:
            if A[i] == A[j]:
                result = 'NO'
                
                goto .end


label.end
#出力
print(result)
Problem p03804 (python)

Fixed submission:
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

ah = len(a)
aw = len(a[0])
bh = len(b)
bw = len(b[0])

for i in range(ah - bh + 1):
    for j in range(aw - bw + 1):
        tmp = []
        for k in range(bh):
            tmp.append(a[i + k][j : j + bw])
        if b == tmp:
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

h = len(b)
w = len(b[0])

for i in range(h):
    for j in range(w):
        tmp = []
        for k in range(h):
            tmp.append(a[i + k][j : j + w])
        if b == tmp:
            print("Yes")
            break
    else:
        continue
    break
else:
    print("No")
Problem p02622 (python)

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

Buggy submission (verdict: Runtime Error):
t=input()
i=0
ans=0
for i in range(len(s)):
    if s[i]!=t[i]:
        ans+=1
print(ans)
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];ans=0;j=m
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])
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()))
a=[0];b=[0];ans=0;j=m
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])
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()))
ans=0
i=0
j=0
while k>=0:
    if i==n and j<m:
        k=k-b[j]
        j+=1
        ans+=1
    elif j==m and i<n:
        k=k-b[i]
        i+=1
        ans+=1
    elif i<n and j<m:
        if a[i]<b[j]:
            k=k-a[i]
            i+=1
            ans+=1
        else:
            k=k-b[j]
            j+=1
            ans+=1
    else:break
if k<0:
    print(ans-1)
else:
    print(ans)
Problem p02862 (python)

Fixed submission:
import math
X,Y = map(int,input().split())
a,b = (2*Y-X)/3,(2*X-Y)/3
n = 10**9+7
def cmb(n, r, mod=10**9+7):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * pow(denom, mod-2, mod) % mod
def count():
  if not (a//1 == a and b//1==b):
    return 0
  else:
    ahat = int(a%n)
    bhat = int(b%n)
    return cmb(ahat+bhat,ahat)


print(int(count())%(10**9+7))

Buggy submission (verdict: Runtime Error):
import math
X,Y = map(int,input().split())
a,b = (2*Y-X)/3,(2*X-Y)/3
n = 10**9+7
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**4
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 )
def count():
  if not (a//1 == a and b//1==b):
    return 0
  else:
    ahat = int(a%n)
    bhat = int(b%n)
    return cmb(ahat+bhat,ahat)


print(int(count())%(10**9+7))
Problem p02912 (python)

Fixed submission:
import heapq
N,M = map(int,input().split())
A = list(map(lambda x:int(x)*(-1),input().split()))
heapq.heapify(A)
for _ in range(M):
  heapq.heappush(A,((heapq.heappop(A)*-1)//2)*-1)

print(sum(A)*-1)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
A.sort(reverse=True)
for _ in range(M):
  A[0] //=2
  i = 1
  while i < N:
    if A[0] > A[i]:
      A[0:i] = [*A[1:i],A[0]]
      break
    if i == N-1:
      A[0:i] = [*A[1:i],A[0]]
    i +=1


print(sum(A))
Problem p02819 (python)

Fixed submission:
li = []

def is_prime(n):
  for m in li:
    if m * m > n: 
      return True
    if n % m == 0:
      return False
  return True

n = int(input())
for i in range(2, n):
  if is_prime(i):
    li.append(i)

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

Buggy submission (verdict: Runtime Error):
li = []

def is_prime(n):
        return False
    for m in li:
        if m * m > n: 
            return True
        if n % m == 0:
            return False
    return True

n = int(input())
for i in range(2, n):
  if is_prime(i):
    li.append(i)

while True:
  if is_prime(n):
    print(n)
    break
  n += 1
Problem p02829 (python)

Fixed submission:
a = int(input())
b = int(input())
nums = [1,2,3]
nums.remove(a)
nums.remove(b)
print(*nums)

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
nums = "123"
nums.remove(a)
nums.remove(b)
print(nums)
Problem p02836 (python)

Fixed submission:
a = input()
b = 0
for i, j in zip(a, a[::-1]):
	if i != j:
		b += 1

print(b//2 + b%2)

Buggy submission (verdict: Runtime Error):
a = input()
b = 0
for c, (i, j) in enumerate(zip(a, a[::-1])):
	if i != j:
    	b += 1

print(b//2 + b%2)
Problem p02859 (python)

Fixed submission:
r = int(input())
print(r**2)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
t = s[:(n//2)] * 2
if s == t:
    print("Yes")
else:
    print("No")
Problem p02990 (python)

Fixed submission:
from sys import stdin
from math import factorial

def permutations_count(n, r):
  return factorial(n) // factorial(r) // factorial(n - r)

N,K = map(int,stdin.readline().split())
mod = pow(10,9)+7

frame = N-K+1
for i in range(1,K+1):
  if K == N:
    if i == 1:
      print("1")
    else:
      print("0")
  else:
    if i > frame:
      print("0")
    else:
      select=permutations_count(frame, i) % mod
      pattern=permutations_count(K-1, i-1) % mod
      print((select * pattern) % mod )

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

def permutations_count(n, r):
  return factorial(n) // factorial(r) // factorial(n - r)

N,K = map(int,stdin.readline().split())
mod = pow(10,9)+7

frame = N-K+1
for i in range(1,K+1):
  if K == N:
    if i == 1:
      print("1")
    else:
      print("0")
  else:
    select=permutations_count(frame, i) % mod
    pattern=permutations_count(K-1, i-1) % mod
    print((select * pattern) % mod )

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

def permutations_count(n, r):
  return factorial(n) // factorial(r) // factorial(n - r)

N,K = map(int,stdin.readline().split())
mod = pow(10,9)+7

if N == K:
  print("1")
  exit()

frame = N-K+1
for i in range(1,K+1):
  select=permutations_count(frame, i) % mod
  pattern=permutations_count(K-1, i-1) % mod
  print((select * pattern) % mod )

Buggy submission (verdict: Runtime Error):
from sys import stdin
from math import factorial
from operator import mul
from functools import reduce

def permutations_count(n, r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N,K = map(int,stdin.readline().split())
mod = pow(10,9)+7

frame = N-K+1
for i in range(1,K+1):
  select=permutations_count(frame, i) % mod
  pattern=permutations_count(K-1, i-1) % mod
  print((select * pattern) % mod )

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

def permutations_count(n, r):
  return factorial(n) // factorial(r) // factorial(n - r)

N,K = map(int,stdin.readline().split())
mod = pow(10,9)+7

frame = N-K+1
for i in range(1,K+1):
  select=permutations_count(frame, i) % mod
  pattern=permutations_count(K-1, i-1) % mod
  print((select * pattern) % mod )
Problem p03013 (python)

Fixed submission:
from sys import stdin

def main():
  N, M = map(int, stdin.readline().rstrip().split())
  beforeA=-1
  Mlist=[]

  for i in range(M):
    a = int(stdin.readline().rstrip())
    if (a-beforeA)==1:
      print("0")
      exit()
    Mlist.append(a)
    beforeA = a
      
  if N == 1 or (N == 2 and M==1):
    print("1")
    exit()
  if N == 2:
    print("2")
    exit()

  Mindex=0
  broken=-2
  if len(Mlist) >0:
    broken = Mlist[Mindex]
  an2=0
  an1=1
  patern=1
  brokenNext=False
  for i in range(1,N+1):
    if broken == i:
      Mindex+=1
      if len(Mlist) > Mindex:
        broken = Mlist[Mindex]
      brokenNext=True
      continue
    if brokenNext:
      brokenNext=False
      an2=0
      continue
    patern=(an1+an2)%1000000007
    an2=an1
    an1=patern
    #print("{}: {}".format(i,patern))
  print(patern%1000000007 )

main()

Buggy submission (verdict: Runtime Error):
from sys import stdin
def main():
  N, M = map(int, stdin.readline().rstrip().split())
  paterList=[]
  Abefore=0

  a1=1
  a2=2
  for i in range(M):
    A = int(input())
    stepNum=A-Abefore
    
    if stepNum == 1:
      print("0")
      return
    elif stepNum <= 3:
      paterList.append(stepNum-1)
    else:
      an2=a1
      an1=a2
      for j in range(stepNum -1-2):
        patern += an2+an1
        an2 = an1
        an1 = patter
      paterList.append(patern//1000000007 )
  print(sum(paterList)//1000000007)
      
input = lambda: stdin.readline()
main()
Problem p03201 (python)

Fixed submission:
# -*- coding: utf-8 -*-
import collections

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
c=collections.Counter(A)

pairCounter=0

beki=29
nibeki=2**beki

for i in range(N):
  target = A[i]
  if c[target] < 1:
    continue
  c[target]-= 1

  while (nibeki > target):
    beki-=1
    nibeki=2**beki

  pair = nibeki * 2 - target
  if pair in c.keys() and c[pair] > 0:
    c[pair]-= 1
    pairCounter+=1

print(pairCounter)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import copy

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

pairCounter=0
for i in range(N):
  if A[i] < 0:
    continue
  for b in range(9):
    beki=2**b
    if beki > A[i]:
      pair=beki - A[i]
      if A.count(pair) >0:
        A[i] = -1
        A[A.index(pair)] = -1
        pairCounter+=1
      break
print(pairCounter)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
import copy

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

pairCounter=0
for i in range(N):
  if A[i] < 0:
    continue
  for b in range(9):
    pair=2**b - A[i]
    if pair < 1:
      continue
    if A.count(pair) >0:
      A[i] = -1
      A[A.index(pair)] = -1
      pairCounter+=1
      break

B=copy.copy(org)      
B.sort(reverse=True)
print(B)

pairCounterB=0
for i in range(N):
  if B[i] < 0:
    continue
  for b in range(9):
    pair=2**b - B[i]
    if pair < 1:
      continue
    if B.count(pair) >0:
      B[i] = -1
      B[B.index(pair)] = -1
      pairCounterB+=1
      break
      
if pairCounterB < pairCounter:
  print(pairCounter)
else:
  print(pairCounterB)

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

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

pairCounter=0
for i in range(N):
  if A[i] < 0:
    continue
  for b in range(9):
    pair=2**b - A[i]
    if pair < 1:
      continue
    #print(pair)
    if A.count(pair) >0:
      A[i] = -1
      A[A.index(pair)] = -1
      pairCounter+=1
      break

print(pairCounter)

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

N = int(input())
A = list(map(int, input().split()))
#A.sort(reverse=True)

pairCounter=0
for i in range(N):
  if A[i] < 0:
    continue
  for b in range(9):
    pair=2**b - A[i]
    if A.count(pair) >0:
      A[i] = -1
      A[A.index(pair)] = -1
      pairCounter+=1
      break

print(pairCounter)

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

N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)

"""
pairCounter=0
for i in range(N):
  for j in range(N -i -1):
    if A[j+i +1] < 1:
      continue
    if A[i] < 1:
      break
    wa = A[i] + A[j+i +1]
    for b in range(9):
      if 2**b & wa == wa:
        A[i]=-1
        A[j+i +1]=-1
        pairCounter+=1
        break
"""

pairCounter=0
for i in range(N):
  if A[i] < 0:
    continue
  for b in range(9):
    pair=2**b - A[i]
    if A.count(pair) >0:
      A[i] = -1
      A[A.index(pair)] = -1
      pairCounter+=1
      break

print(pairCounter)
Problem p02933 (python)

Fixed submission:
import sys
a = []
for l in sys.stdin:
    a.append(l)

if int(a[0]) >= 3200:
    print(a[1])
else:
    print('red')

Buggy submission (verdict: Runtime Error):
import sys
a = []
for l in sys.stdin:
    a.append(int(l))

if a[0] >= 3200:
    print(a[1])
else:
    print('red')
Problem p02777 (python)

Fixed submission:
s, t = input().split()
a, b = map(int, input().split())
u = input()

if s == u:
    print(a-1, b)
else:
    print(a, b-1)

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

if s == u:
    print(f'{a-1} {b}')
else:
    print(f'{a} {b-1}')
Problem p02627 (python)

Fixed submission:
a=input(str())
if(a.isupper()):
    print("A")
else:
    print("a")

Buggy submission (verdict: Runtime Error):
N=int(input())
i=0
x=""
while(N > 26**i):
    i +=1
i -= 1
while(i!=-1):
    if(N//26**i==26):
        x += "z"
        N=N-(26**i)*26
    elif(N//26**i==1):
        x += "a"
        N=N-(26**i)
    elif(N//26**i==2):
        x += "b"
        N=N-(26**i)*2
    elif(N//26**i==3):
        x += "c"
        N=N-(26**i)*3
    elif(N//26**i==4):
        x += "d"
        N=N-(26**i)*4    
    elif(N//26**i==5):
        x += "e"
        N=N-(26**i)*5
    elif(N//26**i==6):
        x += "f"
        N=N-(26**i)*6
    elif(N//26**i==7):
        x += "g"
        N=N-(26**i)*7
    elif(N//26**i==8):
        x += "h"
        N=N-(26**i)*8
    elif(N//26**i==9):
        x += "i"
        N=N-(26**i)*9
    elif(N//26**i==10):
        x += "j"
        N=N-(26**i)*10
    elif(N//26**i==11):
        x += "k"
        N=N-(26**i)*11
    elif(N//26**i==12):
        x += "l"
        N=N-(26**i)*12
    elif(N//26**i==13):
        x += "m"
        N=N-(26**i)*13
    elif(N//26**i==14):
        x += "n"
        N=N-(26**i)*14    
    elif(N//26**i==15):
        x += "o"
        N=N-(26**i)*15
    elif(N//26**i==16):
        x += "p"
        N=N-(26**i)*16
    elif(N//26**i==17):
        x += "q"
        N=N-(26**i)*17
    elif(N//26**i==18):
        x += "r"
        N=N-(26**i)*18
    elif(N//26**i==19):
        x += "s"
        N=N-(26**i)*19
    elif(N//26**i==20):
        x += "t"
        N=N-(26**i)*20
    elif(N//26**i==21):
        x += "u"
        N=N-(26**i)*21
    elif(N//26**i==22):
        x += "v"
        N=N-(26**i)*22
    elif(N//26**i==23):
        x += "w"
        N=N-(26**i)*23
    elif(N//26**i==24):
        x += "x"
        N=N-(26**i)*24    
    elif(N//26**i==25):
        x += "y"
        N=N-(26**i)*25
    i -= 1
print(x)
Problem p02881 (python)

Fixed submission:
import numpy as np

n = int(input())

patterns = []

for i in range(1, int(np.sqrt(n)) + 1):
	if n % i == 0:
		patterns.append(i + n // i - 2)

print(min(patterns))

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

n = int(input())

patterns = []

for i in range(1, int(np.sqrt(n))):
	if n % i == 0:
		patterns.append(i + n // i - 2)

print(min(patterns))
Problem p02682 (python)

Fixed submission:
#!/usr/bin/env python3
a, b, c, k = map(int, input().split())
if a + b <= k:
    print(a - (k - (a + b)))
    exit()
elif a <= k:
    print(a)
else:
    print(k)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
a, b, c, k = map(int, input().split())
A = [1] * a
B = [0] * b
C = [-1] * c
A.extend(B)
A.extend(C)
print(sum(A[:k]))
Problem p02754 (python)

Fixed submission:
#!/usr/bin/env python3
n, a, b = map(int, input().split())
x = n // (a + b)
r = n % (a + b)
print(a * x + r) if r < a else print((a * (x + 1)))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
n, a, b = map(int, input().split())
s = "b" * a
r = "r" * b
ans = ""
for i in range(n):
    ans += s
    ans += r
    if len(ans) >= n:
        break
print(ans[:n].count("b"))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
n, a, b = map(int, input().split())
ans = ""
s = "b" * a
t = "r" * b
while(True):
    if len(ans) <= n:
        ans += s
        if len(ans) <= n:
            ans += t
        else:
            print(ans[:n].count("b"))
            break
    else:
        print(ans.count("b"))
        break
Problem p02831 (python)

Fixed submission:
#!/usr/bin/env python3
import fractions
a, b = map(int, input().split())
f = fractions.gcd(a, b)
ans = a * b // f
print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import math
a, b = map(int, input().split())
print(int(a * b / math.gcd(a, b)))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import math
a, b = map(int, input().split())
print(int(a * b / math.gcd(a, b)))
Problem p02881 (python)

Fixed submission:
import math
N = int(input())
i = 1
min = 9000000000000
for _ in range(1, int(math.sqrt(N)+1)):
  if N % i == 0:
    j = N/i
    sum = j + i
    if sum < min:
      min = sum
      ans = i-1+j-1
    else:
      break
  i += 1
print(int(ans))

Buggy submission (verdict: Runtime Error):
N = int(input())
i = 1
min = 1000000000000
for _ in range(N):
  if N % i == 0:
    j = N/i
    sum = j + i
    if sum < min:
      min = sum
      ans = i-1+j-1
    else:
      break
  i += 1
print(ans)
Problem p03705 (python)

Fixed submission:
s = input().split(" ");
n = int(s[0]);
a = int(s[1]);
b = int(s[2]);
if a > b :
  print(0);
else :
  if n == 1 :
    if a==b :
      print(1);
    else :
      print(0);
  else :
    ans = (b - a)*(n - 2)+1;
    print(ans);

Buggy submission (verdict: Runtime Error):
s = input().split(" ");
n = s[0];
a = s[1];
b = s[2];
if a > b :
  print(0);
else
  if n = 1 or n = 2:
    print(1);
  else
    ans = (b - a)*(n - 2)+1;
    print(ans);