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

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

dp = [float('inf')]*(N+1)
dp[0]=0
dp[1]=0
    

for i in range(N):
    if i!=0:
        for k in range(K):
            if i-k>=1:
                dp[i+1] = min ( dp[i+1] ,dp[i-k] + abs(H[i]-H[i-(k+1)]) )
print(int(dp[N]))
# print(dp)

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

import numpy as np
dp = np.ones(N+1,dtype=float)*float('inf')
dp[0]=0
dp[1]=0
    

for i in range(N):
    if i!=0:
        for k in range(K):
            if i-k>=1:
                dp[i+1] = min ( dp[i+1] ,dp[i-k] + abs(H[i]-H[i-(k+1)]) )
print(int(dp[N]))
# print(dp)

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

#入力
N,K=map(int,input().split())
H=list(map(int,input().split()))

dp = np.ones(N+1,dtype=float)*float('inf')
dp[0]=0
dp[1]=0
    

for i in range(N):
    if i!=0:
        for k in range(K):
            if i-k>=1:
                dp[i+1] = min ( dp[i+1] ,dp[i-k] + abs(H[i]-H[i-(k+1)]) )
print(int(dp[N]))
# print(dp)
Problem p03162 (python)

Fixed submission:
N=int(input())
dp=[]
for j in range(N+1):
    dp.append([0,0,0])

for i in range(N):
    a,b,c = map(int,input().split())
    if i == 0:
        dp[i+1][0] = dp[i][0]+a
        dp[i+1][1] = dp[i][1]+b
        dp[i+1][2] = dp[i][2]+c
    else:
        dp[i+1][0] = max(dp[i][1]+a, dp[i][2]+a)
        dp[i+1][1] = max(dp[i][0]+b, dp[i][2]+b)
        dp[i+1][2] = max(dp[i][0]+c, dp[i][1]+c)

# print(dp,sep="\n")
print(max(dp[N][0],dp[N][1],dp[N][2]))

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

N=int(input())
dp=[0]*(N+1)


for i in range(N):
    a,b,c = map(int,input().split())
    if i == 0:
        dp[i+1] = dp[i]+max(a,b,c)
        flg = [a,b,c].index(max([a,b,c]))
    else:
        if flg==0:
            dp[i+1] = dp[i] + max(b,c)
            flg = [a,b,c].index(max([b,c]))
        elif flg==1:
            dp[i+1] = dp[i] + max(a,c)
            flg = [a,b,c].index(max([a,c]))
        else:
            dp[i+1] = dp[i] + max(a,b)
            flg = [a,b,c].index(max([a,b]))

# print(dp)
print(dp[N])
Problem p03231 (python)

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

from fractions import gcd

lcm=n*m//gcd(n,m)

if s[0]!=t[0]:
    print(-1)
    exit(0)

ans=lcm
# sについて
dn={}
for i in range(n):
    if i==0:
        dn[1]=s[i]
    else:
        dn[i*int((lcm)/n) +1]=s[i]

for j in range(m):
    if j==0:
        continue
    else:
        k = j*int(lcm/m) + 1

        if k in dn:
            if dn[k]!=t[j]:
                ans=-1
        else:
            dn[k]=t[j]

print(ans)

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

from math import gcd

lcm=n*m//gcd(n,m)

if s[0]!=t[0]:
    print(-1)
    exit(0)

ans=lcm
# sについて
dn={}
for i in range(n):
    if i==0:
        dn[1]=s[i]
    else:
        dn[i*int((lcm)/n) +1]=s[i]

for j in range(m):
    if j==0:
        continue
    else:
        k = j*int(lcm/m) + 1

        if k in dn:
            if dn[k]!=t[j]:
                ans=-1
        else:
            dn[k]=t[j]

print(ans)
Problem p03393 (python)

Fixed submission:
s=input()
alp='abcdefghijklmnopqrstuvwxyz'

if s=='zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit(0)

d={}
e={}
for i in range(len(alp)):
    d[alp[i]]=i
    e[i]=alp[i]

