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

Fixed submission:
import sys

read = sys.stdin.read

n, m, *a = map(int, read().split())
mod = 1000000007
dp = [0] * (n+1)
dp[0] = 1
if a and a[0] == 1:
    dp[1] = 0
    a.pop(0)
else:
    dp[1] = 1
for i in range(2, n+1):
    if a and i == a[0]:
        a.pop(0)
        dp[i] == 0
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % mod
print(dp[-1])

Buggy submission (verdict: Runtime Error):
import sys

read = sys.stdin.read

n, m, *a = map(int, read().split())
mod = 1000000007
dp = [0] * (n+1)
dp[0] = 1
if a[0] == 1:
    dp[1] = 0
    a.pop(0)
else:
    dp[1] = 1
for i in range(2, n+1):
    if a and i == a[0]:
        a.pop(0)
        dp[i] == 0
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % mod
print(dp[-1])
Problem p03042 (python)

Fixed submission:
s = input()
front = int(s[:2])
back = int(s[2:])
if 0 < front < 13 and 0 < back < 13:
    ans = 'AMBIGUOUS'
elif 0 < front < 13:
    ans = 'MMYY'
elif 0 < back < 13:
    ans = 'YYMM'
else:
    ans = 'NA'
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
front = int(s[:2])
back = int(s[2:])
if 0 in (front, back):
    ans = 'NA'
elif 0 < front < 13 and 0 < back < 13:
    ans = 'AMBIGUOUS'
elif 0 < front < 13:
    ans = 'MMYY'
elif 0 < back < 13:
    ans = 'YYMM'
print(ans)
Problem p03209 (python)

Fixed submission:
N, X = map(int, input().split())
burger  = [1] * N
patty = [1] * N
for i in range(1, N):
    burger[i] = burger[i-1] * 2 + 3
    patty[i] = patty[i-1] * 2 + 1


def func(level, x):
    if level == 0:
        return 0 if x <= 0 else 1
    if burger[level-1] + 1 < x:
        return func(level-1, x-burger[level-1]-2) + patty[level-1] + 1
    else:
        return func(level-1, x-1)


print(func(N, X))

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
burger  = [1] * (N+1)
patty = [1] * (N+1)
for i in range(1, N+1):
    burger[i] = burger[i-1] * 2 + 3
    patty[i] = patty[i-1] * 2 + 1


def func(level, x):
    if burger[level-1] + 1 <= x:
        return func(level-1, x-burger[level-1]-2) + patty[level-1] + 1
    else:
        return func(level-1, x-1)
    if level == 0:
        return 0


print(func(N, X))
Problem p03327 (python)

Fixed submission:
N = int(input())
print('ABC' if N < 1000 else 'ABD')

Buggy submission (verdict: Runtime Error):
N = int(input())
if N < 1000:
  print('ABC{:03}'.format(N))
else:
  print('ABD{:03}'.format(str(N)[1:]))
Problem p03011 (python)

Fixed submission:
p, q, r = [int(i) for i in input().split()]

print(min(p + q, q + r, r + p))

Buggy submission (verdict: Runtime Error):
from sys import setrecursionlimit
setrecursionlimit(10 ** 8)

A = input()
B = input()

class Source():
  def __init__(self, S):
    self.S = S
    self.pos = 0
   
  
def peek(S):
  return S.S[S.pos] if S.pos < len(S.S) else -1

def next(S):
  print(S.S[S.pos], end='')
  S.pos += 1
  
def tree(S):
  next(S)
  if peek(S) == ')':
    next(S)
    return -1
  left = tree(S)
  center = root(S)
  right = tree(S)
  next(S)
  
def root(S):
  res = 0
  next(S)
  while peek(S) != ']':
    res += res * 10 + int(peek(S))
    next(S)
  next(S)
  
  return res
  
tree(Source('(' + A + ')'))
Problem p03108 (python)

Fixed submission:
from sys import setrecursionlimit
setrecursionlimit(10 ** 9)

