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

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

summ=sum(a)
num=[0 for i in range(10**5+1)]
for i in range(n):
    num[a[i]] += 1
for i in range(q):
    b,c=map(int,input().split())
    b_num=num[b]
    num[c] += b_num
    num[b]=0
    summ +=(c-b)*b_num
    print(summ)

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

summ=sum(a)
num=[a.count(i) for i in range(1,100000)]
for i in range(q):
    b,c=map(int,input().split())
    b_num=num[b]
    num[c] += num[b]
    num[b]=0
    summ +=(c-b)*b_num
    print(summ)
Problem p02631 (python)

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

xor=0
for i in a:
    xor ^= i

pop=0 #xorのpopにする
while(xor >> pop >=1):
    pop += 1

sum_xor=xor #各猫の排他的論理和

ans=[]
for i in a:
    x=i^sum_xor
    ans.append(x)

print(" ".join(map(str, ans)))

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

xor=0
for i in a:
    xor ^= i

pop=0 #xorのpopにする
while(xor >> pop >=1):
    pop += 1

sum_xor=0 #各猫の排他的論理和
if N%2==1:
    for i in range(pop):
        sum_xor += 2 **i
else:
    sum_xor=xor

ans=[]
for i in range(n):
    x=a[i]^sum_xor
    if i<n-1:
        print(x,end=' ')
    else:
        print(x)

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

xor=0
for i in a:
    xor ^= i

pop=0 #xorのpopにする
while(xor >> pop >=1):
    pop += 1

sum_xor=0 #各猫の排他的論理和
if N%2==1:
    for i in range(pop):
        sum_xor += 2 **i
else:
    sum_xor=xor

for i in range(n):
    x=a[i]^sum_xor
    print(x,end=' ')
Problem p02639 (python)

Fixed submission:
x=list(map(int,input().split()))
 
for i in range(len(x)):
    if x[i]==0:
        print(i+1)
        break

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

for i in range(len(x)):
  if x[i]==0:
    print(i+1)
    break:
Problem p03166 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10**5+10)

N,M=map(int,input().split())

G=[[] for i in range(N)] #グラフを隣接リストで表現
for j in range(M):
    x,y=map(lambda x:int(x)-1,input().split())
    G[x].append(y)

dp=[-1]*N

def longest_path(v): #vを始点とした時の最長パスの長さ
    if dp[v] != -1: #更新済みの場合
        return dp[v]
    
    #更新されていなかった場合
    tmp_max = 0
    for u in G[v]:
        tmp_max = max(tmp_max,longest_path(u)+1)
    dp[v] = tmp_max #きちんとメモする
    
    return dp[v]

ans=0
for i in range(N):
    ans = max(ans,longest_path(i))

print(ans)

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

G=[[] for i in range(N)] #グラフを隣接リストで表現
for j in range(M):
    x,y=map(lambda x:int(x)-1,input().split())
    G[x].append(y)

dp=[-1]*N

def longest_path(v): #vを始点とした時の最長パスの長さ
    if dp[v] != -1: #更新済みの場合
        return dp[v]
    
    #更新されていなかった場合
    tmp_max = 0
    for u in G[v]:
        tmp_max = max(tmp_max,longest_path(u)+1)
    dp[v] = tmp_max #きちんとメモする
    
    return dp[v]

ans=0
for i in range(N):
    ans = max(ans,longest_path(i))

print(ans)
Problem p02556 (python)

Fixed submission:
n=int(input())
xbox=[]
ybox=[]
for i in range(n):
    x,y = map(int,input().split())
    xbox.append(x)
    ybox.append(y)
xmax=max(xbox)
xmin = min(xbox)
ymax=max(ybox)
ymin=min(ybox)
box1=[]
box2=[]
box3=[]
box4=[]
for i in range(n):
    box1.append(xmax+ymax-xbox[i]-ybox[i])
    box2.append(-xmin + ymax + xbox[i] - ybox[i])
    box3.append(xmax - ymax - xbox[i] + ybox[i])
    box4.append(-xmax - ymax + xbox[i] + ybox[i])
print(max([max(box1)-min(box1),max(box2)-min(box2),max(box3)-min(box3),max(box4)-min(box4)]))