n=len(s)
if n!=26:
    ans=[]
    for i in range(n):
        ans.append(d[s[i]])

    for j in range(26):
        if j not in ans:
            ans.append(j)
            break

    st=''
    for k in ans:
        st+=e[k]
else:
    arr=[]

    dp=[]
    for i in range(n):
        dp.append(d[s[i]])
    
    while True:
        v=dp.pop()

        tmp=[j for j in arr if j>v]
        if len(tmp)!=0:
            dp.append(min(tmp))
            break
        
        arr.append(v)
        
    st=''
    for k in dp:
        st+=e[k]



print(st)

Buggy submission (verdict: Runtime Error):
s=input()
alp='abcdefghijklmnopqrstuvwxyz'

if s=='zyxwvutsrqponmlkjihgfedcba':
    print(-1)
    exit(0)

d={}
e={}
for i in range(len(alp)):
    d[alp[i]]=i
    e[i]=alp[i]

n=len(s)
if n!=26:
    ans=[]
    for i in range(n):
        ans.append(d[s[i]])

    for j in range(26):
        if j not in ans:
            ans.append(j)
            break

    st=''
    for k in ans:
        st+=e[k]
else:
    indices=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]
    dp=[]
    flgs=[0]*n

    for i in range(n):
        dp.append(min(indices))
        if dp[i]==d[s[i]]:
            flgs[i]=0
        else:
            flgs[i]=1
        indices.remove(d[s[i]])

    indices=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]
    ans=[]
    for j in range(n):
        if flgs[j]==0 and flgs[j+1]==0:
            ans.append(d[s[j]])
            indices.remove(d[s[j]])
        else:
            indices.remove(d[s[j]])
            ans.append(min(indices))
            break

    st=''
    for k in ans:
        st+=e[k]


print(st)
Problem p03557 (python)

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

b=sorted(b)
c=sorted(c)

from bisect import bisect_right

d=[]
for i in range(n):
    index = bisect_right(c,b[i])    

    d.append(n-index)

import numpy as np
s=sum(d)
cum=np.cumsum(d)

ans=0
for j in range(n):
    dex = bisect_right(b,a[j])
    if dex==0:
        ans+=s
    elif dex==n:
        continue
    else:
        ans+=s-cum[dex-1]

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()))

b=sorted(b)
c=sorted(c)

from bisect import bisect_right

d=[]
for i in range(n):
    index = bisect_right(c,b[i])
    if b[i]==c[index]:
        index-=1
    
    if index==-1:
        index=1

    d.append(n-index)

import numpy as np
s=sum(d)
cum=np.cumsum(d)

ans=0
for j in range(n):
    dex = bisect_right(b,a[j])
    if dex==0:
        ans+=s
    elif dex==n:
        continue
    else:
        ans+=s-cum[dex-1]


    

print(ans)
Problem p03565 (python)

Fixed submission:
s=input()
t=input()


kouho=[]
for i in range(len(s)-len(t)+1):
    ans=s[:i]
    tmp=s[i:(i+len(t))]

    for j in range(len(t)):
        if tmp[j]==t[j]:
            ans+=t[j]
        elif tmp[j]=='?': 
            ans+=t[j]
        elif tmp[j]!='?' and tmp[j]!=t[j]:
            break
    ans=ans+s[(i+len(t)):]

    if len(ans)==len(s):
        kouho.append(ans)

if len(kouho)==0:
    print('UNRESTORABLE')
    exit(0)

answers=[]
for j in kouho:

    tmp_ans=''
    for k in range(len(j)):
        if j[k]=='?':
            tmp_ans+='a'
        else:
            tmp_ans+=j[k]

    answers.append(tmp_ans)

answers=sorted(answers)
print(answers[0])

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

alp='abcdefghijklmnopqrstuvwxyz'
d={}
e={}
for i in range(len(alp)):
    d[i]=alp[i]
    e[alp[i]]=i


