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

Fixed submission:
N=int(input())
X=list(map(int, input().split()))
ans=1
if 0 in X:
    print(0)
else:
    for i in range(N):
        ans *= X[i]
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)

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

ans=1
if 0 in X:
    print(0)
else:
    X.sorted(reverse = True)
    for i in range(N):
        ans *= X[i]
        if 10**18<ans:
            print(-1)
            break
    else:
        print(ans)

Buggy submission (verdict: Runtime Error):
_=input()
X=int(eval(input().replace(*' *')))
print(X if X <= 1e18 else -1)

Buggy submission (verdict: Runtime Error):
_=input()
X=int(eval(input().replace(*' *')))
print(X if X=<1e18 else -1)

Buggy submission (verdict: Runtime Error):
_=input()
X=eval(input().replace(*' *'))
print(X if X<10**18 else -1)

Buggy submission (verdict: Runtime Error):
_=input()
X=eval(input().replace(*' *'))
print(X if X<= 10**18 else -1)
Problem p02910 (python)

Fixed submission:
import re
S=input()
print("NYoe s"[len(re.sub("[RUD]",'',S[0::2]))==0==len(re.sub("[LUD]",'',S[1::2]))::2])

Buggy submission (verdict: Runtime Error):
S=input()
print("NYoe s"[len(re.sub("[RUD]",'',S[0::2]))==0==len(re.sub("[LUD]",'',S[1::2]))::2])
Problem p02936 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**7)
 
N, Q = map(int, input().split())
graph = [[] for i in range(N)]
cnt = [0]*N

# 入力しながらグラフを作成
for i in range(N-1):
  a, b = map(int, input().split())
  a, b = a-1, b-1
  graph[a].append(b)
  graph[b].append(a)

# 初期値を設定
for i in range(Q):
  p, x = map(int, input().split())
  cnt[p-1] += x

v = [False]*N

# stack=[]
def dfs(n,prv):
  # stack.append(n)
  if v[n]: return
  cnt[n] += prv
  v[n] = True
  for nv in graph[n]:
    dfs(nv, cnt[n])
   
dfs(0,0)
print(*cnt)
# print(stack)

Buggy submission (verdict: Runtime Error):
N,Q=map(int,input().split())
G=[list(map(int,input().split())) for _ in range(N-1)]
P=[list(map(int,input().split())) for _ in range(Q)]

gr=[[]]*N
for i in G:
    v=i[0]
    gr[v-1]=[*gr[v-1],i[1]]

cnt=[0]*N

def dfs(p,x):
    cnt[p-1]+=x
    for n in gr[p-1]:
        dfs(n,x)
    return

for p,x in P:
    dfs(p,x)
print(' '.join(map(str,cnt)))
Problem p02953 (python)

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

for i in range(-1,-len(H),-1):
   #print(i,H[i],H[i-1])
   if H[i]<H[i-1]-1:
    print('No')
    break
   if H[i-1]-1 == H[i]:
    H[i-1]=H[i]
else:
   print('Yes')

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

p1=p2=0
for i in H:
   print(prv,i,i<prv-1,prv<=i, prv-1<=i)
   if i<max(p2,p1-1):
    #print('No')
    break
   if i<p1:
    p2=p1-1
   else:
    p2=p1
   p1=i
else:
    print('Yes')
Problem p03244 (python)

Fixed submission:
N=int(input())
*V,=map(int,input().split())
import collections

import collections

c1=collections.Counter(V[0::2])
c1=sorted(c1.items(), key=lambda x: x[1], reverse=True)
e=c1[0][0]

c2=collections.Counter(V[1::2])
c2=sorted(c2.items(), key=lambda x: x[1], reverse=True)
o=c2[0][0]

cnt=0
if e!=o:
    cnt=sum(e!=i for i in V[0::2])
    cnt+=sum(o!=i for i in V[1::2])
