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

Fixed submission:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
import math
F = sys.stdin

D, G = map(int,F.readline().split())
p = []
c = []
all_score = []
maisu = 0
ans = 0
sum = 0
all_selected = [0]*D
for k in range(D):
    p1, c1 = map(int,F.readline().split())
    p.append(p1)
    c.append(c1)
    all_score.append(100 * (k+1) * p1 + c1)

for bit in range(1<<D):
    for i in range(D):
        if bit & (1<<i):
            all_selected[i] = 1
            sum += all_score[i]
            maisu += p[i]

    nokori = G - sum
    if nokori <= 0:
        if ans == 0:
            ans = maisu
        else:
            ans = min(ans, maisu)
        all_selected = [0]*D
        maisu = 0
        sum = 0
        continue

    for j in range(D)[::-1]:
        if all_selected[j] == 0:
            nokorimaisu = math.ceil(nokori / (100 * (j+1)))
            if nokorimaisu <= p[j]:
                maisu += nokorimaisu
                if ans == 0:
                    ans = maisu
                else:
                    ans = min(ans, maisu)
            break

    all_selected = [0]*D
    maisu = 0
    sum = 0

print(ans)

Buggy submission (verdict: Runtime Error):
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
F = sys.stdin

D, G = map(int,F.readline().split())
p = []
c = []
all_score = []
maisu = 0
ans = 0
sum = 0
all_selected = [0]*D
for k in range(D):
    p1, c1 = map(int,F.readline().split())
    p.append(p1)
    c.append(c1)
    all_score.append(100 * k * p1 + c1)

