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

Fixed submission:
import sys
import numpy as np
from operator import mul
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

d = int(readline())
c = list(map(int, readline().split()))
s = []
for _ in range(d):
    add = list(map(int, readline().split()))
    s.append(add)

#t = [0] * d
day = 0
satisfy = 0
sumC = sum(c)
count = np.zeros(26)

for i in range(d):
    #t = int(readline()) - 1
    tarLis = s[day]
    tar = max(tarLis)
    t = tarLis.index(tar) + 1
    print(t)
    day += 1
    '''
    up = s[day][t]
    count += 1
    count[t] = 0
    sub = map(mul, count, c)
    satisfy += (up - sum(sub))

    # satisfy
    print(satisfy)
    '''

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from operator import mul
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

d = int(readline())
c = list(map(int, readline().split()))
s = []
for _ in range(d):
    add = list(map(int, readline().split()))
    s.append(add)

#t = [0] * d
day = 0
satisfy = 0
sumC = sum(c)
count = np.zeros(26)

for i in range(d):
    t = int(readline()) - 1
    up = s[day][t]
    count += 1
    count[t] = 0
    sub = map(mul, count, c)
    satisfy += (up - sum(sub))

    # satisfy
    print(satisfy)

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np
from operator import mul
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

d = int(readline())
c = list(map(int, readline().split()))
s = []
for _ in range(d):
    add = list(map(int, readline().split()))
    s.append(add)

#t = [0] * d
day = 0
satisfy = 0
sumC = sum(c)
count = np.zeros(26)

for i in range(d):
    #t = int(readline()) - 1
    tarLis = s[day]
    tar = max(tarLis)
    t = tarLis.index(t) + 1
    print(t)
    day += 1
    '''
    up = s[day][t]
    count += 1
    count[t] = 0
    sub = map(mul, count, c)
    satisfy += (up - sum(sub))

    # satisfy
    print(satisfy)
    '''
Problem p02691 (python)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))

minus = [0] * N
plus = [0] * N

for i in range(N):
    minus[i] = (i + 1) - A[i]
    plus[i] = (i + 1) + A[i]

count = Counter(minus)
most = count.most_common()
num = len(most)

countPP = Counter(plus)
#mostPP = countPP.most_common()
#check = mostPP[:][0]
ans = 0

for i in range(num):
    elm = most[i]
    fir = elm[0]
    sec = elm[1]
    # if (fir in check):

    aa = countPP[fir]
    #    print(aa)
    ans += aa * sec

    # try countPP[tar]:

print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
n = int(input())
a = list(map(int, input().split()))
idList = [i for i in range(1, n+1)]
temp = 0
for i in range(n):
    tar = a[temp]
    if (tar >= n):
        del a[i]
        del idList[i]

    else:
        temp += 1

com = list(itertools.combinations(idList, 2))

num = len(com)
ans = 0
for i in range(num):
    aa = com[i]
    # print(aa)
    idA = aa[0]
    idB = aa[1]
    dif = abs(idA - idB)
    indexA = idList.index(idA)
    indexB = idList.index(idB)

    height = a[indexA] + a[indexB]

    if (height == dif):
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
import itertools
n = int(input())
a = list(map(int, input().split()))
idList = [i for i in range(1, n+1)]
temp = 0
for i in range(n):
    tar = a[temp]
    if (tar >= n):
        del a[i]
        del idList[i]

    else:
        temp += 1

com = list(itertools.combinations(idList, 2))

num = len(com)
ans = 0
for i in range(num):
    aa = com[i]
    # print(aa)
    idA = aa[0]
    idB = aa[1]
    dif = abs(idA - idB)
    height = a[idA - 1] + a[idB - 1]

    if (height == dif):
        ans += 1

print(ans)
Problem p02705 (python)

Fixed submission:
import math

r = int(input())
ans = math.pi*(2*r)
print(ans)

Buggy submission (verdict: Runtime Error):
r = input()

