Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

h,w,m = map(int,input().split())
t = list(list(map(int,input().split())) for _ in range(m))

b = list([0]*w for _ in range(h))

for i in range(m):
  x,y = t[i]
  b[x-1][y-1] += 1

h_max = max(np.sum(b, axis=0))
w_max = max(np.sum(b, axis=1))

h_index = [n for n, v in enumerate(np.sum(b, axis=0)) if v == h_max]
w_index = [n for n, v in enumerate(np.sum(b, axis=1)) if v == w_max]

ans = h_max + w_max

for j in h_index:
  for k in w_index:
    if b[k][j] == 0:
      print(ans)
      exit()
print(ans-1)

Fixed submission:
import numpy as np

h,w,m = map(int,input().split())
t = list(tuple(map(lambda x: int(x)-1,input().split())) for _ in range(m))

H = [0] * h
W = [0] * w
for x,y in t:
    H[x] += 1
    W[y] += 1
H_max = max(H)
W_max = max(W)

H_index = [x for x,i in enumerate(H) if i == H_max]
W_index = [y for y,j in enumerate(W) if j == W_max]

ans = H_max + W_max

t = set(t)
for r in H_index:
    for c in W_index:
        if (r, c) not in t:
            print(ans)
            exit()
print(ans - 1)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

h,w,m = map(int,input().split())
t = list(list(map(int,input().split())) for _ in range(m))

b = list([0]*w for _ in range(h))

for i in range(m):
  x,y = t[i]
  b[x-1][y-1] += 1

h_max = max(np.sum(b, axis=0))
w_max = max(np.sum(b, axis=1))

h_index = [n for n, v in enumerate(np.sum(b, axis=0)) if v == h_max]
w_index = [n for n, v in enumerate(np.sum(b, axis=1)) if v == w_max]

ans = h_max + w_max

for j in range(len(h_index)):
  for k in range(len(w_index)):
    if b[w_index[k]][h_index[j]] == 0:
      print(ans)
      exit()
print(ans-1)

Fixed submission:
import numpy as np

h,w,m = map(int,input().split())
t = list(tuple(map(lambda x: int(x)-1,input().split())) for _ in range(m))

H = [0] * h
W = [0] * w
for x,y in t:
    H[x] += 1
    W[y] += 1
H_max = max(H)
W_max = max(W)

H_index = [x for x,i in enumerate(H) if i == H_max]
W_index = [y for y,j in enumerate(W) if j == W_max]

ans = H_max + W_max

t = set(t)
for r in H_index:
    for c in W_index:
        if (r, c) not in t:
            print(ans)
            exit()
print(ans - 1)

Buggy python submission (verdict: Time Limit Exceeded):
h,w,m = map(int,input().split())
t = list(list(map(int,input().split())) for _ in range(m))

ans = 0

for i in range(h):
  for j in range(w):
    n = [l[0] for l in t].count(i+1) +  [l[1] for l in t].count(j+1)
    if [i+1,j+1] in t:
      n -= 1
    if n > ans:
      ans = n
      
print(ans)

Fixed submission:
import numpy as np

h,w,m = map(int,input().split())
t = list(tuple(map(lambda x: int(x)-1,input().split())) for _ in range(m))

H = [0] * h
W = [0] * w
for x,y in t:
    H[x] += 1
    W[y] += 1
H_max = max(H)
W_max = max(W)

H_index = [x for x,i in enumerate(H) if i == H_max]
W_index = [y for y,j in enumerate(W) if j == W_max]

ans = H_max + W_max

t = set(t)
for r in H_index:
    for c in W_index:
        if (r, c) not in t:
            print(ans)
            exit()
print(ans - 1)
Buggy python submission (verdict: Runtime Error):
x,k,d = list(map(int,input().split()))

xi = abs(x)
if abs(x) > d*k:
  m = min(abs(x+d*k),abs(x-d*k))
else:
  for _ in range(k):
    xi -= d
    if xi < 0:
      m = min(abs(xi),abs(xi+d),abs(xi-d))
      break
print(m)

Fixed submission:
s = input()

if s == "RRR":
  d = 3
elif s == "RRS" or s == "SRR":
  d = 2
elif s == "SSS":
  d = 0
else:
  d = 1
print(d)
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())

a = 7
for i in range(k):
  if a % k == 0:
    print(i+1)
    exit()
  else:
    i += 1
    a += 7*(10**i)
print(-1)

Fixed submission:
k = int(input())
 