c=[]
q=''
for i in range(len(t)+1):
    q=(t[:i] + '?'*(len(t)-i))
    m=s.rfind(q)
    if m==-1:
        continue

    c.append(m)


h=[]
for j in range(len(t),len(s)+1,1):
    q='?'*j
    m=s.rfind(q)
    if m==-1:
        continue
    h.append(m)

ans=''
if len(c)==0 and len(h)==0:
    ans='UNRESTORABLE'
elif len(c)>0 and len(h)==0:
    index=max(c)
    j=0
    for i in range(len(s)):
        if i>=index and i<= index+len(t):
            ans+=t[j]
            j+=1
        elif s[i]=='?':
            ans+='a'
        else:
            ans+=s[i]     
elif len(h)>0 and len(c)==0:
    index=max(h)
    j=0
    for i in range(len(s)):
        if i>=index and i<= index+len(t):
            ans+=t[j]
            j+=1
        elif s[i]=='?':
            ans+='a'
        else:
            ans+=s[i] 
else:
    index=max(max(c),max(h))
    j=0
    for i in range(len(s)):
        if i>=index and i<= index+len(t):
            ans+=t[j]
            j+=1
        elif s[i]=='?':
            ans+='a'
        else:
            ans+=s[i] 

print(ans)
Problem p03721 (python)

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

d={}
for _ in range(n):
    a_i,b_i=map(int,input().split())
    if a_i in d:
        d[a_i]+=b_i
    else:
        d[a_i]=b_i


a=[]
b=[]

d=sorted(d.items(),key=lambda x: x[0])


prev=0
for key,value in d:
    a.append(key)
    b.append(prev+value)

    prev+=value


for j in range(len(b)):
    if k<=b[j]:
        break

print(a[j])

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

a=[]
b=[]
d={}
for _ in range(n):
    a_i,b_i=map(int,input().split())
    d[a_i]=b_i

d=sorted(d.items(),key=lambda x: x[0])


prev=0
for key,value in d:
    a.append(key)
    b.append(prev+value)

    prev+=value


for j in range(n):
    if k<=b[j]:
        break

print(a[j])
Problem p03910 (python)

Fixed submission:
n=int(input())

import bisect

ans=[1]
i=1
s=1
while True:
    if s>=n:
        break
    i+=1
    s+=i
    ans.append(i)

dif = s-n
if dif==0:
    for i in range(len(ans)):
        print(ans[i])
    exit(0)
    
index = bisect.bisect_left(ans,dif)

for i in range(len(ans)):
    if i==index:
        continue
    print(ans[i])

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

ans=[1]
i=1
s=1
while True:
    if s>=n:
        break
    i+=1
    s+=i
    ans.append(i)

dif = s-n
if dif==0:
    for i in range(len(ans)):
        print(ans[i])
    exit(0)
    
for i in range(len(ans)):
    if a[i]==dif:
        continue
    print(ans[i])
Problem p03943 (python)

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

max_des = max(A)

A.remove(max_des)

if sum(A)==max_des:
    print('Yes')
else:
    print('No')

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


total =sum([a,b,c])


if sum_A%3==0:
    print('Yes')
else:
    print('No')
Problem p03998 (python)

Fixed submission:
s_a = list(input())
s_b = list(input())
s_c = list(input())
x=s_a[0]

while True:
    if x=='a':
        if len(s_a)==0:
            print('A')
            exit()

        x=s_a[0]
        s_a.remove(x)


    elif x=='b':
        if len(s_b)==0:
            print('B')
            exit()
        x=s_b[0]
        s_b.remove(x)
        

    elif x=='c':
        if len(s_c)==0:
            print('C')
            exit()
        x=s_c[0]
        s_c.remove(x)

Buggy submission (verdict: Runtime Error):
s_a = list(input())
s_b = list(input())
s_c = list(input())

S=[s_a,s_b,s_c]

