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

Fixed submission:
n,k = map(int,input().split())
S = input()+'!'
A = [0]
tmp = 1
for i in range(1,n+1):
    if S[i] == S[i-1]:
        tmp += 1
    else:
        A.append(tmp)
        tmp = 1
for i in range(1,len(A)):
    A[i] += A[i-1]
#print(A)
res = 0
if S[0] == '0':
    for i in range(len(A)):
        if i%2 == 0:
            ans = A[min(i+2*k,len(A)-1)]-A[i]
        else:
            ans = A[min(i+2*k+1,len(A)-1)]-A[i]
        if res <= ans:
            res = ans
else:
    for i in range(len(A)):
        if i%2 == 0:
            ans = A[min(len(A)-1,i+2*k+1)]-A[i]
        else:
            ans = A[min(i+2*k,len(A)-1)]-A[i]
        if res <= ans:
            res = ans

print(res)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float('inf')
MOD = 10**9+7
dy = [0,1,0,-1]
dx = [1,0,-1,0]
ddy = [0,1,1,1,0,-1,-1,-1]
ddx = [1,1,0,-1,-1,-1,0,1]

n,k = map(int,input().split())
S = input()+'!'

get = [0]
tmp = 1
for i in range(1,n+1):
    if S[i] == S[i-1]:
        tmp += 1
    else:
        get.append(tmp)
        tmp = 1

get = get + [0]

for i in range(1,len(get)):
    get[i] += get[i-1]

res = 0
if S[0] == '0':
    for i in range(len(get)-2*k):
        if i%2 == 0:
            ans = get[i+2*k]-get[i]
        else:
            ans = get[min(i+2*k+1,len(get))]-get[i]
        if res <= ans:
            res = ans
else:
    for i in range(len(get)-2*k):
        if i%2 == 0:
            ans = get[min(len(get),i+2*k+1)]-get[i]
        else:
            ans = get[i+2*k]-get[i]
        if res <= ans:
            res = ans

print(res)
Problem p03078 (python)

Fixed submission:
x,y,z,k = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
res = []
for p in range(x):
	for q in range(y):
		if (p+1)*(q+1) > k:
			break
		for r in range(z):
			if (p+1)*(q+1)*(r+1) > k:
				break
			res.append(A[p]+B[q]+C[r])
res.sort(reverse=True)
for i in res[:k]:
	print(i)

Buggy submission (verdict: Runtime Error):
import math,itertools,fractions,heapq,collections,re,bisect,sys,functools