a = 7
for i in range(k):
  if a % k == 0:
    print(i+1)
    break
  a = (10*a+7) % k
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
c = list(input())

if "W" not in c:
  print(0)
  exit()

elif "R" not in c:
  print(0)
  exit()

w = c.index("W")
r = n-1 - c[::-1].index("R")

cnt = 0
while w < r:
  c[w],c[r] = c[r],c[w]
  w = c.index("W")
  r = n-1 - c[::-1].index("R")
  cnt += 1
else:
  print(cnt)

Fixed submission:
n = int(input())
c = list(input())

r = c.count('R')  
wr = c[:r].count('W')  

print(wr)

Buggy python submission (verdict: Runtime Error):
n = int(input())
c = list(input())

w = c.index("W")
r = n-1 - c[::-1].index("R")

cnt = 0
while w < r:
  c[w],c[r] = c[r],c[w]
  w = c.index("W")
  r = n-1 - c[::-1].index("R")
  cnt += 1
else:
  print(cnt)

Fixed submission:
n = int(input())
c = list(input())

r = c.count('R')  
wr = c[:r].count('W')  

print(wr)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

table = [0]*(n+1)
for i in range(1,n+1):
   for j in range(i,n+1,i):
      table[j] += 1
ans = 0
for i in range(1,n+1):
  ans += i*table[i]
print(ans)

Fixed submission:
n = int(input())

ans = 0
for i in range(1,n+1):
  k = n//i
  ans += i*(k*(k+1)//2)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())

def div_num(x):
  num = 0
  for i in range(1,x+1):
    if x % i == 0:
      num += 1
  return num

ans = 0
for i in range(1,n+1):
  ans += i * div_num(i)
print(ans)

Fixed submission:
n = int(input())

ans = 0
for i in range(1,n+1):
  k = n//i
  ans += i*(k*(k+1)//2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,m=map(int,input().split())

mod = 10**9+7

fact = [1]
for i in range(1,5*10**5 + 1):
  fact.append((fact[-1]*i) % mod)
  
revfact = [1]
for i in range(1,5*10**5 + 1):
  revfact.append(pow(fact[i],mod-2,mod))

A = (fact[m]*revfact[n]*revfact[m-n]*fact[n]) % mod
B = 0
for i in range(n+1):
  tmp = (fact[n]*revfact[i]*revfact[n-i])*(fact[m-i]*revfact[n-i]*revfact[m-n])*fact[n-i]
  if i % 2 == 0:
    B += tmp
    B %= mod
  else:
    B -= tmp
    B %= mod
print((A*B) % mod)

Fixed submission:
def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs
        

N, M = map(int, input().split())

MOD = 10 ** 9 + 7
modFacts, invs = prepare(max(N, M))

ans = 0
for i in range(N + 1):
    Ti = (modFacts[N] * invs[i] * invs[N - i]) % MOD
    Ti *= (modFacts[M] * invs[M - i]) % MOD
    Ti %= MOD
    Ti *= pow(modFacts[M - i] * invs[(M - i) - (N - i)], 2, MOD)
    Ti %= MOD
    ans += pow(-1, i) * Ti
    ans %= MOD

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from scipy.special import perm
from scipy.special import comb

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

p = perm(m,n,exact=True)

d = [0]*n
d[0] += p
for i in range(1,n):
  d[i] += (perm(m,n-i,exact=True)*(perm(m-n+i,i,exact=True)**2) - sum(d[:i]))*comb(n,i,exact=True)

ans = (p**2 - sum(d[:n])) % (10**9 + 7)
print(ans)

Fixed submission:
def prepare(n):
    global MOD
    modFacts = [0] * (n + 1)
    modFacts[0] = 1
    for i in range(n):
        modFacts[i + 1] = (modFacts[i] * (i + 1)) % MOD

    invs = [1] * (n + 1)
    invs[n] = pow(modFacts[n], MOD - 2, MOD)
    for i in range(n, 1, -1):
        invs[i - 1] = (invs[i] * i) % MOD

    return modFacts, invs
        

N, M = map(int, input().split())

MOD = 10 ** 9 + 7
modFacts, invs = prepare(max(N, M))

ans = 0
for i in range(N + 1):
    Ti = (modFacts[N] * invs[i] * invs[N - i]) % MOD
    Ti *= (modFacts[M] * invs[M - i]) % MOD
    Ti %= MOD
    Ti *= pow(modFacts[M - i] * invs[(M - i) - (N - i)], 2, MOD)
    Ti %= MOD
    ans += pow(-1, i) * Ti
    ans %= MOD

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
q = int(input())
for _ in range(q):
  b,c = map(int,input().split())
  for n,i in enumerate(a):
    if i == b:
      a[n] = c
  print(sum(a))

Fixed submission:
from collections import Counter

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

C = Counter(a)
s = sum(a)

for _ in range(q):
  b,c = map(int,input().split())
  s = s - b*C[b] + c*C[b]
  C[c] += C[b]
  C[b] = 0
  print(s)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

b = [0]*n
for i in range(n):
  b[i] = list(map(int, bin(a[i])[2:][::-1]))

l = max(map(len, b))
b_pad = list(map(lambda x: x + [0]*(l-len(x)), b))

for j in range(n):
  b_add = (np.sum(b_pad,axis=0) - np.array(b_pad[j])) % 2
  ans = 0
  for k in range(l):
    ans += (2**(k))*b_add[k]
  print(ans,end=" ")

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

s = a[0]
for i in range(1,n):
  s ^= a[i]

ans = [0]*n
for j in range(n):
  ans[j] = s ^ a[j]

print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = sorted(map(int, input().split()))
l = [0]*(10**6+1)

for i in a:
  if l[i] == 0:
    l[i] = 1
    for j in range(i*2, max(a)+1, i):
      l[j] = -1
  else:
    l[i] = -1
print(l.count(1))

Fixed submission:
n = int(input())
a = sorted(map(int, input().split()))
l = [0]*(10**6+1)
M = max(a)

for i in a:
  if l[i] == 0:
    l[i] = 1
    for j in range(i*2, M+1, i):
      l[j] = -1
  else:
    l[i] = -1
print(l.count(1))

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
a = list(map(int,input().split()))
a.sort()
l = [0]*(10**6+1)

for i in a:
  if l[i] == 0:
    l[i] = 1
    for j in range(i*2,max(a)+1,i):
      l[j] = -1
  else:
    l[i] = -1
print(l.count(1))

Fixed submission:
n = int(input())
a = sorted(map(int, input().split()))
l = [0]*(10**6+1)
M = max(a)

for i in a:
  if l[i] == 0:
    l[i] = 1
    for j in range(i*2, M+1, i):
      l[j] = -1
  else:
    l[i] = -1
print(l.count(1))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a.sort()
l = [0]*(10**6)

for i in a:
  if l[i] == 0:
    l[i] = 1
    for j in range(i*2,max(a)+1,i):
      l[j] = -1
  else:
    l[i] = -1
print(l.count(1))

Fixed submission:
n = int(input())
a = sorted(map(int, input().split()))
l = [0]*(10**6+1)
M = max(a)

for i in a:
  if l[i] == 0:
    l[i] = 1
    for j in range(i*2, M+1, i):
      l[j] = -1
  else:
    l[i] = -1
print(l.count(1))

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int,input().split()))
a.sort()
l = [0]*(10**6)

