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

Fixed submission:
from collections import Counter
n,k = map(int,input().split())
td = [list(map(int,input().split())) for i in range(n)]
td.sort(key = lambda x:x[1],reverse=True)
ans = list(range(k))
ansv = sum((td[i][1] for i in range(k)))
c = Counter((td[i][0] for i in range(k)))
cnt = len(c)
ansv += len(c)**2
ptr = k
ansls = [ansv]
for i in range(k-1,-1,-1):
  t,d = td[ans[i]]
  if ptr < n and c[t] > 1:
    while ptr < n and c[td[ptr][0]] >= 1:
      ptr += 1
    if ptr >= n:
      break
    ansv = ansv-d+2*cnt+1+td[ptr][1]
    c[t] -= 1
    c[td[ptr][0]] += 1
    cnt += 1
    ptr += 1
    ansls.append(ansv)
print(max(ansls))

Buggy submission (verdict: Runtime Error):
from collections import Counter
n,k = map(int,input().split())
td = [list(map(int,input().split())) for i in range(n)]
td.sort(key = lambda x:x[1],reverse=True)
ans = list(range(k))
ansv = sum((td[i][1] for i in range(k)))
c = Counter((td[i][0] for i in range(k)))
cnt = len(c)
ansv += len(c)**2
ptr = k
ansls = [ansv]
for i in range(k-1,-1,-1):
  t,d = td[ans[i]]
  if ptr < n and c[t] > 1:
    while ptr < n and c[td[ptr][0]] >= 1:
      ptr += 1
    ansv = ansv-d+2*cnt+1+td[ptr][1]
    c[t] -= 1
    c[td[ptr][0]] += 1
    cnt += 1
    ptr += 1
    ansls.append(ansv)
print(max(ansls))
Problem p03158 (python)

Fixed submission:
import sys
input = sys.stdin.readline
from itertools import accumulate
import bisect
n,q = map(int,input().split())
if n%2:
  a = [0]+list(map(int,input().split()))
  n += 1
else:
  a = list(map(int,input().split()))
