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

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]

sa = sorted(A)
from bisect import *
hv = sa[-1] / 2
ri = bisect_right(sa, hv)

if ri == 0:
    print(sa[-1], sa[ri])
elif len(sa) == 2:
    print(sa[1], sa[0])
else:
    print(sa[-1], sa[ri - 1] if abs(sa[ri - 1] - hv) < abs(sa[ri] - hv) else sa[ri])

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]

sa = sorted(A)
import math
from bisect import *
hv = sa[-1] / 2
hl, hr = math.floor(hv), math.ceil(hv)
ri = bisect_right(sa, hv)

import operator
import functools
def dist(x):
    if x <= hl:
        return functools.reduce(operator.imul, range(hl, x, -1)) / functools.reduce(operator.imul, range(hr, hr + (hl - x) + 1))
    else:
        return functools.reduce(operator.imul, range(hr, hr + (x - hr) + 1)) / functools.reduce(operator.imul, range(x, hl, -1))

if ri == 0:
    print(sa[-1], sa[ri])
elif len(sa) == 2:
    print(sa[1], sa[0])
else:
    print(sa[-1], sa[ri - 1] if dist(sa[ri - 1]) > dist(sa[ri]) else sa[ri])
Problem p03436 (python)

Fixed submission:
H, W = map(int, input().split())
S = [input() for _ in range(H)]

import heapq
def dijkstra(adj, n, st=1):
    dj = [2**64] * (n)
    dj[st] = 0
    q = []
    heapq.heappush(q, (0, st))
    while q:
        fc, fn = heapq.heappop(q)
        if dj[fn] < fc: continue
        for tn, lc in adj[fn]:
            if dj[fn] + lc < dj[tn]:
                dj[tn] = dj[fn] + lc
                heapq.heappush(q, (dj[tn], tn))
    return dj

def cid(x):
    return x[0] * W + x[1]

def cl(adj, x, y):
    xid = cid(x)
    yid = cid(y)
    adj[xid].append((yid, 1))
    adj[yid].append((xid, 1))

adj = dict([(x, []) for x in range(H*W)])
for i in range(H):
    for j in range(W):
        if S[i][j] == "#": continue
        ni = i + 1
        if ni < H and S[ni][j] == ".":
            cl(adj, (i, j), (ni, j))
        nj = j + 1
        if nj < W and S[i][nj] == ".":
            cl(adj, (i, j), (i, nj))

c = dijkstra(adj, H*W, cid((0,0)))
hwc = c[cid((H-1,W-1))]
print(-1 if hwc == 2**64 else H * W - sum(s.count("#") for s in S) - hwc - 1)

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [input() for _ in range(H)]

import heapq
def dijkstra(adj, n, st=1):
    dj = [2**64] * (n)
    dj[st] = 0
    q = []
    heapq.heappush(q, (0, st))
    while q:
        fc, fn = heapq.heappop(q)
        if dj[fn] < fc: continue
        for tn, lc in adj[fn]:
            if dj[fn] + lc < dj[tn]:
                dj[tn] = dj[fn] + lc
                heapq.heappush(q, (dj[tn], tn))
    return dj

def cid(x):
    return x[0] * W + x[1]

def cl(adj, x, y):
    xid = cid(x)
    yid = cid(y)
    links = adj.setdefault(xid , [])
    links.append((yid, 1))
    links = adj.setdefault(yid, [])
    links.append((xid, 1))

adj = {}
for i in range(H):
    for j in range(W):
        if S[i][j] == "#": continue
        ni = i + 1
        if ni < H and S[ni][j] == ".":
            cl(adj, (i, j), (ni, j))
        nj = j + 1
        if nj < W and S[i][nj] == ".":
            cl(adj, (i, j), (i, nj))

c = dijkstra(adj, H*W, cid((0,0)))
hwc = c[cid((H-1,W-1))]
print(-1 if hwc == 2**64 else H * W - sum(s.count("#") for s in S) - hwc - 1)
Problem p03503 (python)