for i in a:
  if l[i] == 0:
    l[i] = 1
    for j in range(i*2,max(a)+1,i):
      l[j] = -1
  elif l[i] == 1:
    l[i] = -1
print(l.count(1))

Fixed submission:
n = int(input())
a = sorted(map(int, input().split()))
l = [0]*(10**6+1)
M = max(a)

for i in a:
  if l[i] == 0:
    l[i] = 1
    for j in range(i*2, M+1, i):
      l[j] = -1
  else:
    l[i] = -1
print(l.count(1))
Buggy python submission (verdict: Time Limit Exceeded):
from math import gcd
from functools import reduce

def gcd2(*numbers):
    return reduce(gcd, numbers)

k = int(input())

ans = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      ans += gcd2(a,b,c)
print(ans)

Fixed submission:
from math import gcd

k = int(input())

ans = 0
for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      ans += gcd(gcd(a,b),c)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
mod = 10**9+7

l = [0]*(k+1)

for i in range(k,0,-1):
  m = k//i
  l[i] += m**n
  for j in range(2,m+1):
    l[i] -= l[i*j]

ans = 0
for i in range(k+1):
  ans += i*l[i] % mod
  ans %= mod
print(ans)

Fixed submission:
n,k = map(int,input().split())
mod = 10**9+7

l = [0]*(k+1)

