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

Fixed submission:
N=input()
a=list(N)
b=len(a)
sum=0
for i in range(b):
          a[i]=int(a[i])
          sum += a[i]
N=int(N)
if(N%sum==0):
              print("Yes")
else:
              print("No")

Buggy submission (verdict: Runtime Error):
N=input
a=list(N)
b=len(a)
sum=0
for i in range(b):
  a[i]=int(a[i])
  sum += a[i]
  print(a[i])
N=int(N)
if(N%sum==0):
      print("Yes")
else:
      print("No")

Buggy submission (verdict: Runtime Error):
N=input()
a=list(N)
b=len(a)
sum=0
for i in range(b):
  a[i]=int(a[i])
  sum += a[i]
  print(a[i])
if(N%sum==0):
  print("Yes")
else:
  print("No")
Problem p03504 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N,C = map(int,input().split())
time = [0]*(100009*2)
channel = [[0]*(100009*2) for _ in range(C)]
#(方針)チャンネル関係なしに
#同じチャンネルの連続だと録画開始時間に0.5秒のロスがない
# 同チャンネルで 1-7 7-8 → [0.5,8) → 録画機1つ(0.5~7.99) 
# 違うチャンネルで 1-7 7-8 → [0.5,7) 0.5~6.99 , [6.5,8) 6.5~7.99 → 録画機2つ

#前処理:　同チャンネル#0.5が扱いずらいので,sを2s-1,tを2tに対応させる
#ex: 1-3 → 0.5-3 → 1-6
#ex: 3-5 → 2.5-5 → 5-10
#ex: 1-3,3-5 → 1-6,5-10 → 2個必要の区間をつなげる(ex. 1-7 7-8 → 1-8）
max_num = 0
for i in range(N):
 s,t,c = map(int,input().split())
 s,t = 2*s-1,2*t 
 if(channel[c-1][s-1] == 1): channel[c-1][s-1] = 0
 else: channel[c-1][s] = 1
 channel[c-1][t] = 1
 max_num = max(max_num,t)

#imos法
#0.5が扱いずらいので,sを2s-1,tを2tに対応させる
#ex: 1-3 → 0.5-3 → 1-6
#ex: 3-5 → 2.5-5 → 5-10
#ex: 1-3,3-5 → 1-6,5-10 → 2個必要
#A = []
tmp = 0
for i in range(C):
 for j in range(max_num+10):
  if((tmp == 0)and(channel[i][j] == 1)):
    tmp = 1
    a = j
  elif((tmp == 1)and(channel[i][j] == 1)):
    tmp = 0
    b = j
    #A.append([a,b])
    time[a] += 1
    time[b+1] -= 1
#print(A)
    
ans = 0
for i in range(max_num+10):
  if(i != 0): time[i] += time[i-1]
  ans = max(ans,time[i])
print(ans)
#print(time)

Buggy submission (verdict: Runtime Error):
N,C = map(int,input().split())
num = 100009
channel = [[0]*num for _ in range(C)]
time = [0]*num

max_num = 0
for i in range(N):
  s,t,c = map(int,input().split())
  s,t,c = 2*s-1,2*t,c-1
  if(channel[c-1][s-1] == 1): channel[c-1][s-1] = 0
  channel[c-1][s] = 1 
  channel[c-1][t] = 1
  max_num = max(max_num,t)

tmp = 0
for i in range(C):
 for j in range(max_num+9):
  if((tmp == 0)and(channel[i][j] == 1)):
    tmp = 1
    a = j
  elif((tmp == 1)and(channel[i][j] == 1)):
    tmp = 0
    b = j
    time[a] += 1
    time[b+1] -= 1

ans = 0    
for i in range(max_num+9):
  if(i != 0): time[i] += time[i-1]
  ans = max(ans,time[i])
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N,C = map(int,input().split())
time = [0]*100009
channel = [[0]*100009 for _ in range(C)]
#(方針)チャンネル関係なしに
#同じチャンネルの連続だと録画開始時間に0.5秒のロスがない
# 同チャンネルで 1-7 7-8 → [0.5,8) → 録画機1つ(0.5~7.99) 
# 違うチャンネルで 1-7 7-8 → [0.5,7) 0.5~6.99 , [6.5,8) 6.5~7.99 → 録画機2つ