order=0
while true:
    if S[order][0]=='a':
        del S[0][0]
        order=0
    elif S[order][0]=='b':
        del S[1][0]
        order=1
    else:
        del S[2][0]
        order=2

    if len(S[order]==0:
        print('A')
        exit(0)
    elif len(S[order])==0:
        print('B')
        exit(0)
    elif len(S[order])==0:
        print('C')
        exit(0)
Problem p04011 (python)

Fixed submission:
N=int(input())
K=int(input())
X=int(input())
Y=int(input())

if N>=K:
    print(X*K + Y*(N-K))
else:
    print(X*N)

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

result=0

for i in range(2**N):
    list2 =[]
    for j in range(N):
        if (i >> j) &1 == 1:
            list2.append(cards[j])
    if len(list2)!=0:
        ave =sum(list2)/len(list2)
        if ave==A:
            result+=1

print(result)

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

if N>=k:
    print(X*K + Y*(K-N))
else:
    print(X*N)
Problem p04012 (python)

Fixed submission:

w=input()

import collections 

l=collections.Counter(list(w))
l=list(l.values())

flg=0
for i in range(len(l)):
    if l[i]%2!=0:
        flg+=1

if flg==0:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
import collections 

w=input()

l=collections.Counter(list(w))
l=list(l.values())
flg=0
for i in range(len(l)):
    if l[i]%2!=0:
        flg+=1

if flg==0:
    print('Yes')
else:
    pritn('No')
Problem p02780 (python)

Fixed submission:
'''
.append(要素) リストに要素を追加 
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
import itertools
from functools import reduce
from operator import mul

f = [int(s) for s in stdin.readline().rstrip().split()]
N = f[0]
K = f[1]
p = list(map(lambda x: 1/2+x/2, [int(s)
                                 for s in stdin.readline().rstrip().split()]))
E = []
tmp = 0
for el in p:
    tmp += el
    E.append(tmp)
past = E[K - 1]
for el in range(len(E)):
    if el - K < 0:
        continue
    e = E[el] - E[el - K]
    if past < e:
        past = e
print(past)

Buggy submission (verdict: Runtime Error):
'''
.append(要素) リストに要素を追加 
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
import itertools
from functools import reduce
from operator import mul

f = [int(s) for s in stdin.readline().rstrip().split()]
N = f[0]
K = f[1]
p = list(map(lambda x: 1/2+x/2, [int(s)
                                 for s in stdin.readline().rstrip().split()]))

print(p)
E = []
tmp = 0
for el in p:
    tmp += el
    E.append(tmp)

print(E)
past = -20000
for el in range(len(E)):
    if el - K < 0:
        continue
    e = E[el] - E[el - K]
    if past < e:
        past = e
print(e)
Problem p02854 (python)

Fixed submission:
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math

N = int(stdin.readline().rstrip())
d = [int(s) for s in stdin.readline().rstrip().split()]
count = 0
sumF = d[0]
sumB = d[len(d) - 1]
count = 0
countF = 0
countB = len(d) - 1
while count < len(d):
    if sumF < sumB:
        sumF += d[countF+1]
        countF += 1
        count += 1
    elif sumB < sumF:
        sumB += d[countB-1]
        countB -= 1
        count += 1
    else:
        sumF += d[countF+1]
        countF += 1
        sumB += d[countB-1]
        countB -= 1
        count += 2
print(abs(sum(d[0:countF])-sum(d[countF:len(d)])))

Buggy submission (verdict: Runtime Error):
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math

N = int(stdin.readline().rstrip())
d = [int(s) for s in stdin.readline().rstrip().split()]
count = 0
sumF = d[0]
sumB = d[len(d) - 1]
count = 0
countF = 0
countB = len(d) - 1
while count != len(d):
    if sumF < sumB:
        sumF += d[countF+1]
        countF += 1
        count += 1
    elif sumB < sumF:
        sumB += d[countB-1]
        countB -= 1
        count += 1
    else:
        sumF += d[countF+1]
        countF += 1
        sumB += d[countB-1]
        countB -= 1
        count += 2
print(abs(sum(d[0:countF])-sum(d[countF:len(d)])))
Problem p02882 (python)

Fixed submission:
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.extend(要素)
.insert(場所,要素)
del 配列名[場所]
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)
'''
'''
sort()50
sorted(reverse=true)
'''
'''
2分探索
bisect.bisect_left(リスト, 要素)
'''
data = stdin.readline().rstrip().split()
a = float(data[0])
b = float(data[1])
x = float(data[2])
if (b * a * a >= 2 * x):
    print(90.0 - math.degrees(math.atan(2 * x / (a * b * b))))
elif (not a * a * b == x):
    print(90.0 - math.degrees(math.atan(a * a * a / (2 * a * a * b - 2 * x))))
else:
    print(0.0)

Buggy submission (verdict: Runtime Error):
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.extend(要素)
.insert(場所,要素)
del 配列名[場所]
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)
'''
'''
sort()50
sorted(reverse=true)
'''
'''
2分探索
bisect.bisect_left(リスト, 要素)
'''
data = stdin.readline().rstrip().split()
a = float(data[0])
b = float(data[1])
x = float(data[2])
if (b * a * a >= 2 * x):
    print(90.0 - math.degrees(math.atan(2 * x / (a * b * b))))