else:
    if len(c1)==1 and len(c2)==1:
        cnt=N//2
    elif len(c1)==1:
        cnt1=sum(e!=i for i in V[0::2])
        cnt1+=sum(c2[1][0]!=i for i in V[1::2])
        
        cnt2=sum(e!=i for i in V[0::2])
        cnt2+=sum(c2[1][1]!=i for i in V[1::2])
        cnt=min(cnt1,cnt2)
    elif len(c2)==1:
        cnt1=sum(c1[1][0]!=i for i in V[0::2])
        cnt1+=sum(o!=i for i in V[1::2])

        cnt2=sum(c1[1][1]!=i for i in V[0::2])
        cnt2+=sum(o!=i for i in V[1::2])
        cnt=min(cnt1,cnt2)
    else:    
        cnt1=sum(e!=i for i in V[0::2])
        cnt1+=sum(c2[1][0]!=i for i in V[1::2])
        
        cnt2=sum(c1[1][0]!=i for i in V[0::2])
        cnt2+=sum(o!=i for i in V[1::2])
        cnt=min(cnt1,cnt2)
print(cnt)

Buggy submission (verdict: Runtime Error):
N=int(input())
*V,=map(int,input().split())
import Counter from collections 

c1=Counter(V[0::2]).most_common()+[(0,0)]
c2=Counter(V[1::2]).most_common()+[(0,0)]
if c1[0][0]!=c2[0][0]:
    print(N-c1[0][1]-c2[0][1])
else:
    print(min(N-c1[0][1]-c2[1][1],N-c1[1][1]-c2[0][1]))

Buggy submission (verdict: Runtime Error):
N=int(input())
*V,=map(int,input().split())
import collections import Counter

c1=Counter(V[0::2]).most_common()+[(0,0)]
c2=Counter(V[1::2]).most_common()+[(0,0)]
if c1[0][0]!=c2[0][0]:
    print(N-c1[0][1]-c2[0][1])
else:
    print(min(N-c1[0][1]-c2[1][1],N-c1[1][1]-c2[0][1]))
Problem p03282 (python)

Fixed submission:
S=input()
K=int(input())

for i in range(K):
    if S[i]!='1':
        print(int(S[i]))
        break
else:
    print(1)

Buggy submission (verdict: Runtime Error):
S=input()
K=int(input())

for i in range(K):
    if s[i]!='1':
        print(int(s[i]))
        break
else:
    print(1)
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
print("Even" if a*b % 2 == 0 else "Odd")

Buggy submission (verdict: Runtime Error):
import sys

args = sys.argv

# print(args[0])

x1 = int(args[1])
x2 = int(args[2])

if (x1 * x2) % 2 == 0 :
    print("Even")
else:
    print("Odd")
Problem p03457 (python)

Fixed submission:
N=int(input())
P=[(0,0,0)]*(N+1)

D=[0]*(N+1)

P[0]=(0,0,0)
D[0]=1
for i in range(1,N+1):
    t,x,y=map(int,input().split())
    dt=t-P[i-1][0]
    dx=abs(x-P[i-1][1])
    dy=abs(y-P[i-1][2])
    if dt < (dx+dy): #時間<移動距離
        print('No')
        break
    if ((dx+dy)==0 and dt%2!=0): #移動しない場合には時間はmod2==0
        print('No')
        break
    #if (dt-(dx+dy))%2==0 or dt%(dx+dy)==0:
    if (dt-(dx+dy))%2!=0:
        print('No')
        break
    
    P[i]=(t,x,y)
else:
    print('Yes')

Buggy submission (verdict: Runtime Error):
N=int(input())
P=[(0,0,0)]*(N+1)

D=[0]*(N+1)

P[0]=(0,0,0)
D[0]=1
for i in range(1,N+1):
    t,x,y=map(int,input().split())
    dt=t-P[i-1][0]
    dx=abs(x-P[i-1][1])
    dy=abs(y-P[i-1][2])
    if dt < (dx+dy): 時間<移動距離
        print('No')
        break
    if ((dx+dy)==0 and dt%2!=0):移動しない場合には時間はmod2==0
        print('No')
        break
    #if (dt-(dx+dy))%2==0 or dt%(dx+dy)==0:
    if (dt-(dx+dy))%2!=0:
        print('No')
        break
    
    P[i]=(t,x,y)
else:
    print('Yes')
Problem p03549 (python)

Fixed submission:
N,M=map(int,input().split())
print((M*1900+100*(N-M))*(2**M))

