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

Fixed submission:
n,x=map(int,raw_input().split())
m=[int(raw_input()) for j in xrange(n)]
m.sort()

cnt = n
x -= sum(m)
cnt += x / m[0]

print cnt

Buggy submission (verdict: Runtime Error):
n,x=map(int,raw_input().split())
m=[int(raw_input()) for xrange(n)]
m.sort()

cnt = n
x -= sum(m)
cnt += x / m[0]

print cnt
Problem p03385 (python)

Fixed submission:
if ''.join(sorted(raw_input())) == 'abc':
  print 'Yes'
else:
  print 'No'

Buggy submission (verdict: Runtime Error):
if ''.join((sorted(raw_input())) == 'abc':
  print 'Yes'
else:
  print 'No'
Problem p03486 (python)

Fixed submission:
s=raw_input()
t=raw_input()
sa=''.join(sorted(s))
tz=''.join(sorted(t,reverse=True))
if sa < tz:
  print 'Yes'
else:
  print 'No'

Buggy submission (verdict: Runtime Error):
s=raw_input()
t=raw_input()
sa=''.join(sorted(s))
tz=''.join(sorted(t,reverse=True))
if sa < tz:
  print 'Yes'
else:
  pritn 'No'
Problem p03494 (python)

Fixed submission:
N=int(raw_input())
A=map(int,raw_input().split())
def f(x):
  cnt = 0
  while x >= 2 and x % 2 == 0:
    x /= 2
    cnt += 1
  return cnt
C=map(f,A)
print min(C)

Buggy submission (verdict: Runtime Error):
N=int(raw_input())
A=map(int,raw_input().split())
def f(x):
  cnt = 0
  while x >= 2:
    x /= 2
    cnt += 1
  return cnt
C=map(f,A)
pritn min(C)
Problem p03970 (python)

Fixed submission:
s=raw_input()
t='CODEFESTIVAL2016'
c=0
for i in range(16):
  if s[i] != t[i]:
    c += 1
print c

Buggy submission (verdict: Runtime Error):
s=raw_input()
t='CODEFESTIVAL2016'
c=0
for i in range(16);
  if s[i] != t[i]:
    c += 1
print c
Problem p03998 (python)

Fixed submission:
def solve(s):
  turn = 'a'
  while True:
    if len(s[turn]) == 0:
      return turn.upper()
    nxt, s[turn] = s[turn][0], s[turn][1:]
    turn = nxt

s = {}
s['a']=raw_input()
s['b']=raw_input()
s['c']=raw_input()
print solve(s)

Buggy submission (verdict: Runtime Error):
s = {}
s['a']=raw_input()
s['b']=raw_input()
s['c']=raw_input()
def solve(s):
  turn = 'a'
  while True:
    if len(s[turn]) == 0:
      return turn.upper()
    nxt, s[turn] = s[turn][0], s[turn][1:]
   	turn = nxt
print solve(s)

Buggy submission (verdict: Runtime Error):
s = {}
s['a']=raw_input()
s['b']=raw_input()
s['c']=raw_input()
def solve(s):
  turn = 'a'
  while True:
    nxt, s[turn] = s[turn][0], s[turn][1:]
    if len(s[turn]) == 0:
      return turn.upper()
   	turn = nxt
print solve(s)
Problem p02687 (python)

Fixed submission:
S = input()

if S == 'ABC':
  S = 'ARC'
else:
  S = 'ABC'
  
print(S)

Buggy submission (verdict: Runtime Error):
if S == 'ABC':
  S = 'ARC'
else:
  S = 'ABC'
  
print(S)
Problem p03281 (python)

Fixed submission:
N = int(input())

ans = 0
for n in range(1,int(N/2)+1):
    if 2*n+1 > N:
        break
    for i in range(1,int(N**(1/2)/2)+1):
        for j in range(i+1,int(N**(1/2)/2)+1):
            for k in range(j+1,int(N**(1/2)/2)+1):
                if 2*n+1 == (2*i+1)*(2*j+1)*(2*k+1):
                    ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import sympy

N = int(input())

ans = 0
for i in range(1, int(N/2)+1):
    if len(sympy.divisors(2*i+1))==8:
        ans += 1

print(ans)
Problem p03544 (python)

Fixed submission:
N = int(input())

if N == 0:
    print(2)
    exit()
elif N == 1:
    print(1)
    exit()

L_2 = 2
L_1 = 1
for i in range(N-1):
    L = L_1+L_2
    L_2 = L_1
    L_1 = L
print(L)

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

L_2 = 2
L_1 = 1
for i in range(N-1):
    L = L_1+L_2
    L_2 = L_1
    L_1 = L
print(L)
Problem p03607 (python)

Fixed submission:
N = int(input())
num = {}
for i in range(N):
    A = int(input())
    if A in num.keys():
        num[A] += 1
    else:
        num[A] = 1
ans = 0
for i, j in num.items():
    if j%2 == 1:
        ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
ans = []
for i in range(N):
    A = int(input())
    if A in ans:
        ans.append(A)
    else:
        ans.remove(A)
print(len(ans))
Problem p03697 (python)

Fixed submission:
A, B = map(int,input().split())
if A+B >= 10:
    print('error')
else:
    print(A+B)

Buggy submission (verdict: Runtime Error):
A, B = map(int,input(),split())
if A+B >= 10:
  print('error')
else:
  print(A+B)
Problem p02586 (python)

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

V = [[0]*(C+1) for _ in range(R+1)]
for _ in range(K):
    r, c, v = map(int, input().split())
    V[r][c] = v

pre = [[0]*(3+1) for _ in range(C+1)]
for i in range(R+1):
    now = [[0]*(3+1) for _ in range(C+1)]
    for j in range(C+1):
        for k in range(3+1):
            if i-1 >= 0:
                now[j][0] = max(now[j][0], pre[j][k])
                now[j][1] = max(now[j][1], pre[j][k] + V[i][j])

            if j-1 >= 0:
                now[j][k] = max(now[j][k], now[j-1][k])
                if k-1 >= 0:
                    now[j][k] = max(now[j][k], now[j-1][k-1] + V[i][j])
    pre = now

print(max(now[C]))

Buggy submission (verdict: Runtime Error):
R, C, K = map(int, input().split())
# print(R,C,K)

# vis = [[False]*C for _ in range(R)]
mesh = [[0]*C for _ in range(R)]

for _ in range(K):
    r, c, v = map(int, input().split())
    mesh[r-1][c-1] = v

# print(vis)
# print(*mesh,sep='\n')

def dfs(i, j, rows):
    # print('i {} j {} rows {}'.format(i,j,rows))
    # print('i {} j {}'.format(i,j))
    # print(*rows,sep='\n')

    v = 0
    if i == R-1 and j == C-1:
        rows[i].append(mesh[i][j])
        # print('rows {}'.format(rows))
        import heapq
        for row in rows:
            r = []
            for x in row:
                heapq.heappush(r, -x)
            if len(r): v += -heapq.heappop(r)
            if len(r): v += -heapq.heappop(r)
            if len(r): v += -heapq.heappop(r)
        rows[i].pop()
        return v
    if i == R or j == C: return v
    # if vis[i][j]: return v
    # vis[i][j] = True
    rows[i].append(mesh[i][j])
    if j+1 < C: v = dfs(i,   j+1, rows)
    if i+1 < R: v = max(v, dfs(i+1, j  , rows))
    rows[i].pop()
    return v

ans = dfs(0, 0, [[] for _ in range(R)])
print(ans)
Problem p02602 (python)

Fixed submission:
n, k = map(int, input().split())
A = [*map(int, input().split())]
for i in range(k, n):
    if A[i-k] < A[i]: print('Yes')
    else: print('No')

Buggy submission (verdict: Runtime Error):
r, g, b = map(int, input().split())
t = 0
while r >= g: g *= 2; t += 1
while g >= b: b *= 2; t += 1
print('No' if t > int(input()) else 'Yes')
Problem p02609 (python)

Fixed submission:
from logging import *
basicConfig(level=DEBUG, format='%(levelname)s: %(message)s')
disable(CRITICAL)

n = int(input())
X = input()
debug('n {}'.format(n))
debug('X {}'.format(X))
po = X.count('1')

# if po == 0:
#     print(0)
#     exit()

pp = po + 1
pm = max(1, po - 1)

rp = 0
rm = 0
for x in X:
    rp = (rp*2 + int(x)) % pp
    rm = (rm*2 + int(x)) % pm

bp = [0]*(n) # 2^i % (po+1)
bm = [0]*(n) # 2^i % (po-1)
bp[n-1] = 1 % pp
bm[n-1] = 1 % pm
for i in range(n-1,0,-1):
    bp[i-1] = bp[i]*2 % pp
    bm[i-1] = bm[i]*2 % pm

debug('po {}'.format(po))
debug('pp {}'.format(pp))
debug('pm {}'.format(pm))
debug('rp {}'.format(rp))
debug('rm {}'.format(rm))
debug('bp {}'.format(bp))
debug('bm {}'.format(bm))
debug('===')

def popcount(x):
    c = 0
    while x > 0:
        if x & 1: c += 1
        x //= 2
    return c

def f(x):
    if x==0: return 0
    return f(x % popcount(x)) + 1

for i in range(n):
    if X[i] == '0':
        ri = (rp + bp[i]) % pp
    else: # '1'
        if po-1 != 0: ri = (rm - bm[i]) % pm
        else:
            print(0)
            continue
    debug('i {} ri {}'.format(i,ri))
    c = f(ri) + 1
    debug('c {}'.format(c))
    print(c)

Buggy submission (verdict: Runtime Error):
from logging import *
basicConfig(level=DEBUG, format='%(levelname)s: %(message)s')
disable(CRITICAL)

n = int(input())
# X = [int(x) for x in input()]
X = input()
debug('n {}'.format(n))
debug('X {}'.format(X))
po = X.count('1')
ro = 0
rp = 0
rm = 0
for x in X:
    ro = (ro*2 + int(x)) % (po)
    rp = (rp*2 + int(x)) % (po+1)
    rm = (rm*2 + int(x)) % (po-1)

b = [0]*(n) # 2^i
bp = [0]*(n) # 2^i % (po+1)
bm = [0]*(n) # 2^i % (po-1)
b[n-1] = 1 % (po)
bp[n-1] = 1 % (po+1)
bm[n-1] = 1 % (po-1)
for i in range(n-1,0,-1):
    # debug('i {}'.format(i))
    b[i-1] = b[i]*2%(po)
    bp[i-1] = bp[i]*2%(po+1)
    bm[i-1] = bm[i]*2%(po-1)

debug('po {}'.format(po))
debug('ro {}'.format(ro))
debug('rp {}'.format(ro))
debug('rm {}'.format(ro))
debug('b {}'.format(b))
debug('bp {}'.format(bp))
debug('bm {}'.format(bm))
debug('===')

def popcount(x):
    c = 0
    while x > 0:
        if x & 1: c += 1
        x //= 2
    return c

def f(x):
    if x==0: return 0
    return f(x % popcount(x)) + 1

for i in range(n):
    if X[i] == '0':
        ri = (rp + bp[i]) % (po+1)
    else: # '1'
        ri = (rm - bm[i]) % (po-1)
    debug('ri {}'.format(ri))
    c = f(ri) + 1
    debug('c {}'.format(c))
    print(c)
Problem p02780 (python)

Fixed submission:
# D - Dice in Line
n,k = map(int,input().split())
p = [0]*k + list(map(int,input().split()))
ans = sum = 0
for i in range(n):
    sum += p[i+k] - p[i]
    ans = max(ans, sum)
print((ans+k)/2)

Buggy submission (verdict: Runtime Error):
# D - Dice in Line
n,k = map(int,input().split())
p = [0]*k + [*map(int,input().split())]
ans = sum = 0
for i in range(n):
    sum += p[i+k] - p[i]
    ans = max(ans, sum)
print((ans+k)/2)
Problem p02814 (python)

Fixed submission:
from fractions import gcd
from functools import reduce
def lcm(a, b):return a//gcd(a,b)*b

def f(x):
    c = 0
    while x%2==0:
        x //= 2
        c += 1
    return c

n,m = map(int, input().split())
a = list(map(lambda x:int(x)//2, input().split()))
t = f(a[0])
m >>= t
l = 1
for x in a:
    if f(x) != t:
        print(0)
        quit()
    x >>= t
    l = l // gcd(l,x) * x
    if l > m:
        print(0)
        quit()

print((m//l+2-1)//2) # round up

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

def lcm(a, b):return a//gcd(a,b)*b
def lcm_list(x): return reduce(lcm, x)
def gcd_list(x): return reduce(gcd, x)

n,m = map(int, input().split())
a = [*map(lambda x: int(x)//2 , input().split())]
l = lcm_list(a)
if l <= m:
    print((m//l+2-1)//2) # round up
else:
    print(0)
Problem p02882 (python)

Fixed submission:
# D - Water Bottle
from math import atan, degrees
a,b,x = map(float, input().split())
s = x/a
print( degrees( atan( b/(s/b*2) if s<a*b/2 else (b-s/a)*2/a ) ) )

Buggy submission (verdict: Runtime Error):
// D - Water Bottle
#include <bits/stdc++.h>
using namespace std;
using dbl = double;
#define PI (M_PI)
#define DEG(rad) ((rad)*180/PI)
#define EPS (0.000000001) // 誤差範囲

dbl f(dbl a, dbl b, dbl rad){//rad 傾けたとき a*a*b の容器にあふれずに入れられる水の量は？
	if(PI/2 - rad < EPS) return 0.0;//誤差範囲で90°といえるなら0を返す
	dbl c = tan(rad);//rad 傾けてみる
	//入れられる水の量: b/a(45°)以下？ yes:容器の体積-空き容量(横から見て、奥行き*△) no:奥行き*△
	return c<=b/a? a*a*b - a*(a*(a*c)/2): a*(b*(b/c)/2);
}

dbl solve(dbl a, dbl b, dbl x){
	dbl ok = PI/2;
	dbl ng = 0;
	dbl volume = 0;
	while(abs(x - volume) >= EPS){
		dbl mid = (ok+ng)/2;// mid: この角度でどれだけ水を入れられるか？
		volume = f(a,b,mid);
		if(volume <= x) ok = mid;// 角度を小さくして、もっと多く入るようにする
		else ng = mid;// 角度を大きくして、もっと少なく入るようにする
	}
	return ok;
}

int main(){
	dbl a,b,x; cin>>a>>b>>x;
	printf("%.10f\n", DEG(solve(a, b, x)));
}

Buggy submission (verdict: Runtime Error):
// D - Water Bottle
#include <bits/stdc++.h>
using namespace std;
using dbl = double;

int main(){
	dbl a,b,x; cin>>a>>b>>x;
	dbl s = x/a;
	dbl h = b, w = a;
	if(s < a*b/2) w = s/b*2;
	else h = (b-s/a)*2;
	printf("%.10f\n", atan2(h, w)*180/M_PI);
}
Problem p02886 (python)

Fixed submission:
N = int(input())
# D = [*map(int,input().split())]
D = [d for d in map(int,input().split())]
ans = 0
# for i in range(N-1):
#     for j in range(i+1,N):
for j in range(N):
    for i in range(j):
        ans += D[i] * D[j]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
D = [*map(int,input().split())]
ans = 0
for i in range(N-1):
    for j in range(i+1,N):
# for j in range(N):
#     for i in range(j):
        ans += D[i] * D[j]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
D = [*map(int,input().split())]
ans = 0
# for i in range(N-1):
#     for j in range(i+1,N):
for j in range(N):
    for i in range(j):
        ans += D[i] * D[j]
print(ans)
Problem p03353 (python)

Fixed submission:
s = input()
k = int(input())
n = len(s)

# print('s',s,'k',k)
c = set()
for i in range(n):
    # print(s[i:i+5])
    t = s[i:i+5]
    for j in range(1,5+1):
        # print(t[:j])
        c.add(t[:j])

c = list(c)
c.sort()
# print(*c,sep='\n')
print(c[k-1])

Buggy submission (verdict: Runtime Error):
s = input()
k = int(input())
n = len(s)
# print(s,k,n)

c = set()
for i in range(n-1):
    for j in range(i+1, n+1):
        c.add(s[i:j])

c=list(c)
# print(c)
c.sort()
# print(c)

if len(c) > 0: print(c[k-1])
else: print(s)
Problem p02579 (python)

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

from collections import deque

H, W = map(int,input().split())
sth, stw = map(int,input().split())
glh, glw = map(int,input().split())
sth, stw = sth-1, stw-1
glh, glw = glh-1, glw-1

INF = -1
Gmap = [list(input()) for _ in range(H)]
seen = [[INF]*W for _ in range(H)]
direc = {(1,0), (-1,0), (0,1), (0,-1)}
direc5 = set([])
for i in range(-2,3):
    for j in range(-2,3):
        direc5.add((i, j))
direc5 = direc5 - direc
direc5 = direc5 - {(0,0)}

def bfs(pnxt):
    next_q = deque([])
    for h, w in pnxt:
        next_q.append((h,w))
        seen[h][w] = 0
    nxt = set([])
    while len(next_q)!=0:
        h, w = next_q.popleft()
        if h == glh and w == glw:
            print(ret)
            exit()
        for dh, dw in direc:
            hs, ws = h + dh, w + dw
            if not (0<=hs<H and 0<=ws<W):
                continue
            if Gmap[hs][ws]=='.' and seen[hs][ws]==INF:
                next_q.append((hs, ws))
                seen[hs][ws] = 0
        for dh, dw in direc5:
            hs, ws = h + dh, w + dw
            if not (0<=hs<H and 0<=ws<W):
                continue
            if Gmap[hs][ws]=='.' and seen[hs][ws]==INF and not (hs, ws) in nxt:
                nxt.add((hs, ws))
    return nxt

ret = 0
nxt_st = set([])
nxt_st.add((sth, stw))
while len(nxt_st)>0:
    nxt_st = bfs(nxt_st)
    ret += 1
print(-1)

Buggy submission (verdict: Runtime Error):
#!/usr/bin python3
# -*- coding: utf-8 -*-

from collections import deque

H, W = map(int,input().split())
sth, stw = map(int,input().split())
glh, glw = map(int,input().split())
sth, stw = sth-1, stw-1
glh, glw = glh-1, glw-1

INF = -1
Gmap = [list(input()) for _ in range(H)]
seen = [[INF]*W for _ in range(H)]
direc = {(1,0), (-1,0), (0,1), (0,-1)}
direc5 = set([])
for i in range(-2,3):
    for j in range(-2,3):
        direc5.add((i, j))
direc5 = direc5 - direc
direc5 = direc5 - {(0,0)}

def bfs(pnxt):
    next_q = deque([])
    for h, w in pnxt:
        next_q.append((h,w))
        seen[h][w] = 0
    nxt = set([])
    while len(next_q)!=0:
        h, w = next_q.popleft()
        print(next_q)
        if h == glh and w == glw:
            exit()
        for dh, dw in direc:
            hs, ws = h + dh, w + dw
            if not (0<=hs<H and 0<=ws<W):
                continue
            if Gmap[hs][ws]=='.' and seen[hs][ws]==INF:
                next_q.append((hs, ws))
                seen[hs][ws] = 0
        for dh, dw in direc5:
            hs, ws = h + dh, w + dw
            if not (0<=hs<H and 0<=ws<W):
                continue
            if Gmap[hs][ws]=='.' and seen[hs][ws]==INF and not (hs, ws) in nxt:
                nxt.add((hs, ws))
    return nxt

ret = 0
nxt_st = set([])
nxt_st.add((sth, stw))
while len(nxt_st)>0:
    nxt_st = bfs(nxt_st)
    ret += 1
print(-1)
Problem p02632 (python)

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    mod = 10**9+7
    K = int(input())
    S = input()
    Nk = len(S)
    ret = 0
    nCk = 1
    pw25 = 1
    pw26 = pow(26,K,mod)
    inv26 = pow(26,mod-2,mod)
    for i in range(K+1):
        ret += nCk * pw25 * pw26
        ret %= mod
        nCk *= (i+Nk) * pow(i+1,mod-2,mod)
        nCk %= mod
        pw25 = (pw25*25)%mod
        pw26 = (pw26*inv26)%mod

    print(ret)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin python3
# -*- coding: utf-8 -*-

mod = 10**9+7               # mod素数
N = 1000002                   # 出力の制限
g1 = [1]*(N+1)              # 元テーブル
g2 = [1]*(N+1)              # 逆元テーブル
for i in range( 2, N + 1 ): # 準備
    g1[i] = ( g1[i-1] * i ) % mod
    g2[i] = ( g2[i-1] * pow(i,mod-2,mod) ) % mod

def nCr(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

def main():
#    mod = 10**9+7
    K = int(input())
    S = input()
    Nk = len(S)
    ret = 0
    pw25 = 1
    pw26 = pow(26,K,mod)
    inv26 = pow(26,mod-2,mod)
    for i in range(K+1):
        ret += nCr(i+Nk-1,i,mod) * pw25 * pw26
        ret %= mod
        pw25 = (pw25*25)%mod
        pw26 = (pw26*inv26)%mod

    print(ret)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin python3
# -*- coding: utf-8 -*-

mod = 10**9+7
N = 10**5                   # 出力の制限
g1 = [1]*(N+1)              # 元テーブル
g2 = [1]*(N+1)              # 逆元テーブル
for i in range( 2, N + 1 ): # 準備
    g1[i] = ( g1[i-1] * i ) % mod
    g2[i] = ( g2[i-1] * pow(i,mod-2,mod) ) % mod

def nCr(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

def main():
    K = int(input())
    S = input()
    Nk = len(S)
    ret = 0
    for i in range(K+1):
        ret += nCr(i+Nk-1, Nk-1, mod) * pow(25,i,mod) * pow(26,K-i,mod)
        ret %= mod
    print(ret)

if __name__ == '__main__':
    main()
Problem p02647 (python)

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(min(K,50)):
        dm = [0]*N
        for x in range(N):
            dm[max(x - A[x],0)]+=1
            if x+A[x]+1<N:
                dm[x+A[x]+1]+=-1
        for j in range(1,N):
            dm[j]=dm[j-1]+dm[j]
        A[:] = dm[:]
    print(*A)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(min(K,100)):
        dm = [0]*N
        for x in range(N):
            dm[max(x - A[x],0)]+=1
            if x+A[i]+1<N:
                dm[x+A[x]+1]+=-1
        for j in range(1,N):
            dm[j]=dm[j-1]+dm[j]
        A[:] = dm[:]
    print(*A)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    dm = [0]*N
    dm[:] = A[:]

    for i in range(K):
        dm_ = [0]*N
        for x in range(N):
            dm_[max(x - dm[x],0)]+=1
            if x+dm[i]+1<N:
                dm_[x + dm[x] + 1]+=-1
        dm[:] = dm_[:]

#            print(dm)
        for j in range(1,N):
            dm[j]=dm[j-1]+dm[j]
    print(*dm)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
#    N = 10
#    K = 1
#    A = [0]*10
#    A[0] = 1

    for i in range(K):
        dm = [0]*N
        for x in range(N):
            dm[max(x - A[x],0)]+=1
            if x+A[i]+1<=N:
                dm[x + A[x] + 1]+=-1
#            print(dm)
        for j in range(1,N):
            dm[j]=dm[j-1]+dm[j]
        A[:] = dm[:]
    print(*A)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    for i in range(K):
        dm = [0]*N
        for x in range(N):
            dm[max(x - A[x],0)]+=1
            if x+A[i]+1<N:
                dm[x+A[x]+1]+=-1
        for j in range(1,N):
            dm[j]=dm[j-1]+dm[j]
        A[:] = dm[:]
    print(*A)

if __name__ == '__main__':
    main()
Problem p02787 (python)

Fixed submission:
import numpy as np
H,N=map(int, input().split())
A = [None]*N
B = [None]*N
for i in range(N):
  A[i],B[i]=map(int,input().split())
dp=[10**8]*(H+1)
A = np.array(A)
B = np.array(B)
dp = np.array(dp)
dp[0]=0
for i in range(1,H+1):
  x=np.amin((dp[np.maximum(0,i-A)]+B))
  dp[i]=min(x,dp[i])
print(dp[-1])

Buggy submission (verdict: Runtime Error):
#!/usr/bin python3
# -*- coding: utf-8 -*-

h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

#DP[i] = i までの魔法でモンスターの体力を減らすため消耗する魔力の最小値
dp = [0] * h

for i in range(h):
    dp[i] = min(dp[i-a] + b for a, b in ab)
print(dp[h-1])

Buggy submission (verdict: Runtime Error):
#!/usr/bin python3
# -*- coding: utf-8 -*-

h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]

#DP[i] = i までの魔法でモンスターの体力を減らすため消耗する魔力の最小値
dp = [0] * h

for i in range(h):
    nw = 10**10
    for a, b in ab:
        nw = min(nw ,dp[i-a] + b)
    dp[i] = nw
print(dp[h-1])
Problem p02788 (python)

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

from bisect import bisect_left, bisect_right

n, d, a = map(int, input().split())
x = []
xh = dict()
for _ in range(n):
    xi, hi = map(int, input().split())
    x.append(xi)
    xh[xi] = hi
x.sort()

l = 0
ret = 0
ai = [0] * (n+1)
anow = 0
while l < n:
    xl = x[l]
    hl = xh[xl]
    anow += ai[l]
    hl -= a * anow
    if hl > 0:
        r = bisect_right(x, xl+2*d)
        k = (hl+(a-1))//a
        ret += k
        anow += k
        ai[r] -= k
    l += 1
print(ret)

Buggy submission (verdict: Runtime Error):
#!/usr/bin python3
# -*- coding: utf-8 -*-

from bisect import bisect_left, bisect_right
import numpy as np

n, d, a = map(int, input().split())
xh=[list(map(int, input().split())) for _ in range(n)]
xh.sort()
xh = np.array(xh)
xh = xh.T
x = xh[0][:]
h = xh[1][:]
l = 0
ret = 0
while l < n:
    xl = x[l]
    hl = h[l]
    l += 1
    if hl <= 0:
        continue
    r = bisect_right(x, xl+2*d)
    k = (hl+(a-1))//a
    ret += k
    h[l:r] -= k * a
print(ret)
Problem p02796 (python)

Fixed submission:
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    XL = [None] * N
    for n in range(N):
        X, L = map(int,input().split())
        XL[n] = [X-L,X+L]
    XL.sort(key=lambda x:x[1])
    ret = 1
    TMP = XL[0][1]
    for x in XL[1:]:
        if TMP<=x[0]:
            TMP = x[1]
            ret += 1
    print(ret)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
int(input())
A = [list(map(int,input().split())) for i in list(range(N))]
B = [[i[0]+i[1], i[0]-i[1]] for i in A]
B.sort()
prev=B[0]
cnt=N
for i in range(1,N):
  if prev[0]<B[i][1]:
    cnt-=1
  else:
    prev=B[i]
print(cnt)

Buggy submission (verdict: Runtime Error):
int(input())
A = [list(map(int,input().split())) for i in list(range(N))]
B = [[i[0]+i[1], i[0]-i[1]] for i in A]
B.sort()
prev=B[0]
cnt=N
for i in range(1,N):
  if prev[0]<B[i][1]:
    nt-=1
  else:
    prev=B[i]
print(cnt)

Buggy submission (verdict: Runtime Error):
 int(input())
A = [list(map(int,input().split())) for i in list(range(N))]
B = [[i[0]+i[1], i[0]-i[1]] for i in A]
B.sort()
prev=B[0]
cnt=N
for i in range(1,N):
  if prev[0]<B[i][1]:
    nt-=1
  else:
    prev=B[i]
print(cnt)
Problem p02818 (python)

Fixed submission:
a,b,k=map(int,input().split())
if a>=k:
  print(a-k,b)
else:
  print(0,max(b+a-k,0))

Buggy submission (verdict: Runtime Error):
a,b,k=map(int,input().split())
if a>=k:
  print(a-k,b)
elif:
  print(0,max(b+a-k,0))