Fixed submission:
import numpy as np
N = int(input())
F = [[int(x) for x in input().split()] for _ in range(N)]
P = [[int(x) for x in input().split()] for _ in range(N)]

f = np.array(F)
ans = float('-inf')
for n in range(1, 2**10):
    a = np.array([int(x) for x in bin(n)[2:].rjust(10, '0')])
    p = sum([P[i][x] for i,x in enumerate(np.sum(f * a, axis=1))])
    ans = max(ans, p)
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import numpy as np
N = int(input())
F = [[int(x) for x in input().split()] for _ in range(N)]
P = [[int(x) for x in input().split()] for _ in range(N)]

f = np.array(F)
ans = -math.inf
for n in range(1, 2**10):
    a = np.array([int(x) for x in bin(n)[2:].rjust(10, '0')])
    p = sum([P[i][x] for i,x in enumerate(np.sum(f * a, axis=1))])
    ans = max(ans, p)
print(ans)
Problem p03557 (python)

Fixed submission:
import bisect, functools, sys
sys.setrecursionlimit(10**6)
N = int(input())
A = sorted(int(x) for x in input().split())
B = sorted(int(x) for x in input().split())
C = sorted(int(x) for x in input().split())

@functools.lru_cache(maxsize=None)
def a(n):
    return bisect.bisect_left(A, n)

b_cache = [0] * (N + 1)
b_cached = [False] * (N + 1)
def b_i(i):
    global b_cache, b_cached
    if i >= 1:
        if not b_cached[i - 1]: b_i(i - 1)
        t = b_cache[i - 1] + a(B[i - 1])
        b_cache[i] = t
        b_cached[i] = True
        return t
    return 0

@functools.lru_cache(maxsize=None)
def b(n):
    return b_i(min(N, bisect.bisect_left(B, n)))

def c():
    return sum(b(x) for x in C)

print(c())

Buggy submission (verdict: Runtime Error):
import bisect, functools, sys
sys.setrecursionlimit(10**6)
N = int(input())
A = sorted(int(x) for x in input().split())
B = sorted(int(x) for x in input().split())
C = sorted(int(x) for x in input().split())

@functools.lru_cache(maxsize=None)
def a(n):
    return bisect.bisect_left(A, n)

b_cache = [0] * N
b_cached = [False] * N
def b_i(i):
    if i >= 1:
        if not b_cached[i - 1]: b_i(i - 1)
        t = b_cahce[i - 1] + a(B[i - 1])
        b_cache[i] = t
        b_cached[i] = True
        return t
    return 0

@functools.lru_cache(maxsize=None)
def b(n):
    return b_i(min(len(B), bisect.bisect_left(B, n)))

def c():
    return sum(b(x) for x in C)

print(c())

Buggy submission (verdict: Runtime Error):
import bisect, functools
N = int(input())
A = sorted(int(x) for x in input().split())
B = sorted(int(x) for x in input().split())
C = sorted(int(x) for x in input().split())

@functools.lru_cache(maxsize=None)
def a(n):
    return bisect.bisect_left(A, n)

@functools.lru_cache(maxsize=None)
def b_i(i):
    if i >= 1:
        return b_i(i - 1) + a(B[i - 1])
    return 0

@functools.lru_cache(maxsize=None)
def b(n):
    return b_i(min(len(B), bisect.bisect_left(B, n)))

def c():
    return sum(b(x) for x in C)

print(c())
Problem p03558 (python)

Fixed submission:
K = int(input())

import heapq
def dijkstra(adj, n, start):
    dj = [10**6] * (n + 1)
    dj[start] = 0
    q = []
    heapq.heappush(q, (0, start))
    while q:
        fc, fn = heapq.heappop(q)
        if dj[fn] < fc: continue
        for tn, lc in adj[fn]:
            if dj[tn] > dj[fn] + lc:
                dj[tn] = dj[fn] + lc
                heapq.heappush(q, (dj[tn], tn))
    return dj

