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

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

import sys
from itertools import product
readline = sys.stdin.readline

def check1(A):
    K = max(A)
    table = [-1]*(K+1)
    for i in range(Q):
        table[A[i]] = i
    
    if -1 in table:
        return False
    if any(t1-t2 < 0 for t1, t2 in zip(table, table[1:])):
        return False
    return True

INF = 10**9+7
def check2(A):
    stack = []
    used = set()
    for a in A[::-1] + list(range(M)):
        if a not in used:
            used.add(a)
            stack.append(a)
    
    C = dict()
    for i in range(M):
        C[stack[i]] = i
    
    table = [0]*M + [INF]
    for a in A[::-1]:
        if table[C[a]] < table[C[a]-1]:
            table[C[a]] += 1
    
    used = set()
    ch = []
    for i in range(M):
        if table[i] < N:
            break
        ch.append(stack[i])
        used.add(stack[i])
    for i in range(M):
        if i not in used:
            used.add(i)
            ch.append(i)
    
    return stack == ch

N, M = map(int, readline().split())
Q = int(readline())
A = list(map(lambda x: int(x)-1, readline().split()))

ans = 'Yes'
if not check1(A):
    if not check2(A):
        ans = 'No'
print(ans)

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

def check1(A):
    K = max(A)
    table = [-1]*(K+1)
    for i in range(Q):
        table[A[i]] = i
    
    if -1 in table:
        return False
    if any(t1-t2 < 0 for t1, t2 in zip(table, table[1:])):
        return False
    return True

INF = 10**9+7
def check2(A):
    stack = []
    used = set()
    for a in A[::-1] + list(range(M)):
        if a not in used:
            used.add(a)
            stack.append(a)
    
    C = dict()
    for i in range(M):
        C[stack[i]] = i
    
    table = [0]*N + [INF]
    for a in A[::-1]:
        if table[C[a]] < table[C[a]-1]:
            table[C[a]] += 1
    
    zero = stack.index(0)
    if all(t2 > t1 for t1, t2 in zip(stack[zero:], stack[zero+1:])):
        for a in stack[zero:]:
            table[C[a]] = N
    

    return  all(t >= N or t == 0 for t in table)

N, M = map(int, readline().split())
Q = int(readline())
A = list(map(lambda x: int(x)-1, readline().split()))

ans = 'Yes'
if not check1(A):
    A = [0]*N + A
    if not check2(A):
        ans = 'No'
print(ans)
Problem p04015 (python)

Fixed submission:
from collections import defaultdict
H = defaultdict(lambda: 0)
H[0] = 1
def inpl(): return [int(i) for i in input().split()]
N, A = inpl()
x = inpl()
x = [i-A for i in x]
H[0]= 1
for i in x:
    for ni,nv in H.copy().items():
        H[ni+i] += nv
print(H[0]-1)

Buggy submission (verdict: Runtime Error):
def inpl(): return [int(i) for i in input().split()]
def hmd(a, b):
    ctr = -1
    while H[ctr+1][a] < b:
        ctr += 1
    vn = H[ctr][a]
    if (vn == b and ctr == 0) or ctr == -1:
        return 1
    return 2**ctr + hmd(vn,b)
N = int(input())
x = inpl() + [10**10]
L = int(input())
H = []
G = [N-1]*N
b = 0
for a in range(N):
    while x[b+1] - x[a] <= L:
        if b == N-1:
            break
        b += 1
    G[a] = b
H.append(G)
while G[0] != N-1:
    G = [G[i] for i in G]
    H.append(G)
H.append([10**10]*N)
Q = int(input())
for _ in range(Q):
    a, b = sorted(inpl())
    print(hmd(a-1,b-1))
Problem p04027 (python)