Buggy submission (verdict: Runtime Error):
N,M=map(int,input().split())
import sympy as sym
oo = sym.oo
n=sym.symbols('n')
t=M*1900+(N-M)*100
p=(1/2)**M
q=1-(1/2)**M
print(sym.summation(n*t*p*q**(n-1), (n, 1, oo)))
Problem p03565 (python)

Fixed submission:
S=input()
T=input()

lt=len(T)
ls=len(S)
S+='%'*lt

if ls<lt:
    flg=0
else:
    for i in range(ls-lt+1,-1,-1):
        # print('***',S[i:i+lt])
        flg=1
        for j in range(i,i+lt):
            s=S[j]
            # print(s,T[j-i])
            if s=='?': continue
            if s=='%' or s!=T[j-i]:
                flg=0
                break
        if flg==1:
            break
if flg:
    print((S[0:i]+T+S[i+lt:ls]).replace('?','a'))
else:
    print('UNRESTORABLE')

Buggy submission (verdict: Runtime Error):
S=input()
T=input()

lt=len(T)
ls=len(S)
S+='%'*lt

for i in range(ls-lt+1):
    # print('***',S[i:i+lt])
    flg=1
    for j in range(i,i+lt):
        s=S[j]
        # print(s,T[j-i])
        if s=='?': continue
        if s=='%' or s!=T[j-i]:
            flg=0
            break
    if flg==1:
        break
if flg:
    print((S[0:i]+T+S[i+lt:ls]).replace('?','a'))
else:
    print('UNRESTORABLE')
Problem p03612 (python)

Fixed submission:
N=int(input())
P=map(int,input().split())
S=[]
for x,y in zip(P, range(1,N+1)):
    if x==y: S.append(y)

S.append('$')
L=len(S)

lake=[]
lake.append(S[0])
i=1
a=0
while i<L:
    if S[i]=='$':
     a+=1
    elif lake[0]+1!=S[i]:
     a+=1
     lake=[]
     lake.append(S[i])
    else:
     lake.append(S[i])
    i+=1
print(a)

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

i=c=0
while i<L:
  if P[i]==i+1:
    c+=1
    i+=1
  i+=1
print(c)
Problem p03773 (python)

Fixed submission:
A,B=map(int, input().split())
print(A+B) if (A+B) < 24 else print(A+B-24)

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

ans = 10**18

for i in range(1, int(N**0.5)+1):
    if N % i == 0:
        b = N//i
        ans = min(ans, max( len(str(i)),  len(str(b))))
print(ans)
Problem p02713 (python)

Fixed submission:
from math import gcd
 
K=int(input())
 
S=0
for a in range(1,K+1):
    for b in range(1,K+1):
        calc=gcd(a,b)
        for c in range(1,K+1):
                S+=gcd(calc,c)
 
print(S)

Buggy submission (verdict: Runtime Error):
import numpy as np
 
K=int(input())
 
S=0
for a in range(1,K+1):
    for b in range(1,K+1):
        calc=np.gcd(a,b)
        for c in range(1,K+1):
                S+=np.gcd(calc,c)
 
print(S)

Buggy submission (verdict: Runtime Error):
import numpy as np
 
K=int(input())
 
S=0
for a in range(1,K+1):
    for b in range(1,K+1):
        calc=np.gcd(a,b)
        for c in range(1,K+1):
            if(c%calc==0):
                S+=calc
            else:
                S+=np.gcd(calc,c)
 
print(S)

Buggy submission (verdict: Runtime Error):
import numpy as np
 
K=int(input())
 
S=0
for a in range(1,K+1):
    for b in range(1,K+1):
        calc=np.gcd(a,b)
        for c in range(1,K+1):
            if(c%calc==0):
                S+=calc
            else:
                S+=np.gcd(calc,c)
 
print(S)
Problem p02802 (python)

Fixed submission:
import numpy as np

NM=np.array(input().split(" "),dtype=np.int32)

result={}
tmp=[]

for i in range(NM[1]):
    s=input().split(" ")
    result.setdefault(s[0],[]).append(s[1])

corrects=0
penalty=0
keys=result.keys()

for k in keys:
    L=result[k]
    if('AC' in L):
        idx=L.index('AC')
    else:
        idx=-1
    if(idx==-1):
        continue
    else:
        penalty+=idx
        corrects+=1