adj = {}
for i in range(K):
    t = adj.setdefault(i, [])
    t.append(((i + 1) % K, 1))
    t.append(((i * 10) % K, 0))

costs = dijkstra(adj, K - 1, 1)
print(costs[0] + 1)

Buggy submission (verdict: Runtime Error):
import bisect, functools
N = int(input())
A = sorted(int(x) for x in input().split())
B = sorted(int(x) for x in input().split())
C = sorted(int(x) for x in input().split())

@functools.lru_cache(maxsize=None)
def a(n):
    return bisect.bisect_left(A, n)

@functools.lru_cache(maxsize=None)
def b_i(i):
    if i >= 1:
        return b_i(i - 1) + a(B[i - 1])
    return 0

@functools.lru_cache(maxsize=None)
def b(n):
    return b_i(min(len(B), bisect.bisect_left(B, n)))

def c():
    return sum(b(x) for x in C)

print(c())
Problem p03599 (python)

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

import functools
import sys
sys.setrecursionlimit(10**5)

@functools.lru_cache(maxsize=None)
def calc_strength(sugar, water):
    if water == 0: return -1
    return sugar * 100 / (sugar + water)

@functools.lru_cache(maxsize=None)
def f(strength, sugar, water):
    cand = [(strength, sugar + water, sugar)]
    for x in ((C, 0), (D, 0), (0, 100*A), (0, 100*B)):
        s, w = sugar + x[0], water + x[1]
        if s + w <= F and s * 100 <= w * E:
            cand.append(f(calc_strength(s, w), s, w))
    return max(cand)
    
print(*f(-1, 0, 0)[1:])

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

import functools

@functools.lru_cache(maxsize=None)
def calc_strength(sugar, water):
    if water == 0: return -1
    return sugar * 100 / (sugar + water)

@functools.lru_cache(maxsize=None)
def f(strength, sugar, water):
    cand = []
    for x in ((C, 0), (D, 0), (0, 100*A), (0, 100*B)):
        s, w = sugar + x[0], water + x[1]
        if s + w <= F and s * 100 <= w * E:
            cand.append(f(calc_strength(s, w), s, w))
    if cand: return sorted(cand, reverse=True)[0]
    return (strength, sugar + water, sugar)
    
print(f(-1, 0, 0)[1:])
Problem p03659 (python)

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]

total = sum(A)

ans = float('inf')
nusuke = 0
for a in A[:-1]:
  nusuke += a
  ans = min(ans, abs(nusuke - (total - nusuke)))

print(ans)

Buggy submission (verdict: Runtime Error):
import math

N = int(input())
A = [int(x) for x in input().split()]

total = sum(A)

ans = math.inf
nusuke = 0
for a in A[:-1]:
    nusuke += a
    ans = min(ans, abs(nusuke - (total - nusuke)))

print(ans)
Problem p03674 (python)

Fixed submission:
n = int(input())
A = [int(x) for x in input().split()]

p = 10**9 + 7

found = {}
for i, a in enumerate(A):
    if a in found:
        dup = a
        dup_1 = found[a]
        dup_2 = i
    found[a] = i

from functools import lru_cache

@lru_cache(maxsize=None)
def gfp_inv(x, p):
    return pow(x, p - 2, p)

from itertools import chain, accumulate
memo_fact = list(chain([1], accumulate(range(1, 10**5 + 2), lambda a, x: a * x % p)))

def comb(n, m):
    if m < 0 or n < m: return 0
    if n == m: return 1
    return memo_fact[n] * gfp_inv(memo_fact[n - m], p) * gfp_inv(memo_fact[m], p) % p

intv = dup_2 - dup_1 - 1
for k in range(1, n + 2):
    ans = comb(n + 1, k)
    ans -= comb(n + 1 - intv - 2, k - 1)
    print(ans % p)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = [int(x) for x in input().split()]

p = 10**9 + 7

found = {}
for i, a in enumerate(A):
    if a in found:
        dup = a
        dup_1 = found[a]
        dup_2 = i
    found[a] = i