#前処理:　同チャンネルの区間をつなげる(ex. 1-7 7-8 → 1-8）
max_num = 0
for i in range(N):
 s,t,c = map(int,input().split())
 if(channel[c-1][s-1] == 1): channel[c-1][s-1] = 0
 else: channel[c-1][s-1] = 1
 channel[c-1][t-1] = 1
 max_num = max(max_num,t)

#imos法
A = []
tmp = 0
for i in range(C):
 for j in range(max_num):
  if((tmp == 0)and(channel[i][j] == 1)):
    tmp = 1
    a = j
  elif((tmp == 1)and(channel[i][j] == 1)):
    tmp = 0
    b = j
    a,b = a*2,b*2
    time[a] += 1
    time[b+1] -= 1

ans = 0
for i in range(max_num+1):
  if(i != 0): time[i] += time[i-1]
  ans = max(ans,time[i])
print(ans)
#print(time)
Problem p03555 (python)

Fixed submission:
a=input()
a=list(a)
b=input()
b=list(b)
n=len(a)
j=1
for i in range(n):
  if(a[i]!=b[-(i+1)]):
    j=0
if(j==1):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
    a=input()
    a=list(a)
    b=input()
    b=list(b)
    n=len(a)
    j=1
    for i in range(n):
      if(a[i]!=b[-(i+1)]):
        j=0
    if(j==1):
      print("YES")
    else:
      print("NO")

Buggy submission (verdict: Runtime Error):
    a=input().split()
    a=list(a)
    b=input().split()
    b=list(b)
    n=len(a)
    N=1
    for i in range(n):
      if(a[i]!=b[-(i+1)]):
        N=0
    if(N==1):
      print("YES")
    else:
      print("NO")

Buggy submission (verdict: Runtime Error):
a=input().split()
a=list(a)
b=input().split()
b=list()
n=len(a)
N=1
for i in range(n):
  if(a[i]!=b[-(i+1)]):
    N=0
if(N==1):
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a=input()
a=list(a)
b=input()
b=list(b)
n=len(a)
j=1
for i in range(n):
  if(a[i]!=b[n-i]):
    j=0
if(j==1):
  print("YES")
else:
  print("NO")
Problem p03556 (python)

Fixed submission:
import math
N=int(input())
n=math.sqrt(N)
m=math.floor(n)
print(m*m)

Buggy submission (verdict: Runtime Error):
def divisor_num(n):
    a = 1
    for _, x in factorization(n):
        a *= x + 1
    return a
  
N=int(input())
n=0
x=1
for i in range(N+1):
  n=divisor_num(i)
  if(i%2!=0):
   x=i
print(x)

Buggy submission (verdict: Runtime Error):
def bisearch(f, n):
    l = 0
    r = n
    fl = f(l)
    fr = f(r)
    while l <= r:
        m = (l + r) // 2
        fm = f(m)
        if fm == n:
            return m
        elif fm > n:
            r = m - 1
            fr = f(r)
        else:
            l = m + 1
            fl = f(l)

def try_square_root(n2):
    return bisearch(lambda n:n*n, n2)

N=int(input())
a=0
b=0
x=0
for i in range(N+1):
  a=try_square_root(i)
  b=int(a)
  if(i==b*b):
    x=i
print(x)
Problem p03559 (python)

Fixed submission:
import bisect
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort()
B.sort()
C.sort()
ans = 0
#順序維持のbisect (二分探索を利用したライブラリ）
for i in range(N):
    count_a = bisect.bisect_left(A,B[i])
    count_c = N -bisect.bisect_right(C,B[i])
    ans += count_a*count_c
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
All = [] #全ての数字格納リスト
B_A = [] #Biより小さいAjの個数格納リスト
B_C = [] #Biより大きいCkの個数格納リスト