print("{} {}".format(corrects,penalty))

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

NM=np.array(input().split(" "),dtype=np.int32)

result={}
tmp=[]

for i in range(NM[1]):
    s=input().split(" ")
    result.setdefault(s[0],[]).append(s[1])

corrects=0
penalty=0
keys=result.keys()

for k in keys:
    L=result[k]
    idx=L.index('AC')
    if(idx==-1):
        continue
    else:
        penalty+=idx
        corrects+=1

print("{} {}".format(corrects,penalty))

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

NM=np.array(input().split(" "),dtype=np.int32)

result={}
pre_idx=""
tmp=[]
for i in range(NM[1]):
    s=input().split(" ")
    idx=s[0]
    if(pre_idx!=idx):
        result[idx]=[]
        result[idx].append(s[1])
    else:
        result[idx].append(s[1])
    pre_idx=idx

corrects=0
penalty=0
keys=result.keys()

for k in keys:
    L=result[k]
    idx=L.index('AC')
    if(idx==-1):
        continue
    else:
        penalty+=idx
        corrects+=1

print("{} {}".format(corrects,penalty))

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

NM=np.array(input().split(" "),dtype=np.int32)

result={}
pre_idx=""
tmp=[]
for i in range(NM[1]):
    s=input().split(" ")
    idx=s[0]
    if(pre_idx==idx):
        tmp.append(s[1])
        if(i==NM[1]-1):
            result[pre_idx]=tmp
    elif(pre_idx!=idx):
        tmp=[]
        result[idx]=tmp
        tmp.append(s[1])
        pre_idx=idx

corrects=0
penalty=0
keys=result.keys()

for k in keys:
    L=result[k]
    idx=L.index('AC')
    if(idx==-1):
        continue
    else:
        penalty+=idx
        corrects+=1

print("{} {}".format(corrects,penalty))
Problem p02971 (python)

Fixed submission:
import numpy as np

N=int(input())

X=[]
for x in range(N):
    X.append(int(input()))

Y=[]
Y=np.sort(X)[::-1]

for i in range(N):
    ans=Y[0]
    if ans==X[i]:
        ans=Y[1]
    print(ans)

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

N=int(input())

X=[]
for x in range(N):
    X.append(int(input()))

Y=[]
Y=np.sort(X)[::-1]

for i in range(N):
    ans=s[0]
    if ans==X[i]:
        ans=s[1]
    print(ans)
Problem p02639 (python)

Fixed submission:
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
#n = int(input())
#a, v = map(int, sys.stdin.readline().split())
#s = input()
x = list(map(int, sys.stdin.readline().split()))
     

for i in range(5):
    if x[i] == 0:
        print(i+1)

Buggy submission (verdict: Runtime Error):
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
n = int(input())
#x, y = map(int, sys.stdin.readline().split())
#s = input()
a = list(map(int, sys.stdin.readline().split()))
     
def make_divisors(n):
    i = 1
    while i*i <= n:
        if n % i == 0:
            p = i
            q = n//i
            if p in d:
                return 0
            if q in d:
                return 0
        i += 1
    return 1

a.sort()
ans = 0
if a[0] == a[1]:
    ans -= 1
d = {}
for j in range(n):
    ans += make_divisors(a[j])
    d[a[j]] = a[j]

print(ans)
Problem p02756 (python)

Fixed submission:
import sys
import math
import collections
from collections import deque
def main():
    #n = int(input())
    #a, b = map(int, input().split())
    s = input()
    #x = list(map(int, input().split()))
    q = int(input())
    d = deque([])
    for i in range(len(s)):
        d.append(s[i])

    rev = 1
    for i in range(q):
        que = sys.stdin.readline().split()
        if que[0] == "1":
            rev *= -1

        else:
            if rev == 1:
                if que[1] == "1":
                    d.appendleft(que[2])
                else:
                    d.append(que[2])

            else:
                if que[1] == "1":
                    d.append(que[2])
                else:
                    d.appendleft(que[2])


    if rev == 1:
        for i in range(len(d)):
            print(d.popleft(), end="")
    else:
        for i in range(len(d)):
            print(d.pop(), end="")

main()