Buggy submission (verdict: Runtime Error):
n=int(input())
xbox=[]
ybox=[]
for i in range(n):
    x,y = map(int,input().split())
    xbox.append(x)
    ybox.append(y)
xmax=max(xbox)
xmin = min(xbox)
ymax=max(ybox)
ymin=min(ybox)
box1=[]
box2=[]
box3=[]
box4=[]
for i in range(n):
    box1.append(xmax+ymax-xbox[i]-ybox[i])
    box2.append(-xmin + ymax + xbox[i] - ybox[i])
    box2.append(xmax - ymax - xbox[i] + ybox[i])
    box2.append(-xmax - ymax + xbox[i] + ybox[i])
print(max([max(box1)-min(box1),max(box2)-min(box2),max(box3)-min(box3),max(box4)-min(box4)]))
Problem p02603 (python)

Fixed submission:
n= int(input())
a = list(map(int,input().split()))
s=0
k=0
top=[]
bottom=[]
t=0
ans=1000
ka=0
while a[s]==a[s+1] and s<n-1:
    s+=1
    if s == n - 1:
        break
if s==n-1:
    print(ans)
else:
    if a[s]>a[s+1]:
        k=-1
        t=1
    else:
        k=1

    while s<n-1:
        while a[s]*k <= a[s+1]*k and s<n-1:
            s+=1
            if s==n-1:
                break
        if k ==-1:
            bottom.append(a[s])
        else:
            top.append(a[s])
        k *= -1
        s+=1
    if k == 1:
        top.append(a[-1])
    else:
        bottom.append(a[-1])
    if t==1:
        for i in range(len(top)):
            ka+=ans//bottom[i]
            ans = ans % bottom[i]
            ans += ka*top[i]
            ka = 0
    else:
        for i in range(len(top)):

            if i== 0:
                ka += ans // a[i]
                ans = ans % a[i]
                ans += ka * top[i]
                ka = 0
            else:
                ka+=ans//bottom[i-1]
                ans = ans % bottom[i-1]
                ans += ka*top[i]
                ka = 0
    print(ans)

Buggy submission (verdict: Runtime Error):
n= int(input())
a = list(map(int,input().split()))
s=0
k=0
top=[]
bottom=[]
t=0
ans=1000
ka=0
while a[s]==a[s+1] and s<n-1:
    s+=1
if s==n-1:
    print(ans)
else:
    if a[s]>a[s+1]:
        k=-1
        t=1
    else:
        k=1

    while s<n-1:
        while a[s]*k <= a[s+1]*k and s<n-1:
            s+=1
            if s==n-1:
                break
        if k ==-1:
            bottom.append(a[s])
        else:
            top.append(a[s])
        k *= -1
        s+=1
    if k == 1:
        top.append(a[-1])
    else:
        bottom.append(a[-1])
    if t==1:
        for i in range(len(top)):
            ka+=ans//bottom[i]
            ans = ans % bottom[i]
            ans += ka*top[i]
            ka = 0
    else:
        for i in range(len(top)):
            
            if i== 0:
                ka += ans // a[i]
                ans = ans % a[i]
                ans += ka * top[i]
                ka = 0
            else:
                ka+=ans//bottom[i-1]
                ans = ans % bottom[i-1]
                ans += ka*top[i]
                ka = 0
    print(ans)
Problem p02658 (python)

Fixed submission:
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]


n = I()
a = LI()
ans = 1
a.sort()
for i in range(n):
    ans *= a[i]
    if ans >= 10**18+1:
        print(-1)
        sys.exit()
    elif ans == 0:
        print(0)
        sys.exit()
print(int(ans))

Buggy submission (verdict: Runtime Error):
n = I()
a = LI()
ans = 1
a.sort()
for i in range(n):
    ans *= a[i]
    if ans > 10**18+1:
        print(-1)
        exit()
    elif ans == 0:
        print(0)
        exit()
print(int(ans))
Problem p02678 (python)

Fixed submission:
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque


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


def I(): return int(sys.stdin.readline().rstrip())


def MI(): return map(int, sys.stdin.readline().rstrip().split())


def MS(): return map(str, sys.stdin.readline().rstrip().split())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def LS(): return list(sys.stdin.readline().rstrip().split())


# N = I()
# A = [LI() for _ in range(N)]