for i in range(N):
  All.append([A[i],0])
  All.append([B[i],1])
  All.append([C[i],2])
All.sort()

count1,count2 = 0,0
for i in range(3*N):
  if(All[i][1] == 1):     
    if(i == 0):
      B_A.append(count1)
      if((All[i][0] == All[i+1][0])and(All[i+1][1] == 2)): B_C.append(N-count2-1)
      else: B_C.append(N-count2)
    elif(i == N-1):
      if((All[i][0] == All[i-1][0])and(All[i-1][1] == 0)): B_A.append(count1-1)
      else: B_A.append(count1)
      B_C.append(N-count2)
    else:
      if((All[i][0] == All[i-1][0])and(All[i-1][1] == 0)): B_A.append(count1-1)
      else: B_A.append(count1)
      if((All[i][0] == All[i+1][0])and(All[i+1][1] == 2)): B_C.append(N-count2-1)
      else: B_C.append(N-count2)
    
  if(All[i][1] == 0): count1 += 1
  if(All[i][1] == 2): count2 += 1

ans = 0
for i in range(N):
 ans += B_A[i]*B_C[i]
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
All = [] #全ての数字格納リスト
B_A = [] #Biより小さいAjの個数格納リスト
B_C = [] #Biより大きいCkの個数格納リスト

for i in range(N):
  All.append([A[i],0])
  All.append([B[i],1])
  All.append([C[i],2])
All.sort()

count1,count2 = 0,0
for i in range(3*N):
  if(All[i][1] == 1):     
    if((i != 0)and(i != N-1)):
      if((All[i][0] == All[i-1][0])and(All[i-1][1] == 0)): B_A.append(count1-1)
      else: B_A.append(count1)
      if((All[i][0] == All[i+1][0])and(All[i+1][1] == 2)): B_C.append(N-count2-1)
      else: B_C.append(N-count2)
    else:
      B_A.append(count1),B_C.append(N-count2)
    
  if(All[i][1] == 0): count1 += 1
  if(All[i][1] == 2): count2 += 1

ans = 0
for i in range(N):
 ans += B_A[i]*B_C[i]
print(ans)
Problem p03644 (python)

Fixed submission:
N = int(input())

if(N<2):
  print(N)
elif(2<=N<4):
  print(2)
elif(4<=N<8):
  print(4)
elif(8<=N<16):
  print(8)
elif(16<=N<32):
  print(16)
elif(32<=N<64):
  print(32)
elif(64<=N):
  print(64)

Buggy submission (verdict: Runtime Error):
N=int(input())
count=0
C=[]
for i in range(N):
 if(i!=0):
  a=int(i/2)
  if(i%2==0):
    count +=1
    while(a%2!=1):
     count +=1
     a=int(a/2)
  else:
     count =0
  C.append(count)
b=max(C)
for i inrange(N):
 C[i]==b
 print(i)
Problem p03944 (python)

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

x1 = 0
x2 = W
y1 = 0
y2 = H
rectangle_S = W*H
black_S = 0
judge = 1 #1:黒部分全部でない,0:黒部分全部

for i in range(N):
  x,y,a = map(int,input().split())
  if(a == 1):
    if(x < x1):
     black_S += 0
     x1 = x1
    elif(x1 <= x <= x2):
     black_S += (x-x1)*(y2-y1)
     x1 = x
    elif(x2 < x):
     black_S = W*H
     break      
  elif(a == 2):
    if(x < x1):
     black_S = W*H
     judge = 0 #黒全部
    elif(x1 <= x <= x2):
     black_S += (x2-x)*(y2-y1)
     x2 = x
    elif(x2 < x):
     black_S += 0
     #x2 = x2   
  elif(a == 3):
    if(y < y1):
     black_S += 0
     y1 = y1
    elif(y1 <= y <= y2):
     black_S += (y-y1)*(x2-x1)
     y1 = y
    elif(y2 < y):
     black_S = W*H
     judge = 0   
  elif(a == 4):
    if(y < y1):
     black_S = W*H
     judge = 0 #黒全部
    elif(y1 <= y <= y2):
     black_S += (y2-y)*(x2-x1)
     y2 = y
    elif(y2 < y):
     black_S += 0
     #y2 = y2