Buggy submission (verdict: Runtime Error):
import sys
import math
import collections
from collections import deque
#n = int(input())
#a, b = map(int, input().split())
s = input()
#x = list(map(int, input().split()))
q = int(input())
d = deque([])
for i in range(len(s)):
    d.append(s[i])

rev = 1
for i in range(q):
    que = list(map(int, input().split()))
    if que[0] == "1":
        rev *= -1

    else:
        if rev == 1:
            if que[1] == "1":
                d.appendleft(que[2])
            else:
                d.append(que[2])

        else:
            if que[1] == "1":
                d.append(que[2])
            else:
                d.appendleft(que[2])


if rev == 1:
    for i in range(len(d)):
        print(d.popleft(), end="")
else:
    for i in range(len(d)):
        print(d.pop(), end="")
Problem p02797 (python)

Fixed submission:
n, k, s = map(int, input().split())

if s != 10 ** 9:
    for i in range(n):
        if i < k:
            print(s, end=" ")
        else:
            print(s+1, end=" ")

else:
    for i in range(n):
        if i < k:
            print(s, end=" ")
        else:
            print(s-1, end=" ")

Buggy submission (verdict: Runtime Error):
n, k, s = map(int, input().split())

if s != 10 ** 9
    for i in range(n):
        if i < k:
            print(s, end=" ")
        else:
            if s+1
            print(s+1, end=" ")

else:
    for i in range(n):
        if i < k:
            print(s, end=" ")
        else:
            if s+1
            print(s-1, end=" ")
Problem p02888 (python)

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

l.sort(reverse=True)
ans = 0
for i in range(n-2):
    j = i+1
    k = n-1
    while (j < k):
        if l[i] - l[j] - l[k] < 0:
            ans += k - j
            j += 1
        else:
            k -= 1

print(ans)

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

l = sorted(l, reverse = True)
count = 1
same = []
two = []
ans = 0
for i in range(n-1):
    if l[i] == l[i+1]:
        count += 1
        if l[i] not in same:
            same.append(l[i])
    else:
        if count >= 2:
            two.append(l[i])
        count = 1
    
if count >= 2:
    two.append(l[i])

         
for i in range(len(same)):
    l = [j for j in l if j != same[i]]
    l.append(same[i])


l = sorted(l, reverse = True)
for i in range(len(l)-2):
    for j in range(len(l)-2-i):
        if l[i] > 2 * l[i+j+1]:
            break
        for k in range(len(l)-2-i-j):
            if l[i] < l[i+j+1] + l[i+j+k+2]:
                ans += 1
            else:
                break

for i in range(len(two)):
    for j in range(len(l)):
        if 2 * l[two[i]] > l[j] > int(l[two[i]] / 2):
            ans += 1
print(ans)
Problem p02903 (python)

Fixed submission:
h, w, a, b = map(int, input().split())

ans = []
for i in range(b):
    l = [1 for j in range(w)]
    ans.append(l)

for i in range(h-b):
    l = [0 for j in range(w)]
    ans.append(l)

if h % 2 == 0:
    m = int(h/2)
else:
    m = int(h/2) + 1

for i in range(m):
    if sum(ans[2*i]) != a or sum(ans[2*i]) != w-a:
        for j in range(min(abs(sum(ans[2*i])-a), abs(sum(ans[2*i])-w+a))):
            ans[2*i][j] = 1 - ans[2*i][j]
            if i != int(h/2):
                ans[2*i+1][j] = 1 - ans[2*i+1][j]
                
for i in range(len(ans)):
    for j in range(len(ans[i])):
        print(ans[i][j], end="")
    print()

Buggy submission (verdict: Runtime Error):
h, w, a, b = map(int, input().split())

ans = []
for i in range(b):
    l = [1 for j in range(w)]
    ans.append(l)

for i in range(h-b):
    l = [0 for j in range(w)]
    ans.append(l)
    

for i in range(int(h/2)+1):
    if sum(ans[2*i]) != a or sum(ans[2*i]) != w-a:
        for j in range(min(abs(sum(ans[2*i])-a), abs(sum(ans[2*i])-w+a))):
            ans[2*i][j] = 1 - ans[2*i][j]
            if 2 * i + 1 != h:
                ans[2*i+1][j] = 1 - ans[2*i+1][j]

