Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import sys
class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x


N, M = map(int, input().split())
info = [tuple(map(int, s.split())) for s in sys.stdin.readlines()]
#print(info)

uf = UnionFind(N)

for a, b in info:
    a -= 1; b -= 1
    uf.union(a, b)

#ans = min(uf.parents)

print(-ans)

Fixed submission:
import sys
class UnionFind():
    def __init__(self, n):
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x


N, M = map(int, input().split())
info = [tuple(map(int, s.split())) for s in sys.stdin.readlines()]
#print(info)

uf = UnionFind(N)

for a, b in info:
    a -= 1; b -= 1
    uf.union(a, b)

ans = min(uf.parents)

print(-ans)
Buggy python submission (verdict: Runtime Error):
x,k,d = map(int,input().split())
x = abs(x)
if x//d > k:
  print(x-k*d)
elif (k-x//d)%2 == 0:
  print(x%d)
else:
  print(d-x%d)

Fixed submission:
s = input()
#print(s[0])
if s[0]==s[1]==s[2]=="R":
    print(3)
elif s[0]=="R" and s[1]=="R":
    print(2)
elif s[1]=="R" and s[2]=="R":
    print(2)
elif s[0]=="R":
    print(1)
elif s[1]=="R":
    print(1)
elif s[2]=="R":
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
k = int(input())
i = len(str(k))
cnt = 0
kanou = ["1","3","7","9"]
hukanou = ["0","2","4","5","6","8"]
if (str(k)[len(str(k))-1]) in kanou:
    cnt = 0
    for i in range(i):
        if str(k)[i] in hukanou:
            cnt = 1
            break
    if cnt == 0:
        while True:
            if(int('7'*i))%k==0:
                cnt = 1
                break
            else:
                i += 1
        print(i)
    elif cnt == 1:
        if k%7==0 and k%3==0:
            print(k)
        else:
            print(k-1)
else:
    print(-1)

Fixed submission:
def calc(k):
    cur = 0
    for i in range(1, 10 ** 7):
        cur *= 10
        cur += 7
        cur %= k
        if cur == 0:
            return i

    return -1


k = int(input())
print(calc(k))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
ans = 0
for i in range(1, n+1):
    for j in range(i, n+1, i):
        ans += j
print(ans)

Fixed submission:
n = int(input())
ans = 0
for i in range(1, n+1):
    a = n//i
    ans += (i + a*i)*a
print(ans//2)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ans = sum(a)
#print(ans)
q = int(input())
import collections
cc = collections.Counter(a)
#print(cc)
for i in range(q):
    b,c = map(int,input().split())
    tmp = cc[b]
    cc[b] = 0
    s=s-b*tmp+c*tmp
    cc[c]+=tmp
    print(s)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
#print(ans)
q = int(input())
import collections
cc = collections.Counter(a)
#print(cc)
for i in range(q):
    b,c = map(int,input().split())
    tmp = cc[b]
    cc[b] = 0
    s=s-b*tmp+c*tmp
    cc[c]+=tmp
    print(s)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
ans = sum(a)
#print(ans)
q = int(input())
import collections
cc = collections.Counter(a)
print(cc)
for i in range(q):
    b,c = map(int,input().split())
    tmp = cc[b]
    cc[b] = 0
    s=s-b*tmp+c*tmp
    cc[c]+=tmp
    print(s)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
#print(ans)
q = int(input())
import collections
cc = collections.Counter(a)
#print(cc)
for i in range(q):
    b,c = map(int,input().split())
    tmp = cc[b]
    cc[b] = 0
    s=s-b*tmp+c*tmp
    cc[c]+=tmp
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
ans = sum(a)
#print(ans)
q = int(input())
b = []
c = []
from itertools import groupby
d = [[key,len(list(group))] for key,group in groupby(sorted(a))]

for j in range(q):
    b,c = map(int,input().split())
    
    for i in range(len(d)):
        if b==d[i][0]:
            d[i][0] = c
            ans = ans + ((c-b)*d[i][1])
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
#print(ans)
q = int(input())
import collections
cc = collections.Counter(a)
#print(cc)
for i in range(q):
    b,c = map(int,input().split())
    tmp = cc[b]
    cc[b] = 0
    s=s-b*tmp+c*tmp
    cc[c]+=tmp
    print(s)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted(list(map(int,input().split())))
ans = sum(a)
#print(ans)
q = int(input())
b = []
c = []
for i in range(q):
    bb,cc = map(int,input().split())
    b.append(bb)
    c.append(cc)
#print(b)
#print(c)
from itertools import groupby
d = [[key,len(list(group))] for key,group in groupby(sorted(a))]
#print(d)
for j in range(q):
    for i in range(len(d)):
        if b[j]==d[i][0]:
            d[i][0] = c[j]
            ans = ans + ((c[j]-b[j])*d[i][1])
    print(ans)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
s = sum(a)
#print(ans)
q = int(input())
import collections
cc = collections.Counter(a)
#print(cc)
for i in range(q):
    b,c = map(int,input().split())
    tmp = cc[b]
    cc[b] = 0
    s=s-b*tmp+c*tmp
    cc[c]+=tmp
    print(s)
Buggy python submission (verdict: Runtime Error):
import numpy as np
import math
a,b,h,m = map(int, input().split())
ty = ((h*60+m)/60)/12
ta = (m)/60
if abs(ty-ta)>0.5:
    k = 1-abs(ty-ta)
else:
    k = abs(ty-ta)
#print(k)
if h*60+m==12*m
    print(b-a)
else:
    ans = a**2+b**2-2*a*b*(np.cos(k*2*math.pi))
    print(math.sqrt(ans))

Fixed submission:
import numpy as np
import math
a,b,h,m = map(int, input().split())
ty = ((h*60+m)/60)/12
ta = (m)/60
if abs(ty-ta)>0.5:
    k = 1-abs(ty-ta)
else:
    k = abs(ty-ta)
#print(k)
if h*60+m==12*m:
    print(abs(b-a))
else:
    ans = a**2+b**2-2*a*b*(np.cos(k*2*math.pi))
    print(math.sqrt(ans))
Buggy python submission (verdict: Runtime Error):
n, mm, q = map(int,input().split())
a, b, c, d = [0]*q, [0]*q, [0]*q, [0]*q
for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())
import itertools
td = []
ttd = []

m = []
for i in range(1,mm+1):
    m.append(i)

s = list(itertools.combinations(m, n))
for j in range(len(s)):
    for i in range(q):
        if s[j][b[i]-1] - s[j][a[i]-1] == c[i]:
            td.append(d[i])
    ttd.append(sum(td))
    td = []
print(max(ttd))
    

Fixed submission:
n, mm, q = map(int,input().split())
a, b, c, d = [0]*q, [0]*q, [0]*q, [0]*q
for i in range(q):
    a[i],b[i],c[i],d[i] = map(int,input().split())
import itertools
td = []
ttd = []

m = []
for i in range(1,mm+1):
    m.append(i)

s = list(itertools.combinations_with_replacement(m, n))
for j in range(len(s)):
    for i in range(q):
        if s[j][b[i]-1] - s[j][a[i]-1] == c[i]:
            td.append(d[i])
    ttd.append(sum(td))
    td = []
if ttd==[]:
    print(0)
else:
    print(max(ttd))
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    print(a.count(i+1))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
li = [0]*n
for i in a:
    li[i-1] += 1
print(*li, sep="\n")

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
for i in range(n):
    print(a.count(i+1))

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
li = [0]*n
for i in a:
    li[i-1] += 1
print(*li, sep="\n")
Buggy python submission (verdict: Runtime Error):
c=a[0:int((len(a)-1)/2)]
b=''.join(list(reversed(a)))
d=a[int((len(a)+3)/2)-1:]
 
if a!=b:
  print("No")
elif c!=d:
  print("No")
else:
  print("Yes")

Fixed submission:
a=input()
#b=reversed(a)
c=a[0:int((len(a)-1)/2)]
b=''.join(list(reversed(a)))
d=a[int((len(a)+3)/2)-1:]
 
if a!=b:
  print("No")
elif c!=d:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Time Limit Exceeded):
na,nb,nm = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
TA = []
for i in range(nm):
    m1, m2, m3 = map(int,input().split())
    T = a[m1-1]+b[m2-1]-m3
    TA.append(T)