sys.setrecursionlimit(10**7)
inf = float('inf')
mod = 10**9+7
dy = [-1,0,1,0]
dx = [0,1,0,-1]
ddy = [-1,-1,0,1,1,1,0,-1]
ddx = [0,1,1,1,0,-1,-1,-1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

#######################################################################

x,y,z,k = LI()
A = sorted(LI(),reverse=True)
B = sorted(LI(),reverse=True)
C = sorted(LI(),reverse=True)

ab = []
for a in A:
    for b in B:
            ab.append(a+b)
ab.sort(reverse=True)
res = []
for i in range(k):
    for c in C:
        res.append(ab[i]+c)
res.sort(reverse=True)

for i in range(k):
    print(res[i])
Problem p03086 (python)

Fixed submission:
S = input()+'Z'
X = 'ATCG'
res = [0]
count = 0
for i in S:
    if i in X:
        count += 1
    else:
        res.append(count)
        count = 0
print(max(res))

Buggy submission (verdict: Runtime Error):
S = input()
X = 'ATCG'
res = []
cnt = 0
for s in S:
    if s in X:
        cnt += 1
        res.append(cnt)
    else:
        cnt = 0
print(max(res))

Buggy submission (verdict: Runtime Error):
S = input()
A = ['A','T','C','G']
res = []
count = 0
for i in S:
    if i in A:
        count += 1
    else:
        res.append(count)
        count = 0
print(max(res))
Problem p03087 (python)

Fixed submission:
n,q = map(int,input().split())
S = input()
N = [0]*(10**5+1)
for i in range(1,n):
    if S[i-1]=='A'and S[i]=='C':
        N[i] = 1
SUM = [0]*(10**5+1)
for i in range(1,n):
    SUM[i] += SUM[i-1]+N[i]
for i in range(q):
    l,r = map(int,input().split())
    print(SUM[r-1]-SUM[l-1])

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
S = input()
N = [0]*(10**5+1)
for i in range(1,n+1):
    if S[i-1]=='A'and S[i]=='C':
        N[i] = 1
SUM = [0]*(10**5+1)
for i in range(1,n+1):
    SUM[i] += SUM[i-1]+N[i]
for i in range(q):
    l,r = map(int,input().split())
    print(SUM[r-1]-SUM[l-1])

Buggy submission (verdict: Runtime Error):
n,q = map(int,input().split())
S = input()
N = [0]*(10**5+1)
for i in range(1,n+1):
    if S[i-1]=='A'and S[i]=='C':
        N[i] = 1
for i in range(q):
    l,r = map(int,input().split())
    print(sum(N[:r])-sum(N[:l]))
Problem p03103 (python)

Fixed submission:
n,m = map(int,input().split())
ab = []
for i in range(n):
        ab.append([int(j) for j in input().split()])
ab.sort()
cnt = 0
ans = 0
for i in ab:
    cnt += i[1]
    ans += i[0]*i[1]
    if cnt >= m:
        ans -= i[0]*(cnt-m)
        print(ans)
        exit()

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
AB = sorted([list(map(int,input().split())) for i in range(N)])
res = 0
for a,b in range(N):
    M -= b
    res += a*b
    if M < 0:
        res += a*M
        break
print(res)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
AB = [(int(i) for i in input().split()) for j in range(n)]
AB.sort()
res = 0
for a,b in AB:
	m -= b
	if m >= 0:
		res += a*b
	else:
		m += b
		res += a*m
		break
print(res)
Problem p03129 (python)

Fixed submission:
import sys,math
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float('inf')
MOD = 10**9+7
dy = [0,1,0,-1]
dx = [1,0,-1,0]
ddy = [0,1,1,1,0,-1,-1,-1]
ddx = [1,1,0,-1,-1,-1,0,1]

n,k = map(int,input().split())
if math.ceil(n/2) >= k:
    print('YES')
else:
    print('NO')

Buggy submission (verdict: Runtime Error):
n = int(input())+1
a = int(input())
b = int(input())
print((n-a)*(n-b))
Problem p03219 (python)

Fixed submission:
x,y = map(int,input().split())
print(x + y // 2)

Buggy submission (verdict: Runtime Error):
n = int(input())
t,a = map(int,input().split())
H_list = list(map(int,input().split()))
temp_list = [t-h*0.006 for h in H_list ]
ans_list = [abs(a-x) for x in temp_list]
ans = min(ans_list)
print(ans_list.index(ans)+1)
Problem p03220 (python)

Fixed submission:
n = int(input())
t,a = map(int,input().split())
H_list = list(map(int,input().split()))
temp_list = [t-h*0.006 for h in H_list ]
ans_list = [abs(a-x) for x in temp_list]
ans = min(ans_list)
print(ans_list.index(ans)+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
t,a = map(int,input().split())
H_list = list(map(int,input().split()))
t_list = [t-h*0.006 for h in H_list ]
a_list = [abs(a-x) for x in temp_list]
print(a_list.index(min(a_list))+1)
Problem p03231 (python)

Fixed submission:
N,M = map(int,input().split())
S = input()
T = input()
from fractions import gcd
G = gcd(N,M)
if S[::N//G] == T[::M//G]:
    print(N*M//G)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
S = input()
T = input()
from fractions import gcd
L = N*M//gcd(N,M)
res = [0]*(L)
cnt1 = 0
for s in S:
    res[cnt1*L//N] = s
    cnt1 += 1
cnt2 = 0
for t in T:
    if res[cnt2*L//M] == 0 or res[cnt2*L//M] == t:
        res[cnt2*L//M] = t
        cnt2 += 1
    else:
        print(-1)
        exit()
print(L)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
S = input()
T = input()
from fractions import gcd
L = N*M//gcd(N,M)
res = ['!']*(10**10)
cnt1 = 0
for s in S:
    if cnt1*L//N > L:
        print(-1)
        exit()
    res[cnt1*L//N] = s
    cnt1 += 1
cnt2 = 0
for t in T:
    if cnt2*L//M > L:
        print(-1)
        exit()
    if res[cnt2*L//M] == '!' or res[cnt2*L//M] == t:
        res[cnt2*L//M] = t
        cnt2 += 1
    else:
        print(-1)
        exit()
print(L)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
S = input()
T = input()
from fractions import gcd
L = N*M//gcd(N,M)
res = ['!']*(L+100)
cnt1 = 0
for s in S:
    if cnt1*L//N > L:
        print(-1)
        exit()
    res[cnt1*L//N] = s
    cnt1 += 1
cnt2 = 0
for t in T:
    if cnt2*L//M > L:
        print(-1)
        exit()
    if res[cnt2*L//M] == '!' or res[cnt2*L//M] == t:
        res[cnt2*L//M] = t
        cnt2 += 1
    else:
        print(-1)
        exit()
print(L)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
S = input()
T = input()
from fractions import gcd
L = N*M//gcd(N,M)
res = ['!']*(L+100)
cnt1 = 0
for s in S:
    res[cnt1*L//N] = s
    cnt1 += 1
cnt2 = 0
for t in T:
    if res[cnt2*L//M] == '!' or res[cnt2*L//M] == t:
        res[cnt2*L//M] = t
        cnt2 += 1
    else:
        print(-1)
        exit()
print(L)

Buggy submission (verdict: Runtime Error):
N,M = map(int,input().split())
S = input()
T = input()
from fractions import gcd
L = N*M//gcd(N,M)
res = ['!']*(L+1)
cnt1 = 0
for s in S:
    res[cnt1*L//N] = s
    cnt1 += 1
cnt2 = 0
for t in T:
    if res[cnt2*L//M] == '!' or res[cnt2*L//M] == t:
        res[cnt2*L//M] = t
        cnt2 += 1
    else:
        print(-1)
        exit()
print(L)
Problem p03274 (python)

Fixed submission:
n,k = map(int,input().split())
X = list(map(int,input().split()))
S = []
for i in range(n-k+1):
	if X[i]*X[i+k-1] < 0:
		S.append(X[i+k-1]-X[i]+min(abs(X[i+k-1]),abs(X[i])))
	else:
		S.append(max(abs(X[i+k-1]),abs(X[i])))
print(min(S))

Buggy submission (verdict: Runtime Error):
N,K = map(int,input().split())
X = list(map(int,input().split()))
res = 10**10
for i in range(N-K+1):
    if X[i]*X[i+K-1] >= 0:
        res = min(res,max(abs(X[i+K-1],X[i])))
    else:
        res = min(res,abs(X[i])*2+X[i+K-1],X[i+K-1]*2+abs(X[i]))
print(res)
Problem p03287 (python)

Fixed submission:
from collections import Counter
n,m = map(int,input().split())
A = list(map(int,input().split()))
B = [0]
for a in A:
    B.append((B[-1]+a)%m)
D = Counter(B)
res = 0
for v in D.values():
    res += v*(v-1)//2
print(res)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
A = [int(i)%m for i in input().split()]  
S = [0]*n
S[0] = A[0]
for i in range(n):
	S[i] = (S[i-1]+A[i])%m
D = dict()
for s in S:
	if s in D:D[s] += 1
	else:D[s] = 1
res = D[0]
for v in D.values():
	res += v*(v-1)//2
print(res)

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().split())
A = [int(i)%m for i in input().split()]  
S = [0]*n
S[0] = A[0]
for i in range(n):
	S[i] = (S[i-1]+A[i])%m
D = dict()
for s in S:
	if s in D:D[s] += 1
	else:D[s] = 1
res = D[0]
for v in D.values():
	res += v*(v-1)//2
print(res)
Problem p03433 (python)

Fixed submission:
n = int(input()) % 500
a = int(input())
if a >= n:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
A = sorted(A,reverse=True)
A_card = []
B_card = []
for i in range(n):
        if i%2 == 0:
                A_card.append(A[i])
        else:
                B_card.append(A[i])
print(sum(A_card) - sum(B_card))

Buggy submission (verdict: Runtime Error):
n = int(input())
A = sorted(list(map(int,input().split())))
A_card = []
B_card = []
for i in range(n):
        if i%2 == 0:
                A_card.append(A[i])
        else:
                B_card.append(A[i])
print(sum(A_card) - sum(B_card))

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
A = sorted(A)
Alice_card = []
Bob_card = []
for i in range(n):
        if i%2 == 0:
                Alice_card.append(A[i])
        else:
                Bob_card.append(A[i])
Alice_total = sum(Alice_card)
Bob_total = sum(Bob_card)
print(abs(Alice_total - Bob_total))

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
Alice_card = []
Bob_card = []
for i in range(n):
        if i%2 == 0:
                Alice_card.append(A[i])
        else:
                Bob_card.append(A[i])
Alice_total = sum(Alice_card)
Bob_total = sum(Bob_card)
print(abs(Alice_total - Bob_total))
Problem p03447 (python)

Fixed submission:
x = int(input()) 
a = int(input())
b = int(input())
print((x-a)%b)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500*i+100*j+50*k == x:
                count += 1 
print(count)
Problem p03469 (python)

Fixed submission:
print(input().replace('2017','2018'))

Buggy submission (verdict: Runtime Error):
n = int(input())
D = [input() for i in range(n)]
print(len(set(D)))
Problem p03477 (python)

Fixed submission:
a,b,c,d = map(int,input().split())
if a+b > c+d:
    print('Left')
elif a+b == c+d:
    print('Balanced')
else:
    print('Right')

Buggy submission (verdict: Runtime Error):
n,a,b =  map(int,input().split())
ans = 0
for i in range(n+1):
        good_num = 0
        for j in str(i) :
                good_num += int(j)
        if a <= good_num <= b:
                ans += i
print(ans)
Problem p03493 (python)

Fixed submission:
print(input().count('1'))

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

c = 0
while all (a%2==0 for a in A):
    A = list(a//2 for a in A)
    c += 1
print(c)
Problem p03523 (python)

Fixed submission:
s = input()
if s == "KIHBR" or s == "AKIHBR" or s == "KIHABR" or s == "KIHBAR" or s == "KIHBRA" or s == "AKIHABR" or s == "AKIHBAR"or s == "AKIHBRA"or s == "KIHABAR"or s == "KIHABRA"or s == "KIHBARA"or s == "AKIHABAR"or s == "AKIHABRA"or s == "AKIHBARA"or s == "KIHABARA"or s == "AKIHABARA":
    print("YES")
else:
    print("NO")

Buggy submission (verdict: Runtime Error):
s = input()
if s == "KIHBR" or s == "AKIHBR" or s == "KIHABR" or s == "KIHBAR" or s == "KIHBRA" or s == "AKIHABR" or s == "AKIHBAR"or s == "AKIHBRA"or s == "KIHABAR"or s == "KIHABRA"or s == "KIHBARA"or s == "AKIHABAR"or s == "AKIHABRA"or s == "AKIHBARA"or s == "KIHABARA"or s == "AKIHABARA":
    print("YWS")
else:
    print("NO)
Problem p03599 (python)

Fixed submission:
A,B,C,D,E,F = map(int,input().split())

W = set()
for i in range(0,F+1,100*A):
    for j in range(0,F+1-i,100*B):
        W.add(i+j)
        
S = set()
for i in range(0,F+1,C):
    for j in range(0,F+1-i,D):
        S.add(i+j)

rate = 0
for w in W:
    for s in S:
        if 0 < w+s <= F and s/(w+s) <= E/(E+100):
            if s/(w+s) >= rate:
                rate= s/(w+s)
                res1,res2 = w+s,s
                
print(res1,res2)

Buggy submission (verdict: Runtime Error):
A,B,C,D,E,F = map(int,input().split())

W = set()
for i in range(0,F+1,100*A):
    for j in range(0,F+1-i,100*B):
        W.add(i+j)
        
S = set()
for i in range(0,F+1,C):
    for j in range(0,F+1-i,D):
        S.add(i+j)

rate = 0
for w in W:
    for s in S:
        if 0 < w+s <= F and s/(w+s) <= E/(E+100):
            if s/(w+s) > rate:
                rate= s/(w+s)
                res1,res2 = w+s,s
                
print(res1,res2)
Problem p03635 (python)

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

Buggy submission (verdict: Runtime Error):
n,m = map(int,input().spilt())
print((n-1)*(m-1))
Problem p03637 (python)

Fixed submission:
n = int(input())
A =list(map(int,input().split()))
num4 = 0
num2 = 0
num1 = 0
for a in A:
    if a%4 == 0:
        num4 += 1
    elif a%2 == 0:
        num2 += 1
    else:
        num1 += 1

if num2 == 0:
    if num4 >= num1-1:
        print("Yes")
    else:
        print("No")
else:
    if num4 >= num1:
        print("Yes")
    else:
        print("No")

Buggy submission (verdict: Runtime Error):
n = int(input())
A =list(map(int,input().split()))
num4 = 0
num2 = 0
num1 = 0
for a in A:
    if a%4 == 0:
        nu+= 1
    elif a%2 == 0:
        num2 += 1
    else:
        num1 += 1

if num2 == 0:
    if num4 >= num1-1:
        print("Yes")
    else:
        print("No")
else:
    if num4 >= num1:
        print("Yes")
    else:
        print("No")
Problem p03645 (python)

Fixed submission:
n,m = map(int,input().split())
route = [0]*(n+10)
for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        route[b] += 1
    if b == n:
        route[a] += 1
if 2 in route:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

s = [0]*n
g = [0]*n

for i in range(m):
    a,b = map(int,input().split())
    if a == 1:
        s[b] = 1
    if b == n:
        g[a] = 1
for i in range(n):
    if s[i] and g[i]:
    print("POSSIBLE")
    exit()

print("IMPOSSIBLE")
Problem p03658 (python)

Fixed submission:
n,k = map(int,input().split())
x = list(map(int,input().split()))
x = sorted(x)
ans = 0
for i in range(k):
    ans += x[-i-1]
print(ans)

Buggy submission (verdict: Runtime Error):
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
int main(){
    int n, k;
    cin >> n >> k;
    int l[100];
    rep(i, n) cin >> l[i];
    sort(l, l + n, greater<int>());
    int res = 0;
    rep(i, k) res += l[i];
    cout << res << endl;
}
Problem p03761 (python)

Fixed submission:
n = int(input())
S = [list(input()) for i in range(n)]
X = "qwertyuiopasdfghjklzxcvbnm"
ans = []
for i in range(26):
	res = []
	for s in S:
		res.append(s.count(X[i]))
	for j in range(min(res)):
		ans.append(X[i])
ans.sort()
print("".join(ans))

Buggy submission (verdict: Runtime Error):
3
a
aa
b
Problem p03844 (python)

Fixed submission:
a,x,b = input().split()
if x == '+':
    print(int(a)+int(b))
else:
    print(int(a)-int(b))

Buggy submission (verdict: Runtime Error):
input()
t = list(map(int,input().split()))
m = int(input())
for i in range(m):
    p,x = map(int,input().split())
    print(sum(t)-t[p-1]+x)
Problem p04029 (python)

Fixed submission:
n = int(input())
print(n*(n+1)//2)

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(-100,101):
    c = 0
    for a in A:
        c += abs((i-a)**2)
    ans.append(c)

print(min(c))
Problem p04031 (python)

Fixed submission:
n = int(input())
A = list(map(int,input().split()))
ave1 = sum(A)//n
ave2 = ave1+1
ans1 = 0
ans2 = 0
for a in A:
    ans1 += (a-ave1)**2
    ans2 += (a-ave2)**2
print(min(ans1,ans2))

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(-100,101):
    c = 0
    for a in A:
        c += (i-a)**2
    ans.append(c)

print(min(min))

Buggy submission (verdict: Runtime Error):
n = int(input())
A = list(map(int,input().split()))
ans = []
for i in range(-100,101):
    c = 0
    for a in A:
        c += (i-a)**2
    ans.append(c)

print(min(c))
Problem p04033 (python)

Fixed submission:
a,b = map(int,input().split())
if a <= 0 <= b:
        print("Zero")

elif b < 0 and (b-a)%2 == 0:
        print("Negative")
else:
        print("Positive")

Buggy submission (verdict: Runtime Error):
a,b = map(int(input().split()))
if a <= 0 <= b:
    print('Zero')
elif b < 0 and b%2 == a%2:
    print('Negative')
else:
    print("Positive")
Problem p02709 (python)

Fixed submission:
from collections import *
import itertools
import sys
sys.setrecursionlimit(10**5)
try: inp = raw_input
except: inp = input
def err(s):
    sys.stderr.write('{}\n'.format(s))

def ni():
    return int(inp())

def nl():
    return [int(_) for _ in inp().split()]

N = ni()
A = nl()

X = sorted(enumerate(A), key=lambda x: x[1], reverse=True)
p = [x for x, _ in X]
sc = [x for _, x in X]

DP = [[-1]*N for _ in range(N)]
def opt(l, i):
    r = N - i + l - 1
    if i == N: return 0
    if DP[i][l] != -1: return DP[i][l]
    v1 = abs(p[i]- l)*sc[i] + opt(l+1, i+1)
    v2 = abs(p[i] - r)*sc[i] + opt(l, i+1)
    DP[i][l] = max(v1, v2)
    return DP[i][l]

print(opt(0, 0))

Buggy submission (verdict: Runtime Error):
from collections import *
import itertools
import sys
try: inp = raw_input
except: inp = input
def err(s):
    sys.stderr.write('{}\n'.format(s))

def ni():
    return int(inp())

def nl():
    return [int(_) for _ in inp().split()]

N = ni()
A = nl()

X = sorted(enumerate(A), key=lambda x: x[1], reverse=True)
p = [x for x, _ in X]
sc = [x for _, x in X]

DP = {}
def opt(l, r, i):
    if i == N: return 0
    T = l, r, i
    if T in DP:
        return DP[T]
    v1 = abs(p[i]- l)*sc[i] + opt(l+1, r, i+1)
    v2 = abs(p[i] - r)*sc[i] + opt(l, r-1, i+1)
    DP[T] = max(v1, v2)
    return DP[T]

print(opt(0, N-1, 0))
Problem p03281 (python)

Fixed submission:
a = int(input())
ans = 0
if a >= 105:
    ans+=1
if a >= 135:
    ans+=1
if a >= 165:
    ans+=1
if a >= 189:
    ans+=1
if a >= 195:
    ans+=1
print(ans)

Buggy submission (verdict: Runtime Error):
a = input()
ans = 0
if a >= 105:
    ans+=1
if a >= 135:
    ans+=1
if a >= 165:
    ans+=1
if a >= 189:
    ans+=1
if a >= 195:
    ans+=1
print(ans)
Problem p02802 (python)

Fixed submission:
def get_ints():
    return map(int, input().split())

n, m = get_ints()
penalty = 0
oks = 0
ac = []
penalty = []
for i in range(n):
    ac.append(False)
    penalty.append(0)
for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if ac[p]:
        continue
    if s == 'AC':
        ac[p] = True
        oks += 1
    else:
        penalty[p] += 1

ans = 0
for i in range(n):
    if ac[i]:
        ans += penalty[i]

print(str(oks) + ' ' + str(ans))

Buggy submission (verdict: Runtime Error):
def get_ints():
    return map(int, input().split())

n, m = get_ints()
penalty = 0
oks = 0
ac = []
for i in range(n):
    ac.append(False)
for i in range(m):
    p, s = input().split()
    p = int(p)
    p -= 1
    if ac[p]:
        continue
    if s == 'AC':
        ac[p] = True
        oks += 1
    else:
        penalty += 1

print(f'{oks} {penalty}')
Problem p02814 (python)

Fixed submission:
from fractions import gcd
from functools import reduce

def get_ints():
    return list(map(int, input().split()))

[n, m] = get_ints()
a = get_ints()

def small_lcm(x, y):
    if x is None or y is None:
        return None
    ans = x * y // gcd(x, y)
    return ans if ans <= m else None

def count_div2(a):
    ans = 0
    while a % 2 == 0:
        ans += 1
        a //= 2
    return ans

cds = list(map(count_div2, a))
for v in cds:
    if v != cds[0]:
        print(0)
        exit(0)

l = reduce(small_lcm, map(lambda x: x // 2, a))
if l is None:
    print(0)
    exit(0)
t = m // l
print(t // 2 if t % 2 == 0 else t // 2 + 1)

Buggy submission (verdict: Runtime Error):
import math
from functools import reduce

def get_ints():
    return list(map(int, input().split()))

[n, m] = get_ints()
a = get_ints()

l = reduce(lambda n, m: n * m // math.gcd(n, m), map(lambda x: x // 2, a))
t = m // l
print(t // 2 if t % 2 == 0 else t // 2 + 1)
Problem p03952 (python)

Fixed submission:
n, x = map(int, input().split())
l = 2 * n - 1

if x == 1 or x == l:
    print('No')
    exit(0)

if n == 2:
    print('Yes\n1\n2\n3')
    exit(0)

ans = list(map(lambda k: (k - n + x) % l + 1, range(l)))
ans[n - 3], ans[n + 1] = ans[n + 1], ans[n - 3]
print('Yes')
for v in ans:
    print(v)

Buggy submission (verdict: Runtime Error):
n, x = map(int, input().split())
l = 2 * n - 1

if x == 1 or x == l:
    print('No')
    exit(0)

ans = list(map(lambda k: (k - n + x) % l + 1, range(l)))
ans[n - 3], ans[n + 1] = ans[n + 1], ans[n - 3]
print('Yes')
print(' '.join(map(str, ans)))