for bit in range(1<<D):
    for i in range(D):
        if bit & (1<<i):
            all_selected[i] = 1
            sum += all_score[i]
            maisu += p[i]

    nokori = G - sum
    if nokori <= 0:
        if ans == 0:
            ans = maisu
        else:
            ans = min(ans, maisu)
        continue
    for j in range(D)[::-1]:
        if all_selected[j] == 0:
            nokorimaisu = (nokori // (100 * j)) + 1
            if nokorimaisu <= p[j]:
                maisu += nokorimaisu
                if ans == 0:
                    ans = maisu
                else:
                    ans = min(ans, maisu)
            break



    all_selected = [0]*D
    maisu = 0
    sum = 0

print(ans)
Problem p04044 (python)

Fixed submission:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
F = sys.stdin
N, L = F.readline().rstrip().split()
N = int(N)
L = int(L)
a = [F.readline().rstrip() for x in range(N)]

a.sort()
answer = ''.join(a)
print(answer)

Buggy submission (verdict: Runtime Error):
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
F = sys.stdin
N, L = int(F.readline().rstrip().split())
a = [F.readline() for x in range(N)]

a.sort()
answer = ''.join(a)
print(answer)
Problem p03032 (python)

Fixed submission:
read = input 
rn = lambda :list(map(int, read().split()))
# O(N^2)
n, k = rn()
V = rn() # 0 ~ n-1
best = 0
for i in range(0, n + 1): # [0, n]
    for j in range(i, n+1): # [i + 1, n]
        # take [0,i), [j, n)
        yes = V[0:i] + V[j: n]
        if len(yes) > k:
            continue
        leftout = k - len(yes)
        yes.sort()
        skip = 0
        for skip in range(len(yes)):
            if yes[skip] <0 and leftout > 0:
                leftout -= 1
            else :
                break
        if best < sum(yes[skip:]):
            best = sum(yes[skip:])
#             print(yes[skip:], k, best)
print(best)

Buggy submission (verdict: Runtime Error):
read = input 
rn = lambda :list(map(int, read().split()))
# O(N^2)
n, k = rn()
V = rn() # 0 ~ n-1
best = 0
for i in range(0, n + 1): # [0, n]
    for j in range(i + 1, n+1): # [i + 1, n]
        # take [0,i), [j, n)
        yes = V[0:i] + V[j: n]
        if len(yes) > k:
            continue
        leftout = k - len(yes)
        yes.sort()
        for skip in range(len(yes)):
            if yes[skip] <0 and leftout > 0:
                leftout -= 1
            else :
                break
        if best < sum(yes[skip:]):
#             print(yes[skip:], k)
            best = sum(yes[skip:])
print(best)
Problem p03044 (python)

Fixed submission:
read = input
n = int(read())
v = [[] for i in range(n+1)] # 邻接
used = [0 for i in range(n+1)] # 节点 1~n
def add(f,t,w):
    v[f].append((t, w))
for i in range(n-1):
    f,t,w = map(int, read().split())
    add(f,t,w)
    add(t,f,w)
# 从1出发，贪心即可，1画1，理论不会有回环
# def dfs(f, s, fa=-1):
#     if s % 2 == 0: 
#         used[f] = 1
#     for t, w in v[f]:
# #         print('%d->%d->%d'%(fa, f, t,), s, w)
#         if t == fa:continue
#         dfs(t, w + s, f)
from queue import Queue
q = Queue()
#def dfs(f, s, fa=-1):
#    if s % 2 == 0: 
#        used[f] = 1
#    for t, w in v[f]:
##         print('%d->%d->%d'%(fa, f, t,), s, w)
#        if t == fa:continue
#        dfs(t, w + s, f)
#
#
#dfs(1,0)
q.put_nowait((1, 0, -1))
while not q.empty():
    f, s, fa = q.get_nowait()
    if s % 2 == 0: 
        used[f] = 1
    for t, w in v[f]:
#         print('%d->%d->%d'%(fa, f, t,), s, w)
        if t == fa:continue
        q.put_nowait(
            (t, w + s, f)
        )
    
for i in used[1:]:
    print(used[i])

Buggy submission (verdict: Runtime Error):
read = input
n = int(read())
v = [[] for i in range(n+1)] # 邻接
used = [0 for i in range(n+1)] # 节点 1~n
def add(f,t,w):
    v[f].append((t, w))
    
for i in range(n-1):
    f,t,w = map(int, read().split())
    add(f,t,w)
    add(t,f,w)
# 从1出发，贪心即可，1画1，理论不会有回环
def dfs(f, s, fa=-1):
    if s % 2 == 0: 
        used[f] = 1
    for t, w in v[f]:
#         print('%d->%d->%d'%(fa, f, t,), s, w)
        if t == fa:continue
        dfs(t, w + s, f)
dfs(1,0)
for i in used[1:]:
    print(used[i])

Buggy submission (verdict: Runtime Error):
n = int(read())
v = [[] for i in range(n+1)] # 邻接
used = [0 for i in range(n+1)] # 节点 1~n
def add(f,t,w):
    v[f].append((t, w))
    
for i in range(n-1):
    f,t,w = map(int, read().split())
    add(f,t,w)
    add(t,f,w)
# 从1出发，贪心即可，1画1，理论不会有回环
def dfs(f, s, fa=-1):
    if s % 2 == 0: 
        used[f] = 1
    for t, w in v[f]:
#         print('%d->%d->%d'%(fa, f, t,), s, w)
        if t == fa:continue
        dfs(t, w + s, f)
dfs(1,0)
for i in used[1:]:
    print(used[i])
Problem p03046 (python)

Fixed submission:
read = input 
rn = lambda :map(int, read().split())
m,k = rn()
import math
N = 2**(m) - 1 # 0~N
r = [i for i in range(N+1)] # 0~N
if k > N:
    print(-1)
# elif N == 1 and k == 0:
#     print(0, 0)
elif N == 1 and k == 1:
    print('-1')
elif k ==  0:
    for i in r:
        print(i, end=' ')
    r.reverse()
    for i in r:
        print(i, end=' ')
elif N == 2 and k == 1:
    print(-1)
else:
    for i in r:
        if i == k:continue
        print(i, end=' ')
    print(k, end=' ')
    r.reverse()
    for i in r:
        if i == k:continue
        print(i, end=' ')
    print(k, end=' ')

Buggy submission (verdict: Runtime Error):
input = read
rn = lambda :map(int, read().split())
m,k = rn()
import math
N = 2**(m) - 1 # 0~N
r = [i for i in range(N+1)] # 0~N
if k > N:
    print(-1)
# elif N == 1 and k == 0:
#     print(0, 0)
elif k ==  0:
    for i in r:
        print(i, end=' ')
    r.reverse()
    for i in r:
        print(i, end=' ')
elif N == 2 and k == 1:
    print(-1)
else:
    for i in r:
        if i == k:continue
        print(i, end=' ')
    print(k, end=' ')
    r.reverse()
    for i in r:
        if i == k:continue
        print(i, end=' ')
    print(k, end=' ')

Buggy submission (verdict: Runtime Error):
input 
rn = lambda :map(int, read().split())
m,k = rn()
import math
N = 2**(m) - 1
r = [i for i in range(N+1)]
if k >= N:
    print(-1)
elif k ==  0:
    for i in r:
        print(i, end=' ')
    r.reverse()
    for i in r:
        print(i, end=' ')
elif N == 2 and k == 1:
    print(-1)
else:
    for i in r:
        if i == k:continue
        print(i, end=' ')
    print(k, end=' ')
    r.reverse()
    for i in r:
        if i == k:continue
        print(i, end=' ')
    print(k, end=' ')
Problem p03048 (python)

Fixed submission:
read = input
A = list(map(int, read().split()))
n = A[-1]
A = A[:3]
A.sort(reverse=True) # descending
ans = 0
if A[1] == A[2] and A[1] == 1: #deal with 1 1
    for i in range(n+1):
        tmp = i*A[0]
        if tmp > n:break
#         print(ans, i, A)
        ans += (n-tmp) - 0 + 1
else :
    for i in range(n+1):
        for j in range(n+1):
            tmp = i * A[0] + j * A[1]
            if tmp > n:break
            tmp = n - tmp
            if tmp % A[2] == 0:
    #             print(i, j, tmp//A[2])
                ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
# A = list(map(int, read().split()))
n = A[-1]
A = A[:3]
A.sort(reverse=True) # descending
ans = 0
if A[1] == A[2] and A[1] == 1: #deal with 1 1
    for i in range(n+1):
        tmp = i*A[0]
        if tmp > n:break
#         print(ans, i, A)
        ans += (n-tmp) - 0 + 1
else :
    for i in range(n+1):
        for j in range(n+1):
            tmp = i * A[0] + j * A[1]
            if tmp > n:break
            tmp = n - tmp
            if tmp % A[2] == 0:
    #             print(i, j, tmp//A[2])
                ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
# read = input
A = list(map(int, read().split()))
n = A[-1]
A = A[:3]
A.sort(reverse=True) # descending
ans = 0
if A[1] == A[2]:# deal with 1 1
    for i in range(n+1):
        tmp = i*A[0]
        if tmp > n:break
        ans += (n-tmp) - 0 + 1
else :
    for i in range(n+1):
        for j in range(n+1):
            tmp = i * A[0] + j * A[1]
            if tmp > n:break
            tmp = n - tmp
            if tmp % A[2] == 0:
    #             print(i, j, tmp//A[2])
                ans += 1
print(ans)
Problem p03063 (python)

Fixed submission:
read = input
n = int(read())
s = read()
SW = [0 for i in range(n)]
SB = [0 for i in range(n)]
for i,c in enumerate(s):
    if i == 0:
        SW[i] = 1 if c == '.' else 0
        SB[i] = 1 if c == '#' else 0
    else :
        SW[i] = SW[i-1] + 1 if c == '.' else SW[i-1]
        SB[i] = SB[i-1] + 1 if c == '#' else SB[i-1]
cost = n
for i in range(n):
    pass
#     print(i, SW[i], SB[i])
for i in range(n + 1):
    startW = 0
    endW = i # left W is [0,i)
    startB = i 
    endB = n # right B is [i, n)
#     print(i)
    if i == 0: # all B 
        cost = min(cost, SW[n-1])
    elif i == n: # all W
        cost = min(cost, SB[n-1])
    else:
        cost = min(cost, 
                   SB[i-1] + (SW[n-1] - SW[i-1])
                  )
#     print(i, cost)
print(cost)

Buggy submission (verdict: Runtime Error):
# read = input
n = int(read())
s = read()
SW = [0 for i in range(n)]
SB = [0 for i in range(n)]
for i,c in enumerate(s):
    if i == 0:
        SW[i] = 1 if c == '.' else 0
        SB[i] = 1 if c == '#' else 0
    else :
        SW[i] = SW[i-1] + 1 if c == '.' else SW[i-1]
        SB[i] = SB[i-1] + 1 if c == '#' else SB[i-1]
cost = n
for i in range(n):
    pass
#     print(i, SW[i], SB[i])
for i in range(n + 1):
    startW = 0
    endW = i # left W is [0,i)
    startB = i 
    endB = n # right B is [i, n)
#     print(i)
    if i == 0: # all B 
        cost = min(cost, n - SW[n-1])
    elif i == n: # all W
        cost = min(cost, n - SB[n-1])
    else:
        cost = min(cost, 
                   i - SB[i-1] + (n-i) - (SB[n-1] - SB[i-1])
                  )
print(cost)
Problem p03076 (python)

Fixed submission:
read = input
a = [read() for i in range(5)]
a = list(map(int, a))
if all(map(lambda x: x%10 == 0, a)):
    print(sum(a))
else :
    g10 = list(filter(lambda x:x%10 > 0 , a))
    l10 = list(filter(lambda x:x%10 == 0 , a))
    m = min(g10, key=lambda x:x%10)
    g100= list(map(lambda x:x//10*10 + 10, g10))
    print(sum(g100)  +sum(l10)- m//10*10 - 10 + m)

Buggy submission (verdict: Runtime Error):
read = input
a = [read() for i in range(5)]
a = list(map(int, a))
if all(map(lambda x: x%10 == 0, a)):
    print(sum(a))
else :
    g10 = list(filter(lambda x:x%10 > 0 , a))
    l10 = list(filter(lambda x:x%10 == 0 , a))
    m = min(g10, key=lambda x:x%10)
    g100= list(map(lambda x:x//10*10 + 10, g10))
    print(sum([*g100  ,*l10 ,- m//10*10 + m]))
Problem p03111 (python)

Fixed submission:
read = input
# read = Read(False, """


# 8 1000 800 100
# 300
# 333
# 400
# 444
# 500
# 555
# 600
# 666

# """).read
tmp = read()
tmp = list(map(int, tmp.split(' ')))
N,A,B,C = tmp
opt = list(map(int, map(lambda x: read(), range(N))))
def dfs(n,a,b,c):
    ret = 10**7
    if(n == N):
        if(min(a,b,c) == 0):
            return ret
        return abs(A - a) + abs(B - b) + abs(C - c) - 30
    cur = opt[n]
    ret = min(ret, dfs(n+1, a + cur, b, c) + 10)
    ret = min(ret, dfs(n+1, a, b + cur, c) + 10)
    ret = min(ret, dfs(n+1, a, b ,c + cur) + 10)
    ret = min(ret, dfs(n+1, a, b ,c ) + 0)
    return ret
print(dfs(0, 0, 0, 0))

Buggy submission (verdict: Runtime Error):
read = input
read = Read(False, """


8 1000 800 100
300
333
400
444
500
555
600
666

""").read
tmp = read()
tmp = list(map(int, tmp.split(' ')))
N,A,B,C = tmp
opt = list(map(int, map(lambda x: read(), range(N))))
def dfs(n,a,b,c):
    ret = 10**7
    if(n == N):
        if(min(a,b,c) == 0):
            return ret
        return abs(A - a) + abs(B - b) + abs(C - c) - 30
    cur = opt[n]
    ret = min(ret, dfs(n+1, a + cur, b, c) + 10)
    ret = min(ret, dfs(n+1, a, b + cur, c) + 10)
    ret = min(ret, dfs(n+1, a, b ,c + cur) + 10)
    ret = min(ret, dfs(n+1, a, b ,c ) + 0)
    return ret
print(dfs(0, 0, 0, 0))
Problem p03112 (python)

Fixed submission:
import bisect
read = input
bisect_right = bisect.bisect_right
# @ see https://docs.python.org/zh-cn/3/library/bisect.html
a ,b , q = map(int, read().split())
INF = 10**18
A =[-INF] + [int(read()) for i in range(a)] +[INF]
B =[-INF] + [int(read()) for i in range(b)] +[INF]
A.sort()
B.sort()
try:
    for i in range(q):
        x = int(read())
        sa = bisect_right(A, x)
        sb = bisect_right(B, x)
        ans = INF
        for pa in [A[sa - 1 ], A[sa]]:
            for pb in [B[sb - 1 ], B[sb]]:
                d1 = abs(x - pa) + abs(pa - pb)
                d2 = abs(x - pb) + abs(pb - pa)
                ans = min(ans, d1, d2)
        print(ans)
except:
    print(x, sa, sb)

Buggy submission (verdict: Runtime Error):
read = input
read = Read(False, """
1 1 3
1
10000000000
2
9999999999
5000000000
""").read
A,B,Q = list(map(int, read().split(' ')))
arrA = list(map(int, [read() for i in range(A)]))
arrB = list(map(int, [read() for i in range(B)]))
arrQ = list(map(int, [read() for i in range(Q)]))
arrA.sort()
arrB.sort()
import bisect
def cs(x, arr):
    al = bisect.bisect_left(arr, x)
    return list(map(lambda i: arr[i], filter(lambda i:i>=0 and i< len(arr), range(al-1, al + 2))))
def same_s(da,db):
    da = da / abs(da)
    db = db / abs(db)
    return da*db>0
    
def t(q,a,b):
    da = q - a
    db = q - b
    if(min(abs(da), abs(db)) == 0):
        return max(abs(da), abs(db))
    if same_s(da, db):
        return max(abs(da), abs(db))
    else :
        return 2*min(abs(da), abs(db)) + max(abs(da), abs(db))
for q in arrQ:
    optA = cs(q, arrA)
    optB = cs(q, arrB)
    ret = 10 ** 11
    for a in optA:
        for b in optB:
            ret = min(ret, t(q, a,b))
    print(ret)
Problem p02772 (python)

Fixed submission:
cnt = int(input())
tar_list = list(map(int, input().split()))
flg = False
for i in range(cnt):

  if tar_list[i] % 2 == 0:
    if tar_list[i] % 3 == 0 or tar_list[i] % 5 == 0:
      flg = False
    else:
      flg = True
      print("DENIED")
      break
      
if flg == False:
  print("APPROVED")

Buggy submission (verdict: Runtime Error):
cnt = int(input())
tar_list = list(map(int, input().split()))
flg = False
for i in range(cnt):

  if tar_list[i] % 2 == 0:
    if tar_list[i] % 3 == 0 or if tar_list[i] % 5 == 0:
    else:
      flg = True
      print("DENIED")
      break
      
if flg == False:
  print("APPROVED")
Problem p02780 (python)

Fixed submission:
total, tar = list(map(int, input().split()))
dice_array = list(map(int, input().split()))

hope_array = [0.0] * total
for i in range(total):
   hope_array[i] = (dice_array[i] * (dice_array[i] + 1)) / 2 / dice_array[i]

dice_total = [0]
 
for i in range(total):
  dice_total.append(hope_array[i] + dice_total[i])
 
ans = dice_total[tar]
tar_num = tar
for i in range(total - tar):
  tmp = dice_total[i + 1 + tar] - dice_total[i + 1]
  if ans < tmp:
    ans = tmp

print(ans)

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

dice_total = [0]

for i in range(total):
  dice_total.append(dice_array[i] + dice_total[i])

ans = dice_total[tar]
tar_num = tar
for i in range(total - tar):
  tmp = dice_total[i + 1 + tar] - dice_total[i + 1]
  if ans < tmp:
    ans = tmp
    tar_num = i + 1

sum_data = 0
cnt = 0
for x in range(tar_num, tar + tar_num):
  sum_data += (dice_array[x] * (dice_array[x] + 1)) / 2 / dice_array[x]
  
print(sum_data)

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

dice_total = [0]

for i in range(total):
  dice_total.append(dice_array[i] + dice_total[i])

ans = dice_total[tar]
tar_num = tar
for i in range(total - tar):
  tmp = dice_total[i + 1 + tar] - dice_total[i + 1]
  if ans < tmp:
    ans = tmp
    tar_num = i + 1

sum_data = 0
cnt = 0
for x in range(tar_num, tar + tar_num):
  cnt = sum(list(range(1, dice_array[x] + 1)))
  sum_data += (cnt / dice_array[x])
  
print(sum_data)

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

dice_total = [0]

for i in range(total):
  dice_total.append(dice_array[i] + dice_total[i])

ans = dice_total[tar]
tar_num = tar
for i in range(total - tar):
  tmp = dice_total[i + 1 + tar] - dice_total[i + 1]
  if ans < tmp:
    tmp = ans
    tar_num = i + 1

sum_data = 0
cnt = 0
for x in range(tar_num, tar + tar_num):
  cnt = sum(list(range(1, dice_array[x] + 1)))
  sum_data += (cnt / dice_array[x])
  
print(sum_data)
Problem p02801 (python)

Fixed submission:
s = input()
print(chr(ord(s[0]) + 1))

Buggy submission (verdict: Runtime Error):
a,b,c=(int(x) for x in input().split())
s = list(map(int, input().split()))
t = 0
for x in s:
  t += x
l = a + 1
chk = l * c
chk -= t
if chk > b:
  print(-1)
elseif chk < 0:
  print(0)
else:
  print(chk)

Buggy submission (verdict: Runtime Error):
s = input()
print chr(ord(s[0]) + 1)

Buggy submission (verdict: Runtime Error):
s = input()
print chr(ord(s) + 1)
Problem p02802 (python)

Fixed submission:
a,b=map(int,input().split())
list = [0]*a
t_cnt = 0
f_cnt = [0]*a
for i in range(b):
  c, d = map(str,input().split())
  x = int(c) - 1
  if list[x] == 0:
    if d == 'AC':
        list[x] = 1
        t_cnt += 1
    else:
        f_cnt[x] += 1
for i in range(a):
  if list[i] ==0:
    f_cnt[i] = 0
print("{} {}".format(t_cnt, sum(f_cnt)))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
list = [0]*a
t_cnt = 0
f_cnt = 0
for i in range(b):
  c, d = map(str,input().split())
  if d == 'AC':
    if list[c-1] == 0:
      list[c-1] = 1
      t_cnt += 1
  else:
    if list[c-1] == 0:
      f_cnt += 1
print("{} {}".format(t_cnt, f_cnt))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
list = [0]*a
t_cnt = 0
f_cnt = 0
for i in range(b):
  c, d = map(str,input().split())
  if d == 'AC':
    if list[c] == 0:
      list[c] = 1
      t_cnt += 1
  else:
    if list[c] == 0:
      f_cnt += 1
print("{} {}".format(t_cnt, f_cnt))

Buggy submission (verdict: Runtime Error):
a,b=(int(x) for x in input().split())
list = []
t_cnt = 0
f_cnt = 0
for i in range(b):
  s = input().split()
  if s[1] == 'AC':
    if not (s[0] in list):
    	list.append(s[0])
        t_cnt += 1
  else:
    if not (s[0] in list):
      f_cnt += 1
print("{} {}".format(t_cnt, f_cnt))
Problem p02811 (python)

Fixed submission:
tar, max = map(int, input().split())
if max <= tar*500:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
tar, max = map(int, input().sprit())
if max <= tar * 500:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
tar, max = map(int, input(),sprit())
if max <= tar * 500:
  print('Yes')
else:
  print('No')
Problem p02813 (python)

Fixed submission:
import itertools
num = int(input())
array1 = tuple(map(int, input().split()))
array2 = tuple(map(int, input().split()))
all_list = list(itertools.permutations(range(1, num + 1)))
 
array1_index = all_list.index(array1) + 1
array2_index = all_list.index(array2) + 1
 
if array1_index > array2_index:
  print(array1_index-array2_index)
else:
  print(array2_index-array1_index)

Buggy submission (verdict: Runtime Error):
import itertools
num = int(input())
array1 = tuple(map(int, input().split()))
array2 = tuple(map(int, input().split()))
all_list = list(itertools.permutations(range(1, num + 1)))
 
array1_index = all_list.index(array1) + 1
array2_index = all_list.index(array2) + 1
 
if array1_index > array2_index:
  print(array1_index-array2_index)
else:
  print(array2_index-array1_index)ar

Buggy submission (verdict: Runtime Error):
import itertools
num = int(input())
array1 = tuple(map(int, input().split()))
array2 = tuple(map(int, input().split()))
all_list = list(itertools.permutations(range(1, num + 1)))
 
array1_index = all_list.index(array1) + 1
array2_index = all_list.index(array2) + 1
 
if array1 > array2:
  print(array1-array2)
else:
  print(array2-array1)

Buggy submission (verdict: Runtime Error):
import itertools
num = int(input())
array1 = tuple(map(int, input().split()))
array2 = tuple(map(int, input().split()))
all_list = list(itertools.permutations(range(num)))
 
array1_index = all_list.index(array1) + 1
array2_index = all_list.index(array2) + 1
 
if array1 > array2:
  print(array1-array2)
else:
  print(array2-array1)

Buggy submission (verdict: Runtime Error):
import itertools
num = int(input())
array1 = list(map(int, input().split()))
array2 = list(map(int, input().split()))
all_list = list(itertools.permutations(range(num)))

array1_index = all_list.index(array1) + 1
array2_index = all_list.index(array2) + 1

if array1 > array2:
  print(array1-array2)
else:
  print(array2-array1)
Problem p02952 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline


def main():
    n = int(input())

    l = [str(i) for i in range(1, n + 1)]
    count = 0
    for i in l:
        if len(i) % 2 == 1:
            count += 1

    print(count)


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
input = sys.stdin.readline


def main():
    n = str(input()).replace("\n", "")

    count = 0
    for i in range(len(n), 0, -1):
        if i % 2 != 0:
            if i == len(n):
                count += int(n[1:]) + 1
            else:
                s = str(i) + "0"
                count += int(s) - 1

    print(count)


if __name__ == '__main__':
    main()
Problem p03659 (python)

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import numpy as np
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    a = list(map(int, input().split()))

    SUM = sum(a)

    ans = list()
    left = a[0]
    for i in range(1, n):
        ans.append(abs(2 * left - SUM))
        left += a[i]

    print(min(ans))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import numpy as np
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    a = list(map(int, input().split()))

    SUM = sum(a)

    ans = sys.maxint
    for i in range(1, n):
        ans = min(ans, abs(2 * sum(a[:i]) - SUM))

    print(ans)


if __name__ == '__main__':
    main()
Problem p03001 (python)

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

Buggy submission (verdict: Runtime Error):
w,h,x,y=map(int,input().split(' '))
if x==w/2 and y==h/2:
    print(str(w*h/2)+" "+ 1)
else:
    print(str(w*h/2)+" "+ 0)