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

Fixed submission:
s = input()
pre = [1]+[0]*12
n = 10**9 + 7
tem = [[i*j%13 for i in range(10)] for j in range(13)]
t = 1
for i in range(len(s)):
    if s[-1*i-1] > "9":
        pre = [sum([pre[k-i] for i in tem[t]])%n for k in range(13)]      
    else:
        te = int(s[-1*i-1])*t % 13
        pre = [pre[i-te] for i in range(13)]
    t = t*10 % 13
print(pre[5])

Buggy submission (verdict: Runtime Error):
import numpy as np
s=input()
M = 10**9+7
if s[0] == "?":
    pre = [1 if i<10 else 0 for i in range(13)]
else:
    pre=[0 for i in range(13)]
    pre[int(s[-1])] += 1
amari = [[0]*13 for _ in range(13)]
for j in range(10):
  for i in range(13):
    amari[i][(i*10+j)%13] += 1
mask = np.array(amari)

for i in range(1, len(s)):
    if s[i] == "?":
        data = np.dot(pre, mask) % M
    else:
        c = int(s[i])
        data=np.array([0 for i in range(13)], dtype=np.int64)
        for k in range(13):
            data[(10*k+c)%13] += pre[k]
        data %= M
    pre = np.array(data.copy(), dtype=np.int64)
if len(s)==1:
    print(pre[5])
else:
    print(data[5])

Buggy submission (verdict: Runtime Error):
import numpy as np
s=input()
M = 10**9+7
if s[0] == "?":
    pre = [1 if i<10 else 0 for i in range(13)]
else:
    pre=[0 for i in range(13)]
    pre[int(s[-1])] += 1
amari = [[0]*13 for _ in range(13)]
for j in range(10):
  for i in range(13):
    amari[i][(i*10+j)%13] += 1
mask = np.array(amari)

for i in range(1, len(s)):
    if s[i] == "?":
        data = np.dot(pre, mask) % M
    else:
        c = int(s[i])
        data=np.array([0 for i in range(13)], dtype=np.int64)
        for k in range(13):
            data[(10*k+c)%13] += pre[k]
        data %= M
    pre = np.array(data.copy(), dtype=np.int64)
if len(s)==1:
    print(pre[5])
else:
    print(data[5])

Buggy submission (verdict: Runtime Error):
s=input()
if s[-1] == "?":
    pre = [1 if i<10 else 0 for i in range(13)]
else:
    pre=[0 for i in range(13)]
    pre[int(s[-1])] += 1
for i in range(1, len(s)):
    data=[0 for i in range(13)]
    tmp = 10**i % 13
    if s[len(s)-1-i] == "?":
        for j in range(10):
            for k in range(13):
                data[(tmp*j+k)%13] += pre[k]
    else:
        tmp = tmp*int(s[len(s)-1-i]) % 13
        for k in range(13):
            data[(tmp+k)%13] += pre[k]
    pre = data.copy()
if len(s)==1:
    print(pre[5]%(10**9+7))
else:
    print(data[5]%(10**9+7))

Buggy submission (verdict: Runtime Error):
s=input()
if s[-1] == "?":
    pre = [1 if i<10 else 0 for i in range(13)]
else:
    pre=[0 for i in range(13)]
    pre[int(s[-1])] += 1
for i in range(1, len(s)):
    data=[0 for i in range(13)]
    tmp = 10**i % 13
    if s[len(s)-1-i] == "?":
        for j in range(10):
            for k in range(13):
                data[(tmp*j+k)%13] += pre[k]
    else:
        tmp = tmp*int(s[len(s)-1-i]) % 13
        for k in range(13):
            data[(tmp+k)%13] += pre[k]
    pre = data.copy()
print(data[5]%(10**9+7))
Problem p02973 (python)

Fixed submission:
def se(c, x, h, l):
    if h == l:
        return l
    t = (h+l)//2
    if c[t] <= x:
        a = se(c,x,h,t+1)
    else:
        a = se(c,x,t,l)
    return a
        
    
import numpy as np
n = int(input())
a = [int(input()) for i in range(n)]
c = [a[-1]]
diff = np.diff(a)
tmp = np.sum(diff<=0)
if tmp == len(diff):
    print(len(a))
elif tmp == 0:
    print(1)
else:
    for i in a[::-1][1:]:
        if c[-1] <= i:
            c.append(i)
        else:
            c[se(c,i,len(c),0)] = i
    print(len(c))