for i in range(na):
    for j in range(nb):
        T = a[i] + b[j]
        TA.append(T)
print(min(TA))

Fixed submission:
na,nb,nm = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
TA = []
for i in range(nm):
    m1, m2, m3 = map(int,input().split())
    T = a[m1-1]+b[m2-1]-m3
    TA.append(T)
T = min(a) + min(b)
TA.append(T)
print(min(TA))

Buggy python submission (verdict: Time Limit Exceeded):
na,nb,nm = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
TA = []
for i in range(nm):
    m1, m2, m3 = map(int,input().split())
    T = a[m1-1]+b[m2-1]-m3
    TA.append(T)
for i in range(na):
    for j in range(nb):
        T = a[i] + b[j]
        TA.append(T)
TA = (sorted(TA))
print(TA[0])

Fixed submission:
na,nb,nm = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
TA = []
for i in range(nm):
    m1, m2, m3 = map(int,input().split())
    T = a[m1-1]+b[m2-1]-m3
    TA.append(T)
T = min(a) + min(b)
TA.append(T)
print(min(TA))
Buggy python submission (verdict: Time Limit Exceeded):
import collections
n = int(input())
s = [input() for i in range(n)]
#print(s)
c = collections.Counter(s)
#print(c.most_common())
a = []
a.append(c.most_common()[0][0])
for i in range(1,len(c.most_common())):
    if c.most_common()[0][1]==c.most_common()[i][1]:
        a.append(c.most_common()[i][0])
