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

Fixed submission:
import fractions
import functools


def lcm(a, b):
    return a * b // fractions.gcd(a, b)


N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
res = functools.reduce(lcm, T)
print(res)

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


def lcm(a, b):
    return a * b // math.gcd(a, b)


N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
res = functools.reduce(lcm, T)
print(res)
Problem p02993 (python)

Fixed submission:
a,b,c,d= list(input())

if a==b:
    print('Bad')
elif b==c:
    print('Bad')
elif c==d:
    print('Bad')
else:
    print('Good')

Buggy submission (verdict: Runtime Error):
import math

A, B, C, D = map(int, input().split(' '))

num_C_baisu = B//C - (A-1)//C #(math.ceil(A/C) - 1)

num_D_baisu = B//D - (A-1)//D #(math.ceil(A/D) - 1)

CD = int(C*D/math.gcd(C,D))

num_CD_baisu = B//CD - (A-1)//CD #(math.ceil(A/CD) - 1)

baisu_num = num_C_baisu + num_D_baisu - num_CD_baisu

print(B-A+1-baisu_num)

Buggy submission (verdict: Runtime Error):
import math

A, B, C, D = map(int, input().split(' '))

num_C_baisu = (B//C - math.ceil(A/C)) + 1

num_D_baisu = (B//D - math.ceil(A/D)) + 1

CD = int(C*D/math.gcd(C,D))

num_CD_baisu = (B//CD - math.ceil(A/CD)) + 1

baisu_num = num_C_baisu + num_D_baisu - num_CD_baisu

print(B-A+1-baisu_num)
Problem p02995 (python)

Fixed submission:
def common_multiple(x, y):
    for i in range(2, min(x, y)+1):
        mod_x = x % i
        mod_y = y % i
        if (mod_x == 0 and mod_y == 0):
            return common_multiple(x // i, y // i) * i
        if (mod_x == 0):
            return common_multiple(x // i, y) * i
        if (mod_y == 0):
            return common_multiple(x, y // i) * i
    return  x * y

a = input().split(" ")
A,B,C,D=int(a[0]) - 1,int(a[1]),int(a[2]),int(a[3])

M = common_multiple(C,D)
B0 = B // C + B // D - B // M
A0 = A // C + A // D - A // M
print(B - A - B0 + A0)

Buggy submission (verdict: Runtime Error):
def common_multiple(x, y):
    for i in range(2, min(x, y)+1):
        mod_x, mod_y = x % i, y % i
        if mod_x != 0 and mod_y != 0:
            next
        x0 = x // i if (mod_x == 0) else x
        y0 = y // i if (mod_y == 0) else y
        return common_multiple(x0, y0) * i
    return x * y


a = input().split(" ")
A, B, C, D = int(a[0]) - 1, int(a[1]), int(a[2]), int(a[3])

M = common_multiple(C, D)
B0 = B // C + B // D - B // M
A0 = A // C + A // D - A // M
print(B - A - B0 + A0)
Problem p03029 (python)

Fixed submission:
try:
    a,p=map(int, input().split())
    assert 0<=a,p<=100
    print(((a*3)+p)//2)
except AssertionError:
    print('')

Buggy submission (verdict: Runtime Error):
N = int(input())
lis = [(input() + " " + str(i+1)).split() for i in range(N)]
 
lis = [k for k in lis]
 
lis.sort(key=lambda k: int(k[1]), reverse=True)
lis.sort(key=lambda k: k[0])
 
 
for j in lis:
    print(j[2])

Buggy submission (verdict: Runtime Error):
N = int(input())
list1 = [(input() + " " + str(i+1)).split() for i in range(N)]
 
list1 = [k for k in list1]
 
list1.sort(key=lambda k: int(k[1]), reverse=True)
list1.sort(key=lambda k: k[0])
 
 
for i in list1:
    print(i[2])

Buggy submission (verdict: Runtime Error):
N = int(input())
list1 = [(input() + " " + str(i+1)).split() for i in range(N)]
 
list1 = [a for a in lis]
 
list1.sort(key=lambda a: int(a[1]), reverse=True)
list1.sort(key=lambda a: a[0])
 
 
for i in list1:
    print(i[2])

Buggy submission (verdict: Runtime Error):
N = int(input())
list1 = [(input() + " " + str(i+1)).split() for i in range(N)]
 
list1 = [a for a in lis]
 
list1.sort(key=lambda a: int(a[1]), reverse=True)
list1.sort(key=lambda a: a[0])
 
 
for i in lis:
    print(i[2])
Problem p03030 (python)

Fixed submission:
n=int(input())
l=list()
for i in range(n):
    s,p=input().split()
    l.append([s,int(p),i+1])
l.sort(key=lambda x:(x[0],-x[1]))
[print(k) for i,j,k in l]

Buggy submission (verdict: Runtime Error):
N = int(input())
lis = [(input() + " " + str(i+1)).split() for i in range(N)]
 
lis = [k for k in lis]
 
lis.sort(key=lambda k: int(k[1]). reverse=True)
lis.sort(key=lambda k: k[0])
 
 
for i in lis:
    print(i[2])

Buggy submission (verdict: Runtime Error):
N = int(input())
list1 = [(input() + " " + str(i+1)).split() for i in range(N)]
 
list1 = [a for a in lis]
 
list1.sort(key=lambda a: int(a[1]), reverse=True)
list1.sort(key=lambda a: a[0])
 
 
for i in list1:
    print(i[2])
Problem p03035 (python)

Fixed submission:
try:
    age,money=map(int, input().split())
    assert 0<=age<=100 and 2<=money<=1000 and money%2==0
    if age<=5:
        print('0')
    elif 6<=age<=12:
        print(money//2)
    else:
        print(money)
except AssertionError:
    print('')

Buggy submission (verdict: Runtime Error):
age,money=map(float, input().split())
assert 1<=age<=100 and 2<=money<=1000 and money%2==0
if age<=5:
    print('0')
elif 6<=age<=12:
    print(money/2)
else:
    print(money)

Buggy submission (verdict: Runtime Error):
age,money=map(int, input().split())
assert 1<=age<=100 and 2<=money<=1000 and money%2==0
if age<=5:
    print('0')
elif 6<=age<=12:
    print(money/2)
else:
    print(money)

Buggy submission (verdict: Runtime Error):
age,money=map(int, input().split())
assert 1<=age<=100 and 2<=b<=1000 and b%2==0
if age<=5:
    print('0')
elif 6<=age<=12:
    print(money/2)
else:
    print(money)

Buggy submission (verdict: Runtime Error):
age,money=map(int, input()).split()
assert 1<=age<=100 and 2<=b<=1000 and b%2==0
if age<=5:
    print('0')
elif 6<=age<=12:
    print(money/2)
else:
    print(money)

Buggy submission (verdict: Runtime Error):
age,money=map(int, input()).split()
assert 1<=age<=100 and 2<=b<=1000 and b%2==0
if age<=5:
	print('0')
elif 6<=age<=12:
  	print(money/2)
else:
  	print(money)
Problem p03434 (python)

Fixed submission:
Alice = 0
Bob = 0
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
Alice = a[::2]
Bob = a[1::2]
print(sum(Alice)-sum(Bob))

Buggy submission (verdict: Runtime Error):
Alice = 0
Bob = 0
N = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
Alice = a[::2]
Bob = a[1::2]
print(Alice-Bob)
Problem p03455 (python)

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

Buggy submission (verdict: Runtime Error):
a,b = int(input())
if a*b % 2 == 1:
  print("Odd")
else:
  print("Even")
Problem p02993 (python)

Fixed submission:
x=input()
def goodorbad(n):
    for i in range (0,3):
        if n[i]==n[i+1]:
            return "Bad\n"
    return "Good\n"
print (goodorbad(x))

Buggy submission (verdict: Runtime Error):
import numpy as np
N=int(input())
a=[]
b=[]
xa=[]
xb=[]
y=[]
for i in range (0,N):
    c,d=(int(x) for x in input().split(" "))
    xa.append(c)
    xb.append(d)
     
z=np.argsort(xb)

for i in range (0,N):
    a.append(xa[z[i]])
    b.append(xb[z[i]])
for i in range (0,N):
    if i==0:
      	y.append(a[0])
    else:
      	y.append(a[i]+y[i-1])
def check(i,a,b):
    if b[i]>=y[i]:
        return True
    else:
        return False
def final_check(a,b,N):
    for i in range (0,N):
        if check(i,a,b)==False:
            return "No"
    return "Yes"
print (final_check(a,b,N))
Problem p02995 (python)

Fixed submission:
A, B, C, D=(int(x) for x in input().split(" "))
import fractions

def eks(x,a):
    return a//x

def wai(x):
    return eks(x,B)-eks(x,A-1)

def lcm(a,b):
    return a*b//fractions.gcd(a,b)

zet=B-A+1-(wai(C)+wai(D)-wai(lcm(C,D)))
print (zet)

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D=(int(x) for x in input().split(" "))
def gcd(x,y): 
  
   while(y): 
        x, y = y, x % y 
  
   return x 
def nb_divisers(n,m):
    return n//m
def nb_d_btw(f,g,n):
    if f%n==0:
        return nb_divisers(g,n)-nb_divisers(f,n)+1
    else:
        return nb_divisers(g,n)-nb_divisers(f,n)
def nb_notdivisers_f(a,b,c,d):
    e=int(c*d/math.gcd(c,d))
    return b-a+1-(nb_d_btw(a,b,c)+nb_d_btw(a,b,d)-nb_d_btw(a,b,e))
print(nb_notdivisers_f(A,B,C,D))

Buggy submission (verdict: Runtime Error):
import math
A,B,C,D=(int(x) for x in input().split(" "))
def nb_divisers(n,m):
    return n//m
def nb_d_btw(f,g,n):
    if f%n==0:
        print(nb_divisers(g,n)-nb_divisers(f,n)+1)
        return nb_divisers(g,n)-nb_divisers(f,n)+1
    else:
        print(nb_divisers(g,n)-nb_divisers(f,n))
        return nb_divisers(g,n)-nb_divisers(f,n)
def nb_notdivisers_f(a,b,c,d):
    e=int(c*d/math.gcd(c,d))
    return b-a+1-(nb_d_btw(a,b,c)+nb_d_btw(a,b,d)-nb_d_btw(a,b,e))
print(nb_notdivisers_f(A,B,C,D))

Buggy submission (verdict: Runtime Error):
import math
a,b,c,d=input().split(" ")
A=int(a)
B=int(b)
C=int(c)
D=int(d)
def nb_divisers(n,m):
    return n//m
def nb_d_btw(f,g,n):
    if f%n==0:
        print(nb_divisers(g,n)-nb_divisers(f,n)+1)
        return nb_divisers(g,n)-nb_divisers(f,n)+1
    else:
        print(nb_divisers(g,n)-nb_divisers(f,n))
        return nb_divisers(g,n)-nb_divisers(f,n)
def nb_notdivisers_f(a,b,c,d):
    e=int(c*d/math.gcd(c,d))
    return b-a+1-(nb_d_btw(a,b,c)+nb_d_btw(a,b,d)-nb_d_btw(a,b,e))
print(nb_notdivisers_f(A,B,C,D))
Problem p03076 (python)

Fixed submission:
import math

list = []
for i in range(5):
    list.append(int(input()))
sum = 0
zeroList = [list[i] for i in range(len(list)) if list[i]%10 == 0]
otherList = [list[i] for i in range(len(list)) if not list[i]%10 == 0]
def func(x):
    return x % 10
otherList.sort(key=func)
for i in range(len(zeroList)):
    sum += zeroList[i]
for i in (otherList[1:]):
    sum += math.ceil(i/10)*10
if not len(otherList) == 0:
    sum += otherList[0]
print(sum)

Buggy submission (verdict: Runtime Error):
import math

list = []
for i in range(5):
    list.append(int(input()))
sum = 0
zeroList = [list[i] for i in range(len(list)) if list[i]%10 == 0]
otherList = [list[i] for i in range(len(list)) if not list[i]%10 == 0]
def func(x):
    return x % 10
otherList.sort(key=func)
for i in range(len(zeroList)):
    sum += zeroList[i]
for i in (otherList[1:]):
    sum += math.ceil(i/10)*10
sum += otherList[0]
print(sum)

Buggy submission (verdict: Runtime Error):
import math

list = []
for i in range(5):
    a = int(input())
    list.append(a)
sum = 0
zeroList = [list[i] for i in range(len(list)) if list[i]%10 == 0]
otherList = [list[i] for i in range(len(list)) if not list[i]%10 == 0]
def func(x):
    return x % 10
otherList.sort(key=func)
print(otherList)
for i in range(len(zeroList)):
    sum += zeroList[i]
    print(sum)
for i in (otherList[1:]):
    sum += math.ceil(i/10)*10
sum += otherList[0]
print(sum)
Problem p03086 (python)

Fixed submission:
s = list(input())
cnt = 0
list = []
for i in range(len(s)):
    if s[i] in ['A','C','G','T']:
        cnt += 1
    else:
        if cnt > 0:
            list.append(cnt)
            cnt = 0
if not cnt == 0:
    list.append(cnt)
if len(list) == 0:
    list.append(0)
max = max(list)
print(max)

Buggy submission (verdict: Runtime Error):
s = list(input())
cnt = 0
list = []
for i in range(len(s)):
    if s[i] in ['A','C','G','T']:
        cnt += 1
    else:
        if cnt > 0:
            list.append(cnt)
            cnt = 0
if not cnt == 0:
    list.append(cnt)
max = max(list)
print(max)

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

Fixed submission:
# review
N,A,B,C = map(int,input().split())
L = [int(input()) for _ in range(N)]
 
def f(i,a,b,c):
    if i == N:
        if min(a, b, c) <= 0:
            return 10**9
        return abs(a-A)+abs(b-B)+abs(c-C)-30
    costx = f(i+1,a,b,c)
    costA = f(i+1,a+L[i],b,c)+10
    costB = f(i+1,a,b+L[i],c)+10
    costC = f(i+1,a,b,c+L[i])+10
    return min(costx,costA,costB,costC)
 
print(f(0,0,0,0))

Buggy submission (verdict: Runtime Error):
# review
import copy
n, a, b, c = map(int, input().split())
lList = []

for _ in range(n) :
        lList.append(int(input()))

lList.sort()
goal = [a, b, c]
goal.sort()

def removed(i,j) :
        goal.remove(i)
        lList.remove(j)

mp = 0
def pick(x, y) : # if same value & goal < lList
        mp = 0
        for i in copy.copy(x) :
                for j in copy.copy(y) :
                        if i == j and i in goal:
                                removed(i,j)
        for i in copy.copy(x) :
                for j in copy.copy(y) :
                        if i < j and i in goal:
                                mp += j - i 
                                removed(i,j)

pick(goal,lList)      


diffList = []
diff = 10
for j in lList :
        for i in goal :
                if abs(i-j) < 10 :
                        diff = min(diff, abs(i-j))
        if diff != 10 :
                diffList.append([diff, i, j])
        diff = 10
for i in diffList :      
        mp += i[0]       
        goal.remove(i[1])
        lList.remove(i[2])

add2 = []
for i in lList :
        for j in lList[i+1:] :
                add2.append(i + j, i, j)
# ------------------------------------------------------
# addList = []
# diff = 10
# for j in add2 :
#         for i in goal :
#                 if abs(i-j[0]) < 10 :
#                         diff = min(diff, abs(i-j[0]))
#         if diff != 10 :
#                 diffList.append([diff, i, j[0]])
#         diff = 10
# for i in diffList :      
#         mp += i[0]       
#         goal.remove(i[1])
#         lList.remove(i[2])


             
print(mp)
Problem p03281 (python)

Fixed submission:
n = int(input())
cnt = 0
divisor = []
for i in range(1,n+1,2) :
        for j in range(1,i+1) :
                if i % j == 0 :
                        cnt += 1
        divisor.append(cnt)
        cnt = 0
ans = 0
for i in divisor :
        if i == 8 :
                ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
for i in range(1,n+1,2) :
	cnt = 0
	for j in range(1,i+1) :
		if i % j == 0 :
        	cnt += 1
	if cnt == 8 :
		ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
for i in range(1,n+1,2) :
 	cnt = 0
	for j in range(1,i+1) :
		if i % j == 0 :
        	cnt += 1
	if cnt == 8 :
		ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
ans = 0
for i in range(1,n+1,2) :
  cnt = 0
    for j in range(1,i+1) :
      if i % j == 0 :
        cnt += 1
    if cnt == 8 :
      ans += 1
print(ans)
Problem p03680 (python)

Fixed submission:
n = int(input())
l = []
ans = 1
for _ in range(n) :
	l.append(int(input()))
if l[0] == 2 :
	print(1)
else :
    i = l[0] - 1
    while True :
        if l[i] == 2 :
            ans += 1
            break
        i = l[i] - 1
        ans += 1
        if ans == n+1 :
            print(-1)
            exit()
    print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = []
ans = 1
for _ in range(n) :
	l.append(int(input()))
if l[0] == 2 :
	print(1)
else :
    i = l[0] - 1
	while True :
		if l[i] == 2 :
			ans += 1
			break
		i = l[i] - 1
		ans += 1
		if ans == n+1 :
			print(-1)
			exit()
	print(ans)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = []
ans = 1
for _ in range(n) :
	l.append(int(input()))
if l[0] == 2 :
	print(1)
else :
	i = l[0] - 1
while True :
	if l[i] == 2 :
		ans += 1
		break
	i = l[i] - 1
	ans += 1
	if ans == n+1 :
		print('-1')
		exit()
print(ans)
Problem p03777 (python)

Fixed submission:
a, b = map(str, input().split())
if a == b :
	print('H')
else : 
	print('D')

Buggy submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a == b :
	print('H')
else : 
	print('D')
Problem p03795 (python)

Fixed submission:
n = int(input())
print((800 * n) - (200 * (n//15)))

Buggy submission (verdict: Runtime Error):
n = int(input())
print((800 * n) - (200 * (n//15))
Problem p03145 (python)

Fixed submission:
l = raw_input().split()

l = map(lambda x: int(x), l)
l.sort()

print l[0] * l[1] / 2

Buggy submission (verdict: Runtime Error):
def bonus(i, l):
  if i in l:
    return 0
  else:
    return (len(l)+1)*(len(l)+1) - len(l)*len(l)

l = raw_input().split()
n = []
variety =[]
count = 0
for x in range(int(l[0])):
  n.append(map(lambda x: int(x),raw_input().split()))

for y in range(int(l[1])):
  max_saf = 0
  num = 0
  for i, x in enumerate(n):
    if max_saf < x[1] + bonus(x[0], variety):
      max_saf = x[1] + bonus(x[0], variety)
      num = i
    
  count = count + max_saf
  print(n[num])
  print(variety)
  print(max_saf)
  if not n[num][0] in variety:
  	variety.append(n[num][0])
  del n[num]
    
    
print (count)
Problem p03261 (python)

Fixed submission:
N = input()
a = []
f = True
for i in range(N):
  a.append(raw_input())
    
for x in range(N-1):
  if a[x][-1:] != a[x+1][:1]:
    f = False
    
if len(a) != len(set(a)):
  f = False

if f:
  print "Yes"
else:
  print "No"

Buggy submission (verdict: Runtime Error):
N = input()
a = []
f = True
for i in range(N):
  a.append(input())
    
for x in range(N-1):
  if a[x][:1] != a[x+1][-1:]:
    f = False
    
if len(a) != len(set(a)):
  f = False

if f:
  print "Yes"
else:
  print "No"
Problem p02993 (python)

Fixed submission:
_input = input()
S = _input

tmp = None
ans = 'Good'
for s in S:
    if s == tmp:
        ans = 'Bad'
        break
    tmp = s

print(ans)

Buggy submission (verdict: Runtime Error):
import fractions

A, B, C, D = tuple([int(a) for a in input().split(' ')])


def func1(n):
    return n - n//C - n//D + n//(C*D//fractions.gcd(C, D))


print(func1(B) - func1(A-1))
Problem p02995 (python)

Fixed submission:
import fractions 

# 01:10
A, B, C, D = tuple([int(a) for a in input().split(' ')])


def func1(n):
    return n - n//C - n//D + n//(C*D//fractions.gcd(C, D))


print(func1(B) - func1(A-1))

Buggy submission (verdict: Runtime Error):
import math

# 01:10
A, B, C, D = tuple([int(a) for a in input().split(' ')])


def func1(n):
    return n - n//C - n//D + n//(C*D//math.gcd(C, D))


print(func1(B) - func1(A-1))
Problem p02993 (python)

Fixed submission:
param = input()
s = list(map(int, list(str(param))))

pre = None
check = True
 
for i in s:
  if pre != None:
    if pre == i:
      print("Bad")
      check = False
      break
  pre = i
  
if check:
  print("Good")

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

def apple_aji(i):
  return int(l) + int(i) - 1

def apple_pie(n):
  ajis = [apple_aji(x) for x in n]
  mini = min(list(map(abs, ajis)))
  mini = mini * -1
  if mini in ajis:
    pass
  else:
    mini = mini * -1
  print(ajis)
  ajis.remove(mini)
  print(ajis)
  return sum(ajis)

print(apple_pie(range(1, int(n))))
Problem p02994 (python)

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

def apple_aji(i):
  return int(l) + int(i) - 1

def remove_min(p):
  minimun = min(list(map(abs, p)))
  if minimun not in p:
    minimun = minimun * -1
  p.remove(minimun)
  return p

def apple_pie(n):
  ajis = [apple_aji(x) for x in n]
  return sum(remove_min(ajis))

print(apple_pie(range(1, int(n)+1)))

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

def apple_aji(i):
  return int(l) + int(i) - 1

def apple_pie(n):
  ajis = [apple_aji(x) for x in n]
  mini = min(list(map(abs, ajis)))
  ajis.remove(mini)
  return sum(ajis)

print(apple_pie(range(1, int(n))))

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

def apple_aji(i):
  return int(l) + int(i) - 1

def apple_pie(n):
  ajis = [apple_aji(x) for x in n]
  ajis.sort()
  mini = min([abs(x) for x in ajis])
  ajis.remove(mini)
  return sum(ajis)

print(apple_pie(range(1, int(n))))
Problem p02995 (python)

Fixed submission:
#ABC131c 3.4以前ではmathではなくfractons

import fractions

a,b,c,d=map(int,input().split())


count_c=b//c - (a-1)//c
count_d=b//d - (a-1)//d
count_cd=b//(c*d//fractions.gcd(c,d)) - (a-1)//(c*d//fractions.gcd(c,d))

print(b-a+1-count_c-count_d+count_cd)

Buggy submission (verdict: Runtime Error):
#ABC131c

import math
from functools import reduce

a,b,c,d=map(int,input().split())


count_c=b//c - (a-1)//c
count_d=b//d - (a-1)//d
count_cd=b//(c*d//math.gcd(c,d)) - (a-1)//(c*d//math.gcd(c,d))

print(b-a+1-count_c-count_d+count_cd)

Buggy submission (verdict: Runtime Error):
#ABC131c

import math


a,b,c,d=map(int,input().split())


count_c=b//c - (a-1)//c
count_d=b//d - (a-1)//d
count_cd=b//(c*d//math.gcd(c,d)) - (a-1)//(c*d//math.gcd(c,d))

print(b-a+1-count_c-count_d+count_cd)
Problem p03062 (python)

Fixed submission:
#https://atcoder.jp/contests/abc125/tasks/abc125_d

from functools import reduce

def positivesum(lists):
	for i in range(len(lists)):
		if lists[i]<0:
			lists[i]=lists[i]*(-1)
	return(sum(lists))
	

n=int(input())
alist=list(map(int,input().split()))

#負数の数をカウント
count=0
for i in range(n):
	if alist[i]<0:
		count+=1


if count==n and count%2==1:
	print(-sum(alist)+2*max(alist))

elif count%2==0:
	print(positivesum(alist))
else:
	alist.sort()
	x=max(alist[count-1],-alist[count])
	print(positivesum(alist)+x*2)

Buggy submission (verdict: Runtime Error):
#https://atcoder.jp/contests/abc125/tasks/abc125_d

from functools import reduce

def positivesum(lists):
	for i in range(len(lists)):
		if lists[i]<0:
			lists[i]=lists[i]*(-1)
	return(sum(lists))
	

n=int(input())
alist=list(map(int,input().split()))

#負数の数をカウント
count=0
for i in range(n):
	if alist[i]<0:
		count+=1

if count%2==0:
	print(positivesum(alist))
else:
	alist.sort()
	x=max(alist[count-1],-alist[count])
	print(positivesum(alist)+x*2)
Problem p03103 (python)

Fixed submission:
#https://atcoder.jp/contests/abc121/tasks/abc121_c

import numpy as np

n,m=map(int,input().split())

ablist=np.array([list(map(int,input().split())) for i in range(n)])

#aの昇順にソート
newablist=ablist[ablist[:,0].argsort(),:]
x=newablist


costcount=0
i=0

while i<n and x[i][1]<= m:
	m -= x[i][1]
	costcount += x[i][0]*x[i][1]
	i += 1

if i < n:
	costcount += m*x[i][0]


print(costcount)

Buggy submission (verdict: Runtime Error):
#https://atcoder.jp/contests/abc121/tasks/abc121_c

import numpy as np

n,m=map(int,input().split())

ablist=np.array([list(map(int,input().split())) for i in range(n)])

#aの昇順にソート
newablist=ablist[ablist[:,0].argsort(),:]
x=newablist


costcount=0
i=0

while x[i][1]<= m:
	m -= x[i][1]
	costcount += x[i][0]*x[i][1]
	i += 1

costcount += m*x[i][0]


print(costcount)
Problem p03471 (python)

Fixed submission:
#お札が合計N枚ある時に合計金額がY円になる枚数の組み合わせ　存在しない場合は（-1,-1,-1）
  
n,y=map(int,input().split())
a,b,c=-1,-1,-1

for i in range(n+1):
	for j in range(n-i+1):
		if 10000*i + 5000*j + 1000*(n-i-j) ==y:
			a,b,c=i,j,(n-i-j)

print(a,b,c)

Buggy submission (verdict: Runtime Error):
#お札が合計N枚ある時に合計金額がY円になる枚数の組み合わせ　存在しない場合は（-1,-1,-1）
  
n=int(input())
y=int(input())
a,b,c=-1,-1,-1

for i in range(n):
	for j in range(n-i):
		if 10000*i + 5000*j + 1000*(n-i-j) ==y:
			a,b,c=i,j,(n-i-j)

print(a,b,c)
Problem p03477 (python)

Fixed submission:
#天秤
  
a,b,c,d=map(int,input().split())

l=a+b
r=c+d

if l==r:
	print("Balanced")
else:
	if l>r:
		print("Left")
	else:
		print("Right")

Buggy submission (verdict: Runtime Error):
#1以上N以下の整数のうち、10進法で各桁の和がA以上B以下であるものについて総和
  
n=int(input())
a=int(input())
b=int(input())

def s(x):
        return x//10000 + x%10000//1000 + x%1000//100 + x%100//10 + x%10

sum=0

for i in range(n+1):
        if a<=int(s(i))<=b:
                sum+=i

print(sum)
Problem p03478 (python)

Fixed submission:
#1以上N以下の整数のうち、10進法で各桁の和がA以上B以下であるものについて総和
  
n,a,b=map(int,input().split())
def s(x):
        return x//10000 + x%10000//1000 + x%1000//100 + x%100//10 + x%10

sum=0

for i in range(n+1):
        if a<=int(s(i))<=b:
                sum+=i

print(sum)

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

l=a+b
r=c+d

if l==r:
	print("Balanced")
else:
	if l>r:
		print("Left")
	else:
		print("Right")

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

l=a+b
r=c+d

if l==r:
	print("Balanced")
else:
	if l>r:
		print("Left")
	else:
		print("Right")

Buggy submission (verdict: Runtime Error):
#1以上N以下の整数のうち、10進法で各桁の和がA以上B以下であるものについて総和
  
n=int(input())
a=int(input())
b=int(input())
 
def s(x):
        return x//10000 + x%10000//1000 + x%1000//100 + x%100//10 + x%10
 
sum=0
 
for i in range(n+1):
        if a<=int(s(i))<=b:
                sum+=i
 
print(sum)