for i in range(k,0,-1):
  m = k//i
  l[i] += pow(k//i,n,mod)
  for j in range(2,m+1):
    l[i] -= l[i*j]

ans = 0
for i in range(k+1):
  ans += i*l[i] % mod
  ans %= mod
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p2 = p[:x]
q2 = q[:y]

for i in range(c):
  if p2[-1] <= q2[-1] and p2[-1] < r[i]:
    p2[-1] = r[i]
    p2.sort(reverse=True)
  if p2[-1] > q2[-1] and q2[-1] < r[i]:
    q2[-1] = r[i]
    q2.sort(reverse=True)
    
ans = sum(p2)+sum(q2)
print(ans)

Fixed submission:
x,y,a,b,c = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort(reverse=True)
q.sort(reverse=True)

p2 = p[:x]
q2 = q[:y]

l = p2 + q2 + r
l.sort(reverse=True)

ans = sum(l[:x+y])
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from copy import copy
from collections import Counter
from scipy.special import comb

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

for k in range(n):
  a = copy(A)
  a.pop(k)
  c = Counter(a)
  ans = 0
  for i in range(1,n+1):
    ans += comb(c[i],2,exact=True)
  print(ans)

Fixed submission:
from copy import copy
from collections import Counter
from scipy.special import comb

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

C = Counter(A)
S = 0
for i in range(1,n+1):
  S += comb(C[i],2,exact=True)

for k in range(n):
  p = A[k]
  ans = S - comb(C[p],2,exact=True) + comb(C[p]-1,2,exact=True)
  print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
q = int(input())
t = [list(map(str,input().split())) for _ in range(q)]

for i in range(q):
  if len(t[i]) == 1:
    s = s[::-1]
  else:
    if t[i][1] == '1':
      s = list(t[i][2]) + s
    else:
      s = s + list(t[i][2])
      
print(''.join(s))

Fixed submission:
from collections import deque

s = list(input())
q = int(input())
t = [list(map(str,input().split())) for _ in range(q)]

d = deque(s)

cnt = 0
for i in range(q):
  if len(t[i]) == 1:
    cnt += 1
  else:
    if (int(t[i][1])+cnt) % 2 != 0:
      d.appendleft(t[i][2])
    else:
      d.append(t[i][2])
      
if cnt%2 != 0:
  d = list(d)[::-1]
print(''.join(d))
Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
p = list(map(int,input().split()))

d_max = 0
for i in range(n-k+1):
  d_max = max(d_max,sum(p[i:k+i]))

ans = (d_max + k)/2
print(ans)

Fixed submission:
n,k = map(int,input().split())
p = list(map(int,input().split()))

d_tmp = sum(p[0:k])
d_max = sum(p[0:k])
for i in range(n-k):
  d_tmp = d_tmp + p[k+i] - p[i]
  d_max = max(d_max,d_tmp)

ans = (d_max + k)/2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
p = list(map(int,input().split()))

d_max = 0
for i in range(n-k+1):
  if d_max < sum(p[i:k+i]):
    d_max = sum(p[i:k+i])

ans = (d_max + k)/2
print(ans)

Fixed submission:
n,k = map(int,input().split())
p = list(map(int,input().split()))

d_tmp = sum(p[0:k])
d_max = sum(p[0:k])
for i in range(n-k):
  d_tmp = d_tmp + p[k+i] - p[i]
  d_max = max(d_max,d_tmp)

ans = (d_max + k)/2
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n,k = map(int,input().split())
p = list(map(int,input().split()))

d = 0
for i in range(n-k+1):
  if d < sum(p[i:k+i]):
    d = sum(p[i:k+i])
    d_start = i

ans = 0
for i in range(k):
  ans += (p[d_start + i] + 1)/2
  
print(ans)

Fixed submission:
n,k = map(int,input().split())
p = list(map(int,input().split()))

d_tmp = sum(p[0:k])
d_max = sum(p[0:k])
for i in range(n-k):
  d_tmp = d_tmp + p[k+i] - p[i]
  d_max = max(d_max,d_tmp)

ans = (d_max + k)/2
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
h = int(input())

cnt = 1
for i in range(10**12):
  h = h//2
  n = 2**(i+1)
  cnt += n
  if h == 1:
    print(cnt)
    exit()

Fixed submission:
h = int(input())

for i in range(10**12):
  if 2**i <= h < 2**(i+1):
    ans = 2**(i+1)-1
    print(ans)
    exit()
Buggy python submission (verdict: Time Limit Exceeded):
h,n = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]