print(*sorted(a))

Fixed submission:
import collections
n = int(input())
s = [input() for i in range(n)]
#print(s)
c = collections.Counter(s)
#print(c.most_common())
a = []
b = (c.most_common())
#print(b)
a.append(b[0][0])
for i in range(1,len(b)):
    if b[0][1] == b[i][1]:
        a.append(b[i][0])
print(*sorted(a))
Buggy python submission (verdict: Runtime Error):
s,t = map(input().split())
a,b = map(int,input().spli())
u = input()
if u==s:
    print(a-1,b)
else:
    print(a,b-1)

Fixed submission:
s = input().split()
a,b = map(int,input().split())
u = input()
if u==s[0]:
    print(a-1,b)
else:
    print(a,b-1)
Buggy python submission (verdict: Runtime Error):
a,b = map(int,input().split())
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

print(lcm(a, b))

Fixed submission:
a,b = map(int,input().split())
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

print(lcm(a, b))
Buggy python submission (verdict: Runtime Error):
N = int(input())
testimony = [[] for _ in range(N)]
for i in range(N):
    num = int(input())
    person, state = map(int,input().split())
    testimony[i].append([person-1,state])
#print(testimony)
        
honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if (i>>j)&1 == 1: # j番目は正直と仮定
            for x,y in testimony[j]:
                if (i>>x)&1 != y: # j番目は正直だが矛盾を発見
                    flag = 1
                    break
    if flag == 0:  # 矛盾がある場合はflag == 1になる
        honest = max(honest, bin(i)[2:].count('1'))  # 1の数をカウントし最大となるものを選択
print(honest)

Fixed submission:
N = int(input())
 
testimony = [[] for _ in range(N)]
 
for i in range(N):
    num = int(input())
    for j in range(num):
        person, state = map(int, input().split())
        testimony[i].append([person-1, state])
        
honest = 0
for i in range(1, 2**N):
    flag = 0
    for j in range(N):
        if (i>>j)&1 == 1: # j番目は正直と仮定
            for x,y in testimony[j]:
                if (i>>x)&1 != y: # j番目は正直だが矛盾を発見
                    flag = 1
                    break
    if flag == 0:  # 矛盾がある場合はflag == 1になる
        honest = max(honest, bin(i)[2:].count('1'))  # 1の数をカウントし最大となるものを選択
print(honest)
Buggy python submission (verdict: Runtime Error):
S = ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"]
s = print()
result = abs(S.index(s)-S.index("SUN"))
print(result)

