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

Fixed submission:
import functools
a = int(input())
S = input()
l = [0] * (a+1)
r = [0] * (a+1)
for i, s in enumerate(S):
  l[i+1] = l[i] + 1 if s=="W" else l[i]
for i,s in enumerate(S[::-1]):
  r[i+1] = r[i] + 1 if s=="E" else r[i]
b = [l[i]+r[a-1-i] for i in range(a)]
c = functools.reduce(lambda x, y: min(x, y), b)
print(c)

Buggy submission (verdict: Runtime Error):
a = int(input())
b= [int(x) for x in input().split()]
c = a
for s in range(a):
  d = b[s]
  e = b[s]
  for t in b[s+1::]:
    d = d ^ t
    e = e + t
    if d == e:
      c += 1
    else:
      break
print(c)
Problem p03353 (python)

Fixed submission:
s = input()
K = int(input())
subs = []
for i in range(len(s)):
  for k in range(K):
    subs.append(s[i: i + 1 + k])
print(sorted(set(subs))[K - 1])

Buggy submission (verdict: Runtime Error):
import re
s = input()
K = int(input())
def finddict(s, sub, dic):
  for _sub in sorted(set(re.findall(sub+'.', s))):
    dic.append(_sub)
    dic = finddict(s, _sub, dic)
    if len(dic) >= K:
      break
  return dic
dic = []
for i in range(26):
  if s.find(chr(97 + i)) >= 0:
    dic += finddict(s, chr(97 + i), [chr(97 + i)])
  if len(dic) >= K:
    print(dic[K - 1])
    break
Problem p03402 (python)

Fixed submission:
A, B = map(int, input().split())
K = 50
G = [['.' for j in range(2 * K)] for i in range(K)] + [['#' for j in range(2 * K)] for i in range(K)]
x = 0
while B > 1:
  for y in range(min(K, B - 1)):
    G[x][x % 2 + 2 * y] = '#'
    B -= 1
  x += 2
x = 2 * K - 1
while A > 1:
  for y in range(min(K, A - 1)):
    G[x][x % 2 + 2 * y] = '.'
    A -= 1
  x -= 2
print(2 * K, 2 * K)
for i in range(2 * K):
  print(''.join(G[i]))

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
K = 5
G = [['.' for j in range(2 * K)] for i in range(K)] + [['#' for j in range(2 * K)] for i in range(K)]
x = 0
while B > 1:
  for y in range(min(K, B - 1)):
    G[x][x % 2 + 2 * y] = '#'
    B -= 1
  x += 1
x = 2 * K - 1
while A > 1:
  for y in range(min(K, A - 1)):
    G[x][x % 2 + 2 * y] = '.'
    A -= 1
  x -= 1
print(2 * K, 2 * K)
for i in range(2 * K):
  print(''.join(G[i]))
Problem p03438 (python)

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
d = sum(B) - sum(A)
for i in range(N):
  if A[i] % 2 != B[i] % 2:
    B[i] += 1
    d -= 1
print('Yes' if sum([max(A[i] - B[i], 0) for i in range(N)]) <= d else 'No')

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
print('Yes' sum([max(A[i] - B[i], 0) for i in range(N)]) <= sum(B) - sum(A) if else 'No')
Problem p03471 (python)

Fixed submission:
N, Y = map(int, input().split())
Y //= 1000
A, B, C = [-1, -1, -1]
for a in range(N + 1):
  for b in range(N - a + 1):
    if 9 * a + 4 * b + N == Y:
      A, B, C = [a, b, N - a - b]
      break
  if A != -1:
    break
print(A, B, C)

Buggy submission (verdict: Runtime Error):
N, Y = map(int, input().split())
Y //= 1000
if Y > N:
  print(-1, -1, -1)
  break
A, B, C = [0, 0, N]
while Y - N >= 9:
  C -= 1
  A += 1
  Y -= 9
while Y - N >= 4:
  C -= 1
  B += 1
  Y -= 4
while Y > N and A > 0:
  A -= 1
  B = 2
  Y -= 1
if Y == N:
  print(A, B, C)