for i in range(len(ans)):
    for j in range(len(ans[i])):
        print(ans[i][j], end="")
    print()
Problem p03047 (python)

Fixed submission:
n, k = map(int, input().split())

print(n-k+1)

Buggy submission (verdict: Runtime Error):
n, k = map(int, input(9.split()))

print(n-k+1)
Problem p03076 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
s = [a, b, c, d, e]
u = []
v = []
ans = 0

for i in range(len(s)):
    if s[i] % 10 == 0:
        ans += s[i]
    else:
        u.append(s[i])
        v.append(s[i] % 10)

if len(v) != 0:
    k = min(v)
    for j in range(len(u)):
        ans += u[j] + 10 - v[j]
        
    ans = ans - 10 + k
print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
s = [a, b, c, d, e]
u = []
v = []
ans = 0

for i in range(len(s)):
    if s[i] % 10 == 0:
        ans += s[i]
    else:
        u.append(s[i])
        v.append(s[i] % 10)

k = min(v)
for j in range(len(u)):
    ans += u[j] + 10 - v[j]
    
ans = ans - 10 + k
print(ans)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
s = [a, b, c, d, e]
u = []
v = []
ans = 0

for i in range(len(s)):
    if s[i] % 10 == 0:
        ans += s[i]
    else:
        u.append(s[i])
        v.append(s[i] % 10)

k = min(v)
for j in range(len(u)):
    ans += u[j] + 10 - v[j]
    
ans = ans - 10 + k
print(ans)
Problem p03102 (python)

Fixed submission:
n, m, c = map(int, input().split())
a = []
b = list(map(int, input().split()))

for i in range(n):
    a.append(list(map(int, input().split())))

count = 0
for i in range(n):
    x = 0
    for j in range(m):
        x += a[i][j] * b[j]
    x += c

    if x > 0:
        count += 1
            
print(count)

Buggy submission (verdict: Runtime Error):
n, m, c = map(int, input().split())
a = [[0 for i in range(m)] for j in range(n)]
b = [0 for i in range(m)]
for i in range(m):
    b[i] = int(input())
for i in range(n):
    for j in range(m):
        a[i][j] = int(input())

count = 0
for i in range(n):
    x = 0
    for j in range(m):
        x += a[i][j] * b[j]
    x += c

    if x > 0:
        count += 1
            
print(count)
Problem p03146 (python)

Fixed submission:
s = int(input())

if s == 1 or s == 2:
    print(4)
else:
    for i in range(1000000):
        if s == 4:
            print(i + 4)
            break

            
        if s % 2 == 0:
            s = s / 2
        else:
            s = 3 * s + 1

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

if s == 1 or s == 2:
    print(4)
elif:
    for i in range(1000000):
        if s == 4:
            print(i + 4)
            break

            
        if s % 2 == 0:
            s = s / 2
        else:
            s = 3 * s + 1

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

if s == 1 || s == 2:
    print(4)
elif:
    for i in range(1000000):
        if s == 4:
            print(i + 4)
            break

            
        if s % 2 == 0:
            s = s / 2
        else:
            s = 3 * s + 1
Problem p02618 (python)

Fixed submission:
def main():
    D = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(D)]

    for i in range(D):
        print(1)


if __name__ == "__main__":
    main()

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


def main():
    D = int(input())
    c = list(map(int, input().split()))
    s = [list(map(int, input().split())) for _ in range(D)]

    t = [0] * D

    # ペナルティが多い順にindexを並べる
    penalty = np.array(c)
    for i in range(D):
        ind = 0
        tmp = 0
        for j in range(26):
            if penalty[j] + s[i][j] > tmp:
                tmp = penalty[j] + s[i][j]
                ind = j
        penalty[ind] = 0
        t[i] = ind + 1
        for j in range(26):
            penalty[j] += c[j]

    for tt in t:
        print(tt)


def calc(s, c, t):
    d = [0] * 26

    ans = 0
    days = 0
    for tt in t:
        for i in range(26):
            d[i] += 1
        d[tt-1] = 0
        ans += s[days][tt-1]
        for i in range(26):
            ans -= d[i] * c[i]
        days += 1
        print(ans)

    return ans


if __name__ == "__main__":
    main()