if(judge == 0):
  print(0)
else:
  print(rectangle_S - black_S)

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

x1 = 0
x2 = W
y1 = 0
y2 = H
rectangle_S = W*H
black_S = 0
judge = 1 #1:黒部分全部でない,0:黒部分全部

for i in range(N):
  x,y,a = map(int,input().split())
  if(a == 1):
    if(x < x1):
     balck_S += 0
     x1 = x1
    elif(x1 <= x <= x2):
     black_S += (x-x1)*(y2-y1)
     x1 = x
    elif(x2 < x):
     black_S = W*H
     break      
  elif(a == 2):
    if(x < x1):
     black_S = W*H
     judge = 0
    elif(x1 <= x <= x2):
     black_S += (x2-x)*(y2-y1)
     x2 = x
    elif(x2 < x):
     black_S += 0
     x2 = x2   
  elif(a == 3):
    if(y < y1):
     balck_S += 0
     y1 = y1
    elif(y1 <= y <= y2):
     black_S += (y-y1)*(x2-x1)
     y1 = y
    elif(y2 < y):
     black_S = W*H
     judge = 0   
  elif(a == 4):
    if(y < y1):
     black_S = W*H
     break
    elif(y1 <= y <= y2):
     black_S += (y2-y)*(x2-x1)
     y2 = y
    elif(y2 < y):
     black_S += 0
     y2 = y2
  #print(x1,x2,y1,y2,black_S)
if(judge == 0):
  print(0)
else:
  print(rectangle_S - black_S)

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

x1 = 0
x2 = W
y1 = 0
y2 = H
rectangle_S = W*H
black_S = 0

for i in range(N):
  x,y,a = map(int,input().split())
  if(a == 1):
    if(x < x1):
     balck_S += 0
     x1 = x1
    elif(x1 <= x <= x2):
     black_S += (x-x1)*(y2-y1)
     x1 = x
    elif(x2 < x):
     black_S = W*H
     break      
  elif(a == 2):
    if(x < x1):
     black_S = W*H
     break
    elif(x1 <= x <= x2):
     black_S += (x2-x)*(y2-y1)
     x2 = x
    elif(x2 < x):
     black_S += 0
     x2 = x2   
  elif(a == 3):
    if(y < y1):
     balck_S += 0
     y1 = y1
    elif(y1 <= y <= y2):
     black_S += (y-y1)*(x2-x1)
     y1 = y
    elif(y2 < y):
     black_S = W*H
     break     
  elif(a == 4):
    if(y < y1):
     black_S = W*H
     break
    elif(y1 <= y <= y2):
     black_S += (y2-y)*(x2-x1)
     y2 = y
    elif(y2 < y):
     black_S += 0
     y2 = y2
  #print(x1,x2,y1,y2,black_S)
  
print(rectangle_S - black_S)
Problem p03962 (python)

Fixed submission:
a = input().split()
a = list(a)
for i in range(3):
  a[i] = int(a[i])
a.sort()

if(a[0] == a[1]):
  if(a[1] == a[2]):
    print(1)
  else:
    print(2)
elif(a[1] == a[2]):
  print(2)
else:
  print(3)

Buggy submission (verdict: Runtime Error):
#include <iostream>
using namespace std;

int main() {
	int a , b , c ;
    int count = 3;
	cin >> a >> b >> c;
	if(a == b) count -= 1;
    if(a == c) count -= 1;
    if(b == c) count -= 1;
    if(count == 0) count += 1;
    cout << count;
      
	return 0;
}
Problem p04045 (python)

Fixed submission:
import itertools
N,K = map(int,input().split())
D = list(map(int,input().split()))

#使用可能数字の取り出し
Num1 = []
for i in range(10):
  if(i in D): continue
  else: Num1.append(i)
 
#組み合わせ
Comb = []
n = len(str(N))
for i in range(n+1):
  Comb.append(Num1)