else:
  print(-1, -1, -1)
Problem p03472 (python)

Fixed submission:
N, H = map(int, input().split())
A = 0
B = [0] * (N + 1)
for i in range(N):
  a, b = map(int, input().split())
  A = max(a, A)
  B[i] = b
B.sort(reverse=True)
cnt = 0
i  = 0
while H > 0:
  if B[i] > A:
    H -= B[i]
    cnt += 1
    i += 1
  else:
    k = -(-H // A)
    H -= A * k
    cnt += k
print(cnt)

Buggy submission (verdict: Runtime Error):
N, H = map(input().split())
D = [[0, 0] for i in range(2 * N)]
for i in range(N):
  a, b = map(int, input().split())
  D[2 * i] = [a, 2]
  D[2 * i + 1] = [b, 1]
D.sort(reverse=True)
cnt = 0
while H > 0:
  d = D[0]
  D = D[1:]
  if d[1] == 1:
    H -= d[0]
    cnt += 1
  else:
    k = -(-H // d[0])
    H -= d[0] * k
    cnt += k
print(cnt)
Problem p03504 (python)

Fixed submission:
import functools
N, C = map(int, input().split())
T = [[0 for i in range(10 ** 5 + 1)] for j in range(C)]
for i in range(N):
  s, t, c = map(int, input().split())
  for j in range(s - 1, t):
    T[c - 1][j] = 1
ans = 0
for j in range(10 ** 5 + 1):
  r = 0
  for i in range(C):
    r += T[i][j]
  ans = max(ans, r)
print(ans)

Buggy submission (verdict: Runtime Error):
N, C = map(int, input().split())
T = [0 for i in range(10 ** 5)]
for i in range(N):
  s, t, c = map(int, input().split())
  for j in range(s - 1, t + 1):
    T[j] += 1
print(max(T))
Problem p03607 (python)

Fixed submission:
from collections import defaultdict
N = int(input())
A = defaultdict(int)
cnt = 0
for i in range(N):
  a = int(input())
  A[a - 1] += 1
for v in A.values():
  cnt += v % 2
print(cnt)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [False] * 10 ** 9
cnt = 0
for i in range(N):
  a = int(input())
  A[a - 1] = not A[a - 1]
  cnt += 1 if A[a - 1] else -1
print(cnt)
Problem p03625 (python)

Fixed submission:
N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse=True)
pre = 0
e1, e2 = 0, 0
for a in A:
  if pre == a:
    if e1 == 0:
      e1 = a
    elif e2 == 0:
      e2 = a
    pre = 0
  else:
    pre = a
print(e1 * e2)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = [int(x) for x in input().split()]
A.sort(reverse=True)
pre = 0
e1, e2 = 0, 0
for a in A:
  if pre == a:
    if e1 == 0:
      e1 = a
    elif e2 == 0:
      e2 == a
  else:
    pre = a
print(a * b)
Problem p03626 (python)

Fixed submission:
N = int(input())
S1 = input()
S2 = input()
p = 10 ** 9 + 7
dp = [0] * N
if S1[0] == S2[0]:
  dp[0] = 3
else:
  dp[0] = 6
for i in range(1, N):
  if S1[i] == S1[i - 1]:
    dp[i] = dp[i - 1]
  elif S1[i - 1] == S2[i - 1]:
    dp[i] = dp[i - 1] * 2 % p
  elif S1[i] == S2[i]:
    dp[i] = dp[i - 1]
  else:
    dp[i] = dp[i - 1] * 3 % p
print(dp[-1])

Buggy submission (verdict: Runtime Error):
N = int(input())
S1 = input()
S2 = input()
p = 10 ** 9 + 7
dp = [0] * (N + 1)
if S1[0] == S2[0]:
  dp[0] = 3
else:
  dp[0] = 6
for i in range(1, N + 1):
  if S1[i] == S1[i - 1]:
    dp[i] = dp[i - 1]
  elif S1[i - 1] == S2[i - 1]:
    dp[i] = dp[i - 1] * 2 % p
  elif S1[i] == S2[i]:
    dp[i] = dp[i - 1]
  else:
    dp[i] = dp[i - 1] * 3 % p
print(dp[N])
Problem p03633 (python)

Fixed submission:
import functools
N = int(input())
T = []
for i in range(N):
  T.append(int(input()))
def gcd(A, B):
  while(True):
    if A and B:
      if A > B:
        A = A % B
      else:
        B = B % A
    else:
      return max(A, B)
 
def lcm(A, B):
  return (A // gcd(A, B)) * B
 
print(functools.reduce(lcm, sorted(T, reverse=True)))

Buggy submission (verdict: Runtime Error):
import math
import functools
N = int(input())
T = []
for i in range(N):
  T.append(int(input()))
def gcd(A, B):
  while(True):
    if A and B:
      if A > B:
        A = A % B
      else:
        B = B % A
    else:
      return max(A, B)
 
def lcm(A, B):
  return int(A * (B / gcd(A, B)))
 
print(functools.reduce(lcm, sorted(T, reverse=True)))

Buggy submission (verdict: Runtime Error):
import math
import functools
N = int(input())
T = []
for i in range(N):
  T.append(int(input()))
def gcd(A, B):
  while(True):
    if A and B:
      if A > B:
        A = A % B
      else:
        B = B % A
    else:
      return max(A, B)

def mcm(A, B):
  return int(A * B / gcd(A, B))

print(functools.reduce(mcm, sorted(T, reverse=True)))
Problem p03737 (python)

Fixed submission:
S = input().split()
print(S[0][0].upper() + S[1][0].upper() + S[2][0].upper())

Buggy submission (verdict: Runtime Error):
a,b,c = map(input().split())
print(a[0].upper() + b[0].upper() + c[0].upper())

Buggy submission (verdict: Runtime Error):
a = map(input().split())
print(a[0].upper() + b[0].upper() + c[0].upper())
Problem p03773 (python)

Fixed submission:
A, B = map(int, input().split())
print((A + B) % 24)

Buggy submission (verdict: Runtime Error):
A, B = map(int, input().split())
return((A + B) % 24)
Problem p03778 (python)

Fixed submission:
W, a, b = map(int, input().split())
print(max(max(a, b) - (min(a, b) + W), 0))

Buggy submission (verdict: Runtime Error):
W, a, b = map(int, input().split())
print(max(min(abs(a - b - w), abs(a - b + w)), 0))
Problem p04013 (python)

Fixed submission:
from collections import Counter
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
C = Counter([0])
for x in X:
  tmp = Counter()
  for i, c in C.items():
    tmp[i + x] += c
  C += tmp
print(C[0] - 1)

Buggy submission (verdict: Runtime Error):
import heapq
N, A = map(int, input().split())
X = [int(x) - A for x in input().split()]
for x in X:
  if x > 0:
    Xp.append(x)
  elif x < 0:
    Xm.append(-x)
  else:
    X0.append(x)
limit = min(sum(Xp), sum(Xm))
Xp = [x for x in Xp if x <= limit]
Xm = [x for x in Xm if x <= limit]
R = [[0, 0] for x in range(limit + 1)]
def c(X, k):
  Q = []
  heapq.heappush(Q, 0)
  for x in X:
    _Q = []
    while Q:
      q = heapq.heappop(Q)
      if q > limit:
        break
      heapq.heappush(_Q, q)
      heapq.heappush(_Q, q + x)
    Q = _Q
  while Q:
    q = heapq.heappop(Q)
    if q > limit:
      break
    R[q][k] += 1
c(Xp, 0)
c(Xm, 1)
print(sum([r[0] * r[1] for r in R]) * (2 ** len(X0)) - 1)
Problem p02612 (python)

Fixed submission:
import math
import sys

def main():

    input = sys.stdin.buffer.readline
    n = int(input())
    if(n%1000 == 0):
        print(0)
    else:
        a = n // 1000
        print((a+1)*1000-n)

if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
def main():

    n = int(input())
    a = n//1000
    print(n%(a*1000))
    
if __name__ == "__main__":
    main()

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

def main():

    n = int(input())
    a = n//1000
    print(n%(a*1000))
    

if __name__ == "__main__":
    main()
Problem p02658 (python)

Fixed submission:
import sys

input = sys.stdin.readline
 
n = int(input())
a = list(map(int, input().strip().split()))
if(0 in a):
 print(0)
 sys.exit()
else:
 ans = a[0]
 for i in range (1,n):
  ans = ans*a[i]
  if(ans > 10**18):
   print(-1)
   sys.exit()
 print(ans)

Buggy submission (verdict: Runtime Error):
import sys
 
input = sys.stdin.readline
 
n = int(input())
a = list(map(int, input().strip().split()))
if(0 in a):
 print(0)
 return
else:
 ans = 1
 for ai in a:
  ans *= ai
  if(ans > 10**18):
   print(-1)
   return

 print(ans)
Problem p02802 (python)

Fixed submission:
import sys

def main():
    n,m = map(int, input().split())
    pn_list = [0]*n
    a = [0]*m
    b = [0]*m
    ans_ac = 0
    ans_pn = 0
    pn_list[0]== -1
    
    for i in range (m):
        a[i],b[i]=input().split()
        a[i] = (int(a[i]))
        # print(a[i])
        if pn_list[a[i]-1] != -1:
            if b[i]== "AC":
                ans_pn += pn_list[a[i]-1]
                ans_ac +=1
                pn_list[a[i]-1] = -1 #ペナルティリスト初期化
            else:
                pn_list[a[i]-1] += 1

    print(ans_ac,ans_pn)
    
   
if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
import sys
def main():
    n,m = map(int, input().split())
    p_list = []
    ans_ac = 0
    ans_pn = 0
    for i in range (m):
        a,b=input().split()
        p_list.append((int(a), b))
        if p_list[i][1] == 'AC':
            ans_ac += 1
        elif p_list[i][1] == 'WA':
            ans_pn += 1
    if p_list[m-1][1] == 'WA':
        ans_pn -= 1

    print(ans_ac,ans_pn)
    
   
if __name__ == "__main__":
    main()
Problem p02607 (python)

Fixed submission:
my_range = int(input())
data_in = list(map(int,input().split()))
n_of_odd = 0
for ind in range(my_range):
  if (ind % 2) == 0:
    rem = data_in[ind] % 2
    n_of_odd = n_of_odd + rem
print(n_of_odd)

Buggy submission (verdict: Runtime Error):
my_range = int(input())
data_in = list(map(int,input().split()))
n_of_odd = 0
for ind in range(int(my_range/2)+1):
  rem = data_in[2*ind] % 2
  n_of_odd = n_of_odd + rem
print(n_of_odd)
Problem p02732 (python)

Fixed submission:
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

nn = int(input())
aa = list(map(int,input().split()))

ne = [0]*(nn+1)
cn = [0]*(nn+1)
cnminus1 = [0]*(nn+1)
#print(nn,aa)
#print(len(ne))
for i in range(nn):
    ne[aa[i]] += 1

for i in range(nn+1):
 #   print(ne[i])
    if ne[i] == 0:
        cn[i] = 0
        cnminus1[i] = 0
    elif ne[i] == 1:
        cn[i] = 0
        cnminus1[i] = 0
    elif ne[i] == 2:
        cn[i] = 1
        cnminus1[i] = 0
    else:
        cn[i] = combinations_count(ne[i],2)
        cnminus1[i] = combinations_count(ne[i]-1,2)

sum_cn = sum(cn)

for i in range(nn):
    print(sum_cn - cn[aa[i]] + cnminus1[aa[i]])

Buggy submission (verdict: Runtime Error):
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

nn = int(input())
aa = list(map(int,input().split()))

ne = [0]*200000
cn = [0]*200000
cnminus1 = [0]*nn
#print(nn,aa)
#print(len(ne))
for i in range(nn):
    ne[aa[i]] += 1

for i in range(nn):
 #   print(ne[i])
    if ne[i] == 0:
        cn[i] = 0
        cnminus1[i] = 0
    elif ne[i] == 1:
        cn[i] = 0
        cnminus1[i] = 0
    elif ne[i] == 2:
        cn[i] = 1
        cnminus1[i] = 0
    else:
        cn[i] = combinations_count(ne[i],2)
        cnminus1[i] = combinations_count(ne[i]-1,2)

sum_cn = sum(cn)

for i in range(nn):
    print(sum_cn - cn[aa[i]] + cnminus1[aa[i]])

Buggy submission (verdict: Runtime Error):
import math

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

nn = int(input())
aa = list(map(int,input().split()))

ne = [0]*nn
cn = [0]*nn
cnminus1 = [0]*nn
#print(nn,aa)

for i in range(nn):
    ne[aa[i]] += 1

for i in range(nn):
 #   print(ne[i])
    if ne[i] == 0:
        cn[i] = 0
        cnminus1[i] = 0
    elif ne[i] == 1:
        cn[i] = 0
        cnminus1[i] = 0
    elif ne[i] == 2:
        cn[i] = 1
        cnminus1[i] = 0
    else:
        cn[i] = combinations_count(ne[i],2)
        cnminus1[i] = combinations_count(ne[i]-1,2)

sum_cn = sum(cn)

for i in range(nn):
    print(sum_cn - cn[aa[i]] + cnminus1[aa[i]])
Problem p03162 (python)

Fixed submission:
import math


def chmax(a, b):
    if a >= b:
        return a
    return b


def chmin(a, b):
    if a <= b:
        return a
    return b


def main():
    nn = int(input())
    arr = [list(map(int, input().split())) for l in range(nn)]
    dp = [[0] * 3 for i in range(nn+1)]

    for i in range(nn):
        for j in range(3):
            for k in range(3):
                if j == k:
                    continue
                dp[i+1][j] = chmax(dp[i+1][j],dp[i][k]+arr[i][k])

    print(max(dp[nn][0],dp[nn][1],dp[nn][2]))


main()

Buggy submission (verdict: Runtime Error):
import math


def chmax(a, b):
    if a >= b:
        return a
    return b


def chmin(a, b):
    if a <= b:
        return a
    return b


def main():
    nn = int(input())
    hh = list(map(int, input().split()))

    dp = [math.inf]*nn
    dp[0] = 0
    dp[1] = chmin(dp[1],dp[0]+abs(hh[1]-hh[0]))
    for i in range(2,nn):
        dp[i] = chmin(dp[i],dp[i-1]+abs(hh[i]-hh[i-1]))
        dp[i] = chmin(dp[i],dp[i-2]+abs(hh[i]-hh[i-2]))

    print(dp[nn-1])


main()
Problem p03455 (python)

Fixed submission:
din = list(map(int,input().split()))
if (din[0]*din[1]) % 2 == 0:
  print("Even")
else:
  print("Odd")

Buggy submission (verdict: Runtime Error):
din = map(int, raw_input().split())
if (din[0]*din[1]) % 2 == 0:
  print("Even")
else:
  print("Odd")
Problem p02717 (python)

Fixed submission:
#!/usr/bin/env python3

a, b, c = map(int, input().split())
print("{} {} {}".format(c, a, b))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

a = int(input())
a, b = map(int, input().split())
a = list(str(input()))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

a = int(input())
a, b = map(int, input().split())
a = list(str(input()))

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

a = int(input())
a, b = map(int, input().split())
a = list(str(input()))
Problem p02718 (python)

Fixed submission:
#!/usr/bin/env python3

import numpy as np
N, M = map(int, input().split())
A = list(map(int, input().split()))

A = np.array(A)

num = np.sum(A >= np.sum(A)/(4*M))

if num >= M:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

a = int(input())
a, b = map(int, input().split())
a = list(str(input()))
Problem p02732 (python)

Fixed submission:
#!/usr/bin/env python3

import collections

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

c = collections.Counter(A)
values = c.keys()
counts = c.values()

subs = {}
a_sum = 0
for v, c in zip(values, counts):
    subs[v] = c
    a_sum += (c * (c-1)) // 2

for i in range(N):
    print(a_sum - subs[A[i]] + 1)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

import collections

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

c = collections.Counter(A)
values = c.keys()
counts = c.values()


ans = 0
for i in range(len(values)):
    tmp = counts[i]
    ans += (tmp * (tmp-1))//2

for i in range(N):
    num = A[i]
    index = values.index(num)
    print(ans - counts[index] + 1)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

import collections

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

c = collections.Counter(A)
values, counts = c.keys(), c.values()

ans = 0
for i in range(len(values)):
    tmp = counts[i]
    ans += (tmp * (tmp-1))//2

for i in range(N):
    num = A[i]
    index = values.index(num)
    print(ans - counts[index] + 1)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

import numpy as np

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

unique_array = np.unique(A, return_counts=True)

ans = 0
for i in range(len(unique_array[0])):
    tmp = unique_array[1][i]
    ans += (tmp * (tmp-1))//2


for i in range(N):
    num = A[i]
    index = np.where(unique_array[0] == num)[0]
    print(ans - unique_array[1][index][0] + 1)
Problem p02761 (python)

Fixed submission:
# C
N, M = list(map(int, input().split()))

flag = 0
ans = [0]*N
ans_flag = [0]*N

sc = [list(map(int, input().split())) for _ in range(M)]
for i in range(M):
    s, c = sc[i]
    if ans_flag[s-1] == 1:
        if ans[s-1] != c:
            flag = 1
            break
    ans_flag[s-1] = 1
    ans[s-1] = c

if flag == 1:
    print("-1")
else:
    if N==1:
        for i in ans:
            print(i, end="")

    elif ans[0] == 0 and ans_flag[0]==1:
        print("-1")
    else:
        if ans[0]==0:
            ans[0] = 1
        for i in ans:
            print(i, end="")

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

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

flag = 0
ans = [None for i in range(m)]
# print(ans)
for i in range(m):
    s, c = map(int, input().split())
    if ans[s-1] is None or ans[s-1] == c:
        ans[s-1] = c
    else:
        flag = 1

# print(flag)
if ans[0] == 0:
    flag = 1
if ans[0] is None:
    ans[0] = 1
for i in range(1, len(ans)):
    if ans[i] is None:
        ans[i] = 0

print("".join(map(str, ans)) if flag == 0 else -1)

Buggy submission (verdict: Runtime Error):
# C
N, M = list(map(int, input().split()))

flag = 0
ans = [0]*M
ans_flag = [0]*M

sc = [list(map(int, input().split())) for _ in range(M)]
for i in range(M):
    s, c = sc[i]
    if ans_flag[s-1] == 1:
        if ans[s-1] != c:
            flag = 1
            break
    ans_flag[s-1] = 1
    ans[s-1] = c

if flag == 1:
    print("-1")
else:
    if ans[0] == 0 and ans_flag[0]==1:
        print("-1")
    else:
        if ans[0]==0:
            ans[0] = 1
        for i in ans:
            print(i, end="")

Buggy submission (verdict: Runtime Error):
# C
N, M = list(map(int, input().split()))

flag = 0
ans = [0]*M
ans_flag = [0]*M

sc = [list(map(int, input().split())) for _ in range(M)]
for i in range(M):
    s, c = sc[i]
    if ans_flag[s-1] == 1:
        if ans[s-1] != c:
            flag = 1
            break
    ans_flag[s-1] = 1
    ans[s-1] = c

if flag == 1:
    print("-1")
else:
    if ans[0] == 0 and ans_flag[0]==1:
        print("-1")
    else:
        if ans[0]==0:
            ans[0] = 1
        print(ans)
Problem p02767 (python)

Fixed submission:
import numpy as np
import math
N = int(input())
X = np.array(list(map(int, input().split())))

P_floor = math.floor(np.sum(X)/N)
P_ceil = math.ceil(np.sum(X)/N)

ans = min(np.sum((X-P_floor)**2), np.sum((X-P_ceil)**2))

print(ans)

Buggy submission (verdict: Runtime Error):
# C
import numpy as np
N = int(input())
X = np.array(list(map(int, input().split())))

P_floor = math.floor(np.sum(X)/N)
P_ceil = math.ceil(np.sum(X)/N)

ans = min(np.sum((X-P_floor)**2), np.sum((X-P_ceil)**2))

print(ans)
Problem p02786 (python)

Fixed submission:
import math
def touhi(a,r,n):
    return a*(pow(r, n) - 1)//(r-1)
H = int(input()) 
n = math.floor(math.log2(H))+1
print(touhi(a=1, r=2, n=n))

Buggy submission (verdict: Runtime Error):
# D
def touhi(a,r,n):
    return a*(pow(r, n) - 1)//(r-1)
  
H = int(input()) 
n = math.floor(math.log2(H))+1
print(touhi(a=1, r=2, n=n))
Problem p02802 (python)

Fixed submission:
#!/usr/bin/env python3

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

flag = [0 for _ in range(n)]
wa_num_list = [0 for _ in range(n)]

for i in range(m):
    p, s = list(map(str, input().split()))
    p = int(p)
    if flag[p-1] == 0:
        if s == "WA":
            wa_num_list[p-1] += 1
        else:
            flag[p-1] = 1

pen = 0
for i in range(n):
    if flag[i] == 1:
        pen += wa_num_list[i]

print(sum(flag), pen)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

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

flag = [0 for _ in range(n)]
wa_num_list = [0 for _ in range(n)]

for i in range(m):
    p, s = list(map(str, input().split()))
    p = int(p)
    if flag[p-1] == 0:
        if s == "WA":
            wa_num_list[p-1] += 1
        else:
            flag[p-1] = 1

pen = 0
for i in range(m):
    if flag[i] == 1:
        pen += wa_num_list[i]

print(sum(flag), pen)
Problem p02838 (python)

Fixed submission:
#!/usr/bin/env python3

# mod = 10**9+7

# n = int(input())
# a = list(map(int, input().split()))

# max_digit = 61

# count_0 = [0 for _ in range(max_digit)]
# count_1 = [0 for _ in range(max_digit)]

# for i in range(len(a)):
#     num_str = bin(a[i])[2:]
#     # print(num_str)
#     for j in range(len(num_str)):
#         # print(num_str[-j-1])
#         if num_str[-j-1] == "1":
#             count_1[-j-1] += 1

# # for i in range(max_digit):
# #     count_0[i] = n-count_1[i]

# ans = 0
# count = 1
# for i in range(61):
#     # tmp = count_0[-i-1]*count_1[-i-1]
#     tmp = count_1[-i-1]*(n-count_1[-i-1])
#     ans += tmp*count
#     count = (count*2) % mod
# print(ans % mod)


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

mod = 10**9+7
max_digit = 61

ans = 0
m = 1
for _ in range(max_digit):
    bit = sum(x&m for x in a)
    bit //= m
    non_bit = n - bit
    ans = (ans+bit*non_bit*m)%mod
    m <<= 1
print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

# mod = 10**9+7

# n = int(input())
# a = list(map(int, input().split()))

# max_digit = 61

# count_0 = [0 for _ in range(max_digit)]
# count_1 = [0 for _ in range(max_digit)]

# for i in range(len(a)):
#     num_str = bin(a[i])[2:]
#     # print(num_str)
#     for j in range(len(num_str)):
#         # print(num_str[-j-1])
#         if num_str[-j-1] == "1":
#             count_1[-j-1] += 1

# # for i in range(max_digit):
# #     count_0[i] = n-count_1[i]

# ans = 0
# count = 1
# for i in range(61):
#     # tmp = count_0[-i-1]*count_1[-i-1]
#     tmp = count_1[-i-1]*(n-count_1[-i-1])
#     ans += tmp*count
#     count = (count*2) % mod
# print(ans % mod)


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

mod = 10**9+7
max_digit = 61

ans = 0
m = 1
for _ in range(max_digit):
    bit = sum(x&m x in a)
    bit //= m
    non_bit = n - bit
    ans = (ans+bit*nonbit*m)%mod
    m <<= 1
print(ans)