ans = 2*r*3.141
print(ans)
Problem p02706 (python)

Fixed submission:
import numpy as np
N, M = map(int, input().split())
data = np.array(input().split(), dtype=np.int64)

#height = [int(input()) for _ in range(M)]
sum = N - np.sum(data)

if (sum >= 0):
    print(sum)
else:
    print('-1')

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

height = [input() for i in range(M)]
sum = N - sum(height)

if (sum >= 0):
    print(sum)
else:
    print('-1')
Problem p02708 (python)

Fixed submission:
N, K = map(int, input().split())
# 小さい方から順にk個とったものと、大きい方から順にk個とったものの差
# １刻みから作る最小と最大間は、全てを満たす


def calc(x, N):
    a = x * (x - 1) // 2
    b = (2 * N - x + 1) * x // 2
    return b - a + 1


tot = 0
for i in range(K, N + 2):
    ans = calc(i, N)
 #   print(ans)
    tot += ans

aa = tot % (10 ** 9 + 7)

print(aa)

Buggy submission (verdict: Runtime Error):
N, K = map(int, input().split())
# 今回は、等差数列の和の差をとって、


def calc(x):
    a = x * (x - 1) // 2
    b = (2 N - x + 1) * x // 2
    return a - b + 1


for i in range(K, N + 2):
    ans = calc(i)
    tot = +=ans

tot /= 10 ** 9 + 7

print(tot)
Problem p02761 (python)

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

temp = list(['?'] * n)

# print(temp)
if (m == 0):
    if (n == 1):
        ans = 0
    else:
        ans = '1' + '0' * (n - 1)

else:
    for _ in range(m):
        s, c = map(int, input().split())
        if (s == 1 and c == 0 and n >= 2):
            print(-1)
            exit()
        else:
            pass

        if (temp[s-1] == '?'):
            temp[s - 1] = str(c)
        elif (temp[s - 1] == str(c)):
            pass
        else:
            print(-1)
            exit()

    if (temp[0] == '?'):
        temp[0] = '1'

    ans01 = ''.join(temp)
    ans = ans01.replace('?', '0')

print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
# n: ketasuu
# m: num of list
data = [[0] * 2] * m
for i in range(m):
    a, b = map(int, input().split())
    # data[i][0], data[i][1] = a, b  >>>間違い
    data[i] = a, b
dataSort = sorted(data)
start = dataSort[0][0]
strVal = dataSort[0][1]

aList = ['1'] + ['0'] * (n - 1)

flag = True
for i in range(m):
    tar = dataSort[i][0]
    tarVal = dataSort[i][1]

    if (tar == 1 and tarVal == 0):
        # print('-1')
        ans = -1
        flag = False
        break
    if (tar == start):
        if (tarVal != strVal):
            ans = -1
            flag = False
            break

    else:
        start = tar
        strVal = tarVal

    aList[tar - 1] = str(tarVal)


if (flag == True):
    ans = ''.join(aList)

print(ans)

Buggy submission (verdict: Runtime Error):
n, m = map(int, input().split())
# n: ketasuu
# m: num of list
data = [[0] * 2] * m
for i in range(m):
    a, b = map(int, input().split())
    # data[i][0], data[i][1] = a, b  >>>間違い
    data[i] = a, b
dataSort = sorted(data)
start = dataSort[0][0]
strVal = dataSort[0][1]

aList = [0, 0, 0]
flag = True
for i in range(m):
    tar = dataSort[i][0]
    tarVal = dataSort[i][1]

    if (tar == 1 and tarVal == 0):
        # print('-1')
        ans = -1
        flag = False
        break
    if (tar == start):
        if (tarVal != strVal):
            ans = -1
            flag = False
            break

    else:
        start = tar
        strVal = tarVal

    aList[tar - 1] = tarVal


if (flag == True):
    ans = str(aList[0]) + str(aList[1]) + str(aList[2])