Buggy submission (verdict: Runtime Error):
def se(c, x, h, l):
    if h == l:
        return l
    t = (h+l)//2
    if c[t] < x:
        a = se(c,x,h,t)
    else:
        a = se(c,x,t,h)
    return a
        
    
import numpy as np
n = int(input())
a = [int(input()) for i in range(n)]
c = [a[-1]]
if len(np.unique(a)) == 1:
    print(len(a))
else:
    for i in a[::-1][1:]:
        if max(c) <= i:
            c.append(i)
        else:
            c[se(c,i,len(c),0)] = i
    print(len(c))

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
a = [int(input()) for i in range(n)]
c = [a[-1]]
if len(np.unique(a)) == 1:
    print(len(a))
else:
    for i in a[::-1][1:]:
        if max(c) <= i:
            c.append(i)
        else:
            mask = np.array(c) - i > 0
            c[mask][np.argmin(c[mask])] = i
    print(len(c))
Problem p03162 (python)

Fixed submission:
n = int(input())
dp = [int(i) for i in input().split()]
for i in range(n-1):
    a, b, c = map(int, input().split())
    a0 = dp[0]
    b0 = dp[1]
    c0 = dp[2]
    
    dp[0] = max(b0, c0) + a
    dp[1] = max(c0, a0) + b
    dp[2] = max(a0, b0) + c
print(max(dp))

Buggy submission (verdict: Runtime Error):
n = int(input())
dp = [map(int, input().split())]
for i in range(n-1):
    a, b, c = map(int, input().split())
    a0 = dp[0]
    b0 = dp[1]
    c0 = dp[2]
    
    dp[0] = max(b0, c0) + a
    dp[1] = max(c0, a0) + b
    dp[2] = max(a0, b0) + c
print(max(dp))
Problem p03164 (python)

Fixed submission:
n, w = map(int, input().split())
a = [[int(i) for i in input().split(" ")] for j in range(n)]
dp = [[0]+[float("inf")]*(10**5) for i in range(n+1)]
for i in range(1, n+1):
    w_, v_ = a[i-1]
    for j in range(1, 10**5+1):
        if j < v_:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = min(dp[i-1][j-v_]+w_, dp[i-1][j])
for i in range(10**5, -1, -1):
    if dp[n][i]<=w:
        print(i)
        break

Buggy submission (verdict: Runtime Error):
n, w = map(int, input().split())
a = [[int(i) for i in input().split(" ")] for j in range(n)]
dp = [[0]*(w+1) for i in range(n+1)]
for i in range(1, n+1):
    w_, v_ = a[i-1]
    for j in range(1, w+1):
        if j < w_:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j-w_]+v_, dp[i-1][j])
print(dp[n][w])
Problem p03241 (python)

