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

Fixed submission:
import math
import sys
from collections import defaultdict

input = sys.stdin.readline
mod = 1000000007

n = int(input())

n2 = [1]
for _ in range(n):
    n2.append(n2[-1] * 2 % mod)

zero = 0
plus = defaultdict(int)
minus = defaultdict(int)

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        zero += 1
        continue
    elif a == 0:
        plus[(1, 0)] += 1
    elif b == 0:
        minus[(1, 0)] += 1
    else:
        p = math.gcd(a, b)
        a //= p
        b //= p
        if a * b > 0:
            plus[(abs(a), abs(b))] += 1
        else:
            minus[(abs(b), abs(a))] += 1

n -= zero
ans = 1

for k, v in plus.items():
    if minus[k] > 0:
        ans *= (n2[v] + n2[minus[k]] - 1)
        ans %= mod
        n -= v + minus[k]

ans *= n2[n]
ans %= mod
ans += zero - 1
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import sys
from collections import defaultdict

input = sys.stdin.readline
mod = 1000000007

n = int(input())

n2 = [1]
for _ in range(n):
    n2.append(n2[-1] * 2 % mod)

zero = 0
plus = defaultdict(int)
minus = defaultdict(int)

for _ in range(n):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        zero += 1
        continue
    p = math.gcd(a, b)
    a //= p
    b //= p
    if a * b > 0:
        plus[(abs(a), abs(b))] += 1
    else:
        minus[(abs(b), abs(a))] += 1

n -= zero

for k, v in plus.items():
    if minus[k] > 0:
        ans *= (n2[v] + n2[minus[k]] - 1)
        ans %= mod
        n -= v + minus[k]

ans *= n2[n]
ans = ans + zero - 1
ans %= mod
print(ans)

Buggy submission (verdict: Runtime Error):
import math
import sys
from collections import defaultdict

input = sys.stdin.readline
mod = 1000000007

n = int(input())

n2 = [1]
for _ in range(n):
    n2.append(n2[-1] * 2 % mod)

zero = 0
plus = defaultdict(int)
minus = defaultdict(int)

for _ in range(n):
    a, b = map(int, input().split())
    if a * b == 0:
        zero += 1
    p = math.gcd(a, b)
    a //= p
    b //= p
    if a * b > 0:
        plus[(abs(a), abs(b))] += 1
    else:
        minus[(abs(b), abs(a))] += 1


ans = zero + 1
ans %= mod
n -= zero

for k, v in plus.items():
    if minus[k] > 0:
        ans *= (n2[v] + n2[minus[k]] - 1)
        ans %= mod
        n -= v + minus[k]

ans *= n2[n]
ans %= mod
print(ans - 1)

Buggy submission (verdict: Runtime Error):
import math
import sys
from collections import defaultdict

input = sys.stdin.readline
mod = 1000000007

n = int(input())

n2 = [1]
for _ in range(n):
    n2.append(n2[-1] * 2 % mod)

zero = 0
plus = defaultdict(int)
minus = defaultdict(int)

for _ in range(n):
    a, b = map(int, input().split())
    if a * b == 0:
        zero += 1
    p = math.gcd(a, b)
    a //= p
    b //= p
    if a * b > 0:
        plus[(abs(a), abs(b))] += 1
    else:
        minus[(abs(b), abs(a))] += 1


ans = zero + 1
ans %= mod
n -= zero

for k, v in plus.items():
    if minus[k] > 0:
        ans *= (n2[v] + n2[minus[k]] - 1)
        ans %= mod
        n -= v + minus[k]

ans *= n2[n]
print(ans - 1)
Problem p03332 (python)

Fixed submission:
N, A, B, K = map(int, input().split())

mod = 998244353
fact = [1] * (N + 1)
ifact = [1] * (N + 1)


def init():
    for i in range(N):
        fact[i + 1] = fact[i] * (i + 1) % mod
        ifact[i + 1] = pow(fact[i + 1], mod - 2, mod)


def comb(x, y):
    if y < 0 or y > x:
        return 0
    return (fact[x] * ifact[x - y] * ifact[y]) % mod