Comb = list(itertools.product(*Comb))

ans = -1
for i in range(len(Comb)):
  tmp = Comb[i]
  tmp_num = ''
  for j in range(n): tmp_num += str(tmp[j])
  tmp_num = int(tmp_num)
  if(N <= tmp_num):
    ans = tmp_num
    break
    
if(ans == -1):
  for i in range(len(Comb)):
   tmp = Comb[i]
   tmp_num = ''
   for j in range(n+1): tmp_num += str(tmp[j])
   tmp_num = int(tmp_num)
   if(N <= tmp_num):
     ans = tmp_num
     break
print(ans)

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

#使用可能数字の取り出し
Num1 = []
for i in range(10):
  if(i in D): continue
  else: Num1.append(i)
 
#組み合わせ
Comb = []
n = len(str(N))
for i in range(n):
  Comb.append(Num1)
Comb = list(itertools.product(*Comb))

for i in range(len(Comb)):
  tmp = Comb[i]
  tmp_num = ''
  for j in range(n): tmp_num += str(tmp[j])
  tmp_num = int(tmp_num)
  if(N <= tmp_num):
    ans = tmp_num
    break
    
print(ans)

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

#使用可能数字の取り出し
Num = [1]*10 #index = num, 使用可能: 1,使用不可: 0
Num1 = [] #使用可能数字格納
for i in range(K):
  Num[D[i]] = 0
for i in range(10):
  if(Num[i] == 1):Num1.append(i)
 
#組み合わせ
Comb = []
n = len(str(N))
for i in range(n):
  Comb.append(Num1)
Comb = list(itertools.product(*Comb))

for i in range(len(Comb)):
  tmp = Comb[i]
  tmp_num = ''
  for j in range(n): tmp_num += str(tmp[j])
  tmp_num = int(tmp_num)
  if(N <= tmp_num):
    ans = tmp_num
    break
    
print(ans)
Problem p02684 (python)

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

genzaichi=1
rireki=set()
houmon=[0]*(N+1)
flag=0

for i in range(1,K+1):
    genzaichi=A[genzaichi-1]
    if genzaichi not in rireki:
        houmon[genzaichi]=i
        rireki.add(genzaichi)
    else:
        roop_from=genzaichi
        x=houmon[roop_from]
        roop=i-x
        flag=1
        break

if flag==0:
    print(genzaichi)