Fixed submission:
import math
n, m = map(int, input().split())
if m%2 == 0:
    divisor = [1, 2, m//2, m]
else:
    divisor = [1, m]
for i in range(3, int(math.sqrt(m))+1):
    if m%i == 0:
        divisor.append(i)
        divisor.append(m//i)
divisor = sorted(divisor, reverse=True)
a = m//n
for i in divisor:
    if i > a:
        continue
    if (m-(m//i*i))%i == 0:
        break
print(i)

Buggy submission (verdict: Runtime Error):
import math
n, m = map(int, input().split())
if m%2 == 0:
    divisor = [2, m//2]
else:
    divisor = []
for i in range(3, int(math.sqrt(m))+1):
    if m%i == 0:
        divisor.append(i)
        divisor.append(m//i)
divisor = sorted(divisor, reverse=True)
a = m//n
for i in divisor:
    if i > a:
        continue
    if (m-(m//i*i))%i == 0:
        break
print(i)

Buggy submission (verdict: Runtime Error):
import math
n, m = map(int, input().split())
if m%2 == 0:
    divisor = [2, m//2]
else:
    divisor = []
for i in range(3, int(math.sqrt(m))+1, 2):
    if m%i == 0:
        divisor.append(i)
        divisor.append(m//i)
divisor = sorted(divisor, reverse=True)
a = m//n
for i in divisor:
    if i > a:
        continue
    if (m-(m//i*i))%i == 0:
        break
print(i)
Problem p03102 (python)

Fixed submission:
N, M, C = map(int, input().split())
B_list = list(map(int, input().split()))
A_lists = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
for A_list in A_lists:
    tmp = [a * b for a, b in zip(A_list, B_list)]
    tmp = sum(tmp) + C
    if tmp > 0:
        cnt += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
3 3 0
100 -100 0
0 100 100
100 100 100
-100 100 100
Problem p03155 (python)

Fixed submission:
N = int(input())
H = int(input())
W = int(input())
print((N - H + 1) * (N - W + 1))

Buggy submission (verdict: Runtime Error):
H, W = map(int, input().split())
S = [input() for i in range(H)]
 
 
b_list = []
for row in S:
    tmp_raw = []
    for j, t in enumerate(row):
        if t == '#':
            tmp_raw.append(j)
    b_list.append(tmp_raw)
tmp = -1
res = {}
raw_before = []
for i, raw in enumerate(b_list):
    res[i] = {}
    for j in raw:
        res[i][j] = []
        if not((j - 1) in raw or j == 0):
            res[i][j].append((i, j-1))
        if not((j + 1) in raw or j == W -1):
            res[i][j].append((i, j+1))
        if not(i == 0 or j in raw_before):
            res[i][j].append((i-1, j))
        if not(i == H - 1):
            if not(j in b_list[i+1]):
                res[i][j].append((i+1, j))
    raw_before = raw
 
 
 
before = 0
for i, raw in enumerate(b_list):
    for j in raw:
         before += len(res[i][j])
while True:
    for i, raw in enumerate(b_list):
        for j in raw:
            try:
                if S[i-1][j] == '.' or S[i][j-1] == '.':
                    res[i][j] += res[i-1][j-1]
            except:
                pass
            try:
                if S[i+1][j] == '.' or S[i][j-1] == '.':
                    res[i][j] += res[i+1][j-1]
            except:
                pass
            try:
                if S[i-1][j] == '.' or S[i][j+1] == '.':
                    res[i][j] += res[i-1][j+1]
            except:
                pass
            try:
                if S[i+1][j] == '.' or S[i][j+1] == '.':
                    res[i][j] += res[i+1][j+1]
            except:
                pass
    before = result
    for i, raw in enumerate(b_list):
        for j in raw:
            res[i][j] = list(set(res[i][j]))
    result = 0
    for i, raw in enumerate(b_list):
        for j in raw:
             result += len(res[i][j])
    if before == result:
        break
print(result)
Problem p03160 (python)

Fixed submission:
N = int(input())
h_list = list(map(int, input().split()))
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
import numpy as np
dp_list = [np.inf] * N
dp_list[0] = 0
dp_list[1] = abs(h_list[1] - h_list[0])
for i in range(2, N):
    dp_list[i] = chmin(dp_list[i], dp_list[i-1] + abs(h_list[i-1] - h_list[i]))
    dp_list[i] = chmin(dp_list[i], dp_list[i-2] + abs(h_list[i-2] - h_list[i]))
print(dp_list[-1])

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

dp_list = [0]
for n in range(1, N):
  tmp_h = h_list[n]
  if n < K:
    lst = [abs(tmp_h - h_list[i]) + dp_list[i] for i in range(n)]
    else:
      lst = [abs(tmp_h - h_list[n-k]) + dp_list[n-k] for k in range(1, K + 1)]
      dp_list.append(min(lst))
      print(dp_list[-1])
Problem p03161 (python)

Fixed submission:
N, K = map(int, input().split())
h_list = list(map(int, input().split()))
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
dp_list = [1000000000] * N
dp_list[0] = 0
dp_list[1] = abs(h_list[1] - h_list[0])
for n in range(1, N):
    for k in range(1, K+1):
        dp_list[n] = chmin(dp_list[n], dp_list[n-k] + abs(h_list[n-k] - h_list[n]))
        if n-k == 0:
            break
print(dp_list[-1])

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

dp_list = [0]
for n in range(1, N):
  tmp_h = h_list[n]
  if n < K:
    lst = [abs(tmp_h - h_list[i]) + dp_list[i] for i in range(n)]
    else:
      lst = [abs(tmp_h - h_list[n-k]) + dp_list[n-k] for k in range(1, K + 1)]
      dp_list.append(min(lst))
      print(dp_list[-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
h_list = list(map(int, input().split()))
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
import numpy as np
dp_list = [1000000000] * N
dp_list[0] = 0
dp_list[1] = abs(h_list[1] - h_list[0])
for n in range(1, N):
    for k in range(1, K+1):
        dp_list[n] = chmin(dp_list[n], dp_list[n-k] + abs(h_list[n-k] - h_list[n]))
        if n-k == 0:
            break
print(dp_list[-1])

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
h_list = list(map(int, input().split()))
def chmin(a, b):
    if a > b:
        return b
    else:
        return a
import numpy as np
dp_list = [np.inf] * N
dp_list[0] = 0
dp_list[1] = abs(h_list[1] - h_list[0])
for n in range(1, N):
    for k in range(1, K+1):
        dp_list[n] = chmin(dp_list[n], dp_list[n-k] + abs(h_list[n-k] - h_list[n]))
        if n-k == 0:
            break
print(dp_list[-1])

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

import numpy as np
dp_list = [np.inf] * N
dp_list[0] = 0
dp_list[1] = abs(h_list[1] - h_list[0])
for n in range(1, N):
    for k in range(1, K+1):
        dp_list[n] = chmin(dp_list[n], dp_list[n-k] + abs(h_list[n-k] - h_list[n]))
        if n-k == 0:
            break
print(dp_list[-1])
Problem p03162 (python)

Fixed submission:
N = int(input())
happy_list = [list(map(int, input().split())) for n in range(N)]
def chmax(a, b):
    if a > b:
        return a
    else:
        return b
dp_list = [[0, 0, 0]]
for n in range(1, N+1):
    tmp = [0, 0, 0]
    tmp[1] = chmax(tmp[1], dp_list[n-1][0] + happy_list[n-1][1])
    tmp[2] = chmax(tmp[2], dp_list[n-1][0] + happy_list[n-1][2])
    tmp[0] = chmax(tmp[0], dp_list[n-1][1] + happy_list[n-1][0])
    tmp[2] = chmax(tmp[2], dp_list[n-1][1] + happy_list[n-1][2])
    tmp[0] = chmax(tmp[0], dp_list[n-1][2] + happy_list[n-1][0])
    tmp[1] = chmax(tmp[1], dp_list[n-1][2] + happy_list[n-1][1])
    dp_list.append(tmp)
print(max(tmp))

Buggy submission (verdict: Runtime Error):
N = int(input())
abc_list = [list(map(int, input().split())) for _ in range(N)]

happy_list = [[0, 0, 0]] # n日目にa|b|cを選んだときの幸福のそこまでの最大値
# before_act = -1 # a: 0, b: 1, c: 2
for n in range(N):
    before_happy_a, before_happy_b, before_happy_c = happy_list[-1]
    a, b, c = abc_list[n]
    tmp_happy_a = max(before_happy_b, before_happy_c) + a
    tmp_happy_b = max(before_happy_c, before_happy_a) + b
    tmp_happy_c = max(before_happy_a, before_happy_b) + c
    happy_list.append([tmp_happy_a, tmp_happy_b, tmp_happy_c])

print(max(happy_list[-1]))s
Problem p03238 (python)

Fixed submission:
n = int(input())
if n==1:
    print('Hello World')
else:
    a = int(input())
    b = int(input())
    print(a+b)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())
if n==1:
    print('Hello World')
else:
    print(a+b)
Problem p03262 (python)

Fixed submission:
N, X = map(int, input().split())
x_list = [abs(int(i) - X) for i in input().split()]
# N, X = map(int, '3 81'.split())
# x_list = [abs(int(i) - X) for i in '33 105 57'.split()]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
res = [x_list[0]]
for i in range(1, N):
    res.append(gcd(res[i-1], x_list[i]))
print(min(res))

Buggy submission (verdict: Runtime Error):
N, X = map(int, input().split())
x_lst = [int(i) for i in input().split()]
# N, X = map(int, '3 81'.split())
# x_list = [abs(int(i) - X) for i in '33 105 57'.split()]
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
res = [x_list[0]]
for i in range(1, N):
    res.append(gcd(res[i-1], x_list[i]))
print(min(res))
Problem p03280 (python)

Fixed submission:

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

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

Buggy submission (verdict: Runtime Error):
import numpy as np
def main():
    N, M, Q = map(int, input().split())
    LR = []
    for i in range(M):
        l, r = map(int, input().split())
        LR.append([l-1, r])
    PQ = []
    for i in range(Q):
        p, q = map(int, input().split())
        PQ.append([p-1, q-1])
    ar = np.zeros([M, N])
    for m in range(M):
        ar[m, LR[m][0]:LR[m][1]] = 1
    flags_start = [np.ones(M, dtype=np.bool)]
    flags_end = []
    for i in range(1, N):
        flags_start.append((ar[:, :i].max(axis=1)==0))# * (ar[:, i:].max(axis=1)==1))
        flags_end.append((ar[:, i:].max(axis=1)==0))# * (ar[:, :i].max(axis=1)==1))
    flags_end.append(np.ones(M, dtype=np.bool))
    for q in range(Q):
        left = PQ[q][0]
        right = PQ[q][1]
        print(sum(flags_start[left] * flags_end[right]))

if __name__=='__main__':
    main()

Buggy submission (verdict: Runtime Error):

A = int(input())
B = int(input())

print(A*B-A-B+1)
Problem p03283 (python)

Fixed submission:
import numpy as np
N, M, Q = map(int, input().split())
LR = []
for i in range(M):
    l, r = map(int, input().split())
    LR.append([l, r])
PQ = []
for i in range(Q):
    p, q = map(int, input().split())
    PQ.append([p, q])
ar_sec = np.zeros([N, N])
for i in range(M):
    l, r = LR[i][0], LR[i][1]
    ar_sec[l-1][r-1] += 1


ar_sum = np.zeros([N+1, N+1])
for i in range(N):
    for j in range(N):
        ar_sum[i+1][j+1] = ar_sum[i][j+1]+ar_sum[i+1][j]-ar_sum[i][j]+ar_sec[i][j]

for i in range(Q):
    p, q = PQ[i][0], PQ[i][1]
    print(int(ar_sum[q][q]-ar_sum[p-1][q]))

Buggy submission (verdict: Runtime Error):
N, M, Q = map(int, input().split())
LR = []
for i in range(M):
    l, r = map(int, input().split())
    LR.append([l-1, r])
PQ = []
for i in range(Q):
    p, q = map(int, input().split())
    PQ.append([p-1, q-1])


import numpy as np
ar = np.zeros([M, N])
for m in range(M):
    ar[m, LR[m][0]:LR[m][1]] = 1

for q in range(Q):
    left = PQ[q][0]
    right = PQ[q][1]
    if left != 0 and right!=9:
        flag = (ar[:, left-1] == 0)* (ar[:, right+1] == 0) * (ar[:, left:right+1].max(axis=1) > 0)
        print(sum(flag))
    elif left == 0 and right!=9:
        flag = (ar[:, right+1] == 0) * (ar[:, left:right+1].max(axis=1) > 0)
        print(sum(flag))
    elif left != 0 and right==9:
        flag = (ar[:, left-1] == 0) * (ar[:, left:right+1].max(axis=1) > 0)
        print(sum(flag))
    else:
        print(M)
Problem p03284 (python)

Fixed submission:
N, K = map(int, input().split())
if N % K==0:
    print(0)
else:
    print(1)

Buggy submission (verdict: Runtime Error):
def comb1(n, r):
    if n == 0 or r == 0: return 1
    return comb1(n, r-1) * (n-r+1) / r 
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
# N, M = 10, 400000000
# A = [int(i) for i in '1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000'.split()]
surplus = {0:0}
res = 0
tmp = 0
B = []
for i in range(0, N):
    tmp += A[i] % M
    B.append(tmp)
    surplus[tmp] = 0
for i in B:
    surplus[i] += 1
for tmp_key in surplus.keys():
    res += comb1(surplus[tmp_key], 2)

corner = surplus[0]
if corner == 0:
    res -= 1
else:
    res += corner
print(int(res))
Problem p03287 (python)

Fixed submission:
def comb1(n, r):
    if n == 0 or r == 0: return 1
    return comb1(n, r-1) * (n-r+1) / r 
N, M = map(int, input().split())
A = [int(i) for i in input().split()]
# N, M = 10, 400000000
# A = [int(i) for i in '1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000'.split()]
surplus = {0:0}
res = 0
tmp = 0
B = []
for i in range(0, N):
    tmp += A[i]
    tmp %= M
    B.append(tmp)
    surplus[tmp] = 0
for i in B:
    surplus[i] += 1

for tmp_key in surplus.keys():
    res += comb1(surplus[tmp_key], 2)

corner = surplus[0]
if corner == 0:
    res -= 1
else:
    res += corner
print(int(res))

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())
A = []
res = 0
for i in input().split():
    A.append(int(i))
    if A[-1]%M==0:
        res += 1
ar = np.eye(N) * A

for h in range(0, N):
    for w in range(1, h+1):
        ar[-h-1, -h-1+w] = ar[-h, -h-1+w] + ar[-h-1, -h-2+w] - ar[-h, -h-2+w]
        if ar[-h-1, -h-1+w] % M == 0:
            res += 1
# print(int(sum(sum(ar % M == 0)) - sum(np.linspace(1, N-1, N-1))))
print(res)
Problem p03288 (python)

Fixed submission:
R = int(input())
if R<1200:
    print('ABC')
elif R<2800:
    print('ARC')
else:
    print('AGC')

Buggy submission (verdict: Runtime Error):
R = int(input())
if R<1200:
Problem p03316 (python)

Fixed submission:

N = int(input())

N_str = str(N)
S = sum([int(N_str[i]) for i in range(len(N_str))])

if N % S == 0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):

D, W = map(int, input().split())
if W == 100:
    print(101*(100**D))
else:
    print(W*(100**D))
Problem p03475 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 10 02:27:58 2018

@author: Yuki
"""

N = int(input())
data  = []
for i in range(N-1):
    c, s, f = map(int, input().split())
    data.append([c, s, f])

def train_time(start_time=0, data_list=[12, 24, 6]):
    if data_list[1] <= start_time:
        return start_time + (data_list[2] - start_time%data_list[2])%data_list[2] + data_list[0]
    else:
        return data_list[1] + data_list[0]

#N = 4
#data = [[12, 24, 6], [52, 16, 4], [99, 2, 2]]

res = []
for i in range(N-1):
    need_time = 0
    for ii in range(i, N-1):
        need_time = train_time(need_time, data[ii])
    res.append(need_time)

for i in range(N-1):
    print(res[i])
print(0)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 10 02:27:58 2018

@author: Yuki
"""

N = int(input())
data  = []
for i in range(N-1):
    c, s, f = map(int, input().split())
#    data.append([c, s, f])

def train_time(start_time=0, data_list=[12, 24, 6]):
    if data_list[1] <= start_time:
        return start_time + (data_list[2] - start_time%data_list[2])%data_list[2] + data_list[0]
    else:
        return data_list[1] + data_list[0]

#N = 4
#data = [[12, 24, 6], [52, 16, 4], [99, 2, 2]]

res = []
for i in range(N-1):
    need_time = 0
    for ii in range(i, N-1):
        need_time = train_time(need_time, data[ii])
    res.append(need_time)

for i in range(N-1):
    print(res[i])
Problem p03487 (python)

Fixed submission:
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 10 01:03:03 2018

@author: Yuki
"""


N = int(input())
A = sorted([int(i) for i in input().split()])
import collections
#N = 5
#A = sorted([2, 4, 1, 4, 2])
cnt_dict = collections.Counter(A)
res_cnt = 0
for key in cnt_dict.keys():
    if key == cnt_dict[key]:
        pass
    else:
        if key < cnt_dict[key]:
            res_cnt += cnt_dict[key] - key
        else:
            res_cnt += cnt_dict[key]
print(res_cnt)

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 10 01:03:03 2018

@author: Yuki
"""
import numpy as np

N = int(input())
A = sorted([int(i) for i in input().split()])
#N = 8
#A = sorted([2, 7, 1, 8, 2, 8, 1, 8])
A_uni = np.array(sorted(list(set(A))))
A = np.array(A)


tmp = 0
res_cnt = 0
i = 0
for i in range(len(A_uni)):
    tmp_number = A_uni[i]
    if len(A) <= tmp_number+1:
        res_cnt += len(A)
        break
    else:
        if A[tmp_number-1] != tmp_number:
            del_cnt = 1
            while True:
                if A[del_cnt] == tmp_number:
                    del_cnt += 1
                else:
                    res_cnt += del_cnt
                    A = A[del_cnt:]

                    break
        else:
            if A[tmp_number] != tmp_number:
                A = A[tmp_number:]
            else:
                A = A[tmp_number:]
                del_cnt = 1
                while True:
                    if A[del_cnt] != tmp_number:
                        A = A[del_cnt:]
                        res_cnt += del_cnt
                        break
                    else:
                        del_cnt += 1
                    
print(res_cnt)