ans = 0
init()
for a in range(N + 1):
    n = K - a * A
    if n < 0:
        break
    if n % B == 0:
        ans += (comb(N, a) * (comb(N, n // B))) % mod
print(ans % mod)

Buggy submission (verdict: Runtime Error):

N, A, B, K = map(int, input().split())

mod = 998244353
F = [1]
RF = []


def inv(x):
    res = 1
    k = mod - 2
    y = x
    while k:
        if k & 1:
            res = (res * y) % mod
        y = (y * y) % mod
        k //= 2
    return res


def init():
    for i in range(N):
        F.append((F[i] * (i + 1)) % mod)
    for i in F:
        RF.append(inv(i))


def comb(x, y):
    return (F[x] * ((inv(F[x - y]) * inv(F[y])) % mod)) % mod


ans = 0
init()
for a in range(N):
    b = (K - a * A) / B
    if b < 0:
        break
    if b.is_integer():
        ans += (comb(N, a) * (comb(N, int(b)))) % mod
print(ans % mod)

Buggy submission (verdict: Runtime Error):

N, A, B, K = map(int, input().split())

mod = 998244353
F = [1]
RF = []


def inv(x):
    res = 1
    k = mod - 2
    y = x
    while k:
        if k & 1:
            res = (res * y) % mod
        y = (y * y) % mod
        k //= 2
    return res


def init():
    for i in range(N):
        F.append((F[i] * (i + 1)) % mod)
    for i in F:
        RF.append(inv(i))


def comb(x, y):
    return (F[x] * ((RF[x - y] * RF[y]) % mod)) % mod


ans = 0
init()
for a in range(N):
    b = (K - a * A) / B
    if b < 0:
        break
    if b.is_integer():
        ans += (comb(N, a) * (comb(N, int(b)))) % mod
print(ans % mod)

Buggy submission (verdict: Runtime Error):

N, A, B, K = map(int, input().split())

mod = 998244353
F = [1]
RF = []


def inv(x):
    res = 1
    k = mod - 2
    y = x
    while k:
        if k & 1:
            res = (res * y) % mod
        y = (y * y) % mod
        k //= 2
    return res


def init():
    for i in range(N):
        F.append((F[i] * (i + 1)) % mod)
    for i in F:
        RF.append(inv(i))


def comb(x, y):
    return (F[x] * ((RF[x - y] * RF[y]) % mod)) % mod


ans = 0
init()
for a in range(N):
    b = (K - a * A) / B
    if b < 0:
        break
    if b.is_integer():
        ans += (comb(N, a) * (comb(N, int(b)))) % mod
print(ans % mod)
Problem p02989 (python)

Fixed submission:
a=int(input())
n=sorted(list(map(int,input().split())))
print(n[a//2]-n[a//2-1])

Buggy submission (verdict: Runtime Error):
a=int(input())
s=list(map(int,input().split()))
s.sort()
print(s[a/2]-a[a/2-1])
Problem p03315 (python)

Fixed submission:
a=0
s=input()
for i in range(4):
    if s[i]=="-":
        a-=1
    else:
        a+=1
print(a)

Buggy submission (verdict: Runtime Error):
a=0
s=input()
for i in s:
    if s[i]=='-':
        a-=1
    else:
        a+=1
print(a)
Problem p02661 (python)

Fixed submission:
n = int(input())
l = [list(map(int, input().split())) for i in range(n)]

a = sorted(l, key=lambda x:x[0])
b = sorted(l, key=lambda x:x[1])

if n % 2 == 1:
  print(b[n//2][1] - a[n//2][0] +1)
else:
  print((b[n//2][1]+b[n//2-1][1])-(a[n//2][0]+a[n//2-1][0])+1)

Buggy submission (verdict: Runtime Error):
n = int(input())
l = [list(map(int, input().split())) for i in range(n)]

a = sorted(l, key=lambda x:x[0])
b = sorted(l, key=lambda x:x[1])

if n % 2 == 1:
  print(b[n//2] - a[n//2] +1)
else:
  print((b[n//2][1] - a[n//2-1][0]+1)*(b[n//2][1] - a[n//2-1][0])//2)
Problem p02679 (python)

Fixed submission:
import math
def modpow(a, n, p):
  if n == 0:
    return 1
  if n == 1:
    return a % p 
  elif n % 2 == 1:
    return a * modpow(a, n-1, p) % p
  else:
    return modpow(a, n//2, p) **2 % p
MOD = 1000000007
n = int(input())
#初期値が0の辞書
from collections import defaultdict
pp = defaultdict(lambda: 0) 
pm = defaultdict(lambda: 0) 
def seiki(x,y):
    tmp=math.gcd(x,y)
    return (x//tmp,y//tmp)

a0b0 = 0

for i in range(n):
  a, b = map(int, input().split())

  if a == 0 and b == 0:
    a0b0 += 1
  elif a == 0:
    pp[(0,1)] += 1

  elif b == 0:
    pm[(0,1)] += 1

  elif a*b>0:
    tmp = seiki(abs(a),abs(b))
    pp[tmp] += 1

  else:
    tmp = seiki(abs(b),abs(a))
    pm[tmp] += 1

ans = 1
for key in set(pp.keys()) | set(pm.keys()):
    pp_v=pp[key]
    pm_v=pm[key]
    ans*=(modpow(2,pm_v,MOD)+modpow(2,pp_v,MOD)-1)
    ans%=MOD

ans = (ans+a0b0-1) % MOD
print(ans)

Buggy submission (verdict: Runtime Error):
def modpow(a, n, p):
  if n == 0:
    return 1
  if n == 1:
    return a % p 
  elif n % 2 == 1:
    return a * modpow(a, n-1, p) % p
  else:
    return modpow(a, n//2, p) **2 % p
MOD = 1000000007
n = input()
dct1 = {}
dct2 = {}
l = []
for i in range(n):
  a, b = map(int, input().split())
  l.append((a, b))
  if a == 0:
    dct1["a0"] = dct1.get("a0", 0) + 1
  elif b == 0:
    dct1["b0"] = dct1.get("b0", 0) + 1
  else:
    dct1[a/b] = dct1.get(a/b, 0) + 1
    dct2[-b/a] = dct2.get(-b/a, 0) + 1

count = 0
for i in range(n):
  a, b = l[i]
    l.append((a, b))
  if a == 0:
    count += modpow(2, n-1-i-dct1["b0"], MOD)
  elif b == 0:
    count += modpow(2, n-1-i-dct1["a0"], MOD)
  else:
    count += modpow(2, n-1-i-dct2[a/b], MOD)
print(count % MOD)
Problem p02685 (python)

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

def modpow(a, n, p):
  if n == 0:
    return 1
  if n == 1:
    return a % p 
  elif n % 2 == 1:
    return a * modpow(a, n-1, p) % p
  else:
    return modpow(a, n//2, p) **2 % p
dp = [0]*(k+1)
dp[0] = m* modpow(m-1, n-1, MOD) % MOD
bunsi = 1
bunbo = 1
for j in range(1, k+1):
  bunsi = bunsi * (n-j) % MOD
  bunbo = bunbo * j % MOD

  comb = bunsi * modpow(bunbo, MOD-2, MOD) % MOD
  dp[j] = (m * modpow(m-1, n-1-j, MOD)*comb % MOD + dp[j-1]) % MOD
print(dp[k])

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
MOD = 998244353

def modpow(a, n, p):
  if n == 1:
    return a % p 
  elif n % 2 == 1:
    return a * modpow(a, n-1, p) % p
  else:
    return modpow(a, n//2, p) **2 % p
dp = [0]*(k+1)
dp[0] = m* modpow(m-1, n-1, MOD) % MOD
for j in range(1, k+1):
  bunsi = 1
  for i in range(n-1-j+1, n):
    bunsi = bunsi * i % MOD

  bunbo = 1
  for i in range(1, j+1):
    bunbo = bunbo * i % MOD

  comb = bunsi * modpow(bunbo, MOD-2, MOD) % MOD
  dp[j] = (m * modpow(m-1, n-1-j, MOD)*comb % MOD + dp[j-1]) % MOD
print(dp[k])

Buggy submission (verdict: Runtime Error):
n, m, k = map(int, input().split())
MOD = 998244353

def modpow(a, n, p):
  if n == 1:
    return a % p 
  elif n % 2 == 1:
    return a * modpow(a, n-1, p) % p
  else:
    return modpow(a, n//2, p) **2 % p

bunsi = 1
for i in range(n-1-k+1, n):
  bunsi = bunsi * i % MOD

bunbo = 1
for i in range(1, k+1):
  bunbo = bunbo * i % MOD

comb = bunsi * modpow(bunbo, MOD-2, MOD) % MOD
print(m * modpow(m-1, n-1-k, MOD)*modpow(m, k, MOD)*comb % MOD)
Problem p02695 (python)

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

l = []
for i in range(q):
  a,b,c,d = map(int, input().split())
  l.append((a,b,c,d))
  
comb = itertools.combinations_with_replacement(range(1,m+1), n)

max_score = 0
for e in comb:
  score = 0
  for j in l:
    if e[j[1]-1]-e[j[0]-1]==j[2]:
      
      score += j[3]
  if score > max_score:
    max_score = score
print(max_score)

Buggy submission (verdict: Runtime Error):

n, m , q = map(int, input().split())
 
l = []
for i in range(q):
  a,b,c,d = map(int, input().split())
  l.append((a,b,c,d))
max_score = 0
comb = [[1]]
while len(comb[0]) > 0:
  seed = comb.pop()
  if len(seed) == n:
    score = 0
    for j in l:
      if seed[j[1]-1]-seed[j[0]-1]==j[2]:
      
        score += j[3]
    if score > max_score:
      max_score = score
  else:
    for k in range(seed[-1], m+1):
      comb.append(seed.copy().append(k))
print(max_score)

Buggy submission (verdict: Runtime Error):
n, m , q = map(int, input().split())
import itertools
n, m , q = map(int, input().split())

l = []
for i in range(q):
  a,b,c,d = map(int, input().split())
  l.append((a,b,c,d))
  
comb = itertools.combinations_with_replacement(range(1,m+1), n)

max_score = 0
for e in comb:
  score = 0
  for j in l:
    if e[j[1]-1]-e[j[0]-1]==j[2]:
      
      score += j[3]
  if score > max_score:
    max_score = score
print(max_score)
Problem p02707 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for i in range(n-1):
  b[a[i]-1] += 1
  
for e in b:
  print(e)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for i in range(1, n):
  b[a[i]] += 1

for e in b:
  print(e)
Problem p02729 (python)

Fixed submission:
from scipy.misc import comb
n, m = map(int, input().split())
print(comb(n,2, exact=True)+comb(m,2,exact=True))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
n, m = map(int, input().split())
print(comb(n,2, exact=True)+comb(m,2,exact=True))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
n, m = map(int, input().split())
print(comb(n,2, exact=True)+comb(m,2,exact=True))

Buggy submission (verdict: Runtime Error):
from scipy.special import comb
n, m = map(int, input().split())
print(comb(n,2, exact=True)+comb(m,2,exact=True))
Problem p02762 (python)

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

g = [[] for i in range(n+1)]
f = [0]*(n+1)
b = []
for i in range(m):
  u, v = map(int, input().split())
  g[u].append(v)
  g[v].append(u)
  f[u] += 1
  f[v] += 1
for i in range(k):
  b.append(map(int, input().split()))
count = 0
renketu_list = [-1]*(n+1)
renketu_size = [0]
stack = []
for i in range(1, n+1):
  if renketu_list[i] == -1:
    count += 1
    renketu_list[i] = count
    renketu_size.append(1)
    while len(g[i]) > 0:
      stack.append(g[i].pop())
    while len(stack) > 0:
      v=stack.pop()
      if renketu_list[v] == -1:
        renketu_list[v] = count
        renketu_size[count] += 1
        while len(g[v])>0:
          stack.append(g[v].pop())

s = [0] * (n+1)
for i in range(1, n+1):
  s[i] += renketu_size[renketu_list[i]] - f[i] - 1
  
for i in range(k):
  u, v = b[i]
  if renketu_list[u] == renketu_list[v]:
    s[u] -= 1
    s[v] -= 1

print(" ".join(list(map(str, s[1:]))))

Buggy submission (verdict: Runtime Error):
n,m,k = map(int, input().split())

g = [[] for i in range(n+1)]
f = [0]*(n+1)
b = []
for i in range(m):
  u, v = map(int, input().split())
  g[u].append(v)
  g[v].append(u)
  f[u] += 1
  f[v] += 1
for i in range(k):
  b.append(map(int, input().split()))

count = 0
renketu_list = [-1]*(n+1)
renketu_size = [0]
stack = []
for i in range(1, n+1):
  if renketu_list[i] == -1:
    count += 1
    renketu_list[i] = count
    renketu_size.append(1)
    while len(g[i]) > 0:
      stack.append(g[i].pop())
    while len(stack) > 0:
      u,v=stack.pop()
      if renketu_list[v] == -1:
        renketu_list[v] = count
        renketu_size[count] += 1
        while len(g[v])>0:
          stack.append(g[v].pop())

s = [0] * (n+1)
for i in range(1, n):
  s[i] += renketu_size[renketu_list[i]] + f[i]
  
for i in range(k):
  u, v = b[i]
  if renketu_list[u] == renketu_list[v]:
    s[u] -= 1
    s[v] -= 1

print(" ".join(list(map(str, s))))
Problem p02792 (python)

Fixed submission:
n = int(input())

mat = [[0]*10 for i in range(10)]

for i in range(n+1):
  if i % 10 != 0:
    str_i = str(i)
    mat[int(str_i[0])][int(str_i[-1])] += 1
c = 0
for y in range(1, 10):
  for x in range(y, 10):
    if y == x:
      c += mat[y][x] * mat[x][y]
    else:
      c += mat[y][x] * mat[x][y] * 2
print(c)

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

mat = [[0]*10 for i in range(10)]

for i in range(n+1):
  if i % 10 != 0:
    str_i = str(i)
    mat[str_i[0]][str_i[-1]] += 1
c = 0
for y in range(1, 10):
  for x in range(y, 10):
    c += mat[y][x] * mat[x][y]
print(c)
Problem p02819 (python)

Fixed submission:
import math
def is_sosu(n):
  for i in range(2, math.floor(math.sqrt(n))+1):
    if n % i == 0:
      return False
  return True

x = int(input())
for i in range(x, x*2):
  if is_sosu(i):
    print(i)
    exit()

Buggy submission (verdict: Runtime Error):
import math
def is_sosu(n):
  for i in range(2, math.sqrt(n)//1+1):
    if n % i == 0:
      return False
  return True

x = int(input())
for i in range(x, x*2):
  if is_sosu(i):
    print(i)
    exit()
Problem p02831 (python)

Fixed submission:
a,b=map(int,input().split())
import fractions
print(a*b//fractions.gcd(a,b))

Buggy submission (verdict: Runtime Error):
a,b=map(int,input().split())
import math
print(a*b//math.gcd(a,b))
Problem p02836 (python)

Fixed submission:
s = input()
count = 0
for i in range(len(s)):
  if s[i] != s[len(s)-1-i]:
    count += 1
print(count//2)

Buggy submission (verdict: Runtime Error):
s = input()
count = 0
for i in range(len(s)):
  if s[i] != s[len(n)-1-i]:
    count += 1
print(count//2)
Problem p02862 (python)

Fixed submission:
from scipy.misc import comb
def modpow(a, n, p):
  if n == 1:
    return a % p 
  elif n % 2 == 1:
    return a * modpow(a, n-1, p) % p
  else:
    return modpow(a, n//2, p) **2 % p
x, y = map(int, input().split())
t = (2*y-x)/3
s = (2*x-y)/3
if not t.is_integer() or t<0 or not s.is_integer() or s<0:
  print(0)
else:
  t = int(t)
  s = int(s)
  bunsi = 1
  for i in range(s+t-s+1, s+t+1):
    bunsi = bunsi * i % 1000000007
  bunbo = 1
  for i in range(1, s+1):
    bunbo = bunbo * i % 1000000007
  ans = bunsi * modpow(bunbo, 1000000007-2, 1000000007) % 1000000007
  print(ans)

Buggy submission (verdict: Runtime Error):
from scipy.misc import comb
x, y = map(int, input().split())
t = (2*y-x)/3
s = (2*x-y)/3
if not t.is_integer() or t<0 or not s.is_integer() or s<0:
  print(0)
else:
  print(int(comb(s+t, min(s, t))%1000000007))
Problem p02912 (python)

Fixed submission:
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a) 

for i in range(m):
  max_ = -heapq.heappop(a)
  d = max_ // 2
  heapq.heappush(a, -d)

c = 0
for i in range(len(a)):
  c -= heapq.heappop(a)
print(c)

Buggy submission (verdict: Runtime Error):
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a) 

for i in range(m):
  max_ = a.heappop()
  d = max_ // 2
  a.heappush(d)

print(sum(a))

c = 0
for i in range(len(a)):
  c += a.heappop()
print(c)

Buggy submission (verdict: Runtime Error):
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x)*(-1), input().split()))
heapq.heapify(a) 

for i in range(m):
  max_ = a.heappop()
  d = max_ // 2
  a.heappush(d)

print(sum(a))
Problem p02916 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
s = 0
for i in range(n):
  s += b[a[i]-1]
  if 0 < i  and a[i] == a[i-1]+1:
    s += c[a[i-1]-1]

print(s)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
s = 0
for i in range(n):
  s += b[a[i]]
  if i < n-1 and a[i+1] == a[i]+1:
    s += c[i]

print(s)
Problem p02925 (python)

Fixed submission:
n = int(input())
table = [[] for _ in range(n+1)]
for i in range(1, n+1):
  a = list(map(int, input().split()))
  table[i] = a
cursor = [0]*(n+1)
is_matched = set()
d = 0
match = 0
while match < n * (n-1) //2:
  now_match = match
  for i in range(1, n):
    if cursor[i] < n-1 and i not in is_matched:
      j = table[i][cursor[i]]
      if i < j and j not in is_matched and table[j][cursor[j]] == i :
        match += 1
        cursor[i] += 1
        is_matched.add(i)
        cursor[j] += 1
        is_matched.add(j)
  if now_match == match:
    print(-1)
    exit()
  if d > 30000:
    print(499500)
    exit()  
  d += 1
  is_matched.clear()
print(d)

Buggy submission (verdict: Runtime Error):
n = int(input())
table = []
for i in range(n):
  a = list(map(int, input().split()))
  table.append(a)
cursor = [0]*(n+1)
is_matched = [False] * (n+1)
d = 0
match = 0
while match < n * (n-1) //2:
  for i in range(1, n+1):
    for j in range(i+1, n+1):
      if table[i][cursor[i]] == j and not is_matched[i] and table[j][cursor[j]] == i and not is_matched[j]:
        match += 1
        cursor[i] += 1 
        is_matched[i] = True
        cursor[j] += 1
        is_matched[j] = True
      
  d += 1
  is_matched =  [False] * (n+1)
print(d)
Problem p02948 (python)

Fixed submission:
import heapq
n,m=map(int, input().split())
lst = []
for i in range(n):
  a,b=map(int, input().split())
  lst.append((-b,a))
lst = sorted(lst, key=lambda x:x[1])

now_idx = 0
queue = []
sum_ = 0
for i in range(1,m+1):
  for j in range(now_idx, n):
    if lst[j][1] <= i:
      heapq.heappush(queue, lst[j])
    else:
      now_idx = j
      break
  else:
    now_idx = n
  if len(queue)>0:
    sum_ -= heapq.heappop(queue)[0]
print(sum_)

Buggy submission (verdict: Runtime Error):
import heapq
n,m=map(int, input().split())
lst = []
for i in range(n):
  a,b=map(int, input().split())
  lst.append((-b,a))
lst = sorted(lst, key=lambda x:x[1])

now_idx = 0
queue = []
sum_ = 0
for i in range(1,m):
  for j in range(now_idx, n):
    if lst[j][1] <= i:
      heapq.heappush(queue, lst[j])
    else:
      now_idx = j
      break
  sum_ -= heapq.heappop(queue)
print(sum_)
Problem p02984 (python)

Fixed submission:
n = int(input())
a = list(map(int, input().split()))
x = [0] * n
x[0] += a[0]
for i in range(1, n, 2):
  x[0] += - a[i] + a[i+1]

for i in range(1, n):
  x[i] = -x[i-1] + 2*a[i-1]
  
o = " ".join(map(str, x))
print(o)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
x = [0] * n
x[0] += a[0]
for i in range(1, n, 2):
  x[0] += - a[i] + a[i+1]

for i in range(1, n):
  x[i] = -x[i-1] + 2*a[i-1]
  
o = " ".join(x)
print(o)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))
x = [0] * n
x[0] += a[0]
for i in range(1, n, 2):
  x[0] - a[i] + a[i+1]

for i in range(1, n):
  x[i] = -x[i-1] + 2*a[i-1]
  
o = " ".join(x)
print(o)
Problem p02987 (python)

Fixed submission:
s = input()
d = {}
for e in s:
  if e in d:
    d[e] += 1
  else:
    d[e] = 1

if len(d) == 2 and set(d.values()) == {2}:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
s = input()
d = {}
for e in s:
  if e in d:
    d[e] += 1
  else:
    d[e] = 1

if len(d) == 2 and set(d.values()) = {2}:
  print("Yes")
else:
  print("No")
Problem p03015 (python)

Fixed submission:
l = input()
dp1 = [0] * (len(l)+1)
dp2 = [0] * (len(l)+1)
 
dp1[1] = 1
dp2[1] = 2
if l == '1':
  print(3)
  exit()
for i in range(1, len(l)):
  if l[i] == '0':
    dp1[i+1] = 3 * dp1[i]
    dp1[i+1] %= 1000000007
    dp2[i+1] = dp2[i]
  else:
    dp1[i+1] = 3 * dp1[i] + dp2[i]
    dp1[i+1] %= 1000000007
    dp2[i+1] = 2 * dp2[i]
    dp2[i+1] %= 1000000007
print((dp1[len(l)] + dp2[len(l)]) % 1000000007)

Buggy submission (verdict: Runtime Error):
l = input()
dp1 = [0] * (len(l)+1)
dp2 = [0] * (len(l)+1)
 
dp1[1] = 1
dp2[1] = 2
if l == '1':
  print(3)
  exit()
for i in range(1, len(l)):
  if l[i] == '0':
  	dp1[i+1] = 3 * dp1[i] + 1 * dp2[i]
    dp1[i+1] %= 1000000007
  	dp2[i+1] = dp2[i]
  else:
    dp1[i+1] = 3 * dp1[i] + 3 * dp2[i]
    dp1[i+1] %= 1000000007
    dp2[i+1] = 3 * dp2[i]
    dp2[i+1] %= 1000000007
print(dp1[len(l)] % 1000000007)

Buggy submission (verdict: Runtime Error):
l = input()
dp1 = [0] * (len(l)+1)
dp2 = [0] * (len(l)+1)

dp1[1] = 1
dp2[1] = 2
if l == '1':
  print(3)
  exit()
for i in range(1, len(l)):
  if l[i] == '0':
  	dp1[i+1] = 3 * dp1[i] + 1 * dp2[i]
    dp1[i+1] %= 1000000007
  	dp2[i+1] = dp2[i]
  else:
    dp1[i+1] = 3 * dp1[i] + 3 * dp2[i]
    dp1[i+1] %= 1000000007
    dp2[i+1] = 3 * dp2[i]
    dp2[i+1] %= 1000000007

print(dp1[len(l)] % 1000000007)