Fixed submission:
S = ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"]
s = input()
result = abs(S.index(s)-S.index("SUN"))
if result ==0:
  result = 7
else:
  pass
print(result)
Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
l = list(map(int,input().split()))
l = sorted(l)
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        #print(l[i],l[j])
        for z in range(j+1,n):
            if l[i]+l[j]>l[z]:
                cnt  += 1
                #print(l[i],l[j],l[z])
print(cnt)

Fixed submission:
from bisect import bisect_left
n = int(input())
l = list(map(int,input().split()))
l = sorted(l)
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        #print(l[i],l[j])
        cnt += bisect_left(l, l[i] + l[j]) - (j + 1)
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n = int(input())
l = list(map(int,input().split()))
l = sorted(l)
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        #print(l[i],l[j])
        for z in range(j+1,n):
            if l[i]+l[j]>l[z] and l[z]+l[i]>l[j]:
                cnt  += 1
                #print(l[i],l[j],l[z])
print(cnt)

Fixed submission:
from bisect import bisect_left
n = int(input())
l = list(map(int,input().split()))
l = sorted(l)
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        #print(l[i],l[j])
        cnt += bisect_left(l, l[i] + l[j]) - (j + 1)
print(cnt)
Buggy python submission (verdict: Runtime Error):
n,W = map(int,input().split())
w,v = [0]*n, [0]*n
for i in range(n):
    w[i], v[i] = map(int,input().split())

dp = [[0]*(W+1) for _ in range(n+1)]
for i in range(n):
    for j in range(W+1):
        if j-w[i]>=0:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]]+v[i])
        dp[i+1][j] = max(dp[i+1][j],dp[i][j])
print(dp[n][W])

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

dp = [float("inf") for _ in range(n)]
dp[0] = 0
for i in range(n-1):
    dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]))
    if i<n-2:
        dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i]))
print(dp[n-1])

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

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

dp = [float("inf") for _ in range(n)]
dp[0] = 0
for i in range(n-1):
    dp[i+1] = min(dp[i+1], dp[i]+abs(h[i+1]-h[i]))
    if i<n-2:
        dp[i+2] = min(dp[i+2], dp[i]+abs(h[i+2]-h[i]))
print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [float("inf") for _ in range(n)]
dp[0] = 0
for i in range(n-1):
    for j in range(1,k+1):
        if i<n-j:
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]))
print(dp[n-1])

Fixed submission:
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp = [float("inf") for _ in range(n)]
dp[0] = 0
for i in range(n-1):
    for j in range(1,k+1):
        if i<n-j:
            dp[i+j] = min(dp[i+j], dp[i]+abs(h[i]-h[i+j]))
print(dp[n-1])
Buggy python submission (verdict: Time Limit Exceeded):
n,W = map(int,input().split())
w,v = [0]*n, [0]*n
for i in range(n):
    w[i], v[i] = map(int,input().split())

dp = [[0]*(W+1) for _ in range(n+1)]
for i in range(n):
    for j in range(W+1):
        if j-w[i]>=0:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]]+v[i])
        dp[i+1][j] = max(dp[i+1][j],dp[i][j])
print(dp[n][W])

Fixed submission:
n,W = map(int,input().split())
w,v = [0]*n, [0]*n
for i in range(n):
    w[i], v[i] = map(int,input().split())

dp = [[0]*(W+1) for _ in range(n+1)]
for i in range(n):
    for j in range(W+1):
        if j-w[i]>=0:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-w[i]]+v[i])
        dp[i+1][j] = max(dp[i+1][j],dp[i][j])
print(dp[n][W])
Buggy python submission (verdict: Runtime Error):
import sys
import resource
sys.setrecursionlimit(10000)
n,k=map(int,input().rstrip().split())
p=list(map(int,input().rstrip().split()))
c=list(map(int,input().rstrip().split()))
def find(start,now,up,max,sum,count,flag):
    if start==now:
        flag+=1
    if start==now and flag==2:
        return [max,sum,count]
    elif count==up:
        return [max,sum,count]
    else:
        count+=1
        sum+=c[p[now-1]-1]
        if max<sum:
            max=sum
        return find(start,p[now-1],up,max,sum,count,flag)