from functools import lru_cache

@lru_cache(maxsize=None)
def gfp_inv(x, p):
    return pow(x, p - 2, p)

from itertools import chain, accumulate
memo_fact = list(chain([1], accumulate(range(1, 10**5 + 1), lambda a, x: a * x % p)))

def comb(n, m):
    if m < 0 or n < m: return 0
    if n == m: return 1
    return memo_fact[n] * gfp_inv(memo_fact[n - m], p) * gfp_inv(memo_fact[m], p) % p

intv = dup_2 - dup_1 - 1
for k in range(1, n + 2):
    ans = comb(n + 1, k)
    ans -= comb(n + 1 - intv - 2, k - 1)
    print(ans % p)

Buggy submission (verdict: Runtime Error):
init_input()

n = int(input())
A = [int(x) for x in input().split()]

found = {}
for i, a in enumerate(A):
    if a in found:
        dup = a
        dup_1 = found[a]
        dup_2 = i
    found[a] = i

from functools import lru_cache

@lru_cache(maxsize=None)
def gfp_inv(x, p):
    return pow(x, p - 2, p)

@lru_cache(maxsize=None)
def fact(n, m, p):
    ret = 1
    for i in range(m, n + 1):
        ret = (ret * i) % p
    return ret

def comb(n, m):
    if m < 0 or n < m: return 0
    if n == m: return 1
    return fact(n, n - m + 1, p) * gfp_inv(fact(m, 1, p), p) % p

p = 10**9 + 7

intv = dup_2 - dup_1 - 1
for k in range(1, n + 2):
    ans = comb(n + 1, k)
    ans -= comb(n + 1 - intv - 2, k - 1)
    print(ans % p)
Problem p03680 (python)

Fixed submission:
n = int(input())
a = [int(input()) for _ in range(n)]

c = 1
for i in range(n):
  c = a[c - 1]
  if c == 2:
    print(i + 1)
    exit(0)

print(-1)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [int(input()) for _ in range(n)]

c = 1
for i in range(n):
  if c == 2:
    print(i + 1)
    exit(0)
  c = a[c]
print(-1)
Problem p03700 (python)

Fixed submission:
N, A, B = map(int, input().split())
H = sorted(int(input()) for _ in range(N))

import bisect, math
def f(ll, ul):
    if ul == ll: return ll
    cur = (ll + ul) // 2
    r = H[bisect.bisect_right(H, B * cur):]
    p = sum(math.ceil((x - B * cur) / (A - B)) for x in r)

    if p == cur:
        return cur
    elif p < cur:
        return f(ll, cur)
    else:
        return f(cur + 1, ul)

print(f(0, math.ceil((H[-1]) / B)))

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

def bf(links, n, st=1):
    inf = float('inf')
    dj = [inf] * (n + 1)
    dj[st] = 0
    for i in range(N):
        updated = False
        for link in links:
            fn, tn, lc = link
            lc *= -1
            if dj[fn] + lc < dj[tn]:
                dj[tn] = dj[fn] + lc
                updated = True
        if not updated: break
    else:
        pn = dj[-1]
        for i in range(N):
            updated = False
            for link in links:
                fn, tn, lc = link
                lc *= -1
                if dj[fn] + lc < dj[tn]:
                    dj[tn] = dj[fn] + lc
                    updated = True
            if not updated: break
        return inf if pn != dj[-1] else -dj[-1]
    return -dj[-1]

links = []
for _ in range(M):
    links.append([int(x) for x in input().split()])

print(bf(links, N, 1))

Buggy submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
H = sorted(int(input()) for _ in range(N))

import bisect, math
def f(ll, ul):
    if ul - ll == 1: return ll
    cur = (ll + ul) // 2
    r = H[bisect.bisect_right(H, B * cur):]
    p = sum(math.ceil((x - B * cur) / (A - B)) for x in r)

    if p == cur:
        return cur
    elif p < cur:
        return f(ll, cur)
    else:
        return f(cur + 1, ul)