else:
    print(90.0 - math.degrees(math.atan(a*a*a/(2 * a*a*b-2 * x))))
Problem p02885 (python)

Fixed submission:
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import copy

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.extend(要素)
.insert(場所,要素)
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)
'''

tes = stdin.readline().rstrip().split()
a = int(tes[0])
b = int(tes[1])
res = a - b * 2
if (res <= 0):
    print(0)
else:
    print(res)

Buggy submission (verdict: Runtime Error):
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import copy

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.extend(要素)
.insert(場所,要素)
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)
'''

n = int(stdin.readline().rstrip())
d = stdin.readline().rstrip().split()
res = 0
count1 = 0
for el1 in d:
    count2 = 0
    for el2 in d:
        if (count2 > count1):
            res += int(el1) * int(el2)
        count2 += 1
    count1 += 1

print(res)
Problem p02886 (python)

Fixed submission:
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import copy

# 入力 =stdin.readline().rstrip()
# 分割 = stdin.readline().rstrip().split()

'''
条件に合うものを絞り込む
data = [1, 2, 3]
s = [x for x in data if x % 3 == 0]
'''

'''
文字配列を数値に
l_si = ['-10', '0', '100']

l_si_i = [int(s) for s in l_si]
'''

'''
a = [2, 4, 6, 8]
b = [3, 6, 9]

print(list(set(a) | set(b)))  # 和集合
print(list(set(a) & set(b)))  # 積集合
'''

'''
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
count = 0
while len([x for x in A if x % 2 == 0]) == N:
    A = list(map(lambda y: y / 2, A))
    count += 1
print(count)
'''

'''
.append(要素)
.extend(要素)
.insert(場所,要素)
-1で末尾で末尾から一つ前
'''
'''
間に空白追加
' '.join(lis)
'''
'''
copy.copy(配列名)
'''

n = int(stdin.readline().rstrip())
d = stdin.readline().rstrip().split()
res = 0
count1 = 0
for el1 in d:
    count2 = 0
    for el2 in d:
        if (count2 > count1):
            res += int(el1) * int(el2)
        count2 += 1
    count1 += 1

print(res)

Buggy submission (verdict: Runtime Error):
n = int(stdin.readline().rstrip())
d = stdin.readline().rstrip().split()
res = 0
count1 = 0
for el1 in d:
    count2 = 0
    for el2 in d:
        if (count2 > count1):
            res += int(el1) * int(el2)
        count2 += 1
    count1 += 1

print(res)
Problem p02548 (python)

Fixed submission:
N = int(input())
 
ans = 0
for a in range(1,N):
    ans += (N-1)//a
        
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input_[0])

