Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
S = input()

if len(set(S)) == 26:
  print("None")
else:
  for dam in ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]:
    if not dam in list(set(S)):
           break
print(dam)

Fixed submission:
S = input()

if len(set(S)) == 26:
  print("None")
else:
  for dam in ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]:
    if not dam in list(set(S)):
           break
  print(dam)
Buggy python submission (verdict: Runtime Error):
N, M = [int(i) for i in input().split(" ")]

for i in range(0,N):
	lst.append(input().split(" "))

for i in range(1,N+1):
	print(lst.count(i)

Fixed submission:
N, M = [int(i) for i in input().split(" ")]
lst = []

for i in range(0,M):
	lst.extend(input().split(" "))
for i in range(1,N+1):
	print(lst.count("{}".format(i)))

Buggy python submission (verdict: Runtime Error):
N, M = [int(i) for i in input().split(" ")]

for i in range(0,N)
	lst.append(input().split(" "))

for i in range(1,N+1)
	print(lst.count(i))

Fixed submission:
N, M = [int(i) for i in input().split(" ")]
lst = []

for i in range(0,M):
	lst.extend(input().split(" "))
for i in range(1,N+1):
	print(lst.count("{}".format(i)))
Buggy python submission (verdict: Runtime Error):
s = list(input())
print(len(s[s.index("A"):s.index("Z",-1)]+1))

Fixed submission:
s= input()
print(s.rindex("Z")-s.index("A")+1)
Buggy python submission (verdict: Time Limit Exceeded):
K, S = [int(n) for n in input().split(" ")]
 
cnt = 0
 
for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x+y+z == S:
        cnt +=1
 
print(cnt)

Fixed submission:
K, S = [int(n) for n in input().split(" ")]
 
cnt = 0
 
for x in range(K+1):
  for y in range(K+1):
      if S-x-y <= K and S-x-y >= 0:
            
        cnt +=1
 
print(cnt)

Buggy python submission (verdict: Runtime Error):
K, S = int(input().split(" "))

cnt = 0

for x in range(K+1):
  for y in range(K+1):
    for z in range(K+1):
      if x+y+z == S:
        cnt +=1

print(cnt)

Fixed submission:
K, S = [int(n) for n in input().split(" ")]
 
cnt = 0
 
for x in range(K+1):
  for y in range(K+1):
      if S-x-y <= K and S-x-y >= 0:
            
        cnt +=1
 
print(cnt)
Buggy python submission (verdict: Runtime Error):
S = input()

if S.replace("dream"," ").replace("dreamer"," ").replace("erase"," ").replace("eraser"," "):
  print("NO")
else:
  print("YES


Fixed submission:
S = input()

if S.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream",""):
  print("NO")
else:
  print("YES")

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

if S.replace("dream"," ").replace("dreamer"," ").replace.("erase"," ").replace("eraser"," "):
  print("YES")
else:
  print("NO")


Fixed submission:
S = input()

if S.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream",""):
  print("NO")
else:
  print("YES")

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

if S.replace("dream",).replace("dreamer",).replace.("erase",).replace("eraser",):
  print("NO")
else:
  print("YES")

Fixed submission:
S = input()

if S.replace("eraser","").replace("erase","").replace("dreamer","").replace("dream",""):
  print("NO")
else:
  print("YES")
Buggy python submission (verdict: Runtime Error):
W, H, N = [int(i) for i in input().split(" ")]

a1 = [0,0]
a2 = [W,0]
a3 = [0,0]
a4 = [0,H]

for i in range(0,N):
  lst = [int(i) for i in input().split(" ")]
  if lst[2] == 1:
    a1[0] = max(a1[0],lst[0])
  elif lst[2] == 2:
    a2[0] = max(a2[0],lst[0])
  elif lst[2] == 3:
    a3[1] = max(a3[1],lst[1])
  elif lst[2] == 4:
    a4[1] = max(a4[1],lst[1])

print(max(0,a2[0]-a1[0])*max(0,(a4[1]-a3[1]))


Fixed submission:
W, H, N = [int(i) for i in input().split(" ")]

a1 = [0,0]
a2 = [W,0]
a3 = [0,0]
a4 = [0,H]

for i in range(0,N):
  lst = [int(i) for i in input().split(" ")]
  if lst[2] == 1 and lst[0] > a1[0]:
    a1[0] = lst[0]
  elif lst[2] == 2 and lst[0] < a2[0]:
    a2[0] = lst[0]
  elif lst[2] == 3 and lst[1] > a3[1]:
    a3[1] = lst[1]
  elif lst[2] == 4 and lst[1] < a4[1]:
    a4[1] = lst[1]

if (a2[0]-a1[0])<0 or (a4[1]-a3[1])<0:
    print(0)
else:
    print((a2[0]-a1[0])*(a4[1]-a3[1]))

Buggy python submission (verdict: Runtime Error):
W, H, N = [int(i) for i in input().split(" ")]

a1 = [0,0]
a2 = [W,0]
a3 = [0,0]
a4 = [0,H]

for i in range(0,N):
  lst = [int(i) for i in input().split(" ")]
  if lst[2] == 1:
    a1[0] = max(a1[0],lst[0])
  elif lst[2] == 2:
    a2[0] = max(a2[0],lst[0])
  elif lst[2] == 3:
    a3[1] = max(a3[1],lst[1])
  elif lst[2] == 4:
    a4[1] = max(a4[1]1,lst[1])

print(max(0,a2[0]-a1[0])*max(0,(a4[1]-a3[1]))


Fixed submission:
W, H, N = [int(i) for i in input().split(" ")]

a1 = [0,0]
a2 = [W,0]
a3 = [0,0]
a4 = [0,H]

for i in range(0,N):
  lst = [int(i) for i in input().split(" ")]
  if lst[2] == 1 and lst[0] > a1[0]:
    a1[0] = lst[0]
  elif lst[2] == 2 and lst[0] < a2[0]:
    a2[0] = lst[0]
  elif lst[2] == 3 and lst[1] > a3[1]:
    a3[1] = lst[1]
  elif lst[2] == 4 and lst[1] < a4[1]:
    a4[1] = lst[1]

if (a2[0]-a1[0])<0 or (a4[1]-a3[1])<0:
    print(0)
else:
    print((a2[0]-a1[0])*(a4[1]-a3[1]))

Buggy python submission (verdict: Runtime Error):
W, H, N = [int(i) for i in input().split(" ")]

a1 = [0,0]
a2 = [W,0]
a3 = [0,0]
a4 = [0,H]

for i in range(0,N):
  lst = [int(i) for i in input().split(" ")]
  if lst[2] == 1:
    a1[0] = max(a1[0],lst[0])
  elif lst[2] == 2:
    a2[0] = max(a2[0],lst[0])
  elif lst[2] == 3:
    a3[1] = max(a3[1],lst[1])
  elif lst[2] == 4:
    a4[1] = max(a4[]1,lst[1])

print(max(0,a2[0]-a1[0])*max(0,(a4[1]-a3[1]))


Fixed submission:
W, H, N = [int(i) for i in input().split(" ")]

a1 = [0,0]
a2 = [W,0]
a3 = [0,0]
a4 = [0,H]

for i in range(0,N):
  lst = [int(i) for i in input().split(" ")]
  if lst[2] == 1 and lst[0] > a1[0]:
    a1[0] = lst[0]
  elif lst[2] == 2 and lst[0] < a2[0]:
    a2[0] = lst[0]
  elif lst[2] == 3 and lst[1] > a3[1]:
    a3[1] = lst[1]
  elif lst[2] == 4 and lst[1] < a4[1]:
    a4[1] = lst[1]

if (a2[0]-a1[0])<0 or (a4[1]-a3[1])<0:
    print(0)
else:
    print((a2[0]-a1[0])*(a4[1]-a3[1]))
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/env python3
# coding: utf-8
"""
about module
"""

def main():
    n, k = map(int, input().split())

    while n*2 > k:
        n = abs(n-k)
    return n

if __name__ == '__main__':
    print(main())


Fixed submission:
#!/usr/bin/env python3
# coding: utf-8
"""
about module
"""


def main():
    n, k = map(int, input().split())
    if n > k:
        n = n % k

    while n * 2 > k:
        n = abs(n - k)
    return n


if __name__ == '__main__':
    print(main())
Buggy python submission (verdict: Runtime Error):
# GCD on Blackboard
"""
リストのどの要素を抜いた時に最大公約数が最大値をとるか調べて、
その時の最大公約数を出力する。
"""

from functools import reduce

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


def get_gcd(a, b):
    """
    ユークリッド互除法により最大公約数を求める。
    """
    if a < b:
        a, b = b, a

    elif a % b == 0:
        return b

    return get_gcd(b, a % b)


def get_gcd_l(l):
    """
    リストの要素の最大公約数を求める。
    """
    return reduce(get_gcd, l)


def answer(l):
    """
    どの要素を抜いた時に最大公約数が最大値をとるか調べる。
    """
    len_l = len(l)
    answers = []  # 答えの案

    for i in range(len_l): # 要素を1個ずつ消してみる。
        temp_l = []
        temp_l += l[0 : i]
        temp_l += l[i+1 : len_l]
        answers.append(get_gcd_l(temp_l))
    ans = max(answers)
    return ans


def main():
    """
    答えを出力する。
    """
    print(answer(A))


if __name__ == '__main__':
    main()


Fixed submission:
#Biscuit Generator

A, B, T = map(int, input().split())

def answer():
    ans = T // A * B
    return ans

def main():
    print(answer())


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
# abc061_c
"""
Big Array
"""

test = False

def answer():
    """
    答えを出力する関数
    """
    l_1 = []
    l_2 = []
    N, K = map(int, input().split())

    for _ in range(N):
        l_1.append(list(map(int, input().split())))


    l_1.sort()
    if test:
        print(l_1)

    for v in l_1:
        l_2.extend([v[0]] * v[1])

    # 小さい順にソートして、K-1番目の要素を出力
    if test:
        print(l_2)
    print(l_2[K-1])


def main():
    """
    処理を実行する関数
    """
    answer()


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/python3
# abc061_c
"""
Big Array
"""

def answer():
    """
    答えを出力する関数
    """
    l = []
    N, K = map(int, input().split())
    counter = 0

    for _ in range(N):
        l.append(list(map(int, input().split())))

    l.sort()
    for v in l:
        counter += v[1]
        if counter >= K:
            print(v[0])
            break

def main():
    """
    処理を実行する関数
    """
    answer()


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin/python3
# abc061_c
"""
Big Array
"""

def answer():
    """
    答えを出力する関数
    """
    l = []
    N, K = map(int, input().split())

    for _ in range(N):
        a, b = map(int, input().split())
        l += [a] * b

    # 小さい順にソートして、K-1番目の要素を出力
    l.sort()
    print(l[K-1])


def main():
    """
    処理を実行する関数
    """
    answer()


if __name__ == '__main__':
    main()


Fixed submission:
#!/usr/bin/python3
# abc061_c
"""
Big Array
"""

def answer():
    """
    答えを出力する関数
    """
    l = []
    N, K = map(int, input().split())
    counter = 0

    for _ in range(N):
        l.append(list(map(int, input().split())))

    l.sort()
    for v in l:
        counter += v[1]
        if counter >= K:
            print(v[0])
            break

def main():
    """
    処理を実行する関数
    """
    answer()


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#! /usr/bin/python3
# Factors of Factorial

"""
1≦N≦103
"""

import math
import sympy

test = False

N = int(input())


def yakusu_no_kosu(n):
    """
    n! の約数の個数
    """
    d = sympy.factorint(math.factorial(n))
    # n!を素因数分解 {素因数1: 個数, 素因数2: 個数, …}
    l_d = list(d.values())
    # 各素因数(key)の個数(value)のみリストにする

    if test:
        print('l_d =', l_d)

    kosu = 1
    # 約数の数

    for v in l_d:
        kosu *= v + 1
    # 各素因数(key)の個数v(value)から約数の個数を算出

    return kosu


def main():
    """
    N! の約数の個数を 10^9+7 で割った余りを出力
    """
    print(yakusu_no_kosu(N) % (10**9 + 7))


if __name__ == '__main__':
    main()


Fixed submission:
#! /usr/bin/python3
# Factors of Factorial

"""
1≦N≦103
"""

import math
import collections
# import sympy

test = False

N = int(input())


def prime_factors(n):
    """
    自然数 n の素因数のリスト
    """
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            # n = n // i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors


def yakusu_no_kosu(n):
    """
    n! の約数の個数
    """

    l = prime_factors(math.factorial(n))
    c = collections.Counter(l)
    l_c = list(c.values())
    if test:
        print('l =', l)
        print('c =', c)
        print('l_c =', l_c)


    kosu = 1
    # 約数の数
    for v in l_c:
        kosu *= v + 1
    # 各素因数(key)の個数v(value)から約数の個数を算出

    """
    d = sympy.factorint(math.factorial(n))
    # n!を素因数分解 {素因数1: 個数, 素因数2: 個数, …}
    l_d = list(d.values())
    # 各素因数(key)の個数(value)のみリストにする

    if test:
        print('l_d =', l_d)

    kosu = 1
    # 約数の数

    for v in l_d:
        kosu *= v + 1
    # 各素因数(key)の個数v(value)から約数の個数を算出
    """

    return kosu


def main():
    """
    N! の約数の個数を 10^9+7 で割った余りを出力
    """
    print(yakusu_no_kosu(N) % (10**9 + 7))


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
#! /usr/bin/python3
# Between a and b ...

"""
非負の整数 a, b (a≤b) と、正の整数 x が与えられます。
a 以上 b 以下の整数のうち、x で割り切れるものの個数を求めてください。
"""

test_mode = False

a, b, x = map(int, input().split())
counter = 0
limit = b // x

for n in range(1, limit+1):
    if a <= x*n <= b:
        counter += 1

print(counter)


Fixed submission:
#! /usr/bin/python3
# AtCoder *** Contest

_, s, _ = map(str, input().split())

print('A{}C'.format(s[0]))
Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/python3
# Between a and b ...

"""
非負の整数 a, b (a≤b) と、正の整数 x が与えられます。
a 以上 b 以下の整数のうち、x で割り切れるものの個数を求めてください。
"""

test_mode = False

a, b, x = map(int, input().split())
counter = 0

for num in range(a, b+1):
    if num % x == 0:
        counter += 1
        if test_mode:
            print(num, num%x == 0, counter)

print(counter)


Fixed submission:
#! /usr/bin/python3
# Between a and b ...

"""
非負の整数 a, b (a≤b) と、正の整数 x が与えられます。
a 以上 b 以下の整数のうち、x で割り切れるものの個数を求めてください。
"""

test_mode = False

a, b, x = map(int, input().split())

if a%x != 0:
    limit_min = a//x +1
else:
    limit_min = a//x

limit_max = b//x


ans = limit_max - limit_min + 1

print(ans)
Buggy python submission (verdict: Runtime Error):
from scipy.special import comb

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

print(comb(M, 2, exact=True) + comb(N, 2, exact=True))


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

ans = 0
if N > 1:
    ans += int(N*(N-1)/2)
if M > 1:
    ans += int(M*(M-1)/2)
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math

mod = 10**9+7
N,M,K = map(int, input().split())
MAX = min(N*M,mod)

facts = [1 for i in range(MAX)]
invs = [1 for i in range(MAX)]

def inv(x):
	return pow(x,mod-2,mod)

for i in range(1,MAX):
    facts[i] = (facts[i-1] * i)% mod
    invs[i] = inv(facts[i])

def nCr(n,r):
	return facts[n] * invs[r] * invs[n-r] % mod

def main():
    ans = 0
    complement = nCr((N*M-2)%mod,(K-2)%mod)
    for i in range(N-1):
        for j in range(i+1,N):
            d = abs(i - j)
            ans += d * M**2
    for i in range(M-1):
        for j in range(i+1,M):
            d = abs(i - j)
            ans += d * N**2
    print((ans*complement) % mod)

main()


Fixed submission:
import math

mod = 10**9+7
N,M,K = map(int, input().split())
MAX = min(N*M,mod)

facts = [1 for i in range(MAX)]
invs = [1 for i in range(MAX)]

def inv(x):
	return pow(x,mod-2,mod)

for i in range(1,MAX):
    facts[i] = (facts[i-1] * i)% mod
    invs[i] = inv(facts[i])

def nCr(n,r):
	return facts[n] * invs[r] * invs[n-r] % mod

def main():
    ans = 0
    complement = nCr((N*M-2)%mod,(K-2)%mod)
    for i in range(1,N):
        ans += i * (N-i) * M**2
    for i in range(1,M):
        ans += i * (M-i) * N**2
    print((ans*complement) % mod)

main()

Buggy python submission (verdict: Time Limit Exceeded):
import math

def cmb(n,r):
    if r == 0:
        return 1
    return math.factorial(n) // math.factorial(n-r) // math.factorial(r)

def main():
    N,M,K = map(int, input().split())
    ans = 0
    complement = cmb(N*M-2,K-2)
    for i in range(N-1):
        for j in range(i+1,N):
            d = abs(i - j)
            ans += d * M**2
    for i in range(M-1):
        for j in range(i+1,M):
            d = abs(i - j)
            ans += d * N**2
    print((ans*complement) % 1000000007)

main()


Fixed submission:
import math

mod = 10**9+7
N,M,K = map(int, input().split())
MAX = min(N*M,mod)

facts = [1 for i in range(MAX)]
invs = [1 for i in range(MAX)]

def inv(x):
	return pow(x,mod-2,mod)

for i in range(1,MAX):
    facts[i] = (facts[i-1] * i)% mod
    invs[i] = inv(facts[i])

def nCr(n,r):
	return facts[n] * invs[r] * invs[n-r] % mod

def main():
    ans = 0
    complement = nCr((N*M-2)%mod,(K-2)%mod)
    for i in range(1,N):
        ans += i * (N-i) * M**2
    for i in range(1,M):
        ans += i * (M-i) * N**2
    print((ans*complement) % mod)

main()
Buggy python submission (verdict: Time Limit Exceeded):
import sys

def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

def lcm(a, b):
    return (a * b) // gcd(a, b)

def cmp(x, y, l):
	if len(x) < len(y):
		x, y = y, x
	lx = int(l/len(x))
	ly = int(l/len(y))
	for i in range(l):
		if i%lx == 0 and i%ly == 0 and x[int(i/lx)] != y[int(i/ly)]:
			return False
	return True

if __name__ == '__main__':
	N, M = list(map(int, input().split()))
	S = input()
	T = input()
	L = lcm(N,M)
	if not cmp(S,T,L):
		print(-1)
	else:
		print(L)


Fixed submission:
def gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return gcd(b, c)

def lcm(a, b):
    return (a * b) // gcd(a, b)

def cmp(x, y, l):
	if len(x) < len(y):
		x, y = y, x
	lx = int(l/len(x))
	ly = int(l/len(y))
	lc = lcm(lx,ly)
	lt = [i*lc for i in range(int(l/lc))]
	for i in lt:
		if i%lc == 0 and x[int(i/lx)] != y[int(i/ly)]:
			return False
	return True

def cmp2(x, y, l):
	if len(x) < len(y):
		x, y = y, x
	lx = int(l/len(x))
	ly = int(l/len(y))
	for i in range(l):
		if i%lx == 0 and i%ly == 0 and x[int(i/lx)] != y[int(i/ly)]:
			return False
	return True


if __name__ == '__main__':
	N, M = list(map(int, input().split()))
	S = input()
	T = input()
	L = lcm(N,M)
	if not cmp(S,T,L):
		print(-1)
	else:
		print(L)
Buggy python submission (verdict: Runtime Error):
N, M = list(map(int,input().split()))
 
d = int(M/N)
 
if M%N == 0:
	print(d)
else: 
    ans = 1
    for i in range(m//n+1, 0, -1):
        if m % i == 0:
            if (m // i) >= n:
                print(i)
                break
	# i = 0
	# while True:
	# 	if M%(N+i+1) == 0:
	# 		print(int(M/(N+i+1)))
	# 		break
	# 	i += 1

Fixed submission:
n = int(input())

if n == 1:
	print('Hello World')
else:
	A = int(input())
	B = int(input())
	print(A + B)
Buggy python submission (verdict: Runtime Error):
import sys

n = input()

if n[0] == '9':
	m = ''.join(['9']*len(n))
	if int(n) > int(m):
		print(''.join(['1']*(len(n)+1)))
		sys.exit()
	else:
		print(m)
		sys.exit()
else:
	s = n[0]
	m = ''.join([s]*len(n))
	if int(n) > int(m):
		print(''.join([s+1]*len(n)))
		sys.exit()
	else:
		print(m)
		sys.exit()




Fixed submission:
import sys

n = input()

if n[0] == '9':
	m = ''.join(['9']*len(n))
	if int(n) > int(m):
		print(''.join(['1']*(len(n)+1)))
		sys.exit()
	else:
		print(m)
		sys.exit()
else:
	s = n[0]
	m = ''.join([s]*len(n))
	if int(n) > int(m):
		print(''.join([str(int(s)+1)]*len(n)))
		sys.exit()
	else:
		print(m)
		sys.exit()
Buggy python submission (verdict: Runtime Error):
order = list(raw_input())
price = 700
for x in order:
	if x == 'o':
		price = price + 100
print(price)


Fixed submission:
order = input()
order = list(order)
price = 700
for x in order:
	if x == 'o':
		price = price + 100
print(price)
Buggy python submission (verdict: Runtime Error):
import math

d = list(map(int,input().split(' ')))
N = d[0]
X = d[1]
min_m = 0

n = int(input())
for i in range(n):
	mi = input()
	X = X - mi
	if min_m == 0 or min_m > mi:
		min_m = mi

print(N + math.floor(X/mi))

Fixed submission:
import math

d = list(map(int,input().split(' ')))
N = d[0]
X = d[1]
min_m = 0

for i in range(N):
	mi = int(input())
	X = X - mi
	if min_m == 0 or min_m > mi:
		min_m = mi

print(N + math.floor(X/min_m))

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

d = input()
m = []
itr = 0
cnt = 0
N = 0
X = 0
min_m = 0
for i in range(d):
	if itr == 0:
		e = input().split()
		N = e[0]
		X = e[1]
	else:
		X = X - input()
		mi = input()
		if min_m == 0 or min_m > mi
			min_m = mi
	itr = itr + 1
print(N + math.floor(X/mi))

Fixed submission:
import math

d = list(map(int,input().split(' ')))
N = d[0]
X = d[1]
min_m = 0

for i in range(N):
	mi = int(input())
	X = X - mi
	if min_m == 0 or min_m > mi:
		min_m = mi

print(N + math.floor(X/min_m))
Buggy python submission (verdict: Runtime Error):
from sys import exit

N,M = map(int, input().split())
S = [0]*M
C = [0]*M
for i in range(M):
    S[i],C[i] = map(int,input().split())

k = [-1]*N
for i in range(M):
    s,c = S[i],C[i]
    if k[s-1]==-1:
        k[s-1] = c
    else:
        if k[s-1]!=c:
            print(-1)
            exit()

ans = [0]*N
for i in range(N):
    if k[i]==-1:
        ans[i] = 0
    else:
        ans[i] = k[i]


if N==1:
    if mask[0]==1:
        print(ans[0])
    else:
        print(-1)
    exit()

if ans[0]==0:
    print(-1)
    exit()

print(*ans,sep='')

Fixed submission:
from sys import exit

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

S = [0]*M
C = [0]*M
for i in range(M):
    S[i],C[i] = map(int,input().split())

k = [-1]*N
for i in range(M):
    s,c = S[i],C[i]
    if k[s-1]==-1:
        k[s-1] = c
    else:
        if k[s-1]!=c:
            print(-1)
            exit()

ans = [0]*N
for i in range(N):
    if k[i]==-1:
        ans[i] = 0
    else:
        ans[i] = k[i]


if N==1:
    print(ans[0])
    exit()

if ans[0]==0:
    f=True
    for i,j in zip(S,C):
        if i==1 and j==0:
            f = False
            break
    if f:
        ans[0] = 1
    else:
        print(-1)
        exit()

print(*ans,sep='')
Buggy python submission (verdict: Time Limit Exceeded):
class UnionFind():
	def __init__(self, N):
		self.N = N # データ数
		self.d = [-1]*N # 親の番号，根の場合は，-(集合の要素数)

	def find(self, x):
		if self.d[x]<0:
			return x
		else:
			self.d[x] = self.find(self.d[x])
			return self.d[x]

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x==y: return False
		if self.d[x] > self.d[y]: x,y = y,x
		self.d[x] += self.d[y]
		self.d[y] = x
		return True

	def same(self, x, y):
		return self.find(x)==self.find(y)

	def size(self, x):
		return -self.d[self.find(x)]


n,m,k = map(int, input().split())
uf = UnionFind(n)
G_friend = [[] for i in range(n)]
for i in range(m):
    a,b = map(lambda x: int(x)-1, input().split())
    G_friend[a].append(b)
    G_friend[b].append(a)
    uf.union(a,b)

num_block = [0]*n
for i in range(k):
    a,b = map(lambda x: int(x)-1, input().split())
    if uf.same(a,b) and b not in G_friend[a]:
        num_block[a] += 1
        num_block[b] += 1

ans = [0]*n
for i in range(n):
    ans[i] = uf.size(i) - len(G_friend[i]) - 1 - num_block[i]
print(*ans)

Fixed submission:
class UnionFind():
	def __init__(self, N):
		self.N = N # データ数
		self.d = [-1]*N # 親の番号，根の場合は，-(集合の要素数)

	def find(self, x):
		if self.d[x]<0:
			return x
		else:
			self.d[x] = self.find(self.d[x])
			return self.d[x]

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)
		if x==y: return False
		if self.d[x] > self.d[y]: x,y = y,x
		self.d[x] += self.d[y]
		self.d[y] = x
		return True

	def same(self, x, y):
		return self.find(x)==self.find(y)

	def size(self, x):
		return -self.d[self.find(x)]


n,m,k = map(int, input().split())
uf = UnionFind(n)
G_friend = [[] for i in range(n)]
for i in range(m):
    a,b = map(lambda x: int(x)-1, input().split())
    G_friend[a].append(b)
    G_friend[b].append(a)
    uf.union(a,b)

num_block = [0]*n
for i in range(k):
    a,b = map(lambda x: int(x)-1, input().split())
    if uf.same(a,b) and b not in G_friend[a]:
        num_block[a] += 1
        num_block[b] += 1

ans = [0]*n
for i in range(n):
    ans[i] = uf.size(i) - len(G_friend[i]) - 1 - num_block[i]
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
H,N = map(int, input().split())
A = [0]*N
B = [0]*N
for i in range(N):
    A[i], B[i] = map(int, input().split())

dp = [0]*(H+max(A)+1)
dp[0] = 0
for i in range(1, H+max(A)+1):
    for j in range(N):
        t = max(0,i-A[j])
        if dp[i]==0:
            dp[i] = dp[t] + B[j]
        else:
            dp[i] = min(dp[i], dp[t]+B[j])

ans = dp[H]
for i in range(H, H+max(A)+1):
    ans = min(ans, dp[i])
print(ans)


Fixed submission:
H,N = map(int, input().split())
A = [0]*N
B = [0]*N
for i in range(N):
    A[i], B[i] = map(int, input().split())

dp = [0]*(H+max(A)+1)
dp[0] = 0
for i in range(1, H+max(A)+1):
    for j in range(N):
        t = max(0,i-A[j])
        if dp[i]==0:
            dp[i] = dp[t] + B[j]
        else:
            dp[i] = min(dp[i], dp[t]+B[j])

ans = dp[H]
for i in range(H, H+max(A)+1):
    ans = min(ans, dp[i])
print(ans)