print(ans)
Problem p02802 (python)

Fixed submission:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

acCount = 0
waCount = 0
check = [0] * n
waCheck = [0] * n

for i in range(m):
    p, s = map(str, input().split())
    # print(p,s)
    p = int(p)
    if (check[p - 1] == 0):
        if (s == 'WA'):
            waCheck[p - 1] += 1

        else:
            acCount += 1
            waCount += waCheck[p - 1]

            check[p - 1] = 1
    else:
        continue

print(acCount, waCount)

Buggy submission (verdict: Runtime Error):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

acCount = 0
waCount = 0
check = [0] * n
waCheck = [0] * n

for i in range(m):
    p, s = map(str, input().split())
    # print(p,s)
    p = int(p)
    if (check[p - 1] == 0):
        if (s == 'WA'):
            waCheck[p - 1] += 1

        else:
            acCount += 1
            waCheck += waCheck[p - 1]

            check[p - 1] = 1
    else:
        continue

print(acCount, waCount)
Problem p03673 (python)

Fixed submission:
n = int(input())
a = list(map(str, input().split()))
b = []
'''
b = [str(a[0])]
if (n == 1):
    print(a[0])
    exit()

a = a[1:]

for i in a:
    b.append(str(i))
    b.reverse()
'''
'''
loop = int(n / 2)
loop_rest = n - loop

for i in range(loop):
    tar_index = (n - 1) - 2 * i
    tar = a[tar_index]

    b.append(str(tar))


if (n % 2 == 0):
    tar_index = 0
else:
    tar_index = 1

for i in range(loop_rest):
    b.append(str(a[tar_index]))
    tar_index += 2
'''

# 一つおきでListを取る場合。
# a[0::2]
# 1つ目：起点。
# 2つ目：Step

# a[::-1]
# > -1step,つまりReverse

if n % 2 == 1:
    print(" ".join((a[0::2][::-1] + a[1::2])))
else:
    print(" ".join((a[1::2][::-1] + a[0::2])))

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = []
'''
b = [str(a[0])]
if (n == 1):
    print(a[0])
    exit()

a = a[1:]

for i in a:
    b.append(str(i))
    b.reverse()
'''

loop = int(n / 2)
loop_rest = n - loop

for i in range(loop):
    tar_index = (n - 1) - 2 * i
    tar = a[tar_index]

    b.append(str(tar))


if (n % 2 == 0):
    tar_index = 0
else:
    tar_index = 1

for i in range(loop_rest):
    b.append(str(a[tar_index]))
    tar_index += 2

print(' '.join(b))
Problem p03681 (python)

Fixed submission:
import math
n, m = map(int, input().split())
diff = abs(n - m)

# 階乗は、factorial

if (diff > 1):
    print(0)
else:
    x = math.factorial(n)
    y = math.factorial(m)

    if (n == m):
        tt = 2
    else:
        tt = 1

    ans = tt * (x * y) % (10 ** 9 + 7)

    print(ans)

Buggy submission (verdict: Runtime Error):
import math
n, m = map(int, input().split())
dif = abs(n - m)

if (diff > 1):
    print(0)
else:
    x = math.factorial(n)
    y = math.factorial(m)

    if (n == m):
        tt = 2
    else:
        tt = 1

    ans = tt * (x * y) / (10 ** 9 + 7)

    print(ans)
Problem p03695 (python)

Fixed submission:
import math
import numpy as np

n = int(input())
a = list(map(int, input().split()))
check = [0] * 9
for i, val in enumerate(a):
    tar = math.floor(val / 400)
    if (tar > 8):
        tar = 8

    check[int(tar)] += 1


checkA = np.array(check[:8])
#print(checkA)
num = np.count_nonzero(checkA != 0)

less = max(num, 1)
#more = min(8, num + check[8])
more = num + check[8]
# print(check[8])

