Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
n, m, k = map(int, input().split())
mod = 998244353
def powerDX(n, r, mod):
  if r == 0: return 1
  if r%2 == 0:
    return powerDX(n*n % mod, r//2, mod) % mod
  if r%2 == 1:
    return n * powerDX(n, r-1, mod) % mod
 
def combination(n, r, mod):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * powerDX(denom, mod-2, mod) % mod
 
ans = 0
for i in range(0, k+1):
  ans += m*combination(n-1, i, mod)*powerDX(m-1, n-i-1, mod)
  ans %= mod
print(ans)

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

def powerDX(n, r, mod):
  if r == 0: return 1
  if r%2 == 0:
    return powerDX(n*n % mod, r//2, mod) % mod
  if r%2 == 1:
    return n * powerDX(n, r-1, mod) % mod

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
 
for i in range(2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
for i in range(0, k+1):
  ans += m*cmb(n-1, i, mod)*powerDX(m-1, n-i-1, mod)
  ans %= mod
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n, m, k = map(int, input().split())
mod = 998244353
def powerDX(n, r, mod):
  if r == 0: return 1
  if r%2 == 0:
    return powerDX(n*n % mod, r//2, mod) % mod
  if r%2 == 1:
    return n * powerDX(n, r-1, mod) % mod
 
def combination(n, r, mod):
    n1, r = n+1, min(r, n-r)
    numer = denom = 1
    for i in range(1, r+1):
        numer = numer * (n1-i) % mod
        denom = denom * i % mod
    return numer * powerDX(denom, mod-2, mod) % mod
 
ans = 0
for i in range(0, k+1):
  ans += m*combination(n-1, i, mod)*powerDX(m-1, n-i-1, mod)
  ans %= mod
print(ans)

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

def powerDX(n, r, mod):
  if r == 0: return 1
  if r%2 == 0:
    return powerDX(n*n % mod, r//2, mod) % mod
  if r%2 == 1:
    return n * powerDX(n, r-1, mod) % mod

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
 
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
 
for i in range(2, n + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

ans = 0
for i in range(0, k+1):
  ans += m*cmb(n-1, i, mod)*powerDX(m-1, n-i-1, mod)
  ans %= mod
print(ans)
Buggy python submission (verdict: Runtime Error):
import sys
import os
f = open('input.txt', 'r')
sys.stdin = f

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

mans = [0]*n
for i in range(k):
    d = input()
    a = list(map(int, input().split()))
    for aa in a:
        mans[aa-1] += 1

cnt = 0
for m in range(len(mans)):
    if mans[m] == 0:
        cnt += 1

print(cnt)


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

mans = [0]*n
for i in range(k):
    d = input()
    a = list(map(int, input().split()))
    for aa in a:
        mans[aa-1] += 1

cnt = 0
for m in range(len(mans)):
    if mans[m] == 0:
        cnt += 1

print(cnt)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

fromLeft = [-1]*n

for i in range(n):
    fromLeft[i] = a[i] - i

ans = 0

ldList = [0]*(3*10**5)

for i in reversed(range(n)):
    if -1*fromLeft[i] < 3*10**5-10:
        ldList[-1*fromLeft[i]] += 1
    if a[i]+i < 3*10**5-10:
        ans += ldList[a[i]+i]

print(ans)

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

fromLeft = [-1]*n

for i in range(n):
    fromLeft[i] = a[i] - i

ans = 0

ldList = [0]*(n*2+5)

for i in reversed(range(n)):
    if 0 <= fromLeft[i]+n+1 and fromLeft[i]+n+1 < n*2+5:
        ldList[fromLeft[i]+n+1] += 1
    if 0 <= -1*a[i]-i+n+1 and -1*a[i]-i+n+1 < n*2+5:
        ans += ldList[-1*a[i]-i+n+1]

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

fromLeft = [-1]*n

for i in range(n):
    fromLeft[i] = a[i] - i

ans = 0

ldList = [0]*(3*10**5)

for i in reversed(range(n)):
    if fromLeft[i] < 3*10**5-10:
        ldList[fromLeft[i]] += 1
    ans += ldList[-1*a[i]-i]

print(ans)

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

fromLeft = [-1]*n

for i in range(n):
    fromLeft[i] = a[i] - i

ans = 0

ldList = [0]*(n*2+5)

for i in reversed(range(n)):
    if 0 <= fromLeft[i]+n+1 and fromLeft[i]+n+1 < n*2+5:
        ldList[fromLeft[i]+n+1] += 1
    if 0 <= -1*a[i]-i+n+1 and -1*a[i]-i+n+1 < n*2+5:
        ans += ldList[-1*a[i]-i+n+1]

print(ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

fromLeft = [-1]*n

for i in range(n):
    fromLeft[i] = a[i] - i

ans = 0

ldList = [0]*(3*10**5)

for i in reversed(range(n)):
    ldList[fromLeft[i]] += 1
    ans += ldList[-1*a[i]-i]

print(ans)

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

fromLeft = [-1]*n

for i in range(n):
    fromLeft[i] = a[i] - i

ans = 0

ldList = [0]*(n*2+5)

for i in reversed(range(n)):
    if 0 <= fromLeft[i]+n+1 and fromLeft[i]+n+1 < n*2+5:
        ldList[fromLeft[i]+n+1] += 1
    if 0 <= -1*a[i]-i+n+1 and -1*a[i]-i+n+1 < n*2+5:
        ans += ldList[-1*a[i]-i+n+1]

print(ans)

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

fromLeft = [-1]*n

for i in range(n):
    fromLeft[i] = a[i] - i

ans = 0

for i in range(n):
    ans += fromLeft[i:].count(-1*a[i]-i)

print(ans)


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

fromLeft = [-1]*n

for i in range(n):
    fromLeft[i] = a[i] - i

ans = 0

ldList = [0]*(n*2+5)

for i in reversed(range(n)):
    if 0 <= fromLeft[i]+n+1 and fromLeft[i]+n+1 < n*2+5:
        ldList[fromLeft[i]+n+1] += 1
    if 0 <= -1*a[i]-i+n+1 and -1*a[i]-i+n+1 < n*2+5:
        ans += ldList[-1*a[i]-i+n+1]

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input()))

out = [0]*n

for aa in a:
  out[a] += 1

for o in range(len(out)):
  print(o)

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

out = [0]*n

for aa in a:
  out[aa-1] += 1

for i in range(len(out)):
  print(out[i])
Buggy python submission (verdict: Runtime Error):
n = int(input())
if n == 2:
    print(1)
elif n == 3:
    print(2)
else:
    #print(make_divisors(n-1))
    print(len(make_divisors(n-1))+1)

Fixed submission:
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

N = int(input())
divsN = make_divisors(N)
divsN2 = make_divisors(N-1)
divsN.pop(0)

ans = len(divsN2)-1

for div in divsN:
    n = N+1-1
    while True:
        if n%div != 0 or n==1:
            break
        n //= div
    if n%div == 1:
        ans += 1

print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

data = [0]*n

for aa in a:
  data[aa] += 1

allans = 0
for d in data:
  if d >= 2:
    allans += (d*(d-1))//2
    
for aa in a:
  if data[aa] == 2:
    print(allans - (data[aa]*(data[aa]-1))//2)
  elif data[aa] > 2:
    print(allans - (data[aa]-1))
  else:
    print(allans)
  

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

data = [0]*(n+1)

for aa in a:
  data[aa] += 1

allans = 0
for d in data:
  if d >= 2:
    allans += (d*(d-1))//2
    
for aa in a:
  if data[aa] == 2:
    print(allans - (data[aa]*(data[aa]-1))//2)
  elif data[aa] > 2:
    print(allans - (data[aa]-1))
  else:
    print(allans)
Buggy python submission (verdict: Runtime Error):
import sys
a, b, c = input().split()

if c - a - b > 0:
  print("No")
  sys.exit()

if 4*a*b < (c-a-b)**2:
  print("Yes")
else:
  print("No")

Fixed submission:
import sys
a, b, c = map(int, input().split())

if c - a - b < 0:
  print("No")
  sys.exit()

if 4*a*b < (c-a-b)**2:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
q = int(input())

flag_swap = False
for i in range(q):
  query = list(input().split())
  if query[0] == "1":
    flag_swap = not flag_swap
  else:
    if (query[1] == "1" and not flag_swap) or (query[1] == "2" and flag_swap):
      s = query[2] + s
    else:
      s += query[2]

idx = range(len(s))
if flag_swap:
  idx = reversed(idx)
for i in idx:
  print(s[i], end="")
  
      
      

Fixed submission:
s = input()
q = int(input())
left = ""
right = ""
flag_swap = False
for i in range(q):
  query = list(input().split())
  if query[0] == "1":
    flag_swap = not flag_swap
  else:
    if (query[1] == "1" and not flag_swap) or (query[1] == "2" and flag_swap):
      left += query[2]
    else:
      right += query[2]

if flag_swap:
  print(right[::-1]+s[::-1]+left)
else:
  print(left[::-1]+s+right)
Buggy python submission (verdict: Time Limit Exceeded):
h, n = map(int, input().split())
dp = [10**10]*(h+10**4+1)
dp[0] = 0

for _ in range(n):
  a, b = map(int, input().split())
  for i in range(a, len(dp)):
    dp[i] = min(dp[i-a]+b, dp[i])

print(min(dp[h:]))

Fixed submission:
h, n = map(int, input().split())
dp = [10**10]*(h+10**4+1)
dp[0] = 0

for _ in range(n):
  a, b = map(int, input().split())
  for i in range(a, len(dp)):
    dp[i] = min(dp[i-a]+b, dp[i])

print(min(dp[h:]))
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())

if a+b == 3:
  print(3)
elif a+b == 4:
  print(2)
else:
  print(1)

Fixed submission:
a = int(input())
b = int(input())

if a+b == 3:
  print(3)
elif a+b == 4:
  print(2)
else:
  print(1)
Buggy python submission (verdict: Runtime Error):
import math
a,b,x = map(int, input().split())

def xx(y):
  aHeight = a*math.sin(y)
  bHeight = b*math.sin(0.5*math.pi-y)
  if aHeight < bHeight:
    menseki = 0.5*a*b + (bHeight/aHeight*a-b)*math.sin(0.5*math.pi-y)*(a/math.cos(y))
  else:
    aD = bHeight/math.sin(y)
    menseki = 0.5*aD*b
  return menseki

minY = 0
maxY = 0.5*math.pi
while True:
  menseki = xx((minY+maxY)/2)
  if abs(x/a - menseki) < 0.1:
    print((minY+maxY)/2 * (180/math.pi))
    break
  elif menseki < x/a:
    maxY = (minY+maxY)/2
  else:
    minY = (minY+maxY)/2

Fixed submission:
a,b = map(int, input().split())
if a <= 9 and b <= 9:
  print(a*b)
else:
  print(-1)

Buggy python submission (verdict: Runtime Error):
import math
N = int(input())
sqN = int(math.sqrt(N))
for i in range(sqN):
  if N % (sqN-i) == 0:
    print(int(N/(sqN-i)+sqN-i))
    break

Fixed submission:
a,b = map(int, input().split())
if a <= 9 and b <= 9:
  print(a*b)
else:
  print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())

dp = [[10**10 for _ in range(2**n)] for j in range(m)]
dp[0][0] = 0
a, b = map(int, input().split())
c = list(map(int, input().split()))
idx = 0
for cc in c:
  idx += 2**(cc-1)
for j in range(1, 2**n):
  if ~idx & j == 0:
    dp[0][j] = a

for i in range(1, m):
  a, b = map(int, input().split())
  c = list(map(int, input().split()))
  idx = 0
  for cc in c:
    idx += 2**(cc-1)
  for j in range(2**n):
    dp[i][j] = min(dp[i-1][j], dp[i-1][(j|idx)^idx]+a)

if dp[-1][-1] != 10**10:
  print(dp[-1][-1])
else:
  print(-1)

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

dp = [[10**10 for _ in range(2**n)] for j in range(m)]
dp[0][0] = 0
a, b = map(int, input().split())
c = list(map(int, input().split()))
idx = 0
for cc in c:
  idx += 2**(cc-1)
for j in range(1, 2**n):
  if ~idx & j == 0:
    dp[0][j] = a

for i in range(1, m):
  a, b = map(int, input().split())
  c = list(map(int, input().split()))
  idx = 0
  for cc in c:
    idx += 2**(cc-1)
  for j in range(2**n):
    dp[i][j] = min(dp[i-1][j], dp[i-1][(j|idx)^idx]+a)

if dp[-1][-1] != 10**10:
  print(dp[-1][-1])
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
s = input()
 
flag = True
for i in range(s):
  if i%2 == 0 and s[i] == "L":
    flag = False
  if i%2 == 1 and s[i] == "R":
    flag = False
 
if flag:
  print("Yes")
else:
  print("No")

Fixed submission:
s = input()
 
flag = True
for i in range(len(s)):
  if i%2 == 0 and s[i] == "L":
    flag = False
  if i%2 == 1 and s[i] == "R":
    flag = False
 
if flag:
  print("Yes")
else:
  print("No")

Buggy python submission (verdict: Runtime Error):
s = input()

flag = True
for i in range(s):
  if i%2 == 0 and s[i] == "L":
    flag = False
  if i%2 == 1 and s[i] == "R":
    flag = False

if flag:
  print("Yes")
else:
  print("No")

Fixed submission:
s = input()
 
flag = True
for i in range(len(s)):
  if i%2 == 0 and s[i] == "L":
    flag = False
  if i%2 == 1 and s[i] == "R":
    flag = False
 
if flag:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
mod = 10**9+7
data = [[] for j in range(n+1)]
done = [0]*(n+1)
colors = [k-1]*(n+1)

for i in range(n-1):
  a, b = map(int, input().split())
  data[min(a,b)].append(max(a,b))
  data[max(a,b)].append(min(a,b))

queue = [1]
ans = 1
colors[1] += 1
for d in data[1]:
  colors[d] += 1
while queue != []:
  idx = queue.pop(0)
  done[idx] = 1
  ans *= colors[idx]
  ans %= mod
  cnt = 0
  for i in range(len(data[idx])):
    if done[data[idx][i]]:
      continue
    cnt += 1
    colors[data[idx][i]] -= cnt
    queue.append(data[idx][i])

print(ans)
  
  

Fixed submission:
n, k = map(int, input().split())
mod = 10**9+7
data = [[] for j in range(n+1)]
done = [0]*(n+1)
colors = [k-1]*(n+1)

for i in range(n-1):
  a, b = map(int, input().split())
  data[min(a,b)].append(max(a,b))
  data[max(a,b)].append(min(a,b))

queue = [1]
ans = 1
colors[1] += 1
for d in data[1]:
  colors[d] += 1
while queue != []:
  idx = queue.pop(0)
  done[idx] = 1
  ans *= colors[idx]
  ans %= mod
  cnt = 0
  for i in range(len(data[idx])):
    if done[data[idx][i]]:
      continue
    cnt += 1
    colors[data[idx][i]] -= cnt
    queue.append(data[idx][i])

print(ans)
Buggy python submission (verdict: Runtime Error):
def ans(n): 
    if (n == 0 or n == 9): 
        return True
    if (n < 9): 
        return False
  
    return ans((int)(n>>3) - (int)(n&7)) 
  
n = input()
print('Yes' if ans(int(n)) else 'No')
  

Fixed submission:
def ans(n): 

    aa = 0
    for i in n:
        aa+=int(i)
    return True if aa%9==0 else False
        
  
n = input()

print('Yes' if ans(n) else 'No')
Buggy python submission (verdict: Runtime Error):
n = int(input())
cnt = [0] * (n*n)
for a in range(1, int(n**0.5)+1):
    for b in range(1, int(n**0.5)+1):
        for c in range(1, int(n**0.5)+1):
            cnt[a*a + b*b + c*c + a*b + b*c + c*a] += 1

for i in range(1, n+1):
    print(cnt[i])

Fixed submission:
n = int(input())
cnt = [0] * (n*n+1000)
for a in range(1, int(n**0.5)+1):
    for b in range(1, int(n**0.5)+1):
        for c in range(1, int(n**0.5)+1):
            cnt[a*a + b*b + c*c + a*b + b*c + c*a] += 1

for i in range(1, n+1):
    print(cnt[i])
Buggy python submission (verdict: Runtime Error):
import strutils, sequtils
var
  a, p = stdin.readline.split.map(parseFloat)
  n, k: int
(n, k) = a.map(toInt)

p = @[0.0] & p
for i in 1..n:
  p[i] *= (p[i]+1) / (2*p[i])
  p[i] += p[i-1]

var ans = 0.0
for i in 0..n-k: ans = max(ans, p[i+k]-p[i])
echo ans

Fixed submission:
fact = [0]*1010
for i in range(1, 1010): fact[i] = fact[i-1]+i

n, k, *a = map(int, open(0).read().split())
a = list(map(lambda x:fact[x]/x, a))
ans = tmp = sum(a[:k])
for i in range(n-k):
    tmp -= a[i]
    tmp += a[i+k]
    ans = max(ans, tmp)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
fact = [0]*1010
for i in range(1, 1010): fact[i] = fact[i-1]+i

n, k, *a = map(int, open(0).read().split())
ans = 0
for i in range(n-k+1):
    tmp = 0
    for j in a[i:i+k]: tmp += fact[j]/j
    ans = max(ans, tmp)
print(ans)

Fixed submission:
fact = [0]*1010
for i in range(1, 1010): fact[i] = fact[i-1]+i

n, k, *a = map(int, open(0).read().split())
a = list(map(lambda x:fact[x]/x, a))
ans = tmp = sum(a[:k])
for i in range(n-k):
    tmp -= a[i]
    tmp += a[i+k]
    ans = max(ans, tmp)
print(ans)
Buggy python submission (verdict: Runtime Error):
n = int(input())
xls = [list(map(int, input().split()))for i in range(n)]
xls.sort(key=lambda x:x[0])
flag = 1
ans1 = ans2 = 1
x, l = xls[0]
for i in range(1, n):
    nx, nl = xls[i]
    if nx-nl+1<x+l: continue
    if i==1: flag=0
    ans1 += 1
    x, l = nx, nl

if flag:
    x, l = xls[1]
    for i in range(2, n):
        nx, nl = xls[i]
        if nx-nl+1<x+l: continue
        if i==1: flag=0
        ans2 += 1
        x, l = nx, nl
print(max(ans1, ans2))

Fixed submission:
n = int(input())
xls = [list(map(int, input().split()))for i in range(n)]
xls.sort(key=lambda x:sum(x))

ans = 0
now = -1e11
for i in range(n):
    if now<=xls[i][0]-xls[i][1]:
        ans += 1
        now = xls[i][0]+xls[i][1]
print(ans)
Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a<b: a,b=b,a
c = a*b
while b:
    a, b = b, a//b
print(c//b)

Fixed submission:
a, b = map(int, input().split())
if a<b: a,b=b,a
c = a*b
while b: a, b = b, a%b
print(c//a)

Buggy python submission (verdict: Runtime Error):
a, b = map(int, input().split())
if a<b: a,b=b,a
c = a*b
while a%b:
    a, b = b, a//b
print(c//b)

Fixed submission:
a, b = map(int, input().split())
if a<b: a,b=b,a
c = a*b
while b: a, b = b, a%b
print(c//a)
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

MOD = 1000000007
n, *a = map(int, open(0).read().split())

ans = 0
w = 1
for i in range(61):
    zero = one = 0
    for j in range(n):
        if a[j]&1: one += 1
        else: zero += 1
        a[j] >>= 1;
    ans += w * zero * one
    ans %= MOD
    w *= 2
print(ans)


Fixed submission:
MOD = 1000000007
n, *a = map(int, open(0).read().split())

ans = 0
w = 1
for i in range(61):
    zero = one = 0
    for j in range(n):
        if a[j]&1: one += 1
        else: zero += 1
        a[j] >>= 1;
    ans += w * zero * one
    ans %= MOD
    w = w * 2 % MOD
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

MOD = 1000000007
n, *a = map(int, open(0).read().split())

ans = 0
w = 1
for i in range(61):
    zero = one = 0
    for j in range(n):
        if a[j]&1: one += 1
        else: zero += 1
        a[j] >>= 1;
    ans = (ans + w * zero * one)% MOD
    w = w * 2 % MOD
print(ans)


Fixed submission:
MOD = 1000000007
n, *a = map(int, open(0).read().split())

ans = 0
w = 1
for i in range(61):
    zero = one = 0
    for j in range(n):
        if a[j]&1: one += 1
        else: zero += 1
        a[j] >>= 1;
    ans += w * zero * one
    ans %= MOD
    w = w * 2 % MOD
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3

MOD = 1000000007
n, *a = map(int, open(0).read().split())

ans = 0
w = 1
for i in range(61):
    zero = one = 0
    for x in a:
        if (x>>i)&1: one += 1
        else: zero += 1
    ans = (ans + w * zero * one % MOD) % MOD
    w = w * 2 % MOD
print(ans)


Fixed submission:
MOD = 1000000007
n, *a = map(int, open(0).read().split())

ans = 0
w = 1
for i in range(61):
    zero = one = 0
    for j in range(n):
        if a[j]&1: one += 1
        else: zero += 1
        a[j] >>= 1;
    ans += w * zero * one
    ans %= MOD
    w = w * 2 % MOD
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
MOD = 1000000007
n, *a = map(int, open(0).read().split())
ans = 0
for i in range(61):
    zero = one = 0
    for x in a:
        if (x>>i)&1: one += 1
        else: zero += 1
    ans += pow(2, i, MOD) * zero * one % MOD
    ans %= MOD
print(ans)


Fixed submission:
MOD = 1000000007
n, *a = map(int, open(0).read().split())

ans = 0
w = 1
for i in range(61):
    zero = one = 0
    for j in range(n):
        if a[j]&1: one += 1
        else: zero += 1
        a[j] >>= 1;
    ans += w * zero * one
    ans %= MOD
    w = w * 2 % MOD
print(ans)
Buggy python submission (verdict: Runtime Error):
n, *a = map(int, open(0).read().split())
a.sort()
if a[0]!=0:
    print(0)
    exit()

b = [0]*n
for i in a: b[i]+=1

if b[0]!=1:
    print(0)
    exit()

ans = 1
i = 0
while 1:
    if b[i]==0:
        if sum(b[i:])>0:
            print(0)
            exit()
        else:
            break
    ans *= b[i]**b[i+1]
    i += 1

print(ans)

Fixed submission:
n, *a = map(int, open(0).read().split())
if a[0]!=0:
    print(0)
    exit()

b = [0]*n
for i in a: b[i]+=1

if b[0]!=1:
    print(0)
    exit()

ans = 1
i = 0
while i<n-1:
    if b[i]==0:
        if sum(b[i:])>0:
            print(0)
            exit()
        else:
            break
    ans *= b[i]**b[i+1]
    i += 1

print(ans%998244353)
Buggy python submission (verdict: Runtime Error):
n = int(input())
x, y = 0, 0
for i in range(1, int(n**0.5)):
        if n%i==0: x = i
y = n//x
print(x+y-2)

Fixed submission:
n = int(input())
l = int(n**0.5)
while l:
    if n%l: l-=1
    else: break
print((l-1)+(n//l-1))
Buggy python submission (verdict: Time Limit Exceeded):
def gcd(a,b):
    if a<b: a,b=b,a
    while b: a,b = b, a%b
    return a
def main():
  a, b = map(int, input().split())
  c = gcd(a, b)
  ans = 1
  i = 2
  while c!=1:
    if c%i==0: ans+=1
    while c%i==0: c//=i
    i+=1
  print(ans)
if __name__=="__main__":main()

Fixed submission:
def prefactor(x):
  ret = set()
  for i in range(2, int(x**0.5)+1):
    if x%i==0: ret.add(i)
    while x%i==0: x //= i
  if x>1: ret.add(x)
  return ret
    

a, b = map(int, input().split())
print(1+len(prefactor(a) & prefactor(b)))

Buggy python submission (verdict: Runtime Error):
  def gcd(a,b):
    if a<b: a,b=b,a
    while b: a,b = b, a%b
    return a
def main():
  a, b = map(int, input().split())
  c = gcd(a, b)
  ans = 1
  i = 2
  while c!=1:
    if c%i==0: ans+=1
    while c%i==0: c//=i
    i+=1
  print(ans)
if __name__=="__main__":main()

Fixed submission:
def prefactor(x):
  ret = set()
  for i in range(2, int(x**0.5)+1):
    if x%i==0: ret.add(i)
    while x%i==0: x //= i
  if x>1: ret.add(x)
  return ret
    

a, b = map(int, input().split())
print(1+len(prefactor(a) & prefactor(b)))

Buggy python submission (verdict: Time Limit Exceeded):
from math import log
def gcd(a,b):
    if a<b: a,b=b,a
    while b: a,b = b, a%b
    return a
a, b = map(int, input().split())
c = gcd(a, b)
ans = 1
i = 2
while c!=1:
    if c%i==0: ans+=1
    while c%i==0: c//=i
    i+=1
print(ans)

Fixed submission:
def prefactor(x):
  ret = set()
  for i in range(2, int(x**0.5)+1):
    if x%i==0: ret.add(i)
    while x%i==0: x //= i
  if x>1: ret.add(x)
  return ret
    

a, b = map(int, input().split())
print(1+len(prefactor(a) & prefactor(b)))
Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
a = list(map(int, input().split()))
for i in range(m): a.append(a.pop(a.index(max(a)))//2)
print(sum(a))

Fixed submission:
import heapq as hq
n, m = map(int, input().split())
a = []
for i in input().split(): hq.heappush(a, -int(i))
for i in range(m): hq.heappush(a, int(hq.heappop(a)/2))
print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
p = sorted(list(map(int, input().split())))
for i in range(m):
    p.append(p.pop(-1)//2)
    p.sort()
print(sum(p))

Fixed submission:
import heapq as hq
n, m = map(int, input().split())
a = []
for i in input().split(): hq.heappush(a, -int(i))
for i in range(m): hq.heappush(a, int(hq.heappop(a)/2))
print(-sum(a))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(1, n):
  if a[-i]>a[-i-1]: break
print(i-1)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
ans = 0
cnt = 0
for i in range(n-1):
  if a[i] >= a[i+1]: cnt += 1
  else:
    ans = max(ans, cnt)
    cnt = 0
print(max(cnt, ans))
Buggy python submission (verdict: Runtime Error):
n = int(input())
l = list(range(2, n+1))
l.append(1)
ans = 0
for i, m in enumerate(l): ans += (i+1)%m
print(ans)

Fixed submission:
n = int(input())
print(n*(n-1)//2)