n, m = map(int, input().split())
a = [0] * m
b = [0] * m
box = [[] for i in range(n)]
s = deque()
ans = [-1] * (n - 1)
for i in range(m):
    a[i], b[i] = map(int, input().split())
    box[a[i] - 1].append(b[i])
    box[b[i] - 1].append(a[i])
for i in range(len(box[0])):
    s.append([1, box[0][i]])

while len(s) > 0:
    k = s.popleft()

    if ans[k[1] - 2] == -1 and k[1] - 2 != -1:
        ans[k[1] - 2] = k[0]

        for i in range(len(box[k[1] - 1])):
            s.append([k[1], box[k[1] - 1][i]])

print('Yes')
for i in range(len(ans)):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
from bisect import bisect_left, bisect_right, insort
from collections import deque
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def MS(): return map(str, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
# N = I()
# A = [LI() for _ in range(N)]


n,m = map (int,input().split())
a = [0] * n
b = [0] * n
box = [[] for i in range(n)]
s = deque()
ans = [-1] * (n-1)
for i in range(n):
    a[i],b[i] = map (int,input().split())
    box[a[i]-1].append (b[i])
    box[b[i] - 1].append (a[i])
for i in range(len(box[0])):
    s.append([1,box[0][i]])

while len (s) > 0:
    k = s.popleft()

    if ans[k[1] - 2] == -1:
        ans[k[1] - 2] = k[0]

        for i in range(len(box[k[1] - 1])):
            s.append([k[1], box[k[1] - 1][i]])

print('Yes')
for i in range(len(ans)):
    print(ans[i])

Buggy submission (verdict: Runtime Error):
n,m = map (int,input().split())
a = [0] * n
b = [0] * n
box = [[] for i in range(n)]
s = deque()
ans = [-1] * (n-1)
for i in range(n):
    a[i],b[i] = map (int,input().split())
    box[a[i]-1].append (b[i])
    box[b[i] - 1].append (a[i])
for i in range(len(box[0])):
    s.append([1,box[0][i]])

while len (s) > 0:
    k = s.popleft()

    if ans[k[1] - 2] == -1:
        ans[k[1] - 2] = k[0]

        for i in range(len(box[k[1] - 1])):
            s.append([k[1], box[k[1] - 1][i]])

print('Yes')
for i in range(len(ans)):
    print(ans[i])
Problem p02684 (python)

Fixed submission:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
from bisect import bisect_left, bisect_right, insort
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def MS(): return map(str,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
#N = I()
#A = [LI() for _ in range(N)]

n,k = MI()
a = LI()
ans = [1] * n
memo = [-1] * n
memo[0] = 0
s = 0
for i in range(1,n):
    if memo[a[ans[i-1]-1]-1] == -1:
        ans[i] = a[ans[i-1]-1]
        s += 1
        memo[ans[i] - 1] = s

    else:
        t = memo[a[ans[i-1]-1]-1]
        break
if k <= t:
    print(ans[k])
elif t == 0:
    print(ans[(k - 1) % (s-t +1) +1])
else:
    print(ans[(k-(t-1)-1) % (s-t+1) + t])

Buggy submission (verdict: Runtime Error):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
from bisect import bisect_left, bisect_right, insort
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def MS(): return map(str,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
#N = I()
#A = [LI() for _ in range(N)]

n,k = MI()
a = LI()
ans = [1] * n
memo = [-1] * n
memo[0] = 0
s = 0
for i in range(1,n):
    if memo[a[ans[i-1]-1]-1] == -1:
        ans[i] = a[ans[i-1]-1]
        s += 1
        memo[ans[i] - 1] = s

    else:
        t = memo[a[ans[i-1]-1]-1]
        break
if k <= t:
    print(ans.index(k) + 1)
elif t == 0:
    print(ans[(k - 1) % (s-t +1) +1])
else:
    print(ans[(k-(t-1)-1) % (s-t+1) + t])
Problem p02761 (python)

Fixed submission:
n,m = map(int,input().split())
s = [0] * m
c = [0] * m
for i in range(m):
    s[i],c[i] = map(int, input().split())

if n>1:
    ans=[1]+[0]*(n-1)
else:
    ans=[0]
flag = False


for i in range(m):
    if n>2 and s[i]==1 and c[i]==0:
        flag = True
    ans[s[i]-1]=c[i]
    for j in range(i+1,m):
        if s[i]==s[j]:
            if c[i]!=c[j]:
                flag=True

if flag:
    print(-1)
else:
    print("".join(map(str,ans)))

Buggy submission (verdict: Runtime Error):
import sys
n,m = map(int,input().split())
s = [0] * m
c = [0] * m
for i in range(m):
    s[i],c[i] = map(int,input().split())
ans = [10] * max(s)
for i in range(m):
    if s[i] == 1 and c[i] == 0:
        print(-1)
        sys.exit()
    if ans[s[i] - 1] == 10:
        ans[s[i] - 1] = c[i]
    else:
        if c[i] != ans[s[i] - 1]:
            print(-1)
            sys.exit()
    
for i in range(len(ans)):
    if i == 0 and ans[i] == 10:
        ans[i] = 1
    elif ans[i] == 10:
        ans[i] = 0
print(''.join([str(i) for i in ans]))

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
s = [0] * m
c = [0] * m
for i in range(m):
    s[i],c[i] = map(int, input().split())
if n>2:
    ans=[1]+[0]*(n-1)
else:
    ans=[0]
flag = False


for i in range(m):
    if n>2 and s[i]==1 and c[i]==0:
        flag = True
    ans[s[i]-1]=c[i]
    for j in range(i+1,m):
        if s[i]==s[j]:
            if c[i]!=c[j]:
                flag=True

if flag:
    print(-1)
else:
    print("".join(map(str,ans)))
Problem p02767 (python)

Fixed submission:
n = int(input())
x = list(map(int, input().split()))
if max(x)-min(x)==0:
    print(0)
else:
    k=max(x)-min(x)
    box=[0]*k

    for i in range(0,k):
        aa=0
        for j in range(0,n):
           aa = aa+(x[j]-min(x)-i)**2
        box[i]=aa


    print(min(box))

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

k=max(x)-min(x)
box=[0]*k

for i in range(0,k):
    aa=0
    for j in range(0,n):
        aa = aa+(x[j]-min(x)-i)**2
    box[i]=aa


print(min(box))
Problem p02886 (python)

Fixed submission:
import numpy as np
n = int(input())
d = list(map(int,input().split()))
print(int((np.sum(np.array(d))**2 - np.sum(np.array(d)**2)) /2))

Buggy submission (verdict: Runtime Error):
import numpy as np
n = int(input())
d = list(map(int,input().split()))
print(int((np.sum(np.array(d))**2 - np.sum(np.array(d)**2)) /
Problem p02900 (python)

Fixed submission:
import fractions
a, b = map(int,input().split())
g = fractions.gcd(a,b)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
if g == 1:
     print(1)
else:
     print(len(factorization(g))+1)

Buggy submission (verdict: Runtime Error):
import math
a, b = map(int,input().split())
g = math.gcd(a,b)
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
if g == 1:
     print(1)
else:
     print(len(factorization(g))+1)
Problem p02952 (python)

Fixed submission:

n = str(input())
s = len(n)
if s == 1:
     print(n)
elif s == 2:
     print(9)
elif s == 3:
     print(9 + int(n) - 99)
elif s == 4:
     print(9 + 900)
elif s == 5:
     print(909 + int(n) - 9999)
else:
     print(90909)

Buggy submission (verdict: Runtime Error):
n = str(input())
s = len(n)
if s == 1:
     print(n)
elif s == 2:
     print(9)
elif s == 3:
     print(9 + int(n) - 99)
elif s == 4:
     print(9 + 900)
elif s == 5:
     print(909 + n - 9000)
else:
     print(90909)
Problem p03001 (python)

Fixed submission:
w,h,x,y = map(float,input().split())
if x == w/2 and y == h/2:
     print(w*h/2,1)
else:
     print(w*h/2,0)

Buggy submission (verdict: Runtime Error):
w,h,x,y = map(float,input().split())
if x == w/2 and y == h/2:
     print(w*h/2,1)
else:
     print(w*h2,0)
Problem p03086 (python)

Fixed submission:
s =str(input())
ans = 0
aa = []
if s[0] in ['A', 'C', 'G', 'T']:
    ans =1
for i in range(1,len(s)):
    if s[i] in ['A', 'C', 'G', 'T']:
        if s[i-1] in ['A', 'C', 'G', 'T']:
            ans += 1
        else:ans = 1
    else:
        aa.append(ans)
        ans = 0
aa.append(ans)
print(max(aa))

Buggy submission (verdict: Runtime Error):
s =str(input())
ans = 0
aa = []
for i in range(1,len(s)):
    if s[i] in ['A', 'C', 'G', 'T']:
        if s[i-1] in ['A', 'C', 'G', 'T']:
            ans += 1
        else:ans = 1
    else:
        aa.append(ans)
        ans = 0
print(max(aa))
Problem p03103 (python)

Fixed submission:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
#N = I()
#A = [LI() for _ in range(N)]


n,m = map (int,input().split())
a = [0] * n
b = [0] * n
box = [0] * n
for i in range(n):
    a[i],b[i] = map(int,input().split())
    box[i] = [a[i],b[i]]
box.sort(key = lambda x:x[0])
s = 0
ans = 0
while m > 0:
    
    m -= box[s][1]
    ans += box[s][0] * box[s][1]
    s += 1

print(ans - (-m) * box[s - 1][0])

Buggy submission (verdict: Runtime Error):
n,m = map (int,input().split())
a = [0] * n
b = [0] * n
box = [0] * n
for i in range(n):
    a[i],b[i] = map(int,input().split())
    box[i] = [a[i],b[i]]
box.sort(key = lambda x:x[0])
s = 0
ans = 0
while m >= 0:
    m -= box[s][1]
    ans += box[s][0] * box[s][1]
    s += 1
    
print(ans - (-m) * box[s - 1][0])
Problem p03161 (python)

Fixed submission:
import numpy as np
N, K = (int(i) for i in input().split())  
h = np.array([int(i) for i in input().split()])
 
dp = np.empty(N, dtype='int')
 
for i in range(N):
  if i == 0:
    dp[i] = 0
  elif i - K < 0:
    dp[i] = np.min(np.abs(h[i] - h[:i]) + dp[:i])
  else:
    dp[i] = np.min(np.abs(h[i] - h[i-K:i]) + dp[i-K:i])
 
print(dp[N-1])

Buggy submission (verdict: Runtime Error):

n,k = map(int,input().split())
h = list(map(int, input().split()))

dp = [0]*n
dp[0] = 0
dp[1] = np.abs(h[0]-h[1])

for i in range(2,n):
     j = max(0,i-k)
     dp[i] = min([dp[l]+abs(h[i]-h[l]) for l in range(j,i)])

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

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**6)
n,k = map(int,input().split())
h = list(map(int, input().split()))

dp = [0] * n
for i in range(k):
     dp[i]=abs(h[0]-h[i])
for i in range (k,n):
     for j in range(1,k):
          dp[i] = min(dp[i-k]+abs(h[i-k]-h[i]),dp[i-k-1]+abs(h[i-k-1]-h[i]))

print(dp[n-1])

Buggy submission (verdict: Runtime Error):
import sys
setrecursionlimit(10**6)
n,k = map(int,input().split())
h = list(map(int, input().split()))

dp = [0] * n
for i in range(k):
     dp[i]=abs(h[0]-h[i])
for i in range (k,n):
     dp[i] = min([dp[i-j-1]+abs(h[i-j-1]-h[i]) for j in range(k)])

print(dp[n-1])

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

dp = [0] * n
for i in range(k):
     dp[i]=abs(h[0]-h[i])
for i in range (k,n):
     dp[i] = min([dp[i-j-1]+abs(h[i-j-1]-h[i]) for j in range(k)])

print(dp[n-1])
Problem p02618 (python)

Fixed submission:
import copy
D = int( input() )
c = list( map( int, input().split() ) )
s = []
for _ in range( D ):
    s_i = list( map( int, input().split() ) )
    s.append( s_i )

def next_satisfy( d, c, s, next_t, last,  pre_satisfy ):
    ans = pre_satisfy + s[ d ][ next_t ]
    last_d = copy.deepcopy( last[ -1 ] )
    last_d[ next_t ] = d
    last.append( last_d )
    for i in range( 26 ):
        ans -= c[ i ] * ( d - last[ d ][ i ] )
    return ans

t = []
last = [ [ -1 for _ in range( 26 ) ] ]
last_i = [ -1 for _ in range( 26 ) ]
for d in range( D ):
    max_satisfy = - 10 ** 10
    next_t = -1
    for i in range( 26 ):
        satisfy_i = next_satisfy( d, c, s, i, last, 0 )
        if max_satisfy < satisfy_i:
            max_satisfy = satisfy_i
            next_t = i
    last_i[ next_t ] = d
    last.append( copy.deepcopy( last_i ) )
    t.append( next_t + 1 )

for t_i in t:
    print( t_i )

Buggy submission (verdict: Runtime Error):
import copy
D = int( input() )
c = list( map( int, input().split() ) )
s = []
for _ in range( D ):
    s_i = list( map( int, input().split() ) )
    s.append( s_i )

def next_satisfy( d, c, s, next_t, last,  pre_satisfy ):
    ans = pre_satisfy + s[ d ][ next_t ]
    last_d = copy.deepcopy( last[ -1 ] )
    last_d[ next_t ] = d
    last.append( last_d )
    for i in range( 26 ):
        ans -= c[ i ] * ( d - last[ d ][ i ] )
    return ans

t = []
last = [ [ -1 for _ in range( 26 ) ] ]
last_i = [ -1 for _ in range( 26 ) ]
for d in range( D ):
    max_satisfy = - 10 ** 10
    next_t = -1
    for i in range( 26 ):
        satisfy_i = next_satisfy( d, c, s, i, last, 0 )
        if max_satisfy < satisfy_i:
            max_satisfy = satisfy_i
            next_t = i
    last_i[ d ] = next_t
    last.append( copy.deepcopy( last_i ) )
    t.append( next_t + 1 )

for t_i in t:
    print( t_i )
Problem p02606 (python)

Fixed submission:
def main():
    l,r,d = map(int,input().split())
    total = 0
    for i in range(l,r+1):
        if i%d == 0:
            total += 1

    print(total)
    

main()

Buggy submission (verdict: Runtime Error):
def main():
	l,r,d = map(int,input().split())
    total = 0
    for i in range(l,r+1):
      if i%d == 0:
        total += 1
    
    print(total)
  
  
main()
Problem p02607 (python)

Fixed submission:
def main():
    n = int(input())
    arr = list(map(int,input().split()))
    total = 0
    for i in range(1,n+1):
        if arr[i-1]%2 == i%2 and i%2 != 0:
            total += 1

    print(total)
    

main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    arr = list(map(int,input().split()))
    total = 0
    for i in range(1,n+1):
        if arr[i-1]%2 == i%2 and i%2 != 0:
            total += 1

    print(total)
    

main()
Problem p02795 (python)

Fixed submission:
import math

def main():
    h = int(input())
    w = int(input())
    n = int(input())
    print(math.ceil(n/(max(h,w))))

main()

Buggy submission (verdict: Runtime Error):
import math

def main():
  h = int(inout())
  w = int(input())
  n = int(input())
  print(math.ceil(n/(max(h,w))))
  
  
main()
Problem p02937 (python)

Fixed submission:
import bisect

def main():
    s = input()
    t = input()
    sletters = [0]*26
    for i in range(len(s)):
        x = ord(s[i])-ord('a')
        if sletters[x] == 0:
            sletters[x] = [i]
        else:
            sletters[x].append(i)

    ans = 0
    curr_index = -1
    for i in t:
        x = ord(i)-ord('a')
        if sletters[x] == 0:
            print(-1)
            return
        index = bisect.bisect(sletters[x],curr_index)
        #print(sletters[x],i,curr_index,index)
        if index == len(sletters[x]):
            ans += len(s)-curr_index
            curr_index = sletters[x][0]
            ans += curr_index
        else:
            ans += sletters[x][index]-curr_index
            curr_index = sletters[x][index]
        

    print(ans)


main()

Buggy submission (verdict: Runtime Error):
def main():
    s = input()
    t = input()
    sletters = set()
    for i in s:
        sletters.add(i)

    for i in t:
        if i not in sletters:
            print(-1)
            return

    s = s*len(t)
    i = 0
    j = 0
    while i < len(s) and j < len(t):
        if s[i] == t[j]:
            i += 1
            j += 1
        else:
            i += 1

    print(i)


main()