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

Fixed submission:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    import numpy as np
    A.sort()
    ans = sum(A)
    from bisect import bisect_left,bisect_right
    from collections import Counter
    count = Counter(A)
    for i in range(q):
        b,c = map(int, input().split())
        k = count[b]
        if k != 0:
            count[c] += count.pop(b)
        ans += (c-b)* k
        print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    import numpy as np
    A.sort()
    ans = sum(A)
    from bisect import bisect_left,bisect_right
    from collections import Counter
    count = Counter(A)
    for i in range(q):
        b,c = map(int, input().split())
        k = count[b]
        if k != 0
            count[c] += count.pop(b)
        ans += (c-b)* k
        print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    import numpy as np
    A.sort()
    ans = sum(A)
    from bisect import bisect_left,bisect_right
    from collections import Counter
    count = Counter(A)
    for i in range(q):
        b,c = map(int, input().split())
        k = count[b]
        count[c] += count.pop(b)
        ans += (c-b)* k
        print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    A = list(map(int, input().split()))
    q = int(input())
    import numpy as np
    A.sort()
    ans = sum(A)
    for i in range(q):
        b,c = map(int, input().split())
        count = 0
        for j,a in enumerate(A):
            if a == b:
                A[j]=c
                conunt += 1
            elif a > b:
                break
        ans += (c-b)* count
        print(ans)

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

Fixed submission:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    x = list(map(int, input().split()))
    for i,el in enumerate(x):
        if el == 0:
            print(i+1)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
x = list(map(int,input().split()))
for i,el in enumerate(x):
	if el == 0:
    	print(i+1)
Problem p02658 (python)

Fixed submission:
def main():
    import sys
    input = sys.stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    a = sorted(a)
    limit = 10**18
    ans = 1
    for ai in a:
        ans *= ai
        if ans > limit:
            print(-1)
            exit(0)
        if ans == 0:
            break
    print(ans)

    


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    a = sorterd(a)
    limit = 10**18
    ans = 1
    for ai in a:
        ans *= ai
        if ans > limit:
            print(-1)
            exit(0)
        if ans == 0:
            break
    print(ans)

    


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

Fixed submission:
import numpy as np
N, M, X = map(int, input().split())
C = []
A = np.zeros((N, M), dtype=int)
for i in range(N):
    c, *a = map(int, input().split())
    C.append(c)
    A[i] = a

S = np.sum(A, axis=0)
if True in (S < X):
    print(-1)
    exit(0)

C_ = []
for i in range(2**N):
    total = 0
    arr = np.zeros((M,),dtype=int)
    for j in range(N):
        if ((i>>j) & 1) == 1:
            total += C[j]
            arr += A[j]
    if True in (arr < X):
        continue
    C_.append(total)
print(min(C_))

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M, X = map(int, input().split())
C = []
A = np.zeros((N, M), dtype=int)
for i in range(N):
    c, *a = map(int, input().split())
    C.append(c)
    A[i] = a

S = np.sum(A, axis=0)
print(A)
print(S)
if True in (S < X):
    print(-1)
    exit(0)

mlt = [0]*12
C_ = []
for i in range(2**N):
    total = 0
    arr = np.zeros((M,),dtype=int)
    for j in range(N):
        if ((i>>j) & 1) == 1:
            total += C[j]
            arr += A[j]
    if True in (arr < X):
        continue
    C_.append(total)
print(min(C_))
Problem p02684 (python)

Fixed submission:
def main():
    import sys
    input = sys.stdin.buffer.readline
    N, K = map(int, input().split())
    A = list(map(lambda x: int(x)-1, input().split()))
    now = 0
    dict_ = {}
    stack = []
    for i in range(N):
        if now not in dict_:
            dict_[now] = A[now]
            stack.append(now)
            now = A[now]
        else:
            idx = stack.index(now)
            mod = i - idx
            break
    idx = idx + (K-idx) % mod
    idx = min(K, idx)
    print(stack[idx]+1)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.buffer.readline
N, K = map(int, input().split())
A = list(map(lambda x: int(x)-1, input().split()))
now = 0
dict_ = {}
stack = []
for i in range(N):
    if now not in dict_:
        dict_[now] = A[now]
        stack.append(now)
        now = A[now]
    else:
        idx = stack.index(now)
        mod = i+1 - idx
        break
idx = idx + (K-idx) % mod
idx = min(K, idx)
print(stack[idx]+1)
Problem p02697 (python)