print(less, more)
'''
checkA = np.array(check[:8])
num = np.count_nonzero(checkA != 0)
if (num == 0):
    num = 1
rest = 8 - num

more = min(8, num + check[8])

print(num, more)
'''

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

n = int(input())
a = list(map(int, input().split()))
check = [0] * 9
for i, val in enumerate(a):
    tar = math.floor(val / 400)
    check[tar] += 1

checkA = np.array(check[:8])
num = np.count_nonzero(checkA != 0)
rest = 8 - num

if (rest > check[8]):
    more = num + check[8]
else:

    more = 8


print(num, more)
Problem p03796 (python)

Fixed submission:
import math
time = int(input())
p = math.factorial(time)
mod = p % (10**9+7)
print(mod)

Buggy submission (verdict: Runtime Error):
import math
time = int(input())
p = math.factrial(time)
mod = p % (10**9+7)
print(mod)
Problem p03813 (python)

Fixed submission:
score = int(input())
if (score < 1200):
   print("ABC")
else:
   print("ARC")

Buggy submission (verdict: Runtime Error):
score = input()
if (score < 1200):
  print("ABC")
else:
  print("ARC")
Problem p03828 (python)

Fixed submission:
#import math
#from decimal import Decimal
import numpy as np
# nの約数を全て求める
# n!が大きすぎ＞　解説をみると。。
# ex; 24 = 2^3 * 3
#       (1,2,3,4,6,8,12,24) > 8個

# approach, 1~Nごとに、素因数分解をして、カウントする。
# 最後に掛け合わせる。
lim = 10 ** 9 + 7
n = int(input())
# https://note.nkmk.me/python-prime-factorization/

num = [0] * (n + 1)
#num[1] = 1

for i in range(2, n + 1):
    temp = i
    # even number
    while (temp % 2 == 0):
        if (num[2] == 0):
            num[2] = 1
        num[2] += 1
        # print('2A')
        temp //= 2

    f = 3
    # odd number
    while (f * f <= temp):
        if (temp % f == 0):
            if (num[f] == 0):
                num[f] = 1
            num[f] += 1
            #print('B', f)
            temp //= f
        else:
            f += 2
    # prime number
    if (temp != 1):
        if (num[temp] == 0):
            num[temp] += 1
        num[temp] += 1
        #print('C', temp)

numA = np.array(num)
numAA = np.argwhere(numA != 0)
numAAA = numAA.tolist()
# print(numA)

ans = 1
for i in numAAA:
    tar = i[0]
    ans *= num[tar]

#ans = sum(num)
ans %= lim

print(ans)

Buggy submission (verdict: Runtime Error):
import math

# nの約数を全て求める
lim = 10 ** 9 + 7

n = int(input())
if (n <= 2):
    ans = n
else:
    fact = math.factorial(n)

    ans = 1
    loop = int(fact/2)
    for i in range(1, loop + 1):
        if (fact % i == 0):
            #check[i] = 1
            ans += 1


#ans = sum(check)
ans %= lim
print(ans)

Buggy submission (verdict: Runtime Error):
import math

# nの約数を全て求める
lim = 10 ** 9 + 7

n = int(input())
fact = math.factorial(n)
check = [0] * (fact + 1)
for i in range(1, fact + 1):
    if (fact % i == 0):
        check[i] = 1

ans = sum(check)
ans %= lim
print(ans)
Problem p03844 (python)

Fixed submission:
A, val, B = map(str, input().split())


if val=="+":
    print(int(A)+int(B))
else:
    print(int(A)-int(B))

Buggy submission (verdict: Runtime Error):
import numpy as np
N = int(input())
#time=list(map(int,input().split()))
time=np.array(input().split(),dtype=np.int64)
M = int(input())

p={}
x={}
for i in range(M):
    p[i],x[i] = map(int, input().split())
#print(x[1])

sumT=np.sum(time)
for i in range(M):
    PP = p[i]
