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

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

# A内の整数値を用いて作られる最小の整数を求めよ、という問題


def gcd(a, b):
    """
    自然数a, b の最大公約数を求める
    """
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


ans = gcd(A[0], A[1])
for i in range(1, N):
    ans = min(ans, gcd(ans, A[i]))


print(ans)

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

# A内の整数値を用いて作られる最小の整数を求めよ、という問題


def gcd(a, b):
    """
    自然数a, b の最大公約数を求める
    """
    if b == 0:
        return a
    else:
        return gcd(b, a % b)


ans = gcd(A[0], A[1])
for i in range(1, N):
    ans = min(ans, gcd(A[i], A[j]))


print(ans)
Problem p03253 (python)

Fixed submission:
N, M = map(int, input().split())
mod = 10**9 + 7


def factorize(n):
    b = 2
    fct = {}
    while b * b <= n:
        while n % b == 0:
            n //= b
            if b in fct.keys():
                fct[b] += 1
            else:
                fct[b] = 1
        b = b + 1
    if n > 1:
        fct[n] = 1
    return fct


from operator import mul
from functools import reduce


def cmb(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


fac_list = factorize(M)
ans = 1
for k, v in fac_list.items():
    ans *= cmb(v+N-1, v)
    if ans >= mod:
        ans %= mod

print(int(ans))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
mod = 10**9 + 7


def factorize(n):
    b = 2
    fct = {}
    while b * b <= n:
        while n % b == 0:
            n //= b
            if b in fct.keys():
                fct[b] += 1
            else:
                fct[b] = 1
        b = b + 1
    if n > 1:
        fct[n] = 1
    return fct

from scipy.special import comb
fac_list = factorize(M)
ans = 1
for k, v in fac_list.items():
    ans *= comb(v+N-1, v)
    if ans >= mod:
        ans %= mod

print(int(ans))

Buggy submission (verdict: Runtime Error):
import sympy
sympy.factorint(2016)
Problem p03307 (python)

Fixed submission:
N = int(input())

if N % 2 == 0:
    ans = N
else:
    ans = 2 * N


print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
A = [A[i]-(i+1) for i in range(N)]

ans = float("inf")
for b in range(min(A), max(A)+1):
    loss = sum([abs(A[i] - b) for i in range(N)])
    ans = min(ans, loss)


print(ans)
Problem p03326 (python)

Fixed submission:
N, M = map(int, input().split())
cakes = []
for i in range(N):
    x, y, z = map(int, input().split())
    cakes.append([x, y, z])


if M == 0:
    print(0)
    quit()
score = [0]*8
s = sorted(map(lambda c: c[0]+c[1]+c[2], cakes))
score[0] = sum(s[-M:])
score[1] = -sum(s[:M])
s = sorted(map(lambda c: c[0]+c[1]-c[2], cakes))
score[2] = sum(s[-M:])
score[3] = -sum(s[:M])
s = sorted(map(lambda c: c[0]-c[1]+c[2], cakes))
score[4] = sum(s[-M:])
score[5] = -sum(s[:M])
s = sorted(map(lambda c: c[0]-c[1]-c[2], cakes))
score[6] = sum(s[-M:])
score[7] = -sum(s[:M])
print(max(score))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
XYZ = [list(map(int, input().split())) for i in range(N)]

if M == 0:
    print(0)
    quit()
else:
    s1 = sorted(XYZ, key=lambda c: c[0] + c[1] + c[2])
    s1max1 = sum(s1[-M:])
    s1max2 = sum(s1[:M])
    s2 = sorted(XYZ, key=lambda c: c[0] + c[1] - c[2])
    s2max1 = sum(s2[-M:])
    s2max2 = sum(s2[:M])
    s3 = sorted(XYZ, key=lambda c: c[0] - c[1] + c[2])
    s3max1 = sum(s3[-M:])
    s3max2 = sum(s3[:M])
    print(max(s1max1, s1max2, s2max1, s2max2, s3max1, s3max2))
Problem p03327 (python)

Fixed submission:
N = int(input())

if N >= 1000:
    print("ABD")
else:
    print("ABC")

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

def sum_digits(n, m):
    r = 0
    while n:
        r = r + n % m
        m = n // m
    return r

ans = float("inf")
for i in range(N+1):
    ans = min(ans, sum_digits(i, 6) + sum_digits(N-i, 9))
Problem p03329 (python)

Fixed submission:
N = int(input())
A = []

A.append(1)
for i in range(1,7):
    A.append(6**i)
for i in range(1,6):
    A.append(9**i)
    
    
A.sort()
dp = [10*5+5]*(N+1)
dp[0] = 0
for i in range(1, N+1):
    for s in range(len(A)):
        if i-A[s] >= 0:
            dp[i] = min(dp[i-A[s]]+1, dp[i])
            
            
print(dp[N])

Buggy submission (verdict: Runtime Error):


N = int(input())
A = [1]
for i in range(1,7):
    A.append(6 ** i)
for i in range(1, 6):
    A.append(9 ** i)


A = sorted(A)
dp = [float("inf")] * (N+1)
dp[0] = 0

for i in range(1,N+1):
    for k, v in enumerate(A):
        if i >= v:
            dp[i] = min(dp[i], dp[i-A[s]]+1)
            
            
print(dp[N])

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

def sum_digits(n, m):
    r = 0
    while n:
        r = r + n % m
        m = n // m
    return r

ans = float("inf")
for i in range(N+1):
    ans = min(ans, sum_digits(i, 6) + sum_digits(N-i, 9))

print(ans)

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

def sum_digits(n, m):
    r = 0
    while n:
        r = r + n % m
        m = n // m
    return r

ans = float("inf")
for i in range(N+1):
    ans = min(ans, sum_digits(i, 6) + sum_digits(N-i, 9))

print(ans)

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

def sum_digits(n, m):
    r = 0
    while n:
        r = r + n % m
        m = n // m
    return r

ans = float("inf")
for i in range(N+1):
    ans = min(ans, sum_digits(i, 6) + sum_digits(N-i, 9))
Problem p03805 (python)

Fixed submission:
from collections import defaultdict
# dfs, check path len, count paths                                                                                                                           
# test = 2                                                                                                                                                   
n, m = map(int, input().split())
edges = [map(int, input().split()) for i in range(m)]
graph = defaultdict(list)
for k,v in edges:
    graph[k].append(v)
    graph[v].append(k)

cnt = 0
# dfs                                                                                                                                                        
def dfs(node, visited):
    global cnt
    if node in visited:
        return None
    elif len(visited) + 1 == n:
        cnt += 1
        return None
    else:
        for v in graph[node]:
            dfs(v, visited+[node])
dfs(1, [])
print(cnt)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
# dfs, check path len, count paths                                                                                                                           
# test = 2                                                                                                                                                   
n, m = map(int, input().split())
edges = [map(int, input().split()) for i in range(n)]
graph = defaultdict(list)
for k,v in edges:
    graph[k].append(v)
    graph[v].append(k)

cnt = 0
# dfs                                                                                                                                                        
def dfs(node, visited):
    global cnt
    if node in visited:
        return None
    elif len(visited) + 1 == n:
        cnt += 1
        return None
    else:
        for v in graph[node]:
            dfs(v, visited+[node])
dfs(1, [])
print(cnt)
Problem p02863 (python)

Fixed submission:
dp = [[-1 for i in range(6005)] for j in range(6005)]


def f(idx, time):
    if time >= T:
        return 0
    if idx >= N:
        return 0
    if dp[idx][time] != -1:
        return dp[idx][time]
    dp[idx][time] = max(f(idx+1, time), B[idx]+f(idx+1, time+A[idx]))
    return dp[idx][time]

N, T = [int(i) for i in input().split()]
data = []
A, B = [], []

for i in range(N):
    a, b = [int(j) for j in input().split()]
    data.append([a,b])
    A.append(a)
    B.append(b)

data.sort()
A, B = [], []
for i, j in data:
    A.append(i)
    B.append(j)

for idx in range(N, -1, -1):
    for time in range(T, -1, -1):
        if time == T:
            dp[idx][time] = 0
            continue
        if idx == N:
            dp[idx][time] = 0
            continue
        if A[idx]+time >= T:
            fval = 0
        else:
            fval = dp[idx+1][time+A[idx]]
        dp[idx][time] = max(dp[idx+1][time], B[idx] + fval)

print(dp[0][0])

Buggy submission (verdict: Runtime Error):
dp = [[-1 for i in range(6005)] for j in range(6005)]

def f(idx, time):
    if time >= T:
        return 0
    if idx >= N:
        return 0
    if dp[idx][time] != -1:
        return dp[idx][time]
    dp[idx][time] = max(f(idx+1, time), B[idx]+f(idx+1, time+A[idx]))
    return dp[idx][time]

N, T = [int(i) for i in input().split()]
data = []
A, B = [], []

for i in range(N):
    a, b = [int(j) for j in input().split()]
    data.append([a,b])
    A.append(a)
    B.append(b)

data.sort()
A, B = [], []
for i, j in data:
    A.append(i)
    B.append(j)

print(f(0, 0))

Buggy submission (verdict: Runtime Error):
dp = [[-1 for i in range(6005)] for j in range(6005)]

def f(idx, time):
    if time >= T:
        return 0
    if idx >= N:
        return 0
    if dp[idx][time] != -1:
        return dp[idx][time]
    dp[idx][time] = max(f(idx+1, time), B[idx]+f(idx+1, time+A[idx]))
    return dp[idx][time]

N, T = [int(i) for i in input().split()]
A, B = [], []

for i in range(N):
    a, b = [int(j) for j in input().split()]
    A.append(a)
    B.append(b)

print(f(0, 0))

Buggy submission (verdict: Runtime Error):
dp = [[-1 for i in range(3005)] for j in range(3005)]

def f(idx, time):
    if time >= T:
        return 0
    if idx >= N:
        return 0
    if dp[idx][time] != -1:
        return dp[idx][time]
    dp[idx][time] = max(f(idx+1, time), B[idx]+f(idx+1, time+A[idx]))
    return dp[idx][time]

N, T = [int(i) for i in input().split()]
A, B = [], []

for i in range(N):
    a, b = [int(j) for j in input().split()]
    A.append(a)
    B.append(b)

print(f(0, 0))
Problem p02757 (python)

Fixed submission:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,p]=i2()
s=input()

  
if p==2 or p==5:
   x1=0
   for i in range(n):
     if int(s[i])%p==0:
        x1+=i+1  
   print(x1)