else:
    genzaichi=roop_from
    K=(K-x)-((K-x)//roop)*roop
    for i in range(K):
        genzaichi=A[genzaichi-1]
    print(genzaichi)

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

genzaichi=1
rireki=set()
houmon=[0]*(N+1)
flag=0

for i in range(1,K+1):
    genzaichi=A[genzaichi-1]
    if genzaichi not in rireki:
        houmon[genzaichi]=i
        rireki.append(genzaichi)
    else:
        roop_from=genzaichi
        x=houmon[roop_from]
        roop=i-x
        flag=1
        break

if flag==0:
    print(genzaichi)
else:
    genzaichi=roop_from
    K=(K-x)-((K-x)//roop)*roop
    for i in range(K):
        genzaichi=A[genzaichi-1]
    print(genzaichi)

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

genzaichi=1
rireki=[]
houmon=[0]*(N+1)
flag=0

for i in range(1,K+1):
    genzaichi=A[genzaichi-1]
    if genzaichi not in rireki:
        houmon[genzaichi]=i
        rireki.append(genzaichi)
    else:
        roop_from=genzaichi
        x=houmon[roop_from]
        roop=i-x
        flag=1
        break

print("now")
print(x)
print(roop)
print(roop_from)
print(flag)

genzaichi=1
if flag==1:
    K=K-(((K-x)//roop)-1)*roop
    print(K)

for i in range(K):
    genzaichi=A[genzaichi-1]

print(genzaichi)

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

genzaichi=1
rireki=[]
houmon=[0]*(N+1)

for i in range(1,K+1):
    genzaichi=A[genzaichi-1]
    if genzaichi not in rireki:
        houmon[genzaichi]=i
        rireki.append(genzaichi)
    else:
        roop_from=genzaichi
        x=houmon[roop_from]
        roop=i-x
        break

genzaichi=1
if K>=x+roop:
    K=K-x-roop
    genzaichi=roop_from

for i in range(N):
    genzaichi=A[genzaichi-1]

print(genzaichi)
Problem p02748 (python)

Fixed submission:
#入力処理
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
kingaku=[]
for i in range(M):
    x_input, y_input, c_input = map(int, input().split())
    kingaku.append(a[x_input-1]+b[y_input-1]-c_input)
kingaku.append(min(a)+min(b))

print(min(kingaku))

Buggy submission (verdict: Runtime Error):
#入力処理
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
kingaku=[]
for i in range(M):
    x_input, y_input, c_input = map(int, input().split())
    kingaku.append(a[x_input-1][y_input-1]+b[x_input-1][y_input-1]+c_input)
kingaku.append(min(a)+min(b))

print(min(kingaku))
Problem p02911 (python)

Fixed submission:
n,k,q=map(int,input().split())
A=[int(input()) for i in range(q)]

tokuten=[0]*n

for i in range(q):
    tokuten[A[i-1]-1]=tokuten[A[i-1]-1]+1

for i in range(n):
    if tokuten[i]>q-k:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
n,k,q=map(int,input().split())
A=[int(input()) for i in range(q)]

tokuten=[0]*n

for i in range(q):
    tokuten[A[i-1]-1]=tokuten[A[i-1]-1]+1

for i in range(n):
    if tokuten[i]>=q-k+1
        print("Yes")
    else:
        print("No")
Problem p02621 (python)

Fixed submission:
a = int(input())
k = a + a**2 + a**3
print(k)

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
k = len(T)
m = 0
for i in range(k):
  if S[i] != T[i]:
    m += 1
print(m)
Problem p03160 (python)

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

dp = [float("inf")] * N
dp[0] = 0
for i in range(N+1):
    try:
        dp[i+1] = min(dp[i+1], dp[i]+abs(H[i+1]-H[i]))
        dp[i+1] = min(dp[i+1], dp[i-1]+abs(H[i+1]-H[i-1]))
    except:
        continue

print(dp[-1])

Buggy submission (verdict: Runtime Error):
import numpy as np


N = int(input())
abc = []
for n in range(N):
    abc.append(list(map(int, input().split())))

# initialize
dp = np.zeros((N+1, 3))

# dp    
for i in range(N+1):
    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            try:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + abc[i][k])
            except:
                pass

print(int(max(dp[-1])))

Buggy submission (verdict: Runtime Error):
num = list(map(int, input().split()))
H = list(map(int, input().split()))
N = num[0]
K = num[1]

dp = [float("inf")] * N
dp[0] = 0
for i in range(N):
    try:
        for j in range(K):
            dp[i+1] = min(dp[i+1], dp[i-j]+abs(H[i+1]-H[i-j]))
    except:
        continue

print(dp[-1])
Problem p03162 (python)

Fixed submission:
N = int(input())
abc = []
for n in range(N):
    abc.append(list(map(int, input().split())))

# initialize
dp = [[-float("inf")]*3 for i in range(N+1)]
for i in range(3):
    dp[0][i] = 0

# dp    
for i in range(N+1):
    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            try:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + abc[i][k])
            except:
                pass

print(int(max(dp[-1])))

Buggy submission (verdict: Runtime Error):
import numpy as np


N = int(input())
abc = []
for n in range(N):
    abc.append(list(map(int, input().split())))

# initialize
dp = np.zeros((N+1, 3))

# dp    
for i in range(N+1):
    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            try:
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + abc[i][k])
            except:
                pass

print(int(max(dp[-1])))
Problem p03471 (python)

Fixed submission:
all = list(map(int, input().split()))

N = all[0]
Y = all[1]

yu = -1
hi = -1
no = -1
for i in range(N+1):
    for j in range((N+1)-i):
        c = (N-(i+j))
        total = 10000*i + 5000*j + 1000*c
        if Y==total:
            yu = i
            hi = j
            no = c
            break
        else:
            continue
    else:
        continue 
    break

print(str(yu) + " " + str(hi) + " " + str(no))

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

N = all[0]
Y = all[1]

yu = -1
hi = -1
no = -1
for i in range(N):
    for j in range(N-i):
        c = (N-(i+j))
        total = 10000*i + 5000*j + 1000*c
        if Y!=total:
            continue
        else:
            yu = i
            hi = j
            no = c
            check += 1
            break
    else:
        continue 
    break

print(yu)
print(" ")
print(hi)
print(" ")
print(no)
print(" ")

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

N = all[0]
Y = all[1]

check = 0
for i in range(N):
    j = 0
    for j in range(N-(i+j)):
        c = (N-(i+j))
        total = 10000*i + 5000*j + 1000*c
        if Y!=total:
            continue
        else:
            yu = i
            hi = j
            no = c
            check += 1
            break
    else:
        continue 
    break

if check==100:
    yu = -1
    hi = -1
    no = -1

print(yu)
print(" ")
print(hi)
print(" ")
print(no)
print(" ")

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

N = all[0]
Y = all[1]

check = 0
for i in range(N):
    for j in range(N-(i+j)):
        c = (N-(i+j))
        total = 10000*i + 5000*j + 1000*c
        if Y!=total:
            continue
        else:
            yu = i
            hi = j
            no = c
            check += 1
            break
    else:
        continue 
    break

if check==100:
    yu = -1
    hi = -1
    no = -1

print(yu)
print(" ")
print(hi)
print(" ")
print(no)
print(" ")

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

N = all[0]
Y = all[1]

check = 0
for i in range(N):
    for j in range(N-i):
        c = (N-(i+j))
        total = 10000*i + 5000*j + 1000*c
        if Y!=total:
            continue
        else:
            yu = i
            hi = j
            no = c
            check += 1
            break
    else:
        continue 
    break

if check==100:
    yu = -2
    hi = -1
    no = -1

print(yu)
print(" ")
print(hi)
print(" ")
print(no)
print(" ")

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

N = all[0]
Y = all[1]

for i in range(N):
    for j in range(N-i):
        if N!=i+j+abs(N-(i+j)):
            yu = -1
            hi = -1
            no = -1
            break
        else:
            total = 10000*i + 5000*j + 1000*(N-(i+j))
            if Y!=total:
                continue
            else:
                yu = i
                hi = j
                no = (N-(i+j))
    else:
        continue
    break

print(str(yu) + " " + str(hi) + " " + str(no))
Problem p03493 (python)

Fixed submission:
vec = str(input())
cnt = 0
for s in vec:
    if s=="1":
        cnt += 1

print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
cnt = 0
while True:
    for i in range(N):
        if A[i]%2==1:
            break
        A[i] = A[i]//2
    else:
        cnt += 1
        continue
    break
Problem p02612 (python)

Fixed submission:
N = int(input())
n=N%1000
if(n>0):
    print(1000-n)
else:
    print(0)

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

print(1000-N%1000)

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

print(N%1000)
Problem p02621 (python)

Fixed submission:
a = int(input())
b = a + a**2 + a**3
print(b)

Buggy submission (verdict: Runtime Error):
a,b,c = (int(i) for i in input().split())
N = list(map(int, input().split())) 
M = list(map(int, input().split())) 
n = 0
m = 0
e = 0
for i in range(a+b):
  if N[n] < M[m] and n < a:
    c -= N[n]
    e += 1
    print(c)
    n += 1
  elif N[n] > M[m] and m < a:
    c -= M[m]
    e += 1
    m += 1
    print(c)

  if c < 0:
    e -= 1
    break

print(e)
Problem p03280 (python)

Fixed submission:
length, width = map(int, input().split())
print((length-1)*(width-1))

Buggy submission (verdict: Runtime Error):
length, width = map(input().split())
print((length-1)*(width-1))