ans = 0
for c in range(1,N):
    N_ = N-c
    sq_N_ = int(N_**(1/2))
    for a in range(1,sq_N_+1):
        if N_ % a == 0:
            b = N_//a
            ans += 2
        if a == b:
            ans -= 1
print(ans)

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

ans = 0
for c in range(1,N):
    N_ = N-c
    sq_N_ = int(N_**(1/2))
    for a in range(1,sq_N_+1):
        if N_ % a == 0:
            b = N_//a
            ans += 2
        if a == b:
            ans -= 1
print(ans)
Problem p02584 (python)

Fixed submission:
X,K,D = list(map(int,input().split()))

N = abs(X)//D

if N >= K:
    ans = abs(X) - K*D
elif (K-N)%2 == 0:
    ans = abs(X) - N*D
else:
    ans = D - (abs(X) - N*D)
print(ans)

Buggy submission (verdict: Runtime Error):
X,K,D = list(map(int,input_[0].split()))

N = abs(X)//D

if N >= K:
    ans = abs(X) - K*D
elif (K-N)%2 == 0:
    ans = abs(X) - N*D
else:
    ans = D - (abs(X) - N*D)
print(ans)
Problem p02642 (python)

Fixed submission:
# %%time
# from collections import Counter

N=list(map(int,input().split()))
A=list(map(int,input().split()))

# A=list(range(2,10**6))

# counter = Counter(A)

A.sort()
max=A[-1]
dp=[0]*(max+1)

for i in A:
    if dp[i]!=0:
        dp[i]+=1
        continue
    for j in range(1*i,max+1,i):
        dp[j]+=1
        
ans=[]
for a_idx,a in enumerate(A):
    if dp[a] == 1:
        ans.append(a)
        
print(len(ans))

Buggy submission (verdict: Runtime Error):
N=list(map(int,input().split()))
A=list(map(int,input().split()))
A=list(set(A))
A.sort()
 
ans=[]
for a in A:
    for ans_idx in range(len(ans)+1):
        if ans_idx == len(ans):
            ans.append(a)
            ans_.append(a)
            break
            
        ans_temp=ans[ans_idx]
        if a % ans_temp == 0:
            break
        
print(len(ans))

Buggy submission (verdict: Runtime Error):
cnt=0
ans=[]
ans_=[]
for a in A:
    for ans_idx in range(len(ans)+1):
        if ans_idx == len(ans):
            ans.append(a)
            ans_.append(a)
            break
            
        ans_temp=ans[ans_idx]
        if a % ans_temp == 0:
            if a in ans_:
                ans_.remove(a)
            break
        
print(len(ans_))
Problem p02658 (python)

Fixed submission:
N=int(input())

A=list(map(int,input().split()))

ans=1
if 0 in A:
    ans=0
else:
    for a in A:
        ans=ans*a
        if ans > 10**18:
            ans=-1
            break

print(ans)

Buggy submission (verdict: Runtime Error):
ans=1
if 0 in A:
    ans=0
else:
    for a in A:
        ans=ans*a
        if ans > 10**18:
            ans=-1
            break

print(ans)
Problem p02677 (python)

Fixed submission:
import numpy as np

A,B,H,M=list(map(int,input().split()))

short_angle = 360*(1-(H+M/60)/12)
long_angle = 360*(1-M/60)

angle=abs(short_angle-long_angle)

if angle > 180:
    angle =360-angle
    
# print(angle)

ans_2=A**2+B**2-2*A*B*np.cos(np.pi*angle/180)
ans=np.sqrt(ans_2)

print(ans)

Buggy submission (verdict: Runtime Error):
import numpy as np
A,B,H,M=list(map(int,input().split()))

short_angle = 360*(1-(H+M/60)/12)
long_angle = 360*(1-M/60)

angle=abs(short_angle-long_angle)

if angle > 180:
    angle =360-angle
    
# print(angle)

ans_2=A**2+B**2-2*A*B*np.cos(np.pi*angle/180)
ans=np.sqrt(ans_2)

print(ans)