else:
  t=0
  x2=0
  d={0:1}
  a=1
  for i in range(n)[::-1]:
     t+=int(s[i])*a
     t%=p
     a*=10
     a%=p
     if t in d:
        x2+=d[t]
        d[t]+=1
     else:
        d[t]=1
  print(x2)

Buggy submission (verdict: Runtime Error):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
[n,p]=i2()
s=input()

  
if p==2 or p==5:
   x1=0
   for i in range(n):
     if int(s[i])%p==0:
        x1+=i+1  
   print(x1)
else:
  t=0
  x2=0
  d=[0]
  for i in range(n)[::-1]:
     t+=int(s[i])*a
     t%=p
     a*=10
     d.append(t)
  from collections import Counter
  c= Counter(d)
  x=0
  for i in c.values():
    if i>1:
      x+=i*(i-1)//2
  print(x)
Problem p02763 (python)

Fixed submission:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
import sys
sys.setrecursionlimit(10**6)

n=i1()
s=input()
q=i1()
N=0
while n:
  n>>=1
  N+=1
n=2**N

t=[0 for i in range(2*n-1)]

def ud(i,x):
  i+=n-1
  t[i]=x
  while i:
    i=(i-1)//2
    t[i]=t[i*2+1] | t[i*2+2]

def qr(a,b,k,l,r):
  
  if r<=a or b<=l:
     return 0
  elif a<=l and r<=b:
     
     return t[k]
  else:
     return qr(a,b,k*2+1,l,(l+r)//2) | qr(a,b,k*2+2,(l+r)//2,r)

for i in range(len(s)):
  ud(i,1<<(ord(s[i])-ord("a")))

while q:
 [ty,i,c]=[i for i in input().split()]
 ty=int(ty)
 i=int(i)
 if ty==1:
   ud(i-1,1<<(ord(c)-ord("a")))
 else:
   c=int(c)
   x=0
   z=qr(i-1,c,0,0,n)
   while z:
     if z%2==1:
        x+=1
     z>>=1
   print(x)
 q-=1

Buggy submission (verdict: Runtime Error):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
import math
import sys
sys.setrecursionlimit(10**6)

n=i1()
s=input()
q=i1()

n=2**(int(math.log2(n))+1)

t=[set([]) for i in range(2*n-1)]

def ud(i,x):
  i+=n-1
  t[i]=x
  while i:
    i=(i-1)//2
    t[i]=t[i*2+1] | t[i*2+2]

def qr(a,b,k,l,r):
  if r<=a or b<=l:
     if b==l:
         return t[k]
     return set([])
  elif a<=l and r<=b:
     return t[k]
  else:
     return qr(a,b,k*2+1,l,(l+r)//2) | qr(a,b,k*2+2,(l+r)//2,r)

for i in range(len(s)):
  ud(i,set([s[i]]))

while q:
 [ty,i,c]=[i for i in input().split()]
 ty=int(ty)
 i=int(i)
 if ty==1:
   ud(i-1,set([c]))
 else:
   c=int(c)
   if i==c:
     print(1)
   else:
     print(len(qr(i-1,c-1,0,0,n)))
   
 q-=1
Problem p03346 (python)

Fixed submission:
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
p=[]
q=[0 for i in range(n)]
for i in range(n):   
 p.append(i1())
 q[p[-1]-1]=i
k=1
s=0
for i in range(n-1):
  if q[i+1]-q[i]>0:
     k+=1
  else:
     s=max(s,k)
     k=1
s=max(s,k)
print(n-s)

Buggy submission (verdict: Runtime Error):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
n=i1()
p=[]
q=[0 for i in range(n)]
for i in range(n):   
 p.append(i1())
 q[p[-1]-1]=i
k=1
s=0
while n-1>j:
  if q[i+1]-q[i]>0:
     k+=1
  else:
     s=max(s,k)
     k=1
  j+=1
s=max(s,k)
print(n-s)
Problem p03986 (python)

Fixed submission:
s = input()

a=[]
for i in range(len(s)):
 if s[i]=="S":
     a.append("S")
 if s[i]=="T":
     if len(a)==0 or a[-1]=="T":
         a.append("T")
     if a[-1]=="S":
         a.pop()
print (len(a))

Buggy submission (verdict: Runtime Error):
n = int(input())
a=[int(i) for i in input().split()]
s=[]
sa=n*(n+1)/2

s.append(a)
for i in range(1,n):
  s.append([])
  for j in range(len(s[i-1])-1):
    if s[i-1][j]<s[i-1][j+1]:
        s[i].append(s[i-1][j])
        sa+=s[i-1][j]
    else:
        s[i].append(s[i-1][j+1])
        sa+=s[i-1][j+1]
print(int(sa))
Problem p02935 (python)

Fixed submission:
#from functools import reduce
N = int(input())
Xs_ = sorted(map(int,input().split()))
print(sum([Xs_[i]*(2**(-N+1)) if i == 0 else Xs_[i]* (2**(-N+i)) for i in range(N)]))

Buggy submission (verdict: Runtime Error):
#from functools import reduce
N = int(input())
Xs = list(map(int,input().split()))
Xs_ = sorted(Xs)
print(sum([Xs_[i]* (2**(-n+i-1)) if i != 0 else Xs_[i]*(2**(-n)) for i in range(N)]))
Problem p02948 (python)

Fixed submission:
import heapq
N,M = map(int,input().split())
dic = {}
for i in range(N):
  A,B = map(int,input().split())
  if A <= M:
    if A in dic.keys():
      dic[A].append(B)
    else:
      dic[A] = [B]
      
ans = 0
plan = []
for i in range(1,M+1):
  if i in dic.keys():
    for w in dic[i]:
        heapq.heappush(plan,-w)
  if len(plan) != 0:
    ans += heapq.heappop(plan)

print(-ans)

Buggy submission (verdict: Runtime Error):
import heapq
N,M = map(int,input().split())
dic = {}
for i in range(N):
  A,B = map(int,input().split())
  if A <= M:
    if dic[A]:
      dic[A].append(B)
    else:
      dic[A] = [B]
      
ans = 0
plan = heapq()
for i in range(1,M+1):
  for w in dic[i]:
    heapq.heappush(plan,-w)
  if len(plan) != 0:
    ans += heappop(plan)

print(-ans)
Problem p02833 (python)

Fixed submission:
N=input()
lenN=len(N)
N=int(N)




if N%2==1 or N<10:
    print(0)
else:
    count=0
    loop=0
    while(1):
        if N<(10*5**loop):
            break
        else:
            count+=N//(10*5**loop)
            loop+=1
    print(count)

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


if N%2==1 or N<10:
    print(0)
else:
    count=0
    loop=0
    while(1):
        if N<(10*5**loop) or N%(10*5**loop)!=0:
            break
        else:
            count+=N//(10*5**loop)
            loop+=1
print(count)

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

else:
    count=0
    loop=0
    while(1):
        if N<(10*5**loop) or N%(10*5**loop)!=0:
            break
        else:
            count+=N//(10*5**loop)
            loop+=1
            print(count)
Problem p02912 (python)

Fixed submission:
import heapq

N,M=input().split()
N,M=int(N),int(M)
A=input().split()
A=[-int(n) for n in A]

heapq.heapify(A)

for i in range(M):
    a=((-1*heapq.heappop(A))//2)*(-1)
    heapq.heappush(A,a)
sum=0
for i in range(N):
    sum+=A[i]
print(-sum)

Buggy submission (verdict: Runtime Error):
import heapq

N,M=input().split()
N,M=int(N),int(M)
A=input().split()
A=[-int(n) for n in A]

heapq.heapify(A)

for i in range(M):
    a=((-1*heapq.heappop(A))//2)*(-1)
    print(A)
    heapq.heappush(A,a)
    print(A)
sum=0
for i in range(N):
    sum+=A[i]
print(-sum)
Problem p02948 (python)

Fixed submission:
import heapq
N,M=(int(i) for i in input().split())



tasks=[[] for i in range(10**5+1)]
for i in range(N):
    a,b=(int(i) for i in input().split())
    tasks[a-1].append(b)

pq=[]
ans=0
for i in range(M):
    for b in tasks[i]:
        heapq.heappush(pq,-b)
    if len(pq)!=0:
        temp=heapq.heappop(pq)
        ans-=temp

print(ans)

Buggy submission (verdict: Runtime Error):
import heapq
N,M=(int(i) for i in input().split())



tasks=[[] for i in range(10**5+1)]
for i in range(N):
    a,b=(int(i) for i in input().split())
    tasks[a-1].append(b)

pq=[]
ans=0
for i in range(M):
    for b in tasks[i]:
        heappush(pq,b)
    if len(pq)!=0:
        ans+=heappop(pq)

print(ans)
Problem p02753 (python)

Fixed submission:
a = input()
if a == "AAA":
  print("No")
else:
  if a == "BBB":
    print("No")
  else:
    print("Yes")

Buggy submission (verdict: Runtime Error):
a = input()
if a == "AAA":
  print("No")
if b == "BBB":
  print("No")
else:
  print("Yes")
Problem p03137 (python)

Fixed submission:
import numpy as np
import heapq

n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

if n >= m:
    print(0)
else:
    npx = np.array(x)
    li = list(np.diff(npx, n = 1))

    print(sum(heapq.nsmallest(len(li)-n+1, li)))

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

if n >= m:
    print(0)

li = []
for i in range(len(x)-1):
    li.append(x[i+1] - x[i])

for i in range(n-1):
    m = max(li)
    li.remove(m)

print(sum(li))
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

def gcd_list(a):
  for i in range(n - 1):
    a[i + 1] = gcd(a[i], a[i + 1])
  return a[n - 1]
  
print(gcd_list(a))

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

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

def gcd(numbers):
    return functools.reduce(math.gcd, numbers)
  
print(gcd(a))

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

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

def gcd(numbers):
    return reduce(math.gcd, numbers)
  
print(gcd(a))
Problem p02759 (python)

Fixed submission:
n = int(input())

if n % 2 == 0:
  print(n // 2)
else:
  print(n // 2 + 1)

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

if n % 2 == 0:
  print(n // 2)
else:
  print(n // 2 + 1)
Problem p02879 (python)

Fixed submission:
n,m=map(str,input().split())
if(len(n)<=1 and len(m)<=1):
	print(int(n)*int(m))
else:
	print(-1)

Buggy submission (verdict: Runtime Error):
n,m=map(s,input().split())
if(len(n)<=1 and len(m)<=1):
	print(int(n)*int(m))
else:
	print(-1)
Problem p03634 (python)

Fixed submission:
n = int(input())
edge = [list(map(int, input().split())) for i in range(n-1)]
q, k = map(int, input().split())
query = [list(map(int, input().split())) for i in range(q)]

d = [0 for i in range(n+1)]
visited = [False for i in range(n+1)]
adj = [[] for i in range(n+1)]

for e in edge:
    adj[e[0]].append([e[1], e[2]])
    adj[e[1]].append([e[0], e[2]])
    
st = [k]
visited[k] = True
while st:
    u = st.pop()
    for p in adj[u]:
        v, w = map(int, p)
        if not visited[v]:
            visited[v] = True
            d[v] = d[u]+w
            st.append(v)

for p in query:
    print(d[p[0]]+d[p[1]])

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

d = [0 for i in range(n+1)]
adj = [[] for i in range(n+1)]

def dfs(u, par):
    for p in adj[u]:
        v, w = map(int, p)
        # print(v, w)
        if v != par:
            d[v] = d[u]+w
            dfs(v, u)

edge = [list(map(int, input().split())) for i in range(n-1)]
q, k = map(int, input().split())
query = [list(map(int, input().split())) for i in range(q)]

for e in edge:
    adj[e[0]].append([e[1], e[2]])
    adj[e[1]].append([e[0], e[2]])
    
dfs(k, -1)

for p in query:
    print(d[p[0]]+d[p[1]])
Problem p02754 (python)

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

answer =0

if A==0:
    answer = 0
elif B==0:
    answer = N
else:
    tail=0
    if N%(A+B) > A:
        tail = A
    else:
        tail = N%(A+B)
    answer = A * (N//(A+B)) + tail

print(answer)

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

answer =0

if A==0:
    answer = 0
elif b==0:
    answer = N
else:
    tail=0
    if N%(A+B) > B:
        tail = B
    else:
        tail = N%(A+B)
    answer = A * (N//(A+B)) + tail

print(answer)

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

answer =0

if A==0:
    answer = 0
if b==0:
    answer = N
else:
    tail=0
    if N%(A+B) > B:
        tail = B
    else:
        tail = N%(A+B)
    answer = A * (N//(A+B)) + tail

print(answer)
Problem p02777 (python)

Fixed submission:
S,T=input().split()
A,B=map(int,input().split())
U = input()
if U == S:
    print('{} {}'.format(A-1, B))
else:
    print('{} {}'.format(A, B-1))

Buggy submission (verdict: Runtime Error):
S,T=input().split()
A,B=map(int,input().split())
U = input()
if U == S:
    print (f"{A-1} {B}")
else:
    print(f"{A} {B-1}")

Buggy submission (verdict: Runtime Error):
s, t = input().split()
a,b = map(int,input().split())
u = input()
if u == s:
     print (f"{a-1} {b}")
else:
    print(f"{a} {b-1}")

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

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

Fixed submission:
week = {'SUN':7,'MON':6,'TUE':5,'WED':4,'THU':3,'FRI':2,'SAT':1}
s = input()
print(week[s])

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

s = int(x/a)
X = x - b*len(str(s))
if X < 0:
  print(0)
  exit()

for i in range(s,-1,-1):
  if a*i+b*len(str(i)) <= x:
    if i >= 10**9:
      print(10**9)
      exit()
    print(i)
    exit()
print(0)

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

s = int(x/a)

for i in range(s,-1,-1):
  if a*i+b*len(str(i)) <= x:
    if i >= 10**9:
      print(10**9)
      exit()
    print(i)
    exit()
print(0)
Problem p02881 (python)

Fixed submission:
import sys
import numpy as np
N = int(input())
for i in range(int(np.sqrt(N)), 0, -1):
  if N / i == int(N / i):
      print(int(N / i + i - 2))
      sys.exit()
print(N - 1)

Buggy submission (verdict: Runtime Error):
import math
N = int(input())
for i in range(int(math.sqrt(N)), 0, -1):
  if N / i == int(N / i):
      print(int(N / i + i - 2))
      sys.exit()
Problem p02771 (python)

Fixed submission:
a,b,c = map(int,input().split())

n=set([a,b,c])

if len(n)==2:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
import itertools

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

t=[]

for a,b in itertools.combinations(s,2):
  t.append(a*b)

t.sort()

print(t[k-1])
Problem p02880 (python)

Fixed submission:
n = int(input())

for a in range(1, 10):
  for b in range(a, 10):
    if n == a * b:
      print('Yes')
      exit()

print('No')

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

for a in range(1, 10):
  for b in range(a, 10):
    if n = a * b:
      print('Yes')
      exit()

print('No')