Fixed submission:
from itertools import accumulate
N, C = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
mod = 10**9 + 7
X = [list(accumulate([pow(x, d, mod) for x in range(401)])) for d in range(C+1)]
dp = [[0]*(C+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1, N+1):
    for d in range(C+1):
        dp[i][d] = sum([dp[i-1][d-k]*(X[k][B[i-1]] - X[k][A[i-1]-1]) for k in range(d+1)])%mod
        
print(dp[-1][-1])

Buggy submission (verdict: Runtime Error):
for _ in range(test_case):
import sys
from itertools import accumulate
readline = sys.stdin.readline
MOD = 10**9+7

N, C = map(int, readline().split())
A = [0] + list(map(int, readline().split()))
B = [0] + list(map(int, readline().split()))

acsq = [list(accumulate([pow(i, j, MOD) for i in range(max(B)+1)])) for j in range(C+1)]
dp = [[0]*(C+1) for _ in range(N+1)]
dp[0][0] = 1
for i in range(1, N+1):
    a, b = A[i], B[i]
    for c in range(C+1):
        res = 0
        for j in range(c+1):
            res = (res + (acsq[c-j][b] - acsq[c-j][a-1])*dp[i-1][j]) % MOD
        dp[i][c] = res
print(dp[N][C])
Problem p04048 (python)

Fixed submission:
N, X = [int(i) for i in input().split()]
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
scale = gcd(N, X)
print(scale*(N//scale-1)*3)

Buggy submission (verdict: Runtime Error):
N, X = [int(i) for i in input().split()]
import math

gcd = math.gcd(N, X)
print(gcd*(N//gcd-1)*3)
Problem p02632 (python)

Fixed submission:
K = int(input())
S = input()
N = len(S)
mod = int(1e9+7)

### 123
### a1bb2ccc3dddd 10文字インサート
# pow(25,6) * pow(26,4) * 8C2
# (3はfixで、それより前の8mojiから1/2を入れる場所を決める）
# これを3の位置でループする（1-indexで 3<=i<=N)

# 123dddddddddd
# pow(25,0) * pow(26,10) * 2C2(1)
# 12x3ddddddddd
# pow(25,1) * pow(26,9) * 3C2( = 2C2 * 3 / 1)
# 12xx3dddddddd
# pow(25,2) * pow(26,8) * 4C2( = 3C2 * 4 / 2)
# ...
# 12xxxxxxxxxx3
# pow(25,10) * pow(26,0) * 12C2( = 11C2 * 12 / 10)

# 5C5, 6C5, 7C5 1, 6, 21, 56

wk = pow(26,K,mod)
inv26 = pow(26,-1,mod)

ans = wk
for i in range(1,K+1):
  wk = (wk * 25 * inv26) % mod
  wk = (wk * (N-1+i) * pow(i,-1,mod) % mod)
  ans = (ans + wk)%mod
    
print(ans)

Buggy submission (verdict: Runtime Error):
K = int(input())
S = input()
N = len(S)
mod = int(1e9+7)

### 123
### a1bb2ccc3dddd 10文字インサート
# pow(25,6) * pow(26,4) * 8C2
# (3はfixで、それより前の8mojiから1/2を入れる場所を決める）
# これを3の位置でループする（1-indexで 3<=i<=N)

# 123dddddddddd
# pow(25,0) * pow(26,10) * 2C2(1)
# 12x3ddddddddd
# pow(25,1) * pow(26,9) * 3C2( = 2C2 * 3 / 1)
# 12xx3dddddddd
# pow(25,2) * pow(26,8) * 4C2( = 3C2 * 4 / 2)
# ...
# 12xxxxxxxxxx3
# pow(25,10) * pow(26,0) * 12C2( = 11C2 * 12 / 10)

# 5C5, 6C5, 7C5 1, 6, 21, 56

wk = pow(26,K,mod)
inv26 = pow(26,-1,mod)

ans = wk
for i in range(1,K+1):
  wk = (wk * 25 * inv26) % mod
  wk = (wk * (N-1+i) * pow(i,-1,mod) % mod)
  ans = (ans + wk)%mod
    
print(ans)
Problem p02683 (python)

Fixed submission:
import numpy as np
from itertools import product
N,M,X = list(map(int, input().split()))
C = [0] * N
A = []

for i in range(N):
  wk = list(map(int, input().split()))
  C[i] = wk[0]
  A.append(wk[1:])

C = np.array(C)
A = np.array(A)

ans = -1
for pt in product([0,1], repeat = N):
  p = np.array(pt)  
  #print(C.dot(p))
  #print(p.dot(A))
  rikai = p.dot(A)
  if min(rikai) >= X:
    ans = C.dot(p) if ans == -1 else min(ans, C.dot(p))
  
print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
from itertools import product
N,M,X = list(map(int, input().split()))
C = [0] * N
A = []

for i in range(N):
  wk = list(map(int, input().split()))
  C[i] = wk[0]
  A.append(wk[1:])

C = np.array(C)
A = np.array(A)

ans = -1
for pt in product([0,1], repeat = N):
  p = np.array(pt)  
  #print(C.dot(p))
  #print(p.dot(A))
  rikai = p.dot(A)
  if min(rikai) >= X:
    ans = C.dot(p) if ans == -1 else min(ans, C.dot(p))
  
print(ans)
Problem p02837 (python)

Fixed submission:
N = int(input())

L = [0] * N

for i in range(N):
  A = int(input())
  if A == 0:
    L[i] = []
  else:
    L[i] = [list(map(int, input().split()))]
  for j in range(1,A):
    L[i].append(list(map(int, input().split())))
    
#print(L)

ans = 0
for i in range(2**N):
  pat = str(format(i, '0' + str(N) + 'b'))
  flg = True
  #S = [-1] * (N)
  for j in range(N):
    if pat[j] == "1": # trueman
      for rule in L[j]:
        if pat[rule[0]-1] == "0" and rule[1] == 1:
          flg = False
          break
        if pat[rule[0]-1] == "1" and rule[1] == 0:
          flg = False
          break
  #print("XXX", flg, pat, j)
  if flg:
    work = 0
    for ch in pat:
      if ch == "1":
        work += 1
    #print("XXX", flg, pat, j, work)
    ans = max(ans, work)
    
print(ans)

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

L = [0] * N

for i in range(N):
  A = int(input())
  #print(i)
  L[i] = [list(map(int, input().split()))]
  for j in range(1,A):
    L[i].append(list(map(int, input().split())))
    
#print(L)

ans = 0
for i in range(2**N):
  pat = str(format(i, '0' + str(N) + 'b'))
  flg = True
  #S = [-1] * (N)
  for j in range(N):
    if pat[j] == "1": # trueman
      for rule in L[j]:
        if pat[rule[0]-1] == "0" and rule[1] == 1:
          flg = False
          break
        if pat[rule[0]-1] == "1" and rule[1] == 0:
          flg = False
          break
  #print("XXX", flg, pat, j)
  if flg:
    work = 0
    for ch in pat:
      if ch == "1":
        work += 1
    #print("XXX", flg, pat, j, work)
    ans = max(ans, work)
    
print(ans)
Problem p02882 (python)

Fixed submission:
import math
a,b,x = list(map(int, input().split()))

x = x / a

if a*b == x:
  print(0)
elif x > a*b / 2:
  print(90 - math.degrees(math.atan(a*a/2/(a*b - x))))
else:
  print(90 - math.degrees(math.atan(2*x/b/b)))

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

x = x / a

if x > a*b / 2:
  print(90 - math.degrees(math.atan(a*a/2/(a*b - x))))
else:
  print(90 - math.degrees(math.atan(2*x/b/b)))
Problem p02921 (python)

Fixed submission:
S = input()
T = input()

ans = 0
for i in range(len(S)):
  if S[i] == T[i]:
    ans += 1
    
print(ans)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()

ans = 0
for i in len(S):
  if S[i] == T[i]:
    ans += 1
    
print(ans)
Problem p03006 (python)

Fixed submission:
from collections import Counter
N = int(input())
X = []
for _ in range(N):
  X.append(list(map(int, input().split())))
  
if N == 1:
  print(1)
  exit(0)
A = []
for i in range(N):
  for j in range(N):
    if i==j:
      continue
    A.append((X[i][0]-X[j][0], X[i][1]-X[j][1]))
    
C = Counter(A)
print(N - C.most_common()[0][1])

Buggy submission (verdict: Runtime Error):
from collections import Counter
N = int(input())
X = []
for _ in range(N):
  X.append(list(map(int, input().split())))
  
A = []
for i in range(N):
  for j in range(i+1,N):
    A.append((abs(X[i][0]-X[j][0]), abs(X[i][1]-X[j][1])))
    
C = Counter(A)
print(N - C.most_common()[0][1])
Problem p03044 (python)

Fixed submission:
import sys
N = int(input())
V = {}
if N == 1:
  print(0)
  exit(0)

# change limit for deep tree (recursion)
sys.setrecursionlimit(N)

# Vertice
for i in range(N-1):
  u,v,w = list(map(int, input().split()))
  u,v = u-1, v-1 #1-index -> 0-index
  if u not in V:
    V[u] = [[v,w]]
  else:
    V[u].append([v,w])
  if v not in V:
    V[v] = [[u,w]]
  else:
    V[v].append([u,w])
     
#print(V)
ANS = [-1] * N
visited = [False] * N

def dfs(pos):
  visited[pos] = True
  for x,w in V[pos]:
    if visited[x]:
      continue
    if w % 2 == 0:
      ANS[x] = ANS[pos]
    else:
      ANS[x] = 1 - ANS[pos]
    #print(pos,x,ANS)
    dfs(x)
  return

ANS[0] = 0
dfs(0)

for a in ANS:
  print(a)

Buggy submission (verdict: Runtime Error):
N = int(input())
V = {}
if N == 1:
  print(0)
  exit(0)

# Vertice
for i in range(N-1):
  u,v,w = list(map(int, input().split()))
  u,v = u-1, v-1 #1-index -> 0-index
  if u not in V:
    V[u] = [[v,w]]
  else:
    V[u].append([v,w])
  if v not in V:
    V[v] = [[u,w]]
  else:
    V[v].append([u,w])
     
#print(V)
ANS = [-1] * N
visited = [False] * N

def dfs(pos):
  visited[pos] = True
  for x,w in V[pos]:
    if visited[x]:
      continue
    if w % 2 == 0:
      ANS[x] = ANS[pos]
    else:
      ANS[x] = 1 - ANS[pos]
    #print(pos,x,ANS)
    dfs(x)
  return

ANS[0] = 0
dfs(0)

for a in ANS:
  print(a)

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

# Vertice
for i in range(N-1):
  u,v,w = list(map(int, input().split()))
  u,v = u-1, v-1 #1-index -> 0-index
  if u not in V:
    V[u] = [[v,w]]
  else:
    V[u].append([v,w])
  if v not in V:
    V[v] = [[u,w]]
  else:
    V[v].append([u,w])
     
#print(V)
ANS = [-1] * N
visited = [False] * N

def dfs(pos):
  visited[pos] = True
  for x,w in V[pos]:
    if visited[x]:
      continue
    if w % 2 == 0:
      ANS[x] = ANS[pos]
    else:
      ANS[x] = 1 - ANS[pos]
    #print(pos,x,ANS)
    dfs(x)
  return

ANS[0] = 0
dfs(0)

for a in ANS:
  print(a)
Problem p03102 (python)

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

ans = 0

for i in range(N):
  A = list(map(int, input().split()))
  work = C
  for j in range(M):
    work += A[j] * B[j]
  if work > 0:
    ans += 1
    
print(ans)

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

ans = 0

for i in range(N):
  work = C
  for j in range(M):
    work += A[j] * B[j]
  if work >= 0:
    ans += 1
    
print(ans)
Problem p03105 (python)

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

Buggy submission (verdict: Runtime Error):
A, B, C = map(int, input.split())
print(min(B//A, C))
Problem p03128 (python)

Fixed submission:
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [6,2,5,5,4,5,6,3,7,6] # B[i]がiを作るのに必要なマッチ棒の数

# dp[i]: i本マッチ使って作れるMAX桁数。。
dp = [-1 for _ in range(N+10)]
dp[0] = 0
A.sort()
visited = [False for _ in range(N+10)]
h = []
heapq.heappush(h, (0,0))

while h:
  now_n, keta = heapq.heappop(h)
  if visited[now_n]:
    continue
  visited[now_n] = True
  for a in A:
    nxt_n = now_n + B[a]
    if nxt_n >= N + 10:
      continue
    dp[nxt_n] = max(dp[nxt_n], dp[now_n] + 1)
    heapq.heappush(h, (nxt_n, dp[now_n] + 1))
    
#print(dp)

A.sort(reverse=True)
# 上の桁から決めていく。dp[N]
ANS = []
zan = N
for i in range(dp[N],0,-1):
  bugf = True
  # sorted(a) 大きい方から試す
  for a in A:
    if dp[zan-B[a]] == dp[zan] - 1:
      ANS.append(str(a))
      zan = zan - B[a]
      bugf = False
      break
  if bugf:
    # Aが構成できない、と言うことなのでここは通らないはず
    print("bug...")
  
print("".join(ANS))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
B = [6,2,5,5,4,5,6,3,7,6] # B[i]がiを作るのに必要なマッチ棒の数

C = []
for a in A:
  C.append(B[a])
  
dp = [0] * (N+1)

dp[0] = 0
for i in range(1,len(dp)):
  for c in C:
    if i-c >= 0:
      dp[i] = max(dp[i-c] + 1, dp[i])

X = max(dp)
pos = N
ans = ""
#print(X)
for cnt in range(X):
  for i in range(9,0,-1):
    if i in A:
      if dp[pos] != dp[pos-B[i]] + 1:
        continue
      if cnt == X-1 and pos - B[i] != 0:
        continue
      pos = pos - B[i]
      ans = ans + str(i)
      break
      
print(ans)
Problem p03148 (python)

Fixed submission:
import heapq
N,K = map(int, input().split())

I = []
for _ in range(N):
  t,d = map(int, input().split())
  I.append((d,t))
  
I.sort(reverse=True)

# heap_can_delete
h_d = []
# heap_can_add
h_a = []

wk = 0
kind = 0
# 出現したことのあるネタ
ap = set()
for i in range(K):
  d,t = I[i]
  wk += d
  if t not in ap:
    ap.add(t)
    kind += 1
  else:
    heapq.heappush(h_d, (d,t))

for i in range(K,N):
  d,t = I[i]
  if t not in ap:
    ap.add(t)
    # maxをpopさせるために、価値を-1かけておく
    heapq.heappush(h_a, ((-1) * d, t))
  
ans = wk + kind ** 2
while len(h_d) > 0 and len(h_a) > 0:
  d1,t1 = heapq.heappop(h_d)
  d2,t2 = heapq.heappop(h_a)
  d2 = (-1) * d2
  wk = wk - d1 + d2
  kind += 1
  ans = max(ans, wk + kind ** 2)
  
print(ans)

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

I = []
for _ in range(N):
  t,d = map(int, input().split())
  I.append((d,t))
  
I.sort(reverse=True)

# heap_can_delete
h_d = []
# heap_can_add
h_a = []

wk = 0
kind = 0
# 出現したことのあるネタ
ap = set()
for i in range(K):
  d,t = I[i]
  wk += d
  if t not in ap:
    ap.add(t)
    kind += 1
  else:
    heapq.heappush(h_d, (d,t))

for i in range(K,N):
  d,t = I[i]
  if t not in ap:
    ap.add(t)
    # maxをpopさせるために、価値を-1かけておく
    heapq.heappush(h_a, ((-1) * d, t))
  
ans = wk + kind ** 2
while len(h_d) > 0:
  d1,t1 = heapq.heappop(h_d)
  d2,t2 = heapq.heappop(h_a)
  d2 = (-1) * d2
  wk = wk - d1 + d2
  kind += 1
  ans = max(ans, wk + kind ** 2)
  
print(ans)
Problem p03241 (python)

Fixed submission:
N, M = map(int, input().split())
if M == 1:
  print(1)
  exit(0)
  
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a
  
fct = factorize(M)
#print(fct, num(fct))

ans = 1
for div in divisorize(fct):
    #print(div, num(div))
    temp = num(div)
    if N * temp <= M:
      ans = max(ans, temp)
      
print(ans)

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

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a
  
fct = factorize(M)
#print(fct, num(fct))

ans = 1
for div in divisorize(fct):
    #print(div, num(div))
    temp = num(div)
    if N * temp <= M:
      ans = max(ans, temp)
      
print(ans)

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

def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct


def divisorize(fct):
    b, e = fct.pop()  # base, exponent
    pre_div = divisorize(fct) if fct else [[]]
    suf_div = [[(b, k)] for k in range(e + 1)]
    return [pre + suf for pre in pre_div for suf in suf_div]


def num(fct):
    a = 1
    for base, exponent in fct:
        a = a * base**exponent
    return a
  
fct = factorize(M)
#print(fct, num(fct))

sum_i = int(1e9+7)
for div in divisorize(fct):
    #print(div, num(div))
    temp = num(div)
    if temp >= N:
      sum_i = min(sum_i, temp)
      
print(M // sum_i)
Problem p03264 (python)

Fixed submission:
N = int(input())

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

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

if N % 2 == 0:
  print((N // 2) ** 2)
else:
  print((N // 2) * (N // 2 + 1)
Problem p03280 (python)

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

print((A-1)*(B-1))

Buggy submission (verdict: Runtime Error):
A = int(input())
B = int(input())

print((A-1)*(B-1))
Problem p03323 (python)

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

if A <= 8 and B <= 8:
    print("Yay!")
else:
    print(":(")

Buggy submission (verdict: Runtime Error):
A=int(input())
B=int(input())

if A <= 8 and B <= 8:
    print("Yay!")
else:
    print(":(")
Problem p03407 (python)

Fixed submission:
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())
# 文字列の入力
if a+b>=c:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b, c = map(int, input().split())
# 文字列の入力
if a+b>=c:
  print "Yes"
else:
  print "No"
Problem p03434 (python)

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

Arr.sort(reverse=True)

i = 0
ans = 0
for a in Arr:
  if i%2 == 0:
    ans += a
  else:
    ans -= a
  i += 1

print(ans)

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

Arr.sort(reverse=True)

i = 0
ans = 0
for a in arr:
  if i%2 == 0:
    ans += a
  else:
    ans -= a

print(ans)
Problem p03469 (python)

Fixed submission:
S = input()
 
print(S[0:3] + '8' + S[4:])

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

S[3] = '8'
print(S)
Problem p03547 (python)

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

if a < b:
  print("<")
elif a > b:
  print(">")
else:
  print("=")

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

if a < b:
  print("<")
elif a > b:
  print(">")
else:
  print("=")
Problem p03556 (python)

Fixed submission:
from math import floor, sqrt

print(floor(sqrt(int(input()))) ** 2)

Buggy submission (verdict: Runtime Error):
from math import floor, sqrt

print(floor(sqrt(int(input())) ** 2)
Problem p03583 (python)

Fixed submission:
N = int(input())

# a >= b >= c を仮定できる
# a,b,c <= 3500
# 4/N <= 3/a  a <= 0.75N
# 4/N >= 3/c  c >= 0.75N

least = int(0.75 * N) + 2
max = 3501
for b in range(1,max):
  for a in range(1,least):
    res = 4/N - 1/a - 1/b
    if res<=0:
      continue
    candc = int(1/res)
    for c in range(candc-1,candc+2):
      if 4*a*b*c == N*(a*b + b*c + c*a):
        print(a,b,c)
        exit(0)

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

# a >= b >= c を仮定できる
# a,b,c <= 3500
# 4/N <= 3/a  a <= 0.75N
# 4/N >= 3/c  c >= 0.75N

amax = int(0.75 * N) + 2
bmin = int(0.75 * N) - 1
max = 3501
for b in range(bmin,max):
  for a in range(1,amax):
    res = 4/N - 1/a - 1/b
    if res<=0:
      continue
    candc = int(1/res)
    for c in range(candc-1,candc+2):
      if 4*a*b*c == N*(a*b + b*c + c*a):
        print(a,b,c)
        exit(0)
Problem p03633 (python)

Fixed submission:
N = int(input())

A = []
for i in range(N):
  A.append(int(input()))

def GCD(a,b):
  if a < b:
    a, b = b, a
  while b > 0:
    a, b = b, a%b
  
  return a

def LCM(a,b):
  return a*b // GCD(a,b)

lcm = A[0]
for i in range(1,N):
  lcm = LCM(lcm, A[i])

print(lcm)

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

A = []
for i in range(N):
  A.append(int(input()))

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

def LCM(a,b):
  return int(a*b/GCD(a,b))

prev = A[0]
for i in range(1,N):
  lcm = LCM(prev, A[i])
  prev = lcm

print(prev)
Problem p03698 (python)

Fixed submission:
S = input()

li = set()
for i in range(len(S)):
  li.add(S[i])

if len(S) == len(li):
  print("yes")
else:
  print("no")

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

li = set()
for i in len(S):
  li.add(S[i])

if len(S) == len(li):
  print("yes")
else:
  print("no")
Problem p03732 (python)

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

W1,V1 = map(int, input().split())

P = {W1:[V1], W1+1:[], W1+2:[], W1+3:[]}

for i in range(1,N):
  w,v = map(int, input().split())
  P[w].append(v)

PS={}
for k,v in P.items():
  v.sort(reverse=True)
  S = [0] * (len(v)+1)
  for i in range(len(v)):
    S[i+1] = S[i] + v[i]
  PS[k] = S
  
#print(P)
#print(PS)
A,B,C,D = len(PS[W1]), len(PS[W1+1]), len(PS[W1+2]), len(PS[W1+3])
ans = 0
for a in range(A):
  for b in range(B):
    for c in range(C):
      for d in range(D):
        if a*W1 + b*(W1+1) + c*(W1+2) + d*(W1+3) > W:
          continue
        ans = max(ans, PS[W1][a] + PS[W1+1][b] + PS[W1+2][c] + PS[W1+3][d])
        
print(ans)

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

#dp[i][w] : i番目までの品物で、wの重みでできる最大の価値. 1-indexed
dp = [[0] * (W+1) for i in range(N+1)]

for i in range(1,N+1):
  weight = P[i-1][0]
  value = P[i-1][1]

  for j in range(W+1):
    if j - weight >= 0:
      dp[i][j] = max(dp[i-1][j-weight] + value, dp[i-1][j])
    else:
      dp[i][j] = dp[i-1][j]

#print(dp)
print(max(dp[N][:]))
Problem p03778 (python)

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

if B >= A+W:
  print(abs(A+W-B))
elif B+W <= A:
  print(abs(B+W-A))
else:
  print(0)

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

if B >= A+W:
  print(abs(A+W-b))
elif B+W <= A:
  print(abs(B+W-A))
else:
  print(0)