dp = [float("inf")]*(h+1)
dp[0] = 0

for i in range(h):
  for d,c in ab:
    hp = min(i+d,h)
    dp[hp] = min(dp[hp],dp[i]+c)

print(dp[-1])

Fixed submission:
h,n = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]

dp = [float("inf")]*(h+1)
dp[0] = 0

for i in range(h):
  for d,c in ab:
    hp = min(i+d,h)
    dp[hp] = min(dp[hp],dp[i]+c)

print(dp[-1])

Buggy python submission (verdict: Time Limit Exceeded):
h,n = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
a,b = map(list,zip(*ab))

dp = [float("inf")]*(h+1)
dp[0] = 0

for i in range(h):
  for d,c in ab:
    hp = min(i+d,h)
    dp[hp] = min(dp[hp],dp[i]+c)

print(dp[h])

Fixed submission:
h,n = map(int,input().split())
ab = [list(map(int,input().split())) for _ in range(n)]

dp = [float("inf")]*(h+1)
dp[0] = 0

for i in range(h):
  for d,c in ab:
    hp = min(i+d,h)
    dp[hp] = min(dp[hp],dp[i]+c)

print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))

cnt = 1
for i in range(1,n):
  if p[i] > p[i-1]:
    continue
  elif min(p[:i+1]) == p[i]:
    cnt += 1
print(cnt)

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

min_num = 10**6
cnt = 0
for i in range(n):
  if p[i] < min_num:
    min_num = p[i]
    cnt += 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
p = list(map(int,input().split()))

cnt = 0
for i in range(n):
  if min(p[:i+1]) == p[i]:
    cnt += 1
print(cnt)

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

min_num = 10**6
cnt = 0
for i in range(n):
  if p[i] < min_num:
    min_num = p[i]
    cnt += 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):

n = int(input())

ans = 0
count = 0

a, b, c = 1, 1, 1

while a <= n:

    # print("A : {0}".format(a))

    while a * b < n:

        # print("B : {0}".format(b))

        ans += 1

        # if c >= n - (a * b) :
        #     ans += 1

        # while a * b + c <= n:

        #     # print("C : {0}".format(c))

        #     count += 1

        #     if a * b + c == n :
        #         ans += 1

        #     c += 1

        b += 1
        c = 1

    a += 1
    b, c = 1, 1

# print("計算実行回数 : {0}".format(count))
print(ans)

Fixed submission:

n = int(input())

ans = 0
count = 0

a, b, c = 1, 1, 1