Fixed submission:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n,m = map(int, input().split())
    r = m//2
    s = 1
    e = 2*r+1
    for _ in range(r):
        print(s,e)
        s += 1
        e -=1
    
    s = n-2*(m-r)+1
    e = n
    for _ in range(m-r):
        print(s,e)
        s += 1
        e -=1


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n,m = map(int, input().split())
    if n%2 == 0
        for i in range(m):
            print(n//2-i,n//2+i)
    else:
        for i in range(m):
            print(n//2-i,n//2+i+2)



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

Fixed submission:
from collections import deque
from bisect import bisect_left as bile

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    sys.setrecursionlimit(10**6)
    n = int(input())
    arr = list(map(int, input().split()))
    adj = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        adj[a].append(b)
        adj[b].append(a)

    ans = [0]*n
    inf = 1e18
    dp = [inf]*(n+10)
    parent = [-1]*n
    def dfs(s):
        idx = bile(dp, arr[s])
        tmp = dp[idx]
        dp[idx] = arr[s]
        ans[s] = bile(dp, inf)

        for v in adj[s]:
            if v == parent[s]:
                continue
            parent[v] = s
            dfs(v)
        dp[idx] = tmp
        return ans
        
    ans = dfs(0)
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from collections import deque
from bisect import bisect_left as bile

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    arr = list(map(int, input().split()))
    adj = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        adj[a].append(b)
        adj[b].append(a)

    ans = [0]*n
    inf = 1e18
    dp = [inf]*(n+10)
    parent = [-1]*n
    def dfs(s):
        idx = bile(dp, arr[s])
        tmp = dp[idx]
        dp[idx] = arr[s]
        ans[s] = bile(dp, inf)

        for v in adj[s]:
            if v == parent[s]:
                continue
            parent[v] = s
            dfs(v)
        dp[idx] = tmp
        return ans
        
    ans = dfs(0)
    for a in ans:
        print(a)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from collections import deque
from bisect import bisect_left as bile

    # while stack:
    #     node = stack.pop()
    #     for v in adj[node]:
    #         if v == parent[node]:
    #             continue
    #         parent[v] = node
    #         stack.append(v)
    #     dp
    

def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    n = int(input())
    arr = list(map(int, input().split()))
    adj = [[] for _ in range(n)]
    for i in range(n-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        adj[a].append(b)
        adj[b].append(a)

    ans = [0]*n
    inf = 1e18
    dp = [inf]*n
    parent = [-1]*n
    def dfs(s):
        
        idx = bile(dp, arr[s])
        tmp = dp[idx]
        dp[idx] = arr[s]
        ans[s] = bile(dp, inf)

        for v in adj[s]:
            if v == parent[s]:
                continue
            parent[v] = s
            dfs(v)
        dp[idx] = tmp
        return ans
        
    ans = dfs(0)
    for a in ans:
        print(a)


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

Fixed submission:
a,b,c,d = map(int,input().split())
turn = 0
while a > 0 and c> 0:
    if turn%2 ==0:
        c -= b
    else:
        a -= d
    turn += 1
if turn%2 == 1:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
a,b,c,d = map(int,input(),split())
turn = 0
while a > 0 and c> 0:
    if turn%2 ==0:
        c -= b
    else:
        a -= d
    turn += 1
if turn%2 == 1:
    print('Yes')
else:
    print('No')
Problem p02702 (python)

Fixed submission:
# import sys 
# import os
# path = os.path.join(os.getcwd(),'input.txt')
# input = open(path).readline

import numpy as np
S = input()
cand = np.zeros(2019,dtype=int)
rem = 0
order = 1
mod = 2019
for s in S[::-1]:
    rem += (int(s)*order)%mod
    rem %= mod
    cand[rem] +=1
    order *= 10
    order %=mod
ans = cand[0]
cand = cand[cand>1]
for c in cand:
    ans += c*(c-1)/2
print(int(ans))

Buggy submission (verdict: Runtime Error):
# import sys 
# import os
# import numpy as np
# path = os.path.join(os.getcwd(),'input.txt')
# input = open(path).readline

S = input()
cand = np.zeros(2019,dtype=int)
ans = 0
rem = 0
for i,s in enumerate(S[::-1]):
    rem += int(s)*(10**i)
    rem %= 2019
    cand[rem] +=1
ans = cand[0]
cand = cand[cand>1]
for c in cand:
    ans += c*(c-1)/2
print(int(ans))
Problem p02714 (python)

Fixed submission:
N = int(input())
S= input()
sub = 0
R,G,B = [],[],[]
r = S.count('R')
g = S.count('G')
b = S.count('B') 
for i in range(N):
    for j in range(i+1,N):
        if 2*j-i > N-1:
            break
        if S[i] != S[j] and S[2*j-i] != S[i] and S[2*j-i] != S[j]:
            sub += 1
ans = r*g*b -sub
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
s = input()
#ans = s.count('R')*s.count('G')*s.count('B')
ans = 0
for i in range(n-2):
	s1 = s[i]
	for j in range(i+1,n-1):
    	s2 = s[j]
        if s1 == s2:
        	pass
        else:
        	s[2*j-i] != s1 and s[2*j-i] != s2:
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S= input()
sub = 0
R,G,B = [],[],[]
r = S.count('R')
g = S.count('G')
b = S.count('B') 
for i in range(N):
    for j in range(i+1,N+1):
        if S[i] != S[j] and S[2*j-i] != S[i] and S[2*j-i] != S[j]:
            sub += 1
ans = r*g*b -sub
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
S= input()
count = 0
R,G,B = [],[],[]
r = S.count('R')
g = S.count('G')
b = S.count('B') 
for i in range(N):
    for j in range(i+1,N+1):
        if S[i] != S[j] and S[2*j-i] != S[i] and S[2*j-i] != S[j]:
            sub += 1
ans = r*g*b -sub
print(ans)
Problem p02717 (python)

Fixed submission:
x,y,z = map(int, input().split())
x,y,z = z,x,y
print(x,y,z)

Buggy submission (verdict: Runtime Error):
import collections
def prime_factorize(n):
    a = []
    while n%2 == 0:
        a.append(2)
        n//=2
    f =3
    while f*f <= n:
        if n%f == 0:
            a.append(f)
            n//=f
        else:
            f +=2
    if n != 1:
        a.append(n)
    return a

# N-1の約数を数える
N = int(input())
factor = collections.Counter(prime_factorize(N-1))
K = 1
for i in list(factor.values()):
    K *= i+1
K -=1
for f in range(2, int(N**0.5)+1):
    n = N
    if n%f != 0:
        continue
    while n%f ==0:
        n//=f
    if n%f ==1 or n==1:
        K+=1
#最後は自分自身を加える。
K +=1
print(K)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
A = list(map(int,input().split()))
shreshold = sum(A)/(4*M)
ret = [a for a in A if a >= shreshold]
if len(ret) < M:
    print('no')
else:
    print('yes')
Problem p02720 (python)

Fixed submission:
import queue
K = int(input())
q = queue.Queue()
for i in range(1,10):
    q.put(i)

for i in range(K):
    x = q.get()
    a = x%10
    if a !=0:
        q.put(10*x +a -1)
    q.put(10*x +a )
    if a != 9:
        q.put(10*x +a +1)
print(x)

Buggy submission (verdict: Runtime Error):
k = int(input())
stack = list(range(1,10))
for i in range(k):
  num = stack.pop(0)
  if (m:=num%10) == 0:
    stack.append([num*10 + m,num*10+m+1])
  elif m == 9:
    stack.append([num*1 + m -1,num*10 + m])
  else:
    stack.append([num*10 + m -1,num*10 + m, num*10+ m + 1])
print(num)
Problem p02721 (python)

Fixed submission:
import sys
def yutori():
    N, K, C = map(int,sys.stdin.readline().split())
    S = [i for i in sys.stdin.readline()]
    l = [i+1 for i in range(N) if S[i] == 'o']
    Left = []
    Right = []
    for u in l:
        if Left == []:
            Left.append(u)
        if u > Left[-1] + C:
            Left.append(u)
        if len(Right) == K:
            break
        
    if len(Left) <K:
        exit()

    for u in l[::-1]:
        if Right== []:
            Right.append(u)
        if u < Right[-1] - C:
            Right.append(u)
        if len(Right) == K:
            break

    if len(Right) <K:
            exit()
    
    for i in range(K):
        if Left[i] == Right[-i-1]:
            print(Left[i])

yutori()

Buggy submission (verdict: Runtime Error):
import sys
def yutori():
    N, K, C = map(int,sys.stdin.readline().split())
    S = [i for i in sys.stdin.readline()]
    l = [i+1 for i in range(N) if S[i] == 'o']
    Left = [0]*K
    Right = [0]*K
    count = 0
    for u in l:
        if Left[0] == 0:
            Left[count] = u
        if u > Left[count] + C:
            count +=1
            Left[count] = u
        continue

    count = 1
    for u in l[::-1]:
        if Right[-1] == 0:
            Right[-count] = u
        if u < Right[-count] - C:
            count +=1
            Right[-count] = u
        continue

    if Left[-1] == 0 or Right [0] == 0:
        return 
    for i in range(K):
        if Left[i] == Right[i]:
            print(Left[i])

yutori()
Problem p02730 (python)

Fixed submission:
def main():
    import sys
    #input = sys.stdin.readline
    s = input()
    n = len(s)
    s_l = s[:int((n-1)/2)]
    s_r = s[int((n+1)/2):]
    if s == s[::-1] and s_l == s_l[::-1] and s_r == s_r[::-1]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys
    input = sys.stdin.buffer.readline
    s = input()
    n = len(s)
    s_l = s[:(n-1)/2]
    s_r = s[(n+3)/2:]
    if s == s[::-1] and s_l == s_l[::-1] and s_r == s_r[::-1]:
        print('Yes')
    else:
        print('No')


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

Fixed submission:
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n, q = map(int, input().split())
    adj = [[] for _ in range(n)]
    for _ in range(n-1):
        a, b = map(lambda x: int(x)-1, input().split())
        adj[a].append(b)
        adj[b].append(a)
    ans = [0]*n
    for _ in range(q):
        p, x = map(int, input().split())
        p -=1
        ans[p] += x
    
    from collections import deque
    que = deque([0])
    parent = [-1]*n
    while que:
        node = que.pop()
        for v in adj[node]:
            if v == parent[node]:
                continue
            parent[v] = node
            que.append(v)
            ans[v] += ans[node]
    for a in ans:
        print(a)

        

    
if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i++)
typedef long long ll;
#define repran(i, a,b) for (int i = a; i<b;i++)
#define repd(i, n) for (int i = n-1; i > -1; i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using LP = pair<ll,ll>;
using P = pair<int,ll>;
int n;
ll inf = 1e18;

int main()
{
    int n ,q;
    cin >> n >> q;
    vector<vector<int>> G(n, vector<int>());
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        --a;--b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<ll> ans(n, 0);
    vector<ll> acc(n, 0);
    rep(i, q){
        int p; ll x;
        cin >> p >>x;
        --p;
        acc[p] += x;
    }
    //dfs
    deque<P> deq;
    deq.emplace_back(0, acc[0]);
    ans[0] = acc[0];
    vector<int> parent(n, -1);
    while(!deq.empty()){
        P now = deq.back();deq.pop_back();
        int node = now.first;
        ll cost = now.second;
        for (int child : G[node]){
            if(child == parent[node]) continue;
            parent[child] = node;
            ans[child] = ans[node]+acc[child];
            deq.emplace_back(child, acc[child]);
        }

    }
    rep(i, n) cout << ans[i] << endl;

}
Problem p03006 (python)

Fixed submission:
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    x, y = [0]*n, [0]*n
    for i in range(n):
        x[i], y[i] = map(int, input().split())
    from collections import defaultdict
    xy = defaultdict(int)
    for i in range(n):
        for j in range(n):
            if i == j: continue
            xy[(x[i]-x[j], y[i]-y[j])] += 1
    if xy == {}:
        print(1)
        return
    p, q = max(xy, key=lambda x: xy[x])
    ans = n
    for i in range(n):
        for j in range(n):
            if i == j: continue
            if x[i]-x[j] == p and y[i]-y[j] == q:
                ans -= 1
    print(ans)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    x, y = [0]*n, [0]*n
    for i in range(n):
        x[i], y[i] = map(int, input().split())
    from collections import defaultdict
    xy = defaultdict(int)
    for i in range(n):
        for j in range(n):
            if i == j: continue
            xy[(x[i]-x[j], y[i]-y[j])] += 1
    p, q = max(xy, key=lambda x: xy[x])
    ans = n
    for i in range(n):
        for j in range(n):
            if i == j: continue
            if x[i]-x[j] == p and y[i]-y[j] == q:
                ans -= 1
    print(ans)
    

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

Fixed submission:
import sys
import numpy as np
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())


def main():
    n = ii()
    x = []  
    ans = 0     
    for i in range(n):
        a, b = mi()
        x.append(a+b)
        ans -= b
    x.sort(reverse=True)
    ans += sum(x[::2])    
    print(ans)






if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
def input(): return sys.stdin.readline().rstrip()
def ii(): return int(input())
def mi(): return map(int, input().split())
def li(): return list(mi())


def main():
    n = ii()
    aa, bb = [], []        
    for i in range(n):
        a, b = mi()
        aa.append(a)
        bb.append(b)
    idxa = sorted(range(n), key=lambda x: aa[x])
    idxb = sorted(range(n), key=lambda x: bb[x])
    visted = [False]*n
    cura, curb = 0, 0
    t = 0
    ans = 0
    while cura < n-1 and curb < n-1:
        if t%2 == 0:
            while visted[idxb[curb]]:
                curb += 1
            ans += aa[idxb[curb]]
            visted[idxb[curb]]=True
        if t%2 == 1:
            while visted[idxa[cura]]:
                cura += 1
            ans -= bb[idxa[cura]]
            visted[idxa[cura]]=True
        t += 1
    print(ans)






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

Fixed submission:
import sys



input = sys.stdin.readline
N = int(input())
H = list(map(int,input().split()))

dp = 0
i = 0
dp = [0]*(N)
for i in range(1,N):
    if i ==1:
        dp[i] = dp[i-1] + abs(H[i]-H[i-1])
        continue
    dp[i] = min(dp[i-1] + abs(H[i]-H[i-1]),dp[i-2] + abs(H[i]-H[i-2]))

print(dp[N-1])

Buggy submission (verdict: Runtime Error):
import sys

# import os
# path = os.getcwd()
# path = os.path.join(path,"input.txt")
# sys.stdin = open(path)

input = sys.stdin.readline
N,K = map(int,input().split())
H = list(map(int,input().split()))
dp = [0].append([float('inf')]*(K))
for i in range(N-1):
    dp_ = dp.pop(0)
    if i >= N-K-1:
        dp = [min(dp_+abs(H[i+j+1]-H[i]),dp[j]) for j in range(N-i-1)]
        continue
    dp = [min(dp_+abs(H[i+j+1]-H[i]),dp[j])  for j in range(K)]
    dp.append(float("inf"))
    print(dp)

print(dp[0])

Buggy submission (verdict: Runtime Error):
import sys

import os
path = os.getcwd()
path = os.path.join(path,"input.txt")
sys.stdin = open(path)

input = sys.stdin.readline
N = int(input())
H = list(map(int,input().split()))

dp = 0
i = 0
while i<N-1:
    if i == N-2:
        dp += abs(H[N-1]-H[i])
        break
    if abs(H[i+1]-H[i]) < abs(H[i+2]-H[i]):
        dp += abs(H[i+1]-H[i])
        i += 1
    else:
        dp += abs(H[i+2]-H[i])
        i += 2
print(dp)
Problem p03162 (python)

Fixed submission:
import sys

# import os
# path = os.getcwd()
# path = os.path.join(path,"input.txt")
# sys.stdin = open(path)

input = sys.stdin.readline
import numpy as np
N = int(input())
abc = np.zeros((N,3))
for i in range(N):
    abc[i] = list(map(int,input().split()))

dp = np.zeros((N,3))
for i in range(N):
    if i == 0:
        dp[i] = abc[i]
        continue
    dp_a,dp_b,dp_c = dp[i-1]
    dp[i] = abc[i] + [max(dp_b,dp_c),max(dp_a,dp_c),max(dp_a,dp_b)]
print(int(max(dp[N-1])))

Buggy submission (verdict: Runtime Error):
import sys

# import os
# path = os.getcwd()
# path = os.path.join(path,"input.txt")
# sys.stdin = open(path)

input = sys.stdin.readline
import numpy as np
N = int(input())
abc = np.zeros((N,3))
for i in range(N):
    abc[i] = list(map(int,input().split()))

dp = np.zeros((N,3))
for i in range(N):
    if i == 0:
        dp[i] = abc[i]
        continue
    dp_a,dp_b,dp_c = dp[i-1]
    dp[i] = abc[i] + [max(dp_b,dp_c),max(dp_a,dp_c),max(dp_a,dp_b)]
print(int(max(dp[N-1])))