print(f(0, math.ceil((H[-1]) / B) + 1))
Problem p03828 (python)

Fixed submission:
from functools import reduce
from copy import deepcopy

n = int(input())

def dadd(t, s): 
    for k,v in s.items():
        t[k] = t.get(k, 0) + v 
    return t

def pfd(c, i): 
    for j in range(2, i // 2 + 1): 
        if i % j == 0:
            d = i // j
            return dadd(deepcopy(c[j]), c.get(d, dict()))
    return { i: 1 } 

p,c = {},{}
for i in range(2, n + 1): 
    q = pfd(c, i)
    c[i] = q 
    dadd(p, q)

tot = reduce(lambda a,v: a * (v + 1), p.values(), 1)
print(tot % (10 ** 9 + 7))

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

n = int(input())

def dadd(t, s): 
    for k,v in s.items():
        t[k] = t.get(k, 0) + v 
    return t

def pfd(c, i): 
    for j in range(2, i // 2 + 1): 
        if i % j == 0:
            d = i // j
            return dadd(deepcopy(c[j]), c.get(d, dict()))
    return { i: 1 } 

p,c = {},{}
for i in range(2, n + 1): 
    q = pfd(c, i)
    c[i] = q 
    dadd(p, q)

tot = reduce(lambda a,(k,v): a * (v + 1), p.items(), 1)
print(tot % (10 ** 9 + 7))
Problem p03860 (python)

Fixed submission:
import re
s = input()
print("A%sC" % re.match('AtCoder (.).* Contest', s).group(1))

Buggy submission (verdict: Runtime Error):
import re
s = input()
print("A%sC" % re.match('AtCoder (.).* Contest', s)[1])
Problem p03861 (python)

Fixed submission:
a,b,x = map(int, input().split())
print(b // x - (a - 1) // x)

Buggy submission (verdict: Runtime Error):
import re
s = input()
print("A%sC" % re.match('AtCoder (.).* Contest', s)[1])
Problem p03037 (python)

Fixed submission:
n,m=map(int,input().split())
maxl=1
minr=n
while m:
  l,r=map(int,input().split())
  maxl=max(maxl,l)
  minr=min(minr,r)
  m-=1
print(max(0,minr-maxl+1))

Buggy submission (verdict: Runtime Error):
    n,m=map(int,input().split())
    maxl=1
    minr=n
    while m:
      l,r=map(int,input().split())
      maxl=max(maxl,l)
      minr=min(minr,r)
      m-=1
    print(max(0,minr-maxl+1))

Buggy submission (verdict: Runtime Error):
n,m=map(int,input().split())
maxl=1
minr=N
while m:
  l,r=map(int,input().split())
  maxl=max(maxl,l)
  minr=min(minr,r)
  m-=1
print(max(0,maxl-minr+1))
Problem p02981 (python)

Fixed submission:
n, a, b = (int(i) for i in input().split())
if n*a > b:
  print(b)
else:
  print(n*a)

Buggy submission (verdict: Runtime Error):
a = [int(i) for i in input().split()]
if a[0]*a[1] > a[2]:
  return c
else:
  return a[0]*a[1]

Buggy submission (verdict: Runtime Error):
a, b, c = (int(i) for i in input().split())
if a*b >= c:
  return c
else:
  return a*b
Problem p02981 (python)

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

Buggy submission (verdict: Runtime Error):
L, R = map(int, input().split())

result = 2019

for i in range(2019):
    if L+i > R-1:
        break;
    for j in range(i+1, 2019):
        if(L+j > R):
            break
        else:
            result = min(result,((L+i)*(L+j))%2019)

print(result)
Problem p02981 (python)

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

if n * a < b:
  print(n * a)
else:
  print(b)

Buggy submission (verdict: Runtime Error):
n, r = map(int, input().split())
if r-n >= 2019:
  print(0)
  sys.exit(0)
mini = 2019
#nM = n % 2019
#rM = r % 2019
for i in range(n, r+1):
  for j in range(i+1, r+1):
    mini = min((i*j)%2019, mini)
print(mini)
Problem p02983 (python)

Fixed submission:
import sys
n, r = map(int, input().split())
if r-n >= 2019:
  print(0)
  sys.exit(0)
mini = 2019
#nM = n % 2019
#rM = r % 2019
for i in range(n, r+1):
  for j in range(i+1, r+1):
    mini = min((i*j)%2019, mini)
print(mini)

Buggy submission (verdict: Runtime Error):
n, r = map(int, input().split())
if r-n >= 2019:
  print(0)
  sys.exit(0)
mini = 2019
#nM = n % 2019
#rM = r % 2019
for i in range(n, r+1):
  for j in range(i+1, r+1):
    mini = min((i*j)%2019, mini)
print(mini)

Buggy submission (verdict: Runtime Error):
n, r = map(int, input().split())
if r - n >= 2019:
  print(0)
  sys.exit(0)
min = 2019
#nM = n % 2019
#rM = r % 2019
for i in range(n, r+1):
  for j in range(i+1, r+1):
    min = min((i*j)%2019, min)
print(min)
Problem p02981 (python)

Fixed submission:
x,y,z = map(int, input().split())
D = x * y
T=z
if  D < T :
      print(D)
else : print(T)

Buggy submission (verdict: Runtime Error):
x,y,z = map(int, input().split())
D = x * y
T=z
 if  D < T :
     print(D)
 else : print(T)

Buggy submission (verdict: Runtime Error):
x,y,z = map(int, input().split())
D = x * y
T=z
 if  D < T :
      print(D)
 else : print(T)

Buggy submission (verdict: Runtime Error):
x,y,z = map(int, input().split())
D=x*y
T=z
 if D<T:
  print(D)
 else:  print(T)

Buggy submission (verdict: Runtime Error):
x,y,z = map(int, input().split())
D=x*y
T=z
 if( D<T,print(D))
 else(D>T,print(T)

Buggy submission (verdict: Runtime Error):
input(taxi)
input(train)
print(train+taxi)
Problem p02981 (python)

Fixed submission:
N,A,B=map(int,input().split())
if A*N<B :
  print(A*N)
else:
  print(B)

Buggy submission (verdict: Runtime Error):
N,A,B=map(int,iput(),split())
if A*N<B :
  print(A*N)
else:
    print(B)

Buggy submission (verdict: Runtime Error):
A,B,N=map(int,iput(),split())
if A*N<B :
  print(A*N)
else:
    print(B)

Buggy submission (verdict: Runtime Error):
A,B,N=map(int,iput(),split())
if A*N<B :
  print("A*N")
else:
  print("B")

Buggy submission (verdict: Runtime Error):
A,B=map(int,iput(),split())
if A*N<B :
  print(A*N)
else:
    print(B)

Buggy submission (verdict: Runtime Error):
A,B=map(int,iput(),split())
if A*N<B :
  print("A*N")
else:
    print("B")

Buggy submission (verdict: Runtime Error):
A,B=map(int,iput(),split())
if A*N<B :
  print"A*N"
  else:
    print"B"
Problem p02981 (python)

Fixed submission:
a = [int(i) for i in input().split()]
x = a[0] * a[1]
y = a[2]

if (x<y):
  print(x)
else:
  print(y)

Buggy submission (verdict: Runtime Error):
import numpy as np
 
N = int(input())
X = [int(i) for i in input().split()]
a = np.eye(N)
b = np.roll(a, 1, axis=1)
A = a + b
 
Y = np.linalg.solve(A, X)
 
Y = list(map(lambda x: str(int(x*2)), Y))
print(' '.join(Y))
Problem p02982 (python)

Fixed submission:
import math as ma

def dist(a, b, D):
  r = 0
  for i in range(D):
    r = r + (a[i]-b[i])**2

  return ma.sqrt(r)

N, D = (int(i) for i in input().split())
X = [[int(i) for i in input().split()] for i in range(N)]

ret = 0
for i in range(N):
  for j in range(i+1, N):
    d = dist(X[i], X[j], D)
    if (d == int(d)):
      ret = ret + 1

print(ret)

Buggy submission (verdict: Runtime Error):
import numpy


N, D = (int(i) for i in input().split())
X = [[int(i) for i in input().split()] for i in range(N)]
print([D, N])
print(X)

a = numpy.array(X[0])
b = numpy.array(X[1])
u = b - z
print(numpy.linalg.norm(u))
Problem p02981 (python)

Fixed submission:
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())

if a*b >= c:
    print(c)
else:
    print(a*b)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# 整数Nの入力
N = int(input())

# 整数Aの入力
A = int(input())

# 整数Bの入力
B = int(input())

if N*A >= B:
    print(B)
else:
    print(N*A)
Problem p03035 (python)

Fixed submission:
import sys

old, yen = input().split()

if int(old) >= 13 :
    print(yen)
elif int(old) >= 6 :
    print(int(int(yen)/2))
else :
    print(0)

Buggy submission (verdict: Runtime Error):
import sys

n,m = input().split()
n,m = int(n), int(m)


list = []

count = 0
lMin, rMax = -1, -1

for i in range(0,m) :
    l, r = input().split()

    list.append((int(l),int(r)))

    if lMin == -1 and rMax == -1:
        lMin, rMax = list[i]
    else:
        if lMin < list[i][0] :
            lMin = list[i][0]
            
        if rMax > list[i][1] :
            rMax = list[i][1]

print(rMax - lMin +1)
Problem p03037 (python)

Fixed submission:
import sys

n,m = input().split()
n,m = int(n), int(m)


list = []

count = 0
lMin, rMax = -1, -1

for i in range(0,m) :
    l, r = input().split()

    list.append((int(l),int(r)))

    if lMin == -1 and rMax == -1:
        lMin, rMax = list[i]
    else:
        if lMin < list[i][0] :
            lMin = list[i][0]
            
        if rMax > list[i][1] :
            rMax = list[i][1]

count = rMax - lMin +1

if count < 0 : 
    count = 0

print(count)

Buggy submission (verdict: Runtime Error):
import sys

n,m = input().split()
n,m = int(n), int(m)

l, r = [],[]

count = 0

for i in range(1,m) :
    l[i], r[i] = input().split()
    l[i], r[i]  = int(l[i]), int( r[i] )

    if l[i] <= m and m <= r[i] :
        count = count + m - l[i]
Problem p03485 (python)

Fixed submission:
a,b = map(int, input().split())
print((a+b+1)//2)

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

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

Fixed submission:
def main():
    string = input()
    for i in range(len(string) - 1):
        if string[i] == string[i + 1]:
            return "Bad"
    return "Good"

print(main())

Buggy submission (verdict: Runtime Error):
string = input().split()
for i in range(len(string) - 1):
  if string[i] == string[i+1]
  	return print('Bad')
  
return print('Good')
Problem p02995 (python)

Fixed submission:
import fractions

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

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

def count_multiple(n):
    return (B // n) - ((A - 1) // n)

def count_not_multiple(n):
    return (B - A + 1) - count_multiple(n)

cnm = count_not_multiple
print(cnm(C) + cnm(D) - cnm(lcm(C, D)))

Buggy submission (verdict: Runtime Error):
def main():
    N = int(input())
    tasks = [tuple(map(int, input().split())) for _ in range(N)]
    tasks.sort(key=lambda x: x[1])
    time = 0
    for A, B in tasks:
        time += A
        if B < time:
            return 'No'
    return 'Yes'

print(main())

Buggy submission (verdict: Runtime Error):
import math

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

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

def count_multiple(n):
    return (B // n) - ((A - 1) // n)

def count_not_multiple(n):
    return (B - A + 1) - count_multiple(n)

cnm = count_not_multiple
print(cnm(C) + cnm(D) - cnm(lcm(C, D)))