kara=[-10000000000]
for i in range(1,n+1):
    m=find(i,i,n,c[p[i-1]-1],0,0,0)
    if m[2]>=k:
        m=find(i,i,k,c[p[i-1]-1],0,0,0)
        if m[0]>kara[0]:
            kara[0]=m[0]
    elif m[1]<=0:
        if m[0]>kara[0]:
            kara[0]=m[0]
    else:
        w=k%m[2]
        if w==0:
            w=m[2]
        spe=find(i,i,w,c[p[i-1]-1],0,0,0)[0]
        if m[1]+spe>m[0] and m[1]*(k-w)//m[2]+spe>kara[0]:
            kara[0]=m[1]*(k-w)//m[2]+spe
        elif m[1]+spe<=m[0] and m[1]*((k-w)//m[2]-1)+m[0]>kara[0]:
            kara[0]=m[1]*((k-w)//m[2]-1)+m[0]
print(kara[0])

Fixed submission:
main=input().rstrip()
count=0
flag=0
for i in range(3):
    if main[i]=='R' and flag==0:
        count+=1
    elif main[i]=='R' and flag==1:
        count=0
        count+=1
        flag=0
    else:
        flag=1
print(count)

Buggy python submission (verdict: Runtime Error):
n,k=map(int,input().rstrip().split())
p=list(map(int,input().rstrip().split()))
c=list(map(int,input().rstrip().split()))
def find(start,now,up,max,sum,count,flag):
    if start==now:
        flag+=1
    if start==now and flag==2:
        return [max,sum,count]
    elif count==up:
        return [max,sum,count]
    else:
        count+=1
        sum+=c[p[now-1]-1]
        if max<=sum:
            max=sum
        return find(start,p[now-1],up,max,sum,count,flag)
kara=[]
if n>k:
    for i in range(1,n+1):
        kara.append(find(i,i,k,c[p[i-1]-1],0,0,0)[0])
    result=max(kara)
else:
    for i in range(1,n+1):
        m=find(i,i,n,c[p[i-1]-1],0,0,0)
        if m[1]<=0:
            kara.append(m[0])
        else:
            w=k%m[2]
            spe=find(i,i,w,c[p[i-1]-1],0,0,0)[0]
            if w==0:
                spe=0
            if m[0]>int(m[1]*(k-w)//m[2]+spe):
                kara.append(m[0])
            else:
                kara.append(int(m[1]*(k-w)//m[2]+spe))
    result=max(kara)
print(result)


Fixed submission:
main=input().rstrip()
count=0
flag=0
for i in range(3):
    if main[i]=='R' and flag==0:
        count+=1
    elif main[i]=='R' and flag==1:
        count=0
        count+=1
        flag=0
    else:
        flag=1
print(count)
Buggy python submission (verdict: Runtime Error):
N, X, M = map(int, input().split())

appearance = [0] * (M + 1)
cum_sum = [0]
A = X
appearance[A] = 1
cum_sum.append(A)
for a in range(2, N + 1):
    A = (A**2)%M
    if appearance[A] != 0:
        n = a - 1
        break
    appearance[A] = a
    cum_sum.append(cum_sum[-1] + A)
else: n = a

k = appearance[A]
l = (N - n) // (n - k + 1)
m = (N - n) - (n - k + 1)*l + k - 1

ans = cum_sum[n] + (cum_sum[n] - cum_sum[k - 1])*l + cum_sum[m] - cum_sum[k - 1]
print(ans)

Fixed submission:
N, X, M = map(int, input().split())

appearance = [0] * (M + 1)
cum_sum = [0]
A = X
appearance[A] = 1
cum_sum.append(A)
a = 1
for a in range(2, N + 1):
    A = (A**2)%M
    if appearance[A] != 0:
        n = a - 1
        break
    appearance[A] = a
    cum_sum.append(cum_sum[a - 1] + A)
else: n = a

k = appearance[A]
l = (N - n) // (n - k + 1)
m = (N - n) - (n - k + 1)*l + k - 1

ans = cum_sum[n] + (cum_sum[n] - cum_sum[k - 1])*l + cum_sum[m] - cum_sum[k - 1]
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
T = input()

ans = 0
for i in range(len(S)):
  tmp = 0
  for j in range(len(T)):
    if S[i + j] == T[j]:
      tmp += 1
  ans = max(ans, tmp)

print(len(T) - ans)
  


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

ans = 0
for i in range(len(S) - len(T) + 1):
  tmp = 0
  for j in range(len(T)):
    if S[i + j] == T[j]:
      tmp += 1
  ans = max(ans, tmp)

print(len(T) - ans)

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

ans = 0
for i in range(len(S)):
  tmp = 0
  for j in range(len(T)):
    if S[i + j] == T[j]:
      tmp += 1
    ans = max(ans, tmp)

print(len(T) - ans)
  

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

ans = 0
for i in range(len(S) - len(T) + 1):
  tmp = 0
  for j in range(len(T)):
    if S[i + j] == T[j]:
      tmp += 1
  ans = max(ans, tmp)

print(len(T) - ans)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
P = list(map(lambda x:int(x) - 1, input().split()))
C = list(map(int, input().split()))

L = [[] for _ in range(N)]
for i in range(N):
    cnt = C[i]
    blk = P[i]
    L[i].append([cnt, blk])
    for j in range(N):
        li = L[i][j][1]
        if li == i:
            break
        else:
            cnt += C[li]
            blk = P[li]
            L[i].append([cnt, blk])

ans = []
for l in L:
    maxl = 0
    lenl = len(l)
    modK = K % lenl
    numK = K // lenl
    if l[lenl - 1][0] > 0:
        maxl += numK * l[lenl - 1][0]
        maxl += max(l[:modK], key = lambda x:x[0])[0]
    else:
        maxl += max(l[:min(K, lenl)], key = lambda x:x[0])[0]
    ans.append(maxl)

print(max(ans))
            

Fixed submission:
N, K = map(int, input().split())
P = list(map(lambda x:int(x) - 1,input().split()))
C = list(map(int, input().split()))
ans = -10**9

for i in range(N):
    tmp_max = [-10**9]*(N+1)
    total = 0
    current_block = P[i]
    for j in range(1, N + 1):
        total += C[current_block]
        tmp_max[j] = max(tmp_max[j-1], total)
        if current_block == i:
            break
        current_block = P[current_block]
    if total <= 0:
        ans = max(ans, tmp_max[j])
    else:
        n = K // j
        r = K % j
        if r == 0:
            ans = max(ans, total*(n-1) + tmp_max[j])
        else:
            ans = max(ans, total*n + tmp_max[r])

print(ans)
Buggy python submission (verdict: Runtime Error):
import math
N, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse = True)

ans_l = 0
ans_h = A[0]
while ans_l != ans_h:
    ans_m = (ans_l + ans_h) // 2
    tmp_n = 0
    for a in A:
        tmp_n += math.ceil(a / ans_m) - 1
    if tmp_n > K:
        ans_l = ans_m + 1
    else:
        ans_h = ans_m

print(ans_h)

Fixed submission:
X = int(input())

print("Yes") if X >= 30 else print("No")
Buggy python submission (verdict: Runtime Error):
import numpy
n = int(input())
l = numpy.array(list(map(int,input().split())))
av = round(numpy.average(l))
square_list = numpy.square(l - av)

print(numpy.sum(square_list))

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
min_sum = 10**9
for i in range(min(l),max(l)+1):
    min_sum = min(min_sum,sum([(j-i)**2 for j in l]))

print(min_sum)

Buggy python submission (verdict: Runtime Error):
import numpy
n = int(input())
l = list(map(int,input().split()))
av = round(numpy.average(l))
sumsquare = 0
for i in l:
    sumsquare += (i - av)**2
print(sumsquare)

Fixed submission:
n = int(input())
l = list(map(int,input().split()))
min_sum = 10**9
for i in range(min(l),max(l)+1):
    min_sum = min(min_sum,sum([(j-i)**2 for j in l]))

print(min_sum)