fs = [a[i] if i%2 else 0 for i in range(n)]
accss = [0]*n
accff = list(accumulate(a))
accfs = list(accumulate(fs))
xls = []
xpt = []
for i in range(n//2):
  xls.append((a[2*i+1]+a[i+n//2])/2)
  if i == 0:
    xpt.append(accff[n-1]-accff[n//2-1])
  else:
    xpt.append(accff[n-1]-accff[i+n//2-1]+accfs[2*i-1])
for _ in range(q):
  x = bisect.bisect_left(xls,int(input()))
  if x >= n//2:
    print(xpt[-1])
  else:
    print(xpt[x])

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
import bisect
n,q = map(int,input().split())
if n%2:
  a = [0]+list(map(int,input().split()))
  n += 1
else:
  a = list(map(int,input().split()))
fs = [a[i] if i%2 else 0 for i in range(n)]
accss = [0]*n
accff = list(accumulate(a))
accfs = list(accumulate(fs))
xls = []
xpt = []
for i in range(n//2):
  xls.append((a[2*i+1]+a[i+n//2])/2)
  if i == 0:
    xpt.append(accff[n-1]-accff[n//2-1])
  else:
    xpt.append(accff[n-1]-accff[i+n//2-1]+accfs[2*i-1])
for _ in range(q):
  x = bisect.bisect_left(xls,int(input()))
  if x >= n-1:
    print(xpt[-1])
  else:
    print(xpt[x])

Buggy submission (verdict: Runtime Error):
from itertools import accumulate
import bisect
n,q = map(int,input().split())
if n%2:
  a = [0]+list(map(int,input().split()))
  n += 1
else:
  a = list(map(int,input().split()))
fs = [a[i] if i%2 else 0 for i in range(n)]
accss = [0]*n
accff = list(accumulate(a))
accfs = list(accumulate(fs))
xls = []
xpt = []
print(accff)
print(accfs)
for i in range(n//2):
  xls.append((a[2*i+1]+a[i+n//2])/2)
  if i == 0:
    xpt.append(accff[n-1]-accff[n//2-1])
  else:
    xpt.append(accff[n-1]-accff[i+n//2-1]+accfs[2*i-1])
for _ in range(q):
  x = bisect.bisect_left(xls,int(input()))
  if x >= n-1:
    print(xpt[-1])
  else:
    print(xpt[x])
Problem p03160 (python)

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

INF = float('inf')
DP = [INF for i in range(N)]

for i in range(N):
    if i == 1:
        DP[i] = abs(stage[i] - stage[i-1])
    elif i == 2:
        DP[i] = min(abs(stage[i] - stage[i-2]), DP[i-1] + abs(stage[i] - stage[i-2]))
    else:
        DP[i] = min(DP[i-1] + abs(stage[i] - stage[i-1]), DP[i-2] + abs(stage[i] - stage[i-2]))

print(DP[N-1])

Buggy submission (verdict: Runtime Error):
def main():
  n = int(input())
  mod = 10**9+7
  a = []
  for i in range(n):
    a.extend(list(map(int,input().split())))
  dp = [0]*(1<<n)
  dp[0] = 1
  for S in range((1<<n)-1):
    k = bin(S).count("1")*n
    t = dp[S]
    for i in range(n):
      if a[k+i]:
        dp[S|1<<i] = (dp[S|1<<i]+t)%mod
  print(dp[(1<<n)-1])
main()
Problem p03161 (python)

Fixed submission:
N, K = map(int,input().split(' '))
stage = list(map(int, input().split(" ")))

INF = float('inf')
DP = [INF for i in range(N)]
#DP[0] = 0


for i in range(N):
    candidate = [INF for i in range(K)]
    if i == 1:
        DP[i] = abs(stage[i] - stage[i-1])
    elif i > 1:
        for j in range(min(K+1,i+1)):
            if i == j:
                candidate[0] = (abs(stage[i]-stage[0]))
            else:
                candidate[K-1-j]=(DP[i-j] + abs(stage[i]-stage[i-j]))
        DP[i] = min(candidate)

print(DP[N-1])

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

INF = float('inf')
DP = [INF for i in range(N)]
#DP[0] = 0
candidate = []

for i in range(N):
    if i == 1:
        DP[i] = abs(stage[i] - stage[i-1])
    elif i > 1:
        for j in range(min(K+1,i+1)):
            if i == j:
                candidate.append(abs(stage[i]-stage[0]))
            else:
                candidate.append(DP[i-j] + abs(stage[i]-stage[i-j]))
        DP[i] = min(candidate)
        candidate.clear()

print(DP[N-1])
Problem p03196 (python)

Fixed submission:
from collections import Counter
def prm(a):
  if a == 1 or a == 4:
    return False
  for i in range(2,int((a)**0.5+1)):
    if a%i == 0:
      return False
  else:
    return True
prime = []
for i in range(1,10**6+1):
  if prm(i):
    prime.append(i)
def sepa(a):
  ans = []
  while a>1:
    for x in prime:
      if a%x == 0:
        ans.append(x)
        a = a//x
        break
    else:
      ans.append(a)
      a = 1
  return Counter(ans)
n,p = map(int,input().split())
c = sepa(p)
ans = 1
for k,v in c.items():
  if n<=v:
    ans *= k**(v//n)
print(ans)

Buggy submission (verdict: Runtime Error):
def prm(a):
  if a == 1 or a == 4:
    return False
  for i in range(2,int((a)**0.5+1)):
    if a%i == 0:
      return False
  else:
    return True
prime = []
for i in range(1,10**6+1):
  if prm(i):
    prime.append(i)
def sepa(a):
  ans = []
  while a>1:
    for x in prime:
      if a%x == 0:
        ans.append(x)
        a = a//x
        break
    else:
      ans.append(a)
      a = 1
  return Counter(ans)
n,p = map(int,input().split())
c = sepa(p)
ans = 1
for k,v in c.values():
  if n<=v:
    ans *= k**(v//n)
print(ans)
Problem p03203 (python)

Fixed submission:
h,w,n=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(n)]
xy.sort()
cnt=0
ans=h
for x,y in xy:
  if x-1>=y+cnt:
    ans=x-1
    break
  elif x==y+cnt:
    cnt+=1
print(ans)

Buggy submission (verdict: Runtime Error):
h,w,n=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(n)]
xy.sort()
cnt=0
ans=h
for i in range(n):
  if x-1>=y+cnt:
    ans=x-1
    break
  elif x==y+cnt:
    cnt+=1
print(ans)
Problem p03210 (python)

Fixed submission:
n = int(input())
if n == 7 or n == 5 or n == 3:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
n = int(input())
if n == 7 or n == 5 or n == 3:
    print(YES)
else:
    print(NO)

Buggy submission (verdict: Runtime Error):
n = int(input())
if n == 7 or n == 5 or n == 3:
  print(YES)
else:
  print(NO)
Problem p03213 (python)

Fixed submission:
from collections import defaultdict

N = int(input())
prime = [2,3,5,7,11,13,17,19,23,29,31,37,41,
        43,47,53,59,61,67,71,73,79,83,89,97]
ans = 0
factor = defaultdict(int)
for i in range(1,N+1):
    for j in prime:
        while i != 1:
            if i % j == 0:
                factor[j] += 1
                i = i // j
            else:
                break

fact_l = list(dict(factor).items())
fact_l.sort()
n_74 = 0
n_24 = 0
n_14 = 0
n_4 = 0
n_2 = 0
for i, x in enumerate(fact_l):
    if x[1] >= 74:
        n_74 = i + 1
    if x[1] >= 24:
        n_24 = i + 1
    if x[1] >= 14:
        n_14 = i + 1
    if x[1] >= 4:
        n_4 = i + 1
    if x[1] >= 2:
        n_2 = i + 1

print(n_74+(n_24*(n_2-1))+(n_14*(n_4-1))+(n_4*(n_4-1)*(n_2-2)//2))

Buggy submission (verdict: Runtime Error):
from collections import defaultdict

N = int(input())
prime = [2,3,5,7,11,13,17,19,23,29,31,37,41,
        43,47,53,59,61,67,71,73,79,83,89,97]
ans = 0
factor = defaultdict(int)
for i in range(1,N+1):
    for j in prime:
        while i != 1:
            if i % j == 0:
                factor[j] += 1
                i = i // j
            else:
                break

fact_l = list(dict(factor).items())
for i, x in enumerate(fact_l):
    if x[1] >= 74:
        n_74 = i + 1
    if x[1] >= 24:
        n_24 = i + 1
    if x[1] >= 14:
        n_14 = i + 1
    if x[1] >= 4:
        n_4 = i + 1
    if x[1] >= 2:
        n_2 = i + 1

print(n_74+n_24*(n_2-1)+n_14*(n_4-1)+n_4*(n_4-1)*(n_2-2)//2)
Problem p03214 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
avg = sum(a)/n
difmin = 10**18
for i in range(n):
  if difmin>abs(a[i]-avg):
    difmin = abs(a[i]-avg)
    ans = i
print(ans)

Buggy submission (verdict: Runtime Error):
from itertools import accumulate,combinations
n,k = map(int,input().split())
a = list(map(int,input().split()))
acc = [0]+list(accumulate(a))
ls = []
for i,j in combinations(acc,2):
  ls.append(j-i)
x = max(ls).bit_length()
ans = 0
for i in range(x-1,-1,-1):
  cnt = 0
  for j in ls:
    if ans+2**i & j == ans+2**i:
      cnt += 1
  if cnt >= k:
    ans += 2**i
print(ans)
Problem p03227 (python)

Fixed submission:
s=input()
if len(s) == 2:
  print(s)
else:
  print(s[::-1])

Buggy submission (verdict: Runtime Error):
n = int(input())
for i in range(10**3):
    if n == i*(i+1)//2:
        x = i
        break
else:
    print("No")
    exit()
ans = [[] for i in range(x+1)]
app = 0
for i in range(1,x+1):
    for j in range(i):
        app += 1
        ans[j].append(app)
    ans[i].extend([k for k in range(i*(i-1)//2+1,i*(i+1)//2+1)])
print("Yes")
print(x+1)
for ansarr in ans:
    print(x, *ansarr, sep = " ")
Problem p03231 (python)

Fixed submission:
from fractions import gcd
n,m = map(int,input().split())
s = input()
t = input()
x = gcd(n,m)
for i in range(x):
  if s[i*n//x]!=t[i*m//x]:
    print(-1)
    break
else:
  print(n*m//x)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
n,m = map(int,input().split())
s = input()
t = input()
x = gcd(n,m)
for i in range(x+1):
  if s[i*n//x]!=t[i*m//x]:
    print(-1)
    break
else:
  print(n*m//x)
Problem p03233 (python)

Fixed submission:
import sys
input = sys.stdin.readline
import bisect
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]
both = []
for i in range(n):
  both.extend(ab[i])
both.sort()
ans = 10**18
sm = sum(both[:n])
for i in range(n):
  ai = bisect.bisect_left(both,ab[i][0])
  bi = bisect.bisect_left(both,ab[i][1])
  if ai < n and bi < n:
    ans = min(ans,sm)
  elif ai < n-1:
    ans = min(ans,sm-both[n-1]+ab[i][1])
  elif ai == n-1:
    ans = min(ans,sm-both[n-2]+ab[i][1])
  elif bi < n-1:
    ans = min(ans,sm-both[n-1]+ab[i][0])
  elif bi == n-1:
    ans = min(ans,sm-both[n-2]+ab[i][0])
  else:
    ans = min(ans,sm-both[n-1]-both[n-2]+sum(ab[i]))
a,b = list(zip(*ab))
ans = min(ans,sum(a),sum(b))
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline
import bisect
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]
both = []
for i in range(n):
  both.extend(ab[i])
both.sort()
ans = 10**18
sm = sum(both[:n])
for i in range(n):
  ai = bisect.bisect_left(both,ab[i][0])
  bi = bisect.bisect_left(both,ab[i][1])
  if ai < n and bi < n:
    ans = min(ans,sm)
  elif ai < n:
    ans = min(ans,sm-both[n-1]+ab[i][1])
  elif bi < n:
    ans = min(ans,sm-both[n-1]+ab[i][0])
  else:
    ans = min(ans,sm-both[n-1]-both[n-2]+sum(ab[i]))
a,b = list(zip(*ab))
ans = min(ans,sum(a),sum(b))
if ans != sm:
  print(2/0)
else:
  print(ans)
Problem p03238 (python)

Fixed submission:
if int(input())==1:
  print("Hello World")
else:
  print(int(input())+int(input()))

Buggy submission (verdict: Runtime Error):
N,T=map(int,input().split())
ls=[int(input()) for _ in range(N)]
ans=10**18
for i in ls:
  if i[0] <= T:
    ans = min(ans,i[1])
if ans < 10**18:
  print(ans)
else:
  print('TLE')
Problem p03239 (python)

Fixed submission:
N,T=map(int,input().split())
ls=[list(map(int,input().split())) for _ in range(N)]
ans=10**18
for i in ls:
  if i[1] <= T:
    ans = min(ans,i[0])
if ans < 10**18:
  print(ans)
else:
  print('TLE')

Buggy submission (verdict: Runtime Error):
N,T=map(int,input().split())
ls=[int(input()) for _ in range(N)]
ans=10**18
for i in ls:
  if i[1] <= T:
    ans = min(ans,i[0])
if ans < 10**18:
  print(ans)
else:
  print('TLE')

Buggy submission (verdict: Runtime Error):
N,T=map(int,input().split())
ls=[int(input()) for _ in range(N)]
ans=10**18
for i in ls:
  if i[0] <= T:
    ans = min(ans,i[1])
if ans < 10**18:
  print(ans)
else:
  print('TLE')

Buggy submission (verdict: Runtime Error):
N,T=map(int,input().split())
ls=[int(input()) for _ in range(N)]
ans=10**18
for c,t in ls:
  if t <= T:
    ans = min(ans,c)
if ans < 10**18:
  print(ans)
else:
  print('TLE')

Buggy submission (verdict: Runtime Error):
N,T=map(int,input().split())
ls=[int(input()) for _ in range(N)]
ans='TLE'
for c,t in ls:
  if t <= T:
    ans = min(ans,c)
    
print(ans)
Problem p03241 (python)

Fixed submission:
N,M=map(int,input().split())
d=[]
for i in range(1,int(M**0.5+1)):
  if M%i == 0:
    d. append(i)
    d.append(M//i)
dd=list(set(d))
dd.sort()
for x in dd:
  if x>=N:
    print(M//x)
    break

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
d=[]
for i in range(1,int(M**0.5+1)):
  if M%i == 0:
    d.extend(i,M//i)
d=list(set(d)).sort()
for x in d:
  if x>=N:
    print(M//x)
    break
Problem p03262 (python)

Fixed submission:
import fractions
from functools import reduce

N, X = map(int, input().split(' '))
city = list(map(int, input().split(' ')))
for i in range(N):
    city[i] = abs(city[i] - X)
    
def gcd(numbers):
    return reduce(fractions.gcd, numbers)

if N == 1:
    ans = city[0]
else:
    ans = gcd(city)

print(ans)

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

N, X = map(int, input().split(' '))
city = list(map(int, input().split(' ')))
for i in range(N):
    city[i] = city[i] - X
    
def gcd(numbers):
    return reduce(math.gcd, numbers)

if N == 1:
    ans = city[0]
else:
    ans = gcd(city)

print(ans)
Problem p03270 (python)

Fixed submission:
mod = 998244353
rng = 4100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod
def homo(n,k):
  if n<0 or k<=0:
    return 0
  else:
    return cmb(n+k-1,k-1)
k,n = map(int,input().split())
if k%2 == 0:
  flg = 0
else:
  flg = 1
ans = []
for i in range(3,k+2,2):
  ic = (i-1)//2
  anstmp = 0
  for j in range(ic+1):
    t = homo(n-j,(k-ic*2+j))*cmb(ic,j)*pow(2,j,mod)
    anstmp = (anstmp+t)%mod
  ans.append(anstmp)
  ans.append(anstmp)
if flg:
  anstmp = 0
  for j in range(1,k//2+1):
    t = (homo(n-j,j)+homo(n-j-1,j))*cmb(k//2,j)*pow(2,j,mod)
    anstmp = (anstmp+t)%mod
  ans.append(anstmp)
ans2 = ans[:-1]
ans2 = ans2[::-1]
print(*ans,sep="\n")
print(*ans2,sep="\n")

Buggy submission (verdict: Runtime Error):
mod = 998244353
rng = 4100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod
def homo(n,k):
  if n<0 or k<=0:
    return 0
  else:
    return cmb(n+k-1,k-1)
k,n = map(int,input().split())
if k%2 == 0:
  flg = 0
else:
  flg = 1
ans = []
for i in range(3,k+2,2):
  ic = (i-1)//2
  anstmp = 0
  for j in range(ic+1):
    t = homo(n-j,(k-ic*2+j))*cmb(ic,j)*pow(2,j,mod)
    anstmp = (anstmp+t)%mod
  ans.append(anstmp)
  ans.append(anstmp)
if flg:
  anstmp = 0
  for j in range(1,k//2+1):
    t = (homo(n-j,j)*homo(n-j-1,j+1))*cmb(k//2,j)*pow(2,j,mod)
    anstmp = (anstmp+t)%mod
  ans.append(anstmp)
ans2 = ans[:-1]
ans2 = ans2[::-1]
print(*ans,*ans2,sep="\n")

Buggy submission (verdict: Runtime Error):
mod = 998244353
rng = 2100
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod
def homo(n,k):
  if n<0 or k<=0:
    return 0
  else:
    return cmb(n+k-1,k-1)
k,n = map(int,input().split())
if k%2 == 0:
  flg = 0
else:
  flg = 1
ans = []
for i in range(3,k+2,2):
  ic = (i-1)//2
  anstmp = 0
  for j in range(ic+1):
    t = homo(n-j,(k-ic*2+j))*cmb(ic,j)*pow(2,j,mod)
    anstmp = (anstmp+t)%mod
  ans.append(anstmp)
  ans.append(anstmp)
if flg:
  anstmp = 0
  for j in range(1,k//2+1):
    t = (homo(n-j,j)*homo(n-j-1,j+1))*cmb(k//2,j)*pow(2,j,mod)
    anstmp = (anstmp+t)%mod
  ans.append(anstmp)
ans2 = ans[:-1]
ans2 = ans2[::-1]
print(*ans,*ans2,sep="\n")
Problem p03273 (python)

Fixed submission:
h,w = map(int,input().split())
a=[list(input()) for i in range(h)]
b=[]
dl=[]
for i in a:
  if "#" in i:
    b.append(i)
for j in range(w):
  for i in range(len(b)):
    if b[i][j] == "#":
      break
    elif i == len(b)-1:
      dl.append(j)
dl.sort(reverse=True)
for i in dl:
  for j in range(len(b)):
    del b[j][i]
for c in b:
  print(*c,sep="")

Buggy submission (verdict: Runtime Error):
a=[input() for i in range(h)]
b=[]
for i in a:
  if "#" in i:
    b.append(i)
for i in range(w):
  for j in range(len(b)):
    if b[j][i] == "#":
      break
    elif j == len(b)-1:
      for k in range(len(b)):
        print(b[k][:i],b[k][i+1:],sep="")

Buggy submission (verdict: Runtime Error):
h,w = map(int,input().split())
a=[input() for i in range(h)]
b=[]
c=[]
for i in a:
  if "#" in i:
    b.append(i)
for i in range(w):
  for j in range(len(b)):
    if b[j][i] == "#":
      break
    elif j = h-1:
      for k in b:
        del k[j]
print(b)
Problem p03274 (python)

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

INF = float('inf')
ans = INF

if N == K:
    ans = abs(a[N-1]-a[0])+min(abs(a[0]), abs(a[N-1]))
else:
    for i in range(N-K+1):
        ans = min(ans, abs(a[i+K-1]-a[i])+min(abs(a[i+K-1]), abs(a[i])))

print(ans)

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

INF = float('inf')
ans = INF

if N == K:
    ans = min(ans, abs(a[N]-a[0])+min(abs(a[0]), abs(a[N])))
else:
    for i in range(N-K):
        ans = min(ans, abs(a[i+K-1]-a[i])+min(abs(a[i+K-1]), abs(a[i])))

print(ans)
Problem p03293 (python)

Fixed submission:
s=list(input())
t=list(input())
for i in range(len(s)+1):
  if s == t:
    print("Yes")
    break
  else:
    k = s[0]
    for i in range(len(s)-1):
      s[i]=s[i+1]
    s[-1] = k
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s=input()
t=input()
for i in range(len(s)+1):
  if s == t:
    print("Yes")
    break
  else:
    k = s[0]
    for i in range(len(s)-1):
      s[i]=s[i+1]
    s[-1] = k
else:
  print("No")
Problem p03313 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
dp = [[0,0] for i in range(1<<n)]
def merge(ls1,ls2):
  p,q = ls1
  r,s = ls2
  ret = [max(p,r)]
  if p>r:
    ret.append(max(q,r))
  else:
    ret.append(max(p,s))
  return ret
for i in range(1<<n):
  dp[i][0] = a[i]
for i in range(n):
  for j in range(1<<n):
    if 1<<i & j:
      dp[j] = merge(dp[j],dp[1<<i^j])
ans = [0 for i in range(2**n)]
for i in range(1,1<<n):
  ans[i] = max(ans[i-1],sum(dp[i]))
for i in ans:
  if i:
    print(i)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
dp = [[0,0] for i in range(1<<n)]
def merge(ls1,ls2):
  p,q,r,s = *ls1,*ls2
  ret = [max(p,r)]
  if p>r:
    ret.append(max(q,r))
  else:
    ret.append(max(p,s))
  return ret
for i in range(1<<n):
  dp[i][0] = a[i]
for i in range(n):
  for j in range(1<<n):
    if 1<<i & j:
      dp[j] = merge(dp[j],dp[1<<i^j])
ans = [0 for i in range(2**n)]
for i in range(1,1<<n):
  ans[i] = max(ans[i-1],sum(dp[i]))
for i in ans:
  if i:
    print(i)
Problem p03316 (python)

Fixed submission:
N = int(input())
wals = list(str(N))
wals = [int(s) for s in wals]
wa = sum(wals)

if N % wa == 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())
for i in range(12):
wa = 0
  if N // 10 ** i == 0:
    break
  else:
    wa += N // 10 ** i

if N % wa == 0:
  print("Yes")
else:
  print("No")
Problem p03331 (python)

Fixed submission:
n=input()
ls = [10**i for i in range(1,6)]
if int(n) in ls:
  print(10)
else:
  print(sum([int(list(n)[i]) for i in range(len(n))]))

Buggy submission (verdict: Runtime Error):
n=input()
ls = [10**i for i in range(1,6)]
if int(n) in ls:
  print(10)
else:
  print(sum([list(n)[i] for i in range(len(n))]))
Problem p03353 (python)

Fixed submission:
s = input()
N = len(s)
K = int(input())
word = []
for i in range(N):
    for j in range(i, min(N, i+K)):
        word.append(s[i:j+1])

word.sort()
word_set = list(set(word))
word_set.sort()
print(word_set[K-1])

Buggy submission (verdict: Runtime Error):
s = input()
N = len(s)
K = int(input())
word = []
for i in range(N):
    for j in range(i, N):
        word.append(s[i:j+1])

word.sort()
print(word[K])
Problem p03361 (python)

Fixed submission:
h,w=map(int,input().split())
a=[]
for i in range(h):
  a.append(list("."+(input())+"."))
a.insert(0,["."]*(w+2))
a.append(["."]*(w+2))
flg = True
for i in range(h+2):
  for j in range(w+2):
    if a[i][j] == "#":
      for (k,l) in ((i,j+1),(i,j-1),(i+1,j),(i-1,j)):
        if a[k][l] != "#":
          cnt+=1
          if cnt == 4:
            flg = False
    cnt=0
if flg:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
h,w=map(int,input().split())
a=[]
for i in range(h):
  a.append(list("."+(input())+"."))
a.insert(0,["."]*(h+2))
a.append(["."]*(h+2))
flg = True
for i in range(h+2):
  for j in range(w+2):
    if a[i][j] == "#":
      for (k,l) in ((i,j+1),(i,j-1),(i+1,j),(i-1,j)):
        if a[k][l] != "#":
          cnt+=1
          if cnt == 4:
            flg = False
    cnt=0
if flg:
  print("Yes")
else:
  print("No")
Problem p03370 (python)

Fixed submission:
n,x=map(int,input().split())
a=[int(input()) for i in range(n)]
print(n+(x-sum(a))//min(a))

Buggy submission (verdict: Runtime Error):
n,x=map(int,input().split())
a=[int(input()) for i in range(n)]
print(n+(x-sum(a))//min(a)]