class UnionFind():
    def __init__(self, elements):
        self.elements = elements
        self._root = {}
        self._count= {}
        for e in self.elements:
            self._root[e] = e
            self._count[e] = 1
        
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            self._root[x] = y
            self._count[y] += self._count[x]
        
    def root(self, x):
        if self._root[x] != x:
            self._root[x] = self.root(self._root[x])
        return self._root[x]
    
    def size(self, x):
        return self._count[self.root(x)]

n, m = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for j in range(m)]
A.reverse()

ans = [n * (n - 1) // 2]
uf = UnionFind(range(1, n+1))
for a, b in A:
    if uf.root(a) == uf.root(b):
        ans.append(ans[-1])
        continue
    ans.append(ans[-1] - uf.size(a) * uf.size(b))
    uf.unite(a, b)

print(*ans[:-1][::-1], sep='\n')

Buggy submission (verdict: Runtime Error):
class UnionFind():
    def __init__(self, elements):
        self.elements = elements
        self._root = {}
        self._count= {}
        for e in self.elements:
            self._root[e] = e
            self._count[e] = 1
        
    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            self._root[x] = y
            self._count[y] += self._count[x]
        
    def root(self, x):
        if self._root[x] != x:
            self._root[x] = self.root(self._root[x])
        return self._root[x]
    
    def size(self, x):
        return self._count[self.root(x)]
        
    def get_union(self):
        union = {}
        for e in self.elements:
            if self.root(e) in union:
                union[self.root(e)].add(e)
            else:
                union[self.root(e)] = {e}
        return union

n, m = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for j in range(m)]
A.reverse()