while a <= n:

    # print("A : {0}".format(a))
    # print("追加パターン : {0}".format( (n // a) ))

    if a == 1 :
        ans =  ans + ( (n // a) - 1)
    else :

        if n // a == 1 :
            ans = ans + 1
        else :

            if n % a == 0 :
                ans = ans + ( (n // a) - 1)
            else :
                ans = ans + ( (n // a) )

            



    # if n % a == 0 :
    #     ans = ans + ( (n / a) - 1 )
    # else :
    #     ans = ans + ( (n // a) - 1 )

    # ans = ans + (n / a) - 1

    # print("A : {0}".format(a))

    # while a * b < n:

    #     print("B : {0}".format(b))

    #     ans += 1

    #     b += 1
    #     c = 1

    a += 1
    b, c = 1, 1

# print("計算実行回数 : {0}".format(count))
print(ans - 1)

Buggy python submission (verdict: Time Limit Exceeded):

n = int(input())

ans = 0
count = 0

a, b, c = 1, 1, 1

while a <= n:

    # print("A : {0}".format(a))

    while a * b <= n:

        # print("B : {0}".format(b))

        while a * b + c <= n:

            # print("C : {0}".format(c))

            count += 1

            if a * b + c == n :
                ans += 1

            c += 1

        b += 1
        c = 1

    a += 1
    b, c = 1, 1

# print("計算実行回数 : {0}".format(count))
print(ans)

Fixed submission:

n = int(input())

ans = 0
count = 0

a, b, c = 1, 1, 1

while a <= n:

    # print("A : {0}".format(a))
    # print("追加パターン : {0}".format( (n // a) ))

    if a == 1 :
        ans =  ans + ( (n // a) - 1)
    else :

        if n // a == 1 :
            ans = ans + 1
        else :

            if n % a == 0 :
                ans = ans + ( (n // a) - 1)
            else :
                ans = ans + ( (n // a) )

            



    # if n % a == 0 :
    #     ans = ans + ( (n / a) - 1 )
    # else :
    #     ans = ans + ( (n // a) - 1 )

    # ans = ans + (n / a) - 1

    # print("A : {0}".format(a))

    # while a * b < n:

    #     print("B : {0}".format(b))

    #     ans += 1

    #     b += 1
    #     c = 1

    a += 1
    b, c = 1, 1

# print("計算実行回数 : {0}".format(count))
print(ans - 1)
Buggy python submission (verdict: Time Limit Exceeded):

n = int(input())

a_list = list(map(int, input().split()))

if n != 0 :
    ans = a_list[0]
else :
    ans = 0

for i in range(1, n):
    ans = ans * a_list[i]

if 10**18 < ans :
        ans = -1   


print(ans)

Fixed submission:

n = int(input())

a_list = list(map(int, input().split()))

if n != 0 :
    ans = a_list[0]
else :
    ans = 0

if 0 in a_list :
    ans = 0

for i in range(1, n):
    ans = ans * a_list[i]

    if 10**18 < ans :
        ans = -1
        break

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):

n, k = (int(x) for x in input().split())

while n > k:
    n = n - k

temp = n

n = n - k

if abs(temp) < abs(n) :
    print(abs(temp))
else:
    print(abs(n))

Fixed submission:

n, k = (int(x) for x in input().split())

mod = n % k
kari = mod - k

if abs(mod) < abs(kari) :
    print(abs(mod))
else:
    print(abs(kari))
Buggy python submission (verdict: Runtime Error):

a, b = input().split()

int_a = int(a)
int_b = int(b)

a_List = ''
b_List = ''

for i in range(int_a):
    b_List = b_List + b

for i in range(int_b):
    a_List = a_List + a


# print('a_List : ' + a_List)
# print('b_List : ' + b_List)

a_List = int(a_List)
b_List = int(b_List)

if a_List => b_List:
    print(a_List)

else:
    print(b_List)

Fixed submission:

a, b = input().split()

int_a = int(a)
int_b = int(b)

a_List = ''
b_List = ''

for i in range(int_a):
    b_List = b_List + b

for i in range(int_b):
    a_List = a_List + a


# print('a_List : ' + a_List)
# print('b_List : ' + b_List)

a_List = int(a_List)
b_List = int(b_List)

if a_List >= b_List:
    print(a_List)

else:
    print(b_List)

Buggy python submission (verdict: Runtime Error):


a, b = input().split()

int_a = int(a)
int_b = int(b)

a_List = ''
b_List = ''

for i in range(int_a):
    b_List = b_List + b

for i in range(int_b):
    a_List = a_List + a


print('a_List : ' + a_List)
print('b_List : ' + b_List)

# a_List = int(a_List)
# b_List = int(b_List)


if a_List => b_List:
    print(a_List)

else:
    print(b_List)

Fixed submission:

a, b = input().split()

int_a = int(a)
int_b = int(b)

a_List = ''
b_List = ''

for i in range(int_a):
    b_List = b_List + b

for i in range(int_b):
    a_List = a_List + a


# print('a_List : ' + a_List)
# print('b_List : ' + b_List)

a_List = int(a_List)
b_List = int(b_List)

if a_List >= b_List:
    print(a_List)

else:
    print(b_List)

Buggy python submission (verdict: Runtime Error):


a, b = input().split()

int_a = int(a)
int_b = int(b)

a_List = ''
b_List = ''

for i in range(int_a):
    b_List = b_List + b

for i in range(int_b):
    a_List = a_List + a


print('a_List : ' + a_List)
print('b_List : ' + b_List)

# a_List = int(a_List)
# b_List = int(b_List)


if a_List => b_List:
    print(a_List)

else:
    print(b_List)

Fixed submission:

a, b = input().split()

int_a = int(a)
int_b = int(b)

a_List = ''
b_List = ''

for i in range(int_a):
    b_List = b_List + b

for i in range(int_b):
    a_List = a_List + a


# print('a_List : ' + a_List)
# print('b_List : ' + b_List)

a_List = int(a_List)
b_List = int(b_List)

if a_List >= b_List:
    print(a_List)

else:
    print(b_List)
Buggy python submission (verdict: Runtime Error):
# N, Sを入力
n = input()
s = input()

results = re.findall(r"ABC", s)

print(len(results))

Fixed submission:
import re

# N, Sを入力
n = input()
s = input()

results = re.findall(r"ABC", s)

print(len(results))