#    print(np.sum(time_new))
    print(sumT - time[PP-1] + x[PP-1])
Problem p03845 (python)

Fixed submission:
import numpy as np
N = int(input())
#time=list(map(int,input().split()))
time=np.array(input().split(),dtype=np.int64)
M = int(input())

p={}
x={}
for i in range(M):
    p[i],x[i] = map(int, input().split())
#print(x[1])

sumT=np.sum(time)
for i in range(M):
    PP = p[i]
#    print(np.sum(time_new))
    tot = sumT - time[PP-1] + x[i]
    print(tot)

Buggy submission (verdict: Runtime Error):
import numpy as np
#import copy
N = int(input())
#time=list(map(int,input().split()))
time=np.array(input().split(),dtype=np.int64)
M = int(input())

p={}
x={}
for i in range(M):
    p[i],x[i] = map(int, input().split())
#print(x[1])
sumT=np.sum(time)
for i in range(M):
    PP = p[i]
#    print(np.sum(time_new))
    print(sumT - time[PP-1] + x[PP-1])
Problem p03861 (python)

Fixed submission:
import math
import sys
import numpy as np
from decimal import *
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# ----------------------------------------
a, b, x = map(int, readline().split())

ans = Decimal(b // x) - Decimal(a // x)
if (a % x == 0):
    ans += 1

print(int(ans))

Buggy submission (verdict: Runtime Error):
import math
a, b, x =, ap(int, input().split())

ax = a // x
bx = math.ceil(b // x)

tar = ax - bx + 1
print(tar)
Problem p03964 (python)

Fixed submission:
import math
from fractions import Fraction
from decimal import *
# ex) Fraction(2,6) > 1/3 > 0.33333

n = int(input())
x, y = map(int, input().split())
t, a = x, y

for _ in range(n - 1):
    tt, aa = map(int, input().split())

    # c = 1
    '''
    if (t >= a):
        c = math.ceil(tt / t)

    else:
        c = math.ceil(aa / a)
    '''
    # c = math.ceil(max(t / tt, a / aa))
    # c = math.ceil(max(Fraction(t + tt - 1, tt), Fraction(a + aa - 1 / aa)))
    c = max(math.ceil(Fraction(t, tt)), math.ceil(Fraction(a, aa)))
    c = max(1, c)

    t = tt * c
    a = aa * c


ans = t + a
print(ans)

Buggy submission (verdict: Runtime Error):
import math
from fractions import Fraction
n = int(input())

x, y = map(int, input().split())
t, a = x, y

for _ in range(n - 1):
    tt, aa = map(int, input().split())

    #c = 1
    '''
    if (t >= a):
        c = math.ceil(tt / t)

    else:
        c = math.ceil(aa / a)
    '''
    #c = math.ceil(t / tt, a / aa)
    c = math.ceil(Fraction(t, tt), Fraction(a / aa))

    t = tt * c
    a = aa * c


ans = t + a
print(ans)
Problem p02646 (python)

Fixed submission:
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())
D = abs(A - B)
S = V - W
if V - W <= 0:
  print("NO")
else:
  if D / S > T:
    print("NO")
  else:
    print("YES")

Buggy submission (verdict: Runtime Error):
A, V = map(int, input().split())
B, W = map(int, input().split())
D = abs(A - B)
S = V - W
if V - W <= 0:
  print("NO")
else:
  if D / S > T:
    print("NO")
  else:
    print("Yes")
Problem p02683 (python)

Fixed submission:
N, M, X = map(int, input().split())
Q = []
B = [0] * N
C = [0] * (M + 1)
flag = True
MIN = -1
for i in range(N):
  Q.append(list(map(int, input().split())))
  
for i in range(2 ** N):
  C = [0] * (M + 1)
  flag = True
  for j in range(N):
    B[j] = (i >> j) & 1
    
  for j in range(N):
    if B[j] == 1:
      for k in range(M + 1):
        C[k] += Q[j][k]
  for j in range(1, M + 1):
    if C[j] < X:
      flag = False
  if flag == True and (MIN == -1 or MIN > C[0]):
    MIN = C[0]
print(MIN)

Buggy submission (verdict: Runtime Error):
N, M, X = map(int, input().split())
Q = []
B = [0] * N
C = [0] * (M + 1)
flag = True
MIN = -1
for i in range(N):
  Q.append(list(map(int, input().split())))
  
for i in range(2 ** N):
  B = [0] * N
  C = [0] * (M + 1)
  flag = True
  for j in range(N):
    B[j] = (i >> j) & 1
    
  for j in range(N):
    if B[j] == 1:
      for k in range(M + 1):
        C[k] += Q[j][k]
  for j in range(1, M + 1):
    if C[j] < X:
      flag = False
    if flag == True:
      if MIN == -1 or MIN > C[0]:
        MIN = C[0]
      
print(MIN)    
N, M, X = map(int, input().split())
Q = []
B = [0] * N
C = [0] * (M + 1)
flag = True
MIN = -1
for i in range(N):
  Q.append(list(map(int, input().split())))
  
for i in range(2 ** N):
  B = [0] * N
  C = [0] * (M + 1)
  flag = True
  for j in range(N):
    B[j] = (i >> j) & 1
    
  for j in range(N):
    if B[j] == 1:
      for k in range(M + 1):
        C[k] += Q[j][k]
  for j in range(1, M + 1):
    if C[j] < X:
      flag = False
    if flag == True and (MIN == -1 or MIN > C[0]):
      MIN = C[0]
      
print(MIN)
Problem p02690 (python)

Fixed submission:
X = int(input())
Ans = []
for A in range(201):
  for B in range(A):
    if A ** 5 - B ** 5 == X:
      Ans = [A, B]
    if A ** 5 + B ** 5 == X:
      Ans = [A, B * (-1)]
      break
      
print(Ans[0], Ans[1])

Buggy submission (verdict: Runtime Error):
X = int(input())
for A in range(201):
  for B in range(A):
    if A ** 5 - B ** 5 == X:
      Ans = [A, B]
      break
      
print(Ans.split())
Problem p02702 (python)

Fixed submission:
mod_673 = [1] * 672
for i in range(1,672):
    mod_673[i] = (mod_673[i -1] * 10) % 673

S = input()
S = S[::-1]
A = [0] * (len(S) + 1)
B = [0] * (len(S) + 1)
x = 0
Ans = [[0] * 3 for i in range(673)]
for i in range(1, len(S) + 1):
    A[i] = (A[i - 1] + int(S[i - 1]) * mod_673[(i - 1) % 672]) % 673
    B[i] = (B[i - 1] + int(S[i - 1])) % 3

for i in range(len(S) + 1):
    Ans[A[i]][B[i]] += 1

for i in range(673):
    for j in range(3):
        y = Ans[i][j]
        x += y * (y - 1) // 2

print(x)

Buggy submission (verdict: Runtime Error):
mod_673 = [1] * 672
for i in range(1,672):
    mod_673[i] = (mod_673[i -1] * 10) % 673

S = input()
S = S[::-1]
A = [0] * (len(S) + 1)
B = [0] * (len(S) + 1)
x = 0
Ans = [[0] * 3 for i in range(673)]
for i in range(1, len(S) + 1):
    A[i] = (A[i - 1] + int(S[i - 1]) * mod_673[(i - 1) % 673]) % 673
    B[i] = (B[i - 1] + int(S[i - 1])) % 3

for i in range(len(S) + 1):
    Ans[A[i]][B[i]] += 1

for i in range(673):
    for j in range(3):
        y = Ans[i][j]
        x += y * (y - 1) // 2

print(x)
Problem p02706 (python)

Fixed submission:
N, M = map(int, input().split())
A = list(map(int, input().split()))
flag = True
 
for i in  A:
  N = N - i
  if N < 0:
    flag = False
    break
 
if flag == True:
  print(N)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
flag = True
 
for i in  A:
N = N - i
if N < 0:
flag = False
break
 
if flag == True:
  print(N)
else:
  print(-1)

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = list(map(int, input().split()))
flag = True
 
for i in  A:
  N = N - i
  if N < 0:
    flag = False
    break
 
if flag == True:
print(N)
else:
print(-1)

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

for i in  A:
N = N - i
if N < 0:
flag = False
break

if flag == True:
print(N)
else:
print(-1)
Problem p02708 (python)

Fixed submission:
N, K = map(int, input().split())
x = 1000000007
 
A = N * (N * (N + 1) - K * (K - 1)) // 2
B = (N * (N + 1) * (2 * N + 1) - K * (K - 1) * (2 * K - 1)) // 6
C = N - K + 2
D = (N * (N + 1) - K * (K - 1)) // 2

Ans = (A - B + C + D) % x
 
print(Ans)

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

A = (N - 1) * N * (N + 1) // 2
B = N * (N + 1) * (2 * N + 1) // 6
C = N * K * (K + 1) // 2
D = (K - 1) * K * (K + 1) // 3

Ans = (A - B - C + D) % x

print(Ans)
Problem p02730 (python)

Fixed submission:
def kaibunCheck(s):
  flag = True
  n = len(s)
  for i in range((n + 1) // 2):
    if s[i] != s[(i + 1) * (-1)]:
      flag = False

  return flag
        
S = input()
N = len(S)

S1 = S[:(N - 1) // 2]
S2 = S[(N + 1) // 2 :]

if kaibunCheck(S) == True and kaibunCheck(S1) == True and kaibunCheck(S2) == True:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
def kaibunCheck(s):
  flag = True
    n = len(s)
    for i in range((n + 1) // 2):
      if s[i] != s[(i + 1) * (-1)]:
        flag = False
    
  return flag
        
S = input()
N = len(S)

S1 = S[:(N - 1) // 2]
S2 = S[(N + 1) // 2 :]

if kaibunCheck(S) == True and kaibunCheck(S1) == True and kaibunCheck(S2) == True:
  print("Yes")
else:
  print("No")
Problem p02732 (python)

Fixed submission:
def conbination_2(n):
  if n <= 1:
    return 0
  else:
    return int(n * (n - 1) / 2)


N = int(input())
A = list(map(int,input().split()))
S = 0
Count = [0] * N

for i in range(N):
  Count[A[i] - 1] += 1
  
for i in range(N):
  S += conbination_2(Count[i])
  
for i in range(N):
  Ans = S - (Count[A[i] - 1] - 1)
  print(Ans)

Buggy submission (verdict: Runtime Error):
def conbination_2(n):
  if n <= 1:
    return 0
  else:
    return int(n * (n - 1) / 2)


N = int(input())
A = list(map(int,input().split()))
S = 0
Count = [0] * (N - 1)

for i in range(N):
  Count[A[i] - 1] += 1
  
for i in range(N - 1):
  S += conbination_2(Count[i])
  
for i in range(N):
  Ans = S - (Count[A[i] - 1] - 1)
  print(Ans)
Problem p02743 (python)

Fixed submission:
a, b, c = map(int, input().split())
 
N = c- a - b
 
if N > 0 and (4 * a * b) < N ** 2:
  print("Yes")
else:
  print("No")

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

N = c- a - b

if N > 0 4 * a * b < N ** 2:
  print("Yes")
else:
  print("No")
Problem p02747 (python)

Fixed submission:
S = input()
if S == "hi" or S == "hihi" or S == "hihihi" or S == "hihihihi" or S == "hihihihihi":
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
S = input()
if S == "hi" or S == "hihi" or S == "hihihi" or S = "hihihihi" or S == "hihihihihi":
  print("Yes")
else:
  print("No")