ans = [n * (n - 1) // 2]
uf = UnionFind(range(1, n+1))
for a, b in A:
    if uf.root(a) == uf.root(b):
        ans.append(ans[-1])
        continue
    ans.append(ans[-1] - uf.size(a) * uf.size(b))
    uf.unite(a, b)

print(*ans[:-1][::-1], sep='\n')
Problem p03327 (python)

Fixed submission:
n = int(input())

ans = 'ABC' if n <= 999 else 'ABD'

print(ans)

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

ans = 'ABC' if n <= 999: else 'ABD'

print(ans)
Problem p03332 (python)

Fixed submission:
n, a, b, k = [int(i) for i in input().split()]
p = 998244353

def fact(n, p):
    n_ = 1
    yield n_
    for i in range(1, n+1):
         n_ = (n_*i) % p
         yield n_

def invfact(n, f, p):
    m = pow(f[n], p-2, p)
    yield m
    for i in range(n, 0, -1):
        m = m * i % p
        yield m

f = list(fact(n+1, p))
rf = list(invfact(n+1, f, p))
rf.reverse()
ans = 0

for x in range(n+1):
    y = (k-x*a)/b
    if not y.is_integer() or y > n or y < 0:
        continue
    y = int(y)

    ans += (f[n] * rf[x] % p * rf[n-x] % p) * (f[n] * rf[y] % p * rf[n-y] % p) % p

print(ans%p)

Buggy submission (verdict: Runtime Error):
n, a, b, k = [int(i) for i in input().split()]
p = 998244353

def fact(n, p):
    n_ = 1
    yield n_
    for i in range(1, n+1):
         n_ = (n_*i) % p
         yield n_

def invfact(n, f, p):
    m = pow(f[n], p-2, p)
    yield m
    for i in range(n, 0, -1):
        m = m * i % p
        yield m

f = list(fact(n+1, p))
rf = list(invfact(n+1, f, p))
rf.reverse()
ans = 0

for x in range(n+1):
    y = (k-x*a)/b
    if not y.is_integer() or y > n:
        continue
    y = int(y)

    ans += (f[n] * rf[x] % p * rf[n-x] % p) * (f[n] * rf[y] % p * rf[n-y] % p) % p

print(ans%p)

Buggy submission (verdict: Runtime Error):
n, a, b, k = [int(i) for i in input().split()]
p = 998244353

def fact(n, p):
    n_ = 1
    yield n_
    for i in range(1, n+1):
         n_ = (n_*i) % p
         yield n_

def invfact(n, f, p):
    m = pow(f[n], p-2, p)
    yield m
    for i in range(n, 0, -1):
        m = m * i % p
        yield m

f = list(fact(n+1, p))
rf = list(invfact(n+1, f, p))
rf.reverse()
ans = 0

for x in range(n+1):
    y = (k-x*a)/b
    if not y.is_integer():
        continue
    y = int(y)

    ans += (f[n] * rf[x] % p * rf[n-x] % p) * (f[n] * rf[y] % p * rf[n-y] % p) % p

print(ans%p)

Buggy submission (verdict: Runtime Error):
n, a, b, k = [int(i) for i in input().split()]
p = 998244353

def fact(n, p):
    n_ = 1
    yield n_
    for i in range(1, n+1):
         n_ = (n_*i) % p
         yield n_

def invfact(n, f, p):
    m = pow(f[n], p-2, p)
    yield m
    for i in range(n, 0, -1):
        m = m * i % p
        yield m

f = list(fact(n, p))
rf = list(invfact(n, f, p))
rf.reverse()
ans = 0

for x in range(n+1):
    y = (k-x*a)/b
    if not y.is_integer():
        continue
    y = int(y)

    ans += (f[n] * rf[x] % p * rf[n-x] % p) * (f[n] * rf[y] % p * rf[n-y] % p) % p

print(ans%p)
Problem p03365 (python)

Fixed submission:
n = int(input())
p = 10**9 + 7

def fact(n):
    n_ = 1
    yield n_
    for i in range(1, n+1):
         n_ = (n_*i) % p
         yield n_

def invfact(n, f, p):
    m = pow(f[n], p-2, p)
    yield m
    for i in range(n, 0, -1):
        m = m * i % p
        yield m

ans = 0
m = n - 1
f = list(fact(m))
rf = list(invfact(m, f, p))
rf.reverse()
perm = 0

for k in range((n+1)//2, n):
    b = m - k
    a = (m - 1) - (2 * b)
    perm_ = f[a+b] * rf[a] %p * f[k] % p
    ans += (perm_ - perm) %p * k % p
    ans %= p
    perm = perm_

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = 10**9 + 7

def fact(n, p):
    n_ = [1]
    for i in range(1, n+1):
         n_.append((n_[-1]*i) % p)
    return n

def invfact(n, f, p):
    m = [pow(f[n], p-2, p)]
    for i in range(n, 0, -1):
        m.append(m[-1] * i % p)
    return m

ans = 0
m = n - 1
f = fact(m, p)
rf = invfact(m, f, p)
rf.reverse()
perm = 0

for k in range((n+1)//2, n):
    perm_ = f[k-1] * rf[2*k-n] %p * f[k] % p
    ans += (perm_ - perm) %p * k % p
    ans %= p
    perm = perm_

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = 10**9 + 7

# def fact(n, p):
#     n_ = 1
#     yield n_
#     for i in range(1, n+1):
#          n_ = (n_*i) % p
#          yield n_

# def invfact(n, f, p):
#     m = pow(f[n], p-2, p)
#     yield m
#     for i in range(n, 0, -1):
#         m = m * i % p
#         yield m

def fact(n, p):
    n_ = [1]
    for i in range(1, n+1):
         n_.append((n_[-1]*i) % p)
    return n

def invfact(n, f, p):
    m = [pow(f[n], p-2, p)]
    for i in range(n, 0, -1):
        m.append(m[-1] * i % p)
    return m

ans = 0
m = n - 1
f = fact(m, p)
rf = invfact(m, f, p)
rf.reverse()
perm = 0

for k in range((n+1)//2, n):
    perm_ = f[k-1] * rf[2*k-n] %p * f[k] % p
    ans += (perm_ - perm) %p * k % p
    ans %= p
    perm = perm_

print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
p = 10**9 + 7

def fact(n, p):
    n_ = [1]
    for i in range(1, n+1):
         n_.append((n_[-1]*i) % p)
    return n

def invfact(n, f, p):
    m = [pow(f[n], p-2, p)]
    for i in range(n, 0, -1):
        m.append(m[-1] * i % p)
    return m

ans = 0
m = n - 1
f = list(fact(m, p))
rf = list(invfact(m, f, p))
rf.reverse()
perm = 0

for k in range((n+1)//2, n):
    perm_ = f[k-1] * rf[2*k-n] %p * f[k] % p
    ans += (perm_ - perm) %p * k % p
    ans %= p
    perm = perm_

print(ans)
Problem p02935 (python)

Fixed submission:
N = int(input())
v = sorted(list(map(int,input().split())))
c = v[0]
for i in range(1,len(v)):
  c = (v[i]+c)/2
print(c)

Buggy submission (verdict: Runtime Error):
N = int(input())
v = sorted(list(map(int,input().split())))
c = v[0]
for i in range(1,len(v)+1):
  c = (v[i]+c)/2
print(int(c))
Problem p03075 (python)

Fixed submission:
a=int(input())
b=input()
c=input()
d=input()
e=int(input())
k=int(input())
print('Yay!' if (e-a)<=k else ':(')

Buggy submission (verdict: Runtime Error):
a=input()
b=input()
c=input()
d=input()
e=input()
k=input()
print('Yay!' if (e-a)<=k else ':(')

Buggy submission (verdict: Runtime Error):
a=input()
input()
input()
input()
e=input()
k=input()
print('Yay!' if (e-a)<=k else ':(')
Problem p03207 (python)

Fixed submission:
n=int(input())
p=[int(input()) for i in range(n)]
print(sum(p)-max(p)//2)

Buggy submission (verdict: Runtime Error):
input()
x=sum(input())
y=max(input())
print(x-y//2)
Problem p03631 (python)

Fixed submission:
N=input()
print("Yes" if N[0]==N[2] else "No")

Buggy submission (verdict: Runtime Error):
N=input()
print("Yes" if N[0]=N[2] else "No")
Problem p03834 (python)

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

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

Buggy submission (verdict: Runtime Error):
a,b,c=input().split(,)
print(a,b,c)
Problem p03835 (python)

Fixed submission:
k,s=map(int,input().split())
ans=0
for x in range(k+1):
  for y in range(k+1):
    if s-k<=x+y<=s:
      ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
k,s=map(int,input().split())
ans=0
for x in range(k+1):
  for y in range(k+1):
    if x+y+z<=s:
      ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
k,s=map(int,input().split())
ans=0
for x in range(k+1):
  for y in range(k+1):
    if x+y+z<=s:
      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,B=[0],[0]
for i in range(n):
    A.append(A[i]+a[i])
for i in range(m):
    B.append(B[i]+b[i])
ans,j=0,m
for i in range(n+1):
    if A[i]>k:
        break
    while B[j]>k-A[i]:
        j-=1
    ans=max(ans,i+j)
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,B=[0],[0]
for i in range(n):
    A.append(A[i]+a[i])
for i in range(m):
    B.append(B[i]+b[i])
ans,j=0,m
for i in range(n+1):
    if a[i]>k:
        break
    while b[j]>k-a[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)
Problem p02711 (python)

Fixed submission:
s=input()
num=s.count('7')
if num>0:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
n=int(input())
if n in 7:
    print('Yes')
else:
    print('No')
Problem p03723 (python)

Fixed submission:
a,b,c=map(int,input().split())
if a==b==c:
    if a%2==b%2==c%2==0:
        print(-1)
    else:
        print(0)
    exit()
cnt=0
while a%2==b%2==c%2:
    A=a//2
    B=b//2
    C=c//2
    a,b,c=B+C,A+C,A+B
    cnt+=1
print(cnt)

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a==b==c:
    if a%2===b%2==c%2==0:
        print(-1)
    else:
        print(0)
    exit()
cnt=0
while a%2==b%2==c%2:
    A=a//2
    B=b//2
    C=c//2
    a,b,c=B+C,A+C,A+B
    cnt+=1
print(cnt)
Problem p02633 (python)

Fixed submission:
X = int(input())

K = 1
dire = X
while True:
  if (dire % 360) == 0:
    break
  K+=1
  dire+=X

  
print(K)

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

K = 1
direct = X
while True:
  
  if direct % 360 = 0
  	break
  direct += X
  K += 1

print(K)
Problem p02634 (python)

Fixed submission:
import sys
import numpy as np
#from functools import lru_cache
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
MOD = 998_244_353
 
def main(A, B, C, D):
	d = np.zeros((C + 1, D + 1), np.int64)
	d[A,B]=1
	for i in range(A+1,C+1):
  		d[i,B] = B*d[i-1,B] % MOD
	for j in range(B+1,D+1):
		d[A,j] = A*d[A,j-1] % MOD
 
	for i in range(A+1,C+1):
		for j in range(B+1,D+1):
			d[i,j]=((((j*d[i-1,j]) % MOD + i*d[i,j-1] % MOD) % MOD) -((i-1)*((j-1)*d[i-1,j-1] % MOD)% MOD)% MOD)
    
	return d[C,D] % MOD
          
"""    
    print(d[C][D] % MOD)
    dp = np.zeros((C + 1, D + 1), np.int64)
    dp[C, D] = 1
    for d in range(D, 0, -1):
        dp[C, d - 1] = dp[C, d] * C % MOD
    for c in range(C - 1, -1, -1):
        x = 0
        for d in range(D, -1, -1):
            dp[c, d] = (d * dp[c + 1, d] + x) % MOD
            x += dp[c + 1, d]
            x *= c
            x %= MOD
    return dp[A, B]
"""

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.from_dtype(np.int64)
    signature = (i8, i8, i8, i8)
 
    cc = CC('my_module')
    cc.export('main', signature)(main)
    cc.compile()
 
from my_module import main
 
A, B, C, D = map(int, read().split())
print(main(A, B, C, D))

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

d={}
d[(A,B)]=1
for i in range(A+1,C+1):
  d[(i,B)] *= B*d[(i-1,B)] % 998244353
for j in range(B+1,D+1):
  d[(A,j)] *= A*d[(A,j-1)] % 998244353
 
for i in range(A+1,C+1):
  for j in range(B+1,D+1):
    d[(i,j)]=(j*d[(i-1,j)]+i*d[(i,j-1)]-(i-1)*(j-1)*d[(i-1,j-1)]) % 998244353
    
print(d[(C,D)] % 998244353)
Problem p02688 (python)

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

C = [0 for _ in range(N)]
ct = N
for i in range(K):
  d = input()
  A = list(map(int, input().split()))
  for a in A:
    if C[a-1] == 0:
      C[a-1] += 1
      ct -= 1

print(ct)

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

C = [0 for _ in range(N)]
ct = N
for i in range(N):
  d = int(input())
  A = list(map(int, input().split()))
  for a in A:
    if C[a-1] == 0:
      C[a-1] += 1
      ct -= 1

print(ct)
Problem p03253 (python)

Fixed submission:
import math
import sys

N, M = map(int, input().split())
visited = set()

if M == 1:
  print(1)
  sys.exit()
  
limit = math.ceil(math.sqrt(M))
A = []
for i in range(2, limit+1):
  if i in visited:
    continue
  j = i
  while j <= limit:
    visited.add(j)
    j += i
  del j
  k = 0
  while M % i == 0:
    M = M // i
    k += 1
  A.append(k)
if M > 1:
  A.append(1)

  
MOD = 10**9 + 7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

K = max(A) + N - 1
for i in range(2, K + 1):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

# ②事前計算した項を掛け合わせ
def cmb(n, r, MOD):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % MOD
  
ans = 1  
for a in A:
  ans *= cmb(a + N-1, N-1, MOD)
  ans %= MOD
  
print(ans)
#print(A)

Buggy submission (verdict: Runtime Error):
import math

N, M = map(int, input().split())
visited = set()

limit = math.ceil(math.sqrt(M))
A = []
for i in range(2, limit+1):
  if i in visited:
    continue
  j = i
  while j <= limit:
    visited.add(j)
    j += i
  del j
  k = 0
  while M % i == 0:
    M = M // i
    k += 1
  A.append(k)
if M > 1:
  A.append(1)

  
MOD = 10**9 + 7
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

K = max(A) + N - 1
for i in range(2, K + 1):
    fact.append((fact[-1] * i) % MOD)
    inv.append((-inv[MOD % i] * (MOD // i)) % MOD)
    factinv.append((factinv[-1] * inv[-1]) % MOD)

# ②事前計算した項を掛け合わせ
def cmb(n, r, MOD):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % MOD
  
ans = 1  
for a in A:
  ans *= cmb(a + N-1, N-1, MOD)
  ans %= MOD
  
print(ans)
#print(A)
Problem p02659 (python)

Fixed submission:
import math
import sys

a, b = map(str, input().split())
if a == "0" or b == "0.00":
  print(0)
  exit()
ans = 0
ans += int(a) * int(b[0]) * 100
ans += int(a) * int(b[2]) * 10
ans += int(a) * int(b[3])
tmp = list(str(ans))
if len(tmp) == 1 or len(tmp) == 2:
  print(0)
  exit()
tmp.pop(-1)
tmp.pop(-1)
print(int("".join(tmp)))

Buggy submission (verdict: Runtime Error):
import math
a, b = map(str, input().split())
ans = 0
ans += int(a) * int(b[0]) * 100
ans += int(a) * int(b[2]) * 10
ans += int(a) * int(b[3])
tmp = list(str(ans))
tmp.pop(-1)
tmp.pop(-1)
print(int("".join(tmp)))

Buggy submission (verdict: Runtime Error):
a, tmp = map(str, input().split())
b = list(tmp)
del b[1]
bb = "".join(b)
abb = int(a) * int(bb)
ans = list(str(abb))
del ans[-2:]
print(int("".join(ans)))
Problem p02879 (python)

Fixed submission:
a, b = map(int, input().split())
if a >= 10 or b >= 10:
  print(-1)
else:
  print(a*b)

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a >= 10 || b >= 10:
  print(-1)
else:
  print(a*b)
Problem p02897 (python)

Fixed submission:
n = int(input())
if n % 2 == 0:
  print(1/2)
elif n % 2 == 1:
  print((n+1)/(2*n))

Buggy submission (verdict: Runtime Error):
n = int(input())
if n%2=0:
  print(1/2)
else:
  print((n+1)/2n)
Problem p03041 (python)

Fixed submission:
n, k = map(int, input().split())
s = list(input())

for i in range(n):
  if i == k-1:
    s[i] = s[i].lower()
    break
    
print("".join(s))

Buggy submission (verdict: Runtime Error):
n, k = map(int, input().split())
s = input()
print(s[:k-1] + s[k-1].lower + s[k:])
Problem p02790 (python)

Fixed submission:
a,b = map(int,input().split())
if a > b: a,b = b,a
for i in range(b):
  print(a,end='')

Buggy submission (verdict: Runtime Error):
a,b = map(int,input().split())
if a > b: a,b = b,a
for i in ragne(b):
  print(a,end='')
Problem p02829 (python)

Fixed submission:
n = int(input())
m = int(input())
print((5 - n -m)%3 + 1)

Buggy submission (verdict: Runtime Error):
prirt(int(input())^int(input()))

Buggy submission (verdict: Runtime Error):
prirt(int(input()^int(input()))
Problem p02987 (python)

Fixed submission:
s=input()
ans=False
if s[0]==s[1]:
    if s[0]!=s[2] and s[2]==s[3]:
        ans=True
elif s[0]==s[2]:
    if s[0]!=s[1] and s[1]==s[3]:
        ans=True
elif s[0]==s[3]:
    if s[0]!=s[1] and s[1]==s[2]:
        ans=True
if ans:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
s=input()
ans=False
if s[0]==s[1]:
    if s[0]!=s[2] and a[2]==s[3]:
        ans=True
elif s[0]==s[2]:
    if s[0]!=s[1] and s[1]==s[3]:
        ans=True
elif s[0]==s[3]:
    if s[0]!=s[1] and s[1]==s[2]:
        ans=True
if ans:
    print('Yes')
else:
    print('No')
Problem p03011 (python)

Fixed submission:
da=list(map(int,input().split()))
x=-max(da)
for i in da:
    x+=i
print(x)

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

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
x=max(a,max(b,c))
input(a+b+c-x)
Problem p03315 (python)

Fixed submission:
s=str(input())
ans=-4
for i in range(4):
    if s[i]=='+':
        ans+=2
print(ans)

Buggy submission (verdict: Runtime Error):
s=str(input())
ans=-4
for i in range(4):
  if s[i]='+':
    ans+=2
print(ans)

Buggy submission (verdict: Runtime Error):
s=str(input())
ans=-4
for i in range(4):
  if s[i]='+':
    ans+=2
input(ans)
Problem p02594 (python)

Fixed submission:
X=int(input())
if X>=30:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
X=input()
if X>=30:
  print('Yes')
else:
  print('No')
Problem p02759 (python)

Fixed submission:
import math
n = int(input())

print(math.ceil(n/2))

Buggy submission (verdict: Runtime Error):
a
Problem p02781 (python)

Fixed submission:
def comb(n,k):
  if n == 0:
    return 0
  if n == k:
    return 1
  
  num = 1
  for i in range(n-k+1,n+1):
    num *= i
    
  for i in range(2,k+1):
    num //= i
    

  return num
    
def syou(n,k):
  if k == 0:
    return 1
  
  if len(n) < k:
    return 0
  
  if len(n) == 1:
    return int(n)
  
  l = len(n)
  if n[0] == '0':
    return syou(n[1:l], k)
  
  ans = comb(l-1, k) * (9**k)
  
  top = int(n[0])
  ans += comb(l-1, k-1) * (top-1) * (9**(k-1))
  
  ans += syou(n[1:l], k-1)
  return ans


n = input()
k = int(input())

print(syou(n, k))

Buggy submission (verdict: Runtime Error):
def comb(n,k):
  if n == 0:
    return 0
  if n == k:
    return 1
  
  num = 1
  for i in range(n-k+1,n+1):
    num *= i
    
  for i in range(2,k+1):
    num //= i
    

  return num
    
def syou(n,k):
  if k == 0:
    return 1
  
  if len(n) < k:
    return 0
  
  if len(n) == 1:
    return int(n)
  
  if n[0] == '0':
    return syou(n[1:l], k-1)
  
  l = len(n)
  ans = comb(l-1, k) * (9**k)
  
  top = int(n[0])
  ans += comb(l-1, k-1) * (top-1) * (9**(k-1))
  
  ans += syou(n[1:l], k-1)
  print('tmp:', n,k,ans)
  return ans


n = input()
k = int(input())

print(syou(n, k))
Problem p03012 (python)

Fixed submission:


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

list_sum = sum(w)

ans = 1000000
s1 = 0
s2 = list_sum
for i in range(n):
  s1 += w[i]
  s2 -= w[i]
  ans = min(ans,max(s1-s2,s2-s1))

print(ans)

Buggy submission (verdict: Runtime Error):


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

list_sum = sum(list)

ans = 1000000
s1 = 0
s2 = list_sum
for i in range(n):
  s1 += w[i]
  s2 -= w[i]
  ans = min(ans,max(s1-s2,s2-s1))

print(ans)